summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am8
-rw-r--r--lib/Makefile.in2636
-rw-r--r--lib/acl-errno-valid.c52
-rw-r--r--lib/acl-internal.c (renamed from lib/file-has-acl.c)479
-rw-r--r--lib/acl-internal.h106
-rw-r--r--lib/acl.h9
-rw-r--r--lib/acl_entries.c2
-rw-r--r--lib/alignof.h50
-rw-r--r--lib/alloca.in.h6
-rw-r--r--lib/basename-lgpl.c2
-rw-r--r--lib/btowc.c2
-rw-r--r--lib/c-ctype.c396
-rw-r--r--lib/c-ctype.h454
-rw-r--r--lib/c-strcase.h4
-rw-r--r--lib/c-strcasecmp.c4
-rw-r--r--lib/c-strcaseeq.h7
-rw-r--r--lib/c-strncasecmp.c4
-rw-r--r--lib/canonicalize-lgpl.c47
-rw-r--r--lib/close-stream.c78
-rw-r--r--lib/close-stream.h2
-rw-r--r--lib/closeout.c124
-rw-r--r--lib/closeout.h36
-rw-r--r--lib/config.charset6
-rw-r--r--lib/copy-acl.c567
-rw-r--r--lib/ctype.in.h57
-rw-r--r--lib/dfa.c4113
-rw-r--r--lib/dfa.h123
-rw-r--r--lib/dirname-lgpl.c2
-rw-r--r--lib/dirname.h10
-rw-r--r--lib/dosname.h2
-rw-r--r--lib/errno.in.h4
-rw-r--r--lib/error.c33
-rw-r--r--lib/error.h16
-rw-r--r--lib/exitfail.c2
-rw-r--r--lib/exitfail.h2
-rw-r--r--lib/fcntl.in.h22
-rw-r--r--lib/fpending.c60
-rw-r--r--lib/fpending.h29
-rw-r--r--lib/fstat.c2
-rw-r--r--lib/fwriting.c9
-rw-r--r--lib/fwriting.h4
-rw-r--r--lib/get-permissions.c291
-rw-r--r--lib/getdelim.c20
-rw-r--r--lib/getfilecon.c3
-rw-r--r--lib/getopt.c54
-rw-r--r--lib/getopt.in.h22
-rw-r--r--lib/getopt1.c2
-rw-r--r--lib/getopt_int.h2
-rw-r--r--lib/getprogname.c151
-rw-r--r--lib/getprogname.h40
-rw-r--r--lib/gettext.h12
-rw-r--r--lib/gettimeofday.c4
-rw-r--r--lib/glthread/lock.c1057
-rw-r--r--lib/glthread/lock.h927
-rw-r--r--lib/glthread/threadlib.c73
-rw-r--r--lib/gnulib.mk892
-rw-r--r--lib/hard-locale.c72
-rw-r--r--lib/hard-locale.h25
-rw-r--r--lib/ignore-value.h50
-rw-r--r--lib/intprops.h273
-rw-r--r--lib/isblank.c33
-rw-r--r--lib/langinfo.in.h22
-rw-r--r--lib/limits.in.h63
-rw-r--r--lib/local.mk17
-rw-r--r--lib/localcharset.c90
-rw-r--r--lib/localcharset.h4
-rw-r--r--lib/locale.in.h21
-rw-r--r--lib/localeconv.c2
-rw-r--r--lib/localeinfo.c113
-rw-r--r--lib/localeinfo.h54
-rw-r--r--lib/lstat.c2
-rw-r--r--lib/malloc.c4
-rw-r--r--lib/malloca.c33
-rw-r--r--lib/malloca.h19
-rw-r--r--lib/mbrlen.c2
-rw-r--r--lib/mbrtowc.c63
-rw-r--r--lib/mbsinit.c2
-rw-r--r--lib/mbtowc-impl.h2
-rw-r--r--lib/mbtowc.c2
-rw-r--r--lib/memchr.c2
-rw-r--r--lib/memrchr.c161
-rw-r--r--lib/minmax.h60
-rw-r--r--lib/mkostemp.c2
-rw-r--r--lib/msvc-inval.c10
-rw-r--r--lib/msvc-inval.h4
-rw-r--r--lib/msvc-nothrow.c4
-rw-r--r--lib/msvc-nothrow.h4
-rw-r--r--lib/nl_langinfo.c286
-rw-r--r--lib/obstack.c372
-rw-r--r--lib/obstack.h792
-rw-r--r--lib/pathmax.h4
-rw-r--r--lib/progname.c92
-rw-r--r--lib/progname.h62
-rw-r--r--lib/qcopy-acl.c51
-rw-r--r--lib/qset-acl.c49
-rw-r--r--lib/quote.h2
-rw-r--r--lib/quotearg.c174
-rw-r--r--lib/quotearg.h38
-rw-r--r--lib/readlink.c2
-rw-r--r--lib/realloc.c79
-rw-r--r--lib/ref-add.sin2
-rw-r--r--lib/ref-del.sin2
-rw-r--r--lib/regcomp.c360
-rw-r--r--lib/regex.c24
-rw-r--r--lib/regex.h79
-rw-r--r--lib/regex_internal.c109
-rw-r--r--lib/regex_internal.h181
-rw-r--r--lib/regexec.c248
-rw-r--r--lib/rename.c8
-rw-r--r--lib/rmdir.c2
-rw-r--r--lib/same-inode.h8
-rw-r--r--lib/se-context.in.h11
-rw-r--r--lib/se-selinux.in.h13
-rw-r--r--lib/secure_getenv.c54
-rw-r--r--lib/set-acl.c48
-rw-r--r--lib/set-permissions.c (renamed from lib/set-mode-acl.c)830
-rw-r--r--lib/stat.c2
-rw-r--r--lib/stdalign.in.h121
-rw-r--r--lib/stdarg.in.h4
-rw-r--r--lib/stdbool.in.h4
-rw-r--r--lib/stddef.in.h58
-rw-r--r--lib/stdint.in.h769
-rw-r--r--lib/stdio-impl.h36
-rw-r--r--lib/stdio.c3
-rw-r--r--lib/stdio.in.h78
-rw-r--r--lib/stdlib.in.h61
-rw-r--r--lib/streq.h4
-rw-r--r--lib/strerror-override.c2
-rw-r--r--lib/strerror-override.h4
-rw-r--r--lib/strerror.c5
-rw-r--r--lib/string.in.h41
-rw-r--r--lib/stripslash.c2
-rw-r--r--lib/strverscmp.c102
-rw-r--r--lib/sys_stat.in.h4
-rw-r--r--lib/sys_time.in.h207
-rw-r--r--lib/sys_types.in.h6
-rw-r--r--lib/tempname.c125
-rw-r--r--lib/tempname.h17
-rw-r--r--lib/time.in.h77
-rw-r--r--lib/unistd.c1
-rw-r--r--lib/unistd.in.h99
-rw-r--r--lib/unlocked-io.h2
-rw-r--r--lib/verify.h136
-rw-r--r--lib/version-etc-fsf.c2
-rw-r--r--lib/version-etc.c4
-rw-r--r--lib/version-etc.h2
-rw-r--r--lib/wchar.in.h25
-rw-r--r--lib/wcrtomb.c2
-rw-r--r--lib/wctob.c2
-rw-r--r--lib/wctomb-impl.h2
-rw-r--r--lib/wctomb.c2
-rw-r--r--lib/wctype.in.h35
-rw-r--r--lib/xalloc-die.c2
-rw-r--r--lib/xalloc-oversized.h58
-rw-r--r--lib/xalloc.h32
-rw-r--r--lib/xmalloc.c12
156 files changed, 13130 insertions, 7338 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
deleted file mode 100644
index 73c1b33..0000000
--- a/lib/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-include gnulib.mk
-
-SUFFIXES += .a .o .c .y .l .h .sh .elc .el
-
-AM_CPPFLAGS += -I$(top_srcdir)/lib -I$(top_srcdir) -I$(top_builddir)/lib
-
diff --git a/lib/Makefile.in b/lib/Makefile.in
deleted file mode 100644
index 00c857f..0000000
--- a/lib/Makefile.in
+++ /dev/null
@@ -1,2636 +0,0 @@
-# Makefile.in generated by automake 1.12.2 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994-2012 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-2012 Free Software Foundation, Inc.
-#
-# 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 3 of the License, or
-# (at your option) any later version.
-#
-# This file is distributed in the hope that 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 file. If not, see <http://www.gnu.org/licenses/>.
-#
-# 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=. --local-dir=gl --lib=libsed --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alloca btowc c-ctype extensions fwriting getdelim getopt gettext-h localcharset mbrlen mbrtowc mbsinit memchr mkostemp obstack pathmax regex rename selinux-h ssize_t stat-macros stdbool strerror strverscmp unlocked-io verify version-etc-fsf wcrtomb wctob
-
-
-
-VPATH = @srcdir@
-am__make_dryrun = \
- { \
- am__dry=no; \
- case $$MAKEFLAGS in \
- *\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
- *) \
- for am__flg in $$MAKEFLAGS; do \
- case $$am__flg in \
- *=*|--*) ;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done;; \
- esac; \
- test $$am__dry = yes; \
- }
-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@
-DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in $(srcdir)/gnulib.mk \
- $(top_srcdir)/build-aux/depcomp alloca.c
-subdir = lib
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
- $(top_srcdir)/m4/acl.m4 $(top_srcdir)/m4/alloca.m4 \
- $(top_srcdir)/m4/btowc.m4 $(top_srcdir)/m4/canonicalize.m4 \
- $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/configmake.m4 \
- $(top_srcdir)/m4/dirname.m4 \
- $(top_srcdir)/m4/double-slash-root.m4 \
- $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/errno_h.m4 \
- $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/extensions.m4 \
- $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \
- $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fstat.m4 \
- $(top_srcdir)/m4/fwriting.m4 $(top_srcdir)/m4/getdelim.m4 \
- $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettext.m4 \
- $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
- $(top_srcdir)/m4/gnulib-common.m4 \
- $(top_srcdir)/m4/gnulib-comp.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/include_next.m4 \
- $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/langinfo_h.m4 \
- $(top_srcdir)/m4/largefile.m4 $(top_srcdir)/m4/lib-ld.m4 \
- $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
- $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
- $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
- $(top_srcdir)/m4/locale_h.m4 $(top_srcdir)/m4/localeconv.m4 \
- $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lstat.m4 \
- $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/malloca.m4 \
- $(top_srcdir)/m4/mbrlen.m4 $(top_srcdir)/m4/mbrtowc.m4 \
- $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \
- $(top_srcdir)/m4/mbtowc.m4 $(top_srcdir)/m4/memchr.m4 \
- $(top_srcdir)/m4/mkostemp.m4 $(top_srcdir)/m4/mmap-anon.m4 \
- $(top_srcdir)/m4/msvc-inval.m4 \
- $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \
- $(top_srcdir)/m4/nl_langinfo.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \
- $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/po.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/quote.m4 \
- $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/readlink.m4 \
- $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/regex.m4 \
- $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \
- $(top_srcdir)/m4/selinux-context-h.m4 \
- $(top_srcdir)/m4/selinux-selinux-h.m4 \
- $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat.m4 \
- $(top_srcdir)/m4/stdarg.m4 $(top_srcdir)/m4/stdbool.m4 \
- $(top_srcdir)/m4/stddef_h.m4 $(top_srcdir)/m4/stdint.m4 \
- $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
- $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/string_h.m4 \
- $(top_srcdir)/m4/strverscmp.m4 \
- $(top_srcdir)/m4/sys_socket_h.m4 \
- $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
- $(top_srcdir)/m4/sys_types_h.m4 $(top_srcdir)/m4/tempname.m4 \
- $(top_srcdir)/m4/threadlib.m4 $(top_srcdir)/m4/time_h.m4 \
- $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlocked-io.m4 \
- $(top_srcdir)/m4/version-etc.m4 \
- $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/wchar_h.m4 \
- $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcrtomb.m4 \
- $(top_srcdir)/m4/wctob.m4 $(top_srcdir)/m4/wctomb.m4 \
- $(top_srcdir)/m4/wctype_h.m4 $(top_srcdir)/m4/wint_t.m4 \
- $(top_srcdir)/m4/xalloc.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)
-libsed_a_AR = $(AR) $(ARFLAGS)
-am__DEPENDENCIES_1 =
-am_libsed_a_OBJECTS = set-mode-acl.$(OBJEXT) copy-acl.$(OBJEXT) \
- file-has-acl.$(OBJEXT) c-ctype.$(OBJEXT) \
- c-strcasecmp.$(OBJEXT) c-strncasecmp.$(OBJEXT) \
- dirname-lgpl.$(OBJEXT) basename-lgpl.$(OBJEXT) \
- stripslash.$(OBJEXT) exitfail.$(OBJEXT) localcharset.$(OBJEXT) \
- malloca.$(OBJEXT) quotearg.$(OBJEXT) se-context.$(OBJEXT) \
- se-selinux.$(OBJEXT) stdio.$(OBJEXT) tempname.$(OBJEXT) \
- unistd.$(OBJEXT) version-etc.$(OBJEXT) \
- version-etc-fsf.$(OBJEXT) wctype-h.$(OBJEXT) xmalloc.$(OBJEXT) \
- xalloc-die.$(OBJEXT)
-libsed_a_OBJECTS = $(am_libsed_a_OBJECTS)
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-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)
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(libsed_a_SOURCES) $(EXTRA_libsed_a_SOURCES)
-DIST_SOURCES = $(libsed_a_SOURCES) $(EXTRA_libsed_a_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__can_run_installinfo = \
- case $$AM_UPDATE_INFO_DIR in \
- n|no|NO) false;; \
- *) (install-info --version) >/dev/null 2>&1;; \
- esac
-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@
-APPLE_UNIVERSAL_BUILD = @APPLE_UNIVERSAL_BUILD@
-AR = @AR@
-ARFLAGS = @ARFLAGS@
-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@
-COPYRIGHT_YEAR = @COPYRIGHT_YEAR@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-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@
-GETOPT_H = @GETOPT_H@
-GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
-GLIBC21 = @GLIBC21@
-GMSGFMT = @GMSGFMT@
-GMSGFMT_015 = @GMSGFMT_015@
-GNULIB_ATOLL = @GNULIB_ATOLL@
-GNULIB_BTOWC = @GNULIB_BTOWC@
-GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
-GNULIB_CANONICALIZE_FILE_NAME = @GNULIB_CANONICALIZE_FILE_NAME@
-GNULIB_CHDIR = @GNULIB_CHDIR@
-GNULIB_CHOWN = @GNULIB_CHOWN@
-GNULIB_CLOSE = @GNULIB_CLOSE@
-GNULIB_DPRINTF = @GNULIB_DPRINTF@
-GNULIB_DUP = @GNULIB_DUP@
-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_FDATASYNC = @GNULIB_FDATASYNC@
-GNULIB_FDOPEN = @GNULIB_FDOPEN@
-GNULIB_FFLUSH = @GNULIB_FFLUSH@
-GNULIB_FFSL = @GNULIB_FFSL@
-GNULIB_FFSLL = @GNULIB_FFSLL@
-GNULIB_FGETC = @GNULIB_FGETC@
-GNULIB_FGETS = @GNULIB_FGETS@
-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_FREAD = @GNULIB_FREAD@
-GNULIB_FREOPEN = @GNULIB_FREOPEN@
-GNULIB_FSCANF = @GNULIB_FSCANF@
-GNULIB_FSEEK = @GNULIB_FSEEK@
-GNULIB_FSEEKO = @GNULIB_FSEEKO@
-GNULIB_FSTAT = @GNULIB_FSTAT@
-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_GETC = @GNULIB_GETC@
-GNULIB_GETCHAR = @GNULIB_GETCHAR@
-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_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@
-GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
-GNULIB_GL_UNISTD_H_GETOPT = @GNULIB_GL_UNISTD_H_GETOPT@
-GNULIB_GRANTPT = @GNULIB_GRANTPT@
-GNULIB_GROUP_MEMBER = @GNULIB_GROUP_MEMBER@
-GNULIB_ISATTY = @GNULIB_ISATTY@
-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_LOCALECONV = @GNULIB_LOCALECONV@
-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_NONBLOCKING = @GNULIB_NONBLOCKING@
-GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
-GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
-GNULIB_OPEN = @GNULIB_OPEN@
-GNULIB_OPENAT = @GNULIB_OPENAT@
-GNULIB_PCLOSE = @GNULIB_PCLOSE@
-GNULIB_PERROR = @GNULIB_PERROR@
-GNULIB_PIPE = @GNULIB_PIPE@
-GNULIB_PIPE2 = @GNULIB_PIPE2@
-GNULIB_POPEN = @GNULIB_POPEN@
-GNULIB_POSIX_OPENPT = @GNULIB_POSIX_OPENPT@
-GNULIB_PREAD = @GNULIB_PREAD@
-GNULIB_PRINTF = @GNULIB_PRINTF@
-GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
-GNULIB_PTSNAME = @GNULIB_PTSNAME@
-GNULIB_PTSNAME_R = @GNULIB_PTSNAME_R@
-GNULIB_PUTC = @GNULIB_PUTC@
-GNULIB_PUTCHAR = @GNULIB_PUTCHAR@
-GNULIB_PUTENV = @GNULIB_PUTENV@
-GNULIB_PUTS = @GNULIB_PUTS@
-GNULIB_PWRITE = @GNULIB_PWRITE@
-GNULIB_RANDOM = @GNULIB_RANDOM@
-GNULIB_RANDOM_R = @GNULIB_RANDOM_R@
-GNULIB_RAWMEMCHR = @GNULIB_RAWMEMCHR@
-GNULIB_READ = @GNULIB_READ@
-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_SCANF = @GNULIB_SCANF@
-GNULIB_SETENV = @GNULIB_SETENV@
-GNULIB_SETHOSTNAME = @GNULIB_SETHOSTNAME@
-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_NONBLOCKING = @GNULIB_STDIO_H_NONBLOCKING@
-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_NONBLOCKING = @GNULIB_UNISTD_H_NONBLOCKING@
-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_VFSCANF = @GNULIB_VFSCANF@
-GNULIB_VPRINTF = @GNULIB_VPRINTF@
-GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
-GNULIB_VSCANF = @GNULIB_VSCANF@
-GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
-GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
-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_FDATASYNC = @HAVE_DECL_FDATASYNC@
-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_SETHOSTNAME = @HAVE_DECL_SETHOSTNAME@
-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_FDATASYNC = @HAVE_FDATASYNC@
-HAVE_FEATURES_H = @HAVE_FEATURES_H@
-HAVE_FFSL = @HAVE_FFSL@
-HAVE_FFSLL = @HAVE_FFSLL@
-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_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@
-HAVE_GRANTPT = @HAVE_GRANTPT@
-HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@
-HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
-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_MSVC_INVALID_PARAMETER_HANDLER = @HAVE_MSVC_INVALID_PARAMETER_HANDLER@
-HAVE_NANOSLEEP = @HAVE_NANOSLEEP@
-HAVE_NL_LANGINFO = @HAVE_NL_LANGINFO@
-HAVE_OPENAT = @HAVE_OPENAT@
-HAVE_OS_H = @HAVE_OS_H@
-HAVE_PCLOSE = @HAVE_PCLOSE@
-HAVE_PIPE = @HAVE_PIPE@
-HAVE_PIPE2 = @HAVE_PIPE2@
-HAVE_POPEN = @HAVE_POPEN@
-HAVE_POSIX_OPENPT = @HAVE_POSIX_OPENPT@
-HAVE_PREAD = @HAVE_PREAD@
-HAVE_PTSNAME = @HAVE_PTSNAME@
-HAVE_PTSNAME_R = @HAVE_PTSNAME_R@
-HAVE_PWRITE = @HAVE_PWRITE@
-HAVE_RANDOM = @HAVE_RANDOM@
-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_SETHOSTNAME = @HAVE_SETHOSTNAME@
-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_STRUCT_TIMEVAL = @HAVE_STRUCT_TIMEVAL@
-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_TIME_H = @HAVE_SYS_TIME_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_WINSOCK2_H = @HAVE_WINSOCK2_H@
-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@
-INTLLIBS = @INTLLIBS@
-INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
-LDFLAGS = @LDFLAGS@
-LIBICONV = @LIBICONV@
-LIBINTL = @LIBINTL@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBSED_LIBDEPS = @LIBSED_LIBDEPS@
-LIBSED_LTLIBDEPS = @LIBSED_LTLIBDEPS@
-LIB_ACL = @LIB_ACL@
-LIB_SELINUX = @LIB_SELINUX@
-LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
-LOCALE_FR = @LOCALE_FR@
-LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
-LOCALE_JA = @LOCALE_JA@
-LOCALE_ZH_CN = @LOCALE_ZH_CN@
-LTLIBICONV = @LTLIBICONV@
-LTLIBINTL = @LTLIBINTL@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-MKDIR_P = @MKDIR_P@
-MSGFMT = @MSGFMT@
-MSGFMT_015 = @MSGFMT_015@
-MSGMERGE = @MSGMERGE@
-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_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_STDARG_H = @NEXT_AS_FIRST_DIRECTIVE_STDARG_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_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
-NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_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_ERRNO_H = @NEXT_ERRNO_H@
-NEXT_FCNTL_H = @NEXT_FCNTL_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_STDARG_H = @NEXT_STDARG_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_TIME_H = @NEXT_SYS_TIME_H@
-NEXT_SYS_TYPES_H = @NEXT_SYS_TYPES_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@
-OBJEXT = @OBJEXT@
-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@
-POSUB = @POSUB@
-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@
-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_FDOPEN = @REPLACE_FDOPEN@
-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_FTRUNCATE = @REPLACE_FTRUNCATE@
-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_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
-REPLACE_ISATTY = @REPLACE_ISATTY@
-REPLACE_ISWBLANK = @REPLACE_ISWBLANK@
-REPLACE_ISWCNTRL = @REPLACE_ISWCNTRL@
-REPLACE_LCHOWN = @REPLACE_LCHOWN@
-REPLACE_LINK = @REPLACE_LINK@
-REPLACE_LINKAT = @REPLACE_LINKAT@
-REPLACE_LOCALECONV = @REPLACE_LOCALECONV@
-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_PTSNAME = @REPLACE_PTSNAME@
-REPLACE_PTSNAME_R = @REPLACE_PTSNAME_R@
-REPLACE_PUTENV = @REPLACE_PUTENV@
-REPLACE_PWRITE = @REPLACE_PWRITE@
-REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
-REPLACE_READ = @REPLACE_READ@
-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_READ_FUNCS = @REPLACE_STDIO_READ_FUNCS@
-REPLACE_STDIO_WRITE_FUNCS = @REPLACE_STDIO_WRITE_FUNCS@
-REPLACE_STPNCPY = @REPLACE_STPNCPY@
-REPLACE_STRCASESTR = @REPLACE_STRCASESTR@
-REPLACE_STRCHRNUL = @REPLACE_STRCHRNUL@
-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_STRUCT_LCONV = @REPLACE_STRUCT_LCONV@
-REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@
-REPLACE_SYMLINK = @REPLACE_SYMLINK@
-REPLACE_TIMEGM = @REPLACE_TIMEGM@
-REPLACE_TMPFILE = @REPLACE_TMPFILE@
-REPLACE_TOWLOWER = @REPLACE_TOWLOWER@
-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_FEATURE_VERSION = @SED_FEATURE_VERSION@
-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@
-STDARG_H = @STDARG_H@
-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@
-USE_ACL = @USE_ACL@
-USE_NLS = @USE_NLS@
-VERSION = @VERSION@
-WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
-WINDOWS_64_BIT_OFF_T = @WINDOWS_64_BIT_OFF_T@
-WINDOWS_64_BIT_ST_SIZE = @WINDOWS_64_BIT_ST_SIZE@
-WINT_T_SUFFIX = @WINT_T_SUFFIX@
-XFAIL_TESTS = @XFAIL_TESTS@
-XGETTEXT = @XGETTEXT@
-XGETTEXT_015 = @XGETTEXT_015@
-XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
-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@
-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 = libsed.a
-noinst_LTLIBRARIES =
-EXTRA_DIST = acl-internal.h acl.h acl_entries.c alloca.c alloca.in.h \
- btowc.c c-strcaseeq.h canonicalize-lgpl.c dirname.h dosname.h \
- errno.in.h error.c error.h exitfail.h fcntl.in.h fstat.c \
- fwriting.c fwriting.h stdio-impl.h getdelim.c getopt.c \
- getopt.in.h getopt1.c getopt_int.h gettimeofday.c intprops.h \
- langinfo.in.h config.charset ref-add.sin ref-del.sin \
- locale.in.h localeconv.c lstat.c malloc.c malloc.c malloca.h \
- malloca.valgrind mbrlen.c mbrtowc.c mbsinit.c mbtowc-impl.h \
- mbtowc.c memchr.c memchr.valgrind mkostemp.c msvc-inval.c \
- msvc-inval.h msvc-nothrow.c msvc-nothrow.h nl_langinfo.c \
- obstack.c obstack.h pathmax.h quote.h quote.h quotearg.h \
- readlink.c realloc.c regcomp.c regex.c regex.h \
- regex_internal.c regex_internal.h regexec.c rename.c rmdir.c \
- same-inode.h getfilecon.c \
- $(top_srcdir)/build-aux/snippet/_Noreturn.h \
- $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
- $(top_srcdir)/build-aux/snippet/c++defs.h \
- $(top_srcdir)/build-aux/snippet/unused-parameter.h \
- $(top_srcdir)/build-aux/snippet/warn-on-use.h stat.c \
- stat-macros.h stdarg.in.h stdbool.in.h stddef.in.h stdint.in.h \
- stdio.in.h stdlib.in.h streq.h strerror.c strerror-override.c \
- strerror-override.h string.in.h strverscmp.c sys_stat.in.h \
- sys_time.in.h sys_types.in.h tempname.h time.in.h unistd.in.h \
- unlocked-io.h verify.h wchar.in.h wcrtomb.c wctob.c \
- wctomb-impl.h wctomb.c wctype.in.h xalloc.h xalloc-oversized.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) configmake.h $(ERRNO_H) fcntl.h \
- $(GETOPT_H) langinfo.h locale.h selinux/selinux.h \
- $(SELINUX_CONTEXT_H) arg-nonnull.h c++defs.h \
- unused-parameter.h warn-on-use.h $(STDARG_H) $(STDBOOL_H) \
- $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h string.h sys/stat.h \
- sys/time.h sys/types.h time.h unistd.h wchar.h wctype.h
-SUFFIXES = .sed .sin .a .o .c .y .l .h .sh .elc .el
-MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t errno.h \
- errno.h-t fcntl.h fcntl.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 \
- arg-nonnull.h arg-nonnull.h-t c++defs.h c++defs.h-t \
- unused-parameter.h unused-parameter.h-t warn-on-use.h \
- warn-on-use.h-t stdarg.h stdarg.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/time.h sys/time.h-t sys/types.h sys/types.h-t \
- time.h time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \
- wctype.h-t
-MOSTLYCLEANDIRS = selinux sys
-CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \
- ref-del.sed
-DISTCLEANFILES =
-MAINTAINERCLEANFILES =
-AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir) \
- -I$(top_builddir)/lib
-AM_CFLAGS =
-libsed_a_SOURCES = set-mode-acl.c copy-acl.c file-has-acl.c c-ctype.h \
- c-ctype.c c-strcase.h c-strcasecmp.c c-strncasecmp.c \
- dirname-lgpl.c basename-lgpl.c stripslash.c exitfail.c \
- gettext.h localcharset.h localcharset.c malloca.c quotearg.c \
- se-context.in.h se-selinux.in.h se-context.c se-selinux.c \
- stdio.c tempname.c unistd.c version-etc.h version-etc.c \
- version-etc-fsf.c wctype-h.c xmalloc.c xalloc-die.c
-libsed_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@
-libsed_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
-EXTRA_libsed_a_SOURCES = acl_entries.c alloca.c btowc.c \
- canonicalize-lgpl.c error.c fstat.c fwriting.c getdelim.c \
- getopt.c getopt1.c gettimeofday.c localeconv.c lstat.c \
- malloc.c malloc.c mbrlen.c mbrtowc.c mbsinit.c mbtowc.c \
- memchr.c mkostemp.c msvc-inval.c msvc-nothrow.c nl_langinfo.c \
- obstack.c readlink.c realloc.c regcomp.c regex.c \
- regex_internal.c regexec.c rename.c rmdir.c getfilecon.c \
- stat.c strerror.c strerror-override.c strverscmp.c wcrtomb.c \
- wctob.c wctomb.c
-charset_alias = $(DESTDIR)$(libdir)/charset.alias
-charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
-
-# Because this Makefile snippet defines a variable used by other
-# gnulib Makefile snippets, it must be present in all Makefile.am that
-# need it. This is ensured by the applicability 'all' defined above.
-_NORETURN_H = $(top_srcdir)/build-aux/snippet/_Noreturn.h
-ARG_NONNULL_H = arg-nonnull.h
-CXXDEFS_H = c++defs.h
-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 .a .o .c .y .l .h .sh .elc .el .obj
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/gnulib.mk $(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 lib/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnits 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;
-$(srcdir)/gnulib.mk:
-
-$(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)
-libsed.a: $(libsed_a_OBJECTS) $(libsed_a_DEPENDENCIES) $(EXTRA_libsed_a_DEPENDENCIES)
- -rm -f libsed.a
- $(libsed_a_AR) libsed.a $(libsed_a_OBJECTS) $(libsed_a_LIBADD)
- $(RANLIB) libsed.a
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
- @list='$(noinst_LTLIBRARIES)'; \
- locs=`for p in $$list; do echo $$p; done | \
- sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
- sort -u`; \
- test -z "$$locs" || { \
- echo rm -f $${locs}; \
- rm -f $${locs}; \
- }
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/alloca.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl_entries.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloca.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename-lgpl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btowc.Po@am__quote@
-@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)/canonicalize-lgpl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy-acl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname-lgpl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file-has-acl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstat.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fwriting.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdelim.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getfilecon.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettimeofday.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localeconv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloca.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrlen.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrtowc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsinit.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbtowc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memchr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkostemp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-inval.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msvc-nothrow.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nl_langinfo.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obstack.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quotearg.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlink.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regcomp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex_internal.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regexec.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rename.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdir.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/se-context.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/se-selinux.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set-mode-acl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strverscmp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempname.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version-etc-fsf.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version-etc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcrtomb.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@./$(DEPDIR)/wctype-h.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xalloc-die.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@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@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@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) '$<'`
-
-# 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) $(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; \
- target=`echo $@ | sed s/-recursive//`; \
- case "$@" in \
- distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
- *) list='$(SUBDIRS)' ;; \
- esac; \
- 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"
-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
-cscopelist-recursive:
- list='$(SUBDIRS)'; for subdir in $$list; do \
- test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \
- 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"
-
-cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP)'; \
- case "$(srcdir)" in \
- [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
- *) sdir=$(subdir)/$(srcdir) ;; \
- esac; \
- for i in $$list; do \
- if test -f "$$i"; then \
- echo "$(subdir)/$$i"; \
- else \
- echo "$$sdir/$$i"; \
- fi; \
- done >> $(top_builddir)/cscope.files
-
-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 \
- $(am__make_dryrun) \
- || test -d "$(distdir)/$$subdir" \
- || $(MKDIR_P) "$(distdir)/$$subdir" \
- || exit 1; \
- 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:
- if test -z '$(STRIP)'; then \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- install; \
- else \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
- fi
-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-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-local
-
-pdf: pdf-recursive
-
-pdf-am:
-
-ps: ps-recursive
-
-ps-am:
-
-uninstall-am: uninstall-local
-
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
- cscopelist-recursive 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-noinstLIBRARIES clean-noinstLTLIBRARIES cscopelist \
- cscopelist-recursive ctags ctags-recursive distclean \
- distclean-compile distclean-generic 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-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.
-@GL_GENERATE_ALLOCA_H_TRUE@alloca.h: alloca.in.h $(top_builddir)/config.status
-@GL_GENERATE_ALLOCA_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_ALLOCA_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-@GL_GENERATE_ALLOCA_H_TRUE@ cat $(srcdir)/alloca.in.h; \
-@GL_GENERATE_ALLOCA_H_TRUE@ } > $@-t && \
-@GL_GENERATE_ALLOCA_H_TRUE@ mv -f $@-t $@
-@GL_GENERATE_ALLOCA_H_FALSE@alloca.h: $(top_builddir)/config.status
-@GL_GENERATE_ALLOCA_H_FALSE@ rm -f $@
-
-# 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 && \
- mv -f $@-t $@
-
-# We need the following in order to create <errno.h> when the system
-# doesn't have one that is POSIX compliant.
-@GL_GENERATE_ERRNO_H_TRUE@errno.h: errno.in.h $(top_builddir)/config.status
-@GL_GENERATE_ERRNO_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_ERRNO_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-@GL_GENERATE_ERRNO_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
-@GL_GENERATE_ERRNO_H_TRUE@ < $(srcdir)/errno.in.h; \
-@GL_GENERATE_ERRNO_H_TRUE@ } > $@-t && \
-@GL_GENERATE_ERRNO_H_TRUE@ mv $@-t $@
-@GL_GENERATE_ERRNO_H_FALSE@errno.h: $(top_builddir)/config.status
-@GL_GENERATE_ERRNO_H_FALSE@ rm -f $@
-
-# 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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
- -e 's/@''GNULIB_FCNTL''@/$(GNULIB_FCNTL)/g' \
- -e 's/@''GNULIB_NONBLOCKING''@/$(GNULIB_NONBLOCKING)/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 $@
-
-# 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 $(top_builddir)/config.status $(ARG_NONNULL_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
- -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 $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
- -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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
- -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/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_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
- -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
- -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
- -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|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 $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
- $(AM_V_at)$(MKDIR_P) selinux
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_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 $@
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@selinux/context.h: se-context.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ $(AM_V_at)$(MKDIR_P) selinux
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ sed -e '/definition of _GL_UNUSED_PARAMETER/r $(UNUSED_PARAMETER_H)' \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ < $(srcdir)/se-context.in.h; \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ } > $@-t && \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ chmod a-x $@-t && \
-@GL_GENERATE_SELINUX_CONTEXT_H_TRUE@ mv $@-t $@
-@GL_GENERATE_SELINUX_CONTEXT_H_FALSE@selinux/context.h: $(top_builddir)/config.status
-@GL_GENERATE_SELINUX_CONTEXT_H_FALSE@ rm -f $@
-# The arg-nonnull.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
-# off.
-arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/GL_ARG_NONNULL/,$$p' \
- < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
- > $@-t && \
- mv $@-t $@
-# The c++defs.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
-c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/_GL_CXXDEFS/,$$p' \
- < $(top_srcdir)/build-aux/snippet/c++defs.h \
- > $@-t && \
- mv $@-t $@
-# The unused-parameter.h that gets inserted into generated .h files is the same
-# as build-aux/snippet/unused-parameter.h, except that it has the copyright
-# header cut off.
-unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
- < $(top_srcdir)/build-aux/snippet/unused-parameter.h \
- > $@-t && \
- mv $@-t $@
-# The warn-on-use.h that gets inserted into generated .h files is the same as
-# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
-# off.
-warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
- $(AM_V_GEN)rm -f $@-t $@ && \
- sed -n -e '/^.ifndef/,$$p' \
- < $(top_srcdir)/build-aux/snippet/warn-on-use.h \
- > $@-t && \
- mv $@-t $@
-
-# We need the following in order to create <stdarg.h> when the system
-# doesn't have one that works with the given compiler.
-@GL_GENERATE_STDARG_H_TRUE@stdarg.h: stdarg.in.h $(top_builddir)/config.status
-@GL_GENERATE_STDARG_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_STDARG_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-@GL_GENERATE_STDARG_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-@GL_GENERATE_STDARG_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-@GL_GENERATE_STDARG_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-@GL_GENERATE_STDARG_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-@GL_GENERATE_STDARG_H_TRUE@ -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \
-@GL_GENERATE_STDARG_H_TRUE@ < $(srcdir)/stdarg.in.h; \
-@GL_GENERATE_STDARG_H_TRUE@ } > $@-t && \
-@GL_GENERATE_STDARG_H_TRUE@ mv $@-t $@
-@GL_GENERATE_STDARG_H_FALSE@stdarg.h: $(top_builddir)/config.status
-@GL_GENERATE_STDARG_H_FALSE@ rm -f $@
-
-# We need the following in order to create <stdbool.h> when the system
-# doesn't have one that works.
-@GL_GENERATE_STDBOOL_H_TRUE@stdbool.h: stdbool.in.h $(top_builddir)/config.status
-@GL_GENERATE_STDBOOL_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_STDBOOL_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-@GL_GENERATE_STDBOOL_H_TRUE@ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
-@GL_GENERATE_STDBOOL_H_TRUE@ } > $@-t && \
-@GL_GENERATE_STDBOOL_H_TRUE@ mv $@-t $@
-@GL_GENERATE_STDBOOL_H_FALSE@stdbool.h: $(top_builddir)/config.status
-@GL_GENERATE_STDBOOL_H_FALSE@ rm -f $@
-
-# We need the following in order to create <stddef.h> when the system
-# doesn't have one that works with the given compiler.
-@GL_GENERATE_STDDEF_H_TRUE@stddef.h: stddef.in.h $(top_builddir)/config.status
-@GL_GENERATE_STDDEF_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_STDDEF_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-@GL_GENERATE_STDDEF_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
-@GL_GENERATE_STDDEF_H_TRUE@ < $(srcdir)/stddef.in.h; \
-@GL_GENERATE_STDDEF_H_TRUE@ } > $@-t && \
-@GL_GENERATE_STDDEF_H_TRUE@ mv $@-t $@
-@GL_GENERATE_STDDEF_H_FALSE@stddef.h: $(top_builddir)/config.status
-@GL_GENERATE_STDDEF_H_FALSE@ rm -f $@
-
-# We need the following in order to create <stdint.h> when the system
-# doesn't have one that works with the given compiler.
-@GL_GENERATE_STDINT_H_TRUE@stdint.h: stdint.in.h $(top_builddir)/config.status
-@GL_GENERATE_STDINT_H_TRUE@ $(AM_V_GEN)rm -f $@-t $@ && \
-@GL_GENERATE_STDINT_H_TRUE@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-@GL_GENERATE_STDINT_H_TRUE@ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
-@GL_GENERATE_STDINT_H_TRUE@ < $(srcdir)/stdint.in.h; \
-@GL_GENERATE_STDINT_H_TRUE@ } > $@-t && \
-@GL_GENERATE_STDINT_H_TRUE@ mv $@-t $@
-@GL_GENERATE_STDINT_H_FALSE@stdint.h: $(top_builddir)/config.status
-@GL_GENERATE_STDINT_H_FALSE@ rm -f $@
-
-# 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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_STDIO_H''@|$(NEXT_STDIO_H)|g' \
- -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \
- -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \
- -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \
- -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \
- -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
- -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/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_FREAD''@/$(GNULIB_FREAD)/g' \
- -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \
- -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/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_GETC''@/$(GNULIB_GETC)/g' \
- -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/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_PCLOSE''@/$(GNULIB_PCLOSE)/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_SCANF''@/$(GNULIB_SCANF)/g' \
- -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \
- -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \
- -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/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_VFSCANF''@/$(GNULIB_VFSCANF)/g' \
- -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/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_PCLOSE''@|$(HAVE_PCLOSE)|g' \
- -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|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_FDOPEN''@|$(REPLACE_FDOPEN)|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_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|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 $(top_builddir)/config.status $(CXXDEFS_H) \
- $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_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_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \
- -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
- -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
- -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
- -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/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_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
- -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
- -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
- -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|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_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
- -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
- -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
- -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|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 _Noreturn/r $(_NORETURN_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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_STRING_H''@|$(NEXT_STRING_H)|g' \
- -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
- -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/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_FFSL''@|$(HAVE_FFSL)|g' \
- -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
- -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_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|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 $(top_builddir)/config.status $(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|@''GUARD_PREFIX''@|GL|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_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
- -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
- -e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
- -e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/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/time.h> when the system
-# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(top_builddir)/config.status $(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|@''GUARD_PREFIX''@|GL|g' \
- -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_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_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
- -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
- -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
- -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
- -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
- -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
- -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/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_time.in.h; \
- } > $@-t && \
- mv $@-t $@
-
-# We need the following in order to create <sys/types.h> when the system
-# doesn't have one that works with the given compiler.
-sys/types.h: sys_types.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
- -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
- < $(srcdir)/sys_types.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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
- sed -e 's|@''GUARD_PREFIX''@|GL|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_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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
- -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|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
- -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
- -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
- -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
- -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/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_FDATASYNC''@/$(GNULIB_FDATASYNC)/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_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
- -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/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_READ''@/$(GNULIB_READ)/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_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/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''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
- -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/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_FDATASYNC''@|$(HAVE_FDATASYNC)|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_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|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_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|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_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|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_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|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_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|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_ISATTY''@|$(REPLACE_ISATTY)|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_READ''@|$(REPLACE_READ)|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 $@
-
-# We need the following in order to create <wchar.h> when the system
-# version does not work standalone.
-wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|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|@''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 $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
- -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 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/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/lib/acl-errno-valid.c b/lib/acl-errno-valid.c
new file mode 100644
index 0000000..086f75f
--- /dev/null
+++ b/lib/acl-errno-valid.c
@@ -0,0 +1,52 @@
+/* Test whether ACLs are well supported on this system.
+
+ Copyright 2013-2016 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>
+
+#include <acl.h>
+
+#include <errno.h>
+
+/* Return true if errno value ERRNUM indicates that ACLs are well
+ supported on this system. ERRNUM should be an errno value obtained
+ after an ACL-related system call fails. */
+bool
+acl_errno_valid (int errnum)
+{
+ /* Recognize some common errors such as from an NFS mount that does
+ not support ACLs, even when local drives do. */
+ switch (errnum)
+ {
+ case EBUSY: return false;
+ case EINVAL: return false;
+#if defined __APPLE__ && defined __MACH__
+ case ENOENT: return false;
+#endif
+ case ENOSYS: return false;
+
+#if defined ENOTSUP && ENOTSUP != EOPNOTSUPP
+# if ENOTSUP != ENOSYS /* Needed for the MS-Windows port of GNU Emacs. */
+ case ENOTSUP: return false;
+# endif
+#endif
+
+ case EOPNOTSUPP: return false;
+ default: return true;
+ }
+}
diff --git a/lib/file-has-acl.c b/lib/acl-internal.c
index 16380e3..4de60c3 100644
--- a/lib/file-has-acl.c
+++ b/lib/acl-internal.c
@@ -1,6 +1,6 @@
-/* Test whether a file has a nontrivial access control list.
+/* Test whether a file has a nontrivial ACL. -*- coding: utf-8 -*-
- Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,19 +17,12 @@
Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */
-/* Without this pragma, gcc 4.7.0 20120126 may suggest that the
- file_has_acl function might be candidate for attribute 'const' */
-#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
-# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
-#endif
-
#include <config.h>
#include "acl.h"
#include "acl-internal.h"
-
#if USE_ACL && HAVE_ACL_GET_FILE
# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
@@ -75,8 +68,7 @@ acl_access_nontrivial (acl_t acl)
}
return got_one;
-# else /* IRIX, Tru64 */
-# if HAVE_ACL_TO_SHORT_TEXT /* IRIX */
+# elif HAVE_ACL_TO_SHORT_TEXT /* IRIX */
/* Don't use acl_get_entry: it is undocumented. */
int count = acl->acl_cnt;
@@ -93,8 +85,7 @@ acl_access_nontrivial (acl_t acl)
}
return 0;
-# endif
-# if HAVE_ACL_FREE_TEXT /* Tru64 */
+# elif HAVE_ACL_FREE_TEXT /* Tru64 */
/* Don't use acl_get_entry: it takes only one argument and does not work. */
int count = acl->acl_num;
@@ -117,12 +108,21 @@ acl_access_nontrivial (acl_t acl)
}
return 0;
-# endif
+# else
+
+ errno = ENOSYS;
+ return -1;
# endif
}
-# endif
+int
+acl_default_nontrivial (acl_t acl)
+{
+ /* acl is non-trivial if it is non-empty. */
+ return (acl_entries (acl) > 0);
+}
+# endif
#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
@@ -343,18 +343,19 @@ acl_ace_nontrivial (int count, ace_t *entries)
/* Return 1 if the given ACL is non-trivial.
Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
int
-acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb)
+acl_nontrivial (int count, struct acl_entry *entries)
{
int i;
+ if (count > 3)
+ return 1;
+
for (i = 0; i < count; i++)
{
struct acl_entry *ace = &entries[i];
- if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP)
- || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid)
- || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP)))
- return 1;
+ if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP)
+ return 1;
}
return 0;
}
@@ -474,445 +475,33 @@ acl_nontrivial (int count, struct acl *entries)
#endif
-
-/* Return 1 if NAME has a nontrivial access control list, 0 if NAME
- only has no or a base access control list, and -1 (setting errno)
- on error. SB must be set to the stat buffer of NAME, obtained
- through stat() or lstat(). */
-
-int
-file_has_acl (char const *name, struct stat const *sb)
+void
+free_permission_context (struct permission_context *ctx)
{
#if USE_ACL
- if (! S_ISLNK (sb->st_mode))
- {
-# if HAVE_ACL_GET_FILE
-
- /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
- /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
- int ret;
-
- if (HAVE_ACL_EXTENDED_FILE) /* Linux */
- {
- /* On Linux, acl_extended_file is an optimized function: It only
- makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for
- ACL_TYPE_DEFAULT. */
- ret = acl_extended_file (name);
- }
- else /* FreeBSD, Mac OS X, IRIX, Tru64 */
- {
-# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
- /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
- and acl_get_file (name, ACL_TYPE_DEFAULT)
- always return NULL / EINVAL. There is no point in making
- these two useless calls. The real ACL is retrieved through
- acl_get_file (name, ACL_TYPE_EXTENDED). */
- acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED);
- if (acl)
- {
- ret = acl_extended_nontrivial (acl);
- acl_free (acl);
- }
- else
- ret = -1;
-# else /* FreeBSD, IRIX, Tru64 */
- acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS);
- if (acl)
- {
- int saved_errno;
-
- ret = acl_access_nontrivial (acl);
- saved_errno = errno;
- acl_free (acl);
- errno = saved_errno;
-# if HAVE_ACL_FREE_TEXT /* Tru64 */
- /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always
- returns NULL with errno not set. There is no point in
- making this call. */
-# else /* FreeBSD, IRIX */
- /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS)
- and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory
- either both succeed or both fail; it depends on the
- file system. Therefore there is no point in making the second
- call if the first one already failed. */
- if (ret == 0 && S_ISDIR (sb->st_mode))
- {
- acl = acl_get_file (name, ACL_TYPE_DEFAULT);
- if (acl)
- {
- ret = (0 < acl_entries (acl));
- acl_free (acl);
- }
- else
- ret = -1;
- }
-# endif
- }
- else
- ret = -1;
+# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
+ if (ctx->acl)
+ acl_free (ctx->acl);
+# if !HAVE_ACL_TYPE_EXTENDED
+ if (ctx->default_acl)
+ acl_free (ctx->default_acl);
# endif
- }
- if (ret < 0)
- return ACL_NOT_WELL_SUPPORTED (errno) ? 0 : -1;
- return ret;
-
-# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-
-# if defined ACL_NO_TRIVIAL
-
- /* Solaris 10 (newer version), which has additional API declared in
- <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
- acl_fromtext, ...). */
- return acl_trivial (name);
-
-# else /* Solaris, Cygwin, general case */
-
- /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
- of Unixware. The acl() call returns the access and default ACL both
- at once. */
- {
- /* Initially, try to read the entries into a stack-allocated buffer.
- Use malloc if it does not fit. */
- enum
- {
- alloc_init = 4000 / sizeof (aclent_t), /* >= 3 */
- alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (aclent_t))
- };
- aclent_t buf[alloc_init];
- size_t alloc = alloc_init;
- aclent_t *entries = buf;
- aclent_t *malloced = NULL;
- int count;
-
- for (;;)
- {
- count = acl (name, GETACL, alloc, entries);
- if (count < 0 && errno == ENOSPC)
- {
- /* Increase the size of the buffer. */
- free (malloced);
- if (alloc > alloc_max / 2)
- {
- errno = ENOMEM;
- return -1;
- }
- alloc = 2 * alloc; /* <= alloc_max */
- entries = malloced =
- (aclent_t *) malloc (alloc * sizeof (aclent_t));
- if (entries == NULL)
- {
- errno = ENOMEM;
- return -1;
- }
- continue;
- }
- break;
- }
- if (count < 0)
- {
- if (errno == ENOSYS || errno == ENOTSUP)
- ;
- else
- {
- int saved_errno = errno;
- free (malloced);
- errno = saved_errno;
- return -1;
- }
- }
- else if (count == 0)
- ;
- else
- {
- /* Don't use MIN_ACL_ENTRIES: It's set to 4 on Cygwin, but Cygwin
- returns only 3 entries for files with no ACL. But this is safe:
- If there are more than 4 entries, there cannot be only the
- "user::", "group::", "other:", and "mask:" entries. */
- if (count > 4)
- {
- free (malloced);
- return 1;
- }
-
- if (acl_nontrivial (count, entries))
- {
- free (malloced);
- return 1;
- }
- }
- free (malloced);
- }
-# ifdef ACE_GETACL
- /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
- file systems (whereas the other ones are used in UFS file systems). */
- {
- /* Initially, try to read the entries into a stack-allocated buffer.
- Use malloc if it does not fit. */
- enum
- {
- alloc_init = 4000 / sizeof (ace_t), /* >= 3 */
- alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (ace_t))
- };
- ace_t buf[alloc_init];
- size_t alloc = alloc_init;
- ace_t *entries = buf;
- ace_t *malloced = NULL;
- int count;
-
- for (;;)
- {
- count = acl (name, ACE_GETACL, alloc, entries);
- if (count < 0 && errno == ENOSPC)
- {
- /* Increase the size of the buffer. */
- free (malloced);
- if (alloc > alloc_max / 2)
- {
- errno = ENOMEM;
- return -1;
- }
- alloc = 2 * alloc; /* <= alloc_max */
- entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t));
- if (entries == NULL)
- {
- errno = ENOMEM;
- return -1;
- }
- continue;
- }
- break;
- }
- if (count < 0)
- {
- if (errno == ENOSYS || errno == EINVAL)
- ;
- else
- {
- int saved_errno = errno;
- free (malloced);
- errno = saved_errno;
- return -1;
- }
- }
- else if (count == 0)
- ;
- else
- {
- /* In the old (original Solaris 10) convention:
- If there are more than 3 entries, there cannot be only the
- ACE_OWNER, ACE_GROUP, ACE_OTHER entries.
- In the newer Solaris 10 and Solaris 11 convention:
- If there are more than 6 entries, there cannot be only the
- ACE_OWNER, ACE_GROUP, ACE_EVERYONE entries, each once with
- NEW_ACE_ACCESS_ALLOWED_ACE_TYPE and once with
- NEW_ACE_ACCESS_DENIED_ACE_TYPE. */
- if (count > 6)
- {
- free (malloced);
- return 1;
- }
-
- if (acl_ace_nontrivial (count, entries))
- {
- free (malloced);
- return 1;
- }
- }
- free (malloced);
- }
-# endif
-
- return 0;
+# elif defined GETACL /* Solaris, Cygwin */
+ free (ctx->entries);
+# ifdef ACE_GETACL
+ free (ctx->ace_entries);
# endif
# elif HAVE_GETACL /* HP-UX */
- {
- struct acl_entry entries[NACLENTRIES];
- int count;
-
- count = getacl (name, NACLENTRIES, entries);
-
- if (count < 0)
- {
- /* ENOSYS is seen on newer HP-UX versions.
- EOPNOTSUPP is typically seen on NFS mounts.
- ENOTSUP was seen on Quantum StorNext file systems (cvfs). */
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
- ;
- else
- return -1;
- }
- else if (count == 0)
- return 0;
- else /* count > 0 */
- {
- if (count > NACLENTRIES)
- /* If NACLENTRIES cannot be trusted, use dynamic memory
- allocation. */
- abort ();
-
- /* If there are more than 3 entries, there cannot be only the
- (uid,%), (%,gid), (%,%) entries. */
- if (count > 3)
- return 1;
-
- {
- struct stat statbuf;
-
- if (stat (name, &statbuf) < 0)
- return -1;
-
- return acl_nontrivial (count, entries, &statbuf);
- }
- }
- }
-
-# if HAVE_ACLV_H /* HP-UX >= 11.11 */
-
- {
- struct acl entries[NACLVENTRIES];
- int count;
-
- count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries);
-
- if (count < 0)
- {
- /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23.
- EINVAL is seen on NFS in HP-UX 11.31. */
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- ;
- else
- return -1;
- }
- else if (count == 0)
- return 0;
- else /* count > 0 */
- {
- if (count > NACLVENTRIES)
- /* If NACLVENTRIES cannot be trusted, use dynamic memory
- allocation. */
- abort ();
-
- /* If there are more than 4 entries, there cannot be only the
- four base ACL entries. */
- if (count > 4)
- return 1;
-
- return aclv_nontrivial (count, entries);
- }
- }
-
+# if HAVE_ACLV_H
# endif
-# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */
-
- acl_type_t type;
- char aclbuf[1024];
- void *acl = aclbuf;
- size_t aclsize = sizeof (aclbuf);
- mode_t mode;
-
- for (;;)
- {
- /* The docs say that type being 0 is equivalent to ACL_ANY, but it
- is not true, in AIX 5.3. */
- type.u64 = ACL_ANY;
- if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0)
- break;
- if (errno == ENOSYS)
- return 0;
- if (errno != ENOSPC)
- {
- if (acl != aclbuf)
- {
- int saved_errno = errno;
- free (acl);
- errno = saved_errno;
- }
- return -1;
- }
- aclsize = 2 * aclsize;
- if (acl != aclbuf)
- free (acl);
- acl = malloc (aclsize);
- if (acl == NULL)
- {
- errno = ENOMEM;
- return -1;
- }
- }
-
- if (type.u64 == ACL_AIXC)
- {
- int result = acl_nontrivial ((struct acl *) acl);
- if (acl != aclbuf)
- free (acl);
- return result;
- }
- else if (type.u64 == ACL_NFS4)
- {
- int result = acl_nfs4_nontrivial ((nfs4_acl_int_t *) acl);
- if (acl != aclbuf)
- free (acl);
- return result;
- }
- else
- {
- /* A newer type of ACL has been introduced in the system.
- We should better support it. */
- if (acl != aclbuf)
- free (acl);
- errno = EINVAL;
- return -1;
- }
-
# elif HAVE_STATACL /* older AIX */
- union { struct acl a; char room[4096]; } u;
-
- if (statacl (name, STX_NORMAL, &u.a, sizeof (u)) < 0)
- return -1;
-
- return acl_nontrivial (&u.a);
-
# elif HAVE_ACLSORT /* NonStop Kernel */
- {
- struct acl entries[NACLENTRIES];
- int count;
-
- count = acl ((char *) name, ACL_GET, NACLENTRIES, entries);
-
- if (count < 0)
- {
- if (errno == ENOSYS || errno == ENOTSUP)
- ;
- else
- return -1;
- }
- else if (count == 0)
- return 0;
- else /* count > 0 */
- {
- if (count > NACLENTRIES)
- /* If NACLENTRIES cannot be trusted, use dynamic memory
- allocation. */
- abort ();
-
- /* If there are more than 4 entries, there cannot be only the
- four base ACL entries. */
- if (count > 4)
- return 1;
-
- return acl_nontrivial (count, entries);
- }
- }
-
# endif
- }
#endif
-
- return 0;
}
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index a6974d9..636273e 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -1,6 +1,6 @@
-/* Internal implementation of access control lists.
+/* Internal implementation of access control lists. -*- coding: utf-8 -*-
- Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2016 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
@@ -44,16 +44,7 @@ extern int acl (char *, int, int, struct acl *);
extern int aclsort (int, int, struct acl *);
#endif
-#include "error.h"
-#include "quote.h"
-
#include <errno.h>
-#ifndef ENOSYS
-# define ENOSYS (-1)
-#endif
-#ifndef ENOTSUP
-# define ENOTSUP (-1)
-#endif
#include <limits.h>
#ifndef MIN
@@ -69,19 +60,9 @@ extern int aclsort (int, int, struct acl *);
# define fchmod(fd, mode) (-1)
#endif
-/* Recognize some common errors such as from an NFS mount that does
- not support ACLs, even when local drives do. */
-#if defined __APPLE__ && defined __MACH__ /* Mac OS X */
-# define ACL_NOT_WELL_SUPPORTED(Err) \
- ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY || (Err) == ENOENT)
-#elif defined EOPNOTSUPP /* Tru64 NFS */
-# define ACL_NOT_WELL_SUPPORTED(Err) \
- ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY || (Err) == EOPNOTSUPP)
-#else
-# define ACL_NOT_WELL_SUPPORTED(Err) \
- ((Err) == ENOTSUP || (Err) == ENOSYS || (Err) == EINVAL || (Err) == EBUSY)
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
#endif
-
_GL_INLINE_HEADER_BEGIN
#ifndef ACL_INTERNAL_INLINE
# define ACL_INTERNAL_INLINE _GL_INLINE
@@ -146,18 +127,13 @@ rpl_acl_set_fd (int fd, acl_t acl)
# define acl_extended_file(name) (-1)
# endif
-/* Linux-specific */
-# ifndef HAVE_ACL_FROM_MODE
-# define HAVE_ACL_FROM_MODE false
-# define acl_from_mode(mode) (NULL)
+# if ! defined HAVE_ACL_FROM_MODE && ! defined HAVE_ACL_FROM_TEXT
+# define acl_from_mode (NULL)
# endif
-/* Set to 1 if a file's mode is implicit by the ACL.
- Set to 0 if a file's mode is stored independently from the ACL. */
+/* Set to 0 if a file's mode is stored independently from the ACL. */
# if (HAVE_ACL_COPY_EXT_NATIVE && HAVE_ACL_CREATE_ENTRY_NP) || defined __sgi /* Mac OS X, IRIX */
# define MODE_INSIDE_ACL 0
-# else
-# define MODE_INSIDE_ACL 1
# endif
/* Return the number of entries in ACL.
@@ -179,28 +155,31 @@ extern int acl_extended_nontrivial (acl_t);
Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
Return -1 and set errno upon failure to determine it. */
extern int acl_access_nontrivial (acl_t);
+
+/* ACL is an ACL, from a file, stored as type ACL_TYPE_DEFAULT.
+ Return 1 if the given ACL is non-trivial.
+ Return 0 if it is trivial, i.e. equivalent to a simple stat() mode.
+ Return -1 and set errno upon failure to determine it. */
+extern int acl_default_nontrivial (acl_t);
# endif
# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-/* Set to 1 if a file's mode is implicit by the ACL.
- Set to 0 if a file's mode is stored independently from the ACL. */
+/* Set to 0 if a file's mode is stored independently from the ACL. */
# if defined __CYGWIN__ /* Cygwin */
# define MODE_INSIDE_ACL 0
-# else /* Solaris */
-# define MODE_INSIDE_ACL 1
# endif
/* Return 1 if the given ACL is non-trivial.
Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
-extern int acl_nontrivial (int count, aclent_t *entries);
+extern int acl_nontrivial (int count, aclent_t *entries) _GL_ATTRIBUTE_PURE;
# ifdef ACE_GETACL /* Solaris 10 */
/* Test an ACL retrieved with ACE_GETACL.
Return 1 if the given ACL, consisting of COUNT entries, is non-trivial.
Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
-extern int acl_ace_nontrivial (int count, ace_t *entries);
+extern int acl_ace_nontrivial (int count, ace_t *entries) _GL_ATTRIBUTE_PURE;
/* Definitions for when the built executable is executed on Solaris 10
(newer version) or Solaris 11. */
@@ -239,7 +218,7 @@ extern int acl_ace_nontrivial (int count, ace_t *entries);
/* Return 1 if the given ACL is non-trivial.
Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
-extern int acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb);
+extern int acl_nontrivial (int count, struct acl_entry *entries);
# if HAVE_ACLV_H /* HP-UX >= 11.11 */
@@ -267,6 +246,57 @@ extern int acl_nontrivial (int count, struct acl *entries);
# endif
+/* Set to 1 if a file's mode is implicit by the ACL. */
+# ifndef MODE_INSIDE_ACL
+# define MODE_INSIDE_ACL 1
+# endif
+
+#endif
+
+struct permission_context {
+ mode_t mode;
+#if USE_ACL
+# if HAVE_ACL_GET_FILE /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
+ acl_t acl;
+# if !HAVE_ACL_TYPE_EXTENDED
+ acl_t default_acl;
+# endif
+ bool acls_not_supported;
+
+# elif defined GETACL /* Solaris, Cygwin */
+ int count;
+ aclent_t *entries;
+# ifdef ACE_GETACL
+ int ace_count;
+ ace_t *ace_entries;
+# endif
+
+# elif HAVE_GETACL /* HP-UX */
+ struct acl_entry entries[NACLENTRIES];
+ int count;
+# if HAVE_ACLV_H
+ struct acl aclv_entries[NACLVENTRIES];
+ int aclv_count;
+# endif
+
+# elif HAVE_STATACL /* older AIX */
+ union { struct acl a; char room[4096]; } u;
+ bool have_u;
+
+# elif HAVE_ACLSORT /* NonStop Kernel */
+ struct acl entries[NACLENTRIES];
+ int count;
+
+# endif
+#endif
+};
+
+int get_permissions (const char *, int, mode_t, struct permission_context *);
+int set_permissions (struct permission_context *, const char *, int);
+void free_permission_context (struct permission_context *)
+#if ! (defined USE_ACL && (HAVE_ACL_GET_FILE || defined GETACL))
+ _GL_ATTRIBUTE_CONST
#endif
+ ;
_GL_INLINE_HEADER_END
diff --git a/lib/acl.h b/lib/acl.h
index dc36b0d..491b1ba 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -1,6 +1,6 @@
/* acl.c - access control lists
- Copyright (C) 2002, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,12 +17,19 @@
Written by Paul Eggert. */
+#ifndef _GL_ACL_H
+#define _GL_ACL_H 1
+
+#include <stdbool.h>
#include <sys/types.h>
#include <sys/stat.h>
+bool acl_errno_valid (int) _GL_ATTRIBUTE_CONST;
int file_has_acl (char const *, struct stat const *);
int qset_acl (char const *, int, mode_t);
int set_acl (char const *, int, mode_t);
int qcopy_acl (char const *, int, char const *, int, mode_t);
int copy_acl (char const *, int, char const *, int, mode_t);
int chmod_or_fchmod (char const *, int, mode_t);
+
+#endif
diff --git a/lib/acl_entries.c b/lib/acl_entries.c
index 9ba7598..9fc9cf5 100644
--- a/lib/acl_entries.c
+++ b/lib/acl_entries.c
@@ -1,6 +1,6 @@
/* Return the number of entries in an ACL.
- Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/alignof.h b/lib/alignof.h
new file mode 100644
index 0000000..9b51af0
--- /dev/null
+++ b/lib/alignof.h
@@ -0,0 +1,50 @@
+/* Determine alignment of types.
+ Copyright (C) 2003-2004, 2006, 2009-2016 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, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _ALIGNOF_H
+#define _ALIGNOF_H
+
+#include <stddef.h>
+
+/* alignof_slot (TYPE)
+ Determine the alignment of a structure slot (field) of a given type,
+ at compile time. Note that the result depends on the ABI.
+ This is the same as alignof (TYPE) and _Alignof (TYPE), defined in
+ <stdalign.h> if __alignof_is_defined is 1.
+ Note: The result cannot be used as a value for an 'enum' constant,
+ due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
+#if defined __cplusplus
+ template <class type> struct alignof_helper { char __slot1; type __slot2; };
+# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
+#else
+# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+/* alignof_type (TYPE)
+ Determine the good alignment of an object of the given type at compile time.
+ Note that this is not necessarily the same as alignof_slot(type).
+ For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
+ - when -malign-double is not specified: alignof_slot(double) = 4,
+ - when -malign-double is specified: alignof_slot(double) = 8.
+ Note: The result cannot be used as a value for an 'enum' constant,
+ due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
+#if defined __GNUC__ || defined __IBM__ALIGNOF__
+# define alignof_type __alignof__
+#else
+# define alignof_type alignof_slot
+#endif
+
+#endif /* _ALIGNOF_H */
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index cdcaef1..6a25ecd 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Memory allocation on the stack.
- Copyright (C) 1995, 1999, 2001-2004, 2006-2012 Free Software Foundation,
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2016 Free Software Foundation,
Inc.
This program is free software; you can redistribute it and/or modify it
@@ -53,6 +51,8 @@ extern "C"
void *_alloca (unsigned short);
# pragma intrinsic (_alloca)
# define alloca _alloca
+# elif defined __MVS__
+# include <stdlib.h>
# else
# include <stddef.h>
# ifdef __cplusplus
diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c
index 43ef8c2..1182109 100644
--- a/lib/basename-lgpl.c
+++ b/lib/basename-lgpl.c
@@ -1,6 +1,6 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2012 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/btowc.c b/lib/btowc.c
index cec9eca..e7badf9 100644
--- a/lib/btowc.c
+++ b/lib/btowc.c
@@ -1,5 +1,5 @@
/* Convert unibyte character to wide character.
- Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 98ff762..5d9d4d8 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -1,397 +1,3 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Character handling in C locale.
-
- Copyright 2000-2003, 2006, 2009-2012 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. */
-#define NO_C_CTYPE_MACROS
+#define C_CTYPE_INLINE _GL_EXTERN_INLINE
#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/lib/c-ctype.h b/lib/c-ctype.h
index 3148a0d..717ae78 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -1,5 +1,3 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Character handling in C locale.
These functions work like the corresponding functions in <ctype.h>,
@@ -7,7 +5,7 @@
<ctype.h> functions' behaviour depends on the current locale set via
setlocale.
- Copyright (C) 2000-2003, 2006, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2006, 2008-2016 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
@@ -27,6 +25,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */
#include <stdbool.h>
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef C_CTYPE_INLINE
+# define C_CTYPE_INLINE _GL_INLINE
+#endif
#ifdef __cplusplus
extern "C" {
@@ -41,38 +46,6 @@ extern "C" {
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) \
@@ -98,11 +71,84 @@ extern "C" {
&& ('{' == 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
+# define C_CTYPE_ASCII 1
+#elif ! (' ' == '\x40' && '0' == '\xf0' \
+ && 'A' == '\xc1' && 'J' == '\xd1' && 'S' == '\xe2' \
+ && 'a' == '\x81' && 'j' == '\x91' && 's' == '\xa2')
+# error "Only ASCII and EBCDIC are supported"
#endif
+#if 'A' < 0
+# error "EBCDIC and char is signed -- not supported"
+#endif
+
+/* Cases for control characters. */
+
+#define _C_CTYPE_CNTRL \
+ case '\a': case '\b': case '\f': case '\n': \
+ case '\r': case '\t': case '\v': \
+ _C_CTYPE_OTHER_CNTRL
+
+/* ASCII control characters other than those with \-letter escapes. */
+
+#if C_CTYPE_ASCII
+# define _C_CTYPE_OTHER_CNTRL \
+ case '\x00': case '\x01': case '\x02': case '\x03': \
+ case '\x04': case '\x05': case '\x06': case '\x0e': \
+ case '\x0f': case '\x10': case '\x11': case '\x12': \
+ case '\x13': case '\x14': case '\x15': case '\x16': \
+ case '\x17': case '\x18': case '\x19': case '\x1a': \
+ case '\x1b': case '\x1c': case '\x1d': case '\x1e': \
+ case '\x1f': case '\x7f'
+#else
+ /* Use EBCDIC code page 1047's assignments for ASCII control chars;
+ assume all EBCDIC code pages agree about these assignments. */
+# define _C_CTYPE_OTHER_CNTRL \
+ case '\x00': case '\x01': case '\x02': case '\x03': \
+ case '\x07': case '\x0e': case '\x0f': case '\x10': \
+ case '\x11': case '\x12': case '\x13': case '\x18': \
+ case '\x19': case '\x1c': case '\x1d': case '\x1e': \
+ case '\x1f': case '\x26': case '\x27': case '\x2d': \
+ case '\x2e': case '\x32': case '\x37': case '\x3c': \
+ case '\x3d': case '\x3f'
+#endif
-/* Function declarations. */
+/* Cases for lowercase hex letters, and lowercase letters, all offset by N. */
+
+#define _C_CTYPE_LOWER_A_THRU_F_N(n) \
+ case 'a' + (n): case 'b' + (n): case 'c' + (n): case 'd' + (n): \
+ case 'e' + (n): case 'f' + (n)
+#define _C_CTYPE_LOWER_N(n) \
+ _C_CTYPE_LOWER_A_THRU_F_N(n): \
+ case 'g' + (n): case 'h' + (n): case 'i' + (n): case 'j' + (n): \
+ case 'k' + (n): case 'l' + (n): case 'm' + (n): case 'n' + (n): \
+ case 'o' + (n): case 'p' + (n): case 'q' + (n): case 'r' + (n): \
+ case 's' + (n): case 't' + (n): case 'u' + (n): case 'v' + (n): \
+ case 'w' + (n): case 'x' + (n): case 'y' + (n): case 'z' + (n)
+
+/* Cases for hex letters, digits, lower, punct, and upper. */
+
+#define _C_CTYPE_A_THRU_F \
+ _C_CTYPE_LOWER_A_THRU_F_N (0): \
+ _C_CTYPE_LOWER_A_THRU_F_N ('A' - 'a')
+#define _C_CTYPE_DIGIT \
+ case '0': case '1': case '2': case '3': \
+ case '4': case '5': case '6': case '7': \
+ case '8': case '9'
+#define _C_CTYPE_LOWER _C_CTYPE_LOWER_N (0)
+#define _C_CTYPE_PUNCT \
+ 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 '~'
+#define _C_CTYPE_UPPER _C_CTYPE_LOWER_N ('A' - 'a')
+
+
+/* Function definitions. */
/* 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
@@ -119,178 +165,202 @@ extern "C" {
if (c_isalpha (*s)) ...
*/
-extern bool c_isascii (int c) _GL_ATTRIBUTE_CONST; /* not locale dependent */
-
-extern bool c_isalnum (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isalpha (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isblank (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_iscntrl (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isdigit (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_islower (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isgraph (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isprint (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_ispunct (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isspace (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isupper (int c) _GL_ATTRIBUTE_CONST;
-extern bool c_isxdigit (int c) _GL_ATTRIBUTE_CONST;
-
-extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
-extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
-
-
-#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); \
- })
+C_CTYPE_INLINE bool
+c_isalnum (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#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
+C_CTYPE_INLINE bool
+c_isalpha (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#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
+/* The function isascii is not locale dependent.
+ Its use in EBCDIC is questionable. */
+C_CTYPE_INLINE bool
+c_isascii (int c)
+{
+ switch (c)
+ {
+ case ' ':
+ _C_CTYPE_CNTRL:
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#undef c_isblank
-#define c_isblank(c) \
- ({ int __c = (c); \
- (__c == ' ' || __c == '\t'); \
- })
+C_CTYPE_INLINE bool
+c_isblank (int c)
+{
+ return c == ' ' || c == '\t';
+}
-#if C_CTYPE_ASCII
-#undef c_iscntrl
-#define c_iscntrl(c) \
- ({ int __c = (c); \
- ((__c & ~0x1f) == 0 || __c == 0x7f); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_iscntrl (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_CNTRL:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_DIGITS
-#undef c_isdigit
-#define c_isdigit(c) \
- ({ int __c = (c); \
- (__c >= '0' && __c <= '9'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isdigit (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_CONSECUTIVE_LOWERCASE
-#undef c_islower
-#define c_islower(c) \
- ({ int __c = (c); \
- (__c >= 'a' && __c <= 'z'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isgraph (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_ASCII
-#undef c_isgraph
-#define c_isgraph(c) \
- ({ int __c = (c); \
- (__c >= '!' && __c <= '~'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_islower (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_ASCII
-#undef c_isprint
-#define c_isprint(c) \
- ({ int __c = (c); \
- (__c >= ' ' && __c <= '~'); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_isprint (int c)
+{
+ switch (c)
+ {
+ case ' ':
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_LOWER:
+ _C_CTYPE_PUNCT:
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#if C_CTYPE_ASCII
-#undef c_ispunct
-#define c_ispunct(c) \
- ({ int _c = (c); \
- (c_isgraph (_c) && ! c_isalnum (_c)); \
- })
-#endif
+C_CTYPE_INLINE bool
+c_ispunct (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_PUNCT:
+ return true;
+ default:
+ return false;
+ }
+}
-#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
+C_CTYPE_INLINE bool
+c_isspace (int c)
+{
+ switch (c)
+ {
+ case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
+ return true;
+ default:
+ return false;
+ }
+}
-#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
+C_CTYPE_INLINE bool
+c_isupper (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_UPPER:
+ return true;
+ default:
+ return false;
+ }
+}
-#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
+C_CTYPE_INLINE bool
+c_isxdigit (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_DIGIT:
+ _C_CTYPE_A_THRU_F:
+ return true;
+ default:
+ return false;
+ }
+}
-#endif /* optimizing for speed */
+C_CTYPE_INLINE int
+c_tolower (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_UPPER:
+ return c - 'A' + 'a';
+ default:
+ return c;
+ }
+}
+C_CTYPE_INLINE int
+c_toupper (int c)
+{
+ switch (c)
+ {
+ _C_CTYPE_LOWER:
+ return c - 'a' + 'A';
+ default:
+ return c;
+ }
+}
#ifdef __cplusplus
}
#endif
+_GL_INLINE_HEADER_END
+
#endif /* C_CTYPE_H */
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index 46a558d..7e570f5 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Case-insensitive string comparison functions in C locale.
- Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2012 Free Software
+ Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index 779910c..bd113b7 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* c-strcasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/c-strcaseeq.h b/lib/c-strcaseeq.h
index 17e6f04..ed57251 100644
--- a/lib/c-strcaseeq.h
+++ b/lib/c-strcaseeq.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Optimized case-insensitive string comparison in C locale.
- Copyright (C) 2001-2002, 2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2016 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
@@ -35,9 +33,6 @@
# if C_CTYPE_ASCII
# define CASEEQ(other,upper) \
(c_isupper (upper) ? ((other) & ~0x20) == (upper) : (other) == (upper))
-# elif C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
-# define CASEEQ(other,upper) \
- (c_isupper (upper) ? (other) == (upper) || (other) == (upper) - 'A' + 'a' : (other) == (upper))
# else
# define CASEEQ(other,upper) \
(c_toupper (other) == (upper))
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index aa8cd40..c316929 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* c-strncasecmp.c -- case insensitive string comparator in C locale
- Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 6d26fa6..4b1f6cb 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -1,5 +1,5 @@
/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2012 Free Software Foundation, Inc.
+ Copyright (C) 1996-2016 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
@@ -16,16 +16,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+# define _GL_ARG_NONNULL(params)
+
# define _GL_USE_STDLIB_ALLOC 1
# 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>
@@ -83,7 +83,23 @@
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
#endif
+/* Define this independently so that stdint.h is not a prerequisite. */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
#if !FUNC_REALPATH_WORKS || defined _LIBC
+
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the malloc or realloc modules; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
/* 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
@@ -135,9 +151,7 @@ __realpath (const char *name, char *resolved)
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;
+ alloc_failed ();
return NULL;
}
}
@@ -185,7 +199,6 @@ __realpath (const char *name, char *resolved)
#else
struct stat st;
#endif
- int n;
/* Skip sequence of multiple path-separators. */
while (ISSLASH (*start))
@@ -238,9 +251,7 @@ __realpath (const char *name, char *resolved)
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;
+ alloc_failed ();
goto error;
}
rpath = new_rpath;
@@ -268,6 +279,7 @@ __realpath (const char *name, char *resolved)
{
char *buf;
size_t len;
+ ssize_t n;
if (++num_links > MAXSYMLINKS)
{
@@ -278,7 +290,7 @@ __realpath (const char *name, char *resolved)
buf = malloca (path_max);
if (!buf)
{
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
@@ -287,7 +299,7 @@ __realpath (const char *name, char *resolved)
{
int saved_errno = errno;
freea (buf);
- errno = saved_errno;
+ __set_errno (saved_errno);
goto error;
}
buf[n] = '\0';
@@ -298,13 +310,14 @@ __realpath (const char *name, char *resolved)
if (!extra_buf)
{
freea (buf);
- errno = ENOMEM;
+ __set_errno (ENOMEM);
goto error;
}
}
len = strlen (end);
- if ((long int) (n + len) >= path_max)
+ /* Check that n + len + 1 doesn't overflow and is <= path_max. */
+ if (n >= SIZE_MAX - len || n + len >= path_max)
{
freea (buf);
__set_errno (ENAMETOOLONG);
@@ -370,7 +383,7 @@ error:
freea (extra_buf);
if (resolved == NULL)
free (rpath);
- errno = saved_errno;
+ __set_errno (saved_errno);
}
return NULL;
}
diff --git a/lib/close-stream.c b/lib/close-stream.c
new file mode 100644
index 0000000..0c4beae
--- /dev/null
+++ b/lib/close-stream.c
@@ -0,0 +1,78 @@
+/* Close a stream, with nicer error checking than fclose's.
+
+ Copyright (C) 1998-2002, 2004, 2006-2016 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 "close-stream.h"
+
+#include <errno.h>
+#include <stdbool.h>
+
+#include "fpending.h"
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+#endif
+
+/* Close STREAM. Return 0 if successful, EOF (setting errno)
+ otherwise. A failure might set errno to 0 if the error number
+ cannot be determined.
+
+ A failure with errno set to EPIPE may or may not indicate an error
+ situation worth signaling to the user. See the documentation of the
+ close_stdout_set_ignore_EPIPE function for details.
+
+ If a program writes *anything* to STREAM, that program should close
+ STREAM and make sure that it succeeds before exiting. Otherwise,
+ suppose that you go to the extreme of checking the return status
+ of every function that does an explicit write to STREAM. The last
+ printf can succeed in writing to the internal stream buffer, and yet
+ the fclose(STREAM) could still fail (due e.g., to a disk full error)
+ when it tries to write out that buffered data. Thus, you would be
+ left with an incomplete output file and the offending program would
+ exit successfully. Even calling fflush is not always sufficient,
+ since some file systems (NFS and CODA) buffer written/flushed data
+ until an actual close call.
+
+ Besides, it's wasteful to check the return value from every call
+ that writes to STREAM -- just let the internal stream state record
+ the failure. That's what the ferror test is checking below. */
+
+int
+close_stream (FILE *stream)
+{
+ const bool some_pending = (__fpending (stream) != 0);
+ const bool prev_fail = (ferror (stream) != 0);
+ const bool fclose_fail = (fclose (stream) != 0);
+
+ /* Return an error indication if there was a previous failure or if
+ fclose failed, with one exception: ignore an fclose failure if
+ there was no previous error, no data remains to be flushed, and
+ fclose failed with EBADF. That can happen when a program like cp
+ is invoked like this 'cp a b >&-' (i.e., with standard output
+ closed) and doesn't generate any output (hence no previous error
+ and nothing to be flushed). */
+
+ if (prev_fail || (fclose_fail && (some_pending || errno != EBADF)))
+ {
+ if (! fclose_fail)
+ errno = 0;
+ return EOF;
+ }
+
+ return 0;
+}
diff --git a/lib/close-stream.h b/lib/close-stream.h
new file mode 100644
index 0000000..be3d419
--- /dev/null
+++ b/lib/close-stream.h
@@ -0,0 +1,2 @@
+#include <stdio.h>
+int close_stream (FILE *stream);
diff --git a/lib/closeout.c b/lib/closeout.c
new file mode 100644
index 0000000..311faf4
--- /dev/null
+++ b/lib/closeout.c
@@ -0,0 +1,124 @@
+/* Close standard output and standard error, exiting with a diagnostic on error.
+
+ Copyright (C) 1998-2002, 2004, 2006, 2008-2016 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 "closeout.h"
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+#include "close-stream.h"
+#include "error.h"
+#include "exitfail.h"
+#include "quotearg.h"
+
+static const char *file_name;
+
+/* Set the file name to be reported in the event an error is detected
+ by close_stdout. */
+void
+close_stdout_set_file_name (const char *file)
+{
+ file_name = file;
+}
+
+static bool ignore_EPIPE /* = false */;
+
+/* Specify the reaction to an EPIPE error during the closing of stdout:
+ - If ignore = true, it shall be ignored.
+ - If ignore = false, it shall evoke a diagnostic, along with a nonzero
+ exit status.
+ The default is ignore = false.
+
+ This setting matters only if the SIGPIPE signal is ignored (i.e. its
+ handler set to SIG_IGN) or blocked. Only particular programs need to
+ temporarily ignore SIGPIPE. If SIGPIPE is ignored or blocked because
+ it was ignored or blocked in the parent process when it created the
+ child process, it usually is a bug in the parent process: It is bad
+ practice to have SIGPIPE ignored or blocked while creating a child
+ process.
+
+ EPIPE occurs when writing to a pipe or socket that has no readers now,
+ when SIGPIPE is ignored or blocked.
+
+ The ignore = false setting is suitable for a scenario where it is normally
+ guaranteed that the pipe writer terminates before the pipe reader. In
+ this case, an EPIPE is an indication of a premature termination of the
+ pipe reader and should lead to a diagnostic and a nonzero exit status.
+
+ The ignore = true setting is suitable for a scenario where you don't know
+ ahead of time whether the pipe writer or the pipe reader will terminate
+ first. In this case, an EPIPE is an indication that the pipe writer can
+ stop doing useless write() calls; this is what close_stdout does anyway.
+ EPIPE is part of the normal pipe/socket shutdown protocol in this case,
+ and should not lead to a diagnostic message. */
+
+void
+close_stdout_set_ignore_EPIPE (bool ignore)
+{
+ ignore_EPIPE = ignore;
+}
+
+/* Close standard output. On error, issue a diagnostic and _exit
+ with status 'exit_failure'.
+
+ Also close standard error. On error, _exit with status 'exit_failure'.
+
+ Since close_stdout is commonly registered via 'atexit', POSIX
+ and the C standard both say that it should not call 'exit',
+ because the behavior is undefined if 'exit' is called more than
+ once. So it calls '_exit' instead of 'exit'. If close_stdout
+ is registered via atexit before other functions are registered,
+ the other functions can act before this _exit is invoked.
+
+ Applications that use close_stdout should flush any streams
+ other than stdout and stderr before exiting, since the call to
+ _exit will bypass other buffer flushing. Applications should
+ be flushing and closing other streams anyway, to check for I/O
+ errors. Also, applications should not use tmpfile, since _exit
+ can bypass the removal of these files.
+
+ It's important to detect such failures and exit nonzero because many
+ tools (most notably 'make' and other build-management systems) depend
+ on being able to detect failure in other tools via their exit status. */
+
+void
+close_stdout (void)
+{
+ if (close_stream (stdout) != 0
+ && !(ignore_EPIPE && errno == EPIPE))
+ {
+ char const *write_error = _("write error");
+ if (file_name)
+ error (0, errno, "%s: %s", quotearg_colon (file_name),
+ write_error);
+ else
+ error (0, errno, "%s", write_error);
+
+ _exit (exit_failure);
+ }
+
+ if (close_stream (stderr) != 0)
+ _exit (exit_failure);
+}
diff --git a/lib/closeout.h b/lib/closeout.h
new file mode 100644
index 0000000..bde9bf0
--- /dev/null
+++ b/lib/closeout.h
@@ -0,0 +1,36 @@
+/* Close standard output and standard error.
+
+ Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2016 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 CLOSEOUT_H
+# define CLOSEOUT_H 1
+
+# include <stdbool.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+void close_stdout_set_file_name (const char *file);
+void close_stdout_set_ignore_EPIPE (bool ignore);
+void close_stdout (void);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
diff --git a/lib/config.charset b/lib/config.charset
index 0a3b343..947d916 100644
--- a/lib/config.charset
+++ b/lib/config.charset
@@ -1,7 +1,7 @@
#! /bin/sh
# Output a system dependent table of character encoding aliases.
#
-# Copyright (C) 2000-2004, 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000-2004, 2006-2016 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
@@ -348,12 +348,10 @@ case "$os" in
#echo "sun_eu_greek ?" # what is this?
echo "UTF-8 UTF-8"
;;
- freebsd* | os2*)
+ freebsd*)
# 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
diff --git a/lib/copy-acl.c b/lib/copy-acl.c
index 5cc75e1..4b6b443 100644
--- a/lib/copy-acl.c
+++ b/lib/copy-acl.c
@@ -1,6 +1,6 @@
-/* copy-acl.c - copy access control list from one file to another file
+/* Copy access control list from one file to file. -*- coding: utf-8 -*-
- Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,8 +21,10 @@
#include "acl.h"
-#include "acl-internal.h"
+#include <errno.h>
+#include "quote.h"
+#include "error.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -34,565 +36,6 @@
If access control lists are not available, fchmod the target file to
MODE. Also sets the non-permission bits of the destination file
(S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set.
- Return 0 if successful.
- Return -2 and set errno for an error relating to the source file.
- Return -1 and set errno for an error relating to the destination file. */
-
-int
-qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
- int dest_desc, mode_t mode)
-{
-#if USE_ACL && HAVE_ACL_GET_FILE
- /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
- /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
-# if !HAVE_ACL_TYPE_EXTENDED
- /* Linux, FreeBSD, IRIX, Tru64 */
-
- acl_t acl;
- int ret;
-
- if (HAVE_ACL_GET_FD && source_desc != -1)
- acl = acl_get_fd (source_desc);
- else
- acl = acl_get_file (src_name, ACL_TYPE_ACCESS);
- if (acl == NULL)
- {
- if (ACL_NOT_WELL_SUPPORTED (errno))
- return qset_acl (dst_name, dest_desc, mode);
- else
- return -2;
- }
-
- if (HAVE_ACL_SET_FD && dest_desc != -1)
- ret = acl_set_fd (dest_desc, acl);
- else
- ret = acl_set_file (dst_name, ACL_TYPE_ACCESS, acl);
- if (ret != 0)
- {
- int saved_errno = errno;
-
- if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_access_nontrivial (acl))
- {
- acl_free (acl);
- return chmod_or_fchmod (dst_name, dest_desc, mode);
- }
- else
- {
- acl_free (acl);
- chmod_or_fchmod (dst_name, dest_desc, mode);
- errno = saved_errno;
- return -1;
- }
- }
- else
- acl_free (acl);
-
- if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- /* We did not call chmod so far, and either the mode and the ACL are
- separate or special bits are to be set which don't fit into ACLs. */
-
- if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
- return -1;
- }
-
- if (S_ISDIR (mode))
- {
- acl = acl_get_file (src_name, ACL_TYPE_DEFAULT);
- if (acl == NULL)
- return -2;
-
- if (acl_set_file (dst_name, ACL_TYPE_DEFAULT, acl))
- {
- int saved_errno = errno;
-
- acl_free (acl);
- errno = saved_errno;
- return -1;
- }
- else
- acl_free (acl);
- }
- return 0;
-
-# else /* HAVE_ACL_TYPE_EXTENDED */
- /* Mac OS X */
-
- /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
- and acl_get_file (name, ACL_TYPE_DEFAULT)
- always return NULL / EINVAL. You have to use
- acl_get_file (name, ACL_TYPE_EXTENDED)
- or acl_get_fd (open (name, ...))
- to retrieve an ACL.
- On the other hand,
- acl_set_file (name, ACL_TYPE_ACCESS, acl)
- and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
- have the same effect as
- acl_set_file (name, ACL_TYPE_EXTENDED, acl):
- Each of these calls sets the file's ACL. */
-
- acl_t acl;
- int ret;
-
- if (HAVE_ACL_GET_FD && source_desc != -1)
- acl = acl_get_fd (source_desc);
- else
- acl = acl_get_file (src_name, ACL_TYPE_EXTENDED);
- if (acl == NULL)
- {
- if (ACL_NOT_WELL_SUPPORTED (errno))
- return qset_acl (dst_name, dest_desc, mode);
- else
- return -2;
- }
-
- if (HAVE_ACL_SET_FD && dest_desc != -1)
- ret = acl_set_fd (dest_desc, acl);
- else
- ret = acl_set_file (dst_name, ACL_TYPE_EXTENDED, acl);
- if (ret != 0)
- {
- int saved_errno = errno;
-
- if (ACL_NOT_WELL_SUPPORTED (errno) && !acl_extended_nontrivial (acl))
- {
- acl_free (acl);
- return chmod_or_fchmod (dst_name, dest_desc, mode);
- }
- else
- {
- acl_free (acl);
- chmod_or_fchmod (dst_name, dest_desc, mode);
- errno = saved_errno;
- return -1;
- }
- }
- else
- acl_free (acl);
-
- /* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */
- return chmod_or_fchmod (dst_name, dest_desc, mode);
-
-# endif
-
-#elif USE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-
- /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
- of Unixware. The acl() call returns the access and default ACL both
- at once. */
-# ifdef ACE_GETACL
- int ace_count;
- ace_t *ace_entries;
-# endif
- int count;
- aclent_t *entries;
- int did_chmod;
- int saved_errno;
- int ret;
-
-# ifdef ACE_GETACL
- /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
- file systems (whereas the other ones are used in UFS file systems).
- There is an API
- pathconf (name, _PC_ACL_ENABLED)
- fpathconf (desc, _PC_ACL_ENABLED)
- that allows to determine which of the two kinds of ACLs is supported
- for the given file. But some file systems may implement this call
- incorrectly, so better not use it.
- When fetching the source ACL, we simply fetch both ACL types.
- When setting the destination ACL, we try either ACL types, assuming
- that the kernel will translate the ACL from one form to the other.
- (See in <http://docs.sun.com/app/docs/doc/819-2241/6n4huc7ia?l=en&a=view>
- the description of ENOTSUP.) */
- for (;;)
- {
- ace_count = (source_desc != -1
- ? facl (source_desc, ACE_GETACLCNT, 0, NULL)
- : acl (src_name, ACE_GETACLCNT, 0, NULL));
-
- if (ace_count < 0)
- {
- if (errno == ENOSYS || errno == EINVAL)
- {
- ace_count = 0;
- ace_entries = NULL;
- break;
- }
- else
- return -2;
- }
-
- if (ace_count == 0)
- {
- ace_entries = NULL;
- break;
- }
-
- ace_entries = (ace_t *) malloc (ace_count * sizeof (ace_t));
- if (ace_entries == NULL)
- {
- errno = ENOMEM;
- return -2;
- }
-
- ret = (source_desc != -1
- ? facl (source_desc, ACE_GETACL, ace_count, ace_entries)
- : acl (src_name, ACE_GETACL, ace_count, ace_entries));
- if (ret < 0)
- {
- free (ace_entries);
- if (errno == ENOSYS || errno == EINVAL)
- {
- ace_count = 0;
- ace_entries = NULL;
- break;
- }
- else
- return -2;
- }
- if (ret == ace_count)
- break;
- /* Huh? The number of ACL entries changed since the last call.
- Repeat. */
- }
-# endif
-
- for (;;)
- {
- count = (source_desc != -1
- ? facl (source_desc, GETACLCNT, 0, NULL)
- : acl (src_name, GETACLCNT, 0, NULL));
-
- if (count < 0)
- {
- if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
- {
- count = 0;
- entries = NULL;
- break;
- }
- else
- return -2;
- }
-
- if (count == 0)
- {
- entries = NULL;
- break;
- }
-
- entries = (aclent_t *) malloc (count * sizeof (aclent_t));
- if (entries == NULL)
- {
- errno = ENOMEM;
- return -2;
- }
-
- if ((source_desc != -1
- ? facl (source_desc, GETACL, count, entries)
- : acl (src_name, GETACL, count, entries))
- == count)
- break;
- /* Huh? The number of ACL entries changed since the last call.
- Repeat. */
- }
-
- /* Is there an ACL of either kind? */
-# ifdef ACE_GETACL
- if (ace_count == 0)
-# endif
- if (count == 0)
- return qset_acl (dst_name, dest_desc, mode);
-
- did_chmod = 0; /* set to 1 once the mode bits in 0777 have been set */
- saved_errno = 0; /* the first non-ignorable error code */
-
- if (!MODE_INSIDE_ACL)
- {
- /* On Cygwin, it is necessary to call chmod before acl, because
- chmod can change the contents of the ACL (in ways that don't
- change the allowed accesses, but still visible). */
- if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
- saved_errno = errno;
- did_chmod = 1;
- }
-
- /* If both ace_entries and entries are available, try SETACL before
- ACE_SETACL, because SETACL cannot fail with ENOTSUP whereas ACE_SETACL
- can. */
-
- if (count > 0)
- {
- ret = (dest_desc != -1
- ? facl (dest_desc, SETACL, count, entries)
- : acl (dst_name, SETACL, count, entries));
- if (ret < 0 && saved_errno == 0)
- {
- saved_errno = errno;
- if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- && !acl_nontrivial (count, entries))
- saved_errno = 0;
- }
- else
- did_chmod = 1;
- }
- free (entries);
-
-# ifdef ACE_GETACL
- if (ace_count > 0)
- {
- ret = (dest_desc != -1
- ? facl (dest_desc, ACE_SETACL, ace_count, ace_entries)
- : acl (dst_name, ACE_SETACL, ace_count, ace_entries));
- if (ret < 0 && saved_errno == 0)
- {
- saved_errno = errno;
- if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP)
- && !acl_ace_nontrivial (ace_count, ace_entries))
- saved_errno = 0;
- }
- }
- free (ace_entries);
-# endif
-
- if (MODE_INSIDE_ACL
- && did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0))
- {
- /* We did not call chmod so far, and either the mode and the ACL are
- separate or special bits are to be set which don't fit into ACLs. */
-
- if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
- {
- if (saved_errno == 0)
- saved_errno = errno;
- }
- }
-
- if (saved_errno)
- {
- errno = saved_errno;
- return -1;
- }
- return 0;
-
-#elif USE_ACL && HAVE_GETACL /* HP-UX */
-
- struct acl_entry entries[NACLENTRIES];
- int count;
-# if HAVE_ACLV_H
- struct acl aclv_entries[NACLVENTRIES];
- int aclv_count;
-# endif
- int did_chmod;
- int saved_errno;
- int ret;
-
- count = (source_desc != -1
- ? fgetacl (source_desc, NACLENTRIES, entries)
- : getacl (src_name, NACLENTRIES, entries));
-
- if (count < 0)
- {
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
- count = 0;
- else
- return -2;
- }
- else if (count > 0)
- {
- if (count > NACLENTRIES)
- /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */
- abort ();
- }
-
-# if HAVE_ACLV_H
- aclv_count = acl ((char *) src_name, ACL_GET, NACLVENTRIES, aclv_entries);
-
- if (aclv_count < 0)
- {
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- count = 0;
- else
- return -2;
- }
- else if (aclv_count > 0)
- {
- if (aclv_count > NACLVENTRIES)
- /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation. */
- abort ();
- }
-# endif
-
- if (count == 0)
-# if HAVE_ACLV_H
- if (aclv_count == 0)
-# endif
- return qset_acl (dst_name, dest_desc, mode);
-
- did_chmod = 0; /* set to 1 once the mode bits in 0777 have been set */
- saved_errno = 0; /* the first non-ignorable error code */
-
- if (count > 0)
- {
- ret = (dest_desc != -1
- ? fsetacl (dest_desc, count, entries)
- : setacl (dst_name, count, entries));
- if (ret < 0 && saved_errno == 0)
- {
- saved_errno = errno;
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
- {
- struct stat source_statbuf;
-
- if ((source_desc != -1
- ? fstat (source_desc, &source_statbuf)
- : stat (src_name, &source_statbuf)) == 0)
- {
- if (!acl_nontrivial (count, entries, &source_statbuf))
- saved_errno = 0;
- }
- else
- saved_errno = errno;
- }
- }
- else
- did_chmod = 1;
- }
-
-# if HAVE_ACLV_H
- if (aclv_count > 0)
- {
- ret = acl ((char *) dst_name, ACL_SET, aclv_count, aclv_entries);
- if (ret < 0 && saved_errno == 0)
- {
- saved_errno = errno;
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- {
- if (!aclv_nontrivial (aclv_count, aclv_entries))
- saved_errno = 0;
- }
- }
- else
- did_chmod = 1;
- }
-# endif
-
- if (did_chmod <= ((mode & (S_ISUID | S_ISGID | S_ISVTX)) ? 1 : 0))
- {
- /* We did not call chmod so far, and special bits are to be set which
- don't fit into ACLs. */
-
- if (chmod_or_fchmod (dst_name, dest_desc, mode) != 0)
- {
- if (saved_errno == 0)
- saved_errno = errno;
- }
- }
-
- if (saved_errno)
- {
- errno = saved_errno;
- return -1;
- }
- return 0;
-
-#elif USE_ACL && HAVE_ACLX_GET && 0 /* AIX */
-
- /* TODO */
-
-#elif USE_ACL && HAVE_STATACL /* older AIX */
-
- union { struct acl a; char room[4096]; } u;
- int ret;
-
- if ((source_desc != -1
- ? fstatacl (source_desc, STX_NORMAL, &u.a, sizeof (u))
- : statacl (src_name, STX_NORMAL, &u.a, sizeof (u)))
- < 0)
- return -2;
-
- ret = (dest_desc != -1
- ? fchacl (dest_desc, &u.a, u.a.acl_len)
- : chacl (dst_name, &u.a, u.a.acl_len));
- if (ret < 0)
- {
- int saved_errno = errno;
-
- chmod_or_fchmod (dst_name, dest_desc, mode);
- errno = saved_errno;
- return -1;
- }
-
- /* No need to call chmod_or_fchmod at this point, since the mode bits
- S_ISUID, S_ISGID, S_ISVTX are also stored in the ACL. */
-
- return 0;
-
-#elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
-
- struct acl entries[NACLENTRIES];
- int count;
- int ret;
-
- count = acl ((char *) src_name, ACL_GET, NACLENTRIES, entries);
-
- if (count < 0)
- {
- if (0)
- count = 0;
- else
- return -2;
- }
- else if (count > 0)
- {
- if (count > NACLENTRIES)
- /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */
- abort ();
- }
-
- if (count == 0)
- return qset_acl (dst_name, dest_desc, mode);
-
- ret = acl ((char *) dst_name, ACL_SET, count, entries);
- if (ret < 0)
- {
- int saved_errno = errno;
-
- if (0)
- {
- if (!acl_nontrivial (count, entries))
- return chmod_or_fchmod (dst_name, dest_desc, mode);
- }
-
- chmod_or_fchmod (dst_name, dest_desc, mode);
- errno = saved_errno;
- return -1;
- }
-
- if (mode & (S_ISUID | S_ISGID | S_ISVTX))
- {
- /* We did not call chmod so far, and either the mode and the ACL are
- separate or special bits are to be set which don't fit into ACLs. */
-
- return chmod_or_fchmod (dst_name, dest_desc, mode);
- }
- return 0;
-
-#else
-
- return qset_acl (dst_name, dest_desc, mode);
-
-#endif
-}
-
-
-/* Copy access control lists from one file to another. If SOURCE_DESC is
- a valid file descriptor, use file descriptor operations, else use
- filename based operations on SRC_NAME. Likewise for DEST_DESC and
- DST_NAME.
- If access control lists are not available, fchmod the target file to
- MODE. Also sets the non-permission bits of the destination file
- (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set.
Return 0 if successful, otherwise output a diagnostic and return a
negative error code. */
diff --git a/lib/ctype.in.h b/lib/ctype.in.h
new file mode 100644
index 0000000..217812d
--- /dev/null
+++ b/lib/ctype.in.h
@@ -0,0 +1,57 @@
+/* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete.
+
+ Copyright (C) 2009-2016 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, see <http://www.gnu.org/licenses/>. */
+
+/* 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 _@GUARD_PREFIX@_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 _@GUARD_PREFIX@_CTYPE_H
+#define _@GUARD_PREFIX@_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 /* _@GUARD_PREFIX@_CTYPE_H */
+#endif /* _@GUARD_PREFIX@_CTYPE_H */
diff --git a/lib/dfa.c b/lib/dfa.c
new file mode 100644
index 0000000..3e1f35d
--- /dev/null
+++ b/lib/dfa.c
@@ -0,0 +1,4113 @@
+/* dfa.c - deterministic extended regexp routines for GNU
+ Copyright (C) 1988, 1998, 2000, 2002, 2004-2005, 2007-2016 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 June, 1988 by Mike Haertel
+ Modified July, 1988 by Arthur David Olson to assist BMG speedups */
+
+#include <config.h>
+
+#include "dfa.h"
+
+#include <assert.h>
+#include <ctype.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+#include <locale.h>
+
+#define STREQ(a, b) (strcmp (a, b) == 0)
+
+/* ISASCIIDIGIT differs from isdigit, as follows:
+ - Its arg may be any int or unsigned int; it need not be an unsigned char.
+ - It's guaranteed to evaluate its argument exactly once.
+ - It's typically faster.
+ Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
+ only '0' through '9' are digits. Prefer ISASCIIDIGIT to isdigit unless
+ it's important to use the locale's definition of "digit" even when the
+ host does not conform to Posix. */
+#define ISASCIIDIGIT(c) ((unsigned) (c) - '0' <= 9)
+
+#include "gettext.h"
+#define _(str) gettext (str)
+
+#include <wchar.h>
+
+#include "intprops.h"
+#include "xalloc.h"
+#include "localeinfo.h"
+
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* HPUX defines these as macros in sys/param.h. */
+#ifdef setbit
+# undef setbit
+#endif
+#ifdef clrbit
+# undef clrbit
+#endif
+
+/* First integer value that is greater than any character code. */
+enum { NOTCHAR = 1 << CHAR_BIT };
+
+/* This represents part of a character class. It must be unsigned and
+ at least CHARCLASS_WORD_BITS wide. Any excess bits are zero. */
+typedef unsigned long int charclass_word;
+
+/* CHARCLASS_WORD_BITS is the number of bits used in a charclass word.
+ CHARCLASS_PAIR (LO, HI) is part of a charclass initializer, and
+ represents 64 bits' worth of a charclass, where LO and HI are the
+ low and high-order 32 bits of the 64-bit quantity. */
+#if ULONG_MAX >> 31 >> 31 < 3
+enum { CHARCLASS_WORD_BITS = 32 };
+# define CHARCLASS_PAIR(lo, hi) lo, hi
+#else
+enum { CHARCLASS_WORD_BITS = 64 };
+# define CHARCLASS_PAIR(lo, hi) (((charclass_word) (hi) << 32) + (lo))
+#endif
+
+/* An initializer for a charclass whose 32-bit words are A through H. */
+#define CHARCLASS_INIT(a, b, c, d, e, f, g, h) \
+ { \
+ CHARCLASS_PAIR (a, b), CHARCLASS_PAIR (c, d), \
+ CHARCLASS_PAIR (e, f), CHARCLASS_PAIR (g, h) \
+ }
+
+/* The maximum useful value of a charclass_word; all used bits are 1. */
+static charclass_word const CHARCLASS_WORD_MASK
+ = ((charclass_word) 1 << (CHARCLASS_WORD_BITS - 1) << 1) - 1;
+
+/* Number of words required to hold a bit for every character. */
+enum
+{
+ CHARCLASS_WORDS = (NOTCHAR + CHARCLASS_WORD_BITS - 1) / CHARCLASS_WORD_BITS
+};
+
+/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */
+typedef charclass_word charclass[CHARCLASS_WORDS];
+
+/* Convert a possibly-signed character to an unsigned character. This is
+ a bit safer than casting to unsigned char, since it catches some type
+ errors that the cast doesn't. */
+static unsigned char
+to_uchar (char ch)
+{
+ return ch;
+}
+
+/* Contexts tell us whether a character is a newline or a word constituent.
+ Word-constituent characters are those that satisfy iswalnum, plus '_'.
+ Each character has a single CTX_* value; bitmasks of CTX_* values denote
+ a particular character class.
+
+ A state also stores a context value, which is a bitmask of CTX_* values.
+ A state's context represents a set of characters that the state's
+ predecessors must match. For example, a state whose context does not
+ include CTX_LETTER will never have transitions where the previous
+ character is a word constituent. A state whose context is CTX_ANY
+ might have transitions from any character. */
+
+#define CTX_NONE 1
+#define CTX_LETTER 2
+#define CTX_NEWLINE 4
+#define CTX_ANY 7
+
+/* Sometimes characters can only be matched depending on the surrounding
+ context. Such context decisions depend on what the previous character
+ was, and the value of the current (lookahead) character. Context
+ dependent constraints are encoded as 12-bit integers. Each bit that
+ is set indicates that the constraint succeeds in the corresponding
+ context.
+
+ bit 8-11 - valid contexts when next character is CTX_NEWLINE
+ bit 4-7 - valid contexts when next character is CTX_LETTER
+ bit 0-3 - valid contexts when next character is CTX_NONE
+
+ The macro SUCCEEDS_IN_CONTEXT determines whether a given constraint
+ succeeds in a particular context. Prev is a bitmask of possible
+ context values for the previous character, curr is the (single-bit)
+ context value for the lookahead character. */
+#define NEWLINE_CONSTRAINT(constraint) (((constraint) >> 8) & 0xf)
+#define LETTER_CONSTRAINT(constraint) (((constraint) >> 4) & 0xf)
+#define OTHER_CONSTRAINT(constraint) ((constraint) & 0xf)
+
+#define SUCCEEDS_IN_CONTEXT(constraint, prev, curr) \
+ ((((curr) & CTX_NONE ? OTHER_CONSTRAINT (constraint) : 0) \
+ | ((curr) & CTX_LETTER ? LETTER_CONSTRAINT (constraint) : 0) \
+ | ((curr) & CTX_NEWLINE ? NEWLINE_CONSTRAINT (constraint) : 0)) \
+ & (prev))
+
+/* The following macros describe what a constraint depends on. */
+#define PREV_NEWLINE_CONSTRAINT(constraint) (((constraint) >> 2) & 0x111)
+#define PREV_LETTER_CONSTRAINT(constraint) (((constraint) >> 1) & 0x111)
+#define PREV_OTHER_CONSTRAINT(constraint) ((constraint) & 0x111)
+
+#define PREV_NEWLINE_DEPENDENT(constraint) \
+ (PREV_NEWLINE_CONSTRAINT (constraint) != PREV_OTHER_CONSTRAINT (constraint))
+#define PREV_LETTER_DEPENDENT(constraint) \
+ (PREV_LETTER_CONSTRAINT (constraint) != PREV_OTHER_CONSTRAINT (constraint))
+
+/* Tokens that match the empty string subject to some constraint actually
+ work by applying that constraint to determine what may follow them,
+ taking into account what has gone before. The following values are
+ the constraints corresponding to the special tokens previously defined. */
+#define NO_CONSTRAINT 0x777
+#define BEGLINE_CONSTRAINT 0x444
+#define ENDLINE_CONSTRAINT 0x700
+#define BEGWORD_CONSTRAINT 0x050
+#define ENDWORD_CONSTRAINT 0x202
+#define LIMWORD_CONSTRAINT 0x252
+#define NOTLIMWORD_CONSTRAINT 0x525
+
+/* The regexp is parsed into an array of tokens in postfix form. Some tokens
+ are operators and others are terminal symbols. Most (but not all) of these
+ codes are returned by the lexical analyzer. */
+
+typedef ptrdiff_t token;
+#define TOKEN_MAX PTRDIFF_MAX
+
+/* States are indexed by state_num values. These are normally
+ nonnegative but -1 is used as a special value. */
+typedef ptrdiff_t state_num;
+
+/* Predefined token values. */
+enum
+{
+ END = -1, /* END is a terminal symbol that matches the
+ end of input; any value of END or less in
+ the parse tree is such a symbol. Accepting
+ states of the DFA are those that would have
+ a transition on END. */
+
+ /* Ordinary character values are terminal symbols that match themselves. */
+
+ EMPTY = NOTCHAR, /* EMPTY is a terminal symbol that matches
+ the empty string. */
+
+ BACKREF, /* BACKREF is generated by \<digit>
+ or by any other construct that
+ is not completely handled. If the scanner
+ detects a transition on backref, it returns
+ a kind of "semi-success" indicating that
+ the match will have to be verified with
+ a backtracking matcher. */
+
+ BEGLINE, /* BEGLINE is a terminal symbol that matches
+ the empty string at the beginning of a
+ line. */
+
+ ENDLINE, /* ENDLINE is a terminal symbol that matches
+ the empty string at the end of a line. */
+
+ BEGWORD, /* BEGWORD is a terminal symbol that matches
+ the empty string at the beginning of a
+ word. */
+
+ ENDWORD, /* ENDWORD is a terminal symbol that matches
+ the empty string at the end of a word. */
+
+ LIMWORD, /* LIMWORD is a terminal symbol that matches
+ the empty string at the beginning or the
+ end of a word. */
+
+ NOTLIMWORD, /* NOTLIMWORD is a terminal symbol that
+ matches the empty string not at
+ the beginning or end of a word. */
+
+ QMARK, /* QMARK is an operator of one argument that
+ matches zero or one occurrences of its
+ argument. */
+
+ STAR, /* STAR is an operator of one argument that
+ matches the Kleene closure (zero or more
+ occurrences) of its argument. */
+
+ PLUS, /* PLUS is an operator of one argument that
+ matches the positive closure (one or more
+ occurrences) of its argument. */
+
+ REPMN, /* REPMN is a lexical token corresponding
+ to the {m,n} construct. REPMN never
+ appears in the compiled token vector. */
+
+ CAT, /* CAT is an operator of two arguments that
+ matches the concatenation of its
+ arguments. CAT is never returned by the
+ lexical analyzer. */
+
+ OR, /* OR is an operator of two arguments that
+ matches either of its arguments. */
+
+ LPAREN, /* LPAREN never appears in the parse tree,
+ it is only a lexeme. */
+
+ RPAREN, /* RPAREN never appears in the parse tree. */
+
+ ANYCHAR, /* ANYCHAR is a terminal symbol that matches
+ a valid multibyte (or single byte) character.
+ It is used only if MB_CUR_MAX > 1. */
+
+ MBCSET, /* MBCSET is similar to CSET, but for
+ multibyte characters. */
+
+ WCHAR, /* Only returned by lex. wctok contains
+ the wide character representation. */
+
+ CSET /* CSET and (and any value greater) is a
+ terminal symbol that matches any of a
+ class of characters. */
+};
+
+
+/* States of the recognizer correspond to sets of positions in the parse
+ tree, together with the constraints under which they may be matched.
+ So a position is encoded as an index into the parse tree together with
+ a constraint. */
+typedef struct
+{
+ size_t index; /* Index into the parse array. */
+ unsigned int constraint; /* Constraint for matching this position. */
+} position;
+
+/* Sets of positions are stored as arrays. */
+typedef struct
+{
+ position *elems; /* Elements of this position set. */
+ ptrdiff_t nelem; /* Number of elements in this set. */
+ ptrdiff_t alloc; /* Number of elements allocated in ELEMS. */
+} position_set;
+
+/* Sets of leaves are also stored as arrays. */
+typedef struct
+{
+ size_t *elems; /* Elements of this position set. */
+ size_t nelem; /* Number of elements in this set. */
+} leaf_set;
+
+/* A state of the dfa consists of a set of positions, some flags,
+ and the token value of the lowest-numbered position of the state that
+ contains an END token. */
+typedef struct
+{
+ size_t hash; /* Hash of the positions of this state. */
+ position_set elems; /* Positions this state could match. */
+ unsigned char context; /* Context from previous state. */
+ unsigned short constraint; /* Constraint for this state to accept. */
+ token first_end; /* Token value of the first END in elems. */
+ position_set mbps; /* Positions which can match multibyte
+ characters or the follows, e.g., period.
+ Used only if MB_CUR_MAX > 1. */
+ state_num mb_trindex; /* Index of this state in MB_TRANS, or
+ negative if the state does not have
+ ANYCHAR. */
+} dfa_state;
+
+/* Maximum for any transition table count. This should be at least 3,
+ for the initial state setup. */
+enum { MAX_TRCOUNT = 1024 };
+
+/* A bracket operator.
+ e.g., [a-c], [[:alpha:]], etc. */
+struct mb_char_classes
+{
+ ptrdiff_t cset;
+ bool invert;
+ wchar_t *chars; /* Normal characters. */
+ ptrdiff_t nchars;
+};
+
+struct regex_syntax
+{
+ /* Syntax bits controlling the behavior of the lexical analyzer. */
+ reg_syntax_t syntax_bits;
+ bool syntax_bits_set;
+
+ /* Flag for case-folding letters into sets. */
+ bool case_fold;
+
+ /* True if ^ and $ match only the start and end of data, and do not match
+ end-of-line within data. */
+ bool anchor;
+
+ /* End-of-line byte in data. */
+ unsigned char eolbyte;
+
+ /* Cache of char-context values. */
+ int sbit[NOTCHAR];
+
+ /* If never_trail[B], the byte B cannot be a non-initial byte in a
+ multibyte character. */
+ bool never_trail[NOTCHAR];
+
+ /* Set of characters considered letters. */
+ charclass letters;
+
+ /* Set of characters that are newline. */
+ charclass newline;
+};
+
+/* Lexical analyzer. All the dross that deals with the obnoxious
+ GNU Regex syntax bits is located here. The poor, suffering
+ reader is referred to the GNU Regex documentation for the
+ meaning of the @#%!@#%^!@ syntax bits. */
+struct lexer_state
+{
+ char const *ptr; /* Pointer to next input character. */
+ size_t left; /* Number of characters remaining. */
+ token lasttok; /* Previous token returned; initially END. */
+ size_t parens; /* Count of outstanding left parens. */
+ int minrep, maxrep; /* Repeat counts for {m,n}. */
+
+ /* Wide character representation of the current multibyte character,
+ or WEOF if there was an encoding error. Used only if
+ MB_CUR_MAX > 1. */
+ wint_t wctok;
+
+ /* Length of the multibyte representation of wctok. */
+ int cur_mb_len;
+
+ /* We're separated from beginning or (, | only by zero-width characters. */
+ bool laststart;
+};
+
+/* Recursive descent parser for regular expressions. */
+
+struct parser_state
+{
+ token tok; /* Lookahead token. */
+ size_t depth; /* Current depth of a hypothetical stack
+ holding deferred productions. This is
+ used to determine the depth that will be
+ required of the real stack later on in
+ dfaanalyze. */
+};
+
+/* A compiled regular expression. */
+struct dfa
+{
+ /* Syntax configuration */
+ struct regex_syntax syntax;
+
+ /* Fields filled by the scanner. */
+ charclass *charclasses; /* Array of character sets for CSET tokens. */
+ ptrdiff_t cindex; /* Index for adding new charclasses. */
+ ptrdiff_t calloc; /* Number of charclasses allocated. */
+ size_t canychar; /* Index of anychar class, or (size_t) -1. */
+
+ /* Scanner state */
+ struct lexer_state lex;
+
+ /* Parser state */
+ struct parser_state parse;
+
+ /* Fields filled by the parser. */
+ token *tokens; /* Postfix parse array. */
+ size_t tindex; /* Index for adding new tokens. */
+ size_t talloc; /* Number of tokens currently allocated. */
+ size_t depth; /* Depth required of an evaluation stack
+ used for depth-first traversal of the
+ parse tree. */
+ size_t nleaves; /* Number of leaves on the parse tree. */
+ size_t nregexps; /* Count of parallel regexps being built
+ with dfaparse. */
+ bool fast; /* The DFA is fast. */
+ token utf8_anychar_classes[5]; /* To lower ANYCHAR in UTF-8 locales. */
+ mbstate_t mbs; /* Multibyte conversion state. */
+
+ /* The following are valid only if MB_CUR_MAX > 1. */
+
+ /* The value of multibyte_prop[i] is defined by following rule.
+ if tokens[i] < NOTCHAR
+ bit 0 : tokens[i] is the first byte of a character, including
+ single-byte characters.
+ bit 1 : tokens[i] is the last byte of a character, including
+ single-byte characters.
+
+ if tokens[i] = MBCSET
+ ("the index of mbcsets corresponding to this operator" << 2) + 3
+
+ e.g.
+ tokens
+ = 'single_byte_a', 'multi_byte_A', single_byte_b'
+ = 'sb_a', 'mb_A(1st byte)', 'mb_A(2nd byte)', 'mb_A(3rd byte)', 'sb_b'
+ multibyte_prop
+ = 3 , 1 , 0 , 2 , 3
+ */
+ int *multibyte_prop;
+
+ /* Array of the bracket expression in the DFA. */
+ struct mb_char_classes *mbcsets;
+ ptrdiff_t nmbcsets;
+ ptrdiff_t mbcsets_alloc;
+
+ /* Fields filled by the superset. */
+ struct dfa *superset; /* Hint of the dfa. */
+
+ /* Fields filled by the state builder. */
+ dfa_state *states; /* States of the dfa. */
+ state_num sindex; /* Index for adding new states. */
+ ptrdiff_t salloc; /* Number of states currently allocated. */
+
+ /* Fields filled by the parse tree->NFA conversion. */
+ position_set *follows; /* Array of follow sets, indexed by position
+ index. The follow of a position is the set
+ of positions containing characters that
+ could conceivably follow a character
+ matching the given position in a string
+ matching the regexp. Allocated to the
+ maximum possible position index. */
+ bool searchflag; /* We are supposed to build a searching
+ as opposed to an exact matcher. A searching
+ matcher finds the first and shortest string
+ matching a regexp anywhere in the buffer,
+ whereas an exact matcher finds the longest
+ string matching, but anchored to the
+ beginning of the buffer. */
+
+ /* Fields filled by dfaexec. */
+ state_num tralloc; /* Number of transition tables that have
+ slots so far, not counting trans[-1] and
+ trans[-2]. */
+ int trcount; /* Number of transition tables that have
+ been built, other than for initial
+ states. */
+ int min_trcount; /* Number of initial states. Equivalently,
+ the minimum state number for which trcount
+ counts transitions. */
+ state_num **trans; /* Transition tables for states that can
+ never accept. If the transitions for a
+ state have not yet been computed, or the
+ state could possibly accept, its entry in
+ this table is NULL. This points to two
+ past the start of the allocated array,
+ and trans[-1] and trans[-2] are always
+ NULL. */
+ state_num **fails; /* Transition tables after failing to accept
+ on a state that potentially could do so.
+ If trans[i] is non-null, fails[i] must
+ be null. */
+ int *success; /* Table of acceptance conditions used in
+ dfaexec and computed in build_state. */
+ state_num *newlines; /* Transitions on newlines. The entry for a
+ newline in any transition table is always
+ -1 so we can count lines without wasting
+ too many cycles. The transition for a
+ newline is stored separately and handled
+ as a special case. Newline is also used
+ as a sentinel at the end of the buffer. */
+ state_num initstate_notbol; /* Initial state for CTX_LETTER and CTX_NONE
+ context in multibyte locales, in which we
+ do not distinguish between their contexts,
+ as not supported word. */
+ position_set mb_follows; /* Follow set added by ANYCHAR on demand. */
+ state_num **mb_trans; /* Transition tables for states with
+ ANYCHAR. */
+ state_num mb_trcount; /* Number of transition tables for states with
+ ANYCHAR that have actually been built. */
+
+ /* Information derived from the locale. This is at the end so that
+ a quick memset need not clear it specially. */
+
+ /* dfaexec implementation. */
+ char *(*dfaexec) (struct dfa *, char const *, char *,
+ bool, size_t *, bool *);
+
+ /* The locale is simple, like the C locale. These locales can be
+ processed more efficiently, e.g., the relationship between lower-
+ and upper-case letters is 1-1. */
+ bool simple_locale;
+
+ /* Other cached information derived from the locale. */
+ struct localeinfo localeinfo;
+};
+
+/* Some macros for user access to dfa internals. */
+
+/* S could possibly be an accepting state of R. */
+#define ACCEPTING(s, r) ((r).states[s].constraint)
+
+/* STATE accepts in the specified context. */
+#define ACCEPTS_IN_CONTEXT(prev, curr, state, dfa) \
+ SUCCEEDS_IN_CONTEXT ((dfa).states[state].constraint, prev, curr)
+
+static void regexp (struct dfa *dfa);
+
+/* Store into *PWC the result of converting the leading bytes of the
+ multibyte buffer S of length N bytes, using D->localeinfo.sbctowc
+ and updating the conversion state in *D. On conversion error,
+ convert just a single byte, to WEOF. Return the number of bytes
+ converted.
+
+ This differs from mbrtowc (PWC, S, N, &D->mbs) as follows:
+
+ * PWC points to wint_t, not to wchar_t.
+ * The last arg is a dfa *D instead of merely a multibyte conversion
+ state D->mbs.
+ * N must be at least 1.
+ * S[N - 1] must be a sentinel byte.
+ * Shift encodings are not supported.
+ * The return value is always in the range 1..N.
+ * D->mbs is always valid afterwards.
+ * *PWC is always set to something. */
+static size_t
+mbs_to_wchar (wint_t *pwc, char const *s, size_t n, struct dfa *d)
+{
+ unsigned char uc = s[0];
+ wint_t wc = d->localeinfo.sbctowc[uc];
+
+ if (wc == WEOF)
+ {
+ wchar_t wch;
+ size_t nbytes = mbrtowc (&wch, s, n, &d->mbs);
+ if (0 < nbytes && nbytes < (size_t) -2)
+ {
+ *pwc = wch;
+ return nbytes;
+ }
+ memset (&d->mbs, 0, sizeof d->mbs);
+ }
+
+ *pwc = wc;
+ return 1;
+}
+
+#ifdef DEBUG
+
+static void
+prtok (token t)
+{
+ char const *s;
+
+ if (t < 0)
+ fprintf (stderr, "END");
+ else if (t < NOTCHAR)
+ {
+ unsigned int ch = t;
+ fprintf (stderr, "0x%02x", ch);
+ }
+ else
+ {
+ switch (t)
+ {
+ case EMPTY:
+ s = "EMPTY";
+ break;
+ case BACKREF:
+ s = "BACKREF";
+ break;
+ case BEGLINE:
+ s = "BEGLINE";
+ break;
+ case ENDLINE:
+ s = "ENDLINE";
+ break;
+ case BEGWORD:
+ s = "BEGWORD";
+ break;
+ case ENDWORD:
+ s = "ENDWORD";
+ break;
+ case LIMWORD:
+ s = "LIMWORD";
+ break;
+ case NOTLIMWORD:
+ s = "NOTLIMWORD";
+ break;
+ case QMARK:
+ s = "QMARK";
+ break;
+ case STAR:
+ s = "STAR";
+ break;
+ case PLUS:
+ s = "PLUS";
+ break;
+ case CAT:
+ s = "CAT";
+ break;
+ case OR:
+ s = "OR";
+ break;
+ case LPAREN:
+ s = "LPAREN";
+ break;
+ case RPAREN:
+ s = "RPAREN";
+ break;
+ case ANYCHAR:
+ s = "ANYCHAR";
+ break;
+ case MBCSET:
+ s = "MBCSET";
+ break;
+ default:
+ s = "CSET";
+ break;
+ }
+ fprintf (stderr, "%s", s);
+ }
+}
+#endif /* DEBUG */
+
+/* Stuff pertaining to charclasses. */
+
+static bool
+tstbit (unsigned int b, charclass const c)
+{
+ return c[b / CHARCLASS_WORD_BITS] >> b % CHARCLASS_WORD_BITS & 1;
+}
+
+static void
+setbit (unsigned int b, charclass c)
+{
+ c[b / CHARCLASS_WORD_BITS] |= (charclass_word) 1 << b % CHARCLASS_WORD_BITS;
+}
+
+static void
+clrbit (unsigned int b, charclass c)
+{
+ c[b / CHARCLASS_WORD_BITS] &= ~((charclass_word) 1
+ << b % CHARCLASS_WORD_BITS);
+}
+
+static void
+copyset (charclass const src, charclass dst)
+{
+ memcpy (dst, src, sizeof (charclass));
+}
+
+static void
+zeroset (charclass s)
+{
+ memset (s, 0, sizeof (charclass));
+}
+
+static void
+fillset (charclass s)
+{
+ int i;
+ for (i = 0; i < CHARCLASS_WORDS; i++)
+ s[i] = CHARCLASS_WORD_MASK;
+}
+
+static void
+notset (charclass s)
+{
+ int i;
+ for (i = 0; i < CHARCLASS_WORDS; ++i)
+ s[i] = CHARCLASS_WORD_MASK & ~s[i];
+}
+
+static bool
+equal (charclass const s1, charclass const s2)
+{
+ charclass_word w = 0;
+ int i;
+ for (i = 0; i < CHARCLASS_WORDS; i++)
+ w |= s1[i] ^ s2[i];
+ return w == 0;
+}
+
+static bool
+emptyset (charclass const s)
+{
+ charclass_word w = 0;
+ int i;
+ for (i = 0; i < CHARCLASS_WORDS; i++)
+ w |= s[i];
+ return w == 0;
+}
+
+/* Grow PA, which points to an array of *NITEMS items, and return the
+ location of the reallocated array, updating *NITEMS to reflect its
+ new size. The new array will contain at least NITEMS_INCR_MIN more
+ items, but will not contain more than NITEMS_MAX items total.
+ ITEM_SIZE is the size of each item, in bytes.
+
+ ITEM_SIZE and NITEMS_INCR_MIN must be positive. *NITEMS must be
+ nonnegative. If NITEMS_MAX is -1, it is treated as if it were
+ infinity.
+
+ If PA is null, then allocate a new array instead of reallocating
+ the old one.
+
+ Thus, to grow an array A without saving its old contents, do
+ { free (A); A = xpalloc (NULL, &AITEMS, ...); }. */
+
+static void *
+xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
+ ptrdiff_t nitems_max, ptrdiff_t item_size)
+{
+ ptrdiff_t n0 = *nitems;
+
+ /* The approximate size to use for initial small allocation
+ requests. This is the largest "small" request for the GNU C
+ library malloc. */
+ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
+
+ /* If the array is tiny, grow it to about (but no greater than)
+ DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%.
+ Adjust the growth according to three constraints: NITEMS_INCR_MIN,
+ NITEMS_MAX, and what the C language can represent safely. */
+
+ ptrdiff_t n, nbytes;
+ if (INT_ADD_WRAPV (n0, n0 >> 1, &n))
+ n = PTRDIFF_MAX;
+ if (0 <= nitems_max && nitems_max < n)
+ n = nitems_max;
+
+ ptrdiff_t adjusted_nbytes
+ = ((INT_MULTIPLY_WRAPV (n, item_size, &nbytes) || SIZE_MAX < nbytes)
+ ? MIN (PTRDIFF_MAX, SIZE_MAX)
+ : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0);
+ if (adjusted_nbytes)
+ {
+ n = adjusted_nbytes / item_size;
+ nbytes = adjusted_nbytes - adjusted_nbytes % item_size;
+ }
+
+ if (! pa)
+ *nitems = 0;
+ if (n - n0 < nitems_incr_min
+ && (INT_ADD_WRAPV (n0, nitems_incr_min, &n)
+ || (0 <= nitems_max && nitems_max < n)
+ || INT_MULTIPLY_WRAPV (n, item_size, &nbytes)))
+ xalloc_die ();
+ pa = xrealloc (pa, nbytes);
+ *nitems = n;
+ return pa;
+}
+
+/* Ensure that the array addressed by PA holds at least I + 1 items.
+ Either return PA, or reallocate the array and return its new address.
+ Although PA may be null, the returned value is never null.
+
+ The array holds *NITEMS items, where 0 <= I <= *NITEMS; *NITEMS
+ is updated on reallocation. If PA is null, *NITEMS must be zero.
+ Do not allocate more than NITEMS_MAX items total; -1 means no limit.
+ ITEM_SIZE is the size of one item; it must be positive.
+ Avoid O(N**2) behavior on arrays growing linearly. */
+static void *
+maybe_realloc (void *pa, ptrdiff_t i, ptrdiff_t *nitems,
+ ptrdiff_t nitems_max, ptrdiff_t item_size)
+{
+ if (i < *nitems)
+ return pa;
+ return xpalloc (pa, nitems, 1, nitems_max, item_size);
+}
+
+/* In DFA D, find the index of charclass S, or allocate a new one. */
+static ptrdiff_t
+charclass_index (struct dfa *d, charclass const s)
+{
+ ptrdiff_t i;
+
+ for (i = 0; i < d->cindex; ++i)
+ if (equal (s, d->charclasses[i]))
+ return i;
+ d->charclasses = maybe_realloc (d->charclasses, d->cindex, &d->calloc,
+ TOKEN_MAX - CSET, sizeof *d->charclasses);
+ ++d->cindex;
+ copyset (s, d->charclasses[i]);
+ return i;
+}
+
+static bool
+unibyte_word_constituent (struct dfa const *dfa, unsigned char c)
+{
+ return dfa->localeinfo.sbctowc[c] != WEOF && (isalnum (c) || (c) == '_');
+}
+
+static int
+char_context (struct dfa const *dfa, unsigned char c)
+{
+ if (c == dfa->syntax.eolbyte && !dfa->syntax.anchor)
+ return CTX_NEWLINE;
+ if (unibyte_word_constituent (dfa, c))
+ return CTX_LETTER;
+ return CTX_NONE;
+}
+
+/* Set a bit in the charclass for the given wchar_t. Do nothing if WC
+ is represented by a multi-byte sequence. Even for MB_CUR_MAX == 1,
+ this may happen when folding case in weird Turkish locales where
+ dotless i/dotted I are not included in the chosen character set.
+ Return whether a bit was set in the charclass. */
+static bool
+setbit_wc (wint_t wc, charclass c)
+{
+ int b = wctob (wc);
+ if (b == EOF)
+ return false;
+
+ setbit (b, c);
+ return true;
+}
+
+/* Set a bit for B and its case variants in the charclass C.
+ MB_CUR_MAX must be 1. */
+static void
+setbit_case_fold_c (int b, charclass c)
+{
+ int ub = toupper (b);
+ int i;
+ for (i = 0; i < NOTCHAR; i++)
+ if (toupper (i) == ub)
+ setbit (i, c);
+}
+
+/* Return true if the locale compatible with the C locale. */
+
+static bool
+using_simple_locale (bool multibyte)
+{
+ /* The native character set is known to be compatible with
+ the C locale. The following test isn't perfect, but it's good
+ enough in practice, as only ASCII and EBCDIC are in common use
+ and this test correctly accepts ASCII and rejects EBCDIC. */
+ enum { native_c_charset =
+ ('\b' == 8 && '\t' == 9 && '\n' == 10 && '\v' == 11 && '\f' == 12
+ && '\r' == 13 && ' ' == 32 && '!' == 33 && '"' == 34 && '#' == 35
+ && '%' == 37 && '&' == 38 && '\'' == 39 && '(' == 40 && ')' == 41
+ && '*' == 42 && '+' == 43 && ',' == 44 && '-' == 45 && '.' == 46
+ && '/' == 47 && '0' == 48 && '9' == 57 && ':' == 58 && ';' == 59
+ && '<' == 60 && '=' == 61 && '>' == 62 && '?' == 63 && 'A' == 65
+ && 'Z' == 90 && '[' == 91 && '\\' == 92 && ']' == 93 && '^' == 94
+ && '_' == 95 && 'a' == 97 && 'z' == 122 && '{' == 123 && '|' == 124
+ && '}' == 125 && '~' == 126)
+ };
+
+ if (!native_c_charset || multibyte)
+ return false;
+ else
+ {
+ /* Treat C and POSIX locales as being compatible. Also, treat
+ errors as compatible, as these are invariably from stubs. */
+ char const *loc = setlocale (LC_ALL, NULL);
+ return !loc || STREQ (loc, "C") || STREQ (loc, "POSIX");
+ }
+}
+
+/* Fetch the next lexical input character. Set C (of type int) to the
+ next input byte, except set C to EOF if the input is a multibyte
+ character of length greater than 1. Set WC (of type wint_t) to the
+ value of the input if it is a valid multibyte character (possibly
+ of length 1); otherwise set WC to WEOF. If there is no more input,
+ report EOFERR if EOFERR is not null, and return lasttok = END
+ otherwise. */
+# define FETCH_WC(dfa, c, wc, eoferr) \
+ do { \
+ if (! (dfa)->lex.left) \
+ { \
+ if ((eoferr) != 0) \
+ dfaerror (eoferr); \
+ else \
+ return (dfa)->lex.lasttok = END; \
+ } \
+ else \
+ { \
+ wint_t _wc; \
+ size_t nbytes = mbs_to_wchar (&_wc, (dfa)->lex.ptr, \
+ (dfa)->lex.left, dfa); \
+ (dfa)->lex.cur_mb_len = nbytes; \
+ (wc) = _wc; \
+ (c) = nbytes == 1 ? to_uchar ((dfa)->lex.ptr[0]) : EOF; \
+ (dfa)->lex.ptr += nbytes; \
+ (dfa)->lex.left -= nbytes; \
+ } \
+ } while (false)
+
+typedef int predicate (int);
+
+/* The following list maps the names of the Posix named character classes
+ to predicate functions that determine whether a given character is in
+ the class. The leading [ has already been eaten by the lexical
+ analyzer. */
+struct dfa_ctype
+{
+ const char *name;
+ predicate *func;
+ bool single_byte_only;
+};
+
+static const struct dfa_ctype prednames[] = {
+ {"alpha", isalpha, false},
+ {"upper", isupper, false},
+ {"lower", islower, false},
+ {"digit", isdigit, true},
+ {"xdigit", isxdigit, false},
+ {"space", isspace, false},
+ {"punct", ispunct, false},
+ {"alnum", isalnum, false},
+ {"print", isprint, false},
+ {"graph", isgraph, false},
+ {"cntrl", iscntrl, false},
+ {"blank", isblank, false},
+ {NULL, NULL, false}
+};
+
+static const struct dfa_ctype *_GL_ATTRIBUTE_PURE
+find_pred (const char *str)
+{
+ unsigned int i;
+ for (i = 0; prednames[i].name; ++i)
+ if (STREQ (str, prednames[i].name))
+ return &prednames[i];
+ return NULL;
+}
+
+/* Multibyte character handling sub-routine for lex.
+ Parse a bracket expression and build a struct mb_char_classes. */
+static token
+parse_bracket_exp (struct dfa *dfa)
+{
+ bool invert;
+ int c, c1, c2;
+ charclass ccl;
+
+ /* This is a bracket expression that dfaexec is known to
+ process correctly. */
+ bool known_bracket_exp = true;
+
+ /* Used to warn about [:space:].
+ Bit 0 = first character is a colon.
+ Bit 1 = last character is a colon.
+ Bit 2 = includes any other character but a colon.
+ Bit 3 = includes ranges, char/equiv classes or collation elements. */
+ int colon_warning_state;
+
+ wint_t wc;
+ wint_t wc2;
+ wint_t wc1 = 0;
+
+ /* Work area to build a mb_char_classes. */
+ struct mb_char_classes *work_mbc;
+ ptrdiff_t chars_al;
+
+ chars_al = 0;
+ if (dfa->localeinfo.multibyte)
+ {
+ dfa->mbcsets = maybe_realloc (dfa->mbcsets, dfa->nmbcsets,
+ &dfa->mbcsets_alloc, -1,
+ sizeof *dfa->mbcsets);
+
+ /* dfa->multibyte_prop[] hold the index of dfa->mbcsets.
+ We will update dfa->multibyte_prop[] in addtok, because we can't
+ decide the index in dfa->tokens[]. */
+
+ /* Initialize work area. */
+ work_mbc = &dfa->mbcsets[dfa->nmbcsets++];
+ memset (work_mbc, 0, sizeof *work_mbc);
+ }
+ else
+ work_mbc = NULL;
+
+ memset (ccl, 0, sizeof ccl);
+ FETCH_WC (dfa, c, wc, _("unbalanced ["));
+ if (c == '^')
+ {
+ FETCH_WC (dfa, c, wc, _("unbalanced ["));
+ invert = true;
+ known_bracket_exp = dfa->simple_locale;
+ }
+ else
+ invert = false;
+
+ colon_warning_state = (c == ':');
+ do
+ {
+ c1 = NOTCHAR; /* Mark c1 as not initialized. */
+ colon_warning_state &= ~2;
+
+ /* Note that if we're looking at some other [:...:] construct,
+ we just treat it as a bunch of ordinary characters. We can do
+ this because we assume regex has checked for syntax errors before
+ dfa is ever called. */
+ if (c == '[')
+ {
+ FETCH_WC (dfa, c1, wc1, _("unbalanced ["));
+
+ if ((c1 == ':' && (dfa->syntax.syntax_bits & RE_CHAR_CLASSES))
+ || c1 == '.' || c1 == '=')
+ {
+ enum { MAX_BRACKET_STRING_LEN = 32 };
+ char str[MAX_BRACKET_STRING_LEN + 1];
+ size_t len = 0;
+ for (;;)
+ {
+ FETCH_WC (dfa, c, wc, _("unbalanced ["));
+ if (dfa->lex.left == 0
+ || (c == c1 && dfa->lex.ptr[0] == ']'))
+ break;
+ if (len < MAX_BRACKET_STRING_LEN)
+ str[len++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[len] = '\0';
+
+ /* Fetch bracket. */
+ FETCH_WC (dfa, c, wc, _("unbalanced ["));
+ if (c1 == ':')
+ /* Build character class. POSIX allows character
+ classes to match multicharacter collating elements,
+ but the regex code does not support that, so do not
+ worry about that possibility. */
+ {
+ char const *class
+ = (dfa->syntax.case_fold && (STREQ (str, "upper")
+ || STREQ (str, "lower"))
+ ? "alpha" : str);
+ const struct dfa_ctype *pred = find_pred (class);
+ if (!pred)
+ dfaerror (_("invalid character class"));
+
+ if (dfa->localeinfo.multibyte && !pred->single_byte_only)
+ known_bracket_exp = false;
+ else
+ for (c2 = 0; c2 < NOTCHAR; ++c2)
+ if (pred->func (c2))
+ setbit (c2, ccl);
+ }
+ else
+ known_bracket_exp = false;
+
+ colon_warning_state |= 8;
+
+ /* Fetch new lookahead character. */
+ FETCH_WC (dfa, c1, wc1, _("unbalanced ["));
+ continue;
+ }
+
+ /* We treat '[' as a normal character here. c/c1/wc/wc1
+ are already set up. */
+ }
+
+ if (c == '\\' && (dfa->syntax.syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS))
+ FETCH_WC (dfa, c, wc, _("unbalanced ["));
+
+ if (c1 == NOTCHAR)
+ FETCH_WC (dfa, c1, wc1, _("unbalanced ["));
+
+ if (c1 == '-')
+ /* build range characters. */
+ {
+ FETCH_WC (dfa, c2, wc2, _("unbalanced ["));
+
+ /* A bracket expression like [a-[.aa.]] matches an unknown set.
+ Treat it like [-a[.aa.]] while parsing it, and
+ remember that the set is unknown. */
+ if (c2 == '[' && dfa->lex.ptr[0] == '.')
+ {
+ known_bracket_exp = false;
+ c2 = ']';
+ }
+
+ if (c2 == ']')
+ {
+ /* In the case [x-], the - is an ordinary hyphen,
+ which is left in c1, the lookahead character. */
+ dfa->lex.ptr -= dfa->lex.cur_mb_len;
+ dfa->lex.left += dfa->lex.cur_mb_len;
+ }
+ else
+ {
+ if (c2 == '\\' && (dfa->syntax.syntax_bits
+ & RE_BACKSLASH_ESCAPE_IN_LISTS))
+ FETCH_WC (dfa, c2, wc2, _("unbalanced ["));
+
+ colon_warning_state |= 8;
+ FETCH_WC (dfa, c1, wc1, _("unbalanced ["));
+
+ /* Treat [x-y] as a range if x != y. */
+ if (wc != wc2 || wc == WEOF)
+ {
+ if (dfa->localeinfo.multibyte)
+ known_bracket_exp = false;
+ else if (dfa->simple_locale)
+ {
+ int ci;
+ for (ci = c; ci <= c2; ci++)
+ setbit (ci, ccl);
+ if (dfa->syntax.case_fold)
+ {
+ int uc = toupper (c);
+ int uc2 = toupper (c2);
+ for (ci = 0; ci < NOTCHAR; ci++)
+ {
+ int uci = toupper (ci);
+ if (uc <= uci && uci <= uc2)
+ setbit (ci, ccl);
+ }
+ }
+ }
+ else
+ known_bracket_exp = false;
+
+ continue;
+ }
+ }
+ }
+
+ colon_warning_state |= (c == ':') ? 2 : 4;
+
+ if (!dfa->localeinfo.multibyte)
+ {
+ if (dfa->syntax.case_fold)
+ setbit_case_fold_c (c, ccl);
+ else
+ setbit (c, ccl);
+ continue;
+ }
+
+ if (wc == WEOF)
+ known_bracket_exp = false;
+ else
+ {
+ wchar_t folded[CASE_FOLDED_BUFSIZE + 1];
+ unsigned int i;
+ unsigned int n = (dfa->syntax.case_fold
+ ? case_folded_counterparts (wc, folded + 1) + 1
+ : 1);
+ folded[0] = wc;
+ for (i = 0; i < n; i++)
+ if (!setbit_wc (folded[i], ccl))
+ {
+ work_mbc->chars
+ = maybe_realloc (work_mbc->chars, work_mbc->nchars,
+ &chars_al, -1, sizeof *work_mbc->chars);
+ work_mbc->chars[work_mbc->nchars++] = folded[i];
+ }
+ }
+ }
+ while ((wc = wc1, (c = c1) != ']'));
+
+ if (colon_warning_state == 7)
+ dfawarn (_("character class syntax is [[:space:]], not [:space:]"));
+
+ if (! known_bracket_exp)
+ return BACKREF;
+
+ if (dfa->localeinfo.multibyte)
+ {
+ work_mbc->invert = invert;
+ work_mbc->cset = emptyset (ccl) ? -1 : charclass_index (dfa, ccl);
+ return MBCSET;
+ }
+
+ if (invert)
+ {
+ assert (!dfa->localeinfo.multibyte);
+ notset (ccl);
+ if (dfa->syntax.syntax_bits & RE_HAT_LISTS_NOT_NEWLINE)
+ clrbit ('\n', ccl);
+ }
+
+ return CSET + charclass_index (dfa, ccl);
+}
+
+struct lexptr
+{
+ char const *ptr;
+ size_t left;
+};
+
+static void
+push_lex_state (struct dfa *dfa, struct lexptr *ls, char const *s)
+{
+ ls->ptr = dfa->lex.ptr;
+ ls->left = dfa->lex.left;
+ dfa->lex.ptr = s;
+ dfa->lex.left = strlen (s);
+}
+
+static void
+pop_lex_state (struct dfa *dfa, struct lexptr const *ls)
+{
+ dfa->lex.ptr = ls->ptr;
+ dfa->lex.left = ls->left;
+}
+
+static token
+lex (struct dfa *dfa)
+{
+ int c, c2;
+ bool backslash = false;
+ charclass ccl;
+ int i;
+
+ /* Basic plan: We fetch a character. If it's a backslash,
+ we set the backslash flag and go through the loop again.
+ On the plus side, this avoids having a duplicate of the
+ main switch inside the backslash case. On the minus side,
+ it means that just about every case begins with
+ "if (backslash) ...". */
+ for (i = 0; i < 2; ++i)
+ {
+ FETCH_WC (dfa, c, dfa->lex.wctok, NULL);
+
+ switch (c)
+ {
+ case '\\':
+ if (backslash)
+ goto normal_char;
+ if (dfa->lex.left == 0)
+ dfaerror (_("unfinished \\ escape"));
+ backslash = true;
+ break;
+
+ case '^':
+ if (backslash)
+ goto normal_char;
+ if (dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_ANCHORS
+ || dfa->lex.lasttok == END || dfa->lex.lasttok == LPAREN
+ || dfa->lex.lasttok == OR)
+ return dfa->lex.lasttok = BEGLINE;
+ goto normal_char;
+
+ case '$':
+ if (backslash)
+ goto normal_char;
+ if (dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_ANCHORS
+ || dfa->lex.left == 0
+ || ((dfa->lex.left
+ > !(dfa->syntax.syntax_bits & RE_NO_BK_PARENS))
+ && (dfa->lex.ptr[!(dfa->syntax.syntax_bits & RE_NO_BK_PARENS)
+ & (dfa->lex.ptr[0] == '\\')]
+ == ')'))
+ || ((dfa->lex.left
+ > !(dfa->syntax.syntax_bits & RE_NO_BK_VBAR))
+ && (dfa->lex.ptr[!(dfa->syntax.syntax_bits & RE_NO_BK_VBAR)
+ & (dfa->lex.ptr[0] == '\\')]
+ == '|'))
+ || ((dfa->syntax.syntax_bits & RE_NEWLINE_ALT)
+ && dfa->lex.left > 0 && dfa->lex.ptr[0] == '\n'))
+ return dfa->lex.lasttok = ENDLINE;
+ goto normal_char;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_BK_REFS))
+ {
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = BACKREF;
+ }
+ goto normal_char;
+
+ case '`':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ {
+ /* FIXME: should be beginning of string */
+ return dfa->lex.lasttok = BEGLINE;
+ }
+ goto normal_char;
+
+ case '\'':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ {
+ /* FIXME: should be end of string */
+ return dfa->lex.lasttok = ENDLINE;
+ }
+ goto normal_char;
+
+ case '<':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ return dfa->lex.lasttok = BEGWORD;
+ goto normal_char;
+
+ case '>':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ return dfa->lex.lasttok = ENDWORD;
+ goto normal_char;
+
+ case 'b':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ return dfa->lex.lasttok = LIMWORD;
+ goto normal_char;
+
+ case 'B':
+ if (backslash && !(dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ return dfa->lex.lasttok = NOTLIMWORD;
+ goto normal_char;
+
+ case '?':
+ if (dfa->syntax.syntax_bits & RE_LIMITED_OPS)
+ goto normal_char;
+ if (backslash != ((dfa->syntax.syntax_bits & RE_BK_PLUS_QM) != 0))
+ goto normal_char;
+ if (!(dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_OPS)
+ && dfa->lex.laststart)
+ goto normal_char;
+ return dfa->lex.lasttok = QMARK;
+
+ case '*':
+ if (backslash)
+ goto normal_char;
+ if (!(dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_OPS)
+ && dfa->lex.laststart)
+ goto normal_char;
+ return dfa->lex.lasttok = STAR;
+
+ case '+':
+ if (dfa->syntax.syntax_bits & RE_LIMITED_OPS)
+ goto normal_char;
+ if (backslash != ((dfa->syntax.syntax_bits & RE_BK_PLUS_QM) != 0))
+ goto normal_char;
+ if (!(dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_OPS)
+ && dfa->lex.laststart)
+ goto normal_char;
+ return dfa->lex.lasttok = PLUS;
+
+ case '{':
+ if (!(dfa->syntax.syntax_bits & RE_INTERVALS))
+ goto normal_char;
+ if (backslash != ((dfa->syntax.syntax_bits & RE_NO_BK_BRACES) == 0))
+ goto normal_char;
+ if (!(dfa->syntax.syntax_bits & RE_CONTEXT_INDEP_OPS)
+ && dfa->lex.laststart)
+ goto normal_char;
+
+ /* Cases:
+ {M} - exact count
+ {M,} - minimum count, maximum is infinity
+ {,N} - 0 through N
+ {,} - 0 to infinity (same as '*')
+ {M,N} - M through N */
+ {
+ char const *p = dfa->lex.ptr;
+ char const *lim = p + dfa->lex.left;
+ dfa->lex.minrep = dfa->lex.maxrep = -1;
+ for (; p != lim && ISASCIIDIGIT (*p); p++)
+ dfa->lex.minrep = (dfa->lex.minrep < 0
+ ? *p - '0'
+ : MIN (RE_DUP_MAX + 1,
+ dfa->lex.minrep * 10 + *p - '0'));
+ if (p != lim)
+ {
+ if (*p != ',')
+ dfa->lex.maxrep = dfa->lex.minrep;
+ else
+ {
+ if (dfa->lex.minrep < 0)
+ dfa->lex.minrep = 0;
+ while (++p != lim && ISASCIIDIGIT (*p))
+ dfa->lex.maxrep
+ = (dfa->lex.maxrep < 0
+ ? *p - '0'
+ : MIN (RE_DUP_MAX + 1,
+ dfa->lex.maxrep * 10 + *p - '0'));
+ }
+ }
+ if (! ((! backslash || (p != lim && *p++ == '\\'))
+ && p != lim && *p++ == '}'
+ && 0 <= dfa->lex.minrep
+ && (dfa->lex.maxrep < 0
+ || dfa->lex.minrep <= dfa->lex.maxrep)))
+ {
+ if (dfa->syntax.syntax_bits & RE_INVALID_INTERVAL_ORD)
+ goto normal_char;
+ dfaerror (_("invalid content of \\{\\}"));
+ }
+ if (RE_DUP_MAX < dfa->lex.maxrep)
+ dfaerror (_("regular expression too big"));
+ dfa->lex.ptr = p;
+ dfa->lex.left = lim - p;
+ }
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = REPMN;
+
+ case '|':
+ if (dfa->syntax.syntax_bits & RE_LIMITED_OPS)
+ goto normal_char;
+ if (backslash != ((dfa->syntax.syntax_bits & RE_NO_BK_VBAR) == 0))
+ goto normal_char;
+ dfa->lex.laststart = true;
+ return dfa->lex.lasttok = OR;
+
+ case '\n':
+ if (dfa->syntax.syntax_bits & RE_LIMITED_OPS
+ || backslash || !(dfa->syntax.syntax_bits & RE_NEWLINE_ALT))
+ goto normal_char;
+ dfa->lex.laststart = true;
+ return dfa->lex.lasttok = OR;
+
+ case '(':
+ if (backslash != ((dfa->syntax.syntax_bits & RE_NO_BK_PARENS) == 0))
+ goto normal_char;
+ dfa->lex.parens++;
+ dfa->lex.laststart = true;
+ return dfa->lex.lasttok = LPAREN;
+
+ case ')':
+ if (backslash != ((dfa->syntax.syntax_bits & RE_NO_BK_PARENS) == 0))
+ goto normal_char;
+ if (dfa->lex.parens == 0
+ && dfa->syntax.syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD)
+ goto normal_char;
+ dfa->lex.parens--;
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = RPAREN;
+
+ case '.':
+ if (backslash)
+ goto normal_char;
+ if (dfa->canychar == (size_t) -1)
+ {
+ fillset (ccl);
+ if (!(dfa->syntax.syntax_bits & RE_DOT_NEWLINE))
+ clrbit ('\n', ccl);
+ if (dfa->syntax.syntax_bits & RE_DOT_NOT_NULL)
+ clrbit ('\0', ccl);
+ if (dfa->localeinfo.multibyte)
+ for (c2 = 0; c2 < NOTCHAR; c2++)
+ if (dfa->localeinfo.sbctowc[c2] == WEOF)
+ clrbit (c2, ccl);
+ dfa->canychar = charclass_index (dfa, ccl);
+ }
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = (dfa->localeinfo.multibyte
+ ? ANYCHAR
+ : CSET + dfa->canychar);
+
+ case 's':
+ case 'S':
+ if (!backslash || (dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ goto normal_char;
+ if (!dfa->localeinfo.multibyte)
+ {
+ zeroset (ccl);
+ for (c2 = 0; c2 < NOTCHAR; ++c2)
+ if (isspace (c2))
+ setbit (c2, ccl);
+ if (c == 'S')
+ notset (ccl);
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = CSET + charclass_index (dfa, ccl);
+ }
+
+ /* FIXME: see if optimizing this, as is done with ANYCHAR and
+ add_utf8_anychar, makes sense. */
+
+ /* \s and \S are documented to be equivalent to [[:space:]] and
+ [^[:space:]] respectively, so tell the lexer to process those
+ strings, each minus its "already processed" '['. */
+ {
+ struct lexptr ls;
+ push_lex_state (dfa, &ls, &"^[:space:]]"[c == 's']);
+ dfa->lex.lasttok = parse_bracket_exp (dfa);
+ pop_lex_state (dfa, &ls);
+ }
+
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok;
+
+ case 'w':
+ case 'W':
+ if (!backslash || (dfa->syntax.syntax_bits & RE_NO_GNU_OPS))
+ goto normal_char;
+
+ if (!dfa->localeinfo.multibyte)
+ {
+ zeroset (ccl);
+ for (c2 = 0; c2 < NOTCHAR; ++c2)
+ if (dfa->syntax.sbit[c2] == CTX_LETTER)
+ setbit (c2, ccl);
+ if (c == 'W')
+ notset (ccl);
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = CSET + charclass_index (dfa, ccl);
+ }
+
+ /* FIXME: see if optimizing this, as is done with ANYCHAR and
+ add_utf8_anychar, makes sense. */
+
+ /* \w and \W are documented to be equivalent to [_[:alnum:]] and
+ [^_[:alnum:]] respectively, so tell the lexer to process those
+ strings, each minus its "already processed" '['. */
+ {
+ struct lexptr ls;
+ push_lex_state (dfa, &ls, &"^_[:alnum:]]"[c == 'w']);
+ dfa->lex.lasttok = parse_bracket_exp (dfa);
+ pop_lex_state (dfa, &ls);
+ }
+
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok;
+
+ case '[':
+ if (backslash)
+ goto normal_char;
+ dfa->lex.laststart = false;
+ return dfa->lex.lasttok = parse_bracket_exp (dfa);
+
+ default:
+ normal_char:
+ dfa->lex.laststart = false;
+ /* For multibyte character sets, folding is done in atom. Always
+ return WCHAR. */
+ if (dfa->localeinfo.multibyte)
+ return dfa->lex.lasttok = WCHAR;
+
+ if (dfa->syntax.case_fold && isalpha (c))
+ {
+ zeroset (ccl);
+ setbit_case_fold_c (c, ccl);
+ return dfa->lex.lasttok = CSET + charclass_index (dfa, ccl);
+ }
+
+ return dfa->lex.lasttok = c;
+ }
+ }
+
+ /* The above loop should consume at most a backslash
+ and some other character. */
+ abort ();
+ return END; /* keeps pedantic compilers happy. */
+}
+
+static void
+addtok_mb (struct dfa *dfa, token t, int mbprop)
+{
+ if (dfa->talloc == dfa->tindex)
+ {
+ dfa->tokens = x2nrealloc (dfa->tokens, &dfa->talloc,
+ sizeof *dfa->tokens);
+ if (dfa->localeinfo.multibyte)
+ dfa->multibyte_prop = xnrealloc (dfa->multibyte_prop, dfa->talloc,
+ sizeof *dfa->multibyte_prop);
+ }
+ if (dfa->localeinfo.multibyte)
+ dfa->multibyte_prop[dfa->tindex] = mbprop;
+ dfa->tokens[dfa->tindex++] = t;
+
+ switch (t)
+ {
+ case QMARK:
+ case STAR:
+ case PLUS:
+ break;
+
+ case CAT:
+ case OR:
+ dfa->parse.depth--;
+ break;
+
+ case BACKREF:
+ dfa->fast = false;
+ /* fallthrough */
+ default:
+ dfa->nleaves++;
+ /* fallthrough */
+ case EMPTY:
+ dfa->parse.depth++;
+ break;
+ }
+ if (dfa->parse.depth > dfa->depth)
+ dfa->depth = dfa->parse.depth;
+}
+
+static void addtok_wc (struct dfa *dfa, wint_t wc);
+
+/* Add the given token to the parse tree, maintaining the depth count and
+ updating the maximum depth if necessary. */
+static void
+addtok (struct dfa *dfa, token t)
+{
+ if (dfa->localeinfo.multibyte && t == MBCSET)
+ {
+ bool need_or = false;
+ struct mb_char_classes *work_mbc = &dfa->mbcsets[dfa->nmbcsets - 1];
+ ptrdiff_t i;
+
+ /* Extract wide characters into alternations for better performance.
+ This does not require UTF-8. */
+ for (i = 0; i < work_mbc->nchars; i++)
+ {
+ addtok_wc (dfa, work_mbc->chars[i]);
+ if (need_or)
+ addtok (dfa, OR);
+ need_or = true;
+ }
+ work_mbc->nchars = 0;
+
+ /* Characters have been handled above, so it is possible
+ that the mbcset is empty now. Do nothing in that case. */
+ if (work_mbc->cset != -1)
+ {
+ addtok (dfa, CSET + work_mbc->cset);
+ if (need_or)
+ addtok (dfa, OR);
+ }
+ }
+ else
+ {
+ addtok_mb (dfa, t, 3);
+ }
+}
+
+/* We treat a multibyte character as a single atom, so that DFA
+ can treat a multibyte character as a single expression.
+
+ e.g., we construct the following tree from "<mb1><mb2>".
+ <mb1(1st-byte)><mb1(2nd-byte)><CAT><mb1(3rd-byte)><CAT>
+ <mb2(1st-byte)><mb2(2nd-byte)><CAT><mb2(3rd-byte)><CAT><CAT> */
+static void
+addtok_wc (struct dfa *dfa, wint_t wc)
+{
+ unsigned char buf[MB_LEN_MAX];
+ mbstate_t s = { 0 };
+ int i;
+ size_t stored_bytes = wcrtomb ((char *) buf, wc, &s);
+
+ if (stored_bytes != (size_t) -1)
+ dfa->lex.cur_mb_len = stored_bytes;
+ else
+ {
+ /* This is merely stop-gap. buf[0] is undefined, yet skipping
+ the addtok_mb call altogether can corrupt the heap. */
+ dfa->lex.cur_mb_len = 1;
+ buf[0] = 0;
+ }
+
+ addtok_mb (dfa, buf[0], dfa->lex.cur_mb_len == 1 ? 3 : 1);
+ for (i = 1; i < dfa->lex.cur_mb_len; i++)
+ {
+ addtok_mb (dfa, buf[i], i == dfa->lex.cur_mb_len - 1 ? 2 : 0);
+ addtok (dfa, CAT);
+ }
+}
+
+static void
+add_utf8_anychar (struct dfa *dfa)
+{
+ static charclass const utf8_classes[5] = {
+ /* 80-bf: non-leading bytes. */
+ CHARCLASS_INIT (0, 0, 0, 0, 0xffffffff, 0xffffffff, 0, 0),
+
+ /* 00-7f: 1-byte sequence. */
+ CHARCLASS_INIT (0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0, 0, 0, 0),
+
+ /* c2-df: 2-byte sequence. */
+ CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0xfffffffc, 0),
+
+ /* e0-ef: 3-byte sequence. */
+ CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0, 0xffff),
+
+ /* f0-f7: 4-byte sequence. */
+ CHARCLASS_INIT (0, 0, 0, 0, 0, 0, 0, 0xff0000)
+ };
+ const unsigned int n = sizeof (utf8_classes) / sizeof (utf8_classes[0]);
+ unsigned int i;
+
+ /* Define the five character classes that are needed below. */
+ if (dfa->utf8_anychar_classes[0] == 0)
+ for (i = 0; i < n; i++)
+ {
+ charclass c;
+ copyset (utf8_classes[i], c);
+ if (i == 1)
+ {
+ if (!(dfa->syntax.syntax_bits & RE_DOT_NEWLINE))
+ clrbit ('\n', c);
+ if (dfa->syntax.syntax_bits & RE_DOT_NOT_NULL)
+ clrbit ('\0', c);
+ }
+ dfa->utf8_anychar_classes[i] = CSET + charclass_index (dfa, c);
+ }
+
+ /* A valid UTF-8 character is
+
+ ([0x00-0x7f]
+ |[0xc2-0xdf][0x80-0xbf]
+ |[0xe0-0xef[0x80-0xbf][0x80-0xbf]
+ |[0xf0-f7][0x80-0xbf][0x80-0xbf][0x80-0xbf])
+
+ which I'll write more concisely "B|CA|DAA|EAAA". Factor the [0x00-0x7f]
+ and you get "B|(C|(D|EA)A)A". And since the token buffer is in reverse
+ Polish notation, you get "B C D E A CAT OR A CAT OR A CAT OR". */
+ for (i = 1; i < n; i++)
+ addtok (dfa, dfa->utf8_anychar_classes[i]);
+ while (--i > 1)
+ {
+ addtok (dfa, dfa->utf8_anychar_classes[0]);
+ addtok (dfa, CAT);
+ addtok (dfa, OR);
+ }
+}
+
+/* The grammar understood by the parser is as follows.
+
+ regexp:
+ regexp OR branch
+ branch
+
+ branch:
+ branch closure
+ closure
+
+ closure:
+ closure QMARK
+ closure STAR
+ closure PLUS
+ closure REPMN
+ atom
+
+ atom:
+ <normal character>
+ <multibyte character>
+ ANYCHAR
+ MBCSET
+ CSET
+ BACKREF
+ BEGLINE
+ ENDLINE
+ BEGWORD
+ ENDWORD
+ LIMWORD
+ NOTLIMWORD
+ LPAREN regexp RPAREN
+ <empty>
+
+ The parser builds a parse tree in postfix form in an array of tokens. */
+
+static void
+atom (struct dfa *dfa)
+{
+ if (dfa->parse.tok == WCHAR)
+ {
+ if (dfa->lex.wctok == WEOF)
+ addtok (dfa, BACKREF);
+ else
+ {
+ addtok_wc (dfa, dfa->lex.wctok);
+
+ if (dfa->syntax.case_fold)
+ {
+ wchar_t folded[CASE_FOLDED_BUFSIZE];
+ unsigned int i, n = case_folded_counterparts (dfa->lex.wctok,
+ folded);
+ for (i = 0; i < n; i++)
+ {
+ addtok_wc (dfa, folded[i]);
+ addtok (dfa, OR);
+ }
+ }
+ }
+
+ dfa->parse.tok = lex (dfa);
+ }
+ else if (dfa->parse.tok == ANYCHAR && dfa->localeinfo.using_utf8)
+ {
+ /* For UTF-8 expand the period to a series of CSETs that define a valid
+ UTF-8 character. This avoids using the slow multibyte path. I'm
+ pretty sure it would be both profitable and correct to do it for
+ any encoding; however, the optimization must be done manually as
+ it is done above in add_utf8_anychar. So, let's start with
+ UTF-8: it is the most used, and the structure of the encoding
+ makes the correctness more obvious. */
+ add_utf8_anychar (dfa);
+ dfa->parse.tok = lex (dfa);
+ }
+ else if ((0 <= dfa->parse.tok && dfa->parse.tok < NOTCHAR)
+ || dfa->parse.tok >= CSET || dfa->parse.tok == BACKREF
+ || dfa->parse.tok == BEGLINE || dfa->parse.tok == ENDLINE
+ || dfa->parse.tok == BEGWORD || dfa->parse.tok == ANYCHAR
+ || dfa->parse.tok == MBCSET || dfa->parse.tok == ENDWORD
+ || dfa->parse.tok == LIMWORD || dfa->parse.tok == NOTLIMWORD)
+ {
+ addtok (dfa, dfa->parse.tok);
+ dfa->parse.tok = lex (dfa);
+ }
+ else if (dfa->parse.tok == LPAREN)
+ {
+ dfa->parse.tok = lex (dfa);
+ regexp (dfa);
+ if (dfa->parse.tok != RPAREN)
+ dfaerror (_("unbalanced ("));
+ dfa->parse.tok = lex (dfa);
+ }
+ else
+ addtok (dfa, EMPTY);
+}
+
+/* Return the number of tokens in the given subexpression. */
+static size_t _GL_ATTRIBUTE_PURE
+nsubtoks (struct dfa const *dfa, size_t tindex)
+{
+ size_t ntoks1;
+
+ switch (dfa->tokens[tindex - 1])
+ {
+ default:
+ return 1;
+ case QMARK:
+ case STAR:
+ case PLUS:
+ return 1 + nsubtoks (dfa, tindex - 1);
+ case CAT:
+ case OR:
+ ntoks1 = nsubtoks (dfa, tindex - 1);
+ return 1 + ntoks1 + nsubtoks (dfa, tindex - 1 - ntoks1);
+ }
+}
+
+/* Copy the given subexpression to the top of the tree. */
+static void
+copytoks (struct dfa *dfa, size_t tindex, size_t ntokens)
+{
+ size_t i;
+
+ if (dfa->localeinfo.multibyte)
+ for (i = 0; i < ntokens; ++i)
+ addtok_mb (dfa, dfa->tokens[tindex + i], dfa->multibyte_prop[tindex + i]);
+ else
+ for (i = 0; i < ntokens; ++i)
+ addtok_mb (dfa, dfa->tokens[tindex + i], 3);
+}
+
+static void
+closure (struct dfa *dfa)
+{
+ int i;
+ size_t tindex, ntokens;
+
+ atom (dfa);
+ while (dfa->parse.tok == QMARK || dfa->parse.tok == STAR
+ || dfa->parse.tok == PLUS || dfa->parse.tok == REPMN)
+ if (dfa->parse.tok == REPMN && (dfa->lex.minrep || dfa->lex.maxrep))
+ {
+ ntokens = nsubtoks (dfa, dfa->tindex);
+ tindex = dfa->tindex - ntokens;
+ if (dfa->lex.maxrep < 0)
+ addtok (dfa, PLUS);
+ if (dfa->lex.minrep == 0)
+ addtok (dfa, QMARK);
+ for (i = 1; i < dfa->lex.minrep; i++)
+ {
+ copytoks (dfa, tindex, ntokens);
+ addtok (dfa, CAT);
+ }
+ for (; i < dfa->lex.maxrep; i++)
+ {
+ copytoks (dfa, tindex, ntokens);
+ addtok (dfa, QMARK);
+ addtok (dfa, CAT);
+ }
+ dfa->parse.tok = lex (dfa);
+ }
+ else if (dfa->parse.tok == REPMN)
+ {
+ dfa->tindex -= nsubtoks (dfa, dfa->tindex);
+ dfa->parse.tok = lex (dfa);
+ closure (dfa);
+ }
+ else
+ {
+ addtok (dfa, dfa->parse.tok);
+ dfa->parse.tok = lex (dfa);
+ }
+}
+
+static void
+branch (struct dfa* dfa)
+{
+ closure (dfa);
+ while (dfa->parse.tok != RPAREN && dfa->parse.tok != OR
+ && dfa->parse.tok >= 0)
+ {
+ closure (dfa);
+ addtok (dfa, CAT);
+ }
+}
+
+static void
+regexp (struct dfa *dfa)
+{
+ branch (dfa);
+ while (dfa->parse.tok == OR)
+ {
+ dfa->parse.tok = lex (dfa);
+ branch (dfa);
+ addtok (dfa, OR);
+ }
+}
+
+/* Main entry point for the parser. S is a string to be parsed, len is the
+ length of the string, so s can include NUL characters. D is a pointer to
+ the struct dfa to parse into. */
+static void
+dfaparse (char const *s, size_t len, struct dfa *d)
+{
+ d->lex.ptr = s;
+ d->lex.left = len;
+ d->lex.lasttok = END;
+ d->lex.laststart = true;
+ d->lex.parens = 0;
+ if (d->localeinfo.multibyte)
+ {
+ d->lex.cur_mb_len = 0;
+ memset (&d->mbs, 0, sizeof d->mbs);
+ }
+
+ if (!d->syntax.syntax_bits_set)
+ dfaerror (_("no syntax specified"));
+
+ d->parse.tok = lex (d);
+ d->parse.depth = d->depth;
+
+ regexp (d);
+
+ if (d->parse.tok != END)
+ dfaerror (_("unbalanced )"));
+
+ addtok (d, END - d->nregexps);
+ addtok (d, CAT);
+
+ if (d->nregexps)
+ addtok (d, OR);
+
+ ++d->nregexps;
+}
+
+/* Some primitives for operating on sets of positions. */
+
+/* Copy one set to another. */
+static void
+copy (position_set const *src, position_set *dst)
+{
+ if (dst->alloc < src->nelem)
+ {
+ free (dst->elems);
+ dst->elems = xpalloc (NULL, &dst->alloc, src->nelem - dst->alloc, -1,
+ sizeof *dst->elems);
+ }
+ memcpy (dst->elems, src->elems, src->nelem * sizeof *dst->elems);
+ dst->nelem = src->nelem;
+}
+
+static void
+alloc_position_set (position_set *s, size_t size)
+{
+ s->elems = xnmalloc (size, sizeof *s->elems);
+ if (PTRDIFF_MAX < SIZE_MAX / sizeof *s->elems && PTRDIFF_MAX < size)
+ xalloc_die ();
+ s->alloc = size;
+ s->nelem = 0;
+}
+
+/* Insert position P in set S. S is maintained in sorted order on
+ decreasing index. If there is already an entry in S with P.index
+ then merge (logically-OR) P's constraints into the one in S.
+ S->elems must point to an array large enough to hold the resulting set. */
+static void
+insert (position p, position_set *s)
+{
+ ptrdiff_t count = s->nelem;
+ ptrdiff_t lo = 0, hi = count;
+ ptrdiff_t i;
+ while (lo < hi)
+ {
+ ptrdiff_t mid = (lo + hi) >> 1;
+ if (s->elems[mid].index > p.index)
+ lo = mid + 1;
+ else if (s->elems[mid].index == p.index)
+ {
+ s->elems[mid].constraint |= p.constraint;
+ return;
+ }
+ else
+ hi = mid;
+ }
+
+ s->elems = maybe_realloc (s->elems, count, &s->alloc, -1, sizeof *s->elems);
+ for (i = count; i > lo; i--)
+ s->elems[i] = s->elems[i - 1];
+ s->elems[lo] = p;
+ ++s->nelem;
+}
+
+/* Merge S1 and S2 (with the additional constraint C2) into M. The
+ result is as if the positions of S1, and of S2 with the additional
+ constraint C2, were inserted into an initially empty set. */
+static void
+merge_constrained (position_set const *s1, position_set const *s2,
+ unsigned int c2, position_set *m)
+{
+ ptrdiff_t i = 0, j = 0;
+
+ if (m->alloc - s1->nelem < s2->nelem)
+ {
+ free (m->elems);
+ m->alloc = s1->nelem;
+ m->elems = xpalloc (NULL, &m->alloc, s2->nelem, -1, sizeof *m->elems);
+ }
+ m->nelem = 0;
+ while (i < s1->nelem || j < s2->nelem)
+ if (! (j < s2->nelem)
+ || (i < s1->nelem && s1->elems[i].index >= s2->elems[j].index))
+ {
+ unsigned int c = ((i < s1->nelem && j < s2->nelem
+ && s1->elems[i].index == s2->elems[j].index)
+ ? s2->elems[j++].constraint & c2
+ : 0);
+ m->elems[m->nelem].index = s1->elems[i].index;
+ m->elems[m->nelem++].constraint = s1->elems[i++].constraint | c;
+ }
+ else
+ {
+ if (s2->elems[j].constraint & c2)
+ {
+ m->elems[m->nelem].index = s2->elems[j].index;
+ m->elems[m->nelem++].constraint = s2->elems[j].constraint & c2;
+ }
+ j++;
+ }
+}
+
+/* Merge two sets of positions into a third. The result is exactly as if
+ the positions of both sets were inserted into an initially empty set. */
+static void
+merge (position_set const *s1, position_set const *s2, position_set *m)
+{
+ return merge_constrained (s1, s2, -1, m);
+}
+
+/* Delete a position from a set. Return the nonzero constraint of the
+ deleted position, or zero if there was no such position. */
+static unsigned int
+delete (size_t del, position_set *s)
+{
+ size_t count = s->nelem;
+ size_t lo = 0, hi = count;
+ while (lo < hi)
+ {
+ size_t mid = (lo + hi) >> 1;
+ if (s->elems[mid].index > del)
+ lo = mid + 1;
+ else if (s->elems[mid].index == del)
+ {
+ unsigned int c = s->elems[mid].constraint;
+ size_t i;
+ for (i = mid; i + 1 < count; i++)
+ s->elems[i] = s->elems[i + 1];
+ s->nelem = i;
+ return c;
+ }
+ else
+ hi = mid;
+ }
+ return 0;
+}
+
+/* Replace a position with the followed set. */
+static void
+replace (position_set *dst, size_t del, position_set *add,
+ unsigned int constraint, position_set *tmp)
+{
+ unsigned int c = delete (del, dst) & constraint;
+
+ if (c)
+ {
+ copy (dst, tmp);
+ merge_constrained (tmp, add, c, dst);
+ }
+}
+
+/* Find the index of the state corresponding to the given position set with
+ the given preceding context, or create a new state if there is no such
+ state. Context tells whether we got here on a newline or letter. */
+static state_num
+state_index (struct dfa *d, position_set const *s, int context)
+{
+ size_t hash = 0;
+ int constraint = 0;
+ state_num i, j;
+ token first_end = 0;
+
+ for (i = 0; i < s->nelem; ++i)
+ hash ^= s->elems[i].index + s->elems[i].constraint;
+
+ /* Try to find a state that exactly matches the proposed one. */
+ for (i = 0; i < d->sindex; ++i)
+ {
+ if (hash != d->states[i].hash || s->nelem != d->states[i].elems.nelem
+ || context != d->states[i].context)
+ continue;
+ for (j = 0; j < s->nelem; ++j)
+ if (s->elems[j].constraint != d->states[i].elems.elems[j].constraint
+ || s->elems[j].index != d->states[i].elems.elems[j].index)
+ break;
+ if (j == s->nelem)
+ return i;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "new state %zd\n nextpos:", i);
+ for (j = 0; j < s->nelem; ++j)
+ {
+ fprintf (stderr, " %zu:", s->elems[j].index);
+ prtok (d->tokens[s->elems[j].index]);
+ }
+ fprintf (stderr, "\n context:");
+ if (context ^ CTX_ANY)
+ {
+ if (context & CTX_NONE)
+ fprintf (stderr, " CTX_NONE");
+ if (context & CTX_LETTER)
+ fprintf (stderr, " CTX_LETTER");
+ if (context & CTX_NEWLINE)
+ fprintf (stderr, " CTX_NEWLINE");
+ }
+ else
+ fprintf (stderr, " CTX_ANY");
+ fprintf (stderr, "\n");
+#endif
+
+ for (j = 0; j < s->nelem; ++j)
+ {
+ int c = s->elems[j].constraint;
+ if (d->tokens[s->elems[j].index] < 0)
+ {
+ if (SUCCEEDS_IN_CONTEXT (c, context, CTX_ANY))
+ constraint |= c;
+ if (!first_end)
+ first_end = d->tokens[s->elems[j].index];
+ }
+ else if (d->tokens[s->elems[j].index] == BACKREF)
+ constraint = NO_CONSTRAINT;
+ }
+
+
+ /* Create a new state. */
+ d->states = maybe_realloc (d->states, d->sindex, &d->salloc, -1,
+ sizeof *d->states);
+ d->states[i].hash = hash;
+ alloc_position_set (&d->states[i].elems, s->nelem);
+ copy (s, &d->states[i].elems);
+ d->states[i].context = context;
+ d->states[i].constraint = constraint;
+ d->states[i].first_end = first_end;
+ d->states[i].mbps.nelem = 0;
+ d->states[i].mbps.elems = NULL;
+ d->states[i].mb_trindex = -1;
+
+ ++d->sindex;
+
+ return i;
+}
+
+/* Find the epsilon closure of a set of positions. If any position of the set
+ contains a symbol that matches the empty string in some context, replace
+ that position with the elements of its follow labeled with an appropriate
+ constraint. Repeat exhaustively until no funny positions are left.
+ S->elems must be large enough to hold the result. */
+static void
+epsclosure (position_set *initial, struct dfa const *d)
+{
+ position_set tmp;
+ alloc_position_set (&tmp, d->nleaves);
+ for (size_t i = 0; i < d->tindex; ++i)
+ if (d->follows[i].nelem > 0 && d->tokens[i] >= NOTCHAR
+ && d->tokens[i] != BACKREF && d->tokens[i] != ANYCHAR
+ && d->tokens[i] != MBCSET && d->tokens[i] < CSET)
+ {
+ unsigned int constraint;
+ switch (d->tokens[i])
+ {
+ case BEGLINE:
+ constraint = BEGLINE_CONSTRAINT;
+ break;
+ case ENDLINE:
+ constraint = ENDLINE_CONSTRAINT;
+ break;
+ case BEGWORD:
+ constraint = BEGWORD_CONSTRAINT;
+ break;
+ case ENDWORD:
+ constraint = ENDWORD_CONSTRAINT;
+ break;
+ case LIMWORD:
+ constraint = LIMWORD_CONSTRAINT;
+ break;
+ case NOTLIMWORD:
+ constraint = NOTLIMWORD_CONSTRAINT;
+ break;
+ default:
+ constraint = NO_CONSTRAINT;
+ break;
+ }
+
+ delete (i, &d->follows[i]);
+
+ for (size_t j = 0; j < d->tindex; j++)
+ if (i != j && d->follows[j].nelem > 0)
+ replace (&d->follows[j], i, &d->follows[i], constraint, &tmp);
+
+ replace (initial, i, &d->follows[i], constraint, &tmp);
+ }
+}
+
+/* Returns the set of contexts for which there is at least one
+ character included in C. */
+
+static int
+charclass_context (struct dfa const *dfa, charclass c)
+{
+ int context = 0;
+ unsigned int j;
+
+ for (j = 0; j < CHARCLASS_WORDS; ++j)
+ {
+ if (c[j] & dfa->syntax.newline[j])
+ context |= CTX_NEWLINE;
+ if (c[j] & dfa->syntax.letters[j])
+ context |= CTX_LETTER;
+ if (c[j] & ~(dfa->syntax.letters[j] | dfa->syntax.newline[j]))
+ context |= CTX_NONE;
+ }
+
+ return context;
+}
+
+/* Returns the contexts on which the position set S depends. Each context
+ in the set of returned contexts (let's call it SC) may have a different
+ follow set than other contexts in SC, and also different from the
+ follow set of the complement set (sc ^ CTX_ANY). However, all contexts
+ in the complement set will have the same follow set. */
+
+static int _GL_ATTRIBUTE_PURE
+state_separate_contexts (position_set const *s)
+{
+ int separate_contexts = 0;
+ size_t j;
+
+ for (j = 0; j < s->nelem; ++j)
+ {
+ if (PREV_NEWLINE_DEPENDENT (s->elems[j].constraint))
+ separate_contexts |= CTX_NEWLINE;
+ if (PREV_LETTER_DEPENDENT (s->elems[j].constraint))
+ separate_contexts |= CTX_LETTER;
+ }
+
+ return separate_contexts;
+}
+
+
+/* Perform bottom-up analysis on the parse tree, computing various functions.
+ Note that at this point, we're pretending constructs like \< are real
+ characters rather than constraints on what can follow them.
+
+ Nullable: A node is nullable if it is at the root of a regexp that can
+ match the empty string.
+ * EMPTY leaves are nullable.
+ * No other leaf is nullable.
+ * A QMARK or STAR node is nullable.
+ * A PLUS node is nullable if its argument is nullable.
+ * A CAT node is nullable if both its arguments are nullable.
+ * An OR node is nullable if either argument is nullable.
+
+ Firstpos: The firstpos of a node is the set of positions (nonempty leaves)
+ that could correspond to the first character of a string matching the
+ regexp rooted at the given node.
+ * EMPTY leaves have empty firstpos.
+ * The firstpos of a nonempty leaf is that leaf itself.
+ * The firstpos of a QMARK, STAR, or PLUS node is the firstpos of its
+ argument.
+ * The firstpos of a CAT node is the firstpos of the left argument, union
+ the firstpos of the right if the left argument is nullable.
+ * The firstpos of an OR node is the union of firstpos of each argument.
+
+ Lastpos: The lastpos of a node is the set of positions that could
+ correspond to the last character of a string matching the regexp at
+ the given node.
+ * EMPTY leaves have empty lastpos.
+ * The lastpos of a nonempty leaf is that leaf itself.
+ * The lastpos of a QMARK, STAR, or PLUS node is the lastpos of its
+ argument.
+ * The lastpos of a CAT node is the lastpos of its right argument, union
+ the lastpos of the left if the right argument is nullable.
+ * The lastpos of an OR node is the union of the lastpos of each argument.
+
+ Follow: The follow of a position is the set of positions that could
+ correspond to the character following a character matching the node in
+ a string matching the regexp. At this point we consider special symbols
+ that match the empty string in some context to be just normal characters.
+ Later, if we find that a special symbol is in a follow set, we will
+ replace it with the elements of its follow, labeled with an appropriate
+ constraint.
+ * Every node in the firstpos of the argument of a STAR or PLUS node is in
+ the follow of every node in the lastpos.
+ * Every node in the firstpos of the second argument of a CAT node is in
+ the follow of every node in the lastpos of the first argument.
+
+ Because of the postfix representation of the parse tree, the depth-first
+ analysis is conveniently done by a linear scan with the aid of a stack.
+ Sets are stored as arrays of the elements, obeying a stack-like allocation
+ scheme; the number of elements in each set deeper in the stack can be
+ used to determine the address of a particular set's array. */
+static void
+dfaanalyze (struct dfa *d, bool searchflag)
+{
+ /* Array allocated to hold position sets. */
+ position *posalloc = xnmalloc (d->nleaves, 2 * sizeof *posalloc);
+ /* Firstpos and lastpos elements. */
+ position *firstpos = posalloc + d->nleaves;
+ position *lastpos = firstpos + d->nleaves;
+
+ /* Stack for element counts and nullable flags. */
+ struct
+ {
+ /* Whether the entry is nullable. */
+ bool nullable;
+
+ /* Counts of firstpos and lastpos sets. */
+ size_t nfirstpos;
+ size_t nlastpos;
+ } *stkalloc = xnmalloc (d->depth, sizeof *stkalloc), *stk = stkalloc;
+
+ position_set tmp; /* Temporary set for merging sets. */
+ position_set merged; /* Result of merging sets. */
+ int separate_contexts; /* Context wanted by some position. */
+ size_t i, j;
+ position *pos;
+
+#ifdef DEBUG
+ fprintf (stderr, "dfaanalyze:\n");
+ for (i = 0; i < d->tindex; ++i)
+ {
+ fprintf (stderr, " %zu:", i);
+ prtok (d->tokens[i]);
+ }
+ putc ('\n', stderr);
+#endif
+
+ d->searchflag = searchflag;
+ alloc_position_set (&merged, d->nleaves);
+ d->follows = xcalloc (d->tindex, sizeof *d->follows);
+
+ for (i = 0; i < d->tindex; ++i)
+ {
+ switch (d->tokens[i])
+ {
+ case EMPTY:
+ /* The empty set is nullable. */
+ stk->nullable = true;
+
+ /* The firstpos and lastpos of the empty leaf are both empty. */
+ stk->nfirstpos = stk->nlastpos = 0;
+ stk++;
+ break;
+
+ case STAR:
+ case PLUS:
+ /* Every element in the firstpos of the argument is in the follow
+ of every element in the lastpos. */
+ tmp.nelem = stk[-1].nfirstpos;
+ tmp.elems = firstpos;
+ pos = lastpos;
+ for (j = 0; j < stk[-1].nlastpos; ++j)
+ {
+ merge (&tmp, &d->follows[pos[j].index], &merged);
+ copy (&merged, &d->follows[pos[j].index]);
+ }
+ /* fallthrough */
+
+ case QMARK:
+ /* A QMARK or STAR node is automatically nullable. */
+ if (d->tokens[i] != PLUS)
+ stk[-1].nullable = true;
+ break;
+
+ case CAT:
+ /* Every element in the firstpos of the second argument is in the
+ follow of every element in the lastpos of the first argument. */
+ tmp.nelem = stk[-1].nfirstpos;
+ tmp.elems = firstpos;
+ pos = lastpos + stk[-1].nlastpos;
+ for (j = 0; j < stk[-2].nlastpos; ++j)
+ {
+ merge (&tmp, &d->follows[pos[j].index], &merged);
+ copy (&merged, &d->follows[pos[j].index]);
+ }
+
+ /* The firstpos of a CAT node is the firstpos of the first argument,
+ union that of the second argument if the first is nullable. */
+ if (stk[-2].nullable)
+ stk[-2].nfirstpos += stk[-1].nfirstpos;
+ else
+ firstpos += stk[-1].nfirstpos;
+
+ /* The lastpos of a CAT node is the lastpos of the second argument,
+ union that of the first argument if the second is nullable. */
+ if (stk[-1].nullable)
+ stk[-2].nlastpos += stk[-1].nlastpos;
+ else
+ {
+ pos = lastpos + stk[-2].nlastpos;
+ for (j = stk[-1].nlastpos; j-- > 0;)
+ pos[j] = lastpos[j];
+ lastpos += stk[-2].nlastpos;
+ stk[-2].nlastpos = stk[-1].nlastpos;
+ }
+
+ /* A CAT node is nullable if both arguments are nullable. */
+ stk[-2].nullable &= stk[-1].nullable;
+ stk--;
+ break;
+
+ case OR:
+ /* The firstpos is the union of the firstpos of each argument. */
+ stk[-2].nfirstpos += stk[-1].nfirstpos;
+
+ /* The lastpos is the union of the lastpos of each argument. */
+ stk[-2].nlastpos += stk[-1].nlastpos;
+
+ /* An OR node is nullable if either argument is nullable. */
+ stk[-2].nullable |= stk[-1].nullable;
+ stk--;
+ break;
+
+ default:
+ /* Anything else is a nonempty position. (Note that special
+ constructs like \< are treated as nonempty strings here;
+ an "epsilon closure" effectively makes them nullable later.
+ Backreferences have to get a real position so we can detect
+ transitions on them later. But they are nullable. */
+ stk->nullable = d->tokens[i] == BACKREF;
+
+ /* This position is in its own firstpos and lastpos. */
+ stk->nfirstpos = stk->nlastpos = 1;
+ stk++;
+
+ --firstpos, --lastpos;
+ firstpos->index = lastpos->index = i;
+ firstpos->constraint = lastpos->constraint = NO_CONSTRAINT;
+
+ /* Allocate the follow set for this position. */
+ alloc_position_set (&d->follows[i], 1);
+ break;
+ }
+#ifdef DEBUG
+ /* ... balance the above nonsyntactic #ifdef goo... */
+ fprintf (stderr, "node %zu:", i);
+ prtok (d->tokens[i]);
+ putc ('\n', stderr);
+ fprintf (stderr,
+ stk[-1].nullable ? " nullable: yes\n" : " nullable: no\n");
+ fprintf (stderr, " firstpos:");
+ for (j = stk[-1].nfirstpos; j-- > 0;)
+ {
+ fprintf (stderr, " %zu:", firstpos[j].index);
+ prtok (d->tokens[firstpos[j].index]);
+ }
+ fprintf (stderr, "\n lastpos:");
+ for (j = stk[-1].nlastpos; j-- > 0;)
+ {
+ fprintf (stderr, " %zu:", lastpos[j].index);
+ prtok (d->tokens[lastpos[j].index]);
+ }
+ putc ('\n', stderr);
+#endif
+ }
+
+#ifdef DEBUG
+ for (i = 0; i < d->tindex; ++i)
+ if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF
+ || d->tokens[i] == ANYCHAR || d->tokens[i] == MBCSET
+ || d->tokens[i] >= CSET)
+ {
+ fprintf (stderr, "follows(%zu:", i);
+ prtok (d->tokens[i]);
+ fprintf (stderr, "):");
+ for (j = d->follows[i].nelem; j-- > 0;)
+ {
+ fprintf (stderr, " %zu:", d->follows[i].elems[j].index);
+ prtok (d->tokens[d->follows[i].elems[j].index]);
+ }
+ putc ('\n', stderr);
+ }
+#endif
+
+ /* Get the epsilon closure of the firstpos of the regexp. The result will
+ be the set of positions of state 0. */
+ merged.nelem = 0;
+ for (i = 0; i < stk[-1].nfirstpos; ++i)
+ insert (firstpos[i], &merged);
+
+ /* For each follow set that is the follow set of a real position, replace
+ it with its epsilon closure. */
+ epsclosure (&merged, d);
+
+ /* Build the initial state. */
+ separate_contexts = state_separate_contexts (&merged);
+ if (separate_contexts & CTX_NEWLINE)
+ state_index (d, &merged, CTX_NEWLINE);
+ d->initstate_notbol = d->min_trcount
+ = state_index (d, &merged, separate_contexts ^ CTX_ANY);
+ if (separate_contexts & CTX_LETTER)
+ d->min_trcount = state_index (d, &merged, CTX_LETTER);
+ d->min_trcount++;
+ d->trcount = 0;
+
+ free (posalloc);
+ free (stkalloc);
+ free (merged.elems);
+}
+
+
+/* Return the transition out of state s of d for the input character uc,
+ updating the slots in trans accordingly.
+
+ Do not worry about all possible input characters; calculate just the group
+ of positions that match uc. Label it with the set of characters that
+ every position in the group matches (taking into account, if necessary,
+ preceding context information of s). Then find the union
+ of these positions' follows, i.e., the set of positions of the
+ new state. For each character in the group's label, set the transition
+ on this character to be to a state corresponding to the set's positions,
+ and its associated backward context information, if necessary.
+
+ When building a searching matcher, include the positions of state
+ 0 in every state.
+
+ The group is constructed by building an equivalence-class
+ partition of the positions of s.
+
+ For each position, find the set of characters C that it matches. Eliminate
+ any characters from C that fail on grounds of backward context.
+
+ Check whether the group's label L has nonempty
+ intersection with C. If L - C is nonempty, create a new group labeled
+ L - C and having the same positions as the current group, and set L to
+ the intersection of L and C. Insert the position in the group, set
+ C = C - L, and resume scanning.
+
+ If after comparing with every group there are characters remaining in C,
+ create a new group labeled with the characters of C and insert this
+ position in that group. */
+static state_num
+dfastate (state_num s, struct dfa *d, unsigned char uc, state_num trans[])
+{
+ leaf_set group; /* Positions that match the input char. */
+ charclass label; /* The group's label. */
+ position_set follows; /* Union of the follows of the group. */
+ position_set tmp; /* Temporary space for merging sets. */
+ state_num state; /* New state. */
+ state_num state_newline; /* New state on a newline transition. */
+ state_num state_letter; /* New state on a letter transition. */
+ size_t i, j, k;
+
+#ifdef DEBUG
+ fprintf (stderr, "build state %td\n", s);
+#endif
+
+ group.elems = xnmalloc (d->nleaves, sizeof *group.elems);
+ group.nelem = 0;
+
+ fillset (label);
+
+ for (i = 0; i < d->states[s].elems.nelem; ++i)
+ {
+ charclass matches; /* Set of matching characters. */
+ position pos = d->states[s].elems.elems[i];
+ bool matched = false;
+ if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR)
+ {
+ zeroset (matches);
+ setbit (d->tokens[pos.index], matches);
+ if (d->tokens[pos.index] == uc)
+ matched = true;
+ }
+ else if (d->tokens[pos.index] >= CSET)
+ {
+ copyset (d->charclasses[d->tokens[pos.index] - CSET], matches);
+ if (tstbit (uc, d->charclasses[d->tokens[pos.index] - CSET]))
+ matched = true;
+ }
+ else if (d->tokens[pos.index] == ANYCHAR)
+ {
+ copyset (d->charclasses[d->canychar], matches);
+ if (tstbit (uc, d->charclasses[d->canychar]))
+ matched = true;
+
+ /* ANYCHAR must match with a single character, so we must put
+ it to D->states[s].mbps which contains the positions which
+ can match with a single character not a byte. If all
+ positions which has ANYCHAR does not depend on context of
+ next character, we put the follows instead of it to
+ D->states[s].mbps to optimize. */
+ if (SUCCEEDS_IN_CONTEXT (pos.constraint, d->states[s].context,
+ CTX_NONE))
+ {
+ if (d->states[s].mbps.nelem == 0)
+ alloc_position_set (&d->states[s].mbps,
+ d->follows[pos.index].nelem);
+ for (j = 0; j < d->follows[pos.index].nelem; j++)
+ insert (d->follows[pos.index].elems[j], &d->states[s].mbps);
+ }
+ }
+ else
+ continue;
+
+ /* Some characters may need to be eliminated from matches because
+ they fail in the current context. */
+ if (pos.constraint != NO_CONSTRAINT)
+ {
+ if (!SUCCEEDS_IN_CONTEXT (pos.constraint,
+ d->states[s].context, CTX_NEWLINE))
+ for (j = 0; j < CHARCLASS_WORDS; ++j)
+ matches[j] &= ~d->syntax.newline[j];
+ if (!SUCCEEDS_IN_CONTEXT (pos.constraint,
+ d->states[s].context, CTX_LETTER))
+ for (j = 0; j < CHARCLASS_WORDS; ++j)
+ matches[j] &= ~d->syntax.letters[j];
+ if (!SUCCEEDS_IN_CONTEXT (pos.constraint,
+ d->states[s].context, CTX_NONE))
+ for (j = 0; j < CHARCLASS_WORDS; ++j)
+ matches[j] &= d->syntax.letters[j] | d->syntax.newline[j];
+
+ /* If there are no characters left, there's no point in going on. */
+ for (j = 0; j < CHARCLASS_WORDS && !matches[j]; ++j)
+ continue;
+ if (j == CHARCLASS_WORDS)
+ continue;
+
+ /* If we have reset the bit that made us declare "matched", reset
+ that indicator, too. This is required to avoid an infinite loop
+ with this command: echo cx | LC_ALL=C grep -E 'c\b[x ]' */
+ if (!tstbit (uc, matches))
+ matched = false;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, " nextpos %zu:", pos.index);
+ prtok (d->tokens[pos.index]);
+ fprintf (stderr, " of");
+ for (j = 0; j < NOTCHAR; j++)
+ if (tstbit (j, matches))
+ fprintf (stderr, " 0x%02zx", j);
+ fprintf (stderr, "\n");
+#endif
+
+ if (matched)
+ {
+ for (k = 0; k < CHARCLASS_WORDS; ++k)
+ label[k] &= matches[k];
+ group.elems[group.nelem++] = pos.index;
+ }
+ else
+ {
+ for (k = 0; k < CHARCLASS_WORDS; ++k)
+ label[k] &= ~matches[k];
+ }
+ }
+
+ alloc_position_set (&follows, d->nleaves);
+ alloc_position_set (&tmp, d->nleaves);
+
+ if (group.nelem > 0)
+ {
+ int possible_contexts; /* Contexts that the group can match. */
+ int separate_contexts; /* Context that new state wants to know. */
+
+ follows.nelem = 0;
+
+ /* Find the union of the follows of the positions of the group.
+ This is a hideously inefficient loop. Fix it someday. */
+ for (j = 0; j < group.nelem; ++j)
+ for (k = 0; k < d->follows[group.elems[j]].nelem; ++k)
+ insert (d->follows[group.elems[j]].elems[k], &follows);
+
+ /* If we are building a searching matcher, throw in the positions
+ of state 0 as well, if possible. */
+ if (d->searchflag)
+ {
+ /* If a token in follows.elems is not 1st byte of a multibyte
+ character, or the states of follows must accept the bytes
+ which are not 1st byte of the multibyte character.
+ Then, if a state of follows encounters a byte, it must not be
+ a 1st byte of a multibyte character nor a single byte character.
+ In this case, do not add state[0].follows to next state, because
+ state[0] must accept 1st-byte.
+
+ For example, suppose <sb a> is a certain single byte character,
+ <mb A> is a certain multibyte character, and the codepoint of
+ <sb a> equals the 2nd byte of the codepoint of <mb A>. When
+ state[0] accepts <sb a>, state[i] transits to state[i+1] by
+ accepting the 1st byte of <mb A>, and state[i+1] accepts the
+ 2nd byte of <mb A>, if state[i+1] encounters the codepoint of
+ <sb a>, it must not be <sb a> but the 2nd byte of <mb A>, so do
+ not add state[0]. */
+
+ bool mergeit = !d->localeinfo.multibyte;
+ if (!mergeit)
+ for (mergeit = true, j = 0; mergeit && j < follows.nelem; j++)
+ mergeit &= d->multibyte_prop[follows.elems[j].index];
+ if (mergeit)
+ {
+ merge (&d->states[0].elems, &follows, &tmp);
+ copy (&tmp, &follows);
+ }
+ }
+
+ /* Find out if the new state will want any context information. */
+ possible_contexts = charclass_context (d, label);
+ separate_contexts = state_separate_contexts (&follows);
+
+ /* Find the state(s) corresponding to the union of the follows. */
+ if (possible_contexts & ~separate_contexts)
+ state = state_index (d, &follows, separate_contexts ^ CTX_ANY);
+ else
+ state = -1;
+ if (separate_contexts & possible_contexts & CTX_NEWLINE)
+ state_newline = state_index (d, &follows, CTX_NEWLINE);
+ else
+ state_newline = state;
+ if (separate_contexts & possible_contexts & CTX_LETTER)
+ state_letter = state_index (d, &follows, CTX_LETTER);
+ else
+ state_letter = state;
+ }
+
+ /* If we are a searching matcher, the default transition is to a state
+ containing the positions of state 0, otherwise the default transition
+ is to fail miserably. */
+ else if (d->searchflag)
+ {
+ state_newline = 0;
+ state_letter = d->min_trcount - 1;
+ state = d->initstate_notbol;
+ }
+ else
+ {
+ state_newline = -1;
+ state_letter = -1;
+ state = -1;
+ }
+
+ /* Set the transitions for each character in the label. */
+ for (i = 0; i < NOTCHAR; i++)
+ if (tstbit (i, label))
+ switch (d->syntax.sbit[i])
+ {
+ case CTX_NEWLINE:
+ trans[i] = state_newline;
+ break;
+ case CTX_LETTER:
+ trans[i] = state_letter;
+ break;
+ default:
+ trans[i] = state;
+ break;
+ }
+
+#ifdef DEBUG
+ fprintf (stderr, "trans table %td", s);
+ for (i = 0; i < NOTCHAR; ++i)
+ {
+ if (!(i & 0xf))
+ fprintf (stderr, "\n");
+ fprintf (stderr, " %2td", trans[i]);
+ }
+ fprintf (stderr, "\n");
+#endif
+
+ free (group.elems);
+ free (follows.elems);
+ free (tmp.elems);
+
+ /* Keep the newline transition in a special place so we can use it as
+ a sentinel. */
+ if (tstbit (d->syntax.eolbyte, label))
+ {
+ d->newlines[s] = trans[d->syntax.eolbyte];
+ trans[d->syntax.eolbyte] = -1;
+ }
+
+ return trans[uc];
+}
+
+/* Make sure D's state arrays are large enough to hold NEW_STATE. */
+static void
+realloc_trans_if_necessary (struct dfa *d, state_num new_state)
+{
+ state_num oldalloc = d->tralloc;
+ if (oldalloc <= new_state)
+ {
+ state_num **realtrans = d->trans ? d->trans - 2 : NULL;
+ ptrdiff_t newalloc, newalloc1;
+ newalloc1 = realtrans ? d->tralloc + 2 : 0;
+ realtrans = xpalloc (realtrans, &newalloc1, new_state - oldalloc + 1,
+ -1, sizeof *realtrans);
+ realtrans[0] = realtrans[1] = NULL;
+ d->trans = realtrans + 2;
+ d->tralloc = newalloc = newalloc1 - 2;
+ d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+ d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+ d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+ if (d->localeinfo.multibyte)
+ {
+ realtrans = d->mb_trans ? d->mb_trans - 2 : NULL;
+ realtrans = xnrealloc (realtrans, newalloc1, sizeof *realtrans);
+ if (oldalloc == 0)
+ realtrans[0] = realtrans[1] = NULL;
+ d->mb_trans = realtrans + 2;
+ }
+ for (; oldalloc < newalloc; oldalloc++)
+ {
+ d->trans[oldalloc] = NULL;
+ d->fails[oldalloc] = NULL;
+ if (d->localeinfo.multibyte)
+ d->mb_trans[oldalloc] = NULL;
+ }
+ }
+}
+
+/* Calculate the transition table for a new state derived from state s
+ for a compiled dfa d after input character uc, and return the new
+ state number. */
+
+static state_num
+build_state (state_num s, struct dfa *d, unsigned char uc)
+{
+ /* A pointer to the new transition table, and the table itself. */
+ state_num **ptrans = (ACCEPTING (s, *d) ? d->fails : d->trans) + s;
+ state_num *trans = *ptrans;
+
+ if (!trans)
+ {
+ /* MAX_TRCOUNT is an arbitrary upper limit on the number of
+ transition tables that can exist at once, other than for
+ initial states. Often-used transition tables are quickly
+ rebuilt, whereas rarely-used ones are cleared away. */
+ if (MAX_TRCOUNT <= d->trcount)
+ {
+ for (state_num i = d->min_trcount; i < d->tralloc; i++)
+ {
+ free (d->trans[i]);
+ free (d->fails[i]);
+ d->trans[i] = d->fails[i] = NULL;
+ }
+ d->trcount = 0;
+ }
+
+ d->trcount++;
+ *ptrans = trans = xmalloc (NOTCHAR * sizeof *trans);
+
+ /* Fill transition table with a default value which means that the
+ transited state has not been calculated yet. */
+ for (int i = 0; i < NOTCHAR; i++)
+ trans[i] = -2;
+ }
+
+ /* Set up the success bits for this state. */
+ d->success[s] = 0;
+ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s, *d))
+ d->success[s] |= CTX_NEWLINE;
+ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_LETTER, s, *d))
+ d->success[s] |= CTX_LETTER;
+ if (ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NONE, s, *d))
+ d->success[s] |= CTX_NONE;
+
+ s = dfastate (s, d, uc, trans);
+
+ /* Now go through the new transition table, and make sure that the trans
+ and fail arrays are allocated large enough to hold a pointer for the
+ largest state mentioned in the table. */
+ state_num maxstate = -1;
+ for (int i = 0; i < NOTCHAR; i++)
+ if (maxstate < trans[i])
+ maxstate = trans[i];
+ realloc_trans_if_necessary (d, maxstate);
+
+ return s;
+}
+
+/* Multibyte character handling sub-routines for dfaexec. */
+
+/* Consume a single byte and transit state from 's' to '*next_state'.
+ This function is almost same as the state transition routin in dfaexec.
+ But state transition is done just once, otherwise matching succeed or
+ reach the end of the buffer. */
+static state_num
+transit_state_singlebyte (struct dfa *d, state_num s, unsigned char const **pp)
+{
+ state_num *t;
+
+ if (d->trans[s])
+ t = d->trans[s];
+ else if (d->fails[s])
+ t = d->fails[s];
+ else
+ {
+ build_state (s, d, **pp);
+ if (d->trans[s])
+ t = d->trans[s];
+ else
+ {
+ t = d->fails[s];
+ assert (t);
+ }
+ }
+
+ if (t[**pp] == -2)
+ build_state (s, d, **pp);
+
+ return t[*(*pp)++];
+}
+
+/* Transit state from s, then return new state and update the pointer of
+ the buffer. This function is for a period operator which can match a
+ multi-byte character. */
+static state_num
+transit_state (struct dfa *d, state_num s, unsigned char const **pp,
+ unsigned char const *end)
+{
+ state_num s1, s2;
+ wint_t wc;
+ int separate_contexts;
+ size_t i;
+
+ int mbclen = mbs_to_wchar (&wc, (char const *) *pp, end - *pp, d);
+
+ /* This state has some operators which can match a multibyte character. */
+ d->mb_follows.nelem = 0;
+
+ /* Calculate the state which can be reached from the state 's' by
+ consuming 'mbclen' single bytes from the buffer. */
+ s1 = s;
+ for (i = 0; i < mbclen && (i == 0 || d->min_trcount <= s); i++)
+ s = transit_state_singlebyte (d, s, pp);
+ *pp += mbclen - i;
+
+ if (wc == WEOF)
+ {
+ /* It is an invalid character, so ANYCHAR is not accepted. */
+ return s;
+ }
+
+ /* If all positions which have ANYCHAR do not depend on the context
+ of the next character, calculate the next state with
+ pre-calculated follows and cache the result. */
+ if (d->states[s1].mb_trindex < 0)
+ {
+ if (MAX_TRCOUNT <= d->mb_trcount)
+ {
+ state_num s3;
+ for (s3 = -1; s3 < d->tralloc; s3++)
+ {
+ free (d->mb_trans[s3]);
+ d->mb_trans[s3] = NULL;
+ }
+
+ for (i = 0; i < d->sindex; i++)
+ d->states[i].mb_trindex = -1;
+ d->mb_trcount = 0;
+ }
+ d->states[s1].mb_trindex = d->mb_trcount++;
+ }
+
+ if (! d->mb_trans[s])
+ {
+ enum { TRANSPTR_SIZE = sizeof *d->mb_trans[s] };
+ enum { TRANSALLOC_SIZE = MAX_TRCOUNT * TRANSPTR_SIZE };
+ d->mb_trans[s] = xmalloc (TRANSALLOC_SIZE);
+ for (i = 0; i < MAX_TRCOUNT; i++)
+ d->mb_trans[s][i] = -1;
+ }
+ else if (d->mb_trans[s][d->states[s1].mb_trindex] >= 0)
+ return d->mb_trans[s][d->states[s1].mb_trindex];
+
+ if (s == -1)
+ copy (&d->states[s1].mbps, &d->mb_follows);
+ else
+ merge (&d->states[s1].mbps, &d->states[s].elems, &d->mb_follows);
+
+ separate_contexts = state_separate_contexts (&d->mb_follows);
+ s2 = state_index (d, &d->mb_follows, separate_contexts ^ CTX_ANY);
+ realloc_trans_if_necessary (d, s2);
+
+ d->mb_trans[s][d->states[s1].mb_trindex] = s2;
+
+ return s2;
+}
+
+/* The initial state may encounter a byte which is not a single byte character
+ nor the first byte of a multibyte character. But it is incorrect for the
+ initial state to accept such a byte. For example, in Shift JIS the regular
+ expression "\\" accepts the codepoint 0x5c, but should not accept the second
+ byte of the codepoint 0x815c. Then the initial state must skip the bytes
+ that are not a single byte character nor the first byte of a multibyte
+ character.
+
+ Given DFA state d, use mbs_to_wchar to advance MBP until it reaches
+ or exceeds P, and return the advanced MBP. If WCP is non-NULL and
+ the result is greater than P, set *WCP to the final wide character
+ processed, or to WEOF if no wide character is processed. Otherwise,
+ if WCP is non-NULL, *WCP may or may not be updated.
+
+ Both P and MBP must be no larger than END. */
+static unsigned char const *
+skip_remains_mb (struct dfa *d, unsigned char const *p,
+ unsigned char const *mbp, char const *end)
+{
+ wint_t wc;
+ if (d->syntax.never_trail[*p])
+ return p;
+ while (mbp < p)
+ mbp += mbs_to_wchar (&wc, (char const *) mbp,
+ end - (char const *) mbp, d);
+ return mbp;
+}
+
+/* Search through a buffer looking for a match to the struct dfa *D.
+ Find the first occurrence of a string matching the regexp in the
+ buffer, and the shortest possible version thereof. Return a pointer to
+ the first character after the match, or NULL if none is found. BEGIN
+ points to the beginning of the buffer, and END points to the first byte
+ after its end. Note however that we store a sentinel byte (usually
+ newline) in *END, so the actual buffer must be one byte longer.
+ When ALLOW_NL, newlines may appear in the matching string.
+ If COUNT is non-NULL, increment *COUNT once for each newline processed.
+ If MULTIBYTE, the input consists of multibyte characters and/or
+ encoding-error bytes. Otherwise, it consists of single-byte characters.
+ Here is the list of features that make this DFA matcher punt:
+ - [M-N] range in non-simple locale: regex is up to 25% faster on [a-z]
+ - [^...] in non-simple locale
+ - [[=foo=]] or [[.foo.]]
+ - [[:alpha:]] etc. in multibyte locale (except [[:digit:]] works OK)
+ - back-reference: (.)\1
+ - word-delimiter in multibyte locale: \<, \>, \b, \B
+ See using_simple_locale for the definition of "simple locale". */
+
+static inline char *
+dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl,
+ size_t *count, bool multibyte)
+{
+ state_num s, s1; /* Current state. */
+ unsigned char const *p, *mbp; /* Current input character. */
+ state_num **trans, *t; /* Copy of d->trans so it can be optimized
+ into a register. */
+ unsigned char eol = d->syntax.eolbyte; /* Likewise for eolbyte. */
+ unsigned char saved_end;
+ size_t nlcount = 0;
+
+ if (MAX_TRCOUNT <= d->sindex)
+ {
+ for (s = d->min_trcount; s < d->sindex; s++)
+ {
+ free (d->states[s].elems.elems);
+ free (d->states[s].mbps.elems);
+ }
+ d->sindex = d->min_trcount;
+
+ if (d->trans)
+ {
+ for (s = 0; s < d->tralloc; s++)
+ {
+ free (d->trans[s]);
+ free (d->fails[s]);
+ d->trans[s] = d->fails[s] = NULL;
+ }
+ d->trcount = 0;
+ }
+
+ if (d->localeinfo.multibyte && d->mb_trans)
+ {
+ for (s = -1; s < d->tralloc; s++)
+ {
+ free (d->mb_trans[s]);
+ d->mb_trans[s] = NULL;
+ }
+ for (s = 0; s < d->min_trcount; s++)
+ d->states[s].mb_trindex = -1;
+ d->mb_trcount = 0;
+ }
+ }
+
+ if (!d->tralloc)
+ realloc_trans_if_necessary (d, 0);
+
+ s = s1 = 0;
+ p = mbp = (unsigned char const *) begin;
+ trans = d->trans;
+ saved_end = *(unsigned char *) end;
+ *end = eol;
+
+ if (multibyte)
+ {
+ memset (&d->mbs, 0, sizeof d->mbs);
+ if (d->mb_follows.alloc == 0)
+ alloc_position_set (&d->mb_follows, d->nleaves);
+ }
+
+ for (;;)
+ {
+ while ((t = trans[s]) != NULL)
+ {
+ if (s < d->min_trcount)
+ {
+ if (!multibyte || d->states[s].mbps.nelem == 0)
+ {
+ while (t[*p] == s)
+ p++;
+ }
+ if (multibyte)
+ p = mbp = skip_remains_mb (d, p, mbp, end);
+ }
+
+ if (multibyte)
+ {
+ s1 = s;
+
+ if (d->states[s].mbps.nelem == 0
+ || d->localeinfo.sbctowc[*p] != WEOF || (char *) p >= end)
+ {
+ /* If an input character does not match ANYCHAR, do it
+ like a single-byte character. */
+ s = t[*p++];
+ }
+ else
+ {
+ s = transit_state (d, s, &p, (unsigned char *) end);
+ mbp = p;
+ trans = d->trans;
+ }
+ }
+ else
+ {
+ s1 = t[*p++];
+ t = trans[s1];
+ if (! t)
+ {
+ state_num tmp = s;
+ s = s1;
+ s1 = tmp; /* swap */
+ break;
+ }
+ if (s < d->min_trcount)
+ {
+ while (t[*p] == s1)
+ p++;
+ }
+ s = t[*p++];
+ }
+ }
+
+ if (s < 0)
+ {
+ if (s == -2)
+ {
+ s = build_state (s1, d, p[-1]);
+ trans = d->trans;
+ }
+ else if ((char *) p <= end && p[-1] == eol && 0 <= d->newlines[s1])
+ {
+ /* The previous character was a newline. Count it, and skip
+ checking of multibyte character boundary until here. */
+ nlcount++;
+ mbp = p;
+
+ s = (allow_nl ? d->newlines[s1]
+ : d->syntax.sbit[eol] == CTX_NEWLINE ? 0
+ : d->syntax.sbit[eol] == CTX_LETTER ? d->min_trcount - 1
+ : d->initstate_notbol);
+ }
+ else
+ {
+ p = NULL;
+ goto done;
+ }
+ }
+ else if (d->fails[s])
+ {
+ if ((d->success[s] & d->syntax.sbit[*p])
+ || ((char *) p == end
+ && ACCEPTS_IN_CONTEXT (d->states[s].context, CTX_NEWLINE, s,
+ *d)))
+ goto done;
+
+ if (multibyte && s < d->min_trcount)
+ p = mbp = skip_remains_mb (d, p, mbp, end);
+
+ s1 = s;
+ if (!multibyte || d->states[s].mbps.nelem == 0
+ || d->localeinfo.sbctowc[*p] != WEOF || (char *) p >= end)
+ {
+ /* If a input character does not match ANYCHAR, do it
+ like a single-byte character. */
+ s = d->fails[s][*p++];
+ }
+ else
+ {
+ s = transit_state (d, s, &p, (unsigned char *) end);
+ mbp = p;
+ trans = d->trans;
+ }
+ }
+ else
+ {
+ build_state (s, d, p[0]);
+ trans = d->trans;
+ }
+ }
+
+ done:
+ if (count)
+ *count += nlcount;
+ *end = saved_end;
+ return (char *) p;
+}
+
+/* Specialized versions of dfaexec for multibyte and single-byte cases.
+ This is for performance, as dfaexec_main is an inline function. */
+
+static char *
+dfaexec_mb (struct dfa *d, char const *begin, char *end,
+ bool allow_nl, size_t *count, bool *backref)
+{
+ return dfaexec_main (d, begin, end, allow_nl, count, true);
+}
+
+static char *
+dfaexec_sb (struct dfa *d, char const *begin, char *end,
+ bool allow_nl, size_t *count, bool *backref)
+{
+ return dfaexec_main (d, begin, end, allow_nl, count, false);
+}
+
+/* Always set *BACKREF and return BEGIN. Use this wrapper for
+ any regexp that uses a construct not supported by this code. */
+static char *
+dfaexec_noop (struct dfa *d, char const *begin, char *end,
+ bool allow_nl, size_t *count, bool *backref)
+{
+ *backref = true;
+ return (char *) begin;
+}
+
+/* Like dfaexec_main (D, BEGIN, END, ALLOW_NL, COUNT, D->localeinfo.multibyte),
+ but faster and set *BACKREF if the DFA code does not support this
+ regexp usage. */
+
+char *
+dfaexec (struct dfa *d, char const *begin, char *end,
+ bool allow_nl, size_t *count, bool *backref)
+{
+ return d->dfaexec (d, begin, end, allow_nl, count, backref);
+}
+
+struct dfa *
+dfasuperset (struct dfa const *d)
+{
+ return d->superset;
+}
+
+bool
+dfaisfast (struct dfa const *d)
+{
+ return d->fast;
+}
+
+static void
+free_mbdata (struct dfa *d)
+{
+ ptrdiff_t i;
+
+ free (d->multibyte_prop);
+
+ for (i = 0; i < d->nmbcsets; ++i)
+ free (d->mbcsets[i].chars);
+
+ free (d->mbcsets);
+ free (d->mb_follows.elems);
+
+ if (d->mb_trans)
+ {
+ state_num s;
+ for (s = -1; s < d->tralloc; s++)
+ free (d->mb_trans[s]);
+ free (d->mb_trans - 2);
+ }
+}
+
+/* Return true if every construct in D is supported by this DFA matcher. */
+static bool _GL_ATTRIBUTE_PURE
+dfa_supported (struct dfa const *d)
+{
+ size_t i;
+ for (i = 0; i < d->tindex; i++)
+ {
+ switch (d->tokens[i])
+ {
+ case BEGWORD:
+ case ENDWORD:
+ case LIMWORD:
+ case NOTLIMWORD:
+ if (!d->localeinfo.multibyte)
+ continue;
+ /* fallthrough */
+
+ case BACKREF:
+ case MBCSET:
+ return false;
+ }
+ }
+ return true;
+}
+
+static void
+dfaoptimize (struct dfa *d)
+{
+ size_t i;
+ bool have_backref = false;
+
+ if (!d->localeinfo.using_utf8)
+ return;
+
+ for (i = 0; i < d->tindex; ++i)
+ {
+ switch (d->tokens[i])
+ {
+ case ANYCHAR:
+ /* Lowered. */
+ abort ();
+ case BACKREF:
+ have_backref = true;
+ break;
+ case MBCSET:
+ /* Requires multi-byte algorithm. */
+ return;
+ default:
+ break;
+ }
+ }
+
+ if (!have_backref && d->superset)
+ {
+ /* The superset DFA is not likely to be much faster, so remove it. */
+ dfafree (d->superset);
+ free (d->superset);
+ d->superset = NULL;
+ }
+
+ free_mbdata (d);
+ d->localeinfo.multibyte = false;
+ d->dfaexec = dfaexec_sb;
+ d->fast = true;
+}
+
+static void
+dfassbuild (struct dfa *d)
+{
+ size_t i, j;
+ bool have_achar = false;
+ bool have_nchar = false;
+ struct dfa *sup = dfaalloc ();
+
+ *sup = *d;
+ sup->localeinfo.multibyte = false;
+ sup->dfaexec = dfaexec_sb;
+ sup->multibyte_prop = NULL;
+ sup->mbcsets = NULL;
+ sup->superset = NULL;
+ sup->states = NULL;
+ sup->sindex = 0;
+ sup->follows = NULL;
+ sup->tralloc = 0;
+ sup->trans = NULL;
+ sup->fails = NULL;
+ sup->success = NULL;
+ sup->newlines = NULL;
+
+ sup->charclasses = xnmalloc (sup->calloc, sizeof *sup->charclasses);
+ if (d->cindex)
+ {
+ memcpy (sup->charclasses, d->charclasses,
+ d->cindex * sizeof *sup->charclasses);
+ }
+
+ sup->tokens = xnmalloc (d->tindex, 2 * sizeof *sup->tokens);
+ sup->talloc = d->tindex * 2;
+
+ for (i = j = 0; i < d->tindex; i++)
+ {
+ switch (d->tokens[i])
+ {
+ case ANYCHAR:
+ case MBCSET:
+ case BACKREF:
+ {
+ charclass ccl;
+ fillset (ccl);
+ sup->tokens[j++] = CSET + charclass_index (sup, ccl);
+ sup->tokens[j++] = STAR;
+ if (d->tokens[i + 1] == QMARK || d->tokens[i + 1] == STAR
+ || d->tokens[i + 1] == PLUS)
+ i++;
+ have_achar = true;
+ }
+ break;
+ case BEGWORD:
+ case ENDWORD:
+ case LIMWORD:
+ case NOTLIMWORD:
+ if (d->localeinfo.multibyte)
+ {
+ /* These constraints aren't supported in a multibyte locale.
+ Ignore them in the superset DFA. */
+ sup->tokens[j++] = EMPTY;
+ break;
+ }
+ /* fallthrough */
+ default:
+ sup->tokens[j++] = d->tokens[i];
+ if ((0 <= d->tokens[i] && d->tokens[i] < NOTCHAR)
+ || d->tokens[i] >= CSET)
+ have_nchar = true;
+ break;
+ }
+ }
+ sup->tindex = j;
+
+ if (have_nchar && (have_achar || d->localeinfo.multibyte))
+ d->superset = sup;
+ else
+ {
+ dfafree (sup);
+ free (sup);
+ }
+}
+
+/* Parse and analyze a single string of the given length. */
+void
+dfacomp (char const *s, size_t len, struct dfa *d, bool searchflag)
+{
+ dfaparse (s, len, d);
+ dfassbuild (d);
+
+ if (dfa_supported (d))
+ {
+ dfaoptimize (d);
+ dfaanalyze (d, searchflag);
+ }
+ else
+ {
+ d->dfaexec = dfaexec_noop;
+ }
+
+ if (d->superset)
+ {
+ d->fast = true;
+ dfaanalyze (d->superset, searchflag);
+ }
+}
+
+/* Free the storage held by the components of a dfa. */
+void
+dfafree (struct dfa *d)
+{
+ size_t i;
+
+ free (d->charclasses);
+ free (d->tokens);
+
+ if (d->localeinfo.multibyte)
+ free_mbdata (d);
+
+ for (i = 0; i < d->sindex; ++i)
+ {
+ free (d->states[i].elems.elems);
+ free (d->states[i].mbps.elems);
+ }
+ free (d->states);
+
+ if (d->follows)
+ {
+ for (i = 0; i < d->tindex; ++i)
+ free (d->follows[i].elems);
+ free (d->follows);
+ }
+
+ if (d->trans)
+ {
+ for (i = 0; i < d->tralloc; ++i)
+ {
+ free (d->trans[i]);
+ free (d->fails[i]);
+ }
+
+ free (d->trans - 2);
+ free (d->fails);
+ free (d->newlines);
+ free (d->success);
+ }
+
+ if (d->superset)
+ dfafree (d->superset);
+}
+
+/* Having found the postfix representation of the regular expression,
+ try to find a long sequence of characters that must appear in any line
+ containing the r.e.
+ Finding a "longest" sequence is beyond the scope here;
+ we take an easy way out and hope for the best.
+ (Take "(ab|a)b"--please.)
+
+ We do a bottom-up calculation of sequences of characters that must appear
+ in matches of r.e.'s represented by trees rooted at the nodes of the postfix
+ representation:
+ sequences that must appear at the left of the match ("left")
+ sequences that must appear at the right of the match ("right")
+ lists of sequences that must appear somewhere in the match ("in")
+ sequences that must constitute the match ("is")
+
+ When we get to the root of the tree, we use one of the longest of its
+ calculated "in" sequences as our answer.
+
+ The sequences calculated for the various types of node (in pseudo ANSI c)
+ are shown below. "p" is the operand of unary operators (and the left-hand
+ operand of binary operators); "q" is the right-hand operand of binary
+ operators.
+
+ "ZERO" means "a zero-length sequence" below.
+
+ Type left right is in
+ ---- ---- ----- -- --
+ char c # c # c # c # c
+
+ ANYCHAR ZERO ZERO ZERO ZERO
+
+ MBCSET ZERO ZERO ZERO ZERO
+
+ CSET ZERO ZERO ZERO ZERO
+
+ STAR ZERO ZERO ZERO ZERO
+
+ QMARK ZERO ZERO ZERO ZERO
+
+ PLUS p->left p->right ZERO p->in
+
+ CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus
+ p->left : q->right : q->is!=ZERO) ? q->in plus
+ p->is##q->left p->right##q->is p->is##q->is : p->right##q->left
+ ZERO
+
+ OR longest common longest common (do p->is and substrings common
+ leading trailing to q->is have same p->in and
+ (sub)sequence (sub)sequence q->in length and content) ?
+ of p->left of p->right
+ and q->left and q->right p->is : NULL
+
+ If there's anything else we recognize in the tree, all four sequences get set
+ to zero-length sequences. If there's something we don't recognize in the
+ tree, we just return a zero-length sequence.
+
+ Break ties in favor of infrequent letters (choosing 'zzz' in preference to
+ 'aaa')?
+
+ And ... is it here or someplace that we might ponder "optimizations" such as
+ egrep 'psi|epsilon' -> egrep 'psi'
+ egrep 'pepsi|epsilon' -> egrep 'epsi'
+ (Yes, we now find "epsi" as a "string
+ that must occur", but we might also
+ simplify the *entire* r.e. being sought)
+ grep '[c]' -> grep 'c'
+ grep '(ab|a)b' -> grep 'ab'
+ grep 'ab*' -> grep 'a'
+ grep 'a*b' -> grep 'b'
+
+ There are several issues:
+
+ Is optimization easy (enough)?
+
+ Does optimization actually accomplish anything,
+ or is the automaton you get from "psi|epsilon" (for example)
+ the same as the one you get from "psi" (for example)?
+
+ Are optimizable r.e.'s likely to be used in real-life situations
+ (something like 'ab*' is probably unlikely; something like is
+ 'psi|epsilon' is likelier)? */
+
+static char *
+icatalloc (char *old, char const *new)
+{
+ char *result;
+ size_t oldsize;
+ size_t newsize = strlen (new);
+ if (newsize == 0)
+ return old;
+ oldsize = strlen (old);
+ result = xrealloc (old, oldsize + newsize + 1);
+ memcpy (result + oldsize, new, newsize + 1);
+ return result;
+}
+
+static void
+freelist (char **cpp)
+{
+ while (*cpp)
+ free (*cpp++);
+}
+
+static char **
+enlist (char **cpp, char *new, size_t len)
+{
+ size_t i, j;
+ new = memcpy (xmalloc (len + 1), new, len);
+ new[len] = '\0';
+ /* Is there already something in the list that's new (or longer)? */
+ for (i = 0; cpp[i] != NULL; ++i)
+ if (strstr (cpp[i], new) != NULL)
+ {
+ free (new);
+ return cpp;
+ }
+ /* Eliminate any obsoleted strings. */
+ j = 0;
+ while (cpp[j] != NULL)
+ if (strstr (new, cpp[j]) == NULL)
+ ++j;
+ else
+ {
+ free (cpp[j]);
+ if (--i == j)
+ break;
+ cpp[j] = cpp[i];
+ cpp[i] = NULL;
+ }
+ /* Add the new string. */
+ cpp = xnrealloc (cpp, i + 2, sizeof *cpp);
+ cpp[i] = new;
+ cpp[i + 1] = NULL;
+ return cpp;
+}
+
+/* Given pointers to two strings, return a pointer to an allocated
+ list of their distinct common substrings. */
+static char **
+comsubs (char *left, char const *right)
+{
+ char **cpp = xzalloc (sizeof *cpp);
+ char *lcp;
+
+ for (lcp = left; *lcp != '\0'; ++lcp)
+ {
+ size_t len = 0;
+ char *rcp = strchr (right, *lcp);
+ while (rcp != NULL)
+ {
+ size_t i;
+ for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i)
+ continue;
+ if (i > len)
+ len = i;
+ rcp = strchr (rcp + 1, *lcp);
+ }
+ if (len != 0)
+ cpp = enlist (cpp, lcp, len);
+ }
+ return cpp;
+}
+
+static char **
+addlists (char **old, char **new)
+{
+ for (; *new; new++)
+ old = enlist (old, *new, strlen (*new));
+ return old;
+}
+
+/* Given two lists of substrings, return a new list giving substrings
+ common to both. */
+static char **
+inboth (char **left, char **right)
+{
+ char **both = xzalloc (sizeof *both);
+ size_t lnum, rnum;
+
+ for (lnum = 0; left[lnum] != NULL; ++lnum)
+ {
+ for (rnum = 0; right[rnum] != NULL; ++rnum)
+ {
+ char **temp = comsubs (left[lnum], right[rnum]);
+ both = addlists (both, temp);
+ freelist (temp);
+ free (temp);
+ }
+ }
+ return both;
+}
+
+typedef struct must must;
+
+struct must
+{
+ char **in;
+ char *left;
+ char *right;
+ char *is;
+ bool begline;
+ bool endline;
+ must *prev;
+};
+
+static must *
+allocmust (must *mp, size_t size)
+{
+ must *new_mp = xmalloc (sizeof *new_mp);
+ new_mp->in = xzalloc (sizeof *new_mp->in);
+ new_mp->left = xzalloc (size);
+ new_mp->right = xzalloc (size);
+ new_mp->is = xzalloc (size);
+ new_mp->begline = false;
+ new_mp->endline = false;
+ new_mp->prev = mp;
+ return new_mp;
+}
+
+static void
+resetmust (must *mp)
+{
+ freelist (mp->in);
+ mp->in[0] = NULL;
+ mp->left[0] = mp->right[0] = mp->is[0] = '\0';
+ mp->begline = false;
+ mp->endline = false;
+}
+
+static void
+freemust (must *mp)
+{
+ freelist (mp->in);
+ free (mp->in);
+ free (mp->left);
+ free (mp->right);
+ free (mp->is);
+ free (mp);
+}
+
+struct dfamust *
+dfamust (struct dfa const *d)
+{
+ must *mp = NULL;
+ char const *result = "";
+ size_t i, ri;
+ bool exact = false;
+ bool begline = false;
+ bool endline = false;
+ size_t rj;
+ bool need_begline = false;
+ bool need_endline = false;
+ bool case_fold_unibyte = d->syntax.case_fold && MB_CUR_MAX == 1;
+ struct dfamust *dm;
+
+ for (ri = 0; ri < d->tindex; ++ri)
+ {
+ token t = d->tokens[ri];
+ switch (t)
+ {
+ case BEGLINE:
+ mp = allocmust (mp, 2);
+ mp->begline = true;
+ need_begline = true;
+ break;
+ case ENDLINE:
+ mp = allocmust (mp, 2);
+ mp->endline = true;
+ need_endline = true;
+ break;
+ case LPAREN:
+ case RPAREN:
+ assert (!"neither LPAREN nor RPAREN may appear here");
+
+ case EMPTY:
+ case BEGWORD:
+ case ENDWORD:
+ case LIMWORD:
+ case NOTLIMWORD:
+ case BACKREF:
+ case ANYCHAR:
+ case MBCSET:
+ mp = allocmust (mp, 2);
+ break;
+
+ case STAR:
+ case QMARK:
+ resetmust (mp);
+ break;
+
+ case OR:
+ {
+ char **new;
+ must *rmp = mp;
+ must *lmp = mp = mp->prev;
+ size_t j, ln, rn, n;
+
+ /* Guaranteed to be. Unlikely, but ... */
+ if (STREQ (lmp->is, rmp->is))
+ {
+ lmp->begline &= rmp->begline;
+ lmp->endline &= rmp->endline;
+ }
+ else
+ {
+ lmp->is[0] = '\0';
+ lmp->begline = false;
+ lmp->endline = false;
+ }
+ /* Left side--easy */
+ i = 0;
+ while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
+ ++i;
+ lmp->left[i] = '\0';
+ /* Right side */
+ ln = strlen (lmp->right);
+ rn = strlen (rmp->right);
+ n = ln;
+ if (n > rn)
+ n = rn;
+ for (i = 0; i < n; ++i)
+ if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1])
+ break;
+ for (j = 0; j < i; ++j)
+ lmp->right[j] = lmp->right[(ln - i) + j];
+ lmp->right[j] = '\0';
+ new = inboth (lmp->in, rmp->in);
+ freelist (lmp->in);
+ free (lmp->in);
+ lmp->in = new;
+ freemust (rmp);
+ }
+ break;
+
+ case PLUS:
+ mp->is[0] = '\0';
+ break;
+
+ case END:
+ assert (!mp->prev);
+ for (i = 0; mp->in[i] != NULL; ++i)
+ if (strlen (mp->in[i]) > strlen (result))
+ result = mp->in[i];
+ if (STREQ (result, mp->is))
+ {
+ if ((!need_begline || mp->begline) && (!need_endline
+ || mp->endline))
+ exact = true;
+ begline = mp->begline;
+ endline = mp->endline;
+ }
+ goto done;
+
+ case CAT:
+ {
+ must *rmp = mp;
+ must *lmp = mp = mp->prev;
+
+ /* In. Everything in left, plus everything in
+ right, plus concatenation of
+ left's right and right's left. */
+ lmp->in = addlists (lmp->in, rmp->in);
+ if (lmp->right[0] != '\0' && rmp->left[0] != '\0')
+ {
+ size_t lrlen = strlen (lmp->right);
+ size_t rllen = strlen (rmp->left);
+ char *tp = xmalloc (lrlen + rllen);
+ memcpy (tp, lmp->right, lrlen);
+ memcpy (tp + lrlen, rmp->left, rllen);
+ lmp->in = enlist (lmp->in, tp, lrlen + rllen);
+ free (tp);
+ }
+ /* Left-hand */
+ if (lmp->is[0] != '\0')
+ lmp->left = icatalloc (lmp->left, rmp->left);
+ /* Right-hand */
+ if (rmp->is[0] == '\0')
+ lmp->right[0] = '\0';
+ lmp->right = icatalloc (lmp->right, rmp->right);
+ /* Guaranteed to be */
+ if ((lmp->is[0] != '\0' || lmp->begline)
+ && (rmp->is[0] != '\0' || rmp->endline))
+ {
+ lmp->is = icatalloc (lmp->is, rmp->is);
+ lmp->endline = rmp->endline;
+ }
+ else
+ {
+ lmp->is[0] = '\0';
+ lmp->begline = false;
+ lmp->endline = false;
+ }
+ freemust (rmp);
+ }
+ break;
+
+ case '\0':
+ /* Not on *my* shift. */
+ goto done;
+
+ default:
+ if (CSET <= t)
+ {
+ /* If T is a singleton, or if case-folding in a unibyte
+ locale and T's members all case-fold to the same char,
+ convert T to one of its members. Otherwise, do
+ nothing further with T. */
+ charclass *ccl = &d->charclasses[t - CSET];
+ int j;
+ for (j = 0; j < NOTCHAR; j++)
+ if (tstbit (j, *ccl))
+ break;
+ if (! (j < NOTCHAR))
+ {
+ mp = allocmust (mp, 2);
+ break;
+ }
+ t = j;
+ while (++j < NOTCHAR)
+ if (tstbit (j, *ccl)
+ && ! (case_fold_unibyte
+ && toupper (j) == toupper (t)))
+ break;
+ if (j < NOTCHAR)
+ {
+ mp = allocmust (mp, 2);
+ break;
+ }
+ }
+
+ rj = ri + 2;
+ if (d->tokens[ri + 1] == CAT)
+ {
+ for (; rj < d->tindex - 1; rj += 2)
+ {
+ if ((rj != ri && (d->tokens[rj] <= 0
+ || NOTCHAR <= d->tokens[rj]))
+ || d->tokens[rj + 1] != CAT)
+ break;
+ }
+ }
+ mp = allocmust (mp, ((rj - ri) >> 1) + 1);
+ mp->is[0] = mp->left[0] = mp->right[0]
+ = case_fold_unibyte ? toupper (t) : t;
+
+ for (i = 1; ri + 2 < rj; i++)
+ {
+ ri += 2;
+ t = d->tokens[ri];
+ mp->is[i] = mp->left[i] = mp->right[i]
+ = case_fold_unibyte ? toupper (t) : t;
+ }
+ mp->is[i] = mp->left[i] = mp->right[i] = '\0';
+ mp->in = enlist (mp->in, mp->is, i);
+ break;
+ }
+ }
+ done:;
+
+ dm = NULL;
+ if (*result)
+ {
+ dm = xmalloc (sizeof *dm);
+ dm->exact = exact;
+ dm->begline = begline;
+ dm->endline = endline;
+ dm->must = xstrdup (result);
+ }
+
+ while (mp)
+ {
+ must *prev = mp->prev;
+ freemust (mp);
+ mp = prev;
+ }
+
+ return dm;
+}
+
+void
+dfamustfree (struct dfamust *dm)
+{
+ free (dm->must);
+ free (dm);
+}
+
+struct dfa *
+dfaalloc (void)
+{
+ return xmalloc (sizeof (struct dfa));
+}
+
+/* Initialize DFA. */
+void
+dfasyntax (struct dfa *dfa, struct localeinfo const *linfo,
+ reg_syntax_t bits, int dfaopts)
+{
+ int i;
+ memset (dfa, 0, offsetof (struct dfa, dfaexec));
+ dfa->dfaexec = linfo->multibyte ? dfaexec_mb : dfaexec_sb;
+ dfa->simple_locale = using_simple_locale (linfo->multibyte);
+ dfa->localeinfo = *linfo;
+
+ dfa->fast = !dfa->localeinfo.multibyte;
+
+ dfa->canychar = -1;
+ dfa->lex.cur_mb_len = 1;
+ dfa->syntax.syntax_bits_set = true;
+ dfa->syntax.case_fold = (bits & RE_ICASE) != 0;
+ dfa->syntax.anchor = (dfaopts & DFA_ANCHOR) != 0;
+ dfa->syntax.eolbyte = dfaopts & DFA_EOL_NUL ? '\0' : '\n';
+ dfa->syntax.syntax_bits = bits;
+
+ for (i = CHAR_MIN; i <= CHAR_MAX; ++i)
+ {
+ unsigned char uc = i;
+
+ dfa->syntax.sbit[uc] = char_context (dfa, uc);
+ switch (dfa->syntax.sbit[uc])
+ {
+ case CTX_LETTER:
+ setbit (uc, dfa->syntax.letters);
+ break;
+ case CTX_NEWLINE:
+ setbit (uc, dfa->syntax.newline);
+ break;
+ }
+
+ /* POSIX requires that the five bytes in "\n\r./" (including the
+ terminating NUL) cannot occur inside a multibyte character. */
+ dfa->syntax.never_trail[uc] = (dfa->localeinfo.using_utf8
+ ? (uc & 0xc0) != 0x80
+ : strchr ("\n\r./", uc) != NULL);
+ }
+}
+
+/* vim:set shiftwidth=2: */
diff --git a/lib/dfa.h b/lib/dfa.h
new file mode 100644
index 0000000..500ee76
--- /dev/null
+++ b/lib/dfa.h
@@ -0,0 +1,123 @@
+/* dfa.h - declarations for GNU deterministic regexp compiler
+ Copyright (C) 1988, 1998, 2007, 2009-2016 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 June, 1988 by Mike Haertel */
+
+#include <regex.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+#if 3 <= __GNUC__
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC
+#endif
+
+struct localeinfo; /* See localeinfo.h. */
+
+/* Element of a list of strings, at least one of which is known to
+ appear in any R.E. matching the DFA. */
+struct dfamust
+{
+ bool exact;
+ bool begline;
+ bool endline;
+ char *must;
+};
+
+/* The dfa structure. It is completely opaque. */
+struct dfa;
+
+/* Entry points. */
+
+/* Allocate a struct dfa. The struct dfa is completely opaque.
+ The returned pointer should be passed directly to free() after
+ calling dfafree() on it. */
+extern struct dfa *dfaalloc (void) _GL_ATTRIBUTE_MALLOC;
+
+/* DFA options that can be ORed together, for dfasyntax's 4th arg. */
+enum
+ {
+ /* ^ and $ match only the start and end of data, and do not match
+ end-of-line within data. This is always false for grep, but
+ possibly true for other apps. */
+ DFA_ANCHOR = 1 << 0,
+
+ /* '\0' in data is end-of-line, instead of the traditional '\n'. */
+ DFA_EOL_NUL = 1 << 1
+ };
+
+/* Initialize or reinitialize a DFA. This must be called before
+ any of the routines below. The arguments are:
+ 1. The DFA to operate on.
+ 2. Information about the current locale.
+ 3. Syntax bits described in regex.h.
+ 4. Additional DFA options described above. */
+extern void dfasyntax (struct dfa *, struct localeinfo const *,
+ reg_syntax_t, int);
+
+/* Build and return the struct dfamust from the given struct dfa. */
+extern struct dfamust *dfamust (struct dfa const *);
+
+/* Free the storage held by the components of a struct dfamust. */
+extern void dfamustfree (struct dfamust *);
+
+/* Compile the given string of the given length into the given struct dfa.
+ Final argument is a flag specifying whether to build a searching or an
+ exact matcher. */
+extern void dfacomp (char const *, size_t, struct dfa *, bool);
+
+/* Search through a buffer looking for a match to the given struct dfa.
+ Find the first occurrence of a string matching the regexp in the
+ buffer, and the shortest possible version thereof. Return a pointer to
+ the first character after the match, or NULL if none is found. BEGIN
+ points to the beginning of the buffer, and END points to the first byte
+ after its end. Note however that we store a sentinel byte (usually
+ newline) in *END, so the actual buffer must be one byte longer.
+ When ALLOW_NL is true, newlines may appear in the matching string.
+ If COUNT is non-NULL, increment *COUNT once for each newline processed.
+ Finally, if BACKREF is non-NULL set *BACKREF to indicate whether we
+ encountered a back-reference. The caller can use this to decide
+ whether to fall back on a backtracking matcher. */
+extern char *dfaexec (struct dfa *d, char const *begin, char *end,
+ bool allow_nl, size_t *count, bool *backref);
+
+/* Return a superset for D. The superset matches everything that D
+ matches, along with some other strings (though the latter should be
+ rare, for efficiency reasons). Return a null pointer if no useful
+ superset is available. */
+extern struct dfa *dfasuperset (struct dfa const *d) _GL_ATTRIBUTE_PURE;
+
+/* The DFA is likely to be fast. */
+extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
+
+/* Free the storage held by the components of a struct dfa. */
+extern void dfafree (struct dfa *);
+
+/* Error handling. */
+
+/* dfawarn() is called by the regexp routines whenever a regex is compiled
+ that likely doesn't do what the user wanted. It takes a single
+ argument, a NUL-terminated string describing the situation. The user
+ must supply a dfawarn. */
+extern void dfawarn (const char *);
+
+/* dfaerror() is called by the regexp routines whenever an error occurs. It
+ takes a single argument, a NUL-terminated string describing the error.
+ The user must supply a dfaerror. */
+extern _Noreturn void dfaerror (const char *);
diff --git a/lib/dirname-lgpl.c b/lib/dirname-lgpl.c
index 2895cbc..a7aabf9 100644
--- a/lib/dirname-lgpl.c
+++ b/lib/dirname-lgpl.c
@@ -1,6 +1,6 @@
/* dirname.c -- return all but the last element in a file name
- Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2012 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/dirname.h b/lib/dirname.h
index 51a685c..875b31b 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2012 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2016 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -31,6 +31,10 @@
# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
# endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
# if GNULIB_DIRNAME
char *base_name (char const *file);
char *dir_name (char const *file);
@@ -43,4 +47,8 @@ char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file);
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
#endif /* not DIRNAME_H_ */
diff --git a/lib/dosname.h b/lib/dosname.h
index 0468ce4..83a953f 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -1,6 +1,6 @@
/* File names on MS-DOS/Windows systems.
- Copyright (C) 2000-2001, 2004-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2000-2001, 2004-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/errno.in.h b/lib/errno.in.h
index daf7b44..b8397ee 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A POSIX-like <errno.h>.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/error.c b/lib/error.c
index 7d2bc71..b3b1286 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2007, 2009-2016 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
@@ -39,6 +39,11 @@
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
+# define USE_UNLOCKED_IO 0
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
+# define _GL_ARG_NONNULL(a)
+#else
+# include "getprogname.h"
#endif
#if USE_UNLOCKED_IO
@@ -72,14 +77,14 @@ extern void __error (int status, int errnum, const char *message, ...)
extern void __error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message,
...)
- __attribute__ ((__format__ (__printf__, 5, 6)));;
+ __attribute__ ((__format__ (__printf__, 5, 6)));
# define error __error
# define error_at_line __error_at_line
# include <libio/iolibio.h>
-# define fflush(s) INTUSE(_IO_fflush) (s)
+# define fflush(s) _IO_fflush (s)
# undef putc
-# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
+# define putc(c, fp) _IO_putc (c, fp)
# include <bits/libc-lock.h>
@@ -110,9 +115,7 @@ int strerror_r ();
# endif
# endif
-/* The calling program should define program_name and set it to the
- name of the executing program. */
-extern char *program_name;
+#define program_name getprogname ()
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
@@ -171,7 +174,7 @@ print_errno_message (int errnum)
#if defined HAVE_STRERROR_R || _LIBC
char errbuf[1024];
-# if STRERROR_R_CHAR_P || _LIBC
+# if _LIBC || STRERROR_R_CHAR_P
s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
@@ -195,13 +198,12 @@ print_errno_message (int errnum)
#endif
}
-static void
+static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
error_tail (int status, int errnum, const char *message, va_list args)
{
#if _LIBC
if (_IO_fwide (stderr, 0) > 0)
{
-# define ALLOCA_LIMIT 2000
size_t len = strlen (message) + 1;
wchar_t *wmessage = NULL;
mbstate_t st;
@@ -237,7 +239,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
if (res != len)
break;
- if (__builtin_expect (len >= SIZE_MAX / 2, 0))
+ if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
{
/* This really should not happen if everything is fine. */
res = (size_t) -1;
@@ -342,7 +344,10 @@ error_at_line (int status, int errnum, const char *file_name,
if (old_line_number == line_number
&& (file_name == old_file_name
- || strcmp (old_file_name, file_name) == 0))
+ || (old_file_name != NULL
+ && file_name != NULL
+ && strcmp (old_file_name, file_name) == 0)))
+
/* Simply return and print nothing. */
return;
@@ -374,10 +379,10 @@ error_at_line (int status, int errnum, const char *file_name,
}
#if _LIBC
- __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
+ __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
file_name, line_number);
#else
- fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
+ fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
file_name, line_number);
#endif
diff --git a/lib/error.h b/lib/error.h
index 9c2cb8b..6a69db0 100644
--- a/lib/error.h
+++ b/lib/error.h
@@ -1,5 +1,5 @@
/* Declaration for error-reporting function
- Copyright (C) 1995-1997, 2003, 2006, 2008-2012 Free Software Foundation,
+ Copyright (C) 1995-1997, 2003, 2006, 2008-2016 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
@@ -31,6 +31,16 @@
# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
#endif
+/* On mingw, the flavor of printf depends on whether the extensions module
+ * is in use; the check for <stdio.h> determines the witness macro. */
+#ifndef _GL_ATTRIBUTE_SPEC_PRINTF
+# if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
+# define _GL_ATTRIBUTE_SPEC_PRINTF __gnu_printf__
+# else
+# define _GL_ATTRIBUTE_SPEC_PRINTF __printf__
+# endif
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -40,11 +50,11 @@ extern "C" {
If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
extern void error (int __status, int __errnum, const char *__format, ...)
- _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
+ _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 3, 4));
extern void error_at_line (int __status, int __errnum, const char *__fname,
unsigned int __lineno, const char *__format, ...)
- _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
+ _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF, 5, 6));
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
diff --git a/lib/exitfail.c b/lib/exitfail.c
index fdd674c..8033c22 100644
--- a/lib/exitfail.c
+++ b/lib/exitfail.c
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/exitfail.h b/lib/exitfail.h
index 074f212..62311bd 100644
--- a/lib/exitfail.h
+++ b/lib/exitfail.h
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 604c31b..b943973 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
- Copyright (C) 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 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
@@ -34,7 +34,7 @@
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)))
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
@@ -53,7 +53,7 @@
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)))
+#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
# include <sys/stat.h>
#endif
/* The include_next requires a split double-inclusion guard. */
@@ -186,6 +186,22 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
/* Fix up the O_* macros. */
+/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
+ to values outside 'int' range, so omit these misdefinitions.
+ But avoid namespace pollution on non-AIX systems. */
+#ifdef _AIX
+# include <limits.h>
+# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
+# undef O_CLOEXEC
+# endif
+# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
+# undef O_NOFOLLOW
+# endif
+# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
+# undef O_TTY_INIT
+# endif
+#endif
+
#if !defined O_DIRECT && defined O_DIRECTIO
/* Tru64 spells it 'O_DIRECTIO'. */
# define O_DIRECT O_DIRECTIO
diff --git a/lib/fpending.c b/lib/fpending.c
new file mode 100644
index 0000000..ce93604
--- /dev/null
+++ b/lib/fpending.c
@@ -0,0 +1,60 @@
+/* fpending.c -- return the number of pending output bytes on a stream
+ Copyright (C) 2000, 2004, 2006-2007, 2009-2016 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+/* Specification. */
+#include "fpending.h"
+
+#include "stdio-impl.h"
+
+/* Return the number of pending (aka buffered, unflushed)
+ bytes on the stream, FP, that is open for writing. */
+size_t
+__fpending (FILE *fp)
+{
+ /* Most systems provide FILE as a struct and the necessary bitmask in
+ <stdio.h>, because they need it for implementing getc() and putc() as
+ fast macros. */
+#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+ return fp->_IO_write_ptr - fp->_IO_write_base;
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
+ return fp->_p - fp->_bf._base;
+#elif defined __EMX__ /* emx+gcc */
+ return fp->_ptr - fp->_buffer;
+#elif defined __minix /* Minix */
+ return fp_->_ptr - fp_->_buf;
+#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel */
+ return (fp_->_ptr ? fp_->_ptr - fp_->_base : 0);
+#elif defined __UCLIBC__ /* uClibc */
+ return (fp->__modeflags & __FLAG_WRITING ? fp->__bufpos - fp->__bufstart : 0);
+#elif defined __QNX__ /* QNX */
+ return (fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0);
+#elif defined __MINT__ /* Atari FreeMiNT */
+ return fp->__bufp - fp->__buffer;
+#elif defined EPLAN9 /* Plan9 */
+ return fp->wp - fp->buf;
+#elif defined __VMS /* VMS */
+ return (*fp)->_ptr - (*fp)->_base;
+#else
+# error "Please port gnulib fpending.c to your platform!"
+ return 1;
+#endif
+}
diff --git a/lib/fpending.h b/lib/fpending.h
new file mode 100644
index 0000000..61008aa
--- /dev/null
+++ b/lib/fpending.h
@@ -0,0 +1,29 @@
+/* Declare __fpending.
+
+ Copyright (C) 2000, 2003, 2005-2006, 2009-2016 Free Software Foundation,
+ Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Written by Jim Meyering. */
+
+#include <stddef.h>
+#include <stdio.h>
+#if HAVE_STDIO_EXT_H
+# include <stdio_ext.h>
+#endif
+
+#if !HAVE_DECL___FPENDING
+size_t __fpending (FILE *) _GL_ATTRIBUTE_PURE;
+#endif
diff --git a/lib/fstat.c b/lib/fstat.c
index 0418cc6..435c429 100644
--- a/lib/fstat.c
+++ b/lib/fstat.c
@@ -1,5 +1,5 @@
/* fstat() replacement.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/fwriting.c b/lib/fwriting.c
index d4d2703..be9f3c3 100644
--- a/lib/fwriting.c
+++ b/lib/fwriting.c
@@ -1,5 +1,5 @@
/* Retrieve information about a FILE stream.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,14 +29,15 @@ fwriting (FILE *fp)
fast macros. */
#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
return (fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) != 0;
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
+#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
return (fp_->_flags & __SWR) != 0;
#elif defined __EMX__ /* emx+gcc */
return (fp->_flags & _IOWRT) != 0;
#elif defined __minix /* Minix */
return (fp->_flags & _IOWRITING) != 0;
-#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
- return (fp->_flag & _IOWRT) != 0;
+#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, MSVC, NonStop Kernel */
+ return (fp_->_flag & _IOWRT) != 0;
#elif defined __UCLIBC__ /* uClibc */
return (fp->__modeflags & __FLAG_WRITING) != 0;
#elif defined __QNX__ /* QNX */
diff --git a/lib/fwriting.h b/lib/fwriting.h
index 13415b9..f4c7ed7 100644
--- a/lib/fwriting.h
+++ b/lib/fwriting.h
@@ -1,5 +1,5 @@
/* Retrieve information about a FILE stream.
- Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2016 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
@@ -44,7 +44,7 @@
extern "C" {
# endif
-extern bool fwriting (FILE *stream);
+extern bool fwriting (FILE *stream) _GL_ATTRIBUTE_PURE;
# ifdef __cplusplus
}
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
new file mode 100644
index 0000000..bf40dad
--- /dev/null
+++ b/lib/get-permissions.c
@@ -0,0 +1,291 @@
+/* Get permissions of a file. -*- coding: utf-8 -*-
+
+ Copyright (C) 2002-2003, 2005-2016 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, Andreas Grünbacher, and Bruno Haible. */
+
+#include <config.h>
+
+#include <string.h>
+#include "acl.h"
+
+#include "acl-internal.h"
+
+/* Read the permissions of a file into CTX. If DESC is a valid file descriptor,
+ use file descriptor operations, else use filename based operations on NAME.
+ MODE is the file mode obtained from a previous stat call.
+ Return 0 if successful. Return -1 and set errno upon failure. */
+
+int
+get_permissions (const char *name, int desc, mode_t mode,
+ struct permission_context *ctx)
+{
+ memset (ctx, 0, sizeof *ctx);
+ ctx->mode = mode;
+
+#if USE_ACL && HAVE_ACL_GET_FILE
+ /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
+ /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
+# if !HAVE_ACL_TYPE_EXTENDED
+ /* Linux, FreeBSD, IRIX, Tru64 */
+
+ if (HAVE_ACL_GET_FD && desc != -1)
+ ctx->acl = acl_get_fd (desc);
+ else
+ ctx->acl = acl_get_file (name, ACL_TYPE_ACCESS);
+ if (ctx->acl == NULL)
+ return acl_errno_valid (errno) ? -1 : 0;
+
+ /* With POSIX ACLs, a file cannot have "no" acl; a file without
+ extended permissions has a "minimal" acl which is equivalent to the
+ file mode. */
+
+ if (S_ISDIR (mode))
+ {
+ ctx->default_acl = acl_get_file (name, ACL_TYPE_DEFAULT);
+ if (ctx->default_acl == NULL)
+ return -1;
+ }
+
+# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
+
+ /* TODO (see set_permissions). */
+
+# endif
+
+# else /* HAVE_ACL_TYPE_EXTENDED */
+ /* Mac OS X */
+
+ /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
+ and acl_get_file (name, ACL_TYPE_DEFAULT)
+ always return NULL / EINVAL. You have to use
+ acl_get_file (name, ACL_TYPE_EXTENDED)
+ or acl_get_fd (open (name, ...))
+ to retrieve an ACL.
+ On the other hand,
+ acl_set_file (name, ACL_TYPE_ACCESS, acl)
+ and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
+ have the same effect as
+ acl_set_file (name, ACL_TYPE_EXTENDED, acl):
+ Each of these calls sets the file's ACL. */
+
+ if (HAVE_ACL_GET_FD && desc != -1)
+ ctx->acl = acl_get_fd (desc);
+ else
+ ctx->acl = acl_get_file (name, ACL_TYPE_EXTENDED);
+ if (ctx->acl == NULL)
+ return acl_errno_valid (errno) ? -1 : 0;
+
+# endif
+
+#elif USE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
+
+ /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
+ of Unixware. The acl() call returns the access and default ACL both
+ at once. */
+# ifdef ACE_GETACL
+ /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
+ file systems (whereas the other ones are used in UFS file systems).
+ There is an API
+ pathconf (name, _PC_ACL_ENABLED)
+ fpathconf (desc, _PC_ACL_ENABLED)
+ that allows us to determine which of the two kinds of ACLs is supported
+ for the given file. But some file systems may implement this call
+ incorrectly, so better not use it.
+ When fetching the source ACL, we simply fetch both ACL types.
+ When setting the destination ACL, we try either ACL types, assuming
+ that the kernel will translate the ACL from one form to the other.
+ (See in <http://docs.sun.com/app/docs/doc/819-2241/6n4huc7ia?l=en&a=view>
+ the description of ENOTSUP.) */
+ for (;;)
+ {
+ int ret;
+
+ if (desc != -1)
+ ret = facl (desc, ACE_GETACLCNT, 0, NULL);
+ else
+ ret = acl (name, ACE_GETACLCNT, 0, NULL);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == EINVAL)
+ ret = 0;
+ else
+ return -1;
+ }
+ ctx->ace_count = ret;
+
+ if (ctx->ace_count == 0)
+ break;
+
+ ctx->ace_entries = (ace_t *) malloc (ctx->ace_count * sizeof (ace_t));
+ if (ctx->ace_entries == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (desc != -1)
+ ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
+ else
+ ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == EINVAL)
+ {
+ free (ctx->ace_entries);
+ ctx->ace_entries = NULL;
+ ctx->ace_count = 0;
+ break;
+ }
+ else
+ return -1;
+ }
+ if (ret <= ctx->ace_count)
+ {
+ ctx->ace_count = ret;
+ break;
+ }
+ /* Huh? The number of ACL entries has increased since the last call.
+ Repeat. */
+ free (ctx->ace_entries);
+ ctx->ace_entries = NULL;
+ }
+# endif
+
+ for (;;)
+ {
+ int ret;
+
+ if (desc != -1)
+ ret = facl (desc, GETACLCNT, 0, NULL);
+ else
+ ret = acl (name, GETACLCNT, 0, NULL);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
+ ret = 0;
+ else
+ return -1;
+ }
+ ctx->count = ret;
+
+ if (ctx->count == 0)
+ break;
+
+ ctx->entries = (aclent_t *) malloc (ctx->count * sizeof (aclent_t));
+ if (ctx->entries == NULL)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (desc != -1)
+ ret = facl (desc, GETACL, ctx->count, ctx->entries);
+ else
+ ret = acl (name, GETACL, ctx->count, ctx->entries);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
+ {
+ free (ctx->entries);
+ ctx->entries = NULL;
+ ctx->count = 0;
+ break;
+ }
+ else
+ return -1;
+ }
+ if (ret <= ctx->count)
+ {
+ ctx->count = ret;
+ break;
+ }
+ /* Huh? The number of ACL entries has increased since the last call.
+ Repeat. */
+ free (ctx->entries);
+ ctx->entries = NULL;
+ }
+
+#elif USE_ACL && HAVE_GETACL /* HP-UX */
+
+ {
+ int ret;
+
+ if (desc != -1)
+ ret = fgetacl (desc, NACLENTRIES, ctx->entries);
+ else
+ ret = getacl (name, NACLENTRIES, ctx->entries);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+ ret = 0;
+ else
+ return -1;
+ }
+ else if (ret > NACLENTRIES)
+ /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */
+ abort ();
+ ctx->count = ret;
+
+# if HAVE_ACLV_H
+ ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+ ret = 0;
+ else
+ return -2;
+ }
+ else if (ret > NACLVENTRIES)
+ /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation. */
+ abort ();
+ ctx->aclv_count = ret;
+# endif
+ }
+
+#elif USE_ACL && HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
+
+ /* TODO (see set_permissions). */
+
+#elif USE_ACL && HAVE_STATACL /* older AIX */
+
+ {
+ int ret;
+ if (desc != -1)
+ ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+ else
+ ret = statacl ((char *) name, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+ if (ret == 0)
+ ctx->have_u = true;
+ }
+
+#elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
+
+ {
+ int ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
+ if (ret < 0)
+ return -1;
+ else if (ret > NACLENTRIES)
+ /* If NACLENTRIES cannot be trusted, use dynamic memory allocation. */
+ abort ();
+ ctx->count = ret;
+ }
+
+#endif
+
+ return 0;
+
+}
diff --git a/lib/getdelim.c b/lib/getdelim.c
index 6c2dd3d..175d5c7 100644
--- a/lib/getdelim.c
+++ b/lib/getdelim.c
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* getdelim.c --- Implementation of replacement getdelim function.
- Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2012 Free Software
+ Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or
@@ -19,12 +17,12 @@
/* 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 <config.h>
+
#include <stdio.h>
#include <limits.h>
@@ -49,6 +47,16 @@
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
#endif
+static void
+alloc_failed (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* Avoid errno problem without using the realloc module; see:
+ http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#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
@@ -76,6 +84,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, *n);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
@@ -113,6 +122,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
new_lineptr = (char *) realloc (*lineptr, needed);
if (new_lineptr == NULL)
{
+ alloc_failed ();
result = -1;
goto unlock_return;
}
diff --git a/lib/getfilecon.c b/lib/getfilecon.c
index f9c3f58..a124071 100644
--- a/lib/getfilecon.c
+++ b/lib/getfilecon.c
@@ -1,5 +1,5 @@
/* wrap getfilecon, lgetfilecon, and fgetfilecon
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 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
@@ -57,6 +57,7 @@ map_to_failure (int ret, security_context_t *con)
if (ret == 10 && strcmp (*con, "unlabeled") == 0)
{
freecon (*con);
+ *con = NULL;
errno = ENODATA;
return -1;
}
diff --git a/lib/getopt.c b/lib/getopt.c
index 4342a34..8ccb901 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -2,7 +2,7 @@
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-2012 Free Software
+ Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2016 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@@ -487,7 +487,20 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
const struct option *p;
struct option_list *next;
} *ambig_list = NULL;
+#ifdef _LIBC
+/* malloc() not used for _LIBC to simplify failure messages. */
+# define free_option_list(l)
+#else
+# define free_option_list(l) \
+ while (l != NULL) \
+ { \
+ struct option_list *pn = l->next; \
+ free (l); \
+ l = pn; \
+ }
+#endif
int exact = 0;
+ int ambig = 0;
int indfound = -1;
int option_index;
@@ -514,22 +527,37 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
pfound = p;
indfound = option_index;
}
+ else if (ambig)
+ ; /* Taking simpler path to handling ambiguities. */
else if (long_only
|| pfound->has_arg != p->has_arg
|| pfound->flag != p->flag
|| pfound->val != p->val)
{
/* Second or later nonexact match found. */
+#ifdef _LIBC
+ struct option_list *newp = alloca (sizeof (*newp));
+#else
struct option_list *newp = malloc (sizeof (*newp));
- newp->p = p;
- newp->next = ambig_list;
- ambig_list = newp;
+ if (newp == NULL)
+ {
+ free_option_list (ambig_list);
+ ambig_list = NULL;
+ ambig = 1; /* Use simpler fallback message. */
+ }
+ else
+#endif
+ {
+ newp->p = p;
+ newp->next = ambig_list;
+ ambig_list = newp;
+ }
}
}
- if (ambig_list != NULL && !exact)
+ if ((ambig || ambig_list) && !exact)
{
- if (print_errors)
+ if (print_errors && ambig_list)
{
struct option_list first;
first.p = pfound;
@@ -585,18 +613,20 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
fputc ('\n', stderr);
#endif
}
+ else if (print_errors && ambig)
+ {
+ fprintf (stderr,
+ _("%s: option '%s' is ambiguous\n"),
+ argv[0], argv[d->optind]);
+ }
d->__nextchar += strlen (d->__nextchar);
d->optind++;
d->optopt = 0;
+ free_option_list (ambig_list);
return '?';
}
- while (ambig_list != NULL)
- {
- struct option_list *pn = ambig_list->next;
- free (ambig_list);
- ambig_list = pn;
- }
+ free_option_list (ambig_list);
if (pfound != NULL)
{
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index 06b6dfc..64469b7 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -1,5 +1,5 @@
/* Declarations for getopt.
- Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2012 Free Software
+ Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2016 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@@ -47,13 +47,20 @@
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>
+#if defined __GETOPT_PREFIX
+# if !defined __need_getopt
+# if !@HAVE_GETOPT_H@
+# define __need_system_stdlib_h
+# include <stdlib.h>
+# undef __need_system_stdlib_h
+# include <stdio.h>
+# include <unistd.h>
+# endif
+# undef __need_getopt
# endif
-# undef __need_getopt
+# undef __GETOPT_CONCAT
+# undef __GETOPT_XCONCAT
+# undef __GETOPT_ID
# undef getopt
# undef getopt_long
# undef getopt_long_only
@@ -62,6 +69,7 @@
# undef optind
# undef optopt
# undef option
+# undef _getopt_internal
# 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)
diff --git a/lib/getopt1.c b/lib/getopt1.c
index fb2a8f5..63db74f 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2012 Free Software
+ Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2016 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
diff --git a/lib/getopt_int.h b/lib/getopt_int.h
index 2da020c..be4c22e 100644
--- a/lib/getopt_int.h
+++ b/lib/getopt_int.h
@@ -1,5 +1,5 @@
/* Internal declarations for getopt.
- Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2012 Free Software
+ Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2016 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
diff --git a/lib/getprogname.c b/lib/getprogname.c
new file mode 100644
index 0000000..a7246e9
--- /dev/null
+++ b/lib/getprogname.c
@@ -0,0 +1,151 @@
+/* Program name management.
+ Copyright (C) 2016 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 "getprogname.h"
+
+#include <errno.h> /* get program_invocation_name declaration */
+#include <stdlib.h> /* get __argv declaration */
+
+#ifdef _AIX
+# include <unistd.h>
+# include <procinfo.h>
+# include <string.h>
+#endif
+
+#ifdef __MVS__
+# ifndef _OPEN_SYS
+# define _OPEN_SYS
+# endif
+# include <string.h>
+# include <sys/ps.h>
+#endif
+
+#ifdef __hpux
+# include <unistd.h>
+# include <sys/param.h>
+# include <sys/pstat.h>
+# include <string.h>
+#endif
+
+#include "dirname.h"
+
+#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
+char const *
+getprogname (void)
+{
+# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */
+ /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
+ return program_invocation_short_name;
+# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */
+ /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
+ return last_component (program_invocation_name);
+# elif HAVE_GETEXECNAME /* Solaris */
+ /* http://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
+ const char *p = getexecname ();
+ if (!p)
+ p = "?";
+ return last_component (p);
+# elif HAVE_DECL___ARGV /* mingw, MSVC */
+ /* https://msdn.microsoft.com/en-us/library/dn727674.aspx */
+ const char *p = __argv && __argv[0] ? __argv[0] : "?";
+ return last_component (p);
+# elif HAVE_VAR___PROGNAME /* OpenBSD, QNX */
+ /* http://man.openbsd.org/style.9 */
+ /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
+ /* Be careful to declare this only when we absolutely need it
+ (OpenBSD 5.1), rather than when it's available. Otherwise,
+ its mere declaration makes program_invocation_short_name
+ malfunction (have zero length) with Fedora 25's glibc. */
+ extern char *__progname;
+ const char *p = __progname;
+ return p && p[0] ? p : "?";
+# elif _AIX /* AIX */
+ /* Idea by Bastien ROUCARIÈS,
+ http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00095.html
+ Reference: http://
+ ibm.biz/knowctr#ssw_aix_53/com.ibm.aix.basetechref/doc/basetrf1/getprocs.htm
+ */
+ static char *p;
+ static int first = 1;
+ if (first)
+ {
+ first = 0;
+ pid_t pid = getpid ();
+ struct procentry64 procs;
+ p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
+ ? strdup (procs.pi_comm)
+ : NULL);
+ if (!p)
+ p = "?";
+ }
+ return p;
+# elif defined __hpux
+ static char *p;
+ static int first = 1;
+ if (first)
+ {
+ first = 0;
+ pid_t pid = getpid ();
+ struct pst_status status;
+ p = (0 < pstat_getproc (&status, sizeof status, 0, pid)
+ ? strdup (status.pst_ucomm)
+ : NULL);
+ if (!p)
+ p = "?";
+ }
+ return p;
+# elif __MVS__ /* z/OS */
+ /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */
+ static char *p = "?";
+ static int first = 1;
+ if (first)
+ {
+ pid_t pid = getpid ();
+ int token;
+ W_PSPROC buf;
+ first = 0;
+ memset (&buf, 0, sizeof(buf));
+ buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG);
+ buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN);
+ buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
+ if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
+ {
+ for (token = 0; token >= 0;
+ token = w_getpsent (token, &buf, sizeof(buf)))
+ {
+ if (token > 0 && buf.ps_pid == pid)
+ {
+ char *s = strdup (last_component (buf.ps_pathptr));
+ if (s)
+ p = s;
+ break;
+ }
+ }
+ }
+ free (buf.ps_cmdptr);
+ free (buf.ps_conttyptr);
+ free (buf.ps_pathptr);
+ }
+ return p;
+# else
+# error "getprogname module not ported to this OS"
+# endif
+}
+
+#endif
diff --git a/lib/getprogname.h b/lib/getprogname.h
new file mode 100644
index 0000000..e8f9e97
--- /dev/null
+++ b/lib/getprogname.h
@@ -0,0 +1,40 @@
+/* Program name management.
+ Copyright (C) 2016 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_GETPROGNAME_H
+#define _GL_GETPROGNAME_H
+
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Return the base name of the executing program.
+ On native Windows this will usually end in ".exe" or ".EXE". */
+#ifndef HAVE_GETPROGNAME
+extern char const *getprogname (void)
+# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
+ _GL_ATTRIBUTE_PURE
+# endif
+ ;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/gettext.h b/lib/gettext.h
index 5235fe8..9a232cc 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2012 Free Software
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -227,15 +225,17 @@ dcpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
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);
+ found_translation = (translation != msg_ctxt_id);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (translation != msg_ctxt_id)
+ if (found_translation)
return translation;
}
return msgid;
@@ -273,15 +273,17 @@ dcnpgettext_expr (const char *domain,
if (msg_ctxt_id != NULL)
#endif
{
+ int found_translation;
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);
+ found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if (msg_ctxt_id != buf)
free (msg_ctxt_id);
#endif
- if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ if (found_translation)
return translation;
}
return (n == 1 ? msgid : msgid_plural);
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index ba328ae..224ca6a 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Provide gettimeofday for systems that don't have it or for which it's broken.
- Copyright (C) 2001-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c
new file mode 100644
index 0000000..935043b
--- /dev/null
+++ b/lib/glthread/lock.c
@@ -0,0 +1,1057 @@
+/* Locking in multithreaded situations.
+ Copyright (C) 2005-2016 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, see <http://www.gnu.org/licenses/>. */
+
+/* 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_WINDOWS_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 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 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 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/lib/glthread/lock.h b/lib/glthread/lock.h
new file mode 100644
index 0000000..e64506b
--- /dev/null
+++ b/lib/glthread/lock.h
@@ -0,0 +1,927 @@
+/* Locking in multithreaded situations.
+ Copyright (C) 2005-2016 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, see <http://www.gnu.org/licenses/>. */
+
+/* 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_WINDOWS_THREADS
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* We can use CRITICAL_SECTION directly, rather than the native Windows 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 native Windows 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_WINDOWS_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/lib/glthread/threadlib.c b/lib/glthread/threadlib.c
new file mode 100644
index 0000000..be63713
--- /dev/null
+++ b/lib/glthread/threadlib.c
@@ -0,0 +1,73 @@
+/* Multithreading primitives.
+ Copyright (C) 2005-2016 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, see <http://www.gnu.org/licenses/>. */
+
+/* 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/lib/gnulib.mk b/lib/gnulib.mk
index a5c0a79..5f69cd4 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2016 Free Software Foundation, Inc.
#
# 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
@@ -21,51 +21,58 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libsed --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alloca btowc c-ctype extensions fwriting getdelim getopt gettext-h localcharset mbrlen mbrtowc mbsinit memchr mkostemp obstack pathmax regex rename selinux-h ssize_t stat-macros stdbool strerror strverscmp unlocked-io verify version-etc-fsf wcrtomb wctob
+# Reproduce by: gnulib-tool --import --local-dir=gl --lib=libsed --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=gnulib-tests --aux-dir=build-aux --with-tests --avoid=lock-tests --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl acl alloca btowc c-ctype closeout dfa extensions fdl fwriting getdelim getopt gettext-h git-version-gen gitlog-to-changelog ignore-value localcharset manywarnings mbrlen mbrtowc mbsinit memchr memrchr mkostemp non-recursive-gnulib-prefix-hack obstack progname readme-release regex rename selinux-h ssize_t stat-macros stdalign stdbool strerror strverscmp threadlib unlocked-io update-copyright verify version-etc-fsf wcrtomb wctob
-AUTOMAKE_OPTIONS = 1.5 gnits
-SUBDIRS =
-noinst_HEADERS =
-noinst_LIBRARIES =
-noinst_LTLIBRARIES =
-EXTRA_DIST =
-BUILT_SOURCES =
-SUFFIXES =
-MOSTLYCLEANFILES = core *.stackdump
-MOSTLYCLEANDIRS =
-CLEANFILES =
-DISTCLEANFILES =
-MAINTAINERCLEANFILES =
+MOSTLYCLEANFILES += lib/core lib/*.stackdump
-AM_CPPFLAGS =
-AM_CFLAGS =
+noinst_LIBRARIES += lib/libsed.a
-noinst_LIBRARIES += libsed.a
+lib_libsed_a_SOURCES =
+lib_libsed_a_LIBADD = $(gl_LIBOBJS)
+lib_libsed_a_DEPENDENCIES = $(gl_LIBOBJS)
+EXTRA_lib_libsed_a_SOURCES =
-libsed_a_SOURCES =
-libsed_a_LIBADD = $(gl_LIBOBJS)
-libsed_a_DEPENDENCIES = $(gl_LIBOBJS)
-EXTRA_libsed_a_SOURCES =
+## begin gnulib module absolute-header
-## begin gnulib module acl
+# Use this preprocessor expression to decide whether #include_next works.
+# Do not rely on a 'configure'-time test for this, since the expression
+# might appear in an installed header, which is used by some other compiler.
+HAVE_INCLUDE_NEXT = lib/(__GNUC__ lib/|| lib/60000000 lib/<= lib/__DECC_VER)
-libsed_a_SOURCES += set-mode-acl.c copy-acl.c file-has-acl.c
+## end gnulib module absolute-header
-EXTRA_DIST += acl-internal.h acl.h acl_entries.c
+## begin gnulib module acl
-EXTRA_libsed_a_SOURCES += acl_entries.c
+lib_libsed_a_SOURCES += lib/copy-acl.c lib/set-acl.c
## end gnulib module acl
+## begin gnulib module acl-permissions
+
+lib_libsed_a_SOURCES += lib/acl-errno-valid.c lib/acl-internal.c lib/get-permissions.c lib/set-permissions.c
+
+EXTRA_DIST += lib/acl-internal.h lib/acl.h lib/acl_entries.c
+
+EXTRA_lib_libsed_a_SOURCES += lib/acl_entries.c
+
+## end gnulib module acl-permissions
+
+## begin gnulib module alignof
+
+
+EXTRA_DIST += lib/alignof.h
+
+## end gnulib module alignof
+
## begin gnulib module alloca
-libsed_a_LIBADD += @ALLOCA@
-libsed_a_DEPENDENCIES += @ALLOCA@
-EXTRA_DIST += alloca.c
+lib_libsed_a_LIBADD += @ALLOCA@
+lib_libsed_a_DEPENDENCIES += @ALLOCA@
+EXTRA_DIST += lib/alloca.c
-EXTRA_libsed_a_SOURCES += alloca.c
+EXTRA_lib_libsed_a_SOURCES += lib/alloca.c
## end gnulib module alloca
@@ -76,66 +83,89 @@ 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.
if GL_GENERATE_ALLOCA_H
-alloca.h: alloca.in.h $(top_builddir)/config.status
+lib/alloca.h: lib/alloca.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/alloca.in.h; \
+ cat $(top_srcdir)/lib/alloca.in.h; \
} > $@-t && \
mv -f $@-t $@
else
-alloca.h: $(top_builddir)/config.status
+lib/alloca.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += alloca.h alloca.h-t
+MOSTLYCLEANFILES += lib/alloca.h lib/alloca.h-t
-EXTRA_DIST += alloca.in.h
+EXTRA_DIST += lib/alloca.in.h
## end gnulib module alloca-opt
+## begin gnulib module announce-gen
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/announce-gen
+
+## end gnulib module announce-gen
+
## begin gnulib module btowc
-EXTRA_DIST += btowc.c
+EXTRA_DIST += lib/btowc.c
-EXTRA_libsed_a_SOURCES += btowc.c
+EXTRA_lib_libsed_a_SOURCES += lib/btowc.c
## end gnulib module btowc
## begin gnulib module c-ctype
-libsed_a_SOURCES += c-ctype.h c-ctype.c
+lib_libsed_a_SOURCES += lib/c-ctype.h lib/c-ctype.c
## end gnulib module c-ctype
## begin gnulib module c-strcase
-libsed_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c
+lib_libsed_a_SOURCES += lib/c-strcase.h lib/c-strcasecmp.c lib/c-strncasecmp.c
## end gnulib module c-strcase
## begin gnulib module c-strcaseeq
-EXTRA_DIST += c-strcaseeq.h
+EXTRA_DIST += lib/c-strcaseeq.h
## end gnulib module c-strcaseeq
## begin gnulib module canonicalize-lgpl
-EXTRA_DIST += canonicalize-lgpl.c
+EXTRA_DIST += lib/canonicalize-lgpl.c
-EXTRA_libsed_a_SOURCES += canonicalize-lgpl.c
+EXTRA_lib_libsed_a_SOURCES += lib/canonicalize-lgpl.c
## end gnulib module canonicalize-lgpl
+## begin gnulib module close-stream
+
+lib_libsed_a_SOURCES += lib/close-stream.c
+
+EXTRA_DIST += lib/close-stream.h
+
+## end gnulib module close-stream
+
+## begin gnulib module closeout
+
+lib_libsed_a_SOURCES += lib/closeout.c
+
+EXTRA_DIST += lib/closeout.h
+
+## end gnulib module closeout
+
## begin gnulib module configmake
# Listed in the same order as the GNU makefile conventions, and
-# provided by autoconf 2.59c+.
+# provided by autoconf 2.59c+ or 2.70.
# The Automake-defined pkg* macros are appended, in the order
# listed in the Automake 1.10a+ documentation.
-configmake.h: Makefile
+lib/configmake.h: Makefile
$(AM_V_GEN)rm -f $@-t && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
echo '#define PREFIX "$(prefix)"'; \
@@ -148,6 +178,7 @@ configmake.h: Makefile
echo '#define SYSCONFDIR "$(sysconfdir)"'; \
echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
+ echo '#define RUNSTATEDIR "$(runstatedir)"'; \
echo '#define INCLUDEDIR "$(includedir)"'; \
echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
echo '#define DOCDIR "$(docdir)"'; \
@@ -168,23 +199,65 @@ configmake.h: Makefile
} | sed '/""/d' > $@-t && \
mv -f $@-t $@
-BUILT_SOURCES += configmake.h
-CLEANFILES += configmake.h configmake.h-t
+BUILT_SOURCES += lib/configmake.h
+CLEANFILES += lib/configmake.h lib/configmake.h-t
## end gnulib module configmake
+## begin gnulib module ctype
+
+BUILT_SOURCES += lib/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.
+lib/ctype.h: lib/ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''GUARD_PREFIX''@|GL|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_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)' \
+ < $(top_srcdir)/lib/ctype.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += lib/ctype.h lib/ctype.h-t
+
+EXTRA_DIST += lib/ctype.in.h
+
+## end gnulib module ctype
+
+## begin gnulib module dfa
+
+lib_libsed_a_SOURCES += lib/dfa.c lib/localeinfo.c
+
+EXTRA_DIST += lib/dfa.h lib/localeinfo.h
+
+## end gnulib module dfa
+
## begin gnulib module dirname-lgpl
-libsed_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c
+lib_libsed_a_SOURCES += lib/dirname-lgpl.c lib/basename-lgpl.c lib/stripslash.c
-EXTRA_DIST += dirname.h
+EXTRA_DIST += lib/dirname.h
## end gnulib module dirname-lgpl
+## begin gnulib module do-release-commit-and-tag
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/do-release-commit-and-tag
+
+## end gnulib module do-release-commit-and-tag
+
## begin gnulib module dosname
-EXTRA_DIST += dosname.h
+EXTRA_DIST += lib/dosname.h
## end gnulib module dosname
@@ -195,7 +268,7 @@ BUILT_SOURCES += $(ERRNO_H)
# We need the following in order to create <errno.h> when the system
# doesn't have one that is POSIX compliant.
if GL_GENERATE_ERRNO_H
-errno.h: errno.in.h $(top_builddir)/config.status
+lib/errno.h: lib/errno.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -209,43 +282,43 @@ errno.h: errno.in.h $(top_builddir)/config.status
-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; \
+ < $(top_srcdir)/lib/errno.in.h; \
} > $@-t && \
mv $@-t $@
else
-errno.h: $(top_builddir)/config.status
+lib/errno.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += errno.h errno.h-t
+MOSTLYCLEANFILES += lib/errno.h lib/errno.h-t
-EXTRA_DIST += errno.in.h
+EXTRA_DIST += lib/errno.in.h
## end gnulib module errno
## begin gnulib module error
-EXTRA_DIST += error.c error.h
+EXTRA_DIST += lib/error.c lib/error.h
-EXTRA_libsed_a_SOURCES += error.c
+EXTRA_lib_libsed_a_SOURCES += lib/error.c
## end gnulib module error
## begin gnulib module exitfail
-libsed_a_SOURCES += exitfail.c
+lib_libsed_a_SOURCES += lib/exitfail.c
-EXTRA_DIST += exitfail.h
+EXTRA_DIST += lib/exitfail.h
## end gnulib module exitfail
## begin gnulib module fcntl-h
-BUILT_SOURCES += fcntl.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/fcntl.h: lib/fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -265,39 +338,55 @@ fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-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; \
+ < $(top_srcdir)/lib/fcntl.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += fcntl.h fcntl.h-t
+MOSTLYCLEANFILES += lib/fcntl.h lib/fcntl.h-t
-EXTRA_DIST += fcntl.in.h
+EXTRA_DIST += lib/fcntl.in.h
## end gnulib module fcntl-h
+## begin gnulib module fpending
+
+
+EXTRA_DIST += lib/fpending.c lib/fpending.h lib/stdio-impl.h
+
+EXTRA_lib_libsed_a_SOURCES += lib/fpending.c
+
+## end gnulib module fpending
+
## begin gnulib module fstat
-EXTRA_DIST += fstat.c
+EXTRA_DIST += lib/fstat.c
-EXTRA_libsed_a_SOURCES += fstat.c
+EXTRA_lib_libsed_a_SOURCES += lib/fstat.c
## end gnulib module fstat
## begin gnulib module fwriting
-EXTRA_DIST += fwriting.c fwriting.h stdio-impl.h
+EXTRA_DIST += lib/fwriting.c lib/fwriting.h lib/stdio-impl.h
-EXTRA_libsed_a_SOURCES += fwriting.c
+EXTRA_lib_libsed_a_SOURCES += lib/fwriting.c
## end gnulib module fwriting
+## begin gnulib module gendocs
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/gendocs.sh
+
+## end gnulib module gendocs
+
## begin gnulib module getdelim
-EXTRA_DIST += getdelim.c
+EXTRA_DIST += lib/getdelim.c
-EXTRA_libsed_a_SOURCES += getdelim.c
+EXTRA_lib_libsed_a_SOURCES += lib/getdelim.c
## end gnulib module getdelim
@@ -307,7 +396,7 @@ 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 $(top_builddir)/config.status $(ARG_NONNULL_H)
+lib/getopt.h: lib/getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -317,46 +406,121 @@ getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
-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; \
+ < $(top_srcdir)/lib/getopt.in.h; \
} > $@-t && \
mv -f $@-t $@
-MOSTLYCLEANFILES += getopt.h getopt.h-t
+MOSTLYCLEANFILES += lib/getopt.h lib/getopt.h-t
-EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h
+EXTRA_DIST += lib/getopt.c lib/getopt.in.h lib/getopt1.c lib/getopt_int.h
-EXTRA_libsed_a_SOURCES += getopt.c getopt1.c
+EXTRA_lib_libsed_a_SOURCES += lib/getopt.c lib/getopt1.c
## end gnulib module getopt-posix
+## begin gnulib module getprogname
+
+lib_libsed_a_SOURCES += lib/getprogname.h lib/getprogname.c
+
+## end gnulib module getprogname
+
## begin gnulib module gettext-h
-libsed_a_SOURCES += gettext.h
+lib_libsed_a_SOURCES += lib/gettext.h
## end gnulib module gettext-h
## begin gnulib module gettimeofday
-EXTRA_DIST += gettimeofday.c
+EXTRA_DIST += lib/gettimeofday.c
-EXTRA_libsed_a_SOURCES += gettimeofday.c
+EXTRA_lib_libsed_a_SOURCES += lib/gettimeofday.c
## end gnulib module gettimeofday
+## begin gnulib module git-version-gen
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/git-version-gen
+
+## end gnulib module git-version-gen
+
+## begin gnulib module gitlog-to-changelog
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/gitlog-to-changelog
+
+## end gnulib module gitlog-to-changelog
+
+## begin gnulib module gnu-web-doc-update
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/gnu-web-doc-update
+
+## end gnulib module gnu-web-doc-update
+
+## begin gnulib module gnumakefile
+
+distclean-local: clean-GNUmakefile
+clean-GNUmakefile:
+ test '$(srcdir)' = . || rm -f $(top_builddir)/GNUmakefile
+
+EXTRA_DIST += $(top_srcdir)/GNUmakefile
+
+## end gnulib module gnumakefile
+
+## begin gnulib module gnupload
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/gnupload
+
+## end gnulib module gnupload
+
+## begin gnulib module hard-locale
+
+lib_libsed_a_SOURCES += lib/hard-locale.c
+
+EXTRA_DIST += lib/hard-locale.h
+
+## end gnulib module hard-locale
+
+## begin gnulib module havelib
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
+
+## end gnulib module havelib
+
+## begin gnulib module ignore-value
+
+
+EXTRA_DIST += lib/ignore-value.h
+
+## end gnulib module ignore-value
+
## begin gnulib module intprops
-EXTRA_DIST += intprops.h
+EXTRA_DIST += lib/intprops.h
## end gnulib module intprops
+## begin gnulib module isblank
+
+
+EXTRA_DIST += lib/isblank.c
+
+EXTRA_lib_libsed_a_SOURCES += lib/isblank.c
+
+## end gnulib module isblank
+
## begin gnulib module langinfo
-BUILT_SOURCES += langinfo.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+lib/langinfo.h: lib/langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -374,18 +538,46 @@ langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-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; \
+ < $(top_srcdir)/lib/langinfo.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += langinfo.h langinfo.h-t
+MOSTLYCLEANFILES += lib/langinfo.h lib/langinfo.h-t
-EXTRA_DIST += langinfo.in.h
+EXTRA_DIST += lib/langinfo.in.h
## end gnulib module langinfo
+## begin gnulib module limits-h
+
+BUILT_SOURCES += $(LIMITS_H)
+
+# We need the following in order to create <limits.h> when the system
+# doesn't have one that is compatible with GNU.
+if GL_GENERATE_LIMITS_H
+lib/limits.h: lib/limits.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|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_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
+ < $(top_srcdir)/lib/limits.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+lib/limits.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += lib/limits.h lib/limits.h-t
+
+EXTRA_DIST += lib/limits.in.h
+
+## end gnulib module limits-h
+
## begin gnulib module localcharset
-libsed_a_SOURCES += localcharset.h localcharset.c
+lib_libsed_a_SOURCES += lib/localcharset.h lib/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
@@ -394,7 +586,7 @@ libsed_a_SOURCES += localcharset.h localcharset.c
# 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
+all-local: lib/charset.alias lib/ref-add.sed lib/ref-del.sed
charset_alias = $(DESTDIR)$(libdir)/charset.alias
charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@@ -416,12 +608,12 @@ install-exec-localcharset: all-local
$(mkinstalldirs) $(DESTDIR)$(libdir) ; \
fi ; \
if test -f $(charset_alias); then \
- sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
+ sed -f lib/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) ; \
+ sed -f lib/ref-add.sed lib/charset.alias > $(charset_tmp) ; \
$(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
rm -f $(charset_tmp) ; \
fi ; \
@@ -430,7 +622,7 @@ install-exec-localcharset: all-local
uninstall-local: uninstall-localcharset
uninstall-localcharset: all-local
if test -f $(charset_alias); then \
- sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
+ sed -f lib/ref-del.sed $(charset_alias) > $(charset_tmp); \
if grep '^# Packages using this file: $$' $(charset_tmp) \
> /dev/null; then \
rm -f $(charset_alias); \
@@ -440,30 +632,30 @@ uninstall-localcharset: all-local
rm -f $(charset_tmp); \
fi
-charset.alias: config.charset
- $(AM_V_GEN)rm -f t-$@ $@ && \
- $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
- mv t-$@ $@
+lib/charset.alias: lib/config.charset
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ $(SHELL) $(top_srcdir)/lib/config.charset '$(host)' > $@-t && \
+ mv $@-t $@
-SUFFIXES += .sed .sin
+# SUFFIXES += .sed .sin
.sin.sed:
- $(AM_V_GEN)rm -f t-$@ $@ && \
- sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
- mv t-$@ $@
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > $@-t && \
+ mv $@-t $@
-CLEANFILES += charset.alias ref-add.sed ref-del.sed
+CLEANFILES += lib/charset.alias lib/ref-add.sed lib/ref-del.sed
-EXTRA_DIST += config.charset ref-add.sin ref-del.sin
+EXTRA_DIST += lib/config.charset lib/ref-add.sin lib/ref-del.sin
## end gnulib module localcharset
## begin gnulib module locale
-BUILT_SOURCES += locale.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/locale.h: lib/locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -483,230 +675,280 @@ locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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; \
+ < $(top_srcdir)/lib/locale.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += locale.h locale.h-t
+MOSTLYCLEANFILES += lib/locale.h lib/locale.h-t
-EXTRA_DIST += locale.in.h
+EXTRA_DIST += lib/locale.in.h
## end gnulib module locale
## begin gnulib module localeconv
-EXTRA_DIST += localeconv.c
+EXTRA_DIST += lib/localeconv.c
-EXTRA_libsed_a_SOURCES += localeconv.c
+EXTRA_lib_libsed_a_SOURCES += lib/localeconv.c
## end gnulib module localeconv
-## begin gnulib module lstat
+## begin gnulib module lock
+lib_libsed_a_SOURCES += lib/glthread/lock.h lib/glthread/lock.c
-EXTRA_DIST += lstat.c
+## end gnulib module lock
-EXTRA_libsed_a_SOURCES += lstat.c
+## begin gnulib module lstat
-## end gnulib module lstat
-## begin gnulib module malloc-gnu
+EXTRA_DIST += lib/lstat.c
+
+EXTRA_lib_libsed_a_SOURCES += lib/lstat.c
+## end gnulib module lstat
-EXTRA_DIST += malloc.c
+## begin gnulib module maintainer-makefile
-EXTRA_libsed_a_SOURCES += malloc.c
+EXTRA_DIST += $(top_srcdir)/maint.mk
-## end gnulib module malloc-gnu
+## end gnulib module maintainer-makefile
## begin gnulib module malloc-posix
-EXTRA_DIST += malloc.c
+EXTRA_DIST += lib/malloc.c
-EXTRA_libsed_a_SOURCES += malloc.c
+EXTRA_lib_libsed_a_SOURCES += lib/malloc.c
## end gnulib module malloc-posix
## begin gnulib module malloca
-libsed_a_SOURCES += malloca.c
+lib_libsed_a_SOURCES += lib/malloca.c
-EXTRA_DIST += malloca.h malloca.valgrind
+EXTRA_DIST += lib/malloca.h lib/malloca.valgrind
## end gnulib module malloca
## begin gnulib module mbrlen
-EXTRA_DIST += mbrlen.c
+EXTRA_DIST += lib/mbrlen.c
-EXTRA_libsed_a_SOURCES += mbrlen.c
+EXTRA_lib_libsed_a_SOURCES += lib/mbrlen.c
## end gnulib module mbrlen
## begin gnulib module mbrtowc
-EXTRA_DIST += mbrtowc.c
+EXTRA_DIST += lib/mbrtowc.c
-EXTRA_libsed_a_SOURCES += mbrtowc.c
+EXTRA_lib_libsed_a_SOURCES += lib/mbrtowc.c
## end gnulib module mbrtowc
## begin gnulib module mbsinit
-EXTRA_DIST += mbsinit.c
+EXTRA_DIST += lib/mbsinit.c
-EXTRA_libsed_a_SOURCES += mbsinit.c
+EXTRA_lib_libsed_a_SOURCES += lib/mbsinit.c
## end gnulib module mbsinit
## begin gnulib module mbtowc
-EXTRA_DIST += mbtowc-impl.h mbtowc.c
+EXTRA_DIST += lib/mbtowc-impl.h lib/mbtowc.c
-EXTRA_libsed_a_SOURCES += mbtowc.c
+EXTRA_lib_libsed_a_SOURCES += lib/mbtowc.c
## end gnulib module mbtowc
## begin gnulib module memchr
-EXTRA_DIST += memchr.c memchr.valgrind
+EXTRA_DIST += lib/memchr.c lib/memchr.valgrind
-EXTRA_libsed_a_SOURCES += memchr.c
+EXTRA_lib_libsed_a_SOURCES += lib/memchr.c
## end gnulib module memchr
+## begin gnulib module memrchr
+
+
+EXTRA_DIST += lib/memrchr.c
+
+EXTRA_lib_libsed_a_SOURCES += lib/memrchr.c
+
+## end gnulib module memrchr
+
+## begin gnulib module minmax
+
+lib_libsed_a_SOURCES += lib/minmax.h
+
+## end gnulib module minmax
+
## begin gnulib module mkostemp
-EXTRA_DIST += mkostemp.c
+EXTRA_DIST += lib/mkostemp.c
-EXTRA_libsed_a_SOURCES += mkostemp.c
+EXTRA_lib_libsed_a_SOURCES += lib/mkostemp.c
## end gnulib module mkostemp
## begin gnulib module msvc-inval
-EXTRA_DIST += msvc-inval.c msvc-inval.h
+EXTRA_DIST += lib/msvc-inval.c lib/msvc-inval.h
-EXTRA_libsed_a_SOURCES += msvc-inval.c
+EXTRA_lib_libsed_a_SOURCES += lib/msvc-inval.c
## end gnulib module msvc-inval
## begin gnulib module msvc-nothrow
-EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
+EXTRA_DIST += lib/msvc-nothrow.c lib/msvc-nothrow.h
-EXTRA_libsed_a_SOURCES += msvc-nothrow.c
+EXTRA_lib_libsed_a_SOURCES += lib/msvc-nothrow.c
## end gnulib module msvc-nothrow
## begin gnulib module nl_langinfo
-EXTRA_DIST += nl_langinfo.c
+EXTRA_DIST += lib/nl_langinfo.c
-EXTRA_libsed_a_SOURCES += nl_langinfo.c
+EXTRA_lib_libsed_a_SOURCES += lib/nl_langinfo.c
## end gnulib module nl_langinfo
+## begin gnulib module non-recursive-gnulib-prefix-hack
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/prefix-gnulib-mk
+
+## end gnulib module non-recursive-gnulib-prefix-hack
+
## begin gnulib module obstack
-EXTRA_DIST += obstack.c obstack.h
+EXTRA_DIST += lib/obstack.c lib/obstack.h
-EXTRA_libsed_a_SOURCES += obstack.c
+EXTRA_lib_libsed_a_SOURCES += lib/obstack.c
## end gnulib module obstack
## begin gnulib module pathmax
-EXTRA_DIST += pathmax.h
+EXTRA_DIST += lib/pathmax.h
## end gnulib module pathmax
+## begin gnulib module progname
+
+lib_libsed_a_SOURCES += lib/progname.h lib/progname.c
+
+## end gnulib module progname
+
+## begin gnulib module qcopy-acl
+
+lib_libsed_a_SOURCES += lib/qcopy-acl.c
+
+## end gnulib module qcopy-acl
+
+## begin gnulib module qset-acl
+
+lib_libsed_a_SOURCES += lib/qset-acl.c
+
+## end gnulib module qset-acl
+
## begin gnulib module quote
-EXTRA_DIST += quote.h
+EXTRA_DIST += lib/quote.h
## end gnulib module quote
## begin gnulib module quotearg
-libsed_a_SOURCES += quotearg.c
+lib_libsed_a_SOURCES += lib/quotearg.c
-EXTRA_DIST += quote.h quotearg.h
+EXTRA_DIST += lib/quote.h lib/quotearg.h
## end gnulib module quotearg
## begin gnulib module readlink
-EXTRA_DIST += readlink.c
+EXTRA_DIST += lib/readlink.c
-EXTRA_libsed_a_SOURCES += readlink.c
+EXTRA_lib_libsed_a_SOURCES += lib/readlink.c
## end gnulib module readlink
-## begin gnulib module realloc-posix
-
+## begin gnulib module readme-release
-EXTRA_DIST += realloc.c
-EXTRA_libsed_a_SOURCES += realloc.c
+EXTRA_DIST += $(top_srcdir)/README-release
-## end gnulib module realloc-posix
+## end gnulib module readme-release
## begin gnulib module regex
-EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c
+EXTRA_DIST += lib/regcomp.c lib/regex.c lib/regex.h lib/regex_internal.c lib/regex_internal.h lib/regexec.c
-EXTRA_libsed_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
+EXTRA_lib_libsed_a_SOURCES += lib/regcomp.c lib/regex.c lib/regex_internal.c lib/regexec.c
## end gnulib module regex
## begin gnulib module rename
-EXTRA_DIST += rename.c
+EXTRA_DIST += lib/rename.c
-EXTRA_libsed_a_SOURCES += rename.c
+EXTRA_lib_libsed_a_SOURCES += lib/rename.c
## end gnulib module rename
## begin gnulib module rmdir
-EXTRA_DIST += rmdir.c
+EXTRA_DIST += lib/rmdir.c
-EXTRA_libsed_a_SOURCES += rmdir.c
+EXTRA_lib_libsed_a_SOURCES += lib/rmdir.c
## end gnulib module rmdir
## begin gnulib module same-inode
-EXTRA_DIST += same-inode.h
+EXTRA_DIST += lib/same-inode.h
## end gnulib module same-inode
+## begin gnulib module secure_getenv
+
+
+EXTRA_DIST += lib/secure_getenv.c
+
+EXTRA_lib_libsed_a_SOURCES += lib/secure_getenv.c
+
+## end gnulib module secure_getenv
+
## begin gnulib module selinux-h
-libsed_a_SOURCES += se-context.in.h se-selinux.in.h se-context.c se-selinux.c
+lib_libsed_a_SOURCES += lib/se-context.in.h lib/se-selinux.in.h lib/se-context.c lib/se-selinux.c
-BUILT_SOURCES += selinux/selinux.h
-selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
- $(AM_V_at)$(MKDIR_P) selinux
+BUILT_SOURCES += lib/selinux/selinux.h
+lib/selinux/selinux.h: lib/se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
+ $(AM_V_at)$(MKDIR_P) lib/selinux
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -715,33 +957,33 @@ selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status $(UNUSED_PARAME
-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; \
+ < $(top_srcdir)/lib/se-selinux.in.h; \
} > $@-t && \
chmod a-x $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
+MOSTLYCLEANFILES += lib/selinux/selinux.h lib/selinux/selinux.h-t
BUILT_SOURCES += $(SELINUX_CONTEXT_H)
if GL_GENERATE_SELINUX_CONTEXT_H
-selinux/context.h: se-context.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
- $(AM_V_at)$(MKDIR_P) selinux
+lib/selinux/context.h: lib/se-context.in.h $(top_builddir)/config.status $(UNUSED_PARAMETER_H)
+ $(AM_V_at)$(MKDIR_P) lib/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; \
+ < $(top_srcdir)/lib/se-context.in.h; \
} > $@-t && \
chmod a-x $@-t && \
mv $@-t $@
else
-selinux/context.h: $(top_builddir)/config.status
+lib/selinux/context.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
-MOSTLYCLEANDIRS += selinux
+MOSTLYCLEANFILES += lib/selinux/context.h lib/selinux/context.h-t
+MOSTLYCLEANDIRS += lib/selinux
-EXTRA_DIST += getfilecon.c
+EXTRA_DIST += lib/getfilecon.c
-EXTRA_libsed_a_SOURCES += getfilecon.c
+EXTRA_lib_libsed_a_SOURCES += lib/getfilecon.c
## end gnulib module selinux-h
@@ -764,19 +1006,19 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h
# present in all Makefile.am that need it. This is ensured by the applicability
# 'all' defined above.
-BUILT_SOURCES += arg-nonnull.h
+BUILT_SOURCES += lib/arg-nonnull.h
# The arg-nonnull.h that gets inserted into generated .h files is the same as
# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
# off.
-arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
+lib/arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/GL_ARG_NONNULL/,$$p' \
< $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
> $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+MOSTLYCLEANFILES += lib/arg-nonnull.h lib/arg-nonnull.h-t
-ARG_NONNULL_H=arg-nonnull.h
+ARG_NONNULL_H=lib/arg-nonnull.h
EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h
@@ -789,18 +1031,18 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h
# present in all Makefile.am that need it. This is ensured by the applicability
# 'all' defined above.
-BUILT_SOURCES += c++defs.h
+BUILT_SOURCES += lib/c++defs.h
# The c++defs.h that gets inserted into generated .h files is the same as
# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
-c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
+lib/c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/_GL_CXXDEFS/,$$p' \
< $(top_srcdir)/build-aux/snippet/c++defs.h \
> $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += c++defs.h c++defs.h-t
+MOSTLYCLEANFILES += lib/c++defs.h lib/c++defs.h-t
-CXXDEFS_H=c++defs.h
+CXXDEFS_H=lib/c++defs.h
EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h
@@ -813,19 +1055,19 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h
# present in all Makefile.am that need it. This is ensured by the applicability
# 'all' defined above.
-BUILT_SOURCES += unused-parameter.h
+BUILT_SOURCES += lib/unused-parameter.h
# The unused-parameter.h that gets inserted into generated .h files is the same
# as build-aux/snippet/unused-parameter.h, except that it has the copyright
# header cut off.
-unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h
+lib/unused-parameter.h: $(top_srcdir)/build-aux/snippet/unused-parameter.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/GL_UNUSED_PARAMETER/,$$p' \
< $(top_srcdir)/build-aux/snippet/unused-parameter.h \
> $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += unused-parameter.h unused-parameter.h-t
+MOSTLYCLEANFILES += lib/unused-parameter.h lib/unused-parameter.h-t
-UNUSED_PARAMETER_H=unused-parameter.h
+UNUSED_PARAMETER_H=lib/unused-parameter.h
EXTRA_DIST += $(top_srcdir)/build-aux/snippet/unused-parameter.h
@@ -833,19 +1075,19 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/unused-parameter.h
## begin gnulib module snippet/warn-on-use
-BUILT_SOURCES += warn-on-use.h
+BUILT_SOURCES += lib/warn-on-use.h
# The warn-on-use.h that gets inserted into generated .h files is the same as
# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
# off.
-warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
+lib/warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
$(AM_V_GEN)rm -f $@-t $@ && \
sed -n -e '/^.ifndef/,$$p' \
< $(top_srcdir)/build-aux/snippet/warn-on-use.h \
> $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
+MOSTLYCLEANFILES += lib/warn-on-use.h lib/warn-on-use.h-t
-WARN_ON_USE_H=warn-on-use.h
+WARN_ON_USE_H=lib/warn-on-use.h
EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
@@ -854,19 +1096,42 @@ EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
## begin gnulib module stat
-EXTRA_DIST += stat.c
+EXTRA_DIST += lib/stat.c
-EXTRA_libsed_a_SOURCES += stat.c
+EXTRA_lib_libsed_a_SOURCES += lib/stat.c
## end gnulib module stat
## begin gnulib module stat-macros
-EXTRA_DIST += stat-macros.h
+EXTRA_DIST += lib/stat-macros.h
## end gnulib module stat-macros
+## begin gnulib module stdalign
+
+BUILT_SOURCES += $(STDALIGN_H)
+
+# We need the following in order to create <stdalign.h> when the system
+# doesn't have one that works.
+if GL_GENERATE_STDALIGN_H
+lib/stdalign.h: lib/stdalign.in.h $(top_builddir)/config.status
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(top_srcdir)/lib/stdalign.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+else
+lib/stdalign.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES += lib/stdalign.h lib/stdalign.h-t
+
+EXTRA_DIST += lib/stdalign.in.h
+
+## end gnulib module stdalign
+
## begin gnulib module stdarg
BUILT_SOURCES += $(STDARG_H)
@@ -874,7 +1139,7 @@ BUILT_SOURCES += $(STDARG_H)
# We need the following in order to create <stdarg.h> when the system
# doesn't have one that works with the given compiler.
if GL_GENERATE_STDARG_H
-stdarg.h: stdarg.in.h $(top_builddir)/config.status
+lib/stdarg.h: lib/stdarg.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -882,16 +1147,16 @@ stdarg.h: stdarg.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \
- < $(srcdir)/stdarg.in.h; \
+ < $(top_srcdir)/lib/stdarg.in.h; \
} > $@-t && \
mv $@-t $@
else
-stdarg.h: $(top_builddir)/config.status
+lib/stdarg.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += stdarg.h stdarg.h-t
+MOSTLYCLEANFILES += lib/stdarg.h lib/stdarg.h-t
-EXTRA_DIST += stdarg.in.h
+EXTRA_DIST += lib/stdarg.in.h
## end gnulib module stdarg
@@ -902,19 +1167,19 @@ BUILT_SOURCES += $(STDBOOL_H)
# We need the following in order to create <stdbool.h> when the system
# doesn't have one that works.
if GL_GENERATE_STDBOOL_H
-stdbool.h: stdbool.in.h $(top_builddir)/config.status
+lib/stdbool.h: lib/stdbool.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
+ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(top_srcdir)/lib/stdbool.in.h; \
} > $@-t && \
mv $@-t $@
else
-stdbool.h: $(top_builddir)/config.status
+lib/stdbool.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += stdbool.h stdbool.h-t
+MOSTLYCLEANFILES += lib/stdbool.h lib/stdbool.h-t
-EXTRA_DIST += stdbool.in.h
+EXTRA_DIST += lib/stdbool.in.h
## end gnulib module stdbool
@@ -925,7 +1190,7 @@ 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.
if GL_GENERATE_STDDEF_H
-stddef.h: stddef.in.h $(top_builddir)/config.status
+lib/stddef.h: lib/stddef.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -933,18 +1198,19 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
-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_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
-e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
-e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
- < $(srcdir)/stddef.in.h; \
+ < $(top_srcdir)/lib/stddef.in.h; \
} > $@-t && \
mv $@-t $@
else
-stddef.h: $(top_builddir)/config.status
+lib/stddef.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += stddef.h stddef.h-t
+MOSTLYCLEANFILES += lib/stddef.h lib/stddef.h-t
-EXTRA_DIST += stddef.in.h
+EXTRA_DIST += lib/stddef.in.h
## end gnulib module stddef
@@ -955,7 +1221,7 @@ BUILT_SOURCES += $(STDINT_H)
# We need the following in order to create <stdint.h> when the system
# doesn't have one that works with the given compiler.
if GL_GENERATE_STDINT_H
-stdint.h: stdint.in.h $(top_builddir)/config.status
+lib/stdint.h: lib/stdint.in.h $(top_builddir)/config.status
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -964,6 +1230,7 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-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_C99_STDINT_H''@/$(HAVE_C99_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' \
@@ -985,27 +1252,27 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
-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; \
+ -e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
+ < $(top_srcdir)/lib/stdint.in.h; \
} > $@-t && \
mv $@-t $@
else
-stdint.h: $(top_builddir)/config.status
+lib/stdint.h: $(top_builddir)/config.status
rm -f $@
endif
-MOSTLYCLEANFILES += stdint.h stdint.h-t
+MOSTLYCLEANFILES += lib/stdint.h lib/stdint.h-t
-EXTRA_DIST += stdint.in.h
+EXTRA_DIST += lib/stdint.in.h
## end gnulib module stdint
## begin gnulib module stdio
-BUILT_SOURCES += stdio.h
-libsed_a_SOURCES += stdio.c
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/stdio.h: lib/stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1066,7 +1333,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-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 | \
+ < $(top_srcdir)/lib/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' \
@@ -1121,19 +1388,19 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += stdio.h stdio.h-t
+MOSTLYCLEANFILES += lib/stdio.h lib/stdio.h-t
-EXTRA_DIST += stdio.in.h
+EXTRA_DIST += lib/stdio.in.h
## end gnulib module stdio
## begin gnulib module stdlib
-BUILT_SOURCES += stdlib.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) \
+lib/stdlib.h: lib/stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
$(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
@@ -1160,11 +1427,13 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
-e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
-e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
+ -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/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_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
-e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
-e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
-e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
@@ -1173,7 +1442,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-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 | \
+ < $(top_srcdir)/lib/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' \
@@ -1188,11 +1457,13 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
+ -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
-e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|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_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
-e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
-e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
@@ -1209,6 +1480,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
-e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+ -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
@@ -1222,44 +1494,44 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += stdlib.h stdlib.h-t
+MOSTLYCLEANFILES += lib/stdlib.h lib/stdlib.h-t
-EXTRA_DIST += stdlib.in.h
+EXTRA_DIST += lib/stdlib.in.h
## end gnulib module stdlib
## begin gnulib module streq
-EXTRA_DIST += streq.h
+EXTRA_DIST += lib/streq.h
## end gnulib module streq
## begin gnulib module strerror
-EXTRA_DIST += strerror.c
+EXTRA_DIST += lib/strerror.c
-EXTRA_libsed_a_SOURCES += strerror.c
+EXTRA_lib_libsed_a_SOURCES += lib/strerror.c
## end gnulib module strerror
## begin gnulib module strerror-override
-EXTRA_DIST += strerror-override.c strerror-override.h
+EXTRA_DIST += lib/strerror-override.c lib/strerror-override.h
-EXTRA_libsed_a_SOURCES += strerror-override.c
+EXTRA_lib_libsed_a_SOURCES += lib/strerror-override.c
## end gnulib module strerror-override
## begin gnulib module string
-BUILT_SOURCES += string.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/string.h: lib/string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1304,7 +1576,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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 | \
+ < $(top_srcdir)/lib/string.in.h | \
sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
-e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
-e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
@@ -1344,32 +1616,32 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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; \
+ < $(top_srcdir)/lib/string.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += string.h string.h-t
+MOSTLYCLEANFILES += lib/string.h lib/string.h-t
-EXTRA_DIST += string.in.h
+EXTRA_DIST += lib/string.in.h
## end gnulib module string
## begin gnulib module strverscmp
-EXTRA_DIST += strverscmp.c
+EXTRA_DIST += lib/strverscmp.c
-EXTRA_libsed_a_SOURCES += strverscmp.c
+EXTRA_lib_libsed_a_SOURCES += lib/strverscmp.c
## end gnulib module strverscmp
## begin gnulib module sys_stat
-BUILT_SOURCES += sys/stat.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
+lib/sys/stat.h: lib/sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_at)$(MKDIR_P) lib/sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1414,24 +1686,24 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-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; \
+ < $(top_srcdir)/lib/sys_stat.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
-MOSTLYCLEANDIRS += sys
+MOSTLYCLEANFILES += lib/sys/stat.h lib/sys/stat.h-t
+MOSTLYCLEANDIRS += lib/sys
-EXTRA_DIST += sys_stat.in.h
+EXTRA_DIST += lib/sys_stat.in.h
## end gnulib module sys_stat
## begin gnulib module sys_time
-BUILT_SOURCES += sys/time.h
+BUILT_SOURCES += lib/sys/time.h
# We need the following in order to create <sys/time.h> when the system
# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
+lib/sys/time.h: lib/sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_at)$(MKDIR_P) lib/sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1449,23 +1721,23 @@ sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-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_time.in.h; \
+ < $(top_srcdir)/lib/sys_time.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += sys/time.h sys/time.h-t
+MOSTLYCLEANFILES += lib/sys/time.h lib/sys/time.h-t
-EXTRA_DIST += sys_time.in.h
+EXTRA_DIST += lib/sys_time.in.h
## end gnulib module sys_time
## begin gnulib module sys_types
-BUILT_SOURCES += sys/types.h
+BUILT_SOURCES += lib/sys/types.h
# We need the following in order to create <sys/types.h> when the system
# doesn't have one that works with the given compiler.
-sys/types.h: sys_types.in.h $(top_builddir)/config.status
- $(AM_V_at)$(MKDIR_P) sys
+lib/sys/types.h: lib/sys_types.in.h $(top_builddir)/config.status
+ $(AM_V_at)$(MKDIR_P) lib/sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1474,30 +1746,38 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
-e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
- < $(srcdir)/sys_types.in.h; \
+ < $(top_srcdir)/lib/sys_types.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += sys/types.h sys/types.h-t
+MOSTLYCLEANFILES += lib/sys/types.h lib/sys/types.h-t
-EXTRA_DIST += sys_types.in.h
+EXTRA_DIST += lib/sys_types.in.h
## end gnulib module sys_types
## begin gnulib module tempname
-libsed_a_SOURCES += tempname.c
+lib_libsed_a_SOURCES += lib/tempname.c
-EXTRA_DIST += tempname.h
+EXTRA_DIST += lib/tempname.h
## end gnulib module tempname
+## begin gnulib module threadlib
+
+lib_libsed_a_SOURCES += lib/glthread/threadlib.c
+
+EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
+
+## end gnulib module threadlib
+
## begin gnulib module time
-BUILT_SOURCES += time.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/time.h: lib/time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1505,15 +1785,20 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-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_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/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/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/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|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
+ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
+ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
@@ -1521,26 +1806,27 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-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 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_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; \
+ < $(top_srcdir)/lib/time.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += time.h time.h-t
+MOSTLYCLEANFILES += lib/time.h lib/time.h-t
-EXTRA_DIST += time.in.h
+EXTRA_DIST += lib/time.in.h
## end gnulib module time
## begin gnulib module unistd
-BUILT_SOURCES += unistd.h
-libsed_a_SOURCES += unistd.c
+BUILT_SOURCES += lib/unistd.h
+lib_libsed_a_SOURCES += lib/unistd.c
# 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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/unistd.h: lib/unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1599,7 +1885,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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 | \
+ < $(top_srcdir)/lib/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' \
@@ -1613,7 +1899,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
-e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
@@ -1635,6 +1920,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
-e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
-e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
+ -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|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' \
@@ -1651,6 +1937,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
+ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
-e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
@@ -1663,9 +1950,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
-e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|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_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
-e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
@@ -1678,45 +1967,66 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += unistd.h unistd.h-t
+MOSTLYCLEANFILES += lib/unistd.h lib/unistd.h-t
-EXTRA_DIST += unistd.in.h
+EXTRA_DIST += lib/unistd.in.h
## end gnulib module unistd
## begin gnulib module unlocked-io
-EXTRA_DIST += unlocked-io.h
+EXTRA_DIST += lib/unlocked-io.h
## end gnulib module unlocked-io
+## begin gnulib module update-copyright
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/update-copyright
+
+## end gnulib module update-copyright
+
+## begin gnulib module useless-if-before-free
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/useless-if-before-free
+
+## end gnulib module useless-if-before-free
+
+## begin gnulib module vc-list-files
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/vc-list-files
+
+## end gnulib module vc-list-files
+
## begin gnulib module verify
-EXTRA_DIST += verify.h
+EXTRA_DIST += lib/verify.h
## end gnulib module verify
## begin gnulib module version-etc
-libsed_a_SOURCES += version-etc.h version-etc.c
+lib_libsed_a_SOURCES += lib/version-etc.h lib/version-etc.c
## end gnulib module version-etc
## begin gnulib module version-etc-fsf
-libsed_a_SOURCES += version-etc-fsf.c
+lib_libsed_a_SOURCES += lib/version-etc-fsf.c
## end gnulib module version-etc-fsf
## begin gnulib module wchar
-BUILT_SOURCES += wchar.h
+BUILT_SOURCES += lib/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 $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
+lib/wchar.h: lib/wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1726,6 +2036,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-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_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
-e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
-e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \
@@ -1765,7 +2076,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-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 | \
+ < $(top_srcdir)/lib/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' \
@@ -1825,47 +2136,47 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += wchar.h wchar.h-t
+MOSTLYCLEANFILES += lib/wchar.h lib/wchar.h-t
-EXTRA_DIST += wchar.in.h
+EXTRA_DIST += lib/wchar.in.h
## end gnulib module wchar
## begin gnulib module wcrtomb
-EXTRA_DIST += wcrtomb.c
+EXTRA_DIST += lib/wcrtomb.c
-EXTRA_libsed_a_SOURCES += wcrtomb.c
+EXTRA_lib_libsed_a_SOURCES += lib/wcrtomb.c
## end gnulib module wcrtomb
## begin gnulib module wctob
-EXTRA_DIST += wctob.c
+EXTRA_DIST += lib/wctob.c
-EXTRA_libsed_a_SOURCES += wctob.c
+EXTRA_lib_libsed_a_SOURCES += lib/wctob.c
## end gnulib module wctob
## begin gnulib module wctomb
-EXTRA_DIST += wctomb-impl.h wctomb.c
+EXTRA_DIST += lib/wctomb-impl.h lib/wctomb.c
-EXTRA_libsed_a_SOURCES += wctomb.c
+EXTRA_lib_libsed_a_SOURCES += lib/wctomb.c
## end gnulib module wctomb
## begin gnulib module wctype-h
-BUILT_SOURCES += wctype.h
-libsed_a_SOURCES += wctype-h.c
+BUILT_SOURCES += lib/wctype.h
+lib_libsed_a_SOURCES += lib/wctype-h.c
# 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 $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+lib/wctype.h: lib/wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
@@ -1874,6 +2185,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
-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_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
-e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
-e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
@@ -1889,33 +2201,33 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
-e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/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; \
+ < $(top_srcdir)/lib/wctype.in.h; \
} > $@-t && \
mv $@-t $@
-MOSTLYCLEANFILES += wctype.h wctype.h-t
+MOSTLYCLEANFILES += lib/wctype.h lib/wctype.h-t
-EXTRA_DIST += wctype.in.h
+EXTRA_DIST += lib/wctype.in.h
## end gnulib module wctype-h
## begin gnulib module xalloc
-libsed_a_SOURCES += xmalloc.c
+lib_libsed_a_SOURCES += lib/xmalloc.c
-EXTRA_DIST += xalloc.h
+EXTRA_DIST += lib/xalloc.h
## end gnulib module xalloc
## begin gnulib module xalloc-die
-libsed_a_SOURCES += xalloc-die.c
+lib_libsed_a_SOURCES += lib/xalloc-die.c
## end gnulib module xalloc-die
## begin gnulib module xalloc-oversized
-EXTRA_DIST += xalloc-oversized.h
+EXTRA_DIST += lib/xalloc-oversized.h
## end gnulib module xalloc-oversized
diff --git a/lib/hard-locale.c b/lib/hard-locale.c
new file mode 100644
index 0000000..c7d9da5
--- /dev/null
+++ b/lib/hard-locale.c
@@ -0,0 +1,72 @@
+/* hard-locale.c -- Determine whether a locale is hard.
+
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2016 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 "hard-locale.h"
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __GLIBC__
+# define GLIBC_VERSION __GLIBC__
+#elif defined __UCLIBC__
+# define GLIBC_VERSION 2
+#else
+# define GLIBC_VERSION 0
+#endif
+
+/* Return true if the current CATEGORY locale is hard, i.e. if you
+ can't get away with assuming traditional C or POSIX behavior. */
+bool
+hard_locale (int category)
+{
+ bool hard = true;
+ char const *p = setlocale (category, NULL);
+
+ if (p)
+ {
+ if (2 <= GLIBC_VERSION)
+ {
+ if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
+ hard = false;
+ }
+ else
+ {
+ char *locale = strdup (p);
+ if (locale)
+ {
+ /* Temporarily set the locale to the "C" and "POSIX" locales
+ to find their names, so that we can determine whether one
+ or the other is the caller's locale. */
+ if (((p = setlocale (category, "C"))
+ && strcmp (p, locale) == 0)
+ || ((p = setlocale (category, "POSIX"))
+ && strcmp (p, locale) == 0))
+ hard = false;
+
+ /* Restore the caller's locale. */
+ setlocale (category, locale);
+ free (locale);
+ }
+ }
+ }
+
+ return hard;
+}
diff --git a/lib/hard-locale.h b/lib/hard-locale.h
new file mode 100644
index 0000000..7644afa
--- /dev/null
+++ b/lib/hard-locale.h
@@ -0,0 +1,25 @@
+/* Determine whether a locale is hard.
+
+ Copyright (C) 1999, 2003-2004, 2009-2016 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 HARD_LOCALE_H_
+# define HARD_LOCALE_H_ 1
+
+# include <stdbool.h>
+
+bool hard_locale (int);
+
+#endif /* HARD_LOCALE_H_ */
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
new file mode 100644
index 0000000..6713d96
--- /dev/null
+++ b/lib/ignore-value.h
@@ -0,0 +1,50 @@
+/* ignore a function return without a compiler warning. -*- coding: utf-8 -*-
+
+ Copyright (C) 2008-2016 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
+
+/* Normally casting an expression to void discards its value, but GCC
+ versions 3.4 and newer have __attribute__ ((__warn_unused_result__))
+ which may cause unwanted diagnostics in that case. Use __typeof__
+ and __extension__ to work around the problem, if the workaround is
+ known to be needed. */
+#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
+# define ignore_value(x) \
+ (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
+#else
+# define ignore_value(x) ((void) (x))
+#endif
+
+#endif
diff --git a/lib/intprops.h b/lib/intprops.h
index 2485c78..8add5de 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -1,10 +1,10 @@
/* intprops.h -- properties of integer types
- Copyright (C) 2001-2005, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2016 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
+ This 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,
@@ -21,9 +21,13 @@
#define _GL_INTPROPS_H
#include <limits.h>
+#include <verify.h>
-/* Return an integer value, converted to the same type as the integer
- expression E after integer type promotion. V is the unconverted value. */
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Return a value with the common real type of E and V and the value of V. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
@@ -37,59 +41,73 @@
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 signed integer expression E uses two's complement. */
-#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
-
-/* True if the arithmetic type T is signed. */
+/* True if the real type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* Return 1 if the integer expression E, after integer promotion, has
- a signed type. */
-#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
+/* Return 1 if the real expression E, after promotion, has a
+ signed or floating type. */
+#define EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
-/* Minimum and maximum values for integer types and expressions. 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. */
+/* Minimum and maximum values for integer types and expressions. */
+
+/* The width in bits of the integer type or expression T.
+ Padding bits are not supported; this is checked at compile-time below. */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
/* The maximum and minimum values for the integer type T. */
-#define TYPE_MINIMUM(t) \
- ((t) (! TYPE_SIGNED (t) \
- ? (t) 0 \
- : TYPE_SIGNED_MAGNITUDE (t) \
- ? ~ (t) 0 \
- : ~ TYPE_MAXIMUM (t)))
+#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
#define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
- : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+ : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
/* The maximum and minimum values for the type of the expression E,
after integer promotion. E should not have side effects. */
#define _GL_INT_MINIMUM(e) \
- (_GL_INT_SIGNED (e) \
- ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
+ (EXPR_SIGNED (e) \
+ ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_CONVERT (e, 0))
#define _GL_INT_MAXIMUM(e) \
- (_GL_INT_SIGNED (e) \
+ (EXPR_SIGNED (e) \
? _GL_SIGNED_INT_MAXIMUM (e) \
: _GL_INT_NEGATE_CONVERT (e, 1))
#define _GL_SIGNED_INT_MAXIMUM(e) \
- (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
+ (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
+
+/* Work around OpenVMS incompatibility with C99. */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
+/* This include file assumes that signed types are two's complement without
+ padding bits; the above macros have undefined behavior otherwise.
+ If this is a problem for you, please let us know how to fix it for your host.
+ As a sanity check, test the assumption for some signed types that
+ <limits.h> bounds. */
+verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
+verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
+verify (TYPE_MINIMUM (short int) == SHRT_MIN);
+verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
+verify (TYPE_MINIMUM (int) == INT_MIN);
+verify (TYPE_MAXIMUM (int) == INT_MAX);
+verify (TYPE_MINIMUM (long int) == LONG_MIN);
+verify (TYPE_MAXIMUM (long int) == LONG_MAX);
+#ifdef LLONG_MAX
+verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
+verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
+#endif
+/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
+#ifdef UINT_WIDTH
+verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
+#endif
-/* Return 1 if the __typeof__ keyword works. This could be done by
+/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
-#if 2 <= __GNUC__ || 0x5110 <= __SUNPRO_C
+#if (2 <= __GNUC__ \
+ || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
+ || (0x5110 <= __SUNPRO_C && !__STDC__))
# define _GL_HAVE___TYPEOF__ 1
#else
# define _GL_HAVE___TYPEOF__ 0
@@ -117,8 +135,7 @@
signed, this macro may overestimate the true bound by one byte when
applied to unsigned types of size 2, 4, 16, ... bytes. */
#define INT_STRLEN_BOUND(t) \
- (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \
- - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
+ _GL_SIGNED_TYPE_OR_EXPR (t))
/* Bound on buffer size needed to represent an integer type or expression T,
@@ -223,24 +240,40 @@
? (a) < (min) >> (b) \
: (max) >> (b) < (a))
+/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
+#define _GL_HAS_BUILTIN_OVERFLOW \
+ (5 <= __GNUC__ || __has_builtin (__builtin_add_overflow))
+
+/* True if __builtin_add_overflow_p (A, B, C) works. */
+#define _GL_HAS_BUILTIN_OVERFLOW_P \
+ (7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p))
/* The _GL*_OVERFLOW macros have the same restrictions as the
*_RANGE_OVERFLOW macros, except that they do not assume that operands
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
that the result (e.g., A + B) has that type. */
-#define _GL_ADD_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? (b) <= (a) + (b) \
- : (b) < 0 ? (a) <= (a) + (b) \
- : (a) + (b) < (b))
-#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
- ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
- : (a) < 0 ? 1 \
- : (b) < 0 ? (a) - (b) <= (a) \
- : (a) < (b))
-#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
- (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
- || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? (b) <= (a) + (b) \
+ : (b) < 0 ? (a) <= (a) + (b) \
+ : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
+ ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
+ : (a) < 0 ? 1 \
+ : (b) < 0 ? (a) - (b) <= (a) \
+ : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
+ (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
+ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
: (a) < 0 ? (b) <= (a) + (b) - 1 \
@@ -262,22 +295,29 @@
: (a) % - (b)) \
== 0)
-
-/* Integer overflow checks.
+/* Check for integer overflow, and report low order bits of answer.
The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
might not yield numerically correct answers due to arithmetic overflow.
- They work correctly on all known practical hosts, and do not rely
+ The INT_<op>_WRAPV macros also store the low-order bits of the answer.
+ These macros work correctly on all known practical hosts, and do not rely
on undefined behavior due to signed arithmetic overflow.
- Example usage:
+ Example usage, assuming A and B are long int:
- long int i = ...;
- long int j = ...;
- if (INT_MULTIPLY_OVERFLOW (i, j))
- printf ("multiply would overflow");
+ if (INT_MULTIPLY_OVERFLOW (a, b))
+ printf ("result would overflow\n");
else
- printf ("product is %ld", i * j);
+ printf ("result is %ld (no overflow)\n", a * b);
+
+ Example usage with WRAPV flavor:
+
+ long int result;
+ bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
+ printf ("result is %ld (%s)\n", result,
+ overflow ? "after overflow" : "no overflow");
+
+ Restrictions on these macros:
These macros do not check for all possible numerical problems or
undefined or unspecified behavior: they do not check for division
@@ -286,6 +326,9 @@
These macros may evaluate their arguments zero or multiple times, so the
arguments should not have side effects.
+ The WRAPV macros are not constant expressions. They support only
+ +, binary -, and *. The result type must be signed.
+
These macros are tuned for their last argument being a constant.
Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
@@ -295,8 +338,12 @@
_GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
#define INT_SUBTRACT_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#define INT_NEGATE_OVERFLOW(a) \
- INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+ INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
#define INT_MULTIPLY_OVERFLOW(a, b) \
_GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
#define INT_DIVIDE_OVERFLOW(a, b) \
@@ -316,4 +363,102 @@
_GL_INT_MINIMUM (0 * (b) + (a)), \
_GL_INT_MAXIMUM (0 * (b) + (a)))
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
+ Return 1 if the result overflows. See above for restrictions. */
+#define INT_ADD_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
+#define INT_SUBTRACT_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, -, __builtin_sub_overflow, INT_SUBTRACT_OVERFLOW)
+#define INT_MULTIPLY_WRAPV(a, b, r) \
+ _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
+
+/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
+ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
+ https://llvm.org/bugs/show_bug.cgi?id=25390
+ For now, assume all versions of GCC-like compilers generate bogus
+ warnings for _Generic. This matters only for older compilers that
+ lack __builtin_add_overflow. */
+#if __GNUC__
+# define _GL__GENERIC_BOGUS 1
+#else
+# define _GL__GENERIC_BOGUS 0
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+ the operation. BUILTIN is the builtin operation, and OVERFLOW the
+ overflow predicate. Return 1 if the result overflows. See above
+ for restrictions. */
+#if _GL_HAS_BUILTIN_OVERFLOW
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
+#elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (_Generic \
+ (*(r), \
+ signed char: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ signed char, SCHAR_MIN, SCHAR_MAX), \
+ short int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ short int, SHRT_MIN, SHRT_MAX), \
+ int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX), \
+ long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX), \
+ long long int: \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX)))
+#else
+# define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
+ (sizeof *(r) == sizeof (signed char) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+ signed char, SCHAR_MIN, SCHAR_MAX) \
+ : sizeof *(r) == sizeof (short int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+ short int, SHRT_MIN, SHRT_MAX) \
+ : sizeof *(r) == sizeof (int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
+ int, INT_MIN, INT_MAX) \
+ : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
+# ifdef LLONG_MAX
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ (sizeof *(r) == sizeof (long int) \
+ ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX) \
+ : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
+ long long int, LLONG_MIN, LLONG_MAX))
+# else
+# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
+ _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
+ long int, LONG_MIN, LONG_MAX)
+# endif
+#endif
+
+/* Store the low-order bits of A <op> B into *R, where the operation
+ is given by OP. Use the unsigned type UT for calculation to avoid
+ overflow problems. *R's type is T, with extremal values TMIN and
+ TMAX. T must be a signed integer type. Return 1 if the result
+ overflows. */
+#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ (sizeof ((a) op (b)) < sizeof (t) \
+ ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
+ : _GL_INT_OP_CALC1 (a, b, r, op, overflow, ut, t, tmin, tmax))
+#define _GL_INT_OP_CALC1(a, b, r, op, overflow, ut, t, tmin, tmax) \
+ ((overflow (a, b) \
+ || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
+ || (tmax) < ((a) op (b))) \
+ ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
+ : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
+
+/* Return A <op> B, where the operation is given by OP. Use the
+ unsigned type UT for calculation to avoid overflow problems.
+ Convert the result to type T without overflow by subtracting TMIN
+ from large values before converting, and adding it afterwards.
+ Compilers can optimize all the operations except OP. */
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
+ (((ut) (a) op (ut) (b)) <= (tmax) \
+ ? (t) ((ut) (a) op (ut) (b)) \
+ : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
+
#endif /* _GL_INTPROPS_H */
diff --git a/lib/isblank.c b/lib/isblank.c
new file mode 100644
index 0000000..6cc7379
--- /dev/null
+++ b/lib/isblank.c
@@ -0,0 +1,33 @@
+/* Test whether a character is a blank.
+
+ Copyright (C) 2009-2016 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 <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/lib/langinfo.in.h b/lib/langinfo.in.h
index d555b75..e11617c 100644
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for and wrapper around <langinfo.h>.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 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
@@ -51,7 +49,10 @@ typedef int nl_item;
# define CODESET 10000
/* nl_langinfo items of the LC_NUMERIC category */
# define RADIXCHAR 10001
+# define DECIMAL_POINT RADIXCHAR
# define THOUSEP 10002
+# define THOUSANDS_SEP THOUSEP
+# define GROUPING 10114
/* nl_langinfo items of the LC_TIME category */
# define D_T_FMT 10003
# define D_FMT 10004
@@ -104,6 +105,21 @@ typedef int nl_item;
# define ALT_DIGITS 10051
/* nl_langinfo items of the LC_MONETARY category */
# define CRNCYSTR 10052
+# define CURRENCY_SYMBOL CRNCYSTR
+# define INT_CURR_SYMBOL 10100
+# define MON_DECIMAL_POINT 10101
+# define MON_THOUSANDS_SEP 10102
+# define MON_GROUPING 10103
+# define POSITIVE_SIGN 10104
+# define NEGATIVE_SIGN 10105
+# define FRAC_DIGITS 10106
+# define INT_FRAC_DIGITS 10107
+# define P_CS_PRECEDES 10108
+# define N_CS_PRECEDES 10109
+# define P_SEP_BY_SPACE 10110
+# define N_SEP_BY_SPACE 10111
+# define P_SIGN_POSN 10112
+# define N_SIGN_POSN 10113
/* nl_langinfo items of the LC_MESSAGES category */
# define YESEXPR 10053
# define NOEXPR 10054
diff --git a/lib/limits.in.h b/lib/limits.in.h
new file mode 100644
index 0000000..a1eae02
--- /dev/null
+++ b/lib/limits.in.h
@@ -0,0 +1,63 @@
+/* A GNU-like <limits.h>.
+
+ Copyright 2016 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, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* The include_next requires a split double-inclusion guard. */
+#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
+
+#ifndef _@GUARD_PREFIX@_LIMITS_H
+#define _@GUARD_PREFIX@_LIMITS_H
+
+/* The number of usable bits in an unsigned or signed integer type
+ with minimum value MIN and maximum value MAX, as an int expression
+ suitable in #if. Cover all known practical hosts. This
+ implementation exploits the fact that MAX is 1 less than a power of
+ 2, and merely counts the number of 1 bits in MAX; "COBn" means
+ "count the number of 1 bits in the low-order n bits"). */
+#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
+#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
+#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
+#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
+#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
+#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
+#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (! defined ULLONG_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
+# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
+# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
+# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
+# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
+# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
+# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
+# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
+# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
+# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
+# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
+#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
+
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
+#endif /* _@GUARD_PREFIX@_LIMITS_H */
diff --git a/lib/local.mk b/lib/local.mk
new file mode 100644
index 0000000..0d3562f
--- /dev/null
+++ b/lib/local.mk
@@ -0,0 +1,17 @@
+# Copyright 1997-2016 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, see <http://www.gnu.org/licenses/>.
+#
+
+include lib/gnulib.mk
diff --git a/lib/localcharset.c b/lib/localcharset.c
index 7401479..fa5fcbc 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-2016 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
@@ -36,6 +34,7 @@
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_NATIVE
+# include <locale.h>
#endif
#if defined __EMX__
@@ -67,6 +66,11 @@
# include <os2.h>
#endif
+/* For MB_CUR_MAX_L */
+#if defined DARWIN7
+# include <xlocale.h>
+#endif
+
#if ENABLE_RELOCATABLE
# include "relocatable.h"
#else
@@ -124,7 +128,7 @@ get_charset_aliases (void)
cp = charset_aliases;
if (cp == NULL)
{
-#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
+#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2)
const char *dir;
const char *base = "charset.alias";
char *file_name;
@@ -338,6 +342,36 @@ get_charset_aliases (void)
"CP54936" "\0" "GB18030" "\0"
"CP65001" "\0" "UTF-8" "\0";
# endif
+# if defined OS2
+ /* 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. */
+
+ /* The list of encodings is taken from "List of OS/2 Codepages"
+ by Alex Taylor:
+ <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
+ See also "IBM Globalization - Code page identifiers":
+ <http://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */
+ cp = "CP813" "\0" "ISO-8859-7" "\0"
+ "CP878" "\0" "KOI8-R" "\0"
+ "CP819" "\0" "ISO-8859-1" "\0"
+ "CP912" "\0" "ISO-8859-2" "\0"
+ "CP913" "\0" "ISO-8859-3" "\0"
+ "CP914" "\0" "ISO-8859-4" "\0"
+ "CP915" "\0" "ISO-8859-5" "\0"
+ "CP916" "\0" "ISO-8859-8" "\0"
+ "CP920" "\0" "ISO-8859-9" "\0"
+ "CP921" "\0" "ISO-8859-13" "\0"
+ "CP923" "\0" "ISO-8859-15" "\0"
+ "CP954" "\0" "EUC-JP" "\0"
+ "CP964" "\0" "EUC-TW" "\0"
+ "CP970" "\0" "EUC-KR" "\0"
+ "CP1089" "\0" "ISO-8859-6" "\0"
+ "CP1208" "\0" "UTF-8" "\0"
+ "CP1381" "\0" "GB2312" "\0"
+ "CP1386" "\0" "GBK" "\0"
+ "CP3372" "\0" "EUC-JP" "\0";
+# endif
#endif
charset_aliases = cp;
@@ -458,14 +492,34 @@ locale_charset (void)
static char buf[2 + 10 + 1];
- /* The Windows API 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 ());
+ /* The Windows API has a function returning the locale's codepage as
+ a number, but the value doesn't change according to what the
+ 'setlocale' call specified. So we use it as a last resort, in
+ case the string returned by 'setlocale' doesn't specify the
+ codepage. */
+ char *current_locale = setlocale (LC_ALL, NULL);
+ char *pdot;
+
+ /* If they set different locales for different categories,
+ 'setlocale' will return a semi-colon separated list of locale
+ values. To make sure we use the correct one, we choose LC_CTYPE. */
+ if (strchr (current_locale, ';'))
+ current_locale = setlocale (LC_CTYPE, NULL);
+
+ pdot = strrchr (current_locale, '.');
+ if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
+ sprintf (buf, "CP%s", pdot + 1);
+ else
+ {
+ /* The Windows API 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
@@ -475,6 +529,8 @@ locale_charset (void)
ULONG cp[3];
ULONG cplen;
+ codeset = NULL;
+
/* Allow user to override the codeset, as set in the operating system,
with standard language environment variables. */
locale = getenv ("LC_ALL");
@@ -506,10 +562,12 @@ locale_charset (void)
}
}
- /* Resolve through the charset.alias file. */
- codeset = locale;
+ /* For the POSIX locale, don't use the system's codepage. */
+ if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
+ codeset = "";
}
- else
+
+ if (codeset == NULL)
{
/* OS/2 has a function returning the locale's codepage as a number. */
if (DosQueryCp (sizeof (cp), cp, &cplen))
@@ -547,7 +605,7 @@ locale_charset (void)
#ifdef DARWIN7
/* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
(the default codeset) does not work when MB_CUR_MAX is 1. */
- if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX <= 1)
+ if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
codeset = "ASCII";
#endif
diff --git a/lib/localcharset.h b/lib/localcharset.h
index 883f010..915182e 100644
--- a/lib/localcharset.h
+++ b/lib/localcharset.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2009-2016 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 4d3c543..4083507 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -1,5 +1,5 @@
/* A POSIX <locale.h>.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,16 +14,30 @@
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 _@GUARD_PREFIX@_LOCALE_H
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
+#ifdef _GL_ALREADY_INCLUDING_LOCALE_H
+
+/* Special invocation conventions to handle Solaris header files
+ (through Solaris 10) when combined with gettext's libintl.h. */
+
+#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_LOCALE_H
+
+#define _GL_ALREADY_INCLUDING_LOCALE_H
+
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
+#undef _GL_ALREADY_INCLUDING_LOCALE_H
+
#ifndef _@GUARD_PREFIX@_LOCALE_H
#define _@GUARD_PREFIX@_LOCALE_H
@@ -198,4 +212,5 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
#endif
#endif /* _@GUARD_PREFIX@_LOCALE_H */
+#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
#endif /* _@GUARD_PREFIX@_LOCALE_H */
diff --git a/lib/localeconv.c b/lib/localeconv.c
index 2c91b37..8a1d6d7 100644
--- a/lib/localeconv.c
+++ b/lib/localeconv.c
@@ -1,5 +1,5 @@
/* Query locale dependent information for formatting numbers.
- Copyright (C) 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/localeinfo.c b/lib/localeinfo.c
new file mode 100644
index 0000000..ca96afc
--- /dev/null
+++ b/lib/localeinfo.c
@@ -0,0 +1,113 @@
+/* locale information
+
+ Copyright 2016 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 Paul Eggert. */
+
+#include <config.h>
+
+#include <localeinfo.h>
+
+#include <verify.h>
+
+#include <limits.h>
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wctype.h>
+
+/* The sbclen implementation relies on this. */
+verify (MB_LEN_MAX <= SCHAR_MAX);
+
+/* Return true if the locale uses UTF-8. */
+
+static bool
+is_using_utf8 (void)
+{
+ wchar_t wc;
+ mbstate_t mbs = {0};
+ return mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100;
+}
+
+/* Initialize *LOCALEINFO from the current locale. */
+
+void
+init_localeinfo (struct localeinfo *localeinfo)
+{
+ int i;
+
+ localeinfo->multibyte = MB_CUR_MAX > 1;
+ localeinfo->using_utf8 = is_using_utf8 ();
+
+ for (i = CHAR_MIN; i <= CHAR_MAX; i++)
+ {
+ char c = i;
+ unsigned char uc = i;
+ mbstate_t s = {0};
+ wchar_t wc;
+ size_t len = mbrtowc (&wc, &c, 1, &s);
+ localeinfo->sbclen[uc] = len <= 1 ? 1 : - (int) - len;
+ localeinfo->sbctowc[uc] = len <= 1 ? wc : WEOF;
+ }
+}
+
+/* The set of wchar_t values C such that there's a useful locale
+ somewhere where C != towupper (C) && C != towlower (towupper (C)).
+ For example, 0x00B5 (U+00B5 MICRO SIGN) is in this table, because
+ towupper (0x00B5) == 0x039C (U+039C GREEK CAPITAL LETTER MU), and
+ towlower (0x039C) == 0x03BC (U+03BC GREEK SMALL LETTER MU). */
+static short const lonesome_lower[] =
+ {
+ 0x00B5, 0x0131, 0x017F, 0x01C5, 0x01C8, 0x01CB, 0x01F2, 0x0345,
+ 0x03C2, 0x03D0, 0x03D1, 0x03D5, 0x03D6, 0x03F0, 0x03F1,
+
+ /* U+03F2 GREEK LUNATE SIGMA SYMBOL lacks a specific uppercase
+ counterpart in locales predating Unicode 4.0.0 (April 2003). */
+ 0x03F2,
+
+ 0x03F5, 0x1E9B, 0x1FBE,
+ };
+
+/* Verify that the worst case fits. This is 1 for towupper, 1 for
+ towlower, and 1 for each entry in LONESOME_LOWER. */
+verify (1 + 1 + sizeof lonesome_lower / sizeof *lonesome_lower
+ <= CASE_FOLDED_BUFSIZE);
+
+/* Find the characters equal to C after case-folding, other than C
+ itself, and store them into FOLDED. Return the number of characters
+ stored. */
+
+int
+case_folded_counterparts (wchar_t c, wchar_t folded[CASE_FOLDED_BUFSIZE])
+{
+ int i;
+ int n = 0;
+ wint_t uc = towupper (c);
+ wint_t lc = towlower (uc);
+ if (uc != c)
+ folded[n++] = uc;
+ if (lc != uc && lc != c && towupper (lc) == uc)
+ folded[n++] = lc;
+ for (i = 0; i < sizeof lonesome_lower / sizeof *lonesome_lower; i++)
+ {
+ wint_t li = lonesome_lower[i];
+ if (li != lc && li != uc && li != c && towupper (li) == uc)
+ folded[n++] = li;
+ }
+ return n;
+}
diff --git a/lib/localeinfo.h b/lib/localeinfo.h
new file mode 100644
index 0000000..cf2f9a6
--- /dev/null
+++ b/lib/localeinfo.h
@@ -0,0 +1,54 @@
+/* locale information
+
+ Copyright 2016 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 Paul Eggert. */
+
+#include <limits.h>
+#include <stdbool.h>
+#include <wchar.h>
+
+struct localeinfo
+{
+ /* MB_CUR_MAX > 1. */
+ bool multibyte;
+
+ /* The locale uses UTF-8. */
+ bool using_utf8;
+
+ /* An array indexed by byte values B that contains 1 if B is a
+ single-byte character, -1 if B is an encoding error, and -2 if B
+ is the leading byte of a multibyte character that contains more
+ than one byte. */
+ signed char sbclen[UCHAR_MAX + 1];
+
+ /* An array indexed by byte values B that contains the corresponding
+ wide character (if any) for B if sbclen[B] == 1. WEOF means the
+ byte is not a valid single-byte character, i.e., sbclen[B] == -1
+ or -2. */
+ wint_t sbctowc[UCHAR_MAX + 1];
+};
+
+extern void init_localeinfo (struct localeinfo *);
+
+/* Maximum number of characters that can be the case-folded
+ counterparts of a single character, not counting the character
+ itself. This is a generous upper bound. */
+enum { CASE_FOLDED_BUFSIZE = 32 };
+
+extern int case_folded_counterparts (wchar_t, wchar_t[CASE_FOLDED_BUFSIZE]);
diff --git a/lib/lstat.c b/lib/lstat.c
index 97fe6bb..03b0634 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
/* Work around a bug of lstat on some systems
- Copyright (C) 1997-2006, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 1997-2006, 2008-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/malloc.c b/lib/malloc.c
index 5d05f9f..e9b01d2 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* malloc() function that is glibc compatible.
- Copyright (C) 1997-1998, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1997-1998, 2006-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/malloca.c b/lib/malloca.c
index e6071f5..a613277 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Safe automatic memory allocation.
- Copyright (C) 2003, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@@ -51,12 +49,18 @@
#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]; };
+struct preliminary_header { void *next; int magic; };
/* 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));
+union header {
+ void *next;
+ struct {
+ char room[HEADER_SIZE - MAGIC_SIZE];
+ int word;
+ } magic;
+};
+verify (HEADER_SIZE == sizeof (union 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
@@ -76,20 +80,21 @@ mmalloca (size_t n)
if (nplus >= n)
{
- char *p = (char *) malloc (nplus);
+ void *p = malloc (nplus);
if (p != NULL)
{
size_t slot;
+ union header *h = p;
- p += HEADER_SIZE;
+ p = h + 1;
/* Put a magic number into the indicator word. */
- ((int *) p)[-1] = MAGIC_NUMBER;
+ h->magic.word = MAGIC_NUMBER;
/* Enter p into the hash table. */
slot = (uintptr_t) p % HASH_TABLE_SIZE;
- ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
+ h->next = mmalloca_results[slot];
mmalloca_results[slot] = p;
return p;
@@ -125,15 +130,17 @@ freea (void *p)
void **chain = &mmalloca_results[slot];
for (; *chain != NULL;)
{
+ union header *h = p;
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;
+ union header *p_begin = h - 1;
+ *chain = p_begin->next;
free (p_begin);
return;
}
- chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
+ h = *chain;
+ chain = &h[-1].next;
}
}
/* At this point, we know it was not a mmalloca() result. */
diff --git a/lib/malloca.h b/lib/malloca.h
index aeea648..7996d1b 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Safe automatic memory allocation.
- Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
@@ -23,6 +21,9 @@
#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
+#include <stdint.h>
+
+#include "xalloc-oversized.h"
#ifdef __cplusplus
@@ -75,15 +76,7 @@ extern void freea (void *p);
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
+#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
#ifdef __cplusplus
@@ -94,7 +87,7 @@ extern void * nmalloca (size_t n, size_t s);
/* ------------------- Auxiliary, non-public definitions ------------------- */
/* Determine the alignment of a type at compile time. */
-#if defined __GNUC__
+#if defined __GNUC__ || defined __IBM__ALIGNOF__
# define sa_alignof __alignof__
#elif defined __cplusplus
template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
diff --git a/lib/mbrlen.c b/lib/mbrlen.c
index f52e760..3ceb156 100644
--- a/lib/mbrlen.c
+++ b/lib/mbrlen.c
@@ -1,5 +1,5 @@
/* Recognize multibyte character.
- Copyright (C) 1999-2000, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2008-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index e3f354b..cdd874b 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -20,6 +20,11 @@
/* Specification. */
#include <wchar.h>
+#if C_LOCALE_MAYBE_EILSEQ
+# include "hard-locale.h"
+# include <locale.h>
+#endif
+
#if GNULIB_defined_mbstate_t
/* Implement mbrtowc() on top of mbtowc(). */
@@ -328,7 +333,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t
rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
{
-# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
+ size_t ret;
+ wchar_t wc;
+
+# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
if (s == NULL)
{
pwc = NULL;
@@ -337,6 +345,14 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# endif
+# if MBRTOWC_EMPTY_INPUT_BUG
+ if (n == 0)
+ return (size_t) -2;
+# endif
+
+ if (! pwc)
+ pwc = &wc;
+
# if MBRTOWC_RETVAL_BUG
{
static mbstate_t internal_state;
@@ -352,8 +368,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
size_t count = 0;
for (; n > 0; s++, n--)
{
- wchar_t wc;
- size_t ret = mbrtowc (&wc, s, 1, ps);
+ ret = mbrtowc (&wc, s, 1, ps);
if (ret == (size_t)(-1))
return (size_t)(-1);
@@ -361,8 +376,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (ret != (size_t)(-2))
{
/* The multibyte character has been completed. */
- if (pwc != NULL)
- *pwc = wc;
+ *pwc = wc;
return (wc == 0 ? 0 : count);
}
}
@@ -371,32 +385,23 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
# 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;
+ ret = mbrtowc (pwc, s, n, ps);
- if (pwc == NULL)
- pwc = &dummy;
-# endif
+# if MBRTOWC_NUL_RETVAL_BUG
+ if (ret < (size_t) -2 && !*pwc)
+ return 0;
+# endif
- return mbrtowc (pwc, s, n, ps);
- }
+# if C_LOCALE_MAYBE_EILSEQ
+ if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
+ {
+ unsigned char uc = *s;
+ *pwc = uc;
+ return 1;
+ }
# endif
+
+ return ret;
}
#endif
diff --git a/lib/mbsinit.c b/lib/mbsinit.c
index 638142e..372b523 100644
--- a/lib/mbsinit.c
+++ b/lib/mbsinit.c
@@ -1,5 +1,5 @@
/* Test for initial conversion state.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc-impl.h b/lib/mbtowc-impl.h
index bb75ed2..4be2994 100644
--- a/lib/mbtowc-impl.h
+++ b/lib/mbtowc-impl.h
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc.c b/lib/mbtowc.c
index 97eab4e..fb2b651 100644
--- a/lib/mbtowc.c
+++ b/lib/mbtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/memchr.c b/lib/memchr.c
index b8fb0ef..b565542 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2012
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2016
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
diff --git a/lib/memrchr.c b/lib/memrchr.c
new file mode 100644
index 0000000..e6212e5
--- /dev/null
+++ b/lib/memrchr.c
@@ -0,0 +1,161 @@
+/* memrchr -- find the last occurrence of a byte in a memory block
+
+ Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2016 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).
+
+ This 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 defined _LIBC
+# include <memcopy.h>
+#else
+# include <config.h>
+# define reg_char char
+#endif
+
+#include <string.h>
+#include <limits.h>
+
+#undef __memrchr
+#ifdef _LIBC
+# undef memrchr
+#endif
+
+#ifndef weak_alias
+# define __memrchr memrchr
+#endif
+
+/* Search no more than N bytes of S for C. */
+void *
+__memrchr (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 last 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;
+ n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
+ --n)
+ 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)
+ {
+ longword_ptr++;
+ break;
+ }
+ 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. */
+
+ while (n-- > 0)
+ {
+ if (*--char_ptr == c)
+ return (void *) char_ptr;
+ }
+
+ return NULL;
+}
+#ifdef weak_alias
+weak_alias (__memrchr, memrchr)
+#endif
diff --git a/lib/minmax.h b/lib/minmax.h
new file mode 100644
index 0000000..be6b321
--- /dev/null
+++ b/lib/minmax.h
@@ -0,0 +1,60 @@
+/* MIN, MAX macros.
+ Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2016 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, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _MINMAX_H
+#define _MINMAX_H
+
+/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
+ (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
+ MIN, MAX macro redefinitions on some systems; the workaround is to
+ #include this file as the last one among the #include list. */
+
+/* Before we define the following symbols we get the <limits.h> file
+ since otherwise we get redefinitions on some systems if <limits.h> is
+ included after this file. Likewise for <sys/param.h>.
+ If more than one of these system headers define MIN and MAX, pick just
+ one of the headers (because the definitions most likely are the same). */
+#if HAVE_MINMAX_IN_LIMITS_H
+# include <limits.h>
+#elif HAVE_MINMAX_IN_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+/* Note: MIN and MAX should be used with two arguments of the
+ same type. They might not return the minimum and maximum of their two
+ arguments, if the arguments have different types or have unusual
+ floating-point values. For example, on a typical host with 32-bit 'int',
+ 64-bit 'long long', and 64-bit IEEE 754 'double' types:
+
+ MAX (-1, 2147483648) returns 4294967295.
+ MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
+ MAX (NaN, 0.0) returns 0.0.
+ MAX (+0.0, -0.0) returns -0.0.
+
+ and in each case the answer is in some sense bogus. */
+
+/* MAX(a,b) returns the maximum of A and B. */
+#ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+/* MIN(a,b) returns the minimum of A and B. */
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#endif /* _MINMAX_H */
diff --git a/lib/mkostemp.c b/lib/mkostemp.c
index b769087..31c3e48 100644
--- a/lib/mkostemp.c
+++ b/lib/mkostemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2012 Free Software
+/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2016 Free Software
Foundation, Inc.
This file is derived from the one in the GNU C Library.
diff --git a/lib/msvc-inval.c b/lib/msvc-inval.c
index fb59d3a..baaf39e 100644
--- a/lib/msvc-inval.c
+++ b/lib/msvc-inval.c
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 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
@@ -30,7 +28,7 @@
# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
@@ -47,7 +45,7 @@ gl_msvc_invalid_parameter_handler (const wchar_t *expression,
# if defined _MSC_VER
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
@@ -96,7 +94,7 @@ gl_msvc_inval_current (void)
}
}
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h
index 524ea50..027c949 100644
--- a/lib/msvc-inval.h
+++ b/lib/msvc-inval.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/msvc-nothrow.c b/lib/msvc-nothrow.c
index e7538f8..ba75bbf 100644
--- a/lib/msvc-nothrow.c
+++ b/lib/msvc-nothrow.c
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/msvc-nothrow.h b/lib/msvc-nothrow.h
index 241b093..3493b84 100644
--- a/lib/msvc-nothrow.h
+++ b/lib/msvc-nothrow.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index c73c769..11da646 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -1,6 +1,6 @@
/* nl_langinfo() replacement: query locale dependent information.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,13 +20,71 @@
/* Specification. */
#include <langinfo.h>
+#include <locale.h>
+#include <string.h>
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+# include <stdio.h>
+#endif
+
+/* Return the codeset of the current locale, if this is easily deducible.
+ Otherwise, return "". */
+static char *
+ctype_codeset (void)
+{
+ static char buf[2 + 10 + 1];
+ char const *locale = setlocale (LC_CTYPE, NULL);
+ char *codeset = buf;
+ size_t codesetlen;
+ codeset[0] = '\0';
+
+ if (locale && locale[0])
+ {
+ /* If the locale name contains an encoding after the dot, return it. */
+ char *dot = strchr (locale, '.');
+
+ if (dot)
+ {
+ /* Look for the possible @... trailer and remove it, if any. */
+ char *codeset_start = dot + 1;
+ char const *modifier = strchr (codeset_start, '@');
+
+ if (! modifier)
+ codeset = codeset_start;
+ else
+ {
+ codesetlen = modifier - codeset_start;
+ if (codesetlen < sizeof buf)
+ {
+ codeset = memcpy (buf, codeset_start, codesetlen);
+ codeset[codesetlen] = '\0';
+ }
+ }
+ }
+ }
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ /* If setlocale is successful, it returns the number of the
+ codepage, as a string. Otherwise, fall back on Windows API
+ GetACP, which returns the locale's codepage as a number (although
+ this doesn't change according to what the 'setlocale' call specified).
+ Either way, prepend "CP" to make it a valid codeset name. */
+ codesetlen = strlen (codeset);
+ if (0 < codesetlen && codesetlen < sizeof buf - 2)
+ memmove (buf + 2, codeset, codesetlen + 1);
+ else
+ sprintf (buf + 2, "%u", GetACP ());
+ codeset = memcpy (buf, "CP", 2);
+#endif
+ return codeset;
+}
+
+
#if REPLACE_NL_LANGINFO
/* Override nl_langinfo with support for added nl_item values. */
-# include <locale.h>
-# include <string.h>
-
# undef nl_langinfo
char *
@@ -36,47 +94,18 @@ rpl_nl_langinfo (nl_item 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 "";
- }
+ return ctype_codeset ();
# endif
# if GNULIB_defined_T_FMT_AMPM
case T_FMT_AMPM:
- return "%I:%M:%S %p";
+ return (char *) "%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 "";
+ return (char *) "";
case ERA_D_FMT:
/* The %Ex conversion in strftime behaves like %x if the locale does not
have an alternative time format. */
@@ -95,13 +124,13 @@ rpl_nl_langinfo (nl_item item)
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";
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
# endif
# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
case YESEXPR:
- return "^[yY]";
+ return (char *) "^[yY]";
case NOEXPR:
- return "^[nN]";
+ return (char *) "^[nN]";
# endif
default:
break;
@@ -111,160 +140,181 @@ rpl_nl_langinfo (nl_item item)
#else
-/* Provide nl_langinfo from scratch. */
-
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Provide nl_langinfo from scratch, either for native MS-Windows, or
+ for old Unix platforms without locales, such as Linux libc5 or
+ BeOS. */
-/* 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>
+# include <time.h>
char *
nl_langinfo (nl_item item)
{
+ static char nlbuf[100];
+ struct tm tmm = { 0 };
+
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];
-
- /* The Windows API has a function returning the locale's codepage as
- a number. */
- sprintf (buf, "CP%u", GetACP ());
- return buf;
+ char *codeset = ctype_codeset ();
+ if (*codeset)
+ return codeset;
}
-# elif defined __BEOS__
- return "UTF-8";
+# ifdef __BEOS__
+ return (char *) "UTF-8";
# else
- return "ISO-8859-1";
+ return (char *) "ISO-8859-1";
# endif
/* nl_langinfo items of the LC_NUMERIC category */
case RADIXCHAR:
return localeconv () ->decimal_point;
case THOUSEP:
return localeconv () ->thousands_sep;
+ case GROUPING:
+ return localeconv () ->grouping;
/* 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";
+ return (char *) "%a %b %e %H:%M:%S %Y";
case D_FMT:
case ERA_D_FMT:
- return "%m/%d/%y";
+ return (char *) "%m/%d/%y";
case T_FMT:
case ERA_T_FMT:
- return "%H:%M:%S";
+ return (char *) "%H:%M:%S";
case T_FMT_AMPM:
- return "%I:%M:%S %p";
+ return (char *) "%I:%M:%S %p";
case AM_STR:
- return "AM";
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "AM";
+ return nlbuf;
case PM_STR:
- return "PM";
+ tmm.tm_hour = 12;
+ if (!strftime (nlbuf, sizeof nlbuf, "%p", &tmm))
+ return (char *) "PM";
+ return nlbuf;
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";
+ {
+ static char const days[][sizeof "Wednesday"] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday"
+ };
+ tmm.tm_wday = item - DAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%A", &tmm))
+ return (char *) days[item - DAY_1];
+ return nlbuf;
+ }
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";
+ {
+ static char const abdays[][sizeof "Sun"] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ tmm.tm_wday = item - ABDAY_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%a", &tmm))
+ return (char *) abdays[item - ABDAY_1];
+ return nlbuf;
+ }
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";
+ {
+ static char const months[][sizeof "September"] = {
+ "January", "February", "March", "April", "May", "June", "July",
+ "September", "October", "November", "December"
+ };
+ tmm.tm_mon = item - MON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%B", &tmm))
+ return (char *) months[item - MON_1];
+ return nlbuf;
+ }
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";
+ {
+ static char const abmonths[][sizeof "Jan"] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Sep", "Oct", "Nov", "Dec"
+ };
+ tmm.tm_mon = item - ABMON_1;
+ if (!strftime (nlbuf, sizeof nlbuf, "%b", &tmm))
+ return (char *) abmonths[item - ABMON_1];
+ return nlbuf;
+ }
case ERA:
- return "";
+ return (char *) "";
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. */
+ return (char *) "\0\0\0\0\0\0\0\0\0\0";
+ /* nl_langinfo items of the LC_MONETARY category. */
case CRNCYSTR:
- return "-";
+ return localeconv () ->currency_symbol;
+ case INT_CURR_SYMBOL:
+ return localeconv () ->int_curr_symbol;
+ case MON_DECIMAL_POINT:
+ return localeconv () ->mon_decimal_point;
+ case MON_THOUSANDS_SEP:
+ return localeconv () ->mon_thousands_sep;
+ case MON_GROUPING:
+ return localeconv () ->mon_grouping;
+ case POSITIVE_SIGN:
+ return localeconv () ->positive_sign;
+ case NEGATIVE_SIGN:
+ return localeconv () ->negative_sign;
+ case FRAC_DIGITS:
+ return & localeconv () ->frac_digits;
+ case INT_FRAC_DIGITS:
+ return & localeconv () ->int_frac_digits;
+ case P_CS_PRECEDES:
+ return & localeconv () ->p_cs_precedes;
+ case N_CS_PRECEDES:
+ return & localeconv () ->n_cs_precedes;
+ case P_SEP_BY_SPACE:
+ return & localeconv () ->p_sep_by_space;
+ case N_SEP_BY_SPACE:
+ return & localeconv () ->n_sep_by_space;
+ case P_SIGN_POSN:
+ return & localeconv () ->p_sign_posn;
+ case N_SIGN_POSN:
+ return & localeconv () ->n_sign_posn;
/* nl_langinfo items of the LC_MESSAGES category
TODO: Really use the locale. */
case YESEXPR:
- return "^[yY]";
+ return (char *) "^[yY]";
case NOEXPR:
- return "^[nN]";
+ return (char *) "^[nN]";
default:
- return "";
+ return (char *) "";
}
}
diff --git a/lib/obstack.c b/lib/obstack.c
index fc50f1e..6e7b52c 100644
--- a/lib/obstack.c
+++ b/lib/obstack.c
@@ -1,32 +1,32 @@
/* obstack.c - subroutines used implicitly by object stack macros
+ Copyright (C) 1988-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
- Copyright (C) 1988-1994, 1996-2006, 2009-2012 Free Software Foundation, Inc.
+ The GNU C Library 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 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,
+ The GNU C 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 General Public License for more details.
+ 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 the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef _LIBC
# include <obstack.h>
-# include <shlib-compat.h>
#else
# include <config.h>
# include "obstack.h"
#endif
-/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
- incremented whenever callers compiled using an old obstack.h can no
- longer properly call the functions in this obstack.c. */
-#define OBSTACK_INTERFACE_VERSION 1
+/* NOTE BEFORE MODIFYING THIS FILE: _OBSTACK_INTERFACE_VERSION in
+ obstack.h must be incremented whenever callers compiled using an old
+ obstack.h can no longer properly call the functions in this file. */
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself, and the installed library
@@ -36,114 +36,80 @@
(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. */
-
-#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
# include <gnu-versions.h>
-# if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
-# define ELIDE_CODE
+# if (_GNU_OBSTACK_INTERFACE_VERSION == _OBSTACK_INTERFACE_VERSION \
+ || (_GNU_OBSTACK_INTERFACE_VERSION == 1 \
+ && _OBSTACK_INTERFACE_VERSION == 2 \
+ && defined SIZEOF_INT && defined SIZEOF_SIZE_T \
+ && SIZEOF_INT == SIZEOF_SIZE_T))
+# define _OBSTACK_ELIDE_CODE
# endif
#endif
-#include <stddef.h>
-
-#ifndef ELIDE_CODE
-
+#ifndef _OBSTACK_ELIDE_CODE
+/* If GCC, or if an oddball (testing?) host that #defines __alignof__,
+ use the already-supplied __alignof__. Otherwise, this must be Gnulib
+ (as glibc assumes GCC); defer to Gnulib's alignof_type. */
+# if !defined __GNUC__ && !defined __alignof__
+# include <alignof.h>
+# define __alignof__(type) alignof_type (type)
+# endif
+# include <stdlib.h>
# include <stdint.h>
-/* Determine default alignment. */
-union fooround
-{
- uintmax_t i;
- long double d;
- void *p;
-};
-struct fooalign
-{
- char c;
- union fooround u;
-};
-/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
- But in fact it might be less smart and round addresses to as much as
- DEFAULT_ROUNDING. So we prepare for it to do that. */
-enum
- {
- DEFAULT_ALIGNMENT = offsetof (struct fooalign, u),
- DEFAULT_ROUNDING = sizeof (union fooround)
- };
-
-/* When we copy a long block of data, this is the unit to do it with.
- On some machines, copying successive ints does not work;
- in such a case, redefine COPYING_UNIT to 'long' (if that works)
- or 'char' as a last resort. */
-# ifndef COPYING_UNIT
-# define COPYING_UNIT int
+# ifndef MAX
+# define MAX(a,b) ((a) > (b) ? (a) : (b))
# endif
+/* Determine default alignment. */
-/* The functions allocating more room by calling 'obstack_chunk_alloc'
- jump to the handler pointed to by 'obstack_alloc_failed_handler'.
- This can be set to a user defined function which should either
- abort gracefully or use longjump - but shouldn't return. This
- variable by default points to the internal function
- 'print_and_abort'. */
-static _Noreturn void print_and_abort (void);
-void (*obstack_alloc_failed_handler) (void) = print_and_abort;
+/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
+ But in fact it might be less smart and round addresses to as much as
+ DEFAULT_ROUNDING. So we prepare for it to do that.
+
+ DEFAULT_ALIGNMENT cannot be an enum constant; see gnulib's alignof.h. */
+#define DEFAULT_ALIGNMENT MAX (__alignof__ (long double), \
+ MAX (__alignof__ (uintmax_t), \
+ __alignof__ (void *)))
+#define DEFAULT_ROUNDING MAX (sizeof (long double), \
+ MAX (sizeof (uintmax_t), \
+ sizeof (void *)))
+
+/* Call functions with either the traditional malloc/free calling
+ interface, or the mmalloc/mfree interface (that adds an extra first
+ argument), based on the value of use_extra_arg. */
+
+static void *
+call_chunkfun (struct obstack *h, size_t size)
+{
+ if (h->use_extra_arg)
+ return h->chunkfun.extra (h->extra_arg, size);
+ else
+ return h->chunkfun.plain (size);
+}
-/* Exit value used when 'print_and_abort' is used. */
-# include <stdlib.h>
-# ifdef _LIBC
-int obstack_exit_failure = EXIT_FAILURE;
-# else
-# include "exitfail.h"
-# define obstack_exit_failure exit_failure
-# endif
+static void
+call_freefun (struct obstack *h, void *old_chunk)
+{
+ if (h->use_extra_arg)
+ h->freefun.extra (h->extra_arg, old_chunk);
+ else
+ h->freefun.plain (old_chunk);
+}
-# ifdef _LIBC
-# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4)
-/* A looong time ago (before 1994, anyway; we're not sure) this global variable
- was used by non-GNU-C macros to avoid multiple evaluation. The GNU C
- library still exports it because somebody might use it. */
-struct obstack *_obstack_compat;
-compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0);
-# endif
-# endif
-/* Define a macro that either calls functions with the traditional malloc/free
- calling interface, or calls functions with the mmalloc/mfree interface
- (that adds an extra first argument), based on the state of use_extra_arg.
- For free, do not use ?:, since some compilers, like the MIPS compilers,
- do not allow (expr) ? void : void. */
-
-# define CALL_CHUNKFUN(h, size) \
- (((h) -> use_extra_arg) \
- ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
- : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
-
-# define CALL_FREEFUN(h, old_chunk) \
- do { \
- if ((h) -> use_extra_arg) \
- (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
- else \
- (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
- } while (0)
-
-
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
Objects start on multiples of ALIGNMENT (0 means use default).
- CHUNKFUN is the function to use to allocate chunks,
- and FREEFUN the function to free them.
Return nonzero if successful, calls obstack_alloc_failed_handler if
allocation fails. */
-int
-_obstack_begin (struct obstack *h,
- int size, int alignment,
- void *(*chunkfun) (long),
- void (*freefun) (void *))
+static int
+_obstack_begin_worker (struct obstack *h,
+ _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment)
{
- register struct _obstack_chunk *chunk; /* points to new chunk */
+ struct _obstack_chunk *chunk; /* points to new chunk */
if (alignment == 0)
alignment = DEFAULT_ALIGNMENT;
@@ -164,19 +130,15 @@ _obstack_begin (struct obstack *h,
size = 4096 - extra;
}
- h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
- h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
h->chunk_size = size;
h->alignment_mask = alignment - 1;
- h->use_extra_arg = 0;
- chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
+ chunk = h->chunk = call_chunkfun (h, h->chunk_size);
if (!chunk)
(*obstack_alloc_failed_handler) ();
h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
alignment - 1);
- h->chunk_limit = chunk->limit
- = (char *) chunk + h->chunk_size;
+ h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
@@ -185,51 +147,29 @@ _obstack_begin (struct obstack *h,
}
int
-_obstack_begin_1 (struct obstack *h, int size, int alignment,
- void *(*chunkfun) (void *, long),
+_obstack_begin (struct obstack *h,
+ _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment,
+ void *(*chunkfun) (size_t),
+ void (*freefun) (void *))
+{
+ h->chunkfun.plain = chunkfun;
+ h->freefun.plain = freefun;
+ h->use_extra_arg = 0;
+ return _obstack_begin_worker (h, size, alignment);
+}
+
+int
+_obstack_begin_1 (struct obstack *h,
+ _OBSTACK_SIZE_T size, _OBSTACK_SIZE_T alignment,
+ void *(*chunkfun) (void *, size_t),
void (*freefun) (void *, void *),
void *arg)
{
- register struct _obstack_chunk *chunk; /* points to new chunk */
-
- if (alignment == 0)
- alignment = DEFAULT_ALIGNMENT;
- if (size == 0)
- /* Default size is what GNU malloc can fit in a 4096-byte block. */
- {
- /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
- Use the values for range checking, because if range checking is off,
- the extra bytes won't be missed terribly, but if range checking is on
- and we used a larger request, a whole extra 4096 bytes would be
- allocated.
-
- These number are irrelevant to the new GNU malloc. I suspect it is
- less sensitive to the size of the request. */
- int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
- + 4 + DEFAULT_ROUNDING - 1)
- & ~(DEFAULT_ROUNDING - 1));
- size = 4096 - extra;
- }
-
- h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
- h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
- h->chunk_size = size;
- h->alignment_mask = alignment - 1;
+ h->chunkfun.extra = chunkfun;
+ h->freefun.extra = freefun;
h->extra_arg = arg;
h->use_extra_arg = 1;
-
- chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
- if (!chunk)
- (*obstack_alloc_failed_handler) ();
- h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
- alignment - 1);
- h->chunk_limit = chunk->limit
- = (char *) chunk + h->chunk_size;
- chunk->prev = 0;
- /* The initial chunk now contains no empty object. */
- h->maybe_empty_object = 0;
- h->alloc_failed = 0;
- return 1;
+ return _obstack_begin_worker (h, size, alignment);
}
/* Allocate a new current chunk for the obstack *H
@@ -239,25 +179,27 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
to the beginning of the new one. */
void
-_obstack_newchunk (struct obstack *h, int length)
+_obstack_newchunk (struct obstack *h, _OBSTACK_SIZE_T length)
{
- register struct _obstack_chunk *old_chunk = h->chunk;
- register struct _obstack_chunk *new_chunk;
- register long new_size;
- register long obj_size = h->next_free - h->object_base;
- register long i;
- long already;
+ struct _obstack_chunk *old_chunk = h->chunk;
+ struct _obstack_chunk *new_chunk = 0;
+ size_t obj_size = h->next_free - h->object_base;
char *object_base;
/* Compute size for new chunk. */
- new_size = (obj_size + length) + (obj_size >> 3) + h->alignment_mask + 100;
+ size_t sum1 = obj_size + length;
+ size_t sum2 = sum1 + h->alignment_mask;
+ size_t new_size = sum2 + (obj_size >> 3) + 100;
+ if (new_size < sum2)
+ new_size = sum2;
if (new_size < h->chunk_size)
new_size = h->chunk_size;
/* Allocate and initialize the new chunk. */
- new_chunk = CALL_CHUNKFUN (h, new_size);
+ if (obj_size <= sum1 && sum1 <= sum2)
+ new_chunk = call_chunkfun (h, new_size);
if (!new_chunk)
- (*obstack_alloc_failed_handler) ();
+ (*obstack_alloc_failed_handler)();
h->chunk = new_chunk;
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
@@ -266,36 +208,19 @@ _obstack_newchunk (struct obstack *h, int length)
object_base =
__PTR_ALIGN ((char *) new_chunk, new_chunk->contents, h->alignment_mask);
- /* Move the existing object to the new chunk.
- Word at a time is fast and is safe if the object
- is sufficiently aligned. */
- if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
- {
- for (i = obj_size / sizeof (COPYING_UNIT) - 1;
- i >= 0; i--)
- ((COPYING_UNIT *)object_base)[i]
- = ((COPYING_UNIT *)h->object_base)[i];
- /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
- but that can cross a page boundary on a machine
- which does not do strict alignment for COPYING_UNITS. */
- already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
- }
- else
- already = 0;
- /* Copy remaining bytes one by one. */
- for (i = already; i < obj_size; i++)
- object_base[i] = h->object_base[i];
+ /* Move the existing object to the new chunk. */
+ memcpy (object_base, h->object_base, obj_size);
/* If the object just copied was the only data in OLD_CHUNK,
free that chunk and remove it from the chain.
But not if that chunk might contain an empty object. */
- if (! h->maybe_empty_object
+ if (!h->maybe_empty_object
&& (h->object_base
== __PTR_ALIGN ((char *) old_chunk, old_chunk->contents,
h->alignment_mask)))
{
new_chunk->prev = old_chunk->prev;
- CALL_FREEFUN (h, old_chunk);
+ call_freefun (h, old_chunk);
}
h->object_base = object_base;
@@ -303,9 +228,6 @@ _obstack_newchunk (struct obstack *h, int length)
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
}
-# ifdef _LIBC
-libc_hidden_def (_obstack_newchunk)
-# endif
/* Return nonzero if object OBJ has been allocated from obstack H.
This is here for debugging.
@@ -313,13 +235,13 @@ libc_hidden_def (_obstack_newchunk)
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
obstack.h because it is just for debugging. */
-int _obstack_allocated_p (struct obstack *h, void *obj);
+int _obstack_allocated_p (struct obstack *h, void *obj) __attribute_pure__;
int
_obstack_allocated_p (struct obstack *h, void *obj)
{
- register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk *plp; /* point to previous chunk if any */
+ struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ struct _obstack_chunk *plp; /* point to previous chunk if any */
lp = (h)->chunk;
/* We use >= rather than > since the object cannot be exactly at
@@ -332,17 +254,15 @@ _obstack_allocated_p (struct obstack *h, void *obj)
}
return lp != 0;
}
-
+
/* Free objects in obstack H, including OBJ and everything allocate
more recently than OBJ. If OBJ is zero, free everything in H. */
-# undef obstack_free
-
void
-__obstack_free (struct obstack *h, void *obj)
+_obstack_free (struct obstack *h, void *obj)
{
- register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
- register struct _obstack_chunk *plp; /* point to previous chunk if any */
+ struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
+ struct _obstack_chunk *plp; /* point to previous chunk if any */
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
@@ -351,7 +271,7 @@ __obstack_free (struct obstack *h, void *obj)
while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
{
plp = lp->prev;
- CALL_FREEFUN (h, lp);
+ call_freefun (h, lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
@@ -368,17 +288,11 @@ __obstack_free (struct obstack *h, void *obj)
abort ();
}
-# ifdef _LIBC
-/* Older versions of libc used a function _obstack_free intended to be
- called by non-GCC compilers. */
-strong_alias (obstack_free, _obstack_free)
-# endif
-
-int
+_OBSTACK_SIZE_T
_obstack_memory_used (struct obstack *h)
{
- register struct _obstack_chunk* lp;
- register int nbytes = 0;
+ struct _obstack_chunk *lp;
+ _OBSTACK_SIZE_T nbytes = 0;
for (lp = h->chunk; lp != 0; lp = lp->prev)
{
@@ -386,20 +300,31 @@ _obstack_memory_used (struct obstack *h)
}
return nbytes;
}
-
+
+# ifndef _OBSTACK_NO_ERROR_HANDLER
/* Define the error handler. */
-# ifdef _LIBC
-# include <libintl.h>
-# else
-# include "gettext.h"
-# endif
-# ifndef _
-# define _(msgid) gettext (msgid)
-# endif
+# include <stdio.h>
-# ifdef _LIBC
-# include <libio/iolibio.h>
-# endif
+/* Exit value used when 'print_and_abort' is used. */
+# ifdef _LIBC
+int obstack_exit_failure = EXIT_FAILURE;
+# else
+# include "exitfail.h"
+# define obstack_exit_failure exit_failure
+# endif
+
+# ifdef _LIBC
+# include <libintl.h>
+# else
+# include "gettext.h"
+# endif
+# ifndef _
+# define _(msgid) gettext (msgid)
+# endif
+
+# ifdef _LIBC
+# include <libio/iolibio.h>
+# endif
static _Noreturn void
print_and_abort (void)
@@ -409,12 +334,21 @@ print_and_abort (void)
happen because the "memory exhausted" message appears in other places
like this and the translation should be reused instead of creating
a very similar string which requires a separate translation. */
-# ifdef _LIBC
+# ifdef _LIBC
(void) __fxprintf (NULL, "%s\n", _("memory exhausted"));
-# else
+# else
fprintf (stderr, "%s\n", _("memory exhausted"));
-# endif
+# endif
exit (obstack_exit_failure);
}
-#endif /* !ELIDE_CODE */
+/* The functions allocating more room by calling 'obstack_chunk_alloc'
+ jump to the handler pointed to by 'obstack_alloc_failed_handler'.
+ This can be set to a user defined function which should either
+ abort gracefully or use longjump - but shouldn't return. This
+ variable by default points to the internal function
+ 'print_and_abort'. */
+__attribute_noreturn__ void (*obstack_alloc_failed_handler) (void)
+ = print_and_abort;
+# endif /* !_OBSTACK_NO_ERROR_HANDLER */
+#endif /* !_OBSTACK_ELIDE_CODE */
diff --git a/lib/obstack.h b/lib/obstack.h
index 6a44b44..e558133 100644
--- a/lib/obstack.h
+++ b/lib/obstack.h
@@ -1,90 +1,90 @@
/* obstack.h - object stack macros
- Copyright (C) 1988-1994, 1996-1999, 2003-2006, 2009-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1988-2016 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.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
/* Summary:
-All the apparent functions defined here are macros. The idea
-is that you would use these pre-tested macros to solve a
-very specific set of problems, and they would run fast.
-Caution: no side-effects in arguments please!! They may be
-evaluated MANY times!!
-
-These macros operate a stack of objects. Each object starts life
-small, and may grow to maturity. (Consider building a word syllable
-by syllable.) An object can move while it is growing. Once it has
-been "finished" it never changes address again. So the "top of the
-stack" is typically an immature growing object, while the rest of the
-stack is of mature, fixed size and fixed address objects.
-
-These routines grab large chunks of memory, using a function you
-supply, called 'obstack_chunk_alloc'. On occasion, they free chunks,
-by calling 'obstack_chunk_free'. You must define them and declare
-them before using any obstack macros.
-
-Each independent stack is represented by a 'struct obstack'.
-Each of the obstack macros expects a pointer to such a structure
-as the first argument.
-
-One motivation for this package is the problem of growing char strings
-in symbol tables. Unless you are "fascist pig with a read-only mind"
---Gosper's immortal quote from HAKMEM item 154, out of context--you
-would not like to put any arbitrary upper limit on the length of your
-symbols.
-
-In practice this often means you will build many short symbols and a
-few long symbols. At the time you are reading a symbol you don't know
-how long it is. One traditional method is to read a symbol into a
-buffer, realloc()ating the buffer every time you try to read a symbol
-that is longer than the buffer. This is beaut, but you still will
-want to copy the symbol from the buffer to a more permanent
-symbol-table entry say about half the time.
-
-With obstacks, you can work differently. Use one obstack for all symbol
-names. As you read a symbol, grow the name in the obstack gradually.
-When the name is complete, finalize it. Then, if the symbol exists already,
-free the newly read name.
-
-The way we do this is to take a large chunk, allocating memory from
-low addresses. When you want to build a symbol in the chunk you just
-add chars above the current "high water mark" in the chunk. When you
-have finished adding chars, because you got to the end of the symbol,
-you know how long the chars are, and you can create a new object.
-Mostly the chars will not burst over the highest address of the chunk,
-because you would typically expect a chunk to be (say) 100 times as
-long as an average object.
-
-In case that isn't clear, when we have enough chars to make up
-the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
-so we just point to it where it lies. No moving of chars is
-needed and this is the second win: potentially long strings need
-never be explicitly shuffled. Once an object is formed, it does not
-change its address during its lifetime.
-
-When the chars burst over a chunk boundary, we allocate a larger
-chunk, and then copy the partly formed object from the end of the old
-chunk to the beginning of the new larger chunk. We then carry on
-accreting characters to the end of the object as we normally would.
-
-A special macro is provided to add a single char at a time to a
-growing object. This allows the use of register variables, which
-break the ordinary 'growth' macro.
-
-Summary:
+ All the apparent functions defined here are macros. The idea
+ is that you would use these pre-tested macros to solve a
+ very specific set of problems, and they would run fast.
+ Caution: no side-effects in arguments please!! They may be
+ evaluated MANY times!!
+
+ These macros operate a stack of objects. Each object starts life
+ small, and may grow to maturity. (Consider building a word syllable
+ by syllable.) An object can move while it is growing. Once it has
+ been "finished" it never changes address again. So the "top of the
+ stack" is typically an immature growing object, while the rest of the
+ stack is of mature, fixed size and fixed address objects.
+
+ These routines grab large chunks of memory, using a function you
+ supply, called 'obstack_chunk_alloc'. On occasion, they free chunks,
+ by calling 'obstack_chunk_free'. You must define them and declare
+ them before using any obstack macros.
+
+ Each independent stack is represented by a 'struct obstack'.
+ Each of the obstack macros expects a pointer to such a structure
+ as the first argument.
+
+ One motivation for this package is the problem of growing char strings
+ in symbol tables. Unless you are "fascist pig with a read-only mind"
+ --Gosper's immortal quote from HAKMEM item 154, out of context--you
+ would not like to put any arbitrary upper limit on the length of your
+ symbols.
+
+ In practice this often means you will build many short symbols and a
+ few long symbols. At the time you are reading a symbol you don't know
+ how long it is. One traditional method is to read a symbol into a
+ buffer, realloc()ating the buffer every time you try to read a symbol
+ that is longer than the buffer. This is beaut, but you still will
+ want to copy the symbol from the buffer to a more permanent
+ symbol-table entry say about half the time.
+
+ With obstacks, you can work differently. Use one obstack for all symbol
+ names. As you read a symbol, grow the name in the obstack gradually.
+ When the name is complete, finalize it. Then, if the symbol exists already,
+ free the newly read name.
+
+ The way we do this is to take a large chunk, allocating memory from
+ low addresses. When you want to build a symbol in the chunk you just
+ add chars above the current "high water mark" in the chunk. When you
+ have finished adding chars, because you got to the end of the symbol,
+ you know how long the chars are, and you can create a new object.
+ Mostly the chars will not burst over the highest address of the chunk,
+ because you would typically expect a chunk to be (say) 100 times as
+ long as an average object.
+
+ In case that isn't clear, when we have enough chars to make up
+ the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
+ so we just point to it where it lies. No moving of chars is
+ needed and this is the second win: potentially long strings need
+ never be explicitly shuffled. Once an object is formed, it does not
+ change its address during its lifetime.
+
+ When the chars burst over a chunk boundary, we allocate a larger
+ chunk, and then copy the partly formed object from the end of the old
+ chunk to the beginning of the new larger chunk. We then carry on
+ accreting characters to the end of the object as we normally would.
+
+ A special macro is provided to add a single char at a time to a
+ growing object. This allows the use of register variables, which
+ break the ordinary 'growth' macro.
+
+ Summary:
We allocate large chunks.
We carve out one object at a time from the current chunk.
Once carved, an object never moves.
@@ -96,24 +96,38 @@ Summary:
Because of the way we do it, you can "unwind" an obstack
back to a previous state. (You may remove objects much
as you would with a stack.)
-*/
+ */
/* Don't do the contents of this file more than once. */
#ifndef _OBSTACK_H
#define _OBSTACK_H 1
-
-/* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is
- defined, as with GNU C, use that; that way we don't pollute the
- namespace with <stddef.h>'s symbols. Otherwise, include <stddef.h>
- and use ptrdiff_t. */
-
-#ifdef __PTRDIFF_TYPE__
-# define PTR_INT_TYPE __PTRDIFF_TYPE__
+
+#ifndef _OBSTACK_INTERFACE_VERSION
+# define _OBSTACK_INTERFACE_VERSION 2
+#endif
+
+#include <stddef.h> /* For size_t and ptrdiff_t. */
+#include <string.h> /* For __GNU_LIBRARY__, and memcpy. */
+
+#if __STDC_VERSION__ < 199901L
+# define __FLEXIBLE_ARRAY_MEMBER 1
#else
-# include <stddef.h>
-# define PTR_INT_TYPE ptrdiff_t
+# define __FLEXIBLE_ARRAY_MEMBER
+#endif
+
+#if _OBSTACK_INTERFACE_VERSION == 1
+/* For binary compatibility with obstack version 1, which used "int"
+ and "long" for these two types. */
+# define _OBSTACK_SIZE_T unsigned int
+# define _CHUNK_SIZE_T unsigned long
+# define _OBSTACK_CAST(type, expr) ((type) (expr))
+#else
+/* Version 2 with sane types, especially for 64-bit hosts. */
+# define _OBSTACK_SIZE_T size_t
+# define _CHUNK_SIZE_T size_t
+# define _OBSTACK_CAST(type, expr) (expr)
#endif
/* If B is the base of an object addressed by P, return the result of
@@ -122,18 +136,29 @@ Summary:
#define __BPTR_ALIGN(B, P, A) ((B) + (((P) - (B) + (A)) & ~(A)))
-/* Similar to _BPTR_ALIGN (B, P, A), except optimize the common case
+/* Similar to __BPTR_ALIGN (B, P, A), except optimize the common case
where pointers can be converted to integers, aligned as integers,
- and converted back again. If PTR_INT_TYPE is narrower than a
+ and converted back again. If ptrdiff_t is narrower than a
pointer (e.g., the AS/400), play it safe and compute the alignment
relative to B. Otherwise, use the faster strategy of computing the
alignment relative to 0. */
-#define __PTR_ALIGN(B, P, A) \
- __BPTR_ALIGN (sizeof (PTR_INT_TYPE) < sizeof (void *) ? (B) : (char *) 0, \
+#define __PTR_ALIGN(B, P, A) \
+ __BPTR_ALIGN (sizeof (ptrdiff_t) < sizeof (void *) ? (B) : (char *) 0, \
P, A)
-#include <string.h>
+#ifndef __attribute_pure__
+# define __attribute_pure__ _GL_ATTRIBUTE_PURE
+#endif
+
+/* Not the same as _Noreturn, since it also works with function pointers. */
+#ifndef __attribute_noreturn__
+# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
+# define __attribute_noreturn__ __attribute__ ((__noreturn__))
+# else
+# define __attribute_noreturn__
+# endif
+#endif
#ifdef __cplusplus
extern "C" {
@@ -141,67 +166,72 @@ extern "C" {
struct _obstack_chunk /* Lives at front of each chunk. */
{
- char *limit; /* 1 past end of this chunk */
+ char *limit; /* 1 past end of this chunk */
struct _obstack_chunk *prev; /* address of prior chunk or NULL */
- char contents[4]; /* objects begin here */
+ char contents[__FLEXIBLE_ARRAY_MEMBER]; /* objects begin here */
};
struct obstack /* control current object in current chunk */
{
- long chunk_size; /* preferred size to allocate chunks in */
+ _CHUNK_SIZE_T chunk_size; /* preferred size to allocate chunks in */
struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */
- char *object_base; /* address of object we are building */
- char *next_free; /* where to add next char to current object */
- char *chunk_limit; /* address of char after current chunk */
+ char *object_base; /* address of object we are building */
+ char *next_free; /* where to add next char to current object */
+ char *chunk_limit; /* address of char after current chunk */
union
{
- PTR_INT_TYPE tempint;
- void *tempptr;
+ _OBSTACK_SIZE_T i;
+ void *p;
} temp; /* Temporary for some macros. */
- int alignment_mask; /* Mask of alignment for each object. */
- /* These prototypes vary based on 'use_extra_arg', and we use
- casts to the prototypeless function type in all assignments,
- but having prototypes here quiets -Wstrict-prototypes. */
- struct _obstack_chunk *(*chunkfun) (void *, long);
- void (*freefun) (void *, struct _obstack_chunk *);
+ _OBSTACK_SIZE_T alignment_mask; /* Mask of alignment for each object. */
+
+ /* These prototypes vary based on 'use_extra_arg'. */
+ union
+ {
+ void *(*plain) (size_t);
+ void *(*extra) (void *, size_t);
+ } chunkfun;
+ union
+ {
+ void (*plain) (void *);
+ void (*extra) (void *, void *);
+ } freefun;
+
void *extra_arg; /* first arg for chunk alloc/dealloc funcs */
- unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */
- unsigned maybe_empty_object:1;/* There is a possibility that the current
- chunk contains a zero-length object. This
- prevents freeing the chunk if we allocate
- a bigger chunk to replace it. */
- unsigned alloc_failed:1; /* No longer used, as we now call the failed
- handler on error, but retained for binary
- compatibility. */
+ unsigned use_extra_arg : 1; /* chunk alloc/dealloc funcs take extra arg */
+ unsigned maybe_empty_object : 1; /* There is a possibility that the current
+ chunk contains a zero-length object. This
+ prevents freeing the chunk if we allocate
+ a bigger chunk to replace it. */
+ unsigned alloc_failed : 1; /* No longer used, as we now call the failed
+ handler on error, but retained for binary
+ compatibility. */
};
/* Declare the external functions we use; they are in obstack.c. */
-extern void _obstack_newchunk (struct obstack *, int);
-extern int _obstack_begin (struct obstack *, int, int,
- void *(*) (long), void (*) (void *));
-extern int _obstack_begin_1 (struct obstack *, int, int,
- void *(*) (void *, long),
+extern void _obstack_newchunk (struct obstack *, _OBSTACK_SIZE_T);
+extern void _obstack_free (struct obstack *, void *);
+extern int _obstack_begin (struct obstack *,
+ _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
+ void *(*) (size_t), void (*) (void *));
+extern int _obstack_begin_1 (struct obstack *,
+ _OBSTACK_SIZE_T, _OBSTACK_SIZE_T,
+ void *(*) (void *, size_t),
void (*) (void *, void *), void *);
-extern int _obstack_memory_used (struct obstack *);
+extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *)
+ __attribute_pure__;
-/* The default name of the function for freeing a chunk is 'obstack_free',
- but gnulib users can override this by defining '__obstack_free'. */
-#ifndef __obstack_free
-# define __obstack_free obstack_free
-#endif
-extern void __obstack_free (struct obstack *obstack, void *block);
-
/* Error handler called when 'obstack_chunk_alloc' failed to allocate
more memory. This can be set to a user defined function which
should either abort gracefully or use longjump - but shouldn't
return. The default action is to print a message and abort. */
-extern void (*obstack_alloc_failed_handler) (void);
+extern __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void);
/* Exit value used when 'print_and_abort' is used. */
extern int obstack_exit_failure;
-
+
/* Pointer to beginning of object being allocated or to be allocated next.
Note that this might not be the final address of the object
because a new chunk might be needed to hold the final size. */
@@ -214,50 +244,47 @@ extern int obstack_exit_failure;
/* Pointer to next byte not yet allocated in current chunk. */
-#define obstack_next_free(h) ((h)->next_free)
+#define obstack_next_free(h) ((void *) (h)->next_free)
/* Mask specifying low bits that should be clear in address of an object. */
#define obstack_alignment_mask(h) ((h)->alignment_mask)
/* To prevent prototype warnings provide complete argument list. */
-#define obstack_init(h) \
- _obstack_begin ((h), 0, 0, \
- (void *(*) (long)) obstack_chunk_alloc, \
- (void (*) (void *)) obstack_chunk_free)
+#define obstack_init(h) \
+ _obstack_begin ((h), 0, 0, \
+ _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \
+ _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
-#define obstack_begin(h, size) \
- _obstack_begin ((h), (size), 0, \
- (void *(*) (long)) obstack_chunk_alloc, \
- (void (*) (void *)) obstack_chunk_free)
+#define obstack_begin(h, size) \
+ _obstack_begin ((h), (size), 0, \
+ _OBSTACK_CAST (void *(*) (size_t), obstack_chunk_alloc), \
+ _OBSTACK_CAST (void (*) (void *), obstack_chunk_free))
-#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
- _obstack_begin ((h), (size), (alignment), \
- (void *(*) (long)) (chunkfun), \
- (void (*) (void *)) (freefun))
+#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+ _obstack_begin ((h), (size), (alignment), \
+ _OBSTACK_CAST (void *(*) (size_t), chunkfun), \
+ _OBSTACK_CAST (void (*) (void *), freefun))
#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
- _obstack_begin_1 ((h), (size), (alignment), \
- (void *(*) (void *, long)) (chunkfun), \
- (void (*) (void *, void *)) (freefun), (arg))
+ _obstack_begin_1 ((h), (size), (alignment), \
+ _OBSTACK_CAST (void *(*) (void *, size_t), chunkfun), \
+ _OBSTACK_CAST (void (*) (void *, void *), freefun), arg)
-#define obstack_chunkfun(h, newchunkfun) \
- ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
+#define obstack_chunkfun(h, newchunkfun) \
+ ((void) ((h)->chunkfun.extra = (void *(*) (void *, size_t)) (newchunkfun)))
-#define obstack_freefun(h, newfreefun) \
- ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
+#define obstack_freefun(h, newfreefun) \
+ ((void) ((h)->freefun.extra = (void *(*) (void *, void *)) (newfreefun)))
-#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar))
+#define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar)))
-#define obstack_blank_fast(h,n) ((h)->next_free += (n))
+#define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n)))
#define obstack_memory_used(h) _obstack_memory_used (h)
-
+
#if defined __GNUC__
-/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
- does not implement __extension__. But that compiler doesn't define
- __GNUC_MINOR__. */
-# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
+# if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
# define __extension__
# endif
@@ -266,158 +293,161 @@ extern int obstack_exit_failure;
without using a global variable.
Also, we can avoid using the 'temp' slot, to make faster code. */
-# define obstack_object_size(OBSTACK) \
- __extension__ \
- ({ struct obstack const *__o = (OBSTACK); \
- (unsigned) (__o->next_free - __o->object_base); })
-
-# define obstack_room(OBSTACK) \
- __extension__ \
- ({ struct obstack const *__o = (OBSTACK); \
- (unsigned) (__o->chunk_limit - __o->next_free); })
-
-# define obstack_make_room(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- if (__o->chunk_limit - __o->next_free < __len) \
- _obstack_newchunk (__o, __len); \
- (void) 0; })
-
-# define obstack_empty_p(OBSTACK) \
- __extension__ \
- ({ struct obstack const *__o = (OBSTACK); \
- (__o->chunk->prev == 0 \
- && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
- __o->chunk->contents, \
- __o->alignment_mask)); })
-
-# define obstack_grow(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- if (__o->next_free + __len > __o->chunk_limit) \
- _obstack_newchunk (__o, __len); \
- memcpy (__o->next_free, where, __len); \
- __o->next_free += __len; \
- (void) 0; })
-
-# define obstack_grow0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- if (__o->next_free + __len + 1 > __o->chunk_limit) \
- _obstack_newchunk (__o, __len + 1); \
- memcpy (__o->next_free, where, __len); \
- __o->next_free += __len; \
- *(__o->next_free)++ = 0; \
- (void) 0; })
-
-# define obstack_1grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- if (__o->next_free + 1 > __o->chunk_limit) \
- _obstack_newchunk (__o, 1); \
- obstack_1grow_fast (__o, datum); \
- (void) 0; })
+# define obstack_object_size(OBSTACK) \
+ __extension__ \
+ ({ struct obstack const *__o = (OBSTACK); \
+ (_OBSTACK_SIZE_T) (__o->next_free - __o->object_base); })
+
+/* The local variable is named __o1 to avoid a shadowed variable
+ warning when invoked from other obstack macros. */
+# define obstack_room(OBSTACK) \
+ __extension__ \
+ ({ struct obstack const *__o1 = (OBSTACK); \
+ (_OBSTACK_SIZE_T) (__o1->chunk_limit - __o1->next_free); })
+
+# define obstack_make_room(OBSTACK, length) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ _OBSTACK_SIZE_T __len = (length); \
+ if (obstack_room (__o) < __len) \
+ _obstack_newchunk (__o, __len); \
+ (void) 0; })
+
+# define obstack_empty_p(OBSTACK) \
+ __extension__ \
+ ({ struct obstack const *__o = (OBSTACK); \
+ (__o->chunk->prev == 0 \
+ && __o->next_free == __PTR_ALIGN ((char *) __o->chunk, \
+ __o->chunk->contents, \
+ __o->alignment_mask)); })
+
+# define obstack_grow(OBSTACK, where, length) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ _OBSTACK_SIZE_T __len = (length); \
+ if (obstack_room (__o) < __len) \
+ _obstack_newchunk (__o, __len); \
+ memcpy (__o->next_free, where, __len); \
+ __o->next_free += __len; \
+ (void) 0; })
+
+# define obstack_grow0(OBSTACK, where, length) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ _OBSTACK_SIZE_T __len = (length); \
+ if (obstack_room (__o) < __len + 1) \
+ _obstack_newchunk (__o, __len + 1); \
+ memcpy (__o->next_free, where, __len); \
+ __o->next_free += __len; \
+ *(__o->next_free)++ = 0; \
+ (void) 0; })
+
+# define obstack_1grow(OBSTACK, datum) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ if (obstack_room (__o) < 1) \
+ _obstack_newchunk (__o, 1); \
+ obstack_1grow_fast (__o, datum); })
/* These assume that the obstack alignment is good enough for pointers
or ints, and that the data added so far to the current object
shares that much alignment. */
-# define obstack_ptr_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- if (__o->next_free + sizeof (void *) > __o->chunk_limit) \
- _obstack_newchunk (__o, sizeof (void *)); \
- obstack_ptr_grow_fast (__o, datum); }) \
-
-# define obstack_int_grow(OBSTACK,datum) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- if (__o->next_free + sizeof (int) > __o->chunk_limit) \
- _obstack_newchunk (__o, sizeof (int)); \
- obstack_int_grow_fast (__o, datum); })
-
-# define obstack_ptr_grow_fast(OBSTACK,aptr) \
-__extension__ \
-({ struct obstack *__o1 = (OBSTACK); \
- *(const void **) __o1->next_free = (aptr); \
- __o1->next_free += sizeof (const void *); \
- (void) 0; })
-
-# define obstack_int_grow_fast(OBSTACK,aint) \
-__extension__ \
-({ struct obstack *__o1 = (OBSTACK); \
- *(int *) __o1->next_free = (aint); \
- __o1->next_free += sizeof (int); \
- (void) 0; })
-
-# define obstack_blank(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- int __len = (length); \
- if (__o->chunk_limit - __o->next_free < __len) \
- _obstack_newchunk (__o, __len); \
- obstack_blank_fast (__o, __len); \
- (void) 0; })
-
-# define obstack_alloc(OBSTACK,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_blank (__h, (length)); \
- obstack_finish (__h); })
-
-# define obstack_copy(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow (__h, (where), (length)); \
- obstack_finish (__h); })
-
-# define obstack_copy0(OBSTACK,where,length) \
-__extension__ \
-({ struct obstack *__h = (OBSTACK); \
- obstack_grow0 (__h, (where), (length)); \
- obstack_finish (__h); })
-
-/* The local variable is named __o1 to avoid a name conflict
- when obstack_blank is called. */
-# define obstack_finish(OBSTACK) \
-__extension__ \
-({ struct obstack *__o1 = (OBSTACK); \
- void *__value = (void *) __o1->object_base; \
- if (__o1->next_free == __value) \
- __o1->maybe_empty_object = 1; \
- __o1->next_free \
- = __PTR_ALIGN (__o1->object_base, __o1->next_free, \
- __o1->alignment_mask); \
- if (__o1->next_free - (char *)__o1->chunk \
- > __o1->chunk_limit - (char *)__o1->chunk) \
- __o1->next_free = __o1->chunk_limit; \
- __o1->object_base = __o1->next_free; \
- __value; })
-
-# define obstack_free(OBSTACK, OBJ) \
-__extension__ \
-({ struct obstack *__o = (OBSTACK); \
- void *__obj = (OBJ); \
- if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \
- __o->next_free = __o->object_base = (char *)__obj; \
- else (__obstack_free) (__o, __obj); })
-
+# define obstack_ptr_grow(OBSTACK, datum) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ if (obstack_room (__o) < sizeof (void *)) \
+ _obstack_newchunk (__o, sizeof (void *)); \
+ obstack_ptr_grow_fast (__o, datum); })
+
+# define obstack_int_grow(OBSTACK, datum) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ if (obstack_room (__o) < sizeof (int)) \
+ _obstack_newchunk (__o, sizeof (int)); \
+ obstack_int_grow_fast (__o, datum); })
+
+# define obstack_ptr_grow_fast(OBSTACK, aptr) \
+ __extension__ \
+ ({ struct obstack *__o1 = (OBSTACK); \
+ void *__p1 = __o1->next_free; \
+ *(const void **) __p1 = (aptr); \
+ __o1->next_free += sizeof (const void *); \
+ (void) 0; })
+
+# define obstack_int_grow_fast(OBSTACK, aint) \
+ __extension__ \
+ ({ struct obstack *__o1 = (OBSTACK); \
+ void *__p1 = __o1->next_free; \
+ *(int *) __p1 = (aint); \
+ __o1->next_free += sizeof (int); \
+ (void) 0; })
+
+# define obstack_blank(OBSTACK, length) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ _OBSTACK_SIZE_T __len = (length); \
+ if (obstack_room (__o) < __len) \
+ _obstack_newchunk (__o, __len); \
+ obstack_blank_fast (__o, __len); })
+
+# define obstack_alloc(OBSTACK, length) \
+ __extension__ \
+ ({ struct obstack *__h = (OBSTACK); \
+ obstack_blank (__h, (length)); \
+ obstack_finish (__h); })
+
+# define obstack_copy(OBSTACK, where, length) \
+ __extension__ \
+ ({ struct obstack *__h = (OBSTACK); \
+ obstack_grow (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+# define obstack_copy0(OBSTACK, where, length) \
+ __extension__ \
+ ({ struct obstack *__h = (OBSTACK); \
+ obstack_grow0 (__h, (where), (length)); \
+ obstack_finish (__h); })
+
+/* The local variable is named __o1 to avoid a shadowed variable
+ warning when invoked from other obstack macros, typically obstack_free. */
+# define obstack_finish(OBSTACK) \
+ __extension__ \
+ ({ struct obstack *__o1 = (OBSTACK); \
+ void *__value = (void *) __o1->object_base; \
+ if (__o1->next_free == __value) \
+ __o1->maybe_empty_object = 1; \
+ __o1->next_free \
+ = __PTR_ALIGN (__o1->object_base, __o1->next_free, \
+ __o1->alignment_mask); \
+ if ((size_t) (__o1->next_free - (char *) __o1->chunk) \
+ > (size_t) (__o1->chunk_limit - (char *) __o1->chunk)) \
+ __o1->next_free = __o1->chunk_limit; \
+ __o1->object_base = __o1->next_free; \
+ __value; })
+
+# define obstack_free(OBSTACK, OBJ) \
+ __extension__ \
+ ({ struct obstack *__o = (OBSTACK); \
+ void *__obj = (void *) (OBJ); \
+ if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) \
+ __o->next_free = __o->object_base = (char *) __obj; \
+ else \
+ _obstack_free (__o, __obj); })
+
#else /* not __GNUC__ */
-# define obstack_object_size(h) \
- (unsigned) ((h)->next_free - (h)->object_base)
+# define obstack_object_size(h) \
+ ((_OBSTACK_SIZE_T) ((h)->next_free - (h)->object_base))
-# define obstack_room(h) \
- (unsigned) ((h)->chunk_limit - (h)->next_free)
+# define obstack_room(h) \
+ ((_OBSTACK_SIZE_T) ((h)->chunk_limit - (h)->next_free))
-# define obstack_empty_p(h) \
- ((h)->chunk->prev == 0 \
- && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
- (h)->chunk->contents, \
- (h)->alignment_mask))
+# define obstack_empty_p(h) \
+ ((h)->chunk->prev == 0 \
+ && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk, \
+ (h)->chunk->contents, \
+ (h)->alignment_mask))
/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
so that we can avoid having void expressions
@@ -425,83 +455,87 @@ __extension__ \
Casting the third operand to void was tried before,
but some compilers won't accept it. */
-# define obstack_make_room(h,length) \
-( (h)->temp.tempint = (length), \
- (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0))
-
-# define obstack_grow(h,where,length) \
-( (h)->temp.tempint = (length), \
- (((h)->next_free + (h)->temp.tempint > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
- memcpy ((h)->next_free, where, (h)->temp.tempint), \
- (h)->next_free += (h)->temp.tempint)
-
-# define obstack_grow0(h,where,length) \
-( (h)->temp.tempint = (length), \
- (((h)->next_free + (h)->temp.tempint + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), (h)->temp.tempint + 1), 0) : 0), \
- memcpy ((h)->next_free, where, (h)->temp.tempint), \
- (h)->next_free += (h)->temp.tempint, \
- *((h)->next_free)++ = 0)
-
-# define obstack_1grow(h,datum) \
-( (((h)->next_free + 1 > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), 1), 0) : 0), \
- obstack_1grow_fast (h, datum))
-
-# define obstack_ptr_grow(h,datum) \
-( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
- obstack_ptr_grow_fast (h, datum))
-
-# define obstack_int_grow(h,datum) \
-( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \
- ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
- obstack_int_grow_fast (h, datum))
-
-# define obstack_ptr_grow_fast(h,aptr) \
- (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
-
-# define obstack_int_grow_fast(h,aint) \
- (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
-
-# define obstack_blank(h,length) \
-( (h)->temp.tempint = (length), \
- (((h)->chunk_limit - (h)->next_free < (h)->temp.tempint) \
- ? (_obstack_newchunk ((h), (h)->temp.tempint), 0) : 0), \
- obstack_blank_fast (h, (h)->temp.tempint))
-
-# define obstack_alloc(h,length) \
- (obstack_blank ((h), (length)), obstack_finish ((h)))
-
-# define obstack_copy(h,where,length) \
- (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
-
-# define obstack_copy0(h,where,length) \
- (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
-
-# define obstack_finish(h) \
-( ((h)->next_free == (h)->object_base \
- ? (((h)->maybe_empty_object = 1), 0) \
- : 0), \
- (h)->temp.tempptr = (h)->object_base, \
- (h)->next_free \
- = __PTR_ALIGN ((h)->object_base, (h)->next_free, \
- (h)->alignment_mask), \
- (((h)->next_free - (char *) (h)->chunk \
- > (h)->chunk_limit - (char *) (h)->chunk) \
- ? ((h)->next_free = (h)->chunk_limit) : 0), \
- (h)->object_base = (h)->next_free, \
- (h)->temp.tempptr)
-
-# define obstack_free(h,obj) \
-( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \
- ((((h)->temp.tempint > 0 \
- && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \
- ? (int) ((h)->next_free = (h)->object_base \
- = (h)->temp.tempint + (char *) (h)->chunk) \
- : (((__obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0)))
+# define obstack_make_room(h, length) \
+ ((h)->temp.i = (length), \
+ ((obstack_room (h) < (h)->temp.i) \
+ ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0), \
+ (void) 0)
+
+# define obstack_grow(h, where, length) \
+ ((h)->temp.i = (length), \
+ ((obstack_room (h) < (h)->temp.i) \
+ ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \
+ memcpy ((h)->next_free, where, (h)->temp.i), \
+ (h)->next_free += (h)->temp.i, \
+ (void) 0)
+
+# define obstack_grow0(h, where, length) \
+ ((h)->temp.i = (length), \
+ ((obstack_room (h) < (h)->temp.i + 1) \
+ ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \
+ memcpy ((h)->next_free, where, (h)->temp.i), \
+ (h)->next_free += (h)->temp.i, \
+ *((h)->next_free)++ = 0, \
+ (void) 0)
+
+# define obstack_1grow(h, datum) \
+ (((obstack_room (h) < 1) \
+ ? (_obstack_newchunk ((h), 1), 0) : 0), \
+ obstack_1grow_fast (h, datum))
+
+# define obstack_ptr_grow(h, datum) \
+ (((obstack_room (h) < sizeof (char *)) \
+ ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \
+ obstack_ptr_grow_fast (h, datum))
+
+# define obstack_int_grow(h, datum) \
+ (((obstack_room (h) < sizeof (int)) \
+ ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
+ obstack_int_grow_fast (h, datum))
+
+# define obstack_ptr_grow_fast(h, aptr) \
+ (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr), \
+ (void) 0)
+
+# define obstack_int_grow_fast(h, aint) \
+ (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint), \
+ (void) 0)
+
+# define obstack_blank(h, length) \
+ ((h)->temp.i = (length), \
+ ((obstack_room (h) < (h)->temp.i) \
+ ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \
+ obstack_blank_fast (h, (h)->temp.i))
+
+# define obstack_alloc(h, length) \
+ (obstack_blank ((h), (length)), obstack_finish ((h)))
+
+# define obstack_copy(h, where, length) \
+ (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_copy0(h, where, length) \
+ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_finish(h) \
+ (((h)->next_free == (h)->object_base \
+ ? (((h)->maybe_empty_object = 1), 0) \
+ : 0), \
+ (h)->temp.p = (h)->object_base, \
+ (h)->next_free \
+ = __PTR_ALIGN ((h)->object_base, (h)->next_free, \
+ (h)->alignment_mask), \
+ (((size_t) ((h)->next_free - (char *) (h)->chunk) \
+ > (size_t) ((h)->chunk_limit - (char *) (h)->chunk)) \
+ ? ((h)->next_free = (h)->chunk_limit) : 0), \
+ (h)->object_base = (h)->next_free, \
+ (h)->temp.p)
+
+# define obstack_free(h, obj) \
+ ((h)->temp.p = (void *) (obj), \
+ (((h)->temp.p > (void *) (h)->chunk \
+ && (h)->temp.p < (void *) (h)->chunk_limit) \
+ ? (void) ((h)->next_free = (h)->object_base = (char *) (h)->temp.p) \
+ : _obstack_free ((h), (h)->temp.p)))
#endif /* not __GNUC__ */
@@ -509,4 +543,4 @@ __extension__ \
} /* C++ */
#endif
-#endif /* obstack.h */
+#endif /* _OBSTACK_H */
diff --git a/lib/pathmax.h b/lib/pathmax.h
index bd0bc00..aee22f8 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 Free Software
+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2016 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
diff --git a/lib/progname.c b/lib/progname.c
new file mode 100644
index 0000000..debb760
--- /dev/null
+++ b/lib/progname.c
@@ -0,0 +1,92 @@
+/* Program name management.
+ Copyright (C) 2001-2003, 2005-2016 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2001.
+
+ This 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. */
+#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
+#include "progname.h"
+
+#include <errno.h> /* get program_invocation_name declaration */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+/* String containing name the program is called with.
+ To be initialized by main(). */
+const char *program_name = NULL;
+
+/* Set program_name, based on argv[0].
+ argv0 must be a string allocated with indefinite extent, and must not be
+ modified after this call. */
+void
+set_program_name (const char *argv0)
+{
+ /* libtool creates a temporary executable whose name is sometimes prefixed
+ with "lt-" (depends on the platform). It also makes argv[0] absolute.
+ But the name of the temporary executable is a detail that should not be
+ visible to the end user and to the test suite.
+ Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
+ const char *slash;
+ const char *base;
+
+ /* Sanity check. POSIX requires the invoking process to pass a non-NULL
+ argv[0]. */
+ if (argv0 == NULL)
+ {
+ /* It's a bug in the invoking program. Help diagnosing it. */
+ fputs ("A NULL argv[0] was passed through an exec system call.\n",
+ stderr);
+ abort ();
+ }
+
+ slash = strrchr (argv0, '/');
+ base = (slash != NULL ? slash + 1 : argv0);
+ if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+ {
+ argv0 = base;
+ if (strncmp (base, "lt-", 3) == 0)
+ {
+ argv0 = base + 3;
+ /* On glibc systems, remove the "lt-" prefix from the variable
+ program_invocation_short_name. */
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = (char *) argv0;
+#endif
+ }
+ }
+
+ /* But don't strip off a leading <dirname>/ in general, because when the user
+ runs
+ /some/hidden/place/bin/cp foo foo
+ he should get the error message
+ /some/hidden/place/bin/cp: `foo' and `foo' are the same file
+ not
+ cp: `foo' and `foo' are the same file
+ */
+
+ program_name = argv0;
+
+ /* On glibc systems, the error() function comes from libc and uses the
+ variable program_invocation_name, not program_name. So set this variable
+ as well. */
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
+ program_invocation_name = (char *) argv0;
+#endif
+}
diff --git a/lib/progname.h b/lib/progname.h
new file mode 100644
index 0000000..0a57407
--- /dev/null
+++ b/lib/progname.h
@@ -0,0 +1,62 @@
+/* Program name management.
+ Copyright (C) 2001-2004, 2006, 2009-2016 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2001.
+
+ This 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 _PROGNAME_H
+#define _PROGNAME_H
+
+/* Programs using this file should do the following in main():
+ set_program_name (argv[0]);
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* String containing name the program is called with. */
+extern const char *program_name;
+
+/* Set program_name, based on argv[0].
+ argv0 must be a string allocated with indefinite extent, and must not be
+ modified after this call. */
+extern void set_program_name (const char *argv0);
+
+#if ENABLE_RELOCATABLE
+
+/* Set program_name, based on argv[0], and original installation prefix and
+ directory, for relocatability. */
+extern void set_program_name_and_installdir (const char *argv0,
+ const char *orig_installprefix,
+ const char *orig_installdir);
+#undef set_program_name
+#define set_program_name(ARG0) \
+ set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
+
+/* Return the full pathname of the current executable, based on the earlier
+ call to set_program_name_and_installdir. Return NULL if unknown. */
+extern char *get_full_program_name (void);
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _PROGNAME_H */
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
new file mode 100644
index 0000000..c7bdfbb
--- /dev/null
+++ b/lib/qcopy-acl.c
@@ -0,0 +1,51 @@
+/* Copy access control list from one file to another. -*- coding: utf-8 -*-
+
+ Copyright (C) 2002-2003, 2005-2016 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, Andreas Grünbacher, and Bruno Haible. */
+
+#include <config.h>
+
+#include "acl.h"
+
+#include "acl-internal.h"
+
+
+/* Copy access control lists from one file to another. If SOURCE_DESC is
+ a valid file descriptor, use file descriptor operations, else use
+ filename based operations on SRC_NAME. Likewise for DEST_DESC and
+ DST_NAME.
+ If access control lists are not available, fchmod the target file to
+ MODE. Also sets the non-permission bits of the destination file
+ (S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set.
+ Return 0 if successful.
+ Return -2 and set errno for an error relating to the source file.
+ Return -1 and set errno for an error relating to the destination file. */
+
+int
+qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
+ int dest_desc, mode_t mode)
+{
+ struct permission_context ctx;
+ int ret;
+
+ ret = get_permissions (src_name, source_desc, mode, &ctx);
+ if (ret != 0)
+ return -2;
+ ret = set_permissions (&ctx, dst_name, dest_desc);
+ free_permission_context (&ctx);
+ return ret;
+}
diff --git a/lib/qset-acl.c b/lib/qset-acl.c
new file mode 100644
index 0000000..77227dc
--- /dev/null
+++ b/lib/qset-acl.c
@@ -0,0 +1,49 @@
+/* qset-acl.c - set access control list equivalent to a mode
+
+ Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */
+
+#include <config.h>
+
+#define ACL_INTERNAL_INLINE _GL_EXTERN_INLINE
+
+#include <string.h>
+#include "acl.h"
+
+#include "acl-internal.h"
+
+
+/* Set the access control lists of a file. If DESC is a valid file
+ descriptor, use file descriptor operations where available, else use
+ filename based operations on NAME. If access control lists are not
+ available, fchmod the target file to MODE. Also sets the
+ non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX)
+ to those from MODE if any are set.
+ Return 0 if successful. Return -1 and set errno upon failure. */
+
+int
+qset_acl (char const *name, int desc, mode_t mode)
+{
+ struct permission_context ctx;
+ int ret;
+
+ memset (&ctx, 0, sizeof ctx);
+ ctx.mode = mode;
+ ret = set_permissions (&ctx, name, desc);
+ free_permission_context (&ctx);
+ return ret;
+}
diff --git a/lib/quote.h b/lib/quote.h
index e3b332d..b53d0ea 100644
--- a/lib/quote.h
+++ b/lib/quote.h
@@ -1,6 +1,6 @@
/* quote.h - prototypes for quote.c
- Copyright (C) 1998-2001, 2003, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1998-2001, 2003, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/quotearg.c b/lib/quotearg.c
index 7fb866d..07658b2 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -1,6 +1,6 @@
/* quotearg.c - quote arguments for output
- Copyright (C) 1998-2002, 2004-2012 Free Software Foundation, Inc.
+ Copyright (C) 1998-2002, 2004-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
#include "quotearg.h"
#include "quote.h"
+#include "minmax.h"
#include "xalloc.h"
#include "c-strcaseeq.h"
#include "localcharset.h"
@@ -37,6 +38,7 @@
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
@@ -77,6 +79,8 @@ char const *const quoting_style_args[] =
"literal",
"shell",
"shell-always",
+ "shell-escape",
+ "shell-escape-always",
"c",
"c-maybe",
"escape",
@@ -91,6 +95,8 @@ enum quoting_style const quoting_style_vals[] =
literal_quoting_style,
shell_quoting_style,
shell_always_quoting_style,
+ shell_escape_quoting_style,
+ shell_escape_always_quoting_style,
c_quoting_style,
c_maybe_quoting_style,
escape_quoting_style,
@@ -116,7 +122,7 @@ clone_quoting_options (struct quoting_options *o)
/* Get the value of O's quoting style. If O is null, use the default. */
enum quoting_style
-get_quoting_style (struct quoting_options *o)
+get_quoting_style (struct quoting_options const *o)
{
return (o ? o : &default_quoting_options)->style;
}
@@ -178,7 +184,7 @@ set_custom_quoting (struct quoting_options *o,
static struct quoting_options /* NOT PURE!! */
quoting_options_from_style (enum quoting_style style)
{
- struct quoting_options o = { 0, 0, { 0 }, NULL, NULL };
+ struct quoting_options o = { literal_quoting_style, 0, { 0 }, NULL, NULL };
if (style == custom_quoting_style)
abort ();
o.style = style;
@@ -248,11 +254,15 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
{
size_t i;
size_t len = 0;
+ size_t orig_buffersize = 0;
char const *quote_string = 0;
size_t quote_string_len = 0;
bool backslash_escapes = false;
bool unibyte_locale = MB_CUR_MAX == 1;
bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0;
+ bool pending_shell_escape_end = false;
+ bool encountered_single_quote = false;
+ bool all_c_and_shell_quote_compat = true;
#define STORE(c) \
do \
@@ -263,6 +273,38 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
} \
while (0)
+#define START_ESC() \
+ do \
+ { \
+ if (elide_outer_quotes) \
+ goto force_outer_quoting_style; \
+ escaping = true; \
+ if (quoting_style == shell_always_quoting_style \
+ && ! pending_shell_escape_end) \
+ { \
+ STORE ('\''); \
+ STORE ('$'); \
+ STORE ('\''); \
+ pending_shell_escape_end = true; \
+ } \
+ STORE ('\\'); \
+ } \
+ while (0)
+
+#define END_ESC() \
+ do \
+ { \
+ if (pending_shell_escape_end && ! escaping) \
+ { \
+ STORE ('\''); \
+ STORE ('\''); \
+ pending_shell_escape_end = false; \
+ } \
+ } \
+ while (0)
+
+ process_input:
+
switch (quoting_style)
{
case c_maybe_quoting_style:
@@ -321,11 +363,18 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
break;
+ case shell_escape_quoting_style:
+ backslash_escapes = true;
+ /* Fall through. */
case shell_quoting_style:
- quoting_style = shell_always_quoting_style;
elide_outer_quotes = true;
/* Fall through. */
+ case shell_escape_always_quoting_style:
+ if (!elide_outer_quotes)
+ backslash_escapes = true;
+ /* Fall through. */
case shell_always_quoting_style:
+ quoting_style = shell_always_quoting_style;
if (!elide_outer_quotes)
STORE ('\'');
quote_string = "'";
@@ -345,10 +394,18 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
unsigned char c;
unsigned char esc;
bool is_right_quote = false;
+ bool escaping = false;
+ bool c_and_shell_quote_compat = false;
if (backslash_escapes
+ && quoting_style != shell_always_quoting_style
&& quote_string_len
- && i + quote_string_len <= argsize
+ && (i + quote_string_len
+ <= (argsize == SIZE_MAX && 1 < quote_string_len
+ /* Use strlen only if we must: when argsize is SIZE_MAX,
+ and when the quote string is more than 1 byte long.
+ If we do call strlen, save the result. */
+ ? (argsize = strlen (arg)) : argsize))
&& memcmp (arg + i, quote_string, quote_string_len) == 0)
{
if (elide_outer_quotes)
@@ -362,15 +419,15 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
case '\0':
if (backslash_escapes)
{
- if (elide_outer_quotes)
- goto force_outer_quoting_style;
- STORE ('\\');
+ START_ESC ();
/* If quote_string were to begin with digits, we'd need to
test for the end of the arg as well. However, it's
hard to imagine any locale that would use digits in
quotes, and set_custom_quoting is documented not to
- accept them. */
- if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
+ accept them. Use only a single \0 with shell-escape
+ as currently digits are not printed within $'...' */
+ if (quoting_style != shell_always_quoting_style
+ && i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
{
STORE ('0');
STORE ('0');
@@ -431,6 +488,14 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
case '\t': esc = 't'; goto c_and_shell_escape;
case '\v': esc = 'v'; goto c_escape;
case '\\': esc = c;
+ /* Never need to escape '\' in shell case. */
+ if (quoting_style == shell_always_quoting_style)
+ {
+ if (elide_outer_quotes)
+ goto force_outer_quoting_style;
+ goto store_c;
+ }
+
/* No need to escape the escape if we are trying to elide
outer quotes and nothing else is problematic. */
if (backslash_escapes && elide_outer_quotes && quote_string_len)
@@ -458,6 +523,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
break;
/* Fall through. */
case ' ':
+ c_and_shell_quote_compat = true;
+ /* Fall through. */
case '!': /* special in bash */
case '"': case '$': case '&':
case '(': case ')': case '*': case ';':
@@ -476,13 +543,26 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
break;
case '\'':
+ encountered_single_quote = true;
+ c_and_shell_quote_compat = true;
if (quoting_style == shell_always_quoting_style)
{
if (elide_outer_quotes)
goto force_outer_quoting_style;
+
+ if (buffersize && ! orig_buffersize)
+ {
+ /* Just scan string to see if supports a more concise
+ representation, rather than writing a longer string
+ but returning the length of the more concise form. */
+ orig_buffersize = buffersize;
+ buffersize = 0;
+ }
+
STORE ('\'');
STORE ('\\');
STORE ('\'');
+ pending_shell_escape_end = false;
}
break;
@@ -508,6 +588,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
them. Also, a digit or a special letter would cause
trouble if it appeared in quote_these_too, but that's also
documented as not accepting them. */
+ c_and_shell_quote_compat = true;
break;
default:
@@ -586,6 +667,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
while (! mbsinit (&mbstate));
}
+ c_and_shell_quote_compat = printable;
+
if (1 < m || (backslash_escapes && ! printable))
{
/* Output a multibyte sequence, or an escaped
@@ -596,9 +679,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
{
if (backslash_escapes && ! printable)
{
- if (elide_outer_quotes)
- goto force_outer_quoting_style;
- STORE ('\\');
+ START_ESC ();
STORE ('0' + (c >> 6));
STORE ('0' + ((c >> 3) & 7));
c = '0' + (c & 7);
@@ -610,6 +691,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
if (ilim <= i + 1)
break;
+ END_ESC ();
STORE (c);
c = arg[++i];
}
@@ -619,25 +701,49 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
}
- if (! ((backslash_escapes || elide_outer_quotes)
+ if (! (((backslash_escapes && quoting_style != shell_always_quoting_style)
+ || elide_outer_quotes)
&& quote_these_too
- && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))
+ && quote_these_too[c / INT_BITS] >> (c % INT_BITS) & 1)
&& !is_right_quote)
goto store_c;
store_escape:
- if (elide_outer_quotes)
- goto force_outer_quoting_style;
- STORE ('\\');
+ START_ESC ();
store_c:
+ END_ESC ();
STORE (c);
+
+ if (! c_and_shell_quote_compat)
+ all_c_and_shell_quote_compat = false;
}
if (len == 0 && quoting_style == shell_always_quoting_style
&& elide_outer_quotes)
goto force_outer_quoting_style;
+ /* Single shell quotes (') are commonly enough used as an apostrophe,
+ that we attempt to minimize the quoting in this case. Note itʼs
+ better to use the apostrophe modifier "\u02BC" if possible, as that
+ renders better and works with the word match regex \W+ etc. */
+ if (quoting_style == shell_always_quoting_style && ! elide_outer_quotes
+ && encountered_single_quote)
+ {
+ if (all_c_and_shell_quote_compat)
+ return quotearg_buffer_restyled (buffer, orig_buffersize, arg, argsize,
+ c_quoting_style,
+ flags, quote_these_too,
+ left_quote, right_quote);
+ else if (! buffersize && orig_buffersize)
+ {
+ /* Disable read-only scan, and reprocess to write quoted string. */
+ buffersize = orig_buffersize;
+ len = 0;
+ goto process_input;
+ }
+ }
+
if (quote_string && !elide_outer_quotes)
for (; *quote_string; quote_string++)
STORE (*quote_string);
@@ -649,6 +755,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
force_outer_quoting_style:
/* Don't reuse quote_these_too, since the addition of outer quotes
sufficiently quotes the specified characters. */
+ if (quoting_style == shell_always_quoting_style && backslash_escapes)
+ quoting_style = shell_escape_always_quoting_style;
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
quoting_style,
flags & ~QA_ELIDE_OUTER_QUOTES, NULL,
@@ -724,7 +832,7 @@ struct slotvec
/* Preallocate a slot 0 buffer, so that the caller can always quote
one small component of a "memory exhausted" message in slot 0. */
static char slot0[256];
-static unsigned int nslots = 1;
+static int nslots = 1;
static struct slotvec slotvec0 = {sizeof slot0, slot0};
static struct slotvec *slotvec = &slotvec0;
@@ -732,7 +840,7 @@ void
quotearg_free (void)
{
struct slotvec *sv = slotvec;
- unsigned int i;
+ int i;
for (i = 1; i < nslots; i++)
free (sv[i].val);
if (sv[0].val != slot0)
@@ -763,30 +871,23 @@ quotearg_n_options (int n, char const *arg, size_t argsize,
{
int e = errno;
- unsigned int n0 = n;
struct slotvec *sv = slotvec;
if (n < 0)
abort ();
- if (nslots <= n0)
+ if (nslots <= n)
{
- /* FIXME: technically, the type of n1 should be 'unsigned int',
- but that evokes an unsuppressible warning from gcc-4.0.1 and
- older. If gcc ever provides an option to suppress that warning,
- revert to the original type, so that the test in xalloc_oversized
- is once again performed only at compile time. */
- size_t n1 = n0 + 1;
bool preallocated = (sv == &slotvec0);
- if (xalloc_oversized (n1, sizeof *sv))
+ if (MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) <= n)
xalloc_die ();
- slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv);
+ slotvec = sv = xrealloc (preallocated ? NULL : sv, (n + 1) * sizeof *sv);
if (preallocated)
*sv = slotvec0;
- memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv);
- nslots = n1;
+ memset (sv + nslots, 0, (n + 1 - nslots) * sizeof *sv);
+ nslots = n + 1;
}
{
@@ -896,6 +997,15 @@ quotearg_colon_mem (char const *arg, size_t argsize)
}
char *
+quotearg_n_style_colon (int n, enum quoting_style s, char const *arg)
+{
+ struct quoting_options options;
+ options = quoting_options_from_style (s);
+ set_char_quoting (&options, ':', 1);
+ return quotearg_n_options (n, arg, SIZE_MAX, &options);
+}
+
+char *
quotearg_n_custom (int n, char const *left_quote,
char const *right_quote, char const *arg)
{
diff --git a/lib/quotearg.h b/lib/quotearg.h
index e6b08ab..bc29052 100644
--- a/lib/quotearg.h
+++ b/lib/quotearg.h
@@ -1,6 +1,6 @@
/* quotearg.h - quote arguments for output
- Copyright (C) 1998-2002, 2004, 2006, 2008-2012 Free Software Foundation,
+ Copyright (C) 1998-2002, 2004, 2006, 2008-2016 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -73,6 +73,37 @@ enum quoting_style
*/
shell_always_quoting_style,
+ /* Quote names for the shell if they contain shell metacharacters
+ or other problematic characters (ls --quoting-style=shell-escape).
+ Non printable characters are quoted using the $'...' syntax,
+ which originated in ksh93 and is widely supported by most shells,
+ and proposed for inclusion in POSIX.
+
+ quotearg_buffer:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b"
+ quotearg:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "a:b"
+ quotearg_colon:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\\'", "'a:b'"
+ */
+ shell_escape_quoting_style,
+
+ /* Quote names for the shell even if they would normally not
+ require quoting (ls --quoting-style=shell-escape).
+ Non printable characters are quoted using the $'...' syntax,
+ which originated in ksh93 and is widely supported by most shells,
+ and proposed for inclusion in POSIX. Behaves like
+ shell_escape_quoting_style if QA_ELIDE_OUTER_QUOTES is in effect.
+
+ quotearg_buffer:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b"
+ quotearg:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "a:b"
+ quotearg_colon:
+ "simple", "''$'\\0'' '$'\\t\\n'\\''\"'$'\\033''??/\'", "'a:b'"
+ */
+ shell_escape_always_quoting_style,
+
/* Quote names as for a C language string (ls --quoting-style=c).
Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
in effect. Split into consecutive strings if
@@ -247,7 +278,7 @@ struct quoting_options;
struct quoting_options *clone_quoting_options (struct quoting_options *o);
/* Get the value of O's quoting style. If O is null, use the default. */
-enum quoting_style get_quoting_style (struct quoting_options *o);
+enum quoting_style get_quoting_style (struct quoting_options const *o);
/* In O (or in the default if O is null),
set the value of the quoting style to S. */
@@ -362,6 +393,9 @@ char *quotearg_colon (char const *arg);
/* Like quotearg_colon (ARG), except it can quote null bytes. */
char *quotearg_colon_mem (char const *arg, size_t argsize);
+/* Like quotearg_n_style, except with ':' quoting enabled. */
+char *quotearg_n_style_colon (int n, enum quoting_style s, char const *arg);
+
/* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style
with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See
set_custom_quoting for a description of acceptable LEFT_QUOTE and
diff --git a/lib/readlink.c b/lib/readlink.c
index baac132..e6c3925 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
/* Stub for readlink().
- Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/realloc.c b/lib/realloc.c
deleted file mode 100644
index 99556cc..0000000
--- a/lib/realloc.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* realloc() function that is glibc compatible.
-
- Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2012 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 and Bruno Haible */
-
-#define _GL_USE_STDLIB_ALLOC 1
-#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
-
-#include <stdlib.h>
-
-#include <errno.h>
-
-/* 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/lib/ref-add.sin b/lib/ref-add.sin
index 4ec043f..42d3ab0 100644
--- a/lib/ref-add.sin
+++ b/lib/ref-add.sin
@@ -1,6 +1,6 @@
# Add this package to a list of references stored in a text file.
#
-# Copyright (C) 2000, 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2009-2016 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/lib/ref-del.sin b/lib/ref-del.sin
index eb03881..c77b33b 100644
--- a/lib/ref-del.sin
+++ b/lib/ref-del.sin
@@ -1,6 +1,6 @@
# Remove this package from a list of references stored in a text file.
#
-# Copyright (C) 2000, 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2009-2016 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 160631d..aaa66b9 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1,22 +1,25 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2016 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 General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef _LIBC
+# include <locale/weight.h>
+#endif
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
size_t length, reg_syntax_t syntax);
@@ -95,20 +98,20 @@ 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,
+ const 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,
+ const 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,
+ const char *class_name,
+ const 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,
@@ -150,9 +153,9 @@ static const char __re_error_msgid[] =
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 */
+ gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */
"\0"
-#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
+#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 \\(")
@@ -210,17 +213,9 @@ static const size_t __re_error_msgid_idx[] =
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;
@@ -258,8 +253,7 @@ reg_syntax_t re_syntax_options;
defined in regex.h. We return the old syntax. */
reg_syntax_t
-re_set_syntax (syntax)
- reg_syntax_t syntax;
+re_set_syntax (reg_syntax_t syntax)
{
reg_syntax_t ret = re_syntax_options;
@@ -271,8 +265,7 @@ weak_alias (__re_set_syntax, re_set_syntax)
#endif
int
-re_compile_fastmap (bufp)
- struct re_pattern_buffer *bufp;
+re_compile_fastmap (struct re_pattern_buffer *bufp)
{
re_dfa_t *dfa = bufp->buffer;
char *fastmap = bufp->fastmap;
@@ -293,7 +286,7 @@ weak_alias (__re_compile_fastmap, re_compile_fastmap)
#endif
static inline void
-__attribute ((always_inline))
+__attribute__ ((always_inline))
re_set_fastmap (char *fastmap, bool icase, int ch)
{
fastmap[ch] = 1;
@@ -336,7 +329,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
memset (&state, '\0', sizeof (state));
if (__mbrtowc (&wc, (const char *) buf, p - buf,
&state) == p - buf
- && (__wcrtomb ((char *) buf, towlower (wc), &state)
+ && (__wcrtomb ((char *) buf, __towlower (wc), &state)
!= (size_t) -1))
re_set_fastmap (fastmap, false, buf[0]);
}
@@ -412,7 +405,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
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)
+ if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
!= (size_t) -1)
re_set_fastmap (fastmap, false, *(unsigned char *) buf);
}
@@ -471,10 +464,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
the return codes and their meanings.) */
int
-regcomp (preg, pattern, cflags)
- regex_t *_Restrict_ preg;
- const char *_Restrict_ pattern;
- int cflags;
+regcomp (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
@@ -532,18 +522,9 @@ weak_alias (__regcomp, regcomp)
/* 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
+regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
+ size_t errbuf_size)
{
const char *msg;
size_t msg_size;
@@ -587,7 +568,7 @@ weak_alias (__regerror, regerror)
static const bitset_t utf8_sb_map =
{
/* Set the first 128 bits. */
-# ifdef __GNUC__
+# if defined __GNUC__ && !defined __STRICT_ANSI__
[0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
# else
# if 4 * BITSET_WORD_BITS < ASCII_CHARS
@@ -659,12 +640,14 @@ free_dfa_content (re_dfa_t *dfa)
/* Free dynamically allocated space used by PREG. */
void
-regfree (preg)
- regex_t *preg;
+regfree (regex_t *preg)
{
re_dfa_t *dfa = preg->buffer;
if (BE (dfa != NULL, 1))
- free_dfa_content (dfa);
+ {
+ lock_fini (dfa->lock);
+ free_dfa_content (dfa);
+ }
preg->buffer = NULL;
preg->allocated = 0;
@@ -693,8 +676,7 @@ char *
regcomp/regexec above without link errors. */
weak_function
# endif
-re_comp (s)
- const char *s;
+re_comp (const char *s)
{
reg_errcode_t ret;
char *fastmap;
@@ -785,6 +767,8 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
preg->used = sizeof (re_dfa_t);
err = init_dfa (dfa, length);
+ if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0))
+ err = REG_ESPACE;
if (BE (err != REG_NOERROR, 0))
{
free_dfa_content (dfa);
@@ -798,8 +782,6 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
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))
@@ -807,6 +789,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
re_compile_internal_free_return:
free_workarea_compile (preg);
re_string_destruct (&regexp);
+ lock_fini (dfa->lock);
free_dfa_content (dfa);
preg->buffer = NULL;
preg->allocated = 0;
@@ -839,6 +822,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
if (BE (err != REG_NOERROR, 0))
{
+ lock_fini (dfa->lock);
free_dfa_content (dfa);
preg->buffer = NULL;
preg->allocated = 0;
@@ -954,10 +938,10 @@ static void
internal_function
init_word_char (re_dfa_t *dfa)
{
- dfa->word_ops_used = 1;
int i = 0;
int j;
int ch = 0;
+ dfa->word_ops_used = 1;
if (BE (dfa->map_notascii == 0, 1))
{
bitset_word_t bits0 = 0x00000000;
@@ -1413,7 +1397,7 @@ calc_first (void *extra, bin_tree_t *node)
{
node->first = node;
node->node_idx = re_dfa_add_node (dfa, node->token);
- if (BE (node->node_idx == REG_MISSING, 0))
+ if (BE (node->node_idx == -1, 0))
return REG_ESPACE;
if (node->token.type == ANCHOR)
dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
@@ -1474,8 +1458,8 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
right = node->right->first->node_idx;
else
right = node->next->node_idx;
- assert (REG_VALID_INDEX (left));
- assert (REG_VALID_INDEX (right));
+ assert (left > -1);
+ assert (right > -1);
err = re_node_set_init_2 (dfa->edests + idx, left, right);
}
break;
@@ -1525,7 +1509,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
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))
+ if (BE (clone_dest == -1, 0))
return REG_ESPACE;
dfa->nexts[clone_node] = dfa->nexts[org_node];
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
@@ -1558,7 +1542,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
/* 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))
+ if (BE (clone_dest == -1, 0))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (! ok, 0))
@@ -1572,12 +1556,12 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
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)
+ if (clone_dest == -1)
{
/* 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))
+ if (BE (clone_dest == -1, 0))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (! ok, 0))
@@ -1598,7 +1582,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
org_dest = dfa->edests[org_node].elems[1];
clone_dest = duplicate_node (dfa, org_dest, constraint);
- if (BE (clone_dest == REG_MISSING, 0))
+ if (BE (clone_dest == -1, 0))
return REG_ESPACE;
ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
if (BE (! ok, 0))
@@ -1624,18 +1608,18 @@ search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
&& constraint == dfa->nodes[idx].constraint)
return idx; /* Found. */
}
- return REG_MISSING; /* Not found. */
+ return -1; /* 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
+ Return the index of the new node, or -1 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))
+ if (BE (dup_idx != -1, 1))
{
dfa->nodes[dup_idx].constraint = constraint;
dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
@@ -1694,7 +1678,7 @@ calc_eclosure (re_dfa_t *dfa)
}
#ifdef DEBUG
- assert (dfa->eclosures[node_idx].nelem != REG_MISSING);
+ assert (dfa->eclosures[node_idx].nelem != -1);
#endif
/* If we have already calculated, skip it. */
@@ -1730,7 +1714,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
/* This indicates that we are calculating this node now.
We reference this value to avoid infinite loop. */
- dfa->eclosures[node].nelem = REG_MISSING;
+ dfa->eclosures[node].nelem = -1;
/* If the current node has constraints, duplicate all nodes
since they must inherit the constraints. */
@@ -1752,7 +1736,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
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)
+ if (dfa->eclosures[edest].nelem == -1)
{
incomplete = true;
continue;
@@ -2183,6 +2167,7 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
{
re_dfa_t *dfa = preg->buffer;
bin_tree_t *tree, *branch = NULL;
+ bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
tree = parse_branch (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -2193,9 +2178,16 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
if (token->type != OP_ALT && token->type != END_OF_RE
&& (nest == 0 || token->type != OP_CLOSE_SUBEXP))
{
+ bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
+ dfa->completed_bkref_map = initial_bkref_map;
branch = parse_branch (regexp, preg, token, syntax, nest, err);
if (BE (*err != REG_NOERROR && branch == NULL, 0))
- return NULL;
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ dfa->completed_bkref_map |= accumulated_bkref_map;
}
else
branch = NULL;
@@ -2423,8 +2415,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
case OP_WORD:
case OP_NOTWORD:
tree = build_charclass_op (dfa, regexp->trans,
- (const unsigned char *) "alnum",
- (const unsigned char *) "_",
+ "alnum",
+ "_",
token->type == OP_NOTWORD, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -2432,8 +2424,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
case OP_SPACE:
case OP_NOTSPACE:
tree = build_charclass_op (dfa, regexp->trans,
- (const unsigned char *) "space",
- (const unsigned char *) "",
+ "space",
+ "",
token->type == OP_NOTSPACE, err);
if (BE (*err != REG_NOERROR && tree == NULL, 0))
return NULL;
@@ -2456,14 +2448,22 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
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;
+ bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
+ syntax, err);
+ if (BE (*err != REG_NOERROR && dup_tree == NULL, 0))
+ {
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
+ return NULL;
+ }
+ tree = dup_tree;
/* In BRE consecutive duplications are not allowed. */
if ((syntax & RE_CONTEXT_INVALID_DUP)
&& (token->type == OP_DUP_ASTERISK
|| token->type == OP_OPEN_DUP_NUM))
{
+ if (tree != NULL)
+ postorder (tree, free_tree, NULL);
*err = REG_BADRPT;
return NULL;
}
@@ -2533,7 +2533,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
{
end = 0;
start = fetch_number (regexp, token, syntax);
- if (start == REG_MISSING)
+ if (start == -1)
{
if (token->type == CHARACTER && token->opr.c == ',')
start = 0; /* We treat "{,m}" as "{0,m}". */
@@ -2543,14 +2543,14 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
return NULL;
}
}
- if (BE (start != REG_ERROR, 1))
+ if (BE (start != -2, 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));
+ ? fetch_number (regexp, token, syntax) : -2));
}
- if (BE (start == REG_ERROR || end == REG_ERROR, 0))
+ if (BE (start == -2 || end == -2, 0))
{
/* Invalid sequence. */
if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0))
@@ -2572,7 +2572,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
return elem;
}
- if (BE ((end != REG_MISSING && start > end)
+ if (BE ((end != -1 && start > end)
|| token->type != OP_CLOSE_DUP_NUM, 0))
{
/* First number greater than second. */
@@ -2580,7 +2580,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
return NULL;
}
- if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0))
+ if (BE (RE_DUP_MAX < (end == -1 ? start : end), 0))
{
*err = REG_ESIZE;
return NULL;
@@ -2589,7 +2589,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
else
{
start = (token->type == OP_DUP_PLUS) ? 1 : 0;
- end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING;
+ end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
}
fetch_token (token, regexp, syntax);
@@ -2619,6 +2619,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
/* Duplicate ELEM before it is marked optional. */
elem = duplicate_tree (elem, dfa);
+ if (BE (elem == NULL, 0))
+ goto parse_dup_op_espace;
old_tree = tree;
}
else
@@ -2631,7 +2633,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
}
tree = create_tree (dfa, elem, NULL,
- (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT));
+ (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
if (BE (tree == NULL, 0))
goto parse_dup_op_espace;
@@ -2639,10 +2641,10 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
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,
+ /* This loop is actually executed only when end != -1,
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)
+ if (TYPE_SIGNED (Idx) || end != -1)
for (i = start + 2; i <= end; ++i)
{
elem = duplicate_tree (elem, dfa);
@@ -2670,6 +2672,19 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
#define BRACKET_NAME_BUF_SIZE 32
#ifndef _LIBC
+
+# ifdef RE_ENABLE_I18N
+/* Convert the byte B to the corresponding wide character. In a
+ unibyte locale, treat B as itself if it is an encoding error.
+ In a multibyte locale, return WEOF if B is an encoding error. */
+static wint_t
+parse_byte (unsigned char b, re_charset_t *mbcset)
+{
+ wint_t wc = __btowc (b);
+ return wc == WEOF && !mbcset ? b : wc;
+}
+#endif
+
/* 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.
@@ -2713,7 +2728,6 @@ build_range_exp (const reg_syntax_t syntax,
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]
@@ -2722,16 +2736,12 @@ build_range_exp (const reg_syntax_t syntax,
: ((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);
+ ? parse_byte (start_ch, mbcset) : start_elem->opr.wch);
end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
- ? __btowc (end_ch) : end_elem->opr.wch);
+ ? parse_byte (end_ch, mbcset) : 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))
+ else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
return REG_ERANGE;
/* Got valid collation sequence values, add them as a new entry.
@@ -2758,7 +2768,11 @@ build_range_exp (const reg_syntax_t syntax,
new_nranges);
if (BE (new_array_start == NULL || new_array_end == NULL, 0))
- return REG_ESPACE;
+ {
+ re_free (new_array_start);
+ re_free (new_array_end);
+ return REG_ESPACE;
+ }
mbcset->range_starts = new_array_start;
mbcset->range_ends = new_array_end;
@@ -2772,9 +2786,7 @@ build_range_exp (const reg_syntax_t syntax,
/* 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)
+ if (start_wc <= wc && wc <= end_wc)
bitset_set (sbcset, wc);
}
}
@@ -2843,40 +2855,29 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
/* Local function for parse_bracket_exp used in _LIBC environment.
Seek the collating symbol entry corresponding to NAME.
- Return the index of the symbol in the SYMB_TABLE. */
+ Return the index of the symbol in the SYMB_TABLE,
+ or -1 if not found. */
auto inline int32_t
- __attribute ((always_inline))
- seek_collating_symbol_entry (name, name_len)
- const unsigned char *name;
- size_t name_len;
+ __attribute__ ((always_inline))
+ seek_collating_symbol_entry (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;
+ int32_t elem;
- 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;
+ for (elem = 0; elem < table_size; elem++)
+ if (symb_table[2 * elem] != 0)
+ {
+ int32_t idx = symb_table[2 * elem + 1];
+ /* Skip the name of collating element name. */
+ idx += 1 + extra[idx];
+ if (/* Compare the length of the name. */
+ name_len == extra[idx]
+ /* Compare the name. */
+ && memcmp (name, &extra[idx + 1], name_len) == 0)
+ /* Yep, this is the entry. */
+ return elem;
+ }
+ return -1;
}
/* Local function for parse_bracket_exp used in _LIBC environment.
@@ -2884,9 +2885,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
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;
+ __attribute__ ((always_inline))
+ lookup_collation_sequence_value (bracket_elem_t *br_elem)
{
if (br_elem->type == SB_CHAR)
{
@@ -2914,7 +2914,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
int32_t elem, idx;
elem = seek_collating_symbol_entry (br_elem->opr.name,
sym_name_len);
- if (symb_table[2 * elem] != 0)
+ if (elem != -1)
{
/* We found the entry. */
idx = symb_table[2 * elem + 1];
@@ -2932,7 +2932,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
/* Return the collation sequence value. */
return *(unsigned int *) (extra + idx);
}
- else if (symb_table[2 * elem] == 0 && sym_name_len == 1)
+ else if (sym_name_len == 1)
{
/* No valid character. Match it as a single byte
character. */
@@ -2953,12 +2953,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
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;
+ __attribute__ ((always_inline))
+ build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
+ bracket_elem_t *start_elem, bracket_elem_t *end_elem)
{
unsigned int ch;
uint32_t start_collseq;
@@ -2971,6 +2968,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
0))
return REG_ERANGE;
+ /* FIXME: Implement rational ranges here, too. */
start_collseq = lookup_collation_sequence_value (start_elem);
end_collseq = lookup_collation_sequence_value (end_elem);
/* Check start/end collation sequence values. */
@@ -3036,26 +3034,23 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
pointer argument since 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;
+ __attribute__ ((always_inline))
+ build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
+ Idx *coll_sym_alloc, 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)
+ if (elem != -1)
{
/* 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)
+ else if (name_len == 1)
{
/* No valid character, treat it as a normal
character. */
@@ -3181,6 +3176,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
re_token_t token2;
start_elem.opr.name = start_name_buf;
+ start_elem.type = COLL_SYM;
ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
syntax, first_round);
if (BE (ret != REG_NOERROR, 0))
@@ -3224,6 +3220,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
if (is_range_exp == true)
{
end_elem.opr.name = end_name_buf;
+ end_elem.type = COLL_SYM;
ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
dfa, syntax, true);
if (BE (ret != REG_NOERROR, 0))
@@ -3298,7 +3295,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
#ifdef RE_ENABLE_I18N
mbcset, &char_class_alloc,
#endif /* RE_ENABLE_I18N */
- start_elem.opr.name, syntax);
+ (const char *) start_elem.opr.name,
+ syntax);
if (BE (*err != REG_NOERROR, 0))
goto parse_bracket_exp_free_return;
break;
@@ -3497,8 +3495,6 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
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);
@@ -3508,7 +3504,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
_NL_COLLATE_EXTRAMB);
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_INDIRECTMB);
- idx1 = findidx (&cp, -1);
+ idx1 = findidx (table, indirect, extra, &cp, -1);
if (BE (idx1 == 0 || *cp != '\0', 0))
/* This isn't a valid character. */
return REG_ECOLLATE;
@@ -3519,7 +3515,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
{
char_buf[0] = ch;
cp = char_buf;
- idx2 = findidx (&cp, 1);
+ idx2 = findidx (table, indirect, extra, &cp, 1);
/*
idx2 = table[ch];
*/
@@ -3578,14 +3574,14 @@ 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)
+ const 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)
+ const char *class_name, reg_syntax_t syntax)
#endif /* not RE_ENABLE_I18N */
{
int i;
- const char *name = (const char *) class_name;
+ const char *name = class_name;
/* In case of REG_ICASE "upper" and "lower" match the both of
upper and lower cases. */
@@ -3659,8 +3655,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
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,
+ const char *class_name,
+ const char *extra, bool non_match,
reg_errcode_t *err)
{
re_bitset_ptr_t sbcset;
@@ -3673,26 +3669,21 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
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 */
+ mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
+ if (BE (mbcset == NULL, 0))
+ {
+ re_free (sbcset);
+ *err = REG_ESPACE;
+ return NULL;
}
+ mbcset->non_match = non_match;
+#endif /* RE_ENABLE_I18N */
/* We don't care the syntax in this case. */
ret = build_charclass (trans, sbcset,
@@ -3725,6 +3716,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
#endif
/* Build a tree for simple bracket. */
+#if defined GCC_LINT || defined lint
+ memset (&br_token, 0, sizeof br_token);
+#endif
br_token.type = SIMPLE_BRACKET;
br_token.opr.sbcset = sbcset;
tree = create_token_tree (dfa, NULL, NULL, &br_token);
@@ -3767,27 +3761,26 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
/* 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 -1 if the number field is empty like "{,1}".
Return RE_DUP_MAX + 1 if the number field is too large.
- Return REG_ERROR if an error occurred. */
+ Return -2 if an error occurred. */
static Idx
fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
{
- Idx num = REG_MISSING;
+ Idx num = -1;
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;
+ return -2;
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
+ num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
+ ? -2
+ : num == -1
? c - '0'
: MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
}
@@ -3819,6 +3812,9 @@ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
re_token_type_t type)
{
re_token_t t;
+#if defined GCC_LINT || defined lint
+ memset (&t, 0, sizeof t);
+#endif
t.type = type;
return create_token_tree (dfa, left, right, &t);
}
@@ -3848,7 +3844,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
tree->token.opt_subexp = 0;
tree->first = NULL;
tree->next = NULL;
- tree->node_idx = REG_MISSING;
+ tree->node_idx = -1;
if (left != NULL)
left->parent = tree;
diff --git a/lib/regex.c b/lib/regex.c
index ca4cc9d..432b465 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,22 +1,21 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2016 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 General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
@@ -25,6 +24,7 @@
# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
# endif
# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wold-style-definition"
# pragma GCC diagnostic ignored "-Wtype-limits"
# endif
#endif
diff --git a/lib/regex.h b/lib/regex.h
index c70c8d7..b7496f9 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,23 +1,22 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Definitions for data structures and routines for the regular
expression library.
- Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2012
- Free Software Foundation, Inc.
+ Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2016 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, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _REGEX_H
#define _REGEX_H 1
@@ -43,11 +42,6 @@ extern "C" {
supported within glibc itself, and glibc users should not define
_REGEX_LARGE_OFFSETS. */
-/* 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;
@@ -59,7 +53,6 @@ typedef size_t __re_long_size_t;
/* The traditional GNU regex implementation mishandles strings longer
than INT_MAX. */
-typedef int __re_idx_t;
typedef unsigned int __re_size_t;
typedef unsigned long int __re_long_size_t;
@@ -245,19 +238,16 @@ extern reg_syntax_t re_syntax_options;
| RE_INVALID_INTERVAL_ORD)
# define RE_SYNTAX_GREP \
- (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
- | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
- | RE_NEWLINE_ALT)
+ ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \
+ & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))
# 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)
+ ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
+ & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))
+/* POSIX grep -E behavior is no longer incompatible with GNU. */
# define RE_SYNTAX_POSIX_EGREP \
- (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
- | RE_INVALID_INTERVAL_ORD)
+ RE_SYNTAX_EGREP
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
@@ -492,7 +482,8 @@ typedef struct re_pattern_buffer regex_t;
#ifdef _REGEX_LARGE_OFFSETS
/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
- is wider than ssize_t, so ssize_t is safe. */
+ is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not
+ visible here, so use ssize_t. */
typedef ssize_t regoff_t;
#else
/* The traditional GNU regex implementation mishandles strings longer
@@ -542,7 +533,7 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
BUFFER. Return NULL if successful, and an error string if not.
To free the allocated storage, you must call 'regfree' on BUFFER.
- Note that the translate table must either have been initialised by
+ Note that the translate table must either have been initialized by
'regcomp', with a malloc'ed value, or set to NULL before calling
'regfree'. */
extern const char *re_compile_pattern (const char *__pattern, size_t __length,
@@ -561,34 +552,34 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
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,
+ const char *__String, regoff_t __length,
+ regoff_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,
+ const char *__string1, regoff_t __length1,
+ const char *__string2, regoff_t __length2,
+ regoff_t __start, regoff_t __range,
struct re_registers *__regs,
- __re_idx_t __stop);
+ regoff_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);
+ const char *__String, regoff_t __length,
+ regoff_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);
+ const char *__string1, regoff_t __length1,
+ const char *__string2, regoff_t __length2,
+ regoff_t __start, struct re_registers *__regs,
+ regoff_t __stop);
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -609,7 +600,7 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
regoff_t *__starts, regoff_t *__ends);
#endif /* Use GNU */
-#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
+#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp (const char *);
@@ -651,7 +642,7 @@ extern int regcomp (regex_t *_Restrict_ __preg,
int __cflags);
extern int regexec (const regex_t *_Restrict_ __preg,
- const char *_Restrict_ __string, size_t __nmatch,
+ const char *_Restrict_ __String, size_t __nmatch,
regmatch_t __pmatch[_Restrict_arr_],
int __eflags);
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index d48c354..a3b10dd 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1,22 +1,21 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2016 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 General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
static void re_string_construct_common (const char *str, Idx len,
re_string_t *pstr,
@@ -312,13 +311,12 @@ build_wcs_upper_buffer (re_string_t *pstr)
+ byte_idx), remain_len, &pstr->cur_state);
if (BE (mbclen < (size_t) -2, 1))
{
- wchar_t wcu = wc;
- if (iswlower (wc))
+ wchar_t wcu = __towupper (wc);
+ if (wcu != wc)
{
size_t mbcdlen;
- wcu = towupper (wc);
- mbcdlen = wcrtomb (buf, wcu, &prev_st);
+ mbcdlen = __wcrtomb (buf, wcu, &prev_st);
if (BE (mbclen == mbcdlen, 1))
memcpy (pstr->mbs + byte_idx, buf, mbclen);
else
@@ -382,12 +380,11 @@ build_wcs_upper_buffer (re_string_t *pstr)
mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
if (BE (mbclen < (size_t) -2, 1))
{
- wchar_t wcu = wc;
- if (iswlower (wc))
+ wchar_t wcu = __towupper (wc);
+ if (wcu != 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);
@@ -539,10 +536,7 @@ build_upper_buffer (re_string_t *pstr)
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->mbs[char_idx] = toupper (ch);
}
pstr->valid_len = char_idx;
pstr->valid_raw_len = char_idx;
@@ -683,7 +677,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
pstr->valid_len - offset);
pstr->valid_len -= offset;
pstr->valid_raw_len -= offset;
-#if DEBUG
+#if defined DEBUG && DEBUG
assert (pstr->valid_len > 0);
#endif
}
@@ -835,7 +829,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}
static unsigned char
-internal_function __attribute ((pure))
+internal_function __attribute__ ((pure))
re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
{
int ch;
@@ -928,7 +922,7 @@ internal_function
re_string_context_at (const re_string_t *input, Idx idx, int eflags)
{
int c;
- if (BE (! REG_VALID_INDEX (idx), 0))
+ if (BE (idx < 0, 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;
@@ -942,12 +936,12 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
Idx wc_idx = idx;
while(input->wcs[wc_idx] == WEOF)
{
-#ifdef DEBUG
+#if defined DEBUG && DEBUG
/* It must not happen. */
- assert (REG_VALID_INDEX (wc_idx));
+ assert (wc_idx >= 0);
#endif
--wc_idx;
- if (! REG_VALID_INDEX (wc_idx))
+ if (wc_idx < 0)
return input->tip_context;
}
wc = input->wcs[wc_idx];
@@ -975,7 +969,7 @@ 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))
+ if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
return REG_ESPACE;
return REG_NOERROR;
}
@@ -1083,25 +1077,25 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
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])
+ while (id >= 0 && dest->elems[id] > src1->elems[i1])
--id;
- if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1])
+ if (id < 0 || dest->elems[id] != src1->elems[i1])
dest->elems[--sbase] = src1->elems[i1];
- if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2))
+ if (--i1 < 0 || --i2 < 0)
break;
}
/* Lower the highest of the two items. */
else if (src1->elems[i1] < src2->elems[i2])
{
- if (! REG_VALID_INDEX (--i2))
+ if (--i2 < 0)
break;
}
else
{
- if (! REG_VALID_INDEX (--i1))
+ if (--i1 < 0)
break;
}
}
@@ -1114,7 +1108,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
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))
+ if (delta > 0 && id >= 0)
for (;;)
{
if (dest->elems[is] > dest->elems[id])
@@ -1128,7 +1122,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
{
/* Slide from the bottom. */
dest->elems[id + delta] = dest->elems[id];
- if (! REG_VALID_INDEX (--id))
+ if (--id < 0)
break;
}
}
@@ -1222,8 +1216,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
/* 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); )
+ is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
{
if (dest->elems[id] == src->elems[is])
is--, id--;
@@ -1233,7 +1226,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
--id;
}
- if (REG_VALID_INDEX (is))
+ if (is >= 0)
{
/* If DEST is exhausted, the remaining items of SRC must be unique. */
sbase -= is + 1;
@@ -1262,7 +1255,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
{
/* Slide from the bottom. */
dest->elems[id + delta] = dest->elems[id];
- if (! REG_VALID_INDEX (--id))
+ if (--id < 0)
{
/* Copy remaining SRC elements. */
memcpy (dest->elems, dest->elems + sbase,
@@ -1355,13 +1348,13 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
Return true if SET1 and SET2 are equivalent. */
static bool
-internal_function __attribute ((pure))
+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) ; )
+ for (i = set1->nelem ; --i >= 0 ; )
if (set1->elems[i] != set2->elems[i])
return false;
return true;
@@ -1370,11 +1363,11 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
static Idx
-internal_function __attribute ((pure))
+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))
+ if (set->nelem <= 0)
return 0;
/* Binary search the element. */
@@ -1404,7 +1397,7 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
/* Add the token TOKEN to dfa->nodes, and return the index of the token.
- Or return REG_MISSING if an error occurred. */
+ Or return -1 if an error occurred. */
static Idx
internal_function
@@ -1422,11 +1415,11 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
MAX (sizeof (re_node_set),
sizeof (Idx)));
if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0))
- return REG_MISSING;
+ return -1;
new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
if (BE (new_nodes == NULL, 0))
- return REG_MISSING;
+ return -1;
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);
@@ -1434,7 +1427,13 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
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;
+ {
+ re_free (new_nexts);
+ re_free (new_indices);
+ re_free (new_edests);
+ re_free (new_eclosures);
+ return -1;
+ }
dfa->nexts = new_nexts;
dfa->org_indices = new_indices;
dfa->edests = new_edests;
@@ -1444,13 +1443,11 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
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;
- }
+ ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
+ || token.type == COMPLEX_BRACKET);
#endif
- dfa->nexts[dfa->nodes_len] = REG_MISSING;
+ dfa->nexts[dfa->nodes_len] = -1;
re_node_set_init_empty (dfa->edests + dfa->nodes_len);
re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
return dfa->nodes_len++;
@@ -1485,7 +1482,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
re_dfastate_t *new_state;
struct re_state_table_entry *spot;
Idx i;
-#ifdef lint
+#if defined GCC_LINT || defined lint
/* Suppress bogus uninitialized-variable warnings. */
*err = REG_NOERROR;
#endif
@@ -1533,7 +1530,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
re_dfastate_t *new_state;
struct re_state_table_entry *spot;
Idx i;
-#ifdef lint
+#if defined GCC_LINT || defined lint
/* Suppress bogus uninitialized-variable warnings. */
*err = REG_NOERROR;
#endif
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index ce058b6..b61c638 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -1,22 +1,21 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2016 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 General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _REGEX_INTERNAL_H
#define _REGEX_INTERNAL_H 1
@@ -28,21 +27,57 @@
#include <string.h>
#include <langinfo.h>
-#ifndef _LIBC
-# include "localcharset.h"
-#endif
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
#include <stdbool.h>
#include <stdint.h>
-#if defined _LIBC
-# include <bits/libc-lock.h>
+
+#include "intprops.h"
+
+#ifdef _LIBC
+# include <libc-lock.h>
+# define lock_define(name) __libc_lock_define (, name)
+# define lock_init(lock) (__libc_lock_init (lock), 0)
+# define lock_fini(lock) 0
+# define lock_lock(lock) __libc_lock_lock (lock)
+# define lock_unlock(lock) __libc_lock_unlock (lock)
+#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
+# include "glthread/lock.h"
+ /* Use gl_lock_define if empty macro arguments are known to work.
+ Otherwise, fall back on less-portable substitutes. */
+# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
+ || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
+# define lock_define(name) gl_lock_define (, name)
+# elif USE_POSIX_THREADS
+# define lock_define(name) pthread_mutex_t name;
+# elif USE_PTH_THREADS
+# define lock_define(name) pth_mutex_t name;
+# elif USE_SOLARIS_THREADS
+# define lock_define(name) mutex_t name;
+# elif USE_WINDOWS_THREADS
+# define lock_define(name) gl_lock_t name;
+# else
+# define lock_define(name)
+# endif
+# define lock_init(lock) glthread_lock_init (&(lock))
+# define lock_fini(lock) glthread_lock_destroy (&(lock))
+# define lock_lock(lock) glthread_lock_lock (&(lock))
+# define lock_unlock(lock) glthread_lock_unlock (&(lock))
+#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
+# include <pthread.h>
+# define lock_define(name) pthread_mutex_t name;
+# define lock_init(lock) pthread_mutex_init (&(lock), 0)
+# define lock_fini(lock) pthread_mutex_destroy (&(lock))
+# define lock_lock(lock) pthread_mutex_lock (&(lock))
+# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
#else
-# define __libc_lock_define(CLASS,NAME)
-# define __libc_lock_init(NAME) do { } while (0)
-# define __libc_lock_lock(NAME) do { } while (0)
-# define __libc_lock_unlock(NAME) do { } while (0)
+# define lock_define(name)
+# define lock_init(lock) 0
+# define lock_fini(lock) ((void) 0)
+ /* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */
+# define lock_lock(lock) ((void) dfa)
+# define lock_unlock(lock) ((void) 0)
#endif
/* In case that the system doesn't have isblank(). */
@@ -54,7 +89,6 @@
# 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
@@ -65,7 +99,7 @@
# ifdef _LIBC
# undef gettext
# define gettext(msgid) \
- INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
+ __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
# endif
#else
# define gettext(msgid) (msgid)
@@ -77,15 +111,11 @@
# define gettext_noop(String) String
#endif
-#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
+#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE) || _LIBC
# define RE_ENABLE_I18N
#endif
-#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
-#else
-# define BE(expr, val) (expr)
-#endif
+#define BE(expr, val) __builtin_expect (expr, val)
/* Number of ASCII characters. */
#define ASCII_CHARS 0x80
@@ -101,8 +131,13 @@
/* Rename to standard API for using out of glibc. */
#ifndef _LIBC
+# undef __wctype
+# undef __iswctype
# define __wctype wctype
+# define __iswalnum iswalnum
# define __iswctype iswctype
+# define __towlower towlower
+# define __towupper towupper
# define __btowc btowc
# define __mbrtowc mbrtowc
# define __wcrtomb wcrtomb
@@ -110,37 +145,26 @@
# define attribute_hidden
#endif /* not _LIBC */
-#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-# define __attribute(arg) __attribute__ (arg)
-#else
-# define __attribute(arg)
+#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
+# define __attribute__(arg)
#endif
-typedef __re_idx_t Idx;
-#ifdef _REGEX_LARGE_OFFSETS
-# define IDX_MAX (SIZE_MAX - 2)
-#else
-# define IDX_MAX INT_MAX
-#endif
-
-/* 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))
+#ifndef SSIZE_MAX
+# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
-/* Test whether N is a valid nonzero index. */
+/* The type of indexes into strings. This is signed, not size_t,
+ since the API requires indexes to fit in regoff_t anyway, and using
+ signed integers makes the code a bit smaller and presumably faster.
+ The traditional GNU regex implementation uses int for indexes.
+ The POSIX-compatible implementation uses a possibly-wider type.
+ The name 'Idx' is three letters to minimize the hassle of
+ reindenting a lot of regex code that formerly used 'int'. */
+typedef regoff_t Idx;
#ifdef _REGEX_LARGE_OFFSETS
-# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1))
+# define IDX_MAX SSIZE_MAX
#else
-# define REG_VALID_NONZERO_INDEX(n) (0 < (n))
+# define IDX_MAX INT_MAX
#endif
/* A hash value, suitable for computing hash tables. */
@@ -414,23 +438,23 @@ typedef struct re_dfa_t re_dfa_t;
#ifndef _LIBC
# define internal_function
+# define IS_IN(libc) false
#endif
-#ifndef NOT_IN_libc
static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
Idx new_buf_len)
internal_function;
-# ifdef RE_ENABLE_I18N
+#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 */
+#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));
-#endif
+ internal_function __attribute__ ((pure));
+
#define re_string_peek_byte(pstr, offset) \
((pstr)->mbs[(pstr)->cur_idx + offset])
#define re_string_fetch_byte(pstr) \
@@ -448,7 +472,9 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx 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>
+#if defined _LIBC || HAVE_ALLOCA
+# include <alloca.h>
+#endif
#ifndef _LIBC
# if HAVE_ALLOCA
@@ -465,6 +491,12 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
# endif
#endif
+#ifdef _LIBC
+# define MALLOC_0_IS_NONNULL 1
+#elif !defined MALLOC_0_IS_NONNULL
+# define MALLOC_0_IS_NONNULL 0
+#endif
+
#ifndef MAX
# define MAX(a,b) ((a) < (b) ? (b) : (a))
#endif
@@ -515,7 +547,7 @@ typedef struct bin_tree_storage_t bin_tree_storage_t;
#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_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
@@ -695,7 +727,7 @@ struct re_dfa_t
#ifdef DEBUG
char* re_str;
#endif
- __libc_lock_define (, lock)
+ lock_define (lock)
};
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
@@ -767,7 +799,7 @@ bitset_copy (bitset_t dest, const bitset_t src)
memcpy (dest, src, sizeof (bitset_t));
}
-static void
+static void __attribute__ ((unused))
bitset_not (bitset_t set)
{
int bitset_i;
@@ -779,7 +811,7 @@ bitset_not (bitset_t set)
& ~set[BITSET_WORDS - 1]);
}
-static void
+static void __attribute__ ((unused))
bitset_merge (bitset_t dest, const bitset_t src)
{
int bitset_i;
@@ -787,7 +819,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
dest[bitset_i] |= src[bitset_i];
}
-static void
+static void __attribute__ ((unused))
bitset_mask (bitset_t dest, const bitset_t src)
{
int bitset_i;
@@ -798,7 +830,7 @@ bitset_mask (bitset_t dest, const bitset_t src)
#ifdef RE_ENABLE_I18N
/* Functions for re_string. */
static int
-internal_function __attribute ((pure))
+internal_function __attribute__ ((pure, unused))
re_string_char_size_at (const re_string_t *pstr, Idx idx)
{
int byte_idx;
@@ -811,7 +843,7 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
}
static wint_t
-internal_function __attribute ((pure))
+internal_function __attribute__ ((pure, unused))
re_string_wchar_at (const re_string_t *pstr, Idx idx)
{
if (pstr->mb_cur_max == 1)
@@ -819,15 +851,17 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
return (wint_t) pstr->wcs[idx];
}
-# ifndef NOT_IN_libc
+# ifdef _LIBC
+# include <locale/weight.h>
+# endif
+
static int
-internal_function __attribute ((pure))
+internal_function __attribute__ ((pure, unused))
re_string_elem_size_at (const re_string_t *pstr, Idx idx)
{
-# ifdef _LIBC
+# ifdef _LIBC
const unsigned char *p, *extra;
const int32_t *table, *indirect;
-# include <locale/weight.h>
uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
if (nrules != 0)
@@ -838,14 +872,13 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_INDIRECTMB);
p = pstr->mbs + idx;
- findidx (&p, pstr->len - idx);
+ findidx (table, indirect, extra, &p, pstr->len - idx);
return p - pstr->mbs - idx;
}
else
-# endif /* _LIBC */
+# endif /* _LIBC */
return 1;
}
-# endif
#endif /* RE_ENABLE_I18N */
#ifndef __GNUC_PREREQ
diff --git a/lib/regexec.c b/lib/regexec.c
index f28349a..895db82 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,22 +1,21 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Extended regular expression matching and search library.
- Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2016 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 General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
Idx n) internal_function;
@@ -200,7 +199,7 @@ static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
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)
+static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
internal_function;
/* Entry point for POSIX code. */
@@ -220,18 +219,12 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx)
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;
+regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
+ size_t nmatch, regmatch_t pmatch[], int eflags)
{
reg_errcode_t err;
Idx start, length;
-#ifdef _LIBC
re_dfa_t *dfa = preg->buffer;
-#endif
if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
return REG_BADPAT;
@@ -247,14 +240,14 @@ regexec (preg, string, nmatch, pmatch, eflags)
length = strlen (string);
}
- __libc_lock_lock (dfa->lock);
+ 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);
+ lock_unlock (dfa->lock);
return err != REG_NOERROR;
}
@@ -308,11 +301,8 @@ compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
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;
+re_match (struct re_pattern_buffer *bufp, const char *string, Idx length,
+ Idx start, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, 0, length, regs, true);
}
@@ -321,12 +311,8 @@ 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;
+re_search (struct re_pattern_buffer *bufp, const char *string, Idx length,
+ Idx start, regoff_t range, struct re_registers *regs)
{
return re_search_stub (bufp, string, length, start, range, length, regs,
false);
@@ -336,11 +322,9 @@ 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;
+re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
+ const char *string2, Idx length2, Idx start,
+ struct re_registers *regs, Idx stop)
{
return re_search_2_stub (bufp, string1, length1, string2, length2,
start, 0, regs, stop, true);
@@ -350,12 +334,9 @@ 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;
+re_search_2 (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)
{
return re_search_2_stub (bufp, string1, length1, string2, length2,
start, range, regs, stop, false);
@@ -365,18 +346,20 @@ weak_alias (__re_search_2, re_search_2)
#endif
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,
+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;
+ Idx len;
char *s = NULL;
- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
+ if (BE ((length1 < 0 || length2 < 0 || stop < 0
+ || INT_ADD_WRAPV (length1, length2, &len)),
+ 0))
return -2;
/* Concatenate the strings. */
@@ -412,8 +395,8 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
otherwise the position of the match is returned. */
static regoff_t
-re_search_stub (struct re_pattern_buffer *bufp,
- const char *string, Idx length,
+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)
{
@@ -422,9 +405,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
Idx nregs;
regoff_t rval;
int eflags = 0;
-#ifdef _LIBC
re_dfa_t *dfa = bufp->buffer;
-#endif
Idx last_start = start + range;
/* Check for out-of-range. */
@@ -435,7 +416,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
last_start = 0;
- __libc_lock_lock (dfa->lock);
+ lock_lock (dfa->lock);
eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
@@ -499,11 +480,12 @@ re_search_stub (struct re_pattern_buffer *bufp,
}
re_free (pmatch);
out:
- __libc_lock_unlock (dfa->lock);
+ lock_unlock (dfa->lock);
return rval;
}
static unsigned
+internal_function
re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
int regs_allocated)
{
@@ -582,11 +564,8 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
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;
+re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
+ __re_size_t num_regs, regoff_t *starts, regoff_t *ends)
{
if (num_regs)
{
@@ -614,8 +593,7 @@ int
# ifdef _LIBC
weak_function
# endif
-re_exec (s)
- const char *s;
+re_exec (const char *s)
{
return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
}
@@ -633,12 +611,10 @@ re_exec (s)
(0 <= LAST_START && LAST_START <= LENGTH) */
static reg_errcode_t
-__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)
+__attribute_warn_unused_result__ internal_function
+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 = preg->buffer;
@@ -647,7 +623,7 @@ re_search_internal (const regex_t *preg,
bool fl_longest_match;
int match_kind;
Idx match_first;
- Idx match_last = REG_MISSING;
+ Idx match_last = -1;
Idx extra_nmatch;
bool sb;
int ch;
@@ -856,9 +832,9 @@ re_search_internal (const regex_t *preg,
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 (match_last != -1)
{
- if (BE (match_last == REG_ERROR, 0))
+ if (BE (match_last == -2, 0))
{
err = REG_ESPACE;
goto free_return;
@@ -880,7 +856,7 @@ re_search_internal (const regex_t *preg,
break;
if (BE (err != REG_NOMATCH, 0))
goto free_return;
- match_last = REG_MISSING;
+ match_last = -1;
}
else
break; /* We found a match. */
@@ -891,7 +867,7 @@ re_search_internal (const regex_t *preg,
}
#ifdef DEBUG
- assert (match_last != REG_MISSING);
+ assert (match_last != -1);
assert (err == REG_NOERROR);
#endif
@@ -969,7 +945,7 @@ re_search_internal (const regex_t *preg,
}
static reg_errcode_t
-__attribute_warn_unused_result__
+internal_function __attribute_warn_unused_result__
prune_impossible_nodes (re_match_context_t *mctx)
{
const re_dfa_t *const dfa = mctx->dfa;
@@ -1017,7 +993,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
do
{
--match_last;
- if (! REG_VALID_INDEX (match_last))
+ if (match_last < 0)
{
ret = REG_NOMATCH;
goto free_return;
@@ -1065,7 +1041,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
since initial states may have constraints like "\<", "^", etc.. */
static inline re_dfastate_t *
-__attribute ((always_inline)) internal_function
+__attribute__ ((always_inline)) internal_function
acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
Idx idx)
{
@@ -1098,8 +1074,8 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
}
/* 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.
+ and return the index where the matching end. Return -1 if
+ there is no match, and return -2 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.
@@ -1114,7 +1090,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
const re_dfa_t *const dfa = mctx->dfa;
reg_errcode_t err;
Idx match = 0;
- Idx match_last = REG_MISSING;
+ Idx match_last = -1;
Idx cur_str_idx = re_string_cur_idx (&mctx->input);
re_dfastate_t *cur_state;
bool at_init_state = p_match_first != NULL;
@@ -1126,7 +1102,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
if (BE (cur_state == NULL, 0))
{
assert (err == REG_ESPACE);
- return REG_ERROR;
+ return -2;
}
if (mctx->state_log != NULL)
@@ -1177,11 +1153,11 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
|| (BE (next_char_idx >= mctx->input.valid_len, 0)
&& mctx->input.valid_len < mctx->input.len))
{
- err = extend_buffers (mctx);
+ err = extend_buffers (mctx, next_char_idx + 1);
if (BE (err != REG_NOERROR, 0))
{
assert (err == REG_ESPACE);
- return REG_ERROR;
+ return -2;
}
}
@@ -1195,7 +1171,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
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;
+ return -2;
if (mctx->state_log == NULL
|| (match && !fl_longest_match)
@@ -1278,7 +1254,7 @@ check_halt_state_context (const re_match_context_t *mctx,
/* 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. */
+ return -1 in case of errors. */
static Idx
internal_function
@@ -1296,15 +1272,15 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
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
+ return -2;
+ /* Pick up a valid destination, or return -1 if none
is found. */
- for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i)
+ for (dest_node = -1, 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)
+ if (dest_node == -1)
dest_node = candidate;
else
@@ -1318,7 +1294,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
else if (fs != NULL
&& push_fail_stack (fs, *pidx, candidate, nregs, regs,
eps_via_nodes))
- return REG_ERROR;
+ return -2;
/* We know we are going to exit. */
break;
@@ -1343,13 +1319,13 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
if (fs != NULL)
{
if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1)
- return REG_MISSING;
+ return -1;
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;
+ return -1;
}
}
@@ -1358,7 +1334,7 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
Idx dest_node;
ok = re_node_set_insert (eps_via_nodes, node);
if (BE (! ok, 0))
- return REG_ERROR;
+ return -2;
dest_node = dfa->edests[node].elems[0];
if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
dest_node))
@@ -1374,12 +1350,12 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
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;
+ return -1;
re_node_set_empty (eps_via_nodes);
return dest_node;
}
}
- return REG_MISSING;
+ return -1;
}
static reg_errcode_t
@@ -1415,7 +1391,7 @@ 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));
+ assert (num >= 0);
*pidx = fs->stack[num].idx;
memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
re_node_set_free (eps_via_nodes);
@@ -1508,9 +1484,9 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
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 < 0, 0))
{
- if (BE (cur_node == REG_ERROR, 0))
+ if (BE (cur_node == -2, 0))
{
re_node_set_free (&eps_via_nodes);
if (prev_idx_match_malloced)
@@ -1757,7 +1733,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
&& mctx->input.valid_len < mctx->input.len))
{
reg_errcode_t err;
- err = extend_buffers (mctx);
+ err = extend_buffers (mctx, next_state_log_idx + 1);
if (BE (err != REG_NOERROR, 0))
return err;
}
@@ -1894,10 +1870,10 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
{
Idx edst1 = dfa->edests[cur_node].elems[0];
Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
- ? dfa->edests[cur_node].elems[1] : REG_MISSING);
+ ? dfa->edests[cur_node].elems[1] : -1);
if ((!re_node_set_contains (inv_eclosure, edst1)
&& re_node_set_contains (dest_nodes, edst1))
- || (REG_VALID_NONZERO_INDEX (edst2)
+ || (edst2 > 0
&& !re_node_set_contains (inv_eclosure, edst2)
&& re_node_set_contains (dest_nodes, edst2)))
{
@@ -1977,7 +1953,7 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
switch (dfa->nodes[node].type)
{
case OP_BACK_REF:
- if (bkref_idx != REG_MISSING)
+ if (bkref_idx != -1)
{
struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
do
@@ -2093,8 +2069,8 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
subexp_idx = dfa->nodes[ent->node].opr.idx;
if (ent->subexp_to == str_idx)
{
- Idx ops_node = REG_MISSING;
- Idx cls_node = REG_MISSING;
+ Idx ops_node = -1;
+ Idx cls_node = -1;
for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
{
Idx node = dest_nodes->elems[node_idx];
@@ -2109,7 +2085,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
/* Check the limitation of the open subexpression. */
/* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
- if (REG_VALID_INDEX (ops_node))
+ if (ops_node >= 0)
{
err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
candidates);
@@ -2118,7 +2094,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
}
/* Check the limitation of the close subexpression. */
- if (REG_VALID_INDEX (cls_node))
+ if (cls_node >= 0)
for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
{
Idx node = dest_nodes->elems[node_idx];
@@ -2171,7 +2147,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
re_sift_context_t local_sctx;
Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
- if (first_idx == REG_MISSING)
+ if (first_idx == -1)
return REG_NOERROR;
local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
@@ -2575,7 +2551,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
if (BE (err != REG_NOERROR, 0))
return err;
#ifdef DEBUG
- assert (dfa->nexts[cur_node_idx] != REG_MISSING);
+ assert (dfa->nexts[cur_node_idx] != -1);
#endif
new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
@@ -2641,7 +2617,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
/* 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);
+ assert (dfa->nexts[node_idx] != -1);
#endif
for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
{
@@ -2725,7 +2701,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_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)
+ if (cache_idx != -1)
{
const struct re_backref_cache_entry *entry
= mctx->bkref_ents + cache_idx;
@@ -2814,7 +2790,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
if (bkref_str_off >= mctx->input.len)
break;
- err = extend_buffers (mctx);
+ err = extend_buffers (mctx, bkref_str_off + 1);
if (BE (err != REG_NOERROR, 0))
return err;
@@ -2830,7 +2806,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
nodes = &mctx->state_log[sl_str]->nodes;
cls_node = find_subexp_node (dfa, nodes, subexp_num,
OP_CLOSE_SUBEXP);
- if (cls_node == REG_MISSING)
+ if (cls_node == -1)
continue; /* No. */
if (sub_top->path == NULL)
{
@@ -2909,7 +2885,7 @@ find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
&& node->opr.idx == subexp_idx)
return cls_node;
}
- return REG_MISSING;
+ return -1;
}
/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
@@ -3185,7 +3161,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
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)
+ if (outside_node == -1)
{
/* There are no problematic nodes, just merge them. */
err = re_node_set_merge (&new_nodes, eclosure);
@@ -3271,7 +3247,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
struct re_backref_cache_entry *ent;
- if (cache_idx_start == REG_MISSING)
+ if (cache_idx_start == -1)
return REG_NOERROR;
restart:
@@ -3396,7 +3372,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
/* 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 (BE (ndests <= 0, 0))
{
if (dests_node_malloced)
free (dests_alloc);
@@ -3458,7 +3434,7 @@ out_free:
for (j = 0; j < dests_node[i].nelem; ++j)
{
next_node = dfa->nexts[dests_node[i].elems[j]];
- if (next_node != REG_MISSING)
+ if (next_node != -1)
{
err = re_node_set_merge (&follows, dfa->eclosures + next_node);
if (BE (err != REG_NOERROR, 0))
@@ -3769,7 +3745,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
error_return:
for (j = 0; j < ndests; ++j)
re_node_set_free (dests_node + j);
- return REG_MISSING;
+ return -1;
}
#ifdef RE_ENABLE_I18N
@@ -3781,6 +3757,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
one collating element like '.', '[a-z]', opposite to the other nodes
can only accept one byte. */
+# ifdef _LIBC
+# include <locale/weight.h>
+# endif
+
static int
internal_function
check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
@@ -3900,8 +3880,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
const int32_t *table, *indirect;
const unsigned char *weights, *extra;
const char *collseqwc;
- /* This #include defines a local function! */
-# include <locale/weight.h>
/* match with collating_symbol? */
if (cset->ncoll_syms)
@@ -3937,6 +3915,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
in_collseq = find_collation_sequence_value (pin, elem_len);
}
/* match with range expression? */
+ /* FIXME: Implement rational ranges here, too. */
for (i = 0; i < cset->nranges; ++i)
if (cset->range_starts[i] <= in_collseq
&& in_collseq <= cset->range_ends[i])
@@ -3957,7 +3936,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
indirect = (const int32_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
- int32_t idx = findidx (&cp, elem_len);
+ int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
if (idx > 0)
for (i = 0; i < cset->nequiv_classes; ++i)
{
@@ -3988,18 +3967,9 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
# endif /* _LIBC */
{
/* match with range expression? */
-#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined __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)
+ if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
{
match_len = char_len;
goto check_node_accept_bytes_match;
@@ -4137,7 +4107,7 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
static reg_errcode_t
internal_function __attribute_warn_unused_result__
-extend_buffers (re_match_context_t *mctx)
+extend_buffers (re_match_context_t *mctx, int min_len)
{
reg_errcode_t ret;
re_string_t *pstr = &mctx->input;
@@ -4147,8 +4117,10 @@ extend_buffers (re_match_context_t *mctx)
<= pstr->bufs_len, 0))
return REG_ESPACE;
- /* Double the lengths of the buffers. */
- ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2));
+ /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
+ ret = re_string_realloc_buffers (pstr,
+ MAX (min_len,
+ MIN (pstr->len, pstr->bufs_len * 2)));
if (BE (ret != REG_NOERROR, 0))
return ret;
@@ -4204,7 +4176,7 @@ 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;
+ mctx->match_last = -1;
if (n > 0)
{
/* Avoid overflow. */
@@ -4325,7 +4297,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
return REG_NOERROR;
}
-/* Return the first entry with the same str_idx, or REG_MISSING if none is
+/* Return the first entry with the same str_idx, or -1 if none is
found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
static Idx
@@ -4345,7 +4317,7 @@ search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
return left;
else
- return REG_MISSING;
+ return -1;
}
/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
diff --git a/lib/rename.c b/lib/rename.c
index 4ebfc31..e1d169a 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -1,6 +1,6 @@
/* Work around rename bugs in some systems.
- Copyright (C) 2001-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2006, 2009-2016 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
@@ -285,7 +285,7 @@ rpl_rename (char const *src, char const *dst)
char *dst_temp = (char *) dst;
bool src_slash;
bool dst_slash;
- bool dst_exists;
+ bool dst_exists _GL_UNUSED;
int ret_val = -1;
int rename_errno = ENOTDIR;
struct stat src_st;
@@ -462,7 +462,9 @@ rpl_rename (char const *src, char const *dst)
ret_val = rename (src_temp, dst_temp);
rename_errno = errno;
- out:
+
+ out: _GL_UNUSED_LABEL;
+
if (src_temp != src)
free (src_temp);
if (dst_temp != dst)
diff --git a/lib/rmdir.c b/lib/rmdir.c
index 5017064..4949df2 100644
--- a/lib/rmdir.c
+++ b/lib/rmdir.c
@@ -1,6 +1,6 @@
/* Work around rmdir bugs.
- Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2012 Free Software
+ Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/same-inode.h b/lib/same-inode.h
index 8c3900d..c7a8fb5 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -1,6 +1,6 @@
-/* Determine whether two stat buffers refer to the same file.
+/* Determine whether two stat buffers are known to refer to the same file.
- Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,6 +24,10 @@
&& (a).st_ino[1] == (b).st_ino[1] \
&& (a).st_ino[2] == (b).st_ino[2] \
&& (a).st_dev == (b).st_dev)
+# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* On MinGW, struct stat lacks necessary info, so always return 0.
+ Callers can use !a.st_ino to deduce that the information is unknown. */
+# define SAME_INODE(a, b) 0
# else
# define SAME_INODE(a, b) \
((a).st_ino == (b).st_ino \
diff --git a/lib/se-context.in.h b/lib/se-context.in.h
index a692f5a..c3890a2 100644
--- a/lib/se-context.in.h
+++ b/lib/se-context.in.h
@@ -3,6 +3,9 @@
# include <errno.h>
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef SE_CONTEXT_INLINE
# define SE_CONTEXT_INLINE _GL_INLINE
@@ -29,6 +32,14 @@ SE_CONTEXT_INLINE int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
SE_CONTEXT_INLINE int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
char const *s _GL_UNUSED_PARAMETER)
{ errno = ENOTSUP; return -1; }
+SE_CONTEXT_INLINE char *context_type_get (context_t sc _GL_UNUSED_PARAMETER)
+ { errno = ENOTSUP; return (void *) 0; }
+SE_CONTEXT_INLINE char *context_range_get (context_t sc _GL_UNUSED_PARAMETER)
+ { errno = ENOTSUP; return (void *) 0; }
+SE_CONTEXT_INLINE char *context_role_get (context_t sc _GL_UNUSED_PARAMETER)
+ { errno = ENOTSUP; return (void *) 0; }
+SE_CONTEXT_INLINE char *context_user_get (context_t sc _GL_UNUSED_PARAMETER)
+ { errno = ENOTSUP; return (void *) 0; }
_GL_INLINE_HEADER_END
diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h
index 78d7d14..dd56e27 100644
--- a/lib/se-selinux.in.h
+++ b/lib/se-selinux.in.h
@@ -1,5 +1,5 @@
/* Replacement <selinux/selinux.h> for platforms that lack it.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 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
@@ -31,6 +31,9 @@
# include <sys/types.h>
# include <errno.h>
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
# ifndef SE_SELINUX_INLINE
# define SE_SELINUX_INLINE _GL_INLINE
@@ -41,7 +44,7 @@ _GL_INLINE_HEADER_BEGIN
# if !GNULIB_defined_security_types
typedef unsigned short security_class_t;
-# define security_context_t char*
+typedef char *security_context_t;
# define is_selinux_enabled() 0
SE_SELINUX_INLINE int
@@ -100,6 +103,9 @@ security_compute_create (security_context_t scon _GL_UNUSED_PARAMETER,
security_class_t tclass _GL_UNUSED_PARAMETER,
security_context_t *newcon _GL_UNUSED_PARAMETER)
{ errno = ENOTSUP; return -1; }
+SE_SELINUX_INLINE security_class_t
+string_to_security_class (char const *name)
+ { errno = ENOTSUP; return 0; }
SE_SELINUX_INLINE int
matchpathcon_init_prefix (char const *path _GL_UNUSED_PARAMETER,
char const *prefix _GL_UNUSED_PARAMETER)
@@ -108,6 +114,9 @@ matchpathcon_init_prefix (char const *path _GL_UNUSED_PARAMETER,
# define GNULIB_defined_security_types 1
# endif
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
# endif
diff --git a/lib/secure_getenv.c b/lib/secure_getenv.c
new file mode 100644
index 0000000..88a60dc
--- /dev/null
+++ b/lib/secure_getenv.c
@@ -0,0 +1,54 @@
+/* Look up an environment variable, returning NULL in insecure situations.
+
+ Copyright 2013-2016 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>
+
+#if !HAVE___SECURE_GETENV
+# if HAVE_ISSETUGID || (HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID)
+# include <unistd.h>
+# endif
+#endif
+
+char *
+secure_getenv (char const *name)
+{
+#if HAVE___SECURE_GETENV /* glibc */
+ return __secure_getenv (name);
+#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */
+ if (issetugid ())
+ return NULL;
+ return getenv (name);
+#elif HAVE_GETUID && HAVE_GETEUID && HAVE_GETGID && HAVE_GETEGID /* other Unix */
+ if (geteuid () != getuid () || getegid () != getgid ())
+ return NULL;
+ return getenv (name);
+#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* native Windows */
+ /* On native Windows, there is no such concept as setuid or setgid binaries.
+ - Programs launched as system services have high privileges, but they don't
+ inherit environment variables from a user.
+ - Programs launched by a user with "Run as Administrator" have high
+ privileges and use the environment variables, but the user has been asked
+ whether he agrees.
+ - Programs launched by a user without "Run as Administrator" cannot gain
+ high privileges, therefore there is no risk. */
+ return getenv (name);
+#else
+ return NULL;
+#endif
+}
diff --git a/lib/set-acl.c b/lib/set-acl.c
new file mode 100644
index 0000000..fbb5c16
--- /dev/null
+++ b/lib/set-acl.c
@@ -0,0 +1,48 @@
+/* set-acl.c - set access control list equivalent to a mode
+
+ Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */
+
+#include <config.h>
+
+#include "acl.h"
+
+#include <errno.h>
+
+#include "quote.h"
+#include "error.h"
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+
+/* Set the access control lists of a file. If DESC is a valid file
+ descriptor, use file descriptor operations where available, else use
+ filename based operations on NAME. If access control lists are not
+ available, fchmod the target file to MODE. Also sets the
+ non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX)
+ to those from MODE if any are set.
+ Return 0 if successful. On failure, output a diagnostic, set errno and
+ return -1. */
+
+int
+set_acl (char const *name, int desc, mode_t mode)
+{
+ int ret = qset_acl (name, desc, mode);
+ if (ret != 0)
+ error (0, errno, _("setting permissions for %s"), quote (name));
+ return ret;
+}
diff --git a/lib/set-mode-acl.c b/lib/set-permissions.c
index c7a8343..2c77356 100644
--- a/lib/set-mode-acl.c
+++ b/lib/set-permissions.c
@@ -1,6 +1,6 @@
-/* set-mode-acl.c - set access control list equivalent to a mode
+/* Set permissions of a file. -*- coding: utf-8 -*-
- Copyright (C) 2002-2003, 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2016 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
@@ -15,194 +15,46 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
- Written by Paul Eggert and Andreas Gruenbacher, and Bruno Haible. */
+ Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */
#include <config.h>
-#define ACL_INTERNAL_INLINE _GL_EXTERN_INLINE
-
#include "acl.h"
#include "acl-internal.h"
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-
-
-/* If DESC is a valid file descriptor use fchmod to change the
- file's mode to MODE on systems that have fchown. On systems
- that don't have fchown and if DESC is invalid, use chown on
- NAME instead.
- Return 0 if successful. Return -1 and set errno upon failure. */
-
-int
-chmod_or_fchmod (const char *name, int desc, mode_t mode)
-{
- if (HAVE_FCHMOD && desc != -1)
- return fchmod (desc, mode);
- else
- return chmod (name, mode);
-}
-
-/* Set the access control lists of a file. If DESC is a valid file
- descriptor, use file descriptor operations where available, else use
- filename based operations on NAME. If access control lists are not
- available, fchmod the target file to MODE. Also sets the
- non-permission bits of the destination file (S_ISUID, S_ISGID, S_ISVTX)
- to those from MODE if any are set.
- Return 0 if successful. Return -1 and set errno upon failure. */
-
-int
-qset_acl (char const *name, int desc, mode_t mode)
-{
#if USE_ACL
-# if HAVE_ACL_GET_FILE
- /* POSIX 1003.1e draft 17 (abandoned) specific version. */
- /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
-# if !HAVE_ACL_TYPE_EXTENDED
- /* Linux, FreeBSD, IRIX, Tru64 */
-
- /* We must also have acl_from_text and acl_delete_def_file.
- (acl_delete_def_file could be emulated with acl_init followed
- by acl_set_file, but acl_set_file with an empty acl is
- unspecified.) */
-
-# ifndef HAVE_ACL_FROM_TEXT
-# error Must have acl_from_text (see POSIX 1003.1e draft 17).
-# endif
-# ifndef HAVE_ACL_DELETE_DEF_FILE
-# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17).
-# endif
-
- acl_t acl;
- int ret;
-
- if (HAVE_ACL_FROM_MODE) /* Linux */
- {
- acl = acl_from_mode (mode);
- if (!acl)
- return -1;
- }
- else /* FreeBSD, IRIX, Tru64 */
- {
- /* If we were to create the ACL using the functions acl_init(),
- acl_create_entry(), acl_set_tag_type(), acl_set_qualifier(),
- acl_get_permset(), acl_clear_perm[s](), acl_add_perm(), we
- would need to create a qualifier. I don't know how to do this.
- So create it using acl_from_text(). */
-
-# if HAVE_ACL_FREE_TEXT /* Tru64 */
- char acl_text[] = "u::---,g::---,o::---,";
-# else /* FreeBSD, IRIX */
- char acl_text[] = "u::---,g::---,o::---";
-# endif
-
- if (mode & S_IRUSR) acl_text[ 3] = 'r';
- if (mode & S_IWUSR) acl_text[ 4] = 'w';
- if (mode & S_IXUSR) acl_text[ 5] = 'x';
- if (mode & S_IRGRP) acl_text[10] = 'r';
- if (mode & S_IWGRP) acl_text[11] = 'w';
- if (mode & S_IXGRP) acl_text[12] = 'x';
- if (mode & S_IROTH) acl_text[17] = 'r';
- if (mode & S_IWOTH) acl_text[18] = 'w';
- if (mode & S_IXOTH) acl_text[19] = 'x';
-
- acl = acl_from_text (acl_text);
- if (!acl)
- return -1;
- }
- if (HAVE_ACL_SET_FD && desc != -1)
- ret = acl_set_fd (desc, acl);
- else
- ret = acl_set_file (name, ACL_TYPE_ACCESS, acl);
- if (ret != 0)
- {
- int saved_errno = errno;
- acl_free (acl);
-
- if (ACL_NOT_WELL_SUPPORTED (errno))
- return chmod_or_fchmod (name, desc, mode);
- else
- {
- errno = saved_errno;
- return -1;
- }
- }
- else
- acl_free (acl);
-
- if (S_ISDIR (mode) && acl_delete_def_file (name))
- return -1;
-
- if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- /* We did not call chmod so far, and either the mode and the ACL are
- separate or special bits are to be set which don't fit into ACLs. */
- return chmod_or_fchmod (name, desc, mode);
- }
- return 0;
-
-# else /* HAVE_ACL_TYPE_EXTENDED */
- /* Mac OS X */
-
- /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
- and acl_get_file (name, ACL_TYPE_DEFAULT)
- always return NULL / EINVAL. You have to use
- acl_get_file (name, ACL_TYPE_EXTENDED)
- or acl_get_fd (open (name, ...))
- to retrieve an ACL.
- On the other hand,
- acl_set_file (name, ACL_TYPE_ACCESS, acl)
- and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
- have the same effect as
- acl_set_file (name, ACL_TYPE_EXTENDED, acl):
- Each of these calls sets the file's ACL. */
-
- acl_t acl;
- int ret;
-
- /* Remove the ACL if the file has ACLs. */
- if (HAVE_ACL_GET_FD && desc != -1)
- acl = acl_get_fd (desc);
- else
- acl = acl_get_file (name, ACL_TYPE_EXTENDED);
- if (acl)
- {
- acl_free (acl);
-
- acl = acl_init (0);
- if (acl)
- {
- if (HAVE_ACL_SET_FD && desc != -1)
- ret = acl_set_fd (desc, acl);
- else
- ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
- if (ret != 0)
- {
- int saved_errno = errno;
-
- acl_free (acl);
+# if ! defined HAVE_ACL_FROM_MODE && defined HAVE_ACL_FROM_TEXT /* FreeBSD, IRIX, Tru64 */
+# if HAVE_ACL_GET_FILE && !HAVE_ACL_TYPE_EXTENDED
- if (ACL_NOT_WELL_SUPPORTED (saved_errno))
- return chmod_or_fchmod (name, desc, mode);
- else
- {
- errno = saved_errno;
- return -1;
- }
- }
- acl_free (acl);
- }
- }
-
- /* Since !MODE_INSIDE_ACL, we have to call chmod explicitly. */
- return chmod_or_fchmod (name, desc, mode);
+static acl_t
+acl_from_mode (mode_t mode)
+{
+# if HAVE_ACL_FREE_TEXT /* Tru64 */
+ char acl_text[] = "u::---,g::---,o::---,";
+# else /* FreeBSD, IRIX */
+ char acl_text[] = "u::---,g::---,o::---";
# endif
-# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
-
- int done_setacl = 0;
+ if (mode & S_IRUSR) acl_text[ 3] = 'r';
+ if (mode & S_IWUSR) acl_text[ 4] = 'w';
+ if (mode & S_IXUSR) acl_text[ 5] = 'x';
+ if (mode & S_IRGRP) acl_text[10] = 'r';
+ if (mode & S_IWGRP) acl_text[11] = 'w';
+ if (mode & S_IXGRP) acl_text[12] = 'x';
+ if (mode & S_IROTH) acl_text[17] = 'r';
+ if (mode & S_IWOTH) acl_text[18] = 'w';
+ if (mode & S_IXOTH) acl_text[19] = 'x';
+
+ return acl_from_text (acl_text);
+}
+# endif
+# endif
+# if HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
+static int
+set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
+{
# ifdef ACE_GETACL
/* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
file systems (whereas the other ones are used in UFS file systems). */
@@ -377,53 +229,54 @@ qset_acl (char const *name, int desc, mode_t mode)
if (ret < 0 && errno != EINVAL && errno != ENOTSUP)
{
if (errno == ENOSYS)
- return chmod_or_fchmod (name, desc, mode);
+ {
+ *must_chmod = true;
+ return 0;
+ }
return -1;
}
if (ret == 0)
- done_setacl = 1;
+ return 0;
}
# endif
- if (!done_setacl)
- {
- aclent_t entries[3];
- int ret;
-
- entries[0].a_type = USER_OBJ;
- entries[0].a_id = 0; /* irrelevant */
- entries[0].a_perm = (mode >> 6) & 7;
- entries[1].a_type = GROUP_OBJ;
- entries[1].a_id = 0; /* irrelevant */
- entries[1].a_perm = (mode >> 3) & 7;
- entries[2].a_type = OTHER_OBJ;
- entries[2].a_id = 0;
- entries[2].a_perm = mode & 7;
-
- if (desc != -1)
- ret = facl (desc, SETACL,
- sizeof (entries) / sizeof (aclent_t), entries);
- else
- ret = acl (name, SETACL,
- sizeof (entries) / sizeof (aclent_t), entries);
- if (ret < 0)
- {
- if (errno == ENOSYS || errno == EOPNOTSUPP)
- return chmod_or_fchmod (name, desc, mode);
- return -1;
- }
- }
+ {
+ aclent_t entries[3];
+ int ret;
+
+ entries[0].a_type = USER_OBJ;
+ entries[0].a_id = 0; /* irrelevant */
+ entries[0].a_perm = (mode >> 6) & 7;
+ entries[1].a_type = GROUP_OBJ;
+ entries[1].a_id = 0; /* irrelevant */
+ entries[1].a_perm = (mode >> 3) & 7;
+ entries[2].a_type = OTHER_OBJ;
+ entries[2].a_id = 0;
+ entries[2].a_perm = mode & 7;
- if (!MODE_INSIDE_ACL || (mode & (S_ISUID | S_ISGID | S_ISVTX)))
- {
- /* We did not call chmod so far, so the special bits have not yet
- been set. */
- return chmod_or_fchmod (name, desc, mode);
- }
- return 0;
+ if (desc != -1)
+ ret = facl (desc, SETACL,
+ sizeof (entries) / sizeof (aclent_t), entries);
+ else
+ ret = acl (name, SETACL,
+ sizeof (entries) / sizeof (aclent_t), entries);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS || errno == EOPNOTSUPP)
+ {
+ *must_chmod = true;
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+ }
+}
# elif HAVE_GETACL /* HP-UX */
-
+static int
+context_acl_from_mode (struct permission_context *ctx, const char *name, int desc)
+{
struct stat statbuf;
int ret;
@@ -434,87 +287,60 @@ qset_acl (char const *name, int desc, mode_t mode)
if (ret < 0)
return -1;
- {
- struct acl_entry entries[3];
-
- entries[0].uid = statbuf.st_uid;
- entries[0].gid = ACL_NSGROUP;
- entries[0].mode = (mode >> 6) & 7;
- entries[1].uid = ACL_NSUSER;
- entries[1].gid = statbuf.st_gid;
- entries[1].mode = (mode >> 3) & 7;
- entries[2].uid = ACL_NSUSER;
- entries[2].gid = ACL_NSGROUP;
- entries[2].mode = mode & 7;
-
- if (desc != -1)
- ret = fsetacl (desc, sizeof (entries) / sizeof (struct acl_entry), entries);
- else
- ret = setacl (name, sizeof (entries) / sizeof (struct acl_entry), entries);
- }
- if (ret < 0)
- {
- if (!(errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP))
- return -1;
+ ctx->entries[0].uid = statbuf.st_uid;
+ ctx->entries[0].gid = ACL_NSGROUP;
+ ctx->entries[0].mode = (ctx->mode >> 6) & 7;
+ ctx->entries[1].uid = ACL_NSUSER;
+ ctx->entries[1].gid = statbuf.st_gid;
+ ctx->entries[1].mode = (ctx->mode >> 3) & 7;
+ ctx->entries[2].uid = ACL_NSUSER;
+ ctx->entries[2].gid = ACL_NSGROUP;
+ ctx->entries[2].mode = ctx->mode & 7;
+ ctx->count = 3;
+ return 0;
+}
# if HAVE_ACLV_H /* HP-UX >= 11.11 */
- {
- struct acl entries[4];
-
- entries[0].a_type = USER_OBJ;
- entries[0].a_id = 0; /* irrelevant */
- entries[0].a_perm = (mode >> 6) & 7;
- entries[1].a_type = GROUP_OBJ;
- entries[1].a_id = 0; /* irrelevant */
- entries[1].a_perm = (mode >> 3) & 7;
- entries[2].a_type = CLASS_OBJ;
- entries[2].a_id = 0;
- entries[2].a_perm = (mode >> 3) & 7;
- entries[3].a_type = OTHER_OBJ;
- entries[3].a_id = 0;
- entries[3].a_perm = mode & 7;
-
- ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries);
- if (ret > 0)
- abort ();
- if (ret < 0)
- {
- if (0)
- return chmod_or_fchmod (name, desc, mode);
- return -1;
- }
+static int
+context_aclv_from_mode (struct permission_context *ctx)
+{
+ int ret;
- ret = acl ((char *) name, ACL_SET,
- sizeof (entries) / sizeof (struct acl), entries);
- if (ret < 0)
- {
- if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
- return chmod_or_fchmod (name, desc, mode);
- return -1;
- }
- }
-# else
- return chmod_or_fchmod (name, desc, mode);
+ ctx->aclv_entries[0].a_type = USER_OBJ;
+ ctx->aclv_entries[0].a_id = 0; /* irrelevant */
+ ctx->aclv_entries[0].a_perm = (ctx->mode >> 6) & 7;
+ ctx->aclv_entries[1].a_type = GROUP_OBJ;
+ ctx->aclv_entries[1].a_id = 0; /* irrelevant */
+ ctx->aclv_entries[1].a_perm = (ctx->mode >> 3) & 7;
+ ctx->aclv_entries[2].a_type = CLASS_OBJ;
+ ctx->aclv_entries[2].a_id = 0;
+ ctx->aclv_entries[2].a_perm = (ctx->mode >> 3) & 7;
+ ctx->aclv_entries[3].a_type = OTHER_OBJ;
+ ctx->aclv_entries[3].a_id = 0;
+ ctx->aclv_entries[3].a_perm = ctx->mode & 7;
+ ctx->aclv_count = 4;
+
+ ret = aclsort (ctx->aclv_count, 1, ctx->aclv_entries);
+ if (ret > 0)
+ abort ();
+ return ret;
+}
# endif
- }
-
- if (mode & (S_ISUID | S_ISGID | S_ISVTX))
- {
- /* We did not call chmod so far, so the special bits have not yet
- been set. */
- return chmod_or_fchmod (name, desc, mode);
- }
- return 0;
# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */
-
+static int
+set_acls_from_mode (const char *name, int desc, mode_t mode, bool *must_chmod)
+{
acl_type_list_t types;
size_t types_size = sizeof (types);
acl_type_t type;
if (aclx_gettypes (name, &types, &types_size) < 0
|| types.num_entries == 0)
- return chmod_or_fchmod (name, desc, mode);
+ {
+ *must_chmod = true;
+ return 0;
+ }
/* XXX Do we need to clear all types of ACLs for the given file, or is it
sufficient to clear the first one? */
@@ -611,89 +437,411 @@ qset_acl (char const *name, int desc, mode_t mode)
return ret;
}
- return chmod_or_fchmod (name, desc, mode);
+ *must_chmod = true;
+ return 0;
+}
# elif HAVE_STATACL /* older AIX */
+static int
+context_acl_from_mode (struct permission_context *ctx)
+{
+ ctx->u.a.acl_len = (char *) &ctx->u.a.acl_ext[0] - (char *) &ctx->u.a; /* no entries */
+ ctx->u.a.acl_mode = ctx->mode & ~(S_IXACL | 0777);
+ ctx->u.a.u_access = (ctx->mode >> 6) & 7;
+ ctx->u.a.g_access = (ctx->mode >> 3) & 7;
+ ctx->u.a.o_access = ctx->mode & 7;
+ ctx->have_u = true;
+ return 0;
+}
- union { struct acl a; char room[128]; } u;
+# elif HAVE_ACLSORT /* NonStop Kernel */
+static int
+context_acl_from_mode (struct permission_context *ctx)
+{
int ret;
- u.a.acl_len = (char *) &u.a.acl_ext[0] - (char *) &u.a; /* no entries */
- u.a.acl_mode = mode & ~(S_IXACL | 0777);
- u.a.u_access = (mode >> 6) & 7;
- u.a.g_access = (mode >> 3) & 7;
- u.a.o_access = mode & 7;
+ ctx->entries[0].a_type = USER_OBJ;
+ ctx->entries[0].a_id = 0; /* irrelevant */
+ ctx->entries[0].a_perm = (ctx->mode >> 6) & 7;
+ ctx->entries[1].a_type = GROUP_OBJ;
+ ctx->entries[1].a_id = 0; /* irrelevant */
+ ctx->entries[1].a_perm = (ctx->mode >> 3) & 7;
+ ctx->entries[2].a_type = CLASS_OBJ;
+ ctx->entries[2].a_id = 0;
+ ctx->entries[2].a_perm = (ctx->mode >> 3) & 7;
+ ctx->entries[3].a_type = OTHER_OBJ;
+ ctx->entries[3].a_id = 0;
+ ctx->entries[3].a_perm = ctx->mode & 7;
+ ctx->count = 4;
+
+ ret = aclsort (ctx->count, 1, entries);
+ if (ret > 0)
+ abort ();
+ return ret;
+}
+# endif
- if (desc != -1)
- ret = fchacl (desc, &u.a, u.a.acl_len);
+static int
+set_acls (struct permission_context *ctx, const char *name, int desc,
+ int from_mode, bool *must_chmod, bool *acls_set)
+{
+ int ret = 0;
+
+# if HAVE_ACL_GET_FILE
+ /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
+ /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
+# if !HAVE_ACL_TYPE_EXTENDED
+ /* Linux, FreeBSD, IRIX, Tru64 */
+
+# ifndef HAVE_ACL_FROM_TEXT
+# error Must have acl_from_text (see POSIX 1003.1e draft 17).
+# endif
+# ifndef HAVE_ACL_DELETE_DEF_FILE
+# error Must have acl_delete_def_file (see POSIX 1003.1e draft 17).
+# endif
+
+ if (! ctx->acls_not_supported)
+ {
+ if (ret == 0 && from_mode)
+ {
+ if (ctx->acl)
+ acl_free (ctx->acl);
+ ctx->acl = acl_from_mode (ctx->mode);
+ if (ctx->acl == NULL)
+ ret = -1;
+ }
+
+ if (ret == 0 && ctx->acl)
+ {
+ if (HAVE_ACL_SET_FD && desc != -1)
+ ret = acl_set_fd (desc, ctx->acl);
+ else
+ ret = acl_set_file (name, ACL_TYPE_ACCESS, ctx->acl);
+ if (ret != 0)
+ {
+ if (! acl_errno_valid (errno))
+ {
+ ctx->acls_not_supported = true;
+ if (from_mode || acl_access_nontrivial (ctx->acl) == 0)
+ ret = 0;
+ }
+ }
+ else
+ {
+ *acls_set = true;
+ if (S_ISDIR(ctx->mode))
+ {
+ if (! from_mode && ctx->default_acl &&
+ acl_default_nontrivial (ctx->default_acl))
+ ret = acl_set_file (name, ACL_TYPE_DEFAULT,
+ ctx->default_acl);
+ else
+ ret = acl_delete_def_file (name);
+ }
+ }
+ }
+ }
+
+# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
+
+ /* File systems either support POSIX ACLs (for example, ufs) or NFS4 ACLs
+ (for example, zfs). */
+
+ /* TODO: Implement setting ACLs once get_permissions() reads them. */
+
+# endif
+
+# else /* HAVE_ACL_TYPE_EXTENDED */
+ /* Mac OS X */
+
+ /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
+ and acl_get_file (name, ACL_TYPE_DEFAULT)
+ always return NULL / EINVAL. You have to use
+ acl_get_file (name, ACL_TYPE_EXTENDED)
+ or acl_get_fd (open (name, ...))
+ to retrieve an ACL.
+ On the other hand,
+ acl_set_file (name, ACL_TYPE_ACCESS, acl)
+ and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
+ have the same effect as
+ acl_set_file (name, ACL_TYPE_EXTENDED, acl):
+ Each of these calls sets the file's ACL. */
+
+ if (ctx->acl == NULL)
+ {
+ acl_t acl;
+
+ /* Remove ACLs if the file has ACLs. */
+ if (HAVE_ACL_GET_FD && desc != -1)
+ acl = acl_get_fd (desc);
+ else
+ acl = acl_get_file (name, ACL_TYPE_EXTENDED);
+ if (acl)
+ {
+ acl_free (acl);
+
+ acl = acl_init (0);
+ if (acl)
+ {
+ if (HAVE_ACL_SET_FD && desc != -1)
+ ret = acl_set_fd (desc, acl);
+ else
+ ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
+ acl_free (acl);
+ }
+ else
+ ret = -1;
+ }
+ }
else
- ret = chacl (name, &u.a, u.a.acl_len);
+ {
+ if (HAVE_ACL_SET_FD && desc != -1)
+ ret = acl_set_fd (desc, ctx->acl);
+ else
+ ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl);
+ if (ret != 0)
+ {
+ if (! acl_errno_valid (errno)
+ && ! acl_extended_nontrivial (ctx->acl))
+ ret = 0;
+ }
+ }
+ *acls_set = true;
- if (ret < 0 && errno == ENOSYS)
- return chmod_or_fchmod (name, desc, mode);
+# endif
- return ret;
+# elif defined GETACL /* Solaris, Cygwin, not HP-UX */
-# elif HAVE_ACLSORT /* NonStop Kernel */
+ /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
+ of Unixware. The acl() call returns the access and default ACL both
+ at once. */
- struct acl entries[4];
- int ret;
+ /* If both ace_entries and entries are available, try SETACL before
+ ACE_SETACL, because SETACL cannot fail with ENOTSUP whereas ACE_SETACL
+ can. */
- entries[0].a_type = USER_OBJ;
- entries[0].a_id = 0; /* irrelevant */
- entries[0].a_perm = (mode >> 6) & 7;
- entries[1].a_type = GROUP_OBJ;
- entries[1].a_id = 0; /* irrelevant */
- entries[1].a_perm = (mode >> 3) & 7;
- entries[2].a_type = CLASS_OBJ;
- entries[2].a_id = 0;
- entries[2].a_perm = (mode >> 3) & 7;
- entries[3].a_type = OTHER_OBJ;
- entries[3].a_id = 0;
- entries[3].a_perm = mode & 7;
-
- ret = aclsort (sizeof (entries) / sizeof (struct acl), 1, entries);
- if (ret > 0)
- abort ();
- if (ret < 0)
+ if (from_mode)
+ return set_acls_from_mode (name, desc, ctx->mode, must_chmod);
+
+ if (ret == 0 && ctx->count)
{
- if (0)
- return chmod_or_fchmod (name, desc, mode);
- return -1;
+ if (desc != -1)
+ ret = facl (desc, SETACL, ctx->count, ctx->entries);
+ else
+ ret = acl (name, SETACL, ctx->count, ctx->entries);
+ if (ret < 0)
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+ && acl_nontrivial (ctx->count, ctx->entries) == 0)
+ ret = 0;
+ }
+ else
+ *acls_set = true;
}
- ret = acl ((char *) name, ACL_SET,
- sizeof (entries) / sizeof (struct acl), entries);
- if (ret < 0)
+# ifdef ACE_GETACL
+ if (ret == 0 && ctx->ace_count)
{
- if (0)
- return chmod_or_fchmod (name, desc, mode);
- return -1;
+ if (desc != -1)
+ ret = facl (desc, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
+ else
+ ret = acl (name, ACE_SETACL, ctx->ace_count, ctx->ace_entries);
+ if (ret < 0)
+ {
+ if ((errno == ENOSYS || errno == EINVAL || errno == ENOTSUP)
+ && acl_ace_nontrivial (ctx->ace_count, ctx->ace_entries) == 0)
+ ret = 0;
+ }
+ else
+ *acls_set = true;
}
+# endif
- if (mode & (S_ISUID | S_ISGID | S_ISVTX))
+# elif HAVE_GETACL /* HP-UX */
+
+ if (from_mode)
+ ret = context_acl_from_mode (ctx, name, desc);
+
+ if (ret == 0 && ctx->count > 0)
{
- /* We did not call chmod so far, so the special bits have not yet
- been set. */
- return chmod_or_fchmod (name, desc, mode);
+ if (desc != -1)
+ ret = fsetacl (desc, ctx->count, ctx->entries);
+ else
+ ret = setacl (name, ctx->count, ctx->entries);
+ if (ret < 0)
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+ && (from_mode || !acl_nontrivial (ctx->count, ctx->entries)))
+ ret = 0;
+ }
+ else
+ *acls_set = true;
}
- return 0;
-# else /* Unknown flavor of ACLs */
- return chmod_or_fchmod (name, desc, mode);
+# if HAVE_ACLV_H
+ if (from_mode)
+ ret = context_aclv_from_mode (ctx);
+
+ if (ret == 0 && ctx->aclv_count > 0)
+ {
+ ret = acl ((char *) name, ACL_SET, ctx->aclv_count, ctx->aclv_entries);
+ if (ret < 0)
+ {
+ if ((errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+ && (from_mode || !aclv_nontrivial (ctx->aclv_count, ctx->aclv_entries)))
+ ret = 0;
+ }
+ else
+ *acls_set = true;
+ }
+# endif
+
+# elif HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
+
+ /* TODO: Implement setting ACLs once get_permissions() reads them. */
+
+ if (from_mode)
+ ret = set_acls_from_mode (name, desc, mode, must_chmod);
+
+# elif HAVE_STATACL /* older AIX */
+
+ if (from_mode)
+ ret = context_acl_from_mode (ctx);
+
+ if (ret == 0 && ctx->have_u)
+ {
+ if (desc != -1)
+ ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
+ else
+ ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len);
+ if (ret < 0)
+ {
+ if (errno == ENOSYS && from_mode)
+ ret = 0;
+ }
+ else
+ *acls_set = true;
+ }
+
+# elif HAVE_ACLSORT /* NonStop Kernel */
+
+ if (from_mode)
+ ret = context_acl_from_mode (ctx);
+
+ if (ret == 0 && ctx->count)
+ {
+ ret = acl ((char *) name, ACL_SET, ctx->count, ctx->entries);
+ if (ret != 0)
+ {
+ if (!acl_nontrivial (ctx->count, ctx->entries))
+ ret = 0;
+ }
+ else
+ *acls_set = true;
+ }
+
+# else /* No ACLs */
+
+ /* Nothing to do. */
+
# endif
-#else /* !USE_ACL */
- return chmod_or_fchmod (name, desc, mode);
+
+ return ret;
+}
#endif
+
+/* If DESC is a valid file descriptor use fchmod to change the
+ file's mode to MODE on systems that have fchmod. On systems
+ that don't have fchmod and if DESC is invalid, use chmod on
+ NAME instead.
+ Return 0 if successful. Return -1 and set errno upon failure. */
+
+int
+chmod_or_fchmod (const char *name, int desc, mode_t mode)
+{
+ if (HAVE_FCHMOD && desc != -1)
+ return fchmod (desc, mode);
+ else
+ return chmod (name, mode);
}
-/* As with qset_acl, but also output a diagnostic on failure. */
+/* Set the permissions in CTX on a file. If DESC is a valid file descriptor,
+ use file descriptor operations, else use filename based operations on NAME.
+ If access control lists are not available, fchmod the target file to the
+ mode in CTX. Also sets the non-permission bits of the destination file
+ (S_ISUID, S_ISGID, S_ISVTX) to those from the mode in CTX if any are set.
+ Return 0 if successful. Return -1 and set errno upon failure. */
int
-set_acl (char const *name, int desc, mode_t mode)
+set_permissions (struct permission_context *ctx, const char *name, int desc)
{
- int ret = qset_acl (name, desc, mode);
- if (ret != 0)
- error (0, errno, _("setting permissions for %s"), quote (name));
+ bool acls_set _GL_UNUSED = false;
+ bool early_chmod;
+ bool must_chmod = false;
+ int ret = 0;
+
+#if USE_ACL
+# if HAVE_STATACL
+ /* older AIX */
+ /* There is no need to call chmod_or_fchmod, since the mode
+ bits S_ISUID, S_ISGID, S_ISVTX are also stored in the ACL. */
+
+ early_chmod = false;
+# else
+ /* All other platforms */
+ /* On Cygwin, it is necessary to call chmod before acl, because
+ chmod can change the contents of the ACL (in ways that don't
+ change the allowed accesses, but still visible). */
+
+ early_chmod = (! MODE_INSIDE_ACL || (ctx->mode & (S_ISUID | S_ISGID | S_ISVTX)));
+# endif
+#else
+ /* No ACLs */
+
+ early_chmod = true;
+#endif
+
+ if (early_chmod)
+ {
+ ret = chmod_or_fchmod (name, desc, ctx->mode);
+ if (ret != 0)
+ return -1;
+ }
+
+#if USE_ACL
+ ret = set_acls (ctx, name, desc, false, &must_chmod, &acls_set);
+ if (! acls_set)
+ {
+ int saved_errno = ret ? errno : 0;
+
+ /* If we can't set an acl which we expect to be able to set, try setting
+ the permissions to ctx->mode. Due to possible inherited permissions,
+ we cannot simply chmod. */
+
+ ret = set_acls (ctx, name, desc, true, &must_chmod, &acls_set);
+ if (! acls_set)
+ must_chmod = true;
+
+ if (saved_errno)
+ {
+ errno = saved_errno;
+ ret = -1;
+ }
+ }
+#endif
+
+ if (must_chmod && ! early_chmod)
+ {
+ int saved_errno = ret ? errno : 0;
+
+ ret = chmod_or_fchmod (name, desc, ctx->mode);
+
+ if (saved_errno)
+ {
+ errno = saved_errno;
+ ret = -1;
+ }
+ }
+
return ret;
}
diff --git a/lib/stat.c b/lib/stat.c
index c0bcb88..62e9e0b 100644
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -1,5 +1,5 @@
/* Work around platform bugs in stat.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
new file mode 100644
index 0000000..12f8a15
--- /dev/null
+++ b/lib/stdalign.in.h
@@ -0,0 +1,121 @@
+/* A substitute for ISO C11 <stdalign.h>.
+
+ Copyright 2011-2016 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, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Bruno Haible. */
+
+#ifndef _GL_STDALIGN_H
+#define _GL_STDALIGN_H
+
+/* ISO C11 <stdalign.h> for platforms that lack it.
+
+ References:
+ ISO C11 (latest free draft
+ <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
+ sections 6.5.3.4, 6.7.5, 7.15.
+ C++11 (latest free draft
+ <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
+ section 18.10. */
+
+/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
+ requirement of a structure member (i.e., slot or field) that is of
+ type TYPE, as an integer constant expression.
+
+ This differs from GCC's __alignof__ operator, which can yield a
+ better-performing alignment for an object of that type. For
+ example, on x86 with GCC, __alignof__ (double) and __alignof__
+ (long long) are 8, whereas alignof (double) and alignof (long long)
+ are 4 unless the option '-malign-double' is used.
+
+ The result cannot be used as a value for an 'enum' constant, if you
+ want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
+
+ Include <stddef.h> for offsetof. */
+#include <stddef.h>
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ standard headers, defines conflicting implementations of _Alignas
+ and _Alignof that are no better than ours; override them. */
+#undef _Alignas
+#undef _Alignof
+
+/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
+ <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
+#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
+ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9)))
+# ifdef __cplusplus
+# if 201103 <= __cplusplus
+# define _Alignof(type) alignof (type)
+# else
+ template <class __t> struct __alignof_helper { char __a; __t __b; };
+# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# endif
+# else
+# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+# endif
+#endif
+#if ! (defined __cplusplus && 201103 <= __cplusplus)
+# define alignof _Alignof
+#endif
+#define __alignof_is_defined 1
+
+/* alignas (A), also known as _Alignas (A), aligns a variable or type
+ to the alignment A, where A is an integer constant expression. For
+ example:
+
+ int alignas (8) foo;
+ struct s { int a; int alignas (8) bar; };
+
+ aligns the address of FOO and the offset of BAR to be multiples of 8.
+
+ A should be a power of two that is at least the type's alignment
+ and at most the implementation's alignment limit. This limit is
+ 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
+ to MSVC through at least version 10.0, A should be an integer
+ constant, as MSVC does not support expressions such as 1 << 3.
+ To be portable to Sun C 5.11, do not align auto variables to
+ anything stricter than their default alignment.
+
+ The following C11 requirements are not supported here:
+
+ - If A is zero, alignas has no effect.
+ - alignas can be used multiple times; the strictest one wins.
+ - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
+
+ */
+
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# if defined __cplusplus && 201103 <= __cplusplus
+# define _Alignas(a) alignas (a)
+# elif ((defined __APPLE__ && defined __MACH__ \
+ ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
+ : __GNUC__) \
+ || 061200 <= __HP_cc || 061200 <= __HP_aCC \
+ || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__)
+# define _Alignas(a) __attribute__ ((__aligned__ (a)))
+# elif 1300 <= _MSC_VER
+# define _Alignas(a) __declspec (align (a))
+# endif
+#endif
+#if ((defined _Alignas && ! (defined __cplusplus && 201103 <= __cplusplus)) \
+ || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
+# define alignas _Alignas
+#endif
+#if defined alignas || (defined __cplusplus && 201103 <= __cplusplus)
+# define __alignas_is_defined 1
+#endif
+
+#endif /* _GL_STDALIGN_H */
diff --git a/lib/stdarg.in.h b/lib/stdarg.in.h
index 3659174..63371e2 100644
--- a/lib/stdarg.in.h
+++ b/lib/stdarg.in.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for and wrapper around <stdarg.h>.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index 361987d..7ecf203 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -1,6 +1,4 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2016 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
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 15024c4..f4c4a10 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
- Copyright (C) 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2009-2016 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
@@ -41,7 +39,6 @@
# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
# ifdef __need_wint_t
-# undef _@GUARD_PREFIX@_STDDEF_H
# define _GL_STDDEF_WINT_T
# endif
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
@@ -56,33 +53,58 @@
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
-# ifndef _@GUARD_PREFIX@_STDDEF_H
-# define _@GUARD_PREFIX@_STDDEF_H
-
/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
-#if @REPLACE_NULL@
-# undef NULL
-# ifdef __cplusplus
+# if (@REPLACE_NULL@ \
+ && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
+# 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
+# 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
+# define NULL __null
+# else
+# define NULL 0L
+# endif
+# else
+# define NULL ((void *) 0)
+# endif
# endif
-# else
-# define NULL ((void *) 0)
-# endif
-#endif
+
+# ifndef _@GUARD_PREFIX@_STDDEF_H
+# define _@GUARD_PREFIX@_STDDEF_H
/* Some platforms lack wchar_t. */
#if !@HAVE_WCHAR_T@
# define wchar_t int
#endif
+/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
+ a hack in case the configure-time test was done with g++ even though
+ we are currently compiling with gcc. */
+#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
+/* On the x86, the maximum storage alignment of double, long, etc. is 4,
+ but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
+ and the C11 standard allows this. Work around this problem by
+ using __alignof__ (which returns 8 for double) rather than _Alignof
+ (which returns 4), and align each union member accordingly. */
+# ifdef __GNUC__
+# define _GL_STDDEF_ALIGNAS(type) \
+ __attribute__ ((__aligned__ (__alignof__ (type))))
+# else
+# define _GL_STDDEF_ALIGNAS(type) /* */
+# endif
+typedef union
+{
+ char *__p _GL_STDDEF_ALIGNAS (char *);
+ double __d _GL_STDDEF_ALIGNAS (double);
+ long double __ld _GL_STDDEF_ALIGNAS (long double);
+ long int __i _GL_STDDEF_ALIGNAS (long int);
+} max_align_t;
+#endif
+
# endif /* _@GUARD_PREFIX@_STDDEF_H */
# endif /* _@GUARD_PREFIX@_STDDEF_H */
#endif /* __need_XXX */
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 688b183..566f8e8 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -1,6 +1,4 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Copyright (C) 2001-2002, 2004-2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2016 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
@@ -40,8 +38,7 @@
other system header files; just include the system's <stdint.h>.
Ideally we should test __BIONIC__ here, but it is only defined after
<sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
-#if defined __ANDROID__ \
- && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_
+#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
# @INCLUDE_NEXT@ @NEXT_STDINT_H@
#else
@@ -82,54 +79,60 @@
#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
#define _@GUARD_PREFIX@_STDINT_H
+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+ LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
+#include <limits.h>
+
+/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
+ wint_t. */
+#if @GNULIB_OVERRIDES_WINT_T@
+# undef WINT_MIN
+# undef WINT_MAX
+# define WINT_MIN 0x0U
+# define WINT_MAX 0xffffffffU
+#endif
+
+#if ! @HAVE_C99_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.
Mac OS 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 SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
- LONG_MIN, LONG_MAX, ULONG_MAX. */
-#include <limits.h>
+# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+# include <sys/types.h>
+# endif
-#if @HAVE_INTTYPES_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@
+# 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
+# include <sys/inttypes.h>
+# endif
-#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
+# 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
+# include <sys/bitypes.h>
+# endif
-#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
+# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
/* Minimum and maximum values for an 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_MIN(signed, bits, zero) \
+ ((signed) ? ~ _STDINT_MAX (signed, bits, zero) : (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)
+# define _STDINT_MAX(signed, bits, zero) \
+ (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
#if !GNULIB_defined_stdint_types
@@ -138,26 +141,26 @@
/* Here we assume a standard architecture where the hardware integer
types have 8, 16, 32, optionally 64 bits. */
-#undef int8_t
-#undef uint8_t
+# 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
+# define int8_t gl_int8_t
+# define uint8_t gl_uint8_t
-#undef int16_t
-#undef uint16_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
+# define int16_t gl_int16_t
+# define uint16_t gl_uint16_t
-#undef int32_t
-#undef uint32_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
+# 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
@@ -165,54 +168,54 @@ typedef unsigned int gl_uint32_t;
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
+# 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
+# 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
+# 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
+# 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
+# define int64_t gl_int64_t
+# define GL_INT64_T
+# endif
# 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
+# ifdef UINT64_MAX
# define GL_UINT64_T
-# elif defined _MSC_VER
-# undef 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
+# 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
+# define uint64_t gl_uint64_t
+# define GL_UINT64_T
+# endif
# endif
-#endif
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
-#define _UINT8_T
-#define _UINT32_T
-#define _UINT64_T
+# define _UINT8_T
+# define _UINT32_T
+# define _UINT64_T
/* 7.18.1.2. Minimum-width integer types */
@@ -221,26 +224,26 @@ typedef unsigned long long int gl_uint64_t;
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
+# 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 */
@@ -253,50 +256,55 @@ typedef unsigned long long int gl_uint64_t;
uses types consistent with glibc, as that lessens the chance of
incompatibility with older GNU hosts. */
-#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
+# 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 signed char gl_int_fast8_t;
typedef unsigned char gl_uint_fast8_t;
-#ifdef __sun
+# ifdef __sun
/* Define types compatible with SunOS 5.10, so that code compiled under
earlier SunOS versions works with code compiled under SunOS 5.10. */
typedef int gl_int_fast32_t;
typedef unsigned int gl_uint_fast32_t;
-#else
+# else
typedef long int gl_int_fast32_t;
typedef unsigned long int gl_uint_fast32_t;
-#endif
+# endif
typedef gl_int_fast32_t gl_int_fast16_t;
typedef gl_uint_fast32_t gl_uint_fast16_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
+# 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
+/* kLIBC's stdint.h defines _INTPTR_T_DECLARED and needs its own
+ definitions of intptr_t and uintptr_t (which use int and unsigned)
+ to avoid clashes with declarations of system functions like sbrk. */
+# ifndef _INTPTR_T_DECLARED
+# 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
+# define intptr_t gl_intptr_t
+# define uintptr_t gl_uintptr_t
+# endif
/* 7.18.1.5. Greatest-width integer types */
@@ -307,33 +315,33 @@ typedef unsigned long int gl_uintptr_t;
similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
assuming one type where another is used by the system. */
-#ifndef INTMAX_MAX
-# undef INTMAX_C
-# undef intmax_t
-# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
+# ifndef INTMAX_MAX
+# undef INTMAX_C
+# 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
+# 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
+# define intmax_t gl_intmax_t
+# endif
# endif
-#endif
-#ifndef UINTMAX_MAX
-# undef UINTMAX_C
-# undef uintmax_t
-# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
+# ifndef UINTMAX_MAX
+# undef UINTMAX_C
+# 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
+# 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
+# define uintmax_t gl_uintmax_t
+# endif
# endif
-#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
@@ -341,8 +349,8 @@ typedef unsigned long int gl_uintmax_t;
typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
? 1 : -1];
-#define GNULIB_defined_stdint_types 1
-#endif /* !GNULIB_defined_stdint_types */
+# define GNULIB_defined_stdint_types 1
+# endif /* !GNULIB_defined_stdint_types */
/* 7.18.2. Limits of specified-width integer types */
@@ -351,37 +359,37 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
/* 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
+# 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
+# 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
+# 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 */
@@ -389,38 +397,38 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
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 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
+# 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 */
@@ -428,117 +436,117 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
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 SCHAR_MIN
-#define INT_FAST8_MAX SCHAR_MAX
-#define UINT_FAST8_MAX UCHAR_MAX
-
-#undef INT_FAST16_MIN
-#undef INT_FAST16_MAX
-#undef UINT_FAST16_MAX
-#define INT_FAST16_MIN INT_FAST32_MIN
-#define INT_FAST16_MAX INT_FAST32_MAX
-#define UINT_FAST16_MAX UINT_FAST32_MAX
-
-#undef INT_FAST32_MIN
-#undef INT_FAST32_MAX
-#undef UINT_FAST32_MAX
-#ifdef __sun
-# define INT_FAST32_MIN INT_MIN
-# define INT_FAST32_MAX INT_MAX
-# define UINT_FAST32_MAX UINT_MAX
-#else
-# define INT_FAST32_MIN LONG_MIN
-# define INT_FAST32_MAX LONG_MAX
-# define UINT_FAST32_MAX ULONG_MAX
-#endif
+# undef INT_FAST8_MIN
+# undef INT_FAST8_MAX
+# undef UINT_FAST8_MAX
+# define INT_FAST8_MIN SCHAR_MIN
+# define INT_FAST8_MAX SCHAR_MAX
+# define UINT_FAST8_MAX UCHAR_MAX
+
+# undef INT_FAST16_MIN
+# undef INT_FAST16_MAX
+# undef UINT_FAST16_MAX
+# define INT_FAST16_MIN INT_FAST32_MIN
+# define INT_FAST16_MAX INT_FAST32_MAX
+# define UINT_FAST16_MAX UINT_FAST32_MAX
+
+# undef INT_FAST32_MIN
+# undef INT_FAST32_MAX
+# undef UINT_FAST32_MAX
+# ifdef __sun
+# define INT_FAST32_MIN INT_MIN
+# define INT_FAST32_MAX INT_MAX
+# define UINT_FAST32_MAX UINT_MAX
+# else
+# define INT_FAST32_MIN LONG_MIN
+# define INT_FAST32_MAX LONG_MAX
+# define UINT_FAST32_MAX ULONG_MAX
+# endif
-#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 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
+# 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
+# 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 */
-#ifndef INTMAX_MAX
-# undef INTMAX_MIN
-# ifdef INT64_MAX
-# define INTMAX_MIN INT64_MIN
-# define INTMAX_MAX INT64_MAX
-# else
-# define INTMAX_MIN INT32_MIN
-# define INTMAX_MAX INT32_MAX
+# ifndef INTMAX_MAX
+# undef INTMAX_MIN
+# 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
# endif
-#endif
-#ifndef UINTMAX_MAX
-# ifdef UINT64_MAX
-# define UINTMAX_MAX UINT64_MAX
-# else
-# define UINTMAX_MAX UINT32_MAX
+# ifndef UINTMAX_MAX
+# ifdef UINT64_MAX
+# define UINTMAX_MAX UINT64_MAX
+# else
+# define UINTMAX_MAX UINT32_MAX
+# endif
# endif
-#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)
+# 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, 32, 0)
-# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
-# endif
-#else
-# define PTRDIFF_MIN \
+# define PTRDIFF_MIN \
_STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
-# define PTRDIFF_MAX \
+# define PTRDIFF_MAX \
_STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
-#endif
+# endif
/* sig_atomic_t limits */
-#undef SIG_ATOMIC_MIN
-#undef SIG_ATOMIC_MAX
-#define SIG_ATOMIC_MIN \
+# 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 \
+# 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)
+# 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, 32, 0ul)
+# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
# endif
-#else
-# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
-#endif
/* wchar_t limits */
/* Get WCHAR_MIN, WCHAR_MAX.
@@ -546,29 +554,29 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
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)
+# 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 \
+# 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 \
+# 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 \
+# 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 \
+# define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
/* 7.18.4. Macros for integer constants */
@@ -579,59 +587,120 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
/* 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
+# 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 */
-#ifndef 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
+# ifndef 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
# endif
-#endif
-#ifndef 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
+# ifndef 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
-#endif
+
+#endif /* !@HAVE_C99_STDINT_H@ */
+
+/* Macros specified by ISO/IEC TS 18661-1:2014. */
+
+#if (!defined UINTMAX_WIDTH \
+ && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
+# ifdef INT8_MAX
+# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
+# endif
+# ifdef UINT8_MAX
+# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
+# endif
+# ifdef INT16_MAX
+# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
+# endif
+# ifdef UINT16_MAX
+# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
+# endif
+# ifdef INT32_MAX
+# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
+# endif
+# ifdef UINT32_MAX
+# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
+# endif
+# ifdef INT64_MAX
+# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
+# endif
+# ifdef UINT64_MAX
+# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
+# endif
+# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
+# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
+# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
+# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
+# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
+# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
+# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
+# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
+# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
+# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
+# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
+# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
+# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
+# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
+# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
+# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
+# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
+# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
+# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
+# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
+# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
+# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
+# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
+# ifdef WINT_MAX
+# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
+# endif
+# ifdef SIG_ATOMIC_MAX
+# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
+# endif
+#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
#endif /* _@GUARD_PREFIX@_STDINT_H */
#endif /* !(defined __ANDROID__ && ...) */
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 920b4d4..766d693 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2008, 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008, 2010-2016 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
@@ -28,7 +28,8 @@
#include <errno.h> /* For detecting Plan9. */
-#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
+#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
+ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
# if defined __DragonFly__ /* DragonFly */
/* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
@@ -57,7 +58,7 @@
# define fp_ fp
# endif
-# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ /* NetBSD >= 1.5ZA, OpenBSD */
+# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __ANDROID__ /* NetBSD >= 1.5ZA, OpenBSD, Android */
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
struct __sfileext
@@ -66,7 +67,7 @@
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
+# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin, Android */
# define fp_ub fp_->_ub
# endif
@@ -109,4 +110,31 @@
# define _flag __flag
# endif
+#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ /* newer Windows with MSVC */
+
+/* <stdio.h> does not define the innards of FILE any more. */
+# define WINDOWS_OPAQUE_FILE
+
+struct _gl_real_FILE
+{
+ /* Note: Compared to older Windows and to mingw, it has the fields
+ _base and _cnt swapped. */
+ unsigned char *_ptr;
+ unsigned char *_base;
+ int _cnt;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+};
+# define fp_ ((struct _gl_real_FILE *) fp)
+
+/* These values were determined by a program similar to the one at
+ <http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */
+# define _IOREAD 0x1
+# define _IOWRT 0x2
+# define _IORW 0x4
+# define _IOEOF 0x8
+# define _IOERR 0x10
+
#endif
diff --git a/lib/stdio.c b/lib/stdio.c
deleted file mode 100644
index e6ed829..0000000
--- a/lib/stdio.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <config.h>
-#define _GL_STDIO_INLINE _GL_EXTERN_INLINE
-#include "stdio.h"
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index d054394..5727452 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A GNU-like <stdio.h>.
- Copyright (C) 2004, 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007-2016 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
@@ -48,11 +46,6 @@
#ifndef _@GUARD_PREFIX@_STDIO_H
#define _@GUARD_PREFIX@_STDIO_H
-_GL_INLINE_HEADER_BEGIN
-#ifndef _GL_STDIO_INLINE
-# define _GL_STDIO_INLINE _GL_INLINE
-#endif
-
/* Get va_list. Needed on many systems, including glibc 2.8. */
#include <stdarg.h>
@@ -91,8 +84,13 @@ _GL_INLINE_HEADER_BEGIN
except that it indicates to GCC that the supported format string directives
are the ones of the system printf(), rather than the ones standardized by
ISO C99 and POSIX. */
-#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
+#if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
+ _GL_ATTRIBUTE_FORMAT_PRINTF (formatstring_parameter, first_argument)
+#else
+# define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
/* _GL_ATTRIBUTE_FORMAT_SCANF
indicates to GCC that the function takes a format string and arguments,
@@ -120,6 +118,26 @@ _GL_INLINE_HEADER_BEGIN
# include <unistd.h>
#endif
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
+ it before we #define perror rpl_perror. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
+ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
+ it before we #define remove rpl_remove. */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
+ it before we #define rename rpl_rename. */
+/* But in any case avoid namespace pollution on glibc systems. */
+#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
+ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+ && ! defined __GLIBC__
+# include <io.h>
+#endif
+
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -131,6 +149,15 @@ _GL_INLINE_HEADER_BEGIN
#define _GL_STDIO_STRINGIZE(token) #token
#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
+/* When also using extern inline, suppress the use of static inline in
+ standard headers of problematic Apple configurations, as Libc at
+ least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
+ <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+ Perhaps Apple will fix this some day. */
+#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
+ && defined __GNUC__ && defined __STDC__)
+# undef putc_unlocked
+#endif
#if @GNULIB_DPRINTF@
# if @REPLACE_DPRINTF@
@@ -582,21 +609,27 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
_GL_CXXALIAS_SYS (fwrite, size_t,
(const void *ptr, size_t s, size_t n, FILE *stream));
-/* Work around glibc bug 11959
+/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
which sometimes causes an unwanted diagnostic for fwrite calls.
- This affects only function declaration attributes, so it's not
- needed for C++. */
-# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
-_GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4))
-rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
-{
- size_t r = fwrite (ptr, s, n, stream);
- (void) r;
- return r;
-}
+ This affects only function declaration attributes under certain
+ versions of gcc and clang, and is not needed for C++. */
+# if (0 < __USE_FORTIFY_LEVEL \
+ && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
+ && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
+ && !defined __cplusplus)
# undef fwrite
+# undef fwrite_unlocked
+extern size_t __REDIRECT (rpl_fwrite,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite);
+extern size_t __REDIRECT (rpl_fwrite_unlocked,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite_unlocked);
# define fwrite rpl_fwrite
+# define fwrite_unlocked rpl_fwrite_unlocked
# endif
# endif
_GL_CXXALIASWARN (fwrite);
@@ -710,11 +743,10 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
so any use of gets warrants an unconditional warning; besides, C11
removed it. */
#undef gets
-#if HAVE_RAW_DECL_GETS
+#if HAVE_RAW_DECL_GETS && !defined __cplusplus
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
-
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
struct obstack;
/* Grow an obstack with formatted output. Return the number of
@@ -1340,8 +1372,6 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
-_GL_INLINE_HEADER_END
-
#endif /* _@GUARD_PREFIX@_STDIO_H */
#endif /* _@GUARD_PREFIX@_STDIO_H */
#endif
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 6555840..db3253b 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdlib.h>.
- Copyright (C) 1995, 2001-2004, 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2001-2004, 2006-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,8 +20,9 @@
#endif
@PRAGMA_COLUMNS@
-#if defined __need_malloc_and_calloc
-/* Special invocation convention inside glibc header files. */
+#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
+/* Special invocation conventions inside some gnulib header files,
+ and inside some glibc header files, respectively. */
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
@@ -519,6 +520,44 @@ _GL_CXXALIAS_SYS (putenv, int, (char *string));
_GL_CXXALIASWARN (putenv);
#endif
+#if @GNULIB_QSORT_R@
+/* Sort an array of NMEMB elements, starting at address BASE, each element
+ occupying SIZE bytes, in ascending order according to the comparison
+ function COMPARE. */
+# if @REPLACE_QSORT_R@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef qsort_r
+# define qsort_r rpl_qsort_r
+# endif
+_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg) _GL_ARG_NONNULL ((1, 4)));
+_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg));
+# else
+# if !@HAVE_QSORT_R@
+_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg) _GL_ARG_NONNULL ((1, 4)));
+# endif
+_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
+ int (*compare) (void const *, void const *,
+ void *),
+ void *arg));
+# endif
+_GL_CXXALIASWARN (qsort_r);
+#elif defined GNULIB_POSIXCHECK
+# undef qsort_r
+# if HAVE_RAW_DECL_QSORT_R
+_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
+ "use gnulib module qsort_r for portability");
+# endif
+#endif
+
#if @GNULIB_RANDOM_R@
# if !@HAVE_RANDOM_R@
@@ -766,6 +805,22 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
# endif
#endif
+#if @GNULIB_SECURE_GETENV@
+/* Look up NAME in the environment, returning 0 in insecure situations. */
+# if !@HAVE_SECURE_GETENV@
+_GL_FUNCDECL_SYS (secure_getenv, char *,
+ (char const *name) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
+_GL_CXXALIASWARN (secure_getenv);
+#elif defined GNULIB_POSIXCHECK
+# undef secure_getenv
+# if HAVE_RAW_DECL_SECURE_GETENV
+_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
+ "use gnulib module secure_getenv for portability");
+# endif
+#endif
+
#if @GNULIB_SETENV@
/* Set NAME to VALUE in the environment.
If REPLACE is nonzero, overwrite an existing value. */
diff --git a/lib/streq.h b/lib/streq.h
index 3e83fb6..234f075 100644
--- a/lib/streq.h
+++ b/lib/streq.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Optimized string comparison.
- Copyright (C) 2001-2002, 2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2016 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
diff --git a/lib/strerror-override.c b/lib/strerror-override.c
index f7cac65..9bc9b18 100644
--- a/lib/strerror-override.c
+++ b/lib/strerror-override.c
@@ -1,6 +1,6 @@
/* strerror-override.c --- POSIX compatible system error routine
- Copyright (C) 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/strerror-override.h b/lib/strerror-override.h
index 6468681..5264fd5 100644
--- a/lib/strerror-override.h
+++ b/lib/strerror-override.h
@@ -1,6 +1,6 @@
/* strerror-override.h --- POSIX compatible system error routine
- Copyright (C) 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 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
@@ -48,7 +48,7 @@
|| GNULIB_defined_EOWNERDEAD \
|| GNULIB_defined_ENOTRECOVERABLE \
|| GNULIB_defined_EILSEQ
-extern const char *strerror_override (int errnum);
+extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
# else
# define strerror_override(ignored) NULL
# endif
diff --git a/lib/strerror.c b/lib/strerror.c
index 587bd21..8fff3bd 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -1,6 +1,6 @@
/* strerror.c --- POSIX compatible system error routine
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 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
@@ -66,5 +66,6 @@ strerror (int n)
if (sizeof buf <= len)
abort ();
- return memcpy (buf, msg, len + 1);
+ memcpy (buf, msg, len + 1);
+ return buf;
}
diff --git a/lib/string.in.h b/lib/string.in.h
index 4b5247f..b3213c4 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A GNU-like <string.h>.
- Copyright (C) 1995-1996, 2001-2012 Free Software Foundation, Inc.
+ Copyright (C) 1995-1996, 2001-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,16 +15,32 @@
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 _@GUARD_PREFIX@_STRING_H
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
+#if defined _GL_ALREADY_INCLUDING_STRING_H
+/* Special invocation convention:
+ - On OS X/NetBSD we have a sequence of nested includes
+ <string.h> -> <strings.h> -> "string.h"
+ In this situation system _chk variants due to -D_FORTIFY_SOURCE
+ might be used after any replacements defined here. */
+
+#@INCLUDE_NEXT@ @NEXT_STRING_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_STRING_H
+
+#define _GL_ALREADY_INCLUDING_STRING_H
+
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_STRING_H@
+#undef _GL_ALREADY_INCLUDING_STRING_H
+
#ifndef _@GUARD_PREFIX@_STRING_H
#define _@GUARD_PREFIX@_STRING_H
@@ -402,15 +416,15 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
# undef strndup
# define strndup rpl_strndup
# endif
-_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n)
+_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n)
_GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n));
+_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
# else
# if ! @HAVE_DECL_STRNDUP@
-_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n)
+_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n)
_GL_ARG_NONNULL ((1)));
# endif
-_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n));
+_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
# endif
_GL_CXXALIASWARN (strndup);
#elif defined GNULIB_POSIXCHECK
@@ -430,17 +444,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
# undef strnlen
# define strnlen rpl_strnlen
# endif
-_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
+_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
+_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
# else
# if ! @HAVE_DECL_STRNLEN@
-_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
+_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
_GL_ATTRIBUTE_PURE
_GL_ARG_NONNULL ((1)));
# endif
-_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
+_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
# endif
_GL_CXXALIASWARN (strnlen);
#elif defined GNULIB_POSIXCHECK
@@ -1029,3 +1043,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
#endif /* _@GUARD_PREFIX@_STRING_H */
#endif /* _@GUARD_PREFIX@_STRING_H */
+#endif
diff --git a/lib/stripslash.c b/lib/stripslash.c
index ef458c6..0453e36 100644
--- a/lib/stripslash.c
+++ b/lib/stripslash.c
@@ -1,6 +1,6 @@
/* stripslash.c -- remove redundant trailing slashes from a file name
- Copyright (C) 1990, 2001, 2003-2006, 2009-2012 Free Software Foundation,
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2016 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/strverscmp.c b/lib/strverscmp.c
index 12adb63..22b8505 100644
--- a/lib/strverscmp.c
+++ b/lib/strverscmp.c
@@ -1,23 +1,21 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Compare strings while treating digits characters numerically.
- Copyright (C) 1997, 2000, 2002, 2004, 2006, 2009-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jean-François Bignolles <bignolle@ecoledoc.ibp.fr>, 1997.
- This 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.
+ The GNU C Library 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,
+ The GNU C 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 General Public License for more details.
+ 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/>. */
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#if !_LIBC
# include <config.h>
@@ -28,27 +26,14 @@
/* states: S_N: normal, S_I: comparing integral part, S_F: comparing
fractional parts, S_Z: idem but with leading Zeroes only */
-#define S_N 0x0
-#define S_I 0x4
-#define S_F 0x8
-#define S_Z 0xC
+#define S_N 0x0
+#define S_I 0x3
+#define S_F 0x6
+#define S_Z 0x9
/* result_type: CMP: return diff; LEN: compare using len_diff/diff */
-#define CMP 2
-#define LEN 3
-
-
-/* ISDIGIT differs from isdigit, as follows:
- - Its arg may be any int or unsigned int; it need not be an unsigned char
- or EOF.
- - It's typically faster.
- POSIX says that only '0' through '9' are digits. Prefer ISDIGIT to
- isdigit unless it's important to use the locale's definition
- of "digit" even when the host does not conform to POSIX. */
-#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
-
-#undef __strverscmp
-#undef strverscmp
+#define CMP 2
+#define LEN 3
#ifndef weak_alias
# define __strverscmp strverscmp
@@ -68,30 +53,25 @@ __strverscmp (const char *s1, const char *s2)
int state;
int diff;
- /* Symbol(s) 0 [1-9] others (padding)
- Transition (10) 0 (01) d (00) x (11) - */
- static const unsigned int next_state[] =
+ /* Symbol(s) 0 [1-9] others
+ Transition (10) 0 (01) d (00) x */
+ static const unsigned char next_state[] =
{
- /* state x d 0 - */
- /* S_N */ S_N, S_I, S_Z, S_N,
- /* S_I */ S_N, S_I, S_I, S_I,
- /* S_F */ S_N, S_F, S_F, S_F,
- /* S_Z */ S_N, S_F, S_Z, S_Z
+ /* state x d 0 */
+ /* S_N */ S_N, S_I, S_Z,
+ /* S_I */ S_N, S_I, S_I,
+ /* S_F */ S_N, S_F, S_F,
+ /* S_Z */ S_N, S_F, S_Z
};
- static const int result_type[] =
+ static const signed char result_type[] =
{
- /* state x/x x/d x/0 x/- d/x d/d d/0 d/-
- 0/x 0/d 0/0 0/- -/x -/d -/0 -/- */
-
- /* S_N */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
- CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
- /* S_I */ CMP, -1, -1, CMP, 1, LEN, LEN, CMP,
- 1, LEN, LEN, CMP, CMP, CMP, CMP, CMP,
- /* S_F */ CMP, CMP, CMP, CMP, CMP, LEN, CMP, CMP,
- CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
- /* S_Z */ CMP, 1, 1, CMP, -1, CMP, CMP, CMP,
- -1, CMP, CMP, CMP
+ /* state x/x x/d x/0 d/x d/d d/0 0/x 0/d 0/0 */
+
+ /* S_N */ CMP, CMP, CMP, CMP, LEN, CMP, CMP, CMP, CMP,
+ /* S_I */ CMP, -1, -1, +1, LEN, LEN, +1, LEN, LEN,
+ /* S_F */ CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP, CMP,
+ /* S_Z */ CMP, +1, +1, -1, CMP, CMP, -1, CMP, CMP
};
if (p1 == p2)
@@ -100,17 +80,20 @@ __strverscmp (const char *s1, const char *s2)
c1 = *p1++;
c2 = *p2++;
/* Hint: '0' is a digit too. */
- state = S_N | ((c1 == '0') + (ISDIGIT (c1) != 0));
+ state = S_N + ((c1 == '0') + (isdigit (c1) != 0));
- while ((diff = c1 - c2) == 0 && c1 != '\0')
+ while ((diff = c1 - c2) == 0)
{
+ if (c1 == '\0')
+ return diff;
+
state = next_state[state];
c1 = *p1++;
c2 = *p2++;
- state |= (c1 == '0') + (ISDIGIT (c1) != 0);
+ state += (c1 == '0') + (isdigit (c1) != 0);
}
- state = result_type[state << 2 | ((c2 == '0') + (ISDIGIT (c2) != 0))];
+ state = result_type[state * 3 + (((c2 == '0') + (isdigit (c2) != 0)))];
switch (state)
{
@@ -118,16 +101,17 @@ __strverscmp (const char *s1, const char *s2)
return diff;
case LEN:
- while (ISDIGIT (*p1++))
- if (!ISDIGIT (*p2++))
+ while (isdigit (*p1++))
+ if (!isdigit (*p2++))
return 1;
- return ISDIGIT (*p2) ? -1 : diff;
+ return isdigit (*p2) ? -1 : diff;
default:
return state;
}
}
#ifdef weak_alias
+libc_hidden_def (__strverscmp)
weak_alias (__strverscmp, strverscmp)
#endif
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 4646d79..72d9537 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Provide a more complete sys/stat header file.
- Copyright (C) 2005-2012 Free Software Foundation, Inc.
+ Copyright (C) 2005-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index 56c5447..d535a6a 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Provide a more complete sys/time.h.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,37 +17,43 @@
/* Written by Paul Eggert. */
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
+
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
-#if defined _@GUARD_PREFIX@_SYS_TIME_H
-
-/* Simply delegate to the system's header, without adding anything. */
-# if @HAVE_SYS_TIME_H@
-# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-# endif
-
+/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
+ recursively via <sys/select.h>.
+ Simply delegate to the system's header in this case; it is a no-op.
+ Without this extra ifdef, the C++ gettimeofday declaration below
+ would be a forward declaration in gnulib's nested <sys/time.h>. */
+#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
#else
-# define _@GUARD_PREFIX@_SYS_TIME_H
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_SYS_TIME_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_SYS_TIME_H
+#define _@GUARD_PREFIX@_SYS_TIME_H
-# if @HAVE_SYS_TIME_H@
-# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-# else
-# include <time.h>
-# endif
+#if ! @HAVE_SYS_TIME_H@
+# include <time.h>
+#endif
/* On native Windows with MSVC, get the 'struct timeval' type.
Also, on native Windows with a 64-bit time_t, where we are overriding the
'struct timeval' type, get all declarations of system functions whose
signature contains 'struct timeval'. */
-# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
-# define _GL_INCLUDING_WINSOCK2_H
-# include <winsock2.h>
-# undef _GL_INCLUDING_WINSOCK2_H
-# endif
+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
+# define _GL_INCLUDING_WINSOCK2_H
+# include <winsock2.h>
+# undef _GL_INCLUDING_WINSOCK2_H
+#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -57,112 +61,119 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-# ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
-# endif
+#endif
-# if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
+#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
-# if @REPLACE_STRUCT_TIMEVAL@
-# define timeval rpl_timeval
-# endif
+# if @REPLACE_STRUCT_TIMEVAL@
+# define timeval rpl_timeval
+# endif
-# if !GNULIB_defined_struct_timeval
+# if !GNULIB_defined_struct_timeval
struct timeval
{
time_t tv_sec;
long int tv_usec;
};
-# define GNULIB_defined_struct_timeval 1
-# endif
-
+# define GNULIB_defined_struct_timeval 1
# endif
-# ifdef __cplusplus
+#endif
+
+#ifdef __cplusplus
}
-# endif
+#endif
-# if @GNULIB_GETTIMEOFDAY@
-# if @REPLACE_GETTIMEOFDAY@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
-# endif
+#if @GNULIB_GETTIMEOFDAY@
+# if @REPLACE_GETTIMEOFDAY@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gettimeofday
+# define gettimeofday rpl_gettimeofday
+# endif
_GL_FUNCDECL_RPL (gettimeofday, int,
(struct timeval *restrict, void *restrict)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (gettimeofday, int,
(struct timeval *restrict, void *restrict));
-# else
-# if !@HAVE_GETTIMEOFDAY@
+# else
+# if !@HAVE_GETTIMEOFDAY@
_GL_FUNCDECL_SYS (gettimeofday, int,
(struct timeval *restrict, void *restrict)
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
/* Need to cast, because on glibc systems, by default, the second argument is
struct timezone *. */
_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
(struct timeval *restrict, void *restrict));
-# endif
+# endif
_GL_CXXALIASWARN (gettimeofday);
-# elif defined GNULIB_POSIXCHECK
-# undef gettimeofday
-# if HAVE_RAW_DECL_GETTIMEOFDAY
+# if defined __cplusplus && defined GNULIB_NAMESPACE
+namespace GNULIB_NAMESPACE {
+ typedef ::timeval
+#undef timeval
+ timeval;
+}
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef gettimeofday
+# if HAVE_RAW_DECL_GETTIMEOFDAY
_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
"use gnulib module gettimeofday for portability");
-# endif
# endif
+#endif
/* Hide some function declarations from <winsock2.h>. */
-# if defined _MSC_VER && @HAVE_WINSOCK2_H@
-# if !defined _@GUARD_PREFIX@_UNISTD_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef close
-# define close close_used_without_including_unistd_h
-# else
+#if defined _MSC_VER && @HAVE_WINSOCK2_H@
+# if !defined _@GUARD_PREFIX@_UNISTD_H
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef close
+# define close close_used_without_including_unistd_h
+# else
_GL_WARN_ON_USE (close,
"close() used without including <unistd.h>");
-# endif
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef gethostname
-# define gethostname gethostname_used_without_including_unistd_h
-# else
+# endif
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gethostname
+# define gethostname gethostname_used_without_including_unistd_h
+# else
_GL_WARN_ON_USE (gethostname,
"gethostname() used without including <unistd.h>");
-# endif
# endif
-# if !defined _@GUARD_PREFIX@_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
+# endif
+# if !defined _@GUARD_PREFIX@_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,
@@ -191,17 +202,19 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
"setsockopt() used without including <sys/socket.h>");
_GL_WARN_ON_USE (shutdown,
"shutdown() used without including <sys/socket.h>");
-# endif
# endif
-# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef select
-# define select select_used_without_including_sys_select_h
-# else
+# endif
+# if !defined _@GUARD_PREFIX@_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
#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
+#endif /* _CYGWIN_SYS_TIME_H */
+#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 7d69151..8ab0545 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Provide a more complete sys/types.h.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -25,7 +23,9 @@
#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
/* The include_next requires a split double-inclusion guard. */
+# define _GL_INCLUDING_SYS_TYPES_H
#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
+# undef _GL_INCLUDING_SYS_TYPES_H
#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
#define _@GUARD_PREFIX@_SYS_TYPES_H
diff --git a/lib/tempname.c b/lib/tempname.c
index 26a38ce..b1e9880 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -1,6 +1,6 @@
/* tempname.c - generate the name of a temporary file.
- Copyright (C) 1991-2003, 2005-2007, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1991-2003, 2005-2007, 2009-2016 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
@@ -62,16 +62,14 @@
# define struct_stat64 struct stat64
#else
# define struct_stat64 struct stat
+# define __try_tempname try_tempname
# define __gen_tempname gen_tempname
# define __getpid getpid
# define __gettimeofday gettimeofday
# define __mkdir mkdir
# define __open open
# define __lxstat64(version, file, buf) lstat (file, buf)
-#endif
-
-#if ! (HAVE___SECURE_GETENV || _LIBC)
-# define __secure_getenv getenv
+# define __secure_getenv secure_getenv
#endif
#ifdef _LIBC
@@ -179,21 +177,9 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-/* Generate a temporary file name based on TMPL. TMPL must match the
- rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
- The name constructed does not exist at the time of the call to
- __gen_tempname. TMPL is overwritten with the result.
-
- KIND may be one of:
- __GT_NOCREATE: simply verify that the name does not exist
- at the time of the call.
- __GT_FILE: create the file using open(O_CREAT|O_EXCL)
- and return a read-write fd. The file is mode 0600.
- __GT_DIR: create a directory, which will be mode 0700.
-
- We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+__try_tempname (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *))
{
int len;
char *XXXXXX;
@@ -202,7 +188,6 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
unsigned int count;
int fd = -1;
int save_errno = errno;
- struct_stat64 st;
/* A lower bound on the number of temporary files to attempt to
generate. The maximum total number of temporary file names that
@@ -259,41 +244,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
v /= 62;
XXXXXX[5] = letters[v % 62];
- switch (kind)
- {
- case __GT_FILE:
- fd = __open (tmpl,
- (flags & ~O_ACCMODE)
- | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- break;
-
- case __GT_DIR:
- fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
- break;
-
- case __GT_NOCREATE:
- /* This case is backward from the other three. __gen_tempname
- succeeds if __xstat fails because the name does not exist.
- Note the continue to bypass the common logic at the bottom
- of the loop. */
- if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
- {
- if (errno == ENOENT)
- {
- __set_errno (save_errno);
- return 0;
- }
- else
- /* Give up now. */
- return -1;
- }
- continue;
-
- default:
- assert (! "invalid KIND in __gen_tempname");
- abort ();
- }
-
+ fd = tryfunc (tmpl, args);
if (fd >= 0)
{
__set_errno (save_errno);
@@ -307,3 +258,67 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
__set_errno (EEXIST);
return -1;
}
+
+static int
+try_file (char *tmpl, void *flags)
+{
+ int *openflags = flags;
+ return __open (tmpl,
+ (*openflags & ~O_ACCMODE)
+ | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+}
+
+static int
+try_dir (char *tmpl, void *flags _GL_UNUSED)
+{
+ return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
+}
+
+static int
+try_nocreate (char *tmpl, void *flags _GL_UNUSED)
+{
+ struct_stat64 st;
+
+ if (__lxstat64 (_STAT_VER, tmpl, &st) == 0)
+ __set_errno (EEXIST);
+ return errno == ENOENT ? 0 : -1;
+}
+
+/* Generate a temporary file name based on TMPL. TMPL must match the
+ rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
+ The name constructed does not exist at the time of the call to
+ __gen_tempname. TMPL is overwritten with the result.
+
+ KIND may be one of:
+ __GT_NOCREATE: simply verify that the name does not exist
+ at the time of the call.
+ __GT_FILE: create the file using open(O_CREAT|O_EXCL)
+ and return a read-write fd. The file is mode 0600.
+ __GT_DIR: create a directory, which will be mode 0700.
+
+ We use a clever algorithm to get hard-to-predict names. */
+int
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+{
+ int (*tryfunc) (char *, void *);
+
+ switch (kind)
+ {
+ case __GT_FILE:
+ tryfunc = try_file;
+ break;
+
+ case __GT_DIR:
+ tryfunc = try_dir;
+ break;
+
+ case __GT_NOCREATE:
+ tryfunc = try_nocreate;
+ break;
+
+ default:
+ assert (! "invalid KIND in __gen_tempname");
+ abort ();
+ }
+ return __try_tempname (tmpl, suffixlen, &flags, tryfunc);
+}
diff --git a/lib/tempname.h b/lib/tempname.h
index 7972562..be01c51 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -1,6 +1,6 @@
/* Create a temporary file or directory.
- Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2016 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
@@ -32,6 +32,10 @@
# define GT_NOCREATE 2
# endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Generate a temporary file name based on TMPL. TMPL must match the
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
The name constructed does not exist at the time of the call to
@@ -47,4 +51,15 @@
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
+/* Similar to gen_tempname, but TRYFUNC is called for each temporary
+ name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
+ returns with this value. Otherwise, if errno is set to EEXIST, another
+ name is tried, or else TRY_GEN_TEMPNAME returns -1. */
+extern int try_tempname (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *));
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* GL_TEMPNAME_H */
diff --git a/lib/time.in.h b/lib/time.in.h
index 065fbee..865c114 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A more-standard <time.h>.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -24,11 +22,13 @@
/* 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
+ symbols. (However, skip this for MinGW as it treats __need_time_t
+ incompatibly.) 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 \
+#if (((defined __need_time_t || defined __need_clock_t \
+ || defined __need_timespec) \
+ && !defined __MINGW32__) \
|| defined _@GUARD_PREFIX@_TIME_H)
# @INCLUDE_NEXT@ @NEXT_TIME_H@
@@ -50,20 +50,15 @@
/* 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>. */
+ (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 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
+# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
+# include <unistd.h>
# else
# ifdef __cplusplus
@@ -189,6 +184,39 @@ _GL_CXXALIASWARN (gmtime_r);
# endif
# endif
+/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
+ <http://www.opengroup.org/susv3xsh/localtime.html> and
+ <http://www.opengroup.org/susv3xsh/gmtime.html>. */
+# if @GNULIB_GETTIMEOFDAY@
+# if @REPLACE_LOCALTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef localtime
+# define localtime rpl_localtime
+# endif
+_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
+# else
+_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
+# endif
+_GL_CXXALIASWARN (localtime);
+# endif
+
+# if @GNULIB_GETTIMEOFDAY@
+# if @REPLACE_GMTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gmtime
+# define gmtime rpl_gmtime
+# endif
+_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
+# else
+_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
+# endif
+_GL_CXXALIASWARN (gmtime);
+# 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>. */
@@ -205,6 +233,25 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
_GL_CXXALIASWARN (strptime);
# endif
+# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
+typedef struct tm_zone *timezone_t;
+_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
+_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
+_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
+_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
+_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
+ (timezone_t __tz, time_t const *restrict __timer,
+ struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
+ (timezone_t __tz, time_t const *restrict __timer,
+ struct tm *restrict __result));
+_GL_FUNCDECL_SYS (mktime_z, time_t,
+ (timezone_t __tz, struct tm *restrict __result)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_SYS (mktime_z, time_t,
+ (timezone_t __tz, struct tm *restrict __result));
+# endif
+
/* Convert TM to a time_t value, assuming UTC. */
# if @GNULIB_TIMEGM@
# if @REPLACE_TIMEGM@
diff --git a/lib/unistd.c b/lib/unistd.c
index 6c6a8e2..72bad1c 100644
--- a/lib/unistd.c
+++ b/lib/unistd.c
@@ -1,3 +1,4 @@
#include <config.h>
#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
#include "unistd.h"
+typedef int dummy;
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 4cb8e5f..3aa0b03 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1,7 +1,5 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Substitute for and wrapper around <unistd.h>.
- Copyright (C) 2003-2012 Free Software Foundation, Inc.
+ Copyright (C) 2003-2016 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
@@ -16,32 +14,30 @@
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 _@GUARD_PREFIX@_UNISTD_H
+
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
+#ifdef _GL_INCLUDING_UNISTD_H
/* 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
+ - On Mac OS X 10.3.9 we have a sequence of nested includes
+ <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
+ In this situation, the functions are not yet declared, therefore we cannot
+ provide the C++ aliases. */
-/* Normal invocation. */
-#elif !defined _@GUARD_PREFIX@_UNISTD_H
+#@INCLUDE_NEXT@ @NEXT_UNISTD_H@
+
+#else
+/* Normal invocation convention. */
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_UNISTD_H@
+# define _GL_INCLUDING_UNISTD_H
# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
+# undef _GL_INCLUDING_UNISTD_H
#endif
/* Get all possible declarations of gethostname(). */
@@ -59,9 +55,13 @@
#include <stddef.h>
/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
+/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
+ it before we #define unlink rpl_unlink. */
/* 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_UNLINK@ || defined GNULIB_POSIXCHECK) \
+ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) \
|| ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
&& defined __CYGWIN__)) \
&& ! defined __GLIBC__
@@ -79,9 +79,13 @@
/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
<unistd.h>. */
/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
+/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
+ included here. */
/* But avoid namespace pollution on glibc systems. */
-#ifndef __GLIBC__
+#if !defined __GLIBC__ && !defined __osf__
+# define __need_system_stdlib_h
# include <stdlib.h>
+# undef __need_system_stdlib_h
#endif
/* Native Windows platforms declare chdir, getcwd, rmdir in
@@ -126,9 +130,13 @@
/* Get getopt(), optarg, optind, opterr, optopt.
But avoid namespace pollution on glibc systems. */
#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
+# define __need_getopt
# include <getopt.h>
#endif
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef _GL_UNISTD_INLINE
# define _GL_UNISTD_INLINE _GL_INLINE
@@ -397,6 +405,12 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
/* 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 <TargetConditionals.h>
+# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
+# define _GL_USE_CRT_EXTERNS
+# endif
+# endif
+# ifdef _GL_USE_CRT_EXTERNS
# include <crt_externs.h>
# define environ (*_NSGetEnviron ())
# else
@@ -664,10 +678,19 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
#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@
+# if @REPLACE_GETDTABLESIZE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getdtablesize
+# define getdtablesize rpl_getdtablesize
+# endif
+_GL_FUNCDECL_RPL (getdtablesize, int, (void));
+_GL_CXXALIAS_RPL (getdtablesize, int, (void));
+# else
+# if !@HAVE_GETDTABLESIZE@
_GL_FUNCDECL_SYS (getdtablesize, int, (void));
-# endif
+# endif
_GL_CXXALIAS_SYS (getdtablesize, int, (void));
+# endif
_GL_CXXALIASWARN (getdtablesize);
#elif defined GNULIB_POSIXCHECK
# undef getdtablesize
@@ -757,7 +780,7 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
${LOGNAME-$USER} on Unix platforms,
$USERNAME on native Windows platforms.
*/
-# if !@HAVE_GETLOGIN@
+# if !@HAVE_DECL_GETLOGIN@
_GL_FUNCDECL_SYS (getlogin, char *, (void));
# endif
_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -1274,13 +1297,24 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
#if @GNULIB_READLINKAT@
-# if !@HAVE_READLINKAT@
+# if @REPLACE_READLINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define readlinkat rpl_readlinkat
+# endif
+_GL_FUNCDECL_RPL (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len)
+ _GL_ARG_NONNULL ((2, 3)));
+_GL_CXXALIAS_RPL (readlinkat, ssize_t,
+ (int fd, char const *file, char *buf, size_t len));
+# else
+# 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
+# endif
_GL_CXXALIAS_SYS (readlinkat, ssize_t,
(int fd, char const *file, char *buf, size_t len));
+# endif
_GL_CXXALIASWARN (readlinkat);
#elif defined GNULIB_POSIXCHECK
# undef readlinkat
@@ -1394,13 +1428,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
#if @GNULIB_SYMLINKAT@
-# if !@HAVE_SYMLINKAT@
+# if @REPLACE_SYMLINKAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef symlinkat
+# define symlinkat rpl_symlinkat
+# endif
+_GL_FUNCDECL_RPL (symlinkat, int,
+ (char const *contents, int fd, char const *file)
+ _GL_ARG_NONNULL ((1, 3)));
+_GL_CXXALIAS_RPL (symlinkat, int,
+ (char const *contents, int fd, char const *file));
+# else
+# if !@HAVE_SYMLINKAT@
_GL_FUNCDECL_SYS (symlinkat, int,
(char const *contents, int fd, char const *file)
_GL_ARG_NONNULL ((1, 3)));
-# endif
+# endif
_GL_CXXALIAS_SYS (symlinkat, int,
(char const *contents, int fd, char const *file));
+# endif
_GL_CXXALIASWARN (symlinkat);
#elif defined GNULIB_POSIXCHECK
# undef symlinkat
@@ -1540,4 +1586,5 @@ _GL_CXXALIASWARN (write);
_GL_INLINE_HEADER_END
#endif /* _@GUARD_PREFIX@_UNISTD_H */
+#endif /* _GL_INCLUDING_UNISTD_H */
#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index 65bfbc4..c0ece50 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -1,6 +1,6 @@
/* Prefer faster, non-thread-safe stdio functions if available.
- Copyright (C) 2001-2004, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/verify.h b/lib/verify.h
index 0c320b1..5c8381d 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2016 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
@@ -18,7 +18,7 @@
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
#ifndef _GL_VERIFY_H
-# define _GL_VERIFY_H
+#define _GL_VERIFY_H
/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
@@ -31,14 +31,24 @@
Use this only with GCC. If we were willing to slow 'configure'
down we could also use it with other compilers, but since this
affects only the quality of diagnostics, why bother? */
-# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
-# define _GL_HAVE__STATIC_ASSERT 1
-# endif
+#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
+ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
+ && !defined __cplusplus)
+# define _GL_HAVE__STATIC_ASSERT 1
+#endif
/* The condition (99 < __GNUC__) is temporary, until we know about the
first G++ release that supports static_assert. */
-# if (99 < __GNUC__) && defined __cplusplus
-# define _GL_HAVE_STATIC_ASSERT 1
-# endif
+#if (99 < __GNUC__) && defined __cplusplus
+# define _GL_HAVE_STATIC_ASSERT 1
+#endif
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ system headers, defines a conflicting _Static_assert that is no
+ better than ours; override it. */
+#ifndef _GL_HAVE_STATIC_ASSERT
+# include <stddef.h>
+# undef _Static_assert
+#endif
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
@@ -141,50 +151,50 @@
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
+#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
+#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)
+#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
/* Verify requirement R at compile-time, as an integer constant expression
that returns 1. If R is false, fail at compile-time, preferably
with a diagnostic that includes the string-literal DIAGNOSTIC. */
-# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
- (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
+#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
+ (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
-# ifdef __cplusplus
-# if !GNULIB_defined_struct__gl_verify_type
+#ifdef __cplusplus
+# if !GNULIB_defined_struct__gl_verify_type
template <int w>
struct _gl_verify_type {
unsigned int _gl_verify_error_if_negative: w;
};
-# define GNULIB_defined_struct__gl_verify_type 1
-# endif
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- _gl_verify_type<(R) ? 1 : -1>
-# elif defined _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { \
- _Static_assert (R, DIAGNOSTIC); \
- int _gl_dummy; \
- }
-# else
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+# define GNULIB_defined_struct__gl_verify_type 1
# endif
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ _gl_verify_type<(R) ? 1 : -1>
+#elif defined _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { \
+ _Static_assert (R, DIAGNOSTIC); \
+ int _gl_dummy; \
+ }
+#else
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+#endif
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. If R is false, fail at compile-time, preferably
@@ -193,23 +203,23 @@ template <int w>
Unfortunately, unlike C11, this implementation must appear as an
ordinary declaration, and cannot appear inside struct { ... }. */
-# ifdef _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY _Static_assert
-# else
-# define _GL_VERIFY(R, DIAGNOSTIC) \
- extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
- [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
-# endif
+#ifdef _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY _Static_assert
+#else
+# define _GL_VERIFY(R, DIAGNOSTIC) \
+ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
+ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
+#endif
/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
-# ifdef _GL_STATIC_ASSERT_H
-# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
-# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
-# endif
-# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
-# define static_assert _Static_assert /* C11 requires this #define. */
-# endif
+#ifdef _GL_STATIC_ASSERT_H
+# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
+# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
# endif
+# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
+# define static_assert _Static_assert /* C11 requires this #define. */
+# endif
+#endif
/* @assert.h omit start@ */
@@ -227,18 +237,42 @@ template <int w>
verify_true is obsolescent; please use verify_expr instead. */
-# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
+#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
/* Verify requirement R at compile-time. Return the value of the
expression E. */
-# define verify_expr(R, E) \
- (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
+#define verify_expr(R, E) \
+ (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. */
-# define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+
+/* Assume that R always holds. This lets the compiler optimize
+ accordingly. R should not have side-effects; it may or may not be
+ evaluated. Behavior is undefined if R is false. */
+
+#if (__has_builtin (__builtin_unreachable) \
+ || 4 < __GNUC__ + (5 <= __GNUC_MINOR__))
+# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
+#elif 1200 <= _MSC_VER
+# define assume(R) __assume (R)
+#elif ((defined GCC_LINT || defined lint) \
+ && (__has_builtin (__builtin_trap) \
+ || 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))))
+ /* Doing it this way helps various packages when configured with
+ --enable-gcc-warnings, which compiles with -Dlint. It's nicer
+ when 'assume' silences warnings even with older GCCs. */
+# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
+#else
+# define assume(R) ((void) (0 && (R)))
+#endif
/* @assert.h omit end@ */
diff --git a/lib/version-etc-fsf.c b/lib/version-etc-fsf.c
index c452f40..baaebb6 100644
--- a/lib/version-etc-fsf.c
+++ b/lib/version-etc-fsf.c
@@ -1,5 +1,5 @@
/* Variable with FSF copyright information, for version-etc.
- Copyright (C) 1999-2006, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999-2006, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/version-etc.c b/lib/version-etc.c
index ae1e44d..a9a0fdb 100644
--- a/lib/version-etc.c
+++ b/lib/version-etc.c
@@ -1,5 +1,5 @@
/* Print --version and bug-reporting information in a consistent format.
- Copyright (C) 1999-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@
# define PACKAGE PACKAGE_TARNAME
#endif
-enum { COPYRIGHT_YEAR = 2012 };
+enum { COPYRIGHT_YEAR = 2016 };
/* The three functions below display the --version information the
standard way.
diff --git a/lib/version-etc.h b/lib/version-etc.h
index 5548c02..1a5f603 100644
--- a/lib/version-etc.h
+++ b/lib/version-etc.h
@@ -1,5 +1,5 @@
/* Print --version and bug-reporting information in a consistent format.
- Copyright (C) 1999, 2003, 2005, 2009-2012 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003, 2005, 2009-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 0aada5e..07dbdcb 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2016 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
@@ -32,15 +30,23 @@
#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
+#if (((defined __need_mbstate_t || defined __need_wint_t) \
+ && !defined __MINGW32__ && !defined __KLIBC__) \
+ || (defined __hpux \
+ && ((defined _INTTYPES_INCLUDED && !defined strtoimax) \
+ || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
+ || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
+ || defined _GL_ALREADY_INCLUDING_WCHAR_H)
/* Special invocation convention:
- - Inside glibc and uClibc header files.
+ - Inside glibc and uClibc header files, but not MinGW.
- 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>.
+ - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
+ <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
- 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. */
@@ -107,10 +113,10 @@
# define WEOF -1
# endif
#else
-/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>.
This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
"unchanged by default argument promotions". Override it. */
-# if defined _MSC_VER
+# if @GNULIB_OVERRIDES_WINT_T@
# if !GNULIB_defined_wint_t
# include <crtdefs.h>
typedef unsigned int rpl_wint_t;
@@ -442,6 +448,11 @@ _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
# if !@HAVE_DECL_WCWIDTH@
/* wcwidth exists but is not declared. */
_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
+# elif defined __KLIBC__
+/* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
+ static inline function. The implementation of wcwidth in wcwidth.c
+ causes a "conflicting types" error. */
+# undef wcwidth
# endif
_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
# endif
diff --git a/lib/wcrtomb.c b/lib/wcrtomb.c
index 9e6494e..b931ee9 100644
--- a/lib/wcrtomb.c
+++ b/lib/wcrtomb.c
@@ -1,5 +1,5 @@
/* Convert wide character to multibyte character.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/wctob.c b/lib/wctob.c
index 0885c1b..15e3ff3 100644
--- a/lib/wctob.c
+++ b/lib/wctob.c
@@ -1,5 +1,5 @@
/* Convert wide character to unibyte character.
- Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2010-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/wctomb-impl.h b/lib/wctomb-impl.h
index 68264cf..a6ed971 100644
--- a/lib/wctomb-impl.h
+++ b/lib/wctomb-impl.h
@@ -1,5 +1,5 @@
/* Convert wide character to multibyte character.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/wctomb.c b/lib/wctomb.c
index 736a7c7..f1d14f5 100644
--- a/lib/wctomb.c
+++ b/lib/wctomb.c
@@ -1,5 +1,5 @@
/* Convert wide character to multibyte character.
- Copyright (C) 2011-2012 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/wctype.in.h b/lib/wctype.in.h
index 983336e..be7c14c 100644
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -1,8 +1,6 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
- Copyright (C) 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 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
@@ -27,13 +25,25 @@
* wctrans_t, and wctype_t are not yet implemented.
*/
-#ifndef _@GUARD_PREFIX@_WCTYPE_H
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
+#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
+
+/* Special invocation convention:
+ - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
+ <wctype.h> is being processed, which doesn't include the idempotency
+ guard. */
+
+#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
+
+#else
+/* Normal invocation convention. */
+
+#ifndef _@GUARD_PREFIX@_WCTYPE_H
+
#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
@@ -46,6 +56,13 @@
# include <wchar.h>
#endif
+/* mingw has declarations of towupper and towlower in <ctype.h> as
+ well <wctype.h>. Include <ctype.h> in advance to avoid rpl_ prefix
+ being added to the declarations. */
+#ifdef __MINGW32__
+# include <ctype.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. */
@@ -56,6 +73,9 @@
#ifndef _@GUARD_PREFIX@_WCTYPE_H
#define _@GUARD_PREFIX@_WCTYPE_H
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef _GL_WCTYPE_INLINE
# define _GL_WCTYPE_INLINE _GL_INLINE
@@ -85,10 +105,10 @@ _GL_INLINE_HEADER_BEGIN
# define WEOF -1
# endif
#else
-/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>.
This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
"unchanged by default argument promotions". Override it. */
-# if defined _MSC_VER
+# if @GNULIB_OVERRIDES_WINT_T@
# if !GNULIB_defined_wint_t
# include <crtdefs.h>
typedef unsigned int rpl_wint_t;
@@ -504,3 +524,4 @@ _GL_INLINE_HEADER_END
#endif /* _@GUARD_PREFIX@_WCTYPE_H */
#endif /* _@GUARD_PREFIX@_WCTYPE_H */
+#endif
diff --git a/lib/xalloc-die.c b/lib/xalloc-die.c
index e85d6df..4c7994b 100644
--- a/lib/xalloc-die.c
+++ b/lib/xalloc-die.c
@@ -1,6 +1,6 @@
/* Report a memory allocation failure and exit.
- Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2012 Free Software
+ Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2016 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index ad777d8..503bb37 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -1,6 +1,6 @@
/* xalloc-oversized.h -- memory allocation size checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2016 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
@@ -16,23 +16,53 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef XALLOC_OVERSIZED_H_
-# define XALLOC_OVERSIZED_H_
+#define XALLOC_OVERSIZED_H_
-# include <stddef.h>
+#include <stddef.h>
+#include <stdint.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 a function, so that it
- works correctly even when SIZE_MAX < N.
+/* Default for (non-Clang) compilers that lack __has_builtin. */
+#ifndef __has_builtin
+# define __has_builtin(x) 0
+#endif
+/* True if N * S would overflow in a size_t calculation,
+ or would generate a value larger than PTRDIFF_MAX.
+ This expands to a constant expression if N and S are both constants.
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. */
+ calculations, so the conservative size_t-based dividend to use here
+ is SIZE_MAX - 1. */
+#define __xalloc_oversized(n, s) \
+ ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n))
+
+#if PTRDIFF_MAX < SIZE_MAX
+typedef ptrdiff_t __xalloc_count_type;
+#else
+typedef size_t __xalloc_count_type;
+#endif
+
+/* Return 1 if an array of N objects, each of size S, cannot exist
+ reliably due to size or ptrdiff_t arithmetic overflow. S must be
+ positive and N must be nonnegative. This is a macro, not a
+ function, so that it works correctly even when SIZE_MAX < N. */
+
+#if 7 <= __GNUC__ || __has_builtin (__builtin_add_overflow_p)
# define xalloc_oversized(n, s) \
- ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
+ __builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
+#elif ((5 <= __GNUC__ \
+ || (__has_builtin (__builtin_mul_overflow) \
+ && __has_builtin (__builtin_constant_p))) \
+ && !__STRICT_ANSI__)
+# define xalloc_oversized(n, s) \
+ (__builtin_constant_p (n) && __builtin_constant_p (s) \
+ ? __xalloc_oversized (n, s) \
+ : ({ __xalloc_count_type __xalloc_count; \
+ __builtin_mul_overflow (n, s, &__xalloc_count); }))
+
+/* Other compilers use integer division; this may be slower but is
+ more portable. */
+#else
+# define xalloc_oversized(n, s) __xalloc_oversized (n, s)
+#endif
#endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/lib/xalloc.h b/lib/xalloc.h
index acf30a1..3aad4e3 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -1,6 +1,6 @@
/* xalloc.h -- malloc with out-of-memory checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,9 +19,13 @@
#define XALLOC_H_
#include <stddef.h>
+#include <stdint.h>
#include "xalloc-oversized.h"
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
_GL_INLINE_HEADER_BEGIN
#ifndef XALLOC_INLINE
# define XALLOC_INLINE _GL_INLINE
@@ -38,7 +42,8 @@ extern "C" {
# define _GL_ATTRIBUTE_MALLOC
#endif
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#if ! defined __clang__ && \
+ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
#else
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
@@ -61,7 +66,7 @@ void *xrealloc (void *p, size_t s)
_GL_ATTRIBUTE_ALLOC_SIZE ((2));
void *x2realloc (void *p, size_t *pn);
void *xmemdup (void const *p, size_t s)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2));
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2));
char *xstrdup (char const *str)
_GL_ATTRIBUTE_MALLOC;
@@ -119,10 +124,9 @@ xnrealloc (void *p, size_t n, size_t s)
/* If P is null, allocate a block of at least *PN such objects;
otherwise, reallocate P so that it contains more than *PN objects
- each of S bytes. *PN must be nonzero unless P is null, and S must
- be nonzero. Set *PN to the new number of objects, and return the
- pointer to the new block. *PN is never set to zero, and the
- returned pointer is never null.
+ each of S bytes. S must be nonzero. Set *PN to the new number of
+ objects, and return the pointer to the new block. *PN is never set
+ to zero, and the returned pointer is never null.
Repeated reallocations are guaranteed to make progress, either by
allocating an initial block with a nonzero size, or by allocating a
@@ -193,13 +197,14 @@ x2nrealloc (void *p, size_t *pn, size_t s)
}
else
{
- /* Set N = ceil (1.5 * N) so that progress is made if N == 1.
- Check for overflow, so that N * S stays in size_t range.
- The check is slightly conservative, but an exact check isn't
- worth the trouble. */
- if ((size_t) -1 / 3 * 2 / s <= n)
+ /* Set N = floor (1.5 * N) + 1 so that progress is made even if N == 0.
+ Check for overflow, so that N * S stays in both ptrdiff_t and
+ size_t range. The check may be slightly conservative, but an
+ exact check isn't worth the trouble. */
+ if ((PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX) / 3 * 2 / s
+ <= n)
xalloc_die ();
- n += (n + 1) / 2;
+ n += n / 2 + 1;
}
*pn = n;
@@ -256,5 +261,6 @@ xmemdup (T const *p, size_t s)
#endif
+_GL_INLINE_HEADER_END
#endif /* !XALLOC_H_ */
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 9755985..7d9c077 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -1,6 +1,6 @@
/* xmalloc.c -- malloc with out of memory checking
- Copyright (C) 1990-2000, 2002-2006, 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2002-2006, 2008-2016 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
@@ -93,11 +93,11 @@ void *
xcalloc (size_t n, size_t s)
{
void *p;
- /* Test for overflow, since some calloc implementations don't have
- proper overflow checks. But omit overflow and size-zero tests if
- HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
- returns NULL if successful. */
- if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
+ /* Test for overflow, since objects with size greater than
+ PTRDIFF_MAX cause pointer subtraction to go awry. Omit size-zero
+ tests if HAVE_GNU_CALLOC, since GNU calloc never returns NULL if
+ successful. */
+ if (xalloc_oversized (n, s)
|| (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
xalloc_die ();
return p;