From caebf82dc91c2c8113d0dd289095635d1699cc22 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 20 Jan 2022 14:18:05 +0900 Subject: [PATCH] Imported Upstream version 2.7.4 --- .tarball-version | 2 +- ChangeLog | 82 + GNUmakefile | 2 +- INSTALL | 320 ++-- Makefile.in | 48 +- NEWS | 8 +- TODO | 12 + aclocal.m4 | 23 +- build-aux/config.guess | 6 +- build-aux/config.sub | 10 +- build-aux/depcomp | 2 +- build-aux/git-version-gen | 6 +- build-aux/gitlog-to-changelog | 2 +- build-aux/mdate-sh | 2 +- build-aux/snippet/arg-nonnull.h | 2 +- build-aux/snippet/c++defs.h | 2 +- build-aux/snippet/warn-on-use.h | 2 +- build-aux/texinfo.tex | 142 +- build-aux/update-copyright | 6 +- build-aux/useless-if-before-free | 2 +- build-aux/vc-list-files | 2 +- config.hin | 178 +- configure | 2616 +++++++++++++++++++++++++---- lib/Makefile.in | 209 ++- lib/alloca.in.h | 2 +- lib/argmatch.c | 2 +- lib/argmatch.h | 2 +- lib/asnprintf.c | 2 +- lib/asprintf.c | 2 +- lib/assure.h | 37 + lib/at-func.c | 146 ++ lib/at-func2.c | 282 ++++ lib/backupfile.c | 2 +- lib/backupfile.h | 2 +- lib/basename-lgpl.c | 2 +- lib/basename.c | 2 +- lib/bitrotate.h | 2 +- lib/c-ctype.c | 2 +- lib/c-ctype.h | 2 +- lib/c-strcase.h | 2 +- lib/c-strcasecmp.c | 2 +- lib/c-strcaseeq.h | 2 +- lib/c-strncasecmp.c | 2 +- lib/canonicalize-lgpl.c | 2 +- lib/chdir-long.c | 267 +++ lib/chdir-long.h | 30 + lib/chmodat.c | 3 + lib/chown.c | 151 ++ lib/chownat.c | 3 + lib/cloexec.c | 83 + lib/cloexec.h | 38 + lib/close.c | 2 +- lib/closedir.c | 2 +- lib/config.charset | 6 +- lib/diffseq.h | 2 +- lib/dirent--.h | 2 +- lib/dirent-private.h | 2 +- lib/dirent-safer.h | 2 +- lib/dirent.in.h | 2 +- lib/dirfd.c | 2 +- lib/dirname-lgpl.c | 2 +- lib/dirname.c | 2 +- lib/dirname.h | 2 +- lib/dosname.h | 2 +- lib/dup-safer.c | 2 +- lib/dup2.c | 2 +- lib/errno.in.h | 2 +- lib/error.c | 2 +- lib/error.h | 2 +- lib/exitfail.c | 2 +- lib/exitfail.h | 2 +- lib/fchdir.c | 208 +++ lib/fchmodat.c | 53 + lib/fchown-stub.c | 16 + lib/fchownat.c | 114 ++ lib/fcntl.c | 2 +- lib/fcntl.in.h | 2 +- lib/fd-hook.c | 2 +- lib/fd-hook.h | 2 +- lib/fd-safer.c | 2 +- lib/filename.h | 2 +- lib/filenamecat-lgpl.c | 88 + lib/filenamecat.h | 27 + lib/float+.h | 2 +- lib/float.c | 2 +- lib/float.in.h | 2 +- lib/fstat.c | 2 +- lib/fstatat.c | 135 ++ lib/full-write.c | 2 +- lib/full-write.h | 2 +- lib/getcwd-lgpl.c | 126 ++ lib/getdtablesize.c | 2 +- lib/getopt.c | 2 +- lib/getopt.in.h | 2 +- lib/getopt1.c | 2 +- lib/getopt_int.h | 2 +- lib/gettext.h | 2 +- lib/gettime.c | 2 +- lib/gettimeofday.c | 2 +- lib/gl_anylinked_list1.h | 2 +- lib/gl_anylinked_list2.h | 2 +- lib/gl_linked_list.c | 2 +- lib/gl_linked_list.h | 2 +- lib/gl_list.h | 2 +- lib/gl_xlist.h | 2 +- lib/gnulib.mk | 238 ++- lib/hash.c | 2 +- lib/hash.h | 2 +- lib/ignore-value.h | 2 +- lib/intprops.h | 2 +- lib/itold.c | 2 +- lib/lchown.c | 117 ++ lib/localcharset.c | 44 +- lib/localcharset.h | 2 +- lib/lstat.c | 2 +- lib/malloc.c | 2 +- lib/malloca.c | 2 +- lib/malloca.h | 2 +- lib/mbrtowc.c | 2 +- lib/mbsinit.c | 2 +- lib/memchr.c | 2 +- lib/mempcpy.c | 28 + lib/memrchr.c | 161 ++ lib/minmax.h | 2 +- lib/mkdir.c | 2 +- lib/mkdirat.c | 34 + lib/mktime.c | 2 +- lib/msvc-inval.c | 2 +- lib/msvc-inval.h | 2 +- lib/msvc-nothrow.c | 2 +- lib/msvc-nothrow.h | 2 +- lib/open.c | 181 ++ lib/openat-die.c | 62 + lib/openat-priv.h | 64 + lib/openat-proc.c | 102 ++ lib/openat.c | 286 ++++ lib/openat.h | 123 ++ lib/opendir-safer.c | 2 +- lib/opendir.c | 2 +- lib/parse-datetime.c | 1346 +++++++-------- lib/parse-datetime.h | 2 +- lib/parse-datetime.y | 4 +- lib/pathmax.h | 2 +- lib/pipe-safer.c | 2 +- lib/printf-args.c | 2 +- lib/printf-args.h | 2 +- lib/printf-parse.c | 2 +- lib/printf-parse.h | 2 +- lib/progname.c | 2 +- lib/progname.h | 2 +- lib/quote.h | 2 +- lib/quotearg.c | 2 +- lib/quotearg.h | 2 +- lib/raise.c | 2 +- lib/readdir.c | 2 +- lib/readlink.c | 2 +- lib/readlinkat.c | 61 + lib/realloc.c | 2 +- lib/ref-add.sin | 2 +- lib/ref-del.sin | 2 +- lib/rename.c | 2 +- lib/renameat.c | 157 ++ lib/rmdir.c | 2 +- lib/safe-read.c | 2 +- lib/safe-write.c | 2 +- lib/safe-write.h | 2 +- lib/same-inode.h | 2 +- lib/save-cwd.c | 99 ++ lib/save-cwd.h | 34 + lib/secure_getenv.c | 2 +- lib/setenv.c | 2 +- lib/signal.in.h | 2 +- lib/size_max.h | 2 +- lib/stat-time.h | 18 +- lib/stat.c | 2 +- lib/statat.c | 3 + lib/stdarg.in.h | 2 +- lib/stdbool.in.h | 2 +- lib/stddef.in.h | 43 +- lib/stdint.in.h | 2 +- lib/stdio.in.h | 9 +- lib/stdlib.in.h | 2 +- lib/strdup.c | 54 + lib/streq.h | 2 +- lib/strerror-override.c | 2 +- lib/strerror-override.h | 2 +- lib/strerror.c | 2 +- lib/string.in.h | 2 +- lib/stripslash.c | 2 +- lib/strndup.c | 2 +- lib/strnlen.c | 2 +- lib/symlink.c | 2 +- lib/symlinkat.c | 93 + lib/sys_stat.in.h | 2 +- lib/sys_time.in.h | 2 +- lib/sys_types.in.h | 2 +- lib/tempname.c | 2 +- lib/tempname.h | 2 +- lib/time.in.h | 4 +- lib/time_r.c | 2 +- lib/timespec.h | 6 +- lib/unistd--.h | 2 +- lib/unistd-safer.h | 2 +- lib/unistd.in.h | 4 +- lib/unlink.c | 2 +- lib/unlinkat.c | 109 ++ lib/unsetenv.c | 2 +- lib/utimens.c | 4 +- lib/utimens.h | 2 +- lib/utimensat.c | 158 ++ lib/vasnprintf.c | 17 +- lib/vasnprintf.h | 2 +- lib/vasprintf.c | 2 +- lib/verify.h | 2 +- lib/verror.c | 2 +- lib/verror.h | 2 +- lib/wchar.in.h | 2 +- lib/wctype.in.h | 2 +- lib/write.c | 2 +- lib/xalloc-die.c | 2 +- lib/xalloc-oversized.h | 2 +- lib/xalloc.h | 2 +- lib/xasprintf.c | 2 +- lib/xmalloc.c | 2 +- lib/xmemdup0.c | 2 +- lib/xmemdup0.h | 2 +- lib/xsize.h | 2 +- lib/xstrndup.c | 2 +- lib/xstrndup.h | 2 +- lib/xvasprintf.c | 2 +- lib/xvasprintf.h | 2 +- m4/00gnulib.m4 | 2 +- m4/absolute-header.m4 | 2 +- m4/alloca.m4 | 2 +- m4/backupfile.m4 | 2 +- m4/bison.m4 | 2 +- m4/canonicalize.m4 | 2 +- m4/chdir-long.m4 | 30 + m4/chown.m4 | 204 +++ m4/clock_time.m4 | 2 +- m4/close.m4 | 2 +- m4/closedir.m4 | 2 +- m4/codeset.m4 | 2 +- m4/configmake.m4 | 2 +- m4/d-ino.m4 | 2 +- m4/dirent-safer.m4 | 2 +- m4/dirent_h.m4 | 2 +- m4/dirfd.m4 | 2 +- m4/dirname.m4 | 2 +- m4/double-slash-root.m4 | 2 +- m4/dup2.m4 | 2 +- m4/eealloc.m4 | 2 +- m4/environ.m4 | 2 +- m4/errno_h.m4 | 2 +- m4/error.m4 | 2 +- m4/exponentd.m4 | 2 +- m4/extensions.m4 | 7 +- m4/extern-inline.m4 | 2 +- m4/fchdir.m4 | 61 + m4/fchmodat.m4 | 17 + m4/fchownat.m4 | 108 ++ m4/fcntl-o.m4 | 2 +- m4/fcntl.m4 | 2 +- m4/fcntl_h.m4 | 2 +- m4/filenamecat.m4 | 16 + m4/float_h.m4 | 2 +- m4/fstat.m4 | 2 +- m4/fstatat.m4 | 60 + m4/getcwd.m4 | 160 ++ m4/getdtablesize.m4 | 2 +- m4/getopt.m4 | 2 +- m4/gettime.m4 | 2 +- m4/gettimeofday.m4 | 2 +- m4/glibc21.m4 | 2 +- m4/gnulib-common.m4 | 2 +- m4/gnulib-comp.m4 | 204 ++- m4/include_next.m4 | 2 +- m4/intmax_t.m4 | 2 +- m4/inttypes_h.m4 | 2 +- m4/largefile.m4 | 2 +- m4/lchmod.m4 | 22 - m4/lchown.m4 | 38 + m4/localcharset.m4 | 2 +- m4/locale-fr.m4 | 2 +- m4/locale-ja.m4 | 2 +- m4/locale-zh.m4 | 2 +- m4/longlong.m4 | 2 +- m4/lstat.m4 | 2 +- m4/malloc.m4 | 2 +- m4/malloca.m4 | 2 +- m4/manywarnings.m4 | 2 +- m4/mbrtowc.m4 | 2 +- m4/mbsinit.m4 | 2 +- m4/mbstate_t.m4 | 2 +- m4/memchr.m4 | 2 +- m4/mempcpy.m4 | 26 + m4/memrchr.m4 | 23 + m4/minmax.m4 | 2 +- m4/mkdir.m4 | 2 +- m4/mkdirat.m4 | 23 + m4/mktime.m4 | 2 +- m4/mmap-anon.m4 | 2 +- m4/mode_t.m4 | 26 + m4/msvc-inval.m4 | 2 +- m4/msvc-nothrow.m4 | 2 +- m4/multiarch.m4 | 2 +- m4/nocrash.m4 | 2 +- m4/off_t.m4 | 2 +- m4/open.m4 | 91 + m4/openat.m4 | 36 + m4/opendir.m4 | 2 +- m4/parse-datetime.m4 | 2 +- m4/pathmax.m4 | 2 +- m4/printf.m4 | 2 +- m4/quote.m4 | 2 +- m4/quotearg.m4 | 2 +- m4/raise.m4 | 2 +- m4/readdir.m4 | 2 +- m4/readlink.m4 | 2 +- m4/readlinkat.m4 | 32 + m4/realloc.m4 | 2 +- m4/rename.m4 | 2 +- m4/renameat.m4 | 24 + m4/rmdir.m4 | 2 +- m4/safe-read.m4 | 2 +- m4/safe-write.m4 | 2 +- m4/save-cwd.m4 | 11 + m4/secure_getenv.m4 | 2 +- m4/setenv.m4 | 2 +- m4/signal_h.m4 | 2 +- m4/size_max.m4 | 2 +- m4/ssize_t.m4 | 2 +- m4/stat-time.m4 | 2 +- m4/stat.m4 | 2 +- m4/stdarg.m4 | 2 +- m4/stdbool.m4 | 2 +- m4/stddef_h.m4 | 10 +- m4/stdint.m4 | 2 +- m4/stdint_h.m4 | 2 +- m4/stdio_h.m4 | 25 +- m4/stdlib_h.m4 | 2 +- m4/strdup.m4 | 36 + m4/strerror.m4 | 2 +- m4/string_h.m4 | 2 +- m4/strndup.m4 | 2 +- m4/strnlen.m4 | 2 +- m4/symlink.m4 | 2 +- m4/symlinkat.m4 | 53 + m4/sys_socket_h.m4 | 2 +- m4/sys_stat_h.m4 | 2 +- m4/sys_time_h.m4 | 2 +- m4/sys_types_h.m4 | 2 +- m4/tempname.m4 | 2 +- m4/time_h.m4 | 21 +- m4/time_r.m4 | 2 +- m4/timespec.m4 | 2 +- m4/tm_gmtoff.m4 | 2 +- m4/unistd-safer.m4 | 2 +- m4/unistd_h.m4 | 2 +- m4/unlink.m4 | 2 +- m4/unlinkat.m4 | 33 + m4/utimbuf.m4 | 2 +- m4/utimens.m4 | 2 +- m4/utimensat.m4 | 71 + m4/utimes.m4 | 2 +- m4/vasnprintf.m4 | 2 +- m4/vasprintf.m4 | 2 +- m4/warn-on-use.m4 | 2 +- m4/warnings.m4 | 2 +- m4/wchar_h.m4 | 2 +- m4/wchar_t.m4 | 2 +- m4/wctype_h.m4 | 2 +- m4/wint_t.m4 | 2 +- m4/write.m4 | 2 +- m4/xalloc.m4 | 2 +- m4/xsize.m4 | 2 +- m4/xstrndup.m4 | 2 +- m4/xvasprintf.m4 | 2 +- maint.mk | 6 +- src/Makefile.am | 2 + src/Makefile.in | 56 +- src/inp.c | 9 +- src/patch.c | 13 +- src/pch.c | 11 +- src/safe.c | 463 +++++ src/safe.h | 33 + src/util.c | 103 +- src/util.h | 1 - tests/Makefile.am | 5 +- tests/Makefile.in | 72 +- tests/asymmetric-hunks | 2 +- tests/backup-prefix-suffix | 2 +- tests/bad-usage | 2 +- tests/concat-git-diff | 2 +- tests/copy-rename | 2 +- tests/corrupt-reject-files | 2 +- tests/create-delete | 4 +- tests/criss-cross | 2 +- tests/crlf-handling | 4 +- tests/dash-o-append | 2 +- tests/deep-directories | 28 + tests/empty-files | 2 +- tests/fifo | 2 +- tests/file-modes | 4 +- tests/filename-choice | 2 +- tests/garbage | 25 + tests/git-binary-diff | 2 +- tests/global-reject-files | 2 +- tests/inname | 2 +- tests/line-numbers | 4 +- tests/mangled-numbers-abort | 2 +- tests/merge | 6 +- tests/mixed-patch-types | 2 +- tests/munged-context-format | 4 +- tests/need-filename | 4 +- tests/no-mode-change-git-diff | 34 + tests/no-newline-triggers-assert | 2 +- tests/preserve-c-function-names | 4 +- tests/preserve-mode-and-timestamp | 4 +- tests/quoted-filenames | 2 +- tests/read-only-files | 2 +- tests/reject-format | 6 +- tests/remember-backup-files | 2 +- tests/remember-reject-files | 2 +- tests/remove-directories | 2 +- tests/symlinks | 76 +- tests/test-lib.sh | 18 +- tests/unmodified-files | 2 +- 428 files changed, 10287 insertions(+), 1940 deletions(-) create mode 100644 TODO create mode 100644 lib/assure.h create mode 100644 lib/at-func.c create mode 100644 lib/at-func2.c create mode 100644 lib/chdir-long.c create mode 100644 lib/chdir-long.h create mode 100644 lib/chmodat.c create mode 100644 lib/chown.c create mode 100644 lib/chownat.c create mode 100644 lib/cloexec.c create mode 100644 lib/cloexec.h create mode 100644 lib/fchdir.c create mode 100644 lib/fchmodat.c create mode 100644 lib/fchown-stub.c create mode 100644 lib/fchownat.c create mode 100644 lib/filenamecat-lgpl.c create mode 100644 lib/filenamecat.h create mode 100644 lib/fstatat.c create mode 100644 lib/getcwd-lgpl.c create mode 100644 lib/lchown.c create mode 100644 lib/mempcpy.c create mode 100644 lib/memrchr.c create mode 100644 lib/mkdirat.c create mode 100644 lib/open.c create mode 100644 lib/openat-die.c create mode 100644 lib/openat-priv.h create mode 100644 lib/openat-proc.c create mode 100644 lib/openat.c create mode 100644 lib/openat.h create mode 100644 lib/readlinkat.c create mode 100644 lib/renameat.c create mode 100644 lib/save-cwd.c create mode 100644 lib/save-cwd.h create mode 100644 lib/statat.c create mode 100644 lib/strdup.c create mode 100644 lib/symlinkat.c create mode 100644 lib/unlinkat.c create mode 100644 lib/utimensat.c create mode 100644 m4/chdir-long.m4 create mode 100644 m4/chown.m4 create mode 100644 m4/fchdir.m4 create mode 100644 m4/fchmodat.m4 create mode 100644 m4/fchownat.m4 create mode 100644 m4/filenamecat.m4 create mode 100644 m4/fstatat.m4 create mode 100644 m4/getcwd.m4 delete mode 100644 m4/lchmod.m4 create mode 100644 m4/lchown.m4 create mode 100644 m4/mempcpy.m4 create mode 100644 m4/memrchr.m4 create mode 100644 m4/mkdirat.m4 create mode 100644 m4/mode_t.m4 create mode 100644 m4/open.m4 create mode 100644 m4/openat.m4 create mode 100644 m4/readlinkat.m4 create mode 100644 m4/renameat.m4 create mode 100644 m4/save-cwd.m4 create mode 100644 m4/strdup.m4 create mode 100644 m4/symlinkat.m4 create mode 100644 m4/unlinkat.m4 create mode 100644 m4/utimensat.m4 create mode 100644 src/safe.c create mode 100644 src/safe.h create mode 100755 tests/deep-directories create mode 100644 tests/garbage create mode 100644 tests/no-mode-change-git-diff diff --git a/.tarball-version b/.tarball-version index 2c9b4ef..a4dd9db 100644 --- a/.tarball-version +++ b/.tarball-version @@ -1 +1 @@ -2.7.3 +2.7.4 diff --git a/ChangeLog b/ChangeLog index c21081a..21e051e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,85 @@ +2015-01-31 Andreas Gruenbacher + + Upate NEWS + + Fix indentation heuristic for context diffs + Diffs can be indented by a variable number of spaces, tabs, or X characters. + Make sure that intuit_diff_type() only accepts context diffs where the first + and second line are indented identically, or else another_hunk() will fail. + * src/pch.c (intuit_diff_type): Remember the indentation of the last line. Only + recognize context diff hunks with the same amount of indentation on the first + and second line. + * tests/garbage: New test case. + * tests/Makefile.am (TESTS): Add test case. + +2015-01-31 Quentin Casasnovas + + patch: git-diff mode: do not change permissions if there isn't an explicit mode change. + + tests: add a test case for unwanted mode changes. + + test-lib.sh: factorize require_* functions + Since the code is identical when just checking if a utility is present on + the system or not, we can factorize it. + +2015-01-31 Andreas Gruenbacher + + Add test case for patch behind symlink + * tests/symlinks: Add a test case where the patch file itself is in a path that + follows a symbolic link; we want to continue allowing that. + +2015-01-31 Tim Waugh + + Allow arbitrary symlink targets again + * src/util.c (symlink_target_is_valid): Remove. + (move_file): Remove symlink target checking. + * tests/symlinks: Update test case. + +2015-01-31 Andreas Gruenbacher + + Update list of gnulib modules used + * bootstrap.conf (gnulib_modules): Remove lchmod, lstat, mkdir, readlink, + rename, mkdir, symlink, unlink, utimens. Add fchownat, fchmodat, fstatat, + mkdirat, openat, readlinkat, renameat, symlinkat, unlinkat, utimensat. + * src/util.h: Don't include anymore. + + Use symlink-safe system call replacements + Use the symlink-safe replacements for system calls in many places throughout + the code: In some places this makes patch safe against path traversal attacks; + in other places, it saves the kernel from having to re-traverse the pathnames. + * src/inp.c (plan_b): Use safe_open() + fdopen() instead of fopen(). + * src/util.c (copy_attr): Document why we are safe here. + (create_backup): Use safe_open() instead of creat(). + +2015-01-31 Tim Waugh + + Add symlink-safe system call replacements + Add wrappers around system calls that traverse relative pathnames without + following symlinks. Written by Tim Waugh and Andreas + Gruenbacher . + * src/safe.h: Declare functions here. + * src/safe.c: Implement safe_* system call replacements that do not follow + symlinks along pathnames. Pathname components are resolved with openat(). + Lookup results are cached to keep the overhead reasonably low. + * tests/deep-directories: New path traversal cache test. + * src/Makefile.am (patch_SOURCES): Add safe.[ch]. + * tests/Makefile.am (TESTS): Add new test. + +2015-01-31 Andreas Gruenbacher + + build: update gnulib submodule to latest + +2015-01-31 Tim Waugh + + Avoid closing file descriptor twice + * src/patch.c (main): Make sure we don't close() outfd after passing it on to + fdopen(): the file descriptor might have been reused in the meantime. + +2015-01-29 Andreas Gruenbacher + + Remove unused variable + * src/pch.c (name_is_valid): Remove unused variable. + 2015-01-22 Andreas Gruenbacher Fix the fix for CVE-2015-1196 diff --git a/GNUmakefile b/GNUmakefile index 4ab6429..6617eec 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -5,7 +5,7 @@ # It is necessary if you want to build targets usually of interest # only to the maintainer. -# Copyright (C) 2001, 2003, 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2006-2015 Free Software Foundation, Inc. # This 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/INSTALL b/INSTALL index 2099840..dadea5c 100644 --- a/INSTALL +++ b/INSTALL @@ -1,8 +1,8 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, -Inc. + Copyright (C) 1994-1996, 1999-2002, 2004-2015 Free Software +Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -12,97 +12,96 @@ without warranty of any kind. Basic Installation ================== - Briefly, the shell command `./configure && make && make install' + Briefly, the shell command './configure && make && make install' should configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for +more-detailed instructions are generic; see the 'README' file for instructions specific to this package. Some packages provide this -`INSTALL' file but do not implement all of the features documented +'INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. - The `configure' shell script attempts to guess correct values for + The 'configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that +those values to create a 'Makefile' in each directory of the package. +It may also create one or more '.h' files containing system-dependent +definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). +file 'config.log' containing compiler output (useful mainly for +debugging 'configure'). - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. Caching is -disabled by default to prevent problems with accidental use of stale -cache files. + It can also use an optional file (typically called 'config.cache' and +enabled with '--cache-file=config.cache' or simply '-C') that saves the +results of its tests to speed up reconfiguring. Caching is disabled by +default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can +to figure out how 'configure' could check whether to do them, and mail +diffs or instructions to the address given in the 'README' so they can be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you +some point 'config.cache' contains results you don't want to keep, you may remove or edit it. - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You need `configure.ac' if -you want to change it or regenerate `configure' using a newer version -of `autoconf'. + The file 'configure.ac' (or 'configure.in') is used to create +'configure' by a program called 'autoconf'. You need 'configure.ac' if +you want to change it or regenerate 'configure' using a newer version of +'autoconf'. The simplest way to compile this package is: - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. + 1. 'cd' to the directory containing the package's source code and type + './configure' to configure the package for your system. - Running `configure' might take a while. While running, it prints + Running 'configure' might take a while. While running, it prints some messages telling which features it is checking for. - 2. Type `make' to compile the package. + 2. Type 'make' to compile the package. - 3. Optionally, type `make check' to run any self-tests that come with + 3. Optionally, type 'make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. - 4. Type `make install' to install the programs and any data files and + 4. Type 'make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular - user, and only the `make install' phase executed with root + user, and only the 'make install' phase executed with root privileges. - 5. Optionally, type `make installcheck' to repeat any self-tests, but + 5. Optionally, type 'make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a - regular user, particularly if the prior `make install' required + regular user, particularly if the prior 'make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly + source code directory by typing 'make clean'. To also remove the + files that 'configure' created (so you can compile the package for + a different kind of computer), type 'make distclean'. There is + also a 'make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. - 7. Often, you can also type `make uninstall' to remove the installed + 7. Often, you can also type 'make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. - 8. Some packages, particularly those that use Automake, provide `make + 8. Some packages, particularly those that use Automake, provide 'make distcheck', which can by used by developers to test that all other - targets like `make install' and `make uninstall' work correctly. + targets like 'make install' and 'make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that -the `configure' script does not know about. Run `./configure --help' +the 'configure' script does not know about. Run './configure --help' for details on some of the pertinent environment variables. - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: + You can give 'configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here is +an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix @@ -113,21 +112,21 @@ Compiling For Multiple Architectures You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you can use GNU `make'. `cd' to the +own directory. To do this, you can use GNU 'make'. 'cd' to the directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. This -is known as a "VPATH" build. +the 'configure' script. 'configure' automatically checks for the source +code in the directory that 'configure' is in and in '..'. This is known +as a "VPATH" build. - With a non-GNU `make', it is safer to compile the package for one + With a non-GNU 'make', it is safer to compile the package for one architecture at a time in the source code directory. After you have -installed the package for one architecture, use `make distclean' before +installed the package for one architecture, use 'make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like +"universal" binaries--by specifying multiple '-arch' options to the +compiler but only a single '-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ @@ -136,105 +135,104 @@ this: This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. +using the 'lipo' tool if you have problems. Installation Names ================== - By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX', where PREFIX must be an + By default, 'make install' installs the package's commands under +'/usr/local/bin', include files under '/usr/local/include', etc. You +can specify an installation prefix other than '/usr/local' by giving +'configure' the option '--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses +pass the option '--exec-prefix=PREFIX' to 'configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. In general, the -default for these options is expressed in terms of `${prefix}', so that -specifying just `--prefix' will affect all of the other directory +options like '--bindir=DIR' to specify different values for particular +kinds of files. Run 'configure --help' for a list of the directories +you can set and what kinds of files go in them. In general, the default +for these options is expressed in terms of '${prefix}', so that +specifying just '--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the -correct locations to `configure'; however, many packages provide one or +correct locations to 'configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the -`make install' command line to change installation locations without +'make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each -affected directory. For example, `make install +affected directory. For example, 'make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of -`${prefix}'. Any directories that were specified during `configure', -but not in terms of `${prefix}', must each be overridden at install -time for the entire installation to be relocated. The approach of -makefile variable overrides for each directory variable is required by -the GNU Coding Standards, and ideally causes no recompilation. -However, some platforms have known limitations with the semantics of -shared libraries that end up requiring recompilation when using this -method, particularly noticeable in packages that use GNU Libtool. - - The second method involves providing the `DESTDIR' variable. For -example, `make install DESTDIR=/alternate/directory' will prepend -`/alternate/directory' before all installation names. The approach of -`DESTDIR' overrides is not required by the GNU Coding Standards, and +'${prefix}'. Any directories that were specified during 'configure', +but not in terms of '${prefix}', must each be overridden at install time +for the entire installation to be relocated. The approach of makefile +variable overrides for each directory variable is required by the GNU +Coding Standards, and ideally causes no recompilation. However, some +platforms have known limitations with the semantics of shared libraries +that end up requiring recompilation when using this method, particularly +noticeable in packages that use GNU Libtool. + + The second method involves providing the 'DESTDIR' variable. For +example, 'make install DESTDIR=/alternate/directory' will prepend +'/alternate/directory' before all installation names. The approach of +'DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even -when some directory options were not specified in terms of `${prefix}' -at `configure' time. +when some directory options were not specified in terms of '${prefix}' +at 'configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the +with an extra prefix or suffix on their names by giving 'configure' the +option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. + + Some packages pay attention to '--enable-FEATURE' options to +'configure', where FEATURE indicates an optional part of the package. +They may also pay attention to '--with-PACKAGE' options, where PACKAGE +is something like 'gnu-as' or 'x' (for the X Window System). The +'README' should mention any '--enable-' and '--with-' options that the package recognizes. - For packages that use the X Window System, `configure' can usually + For packages that use the X Window System, 'configure' can usually find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. +you can use the 'configure' options '--x-includes=DIR' and +'--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the -execution of `make' will be. For these packages, running `./configure +execution of 'make' will be. For these packages, running './configure --enable-silent-rules' sets the default to minimal output, which can be -overridden with `make V=1'; while running `./configure +overridden with 'make V=1'; while running './configure --disable-silent-rules' sets the default to verbose, which can be -overridden with `make V=0'. +overridden with 'make V=0'. Particular systems ================== - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in + On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC +is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. - HP-UX `make' updates targets which have the same time stamps as -their prerequisites, which makes it generally unusable when shipped -generated files such as `configure' are involved. Use GNU `make' -instead. + HP-UX 'make' updates targets which have the same time stamps as their +prerequisites, which makes it generally unusable when shipped generated +files such as 'configure' are involved. Use GNU 'make' instead. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try +parse its '' header file. The option '-nodtk' can be used as a +workaround. If GNU CC is not installed, it is therefore recommended to +try ./configure CC="cc" @@ -242,26 +240,26 @@ and if that doesn't work, try ./configure CC="cc -nodtk" - On Solaris, don't put `/usr/ucb' early in your `PATH'. This + On Solaris, don't put '/usr/ucb' early in your 'PATH'. This directory contains several dysfunctional programs; working variants of -these programs are available in `/usr/bin'. So, if you need `/usr/ucb' -in your `PATH', put it _after_ `/usr/bin'. +these programs are available in '/usr/bin'. So, if you need '/usr/ucb' +in your 'PATH', put it _after_ '/usr/bin'. - On Haiku, software installed for all users goes in `/boot/common', -not `/usr/local'. It is recommended to use the following options: + On Haiku, software installed for all users goes in '/boot/common', +not '/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== - There may be some features `configure' cannot figure out + There may be some features 'configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the -_same_ architectures, `configure' can figure that out, but if it prints +_same_ architectures, 'configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: +'--build=TYPE' option. TYPE can either be a short name for the system +type, such as 'sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM @@ -270,101 +268,101 @@ where SYSTEM can have one of these forms: OS KERNEL-OS - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't + See the file 'config.sub' for the possible values of each field. If +'config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will +use the option '--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. +eventually be run) with '--host=TYPE'. Sharing Defaults ================ - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. + If you want to set default values for 'configure' scripts to share, +you can create a site shell script called 'config.site' that gives +default values for variables like 'CC', 'cache_file', and 'prefix'. +'configure' looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: not all 'configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run +environment passed to 'configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: +them in the 'configure' command line, using 'VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc -causes the specified `gcc' to be used as the C compiler (unless it is +causes the specified 'gcc' to be used as the C compiler (unless it is overridden in the site shell script). -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf limitation. Until the limitation is lifted, you can use -this workaround: +Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an +Autoconf limitation. Until the limitation is lifted, you can use this +workaround: CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash -`configure' Invocation +'configure' Invocation ====================== - `configure' recognizes the following options to control how it + 'configure' recognizes the following options to control how it operates. -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. +'--help' +'-h' + Print a summary of all of the options to 'configure', and exit. -`--help=short' -`--help=recursive' +'--help=short' +'--help=recursive' Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. + 'configure', and exit. The 'short' variant lists options used only + in the top level, while the 'recursive' variant lists options also + present in any nested packages. -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' +'--version' +'-V' + Print the version of Autoconf used to generate the 'configure' script, and exit. -`--cache-file=FILE' +'--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to + traditionally 'config.cache'. FILE defaults to '/dev/null' to disable caching. -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. +'--config-cache' +'-C' + Alias for '--cache-file=config.cache'. -`--quiet' -`--silent' -`-q' +'--quiet' +'--silent' +'-q' Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error + suppress all normal output, redirect it to '/dev/null' (any error messages will still be shown). -`--srcdir=DIR' +'--srcdir=DIR' Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. + 'configure' can determine that directory automatically. -`--prefix=DIR' - Use DIR as the installation prefix. *note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. +'--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: for + more details, including other options available for fine-tuning the + installation locations. -`--no-create' -`-n' +'--no-create' +'-n' Run the configure checks, but stop before creating any output files. -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. +'configure' also accepts some other, not widely useful, options. Run +'configure --help' for more details. diff --git a/Makefile.in b/Makefile.in index 6ee448e..bc6329c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -97,7 +97,7 @@ subdir = . DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \ - $(srcdir)/config.hin $(dist_man1_MANS) COPYING \ + $(srcdir)/config.hin $(dist_man1_MANS) COPYING TODO \ build-aux/ar-lib build-aux/compile build-aux/config.guess \ build-aux/config.sub build-aux/depcomp build-aux/install-sh \ build-aux/mdate-sh build-aux/missing build-aux/texinfo.tex \ @@ -112,6 +112,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/canonicalize.m4 \ + $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/d-ino.m4 \ @@ -121,52 +122,61 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/extensions.m4 \ - $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \ + $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \ $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fstat.m4 \ + $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdtablesize.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettime.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/include_next.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/largefile.m4 \ - $(top_srcdir)/m4/lchmod.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/lchown.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/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/mkdir.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ + $(top_srcdir)/m4/mkdirat.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ $(top_srcdir)/m4/opendir.m4 $(top_srcdir)/m4/parse-datetime.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/readdir.m4 \ - $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ + $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rename.m4 \ + $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rmdir.m4 \ $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ - $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/setenv.m4 \ - $(top_srcdir)/m4/setmode.m4 $(top_srcdir)/m4/signal_h.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/ssize_t.m4 \ - $(top_srcdir)/m4/stat-time.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/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/secure_getenv.m4 \ + $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/setmode.m4 \ + $(top_srcdir)/m4/signal_h.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.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/stdint_h.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/symlink.m4 \ - $(top_srcdir)/m4/sys_socket_h.m4 \ + $(top_srcdir)/m4/symlinkat.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/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \ + $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \ @@ -690,6 +700,7 @@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ +HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ @@ -1046,6 +1057,7 @@ 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_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ VERSION = @VERSION@ diff --git a/NEWS b/NEWS index d79cead..9fafde4 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,14 @@ +Changes until version 2.7.4: + * When a file isn't being deleted because the file contents don't match the patch, the resulting message is now "Not deleting file ... as content differs from patch" instead of "File ... is not empty after patch; not deleting". * Function names in hunks (from diff -p) are now preserved in reject files. -* With git-style patches, symlinks that point outside the working directory - will no longer be created (CVE-2015-1196). +* Patch no longer follows symbolic links to input and output files. This + ensures that symbolic links created by git-style patches cannot cause + patch to write outside the working directory (CVE-2015-1196). +* Various fixes. Changes in version 2.7.1: diff --git a/TODO b/TODO new file mode 100644 index 0000000..41324ab --- /dev/null +++ b/TODO @@ -0,0 +1,12 @@ +* Add instrumentation code for the path traversal functions !!! + +access() !!! +Apply the mode fix! +Alpha release ?! +Announcement ... + +* Fix Savannah patches. +* Reduce the number of unnecessary syscalls: for example, stat is often called + repeatedly. +* Call makedirs() before creating files inside the directory; with the dirfd + cache, this causes no extra syscalls anymore. diff --git a/aclocal.m4 b/aclocal.m4 index f4d61b6..e2807fb 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1213,6 +1213,8 @@ m4_include([m4/alloca.m4]) m4_include([m4/backupfile.m4]) m4_include([m4/bison.m4]) m4_include([m4/canonicalize.m4]) +m4_include([m4/chdir-long.m4]) +m4_include([m4/chown.m4]) m4_include([m4/clock_time.m4]) m4_include([m4/close.m4]) m4_include([m4/closedir.m4]) @@ -1232,11 +1234,17 @@ m4_include([m4/error.m4]) m4_include([m4/exponentd.m4]) m4_include([m4/extensions.m4]) m4_include([m4/extern-inline.m4]) +m4_include([m4/fchdir.m4]) +m4_include([m4/fchmodat.m4]) +m4_include([m4/fchownat.m4]) m4_include([m4/fcntl-o.m4]) m4_include([m4/fcntl.m4]) m4_include([m4/fcntl_h.m4]) +m4_include([m4/filenamecat.m4]) m4_include([m4/float_h.m4]) m4_include([m4/fstat.m4]) +m4_include([m4/fstatat.m4]) +m4_include([m4/getcwd.m4]) m4_include([m4/getdtablesize.m4]) m4_include([m4/getopt.m4]) m4_include([m4/gettime.m4]) @@ -1248,7 +1256,7 @@ m4_include([m4/include_next.m4]) m4_include([m4/intmax_t.m4]) m4_include([m4/inttypes_h.m4]) m4_include([m4/largefile.m4]) -m4_include([m4/lchmod.m4]) +m4_include([m4/lchown.m4]) m4_include([m4/localcharset.m4]) m4_include([m4/locale-fr.m4]) m4_include([m4/locale-ja.m4]) @@ -1262,15 +1270,21 @@ m4_include([m4/mbrtowc.m4]) m4_include([m4/mbsinit.m4]) m4_include([m4/mbstate_t.m4]) m4_include([m4/memchr.m4]) +m4_include([m4/mempcpy.m4]) +m4_include([m4/memrchr.m4]) m4_include([m4/minmax.m4]) m4_include([m4/mkdir.m4]) +m4_include([m4/mkdirat.m4]) m4_include([m4/mktime.m4]) m4_include([m4/mmap-anon.m4]) +m4_include([m4/mode_t.m4]) m4_include([m4/msvc-inval.m4]) m4_include([m4/msvc-nothrow.m4]) m4_include([m4/multiarch.m4]) m4_include([m4/nocrash.m4]) m4_include([m4/off_t.m4]) +m4_include([m4/open.m4]) +m4_include([m4/openat.m4]) m4_include([m4/opendir.m4]) m4_include([m4/parse-datetime.m4]) m4_include([m4/pathmax.m4]) @@ -1280,11 +1294,14 @@ m4_include([m4/quotearg.m4]) m4_include([m4/raise.m4]) m4_include([m4/readdir.m4]) m4_include([m4/readlink.m4]) +m4_include([m4/readlinkat.m4]) m4_include([m4/realloc.m4]) m4_include([m4/rename.m4]) +m4_include([m4/renameat.m4]) m4_include([m4/rmdir.m4]) m4_include([m4/safe-read.m4]) m4_include([m4/safe-write.m4]) +m4_include([m4/save-cwd.m4]) m4_include([m4/secure_getenv.m4]) m4_include([m4/setenv.m4]) m4_include([m4/setmode.m4]) @@ -1300,11 +1317,13 @@ m4_include([m4/stdint.m4]) m4_include([m4/stdint_h.m4]) m4_include([m4/stdio_h.m4]) m4_include([m4/stdlib_h.m4]) +m4_include([m4/strdup.m4]) m4_include([m4/strerror.m4]) m4_include([m4/string_h.m4]) m4_include([m4/strndup.m4]) m4_include([m4/strnlen.m4]) m4_include([m4/symlink.m4]) +m4_include([m4/symlinkat.m4]) m4_include([m4/sys_socket_h.m4]) m4_include([m4/sys_stat_h.m4]) m4_include([m4/sys_time_h.m4]) @@ -1317,8 +1336,10 @@ m4_include([m4/tm_gmtoff.m4]) m4_include([m4/unistd-safer.m4]) m4_include([m4/unistd_h.m4]) m4_include([m4/unlink.m4]) +m4_include([m4/unlinkat.m4]) m4_include([m4/utimbuf.m4]) m4_include([m4/utimens.m4]) +m4_include([m4/utimensat.m4]) m4_include([m4/utimes.m4]) m4_include([m4/vasnprintf.m4]) m4_include([m4/vasprintf.m4]) diff --git a/build-aux/config.guess b/build-aux/config.guess index 6c32c86..dbfb978 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-11-04' +timestamp='2015-01-01' # 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 @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." diff --git a/build-aux/config.sub b/build-aux/config.sub index 7cc68ba..6d2e94c 100755 --- a/build-aux/config.sub +++ b/build-aux/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2014 Free Software Foundation, Inc. +# Copyright 1992-2015 Free Software Foundation, Inc. -timestamp='2014-09-26' +timestamp='2015-01-01' # 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 @@ -68,7 +68,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2014 Free Software Foundation, Inc. +Copyright 1992-2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -260,7 +260,7 @@ case $basic_machine in | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ - | fido | fr30 | frv \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ @@ -313,6 +313,7 @@ case $basic_machine in | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -440,6 +441,7 @@ case $basic_machine in | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ diff --git a/build-aux/depcomp b/build-aux/depcomp index 3178801..fda2463 100755 --- a/build-aux/depcomp +++ b/build-aux/depcomp @@ -3,7 +3,7 @@ scriptversion=2013-05-30.07; # UTC -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2015 Free Software Foundation, Inc. # This 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/build-aux/git-version-gen b/build-aux/git-version-gen index 47d6576..8e92c0a 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,8 +1,8 @@ #!/bin/sh # Print a version string. -scriptversion=2014-06-19.19; # UTC +scriptversion=2014-12-02.19; # UTC -# Copyright (C) 2007-2014 Free Software Foundation, Inc. +# Copyright (C) 2007-2015 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -215,7 +215,7 @@ if test "x$v_from_git" != x; then fi # Omit the trailing newline, so that m4_esyscmd can use the result directly. -echo "$v" | tr -d "$nl" +printf %s "$v" # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog index 190f7b5..de934c2 100755 --- a/build-aux/gitlog-to-changelog +++ b/build-aux/gitlog-to-changelog @@ -9,7 +9,7 @@ my $VERSION = '2014-11-20 17:25'; # UTC # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -# Copyright (C) 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2008-2015 Free Software Foundation, Inc. # This 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/build-aux/mdate-sh b/build-aux/mdate-sh index b3719cf..b793600 100755 --- a/build-aux/mdate-sh +++ b/build-aux/mdate-sh @@ -3,7 +3,7 @@ scriptversion=2010-08-21.06; # UTC -# Copyright (C) 1995-2013 Free Software Foundation, Inc. +# Copyright (C) 1995-2015 Free Software Foundation, Inc. # written by Ulrich Drepper , June 1995 # # This program is free software; you can redistribute it and/or modify diff --git a/build-aux/snippet/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h index 9ee8b15..0d55e2b 100644 --- a/build-aux/snippet/arg-nonnull.h +++ b/build-aux/snippet/arg-nonnull.h @@ -1,5 +1,5 @@ /* A C macro for declaring that specific arguments must not be NULL. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. 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/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h index 67b1233..585b38a 100644 --- a/build-aux/snippet/c++defs.h +++ b/build-aux/snippet/c++defs.h @@ -1,5 +1,5 @@ /* C++ compatible function declaration macros. - Copyright (C) 2010-2014 Free Software Foundation, Inc. + Copyright (C) 2010-2015 Free Software Foundation, Inc. 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/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h index 1c4d7bd..90f4985 100644 --- a/build-aux/snippet/warn-on-use.h +++ b/build-aux/snippet/warn-on-use.h @@ -1,5 +1,5 @@ /* A C macro for emitting warnings if a function is used. - Copyright (C) 2010-2014 Free Software Foundation, Inc. + Copyright (C) 2010-2015 Free Software Foundation, Inc. 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/build-aux/texinfo.tex b/build-aux/texinfo.tex index 54cf667..7f5f357 100644 --- a/build-aux/texinfo.tex +++ b/build-aux/texinfo.tex @@ -3,11 +3,12 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2014-11-14.07} +\def\texinfoversion{2015-01-30.16} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. +% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 +% Free Software Foundation, Inc. % % This texinfo.tex file is free software: you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -96,7 +97,9 @@ \let\ptexraggedright=\raggedright \let\ptexrbrace=\} \let\ptexslash=\/ +\let\ptexsp=\sp \let\ptexstar=\* +\let\ptexsup=\sup \let\ptext=\t \let\ptextop=\top {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode @@ -2081,12 +2084,9 @@ end \endgroup } - % In order for the font changes to affect most math symbols and letters, -% we have to define the \textfont of the standard families. Since -% texinfo doesn't allow for producing subscripts and superscripts except -% in the main text, we don't bother to reset \scriptfont and -% \scriptscriptfont (which would also require loading a lot more fonts). +% we have to define the \textfont of the standard families. We don't +% bother to reset \scriptfont and \scriptscriptfont; awaiting user need. % \def\resetmathfonts{% \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy @@ -2100,8 +2100,8 @@ end % \tenSTYLE to set the current font. % % Each font-changing command also sets the names \lsize (one size lower) -% and \lllsize (three sizes lower). These relative commands are used in -% the LaTeX logo and acronyms. +% and \lllsize (three sizes lower). These relative commands are used +% in, e.g., the LaTeX logo and acronyms. % % This all needs generalizing, badly. % @@ -2842,6 +2842,8 @@ end \let\v=\check \let\~=\tilde \let\dotaccent=\dot + % have to provide another name for sup operator + \let\mathopsup=\sup $\finishmath } \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. @@ -2865,6 +2867,18 @@ end } } +% for @sub and @sup, if in math mode, just do a normal sub/superscript. +% If in text, use math to place as sub/superscript, but switch +% into text mode, with smaller fonts. This is a different font than the +% one used for real math sub/superscripts (8pt vs. 7pt), but let's not +% fix it (significant additions to font machinery) until someone notices. +% +\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi} +\def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}% +% +\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi} +\def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}% + % ctrl is no longer a Texinfo command, but leave this definition for fun. \def\ctrl #1{{\tt \rawbackslash \hat}#1} @@ -6335,6 +6349,7 @@ end % other math active characters (just in case), to plain's definitions. \mathactive % + % Inverse of the list at the beginning of the file. \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc @@ -6350,7 +6365,9 @@ end \let\+=\tabalign \let\}=\ptexrbrace \let\/=\ptexslash + \let\sp=\ptexsp \let\*=\ptexstar + %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode \let\t=\ptext \expandafter \let\csname top\endcsname=\ptextop % we've made it outer \let\frenchspacing=\plainfrenchspacing @@ -7416,7 +7433,6 @@ end % % \anythingelse will almost certainly be an error of some kind. - % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. @@ -7525,8 +7541,7 @@ end % the catcode regime underwhich the body was input). % % If you compile with TeX (not eTeX), and you have macros with 10 or more -% arguments, you need that no macro has more than 256 arguments, otherwise an -% error is produced. +% arguments, no macro can have more than 256 arguments (else error). \def\parsemargdef#1;{% \paramno=0\def\paramlist{}% \let\hash\relax @@ -8938,6 +8953,7 @@ directory should work if nowhere else does.} \catcode\count255=#1\relax \advance\count255 by 1 \repeat + } % @documentencoding sets the definition of non-ASCII characters @@ -8975,7 +8991,7 @@ directory should work if nowhere else does.} \utfeightchardefs % \else - \message{Unknown document encoding #1, ignoring.}% + \message{Ignoring unknown document encoding: #1.}% % \fi % utfeight \fi % latnine @@ -8984,10 +9000,11 @@ directory should work if nowhere else does.} \fi % ascii } +% emacs-page % A message to be logged when using a character that isn't available % the default font encoding (OT1). % -\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} +\def\missingcharmsg#1{\message{Character missing, sorry: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} @@ -9023,12 +9040,10 @@ directory should work if nowhere else does.} \gdef^^b4{\'{}} \gdef^^b5{$\mu$} \gdef^^b6{\P} - % - \gdef^^b7{$^.$} + \gdef^^b7{\ifmmode\cdot\else $\cdot$\fi} \gdef^^b8{\cedilla\ } \gdef^^b9{$^1$} \gdef^^ba{\ordm} - % \gdef^^bb{\guillemetright} \gdef^^bc{$1\over4$} \gdef^^bd{$1\over2$} @@ -9283,6 +9298,18 @@ directory should work if nowhere else does.} \UTFviiiLoop \endgroup +\def\globallet{\global\let} % save some \expandafter's below + +% @U{xxxx} to produce U+xxxx, if we support it. +\def\U#1{% + \expandafter\ifx\csname uni:#1\endcsname \relax + \errhelp = \EMsimple + \errmessage{Unicode character U+#1 not supported, sorry}% + \else + \csname uni:#1\endcsname + \fi +} + \begingroup \catcode`\"=12 \catcode`\<=12 @@ -9291,7 +9318,6 @@ directory should work if nowhere else does.} \catcode`\;=12 \catcode`\!=12 \catcode`\~=13 - \gdef\DeclareUnicodeCharacter#1#2{% \countUTFz = "#1\relax %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% @@ -9306,6 +9332,13 @@ directory should work if nowhere else does.} \expandafter\expandafter\expandafter\expandafter \expandafter\expandafter\expandafter \gdef\UTFviiiTmp{#2}% + % + \expandafter\ifx\csname uni:#1\endcsname \relax \else + \errmessage{Internal error, already defined: #1}% + \fi + % + % define an additional control sequence for this code point. + \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp \endgroup} \gdef\parseXMLCharref{% @@ -9343,23 +9376,49 @@ directory should work if nowhere else does.} \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} \endgroup +% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M +% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) +% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) +% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A +% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B +% +% Many of our renditions are less than wonderful, and all the missing +% characters are available somewhere. Loading the necessary fonts +% awaits user request. We can't truly support Unicode without +% reimplementing everything that's been done in LaTeX for many years, +% plus probably using luatex or xetex, and who knows what else. +% We won't be doing that here in this simple file. But we can try to at +% least make most of the characters not bomb out. +% \def\utfeightchardefs{% \DeclareUnicodeCharacter{00A0}{\tie} \DeclareUnicodeCharacter{00A1}{\exclamdown} \DeclareUnicodeCharacter{00A3}{\pounds} + \DeclareUnicodeCharacter{00A7}{\S} \DeclareUnicodeCharacter{00A8}{\"{ }} \DeclareUnicodeCharacter{00A9}{\copyright} \DeclareUnicodeCharacter{00AA}{\ordf} \DeclareUnicodeCharacter{00AB}{\guillemetleft} + \DeclareUnicodeCharacter{00AC}{\ifmmode\lnot\else $\lnot$\fi} \DeclareUnicodeCharacter{00AD}{\-} \DeclareUnicodeCharacter{00AE}{\registeredsymbol} \DeclareUnicodeCharacter{00AF}{\={ }} \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} + \DeclareUnicodeCharacter{00B1}{\ifmmode\pm\else $\pm$\fi} + \DeclareUnicodeCharacter{00B2}{$^2$} + \DeclareUnicodeCharacter{00B3}{$^3$} \DeclareUnicodeCharacter{00B4}{\'{ }} + \DeclareUnicodeCharacter{00B5}{$\mu$} + \DeclareUnicodeCharacter{00B6}{\P} + \DeclareUnicodeCharacter{00B7}{\ifmmode\cdot\else $\cdot$\fi} \DeclareUnicodeCharacter{00B8}{\cedilla{ }} + \DeclareUnicodeCharacter{00B9}{$^1$} \DeclareUnicodeCharacter{00BA}{\ordm} \DeclareUnicodeCharacter{00BB}{\guillemetright} + \DeclareUnicodeCharacter{00BC}{$1\over4$} + \DeclareUnicodeCharacter{00BD}{$1\over2$} + \DeclareUnicodeCharacter{00BE}{$3\over4$} \DeclareUnicodeCharacter{00BF}{\questiondown} \DeclareUnicodeCharacter{00C0}{\`A} @@ -9386,6 +9445,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{00D4}{\^O} \DeclareUnicodeCharacter{00D5}{\~O} \DeclareUnicodeCharacter{00D6}{\"O} + \DeclareUnicodeCharacter{00D7}{\ifmmode\times\else $\times$\fi} \DeclareUnicodeCharacter{00D8}{\O} \DeclareUnicodeCharacter{00D9}{\`U} \DeclareUnicodeCharacter{00DA}{\'U} @@ -9419,6 +9479,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{00F4}{\^o} \DeclareUnicodeCharacter{00F5}{\~o} \DeclareUnicodeCharacter{00F6}{\"o} + \DeclareUnicodeCharacter{00F7}{\ifmmode\div\else $\div$\fi} \DeclareUnicodeCharacter{00F8}{\o} \DeclareUnicodeCharacter{00F9}{\`u} \DeclareUnicodeCharacter{00FA}{\'u} @@ -9438,20 +9499,23 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0107}{\'c} \DeclareUnicodeCharacter{0108}{\^C} \DeclareUnicodeCharacter{0109}{\^c} - \DeclareUnicodeCharacter{0118}{\ogonek{E}} - \DeclareUnicodeCharacter{0119}{\ogonek{e}} \DeclareUnicodeCharacter{010A}{\dotaccent{C}} \DeclareUnicodeCharacter{010B}{\dotaccent{c}} \DeclareUnicodeCharacter{010C}{\v{C}} \DeclareUnicodeCharacter{010D}{\v{c}} \DeclareUnicodeCharacter{010E}{\v{D}} + \DeclareUnicodeCharacter{010F}{d'} + \DeclareUnicodeCharacter{0110}{\DH} + \DeclareUnicodeCharacter{0111}{\dh} \DeclareUnicodeCharacter{0112}{\=E} \DeclareUnicodeCharacter{0113}{\=e} \DeclareUnicodeCharacter{0114}{\u{E}} \DeclareUnicodeCharacter{0115}{\u{e}} \DeclareUnicodeCharacter{0116}{\dotaccent{E}} \DeclareUnicodeCharacter{0117}{\dotaccent{e}} + \DeclareUnicodeCharacter{0118}{\ogonek{E}} + \DeclareUnicodeCharacter{0119}{\ogonek{e}} \DeclareUnicodeCharacter{011A}{\v{E}} \DeclareUnicodeCharacter{011B}{\v{e}} \DeclareUnicodeCharacter{011C}{\^G} @@ -9461,14 +9525,20 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0120}{\dotaccent{G}} \DeclareUnicodeCharacter{0121}{\dotaccent{g}} + \DeclareUnicodeCharacter{0122}{\cedilla{G}} + \DeclareUnicodeCharacter{0123}{\cedilla{g}} \DeclareUnicodeCharacter{0124}{\^H} \DeclareUnicodeCharacter{0125}{\^h} + \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}} + \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}} \DeclareUnicodeCharacter{0128}{\~I} \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} \DeclareUnicodeCharacter{012A}{\=I} \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} \DeclareUnicodeCharacter{012C}{\u{I}} \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} + \DeclareUnicodeCharacter{012E}{\ogonek{I}} + \DeclareUnicodeCharacter{012F}{\ogonek{i}} \DeclareUnicodeCharacter{0130}{\dotaccent{I}} \DeclareUnicodeCharacter{0131}{\dotless{i}} @@ -9476,15 +9546,29 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0133}{ij} \DeclareUnicodeCharacter{0134}{\^J} \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} + \DeclareUnicodeCharacter{0136}{\cedilla{K}} + \DeclareUnicodeCharacter{0137}{\cedilla{k}} + \DeclareUnicodeCharacter{0138}{\ifmmode\kappa\else $\kappa$\fi} \DeclareUnicodeCharacter{0139}{\'L} \DeclareUnicodeCharacter{013A}{\'l} + \DeclareUnicodeCharacter{013B}{\cedilla{L}} + \DeclareUnicodeCharacter{013C}{\cedilla{l}} + \DeclareUnicodeCharacter{013D}{L'}% should kern + \DeclareUnicodeCharacter{013E}{l'}% should kern + \DeclareUnicodeCharacter{013F}{L\U{00B7}} + \DeclareUnicodeCharacter{0140}{l\U{00B7}} \DeclareUnicodeCharacter{0141}{\L} \DeclareUnicodeCharacter{0142}{\l} \DeclareUnicodeCharacter{0143}{\'N} \DeclareUnicodeCharacter{0144}{\'n} + \DeclareUnicodeCharacter{0145}{\cedilla{N}} + \DeclareUnicodeCharacter{0146}{\cedilla{n}} \DeclareUnicodeCharacter{0147}{\v{N}} \DeclareUnicodeCharacter{0148}{\v{n}} + \DeclareUnicodeCharacter{0149}{'n} + \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}} + \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}} \DeclareUnicodeCharacter{014C}{\=O} \DeclareUnicodeCharacter{014D}{\=o} \DeclareUnicodeCharacter{014E}{\u{O}} @@ -9496,6 +9580,8 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0153}{\oe} \DeclareUnicodeCharacter{0154}{\'R} \DeclareUnicodeCharacter{0155}{\'r} + \DeclareUnicodeCharacter{0156}{\cedilla{R}} + \DeclareUnicodeCharacter{0157}{\cedilla{r}} \DeclareUnicodeCharacter{0158}{\v{R}} \DeclareUnicodeCharacter{0159}{\v{r}} \DeclareUnicodeCharacter{015A}{\'S} @@ -9507,10 +9593,12 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0160}{\v{S}} \DeclareUnicodeCharacter{0161}{\v{s}} - \DeclareUnicodeCharacter{0162}{\cedilla{t}} - \DeclareUnicodeCharacter{0163}{\cedilla{T}} + \DeclareUnicodeCharacter{0162}{\cedilla{T}} + \DeclareUnicodeCharacter{0163}{\cedilla{t}} \DeclareUnicodeCharacter{0164}{\v{T}} - + \DeclareUnicodeCharacter{0165}{\v{t}} + \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}} + \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}} \DeclareUnicodeCharacter{0168}{\~U} \DeclareUnicodeCharacter{0169}{\~u} \DeclareUnicodeCharacter{016A}{\=U} @@ -9522,6 +9610,8 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{0170}{\H{U}} \DeclareUnicodeCharacter{0171}{\H{u}} + \DeclareUnicodeCharacter{0172}{\ogonek{U}} + \DeclareUnicodeCharacter{0173}{\ogonek{u}} \DeclareUnicodeCharacter{0174}{\^W} \DeclareUnicodeCharacter{0175}{\^w} \DeclareUnicodeCharacter{0176}{\^Y} @@ -9533,6 +9623,7 @@ directory should work if nowhere else does.} \DeclareUnicodeCharacter{017C}{\dotaccent{z}} \DeclareUnicodeCharacter{017D}{\v{Z}} \DeclareUnicodeCharacter{017E}{\v{z}} + \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}} \DeclareUnicodeCharacter{01C4}{D\v{Z}} \DeclareUnicodeCharacter{01C5}{D\v{z}} @@ -9744,6 +9835,9 @@ directory should work if nowhere else does.} \relax } +% define all the unicode characters we know about, for the sake of @U. +\utfeightchardefs + % Make non-ASCII characters printable again for compatibility with % existing Texinfo documents that may use them, even without declaring a % document encoding. @@ -10165,7 +10259,7 @@ directory should work if nowhere else does.} @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) -@c page-delimiter: "^\\\\message" +@c page-delimiter: "^\\\\message\\|emacs-page" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" diff --git a/build-aux/update-copyright b/build-aux/update-copyright index 90624e9..4eb4b93 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -3,9 +3,9 @@ eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" ${1+"$@"}' if 0; # Update an FSF copyright year list to include the current year. -my $VERSION = '2013-01-03.09:41'; # UTC +my $VERSION = '2015-01-15.20:53'; # UTC -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -124,7 +124,7 @@ use strict; use warnings; my $copyright_re = 'Copyright'; -my $circle_c_re = '(?:\([cC]\)|@copyright{}|©)'; +my $circle_c_re = '(?:\([cC]\)|@copyright{}|\\\\\(co|©)'; my $holder = $ENV{UPDATE_COPYRIGHT_HOLDER}; $holder ||= 'Free Software Foundation, Inc.'; my $prefix_max = 5; diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free index 4c76c75..82a09b3 100755 --- a/build-aux/useless-if-before-free +++ b/build-aux/useless-if-before-free @@ -10,7 +10,7 @@ my $VERSION = '2012-01-06 07:23'; # UTC # If you change this file with Emacs, please let the write hook # do its job. Otherwise, update this string manually. -# Copyright (C) 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2008-2015 Free Software Foundation, Inc. # This 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/build-aux/vc-list-files b/build-aux/vc-list-files index b2bca54..3bf93c3 100755 --- a/build-aux/vc-list-files +++ b/build-aux/vc-list-files @@ -4,7 +4,7 @@ # Print a version string. scriptversion=2011-05-16.22; # UTC -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2015 Free Software Foundation, Inc. # This 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/config.hin b/config.hin index 3044f2d..f15a9cd 100644 --- a/config.hin +++ b/config.hin @@ -18,6 +18,19 @@ /* Define to the number of bits in type 'wint_t'. */ #undef BITSIZEOF_WINT_T +/* Define to 1 if chown fails to change ctime when at least one argument was + not -1. */ +#undef CHOWN_CHANGE_TIME_BUG + +/* Define if chown is not POSIX compliant regarding IDs of -1. */ +#undef CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE + +/* Define if chown modifies symlinks. */ +#undef CHOWN_MODIFIES_SYMLINK + +/* Define to 1 if chown mishandles trailing slash. */ +#undef CHOWN_TRAILING_SLASH_BUG + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ @@ -52,6 +65,14 @@ /* Name of editor program. */ #undef EDITOR_PROGRAM +/* Define to 1 if your platform has fchownat, but it does not reject an empty + file name. */ +#undef FCHOWNAT_EMPTY_FILENAME_BUG + +/* Define to 1 if your platform has fchownat, but it cannot perform lchown + tasks. */ +#undef FCHOWNAT_NOFOLLOW_BUG + /* Define this to 1 if F_DUPFD behavior does not match POSIX */ #undef FCNTL_DUPFD_BUGGY @@ -85,6 +106,14 @@ whether the gnulib module dirname shall be considered present. */ #undef GNULIB_DIRNAME +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fchmodat shall be considered present. */ +#undef GNULIB_FCHMODAT + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fchownat shall be considered present. */ +#undef GNULIB_FCHOWNAT + /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module fscanf shall be considered present. */ #undef GNULIB_FSCANF @@ -93,9 +122,17 @@ whether the gnulib module malloc-gnu shall be considered present. */ #undef GNULIB_MALLOC_GNU +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module openat shall be considered present. */ +#undef GNULIB_OPENAT + /* enable some gnulib portability checks */ #undef GNULIB_PORTCHECK +/* Define to 1 if printf and friends should be labeled with attribute + "__gnu_printf__" instead of "__printf__" */ +#undef GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU + /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module realloc-gnu shall be considered present. */ #undef GNULIB_REALLOC_GNU @@ -104,6 +141,10 @@ whether the gnulib module scanf shall be considered present. */ #undef GNULIB_SCANF +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module statat shall be considered present. */ +#undef GNULIB_STATAT + /* Define to a C preprocessor expression that evaluates to 1 or 0, depending whether the gnulib module strerror shall be considered present. */ #undef GNULIB_STRERROR @@ -115,6 +156,12 @@ /* Define to 1 when the gnulib module chdir should be tested. */ #undef GNULIB_TEST_CHDIR +/* Define to 1 when the gnulib module chown should be tested. */ +#undef GNULIB_TEST_CHOWN + +/* Define to 1 when the gnulib module cloexec should be tested. */ +#undef GNULIB_TEST_CLOEXEC + /* Define to 1 when the gnulib module close should be tested. */ #undef GNULIB_TEST_CLOSE @@ -130,12 +177,27 @@ /* Define to 1 when the gnulib module environ should be tested. */ #undef GNULIB_TEST_ENVIRON +/* Define to 1 when the gnulib module fchdir should be tested. */ +#undef GNULIB_TEST_FCHDIR + +/* Define to 1 when the gnulib module fchmodat should be tested. */ +#undef GNULIB_TEST_FCHMODAT + +/* Define to 1 when the gnulib module fchownat should be tested. */ +#undef GNULIB_TEST_FCHOWNAT + /* Define to 1 when the gnulib module fcntl should be tested. */ #undef GNULIB_TEST_FCNTL /* Define to 1 when the gnulib module fstat should be tested. */ #undef GNULIB_TEST_FSTAT +/* Define to 1 when the gnulib module fstatat should be tested. */ +#undef GNULIB_TEST_FSTATAT + +/* Define to 1 when the gnulib module getcwd should be tested. */ +#undef GNULIB_TEST_GETCWD + /* Define to 1 when the gnulib module getdtablesize should be tested. */ #undef GNULIB_TEST_GETDTABLESIZE @@ -145,8 +207,8 @@ /* Define to 1 when the gnulib module gettimeofday should be tested. */ #undef GNULIB_TEST_GETTIMEOFDAY -/* Define to 1 when the gnulib module lchmod should be tested. */ -#undef GNULIB_TEST_LCHMOD +/* Define to 1 when the gnulib module lchown should be tested. */ +#undef GNULIB_TEST_LCHOWN /* Define to 1 when the gnulib module lstat should be tested. */ #undef GNULIB_TEST_LSTAT @@ -163,9 +225,24 @@ /* Define to 1 when the gnulib module memchr should be tested. */ #undef GNULIB_TEST_MEMCHR +/* Define to 1 when the gnulib module mempcpy should be tested. */ +#undef GNULIB_TEST_MEMPCPY + +/* Define to 1 when the gnulib module memrchr should be tested. */ +#undef GNULIB_TEST_MEMRCHR + +/* Define to 1 when the gnulib module mkdirat should be tested. */ +#undef GNULIB_TEST_MKDIRAT + /* Define to 1 when the gnulib module mktime should be tested. */ #undef GNULIB_TEST_MKTIME +/* Define to 1 when the gnulib module open should be tested. */ +#undef GNULIB_TEST_OPEN + +/* Define to 1 when the gnulib module openat should be tested. */ +#undef GNULIB_TEST_OPENAT + /* Define to 1 when the gnulib module opendir should be tested. */ #undef GNULIB_TEST_OPENDIR @@ -178,6 +255,9 @@ /* Define to 1 when the gnulib module readlink should be tested. */ #undef GNULIB_TEST_READLINK +/* Define to 1 when the gnulib module readlinkat should be tested. */ +#undef GNULIB_TEST_READLINKAT + /* Define to 1 when the gnulib module realloc-posix should be tested. */ #undef GNULIB_TEST_REALLOC_POSIX @@ -187,6 +267,9 @@ /* Define to 1 when the gnulib module rename should be tested. */ #undef GNULIB_TEST_RENAME +/* Define to 1 when the gnulib module renameat should be tested. */ +#undef GNULIB_TEST_RENAMEAT + /* Define to 1 when the gnulib module rmdir should be tested. */ #undef GNULIB_TEST_RMDIR @@ -199,6 +282,9 @@ /* Define to 1 when the gnulib module stat should be tested. */ #undef GNULIB_TEST_STAT +/* Define to 1 when the gnulib module strdup should be tested. */ +#undef GNULIB_TEST_STRDUP + /* Define to 1 when the gnulib module strerror should be tested. */ #undef GNULIB_TEST_STRERROR @@ -211,15 +297,24 @@ /* Define to 1 when the gnulib module symlink should be tested. */ #undef GNULIB_TEST_SYMLINK +/* Define to 1 when the gnulib module symlinkat should be tested. */ +#undef GNULIB_TEST_SYMLINKAT + /* Define to 1 when the gnulib module time_r should be tested. */ #undef GNULIB_TEST_TIME_R /* Define to 1 when the gnulib module unlink should be tested. */ #undef GNULIB_TEST_UNLINK +/* Define to 1 when the gnulib module unlinkat should be tested. */ +#undef GNULIB_TEST_UNLINKAT + /* Define to 1 when the gnulib module unsetenv should be tested. */ #undef GNULIB_TEST_UNSETENV +/* Define to 1 when the gnulib module utimensat should be tested. */ +#undef GNULIB_TEST_UTIMENSAT + /* Define to 1 when the gnulib module vasprintf should be tested. */ #undef GNULIB_TEST_VASPRINTF @@ -252,6 +347,9 @@ /* Define to 1 if you have the `canonicalize_file_name' function. */ #undef HAVE_CANONICALIZE_FILE_NAME +/* Define to 1 if you have the `chown' function. */ +#undef HAVE_CHOWN + /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME @@ -272,6 +370,10 @@ */ #undef HAVE_DECL_DIRFD +/* Define to 1 if you have the declaration of `fchdir', and to 0 if you don't. + */ +#undef HAVE_DECL_FCHDIR + /* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_GETC_UNLOCKED @@ -292,6 +394,10 @@ don't. */ #undef HAVE_DECL_MBSINIT +/* Define to 1 if you have the declaration of `memrchr', and to 0 if you + don't. */ +#undef HAVE_DECL_MEMRCHR + /* Define to 1 if you have the declaration of `program_invocation_name', and to 0 if you don't. */ #undef HAVE_DECL_PROGRAM_INVOCATION_NAME @@ -304,6 +410,10 @@ */ #undef HAVE_DECL_SETENV +/* Define to 1 if you have the declaration of `strdup', and to 0 if you don't. + */ +#undef HAVE_DECL_STRDUP + /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R @@ -344,6 +454,15 @@ /* Define if you have the declaration of environ. */ #undef HAVE_ENVIRON_DECL +/* Define to 1 if you have the `fchdir' function. */ +#undef HAVE_FCHDIR + +/* Define to 1 if you have the `fchmodat' function. */ +#undef HAVE_FCHMODAT + +/* Define to 1 if you have the `fchown' function. */ +#undef HAVE_FCHOWN + /* Define to 1 if you have the `fcntl' function. */ #undef HAVE_FCNTL @@ -356,6 +475,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H +/* Define to 1 if you have the `fstatat' function. */ +#undef HAVE_FSTATAT + /* Define to 1 if you have the `futimens' function. */ #undef HAVE_FUTIMENS @@ -408,6 +530,9 @@ /* Define to 1 if you have the `lchmod' function. */ #undef HAVE_LCHMOD +/* Define to 1 if you have the `lchown' function. */ +#undef HAVE_LCHOWN + /* Define to 1 if you have the `link' function. */ #undef HAVE_LINK @@ -449,12 +574,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* Define to 1 if you have the `mempcpy' function. */ +#undef HAVE_MEMPCPY + +/* Define to 1 if you have the `memrchr' function. */ +#undef HAVE_MEMRCHR + /* Define to 1 if defines the MIN and MAX macros. */ #undef HAVE_MINMAX_IN_LIMITS_H /* Define to 1 if defines the MIN and MAX macros. */ #undef HAVE_MINMAX_IN_SYS_PARAM_H +/* Define to 1 if you have the `mkdirat' function. */ +#undef HAVE_MKDIRAT + /* Define to 1 if you have the `mprotect' function. */ #undef HAVE_MPROTECT @@ -465,6 +599,9 @@ /* Define to 1 if you have the `nanotime' function. */ #undef HAVE_NANOTIME +/* Define to 1 if you have the `openat' function. */ +#undef HAVE_OPENAT + /* Define to 1 if you have the `opendir' function. */ #undef HAVE_OPENDIR @@ -1042,6 +1179,9 @@ /* Define to 1 if you have the `readlink' function. */ #undef HAVE_READLINK +/* Define to 1 if you have the `readlinkat' function. */ +#undef HAVE_READLINKAT + /* Define to 1 if your system has a GNU libc compatible 'realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC_GNU @@ -1052,6 +1192,9 @@ /* Define to 1 if you have the `realpath' function. */ #undef HAVE_REALPATH +/* Define to 1 if you have the `renameat' function. */ +#undef HAVE_RENAMEAT + /* Define to 1 if you have the header file. */ #undef HAVE_SEARCH_H @@ -1106,6 +1249,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R @@ -1152,6 +1298,9 @@ /* Define to 1 if you have the `symlink' function. */ #undef HAVE_SYMLINK +/* Define to 1 if you have the `symlinkat' function. */ +#undef HAVE_SYMLINKAT + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BITYPES_H @@ -1199,6 +1348,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `unlinkat' function. */ +#undef HAVE_UNLINKAT + /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV @@ -1241,6 +1393,10 @@ /* Define if you have the 'wint_t' type. */ #undef HAVE_WINT_T +/* Define to 1 if fstatat (..., 0) works. For example, it does not work in AIX + 7.1. */ +#undef HAVE_WORKING_FSTATAT_ZERO_FLAG + /* Define to 1 if O_NOATIME works. */ #undef HAVE_WORKING_O_NOATIME @@ -1288,6 +1444,9 @@ /* Define if the mbrtowc function returns a wrong return value. */ #undef MBRTOWC_RETVAL_BUG +/* Define to 1 if open() fails to recognize a trailing slash. */ +#undef OPEN_TRAILING_SLASH_BUG + /* Name of package */ #undef PACKAGE @@ -1309,6 +1468,10 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Define to the type that is the result of default argument promotions of + type mode_t. */ +#undef PROMOTED_MODE_T + /* Define to l, ll, u, ul, ull, etc., as suitable for constants of type 'ptrdiff_t'. */ #undef PTRDIFF_T_SUFFIX @@ -1332,6 +1495,9 @@ such as on Solaris 9 or cygwin 1.5. */ #undef RENAME_TRAILING_SLASH_SOURCE_BUG +/* Define to 1 if gnulib's fchdir() replacement is used. */ +#undef REPLACE_FCHDIR + /* Define to 1 if stat needs help when passed a directory name with a trailing slash */ #undef REPLACE_FUNC_STAT_DIR @@ -1340,6 +1506,10 @@ slash */ #undef REPLACE_FUNC_STAT_FILE +/* Define to 1 if open() should work around the inability to open a directory. + */ +#undef REPLACE_OPEN_DIRECTORY + /* Define to 1 if strerror(0) does not return a message implying success. */ #undef REPLACE_STRERROR_0 @@ -1402,6 +1572,10 @@ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif +/* Use GNU style printf and scanf. */ +#ifndef __USE_MINGW_ANSI_STDIO +# undef __USE_MINGW_ANSI_STDIO +#endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS diff --git a/configure b/configure index a09350c..1e1aedc 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for GNU patch 2.7.3. +# Generated by GNU Autoconf 2.69 for GNU patch 2.7.4. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='GNU patch' PACKAGE_TARNAME='patch' -PACKAGE_VERSION='2.7.3' -PACKAGE_STRING='GNU patch 2.7.3' +PACKAGE_VERSION='2.7.4' +PACKAGE_STRING='GNU patch 2.7.4' PACKAGE_BUGREPORT='bug-patch@gnu.org' PACKAGE_URL='http://www.gnu.org/software/patch/' @@ -667,6 +667,7 @@ HAVE_FEATURES_H HAVE_UNISTD_H NEXT_AS_FIRST_DIRECTIVE_UNISTD_H NEXT_UNISTD_H +UNISTD_H_DEFINES_STRUCT_TIMESPEC PTHREAD_H_DEFINES_STRUCT_TIMESPEC SYS_TIME_H_DEFINES_STRUCT_TIMESPEC TIME_H_DEFINES_STRUCT_TIMESPEC @@ -713,6 +714,7 @@ GL_GENERATE_STDDEF_H_FALSE GL_GENERATE_STDDEF_H_TRUE STDDEF_H HAVE_WCHAR_T +HAVE_MAX_ALIGN_T REPLACE_NULL GL_GENERATE_STDARG_H_FALSE GL_GENERATE_STDARG_H_TRUE @@ -1048,6 +1050,23 @@ NEXT_GETOPT_H WINDOWS_64_BIT_ST_SIZE NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H NEXT_SYS_STAT_H +REPLACE_ITOLD +GL_GENERATE_FLOAT_H_FALSE +GL_GENERATE_FLOAT_H_TRUE +FLOAT_H +NEXT_AS_FIRST_DIRECTIVE_FLOAT_H +NEXT_FLOAT_H +NEXT_AS_FIRST_DIRECTIVE_FCNTL_H +NEXT_FCNTL_H +REPLACE_OPENAT +REPLACE_OPEN +REPLACE_FCNTL +HAVE_OPENAT +HAVE_FCNTL +GNULIB_OPENAT +GNULIB_OPEN +GNULIB_NONBLOCKING +GNULIB_FCNTL REPLACE_UTIMENSAT REPLACE_STAT REPLACE_MKNOD @@ -1081,23 +1100,6 @@ GNULIB_FUTIMENS GNULIB_FSTATAT GNULIB_FSTAT GNULIB_FCHMODAT -REPLACE_ITOLD -GL_GENERATE_FLOAT_H_FALSE -GL_GENERATE_FLOAT_H_TRUE -FLOAT_H -NEXT_AS_FIRST_DIRECTIVE_FLOAT_H -NEXT_FLOAT_H -NEXT_AS_FIRST_DIRECTIVE_FCNTL_H -NEXT_FCNTL_H -REPLACE_OPENAT -REPLACE_OPEN -REPLACE_FCNTL -HAVE_OPENAT -HAVE_FCNTL -GNULIB_OPENAT -GNULIB_OPEN -GNULIB_NONBLOCKING -GNULIB_FCNTL EOVERFLOW_VALUE EOVERFLOW_HIDDEN ENOLINK_VALUE @@ -2011,7 +2013,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GNU patch 2.7.3 to adapt to many kinds of systems. +\`configure' configures GNU patch 2.7.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -2081,7 +2083,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GNU patch 2.7.3:";; + short | recursive ) echo "Configuration of GNU patch 2.7.4:";; esac cat <<\_ACEOF @@ -2185,7 +2187,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GNU patch configure 2.7.3 +GNU patch configure 2.7.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2894,7 +2896,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GNU patch $as_me 2.7.3, which was +It was created by GNU patch $as_me 2.7.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3180,34 +3182,47 @@ as_fn_append ac_func_list " getcwd" as_fn_append ac_func_list " readlink" as_fn_append ac_func_list " realpath" as_fn_append ac_header_list " sys/param.h" +as_fn_append ac_header_list " unistd.h" +as_fn_append ac_func_list " chown" +as_fn_append ac_func_list " fchown" as_fn_append ac_func_list " _set_invalid_parameter_handler" as_fn_append ac_header_list " sys/socket.h" +as_fn_append ac_func_list " fchdir" as_fn_append ac_header_list " dirent.h" as_fn_append ac_func_list " fdopendir" as_fn_append ac_func_list " getdtablesize" -as_fn_append ac_header_list " unistd.h" +as_fn_append ac_func_list " fchmodat" +as_fn_append ac_func_list " lchmod" as_fn_append ac_func_list " fcntl" as_fn_append ac_func_list " symlink" +as_fn_append ac_func_list " mempcpy" as_fn_append ac_header_list " sys/stat.h" +as_fn_append ac_func_list " fstatat" gl_getopt_required=GNU as_fn_append ac_header_list " getopt.h" as_fn_append ac_func_list " gettimeofday" as_fn_append ac_func_list " nanotime" as_fn_append ac_header_list " sys/time.h" -as_fn_append ac_func_list " lchmod" as_fn_append ac_func_list " lstat" as_fn_append ac_func_list " mbsinit" as_fn_append ac_func_list " mbrtowc" as_fn_append ac_header_list " sys/mman.h" as_fn_append ac_func_list " mprotect" +as_fn_append ac_func_list " mkdirat" +as_fn_append ac_func_list " openat" +as_fn_append ac_func_list " readlinkat" as_fn_append ac_func_list " link" +as_fn_append ac_func_list " renameat" as_fn_append ac_func_list " secure_getenv" as_fn_append ac_func_list " setenv" as_fn_append ac_header_list " wchar.h" as_fn_append ac_header_list " stdint.h" +as_fn_append ac_func_list " strdup" as_fn_append ac_func_list " strndup" +as_fn_append ac_func_list " symlinkat" as_fn_append ac_func_list " localtime_r" as_fn_append ac_func_list " pipe" +as_fn_append ac_func_list " unlinkat" as_fn_append ac_header_list " utime.h" as_fn_append ac_func_list " futimes" as_fn_append ac_func_list " futimesat" @@ -3828,7 +3843,7 @@ fi # Define the identity of the package. PACKAGE='patch' - VERSION='2.7.3' + VERSION='2.7.4' cat >>confdefs.h <<_ACEOF @@ -5991,6 +6006,8 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + $as_echo "#define __USE_MINGW_ANSI_STDIO 1" >>confdefs.h + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h @@ -6257,6 +6274,8 @@ fi # Code from module absolute-header: # Code from module alloca-opt: # Code from module argmatch: + # Code from module assure: + # Code from module at-internal: # Code from module backupfile: # Code from module bitrotate: # Code from module c-ctype: @@ -6264,7 +6283,10 @@ fi # Code from module c-strcaseeq: # Code from module canonicalize-lgpl: # Code from module chdir: + # Code from module chdir-long: + # Code from module chown: # Code from module clock-time: + # Code from module cloexec: # Code from module close: # Code from module closedir: # Code from module configmake: @@ -6285,13 +6307,19 @@ fi # Code from module extensions: # Code from module extern-inline: + # Code from module fchdir: + # Code from module fchmodat: + # Code from module fchownat: # Code from module fcntl: # Code from module fcntl-h: # Code from module fd-hook: # Code from module filename: + # Code from module filenamecat-lgpl: # Code from module float: # Code from module fstat: + # Code from module fstatat: # Code from module full-write: + # Code from module getcwd-lgpl: # Code from module getdate: # Code from module getdtablesize: # Code from module getopt-gnu: @@ -6308,7 +6336,7 @@ fi # Code from module intprops: # Code from module largefile: - # Code from module lchmod: + # Code from module lchown: # Code from module linked-list: # Code from module list: # Code from module localcharset: @@ -6322,13 +6350,20 @@ fi # Code from module mbrtowc: # Code from module mbsinit: # Code from module memchr: + # Code from module mempcpy: + # Code from module memrchr: # Code from module minmax: # Code from module mkdir: + # Code from module mkdirat: # Code from module mktime: # Code from module msvc-inval: # Code from module msvc-nothrow: # Code from module multiarch: # Code from module nocrash: + # Code from module open: + # Code from module openat: + # Code from module openat-die: + # Code from module openat-h: # Code from module opendir: # Code from module parse-datetime: # Code from module pathmax: @@ -6339,13 +6374,16 @@ fi # Code from module raise: # Code from module readdir: # Code from module readlink: + # Code from module readlinkat: # Code from module realloc: # Code from module realloc-gnu: # Code from module realloc-posix: # Code from module rename: + # Code from module renameat: # Code from module rmdir: # Code from module safe-write: # Code from module same-inode: + # Code from module save-cwd: # Code from module secure_getenv: # Code from module setenv: # Code from module signal: @@ -6358,6 +6396,7 @@ fi # Code from module ssize_t: # Code from module stat: # Code from module stat-time: + # Code from module statat: # Code from module stdarg: @@ -6367,6 +6406,7 @@ fi # Code from module stdint: # Code from module stdio: # Code from module stdlib: + # Code from module strdup-posix: # Code from module streq: # Code from module strerror: # Code from module strerror-override: @@ -6374,6 +6414,7 @@ fi # Code from module strndup: # Code from module strnlen: # Code from module symlink: + # Code from module symlinkat: # Code from module sys_stat: # Code from module sys_time: # Code from module sys_types: @@ -6384,10 +6425,12 @@ fi # Code from module unistd: # Code from module unistd-safer: # Code from module unlink: + # Code from module unlinkat: # Code from module unsetenv: # Code from module update-copyright: # Code from module useless-if-before-free: # Code from module utimens: + # Code from module utimensat: # Code from module vasnprintf: # Code from module vasprintf: # Code from module vc-list-files: @@ -7395,159 +7438,169 @@ done - if test $ac_cv_func__set_invalid_parameter_handler = yes; then - HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 -$as_echo "#define HAVE_MSVC_INVALID_PARAMETER_HANDLER 1" >>confdefs.h +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 +$as_echo_n "checking for uid_t in sys/types.h... " >&6; } +if ${ac_cv_type_uid_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include - else - HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 - fi +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then : + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 +$as_echo "$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then +$as_echo "#define uid_t int" >>confdefs.h +$as_echo "#define gid_t int" >>confdefs.h +fi - GNULIB_OPENDIR=0; - GNULIB_READDIR=0; - GNULIB_REWINDDIR=0; - GNULIB_CLOSEDIR=0; - GNULIB_DIRFD=0; - GNULIB_FDOPENDIR=0; - GNULIB_SCANDIR=0; - GNULIB_ALPHASORT=0; - HAVE_OPENDIR=1; - HAVE_READDIR=1; - HAVE_REWINDDIR=1; - HAVE_CLOSEDIR=1; - HAVE_DECL_DIRFD=1; - HAVE_DECL_FDOPENDIR=1; - HAVE_FDOPENDIR=1; - HAVE_SCANDIR=1; - HAVE_ALPHASORT=1; - REPLACE_OPENDIR=0; - REPLACE_CLOSEDIR=0; - REPLACE_DIRFD=0; - REPLACE_FDOPENDIR=0; + for ac_header in unistd.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" +if test "x$ac_cv_header_unistd_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_UNISTD_H 1 +_ACEOF +fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 -$as_echo_n "checking whether the preprocessor supports include_next... " >&6; } -if ${gl_cv_have_include_next+:} false; then : +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5 +$as_echo_n "checking for working chown... " >&6; } +if ${ac_cv_func_chown_works+:} false; then : $as_echo_n "(cached) " >&6 else - rm -rf conftestd1a conftestd1b conftestd2 - mkdir conftestd1a conftestd1b conftestd2 - cat < conftestd1a/conftest.h -#define DEFINED_IN_CONFTESTD1 -#include_next -#ifdef DEFINED_IN_CONFTESTD2 -int foo; -#else -#error "include_next doesn't work" -#endif -EOF - cat < conftestd1b/conftest.h -#define DEFINED_IN_CONFTESTD1 -#include -#include_next -#ifdef DEFINED_IN_CONFTESTD2 -int foo; -#else -#error "include_next doesn't work" -#endif -EOF - cat < conftestd2/conftest.h -#ifndef DEFINED_IN_CONFTESTD1 -#error "include_next test doesn't work" -#endif -#define DEFINED_IN_CONFTESTD2 -EOF - gl_save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gl_cv_have_include_next=yes + if test "$cross_compiling" = yes; then : + case "$host_os" in # (( + # Guess yes on glibc systems. + *-gnu*) ac_cv_func_chown_works=yes ;; + # If we don't know, assume the worst. + *) ac_cv_func_chown_works=no ;; + esac + else - CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include +$ac_includes_default + #include + +int +main () +{ + + char *f = "conftest.chown"; + struct stat before, after; + + if (creat (f, 0600) < 0) + return 1; + if (stat (f, &before) < 0) + return 1; + if (chown (f, (uid_t) -1, (gid_t) -1) == -1) + return 1; + if (stat (f, &after) < 0) + return 1; + return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); + + ; + return 0; +} + _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gl_cv_have_include_next=buggy +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_chown_works=yes else - gl_cv_have_include_next=no + ac_cv_func_chown_works=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CPPFLAGS="$gl_save_CPPFLAGS" - rm -rf conftestd1a conftestd1b conftestd2 + + rm -f conftest.chown fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 -$as_echo "$gl_cv_have_include_next" >&6; } - PRAGMA_SYSTEM_HEADER= - if test $gl_cv_have_include_next = yes; then - INCLUDE_NEXT=include_next - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next - if test -n "$GCC"; then - PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' - fi - else - if test $gl_cv_have_include_next = buggy; then - INCLUDE_NEXT=include - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next - else - INCLUDE_NEXT=include - INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include - fi - fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5 +$as_echo "$ac_cv_func_chown_works" >&6; } + if test $ac_cv_func_chown_works = yes; then +$as_echo "#define HAVE_CHOWN 1" >>confdefs.h + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 -$as_echo_n "checking whether system header files limit the line length... " >&6; } -if ${gl_cv_pragma_columns+:} false; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown dereferences symlinks" >&5 +$as_echo_n "checking whether chown dereferences symlinks... " >&6; } +if ${gl_cv_func_chown_follows_symlink+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + if test "$cross_compiling" = yes; then : + gl_cv_func_chown_follows_symlink=yes + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef __TANDEM -choke me -#endif +#include +#include +#include + + int + main () + { + int result = 0; + char const *dangling_symlink = "conftest.dangle"; + + unlink (dangling_symlink); + if (symlink ("conftest.no-such", dangling_symlink)) + abort (); + + /* Exit successfully on a conforming system, + i.e., where chown must fail with ENOENT. */ + if (chown (dangling_symlink, getuid (), getgid ()) == 0) + result |= 1; + if (errno != ENOENT) + result |= 2; + return result; + } _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "choke me" >/dev/null 2>&1; then : - gl_cv_pragma_columns=yes +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_chown_follows_symlink=yes else - gl_cv_pragma_columns=no + gl_cv_func_chown_follows_symlink=no fi -rm -f conftest* - - +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 -$as_echo "$gl_cv_pragma_columns" >&6; } - if test $gl_cv_pragma_columns = yes; then - PRAGMA_COLUMNS="#pragma COLUMNS 10000" - else - PRAGMA_COLUMNS= - fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_follows_symlink" >&5 +$as_echo "$gl_cv_func_chown_follows_symlink" >&6; } + if test $gl_cv_func_chown_follows_symlink = no; then +$as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h + fi @@ -7560,28 +7613,328 @@ $as_echo "$gl_cv_pragma_columns" >&6; } + if test $ac_cv_func_chown = no; then + HAVE_CHOWN=0 + else + if test $gl_cv_func_chown_follows_symlink = no; then + REPLACE_CHOWN=1 + fi + if test $ac_cv_func_chown_works = no; then +$as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5 -$as_echo_n "checking if environ is properly declared... " >&6; } - if ${gt_cv_var_environ_declaration+:} false; then : + REPLACE_CHOWN=1 + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown honors trailing slash" >&5 +$as_echo_n "checking whether chown honors trailing slash... " >&6; } +if ${gl_cv_func_chown_slash_works+:} false; then : $as_echo_n "(cached) " >&6 else + touch conftest.file && rm -f conftest.link + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_chown_slash_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_chown_slash_works="guessing no" ;; + esac - cat confdefs.h - <<_ACEOF >conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#if HAVE_UNISTD_H - #include - #endif - /* mingw, BeOS, Haiku declare environ in , not in . */ - #include - extern struct { int foo; } environ; +#include +#include +#include + int main () { -environ.foo = 1; + if (symlink ("conftest.file", "conftest.link")) return 1; + if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_chown_slash_works=yes +else + gl_cv_func_chown_slash_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.link conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_slash_works" >&5 +$as_echo "$gl_cv_func_chown_slash_works" >&6; } + case "$gl_cv_func_chown_slash_works" in + *yes) ;; + *) + +$as_echo "#define CHOWN_TRAILING_SLASH_BUG 1" >>confdefs.h + + REPLACE_CHOWN=1 + ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown always updates ctime" >&5 +$as_echo_n "checking whether chown always updates ctime... " >&6; } +if ${gl_cv_func_chown_ctime_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_chown_ctime_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_chown_ctime_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include +#include + +int +main () +{ + struct stat st1, st2; + if (close (creat ("conftest.file", 0600))) return 1; + if (stat ("conftest.file", &st1)) return 2; + sleep (1); + if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3; + if (stat ("conftest.file", &st2)) return 4; + if (st2.st_ctime <= st1.st_ctime) return 5; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_chown_ctime_works=yes +else + gl_cv_func_chown_ctime_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.file +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_ctime_works" >&5 +$as_echo "$gl_cv_func_chown_ctime_works" >&6; } + case "$gl_cv_func_chown_ctime_works" in + *yes) ;; + *) + +$as_echo "#define CHOWN_CHANGE_TIME_BUG 1" >>confdefs.h + + REPLACE_CHOWN=1 + ;; + esac + fi + + + + + + if test $ac_cv_func__set_invalid_parameter_handler = yes; then + HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 + +$as_echo "#define HAVE_MSVC_INVALID_PARAMETER_HANDLER 1" >>confdefs.h + + else + HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 + fi + + + + + + + + GNULIB_OPENDIR=0; + GNULIB_READDIR=0; + GNULIB_REWINDDIR=0; + GNULIB_CLOSEDIR=0; + GNULIB_DIRFD=0; + GNULIB_FDOPENDIR=0; + GNULIB_SCANDIR=0; + GNULIB_ALPHASORT=0; + HAVE_OPENDIR=1; + HAVE_READDIR=1; + HAVE_REWINDDIR=1; + HAVE_CLOSEDIR=1; + HAVE_DECL_DIRFD=1; + HAVE_DECL_FDOPENDIR=1; + HAVE_FDOPENDIR=1; + HAVE_SCANDIR=1; + HAVE_ALPHASORT=1; + REPLACE_OPENDIR=0; + REPLACE_CLOSEDIR=0; + REPLACE_DIRFD=0; + REPLACE_FDOPENDIR=0; + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the preprocessor supports include_next" >&5 +$as_echo_n "checking whether the preprocessor supports include_next... " >&6; } +if ${gl_cv_have_include_next+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -rf conftestd1a conftestd1b conftestd2 + mkdir conftestd1a conftestd1b conftestd2 + cat < conftestd1a/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd1b/conftest.h +#define DEFINED_IN_CONFTESTD1 +#include +#include_next +#ifdef DEFINED_IN_CONFTESTD2 +int foo; +#else +#error "include_next doesn't work" +#endif +EOF + cat < conftestd2/conftest.h +#ifndef DEFINED_IN_CONFTESTD1 +#error "include_next test doesn't work" +#endif +#define DEFINED_IN_CONFTESTD2 +EOF + gl_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_have_include_next=yes +else + CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_have_include_next=buggy +else + gl_cv_have_include_next=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CPPFLAGS="$gl_save_CPPFLAGS" + rm -rf conftestd1a conftestd1b conftestd2 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_include_next" >&5 +$as_echo "$gl_cv_have_include_next" >&6; } + PRAGMA_SYSTEM_HEADER= + if test $gl_cv_have_include_next = yes; then + INCLUDE_NEXT=include_next + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + if test -n "$GCC"; then + PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' + fi + else + if test $gl_cv_have_include_next = buggy; then + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next + else + INCLUDE_NEXT=include + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include + fi + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system header files limit the line length" >&5 +$as_echo_n "checking whether system header files limit the line length... " >&6; } +if ${gl_cv_pragma_columns+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __TANDEM +choke me +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "choke me" >/dev/null 2>&1; then : + gl_cv_pragma_columns=yes +else + gl_cv_pragma_columns=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_pragma_columns" >&5 +$as_echo "$gl_cv_pragma_columns" >&6; } + if test $gl_cv_pragma_columns = yes; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if environ is properly declared" >&5 +$as_echo_n "checking if environ is properly declared... " >&6; } + if ${gt_cv_var_environ_declaration+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if HAVE_UNISTD_H + #include + #endif + /* mingw, BeOS, Haiku declare environ in , not in . */ + #include + + extern struct { int foo; } environ; +int +main () +{ +environ.foo = 1; ; return 0; } @@ -8078,6 +8431,56 @@ fi +ac_fn_c_check_decl "$LINENO" "fchdir" "ac_cv_have_decl_fchdir" "$ac_includes_default" +if test "x$ac_cv_have_decl_fchdir" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FCHDIR $ac_have_decl +_ACEOF + + + GNULIB_FCHMODAT=0; + GNULIB_FSTAT=0; + GNULIB_FSTATAT=0; + GNULIB_FUTIMENS=0; + GNULIB_LCHMOD=0; + GNULIB_LSTAT=0; + GNULIB_MKDIRAT=0; + GNULIB_MKFIFO=0; + GNULIB_MKFIFOAT=0; + GNULIB_MKNOD=0; + GNULIB_MKNODAT=0; + GNULIB_STAT=0; + GNULIB_UTIMENSAT=0; + HAVE_FCHMODAT=1; + HAVE_FSTATAT=1; + HAVE_FUTIMENS=1; + HAVE_LCHMOD=1; + HAVE_LSTAT=1; + HAVE_MKDIRAT=1; + HAVE_MKFIFO=1; + HAVE_MKFIFOAT=1; + HAVE_MKNOD=1; + HAVE_MKNODAT=1; + HAVE_UTIMENSAT=1; + REPLACE_FSTAT=0; + REPLACE_FSTATAT=0; + REPLACE_FUTIMENS=0; + REPLACE_LSTAT=0; + REPLACE_MKDIR=0; + REPLACE_MKFIFO=0; + REPLACE_MKNOD=0; + REPLACE_STAT=0; + REPLACE_UTIMENSAT=0; + + + + + GNULIB_FCNTL=0; GNULIB_NONBLOCKING=0; @@ -8262,39 +8665,6 @@ _ACEOF fi - GNULIB_FCHMODAT=0; - GNULIB_FSTAT=0; - GNULIB_FSTATAT=0; - GNULIB_FUTIMENS=0; - GNULIB_LCHMOD=0; - GNULIB_LSTAT=0; - GNULIB_MKDIRAT=0; - GNULIB_MKFIFO=0; - GNULIB_MKFIFOAT=0; - GNULIB_MKNOD=0; - GNULIB_MKNODAT=0; - GNULIB_STAT=0; - GNULIB_UTIMENSAT=0; - HAVE_FCHMODAT=1; - HAVE_FSTATAT=1; - HAVE_FUTIMENS=1; - HAVE_LCHMOD=1; - HAVE_LSTAT=1; - HAVE_MKDIRAT=1; - HAVE_MKFIFO=1; - HAVE_MKFIFOAT=1; - HAVE_MKNOD=1; - HAVE_MKNODAT=1; - HAVE_UTIMENSAT=1; - REPLACE_FSTAT=0; - REPLACE_FSTATAT=0; - REPLACE_FUTIMENS=0; - REPLACE_LSTAT=0; - REPLACE_MKDIR=0; - REPLACE_MKFIFO=0; - REPLACE_MKNOD=0; - REPLACE_STAT=0; - REPLACE_UTIMENSAT=0; { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } @@ -8535,6 +8905,175 @@ fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 +$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } +if ${gl_cv_func_lstat_dereferences_slashed_symlink+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f conftest.sym conftest.file + echo >conftest.file + if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +struct stat sbuf; + /* Linux will dereference the symlink and fail, as required by + POSIX. That is better in the sense that it means we will not + have to compile and use the lstat wrapper. */ + return lstat ("conftest.sym/", &sbuf) == 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_lstat_dereferences_slashed_symlink=yes +else + gl_cv_func_lstat_dereferences_slashed_symlink=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + else + # If the 'ln -s' command failed, then we probably don't even + # have an lstat function. + gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" + fi + rm -f conftest.sym conftest.file + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_lstat_dereferences_slashed_symlink" >&5 +$as_echo "$gl_cv_func_lstat_dereferences_slashed_symlink" >&6; } + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *yes) + +cat >>confdefs.h <<_ACEOF +#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 +_ACEOF + + ;; + esac + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getcwd (NULL, 0) allocates memory for result" >&5 +$as_echo_n "checking whether getcwd (NULL, 0) allocates memory for result... " >&6; } +if ${gl_cv_func_getcwd_null+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_getcwd_null="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_getcwd_null="guessing no";; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# if HAVE_UNISTD_H +# include +# else /* on Windows with MSVC */ +# include +# endif +# ifndef getcwd + char *getcwd (); +# endif + +int +main () +{ + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* mingw cwd does not start with '/', but getcwd does allocate. + However, mingw fails to honor non-zero size. */ +#else + if (chdir ("/") != 0) + return 1; + else + { + char *f = getcwd (NULL, 0); + if (! f) + return 2; + if (f[0] != '/') + return 3; + if (f[1] != '\0') + return 4; + return 0; + } +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_getcwd_null=yes +else + gl_cv_func_getcwd_null=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getcwd_null" >&5 +$as_echo "$gl_cv_func_getcwd_null" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getcwd with POSIX signature" >&5 +$as_echo_n "checking for getcwd with POSIX signature... " >&6; } +if ${gl_cv_func_getcwd_posix_signature+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +extern + #ifdef __cplusplus + "C" + #endif + char *getcwd (char *, size_t); + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_func_getcwd_posix_signature=yes +else + gl_cv_func_getcwd_posix_signature=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getcwd_posix_signature" >&5 +$as_echo "$gl_cv_func_getcwd_posix_signature" >&6; } + + @@ -9472,8 +10011,6 @@ fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 $as_echo_n "checking for nl_langinfo and CODESET... " >&6; } if ${am_cv_langinfo_codeset+:} false; then : @@ -9557,69 +10094,6 @@ $as_echo "$ac_cv_gnu_library_2_1" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether lstat correctly handles trailing slash" >&5 -$as_echo_n "checking whether lstat correctly handles trailing slash... " >&6; } -if ${gl_cv_func_lstat_dereferences_slashed_symlink+:} false; then : - $as_echo_n "(cached) " >&6 -else - rm -f conftest.sym conftest.file - echo >conftest.file - if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then - if test "$cross_compiling" = yes; then : - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; - # If we don't know, assume the worst. - *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; - esac - -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -struct stat sbuf; - /* Linux will dereference the symlink and fail, as required by - POSIX. That is better in the sense that it means we will not - have to compile and use the lstat wrapper. */ - return lstat ("conftest.sym/", &sbuf) == 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - gl_cv_func_lstat_dereferences_slashed_symlink=yes -else - gl_cv_func_lstat_dereferences_slashed_symlink=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - else - # If the 'ln -s' command failed, then we probably don't even - # have an lstat function. - gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" - fi - rm -f conftest.sym conftest.file - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_lstat_dereferences_slashed_symlink" >&5 -$as_echo "$gl_cv_func_lstat_dereferences_slashed_symlink" >&6; } - case "$gl_cv_func_lstat_dereferences_slashed_symlink" in - *yes) - -cat >>confdefs.h <<_ACEOF -#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 -_ACEOF - - ;; - esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : @@ -10688,6 +11162,17 @@ $as_echo "$gl_cv_func_memchr_works" >&6; } fi fi +ac_fn_c_check_decl "$LINENO" "memrchr" "ac_cv_have_decl_memrchr" "$ac_includes_default" +if test "x$ac_cv_have_decl_memrchr" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_MEMRCHR $ac_have_decl +_ACEOF + @@ -10765,6 +11250,8 @@ $as_echo "#define HAVE_MINMAX_IN_SYS_PARAM_H 1" >>confdefs.h + + GNULIB_MKTIME=0; GNULIB_NANOSLEEP=0; GNULIB_STRPTIME=0; @@ -10836,6 +11323,43 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for promoted mode_t type" >&5 +$as_echo_n "checking for promoted mode_t type... " >&6; } +if ${gl_cv_promoted_mode_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_promoted_mode_t='int' +else + gl_cv_promoted_mode_t='mode_t' +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_promoted_mode_t" >&5 +$as_echo "$gl_cv_promoted_mode_t" >&6; } + +cat >>confdefs.h <<_ACEOF +#define PROMOTED_MODE_T $gl_cv_promoted_mode_t +_ACEOF + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : @@ -11053,6 +11577,8 @@ fi REPLACE_RAISE=0; + + GNULIB_DPRINTF=0; GNULIB_FCLOSE=0; GNULIB_FDOPEN=0; @@ -11158,6 +11684,8 @@ fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssize_t" >&5 $as_echo_n "checking for ssize_t... " >&6; } if ${gt_cv_ssize_t+:} false; then : @@ -11263,38 +11791,9 @@ fi HAVE_SIGSET_T=0 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 -$as_echo_n "checking for uid_t in sys/types.h... " >&6; } -if ${ac_cv_type_uid_t+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "uid_t" >/dev/null 2>&1; then : - ac_cv_type_uid_t=yes -else - ac_cv_type_uid_t=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 -$as_echo "$ac_cv_type_uid_t" >&6; } -if test $ac_cv_type_uid_t = no; then - -$as_echo "#define uid_t int" >>confdefs.h - - -$as_echo "#define gid_t int" >>confdefs.h - -fi - REPLACE_NULL=0; + HAVE_MAX_ALIGN_T=1; HAVE_WCHAR_T=1; @@ -12064,6 +12563,19 @@ fi + +ac_fn_c_check_decl "$LINENO" "strdup" "ac_cv_have_decl_strdup" "$ac_includes_default" +if test "x$ac_cv_have_decl_strdup" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRDUP $ac_have_decl +_ACEOF + + REPLACE_STRERROR_0=0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strerror(0) succeeds" >&5 $as_echo_n "checking whether strerror(0) succeeds... " >&6; } @@ -12280,6 +12792,8 @@ _ACEOF + + if test $gl_cv_have_include_next = yes; then gl_cv_next_sys_types_h='<'sys/types.h'>' @@ -12383,6 +12897,7 @@ $as_echo "$gl_cv_sys_struct_timespec_in_time_h" >&6; } TIME_H_DEFINES_STRUCT_TIMESPEC=0 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 + UNISTD_H_DEFINES_STRUCT_TIMESPEC=0 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then TIME_H_DEFINES_STRUCT_TIMESPEC=1 else @@ -12443,6 +12958,36 @@ fi $as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; } if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 +$as_echo_n "checking for struct timespec in ... " >&6; } +if ${gl_cv_sys_struct_timespec_in_unistd_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +static struct timespec x; x.tv_sec = x.tv_nsec; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_sys_struct_timespec_in_unistd_h=yes +else + gl_cv_sys_struct_timespec_in_unistd_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_struct_timespec_in_unistd_h" >&5 +$as_echo "$gl_cv_sys_struct_timespec_in_unistd_h" >&6; } + if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then + UNISTD_H_DEFINES_STRUCT_TIMESPEC=1 + fi fi fi fi @@ -12461,6 +13006,7 @@ $as_echo "$gl_cv_sys_struct_timespec_in_pthread_h" >&6; } + if test $gl_cv_have_include_next = yes; then gl_cv_next_time_h='<'time.h'>' else @@ -12530,6 +13076,8 @@ $as_echo "$gl_cv_next_time_h" >&6; } + + ac_fn_c_check_decl "$LINENO" "unsetenv" "ac_cv_have_decl_unsetenv" "$ac_includes_default" if test "x$ac_cv_have_decl_unsetenv" = xyes; then : ac_have_decl=1 @@ -13560,6 +14108,16 @@ fi + gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext" + + + + + + + + + if test $ac_cv_func_canonicalize_file_name = no; then HAVE_CANONICALIZE_FILE_NAME=0 if test $ac_cv_func_realpath = no; then @@ -13595,9 +14153,103 @@ fi fi -cat >>confdefs.h <<_ACEOF -#define GNULIB_CANONICALIZE_LGPL 1 -_ACEOF +cat >>confdefs.h <<_ACEOF +#define GNULIB_CANONICALIZE_LGPL 1 +_ACEOF + + + + + + + + GNULIB_CANONICALIZE_FILE_NAME=1 + + + + + +$as_echo "#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1" >>confdefs.h + + + + + + + + + GNULIB_REALPATH=1 + + + + + +$as_echo "#define GNULIB_TEST_REALPATH 1" >>confdefs.h + + + + + + + + + GNULIB_CHDIR=1 + + + + + +$as_echo "#define GNULIB_TEST_CHDIR 1" >>confdefs.h + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether this system has an arbitrary file name length limit" >&5 +$as_echo_n "checking whether this system has an arbitrary file name length limit... " >&6; } +if ${gl_cv_have_arbitrary_file_name_length_limit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Arrange to define PATH_MAX, like "pathmax.h" does. */ +#if HAVE_UNISTD_H +# include +#endif +#include +#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN +# include +#endif +#if !defined PATH_MAX && defined MAXPATHLEN +# define PATH_MAX MAXPATHLEN +#endif +#ifdef __hpux +# undef PATH_MAX +# define PATH_MAX 1024 +#endif +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# undef PATH_MAX +# define PATH_MAX 260 +#endif + +#ifdef PATH_MAX +have_arbitrary_file_name_length_limit +#endif +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "have_arbitrary_file_name_length_limit" >/dev/null 2>&1; then : + gl_cv_have_arbitrary_file_name_length_limit=yes +else + gl_cv_have_arbitrary_file_name_length_limit=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_arbitrary_file_name_length_limit" >&5 +$as_echo "$gl_cv_have_arbitrary_file_name_length_limit" >&6; } + + if test $gl_cv_have_arbitrary_file_name_length_limit = yes; then @@ -13605,43 +14257,48 @@ _ACEOF - GNULIB_CANONICALIZE_FILE_NAME=1 + gl_LIBOBJS="$gl_LIBOBJS chdir-long.$ac_objext" + : + fi + if test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1; then -$as_echo "#define GNULIB_TEST_CANONICALIZE_FILE_NAME 1" >>confdefs.h + gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext" + fi + if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then - GNULIB_REALPATH=1 -$as_echo "#define GNULIB_TEST_REALPATH 1" >>confdefs.h + gl_LIBOBJS="$gl_LIBOBJS fchown-stub.$ac_objext" + fi - GNULIB_CHDIR=1 + GNULIB_CHOWN=1 -$as_echo "#define GNULIB_TEST_CHDIR 1" >>confdefs.h +$as_echo "#define GNULIB_TEST_CHOWN 1" >>confdefs.h @@ -13730,6 +14387,11 @@ done +$as_echo "#define GNULIB_TEST_CLOEXEC 1" >>confdefs.h + + + + if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then REPLACE_CLOSE=1 @@ -13767,6 +14429,19 @@ done fi + if test $REPLACE_CLOSE = 0; then + + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + REPLACE_CLOSE=1 + fi + fi + if test $REPLACE_CLOSE = 1; then @@ -13814,6 +14489,19 @@ done fi + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + if test $HAVE_CLOSEDIR = 1; then + REPLACE_CLOSEDIR=1 + fi + fi + + if test $HAVE_CLOSEDIR = 0 || test $REPLACE_CLOSEDIR = 1; then @@ -14388,6 +15076,19 @@ done fi + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + if test $HAVE_DUP2 = 1; then + REPLACE_DUP2=1 + fi + fi + + if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then @@ -14474,9 +15175,297 @@ $as_echo "$ac_cv_lib_error_at_line" >&6; } - : + : + + fi + + + + + + + + if test $ac_cv_have_decl_fchdir = no; then + HAVE_DECL_FCHDIR=0 + fi + + + if test $HAVE_FCHDIR = 0; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fchdir.$ac_objext" + + : + +$as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open can visit directories" >&5 +$as_echo_n "checking whether open can visit directories... " >&6; } +if ${gl_cv_func_open_directory_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_open_directory_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_open_directory_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +return open(".", O_RDONLY) < 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_open_directory_works=yes +else + gl_cv_func_open_directory_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_directory_works" >&5 +$as_echo "$gl_cv_func_open_directory_works" >&6; } + case "$gl_cv_func_open_directory_works" in + *yes) ;; + *) + +$as_echo "#define REPLACE_OPEN_DIRECTORY 1" >>confdefs.h + + ;; + esac + fi + + + + + + + GNULIB_FCHDIR=1 + + + + + +$as_echo "#define GNULIB_TEST_FCHDIR 1" >>confdefs.h + + + + + + + + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi + + if test $HAVE_FCHMODAT = 0; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fchmodat.$ac_objext" + + fi + + +cat >>confdefs.h <<_ACEOF +#define GNULIB_FCHMODAT 1 +_ACEOF + + + + + + + GNULIB_FCHMODAT=1 + + + + + +$as_echo "#define GNULIB_TEST_FCHMODAT 1" >>confdefs.h + + + + + + + + ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat" +if test "x$ac_cv_func_fchownat" = xyes; then : + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with AT_SYMLINK_NOFOLLOW" >&5 +$as_echo_n "checking whether fchownat works with AT_SYMLINK_NOFOLLOW... " >&6; } +if ${gl_cv_func_fchownat_nofollow_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + + gl_dangle=conftest.dangle + # Remove any remnants of a previous test. + rm -f $gl_dangle + # Arrange for deletion of the temporary file this test creates. + ac_clean_files="$ac_clean_files $gl_dangle" + ln -s conftest.no-such $gl_dangle + if test "$cross_compiling" = yes; then : + gl_cv_func_fchownat_nofollow_works=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include +#include +int +main () +{ + return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (), + AT_SYMLINK_NOFOLLOW) != 0 + && errno == ENOENT); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fchownat_nofollow_works=yes +else + gl_cv_func_fchownat_nofollow_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_nofollow_works" >&5 +$as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; } + if test $gl_cv_func_fchownat_nofollow_works = no; then : + REPLACE_FCHOWNAT=1 + +$as_echo "#define FCHOWNAT_NOFOLLOW_BUG 1" >>confdefs.h + + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with an empty file name" >&5 +$as_echo_n "checking whether fchownat works with an empty file name... " >&6; } +if ${gl_cv_func_fchownat_empty_filename_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_fchownat_empty_filename_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +int fd; + int ret; + if (mkdir ("conftestdir", 0700) < 0) + return 2; + fd = open ("conftestdir", O_RDONLY); + if (fd < 0) + return 3; + ret = fchownat (fd, "", -1, -1, 0); + close (fd); + rmdir ("conftestdir"); + return ret == 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fchownat_empty_filename_works=yes +else + gl_cv_func_fchownat_empty_filename_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_empty_filename_works" >&5 +$as_echo "$gl_cv_func_fchownat_empty_filename_works" >&6; } + if test "$gl_cv_func_fchownat_empty_filename_works" != yes; then : + REPLACE_FCHOWNAT=1 + +$as_echo "#define FCHOWNAT_EMPTY_FILENAME_BUG 1" >>confdefs.h + + +fi + + if test $REPLACE_CHOWN = 1; then + REPLACE_FCHOWNAT=1 + fi +else + HAVE_FCHOWNAT=0 +fi + + + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fchownat.$ac_objext" + + fi + + +cat >>confdefs.h <<_ACEOF +#define GNULIB_FCHOWNAT 1 +_ACEOF + + + + + + + GNULIB_FCHOWNAT=1 + + + + + +$as_echo "#define GNULIB_TEST_FCHOWNAT 1" >>confdefs.h - fi @@ -14629,6 +15618,25 @@ $as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; } fi + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + + + + if test $ac_cv_func_fcntl = no; then + HAVE_FCNTL=0 + else + REPLACE_FCNTL=1 + fi + + fi + + if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then @@ -14779,6 +15787,9 @@ fi + + + FLOAT_H= REPLACE_FLOAT_LDBL=0 case "$host_os" in @@ -15011,6 +16022,22 @@ fi + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + case "$gl_cv_func_open_directory_works" in + *yes) ;; + *) + REPLACE_FSTAT=1 + ;; + esac + fi + + if test $REPLACE_FSTAT = 1; then @@ -15043,6 +16070,134 @@ $as_echo "#define GNULIB_TEST_FSTAT 1" >>confdefs.h + + + if test $ac_cv_func_fstatat = no; then + HAVE_FSTATAT=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fstatat (..., 0) works" >&5 +$as_echo_n "checking whether fstatat (..., 0) works... " >&6; } +if ${gl_cv_func_fstatat_zero_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + aix*) gl_cv_func_fstatat_zero_flag="guessing no";; + *) gl_cv_func_fstatat_zero_flag="guessing yes";; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + int + main (void) + { + struct stat a; + return fstatat (AT_FDCWD, ".", &a, 0) != 0; + } + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_fstatat_zero_flag=yes +else + gl_cv_func_fstatat_zero_flag=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fstatat_zero_flag" >&5 +$as_echo "$gl_cv_func_fstatat_zero_flag" >&6; } + + case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in + *yes+*yes) ;; + *) REPLACE_FSTATAT=1 + case $gl_cv_func_fstatat_zero_flag in + *yes) + +$as_echo "#define HAVE_WORKING_FSTATAT_ZERO_FLAG 1" >>confdefs.h + + ;; + esac + ;; + esac + fi + + if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext" + + fi + + + + + + GNULIB_FSTATAT=1 + + + + + +$as_echo "#define GNULIB_TEST_FSTATAT 1" >>confdefs.h + + + + + + + + + case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature in + *yes,yes) ;; + *) + REPLACE_GETCWD=1 + ;; + esac + + if test $REPLACE_GETCWD = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS getcwd-lgpl.$ac_objext" + + fi + + + + + + GNULIB_GETCWD=1 + + + + + +$as_echo "#define GNULIB_TEST_GETCWD 1" >>confdefs.h + + + + + + + if test $ac_cv_func_getdtablesize = yes; then # Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft limit # up to an unchangeable hard limit; all other platforms correctly @@ -15430,24 +16585,58 @@ $as_echo "#define GNULIB_TEST_GETTIMEOFDAY 1" >>confdefs.h + for ac_func in lchown +do : + ac_fn_c_check_func "$LINENO" "lchown" "ac_cv_func_lchown" +if test "x$ac_cv_func_lchown" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LCHOWN 1 +_ACEOF +fi +done - if test $ac_cv_func_lchmod = no; then - HAVE_LCHMOD=0 + if test $ac_cv_func_lchown = no; then + HAVE_LCHOWN=0 + else + case "$gl_cv_func_chown_slash_works" in + *yes) ;; + *) + REPLACE_LCHOWN=1 + ;; + esac + case "$gl_cv_func_chown_ctime_works" in + *yes) ;; + *) + REPLACE_LCHOWN=1 + ;; + esac fi + if test $HAVE_LCHOWN = 0 || test $REPLACE_LCHOWN = 1; then + + + + + + gl_LIBOBJS="$gl_LIBOBJS lchown.$ac_objext" + + fi + + - GNULIB_LCHMOD=1 + GNULIB_LCHOWN=1 -$as_echo "#define GNULIB_TEST_LCHMOD 1" >>confdefs.h + +$as_echo "#define GNULIB_TEST_LCHOWN 1" >>confdefs.h @@ -16553,6 +17742,106 @@ $as_echo "#define GNULIB_TEST_MEMCHR 1" >>confdefs.h + + for ac_func in mempcpy +do : + ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy" +if test "x$ac_cv_func_mempcpy" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMPCPY 1 +_ACEOF + +fi +done + + if test $ac_cv_func_mempcpy = no; then + HAVE_MEMPCPY=0 + fi + + if test $HAVE_MEMPCPY = 0; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS mempcpy.$ac_objext" + + + : + + fi + + + + + + GNULIB_MEMPCPY=1 + + + + + +$as_echo "#define GNULIB_TEST_MEMPCPY 1" >>confdefs.h + + + + + + + + + if test $ac_cv_have_decl_memrchr = no; then + HAVE_DECL_MEMRCHR=0 + fi + + for ac_func in memrchr +do : + ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr" +if test "x$ac_cv_func_memrchr" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMRCHR 1 +_ACEOF + +fi +done + + + if test $ac_cv_func_memrchr = no; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS memrchr.$ac_objext" + + : + fi + + + + + + GNULIB_MEMRCHR=1 + + + + + +$as_echo "#define GNULIB_TEST_MEMRCHR 1" >>confdefs.h + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing slash" >&5 $as_echo_n "checking whether mkdir handles trailing slash... " >&6; } if ${gl_cv_func_mkdir_trailing_slash_works+:} false; then : @@ -16642,23 +17931,43 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - rm -rf conftest.dir + rm -rf conftest.dir + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_dot_works" >&5 +$as_echo "$gl_cv_func_mkdir_trailing_dot_works" >&6; } + case "$gl_cv_func_mkdir_trailing_dot_works" in + *yes) ;; + *) + REPLACE_MKDIR=1 + +$as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h + + ;; + esac + + if test $REPLACE_MKDIR = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext" + + fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_dot_works" >&5 -$as_echo "$gl_cv_func_mkdir_trailing_dot_works" >&6; } - case "$gl_cv_func_mkdir_trailing_dot_works" in - *yes) ;; - *) - REPLACE_MKDIR=1 -$as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h - ;; - esac + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi - if test $REPLACE_MKDIR = 1; then + if test $HAVE_MKDIRAT = 0; then @@ -16667,7 +17976,10 @@ $as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h - gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext" + gl_LIBOBJS="$gl_LIBOBJS mkdirat.$ac_objext" + + + fi @@ -16675,6 +17987,21 @@ $as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h + GNULIB_MKDIRAT=1 + + + + + +$as_echo "#define GNULIB_TEST_MKDIRAT 1" >>confdefs.h + + + + + + + + if test $APPLE_UNIVERSAL_BUILD = 1; then # A universal build on Apple Mac OS X platforms. @@ -16980,6 +18307,179 @@ $as_echo "#define HAVE_MSVC_INVALID_PARAMETER_HANDLER 1" >>confdefs.h + case "$host_os" in + mingw* | pw*) + REPLACE_OPEN=1 + ;; + *) + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5 +$as_echo_n "checking whether open recognizes a trailing slash... " >&6; } +if ${gl_cv_func_open_slash+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + touch conftest.tmp + ln -s conftest.tmp conftest.lnk + fi + if test "$cross_compiling" = yes; then : + + case "$host_os" in + freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) + gl_cv_func_open_slash="guessing no" ;; + *) + gl_cv_func_open_slash="guessing yes" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if HAVE_UNISTD_H +# include +#endif +int main () +{ + int result = 0; +#if HAVE_LSTAT + if (open ("conftest.lnk/", O_RDONLY) != -1) + result |= 1; +#endif + if (open ("conftest.sl/", O_CREAT, 0600) >= 0) + result |= 2; + return result; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_open_slash=yes +else + gl_cv_func_open_slash=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.sl conftest.tmp conftest.lnk + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_slash" >&5 +$as_echo "$gl_cv_func_open_slash" >&6; } + case "$gl_cv_func_open_slash" in + *no) + +$as_echo "#define OPEN_TRAILING_SLASH_BUG 1" >>confdefs.h + + REPLACE_OPEN=1 + ;; + esac + ;; + esac + + if test $REPLACE_OPEN = 0; then + + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + REPLACE_OPEN=1 + fi + fi + + + + if test $REPLACE_OPEN = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS open.$ac_objext" + + + + : + + fi + + + + + + GNULIB_OPEN=1 + + + + + +$as_echo "#define GNULIB_TEST_OPEN 1" >>confdefs.h + + + + + + + + + case $ac_cv_func_openat+$gl_cv_func_lstat_dereferences_slashed_symlink in + yes+*yes) + ;; + yes+*) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_OPENAT=1 + ;; + *) + HAVE_OPENAT=0 + ;; + esac + + if test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS openat.$ac_objext" + + + + : + + fi + + +cat >>confdefs.h <<_ACEOF +#define GNULIB_OPENAT 1 +_ACEOF + + + + + + + GNULIB_OPENAT=1 + + + + + +$as_echo "#define GNULIB_TEST_OPENAT 1" >>confdefs.h + + + + + for ac_func in opendir do : @@ -16997,6 +18497,19 @@ done fi + + + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi + + if test $HAVE_FCHDIR = 0; then + if test $HAVE_OPENDIR = 1; then + REPLACE_OPENDIR=1 + fi + fi + + if test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1; then @@ -17376,6 +18889,72 @@ $as_echo "#define GNULIB_TEST_READLINK 1" >>confdefs.h + + if test $ac_cv_func_readlinkat = no; then + HAVE_READLINKAT=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readlinkat signature is correct" >&5 +$as_echo_n "checking whether readlinkat signature is correct... " >&6; } +if ${gl_cv_decl_readlinkat_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check whether original declaration has correct type. */ + ssize_t readlinkat (int, char const *, char *, size_t); +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_decl_readlinkat_works=yes +else + gl_cv_decl_readlinkat_works=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_decl_readlinkat_works" >&5 +$as_echo "$gl_cv_decl_readlinkat_works" >&6; } + if test "$gl_cv_decl_readlink_works" != yes; then + REPLACE_READLINKAT=1 + fi + fi + + if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS readlinkat.$ac_objext" + + fi + + + + + + GNULIB_READLINKAT=1 + + + + + +$as_echo "#define GNULIB_TEST_READLINKAT 1" >>confdefs.h + + + + + + for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" @@ -17798,13 +19377,64 @@ $as_echo "#define RENAME_DEST_EXISTS_BUG 1" >>confdefs.h - GNULIB_RENAME=1 + GNULIB_RENAME=1 + + + + + +$as_echo "#define GNULIB_TEST_RENAME 1" >>confdefs.h + + + + + + + + + + if test $ac_cv_func_renameat = no; then + HAVE_RENAMEAT=0 + elif test $REPLACE_RENAME = 1; then + REPLACE_RENAMEAT=1 + fi + + if test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS renameat.$ac_objext" + + fi + if test $HAVE_RENAMEAT = 0; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS at-func2.$ac_objext" + + fi + + + + + + GNULIB_RENAMEAT=1 -$as_echo "#define GNULIB_TEST_RENAME 1" >>confdefs.h +$as_echo "#define GNULIB_TEST_RENAMEAT 1" >>confdefs.h @@ -17910,6 +19540,9 @@ $as_echo "#define GNULIB_TEST_RMDIR 1" >>confdefs.h + + + if test $ac_cv_func_secure_getenv = no; then HAVE_SECURE_GETENV=0 fi @@ -18607,6 +20240,12 @@ fi + +cat >>confdefs.h <<_ACEOF +#define GNULIB_STATAT 1 +_ACEOF + + STDARG_H='' NEXT_STDARG_H='' { $as_echo "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5 @@ -18820,6 +20459,15 @@ fi STDDEF_H= + ac_fn_c_check_type "$LINENO" "max_align_t" "ac_cv_type_max_align_t" "#include + +" +if test "x$ac_cv_type_max_align_t" = xyes; then : + +else + HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h +fi + if test $gt_cv_c_wchar_t = no; then HAVE_WCHAR_T=0 STDDEF_H=stddef.h @@ -18949,6 +20597,8 @@ $as_echo "$gl_cv_next_stddef_h" >&6; } + + if test $gl_cv_have_include_next = yes; then gl_cv_next_stdio_h='<'stdio.h'>' else @@ -19013,6 +20663,36 @@ $as_echo "$gl_cv_next_stdio_h" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether inttypes macros match system or gnu printf" >&5 +$as_echo_n "checking whether inttypes macros match system or gnu printf... " >&6; } +if ${gl_cv_func_printf_attribute_flavor+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define __STDC_FORMAT_MACROS 1 + #include + #include + findme PRIdMAX findme + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "findme .(ll|j)d. findme" >/dev/null 2>&1; then : + gl_cv_func_printf_attribute_flavor=gnu +else + gl_cv_func_printf_attribute_flavor=system +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_printf_attribute_flavor" >&5 +$as_echo "$gl_cv_func_printf_attribute_flavor" >&6; } + if test "$gl_cv_func_printf_attribute_flavor" = gnu; then + +$as_echo "#define GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU 1" >>confdefs.h + + fi + GNULIB_FSCANF=1 @@ -19215,6 +20895,48 @@ fi + if test $ac_cv_func_strdup = yes; then + if test $gl_cv_func_malloc_posix != yes; then + REPLACE_STRDUP=1 + fi + fi + + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi + + if test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS strdup.$ac_objext" + + : + fi + + + + + + GNULIB_STRDUP=1 + + + + + +$as_echo "#define GNULIB_TEST_STRDUP 1" >>confdefs.h + + + + + + + if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strerror function" >&5 @@ -19631,6 +21353,97 @@ $as_echo "#define GNULIB_TEST_SYMLINK 1" >>confdefs.h + if test $ac_cv_func_symlinkat = no; then + HAVE_SYMLINKAT=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether symlinkat handles trailing slash correctly" >&5 +$as_echo_n "checking whether symlinkat handles trailing slash correctly... " >&6; } +if ${gl_cv_func_symlinkat_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_symlinkat_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_symlinkat_works="guessing no" ;; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +int result = 0; + if (!symlinkat ("a", AT_FDCWD, "conftest.link/")) + result |= 1; + if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2")) + result |= 2; + else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/")) + result |= 4; + return result; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gl_cv_func_symlinkat_works=yes +else + gl_cv_func_symlinkat_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + rm -f conftest.f conftest.link conftest.lnk2 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_symlinkat_works" >&5 +$as_echo "$gl_cv_func_symlinkat_works" >&6; } + case "$gl_cv_func_symlinkat_works" in + *yes) ;; + *) + REPLACE_SYMLINKAT=1 + ;; + esac + fi + + if test $HAVE_SYMLINKAT = 0 || test $REPLACE_SYMLINKAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS symlinkat.$ac_objext" + + fi + + + + + + GNULIB_SYMLINKAT=1 + + + + + +$as_echo "#define GNULIB_TEST_SYMLINKAT 1" >>confdefs.h + + + + + + + + @@ -20222,6 +22035,57 @@ $as_echo "#define GNULIB_TEST_UNLINK 1" >>confdefs.h + + + + if test $ac_cv_func_unlinkat = no; then + HAVE_UNLINKAT=0 + else + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *no) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_UNLINKAT=1 + ;; + *) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + REPLACE_UNLINKAT=1 + fi + ;; + esac + fi + + if test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext" + + fi + + + + + + GNULIB_UNLINKAT=1 + + + + + +$as_echo "#define GNULIB_TEST_UNLINKAT 1" >>confdefs.h + + + + + + if test $ac_cv_have_decl_unsetenv = no; then HAVE_DECL_UNSETENV=0 fi @@ -20442,6 +22306,130 @@ $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h + + + if test $ac_cv_func_utimensat = no; then + HAVE_UTIMENSAT=0 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether utimensat works" >&5 +$as_echo_n "checking whether utimensat works... " >&6; } +if ${gl_cv_func_utimensat_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + gl_cv_func_utimensat_works="guessing no" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +int +main () +{ +int result = 0; + const char *f = "conftest.file"; + if (close (creat (f, 0600))) + return 1; + /* Test whether the AT_SYMLINK_NOFOLLOW flag is supported. */ + { + if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW)) + result |= 2; + } + /* Test whether UTIME_NOW and UTIME_OMIT work. */ + { + struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } }; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 4; + } + sleep (1); + { + struct timespec ts[2] = { { 1, UTIME_NOW }, { 1, UTIME_OMIT } }; + struct stat st; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 8; + if (stat (f, &st)) + result |= 16; + else if (st.st_ctime < st.st_atime) + result |= 32; + } + return result; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef __linux__ +/* The Linux kernel added utimensat in 2.6.22, but has bugs with UTIME_OMIT + in several file systems as recently as 2.6.32. Always replace utimensat + to support older kernels. */ +choke me +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_func_utimensat_works=yes +else + gl_cv_func_utimensat_works="needs runtime check" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + gl_cv_func_utimensat_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_utimensat_works" >&5 +$as_echo "$gl_cv_func_utimensat_works" >&6; } + if test "$gl_cv_func_utimensat_works" != yes; then + REPLACE_UTIMENSAT=1 + fi + fi + + if test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1; then + + + + + + + + + gl_LIBOBJS="$gl_LIBOBJS utimensat.$ac_objext" + + fi + + + + + + GNULIB_UTIMENSAT=1 + + + + + +$as_echo "#define GNULIB_TEST_UTIMENSAT 1" >>confdefs.h + + + + + if test $ac_cv_func_vasnprintf = no; then @@ -23003,7 +24991,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by GNU patch $as_me 2.7.3, which was +This file was extended by GNU patch $as_me 2.7.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23075,7 +25063,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -GNU patch config.status 2.7.3 +GNU patch config.status 2.7.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/lib/Makefile.in b/lib/Makefile.in index d3e2e3d..bc3e544 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -14,7 +14,7 @@ @SET_MAKE@ -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 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 @@ -35,7 +35,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libpatch --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl argmatch backupfile clock-time diffseq dirname dup2 errno exitfail extensions fcntl-h full-write getdate getopt-gnu gettime git-version-gen gitlog-to-changelog hash ignore-value intprops largefile lchmod linked-list lstat maintainer-makefile malloc manywarnings memchr minmax mkdir progname quotearg readlink realloc rename rmdir setenv signal ssize_t stat-time stdbool stdlib symlink sys_stat tempname time unistd unlink update-copyright utimens verror xalloc xlist xmemdup0 +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libpatch --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl argmatch backupfile clock-time diffseq dirname dup2 errno exitfail extensions fchmodat fchownat fcntl-h fstatat full-write getdate getopt-gnu gettime git-version-gen gitlog-to-changelog hash ignore-value intprops largefile linked-list maintainer-makefile malloc manywarnings memchr minmax mkdirat openat progname quotearg readlinkat realloc renameat setenv signal ssize_t stat-time stdbool stdlib symlinkat sys_stat tempname time unistd unlinkat update-copyright utimensat verror xalloc xlist xmemdup0 VPATH = @srcdir@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' @@ -109,6 +109,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/canonicalize.m4 \ + $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/d-ino.m4 \ @@ -118,52 +119,61 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/extensions.m4 \ - $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \ + $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \ $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fstat.m4 \ + $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdtablesize.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettime.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/include_next.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/largefile.m4 \ - $(top_srcdir)/m4/lchmod.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/lchown.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/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/mkdir.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ + $(top_srcdir)/m4/mkdirat.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ $(top_srcdir)/m4/opendir.m4 $(top_srcdir)/m4/parse-datetime.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/readdir.m4 \ - $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ + $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rename.m4 \ + $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rmdir.m4 \ $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ - $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/setenv.m4 \ - $(top_srcdir)/m4/setmode.m4 $(top_srcdir)/m4/signal_h.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/ssize_t.m4 \ - $(top_srcdir)/m4/stat-time.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/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/secure_getenv.m4 \ + $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/setmode.m4 \ + $(top_srcdir)/m4/signal_h.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.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/stdint_h.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/symlink.m4 \ - $(top_srcdir)/m4/sys_socket_h.m4 \ + $(top_srcdir)/m4/symlinkat.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/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \ + $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \ @@ -187,19 +197,22 @@ libpatch_a_AR = $(AR) $(ARFLAGS) am__DEPENDENCIES_1 = am_libpatch_a_OBJECTS = argmatch.$(OBJEXT) backupfile.$(OBJEXT) \ bitrotate.$(OBJEXT) c-ctype.$(OBJEXT) c-strcasecmp.$(OBJEXT) \ - c-strncasecmp.$(OBJEXT) opendir-safer.$(OBJEXT) \ - dirname.$(OBJEXT) basename.$(OBJEXT) dirname-lgpl.$(OBJEXT) \ - basename-lgpl.$(OBJEXT) stripslash.$(OBJEXT) \ - exitfail.$(OBJEXT) fd-hook.$(OBJEXT) full-write.$(OBJEXT) \ - gettime.$(OBJEXT) hash.$(OBJEXT) gl_linked_list.$(OBJEXT) \ - gl_list.$(OBJEXT) localcharset.$(OBJEXT) malloca.$(OBJEXT) \ + c-strncasecmp.$(OBJEXT) cloexec.$(OBJEXT) \ + opendir-safer.$(OBJEXT) dirname.$(OBJEXT) basename.$(OBJEXT) \ + dirname-lgpl.$(OBJEXT) basename-lgpl.$(OBJEXT) \ + stripslash.$(OBJEXT) exitfail.$(OBJEXT) chmodat.$(OBJEXT) \ + chownat.$(OBJEXT) fd-hook.$(OBJEXT) filenamecat-lgpl.$(OBJEXT) \ + full-write.$(OBJEXT) gettime.$(OBJEXT) hash.$(OBJEXT) \ + gl_linked_list.$(OBJEXT) gl_list.$(OBJEXT) \ + localcharset.$(OBJEXT) malloca.$(OBJEXT) openat-die.$(OBJEXT) \ parse-datetime.$(OBJEXT) progname.$(OBJEXT) quotearg.$(OBJEXT) \ - safe-write.$(OBJEXT) stat-time.$(OBJEXT) tempname.$(OBJEXT) \ - timespec.$(OBJEXT) unistd.$(OBJEXT) dup-safer.$(OBJEXT) \ - fd-safer.$(OBJEXT) pipe-safer.$(OBJEXT) utimens.$(OBJEXT) \ - verror.$(OBJEXT) wctype-h.$(OBJEXT) xmalloc.$(OBJEXT) \ - xalloc-die.$(OBJEXT) gl_xlist.$(OBJEXT) xsize.$(OBJEXT) \ - xstrndup.$(OBJEXT) xvasprintf.$(OBJEXT) xasprintf.$(OBJEXT) + safe-write.$(OBJEXT) save-cwd.$(OBJEXT) stat-time.$(OBJEXT) \ + statat.$(OBJEXT) tempname.$(OBJEXT) timespec.$(OBJEXT) \ + unistd.$(OBJEXT) dup-safer.$(OBJEXT) fd-safer.$(OBJEXT) \ + pipe-safer.$(OBJEXT) utimens.$(OBJEXT) verror.$(OBJEXT) \ + wctype-h.$(OBJEXT) xmalloc.$(OBJEXT) xalloc-die.$(OBJEXT) \ + gl_xlist.$(OBJEXT) xsize.$(OBJEXT) xstrndup.$(OBJEXT) \ + xvasprintf.$(OBJEXT) xasprintf.$(OBJEXT) libpatch_a_OBJECTS = $(am_libpatch_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -641,6 +654,7 @@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ +HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ @@ -997,6 +1011,7 @@ 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_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ VERSION = @VERSION@ @@ -1085,42 +1100,49 @@ BUILT_SOURCES = $(ALLOCA_H) configmake.h dirent.h $(ERRNO_H) fcntl.h \ sys/types.h time.h unistd.h wchar.h wctype.h CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \ ref-del.sed -EXTRA_DIST = alloca.in.h argmatch.h backupfile.h c-strcaseeq.h \ - canonicalize-lgpl.c close.c closedir.c dirent-private.h \ - dirent.in.h dirent--.h dirent-safer.h dirfd.c stripslash.c \ - dirname.h dosname.h dup2.c errno.in.h error.c error.h \ - exitfail.h fcntl.c fcntl.in.h fd-hook.h filename.h float.c \ - float.in.h itold.c fstat.c getdate.h getdtablesize.c getopt.c \ - getopt.in.h getopt1.c getopt_int.h gettimeofday.c \ +EXTRA_DIST = alloca.in.h argmatch.h assure.h openat-priv.h \ + openat-proc.c backupfile.h c-strcaseeq.h canonicalize-lgpl.c \ + chdir-long.c chdir-long.h chown.c fchown-stub.c cloexec.h \ + close.c closedir.c dirent-private.h dirent.in.h dirent--.h \ + dirent-safer.h dirfd.c stripslash.c dirname.h dosname.h dup2.c \ + errno.in.h error.c error.h exitfail.h fchdir.c at-func.c \ + fchmodat.c at-func.c fchownat.c fcntl.c fcntl.in.h fd-hook.h \ + filename.h filenamecat.h float.c float.in.h itold.c fstat.c \ + at-func.c fstatat.c getcwd-lgpl.c getdate.h getdtablesize.c \ + getopt.c getopt.in.h getopt1.c getopt_int.h gettimeofday.c \ $(top_srcdir)/build-aux/git-version-gen \ $(top_srcdir)/build-aux/gitlog-to-changelog \ $(top_srcdir)/GNUmakefile hash.h ignore-value.h intprops.h \ - config.charset ref-add.sin ref-del.sin lstat.c \ + lchown.c config.charset ref-add.sin ref-del.sin lstat.c \ $(top_srcdir)/maint.mk malloc.c malloc.c malloca.h \ malloca.valgrind mbrtowc.c mbsinit.c memchr.c memchr.valgrind \ - mkdir.c mktime-internal.h mktime.c msvc-inval.c msvc-inval.h \ - msvc-nothrow.c msvc-nothrow.h dirent-private.h opendir.c \ - parse-datetime.c parse-datetime.h pathmax.h quote.h quote.h \ - quotearg.h raise.c dirent-private.h readdir.c readlink.c \ - realloc.c realloc.c rename.c rmdir.c safe-read.c safe-write.h \ - same-inode.h secure_getenv.c setenv.c signal.in.h \ - $(top_srcdir)/build-aux/snippet/_Noreturn.h \ + mempcpy.c memrchr.c mkdir.c at-func.c mkdirat.c \ + mktime-internal.h mktime.c msvc-inval.c msvc-inval.h \ + msvc-nothrow.c msvc-nothrow.h open.c openat.c openat.h \ + dirent-private.h opendir.c parse-datetime.c parse-datetime.h \ + pathmax.h quote.h quote.h quotearg.h raise.c dirent-private.h \ + readdir.c readlink.c at-func.c readlinkat.c realloc.c \ + realloc.c rename.c at-func2.c renameat.c rmdir.c safe-read.c \ + safe-write.h same-inode.h save-cwd.h secure_getenv.c setenv.c \ + signal.in.h $(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/warn-on-use.h stat.c \ stat-time.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 strndup.c strnlen.c symlink.c \ - sys_stat.in.h sys_time.in.h sys_types.in.h tempname.h \ - time.in.h time_r.c timespec.h unistd.in.h unistd--.h \ - unistd-safer.h unlink.c unsetenv.c \ + stdio.in.h stdlib.in.h strdup.c streq.h strerror.c \ + strerror-override.c strerror-override.h string.in.h strndup.c \ + strnlen.c symlink.c at-func.c symlinkat.c sys_stat.in.h \ + sys_time.in.h sys_types.in.h tempname.h time.in.h time_r.c \ + timespec.h unistd.in.h unistd--.h unistd-safer.h unlink.c \ + at-func.c unlinkat.c unsetenv.c \ $(top_srcdir)/build-aux/update-copyright \ $(top_srcdir)/build-aux/useless-if-before-free utimens.h \ - asnprintf.c float+.h printf-args.c printf-args.h \ - printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h \ - asprintf.c vasprintf.c $(top_srcdir)/build-aux/vc-list-files \ - verify.h wchar.in.h wctype.in.h write.c xalloc.h \ - xalloc-oversized.h xmemdup0.c xmemdup0.h xalloc.h + at-func.c utimensat.c asnprintf.c float+.h printf-args.c \ + printf-args.h printf-parse.c printf-parse.h vasnprintf.c \ + vasnprintf.h asprintf.c vasprintf.c \ + $(top_srcdir)/build-aux/vc-list-files verify.h wchar.in.h \ + wctype.in.h write.c xalloc.h xalloc-oversized.h xmemdup0.c \ + xmemdup0.h xalloc.h MAINTAINERCLEANFILES = parse-datetime.c MOSTLYCLEANDIRS = sys MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t dirent.h \ @@ -1137,29 +1159,36 @@ SUFFIXES = .sed .sin noinst_LIBRARIES = libpatch.a libpatch_a_SOURCES = argmatch.c backupfile.c bitrotate.h bitrotate.c \ c-ctype.h c-ctype.c c-strcase.h c-strcasecmp.c c-strncasecmp.c \ - diffseq.h opendir-safer.c dirname.c basename.c dirname-lgpl.c \ - basename-lgpl.c stripslash.c exitfail.c fd-hook.c full-write.h \ + cloexec.c diffseq.h opendir-safer.c dirname.c basename.c \ + dirname-lgpl.c basename-lgpl.c stripslash.c exitfail.c \ + chmodat.c chownat.c fd-hook.c filenamecat-lgpl.c full-write.h \ full-write.c gettext.h gettime.c hash.c gl_linked_list.h \ gl_linked_list.c gl_anylinked_list1.h gl_anylinked_list2.h \ gl_list.h gl_list.c localcharset.h localcharset.c malloca.c \ - minmax.h parse-datetime.y progname.h progname.c quotearg.c \ - safe-write.c size_max.h stat-time.c tempname.c timespec.c \ - unistd.c dup-safer.c fd-safer.c pipe-safer.c utimens.c \ - verror.h verror.c wctype-h.c xmalloc.c xalloc-die.c gl_xlist.h \ - gl_xlist.c xsize.h xsize.c xstrndup.h xstrndup.c xvasprintf.h \ - xvasprintf.c xasprintf.c + minmax.h openat-die.c parse-datetime.y progname.h progname.c \ + quotearg.c safe-write.c save-cwd.c size_max.h stat-time.c \ + statat.c tempname.c timespec.c unistd.c dup-safer.c fd-safer.c \ + pipe-safer.c utimens.c verror.h verror.c wctype-h.c xmalloc.c \ + xalloc-die.c gl_xlist.h gl_xlist.c xsize.h xsize.c xstrndup.h \ + xstrndup.c xvasprintf.h xvasprintf.c xasprintf.c libpatch_a_LIBADD = $(gl_LIBOBJS) libpatch_a_DEPENDENCIES = $(gl_LIBOBJS) -EXTRA_libpatch_a_SOURCES = canonicalize-lgpl.c close.c closedir.c \ - dirfd.c stripslash.c dup2.c error.c fcntl.c float.c itold.c \ - fstat.c getdtablesize.c getopt.c getopt1.c gettimeofday.c \ - lstat.c malloc.c malloc.c mbrtowc.c mbsinit.c memchr.c mkdir.c \ - mktime.c msvc-inval.c msvc-nothrow.c opendir.c raise.c \ - readdir.c readlink.c realloc.c realloc.c rename.c rmdir.c \ - safe-read.c secure_getenv.c setenv.c stat.c strerror.c \ - strerror-override.c strndup.c strnlen.c symlink.c time_r.c \ - unlink.c unsetenv.c asnprintf.c printf-args.c printf-parse.c \ - vasnprintf.c asprintf.c vasprintf.c write.c xmemdup0.c +EXTRA_libpatch_a_SOURCES = openat-proc.c canonicalize-lgpl.c \ + chdir-long.c chown.c fchown-stub.c close.c closedir.c dirfd.c \ + stripslash.c dup2.c error.c fchdir.c at-func.c fchmodat.c \ + at-func.c fchownat.c fcntl.c float.c itold.c fstat.c at-func.c \ + fstatat.c getcwd-lgpl.c getdtablesize.c getopt.c getopt1.c \ + gettimeofday.c lchown.c lstat.c malloc.c malloc.c mbrtowc.c \ + mbsinit.c memchr.c mempcpy.c memrchr.c mkdir.c at-func.c \ + mkdirat.c mktime.c msvc-inval.c msvc-nothrow.c open.c openat.c \ + opendir.c raise.c readdir.c readlink.c at-func.c readlinkat.c \ + realloc.c realloc.c rename.c at-func2.c renameat.c rmdir.c \ + safe-read.c secure_getenv.c setenv.c stat.c strdup.c \ + strerror.c strerror-override.c strndup.c strnlen.c symlink.c \ + at-func.c symlinkat.c time_r.c unlink.c at-func.c unlinkat.c \ + unsetenv.c at-func.c utimensat.c asnprintf.c printf-args.c \ + printf-parse.c vasnprintf.c asprintf.c vasprintf.c write.c \ + xmemdup0.c # Use this preprocessor expression to decide whether #include_next works. # Do not rely on a 'configure'-time test for this, since the expression @@ -1229,6 +1258,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asprintf.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backupfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Po@am__quote@ @@ -1237,6 +1268,11 @@ distclean-compile: @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)/chdir-long.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chmodat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chown.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chownat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cloexec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closedir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Po@am__quote@ @@ -1246,12 +1282,19 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.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)/fchdir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchmodat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchown-stub.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchownat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-hook.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filenamecat-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/full-write.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getcwd-lgpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdtablesize.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@ @@ -1262,6 +1305,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_xlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/itold.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.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@ @@ -1269,10 +1313,17 @@ distclean-compile: @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)/memchr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memrchr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdir.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdirat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mktime.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)/open.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opendir-safer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opendir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse-datetime.Po@am__quote@ @@ -1284,28 +1335,36 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raise.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rename.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/renameat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdir.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-read.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-write.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/save-cwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/secure_getenv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setenv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat-time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.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)/strndup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tempname.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time_r.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utimens.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utimensat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasnprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verror.Po@am__quote@ @@ -1886,6 +1945,7 @@ warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h @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_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|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; \ @@ -2360,6 +2420,7 @@ 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)' \ diff --git a/lib/alloca.in.h b/lib/alloca.in.h index 5de9aaa..906fe92 100644 --- a/lib/alloca.in.h +++ b/lib/alloca.in.h @@ -1,6 +1,6 @@ /* Memory allocation on the stack. - Copyright (C) 1995, 1999, 2001-2004, 2006-2014 Free Software Foundation, + Copyright (C) 1995, 1999, 2001-2004, 2006-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it diff --git a/lib/argmatch.c b/lib/argmatch.c index f56ab55..0e452bd 100644 --- a/lib/argmatch.c +++ b/lib/argmatch.c @@ -1,6 +1,6 @@ /* argmatch.c -- find a match for a string in an array - Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2014 Free Software + Copyright (C) 1990, 1998-1999, 2001-2007, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/argmatch.h b/lib/argmatch.h index 09645db..bbbfe64 100644 --- a/lib/argmatch.h +++ b/lib/argmatch.h @@ -1,6 +1,6 @@ /* argmatch.h -- definitions and prototypes for argmatch.c - Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2014 Free Software + Copyright (C) 1990, 1998-1999, 2001-2002, 2004-2005, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/asnprintf.c b/lib/asnprintf.c index 0c62197..d6776ca 100644 --- a/lib/asnprintf.c +++ b/lib/asnprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006, 2009-2015 Free Software Foundation, Inc. This 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/asprintf.c b/lib/asprintf.c index 9a69ac4..06ae3dd 100644 --- a/lib/asprintf.c +++ b/lib/asprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2007, 2009-2014 Free Software Foundation, + Copyright (C) 1999, 2002, 2006-2007, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/assure.h b/lib/assure.h new file mode 100644 index 0000000..f44f380 --- /dev/null +++ b/lib/assure.h @@ -0,0 +1,37 @@ +/* Run-time assert-like macros. + + Copyright (C) 2014-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Paul Eggert. */ + +#ifndef _GL_ASSURE_H +#define _GL_ASSURE_H + +#include + +/* Check E's value at runtime, and report an error and abort if not. + However, do nothng if NDEBUG is defined. + + Unlike standard 'assert', this macro always compiles E even when NDEBUG + is defined, so as to catch typos and avoid some GCC warnings. */ + +#ifdef NDEBUG +# define assure(E) ((void) (0 && (E))) +#else +# define assure(E) assert (E) +#endif + +#endif diff --git a/lib/at-func.c b/lib/at-func.c new file mode 100644 index 0000000..bbbe458 --- /dev/null +++ b/lib/at-func.c @@ -0,0 +1,146 @@ +/* Define at-style functions like fstatat, unlinkat, fchownat, etc. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD +# include +# ifndef ENOTSUP +# define ENOTSUP EINVAL +# endif +#else +# include "openat.h" +# include "openat-priv.h" +# include "save-cwd.h" +#endif + +#ifdef AT_FUNC_USE_F1_COND +# define CALL_FUNC(F) \ + (flag == AT_FUNC_USE_F1_COND \ + ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \ + : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) \ + if (flag & ~AT_FUNC_USE_F1_COND) \ + { \ + errno = EINVAL; \ + return FUNC_FAIL; \ + } +#else +# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS)) +# define VALIDATE_FLAG(F) /* empty */ +#endif + +#ifdef AT_FUNC_RESULT +# define FUNC_RESULT AT_FUNC_RESULT +#else +# define FUNC_RESULT int +#endif + +#ifdef AT_FUNC_FAIL +# define FUNC_FAIL AT_FUNC_FAIL +#else +# define FUNC_FAIL -1 +#endif + +/* Call AT_FUNC_F1 to operate on FILE, which is in the directory + open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value, + AT_FUNC_POST_FILE_PARAM_DECLS must include a parameter named flag; + call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than + AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT + or AT_FUNC_FAIL are defined. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ +FUNC_RESULT +AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) +{ + VALIDATE_FLAG (flag); + + if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return CALL_FUNC (file); + +#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD + errno = ENOTSUP; + return FUNC_FAIL; +#else + { + /* Be careful to choose names unlikely to conflict with + AT_FUNC_POST_FILE_PARAM_DECLS. */ + struct saved_cwd saved_cwd; + int saved_errno; + FUNC_RESULT err; + + { + char proc_buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (proc_buf, fd, file); + if (proc_file) + { + FUNC_RESULT proc_result = CALL_FUNC (proc_file); + int proc_errno = errno; + if (proc_file != proc_buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (FUNC_FAIL != proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } + } + + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return FUNC_FAIL; + } + + if (fchdir (fd) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return FUNC_FAIL; + } + + err = CALL_FUNC (file); + saved_errno = (err == FUNC_FAIL ? errno : 0); + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + + free_cwd (&saved_cwd); + + if (saved_errno) + errno = saved_errno; + return err; + } +#endif +} +#undef CALL_FUNC +#undef FUNC_RESULT +#undef FUNC_FAIL diff --git a/lib/at-func2.c b/lib/at-func2.c new file mode 100644 index 0000000..32a64ff --- /dev/null +++ b/lib/at-func2.c @@ -0,0 +1,282 @@ +/* Define 2-FD at-style functions like linkat or renameat. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering and Eric Blake */ + +#include + +#include "openat-priv.h" + +#include +#include +#include +#include + +#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +#include "filenamecat.h" +#include "openat.h" +#include "same-inode.h" +#include "save-cwd.h" + +/* Call FUNC to operate on a pair of files, where FILE1 is relative to FD1, + and FILE2 is relative to FD2. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + FUNC, restore_cwd (up to two times). If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. */ +int +at_func2 (int fd1, char const *file1, + int fd2, char const *file2, + int (*func) (char const *file1, char const *file2)) +{ + struct saved_cwd saved_cwd; + int saved_errno; + int err; + char *file1_alt; + char *file2_alt; + struct stat st1; + struct stat st2; + + /* There are 16 possible scenarios, based on whether an fd is + AT_FDCWD or real, and whether a file is absolute or relative: + + fd1 file1 fd2 file2 action + 0 cwd abs cwd abs direct call + 1 cwd abs cwd rel direct call + 2 cwd abs fd abs direct call + 3 cwd abs fd rel chdir to fd2 + 4 cwd rel cwd abs direct call + 5 cwd rel cwd rel direct call + 6 cwd rel fd abs direct call + 7 cwd rel fd rel convert file1 to abs, then case 3 + 8 fd abs cwd abs direct call + 9 fd abs cwd rel direct call + 10 fd abs fd abs direct call + 11 fd abs fd rel chdir to fd2 + 12 fd rel cwd abs chdir to fd1 + 13 fd rel cwd rel convert file2 to abs, then case 12 + 14 fd rel fd abs chdir to fd1 + 15a fd1 rel fd1 rel chdir to fd1 + 15b fd1 rel fd2 rel chdir to fd1, then case 7 + + Try some optimizations to reduce fd to AT_FDCWD, or to at least + avoid converting an absolute name or doing a double chdir. */ + + if ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1)) + && (fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2))) + return func (file1, file2); /* Case 0-2, 4-6, 8-10. */ + + /* If /proc/self/fd works, we don't need any stat or chdir. */ + { + char proc_buf1[OPENAT_BUFFER_SIZE]; + char *proc_file1 = ((fd1 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file1)) + ? (char *) file1 + : openat_proc_name (proc_buf1, fd1, file1)); + if (proc_file1) + { + char proc_buf2[OPENAT_BUFFER_SIZE]; + char *proc_file2 = ((fd2 == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file2)) + ? (char *) file2 + : openat_proc_name (proc_buf2, fd2, file2)); + if (proc_file2) + { + int proc_result = func (proc_file1, proc_file2); + int proc_errno = errno; + if (proc_file1 != proc_buf1 && proc_file1 != file1) + free (proc_file1); + if (proc_file2 != proc_buf2 && proc_file2 != file2) + free (proc_file2); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } + else if (proc_file1 != proc_buf1 && proc_file1 != file1) + free (proc_file1); + } + } + + /* Cases 3, 7, 11-15 remain. Time to normalize directory fds, if + possible. */ + if (IS_ABSOLUTE_FILE_NAME (file1)) + fd1 = AT_FDCWD; /* Case 11 reduced to 3. */ + else if (IS_ABSOLUTE_FILE_NAME (file2)) + fd2 = AT_FDCWD; /* Case 14 reduced to 12. */ + + /* Cases 3, 7, 12, 13, 15 remain. */ + + if (fd1 == AT_FDCWD) /* Cases 3, 7. */ + { + if (stat (".", &st1) == -1 || fstat (fd2, &st2) == -1) + return -1; + if (!S_ISDIR (st2.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to cases 1, 5. */ + return func (file1, file2); + } + else if (fd2 == AT_FDCWD) /* Cases 12, 13. */ + { + if (stat (".", &st2) == -1 || fstat (fd1, &st1) == -1) + return -1; + if (!S_ISDIR (st1.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to cases 4, 5. */ + return func (file1, file2); + } + else if (fd1 != fd2) /* Case 15b. */ + { + if (fstat (fd1, &st1) == -1 || fstat (fd2, &st2) == -1) + return -1; + if (!S_ISDIR (st1.st_mode) || !S_ISDIR (st2.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (SAME_INODE (st1, st2)) /* Reduced to case 15a. */ + { + fd2 = fd1; + if (stat (".", &st1) == 0 && SAME_INODE (st1, st2)) + return func (file1, file2); /* Further reduced to case 5. */ + } + } + else /* Case 15a. */ + { + if (fstat (fd1, &st1) == -1) + return -1; + if (!S_ISDIR (st1.st_mode)) + { + errno = ENOTDIR; + return -1; + } + if (stat (".", &st2) == 0 && SAME_INODE (st1, st2)) + return func (file1, file2); /* Reduced to case 5. */ + } + + /* Cases 3, 7, 12, 13, 15a, 15b remain. With all reductions in + place, it is time to start changing directories. */ + + if (save_cwd (&saved_cwd) != 0) + openat_save_fail (errno); + + if (fd1 != AT_FDCWD && fd2 != AT_FDCWD && fd1 != fd2) /* Case 15b. */ + { + if (fchdir (fd1) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + fd1 = AT_FDCWD; /* Reduced to case 7. */ + } + + /* Cases 3, 7, 12, 13, 15a remain. Convert one relative name to + absolute, if necessary. */ + + file1_alt = (char *) file1; + file2_alt = (char *) file2; + + if (fd1 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file1)) /* Case 7. */ + { + /* It would be nicer to use: + file1_alt = file_name_concat (xgetcwd (), file1, NULL); + but libraries should not call xalloc_die. */ + char *cwd = getcwd (NULL, 0); + if (!cwd) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + file1_alt = mfile_name_concat (cwd, file1, NULL); + if (!file1_alt) + { + saved_errno = errno; + free (cwd); + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + free (cwd); /* Reduced to case 3. */ + } + else if (fd2 == AT_FDCWD && !IS_ABSOLUTE_FILE_NAME (file2)) /* Case 13. */ + { + char *cwd = getcwd (NULL, 0); + if (!cwd) + { + saved_errno = errno; + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + file2_alt = mfile_name_concat (cwd, file2, NULL); + if (!file2_alt) + { + saved_errno = errno; + free (cwd); + free_cwd (&saved_cwd); + errno = saved_errno; + return -1; + } + free (cwd); /* Reduced to case 12. */ + } + + /* Cases 3, 12, 15a remain. Change to the correct directory. */ + if (fchdir (fd1 == AT_FDCWD ? fd2 : fd1) != 0) + { + saved_errno = errno; + free_cwd (&saved_cwd); + if (file1 != file1_alt) + free (file1_alt); + else if (file2 != file2_alt) + free (file2_alt); + errno = saved_errno; + return -1; + } + + /* Finally safe to perform the user's function, then clean up. */ + + err = func (file1_alt, file2_alt); + saved_errno = (err < 0 ? errno : 0); + + if (file1 != file1_alt) + free (file1_alt); + else if (file2 != file2_alt) + free (file2_alt); + + if (restore_cwd (&saved_cwd) != 0) + openat_restore_fail (errno); + + free_cwd (&saved_cwd); + + if (saved_errno) + errno = saved_errno; + return err; +} +#undef CALL_FUNC +#undef FUNC_RESULT diff --git a/lib/backupfile.c b/lib/backupfile.c index 2ad030f..824c9d0 100644 --- a/lib/backupfile.c +++ b/lib/backupfile.c @@ -1,6 +1,6 @@ /* backupfile.c -- make Emacs style backup file names - Copyright (C) 1990-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2006, 2009-2015 Free Software Foundation, Inc. This 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/backupfile.h b/lib/backupfile.h index e2034c7..678b996 100644 --- a/lib/backupfile.h +++ b/lib/backupfile.h @@ -1,6 +1,6 @@ /* backupfile.h -- declarations for making Emacs style backup file names - Copyright (C) 1990-1992, 1997-1999, 2003-2004, 2009-2014 Free Software + Copyright (C) 1990-1992, 1997-1999, 2003-2004, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c index cec50e9..aae1280 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-2014 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/basename.c b/lib/basename.c index 67d9420..faebe76 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -1,6 +1,6 @@ /* basename.c -- return the last element in a file name - Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2014 Free Software + Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/bitrotate.h b/lib/bitrotate.h index 9ec0b47..1665e99 100644 --- a/lib/bitrotate.h +++ b/lib/bitrotate.h @@ -1,5 +1,5 @@ /* bitrotate.h - Rotate bits in integers - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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-ctype.c b/lib/c-ctype.c index 48c6478..1fb5fe6 100644 --- a/lib/c-ctype.c +++ b/lib/c-ctype.c @@ -1,6 +1,6 @@ /* Character handling in C locale. - Copyright 2000-2003, 2006, 2009-2014 Free Software Foundation, Inc. + Copyright 2000-2003, 2006, 2009-2015 Free Software Foundation, Inc. This 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-ctype.h b/lib/c-ctype.h index b465277..4764473 100644 --- a/lib/c-ctype.h +++ b/lib/c-ctype.h @@ -5,7 +5,7 @@ functions' behaviour depends on the current locale set via setlocale. - Copyright (C) 2000-2003, 2006, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2006, 2008-2015 Free Software Foundation, Inc. This 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-strcase.h b/lib/c-strcase.h index 8e66044..f25bcca 100644 --- a/lib/c-strcase.h +++ b/lib/c-strcase.h @@ -1,5 +1,5 @@ /* Case-insensitive string comparison functions in C locale. - Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2014 Free Software + Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2015 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 b9b26a4..6deb6d1 100644 --- a/lib/c-strcasecmp.c +++ b/lib/c-strcasecmp.c @@ -1,5 +1,5 @@ /* c-strcasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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 5139a30..ffd05a2 100644 --- a/lib/c-strcaseeq.h +++ b/lib/c-strcaseeq.h @@ -1,5 +1,5 @@ /* Optimized case-insensitive string comparison in C locale. - Copyright (C) 2001-2002, 2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2015 Free Software Foundation, Inc. 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/c-strncasecmp.c b/lib/c-strncasecmp.c index 972eb80..b98e368 100644 --- a/lib/c-strncasecmp.c +++ b/lib/c-strncasecmp.c @@ -1,5 +1,5 @@ /* c-strncasecmp.c -- case insensitive string comparator in C locale - Copyright (C) 1998-1999, 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1998-1999, 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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 902380f..1c9f2ee 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-2014 Free Software Foundation, Inc. + Copyright (C) 1996-2015 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 diff --git a/lib/chdir-long.c b/lib/chdir-long.c new file mode 100644 index 0000000..ecc025a --- /dev/null +++ b/lib/chdir-long.c @@ -0,0 +1,267 @@ +/* provide a chdir function that tries not to fail due to ENAMETOOLONG + Copyright (C) 2004-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +#include "chdir-long.h" + +#include +#include +#include +#include +#include +#include + +#include "assure.h" + +#ifndef PATH_MAX +# error "compile this file only if your system defines PATH_MAX" +#endif + +/* The results of openat() in this file are not leaked to any + single-threaded code that could use stdio. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use openat_safer. */ + +struct cd_buf +{ + int fd; +}; + +static void +cdb_init (struct cd_buf *cdb) +{ + cdb->fd = AT_FDCWD; +} + +static int +cdb_fchdir (struct cd_buf const *cdb) +{ + return fchdir (cdb->fd); +} + +static void +cdb_free (struct cd_buf const *cdb) +{ + if (0 <= cdb->fd) + { + bool close_fail = close (cdb->fd); + assure (! close_fail); + } +} + +/* Given a file descriptor of an open directory (or AT_FDCWD), CDB->fd, + try to open the CDB->fd-relative directory, DIR. If the open succeeds, + update CDB->fd with the resulting descriptor, close the incoming file + descriptor, and return zero. Upon failure, return -1 and set errno. */ +static int +cdb_advance_fd (struct cd_buf *cdb, char const *dir) +{ + int new_fd = openat (cdb->fd, dir, + O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + if (new_fd < 0) + return -1; + + cdb_free (cdb); + cdb->fd = new_fd; + + return 0; +} + +/* Return a pointer to the first non-slash in S. */ +static char * _GL_ATTRIBUTE_PURE +find_non_slash (char const *s) +{ + size_t n_slash = strspn (s, "/"); + return (char *) s + n_slash; +} + +/* This is a function much like chdir, but without the PATH_MAX limitation + on the length of the directory name. A significant difference is that + it must be able to modify (albeit only temporarily) the directory + name. It handles an arbitrarily long directory name by operating + on manageable portions of the name. On systems without the openat + syscall, this means changing the working directory to more and more + "distant" points along the long directory name and then restoring + the working directory. If any of those attempts to save or restore + the working directory fails, this function exits nonzero. + + Note that this function may still fail with errno == ENAMETOOLONG, but + only if the specified directory name contains a component that is long + enough to provoke such a failure all by itself (e.g. if the component + has length PATH_MAX or greater on systems that define PATH_MAX). */ + +int +chdir_long (char *dir) +{ + int e = chdir (dir); + if (e == 0 || errno != ENAMETOOLONG) + return e; + + { + size_t len = strlen (dir); + char *dir_end = dir + len; + struct cd_buf cdb; + size_t n_leading_slash; + + cdb_init (&cdb); + + /* If DIR is the empty string, then the chdir above + must have failed and set errno to ENOENT. */ + assure (0 < len); + assure (PATH_MAX <= len); + + /* Count leading slashes. */ + n_leading_slash = strspn (dir, "/"); + + /* Handle any leading slashes as well as any name that matches + the regular expression, m!^//hostname[/]*! . Handling this + prefix separately usually results in a single additional + cdb_advance_fd call, but it's worthwhile, since it makes the + code in the following loop cleaner. */ + if (n_leading_slash == 2) + { + int err; + /* Find next slash. + We already know that dir[2] is neither a slash nor '\0'. */ + char *slash = memchr (dir + 3, '/', dir_end - (dir + 3)); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } + *slash = '\0'; + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; + dir = find_non_slash (slash + 1); + } + else if (n_leading_slash) + { + if (cdb_advance_fd (&cdb, "/") != 0) + goto Fail; + dir += n_leading_slash; + } + + assure (*dir != '/'); + assure (dir <= dir_end); + + while (PATH_MAX <= dir_end - dir) + { + int err; + /* Find a slash that is PATH_MAX or fewer bytes away from dir. + I.e. see if there is a slash that will give us a name of + length PATH_MAX-1 or less. */ + char *slash = memrchr (dir, '/', PATH_MAX); + if (slash == NULL) + { + errno = ENAMETOOLONG; + return -1; + } + + *slash = '\0'; + assure (slash - dir < PATH_MAX); + err = cdb_advance_fd (&cdb, dir); + *slash = '/'; + if (err != 0) + goto Fail; + + dir = find_non_slash (slash + 1); + } + + if (dir < dir_end) + { + if (cdb_advance_fd (&cdb, dir) != 0) + goto Fail; + } + + if (cdb_fchdir (&cdb) != 0) + goto Fail; + + cdb_free (&cdb); + return 0; + + Fail: + { + int saved_errno = errno; + cdb_free (&cdb); + errno = saved_errno; + return -1; + } + } +} + +#if TEST_CHDIR + +# include "closeout.h" +# include "error.h" + +char *program_name; + +int +main (int argc, char *argv[]) +{ + char *line = NULL; + size_t n = 0; + int len; + + program_name = argv[0]; + atexit (close_stdout); + + len = getline (&line, &n, stdin); + if (len < 0) + { + int saved_errno = errno; + if (feof (stdin)) + exit (0); + + error (EXIT_FAILURE, saved_errno, + "reading standard input"); + } + else if (len == 0) + exit (0); + + if (line[len-1] == '\n') + line[len-1] = '\0'; + + if (chdir_long (line) != 0) + error (EXIT_FAILURE, errno, + "chdir_long failed: %s", line); + + if (argc <= 1) + { + /* Using 'pwd' here makes sense only if it is a robust implementation, + like the one in coreutils after the 2004-04-19 changes. */ + char const *cmd = "pwd"; + execlp (cmd, (char *) NULL); + error (EXIT_FAILURE, errno, "%s", cmd); + } + + fclose (stdin); + fclose (stderr); + + exit (EXIT_SUCCESS); +} +#endif + +/* +Local Variables: +compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a" +End: +*/ diff --git a/lib/chdir-long.h b/lib/chdir-long.h new file mode 100644 index 0000000..81dacc3 --- /dev/null +++ b/lib/chdir-long.h @@ -0,0 +1,30 @@ +/* provide a chdir function that tries not to fail due to ENAMETOOLONG + Copyright (C) 2004-2005, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Jim Meyering. */ + +#include +#include + +#include "pathmax.h" + +/* On systems without PATH_MAX, presume that chdir accepts + arbitrarily long directory names. */ +#ifndef PATH_MAX +# define chdir_long(Dir) chdir (Dir) +#else +int chdir_long (char *dir); +#endif diff --git a/lib/chmodat.c b/lib/chmodat.c new file mode 100644 index 0000000..3c69689 --- /dev/null +++ b/lib/chmodat.c @@ -0,0 +1,3 @@ +#include +#define FCHMODAT_INLINE _GL_EXTERN_INLINE +#include "openat.h" diff --git a/lib/chown.c b/lib/chown.c new file mode 100644 index 0000000..11238eb --- /dev/null +++ b/lib/chown.c @@ -0,0 +1,151 @@ +/* provide consistent interface to chown for systems that don't interpret + an ID of -1 as meaning "don't change the corresponding ID". + + Copyright (C) 1997, 2004-2007, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include +#include + +#if !HAVE_CHOWN + +/* Simple stub that always fails with ENOSYS, for mingw. */ +int +chown (const char *file _GL_UNUSED, uid_t uid _GL_UNUSED, + gid_t gid _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_CHOWN */ + +/* Below we refer to the system's chown(). */ +# undef chown + +/* Provide a more-closely POSIX-conforming version of chown on + systems with one or both of the following problems: + - chown doesn't treat an ID of -1 as meaning + "don't change the corresponding ID". + - chown doesn't dereference symlinks. */ + +int +rpl_chown (const char *file, uid_t uid, gid_t gid) +{ + struct stat st; + bool stat_valid = false; + int result; + +# if CHOWN_CHANGE_TIME_BUG + if (gid != (gid_t) -1 || uid != (uid_t) -1) + { + if (stat (file, &st)) + return -1; + stat_valid = true; + } +# endif + +# if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE + if (gid == (gid_t) -1 || uid == (uid_t) -1) + { + /* Stat file to get id(s) that should remain unchanged. */ + if (!stat_valid && stat (file, &st)) + return -1; + if (gid == (gid_t) -1) + gid = st.st_gid; + if (uid == (uid_t) -1) + uid = st.st_uid; + } +# endif + +# if CHOWN_MODIFIES_SYMLINK + { + /* Handle the case in which the system-supplied chown function + does *not* follow symlinks. Instead, it changes permissions + on the symlink itself. To work around that, we open the + file (but this can fail due to lack of read or write permission) and + use fchown on the resulting descriptor. */ + int open_flags = O_NONBLOCK | O_NOCTTY; + int fd = open (file, O_RDONLY | open_flags); + if (0 <= fd + || (errno == EACCES + && 0 <= (fd = open (file, O_WRONLY | open_flags)))) + { + int saved_errno; + bool fchown_socket_failure; + + result = fchown (fd, uid, gid); + saved_errno = errno; + + /* POSIX says fchown can fail with errno == EINVAL on sockets + and pipes, so fall back on chown in that case. */ + fchown_socket_failure = + (result != 0 && saved_errno == EINVAL + && fstat (fd, &st) == 0 + && (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode))); + + close (fd); + + if (! fchown_socket_failure) + { + errno = saved_errno; + return result; + } + } + else if (errno != EACCES) + return -1; + } +# endif + +# if CHOWN_TRAILING_SLASH_BUG + if (!stat_valid) + { + size_t len = strlen (file); + if (len && file[len - 1] == '/' && stat (file, &st)) + return -1; + } +# endif + + result = chown (file, uid, gid); + +# if CHOWN_CHANGE_TIME_BUG + if (result == 0 && stat_valid + && (uid == st.st_uid || uid == (uid_t) -1) + && (gid == st.st_gid || gid == (gid_t) -1)) + { + /* No change in ownership, but at least one argument was not -1, + so we are required to update ctime. Since chown succeeded, + we assume that chmod will do likewise. Fortunately, on all + known systems where a 'no-op' chown skips the ctime update, a + 'no-op' chmod still does the trick. */ + result = chmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO + | S_ISUID | S_ISGID | S_ISVTX)); + } +# endif + + return result; +} + +#endif /* HAVE_CHOWN */ diff --git a/lib/chownat.c b/lib/chownat.c new file mode 100644 index 0000000..3937f9c --- /dev/null +++ b/lib/chownat.c @@ -0,0 +1,3 @@ +#include +#define FCHOWNAT_INLINE _GL_EXTERN_INLINE +#include "openat.h" diff --git a/lib/cloexec.c b/lib/cloexec.c new file mode 100644 index 0000000..29d1a38 --- /dev/null +++ b/lib/cloexec.c @@ -0,0 +1,83 @@ +/* closexec.c - set or clear the close-on-exec descriptor flag + + Copyright (C) 1991, 2004-2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . + + The code is taken from glibc/manual/llio.texi */ + +#include + +#include "cloexec.h" + +#include +#include +#include + +/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, + or clear the flag if VALUE is false. + Return 0 on success, or -1 on error with 'errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ + +int +set_cloexec_flag (int desc, bool value) +{ +#ifdef F_SETFD + + int flags = fcntl (desc, F_GETFD, 0); + + if (0 <= flags) + { + int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC); + + if (flags == newflags + || fcntl (desc, F_SETFD, newflags) != -1) + return 0; + } + + return -1; + +#else /* !F_SETFD */ + + /* Use dup2 to reject invalid file descriptors; the cloexec flag + will be unaffected. */ + if (desc < 0) + { + errno = EBADF; + return -1; + } + if (dup2 (desc, desc) < 0) + /* errno is EBADF here. */ + return -1; + + /* There is nothing we can do on this kind of platform. Punt. */ + return 0; +#endif /* !F_SETFD */ +} + + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int +dup_cloexec (int fd) +{ + return fcntl (fd, F_DUPFD_CLOEXEC, 0); +} diff --git a/lib/cloexec.h b/lib/cloexec.h new file mode 100644 index 0000000..ef5bacc --- /dev/null +++ b/lib/cloexec.h @@ -0,0 +1,38 @@ +/* closexec.c - set or clear the close-on-exec descriptor flag + + Copyright (C) 2004, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . + +*/ + +#include + +/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true, + or clear the flag if VALUE is false. + Return 0 on success, or -1 on error with 'errno' set. + + Note that on MingW, this function does NOT protect DESC from being + inherited into spawned children. Instead, either use dup_cloexec + followed by closing the original DESC, or use interfaces such as + open or pipe2 that accept flags like O_CLOEXEC to create DESC + non-inheritable in the first place. */ + +int set_cloexec_flag (int desc, bool value); + +/* Duplicates a file handle FD, while marking the copy to be closed + prior to exec or spawn. Returns -1 and sets errno if FD could not + be duplicated. */ + +int dup_cloexec (int fd); diff --git a/lib/close.c b/lib/close.c index d7dcb3f..54d1f71 100644 --- a/lib/close.c +++ b/lib/close.c @@ -1,5 +1,5 @@ /* close replacement. - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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/closedir.c b/lib/closedir.c index 940c6f9..f80843f 100644 --- a/lib/closedir.c +++ b/lib/closedir.c @@ -1,5 +1,5 @@ /* Stop reading the entries of a directory. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/config.charset b/lib/config.charset index 289bc44..f06d7e9 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-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2004, 2006-2015 Free Software Foundation, Inc. # # This 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/diffseq.h b/lib/diffseq.h index 1974c36..b418830 100644 --- a/lib/diffseq.h +++ b/lib/diffseq.h @@ -1,6 +1,6 @@ /* Analyze differences between two vectors. - Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2014 Free Software + Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/dirent--.h b/lib/dirent--.h index d7c51ba..17a8853 100644 --- a/lib/dirent--.h +++ b/lib/dirent--.h @@ -1,6 +1,6 @@ /* Like dirent.h, but redefine some names to avoid glitches. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/dirent-private.h b/lib/dirent-private.h index 83531a1..aa01f60 100644 --- a/lib/dirent-private.h +++ b/lib/dirent-private.h @@ -1,5 +1,5 @@ /* Private details of the DIR type. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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/dirent-safer.h b/lib/dirent-safer.h index 8cc75d8..da62b2e 100644 --- a/lib/dirent-safer.h +++ b/lib/dirent-safer.h @@ -1,6 +1,6 @@ /* Invoke dirent-like functions, but avoid some glitches. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/dirent.in.h b/lib/dirent.in.h index 4822d6b..ddd3b84 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -1,5 +1,5 @@ /* A GNU-like . - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/dirfd.c b/lib/dirfd.c index 4d37928..c91f8e5 100644 --- a/lib/dirfd.c +++ b/lib/dirfd.c @@ -1,6 +1,6 @@ /* dirfd.c -- return the file descriptor associated with an open DIR* - Copyright (C) 2001, 2006, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2001, 2006, 2008-2015 Free Software Foundation, Inc. This 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/dirname-lgpl.c b/lib/dirname-lgpl.c index d4a6973..9839135 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-2014 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/dirname.c b/lib/dirname.c index 94f1a36..c22be31 100644 --- a/lib/dirname.c +++ b/lib/dirname.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-2014 Free Software + Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2015 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 657d265..55021ec 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-2014 Free Software Foundation, + Copyright (C) 1998, 2001, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/dosname.h b/lib/dosname.h index b92adfa..893baf6 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-2014 Free Software Foundation, Inc. + Copyright (C) 2000-2001, 2004-2006, 2009-2015 Free Software Foundation, Inc. This 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/dup-safer.c b/lib/dup-safer.c index 8df3cda..c6436cd 100644 --- a/lib/dup-safer.c +++ b/lib/dup-safer.c @@ -1,6 +1,6 @@ /* Invoke dup, but avoid some glitches. - Copyright (C) 2001, 2004-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001, 2004-2006, 2009-2015 Free Software Foundation, Inc. This 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/dup2.c b/lib/dup2.c index 7de6805..0e13214 100644 --- a/lib/dup2.c +++ b/lib/dup2.c @@ -1,6 +1,6 @@ /* Duplicate an open file descriptor to a specified file descriptor. - Copyright (C) 1999, 2004-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1999, 2004-2007, 2009-2015 Free Software Foundation, Inc. This 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 832afc8..affbb97 100644 --- a/lib/errno.in.h +++ b/lib/errno.in.h @@ -1,6 +1,6 @@ /* A POSIX-like . - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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 18ff5db..6683197 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-2014 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009-2015 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 diff --git a/lib/error.h b/lib/error.h index 4aaafb3..ccffef5 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-2014 Free Software Foundation, + Copyright (C) 1995-1997, 2003, 2006, 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/lib/exitfail.c b/lib/exitfail.c index 609afc5..8035b89 100644 --- a/lib/exitfail.c +++ b/lib/exitfail.c @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. This 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 66807d5..62d0ac5 100644 --- a/lib/exitfail.h +++ b/lib/exitfail.h @@ -1,6 +1,6 @@ /* Failure exit status - Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2015 Free Software Foundation, Inc. This 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/fchdir.c b/lib/fchdir.c new file mode 100644 index 0000000..944d1bd --- /dev/null +++ b/lib/fchdir.c @@ -0,0 +1,208 @@ +/* fchdir replacement. + Copyright (C) 2006-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +#include + +/* Specification. */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "assure.h" +#include "dosname.h" +#include "filenamecat.h" + +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif + +/* This replacement assumes that a directory is not renamed while opened + through a file descriptor. + + FIXME: On mingw, this would be possible to enforce if we were to + also open a HANDLE to each directory currently visited by a file + descriptor, since mingw refuses to rename any in-use file system + object. */ + +/* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points + to a directory, it stores info about this directory. */ +typedef struct +{ + char *name; /* Absolute name of the directory, or NULL. */ + /* FIXME - add a DIR* member to make dirfd possible on mingw? */ +} dir_info_t; +static dir_info_t *dirs; +static size_t dirs_allocated; + +/* Try to ensure dirs has enough room for a slot at index fd; free any + contents already in that slot. Return false and set errno to + ENOMEM on allocation failure. */ +static bool +ensure_dirs_slot (size_t fd) +{ + if (fd < dirs_allocated) + free (dirs[fd].name); + else + { + size_t new_allocated; + dir_info_t *new_dirs; + + new_allocated = 2 * dirs_allocated + 1; + if (new_allocated <= fd) + new_allocated = fd + 1; + new_dirs = + (dirs != NULL + ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs) + : (dir_info_t *) malloc (new_allocated * sizeof *dirs)); + if (new_dirs == NULL) + return false; + memset (new_dirs + dirs_allocated, 0, + (new_allocated - dirs_allocated) * sizeof *dirs); + dirs = new_dirs; + dirs_allocated = new_allocated; + } + return true; +} + +/* Return an absolute name of DIR in malloc'd storage. */ +static char * +get_name (char const *dir) +{ + char *cwd; + char *result; + int saved_errno; + + if (IS_ABSOLUTE_FILE_NAME (dir)) + return strdup (dir); + + /* We often encounter "."; treat it as a special case. */ + cwd = getcwd (NULL, 0); + if (!cwd || (dir[0] == '.' && dir[1] == '\0')) + return cwd; + + result = mfile_name_concat (cwd, dir, NULL); + saved_errno = errno; + free (cwd); + errno = saved_errno; + return result; +} + +/* Hook into the gnulib replacements for open() and close() to keep track + of the open file descriptors. */ + +/* Close FD, cleaning up any fd to name mapping if fd was visiting a + directory. */ +void +_gl_unregister_fd (int fd) +{ + if (fd >= 0 && fd < dirs_allocated) + { + free (dirs[fd].name); + dirs[fd].name = NULL; + } +} + +/* Mark FD as visiting FILENAME. FD must be non-negative, and refer + to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero, + this should only be called if FD is visiting a directory. Close FD + and return -1 if there is insufficient memory to track the + directory name; otherwise return FD. */ +int +_gl_register_fd (int fd, const char *filename) +{ + struct stat statbuf; + + assure (0 <= fd); + if (REPLACE_OPEN_DIRECTORY + || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))) + { + if (!ensure_dirs_slot (fd) + || (dirs[fd].name = get_name (filename)) == NULL) + { + int saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } + } + return fd; +} + +/* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3, + and fcntl. Both arguments must be valid and distinct file + descriptors. Close NEWFD and return -1 if OLDFD is tracking a + directory, but there is insufficient memory to track the same + directory in NEWFD; otherwise return NEWFD. */ +int +_gl_register_dup (int oldfd, int newfd) +{ + assure (0 <= oldfd && 0 <= newfd && oldfd != newfd); + if (oldfd < dirs_allocated && dirs[oldfd].name) + { + /* Duplicated a directory; must ensure newfd is allocated. */ + if (!ensure_dirs_slot (newfd) + || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL) + { + int saved_errno = errno; + close (newfd); + errno = saved_errno; + newfd = -1; + } + } + else if (newfd < dirs_allocated) + { + /* Duplicated a non-directory; ensure newfd is cleared. */ + free (dirs[newfd].name); + dirs[newfd].name = NULL; + } + return newfd; +} + +/* If FD is currently visiting a directory, then return the name of + that directory. Otherwise, return NULL and set errno. */ +const char * +_gl_directory_name (int fd) +{ + if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL) + return dirs[fd].name; + /* At this point, fd is either invalid, or open but not a directory. + If dup2 fails, errno is correctly EBADF. */ + if (0 <= fd) + { + if (dup2 (fd, fd) == fd) + errno = ENOTDIR; + } + else + errno = EBADF; + return NULL; +} + + +/* Implement fchdir() in terms of chdir(). */ + +int +fchdir (int fd) +{ + const char *name = _gl_directory_name (fd); + return name ? chdir (name) : -1; +} diff --git a/lib/fchmodat.c b/lib/fchmodat.c new file mode 100644 index 0000000..c09d02d --- /dev/null +++ b/lib/fchmodat.c @@ -0,0 +1,53 @@ +/* Change the protections of file relative to an open directory. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +#include + +#include + +#ifndef HAVE_LCHMOD +/* Use a different name, to avoid conflicting with any + system-supplied declaration. */ +# undef lchmod +# define lchmod lchmod_rpl +static int +lchmod (char const *f _GL_UNUSED, mode_t m _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} +#endif + +/* Solaris 10 has no function like this. + Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory + open on descriptor FD. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then (chmod|lchmod)/restore_cwd. If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. + Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW + on a system without lchmod support causes this function to fail. */ + +#define AT_FUNC_NAME fchmodat +#define AT_FUNC_F1 lchmod +#define AT_FUNC_F2 chmod +#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +#define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode, int flag +#define AT_FUNC_POST_FILE_ARGS , mode +#include "at-func.c" diff --git a/lib/fchown-stub.c b/lib/fchown-stub.c new file mode 100644 index 0000000..62b6969 --- /dev/null +++ b/lib/fchown-stub.c @@ -0,0 +1,16 @@ +#include + +#include +#include + +/* A trivial substitute for 'fchown'. + + DJGPP 2.03 and earlier (and perhaps later) don't have 'fchown', + so we pretend no-one has permission for this operation. */ + +int +fchown (int fd, uid_t uid, gid_t gid) +{ + errno = EPERM; + return -1; +} diff --git a/lib/fchownat.c b/lib/fchownat.c new file mode 100644 index 0000000..3bf5daa --- /dev/null +++ b/lib/fchownat.c @@ -0,0 +1,114 @@ +/* This function serves as replacement for a missing fchownat function, + as well as a work around for the fchownat bug in glibc-2.4: + + when the buggy fchownat-with-AT_SYMLINK_NOFOLLOW operates on a symlink, it + mistakenly affects the symlink referent, rather than the symlink itself. + + Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +#include + +#include +#include + +#include "openat.h" + +#if !HAVE_FCHOWNAT + +/* Replacement for Solaris' function by the same name. + Invoke chown or lchown on file, FILE, using OWNER and GROUP, in the + directory open on descriptor FD. If FLAG is AT_SYMLINK_NOFOLLOW, then + use lchown, otherwise, use chown. If possible, do it without changing + the working directory. Otherwise, resort to using save_cwd/fchdir, + then (chown|lchown)/restore_cwd. If either the save_cwd or the + restore_cwd fails, then give a diagnostic and exit nonzero. */ + +# define AT_FUNC_NAME fchownat +# define AT_FUNC_F1 lchown +# define AT_FUNC_F2 chown +# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +# define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group, int flag +# define AT_FUNC_POST_FILE_ARGS , owner, group +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#else /* HAVE_FCHOWNAT */ + +# undef fchownat + +# if FCHOWNAT_NOFOLLOW_BUG + +/* Failure to handle AT_SYMLINK_NOFOLLOW requires the /proc/self/fd or + fchdir workaround to call lchown for lchownat, but there is no need + to penalize chownat. */ +static int +local_lchownat (int fd, char const *file, uid_t owner, gid_t group); + +# define AT_FUNC_NAME local_lchownat +# define AT_FUNC_F1 lchown +# define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group +# define AT_FUNC_POST_FILE_ARGS , owner, group +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +# endif + +/* Work around bugs with trailing slash, using the same workarounds as + chown and lchown. */ + +int +rpl_fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag) +{ +# if FCHOWNAT_NOFOLLOW_BUG + if (flag == AT_SYMLINK_NOFOLLOW) + return local_lchownat (fd, file, owner, group); +# endif +# if FCHOWNAT_EMPTY_FILENAME_BUG + if (file[0] == '\0') + { + errno = ENOENT; + return -1; + } +# endif +# if CHOWN_TRAILING_SLASH_BUG + { + size_t len = strlen (file); + struct stat st; + if (len && file[len - 1] == '/') + { + if (statat (fd, file, &st)) + return -1; + if (flag == AT_SYMLINK_NOFOLLOW) + return fchownat (fd, file, owner, group, 0); + } + } +# endif + return fchownat (fd, file, owner, group, flag); +} + +#endif /* HAVE_FCHOWNAT */ diff --git a/lib/fcntl.c b/lib/fcntl.c index 1e35dd1..23b73e9 100644 --- a/lib/fcntl.c +++ b/lib/fcntl.c @@ -1,6 +1,6 @@ /* Provide file descriptor control. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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 f63cd6a..e288018 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -1,6 +1,6 @@ /* Like , but with non-working flags defined to 0. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/fd-hook.c b/lib/fd-hook.c index 0171cc6..b1488c4 100644 --- a/lib/fd-hook.c +++ b/lib/fd-hook.c @@ -1,5 +1,5 @@ /* Hook for making making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This program is free software: you can redistribute it and/or modify it diff --git a/lib/fd-hook.h b/lib/fd-hook.h index 1aa264e..bdb9aef 100644 --- a/lib/fd-hook.h +++ b/lib/fd-hook.h @@ -1,5 +1,5 @@ /* Hook for making making file descriptor functions close(), ioctl() extensible. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. 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/fd-safer.c b/lib/fd-safer.c index 148f735..6c1fb2b 100644 --- a/lib/fd-safer.c +++ b/lib/fd-safer.c @@ -1,6 +1,6 @@ /* Return a safer copy of a file descriptor. - Copyright (C) 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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/filename.h b/lib/filename.h index 96dbaaa..4576993 100644 --- a/lib/filename.h +++ b/lib/filename.h @@ -1,5 +1,5 @@ /* Basic filename support macros. - Copyright (C) 2001-2004, 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2007-2015 Free Software Foundation, Inc. This 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/filenamecat-lgpl.c b/lib/filenamecat-lgpl.c new file mode 100644 index 0000000..a359a51 --- /dev/null +++ b/lib/filenamecat-lgpl.c @@ -0,0 +1,88 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-2007, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "filenamecat.h" + +#include +#include + +#include "dirname.h" + +#if ! HAVE_MEMPCPY && ! defined mempcpy +# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N))) +#endif + +/* Return the longest suffix of F that is a relative file name. + If it has no such suffix, return the empty string. */ + +static char const * _GL_ATTRIBUTE_PURE +longest_relative_suffix (char const *f) +{ + for (f += FILE_SYSTEM_PREFIX_LEN (f); ISSLASH (*f); f++) + continue; + return f; +} + +/* Concatenate two file name components, DIR and ABASE, in + newly-allocated storage and return the result. + The resulting file name F is such that the commands "ls F" and "(cd + DIR; ls BASE)" refer to the same file, where BASE is ABASE with any + file system prefixes and leading separators removed. + Arrange for a directory separator if necessary between DIR and BASE + in the result, removing any redundant separators. + In any case, if BASE_IN_RESULT is non-NULL, set + *BASE_IN_RESULT to point to the copy of ABASE in the returned + concatenation. However, if ABASE begins with more than one slash, + set *BASE_IN_RESULT to point to the sole corresponding slash that + is copied into the result buffer. + + Return NULL if malloc fails. */ + +char * +mfile_name_concat (char const *dir, char const *abase, char **base_in_result) +{ + char const *dirbase = last_component (dir); + size_t dirbaselen = base_len (dirbase); + size_t dirlen = dirbase - dir + dirbaselen; + size_t needs_separator = (dirbaselen && ! ISSLASH (dirbase[dirbaselen - 1])); + + char const *base = longest_relative_suffix (abase); + size_t baselen = strlen (base); + + char *p_concat = malloc (dirlen + needs_separator + baselen + 1); + char *p; + + if (p_concat == NULL) + return NULL; + + p = mempcpy (p_concat, dir, dirlen); + *p = DIRECTORY_SEPARATOR; + p += needs_separator; + + if (base_in_result) + *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase); + + p = mempcpy (p, base, baselen); + *p = '\0'; + + return p_concat; +} diff --git a/lib/filenamecat.h b/lib/filenamecat.h new file mode 100644 index 0000000..62f81b0 --- /dev/null +++ b/lib/filenamecat.h @@ -0,0 +1,27 @@ +/* Concatenate two arbitrary file names. + + Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2015 Free Software + Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Jim Meyering. */ + +#if GNULIB_FILENAMECAT +char *file_name_concat (char const *dir, char const *base, + char **base_in_result); +#endif + +char *mfile_name_concat (char const *dir, char const *base, + char **base_in_result); diff --git a/lib/float+.h b/lib/float+.h index 5ff1511..e6aaa92 100644 --- a/lib/float+.h +++ b/lib/float+.h @@ -1,5 +1,5 @@ /* Supplemental information about the floating-point formats. - Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2007. This program is free software; you can redistribute it and/or modify diff --git a/lib/float.c b/lib/float.c index b7c321d..dac9f88 100644 --- a/lib/float.c +++ b/lib/float.c @@ -1,5 +1,5 @@ /* Auxiliary definitions for . - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This program is free software: you can redistribute it and/or modify diff --git a/lib/float.in.h b/lib/float.in.h index db809f8..3bb3826 100644 --- a/lib/float.in.h +++ b/lib/float.in.h @@ -1,6 +1,6 @@ /* A correct . - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This 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/fstat.c b/lib/fstat.c index ffcda9f..7a0521f 100644 --- a/lib/fstat.c +++ b/lib/fstat.c @@ -1,5 +1,5 @@ /* fstat() replacement. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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/fstatat.c b/lib/fstatat.c new file mode 100644 index 0000000..6a9e862 --- /dev/null +++ b/lib/fstatat.c @@ -0,0 +1,135 @@ +/* Work around an fstatat bug on Solaris 9. + + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Paul Eggert and Jim Meyering. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_fstatat doesn't recurse to + rpl_fstatat. */ +#define __need_system_sys_stat_h +#include + +/* Get the original definition of fstatat. It might be defined as a macro. */ +#include +#include +#undef __need_system_sys_stat_h + +#if HAVE_FSTATAT +static int +orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) +{ + return fstatat (fd, filename, buf, flags); +} +#endif + +/* Write "sys/stat.h" here, not , otherwise OSF/1 5.1 DTK cc + eliminates this include because of the preliminary #include + above. */ +#include "sys/stat.h" + +#include +#include +#include + +#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG + +# ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK +# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 +# endif + +/* fstatat should always follow symbolic links that end in /, but on + Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. + Likewise, trailing slash on a non-directory should be an error. + These are the same problems that lstat.c and stat.c address, so + solve it in a similar way. + + AIX 7.1 fstatat (AT_FDCWD, ..., 0) always fails, which is a bug. + Work around this bug if FSTATAT_AT_FDCWD_0_BROKEN is nonzero. */ + +int +rpl_fstatat (int fd, char const *file, struct stat *st, int flag) +{ + int result = orig_fstatat (fd, file, st, flag); + size_t len; + + if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) + return result; + len = strlen (file); + if (flag & AT_SYMLINK_NOFOLLOW) + { + /* Fix lstat behavior. */ + if (file[len - 1] != '/' || S_ISDIR (st->st_mode)) + return 0; + if (!S_ISLNK (st->st_mode)) + { + errno = ENOTDIR; + return -1; + } + result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); + } + /* Fix stat behavior. */ + if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') + { + errno = ENOTDIR; + return -1; + } + return result; +} + +#else /* ! (HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG) */ + +/* On mingw, the gnulib defines 'stat' as a function-like + macro; but using it in AT_FUNC_F2 causes compilation failure + because the preprocessor sees a use of a macro that requires two + arguments but is only given one. Hence, we need an inline + forwarder to get past the preprocessor. */ +static int +stat_func (char const *name, struct stat *st) +{ + return stat (name, st); +} + +/* Likewise, if there is no native 'lstat', then the gnulib + defined it as stat, which also needs adjustment. */ +# if !HAVE_LSTAT +# undef lstat +# define lstat stat_func +# endif + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' fstatat. */ + +# define AT_FUNC_NAME fstatat +# define AT_FUNC_F1 lstat +# define AT_FUNC_F2 stat_func +# define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +# define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag +# define AT_FUNC_POST_FILE_ARGS , st +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_FSTATAT */ diff --git a/lib/full-write.c b/lib/full-write.c index b803677..027f77a 100644 --- a/lib/full-write.c +++ b/lib/full-write.c @@ -1,6 +1,6 @@ /* An interface to read and write that retries (if necessary) until complete. - Copyright (C) 1993-1994, 1997-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1993-1994, 1997-2006, 2009-2015 Free Software Foundation, Inc. This 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/full-write.h b/lib/full-write.h index 589f6e1..b32b53d 100644 --- a/lib/full-write.h +++ b/lib/full-write.h @@ -1,6 +1,6 @@ /* An interface to write() that writes all it is asked to write. - Copyright (C) 2002-2003, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2009-2015 Free Software Foundation, Inc. This 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/getcwd-lgpl.c b/lib/getcwd-lgpl.c new file mode 100644 index 0000000..1e17e19 --- /dev/null +++ b/lib/getcwd-lgpl.c @@ -0,0 +1,126 @@ +/* Copyright (C) 2011-2015 Free Software Foundation, Inc. + This file is part of gnulib. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU 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 . */ + +#include + +/* Specification */ +#include + +#include +#include +#include + +#if GNULIB_GETCWD +/* Favor GPL getcwd.c if both getcwd and getcwd-lgpl modules are in use. */ +typedef int dummy; +#else + +/* Get the name of the current working directory, and put it in SIZE + bytes of BUF. Returns NULL if the directory couldn't be determined + (perhaps because the absolute name was longer than PATH_MAX, or + because of missing read/search permissions on parent directories) + or SIZE was too small. If successful, returns BUF. If BUF is + NULL, an array is allocated with 'malloc'; the array is SIZE bytes + long, unless SIZE == 0, in which case it is as big as + necessary. */ + +# undef getcwd +char * +rpl_getcwd (char *buf, size_t size) +{ + char *ptr; + char *result; + + /* Handle single size operations. */ + if (buf) + { + if (!size) + { + errno = EINVAL; + return NULL; + } + return getcwd (buf, size); + } + + if (size) + { + buf = malloc (size); + if (!buf) + { + errno = ENOMEM; + return NULL; + } + result = getcwd (buf, size); + if (!result) + { + int saved_errno = errno; + free (buf); + errno = saved_errno; + } + return result; + } + + /* Flexible sizing requested. Avoid over-allocation for the common + case of a name that fits within a 4k page, minus some space for + local variables, to be sure we don't skip over a guard page. */ + { + char tmp[4032]; + size = sizeof tmp; + ptr = getcwd (tmp, size); + if (ptr) + { + result = strdup (ptr); + if (!result) + errno = ENOMEM; + return result; + } + if (errno != ERANGE) + return NULL; + } + + /* My what a large directory name we have. */ + do + { + size <<= 1; + ptr = realloc (buf, size); + if (ptr == NULL) + { + free (buf); + errno = ENOMEM; + return NULL; + } + buf = ptr; + result = getcwd (buf, size); + } + while (!result && errno == ERANGE); + + if (!result) + { + int saved_errno = errno; + free (buf); + errno = saved_errno; + } + else + { + /* Trim to fit, if possible. */ + result = realloc (buf, strlen (buf) + 1); + if (!result) + result = buf; + } + return result; +} + +#endif diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c index f0c6271..59b9736 100644 --- a/lib/getdtablesize.c +++ b/lib/getdtablesize.c @@ -1,5 +1,5 @@ /* getdtablesize() function for platforms that don't have it. - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/lib/getopt.c b/lib/getopt.c index 7d950af..3b9c585 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-2014 Free Software + Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/lib/getopt.in.h b/lib/getopt.in.h index 7ab99fb..9248f76 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-2014 Free Software + Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/lib/getopt1.c b/lib/getopt1.c index a184865..2b1feb6 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-2014 Free Software + Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2015 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 24ed672..e893a6e 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-2014 Free Software + Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. diff --git a/lib/gettext.h b/lib/gettext.h index c7d6fd3..599a14e 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -1,5 +1,5 @@ /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2014 Free Software + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/gettime.c b/lib/gettime.c index 1b4ca8d..1c47e3b 100644 --- a/lib/gettime.c +++ b/lib/gettime.c @@ -1,6 +1,6 @@ /* gettime -- get the system clock - Copyright (C) 2002, 2004-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002, 2004-2007, 2009-2015 Free Software Foundation, Inc. This 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/gettimeofday.c b/lib/gettimeofday.c index 8b2058e..e0e2e69 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -1,6 +1,6 @@ /* Provide gettimeofday for systems that don't have it or for which it's broken. - Copyright (C) 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. This 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/gl_anylinked_list1.h b/lib/gl_anylinked_list1.h index 6433442..aa336e3 100644 --- a/lib/gl_anylinked_list1.h +++ b/lib/gl_anylinked_list1.h @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a linked list. - Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h index 8711823..12f732e 100644 --- a/lib/gl_anylinked_list2.h +++ b/lib/gl_anylinked_list2.h @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a linked list. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/lib/gl_linked_list.c b/lib/gl_linked_list.c index 69a63ab..b83e164 100644 --- a/lib/gl_linked_list.c +++ b/lib/gl_linked_list.c @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a linked list. - Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/lib/gl_linked_list.h b/lib/gl_linked_list.h index f65859a..a7b7eec 100644 --- a/lib/gl_linked_list.h +++ b/lib/gl_linked_list.h @@ -1,5 +1,5 @@ /* Sequential list data type implemented by a linked list. - Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/lib/gl_list.h b/lib/gl_list.h index ad6d12f..916f57f 100644 --- a/lib/gl_list.h +++ b/lib/gl_list.h @@ -1,5 +1,5 @@ /* Abstract sequential list data type. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software: you can redistribute it and/or modify diff --git a/lib/gl_xlist.h b/lib/gl_xlist.h index a4f4e89..7ea62c1 100644 --- a/lib/gl_xlist.h +++ b/lib/gl_xlist.h @@ -1,5 +1,5 @@ /* Abstract sequential list data type, with out-of-memory checking. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This program is free software: you can redistribute it and/or modify diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 493cf9c..9d80d74 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-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 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,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libpatch --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl argmatch backupfile clock-time diffseq dirname dup2 errno exitfail extensions fcntl-h full-write getdate getopt-gnu gettime git-version-gen gitlog-to-changelog hash ignore-value intprops largefile lchmod linked-list lstat maintainer-makefile malloc manywarnings memchr minmax mkdir progname quotearg readlink realloc rename rmdir setenv signal ssize_t stat-time stdbool stdlib symlink sys_stat tempname time unistd unlink update-copyright utimens verror xalloc xlist xmemdup0 +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libpatch --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --makefile-name=gnulib.mk --no-conditional-dependencies --no-libtool --macro-prefix=gl argmatch backupfile clock-time diffseq dirname dup2 errno exitfail extensions fchmodat fchownat fcntl-h fstatat full-write getdate getopt-gnu gettime git-version-gen gitlog-to-changelog hash ignore-value intprops largefile linked-list maintainer-makefile malloc manywarnings memchr minmax mkdirat openat progname quotearg readlinkat realloc renameat setenv signal ssize_t stat-time stdbool stdlib symlinkat sys_stat tempname time unistd unlinkat update-copyright utimensat verror xalloc xlist xmemdup0 MOSTLYCLEANFILES += core *.stackdump @@ -73,6 +73,22 @@ EXTRA_DIST += argmatch.h ## end gnulib module argmatch +## begin gnulib module assure + + +EXTRA_DIST += assure.h + +## end gnulib module assure + +## begin gnulib module at-internal + + +EXTRA_DIST += openat-priv.h openat-proc.c + +EXTRA_libpatch_a_SOURCES += openat-proc.c + +## end gnulib module at-internal + ## begin gnulib module backupfile libpatch_a_SOURCES += backupfile.c @@ -115,6 +131,32 @@ EXTRA_libpatch_a_SOURCES += canonicalize-lgpl.c ## end gnulib module canonicalize-lgpl +## begin gnulib module chdir-long + + +EXTRA_DIST += chdir-long.c chdir-long.h + +EXTRA_libpatch_a_SOURCES += chdir-long.c + +## end gnulib module chdir-long + +## begin gnulib module chown + + +EXTRA_DIST += chown.c fchown-stub.c + +EXTRA_libpatch_a_SOURCES += chown.c fchown-stub.c + +## end gnulib module chown + +## begin gnulib module cloexec + +libpatch_a_SOURCES += cloexec.c + +EXTRA_DIST += cloexec.h + +## end gnulib module cloexec + ## begin gnulib module close @@ -334,6 +376,35 @@ EXTRA_DIST += exitfail.h ## end gnulib module exitfail +## begin gnulib module fchdir + + +EXTRA_DIST += fchdir.c + +EXTRA_libpatch_a_SOURCES += fchdir.c + +## end gnulib module fchdir + +## begin gnulib module fchmodat + +libpatch_a_SOURCES += chmodat.c + +EXTRA_DIST += at-func.c fchmodat.c + +EXTRA_libpatch_a_SOURCES += at-func.c fchmodat.c + +## end gnulib module fchmodat + +## begin gnulib module fchownat + +libpatch_a_SOURCES += chownat.c + +EXTRA_DIST += at-func.c fchownat.c + +EXTRA_libpatch_a_SOURCES += at-func.c fchownat.c + +## end gnulib module fchownat + ## begin gnulib module fcntl @@ -393,6 +464,14 @@ EXTRA_DIST += filename.h ## end gnulib module filename +## begin gnulib module filenamecat-lgpl + +libpatch_a_SOURCES += filenamecat-lgpl.c + +EXTRA_DIST += filenamecat.h + +## end gnulib module filenamecat-lgpl + ## begin gnulib module float BUILT_SOURCES += $(FLOAT_H) @@ -433,12 +512,30 @@ EXTRA_libpatch_a_SOURCES += fstat.c ## end gnulib module fstat +## begin gnulib module fstatat + + +EXTRA_DIST += at-func.c fstatat.c + +EXTRA_libpatch_a_SOURCES += at-func.c fstatat.c + +## end gnulib module fstatat + ## begin gnulib module full-write libpatch_a_SOURCES += full-write.h full-write.c ## end gnulib module full-write +## begin gnulib module getcwd-lgpl + + +EXTRA_DIST += getcwd-lgpl.c + +EXTRA_libpatch_a_SOURCES += getcwd-lgpl.c + +## end gnulib module getcwd-lgpl + ## begin gnulib module getdate @@ -549,6 +646,15 @@ EXTRA_DIST += intprops.h ## end gnulib module intprops +## begin gnulib module lchown + + +EXTRA_DIST += lchown.c + +EXTRA_libpatch_a_SOURCES += lchown.c + +## end gnulib module lchown + ## begin gnulib module linked-list libpatch_a_SOURCES += gl_linked_list.h gl_linked_list.c gl_anylinked_list1.h gl_anylinked_list2.h @@ -703,6 +809,24 @@ EXTRA_libpatch_a_SOURCES += memchr.c ## end gnulib module memchr +## begin gnulib module mempcpy + + +EXTRA_DIST += mempcpy.c + +EXTRA_libpatch_a_SOURCES += mempcpy.c + +## end gnulib module mempcpy + +## begin gnulib module memrchr + + +EXTRA_DIST += memrchr.c + +EXTRA_libpatch_a_SOURCES += memrchr.c + +## end gnulib module memrchr + ## begin gnulib module minmax libpatch_a_SOURCES += minmax.h @@ -718,6 +842,15 @@ EXTRA_libpatch_a_SOURCES += mkdir.c ## end gnulib module mkdir +## begin gnulib module mkdirat + + +EXTRA_DIST += at-func.c mkdirat.c + +EXTRA_libpatch_a_SOURCES += at-func.c mkdirat.c + +## end gnulib module mkdirat + ## begin gnulib module mktime @@ -745,6 +878,37 @@ EXTRA_libpatch_a_SOURCES += msvc-nothrow.c ## end gnulib module msvc-nothrow +## begin gnulib module open + + +EXTRA_DIST += open.c + +EXTRA_libpatch_a_SOURCES += open.c + +## end gnulib module open + +## begin gnulib module openat + + +EXTRA_DIST += openat.c + +EXTRA_libpatch_a_SOURCES += openat.c + +## end gnulib module openat + +## begin gnulib module openat-die + +libpatch_a_SOURCES += openat-die.c + +## end gnulib module openat-die + +## begin gnulib module openat-h + + +EXTRA_DIST += openat.h + +## end gnulib module openat-h + ## begin gnulib module opendir @@ -832,6 +996,15 @@ EXTRA_libpatch_a_SOURCES += readlink.c ## end gnulib module readlink +## begin gnulib module readlinkat + + +EXTRA_DIST += at-func.c readlinkat.c + +EXTRA_libpatch_a_SOURCES += at-func.c readlinkat.c + +## end gnulib module readlinkat + ## begin gnulib module realloc-gnu @@ -859,6 +1032,15 @@ EXTRA_libpatch_a_SOURCES += rename.c ## end gnulib module rename +## begin gnulib module renameat + + +EXTRA_DIST += at-func2.c renameat.c + +EXTRA_libpatch_a_SOURCES += at-func2.c renameat.c + +## end gnulib module renameat + ## begin gnulib module rmdir @@ -885,6 +1067,14 @@ EXTRA_DIST += same-inode.h ## end gnulib module same-inode +## begin gnulib module save-cwd + +libpatch_a_SOURCES += save-cwd.c + +EXTRA_DIST += save-cwd.h + +## end gnulib module save-cwd + ## begin gnulib module secure_getenv @@ -1049,6 +1239,12 @@ EXTRA_DIST += stat-time.h ## end gnulib module stat-time +## begin gnulib module statat + +libpatch_a_SOURCES += statat.c + +## end gnulib module statat + ## begin gnulib module stdarg BUILT_SOURCES += $(STDARG_H) @@ -1115,6 +1311,7 @@ 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; \ @@ -1413,6 +1610,15 @@ EXTRA_DIST += stdlib.in.h ## end gnulib module stdlib +## begin gnulib module strdup-posix + + +EXTRA_DIST += strdup.c + +EXTRA_libpatch_a_SOURCES += strdup.c + +## end gnulib module strdup-posix + ## begin gnulib module streq @@ -1565,6 +1771,15 @@ EXTRA_libpatch_a_SOURCES += symlink.c ## end gnulib module symlink +## begin gnulib module symlinkat + + +EXTRA_DIST += at-func.c symlinkat.c + +EXTRA_libpatch_a_SOURCES += at-func.c symlinkat.c + +## end gnulib module symlinkat + ## begin gnulib module sys_stat BUILT_SOURCES += sys/stat.h @@ -1727,6 +1942,7 @@ 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)' \ @@ -1927,6 +2143,15 @@ EXTRA_libpatch_a_SOURCES += unlink.c ## end gnulib module unlink +## begin gnulib module unlinkat + + +EXTRA_DIST += at-func.c unlinkat.c + +EXTRA_libpatch_a_SOURCES += at-func.c unlinkat.c + +## end gnulib module unlinkat + ## begin gnulib module unsetenv @@ -1958,6 +2183,15 @@ EXTRA_DIST += utimens.h ## end gnulib module utimens +## begin gnulib module utimensat + + +EXTRA_DIST += at-func.c utimensat.c + +EXTRA_libpatch_a_SOURCES += at-func.c utimensat.c + +## end gnulib module utimensat + ## begin gnulib module vasnprintf diff --git a/lib/hash.c b/lib/hash.c index d312a26..439c533 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -1,6 +1,6 @@ /* hash - hashing table processing. - Copyright (C) 1998-2004, 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1998-2004, 2006-2007, 2009-2015 Free Software Foundation, Inc. Written by Jim Meyering, 1992. diff --git a/lib/hash.h b/lib/hash.h index 9994f5f..e678a2b 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -1,5 +1,5 @@ /* hash - hashing table processing. - Copyright (C) 1998-1999, 2001, 2003, 2009-2014 Free Software Foundation, + Copyright (C) 1998-1999, 2001, 2003, 2009-2015 Free Software Foundation, Inc. Written by Jim Meyering , 1998. diff --git a/lib/ignore-value.h b/lib/ignore-value.h index 4dd0946..68521ed 100644 --- a/lib/ignore-value.h +++ b/lib/ignore-value.h @@ -1,6 +1,6 @@ /* ignore a function return without a compiler warning - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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/intprops.h b/lib/intprops.h index d0bb7a6..f85ccad 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -1,6 +1,6 @@ /* intprops.h -- properties of integer types - Copyright (C) 2001-2005, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2005, 2009-2015 Free Software Foundation, Inc. This 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/itold.c b/lib/itold.c index 937f480..1eee03e 100644 --- a/lib/itold.c +++ b/lib/itold.c @@ -1,5 +1,5 @@ /* Replacement for 'int' to 'long double' conversion routine. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2011. This program is free software: you can redistribute it and/or modify diff --git a/lib/lchown.c b/lib/lchown.c new file mode 100644 index 0000000..7f5f602 --- /dev/null +++ b/lib/lchown.c @@ -0,0 +1,117 @@ +/* Provide a stub lchown function for systems that lack it. + + Copyright (C) 1998-1999, 2002, 2004, 2006-2007, 2009-2015 Free Software + Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +#include + +#include +#include +#include +#include + +#if !HAVE_LCHOWN + +/* If the system chown does not follow symlinks, we don't want it + replaced by gnulib's chown, which does follow symlinks. */ +# if CHOWN_MODIFIES_SYMLINK +# undef chown +# endif + +/* Work just like chown, except when FILE is a symbolic link. + In that case, set errno to EOPNOTSUPP and return -1. + But if autoconf tests determined that chown modifies + symlinks, then just call chown. */ + +int +lchown (const char *file, uid_t uid, gid_t gid) +{ +# if HAVE_CHOWN +# if ! CHOWN_MODIFIES_SYMLINK + struct stat stats; + + if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode)) + { + errno = EOPNOTSUPP; + return -1; + } +# endif + + return chown (file, uid, gid); + +# else /* !HAVE_CHOWN */ + errno = ENOSYS; + return -1; +# endif +} + +#else /* HAVE_LCHOWN */ + +# undef lchown + +/* Work around trailing slash bugs in lchown. */ +int +rpl_lchown (const char *file, uid_t uid, gid_t gid) +{ + bool stat_valid = false; + int result; + +# if CHOWN_CHANGE_TIME_BUG + struct stat st; + + if (gid != (gid_t) -1 || uid != (uid_t) -1) + { + if (lstat (file, &st)) + return -1; + stat_valid = true; + if (!S_ISLNK (st.st_mode)) + return chown (file, uid, gid); + } +# endif + +# if CHOWN_TRAILING_SLASH_BUG + if (!stat_valid) + { + size_t len = strlen (file); + if (len && file[len - 1] == '/') + return chown (file, uid, gid); + } +# endif + + result = lchown (file, uid, gid); + +# if CHOWN_CHANGE_TIME_BUG && HAVE_LCHMOD + if (result == 0 && stat_valid + && (uid == st.st_uid || uid == (uid_t) -1) + && (gid == st.st_gid || gid == (gid_t) -1)) + { + /* No change in ownership, but at least one argument was not -1, + so we are required to update ctime. Since lchown succeeded, + we assume that lchmod will do likewise. But if the system + lacks lchmod and lutimes, we are out of luck. Oh well. */ + result = lchmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO + | S_ISUID | S_ISGID | S_ISVTX)); + } +# endif + + return result; +} + +#endif /* HAVE_LCHOWN */ diff --git a/lib/localcharset.c b/lib/localcharset.c index ccfa993..1f02aa5 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2006, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2000-2006, 2008-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,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; @@ -342,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: + . + See also "IBM Globalization - Code page identifiers": + . */ + 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; @@ -499,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"); @@ -530,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)) diff --git a/lib/localcharset.h b/lib/localcharset.h index 9011d58..c5e6d46 100644 --- a/lib/localcharset.h +++ b/lib/localcharset.h @@ -1,5 +1,5 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2000-2003, 2009-2015 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/lstat.c b/lib/lstat.c index f70fd43..31dee13 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-2014 Free Software Foundation, Inc. + Copyright (C) 1997-2006, 2008-2015 Free Software Foundation, Inc. This 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 bc81c54..00800a2 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -1,6 +1,6 @@ /* malloc() function that is glibc compatible. - Copyright (C) 1997-1998, 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2006-2007, 2009-2015 Free Software Foundation, Inc. This 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 370551c..198a96c 100644 --- a/lib/malloca.c +++ b/lib/malloca.c @@ -1,5 +1,5 @@ /* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify diff --git a/lib/malloca.h b/lib/malloca.h index 5071e46..7a4190c 100644 --- a/lib/malloca.h +++ b/lib/malloca.h @@ -1,5 +1,5 @@ /* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c index 5743f43..e49d55b 100644 --- a/lib/mbrtowc.c +++ b/lib/mbrtowc.c @@ -1,5 +1,5 @@ /* Convert multibyte character to wide character. - Copyright (C) 1999-2002, 2005-2014 Free Software Foundation, Inc. + Copyright (C) 1999-2002, 2005-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/lib/mbsinit.c b/lib/mbsinit.c index df4bcd1..4effdd8 100644 --- a/lib/mbsinit.c +++ b/lib/mbsinit.c @@ -1,5 +1,5 @@ /* Test for initial conversion state. - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/lib/memchr.c b/lib/memchr.c index 6709f6e..f74cc9a 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-2014 +/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2015 Free Software Foundation, Inc. Based on strlen implementation by Torbjorn Granlund (tege@sics.se), diff --git a/lib/mempcpy.c b/lib/mempcpy.c new file mode 100644 index 0000000..e9f2e34 --- /dev/null +++ b/lib/mempcpy.c @@ -0,0 +1,28 @@ +/* Copy memory area and return pointer after last written byte. + Copyright (C) 2003, 2007, 2009-2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute 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 . */ + +#include + +/* Specification. */ +#include + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +void * +mempcpy (void *dest, const void *src, size_t n) +{ + return (char *) memcpy (dest, src, n) + n; +} diff --git a/lib/memrchr.c b/lib/memrchr.c new file mode 100644 index 0000000..3827208 --- /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-2015 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 . */ + +#if defined _LIBC +# include +#else +# include +# define reg_char char +#endif + +#include +#include + +#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 index af1fc9b..919678d 100644 --- a/lib/minmax.h +++ b/lib/minmax.h @@ -1,5 +1,5 @@ /* MIN, MAX macros. - Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2014 Free Software + Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/mkdir.c b/lib/mkdir.c index 481bbf3..37de12e 100644 --- a/lib/mkdir.c +++ b/lib/mkdir.c @@ -1,7 +1,7 @@ /* On some systems, mkdir ("foo/", 0700) fails because of the trailing slash. On those systems, this wrapper removes the trailing slash. - Copyright (C) 2001, 2003, 2006, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2008-2015 Free Software Foundation, Inc. This 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/mkdirat.c b/lib/mkdirat.c new file mode 100644 index 0000000..3012ac4 --- /dev/null +++ b/lib/mkdirat.c @@ -0,0 +1,34 @@ +/* fd-relative mkdir + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#include + +#include + +/* Solaris 10 has no function like this. + Create a subdirectory, FILE, with mode MODE, in the directory + open on descriptor FD. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then mkdir/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +#define AT_FUNC_NAME mkdirat +#define AT_FUNC_F1 mkdir +#define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode +#define AT_FUNC_POST_FILE_ARGS , mode +#include "at-func.c" diff --git a/lib/mktime.c b/lib/mktime.c index 48b3a40..580bc8e 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,5 +1,5 @@ /* Convert a 'struct tm' to a time_t value. - Copyright (C) 1993-2014 Free Software Foundation, Inc. + Copyright (C) 1993-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Paul Eggert . diff --git a/lib/msvc-inval.c b/lib/msvc-inval.c index f83827f..a1f1dc0 100644 --- a/lib/msvc-inval.c +++ b/lib/msvc-inval.c @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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-inval.h b/lib/msvc-inval.h index a0ef540..8b07269 100644 --- a/lib/msvc-inval.h +++ b/lib/msvc-inval.h @@ -1,5 +1,5 @@ /* Invalid parameter handler for MSVC runtime libraries. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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 b1e5f0c..90cf801 100644 --- a/lib/msvc-nothrow.c +++ b/lib/msvc-nothrow.c @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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 0d4dea5..67b151e 100644 --- a/lib/msvc-nothrow.h +++ b/lib/msvc-nothrow.h @@ -1,6 +1,6 @@ /* Wrappers that don't throw invalid parameter notifications with MSVC runtime libraries. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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/open.c b/lib/open.c new file mode 100644 index 0000000..95c7811 --- /dev/null +++ b/lib/open.c @@ -0,0 +1,181 @@ +/* Open a descriptor to a file. + Copyright (C) 2007-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Bruno Haible , 2007. */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_open doesn't recurse to + rpl_open. */ +#define __need_system_fcntl_h +#include + +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +static int +orig_open (const char *filename, int flags, mode_t mode) +{ + return open (filename, flags, mode); +} + +/* Specification. */ +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +#include "fcntl.h" + +#include +#include +#include +#include +#include +#include + +#ifndef REPLACE_OPEN_DIRECTORY +# define REPLACE_OPEN_DIRECTORY 0 +#endif + +int +open (const char *filename, int flags, ...) +{ + mode_t mode; + int fd; + + mode = 0; + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + +#if GNULIB_defined_O_NONBLOCK + /* The only known platform that lacks O_NONBLOCK is mingw, but it + also lacks named pipes and Unix sockets, which are the only two + file types that require non-blocking handling in open(). + Therefore, it is safe to ignore O_NONBLOCK here. It is handy + that mingw also lacks openat(), so that is also covered here. */ + flags &= ~O_NONBLOCK; +#endif + +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + if (strcmp (filename, "/dev/null") == 0) + filename = "NUL"; +#endif + +#if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR + is specified, then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + says that it + fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ + if (flags & (O_CREAT | O_WRONLY | O_RDWR)) + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + errno = EISDIR; + return -1; + } + } +#endif + + fd = orig_open (filename, flags, mode); + +#if REPLACE_FCHDIR + /* Implementing fchdir and fdopendir requires the ability to open a + directory file descriptor. If open doesn't support that (as on + mingw), we use a dummy file that behaves the same as directories + on Linux (ie. always reports EOF on attempts to read()), and + override fstat() in fchdir.c to hide the fact that we have a + dummy. */ + if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES + && ((flags & O_ACCMODE) == O_RDONLY + || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH))) + { + struct stat statbuf; + if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) + { + /* Maximum recursion depth of 1. */ + fd = open ("/dev/null", flags, mode); + if (0 <= fd) + fd = _gl_register_fd (fd, filename); + } + else + errno = EACCES; + } +#endif + +#if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and fd does not refer to a directory, + then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file without the slash is not a directory, open() must fail + with ENOTDIR. */ + if (fd >= 0) + { + /* We know len is positive, since open did not fail with ENOENT. */ + size_t len = strlen (filename); + if (filename[len - 1] == '/') + { + struct stat statbuf; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } + } +#endif + +#if REPLACE_FCHDIR + if (!REPLACE_OPEN_DIRECTORY && 0 <= fd) + fd = _gl_register_fd (fd, filename); +#endif + + return fd; +} diff --git a/lib/openat-die.c b/lib/openat-die.c new file mode 100644 index 0000000..4accca0 --- /dev/null +++ b/lib/openat-die.c @@ -0,0 +1,62 @@ +/* Report a save- or restore-cwd failure in our openat replacement and then exit. + + Copyright (C) 2005-2006, 2008-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +#include + +#include "openat.h" + +#include + +#ifndef GNULIB_LIBPOSIX +# include "error.h" +#endif + +#include "exitfail.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +_Noreturn void +openat_save_fail (int errnum) +{ +#ifndef GNULIB_LIBPOSIX + error (exit_failure, errnum, + _("unable to record current working directory")); +#endif + /* _Noreturn cannot be applied to error, since it returns + when its first argument is 0. To help compilers understand that this + function does not return, call abort. Also, the abort is a + safety feature if exit_failure is 0 (which shouldn't happen). */ + abort (); +} + + +/* Exit with an error about failure to restore the working directory + during an openat emulation. The caller must ensure that fd 2 is + not a just-opened fd, even when openat_safer is not in use. */ + +_Noreturn void +openat_restore_fail (int errnum) +{ +#ifndef GNULIB_LIBPOSIX + error (exit_failure, errnum, + _("failed to return to initial working directory")); +#endif + + /* As above. */ + abort (); +} diff --git a/lib/openat-priv.h b/lib/openat-priv.h new file mode 100644 index 0000000..f5a3690 --- /dev/null +++ b/lib/openat-priv.h @@ -0,0 +1,64 @@ +/* Internals for openat-like functions. + + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#ifndef _GL_HEADER_OPENAT_PRIV +#define _GL_HEADER_OPENAT_PRIV + +#include +#include +#include + +/* Maximum number of bytes that it is safe to allocate as a single + array on the stack, and that is known as a compile-time constant. + The assumption is that we'll touch the array very quickly, or a + temporary very near the array, provoking an out-of-memory trap. On + some operating systems, there is only one guard page for the stack, + and a page size can be as small as 4096 bytes. Subtract 64 in the + hope that this will let the compiler touch a nearby temporary and + provoke a trap. */ +#define SAFER_ALLOCA_MAX (4096 - 64) + +#define SAFER_ALLOCA(m) ((m) < SAFER_ALLOCA_MAX ? (m) : SAFER_ALLOCA_MAX) + +#if defined PATH_MAX +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (PATH_MAX) +#elif defined _XOPEN_PATH_MAX +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (_XOPEN_PATH_MAX) +#else +# define OPENAT_BUFFER_SIZE SAFER_ALLOCA (1024) +#endif + +char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file); + +/* Trying to access a BUILD_PROC_NAME file will fail on systems without + /proc support, and even on systems *with* ProcFS support. Return + nonzero if the failure may be legitimate, e.g., because /proc is not + readable, or the particular .../fd/N directory is not present. */ +#define EXPECTED_ERRNO(Errno) \ + ((Errno) == ENOTDIR || (Errno) == ENOENT \ + || (Errno) == EPERM || (Errno) == EACCES \ + || (Errno) == ENOSYS /* Solaris 8 */ \ + || (Errno) == EOPNOTSUPP /* FreeBSD */) + +/* Wrapper function shared among linkat and renameat. */ +int at_func2 (int fd1, char const *file1, + int fd2, char const *file2, + int (*func) (char const *file1, char const *file2)); + +#endif /* _GL_HEADER_OPENAT_PRIV */ diff --git a/lib/openat-proc.c b/lib/openat-proc.c new file mode 100644 index 0000000..4e1d341 --- /dev/null +++ b/lib/openat-proc.c @@ -0,0 +1,102 @@ +/* Create /proc/self/fd-related names for subfiles of open directories. + + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "openat-priv.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include "intprops.h" + +#define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s" + +#define PROC_SELF_FD_NAME_SIZE_BOUND(len) \ + (sizeof PROC_SELF_FD_FORMAT - sizeof "%d%s" \ + + INT_STRLEN_BOUND (int) + (len) + 1) + + +/* Set BUF to the expansion of PROC_SELF_FD_FORMAT, using FD and FILE + respectively for %d and %s. If successful, return BUF if the + result fits in BUF, dynamically allocated memory otherwise. But + return NULL if /proc is not reliable, either because the operating + system support is lacking or because memory is low. */ +char * +openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file) +{ + static int proc_status = 0; + + /* Make sure the caller gets ENOENT when appropriate. */ + if (!*file) + { + buf[0] = '\0'; + return buf; + } + + if (! proc_status) + { + /* Set PROC_STATUS to a positive value if /proc/self/fd is + reliable, and a negative value otherwise. Solaris 10 + /proc/self/fd mishandles "..", and any file name might expand + to ".." after symbolic link expansion, so avoid /proc/self/fd + if it mishandles "..". Solaris 10 has openat, but this + problem is exhibited on code that built on Solaris 8 and + running on Solaris 10. */ + + int proc_self_fd = open ("/proc/self/fd", + O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK); + if (proc_self_fd < 0) + proc_status = -1; + else + { + /* Detect whether /proc/self/fd/%i/../fd exists, where %i is the + number of a file descriptor open on /proc/self/fd. On Linux, + that name resolves to /proc/self/fd, which was opened above. + However, on Solaris, it may resolve to /proc/self/fd/fd, which + cannot exist, since all names in /proc/self/fd are numeric. */ + char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof "../fd" - 1)]; + sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, "../fd"); + proc_status = access (dotdot_buf, F_OK) ? -1 : 1; + close (proc_self_fd); + } + } + + if (proc_status < 0) + return NULL; + else + { + size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file)); + char *result = buf; + if (OPENAT_BUFFER_SIZE < bufsize) + { + result = malloc (bufsize); + if (! result) + return NULL; + } + sprintf (result, PROC_SELF_FD_FORMAT, fd, file); + return result; + } +} diff --git a/lib/openat.c b/lib/openat.c new file mode 100644 index 0000000..d1de8b9 --- /dev/null +++ b/lib/openat.c @@ -0,0 +1,286 @@ +/* provide a replacement openat function + Copyright (C) 2004-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_openat doesn't recurse to + rpl_openat. */ +#define __need_system_fcntl_h +#include + +/* Get the original definition of open. It might be defined as a macro. */ +#include +#include +#undef __need_system_fcntl_h + +#if HAVE_OPENAT +static int +orig_openat (int fd, char const *filename, int flags, mode_t mode) +{ + return openat (fd, filename, flags, mode); +} +#endif + +/* Write "fcntl.h" here, not , otherwise OSF/1 5.1 DTK cc eliminates + this include because of the preliminary #include above. */ +#include "fcntl.h" + +#include "openat.h" + +#include +#include +#include +#include +#include +#include + +#if HAVE_OPENAT + +/* Like openat, but work around Solaris 9 bugs with trailing slash. */ +int +rpl_openat (int dfd, char const *filename, int flags, ...) +{ + mode_t mode; + int fd; + + mode = 0; + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + +# if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR + is specified, then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file already exists as a directory, then + - if O_CREAT is specified, open() must fail because of the semantics + of O_CREAT, + - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX + says that it + fails with errno = EISDIR in this case. + If the named file does not exist or does not name a directory, then + - if O_CREAT is specified, open() must fail since open() cannot create + directories, + - if O_WRONLY or O_RDWR is specified, open() must fail because the + file does not contain a '.' directory. */ + if (flags & (O_CREAT | O_WRONLY | O_RDWR)) + { + size_t len = strlen (filename); + if (len > 0 && filename[len - 1] == '/') + { + errno = EISDIR; + return -1; + } + } +# endif + + fd = orig_openat (dfd, filename, flags, mode); + +# if OPEN_TRAILING_SLASH_BUG + /* If the filename ends in a slash and fd does not refer to a directory, + then fail. + Rationale: POSIX + says that + "A pathname that contains at least one non-slash character and that + ends with one or more trailing slashes shall be resolved as if a + single dot character ( '.' ) were appended to the pathname." + and + "The special filename dot shall refer to the directory specified by + its predecessor." + If the named file without the slash is not a directory, open() must fail + with ENOTDIR. */ + if (fd >= 0) + { + /* We know len is positive, since open did not fail with ENOENT. */ + size_t len = strlen (filename); + if (filename[len - 1] == '/') + { + struct stat statbuf; + + if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode)) + { + close (fd); + errno = ENOTDIR; + return -1; + } + } + } +# endif + + return fd; +} + +#else /* !HAVE_OPENAT */ + +# include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ +# include "openat-priv.h" +# include "save-cwd.h" + +/* Replacement for Solaris' openat function. + + First, try to simulate it via open ("/proc/self/fd/FD/FILE"). + Failing that, simulate it by doing save_cwd/fchdir/open/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, upon failure, set errno and return -1, as openat does. + Upon successful completion, return a file descriptor. */ +int +openat (int fd, char const *file, int flags, ...) +{ + mode_t mode = 0; + + if (flags & O_CREAT) + { + va_list arg; + va_start (arg, flags); + + /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4 + creates crashing code when 'mode_t' is smaller than 'int'. */ + mode = va_arg (arg, PROMOTED_MODE_T); + + va_end (arg); + } + + return openat_permissive (fd, file, flags, mode, NULL); +} + +/* Like openat (FD, FILE, FLAGS, MODE), but if CWD_ERRNO is + nonnull, set *CWD_ERRNO to an errno value if unable to save + or restore the initial working directory. This is needed only + the first time remove.c's remove_dir opens a command-line + directory argument. + + If a previous attempt to restore the current working directory + failed, then we must not even try to access a '.'-relative name. + It is the caller's responsibility not to call this function + in that case. */ + +int +openat_permissive (int fd, char const *file, int flags, mode_t mode, + int *cwd_errno) +{ + struct saved_cwd saved_cwd; + int saved_errno; + int err; + bool save_ok; + + if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file)) + return open (file, flags, mode); + + { + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, file); + if (proc_file) + { + int open_result = open (proc_file, flags, mode); + int open_errno = errno; + if (proc_file != buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= open_result || ! EXPECTED_ERRNO (open_errno)) + { + errno = open_errno; + return open_result; + } + } + } + + save_ok = (save_cwd (&saved_cwd) == 0); + if (! save_ok) + { + if (! cwd_errno) + openat_save_fail (errno); + *cwd_errno = errno; + } + if (0 <= fd && fd == saved_cwd.desc) + { + /* If saving the working directory collides with the user's + requested fd, then the user's fd must have been closed to + begin with. */ + free_cwd (&saved_cwd); + errno = EBADF; + return -1; + } + + err = fchdir (fd); + saved_errno = errno; + + if (! err) + { + err = open (file, flags, mode); + saved_errno = errno; + if (save_ok && restore_cwd (&saved_cwd) != 0) + { + if (! cwd_errno) + { + /* Don't write a message to just-created fd 2. */ + saved_errno = errno; + if (err == STDERR_FILENO) + close (err); + openat_restore_fail (saved_errno); + } + *cwd_errno = errno; + } + } + + free_cwd (&saved_cwd); + errno = saved_errno; + return err; +} + +/* Return true if our openat implementation must resort to + using save_cwd and restore_cwd. */ +bool +openat_needs_fchdir (void) +{ + bool needs_fchdir = true; + int fd = open ("/", O_SEARCH); + + if (0 <= fd) + { + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, "."); + if (proc_file) + { + needs_fchdir = false; + if (proc_file != buf) + free (proc_file); + } + close (fd); + } + + return needs_fchdir; +} + +#endif /* !HAVE_OPENAT */ diff --git a/lib/openat.h b/lib/openat.h new file mode 100644 index 0000000..f148adf --- /dev/null +++ b/lib/openat.h @@ -0,0 +1,123 @@ +/* provide a replacement openat function + Copyright (C) 2004-2006, 2008-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Jim Meyering */ + +#ifndef _GL_HEADER_OPENAT +#define _GL_HEADER_OPENAT + +#include + +#include +#include +#include +#include + +#ifndef _GL_INLINE_HEADER_BEGIN + #error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN + +#if !HAVE_OPENAT + +int openat_permissive (int fd, char const *file, int flags, mode_t mode, + int *cwd_errno); +bool openat_needs_fchdir (void); + +#else + +# define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \ + openat (Fd, File, Flags, Mode) +# define openat_needs_fchdir() false + +#endif + +_Noreturn void openat_restore_fail (int); +_Noreturn void openat_save_fail (int); + +/* Using these function names makes application code + slightly more readable than it would be with + fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */ + +#if GNULIB_FCHOWNAT + +# ifndef FCHOWNAT_INLINE +# define FCHOWNAT_INLINE _GL_INLINE +# endif + +FCHOWNAT_INLINE int +chownat (int fd, char const *file, uid_t owner, gid_t group) +{ + return fchownat (fd, file, owner, group, 0); +} + +FCHOWNAT_INLINE int +lchownat (int fd, char const *file, uid_t owner, gid_t group) +{ + return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW); +} + +#endif + +#if GNULIB_FCHMODAT + +# ifndef FCHMODAT_INLINE +# define FCHMODAT_INLINE _GL_INLINE +# endif + +FCHMODAT_INLINE int +chmodat (int fd, char const *file, mode_t mode) +{ + return fchmodat (fd, file, mode, 0); +} + +FCHMODAT_INLINE int +lchmodat (int fd, char const *file, mode_t mode) +{ + return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW); +} + +#endif + +#if GNULIB_STATAT + +# ifndef STATAT_INLINE +# define STATAT_INLINE _GL_INLINE +# endif + +STATAT_INLINE int +statat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, 0); +} + +STATAT_INLINE int +lstatat (int fd, char const *name, struct stat *st) +{ + return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW); +} + +#endif + +/* For now, there are no wrappers named laccessat or leuidaccessat, + since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and + since access rights on symlinks are of limited utility. Likewise, + wrappers are not provided for accessat or euidaccessat, so as to + avoid dragging in -lgen on some platforms. */ + +_GL_INLINE_HEADER_END + +#endif /* _GL_HEADER_OPENAT */ diff --git a/lib/opendir-safer.c b/lib/opendir-safer.c index e31da88..9bbcda8 100644 --- a/lib/opendir-safer.c +++ b/lib/opendir-safer.c @@ -1,6 +1,6 @@ /* Invoke opendir, but avoid some glitches. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/opendir.c b/lib/opendir.c index c67f2e5..9f53110 100644 --- a/lib/opendir.c +++ b/lib/opendir.c @@ -1,5 +1,5 @@ /* Start reading the entries of a directory. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/parse-datetime.c b/lib/parse-datetime.c index 7e4f0ea..bed51e1 100644 --- a/lib/parse-datetime.c +++ b/lib/parse-datetime.c @@ -1,19 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.7. */ +/* A Bison parser, made by GNU Bison 3.0.2. */ /* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. - + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + This program is free software: you can redistribute 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 . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.7" +#define YYBISON_VERSION "3.0.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -62,12 +62,11 @@ /* Copy the first part of user declarations. */ -/* Line 371 of yacc.c */ -#line 1 "./parse-datetime.y" +#line 1 "./parse-datetime.y" /* yacc.c:339 */ /* Parse a string into an internal time stamp. - Copyright (C) 1999-2000, 2002-2014 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -349,14 +348,13 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, } -/* Line 371 of yacc.c */ -#line 354 "parse-datetime.c" +#line 352 "parse-datetime.c" /* yacc.c:339 */ -# ifndef YY_NULL +# ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# define YY_NULLPTR nullptr # else -# define YY_NULL 0 +# define YY_NULLPTR 0 # endif # endif @@ -369,7 +367,7 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, #endif -/* Enabling traces. */ +/* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif @@ -377,33 +375,32 @@ set_hhmmss (parser_control *pc, long int hour, long int minutes, extern int yydebug; #endif -/* Tokens. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - tAGO = 258, - tDST = 259, - tYEAR_UNIT = 260, - tMONTH_UNIT = 261, - tHOUR_UNIT = 262, - tMINUTE_UNIT = 263, - tSEC_UNIT = 264, - tDAY_UNIT = 265, - tDAY_SHIFT = 266, - tDAY = 267, - tDAYZONE = 268, - tLOCAL_ZONE = 269, - tMERIDIAN = 270, - tMONTH = 271, - tORDINAL = 272, - tZONE = 273, - tSNUMBER = 274, - tUNUMBER = 275, - tSDECIMAL_NUMBER = 276, - tUDECIMAL_NUMBER = 277 - }; + enum yytokentype + { + tAGO = 258, + tDST = 259, + tYEAR_UNIT = 260, + tMONTH_UNIT = 261, + tHOUR_UNIT = 262, + tMINUTE_UNIT = 263, + tSEC_UNIT = 264, + tDAY_UNIT = 265, + tDAY_SHIFT = 266, + tDAY = 267, + tDAYZONE = 268, + tLOCAL_ZONE = 269, + tMERIDIAN = 270, + tMONTH = 271, + tORDINAL = 272, + tZONE = 273, + tSNUMBER = 274, + tUNUMBER = 275, + tSDECIMAL_NUMBER = 276, + tUDECIMAL_NUMBER = 277 + }; #endif /* Tokens. */ #define tAGO 258 @@ -427,49 +424,33 @@ extern int yydebug; #define tSDECIMAL_NUMBER 276 #define tUDECIMAL_NUMBER 277 - - +/* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE +typedef union YYSTYPE YYSTYPE; +union YYSTYPE { -/* Line 387 of yacc.c */ -#line 297 "./parse-datetime.y" +#line 297 "./parse-datetime.y" /* yacc.c:355 */ long int intval; textint textintval; struct timespec timespec; relative_time rel; - -/* Line 387 of yacc.c */ -#line 446 "parse-datetime.c" -} YYSTYPE; +#line 440 "parse-datetime.c" /* yacc.c:355 */ +}; # define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 #endif -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus + int yyparse (parser_control *pc); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ /* Copy the second part of user declarations. */ -/* Line 390 of yacc.c */ -#line 473 "parse-datetime.c" +#line 454 "parse-datetime.c" /* yacc.c:358 */ #ifdef short # undef short @@ -483,11 +464,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -507,8 +485,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -530,6 +507,33 @@ typedef short int yytype_int16; # endif #endif +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -537,24 +541,26 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(N) (N) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") #else -static int -YYID (yyi) - int yyi; +# define YY_INITIAL_VALUE(Value) Value #endif -{ - return yyi; -} +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif + #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -572,8 +578,7 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS @@ -585,8 +590,8 @@ YYID (yyi) # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -602,7 +607,7 @@ YYID (yyi) # endif # if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -610,15 +615,13 @@ YYID (yyi) # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -628,7 +631,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -653,16 +656,16 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) #endif @@ -681,7 +684,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ - while (YYID (0)) + while (0) # endif # endif #endif /* !YYCOPY_NEEDED */ @@ -697,17 +700,19 @@ union yyalloc #define YYNNTS 26 /* YYNRULES -- Number of rules. */ #define YYNRULES 91 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 114 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 277 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -741,54 +746,7 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 7, 10, 11, 14, 16, 18, - 20, 22, 24, 26, 28, 30, 32, 34, 38, 41, - 46, 53, 55, 58, 63, 70, 71, 73, 76, 78, - 81, 83, 85, 88, 91, 95, 97, 100, 102, 105, - 108, 111, 115, 121, 125, 129, 132, 137, 140, 144, - 146, 150, 153, 155, 157, 160, 163, 165, 168, 171, - 173, 176, 179, 181, 184, 187, 189, 192, 195, 197, - 200, 203, 206, 209, 211, 213, 216, 219, 222, 225, - 228, 231, 233, 235, 237, 239, 241, 243, 245, 247, - 250, 251 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 29, 0, -1, 30, -1, 31, -1, 23, 48, -1, - -1, 31, 32, -1, 33, -1, 35, -1, 39, -1, - 40, -1, 42, -1, 41, -1, 44, -1, 51, -1, - 52, -1, 34, -1, 43, 24, 36, -1, 20, 15, - -1, 20, 25, 20, 15, -1, 20, 25, 20, 25, - 50, 15, -1, 36, -1, 20, 38, -1, 20, 25, - 20, 37, -1, 20, 25, 20, 25, 50, 37, -1, - -1, 38, -1, 19, 53, -1, 14, -1, 14, 4, - -1, 18, -1, 24, -1, 18, 46, -1, 24, 46, - -1, 18, 19, 53, -1, 13, -1, 18, 4, -1, - 12, -1, 12, 26, -1, 17, 12, -1, 20, 12, - -1, 20, 27, 20, -1, 20, 27, 20, 27, 20, - -1, 20, 16, 19, -1, 16, 19, 19, -1, 16, - 20, -1, 16, 20, 26, 20, -1, 20, 16, -1, - 20, 16, 20, -1, 43, -1, 20, 19, 19, -1, - 45, 3, -1, 45, -1, 47, -1, 17, 5, -1, - 20, 5, -1, 5, -1, 17, 6, -1, 20, 6, - -1, 6, -1, 17, 10, -1, 20, 10, -1, 10, - -1, 17, 7, -1, 20, 7, -1, 7, -1, 17, - 8, -1, 20, 8, -1, 8, -1, 17, 9, -1, - 20, 9, -1, 21, 9, -1, 22, 9, -1, 9, - -1, 46, -1, 19, 5, -1, 19, 6, -1, 19, - 10, -1, 19, 7, -1, 19, 8, -1, 19, 9, - -1, 11, -1, 49, -1, 50, -1, 21, -1, 19, - -1, 22, -1, 20, -1, 20, -1, 20, 46, -1, - -1, 25, 20, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { 0, 324, 324, 325, 329, 336, 338, 342, 344, 346, @@ -818,13 +776,13 @@ static const char *const yytname[] = "iso_8601_time", "o_zone_offset", "zone_offset", "local_zone", "zone", "day", "date", "iso_8601_date", "rel", "relunit", "relunit_snumber", "dayshift", "seconds", "signed_seconds", "unsigned_seconds", "number", - "hybrid", "o_colon_minutes", YY_NULL + "hybrid", "o_colon_minutes", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -833,66 +791,18 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 28, 29, 29, 30, 31, 31, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 33, 34, 35, 35, - 35, 35, 36, 36, 36, 37, 37, 38, 39, 39, - 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, - 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, - 46, 47, 48, 48, 49, 49, 50, 50, 51, 52, - 53, 53 -}; +#define YYPACT_NINF -93 -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 2, 4, - 6, 1, 2, 4, 6, 0, 1, 2, 1, 2, - 1, 1, 2, 2, 3, 1, 2, 1, 2, 2, - 2, 3, 5, 3, 3, 2, 4, 2, 3, 1, - 3, 2, 1, 1, 2, 2, 1, 2, 2, 1, - 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, - 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 0, 2 -}; +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-93))) -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 5, 0, 0, 2, 3, 85, 87, 84, 86, 4, - 82, 83, 1, 56, 59, 65, 68, 73, 62, 81, - 37, 35, 28, 0, 0, 30, 0, 88, 0, 0, - 31, 6, 7, 16, 8, 21, 9, 10, 12, 11, - 49, 13, 52, 74, 53, 14, 15, 38, 29, 0, - 45, 54, 57, 63, 66, 69, 60, 39, 36, 90, - 32, 75, 76, 78, 79, 80, 77, 55, 58, 64, - 67, 70, 61, 40, 18, 47, 90, 0, 0, 22, - 89, 71, 72, 33, 0, 51, 44, 0, 0, 34, - 43, 48, 50, 27, 25, 41, 0, 17, 46, 91, - 19, 90, 0, 23, 26, 0, 0, 25, 42, 25, - 20, 24, 0, 25 -}; +#define YYTABLE_NINF -1 -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 2, 3, 4, 31, 32, 33, 34, 35, 103, - 104, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 9, 10, 11, 45, 46, 93 -}; +#define yytable_value_is_error(Yytable_value) \ + 0 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -93 + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ static const yytype_int8 yypact[] = { 38, 27, 77, -93, 46, -93, -93, -93, -93, -93, @@ -909,7 +819,26 @@ static const yytype_int8 yypact[] = -93, -93, 69, 91 }; -/* YYPGOTO[NTERM-NUM]. */ + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 5, 0, 0, 2, 3, 85, 87, 84, 86, 4, + 82, 83, 1, 56, 59, 65, 68, 73, 62, 81, + 37, 35, 28, 0, 0, 30, 0, 88, 0, 0, + 31, 6, 7, 16, 8, 21, 9, 10, 12, 11, + 49, 13, 52, 74, 53, 14, 15, 38, 29, 0, + 45, 54, 57, 63, 66, 69, 60, 39, 36, 90, + 32, 75, 76, 78, 79, 80, 77, 55, 58, 64, + 67, 70, 61, 40, 18, 47, 90, 0, 0, 22, + 89, 71, 72, 33, 0, 51, 44, 0, 0, 34, + 43, 48, 50, 27, 25, 41, 0, 17, 46, 91, + 19, 90, 0, 23, 26, 0, 0, 25, 42, 25, + 20, 24, 0, 25 +}; + + /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -93, -93, -93, -93, -93, -93, -93, -93, 20, -68, @@ -917,10 +846,17 @@ static const yytype_int8 yypgoto[] = -93, -93, -92, -93, -93, 43 }; -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 4, 31, 32, 33, 34, 35, 103, + 104, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 9, 10, 11, 45, 46, 93 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint8 yytable[] = { 79, 67, 68, 69, 70, 71, 72, 58, 73, 100, @@ -937,12 +873,6 @@ static const yytype_uint8 yytable[] = 101, 0, 88 }; -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-93))) - -#define yytable_value_is_error(Yytable_value) \ - YYID (0) - static const yytype_int8 yycheck[] = { 27, 5, 6, 7, 8, 9, 10, 4, 12, 15, @@ -959,8 +889,8 @@ static const yytype_int8 yycheck[] = 19, -1, 25 }; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 23, 29, 30, 31, 19, 20, 21, 22, 48, @@ -977,30 +907,46 @@ static const yytype_uint8 yystos[] = 15, 37, 25, 50 }; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 28, 29, 29, 30, 31, 31, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 33, 34, 35, 35, + 35, 35, 36, 36, 36, 37, 37, 38, 39, 39, + 40, 40, 40, 40, 40, 40, 40, 41, 41, 41, + 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 43, 44, 44, 44, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, + 46, 47, 48, 48, 49, 49, 50, 50, 51, 52, + 53, 53 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 1, 2, 0, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 2, 4, + 6, 1, 2, 4, 6, 0, 1, 2, 1, 2, + 1, 1, 2, 2, 3, 1, 2, 1, 2, 2, + 2, 3, 5, 3, 3, 2, 4, 2, 3, 1, + 3, 2, 1, 1, 2, 2, 1, 2, 2, 1, + 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, + 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 0, 2 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + #define YYRECOVERING() (!!yyerrstatus) @@ -1017,27 +963,15 @@ do \ else \ { \ yyerror (pc, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) + YYERROR; \ + } \ +while (0) /* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 +#define YYTERROR 1 +#define YYERRCODE 256 -/* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval, pc) -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1047,58 +981,47 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, pc); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, pc); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - parser_control *pc; -#endif { FILE *yyo = yyoutput; YYUSE (yyo); + YYUSE (pc); if (!yyvaluep) return; - YYUSE (pc); # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif - switch (yytype) - { - default: - break; - } + YYUSE (yytype); } @@ -1106,23 +1029,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc) | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_control *pc) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep, pc) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - parser_control *pc; -#endif { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep, pc); YYFPRINTF (yyoutput, ")"); @@ -1133,16 +1044,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, pc) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1153,50 +1056,42 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parser_control *pc) -#else -static void -yy_reduce_print (yyvsp, yyrule, pc) - YYSTYPE *yyvsp; - int yyrule; - parser_control *pc; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_control *pc) { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , pc); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , pc); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule, pc); \ -} while (YYID (0)) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule, pc); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1210,7 +1105,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1233,15 +1128,8 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1257,16 +1145,8 @@ yystrlen (yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1296,27 +1176,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1339,11 +1219,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1351,10 +1231,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, int yycount = 0; /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - - for details. YYERROR is fine as it does not invoke this - function. - If this state is a consistent state with a default action, then the only way this function was invoked is if the default action is an error action. In that case, don't check for expected @@ -1404,7 +1280,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1471,33 +1347,18 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_control *pc) -#else -static void -yydestruct (yymsg, yytype, yyvaluep, pc) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; - parser_control *pc; -#endif { YYUSE (yyvaluep); YYUSE (pc); - if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } @@ -1507,56 +1368,18 @@ yydestruct (yymsg, yytype, yyvaluep, pc) | yyparse. | `----------*/ -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) int yyparse (parser_control *pc) -#else -int -yyparse (pc) - parser_control *pc; -#endif -#endif { /* The lookahead symbol. */ int yychar; -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ -/* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ - _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ - _Pragma ("GCC diagnostic pop") -#else +/* The semantic value of the lookahead symbol. */ /* Default value used for initialization, for pacifying older GCCs or non-GCC compilers. */ -static YYSTYPE yyval_default; -# define YY_INITIAL_VALUE(Value) = Value -#endif -#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -# define YY_IGNORE_MAYBE_UNINITIALIZED_END -#endif -#ifndef YY_INITIAL_VALUE -# define YY_INITIAL_VALUE(Value) /* Nothing. */ -#endif - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); +YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Number of syntax errors so far. */ int yynerrs; @@ -1566,8 +1389,8 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); int yyerrstatus; /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. + 'yyss': related to states. + 'yyvs': related to semantic values. Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ @@ -1635,23 +1458,23 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1659,22 +1482,22 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1683,10 +1506,10 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default); yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1715,7 +1538,7 @@ yybackup: if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (&yylval, pc); } if (yychar <= YYEOF) @@ -1780,7 +1603,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1794,541 +1617,540 @@ yyreduce: switch (yyn) { case 4: -/* Line 1792 of yacc.c */ -#line 330 "./parse-datetime.y" +#line 330 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->seconds = (yyvsp[(2) - (2)].timespec); + pc->seconds = (yyvsp[0].timespec); pc->timespec_seen = true; } +#line 1626 "parse-datetime.c" /* yacc.c:1646 */ break; case 7: -/* Line 1792 of yacc.c */ -#line 343 "./parse-datetime.y" +#line 343 "./parse-datetime.y" /* yacc.c:1646 */ { pc->times_seen++; pc->dates_seen++; } +#line 1632 "parse-datetime.c" /* yacc.c:1646 */ break; case 8: -/* Line 1792 of yacc.c */ -#line 345 "./parse-datetime.y" +#line 345 "./parse-datetime.y" /* yacc.c:1646 */ { pc->times_seen++; } +#line 1638 "parse-datetime.c" /* yacc.c:1646 */ break; case 9: -/* Line 1792 of yacc.c */ -#line 347 "./parse-datetime.y" +#line 347 "./parse-datetime.y" /* yacc.c:1646 */ { pc->local_zones_seen++; } +#line 1644 "parse-datetime.c" /* yacc.c:1646 */ break; case 10: -/* Line 1792 of yacc.c */ -#line 349 "./parse-datetime.y" +#line 349 "./parse-datetime.y" /* yacc.c:1646 */ { pc->zones_seen++; } +#line 1650 "parse-datetime.c" /* yacc.c:1646 */ break; case 11: -/* Line 1792 of yacc.c */ -#line 351 "./parse-datetime.y" +#line 351 "./parse-datetime.y" /* yacc.c:1646 */ { pc->dates_seen++; } +#line 1656 "parse-datetime.c" /* yacc.c:1646 */ break; case 12: -/* Line 1792 of yacc.c */ -#line 353 "./parse-datetime.y" +#line 353 "./parse-datetime.y" /* yacc.c:1646 */ { pc->days_seen++; } +#line 1662 "parse-datetime.c" /* yacc.c:1646 */ break; case 18: -/* Line 1792 of yacc.c */ -#line 369 "./parse-datetime.y" +#line 369 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0); - pc->meridian = (yyvsp[(2) - (2)].intval); + set_hhmmss (pc, (yyvsp[-1].textintval).value, 0, 0, 0); + pc->meridian = (yyvsp[0].intval); } +#line 1671 "parse-datetime.c" /* yacc.c:1646 */ break; case 19: -/* Line 1792 of yacc.c */ -#line 374 "./parse-datetime.y" +#line 374 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0); - pc->meridian = (yyvsp[(4) - (4)].intval); + set_hhmmss (pc, (yyvsp[-3].textintval).value, (yyvsp[-1].textintval).value, 0, 0); + pc->meridian = (yyvsp[0].intval); } +#line 1680 "parse-datetime.c" /* yacc.c:1646 */ break; case 20: -/* Line 1792 of yacc.c */ -#line 379 "./parse-datetime.y" +#line 379 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec); - pc->meridian = (yyvsp[(6) - (6)].intval); + set_hhmmss (pc, (yyvsp[-5].textintval).value, (yyvsp[-3].textintval).value, (yyvsp[-1].timespec).tv_sec, (yyvsp[-1].timespec).tv_nsec); + pc->meridian = (yyvsp[0].intval); } +#line 1689 "parse-datetime.c" /* yacc.c:1646 */ break; case 22: -/* Line 1792 of yacc.c */ -#line 388 "./parse-datetime.y" +#line 388 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (2)].textintval).value, 0, 0, 0); + set_hhmmss (pc, (yyvsp[-1].textintval).value, 0, 0, 0); pc->meridian = MER24; } +#line 1698 "parse-datetime.c" /* yacc.c:1646 */ break; case 23: -/* Line 1792 of yacc.c */ -#line 393 "./parse-datetime.y" +#line 393 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (4)].textintval).value, (yyvsp[(3) - (4)].textintval).value, 0, 0); + set_hhmmss (pc, (yyvsp[-3].textintval).value, (yyvsp[-1].textintval).value, 0, 0); pc->meridian = MER24; } +#line 1707 "parse-datetime.c" /* yacc.c:1646 */ break; case 24: -/* Line 1792 of yacc.c */ -#line 398 "./parse-datetime.y" +#line 398 "./parse-datetime.y" /* yacc.c:1646 */ { - set_hhmmss (pc, (yyvsp[(1) - (6)].textintval).value, (yyvsp[(3) - (6)].textintval).value, (yyvsp[(5) - (6)].timespec).tv_sec, (yyvsp[(5) - (6)].timespec).tv_nsec); + set_hhmmss (pc, (yyvsp[-5].textintval).value, (yyvsp[-3].textintval).value, (yyvsp[-1].timespec).tv_sec, (yyvsp[-1].timespec).tv_nsec); pc->meridian = MER24; } +#line 1716 "parse-datetime.c" /* yacc.c:1646 */ break; case 27: -/* Line 1792 of yacc.c */ -#line 411 "./parse-datetime.y" +#line 411 "./parse-datetime.y" /* yacc.c:1646 */ { pc->zones_seen++; - pc->time_zone = time_zone_hhmm (pc, (yyvsp[(1) - (2)].textintval), (yyvsp[(2) - (2)].intval)); + pc->time_zone = time_zone_hhmm (pc, (yyvsp[-1].textintval), (yyvsp[0].intval)); } +#line 1725 "parse-datetime.c" /* yacc.c:1646 */ break; case 28: -/* Line 1792 of yacc.c */ -#line 419 "./parse-datetime.y" +#line 419 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->local_isdst = (yyvsp[(1) - (1)].intval); - pc->dsts_seen += (0 < (yyvsp[(1) - (1)].intval)); + pc->local_isdst = (yyvsp[0].intval); + pc->dsts_seen += (0 < (yyvsp[0].intval)); } +#line 1734 "parse-datetime.c" /* yacc.c:1646 */ break; case 29: -/* Line 1792 of yacc.c */ -#line 424 "./parse-datetime.y" +#line 424 "./parse-datetime.y" /* yacc.c:1646 */ { pc->local_isdst = 1; - pc->dsts_seen += (0 < (yyvsp[(1) - (2)].intval)) + 1; + pc->dsts_seen += (0 < (yyvsp[-1].intval)) + 1; } +#line 1743 "parse-datetime.c" /* yacc.c:1646 */ break; case 30: -/* Line 1792 of yacc.c */ -#line 434 "./parse-datetime.y" - { pc->time_zone = (yyvsp[(1) - (1)].intval); } +#line 434 "./parse-datetime.y" /* yacc.c:1646 */ + { pc->time_zone = (yyvsp[0].intval); } +#line 1749 "parse-datetime.c" /* yacc.c:1646 */ break; case 31: -/* Line 1792 of yacc.c */ -#line 436 "./parse-datetime.y" +#line 436 "./parse-datetime.y" /* yacc.c:1646 */ { pc->time_zone = HOUR(7); } +#line 1755 "parse-datetime.c" /* yacc.c:1646 */ break; case 32: -/* Line 1792 of yacc.c */ -#line 438 "./parse-datetime.y" - { pc->time_zone = (yyvsp[(1) - (2)].intval); - apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } +#line 438 "./parse-datetime.y" /* yacc.c:1646 */ + { pc->time_zone = (yyvsp[-1].intval); + apply_relative_time (pc, (yyvsp[0].rel), 1); } +#line 1762 "parse-datetime.c" /* yacc.c:1646 */ break; case 33: -/* Line 1792 of yacc.c */ -#line 441 "./parse-datetime.y" +#line 441 "./parse-datetime.y" /* yacc.c:1646 */ { pc->time_zone = HOUR(7); - apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); } + apply_relative_time (pc, (yyvsp[0].rel), 1); } +#line 1769 "parse-datetime.c" /* yacc.c:1646 */ break; case 34: -/* Line 1792 of yacc.c */ -#line 444 "./parse-datetime.y" - { pc->time_zone = (yyvsp[(1) - (3)].intval) + time_zone_hhmm (pc, (yyvsp[(2) - (3)].textintval), (yyvsp[(3) - (3)].intval)); } +#line 444 "./parse-datetime.y" /* yacc.c:1646 */ + { pc->time_zone = (yyvsp[-2].intval) + time_zone_hhmm (pc, (yyvsp[-1].textintval), (yyvsp[0].intval)); } +#line 1775 "parse-datetime.c" /* yacc.c:1646 */ break; case 35: -/* Line 1792 of yacc.c */ -#line 446 "./parse-datetime.y" - { pc->time_zone = (yyvsp[(1) - (1)].intval) + 60; } +#line 446 "./parse-datetime.y" /* yacc.c:1646 */ + { pc->time_zone = (yyvsp[0].intval) + 60; } +#line 1781 "parse-datetime.c" /* yacc.c:1646 */ break; case 36: -/* Line 1792 of yacc.c */ -#line 448 "./parse-datetime.y" - { pc->time_zone = (yyvsp[(1) - (2)].intval) + 60; } +#line 448 "./parse-datetime.y" /* yacc.c:1646 */ + { pc->time_zone = (yyvsp[-1].intval) + 60; } +#line 1787 "parse-datetime.c" /* yacc.c:1646 */ break; case 37: -/* Line 1792 of yacc.c */ -#line 453 "./parse-datetime.y" +#line 453 "./parse-datetime.y" /* yacc.c:1646 */ { pc->day_ordinal = 0; - pc->day_number = (yyvsp[(1) - (1)].intval); + pc->day_number = (yyvsp[0].intval); } +#line 1796 "parse-datetime.c" /* yacc.c:1646 */ break; case 38: -/* Line 1792 of yacc.c */ -#line 458 "./parse-datetime.y" +#line 458 "./parse-datetime.y" /* yacc.c:1646 */ { pc->day_ordinal = 0; - pc->day_number = (yyvsp[(1) - (2)].intval); + pc->day_number = (yyvsp[-1].intval); } +#line 1805 "parse-datetime.c" /* yacc.c:1646 */ break; case 39: -/* Line 1792 of yacc.c */ -#line 463 "./parse-datetime.y" +#line 463 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->day_ordinal = (yyvsp[(1) - (2)].intval); - pc->day_number = (yyvsp[(2) - (2)].intval); + pc->day_ordinal = (yyvsp[-1].intval); + pc->day_number = (yyvsp[0].intval); } +#line 1814 "parse-datetime.c" /* yacc.c:1646 */ break; case 40: -/* Line 1792 of yacc.c */ -#line 468 "./parse-datetime.y" +#line 468 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->day_ordinal = (yyvsp[(1) - (2)].textintval).value; - pc->day_number = (yyvsp[(2) - (2)].intval); + pc->day_ordinal = (yyvsp[-1].textintval).value; + pc->day_number = (yyvsp[0].intval); } +#line 1823 "parse-datetime.c" /* yacc.c:1646 */ break; case 41: -/* Line 1792 of yacc.c */ -#line 476 "./parse-datetime.y" +#line 476 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->month = (yyvsp[(1) - (3)].textintval).value; - pc->day = (yyvsp[(3) - (3)].textintval).value; + pc->month = (yyvsp[-2].textintval).value; + pc->day = (yyvsp[0].textintval).value; } +#line 1832 "parse-datetime.c" /* yacc.c:1646 */ break; case 42: -/* Line 1792 of yacc.c */ -#line 481 "./parse-datetime.y" +#line 481 "./parse-datetime.y" /* yacc.c:1646 */ { /* Interpret as YYYY/MM/DD if the first value has 4 or more digits, otherwise as MM/DD/YY. The goal in recognizing YYYY/MM/DD is solely to support legacy machine-generated dates like those in an RCS log listing. If you want portability, use the ISO 8601 format. */ - if (4 <= (yyvsp[(1) - (5)].textintval).digits) + if (4 <= (yyvsp[-4].textintval).digits) { - pc->year = (yyvsp[(1) - (5)].textintval); - pc->month = (yyvsp[(3) - (5)].textintval).value; - pc->day = (yyvsp[(5) - (5)].textintval).value; + pc->year = (yyvsp[-4].textintval); + pc->month = (yyvsp[-2].textintval).value; + pc->day = (yyvsp[0].textintval).value; } else { - pc->month = (yyvsp[(1) - (5)].textintval).value; - pc->day = (yyvsp[(3) - (5)].textintval).value; - pc->year = (yyvsp[(5) - (5)].textintval); + pc->month = (yyvsp[-4].textintval).value; + pc->day = (yyvsp[-2].textintval).value; + pc->year = (yyvsp[0].textintval); } } +#line 1856 "parse-datetime.c" /* yacc.c:1646 */ break; case 43: -/* Line 1792 of yacc.c */ -#line 501 "./parse-datetime.y" +#line 501 "./parse-datetime.y" /* yacc.c:1646 */ { /* e.g. 17-JUN-1992. */ - pc->day = (yyvsp[(1) - (3)].textintval).value; - pc->month = (yyvsp[(2) - (3)].intval); - pc->year.value = -(yyvsp[(3) - (3)].textintval).value; - pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; + pc->day = (yyvsp[-2].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->year.value = -(yyvsp[0].textintval).value; + pc->year.digits = (yyvsp[0].textintval).digits; } +#line 1868 "parse-datetime.c" /* yacc.c:1646 */ break; case 44: -/* Line 1792 of yacc.c */ -#line 509 "./parse-datetime.y" +#line 509 "./parse-datetime.y" /* yacc.c:1646 */ { /* e.g. JUN-17-1992. */ - pc->month = (yyvsp[(1) - (3)].intval); - pc->day = -(yyvsp[(2) - (3)].textintval).value; - pc->year.value = -(yyvsp[(3) - (3)].textintval).value; - pc->year.digits = (yyvsp[(3) - (3)].textintval).digits; + pc->month = (yyvsp[-2].intval); + pc->day = -(yyvsp[-1].textintval).value; + pc->year.value = -(yyvsp[0].textintval).value; + pc->year.digits = (yyvsp[0].textintval).digits; } +#line 1880 "parse-datetime.c" /* yacc.c:1646 */ break; case 45: -/* Line 1792 of yacc.c */ -#line 517 "./parse-datetime.y" +#line 517 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->month = (yyvsp[(1) - (2)].intval); - pc->day = (yyvsp[(2) - (2)].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->day = (yyvsp[0].textintval).value; } +#line 1889 "parse-datetime.c" /* yacc.c:1646 */ break; case 46: -/* Line 1792 of yacc.c */ -#line 522 "./parse-datetime.y" +#line 522 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->month = (yyvsp[(1) - (4)].intval); - pc->day = (yyvsp[(2) - (4)].textintval).value; - pc->year = (yyvsp[(4) - (4)].textintval); + pc->month = (yyvsp[-3].intval); + pc->day = (yyvsp[-2].textintval).value; + pc->year = (yyvsp[0].textintval); } +#line 1899 "parse-datetime.c" /* yacc.c:1646 */ break; case 47: -/* Line 1792 of yacc.c */ -#line 528 "./parse-datetime.y" +#line 528 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->day = (yyvsp[(1) - (2)].textintval).value; - pc->month = (yyvsp[(2) - (2)].intval); + pc->day = (yyvsp[-1].textintval).value; + pc->month = (yyvsp[0].intval); } +#line 1908 "parse-datetime.c" /* yacc.c:1646 */ break; case 48: -/* Line 1792 of yacc.c */ -#line 533 "./parse-datetime.y" +#line 533 "./parse-datetime.y" /* yacc.c:1646 */ { - pc->day = (yyvsp[(1) - (3)].textintval).value; - pc->month = (yyvsp[(2) - (3)].intval); - pc->year = (yyvsp[(3) - (3)].textintval); + pc->day = (yyvsp[-2].textintval).value; + pc->month = (yyvsp[-1].intval); + pc->year = (yyvsp[0].textintval); } +#line 1918 "parse-datetime.c" /* yacc.c:1646 */ break; case 50: -/* Line 1792 of yacc.c */ -#line 543 "./parse-datetime.y" +#line 543 "./parse-datetime.y" /* yacc.c:1646 */ { /* ISO 8601 format. YYYY-MM-DD. */ - pc->year = (yyvsp[(1) - (3)].textintval); - pc->month = -(yyvsp[(2) - (3)].textintval).value; - pc->day = -(yyvsp[(3) - (3)].textintval).value; + pc->year = (yyvsp[-2].textintval); + pc->month = -(yyvsp[-1].textintval).value; + pc->day = -(yyvsp[0].textintval).value; } +#line 1929 "parse-datetime.c" /* yacc.c:1646 */ break; case 51: -/* Line 1792 of yacc.c */ -#line 553 "./parse-datetime.y" - { apply_relative_time (pc, (yyvsp[(1) - (2)].rel), (yyvsp[(2) - (2)].intval)); } +#line 553 "./parse-datetime.y" /* yacc.c:1646 */ + { apply_relative_time (pc, (yyvsp[-1].rel), (yyvsp[0].intval)); } +#line 1935 "parse-datetime.c" /* yacc.c:1646 */ break; case 52: -/* Line 1792 of yacc.c */ -#line 555 "./parse-datetime.y" - { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } +#line 555 "./parse-datetime.y" /* yacc.c:1646 */ + { apply_relative_time (pc, (yyvsp[0].rel), 1); } +#line 1941 "parse-datetime.c" /* yacc.c:1646 */ break; case 53: -/* Line 1792 of yacc.c */ -#line 557 "./parse-datetime.y" - { apply_relative_time (pc, (yyvsp[(1) - (1)].rel), 1); } +#line 557 "./parse-datetime.y" /* yacc.c:1646 */ + { apply_relative_time (pc, (yyvsp[0].rel), 1); } +#line 1947 "parse-datetime.c" /* yacc.c:1646 */ break; case 54: -/* Line 1792 of yacc.c */ -#line 562 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].intval); } +#line 562 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].intval); } +#line 1953 "parse-datetime.c" /* yacc.c:1646 */ break; case 55: -/* Line 1792 of yacc.c */ -#line 564 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } +#line 564 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].textintval).value; } +#line 1959 "parse-datetime.c" /* yacc.c:1646 */ break; case 56: -/* Line 1792 of yacc.c */ -#line 566 "./parse-datetime.y" +#line 566 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = 1; } +#line 1965 "parse-datetime.c" /* yacc.c:1646 */ break; case 57: -/* Line 1792 of yacc.c */ -#line 568 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].intval); } +#line 568 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].intval); } +#line 1971 "parse-datetime.c" /* yacc.c:1646 */ break; case 58: -/* Line 1792 of yacc.c */ -#line 570 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } +#line 570 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].textintval).value; } +#line 1977 "parse-datetime.c" /* yacc.c:1646 */ break; case 59: -/* Line 1792 of yacc.c */ -#line 572 "./parse-datetime.y" +#line 572 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = 1; } +#line 1983 "parse-datetime.c" /* yacc.c:1646 */ break; case 60: -/* Line 1792 of yacc.c */ -#line 574 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].intval) * (yyvsp[(2) - (2)].intval); } +#line 574 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].intval) * (yyvsp[0].intval); } +#line 1989 "parse-datetime.c" /* yacc.c:1646 */ break; case 61: -/* Line 1792 of yacc.c */ -#line 576 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } +#line 576 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].textintval).value * (yyvsp[0].intval); } +#line 1995 "parse-datetime.c" /* yacc.c:1646 */ break; case 62: -/* Line 1792 of yacc.c */ -#line 578 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } +#line 578 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[0].intval); } +#line 2001 "parse-datetime.c" /* yacc.c:1646 */ break; case 63: -/* Line 1792 of yacc.c */ -#line 580 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].intval); } +#line 580 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].intval); } +#line 2007 "parse-datetime.c" /* yacc.c:1646 */ break; case 64: -/* Line 1792 of yacc.c */ -#line 582 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } +#line 582 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].textintval).value; } +#line 2013 "parse-datetime.c" /* yacc.c:1646 */ break; case 65: -/* Line 1792 of yacc.c */ -#line 584 "./parse-datetime.y" +#line 584 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = 1; } +#line 2019 "parse-datetime.c" /* yacc.c:1646 */ break; case 66: -/* Line 1792 of yacc.c */ -#line 586 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].intval); } +#line 586 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].intval); } +#line 2025 "parse-datetime.c" /* yacc.c:1646 */ break; case 67: -/* Line 1792 of yacc.c */ -#line 588 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } +#line 588 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].textintval).value; } +#line 2031 "parse-datetime.c" /* yacc.c:1646 */ break; case 68: -/* Line 1792 of yacc.c */ -#line 590 "./parse-datetime.y" +#line 590 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = 1; } +#line 2037 "parse-datetime.c" /* yacc.c:1646 */ break; case 69: -/* Line 1792 of yacc.c */ -#line 592 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].intval); } +#line 592 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].intval); } +#line 2043 "parse-datetime.c" /* yacc.c:1646 */ break; case 70: -/* Line 1792 of yacc.c */ -#line 594 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } +#line 594 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].textintval).value; } +#line 2049 "parse-datetime.c" /* yacc.c:1646 */ break; case 71: -/* Line 1792 of yacc.c */ -#line 596 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } +#line 596 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].timespec).tv_sec; (yyval.rel).ns = (yyvsp[-1].timespec).tv_nsec; } +#line 2055 "parse-datetime.c" /* yacc.c:1646 */ break; case 72: -/* Line 1792 of yacc.c */ -#line 598 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].timespec).tv_sec; (yyval.rel).ns = (yyvsp[(1) - (2)].timespec).tv_nsec; } +#line 598 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].timespec).tv_sec; (yyval.rel).ns = (yyvsp[-1].timespec).tv_nsec; } +#line 2061 "parse-datetime.c" /* yacc.c:1646 */ break; case 73: -/* Line 1792 of yacc.c */ -#line 600 "./parse-datetime.y" +#line 600 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = 1; } +#line 2067 "parse-datetime.c" /* yacc.c:1646 */ break; case 75: -/* Line 1792 of yacc.c */ -#line 606 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[(1) - (2)].textintval).value; } +#line 606 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).year = (yyvsp[-1].textintval).value; } +#line 2073 "parse-datetime.c" /* yacc.c:1646 */ break; case 76: -/* Line 1792 of yacc.c */ -#line 608 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[(1) - (2)].textintval).value; } +#line 608 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).month = (yyvsp[-1].textintval).value; } +#line 2079 "parse-datetime.c" /* yacc.c:1646 */ break; case 77: -/* Line 1792 of yacc.c */ -#line 610 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (2)].textintval).value * (yyvsp[(2) - (2)].intval); } +#line 610 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[-1].textintval).value * (yyvsp[0].intval); } +#line 2085 "parse-datetime.c" /* yacc.c:1646 */ break; case 78: -/* Line 1792 of yacc.c */ -#line 612 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[(1) - (2)].textintval).value; } +#line 612 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).hour = (yyvsp[-1].textintval).value; } +#line 2091 "parse-datetime.c" /* yacc.c:1646 */ break; case 79: -/* Line 1792 of yacc.c */ -#line 614 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[(1) - (2)].textintval).value; } +#line 614 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).minutes = (yyvsp[-1].textintval).value; } +#line 2097 "parse-datetime.c" /* yacc.c:1646 */ break; case 80: -/* Line 1792 of yacc.c */ -#line 616 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[(1) - (2)].textintval).value; } +#line 616 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).seconds = (yyvsp[-1].textintval).value; } +#line 2103 "parse-datetime.c" /* yacc.c:1646 */ break; case 81: -/* Line 1792 of yacc.c */ -#line 621 "./parse-datetime.y" - { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[(1) - (1)].intval); } +#line 621 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.rel) = RELATIVE_TIME_0; (yyval.rel).day = (yyvsp[0].intval); } +#line 2109 "parse-datetime.c" /* yacc.c:1646 */ break; case 85: -/* Line 1792 of yacc.c */ -#line 629 "./parse-datetime.y" - { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } +#line 629 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.timespec).tv_sec = (yyvsp[0].textintval).value; (yyval.timespec).tv_nsec = 0; } +#line 2115 "parse-datetime.c" /* yacc.c:1646 */ break; case 87: -/* Line 1792 of yacc.c */ -#line 635 "./parse-datetime.y" - { (yyval.timespec).tv_sec = (yyvsp[(1) - (1)].textintval).value; (yyval.timespec).tv_nsec = 0; } +#line 635 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.timespec).tv_sec = (yyvsp[0].textintval).value; (yyval.timespec).tv_nsec = 0; } +#line 2121 "parse-datetime.c" /* yacc.c:1646 */ break; case 88: -/* Line 1792 of yacc.c */ -#line 640 "./parse-datetime.y" - { digits_to_date_time (pc, (yyvsp[(1) - (1)].textintval)); } +#line 640 "./parse-datetime.y" /* yacc.c:1646 */ + { digits_to_date_time (pc, (yyvsp[0].textintval)); } +#line 2127 "parse-datetime.c" /* yacc.c:1646 */ break; case 89: -/* Line 1792 of yacc.c */ -#line 645 "./parse-datetime.y" +#line 645 "./parse-datetime.y" /* yacc.c:1646 */ { /* Hybrid all-digit and relative offset, so that we accept e.g., "YYYYMMDD +N days" as well as "YYYYMMDD N days". */ - digits_to_date_time (pc, (yyvsp[(1) - (2)].textintval)); - apply_relative_time (pc, (yyvsp[(2) - (2)].rel), 1); + digits_to_date_time (pc, (yyvsp[-1].textintval)); + apply_relative_time (pc, (yyvsp[0].rel), 1); } +#line 2138 "parse-datetime.c" /* yacc.c:1646 */ break; case 90: -/* Line 1792 of yacc.c */ -#line 655 "./parse-datetime.y" +#line 655 "./parse-datetime.y" /* yacc.c:1646 */ { (yyval.intval) = -1; } +#line 2144 "parse-datetime.c" /* yacc.c:1646 */ break; case 91: -/* Line 1792 of yacc.c */ -#line 657 "./parse-datetime.y" - { (yyval.intval) = (yyvsp[(2) - (2)].textintval).value; } +#line 657 "./parse-datetime.y" /* yacc.c:1646 */ + { (yyval.intval) = (yyvsp[0].textintval).value; } +#line 2150 "parse-datetime.c" /* yacc.c:1646 */ break; -/* Line 1792 of yacc.c */ -#line 2332 "parse-datetime.c" +#line 2154 "parse-datetime.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2350,7 +2172,7 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -2365,9 +2187,9 @@ yyreduce: goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ @@ -2418,20 +2240,20 @@ yyerrlab: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval, pc); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval, pc); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -2450,7 +2272,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -2463,29 +2285,29 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp, pc); + yystos[yystate], yyvsp, pc); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -2536,14 +2358,14 @@ yyreturn: yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, pc); } - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, pc); + yystos[*yyssp], yyvsp, pc); YYPOPSTACK (1); } #ifndef yyoverflow @@ -2554,13 +2376,9 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - -/* Line 2055 of yacc.c */ -#line 660 "./parse-datetime.y" +#line 660 "./parse-datetime.y" /* yacc.c:1906 */ static table const meridian_table[] = @@ -2935,7 +2753,7 @@ lookup_word (parser_control const *pc, char *word) } static int -yylex (YYSTYPE *lvalp, parser_control *pc) +yylex (union YYSTYPE *lvalp, parser_control *pc) { unsigned char c; size_t count; diff --git a/lib/parse-datetime.h b/lib/parse-datetime.h index 9c9bb93..443edb9 100644 --- a/lib/parse-datetime.h +++ b/lib/parse-datetime.h @@ -1,6 +1,6 @@ /* Parse a string into an internal time stamp. - Copyright (C) 1995, 1997-1998, 2003-2004, 2007, 2009-2014 Free Software + Copyright (C) 1995, 1997-1998, 2003-2004, 2007, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index 52e6a0c..1b1fec7 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -1,7 +1,7 @@ %{ /* Parse a string into an internal time stamp. - Copyright (C) 1999-2000, 2002-2014 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1031,7 +1031,7 @@ lookup_word (parser_control const *pc, char *word) } static int -yylex (YYSTYPE *lvalp, parser_control *pc) +yylex (union YYSTYPE *lvalp, parser_control *pc) { unsigned char c; size_t count; diff --git a/lib/pathmax.h b/lib/pathmax.h index 33fc355..2f3b64f 100644 --- a/lib/pathmax.h +++ b/lib/pathmax.h @@ -1,5 +1,5 @@ /* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2014 Free Software + Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/pipe-safer.c b/lib/pipe-safer.c index 70fb40f..91b0fe7 100644 --- a/lib/pipe-safer.c +++ b/lib/pipe-safer.c @@ -1,5 +1,5 @@ /* Invoke pipe, but avoid some glitches. - Copyright (C) 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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/printf-args.c b/lib/printf-args.c index 39cd0a4..da17efb 100644 --- a/lib/printf-args.c +++ b/lib/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2014 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/printf-args.h b/lib/printf-args.h index 9364eed..387976c 100644 --- a/lib/printf-args.h +++ b/lib/printf-args.h @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2014 Free Software + Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify diff --git a/lib/printf-parse.c b/lib/printf-parse.c index 131d0f0..40d0a22 100644 --- a/lib/printf-parse.c +++ b/lib/printf-parse.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003, 2006-2014 Free Software Foundation, Inc. + Copyright (C) 1999-2000, 2002-2003, 2006-2015 Free Software Foundation, Inc. This 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/printf-parse.h b/lib/printf-parse.h index 2651195..fda6704 100644 --- a/lib/printf-parse.h +++ b/lib/printf-parse.h @@ -1,5 +1,5 @@ /* Parse printf format string. - Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2014 Free Software + Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2015 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 index 2919be9..fe93bca 100644 --- a/lib/progname.c +++ b/lib/progname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2003, 2005-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/lib/progname.h b/lib/progname.h index fa15871..d1e034f 100644 --- a/lib/progname.h +++ b/lib/progname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2004, 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2004, 2006, 2009-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software: you can redistribute it and/or modify diff --git a/lib/quote.h b/lib/quote.h index fb338a7..28c05fd 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-2014 Free Software Foundation, Inc. + Copyright (C) 1998-2001, 2003, 2009-2015 Free Software Foundation, Inc. This 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 bef7b98..9f91659 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -1,6 +1,6 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998-2002, 2004-2014 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004-2015 Free Software Foundation, Inc. This 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.h b/lib/quotearg.h index da29d7b..d0ccd8b 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-2014 Free Software Foundation, + Copyright (C) 1998-2002, 2004, 2006, 2008-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/raise.c b/lib/raise.c index cf58a7e..d6ba2a1 100644 --- a/lib/raise.c +++ b/lib/raise.c @@ -1,6 +1,6 @@ /* Provide a non-threads replacement for the POSIX raise function. - Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2003, 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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/readdir.c b/lib/readdir.c index b74aebe..8646aac 100644 --- a/lib/readdir.c +++ b/lib/readdir.c @@ -1,5 +1,5 @@ /* Read the next entry of a directory. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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/readlink.c b/lib/readlink.c index 4c49639..965c3e2 100644 --- a/lib/readlink.c +++ b/lib/readlink.c @@ -1,5 +1,5 @@ /* Stub for readlink(). - Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2003-2007, 2009-2015 Free Software Foundation, Inc. This 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/readlinkat.c b/lib/readlinkat.c new file mode 100644 index 0000000..f4826f9 --- /dev/null +++ b/lib/readlinkat.c @@ -0,0 +1,61 @@ +/* Read a symlink relative to an open directory. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Eric Blake */ + +#include + +#include + +#if HAVE_READLINKAT + +# undef readlinkat + +ssize_t +rpl_readlinkat (int fd, char const *file, char *buf, size_t len) +{ + return readlinkat (fd, file, buf, len); +} + +#else + +/* Gnulib provides a readlink stub for mingw; use it for distinction + between EINVAL and ENOENT, rather than always failing with ENOSYS. */ + +/* POSIX 2008 says that unlike readlink, readlinkat returns 0 for + success instead of the buffer length. But this would render + readlinkat worthless since readlink does not guarantee a + NUL-terminated buffer. Assume this was a bug in POSIX. */ + +/* Read the contents of symlink FILE into buffer BUF of size LEN, in the + directory open on descriptor FD. If possible, do it without changing + the working directory. Otherwise, resort to using save_cwd/fchdir, + then readlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +# define AT_FUNC_NAME readlinkat +# define AT_FUNC_F1 readlink +# define AT_FUNC_POST_FILE_PARAM_DECLS , char *buf, size_t len +# define AT_FUNC_POST_FILE_ARGS , buf, len +# define AT_FUNC_RESULT ssize_t +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS +# undef AT_FUNC_RESULT + +#endif diff --git a/lib/realloc.c b/lib/realloc.c index 8dfcfbe..068b081 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -1,6 +1,6 @@ /* realloc() function that is glibc compatible. - Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2014 Free Software + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/ref-add.sin b/lib/ref-add.sin index 0e14022..6cbe5b5 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-2014 Free Software Foundation, Inc. +# Copyright (C) 2000, 2009-2015 Free Software Foundation, Inc. # # This 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 2dbcf7b..f50cf0a 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-2014 Free Software Foundation, Inc. +# Copyright (C) 2000, 2009-2015 Free Software Foundation, Inc. # # This 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/rename.c b/lib/rename.c index 608f838..43be743 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-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2003, 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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/renameat.c b/lib/renameat.c new file mode 100644 index 0000000..fa416f0 --- /dev/null +++ b/lib/renameat.c @@ -0,0 +1,157 @@ +/* Rename a file relative to open directories. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Eric Blake */ + +#include + +#include + +#if HAVE_RENAMEAT + +# include +# include +# include +# include +# include + +# include "dirname.h" +# include "openat.h" + +# undef renameat + +/* renameat does not honor trailing / on Solaris 10. Solve it in a + similar manner to rename. No need to worry about bugs not present + on Solaris, since all other systems either lack renameat or honor + trailing slash correctly. */ + +int +rpl_renameat (int fd1, char const *src, int fd2, char const *dst) +{ + size_t src_len = strlen (src); + size_t dst_len = strlen (dst); + char *src_temp = (char *) src; + char *dst_temp = (char *) dst; + bool src_slash; + bool dst_slash; + int ret_val = -1; + int rename_errno = ENOTDIR; + struct stat src_st; + struct stat dst_st; + + /* Let strace see any ENOENT failure. */ + if (!src_len || !dst_len) + return renameat (fd1, src, fd2, dst); + + src_slash = src[src_len - 1] == '/'; + dst_slash = dst[dst_len - 1] == '/'; + if (!src_slash && !dst_slash) + return renameat (fd1, src, fd2, dst); + + /* Presence of a trailing slash requires directory semantics. If + the source does not exist, or if the destination cannot be turned + into a directory, give up now. Otherwise, strip trailing slashes + before calling rename. */ + if (lstatat (fd1, src, &src_st)) + return -1; + if (lstatat (fd2, dst, &dst_st)) + { + if (errno != ENOENT || !S_ISDIR (src_st.st_mode)) + return -1; + } + else if (!S_ISDIR (dst_st.st_mode)) + { + errno = ENOTDIR; + return -1; + } + else if (!S_ISDIR (src_st.st_mode)) + { + errno = EISDIR; + return -1; + } + +# if RENAME_TRAILING_SLASH_SOURCE_BUG + /* See the lengthy comment in rename.c why Solaris 9 is forced to + GNU behavior, while Solaris 10 is left with POSIX behavior, + regarding symlinks with trailing slash. */ + if (src_slash) + { + src_temp = strdup (src); + if (!src_temp) + { + /* Rather than rely on strdup-posix, we set errno ourselves. */ + rename_errno = ENOMEM; + goto out; + } + strip_trailing_slashes (src_temp); + if (lstatat (fd1, src_temp, &src_st)) + { + rename_errno = errno; + goto out; + } + if (S_ISLNK (src_st.st_mode)) + goto out; + } + if (dst_slash) + { + dst_temp = strdup (dst); + if (!dst_temp) + { + rename_errno = ENOMEM; + goto out; + } + strip_trailing_slashes (dst_temp); + if (lstatat (fd2, dst_temp, &dst_st)) + { + if (errno != ENOENT) + { + rename_errno = errno; + goto out; + } + } + else if (S_ISLNK (dst_st.st_mode)) + goto out; + } +# endif /* RENAME_TRAILING_SLASH_SOURCE_BUG */ + + ret_val = renameat (fd1, src_temp, fd2, dst_temp); + rename_errno = errno; + out: + if (src_temp != src) + free (src_temp); + if (dst_temp != dst) + free (dst_temp); + errno = rename_errno; + return ret_val; +} + +#else /* !HAVE_RENAMEAT */ + +# include "openat-priv.h" + +/* Rename FILE1, in the directory open on descriptor FD1, to FILE2, in + the directory open on descriptor FD2. If possible, do it without + changing the working directory. Otherwise, resort to using + save_cwd/fchdir, then rename/restore_cwd. If either the save_cwd or + the restore_cwd fails, then give a diagnostic and exit nonzero. */ + +int +renameat (int fd1, char const *file1, int fd2, char const *file2) +{ + return at_func2 (fd1, file1, fd2, file2, rename); +} + +#endif /* !HAVE_RENAMEAT */ diff --git a/lib/rmdir.c b/lib/rmdir.c index ec7a586..ae21d54 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-2014 Free Software + Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/safe-read.c b/lib/safe-read.c index c9b8828..dbb6338 100644 --- a/lib/safe-read.c +++ b/lib/safe-read.c @@ -1,6 +1,6 @@ /* An interface to read and write that retries after interrupts. - Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2014 Free Software + Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/safe-write.c b/lib/safe-write.c index bf72dd4..4c178f5 100644 --- a/lib/safe-write.c +++ b/lib/safe-write.c @@ -1,5 +1,5 @@ /* An interface to write that retries after interrupts. - Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2015 Free Software Foundation, Inc. This 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/safe-write.h b/lib/safe-write.h index ae18657..86a32b2 100644 --- a/lib/safe-write.h +++ b/lib/safe-write.h @@ -1,5 +1,5 @@ /* An interface to write() that retries after interrupts. - Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2002, 2009-2015 Free Software Foundation, Inc. This 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/same-inode.h b/lib/same-inode.h index 584f606..ecc3049 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. - Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. This 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/save-cwd.c b/lib/save-cwd.c new file mode 100644 index 0000000..159d8a8 --- /dev/null +++ b/lib/save-cwd.c @@ -0,0 +1,99 @@ +/* save-cwd.c -- Save and restore current working directory. + + Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2015 Free Software + Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Jim Meyering. */ + +#include + +#include "save-cwd.h" + +#include +#include +#include +#include +#include + +#include "chdir-long.h" +#include "unistd--.h" +#include "cloexec.h" + +#if GNULIB_FCNTL_SAFER +# include "fcntl--.h" +#else +# define GNULIB_FCNTL_SAFER 0 +#endif + +/* Record the location of the current working directory in CWD so that + the program may change to other directories and later use restore_cwd + to return to the recorded location. This function may allocate + space using malloc (via getcwd) or leave a file descriptor open; + use free_cwd to perform the necessary free or close. Upon failure, + no memory is allocated, any locally opened file descriptors are + closed; return non-zero -- in that case, free_cwd need not be + called, but doing so is ok. Otherwise, return zero. + + The _raison d'etre_ for this interface is that the working directory + is sometimes inaccessible, and getcwd is not robust or as efficient. + So, we prefer to use the open/fchdir approach, but fall back on + getcwd if necessary. This module works for most cases with just + the getcwd-lgpl module, but to be truly robust, use the getcwd module. + + Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin, + SCO Xenix. Also, SunOS 4 and Irix 5.3 provide the function, yet it + doesn't work for partitions on which auditing is enabled. If + you're still using an obsolete system with these problems, please + send email to the maintainer of this code. */ + +int +save_cwd (struct saved_cwd *cwd) +{ + cwd->name = NULL; + + cwd->desc = open (".", O_SEARCH); + if (!GNULIB_FCNTL_SAFER) + cwd->desc = fd_safer (cwd->desc); + if (cwd->desc < 0) + { + cwd->name = getcwd (NULL, 0); + return cwd->name ? 0 : -1; + } + + set_cloexec_flag (cwd->desc, true); + return 0; +} + +/* Change to recorded location, CWD, in directory hierarchy. + Upon failure, return -1 (errno is set by chdir or fchdir). + Upon success, return zero. */ + +int +restore_cwd (const struct saved_cwd *cwd) +{ + if (0 <= cwd->desc) + return fchdir (cwd->desc); + else + return chdir_long (cwd->name); +} + +void +free_cwd (struct saved_cwd *cwd) +{ + if (cwd->desc >= 0) + close (cwd->desc); + free (cwd->name); +} diff --git a/lib/save-cwd.h b/lib/save-cwd.h new file mode 100644 index 0000000..890f7fb --- /dev/null +++ b/lib/save-cwd.h @@ -0,0 +1,34 @@ +/* Save and restore current working directory. + + Copyright (C) 1995, 1997-1998, 2003, 2009-2015 Free Software Foundation, + Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Jim Meyering. */ + +#ifndef SAVE_CWD_H +# define SAVE_CWD_H 1 + +struct saved_cwd + { + int desc; + char *name; + }; + +int save_cwd (struct saved_cwd *cwd); +int restore_cwd (const struct saved_cwd *cwd); +void free_cwd (struct saved_cwd *cwd); + +#endif /* SAVE_CWD_H */ diff --git a/lib/secure_getenv.c b/lib/secure_getenv.c index 32819e6..31aad1f 100644 --- a/lib/secure_getenv.c +++ b/lib/secure_getenv.c @@ -1,6 +1,6 @@ /* Look up an environment variable more securely. - Copyright 2013-2014 Free Software Foundation, Inc. + Copyright 2013-2015 Free Software Foundation, Inc. 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/setenv.c b/lib/setenv.c index 06791a9..6b16fd5 100644 --- a/lib/setenv.c +++ b/lib/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995-2003, 2005-2014 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2003, 2005-2015 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 diff --git a/lib/signal.in.h b/lib/signal.in.h index 925e16f..0f2ff5a 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/size_max.h b/lib/size_max.h index 461ff1c..5a0568e 100644 --- a/lib/size_max.h +++ b/lib/size_max.h @@ -1,5 +1,5 @@ /* size_max.h -- declare SIZE_MAX through system headers - Copyright (C) 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/lib/stat-time.h b/lib/stat-time.h index b3df6eb..b67d179 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -1,6 +1,6 @@ /* stat-related time functions. - Copyright (C) 2005, 2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -54,7 +54,7 @@ _GL_INLINE_HEADER_BEGIN #endif /* Return the nanosecond component of *ST's access time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_atime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -67,7 +67,7 @@ get_stat_atime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's status change time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_ctime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -80,7 +80,7 @@ get_stat_ctime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's data modification time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_mtime_ns (struct stat const *st) { # if defined STAT_TIMESPEC @@ -93,7 +93,7 @@ get_stat_mtime_ns (struct stat const *st) } /* Return the nanosecond component of *ST's birth time. */ -_GL_STAT_TIME_INLINE long int +_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE get_stat_birthtime_ns (struct stat const *st) { # if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC @@ -108,7 +108,7 @@ get_stat_birthtime_ns (struct stat const *st) } /* Return *ST's access time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_atime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -122,7 +122,7 @@ get_stat_atime (struct stat const *st) } /* Return *ST's status change time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_ctime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -136,7 +136,7 @@ get_stat_ctime (struct stat const *st) } /* Return *ST's data modification time. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_mtime (struct stat const *st) { #ifdef STAT_TIMESPEC @@ -151,7 +151,7 @@ get_stat_mtime (struct stat const *st) /* Return *ST's birth time, if available; otherwise return a value with tv_sec and tv_nsec both equal to -1. */ -_GL_STAT_TIME_INLINE struct timespec +_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE get_stat_birthtime (struct stat const *st) { struct timespec t; diff --git a/lib/stat.c b/lib/stat.c index 35f4b0b..2209826 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -1,5 +1,5 @@ /* Work around platform bugs in stat. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/statat.c b/lib/statat.c new file mode 100644 index 0000000..8cdb17e --- /dev/null +++ b/lib/statat.c @@ -0,0 +1,3 @@ +#include +#define STATAT_INLINE _GL_EXTERN_INLINE +#include "openat.h" diff --git a/lib/stdarg.in.h b/lib/stdarg.in.h index 5b37dd3..5239f51 100644 --- a/lib/stdarg.in.h +++ b/lib/stdarg.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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 651e8df..64a1761 100644 --- a/lib/stdbool.in.h +++ b/lib/stdbool.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2003, 2006-2014 Free Software Foundation, Inc. +/* Copyright (C) 2001-2003, 2006-2015 Free Software Foundation, Inc. Written by Bruno Haible , 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 f5c0e05..44db241 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -1,6 +1,6 @@ /* A substitute for POSIX 2008 , for platforms that have issues. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,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@ @@ -54,33 +53,45 @@ # @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. */ +#if !@HAVE_MAX_ALIGN_T@ +typedef union +{ + char *__p; + double __d; + long double __ld; + long int __i; +} 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 247f0d8..378de2e 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2002, 2004-2014 Free Software Foundation, Inc. +/* Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc. Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. This file is part of gnulib. diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 1e1fe84..759c94d 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 2004, 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -84,8 +84,13 @@ 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, diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index ee64324..428a119 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995, 2001-2004, 2006-2014 Free Software Foundation, Inc. + Copyright (C) 1995, 2001-2004, 2006-2015 Free Software Foundation, Inc. This 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/strdup.c b/lib/strdup.c new file mode 100644 index 0000000..4fdd0bd --- /dev/null +++ b/lib/strdup.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2015 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU 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 . */ + +#ifndef _LIBC +# include +#endif + +/* Get specification. */ +#include + +#include + +#undef __strdup +#ifdef _LIBC +# undef strdup +#endif + +#ifndef weak_alias +# define __strdup strdup +#endif + +/* Duplicate S, returning an identical malloc'd string. */ +char * +__strdup (const char *s) +{ + size_t len = strlen (s) + 1; + void *new = malloc (len); + + if (new == NULL) + return NULL; + + return (char *) memcpy (new, s, len); +} +#ifdef libc_hidden_def +libc_hidden_def (__strdup) +#endif +#ifdef weak_alias +weak_alias (__strdup, strdup) +#endif diff --git a/lib/streq.h b/lib/streq.h index 0e62fb9..6107fc6 100644 --- a/lib/streq.h +++ b/lib/streq.h @@ -1,5 +1,5 @@ /* Optimized string comparison. - Copyright (C) 2001-2002, 2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001-2002, 2007, 2009-2015 Free Software Foundation, Inc. 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 255d933..2bb4d74 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-2014 Free Software Foundation, Inc. + Copyright (C) 2010-2015 Free Software Foundation, Inc. This 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 e98c1c1..7af36df 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-2014 Free Software Foundation, Inc. + Copyright (C) 2010-2015 Free Software Foundation, Inc. This 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.c b/lib/strerror.c index e54f0cc..adba738 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -1,6 +1,6 @@ /* strerror.c --- POSIX compatible system error routine - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This 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/string.in.h b/lib/string.in.h index 9062142..ebd727e 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - Copyright (C) 1995-1996, 2001-2014 Free Software Foundation, Inc. + Copyright (C) 1995-1996, 2001-2015 Free Software Foundation, Inc. This 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/stripslash.c b/lib/stripslash.c index 6f802d4..12359cf 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-2014 Free Software Foundation, + Copyright (C) 1990, 2001, 2003-2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/strndup.c b/lib/strndup.c index cc1a484..793d599 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -1,6 +1,6 @@ /* A replacement function, for systems that lack strndup. - Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2014 Free Software + Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it diff --git a/lib/strnlen.c b/lib/strnlen.c index ddccebc..79e250c 100644 --- a/lib/strnlen.c +++ b/lib/strnlen.c @@ -1,5 +1,5 @@ /* Find the length of STRING, but scan at most MAXLEN characters. - Copyright (C) 2005-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2015 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify diff --git a/lib/symlink.c b/lib/symlink.c index 0e3fae2..14356c3 100644 --- a/lib/symlink.c +++ b/lib/symlink.c @@ -1,5 +1,5 @@ /* Stub for symlink(). - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/symlinkat.c b/lib/symlinkat.c new file mode 100644 index 0000000..ce10d94 --- /dev/null +++ b/lib/symlinkat.c @@ -0,0 +1,93 @@ +/* Create a symlink relative to an open directory. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Eric Blake */ + +#include + +#include +#include + +#if HAVE_SYMLINKAT +# undef symlinkat + +/* Create a symlink, but reject trailing slash. */ +int +rpl_symlinkat (char const *contents, int fd, char const *name) +{ + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + struct stat st; + if (fstatat (fd, name, &st, 0) == 0) + errno = EEXIST; + return -1; + } + return symlinkat (contents, fd, name); +} + +#elif !HAVE_SYMLINK +/* Mingw lacks symlink, and it is more efficient to provide a trivial + wrapper than to go through at-func.c to call rpl_symlink. */ + +int +symlinkat (char const *path1 _GL_UNUSED, int fd _GL_UNUSED, + char const *path2 _GL_UNUSED) +{ + errno = ENOSYS; + return -1; +} + +#else /* HAVE_SYMLINK */ + +/* Our openat helper functions expect the directory parameter first, + not second. These shims make life easier. */ + +/* Like symlink, but with arguments reversed. */ +static int +symlink_reversed (char const *file, char const *contents) +{ + return symlink (contents, file); +} + +/* Like symlinkat, but with arguments reversed. */ + +static int +symlinkat_reversed (int fd, char const *file, char const *contents); + +# define AT_FUNC_NAME symlinkat_reversed +# define AT_FUNC_F1 symlink_reversed +# define AT_FUNC_POST_FILE_PARAM_DECLS , char const *contents +# define AT_FUNC_POST_FILE_ARGS , contents +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +/* Create a symlink FILE, in the directory open on descriptor FD, + holding CONTENTS. If possible, do it without changing the + working directory. Otherwise, resort to using save_cwd/fchdir, + then symlink/restore_cwd. If either the save_cwd or the restore_cwd + fails, then give a diagnostic and exit nonzero. */ + +int +symlinkat (char const *contents, int fd, char const *file) +{ + return symlinkat_reversed (fd, file, contents); +} + +#endif /* HAVE_SYMLINK */ diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index b47a7ff..9f5e853 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -1,5 +1,5 @@ /* Provide a more complete sys/stat header file. - Copyright (C) 2005-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2015 Free Software Foundation, Inc. This 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 30057ad..c556c5d 100644 --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -1,6 +1,6 @@ /* Provide a more complete sys/time.h. - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This 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_types.in.h b/lib/sys_types.in.h index deb5d67..814bc17 100644 --- a/lib/sys_types.in.h +++ b/lib/sys_types.in.h @@ -1,6 +1,6 @@ /* Provide a more complete sys/types.h. - Copyright (C) 2011-2014 Free Software Foundation, Inc. + Copyright (C) 2011-2015 Free Software Foundation, Inc. This 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/tempname.c b/lib/tempname.c index 9b713cb..088b224 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-2014 Free Software Foundation, Inc. + Copyright (C) 1991-2003, 2005-2007, 2009-2015 Free Software Foundation, Inc. This 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/tempname.h b/lib/tempname.h index 44d5f04..b560ee5 100644 --- a/lib/tempname.h +++ b/lib/tempname.h @@ -1,6 +1,6 @@ /* Create a temporary file or directory. - Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. This 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/time.in.h b/lib/time.in.h index 81abdf4..1a6b746 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -1,6 +1,6 @@ /* A more-standard . - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -55,6 +55,8 @@ # include # elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ # include +# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ +# include # else # ifdef __cplusplus diff --git a/lib/time_r.c b/lib/time_r.c index a848d54..0b512de 100644 --- a/lib/time_r.c +++ b/lib/time_r.c @@ -1,6 +1,6 @@ /* Reentrant time functions like localtime_r. - Copyright (C) 2003, 2006-2007, 2010-2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2010-2015 Free Software Foundation, Inc. This 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/timespec.h b/lib/timespec.h index 872cbb7..9ec495a 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2014 Free Software + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -74,7 +74,7 @@ make_timespec (time_t s, long int ns) The (int) cast avoids a gcc -Wconversion warning. */ -_GL_TIMESPEC_INLINE int +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 @@ -84,7 +84,7 @@ timespec_cmp (struct timespec a, struct timespec b) /* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be nonnegative. */ -_GL_TIMESPEC_INLINE int +_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE timespec_sign (struct timespec a) { return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec; diff --git a/lib/unistd--.h b/lib/unistd--.h index 9d0e54d..ada1f6b 100644 --- a/lib/unistd--.h +++ b/lib/unistd--.h @@ -1,6 +1,6 @@ /* Like unistd.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005, 2009-2015 Free Software Foundation, Inc. This 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/unistd-safer.h b/lib/unistd-safer.h index 4b0ca6a..d4251b3 100644 --- a/lib/unistd-safer.h +++ b/lib/unistd-safer.h @@ -1,6 +1,6 @@ /* Invoke unistd-like functions, but avoid some glitches. - Copyright (C) 2001, 2003, 2005, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2005, 2009-2015 Free Software Foundation, Inc. This 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/unistd.in.h b/lib/unistd.in.h index 219f43d..958fea2 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -1,5 +1,5 @@ /* Substitute for and wrapper around . - Copyright (C) 2003-2014 Free Software Foundation, Inc. + Copyright (C) 2003-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -402,7 +402,7 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - " "VARIABLE=VALUE", terminated with a NULL. */ # if defined __APPLE__ && defined __MACH__ # include -# if !defined TARGET_OS_IPHONE && !defined TARGET_IPHONE_SIMULATOR +# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR # define _GL_USE_CRT_EXTERNS # endif # endif diff --git a/lib/unlink.c b/lib/unlink.c index a234be4..e006273 100644 --- a/lib/unlink.c +++ b/lib/unlink.c @@ -1,6 +1,6 @@ /* Work around unlink bugs. - Copyright (C) 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This 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/unlinkat.c b/lib/unlinkat.c new file mode 100644 index 0000000..0d89bf9 --- /dev/null +++ b/lib/unlinkat.c @@ -0,0 +1,109 @@ +/* Work around unlinkat bugs on Solaris 9 and Hurd. + + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* Written by Eric Blake. */ + +#include + +#include + +#include +#include +#include +#include + +#include + +#include "dosname.h" +#include "openat.h" + +#if HAVE_UNLINKAT + +# undef unlinkat + +/* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris + 9. Solve it in a similar manner to unlink. Hurd has the same + issue. */ + +int +rpl_unlinkat (int fd, char const *name, int flag) +{ + size_t len; + int result = 0; + /* rmdir behavior has no problems with trailing slash. */ + if (flag & AT_REMOVEDIR) + return unlinkat (fd, name, flag); + + len = strlen (name); + if (len && ISSLASH (name[len - 1])) + { + /* See the lengthy comment in unlink.c why we disobey the POSIX + rule of letting unlink("link-to-dir/") attempt to unlink a + directory. */ + struct stat st; + result = lstatat (fd, name, &st); + if (result == 0) + { + /* Trailing NUL will overwrite the trailing slash. */ + char *short_name = malloc (len); + if (!short_name) + { + errno = EPERM; + return -1; + } + memcpy (short_name, name, len); + while (len && ISSLASH (short_name[len - 1])) + short_name[--len] = '\0'; + if (len && (lstatat (fd, short_name, &st) || S_ISLNK (st.st_mode))) + { + free (short_name); + errno = EPERM; + return -1; + } + free (short_name); + } + } + if (!result) + result = unlinkat (fd, name, flag); + return result; +} + +#else /* !HAVE_UNLINKAT */ + +/* Replacement for Solaris' function by the same name. + + First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE"). + Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd. + If either the save_cwd or the restore_cwd fails (relatively unlikely), + then give a diagnostic and exit nonzero. + Otherwise, this function works just like Solaris' unlinkat. */ + +# define AT_FUNC_NAME unlinkat +# define AT_FUNC_F1 rmdir +# define AT_FUNC_F2 unlink +# define AT_FUNC_USE_F1_COND AT_REMOVEDIR +# define AT_FUNC_POST_FILE_PARAM_DECLS , int flag +# define AT_FUNC_POST_FILE_ARGS /* empty */ +# include "at-func.c" +# undef AT_FUNC_NAME +# undef AT_FUNC_F1 +# undef AT_FUNC_F2 +# undef AT_FUNC_USE_F1_COND +# undef AT_FUNC_POST_FILE_PARAM_DECLS +# undef AT_FUNC_POST_FILE_ARGS + +#endif /* !HAVE_UNLINKAT */ diff --git a/lib/unsetenv.c b/lib/unsetenv.c index 53721fc..87f41d5 100644 --- a/lib/unsetenv.c +++ b/lib/unsetenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992, 1995-2002, 2005-2014 Free Software Foundation, Inc. +/* Copyright (C) 1992, 1995-2002, 2005-2015 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 diff --git a/lib/utimens.c b/lib/utimens.c index dd3ec66..7386dcf 100644 --- a/lib/utimens.c +++ b/lib/utimens.c @@ -1,6 +1,6 @@ /* Set file access and modification times. - Copyright (C) 2003-2014 Free Software Foundation, Inc. + Copyright (C) 2003-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -24,7 +24,6 @@ #define _GL_UTIMENS_INLINE _GL_EXTERN_INLINE #include "utimens.h" -#include #include #include #include @@ -87,7 +86,6 @@ validate_timespec (struct timespec timespec[2]) { int result = 0; int utime_omit_count = 0; - assert (timespec); if ((timespec[0].tv_nsec != UTIME_NOW && timespec[0].tv_nsec != UTIME_OMIT && ! (0 <= timespec[0].tv_nsec diff --git a/lib/utimens.h b/lib/utimens.h index faaf3c7..cbd06cc 100644 --- a/lib/utimens.h +++ b/lib/utimens.h @@ -1,6 +1,6 @@ /* Set file access and modification times. - Copyright 2012-2014 Free Software Foundation, Inc. + Copyright 2012-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the diff --git a/lib/utimensat.c b/lib/utimensat.c new file mode 100644 index 0000000..59839d4 --- /dev/null +++ b/lib/utimensat.c @@ -0,0 +1,158 @@ +/* Set the access and modification time of a file relative to directory fd. + Copyright (C) 2009-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute 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 . */ + +/* written by Eric Blake */ + +#include + +#include + +#include +#include + +#include "stat-time.h" +#include "timespec.h" +#include "utimens.h" + +#if HAVE_UTIMENSAT + +# undef utimensat + +/* If we have a native utimensat, but are compiling this file, then + utimensat was defined to rpl_utimensat by our replacement + sys/stat.h. We assume the native version might fail with ENOSYS, + or succeed without properly affecting ctime (as is the case when + using newer glibc but older Linux kernel). In this scenario, + rpl_utimensat checks whether the native version is usable, and + local_utimensat provides the fallback manipulation. */ + +static int local_utimensat (int, char const *, struct timespec const[2], int); +# define AT_FUNC_NAME local_utimensat + +/* Like utimensat, but work around native bugs. */ + +int +rpl_utimensat (int fd, char const *file, struct timespec const times[2], + int flag) +{ +# if defined __linux__ || defined __sun + struct timespec ts[2]; +# endif + + /* See comments in utimens.c for details. */ + static int utimensat_works_really; /* 0 = unknown, 1 = yes, -1 = no. */ + if (0 <= utimensat_works_really) + { + int result; +# if defined __linux__ || defined __sun + struct stat st; + /* As recently as Linux kernel 2.6.32 (Dec 2009), several file + systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT, + but work if both times are either explicitly specified or + UTIME_NOW. Work around it with a preparatory [l]stat prior + to calling utimensat; fortunately, there is not much timing + impact due to the extra syscall even on file systems where + UTIME_OMIT would have worked. + + The same bug occurs in Solaris 11.1 (Apr 2013). + + FIXME: Simplify this for Linux in 2016 and for Solaris in + 2024, when file system bugs are no longer common. */ + if (times && (times[0].tv_nsec == UTIME_OMIT + || times[1].tv_nsec == UTIME_OMIT)) + { + if (fstatat (fd, file, &st, flag)) + return -1; + if (times[0].tv_nsec == UTIME_OMIT && times[1].tv_nsec == UTIME_OMIT) + return 0; + if (times[0].tv_nsec == UTIME_OMIT) + ts[0] = get_stat_atime (&st); + else + ts[0] = times[0]; + if (times[1].tv_nsec == UTIME_OMIT) + ts[1] = get_stat_mtime (&st); + else + ts[1] = times[1]; + times = ts; + } +# ifdef __hppa__ + /* Linux kernel 2.6.22.19 on hppa does not reject invalid tv_nsec + values. */ + else if (times + && ((times[0].tv_nsec != UTIME_NOW + && ! (0 <= times[0].tv_nsec + && times[0].tv_nsec < TIMESPEC_RESOLUTION)) + || (times[1].tv_nsec != UTIME_NOW + && ! (0 <= times[1].tv_nsec + && times[1].tv_nsec < TIMESPEC_RESOLUTION)))) + { + errno = EINVAL; + return -1; + } +# endif +# endif + result = utimensat (fd, file, times, flag); + /* Linux kernel 2.6.25 has a bug where it returns EINVAL for + UTIME_NOW or UTIME_OMIT with non-zero tv_sec, which + local_utimensat works around. Meanwhile, EINVAL for a bad + flag is indeterminate whether the native utimensat works, but + local_utimensat will also reject it. */ + if (result == -1 && errno == EINVAL && (flag & ~AT_SYMLINK_NOFOLLOW)) + return result; + if (result == 0 || (errno != ENOSYS && errno != EINVAL)) + { + utimensat_works_really = 1; + return result; + } + } + /* No point in trying openat/futimens, since on Linux, futimens is + implemented with the same syscall as utimensat. Only avoid the + native utimensat due to an ENOSYS failure; an EINVAL error was + data-dependent, and the next caller may pass valid data. */ + if (0 <= utimensat_works_really && errno == ENOSYS) + utimensat_works_really = -1; + return local_utimensat (fd, file, times, flag); +} + +#else /* !HAVE_UTIMENSAT */ + +# define AT_FUNC_NAME utimensat + +#endif /* !HAVE_UTIMENSAT */ + +/* Set the access and modification time stamps of FILE to be + TIMESPEC[0] and TIMESPEC[1], respectively; relative to directory + FD. If flag is AT_SYMLINK_NOFOLLOW, change the times of a symlink, + or fail with ENOSYS if not possible. If TIMESPEC is null, set the + time stamps to the current time. If possible, do it without + changing the working directory. Otherwise, resort to using + save_cwd/fchdir, then utimens/restore_cwd. If either the save_cwd + or the restore_cwd fails, then give a diagnostic and exit nonzero. + Return 0 on success, -1 (setting errno) on failure. */ + +/* AT_FUNC_NAME is now utimensat or local_utimensat. */ +#define AT_FUNC_F1 lutimens +#define AT_FUNC_F2 utimens +#define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW +#define AT_FUNC_POST_FILE_PARAM_DECLS , struct timespec const ts[2], int flag +#define AT_FUNC_POST_FILE_ARGS , ts +#include "at-func.c" +#undef AT_FUNC_NAME +#undef AT_FUNC_F1 +#undef AT_FUNC_F2 +#undef AT_FUNC_USE_F1_COND +#undef AT_FUNC_POST_FILE_PARAM_DECLS +#undef AT_FUNC_POST_FILE_ARGS diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index ec7302a..246831f 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2014 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2015 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -5179,18 +5179,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* SNPRINTF or sprintf failed. Save and use the errno that it has set, if any. */ int saved_errno = errno; + if (saved_errno == 0) + { + if (dp->conversion == 'c' || dp->conversion == 's') + saved_errno = EILSEQ; + else + saved_errno = EINVAL; + } if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); - errno = - (saved_errno != 0 - ? saved_errno - : (dp->conversion == 'c' || dp->conversion == 's' - ? EILSEQ - : EINVAL)); + + errno = saved_errno; return NULL; } diff --git a/lib/vasnprintf.h b/lib/vasnprintf.h index daa946d..3494eef 100644 --- a/lib/vasnprintf.h +++ b/lib/vasnprintf.h @@ -1,5 +1,5 @@ /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2004, 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2007-2015 Free Software Foundation, Inc. This 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/vasprintf.c b/lib/vasprintf.c index eed9037..5dd4abd 100644 --- a/lib/vasprintf.c +++ b/lib/vasprintf.c @@ -1,5 +1,5 @@ /* Formatted output to strings. - Copyright (C) 1999, 2002, 2006-2014 Free Software Foundation, Inc. + Copyright (C) 1999, 2002, 2006-2015 Free Software Foundation, Inc. This 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 a25e514..60eba49 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -1,6 +1,6 @@ /* Compile-time assert-like macros. - Copyright (C) 2005-2006, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2005-2006, 2009-2015 Free Software Foundation, Inc. This 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/verror.c b/lib/verror.c index 9388f62..81a2ffc 100644 --- a/lib/verror.c +++ b/lib/verror.c @@ -1,5 +1,5 @@ /* va_list error handler for noninteractive utilities - Copyright (C) 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. This 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/verror.h b/lib/verror.h index c6292bc..5aaa63c 100644 --- a/lib/verror.h +++ b/lib/verror.h @@ -1,5 +1,5 @@ /* Declaration for va_list error-reporting function - Copyright (C) 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. This 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 473285f..fc06d27 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that have issues. - Copyright (C) 2007-2014 Free Software Foundation, Inc. + Copyright (C) 2007-2015 Free Software Foundation, Inc. This 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/wctype.in.h b/lib/wctype.in.h index ab06653..9050b7e 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -1,6 +1,6 @@ /* A substitute for ISO C99 , for platforms that lack it. - Copyright (C) 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2006-2015 Free Software Foundation, Inc. This 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/write.c b/lib/write.c index ff31dbb..ed2d3b7 100644 --- a/lib/write.c +++ b/lib/write.c @@ -1,5 +1,5 @@ /* POSIX compatible write() function. - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. Written by Bruno Haible , 2008. This program is free software: you can redistribute it and/or modify diff --git a/lib/xalloc-die.c b/lib/xalloc-die.c index 7bdd2a3..3cea638 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-2014 Free Software + Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2015 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 f332922..f0e9778 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-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2015 Free Software Foundation, Inc. This 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/xalloc.h b/lib/xalloc.h index 3f6b5b8..3dfaa87 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-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2003-2004, 2006-2015 Free Software Foundation, Inc. This 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/xasprintf.c b/lib/xasprintf.c index 4e0b5b1..f8eef97 100644 --- a/lib/xasprintf.c +++ b/lib/xasprintf.c @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006, 2009-2014 Free Software Foundation, + Copyright (C) 1999, 2002-2004, 2006, 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 264d44a..e246559 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-2014 Free Software Foundation, Inc. + Copyright (C) 1990-2000, 2002-2006, 2008-2015 Free Software Foundation, Inc. This 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/xmemdup0.c b/lib/xmemdup0.c index 8e36813..46b0f05 100644 --- a/lib/xmemdup0.c +++ b/lib/xmemdup0.c @@ -1,6 +1,6 @@ /* xmemdup0.c -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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/xmemdup0.h b/lib/xmemdup0.h index 278f625..673a47b 100644 --- a/lib/xmemdup0.h +++ b/lib/xmemdup0.h @@ -1,6 +1,6 @@ /* xmemdup0.h -- copy a block of arbitrary bytes, plus a trailing NUL - Copyright (C) 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2008-2015 Free Software Foundation, Inc. This 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/xsize.h b/lib/xsize.h index fd12c67..b2a786a 100644 --- a/lib/xsize.h +++ b/lib/xsize.h @@ -1,6 +1,6 @@ /* xsize.h -- Checked size_t computations. - Copyright (C) 2003, 2008-2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2008-2015 Free Software Foundation, Inc. This 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/xstrndup.c b/lib/xstrndup.c index d2259c8..51831d8 100644 --- a/lib/xstrndup.c +++ b/lib/xstrndup.c @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2006-2007, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2009-2015 Free Software Foundation, Inc. This 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/xstrndup.h b/lib/xstrndup.h index 6a409f7..d510bf3 100644 --- a/lib/xstrndup.h +++ b/lib/xstrndup.h @@ -1,6 +1,6 @@ /* Duplicate a bounded initial segment of a string, with out-of-memory checking. - Copyright (C) 2003, 2009-2014 Free Software Foundation, Inc. + Copyright (C) 2003, 2009-2015 Free Software Foundation, Inc. This 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/xvasprintf.c b/lib/xvasprintf.c index 7a4029e..441ab59 100644 --- a/lib/xvasprintf.c +++ b/lib/xvasprintf.c @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 1999, 2002-2004, 2006-2014 Free Software Foundation, Inc. + Copyright (C) 1999, 2002-2004, 2006-2015 Free Software Foundation, Inc. This 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/xvasprintf.h b/lib/xvasprintf.h index 407a5e0..3b7f5ad 100644 --- a/lib/xvasprintf.h +++ b/lib/xvasprintf.h @@ -1,5 +1,5 @@ /* vasprintf and asprintf with out-of-memory checking. - Copyright (C) 2002-2004, 2006-2014 Free Software Foundation, Inc. + Copyright (C) 2002-2004, 2006-2015 Free Software Foundation, Inc. This 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/m4/00gnulib.m4 b/m4/00gnulib.m4 index 8eca551..c7103ed 100644 --- a/m4/00gnulib.m4 +++ b/m4/00gnulib.m4 @@ -1,5 +1,5 @@ # 00gnulib.m4 serial 3 -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 index ce3e39e..bc19dfc 100644 --- a/m4/absolute-header.m4 +++ b/m4/absolute-header.m4 @@ -1,5 +1,5 @@ # absolute-header.m4 serial 16 -dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/alloca.m4 b/m4/alloca.m4 index d7bdea6..8408bed 100644 --- a/m4/alloca.m4 +++ b/m4/alloca.m4 @@ -1,5 +1,5 @@ # alloca.m4 serial 14 -dnl Copyright (C) 2002-2004, 2006-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2004, 2006-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/backupfile.m4 b/m4/backupfile.m4 index 6924944..fe1a5ab 100644 --- a/m4/backupfile.m4 +++ b/m4/backupfile.m4 @@ -1,5 +1,5 @@ # backupfile.m4 serial 14 -dnl Copyright (C) 2002-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/bison.m4 b/m4/bison.m4 index c003367..acfca78 100644 --- a/m4/bison.m4 +++ b/m4/bison.m4 @@ -1,6 +1,6 @@ # serial 7 -# Copyright (C) 2002, 2005, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2002, 2005, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index ace4556..6d932fd 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,6 +1,6 @@ # canonicalize.m4 serial 26 -dnl Copyright (C) 2003-2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/chdir-long.m4 b/m4/chdir-long.m4 new file mode 100644 index 0000000..1448583 --- /dev/null +++ b/m4/chdir-long.m4 @@ -0,0 +1,30 @@ +#serial 15 + +# Use Gnulib's robust chdir function. +# It can handle arbitrarily long directory names, which means +# that when it is given the name of an existing directory, it +# never fails with ENAMETOOLONG. +# Arrange to compile chdir-long.c only on systems that define PATH_MAX. + +dnl Copyright (C) 2004-2007, 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_CHDIR_LONG], +[ + AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ]) + AC_CACHE_CHECK([whether this system has an arbitrary file name length limit], + gl_cv_have_arbitrary_file_name_length_limit, + [AC_EGREP_CPP([have_arbitrary_file_name_length_limit], + gl_PATHMAX_SNIPPET[ +#ifdef PATH_MAX +have_arbitrary_file_name_length_limit +#endif], + gl_cv_have_arbitrary_file_name_length_limit=yes, + gl_cv_have_arbitrary_file_name_length_limit=no)]) +]) + +AC_DEFUN([gl_PREREQ_CHDIR_LONG], [:]) diff --git a/m4/chown.m4 b/m4/chown.m4 new file mode 100644 index 0000000..633ea3a --- /dev/null +++ b/m4/chown.m4 @@ -0,0 +1,204 @@ +# serial 27 +# Determine whether we need the chown wrapper. + +dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009-2015 Free Software +dnl Foundation, Inc. + +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# chown should accept arguments of -1 for uid and gid, and it should +# dereference symlinks. If it doesn't, arrange to use the replacement +# function. + +# From Jim Meyering. + +m4_version_prereq([2.70], [] ,[ + +# This is taken from the following Autoconf patch: +# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 +AC_DEFUN([AC_FUNC_CHOWN], +[ + AC_REQUIRE([AC_TYPE_UID_T])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CHECK_HEADERS([unistd.h]) + AC_CACHE_CHECK([for working chown], + [ac_cv_func_chown_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + [#include + ]], + [[ + char *f = "conftest.chown"; + struct stat before, after; + + if (creat (f, 0600) < 0) + return 1; + if (stat (f, &before) < 0) + return 1; + if (chown (f, (uid_t) -1, (gid_t) -1) == -1) + return 1; + if (stat (f, &after) < 0) + return 1; + return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); + ]]) + ], + [ac_cv_func_chown_works=yes], + [ac_cv_func_chown_works=no], + [case "$host_os" in # (( + # Guess yes on glibc systems. + *-gnu*) ac_cv_func_chown_works=yes ;; + # If we don't know, assume the worst. + *) ac_cv_func_chown_works=no ;; + esac + ]) + rm -f conftest.chown + ]) + if test $ac_cv_func_chown_works = yes; then + AC_DEFINE([HAVE_CHOWN], [1], + [Define to 1 if your system has a working `chown' function.]) + fi +])# AC_FUNC_CHOWN + +]) + +AC_DEFUN_ONCE([gl_FUNC_CHOWN], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_TYPE_UID_T]) + AC_REQUIRE([AC_FUNC_CHOWN]) + AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([chown fchown]) + + dnl mingw lacks chown altogether. + if test $ac_cv_func_chown = no; then + HAVE_CHOWN=0 + else + dnl Some old systems treated chown like lchown. + if test $gl_cv_func_chown_follows_symlink = no; then + REPLACE_CHOWN=1 + fi + + dnl Some old systems tried to use uid/gid -1 literally. + if test $ac_cv_func_chown_works = no; then + AC_DEFINE([CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE], [1], + [Define if chown is not POSIX compliant regarding IDs of -1.]) + REPLACE_CHOWN=1 + fi + + dnl Solaris 9 ignores trailing slash. + dnl FreeBSD 7.2 mishandles trailing slash on symlinks. + dnl Likewise for AIX 7.1. + AC_CACHE_CHECK([whether chown honors trailing slash], + [gl_cv_func_chown_slash_works], + [touch conftest.file && rm -f conftest.link + AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +]], [[ if (symlink ("conftest.file", "conftest.link")) return 1; + if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2; + ]])], + [gl_cv_func_chown_slash_works=yes], + [gl_cv_func_chown_slash_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_chown_slash_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_chown_slash_works="guessing no" ;; + esac + ]) + rm -f conftest.link conftest.file]) + case "$gl_cv_func_chown_slash_works" in + *yes) ;; + *) + AC_DEFINE([CHOWN_TRAILING_SLASH_BUG], [1], + [Define to 1 if chown mishandles trailing slash.]) + REPLACE_CHOWN=1 + ;; + esac + + dnl OpenBSD fails to update ctime if ownership does not change. + AC_CACHE_CHECK([whether chown always updates ctime], + [gl_cv_func_chown_ctime_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +#include +#include +#include +]], [[ struct stat st1, st2; + if (close (creat ("conftest.file", 0600))) return 1; + if (stat ("conftest.file", &st1)) return 2; + sleep (1); + if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3; + if (stat ("conftest.file", &st2)) return 4; + if (st2.st_ctime <= st1.st_ctime) return 5; + ]])], + [gl_cv_func_chown_ctime_works=yes], + [gl_cv_func_chown_ctime_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_chown_ctime_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_chown_ctime_works="guessing no" ;; + esac + ]) + rm -f conftest.file]) + case "$gl_cv_func_chown_ctime_works" in + *yes) ;; + *) + AC_DEFINE([CHOWN_CHANGE_TIME_BUG], [1], [Define to 1 if chown fails + to change ctime when at least one argument was not -1.]) + REPLACE_CHOWN=1 + ;; + esac + fi +]) + +# Determine whether chown follows symlinks (it should). +AC_DEFUN_ONCE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK], +[ + AC_CACHE_CHECK( + [whether chown dereferences symlinks], + [gl_cv_func_chown_follows_symlink], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include + + int + main () + { + int result = 0; + char const *dangling_symlink = "conftest.dangle"; + + unlink (dangling_symlink); + if (symlink ("conftest.no-such", dangling_symlink)) + abort (); + + /* Exit successfully on a conforming system, + i.e., where chown must fail with ENOENT. */ + if (chown (dangling_symlink, getuid (), getgid ()) == 0) + result |= 1; + if (errno != ENOENT) + result |= 2; + return result; + } + ]])], + [gl_cv_func_chown_follows_symlink=yes], + [gl_cv_func_chown_follows_symlink=no], + [gl_cv_func_chown_follows_symlink=yes] + ) + ] + ) + + if test $gl_cv_func_chown_follows_symlink = no; then + AC_DEFINE([CHOWN_MODIFIES_SYMLINK], [1], + [Define if chown modifies symlinks.]) + fi +]) diff --git a/m4/clock_time.m4 b/m4/clock_time.m4 index 6c4a637..a903e58 100644 --- a/m4/clock_time.m4 +++ b/m4/clock_time.m4 @@ -1,5 +1,5 @@ # clock_time.m4 serial 10 -dnl Copyright (C) 2002-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/close.m4 b/m4/close.m4 index 68510c5..d04aefb 100644 --- a/m4/close.m4 +++ b/m4/close.m4 @@ -1,5 +1,5 @@ # close.m4 serial 8 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/closedir.m4 b/m4/closedir.m4 index d234a52..a4403b4 100644 --- a/m4/closedir.m4 +++ b/m4/closedir.m4 @@ -1,5 +1,5 @@ # closedir.m4 serial 2 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/codeset.m4 b/m4/codeset.m4 index d7de8d6..1c52ffc 100644 --- a/m4/codeset.m4 +++ b/m4/codeset.m4 @@ -1,5 +1,5 @@ # codeset.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2000-2002, 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2000-2002, 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/configmake.m4 b/m4/configmake.m4 index 0cd86cf..49d3a13 100644 --- a/m4/configmake.m4 +++ b/m4/configmake.m4 @@ -1,5 +1,5 @@ # configmake.m4 serial 2 -dnl Copyright (C) 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/d-ino.m4 b/m4/d-ino.m4 index 5ccb733..aa9b243 100644 --- a/m4/d-ino.m4 +++ b/m4/d-ino.m4 @@ -5,7 +5,7 @@ dnl dnl Check whether struct dirent has a member named d_ino. dnl -# Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-2014 Free Software +# Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-2015 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation diff --git a/m4/dirent-safer.m4 b/m4/dirent-safer.m4 index 0a197fb..2009575 100644 --- a/m4/dirent-safer.m4 +++ b/m4/dirent-safer.m4 @@ -1,5 +1,5 @@ #serial 2 -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4 index 3f2b16b..7abd1d0 100644 --- a/m4/dirent_h.m4 +++ b/m4/dirent_h.m4 @@ -1,5 +1,5 @@ # dirent_h.m4 serial 16 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 index b422769..ce56cff 100644 --- a/m4/dirfd.m4 +++ b/m4/dirfd.m4 @@ -2,7 +2,7 @@ dnl Find out how to get the file descriptor associated with an open DIR*. -# Copyright (C) 2001-2006, 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2006, 2008-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/dirname.m4 b/m4/dirname.m4 index d2627b8..2a0be51 100644 --- a/m4/dirname.m4 +++ b/m4/dirname.m4 @@ -1,5 +1,5 @@ #serial 10 -*- autoconf -*- -dnl Copyright (C) 2002-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/double-slash-root.m4 b/m4/double-slash-root.m4 index 937f4bc..f307eb2 100644 --- a/m4/double-slash-root.m4 +++ b/m4/double-slash-root.m4 @@ -1,5 +1,5 @@ # double-slash-root.m4 serial 4 -*- Autoconf -*- -dnl Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 6498fc2..0354c6a 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,5 +1,5 @@ #serial 20 -dnl Copyright (C) 2002, 2005, 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005, 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/eealloc.m4 b/m4/eealloc.m4 index 8a51fe7..322bdd5 100644 --- a/m4/eealloc.m4 +++ b/m4/eealloc.m4 @@ -1,5 +1,5 @@ # eealloc.m4 serial 3 -dnl Copyright (C) 2003, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/environ.m4 b/m4/environ.m4 index cfabe46..4dbf947 100644 --- a/m4/environ.m4 +++ b/m4/environ.m4 @@ -1,5 +1,5 @@ # environ.m4 serial 6 -dnl Copyright (C) 2001-2004, 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2004, 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/errno_h.m4 b/m4/errno_h.m4 index 4ee9e6a..cfaa687 100644 --- a/m4/errno_h.m4 +++ b/m4/errno_h.m4 @@ -1,5 +1,5 @@ # errno_h.m4 serial 12 -dnl Copyright (C) 2004, 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2004, 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/error.m4 b/m4/error.m4 index f08ae50..b3bd7f6 100644 --- a/m4/error.m4 +++ b/m4/error.m4 @@ -1,6 +1,6 @@ #serial 14 -# Copyright (C) 1996-1998, 2001-2004, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-1998, 2001-2004, 2009-2015 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/exponentd.m4 b/m4/exponentd.m4 index 7bee635..84f1691 100644 --- a/m4/exponentd.m4 +++ b/m4/exponentd.m4 @@ -1,5 +1,5 @@ # exponentd.m4 serial 3 -dnl Copyright (C) 2007-2008, 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2008, 2010-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/extensions.m4 b/m4/extensions.m4 index 37f55ca..35bc49c 100644 --- a/m4/extensions.m4 +++ b/m4/extensions.m4 @@ -1,7 +1,7 @@ # serial 13 -*- Autoconf -*- # Enable extensions on systems that normally disable them. -# Copyright (C) 2003, 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2003, 2006-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -68,6 +68,10 @@ dnl configure.ac when using autoheader 2.62. #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif +/* Use GNU style printf and scanf. */ +#ifndef __USE_MINGW_ANSI_STDIO +# undef __USE_MINGW_ANSI_STDIO +#endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS @@ -100,6 +104,7 @@ dnl configure.ac when using autoheader 2.62. AC_DEFINE([_ALL_SOURCE]) AC_DEFINE([_DARWIN_C_SOURCE]) AC_DEFINE([_GNU_SOURCE]) + AC_DEFINE([__USE_MINGW_ANSI_STDIO]) AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) AC_DEFINE([_TANDEM_SOURCE]) AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index 0edbe3c..e74339a 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -1,6 +1,6 @@ dnl 'extern inline' a la ISO C99. -dnl Copyright 2012-2014 Free Software Foundation, Inc. +dnl Copyright 2012-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/fchdir.m4 b/m4/fchdir.m4 new file mode 100644 index 0000000..3d2d97b --- /dev/null +++ b/m4/fchdir.m4 @@ -0,0 +1,61 @@ +# fchdir.m4 serial 21 +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_FCHDIR], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + AC_CHECK_DECLS_ONCE([fchdir]) + if test $ac_cv_have_decl_fchdir = no; then + HAVE_DECL_FCHDIR=0 + fi + + AC_REQUIRE([gl_TEST_FCHDIR]) + if test $HAVE_FCHDIR = 0; then + AC_LIBOBJ([fchdir]) + gl_PREREQ_FCHDIR + AC_DEFINE([REPLACE_FCHDIR], [1], + [Define to 1 if gnulib's fchdir() replacement is used.]) + dnl We must also replace anything that can manipulate a directory fd, + dnl to keep our bookkeeping up-to-date. We don't have to replace + dnl fstatat, since no platform has fstatat but lacks fchdir. + AC_CACHE_CHECK([whether open can visit directories], + [gl_cv_func_open_directory_works], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include +]], [return open(".", O_RDONLY) < 0;])], + [gl_cv_func_open_directory_works=yes], + [gl_cv_func_open_directory_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_open_directory_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_open_directory_works="guessing no" ;; + esac + ])]) + case "$gl_cv_func_open_directory_works" in + *yes) ;; + *) + AC_DEFINE([REPLACE_OPEN_DIRECTORY], [1], [Define to 1 if open() should +work around the inability to open a directory.]) + ;; + esac + fi +]) + +# Determine whether to use the overrides in lib/fchdir.c. +AC_DEFUN([gl_TEST_FCHDIR], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([fchdir]) + if test $ac_cv_func_fchdir = no; then + HAVE_FCHDIR=0 + fi +]) + +# Prerequisites of lib/fchdir.c. +AC_DEFUN([gl_PREREQ_FCHDIR], [:]) diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4 new file mode 100644 index 0000000..b64ff5f --- /dev/null +++ b/m4/fchmodat.m4 @@ -0,0 +1,17 @@ +# fchmodat.m4 serial 1 +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_FCHMODAT], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([fchmodat lchmod]) + if test $ac_cv_func_fchmodat != yes; then + HAVE_FCHMODAT=0 + fi +]) diff --git a/m4/fchownat.m4 b/m4/fchownat.m4 new file mode 100644 index 0000000..f55d2d5 --- /dev/null +++ b/m4/fchownat.m4 @@ -0,0 +1,108 @@ +# fchownat.m4 serial 1 +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +# If we have the fchownat function, and it has the bug (in glibc-2.4) +# that it dereferences symlinks even with AT_SYMLINK_NOFOLLOW, then +# use the replacement function. +# Also if the fchownat function, like chown, has the trailing slash bug, +# use the replacement function. +# Also use the replacement function if fchownat is simply not available. +AC_DEFUN([gl_FUNC_FCHOWNAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_FUNC_CHOWN]) + AC_CHECK_FUNC([fchownat], + [gl_FUNC_FCHOWNAT_DEREF_BUG( + [REPLACE_FCHOWNAT=1 + AC_DEFINE([FCHOWNAT_NOFOLLOW_BUG], [1], + [Define to 1 if your platform has fchownat, but it cannot + perform lchown tasks.]) + ]) + gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG( + [REPLACE_FCHOWNAT=1 + AC_DEFINE([FCHOWNAT_EMPTY_FILENAME_BUG], [1], + [Define to 1 if your platform has fchownat, but it does + not reject an empty file name.]) + ]) + if test $REPLACE_CHOWN = 1; then + REPLACE_FCHOWNAT=1 + fi], + [HAVE_FCHOWNAT=0]) +]) + +# gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]]) +AC_DEFUN([gl_FUNC_FCHOWNAT_DEREF_BUG], +[ + dnl Persuade glibc's to declare fchownat(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_CACHE_CHECK([whether fchownat works with AT_SYMLINK_NOFOLLOW], + gl_cv_func_fchownat_nofollow_works, + [ + gl_dangle=conftest.dangle + # Remove any remnants of a previous test. + rm -f $gl_dangle + # Arrange for deletion of the temporary file this test creates. + ac_clean_files="$ac_clean_files $gl_dangle" + ln -s conftest.no-such $gl_dangle + AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[ +#include +#include +#include +#include +#include +int +main () +{ + return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (), + AT_SYMLINK_NOFOLLOW) != 0 + && errno == ENOENT); +} + ]])], + [gl_cv_func_fchownat_nofollow_works=yes], + [gl_cv_func_fchownat_nofollow_works=no], + [gl_cv_func_fchownat_nofollow_works=no], + ) + ]) + AS_IF([test $gl_cv_func_fchownat_nofollow_works = no], [$1], [$2]) +]) + +# gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]]) +AC_DEFUN([gl_FUNC_FCHOWNAT_EMPTY_FILENAME_BUG], +[ + dnl Persuade glibc's to declare fchownat(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_CACHE_CHECK([whether fchownat works with an empty file name], + [gl_cv_func_fchownat_empty_filename_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[int fd; + int ret; + if (mkdir ("conftestdir", 0700) < 0) + return 2; + fd = open ("conftestdir", O_RDONLY); + if (fd < 0) + return 3; + ret = fchownat (fd, "", -1, -1, 0); + close (fd); + rmdir ("conftestdir"); + return ret == 0; + ]])], + [gl_cv_func_fchownat_empty_filename_works=yes], + [gl_cv_func_fchownat_empty_filename_works=no], + [gl_cv_func_fchownat_empty_filename_works="guessing no"]) + ]) + AS_IF([test "$gl_cv_func_fchownat_empty_filename_works" != yes], [$1], [$2]) +]) diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4 index 43c9312..891a62f 100644 --- a/m4/fcntl-o.m4 +++ b/m4/fcntl-o.m4 @@ -1,5 +1,5 @@ # fcntl-o.m4 serial 4 -dnl Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/fcntl.m4 b/m4/fcntl.m4 index f824beb..733cd2d 100644 --- a/m4/fcntl.m4 +++ b/m4/fcntl.m4 @@ -1,5 +1,5 @@ # fcntl.m4 serial 5 -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4 index fb2556d..b279162 100644 --- a/m4/fcntl_h.m4 +++ b/m4/fcntl_h.m4 @@ -1,6 +1,6 @@ # serial 15 # Configure fcntl.h. -dnl Copyright (C) 2006-2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/filenamecat.m4 b/m4/filenamecat.m4 new file mode 100644 index 0000000..bedb58d --- /dev/null +++ b/m4/filenamecat.m4 @@ -0,0 +1,16 @@ +# filenamecat.m4 serial 11 +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FILE_NAME_CONCAT], +[ + AC_REQUIRE([gl_FILE_NAME_CONCAT_LGPL]) +]) + +AC_DEFUN([gl_FILE_NAME_CONCAT_LGPL], +[ + dnl Prerequisites of lib/filenamecat-lgpl.c. + AC_CHECK_FUNCS_ONCE([mempcpy]) +]) diff --git a/m4/float_h.m4 b/m4/float_h.m4 index a27ef7f..e4853f3 100644 --- a/m4/float_h.m4 +++ b/m4/float_h.m4 @@ -1,5 +1,5 @@ # float_h.m4 serial 9 -dnl Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/fstat.m4 b/m4/fstat.m4 index ddd3fb9..d6a9288 100644 --- a/m4/fstat.m4 +++ b/m4/fstat.m4 @@ -1,5 +1,5 @@ # fstat.m4 serial 4 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/fstatat.m4 b/m4/fstatat.m4 new file mode 100644 index 0000000..e5f9f90 --- /dev/null +++ b/m4/fstatat.m4 @@ -0,0 +1,60 @@ +# fstatat.m4 serial 3 +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +# If we have the fstatat function, and it has the bug (in AIX 7.1) +# that it does not fill in st_size correctly, use the replacement function. +AC_DEFUN([gl_FUNC_FSTATAT], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_FUNCS_ONCE([fstatat]) + + if test $ac_cv_func_fstatat = no; then + HAVE_FSTATAT=0 + else + dnl Test for an AIX 7.1 bug; see + dnl . + AC_CACHE_CHECK([whether fstatat (..., 0) works], + [gl_cv_func_fstatat_zero_flag], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[ + #include + #include + int + main (void) + { + struct stat a; + return fstatat (AT_FDCWD, ".", &a, 0) != 0; + } + ]])], + [gl_cv_func_fstatat_zero_flag=yes], + [gl_cv_func_fstatat_zero_flag=no], + [case "$host_os" in + aix*) gl_cv_func_fstatat_zero_flag="guessing no";; + *) gl_cv_func_fstatat_zero_flag="guessing yes";; + esac + ]) + ]) + + case $gl_cv_func_fstatat_zero_flag+$gl_cv_func_lstat_dereferences_slashed_symlink in + *yes+*yes) ;; + *) REPLACE_FSTATAT=1 + case $gl_cv_func_fstatat_zero_flag in + *yes) + AC_DEFINE([HAVE_WORKING_FSTATAT_ZERO_FLAG], [1], + [Define to 1 if fstatat (..., 0) works. + For example, it does not work in AIX 7.1.]) + ;; + esac + ;; + esac + fi +]) diff --git a/m4/getcwd.m4 b/m4/getcwd.m4 new file mode 100644 index 0000000..b9fbcec --- /dev/null +++ b/m4/getcwd.m4 @@ -0,0 +1,160 @@ +# getcwd.m4 - check for working getcwd that is compatible with glibc + +# Copyright (C) 2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Written by Paul Eggert. +# serial 12 + +AC_DEFUN([gl_FUNC_GETCWD_NULL], + [ + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CHECK_HEADERS_ONCE([unistd.h]) + AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result], + [gl_cv_func_getcwd_null], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +# if HAVE_UNISTD_H +# include +# else /* on Windows with MSVC */ +# include +# endif +# ifndef getcwd + char *getcwd (); +# endif +]], [[ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +/* mingw cwd does not start with '/', but getcwd does allocate. + However, mingw fails to honor non-zero size. */ +#else + if (chdir ("/") != 0) + return 1; + else + { + char *f = getcwd (NULL, 0); + if (! f) + return 2; + if (f[0] != '/') + return 3; + if (f[1] != '\0') + return 4; + return 0; + } +#endif + ]])], + [gl_cv_func_getcwd_null=yes], + [gl_cv_func_getcwd_null=no], + [[case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_getcwd_null="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_getcwd_null="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_getcwd_null="guessing no";; + esac + ]])]) +]) + +AC_DEFUN([gl_FUNC_GETCWD_SIGNATURE], +[ + AC_CACHE_CHECK([for getcwd with POSIX signature], + [gl_cv_func_getcwd_posix_signature], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[extern + #ifdef __cplusplus + "C" + #endif + char *getcwd (char *, size_t); + ]]) + ], + [gl_cv_func_getcwd_posix_signature=yes], + [gl_cv_func_getcwd_posix_signature=no]) + ]) +]) + +dnl Guarantee that getcwd will malloc with a NULL first argument. Assumes +dnl that either the system getcwd is robust, or that calling code is okay +dnl with spurious failures when run from a directory with an absolute name +dnl larger than 4k bytes. +dnl +dnl Assumes that getcwd exists; if you are worried about obsolete +dnl platforms that lacked getcwd(), then you need to use the GPL module. +AC_DEFUN([gl_FUNC_GETCWD_LGPL], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETCWD_NULL]) + AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE]) + + case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_posix_signature in + *yes,yes) ;; + *) + dnl Minimal replacement lib/getcwd-lgpl.c. + REPLACE_GETCWD=1 + ;; + esac +]) + +dnl Check for all known getcwd bugs; useful for a program likely to be +dnl executed from an arbitrary location. +AC_DEFUN([gl_FUNC_GETCWD], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_GETCWD_NULL]) + AC_REQUIRE([gl_FUNC_GETCWD_SIGNATURE]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + gl_abort_bug=no + case "$host_os" in + mingw*) + gl_cv_func_getcwd_path_max=yes + ;; + *) + gl_FUNC_GETCWD_PATH_MAX + case "$gl_cv_func_getcwd_null" in + *yes) + gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]) + ;; + esac + ;; + esac + dnl Define HAVE_MINIMALLY_WORKING_GETCWD and HAVE_PARTLY_WORKING_GETCWD + dnl if appropriate. + case "$gl_cv_func_getcwd_path_max" in + "no"|"no, it has the AIX bug") ;; + *) + AC_DEFINE([HAVE_MINIMALLY_WORKING_GETCWD], [1], + [Define to 1 if getcwd minimally works, that is, its result can be + trusted when it succeeds.]) + ;; + esac + case "$gl_cv_func_getcwd_path_max" in + "no, but it is partly working") + AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], [1], + [Define to 1 if getcwd works, except it sometimes fails when it + shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT.]) + ;; + "yes, but with shorter paths") + AC_DEFINE([HAVE_GETCWD_SHORTER], [1], + [Define to 1 if getcwd works, but with shorter paths + than is generally tested with the replacement.]) + ;; + esac + + if { case "$gl_cv_func_getcwd_null" in *yes) false;; *) true;; esac; } \ + || test $gl_cv_func_getcwd_posix_signature != yes \ + || { case "$gl_cv_func_getcwd_path_max" in *yes*) false;; *) true;; esac; } \ + || test $gl_abort_bug = yes; then + REPLACE_GETCWD=1 + fi +]) + +# Prerequisites of lib/getcwd.c, when full replacement is in effect. +AC_DEFUN([gl_PREREQ_GETCWD], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO]) + : +]) diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index aa523b6..a6b6c1b 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -1,5 +1,5 @@ # getdtablesize.m4 serial 5 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/getopt.m4 b/m4/getopt.m4 index f127028..e76e501 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -1,5 +1,5 @@ # getopt.m4 serial 44 -dnl Copyright (C) 2002-2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/gettime.m4 b/m4/gettime.m4 index c5ec264..cd499ff 100644 --- a/m4/gettime.m4 +++ b/m4/gettime.m4 @@ -1,5 +1,5 @@ # gettime.m4 serial 8 -dnl Copyright (C) 2002, 2004-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2004-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4 index 1c2d66e..ce246e1 100644 --- a/m4/gettimeofday.m4 +++ b/m4/gettimeofday.m4 @@ -1,6 +1,6 @@ # serial 21 -# Copyright (C) 2001-2003, 2005, 2007, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2003, 2005, 2007, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 index ab58b71..3a971c5 100644 --- a/m4/glibc21.m4 +++ b/m4/glibc21.m4 @@ -1,5 +1,5 @@ # glibc21.m4 serial 5 -dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2014 Free Software Foundation, +dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 31e5f94..b301abe 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,5 +1,5 @@ # gnulib-common.m4 serial 36 -dnl Copyright (C) 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 0aa4db8..00de6ad 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -1,5 +1,5 @@ # DO NOT EDIT! GENERATED AUTOMATICALLY! -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 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 @@ -41,6 +41,8 @@ AC_DEFUN([gl_EARLY], # Code from module absolute-header: # Code from module alloca-opt: # Code from module argmatch: + # Code from module assure: + # Code from module at-internal: # Code from module backupfile: # Code from module bitrotate: # Code from module c-ctype: @@ -48,7 +50,10 @@ AC_DEFUN([gl_EARLY], # Code from module c-strcaseeq: # Code from module canonicalize-lgpl: # Code from module chdir: + # Code from module chdir-long: + # Code from module chown: # Code from module clock-time: + # Code from module cloexec: # Code from module close: # Code from module closedir: # Code from module configmake: @@ -69,13 +74,19 @@ AC_DEFUN([gl_EARLY], # Code from module extensions: AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) # Code from module extern-inline: + # Code from module fchdir: + # Code from module fchmodat: + # Code from module fchownat: # Code from module fcntl: # Code from module fcntl-h: # Code from module fd-hook: # Code from module filename: + # Code from module filenamecat-lgpl: # Code from module float: # Code from module fstat: + # Code from module fstatat: # Code from module full-write: + # Code from module getcwd-lgpl: # Code from module getdate: # Code from module getdtablesize: # Code from module getopt-gnu: @@ -92,7 +103,7 @@ AC_DEFUN([gl_EARLY], # Code from module intprops: # Code from module largefile: AC_REQUIRE([AC_SYS_LARGEFILE]) - # Code from module lchmod: + # Code from module lchown: # Code from module linked-list: # Code from module list: # Code from module localcharset: @@ -106,13 +117,20 @@ AC_DEFUN([gl_EARLY], # Code from module mbrtowc: # Code from module mbsinit: # Code from module memchr: + # Code from module mempcpy: + # Code from module memrchr: # Code from module minmax: # Code from module mkdir: + # Code from module mkdirat: # Code from module mktime: # Code from module msvc-inval: # Code from module msvc-nothrow: # Code from module multiarch: # Code from module nocrash: + # Code from module open: + # Code from module openat: + # Code from module openat-die: + # Code from module openat-h: # Code from module opendir: # Code from module parse-datetime: # Code from module pathmax: @@ -123,13 +141,16 @@ AC_DEFUN([gl_EARLY], # Code from module raise: # Code from module readdir: # Code from module readlink: + # Code from module readlinkat: # Code from module realloc: # Code from module realloc-gnu: # Code from module realloc-posix: # Code from module rename: + # Code from module renameat: # Code from module rmdir: # Code from module safe-write: # Code from module same-inode: + # Code from module save-cwd: # Code from module secure_getenv: # Code from module setenv: # Code from module signal: @@ -142,6 +163,7 @@ AC_DEFUN([gl_EARLY], # Code from module ssize_t: # Code from module stat: # Code from module stat-time: + # Code from module statat: # Code from module stdarg: dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode dnl for the builtin va_copy to work. With Autoconf 2.60 or later, @@ -153,6 +175,7 @@ AC_DEFUN([gl_EARLY], # Code from module stdint: # Code from module stdio: # Code from module stdlib: + # Code from module strdup-posix: # Code from module streq: # Code from module strerror: # Code from module strerror-override: @@ -160,6 +183,7 @@ AC_DEFUN([gl_EARLY], # Code from module strndup: # Code from module strnlen: # Code from module symlink: + # Code from module symlinkat: # Code from module sys_stat: # Code from module sys_time: # Code from module sys_types: @@ -170,10 +194,12 @@ AC_DEFUN([gl_EARLY], # Code from module unistd: # Code from module unistd-safer: # Code from module unlink: + # Code from module unlinkat: # Code from module unsetenv: # Code from module update-copyright: # Code from module useless-if-before-free: # Code from module utimens: + # Code from module utimensat: # Code from module vasnprintf: # Code from module vasprintf: # Code from module vc-list-files: @@ -210,6 +236,7 @@ AC_DEFUN([gl_INIT], gl_COMMON gl_source_base='lib' gl_FUNC_ALLOCA + AC_LIBOBJ([openat-proc]) gl_BACKUPFILE gl_CANONICALIZE_LGPL if test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1; then @@ -219,7 +246,21 @@ AC_DEFUN([gl_INIT], gl_STDLIB_MODULE_INDICATOR([canonicalize_file_name]) gl_STDLIB_MODULE_INDICATOR([realpath]) gl_UNISTD_MODULE_INDICATOR([chdir]) + gl_FUNC_CHDIR_LONG + if test $gl_cv_have_arbitrary_file_name_length_limit = yes; then + AC_LIBOBJ([chdir-long]) + gl_PREREQ_CHDIR_LONG + fi + gl_FUNC_CHOWN + if test $HAVE_CHOWN = 0 || test $REPLACE_CHOWN = 1; then + AC_LIBOBJ([chown]) + fi + if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then + AC_LIBOBJ([fchown-stub]) + fi + gl_UNISTD_MODULE_INDICATOR([chown]) gl_CLOCK_TIME + gl_MODULE_INDICATOR_FOR_TESTS([cloexec]) gl_FUNC_CLOSE if test $REPLACE_CLOSE = 1; then AC_LIBOBJ([close]) @@ -263,12 +304,27 @@ AC_DEFUN([gl_INIT], [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) AC_REQUIRE([gl_EXTERN_INLINE]) + gl_FUNC_FCHDIR + gl_UNISTD_MODULE_INDICATOR([fchdir]) + gl_FUNC_FCHMODAT + if test $HAVE_FCHMODAT = 0; then + AC_LIBOBJ([fchmodat]) + fi + gl_MODULE_INDICATOR([fchmodat]) dnl for lib/openat.h + gl_SYS_STAT_MODULE_INDICATOR([fchmodat]) + gl_FUNC_FCHOWNAT + if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then + AC_LIBOBJ([fchownat]) + fi + gl_MODULE_INDICATOR([fchownat]) dnl for lib/openat.h + gl_UNISTD_MODULE_INDICATOR([fchownat]) gl_FUNC_FCNTL if test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1; then AC_LIBOBJ([fcntl]) fi gl_FCNTL_MODULE_INDICATOR([fcntl]) gl_FCNTL_H + gl_FILE_NAME_CONCAT_LGPL gl_FLOAT_H if test $REPLACE_FLOAT_LDBL = 1; then AC_LIBOBJ([float]) @@ -282,6 +338,16 @@ AC_DEFUN([gl_INIT], gl_PREREQ_FSTAT fi gl_SYS_STAT_MODULE_INDICATOR([fstat]) + gl_FUNC_FSTATAT + if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then + AC_LIBOBJ([fstatat]) + fi + gl_SYS_STAT_MODULE_INDICATOR([fstatat]) + gl_FUNC_GETCWD_LGPL + if test $REPLACE_GETCWD = 1; then + AC_LIBOBJ([getcwd-lgpl]) + fi + gl_UNISTD_MODULE_INDICATOR([getcwd]) gl_FUNC_GETDTABLESIZE if test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1; then AC_LIBOBJ([getdtablesize]) @@ -327,8 +393,11 @@ AC_DEFUN([gl_INIT], [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [], [GNUmakefile=$GNUmakefile])]) AC_REQUIRE([gl_LARGEFILE]) - gl_FUNC_LCHMOD - gl_SYS_STAT_MODULE_INDICATOR([lchmod]) + gl_FUNC_LCHOWN + if test $HAVE_LCHOWN = 0 || test $REPLACE_LCHOWN = 1; then + AC_LIBOBJ([lchown]) + fi + gl_UNISTD_MODULE_INDICATOR([lchown]) gl_LOCALCHARSET LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) @@ -370,11 +439,29 @@ AC_DEFUN([gl_INIT], gl_PREREQ_MEMCHR fi gl_STRING_MODULE_INDICATOR([memchr]) + gl_FUNC_MEMPCPY + if test $HAVE_MEMPCPY = 0; then + AC_LIBOBJ([mempcpy]) + gl_PREREQ_MEMPCPY + fi + gl_STRING_MODULE_INDICATOR([mempcpy]) + gl_FUNC_MEMRCHR + if test $ac_cv_func_memrchr = no; then + AC_LIBOBJ([memrchr]) + gl_PREREQ_MEMRCHR + fi + gl_STRING_MODULE_INDICATOR([memrchr]) gl_MINMAX gl_FUNC_MKDIR if test $REPLACE_MKDIR = 1; then AC_LIBOBJ([mkdir]) fi + gl_FUNC_MKDIRAT + if test $HAVE_MKDIRAT = 0; then + AC_LIBOBJ([mkdirat]) + gl_PREREQ_MKDIRAT + fi + gl_SYS_STAT_MODULE_INDICATOR([mkdirat]) gl_FUNC_MKTIME if test $REPLACE_MKTIME = 1; then AC_LIBOBJ([mktime]) @@ -390,6 +477,19 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([msvc-nothrow]) fi gl_MULTIARCH + gl_FUNC_OPEN + if test $REPLACE_OPEN = 1; then + AC_LIBOBJ([open]) + gl_PREREQ_OPEN + fi + gl_FCNTL_MODULE_INDICATOR([open]) + gl_FUNC_OPENAT + if test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1; then + AC_LIBOBJ([openat]) + gl_PREREQ_OPENAT + fi + gl_MODULE_INDICATOR([openat]) dnl for lib/getcwd.c + gl_FCNTL_MODULE_INDICATOR([openat]) gl_FUNC_OPENDIR if test $HAVE_OPENDIR = 0 || test $REPLACE_OPENDIR = 1; then AC_LIBOBJ([opendir]) @@ -418,6 +518,11 @@ AC_DEFUN([gl_INIT], gl_PREREQ_READLINK fi gl_UNISTD_MODULE_INDICATOR([readlink]) + gl_FUNC_READLINKAT + if test $HAVE_READLINKAT = 0 || test $REPLACE_READLINKAT = 1; then + AC_LIBOBJ([readlinkat]) + fi + gl_UNISTD_MODULE_INDICATOR([readlinkat]) gl_FUNC_REALLOC_GNU if test $REPLACE_REALLOC = 1; then AC_LIBOBJ([realloc]) @@ -433,12 +538,21 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([rename]) fi gl_STDIO_MODULE_INDICATOR([rename]) + gl_FUNC_RENAMEAT + if test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1; then + AC_LIBOBJ([renameat]) + fi + if test $HAVE_RENAMEAT = 0; then + AC_LIBOBJ([at-func2]) + fi + gl_STDIO_MODULE_INDICATOR([renameat]) gl_FUNC_RMDIR if test $REPLACE_RMDIR = 1; then AC_LIBOBJ([rmdir]) fi gl_UNISTD_MODULE_INDICATOR([rmdir]) gl_PREREQ_SAFE_WRITE + gl_SAVE_CWD gl_FUNC_SECURE_GETENV if test $HAVE_SECURE_GETENV = 0; then AC_LIBOBJ([secure_getenv]) @@ -461,12 +575,19 @@ AC_DEFUN([gl_INIT], gl_SYS_STAT_MODULE_INDICATOR([stat]) gl_STAT_TIME gl_STAT_BIRTHTIME + gl_MODULE_INDICATOR([statat]) dnl for lib/openat.h gl_STDARG_H AM_STDBOOL_H gl_STDDEF_H gl_STDINT_H gl_STDIO_H gl_STDLIB_H + gl_FUNC_STRDUP_POSIX + if test $ac_cv_func_strdup = no || test $REPLACE_STRDUP = 1; then + AC_LIBOBJ([strdup]) + gl_PREREQ_STRDUP + fi + gl_STRING_MODULE_INDICATOR([strdup]) gl_FUNC_STRERROR if test $REPLACE_STRERROR = 1; then AC_LIBOBJ([strerror]) @@ -496,6 +617,11 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([symlink]) fi gl_UNISTD_MODULE_INDICATOR([symlink]) + gl_FUNC_SYMLINKAT + if test $HAVE_SYMLINKAT = 0 || test $REPLACE_SYMLINKAT = 1; then + AC_LIBOBJ([symlinkat]) + fi + gl_UNISTD_MODULE_INDICATOR([symlinkat]) gl_HEADER_SYS_STAT_H AC_PROG_MKDIR_P gl_HEADER_SYS_TIME_H @@ -518,6 +644,11 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([unlink]) fi gl_UNISTD_MODULE_INDICATOR([unlink]) + gl_FUNC_UNLINKAT + if test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1; then + AC_LIBOBJ([unlinkat]) + fi + gl_UNISTD_MODULE_INDICATOR([unlinkat]) gl_FUNC_UNSETENV if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then AC_LIBOBJ([unsetenv]) @@ -525,6 +656,11 @@ AC_DEFUN([gl_INIT], fi gl_STDLIB_MODULE_INDICATOR([unsetenv]) gl_UTIMENS + gl_FUNC_UTIMENSAT + if test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1; then + AC_LIBOBJ([utimensat]) + fi + gl_SYS_STAT_MODULE_INDICATOR([utimensat]) gl_FUNC_VASNPRINTF gl_FUNC_VASPRINTF gl_STDIO_MODULE_INDICATOR([vasprintf]) @@ -705,6 +841,9 @@ AC_DEFUN([gl_FILE_LIST], [ lib/argmatch.h lib/asnprintf.c lib/asprintf.c + lib/assure.h + lib/at-func.c + lib/at-func2.c lib/backupfile.c lib/backupfile.h lib/basename-lgpl.c @@ -718,6 +857,13 @@ AC_DEFUN([gl_FILE_LIST], [ lib/c-strcaseeq.h lib/c-strncasecmp.c lib/canonicalize-lgpl.c + lib/chdir-long.c + lib/chdir-long.h + lib/chmodat.c + lib/chown.c + lib/chownat.c + lib/cloexec.c + lib/cloexec.h lib/close.c lib/closedir.c lib/config.charset @@ -738,18 +884,26 @@ AC_DEFUN([gl_FILE_LIST], [ lib/error.h lib/exitfail.c lib/exitfail.h + lib/fchdir.c + lib/fchmodat.c + lib/fchown-stub.c + lib/fchownat.c lib/fcntl.c lib/fcntl.in.h lib/fd-hook.c lib/fd-hook.h lib/fd-safer.c lib/filename.h + lib/filenamecat-lgpl.c + lib/filenamecat.h lib/float+.h lib/float.c lib/float.in.h lib/fstat.c + lib/fstatat.c lib/full-write.c lib/full-write.h + lib/getcwd-lgpl.c lib/getdate.h lib/getdtablesize.c lib/getopt.c @@ -772,6 +926,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/ignore-value.h lib/intprops.h lib/itold.c + lib/lchown.c lib/localcharset.c lib/localcharset.h lib/lstat.c @@ -783,14 +938,23 @@ AC_DEFUN([gl_FILE_LIST], [ lib/mbsinit.c lib/memchr.c lib/memchr.valgrind + lib/mempcpy.c + lib/memrchr.c lib/minmax.h lib/mkdir.c + lib/mkdirat.c lib/mktime-internal.h lib/mktime.c lib/msvc-inval.c lib/msvc-inval.h lib/msvc-nothrow.c lib/msvc-nothrow.h + lib/open.c + lib/openat-die.c + lib/openat-priv.h + lib/openat-proc.c + lib/openat.c + lib/openat.h lib/opendir-safer.c lib/opendir.c lib/parse-datetime.h @@ -809,15 +973,19 @@ AC_DEFUN([gl_FILE_LIST], [ lib/raise.c lib/readdir.c lib/readlink.c + lib/readlinkat.c lib/realloc.c lib/ref-add.sin lib/ref-del.sin lib/rename.c + lib/renameat.c lib/rmdir.c lib/safe-read.c lib/safe-write.c lib/safe-write.h lib/same-inode.h + lib/save-cwd.c + lib/save-cwd.h lib/secure_getenv.c lib/setenv.c lib/signal.in.h @@ -825,12 +993,14 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stat-time.c lib/stat-time.h lib/stat.c + lib/statat.c lib/stdarg.in.h lib/stdbool.in.h lib/stddef.in.h lib/stdint.in.h lib/stdio.in.h lib/stdlib.in.h + lib/strdup.c lib/streq.h lib/strerror-override.c lib/strerror-override.h @@ -840,6 +1010,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/strndup.c lib/strnlen.c lib/symlink.c + lib/symlinkat.c lib/sys_stat.in.h lib/sys_time.in.h lib/sys_types.in.h @@ -854,9 +1025,11 @@ AC_DEFUN([gl_FILE_LIST], [ lib/unistd.c lib/unistd.in.h lib/unlink.c + lib/unlinkat.c lib/unsetenv.c lib/utimens.c lib/utimens.h + lib/utimensat.c lib/vasnprintf.c lib/vasnprintf.h lib/vasprintf.c @@ -886,6 +1059,8 @@ AC_DEFUN([gl_FILE_LIST], [ m4/backupfile.m4 m4/bison.m4 m4/canonicalize.m4 + m4/chdir-long.m4 + m4/chown.m4 m4/clock_time.m4 m4/close.m4 m4/closedir.m4 @@ -905,11 +1080,17 @@ AC_DEFUN([gl_FILE_LIST], [ m4/exponentd.m4 m4/extensions.m4 m4/extern-inline.m4 + m4/fchdir.m4 + m4/fchmodat.m4 + m4/fchownat.m4 m4/fcntl-o.m4 m4/fcntl.m4 m4/fcntl_h.m4 + m4/filenamecat.m4 m4/float_h.m4 m4/fstat.m4 + m4/fstatat.m4 + m4/getcwd.m4 m4/getdtablesize.m4 m4/getopt.m4 m4/gettime.m4 @@ -920,7 +1101,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/intmax_t.m4 m4/inttypes_h.m4 m4/largefile.m4 - m4/lchmod.m4 + m4/lchown.m4 m4/localcharset.m4 m4/locale-fr.m4 m4/locale-ja.m4 @@ -935,15 +1116,21 @@ AC_DEFUN([gl_FILE_LIST], [ m4/mbsinit.m4 m4/mbstate_t.m4 m4/memchr.m4 + m4/mempcpy.m4 + m4/memrchr.m4 m4/minmax.m4 m4/mkdir.m4 + m4/mkdirat.m4 m4/mktime.m4 m4/mmap-anon.m4 + m4/mode_t.m4 m4/msvc-inval.m4 m4/msvc-nothrow.m4 m4/multiarch.m4 m4/nocrash.m4 m4/off_t.m4 + m4/open.m4 + m4/openat.m4 m4/opendir.m4 m4/parse-datetime.m4 m4/pathmax.m4 @@ -953,11 +1140,14 @@ AC_DEFUN([gl_FILE_LIST], [ m4/raise.m4 m4/readdir.m4 m4/readlink.m4 + m4/readlinkat.m4 m4/realloc.m4 m4/rename.m4 + m4/renameat.m4 m4/rmdir.m4 m4/safe-read.m4 m4/safe-write.m4 + m4/save-cwd.m4 m4/secure_getenv.m4 m4/setenv.m4 m4/signal_h.m4 @@ -972,11 +1162,13 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stdint_h.m4 m4/stdio_h.m4 m4/stdlib_h.m4 + m4/strdup.m4 m4/strerror.m4 m4/string_h.m4 m4/strndup.m4 m4/strnlen.m4 m4/symlink.m4 + m4/symlinkat.m4 m4/sys_socket_h.m4 m4/sys_stat_h.m4 m4/sys_time_h.m4 @@ -989,8 +1181,10 @@ AC_DEFUN([gl_FILE_LIST], [ m4/unistd-safer.m4 m4/unistd_h.m4 m4/unlink.m4 + m4/unlinkat.m4 m4/utimbuf.m4 m4/utimens.m4 + m4/utimensat.m4 m4/utimes.m4 m4/vasnprintf.m4 m4/vasprintf.m4 diff --git a/m4/include_next.m4 b/m4/include_next.m4 index 69ad3db..233d254 100644 --- a/m4/include_next.m4 +++ b/m4/include_next.m4 @@ -1,5 +1,5 @@ # include_next.m4 serial 23 -dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/intmax_t.m4 b/m4/intmax_t.m4 index af5561e..4bd8155 100644 --- a/m4/intmax_t.m4 +++ b/m4/intmax_t.m4 @@ -1,5 +1,5 @@ # intmax_t.m4 serial 8 -dnl Copyright (C) 1997-2004, 2006-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 1997-2004, 2006-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 index 87be9cf..d0b5f5d 100644 --- a/m4/inttypes_h.m4 +++ b/m4/inttypes_h.m4 @@ -1,5 +1,5 @@ # inttypes_h.m4 serial 10 -dnl Copyright (C) 1997-2004, 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/largefile.m4 b/m4/largefile.m4 index a1b564a..b7a6c48 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -1,6 +1,6 @@ # Enable large files on systems where this is not the default. -# Copyright 1992-1996, 1998-2014 Free Software Foundation, Inc. +# Copyright 1992-1996, 1998-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/lchmod.m4 b/m4/lchmod.m4 deleted file mode 100644 index f227e78..0000000 --- a/m4/lchmod.m4 +++ /dev/null @@ -1,22 +0,0 @@ -#serial 3 - -dnl Copyright (C) 2005-2006, 2008-2014 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. -dnl Provide a replacement for lchmod on hosts that lack it. - -AC_DEFUN([gl_FUNC_LCHMOD], -[ - AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) - - dnl Persuade glibc to declare lchmod(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - - AC_CHECK_FUNCS_ONCE([lchmod]) - if test $ac_cv_func_lchmod = no; then - HAVE_LCHMOD=0 - fi -]) diff --git a/m4/lchown.m4 b/m4/lchown.m4 new file mode 100644 index 0000000..e47b779 --- /dev/null +++ b/m4/lchown.m4 @@ -0,0 +1,38 @@ +# serial 17 +# Determine whether we need the lchown wrapper. + +dnl Copyright (C) 1998, 2001, 2003-2007, 2009-2015 Free Software Foundation, +dnl Inc. + +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering. +dnl Provide lchown on systems that lack it, and work around bugs +dnl on systems that have it. + +AC_DEFUN([gl_FUNC_LCHOWN], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_CHOWN]) + AC_CHECK_FUNCS_ONCE([lchmod]) + AC_CHECK_FUNCS([lchown]) + if test $ac_cv_func_lchown = no; then + HAVE_LCHOWN=0 + else + dnl Trailing slash and ctime bugs in chown also occur in lchown. + case "$gl_cv_func_chown_slash_works" in + *yes) ;; + *) + REPLACE_LCHOWN=1 + ;; + esac + case "$gl_cv_func_chown_ctime_works" in + *yes) ;; + *) + REPLACE_LCHOWN=1 + ;; + esac + fi +]) diff --git a/m4/localcharset.m4 b/m4/localcharset.m4 index ada2f01..f03916c 100644 --- a/m4/localcharset.m4 +++ b/m4/localcharset.m4 @@ -1,5 +1,5 @@ # localcharset.m4 serial 7 -dnl Copyright (C) 2002, 2004, 2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2004, 2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-fr.m4 b/m4/locale-fr.m4 index 27db5ab..92ff552 100644 --- a/m4/locale-fr.m4 +++ b/m4/locale-fr.m4 @@ -1,5 +1,5 @@ # locale-fr.m4 serial 17 -dnl Copyright (C) 2003, 2005-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-ja.m4 b/m4/locale-ja.m4 index c88fe8b..a3abef8 100644 --- a/m4/locale-ja.m4 +++ b/m4/locale-ja.m4 @@ -1,5 +1,5 @@ # locale-ja.m4 serial 12 -dnl Copyright (C) 2003, 2005-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/locale-zh.m4 b/m4/locale-zh.m4 index d3b2347..c5c4ef6 100644 --- a/m4/locale-zh.m4 +++ b/m4/locale-zh.m4 @@ -1,5 +1,5 @@ # locale-zh.m4 serial 12 -dnl Copyright (C) 2003, 2005-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/longlong.m4 b/m4/longlong.m4 index eefb37c..d57bc70 100644 --- a/m4/longlong.m4 +++ b/m4/longlong.m4 @@ -1,5 +1,5 @@ # longlong.m4 serial 17 -dnl Copyright (C) 1999-2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 1999-2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/lstat.m4 b/m4/lstat.m4 index c5e72b8..f6c7dd1 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -1,6 +1,6 @@ # serial 26 -# Copyright (C) 1997-2001, 2003-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-2001, 2003-2015 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/malloc.m4 b/m4/malloc.m4 index 322ad6e..31368ab 100644 --- a/m4/malloc.m4 +++ b/m4/malloc.m4 @@ -1,5 +1,5 @@ # malloc.m4 serial 14 -dnl Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/malloca.m4 b/m4/malloca.m4 index dcc1a08..7248951 100644 --- a/m4/malloca.m4 +++ b/m4/malloca.m4 @@ -1,5 +1,5 @@ # malloca.m4 serial 1 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 3e6dd21..44da98e 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,5 +1,5 @@ # manywarnings.m4 serial 7 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 45696f5..c0d751d 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,5 +1,5 @@ # mbrtowc.m4 serial 26 -dnl Copyright (C) 2001-2002, 2004-2005, 2008-2014 Free Software Foundation, +dnl Copyright (C) 2001-2002, 2004-2005, 2008-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/mbsinit.m4 b/m4/mbsinit.m4 index e1598a1..61c4032 100644 --- a/m4/mbsinit.m4 +++ b/m4/mbsinit.m4 @@ -1,5 +1,5 @@ # mbsinit.m4 serial 8 -dnl Copyright (C) 2008, 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008, 2010-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4 index 068155a..42ad6cd 100644 --- a/m4/mbstate_t.m4 +++ b/m4/mbstate_t.m4 @@ -1,5 +1,5 @@ # mbstate_t.m4 serial 13 -dnl Copyright (C) 2000-2002, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2000-2002, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/memchr.m4 b/m4/memchr.m4 index b9f126c..cb958d8 100644 --- a/m4/memchr.m4 +++ b/m4/memchr.m4 @@ -1,5 +1,5 @@ # memchr.m4 serial 12 -dnl Copyright (C) 2002-2004, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 new file mode 100644 index 0000000..aff590e --- /dev/null +++ b/m4/mempcpy.m4 @@ -0,0 +1,26 @@ +# mempcpy.m4 serial 11 +dnl Copyright (C) 2003-2004, 2006-2007, 2009-2015 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MEMPCPY], +[ + dnl Persuade glibc to declare mempcpy(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'. + AC_REQUIRE([AC_C_RESTRICT]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS([mempcpy]) + if test $ac_cv_func_mempcpy = no; then + HAVE_MEMPCPY=0 + fi +]) + +# Prerequisites of lib/mempcpy.c. +AC_DEFUN([gl_PREREQ_MEMPCPY], [ + : +]) diff --git a/m4/memrchr.m4 b/m4/memrchr.m4 new file mode 100644 index 0000000..f3f74b8 --- /dev/null +++ b/m4/memrchr.m4 @@ -0,0 +1,23 @@ +# memrchr.m4 serial 10 +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_MEMRCHR], +[ + dnl Persuade glibc to declare memrchr(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([memrchr]) + if test $ac_cv_have_decl_memrchr = no; then + HAVE_DECL_MEMRCHR=0 + fi + + AC_CHECK_FUNCS([memrchr]) +]) + +# Prerequisites of lib/memrchr.c. +AC_DEFUN([gl_PREREQ_MEMRCHR], [:]) diff --git a/m4/minmax.m4 b/m4/minmax.m4 index edbeb43..0df832c 100644 --- a/m4/minmax.m4 +++ b/m4/minmax.m4 @@ -1,5 +1,5 @@ # minmax.m4 serial 4 -dnl Copyright (C) 2005, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mkdir.m4 b/m4/mkdir.m4 index 51e78c1..3d9868d 100644 --- a/m4/mkdir.m4 +++ b/m4/mkdir.m4 @@ -1,6 +1,6 @@ # serial 11 -# Copyright (C) 2001, 2003-2004, 2006, 2008-2014 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003-2004, 2006, 2008-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/mkdirat.m4 b/m4/mkdirat.m4 new file mode 100644 index 0000000..0780b2b --- /dev/null +++ b/m4/mkdirat.m4 @@ -0,0 +1,23 @@ +# mkdirat.m4 serial 1 +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_MKDIRAT], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([mkdirat]) + if test $ac_cv_func_mkdirat != yes; then + HAVE_MKDIRAT=0 + fi +]) + +# Prerequisite of mkdirat's declaration and of lib/mkdirat.c. +AC_DEFUN([gl_PREREQ_MKDIRAT], +[ + AC_REQUIRE([AC_TYPE_MODE_T]) +]) diff --git a/m4/mktime.m4 b/m4/mktime.m4 index e8d340a..3f0e1ee 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,5 +1,5 @@ # serial 25 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/mmap-anon.m4 b/m4/mmap-anon.m4 index 94ae2e2..92a88d0 100644 --- a/m4/mmap-anon.m4 +++ b/m4/mmap-anon.m4 @@ -1,5 +1,5 @@ # mmap-anon.m4 serial 10 -dnl Copyright (C) 2005, 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/mode_t.m4 b/m4/mode_t.m4 new file mode 100644 index 0000000..01badba --- /dev/null +++ b/m4/mode_t.m4 @@ -0,0 +1,26 @@ +# mode_t.m4 serial 2 +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and +# include . + +# Define PROMOTED_MODE_T to the type that is the result of "default argument +# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t. +AC_DEFUN([gl_PROMOTED_TYPE_MODE_T], +[ + AC_REQUIRE([AC_TYPE_MODE_T]) + AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [ + dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int', + dnl and to itself otherwise. This assumption is not guaranteed by the ISO C + dnl standard, but we don't know of any real-world counterexamples. + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])], + [gl_cv_promoted_mode_t='int'], + [gl_cv_promoted_mode_t='mode_t']) + ]) + AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t], + [Define to the type that is the result of default argument promotions of type mode_t.]) +]) diff --git a/m4/msvc-inval.m4 b/m4/msvc-inval.m4 index 7f26087..9446fa5 100644 --- a/m4/msvc-inval.m4 +++ b/m4/msvc-inval.m4 @@ -1,5 +1,5 @@ # msvc-inval.m4 serial 1 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/msvc-nothrow.m4 b/m4/msvc-nothrow.m4 index 9e32c17..5d72a04 100644 --- a/m4/msvc-nothrow.m4 +++ b/m4/msvc-nothrow.m4 @@ -1,5 +1,5 @@ # msvc-nothrow.m4 serial 1 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/multiarch.m4 b/m4/multiarch.m4 index 2cb956d..fc575c1 100644 --- a/m4/multiarch.m4 +++ b/m4/multiarch.m4 @@ -1,5 +1,5 @@ # multiarch.m4 serial 7 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/nocrash.m4 b/m4/nocrash.m4 index 5a5d77d..5628318 100644 --- a/m4/nocrash.m4 +++ b/m4/nocrash.m4 @@ -1,5 +1,5 @@ # nocrash.m4 serial 4 -dnl Copyright (C) 2005, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/off_t.m4 b/m4/off_t.m4 index f5885b3..0eb1467 100644 --- a/m4/off_t.m4 +++ b/m4/off_t.m4 @@ -1,5 +1,5 @@ # off_t.m4 serial 1 -dnl Copyright (C) 2012-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2012-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/open.m4 b/m4/open.m4 new file mode 100644 index 0000000..2accbaa --- /dev/null +++ b/m4/open.m4 @@ -0,0 +1,91 @@ +# open.m4 serial 14 +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_OPEN], +[ + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw* | pw*) + REPLACE_OPEN=1 + ;; + *) + dnl open("foo/") should not create a file when the file name has a + dnl trailing slash. FreeBSD only has the problem on symlinks. + AC_CHECK_FUNCS_ONCE([lstat]) + AC_CACHE_CHECK([whether open recognizes a trailing slash], + [gl_cv_func_open_slash], + [# Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + touch conftest.tmp + ln -s conftest.tmp conftest.lnk + fi + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include +#if HAVE_UNISTD_H +# include +#endif +int main () +{ + int result = 0; +#if HAVE_LSTAT + if (open ("conftest.lnk/", O_RDONLY) != -1) + result |= 1; +#endif + if (open ("conftest.sl/", O_CREAT, 0600) >= 0) + result |= 2; + return result; +}]])], + [gl_cv_func_open_slash=yes], + [gl_cv_func_open_slash=no], + [ +changequote(,)dnl + case "$host_os" in + freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*) + gl_cv_func_open_slash="guessing no" ;; + *) + gl_cv_func_open_slash="guessing yes" ;; + esac +changequote([,])dnl + ]) + rm -f conftest.sl conftest.tmp conftest.lnk + ]) + case "$gl_cv_func_open_slash" in + *no) + AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1], + [Define to 1 if open() fails to recognize a trailing slash.]) + REPLACE_OPEN=1 + ;; + esac + ;; + esac + dnl Replace open() for supporting the gnulib-defined fchdir() function, + dnl to keep fchdir's bookkeeping up-to-date. + m4_ifdef([gl_FUNC_FCHDIR], [ + if test $REPLACE_OPEN = 0; then + gl_TEST_FCHDIR + if test $HAVE_FCHDIR = 0; then + REPLACE_OPEN=1 + fi + fi + ]) + dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag. + m4_ifdef([gl_NONBLOCKING_IO], [ + if test $REPLACE_OPEN = 0; then + gl_NONBLOCKING_IO + if test $gl_cv_have_open_O_NONBLOCK != yes; then + REPLACE_OPEN=1 + fi + fi + ]) +]) + +# Prerequisites of lib/open.c. +AC_DEFUN([gl_PREREQ_OPEN], +[ + AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) + : +]) diff --git a/m4/openat.m4 b/m4/openat.m4 new file mode 100644 index 0000000..c928ff7 --- /dev/null +++ b/m4/openat.m4 @@ -0,0 +1,36 @@ +# serial 45 +# See if we need to use our replacement for Solaris' openat et al functions. + +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_OPENAT], +[ + AC_REQUIRE([gl_FCNTL_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([openat]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + case $ac_cv_func_openat+$gl_cv_func_lstat_dereferences_slashed_symlink in + yes+*yes) + ;; + yes+*) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_OPENAT=1 + ;; + *) + HAVE_OPENAT=0 + ;; + esac +]) + +# Prerequisites of lib/openat.c. +AC_DEFUN([gl_PREREQ_OPENAT], +[ + AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T]) + : +]) diff --git a/m4/opendir.m4 b/m4/opendir.m4 index fa29c64..cd83706 100644 --- a/m4/opendir.m4 +++ b/m4/opendir.m4 @@ -1,5 +1,5 @@ # opendir.m4 serial 2 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/parse-datetime.m4 b/m4/parse-datetime.m4 index 7873009..2fc15c6 100644 --- a/m4/parse-datetime.m4 +++ b/m4/parse-datetime.m4 @@ -1,5 +1,5 @@ # parse-datetime.m4 serial 21 -dnl Copyright (C) 2002-2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/pathmax.m4 b/m4/pathmax.m4 index 114f91f..0e3db7a 100644 --- a/m4/pathmax.m4 +++ b/m4/pathmax.m4 @@ -1,5 +1,5 @@ # pathmax.m4 serial 10 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/printf.m4 b/m4/printf.m4 index 652fa1c..ffbb235 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1,5 +1,5 @@ # printf.m4 serial 51 -dnl Copyright (C) 2003, 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/quote.m4 b/m4/quote.m4 index 95b3e71..af72e96 100644 --- a/m4/quote.m4 +++ b/m4/quote.m4 @@ -1,5 +1,5 @@ # quote.m4 serial 6 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/quotearg.m4 b/m4/quotearg.m4 index eaebbf6..985b30d 100644 --- a/m4/quotearg.m4 +++ b/m4/quotearg.m4 @@ -1,5 +1,5 @@ # quotearg.m4 serial 9 -dnl Copyright (C) 2002, 2004-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/raise.m4 b/m4/raise.m4 index 8656578..ed6aae0 100644 --- a/m4/raise.m4 +++ b/m4/raise.m4 @@ -1,5 +1,5 @@ # raise.m4 serial 3 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/readdir.m4 b/m4/readdir.m4 index bd7be5c..8aa348f 100644 --- a/m4/readdir.m4 +++ b/m4/readdir.m4 @@ -1,5 +1,5 @@ # readdir.m4 serial 1 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/readlink.m4 b/m4/readlink.m4 index f9ce868..88c9bfe 100644 --- a/m4/readlink.m4 +++ b/m4/readlink.m4 @@ -1,5 +1,5 @@ # readlink.m4 serial 12 -dnl Copyright (C) 2003, 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/readlinkat.m4 b/m4/readlinkat.m4 new file mode 100644 index 0000000..d0f5e69 --- /dev/null +++ b/m4/readlinkat.m4 @@ -0,0 +1,32 @@ +# serial 4 +# See if we need to provide readlinkat replacement. + +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_READLINKAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([readlinkat]) + if test $ac_cv_func_readlinkat = no; then + HAVE_READLINKAT=0 + else + AC_CACHE_CHECK([whether readlinkat signature is correct], + [gl_cv_decl_readlinkat_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + /* Check whether original declaration has correct type. */ + ssize_t readlinkat (int, char const *, char *, size_t);]])], + [gl_cv_decl_readlinkat_works=yes], + [gl_cv_decl_readlinkat_works=no])]) + if test "$gl_cv_decl_readlink_works" != yes; then + REPLACE_READLINKAT=1 + fi + fi +]) diff --git a/m4/realloc.m4 b/m4/realloc.m4 index f96537b..0e1d338 100644 --- a/m4/realloc.m4 +++ b/m4/realloc.m4 @@ -1,5 +1,5 @@ # realloc.m4 serial 13 -dnl Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/rename.m4 b/m4/rename.m4 index ea57794..b5e4334 100644 --- a/m4/rename.m4 +++ b/m4/rename.m4 @@ -1,6 +1,6 @@ # serial 26 -# Copyright (C) 2001, 2003, 2005-2006, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2005-2006, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/renameat.m4 b/m4/renameat.m4 new file mode 100644 index 0000000..943fe6b --- /dev/null +++ b/m4/renameat.m4 @@ -0,0 +1,24 @@ +# serial 3 +# See if we need to provide renameat replacement. + +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_RENAMEAT], +[ + AC_REQUIRE([gl_FUNC_OPENAT]) + AC_REQUIRE([gl_FUNC_RENAME]) + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([renameat]) + if test $ac_cv_func_renameat = no; then + HAVE_RENAMEAT=0 + elif test $REPLACE_RENAME = 1; then + dnl Solaris 9 and 10 have the same bugs in renameat as in rename. + REPLACE_RENAMEAT=1 + fi +]) diff --git a/m4/rmdir.m4 b/m4/rmdir.m4 index db6a939..09ed159 100644 --- a/m4/rmdir.m4 +++ b/m4/rmdir.m4 @@ -1,5 +1,5 @@ # rmdir.m4 serial 13 -dnl Copyright (C) 2002, 2005, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/safe-read.m4 b/m4/safe-read.m4 index f0c42e0..697a07c 100644 --- a/m4/safe-read.m4 +++ b/m4/safe-read.m4 @@ -1,5 +1,5 @@ # safe-read.m4 serial 6 -dnl Copyright (C) 2002-2003, 2005-2006, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2006, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/safe-write.m4 b/m4/safe-write.m4 index 66648bb..1cef87c 100644 --- a/m4/safe-write.m4 +++ b/m4/safe-write.m4 @@ -1,5 +1,5 @@ # safe-write.m4 serial 4 -dnl Copyright (C) 2002, 2005-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/save-cwd.m4 b/m4/save-cwd.m4 new file mode 100644 index 0000000..8e61212 --- /dev/null +++ b/m4/save-cwd.m4 @@ -0,0 +1,11 @@ +# serial 10 +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Prerequisites for lib/save-cwd.c. +AC_DEFUN([gl_SAVE_CWD], +[ + AC_CHECK_FUNCS_ONCE([fchdir]) +]) diff --git a/m4/secure_getenv.m4 b/m4/secure_getenv.m4 index 149888d..6afe89f 100644 --- a/m4/secure_getenv.m4 +++ b/m4/secure_getenv.m4 @@ -1,5 +1,5 @@ # Look up an environment variable more securely. -dnl Copyright 2013-2014 Free Software Foundation, Inc. +dnl Copyright 2013-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/setenv.m4 b/m4/setenv.m4 index 0f46a7b..3aa38d8 100644 --- a/m4/setenv.m4 +++ b/m4/setenv.m4 @@ -1,5 +1,5 @@ # setenv.m4 serial 26 -dnl Copyright (C) 2001-2004, 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2004, 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index c8f664f..f737c36 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 @@ -1,5 +1,5 @@ # signal_h.m4 serial 18 -dnl Copyright (C) 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/size_max.m4 b/m4/size_max.m4 index 7e192d5..186e3fd 100644 --- a/m4/size_max.m4 +++ b/m4/size_max.m4 @@ -1,5 +1,5 @@ # size_max.m4 serial 10 -dnl Copyright (C) 2003, 2005-2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2005-2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4 index fbe1d06..25bd451 100644 --- a/m4/ssize_t.m4 +++ b/m4/ssize_t.m4 @@ -1,5 +1,5 @@ # ssize_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2001-2003, 2006, 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2003, 2006, 2010-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stat-time.m4 b/m4/stat-time.m4 index ea5c4fc..9c8ceec 100644 --- a/m4/stat-time.m4 +++ b/m4/stat-time.m4 @@ -1,6 +1,6 @@ # Checks for stat-related time functions. -# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2014 Free Software +# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2015 Free Software # Foundation, Inc. # This file is free software; the Free Software Foundation diff --git a/m4/stat.m4 b/m4/stat.m4 index 1ae327b..d1b3768 100644 --- a/m4/stat.m4 +++ b/m4/stat.m4 @@ -1,6 +1,6 @@ # serial 11 -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2015 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/stdarg.m4 b/m4/stdarg.m4 index 732aa31..d208eb3 100644 --- a/m4/stdarg.m4 +++ b/m4/stdarg.m4 @@ -1,5 +1,5 @@ # stdarg.m4 serial 6 -dnl Copyright (C) 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 index 006ed52..7273b82 100644 --- a/m4/stdbool.m4 +++ b/m4/stdbool.m4 @@ -1,6 +1,6 @@ # Check for stdbool.h that conforms to C99. -dnl Copyright (C) 2002-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index c555e29..2310502 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,6 +1,6 @@ -dnl A placeholder for POSIX 2008 , for platforms that have issues. -# stddef_h.m4 serial 4 -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl A placeholder for , for platforms that have issues. +# stddef_h.m4 serial 5 +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -10,6 +10,9 @@ AC_DEFUN([gl_STDDEF_H], AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) AC_REQUIRE([gt_TYPE_WCHAR_T]) STDDEF_H= + AC_CHECK_TYPE([max_align_t], [], [HAVE_MAX_ALIGN_T=0; STDDEF_H=stddef.h], + [[#include + ]]) if test $gt_cv_c_wchar_t = no; then HAVE_WCHAR_T=0 STDDEF_H=stddef.h @@ -43,5 +46,6 @@ AC_DEFUN([gl_STDDEF_H_DEFAULTS], [ dnl Assume proper GNU behavior unless another module says otherwise. REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) + HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T]) HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) ]) diff --git a/m4/stdint.m4 b/m4/stdint.m4 index 1981d9d..4011a49 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -1,5 +1,5 @@ # stdint.m4 serial 43 -dnl Copyright (C) 2001-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stdint_h.m4 b/m4/stdint_h.m4 index 7fc2ce9..5097c0b 100644 --- a/m4/stdint_h.m4 +++ b/m4/stdint_h.m4 @@ -1,5 +1,5 @@ # stdint_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 1997-2004, 2006, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index d15913a..e0c4bde 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,14 +1,35 @@ -# stdio_h.m4 serial 43 -dnl Copyright (C) 2007-2014 Free Software Foundation, Inc. +# stdio_h.m4 serial 44 +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_STDIO_H], [ + dnl For __USE_MINGW_ANSI_STDIO + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_NEXT_HEADERS([stdio.h]) + dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and + dnl inttypes.h behave like gnu instead of system; we must give our + dnl printf wrapper the right attribute to match. + AC_CACHE_CHECK([whether inttypes macros match system or gnu printf], + [gl_cv_func_printf_attribute_flavor], + [AC_EGREP_CPP([findme .(ll|j)d. findme], + [#define __STDC_FORMAT_MACROS 1 + #include + #include + findme PRIdMAX findme + ], [gl_cv_func_printf_attribute_flavor=gnu], + [gl_cv_func_printf_attribute_flavor=system])]) + if test "$gl_cv_func_printf_attribute_flavor" = gnu; then + AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1], + [Define to 1 if printf and friends should be labeled with + attribute "__gnu_printf__" instead of "__printf__"]) + fi + dnl No need to create extra modules for these functions. Everyone who uses dnl likely needs them. GNULIB_FSCANF=1 diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 86aff16..0b4c623 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,5 +1,5 @@ # stdlib_h.m4 serial 42 -dnl Copyright (C) 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/strdup.m4 b/m4/strdup.m4 new file mode 100644 index 0000000..90ea29d --- /dev/null +++ b/m4/strdup.m4 @@ -0,0 +1,36 @@ +# strdup.m4 serial 13 + +dnl Copyright (C) 2002-2015 Free Software Foundation, Inc. + +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_STRDUP], +[ + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_CHECK_FUNCS_ONCE([strdup]) + AC_CHECK_DECLS_ONCE([strdup]) + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi +]) + +AC_DEFUN([gl_FUNC_STRDUP_POSIX], +[ + AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) + AC_CHECK_FUNCS_ONCE([strdup]) + if test $ac_cv_func_strdup = yes; then + if test $gl_cv_func_malloc_posix != yes; then + REPLACE_STRDUP=1 + fi + fi + AC_CHECK_DECLS_ONCE([strdup]) + if test $ac_cv_have_decl_strdup = no; then + HAVE_DECL_STRDUP=0 + fi +]) + +# Prerequisites of lib/strdup.c. +AC_DEFUN([gl_PREREQ_STRDUP], [:]) diff --git a/m4/strerror.m4 b/m4/strerror.m4 index 0763fe3..75a17f2 100644 --- a/m4/strerror.m4 +++ b/m4/strerror.m4 @@ -1,5 +1,5 @@ # strerror.m4 serial 17 -dnl Copyright (C) 2002, 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/string_h.m4 b/m4/string_h.m4 index 64e683f..55d09ef 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -1,6 +1,6 @@ # Configure a GNU-like replacement for . -# Copyright (C) 2007-2014 Free Software Foundation, Inc. +# Copyright (C) 2007-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/strndup.m4 b/m4/strndup.m4 index 55df039..e6e2300 100644 --- a/m4/strndup.m4 +++ b/m4/strndup.m4 @@ -1,5 +1,5 @@ # strndup.m4 serial 21 -dnl Copyright (C) 2002-2003, 2005-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/strnlen.m4 b/m4/strnlen.m4 index 94317f8..5f85d3f 100644 --- a/m4/strnlen.m4 +++ b/m4/strnlen.m4 @@ -1,5 +1,5 @@ # strnlen.m4 serial 13 -dnl Copyright (C) 2002-2003, 2005-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/symlink.m4 b/m4/symlink.m4 index de4924b..a59e2f0 100644 --- a/m4/symlink.m4 +++ b/m4/symlink.m4 @@ -1,7 +1,7 @@ # serial 6 # See if we need to provide symlink replacement. -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/symlinkat.m4 b/m4/symlinkat.m4 new file mode 100644 index 0000000..fd975c8 --- /dev/null +++ b/m4/symlinkat.m4 @@ -0,0 +1,53 @@ +# serial 6 +# See if we need to provide symlinkat replacement. + +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_SYMLINKAT], +[ + AC_REQUIRE([gl_FUNC_OPENAT]) + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([symlinkat]) + if test $ac_cv_func_symlinkat = no; then + HAVE_SYMLINKAT=0 + else + AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly], + [gl_cv_func_symlinkat_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + ]], + [[int result = 0; + if (!symlinkat ("a", AT_FDCWD, "conftest.link/")) + result |= 1; + if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2")) + result |= 2; + else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/")) + result |= 4; + return result; + ]])], + [gl_cv_func_symlinkat_works=yes], + [gl_cv_func_symlinkat_works=no], + [case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_symlinkat_works="guessing yes" ;; + # If we don't know, assume the worst. + *) gl_cv_func_symlinkat_works="guessing no" ;; + esac + ]) + rm -f conftest.f conftest.link conftest.lnk2]) + case "$gl_cv_func_symlinkat_works" in + *yes) ;; + *) + REPLACE_SYMLINKAT=1 + ;; + esac + fi +]) diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 114d828..eaeabe7 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,5 +1,5 @@ # sys_socket_h.m4 serial 23 -dnl Copyright (C) 2005-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2005-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index eaa7642..6c909e8 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,5 +1,5 @@ # sys_stat_h.m4 serial 28 -*- Autoconf -*- -dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4 index 5c79300..50133b9 100644 --- a/m4/sys_time_h.m4 +++ b/m4/sys_time_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for . # serial 8 -# Copyright (C) 2007, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 index 9748905..2232aec 100644 --- a/m4/sys_types_h.m4 +++ b/m4/sys_types_h.m4 @@ -1,5 +1,5 @@ # sys_types_h.m4 serial 5 -dnl Copyright (C) 2011-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2011-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/tempname.m4 b/m4/tempname.m4 index 1594e1f..b1694d6 100644 --- a/m4/tempname.m4 +++ b/m4/tempname.m4 @@ -1,6 +1,6 @@ #serial 5 -# Copyright (C) 2006-2007, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2007, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. diff --git a/m4/time_h.m4 b/m4/time_h.m4 index 9852778..d9c41a4 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -1,8 +1,8 @@ # Configure a more-standard replacement for . -# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. -# serial 8 +# serial 9 # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -26,7 +26,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY], ]) dnl Check whether 'struct timespec' is declared -dnl in time.h, sys/time.h, or pthread.h. +dnl in time.h, sys/time.h, pthread.h, or unistd.h. AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [ @@ -44,6 +44,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], TIME_H_DEFINES_STRUCT_TIMESPEC=0 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 + UNISTD_H_DEFINES_STRUCT_TIMESPEC=0 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then TIME_H_DEFINES_STRUCT_TIMESPEC=1 else @@ -70,12 +71,26 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [gl_cv_sys_struct_timespec_in_pthread_h=no])]) if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in ], + [gl_cv_sys_struct_timespec_in_unistd_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_unistd_h=yes], + [gl_cv_sys_struct_timespec_in_unistd_h=no])]) + if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then + UNISTD_H_DEFINES_STRUCT_TIMESPEC=1 + fi fi fi fi AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC]) ]) AC_DEFUN([gl_TIME_MODULE_INDICATOR], diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 7e15600..8df7e13 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -1,6 +1,6 @@ dnl Reentrant time functions: localtime_r, gmtime_r. -dnl Copyright (C) 2003, 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/timespec.m4 b/m4/timespec.m4 index 2ce654f..06b3533 100644 --- a/m4/timespec.m4 +++ b/m4/timespec.m4 @@ -1,6 +1,6 @@ #serial 15 -# Copyright (C) 2000-2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2000-2001, 2003-2007, 2009-2015 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4 index 486351b..71a88f9 100644 --- a/m4/tm_gmtoff.m4 +++ b/m4/tm_gmtoff.m4 @@ -1,5 +1,5 @@ # tm_gmtoff.m4 serial 3 -dnl Copyright (C) 2002, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/unistd-safer.m4 b/m4/unistd-safer.m4 index 96cb7df..006bba2 100644 --- a/m4/unistd-safer.m4 +++ b/m4/unistd-safer.m4 @@ -1,5 +1,5 @@ #serial 9 -dnl Copyright (C) 2002, 2005-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002, 2005-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index d7346a0..b3c581f 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,5 +1,5 @@ # unistd_h.m4 serial 68 -dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/unlink.m4 b/m4/unlink.m4 index 03cf8ae..094d69a 100644 --- a/m4/unlink.m4 +++ b/m4/unlink.m4 @@ -1,5 +1,5 @@ # unlink.m4 serial 11 -dnl Copyright (C) 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/unlinkat.m4 b/m4/unlinkat.m4 new file mode 100644 index 0000000..6e5fa31 --- /dev/null +++ b/m4/unlinkat.m4 @@ -0,0 +1,33 @@ +# unlinkat.m4 serial 2 +dnl Copyright (C) 2004-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Jim Meyering. + +AC_DEFUN([gl_FUNC_UNLINKAT], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([unlinkat]) + AC_REQUIRE([gl_FUNC_UNLINK]) + AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + if test $ac_cv_func_unlinkat = no; then + HAVE_UNLINKAT=0 + else + case "$gl_cv_func_lstat_dereferences_slashed_symlink" in + *no) + # Solaris 9 has *at functions, but uniformly mishandles trailing + # slash in all of them. + REPLACE_UNLINKAT=1 + ;; + *) + # GNU/Hurd has unlinkat, but it has the same bug as unlink. + if test $REPLACE_UNLINK = 1; then + REPLACE_UNLINKAT=1 + fi + ;; + esac + fi +]) diff --git a/m4/utimbuf.m4 b/m4/utimbuf.m4 index 822a063..7c33ae9 100644 --- a/m4/utimbuf.m4 +++ b/m4/utimbuf.m4 @@ -1,6 +1,6 @@ # serial 9 -# Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2014 Free Software Foundation, +# Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2015 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation diff --git a/m4/utimens.m4 b/m4/utimens.m4 index c9c44cf..b022cfd 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -1,4 +1,4 @@ -dnl Copyright (C) 2003-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/utimensat.m4 b/m4/utimensat.m4 new file mode 100644 index 0000000..9a80fa0 --- /dev/null +++ b/m4/utimensat.m4 @@ -0,0 +1,71 @@ +# serial 5 +# See if we need to provide utimensat replacement. + +dnl Copyright (C) 2009-2015 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Written by Eric Blake. + +AC_DEFUN([gl_FUNC_UTIMENSAT], +[ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([utimensat]) + if test $ac_cv_func_utimensat = no; then + HAVE_UTIMENSAT=0 + else + AC_CACHE_CHECK([whether utimensat works], + [gl_cv_func_utimensat_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ +#include +#include +#include +]], [[int result = 0; + const char *f = "conftest.file"; + if (close (creat (f, 0600))) + return 1; + /* Test whether the AT_SYMLINK_NOFOLLOW flag is supported. */ + { + if (utimensat (AT_FDCWD, f, NULL, AT_SYMLINK_NOFOLLOW)) + result |= 2; + } + /* Test whether UTIME_NOW and UTIME_OMIT work. */ + { + struct timespec ts[2] = { { 1, UTIME_OMIT }, { 1, UTIME_NOW } }; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 4; + } + sleep (1); + { + struct timespec ts[2] = { { 1, UTIME_NOW }, { 1, UTIME_OMIT } }; + struct stat st; + if (utimensat (AT_FDCWD, f, ts, 0)) + result |= 8; + if (stat (f, &st)) + result |= 16; + else if (st.st_ctime < st.st_atime) + result |= 32; + } + return result; + ]])], +dnl FIXME: simplify this in 2012, when file system bugs are no longer common + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#ifdef __linux__ +/* The Linux kernel added utimensat in 2.6.22, but has bugs with UTIME_OMIT + in several file systems as recently as 2.6.32. Always replace utimensat + to support older kernels. */ +choke me +#endif + ]])], + [gl_cv_func_utimensat_works=yes], + [gl_cv_func_utimensat_works="needs runtime check"])], + [gl_cv_func_utimensat_works=no], + [gl_cv_func_utimensat_works="guessing no"])]) + if test "$gl_cv_func_utimensat_works" != yes; then + REPLACE_UTIMENSAT=1 + fi + fi +]) diff --git a/m4/utimes.m4 b/m4/utimes.m4 index c361357..e26a576 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,7 +1,7 @@ # Detect some bugs in glibc's implementation of utimes. # serial 3 -dnl Copyright (C) 2003-2005, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2005, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4 index 106192e..4708f2b 100644 --- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -1,5 +1,5 @@ # vasnprintf.m4 serial 36 -dnl Copyright (C) 2002-2004, 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2004, 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/vasprintf.m4 b/m4/vasprintf.m4 index c76c99c..b785dc3 100644 --- a/m4/vasprintf.m4 +++ b/m4/vasprintf.m4 @@ -1,5 +1,5 @@ # vasprintf.m4 serial 6 -dnl Copyright (C) 2002-2003, 2006-2007, 2009-2014 Free Software Foundation, +dnl Copyright (C) 2002-2003, 2006-2007, 2009-2015 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4 index cc690f8..1e98dc9 100644 --- a/m4/warn-on-use.m4 +++ b/m4/warn-on-use.m4 @@ -1,5 +1,5 @@ # warn-on-use.m4 serial 5 -dnl Copyright (C) 2010-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2010-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/warnings.m4 b/m4/warnings.m4 index 43156f4..5ae01de 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -1,5 +1,5 @@ # warnings.m4 serial 11 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4 index 85db952..9d1b0f8 100644 --- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -1,6 +1,6 @@ dnl A placeholder for ISO C99 , for platforms that have issues. -dnl Copyright (C) 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 index 839a04c..dc964e6 100644 --- a/m4/wchar_t.m4 +++ b/m4/wchar_t.m4 @@ -1,5 +1,5 @@ # wchar_t.m4 serial 4 (gettext-0.18.2) -dnl Copyright (C) 2002-2003, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2003, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 index 3fac0ee..95a4705 100644 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -2,7 +2,7 @@ dnl A placeholder for ISO C99 , for platforms that lack it. -dnl Copyright (C) 2006-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/wint_t.m4 b/m4/wint_t.m4 index 9b07b07..ca3fd44 100644 --- a/m4/wint_t.m4 +++ b/m4/wint_t.m4 @@ -1,5 +1,5 @@ # wint_t.m4 serial 5 (gettext-0.18.2) -dnl Copyright (C) 2003, 2007-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2007-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/write.m4 b/m4/write.m4 index 820dd4f..ce7042e 100644 --- a/m4/write.m4 +++ b/m4/write.m4 @@ -1,5 +1,5 @@ # write.m4 serial 5 -dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/xalloc.m4 b/m4/xalloc.m4 index b6a2257..6dfcab3 100644 --- a/m4/xalloc.m4 +++ b/m4/xalloc.m4 @@ -1,5 +1,5 @@ # xalloc.m4 serial 18 -dnl Copyright (C) 2002-2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2002-2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/xsize.m4 b/m4/xsize.m4 index 3af23ec..98faf7d 100644 --- a/m4/xsize.m4 +++ b/m4/xsize.m4 @@ -1,5 +1,5 @@ # xsize.m4 serial 5 -dnl Copyright (C) 2003-2004, 2008-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003-2004, 2008-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/xstrndup.m4 b/m4/xstrndup.m4 index 8521f0e..296603b 100644 --- a/m4/xstrndup.m4 +++ b/m4/xstrndup.m4 @@ -1,5 +1,5 @@ # xstrndup.m4 serial 2 -dnl Copyright (C) 2003, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2003, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/m4/xvasprintf.m4 b/m4/xvasprintf.m4 index c2d3ec7..715609a 100644 --- a/m4/xvasprintf.m4 +++ b/m4/xvasprintf.m4 @@ -1,5 +1,5 @@ # xvasprintf.m4 serial 2 -dnl Copyright (C) 2006, 2009-2014 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. diff --git a/maint.mk b/maint.mk index 1f5bddd..b6ec1b5 100644 --- a/maint.mk +++ b/maint.mk @@ -2,7 +2,7 @@ # This Makefile fragment tries to be general-purpose enough to be # used by many projects via the gnulib maintainer-makefile module. -## Copyright (C) 2001-2014 Free Software Foundation, Inc. +## Copyright (C) 2001-2015 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -1648,14 +1648,14 @@ _gl_tight_scope: $(bin_PROGRAMS) perl -lne \ '$(_gl_TS_function_match) and print "^$$1\$$"' $$hdr; \ ) | sort -u > $$t; \ - nm -e $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|grep -Ev -f $$t \ + nm -g $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|grep -Ev -f $$t \ && { echo the above functions should have static scope >&2; \ exit 1; } || : ; \ ( printf '^%s$$\n' '__.*' $(_gl_TS_unmarked_extern_vars); \ perl -lne '$(_gl_TS_var_match) and print "^$$1\$$"' \ $$hdr $(_gl_TS_other_headers) \ ) | sort -u > $$t; \ - nm -e $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p' \ + nm -g $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p' \ | sort -u | grep -Ev -f $$t \ && { echo the above variables should have static scope >&2; \ exit 1; } || : diff --git a/src/Makefile.am b/src/Makefile.am index 4c5fc53..7690760 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,8 @@ patch_SOURCES = \ patch.c \ pch.c \ pch.h \ + safe.c \ + safe.h \ util.c \ util.h \ version.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 1b25bb9..2104c86 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -104,6 +104,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/canonicalize.m4 \ + $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/d-ino.m4 \ @@ -113,52 +114,61 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/extensions.m4 \ - $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \ + $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \ $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fstat.m4 \ + $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdtablesize.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettime.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/include_next.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/largefile.m4 \ - $(top_srcdir)/m4/lchmod.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/lchown.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/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/mkdir.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ + $(top_srcdir)/m4/mkdirat.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ $(top_srcdir)/m4/opendir.m4 $(top_srcdir)/m4/parse-datetime.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/readdir.m4 \ - $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ + $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rename.m4 \ + $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rmdir.m4 \ $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ - $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/setenv.m4 \ - $(top_srcdir)/m4/setmode.m4 $(top_srcdir)/m4/signal_h.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/ssize_t.m4 \ - $(top_srcdir)/m4/stat-time.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/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/secure_getenv.m4 \ + $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/setmode.m4 \ + $(top_srcdir)/m4/signal_h.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.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/stdint_h.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/symlink.m4 \ - $(top_srcdir)/m4/sys_socket_h.m4 \ + $(top_srcdir)/m4/symlinkat.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/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \ + $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \ @@ -176,10 +186,12 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__patch_SOURCES_DIST = bestmatch.h common.h inp.c inp.h patch.c \ - pch.c pch.h util.c util.h version.c version.h merge.c + pch.c pch.h safe.c safe.h util.c util.h version.c version.h \ + merge.c @ENABLE_MERGE_TRUE@am__objects_1 = merge.$(OBJEXT) am_patch_OBJECTS = inp.$(OBJEXT) patch.$(OBJEXT) pch.$(OBJEXT) \ - util.$(OBJEXT) version.$(OBJEXT) $(am__objects_1) + safe.$(OBJEXT) util.$(OBJEXT) version.$(OBJEXT) \ + $(am__objects_1) patch_OBJECTS = $(am_patch_OBJECTS) am__DEPENDENCIES_1 = patch_DEPENDENCIES = $(top_builddir)/lib/libpatch.a \ @@ -616,6 +628,7 @@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ +HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ @@ -972,6 +985,7 @@ 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_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ VERSION = @VERSION@ @@ -1043,7 +1057,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) patch_SOURCES = bestmatch.h common.h inp.c inp.h patch.c pch.c pch.h \ - util.c util.h version.c version.h $(am__append_1) + safe.c safe.h util.c util.h version.c version.h \ + $(am__append_1) AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib \ $(am__append_2) patch_LDADD = $(LDADD) $(top_builddir)/lib/libpatch.a $(LIB_CLOCK_GETTIME) \ @@ -1140,6 +1155,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/merge.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pch.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ diff --git a/src/inp.c b/src/inp.c index a7ad070..4969837 100644 --- a/src/inp.c +++ b/src/inp.c @@ -25,6 +25,7 @@ #undef XTERN #define XTERN #include +#include /* Input-file-with-indexable-lines abstract type */ @@ -237,7 +238,7 @@ plan_a (char const *filename) { if (S_ISREG (instat.st_mode)) { - int ifd = open (filename, O_RDONLY|binary_transput); + int ifd = safe_open (filename, O_RDONLY|binary_transput, 0); size_t buffered = 0, n; if (ifd < 0) pfatal ("can't open file %s", quotearg (filename)); @@ -268,7 +269,7 @@ plan_a (char const *filename) else if (S_ISLNK (instat.st_mode)) { ssize_t n; - n = readlink (filename, buffer, size); + n = safe_readlink (filename, buffer, size); if (n < 0) pfatal ("can't read %s %s", "symbolic link", quotearg (filename)); size = n; @@ -339,6 +340,7 @@ plan_a (char const *filename) static void plan_b (char const *filename) { + int ifd; FILE *ifp; int c; size_t len; @@ -351,7 +353,8 @@ plan_b (char const *filename) if (instat.st_size == 0) filename = NULL_DEVICE; - if (! (ifp = fopen (filename, binary_transput ? "rb" : "r"))) + if ((ifd = safe_open (filename, O_RDONLY | binary_transput, 0)) < 0 + || ! (ifp = fdopen (ifd, binary_transput ? "rb" : "r"))) pfatal ("Can't open file %s", quotearg (filename)); if (TMPINNAME_needs_removal) { diff --git a/src/patch.c b/src/patch.c index cb4dbb2..2c51f44 100644 --- a/src/patch.c +++ b/src/patch.c @@ -34,6 +34,7 @@ #include #include #include +#include /* procedures */ @@ -291,7 +292,7 @@ main (int argc, char **argv) if (read_only_behavior != RO_IGNORE && ! inerrno && ! S_ISLNK (instat.st_mode) - && access (inname, W_OK) != 0) + && safe_access (inname, W_OK) != 0) { say ("File %s is read-only; ", quotearg (inname)); if (read_only_behavior == RO_WARN) @@ -339,6 +340,8 @@ main (int argc, char **argv) outstate.ofp = fdopen(outfd, binary_transput ? "wb" : "w"); if (! outstate.ofp) pfatal ("%s", TMPOUTNAME); + /* outstate.ofp now owns the file descriptor */ + outfd = -1; } /* find out where all the lines are */ @@ -540,7 +543,7 @@ main (int argc, char **argv) enum file_attributes attr = 0; struct timespec new_time = pch_timestamp (! reverse); mode_t mode = file_type | - ((new_mode ? new_mode : instat.st_mode) & S_IRWXUGO); + ((set_mode ? new_mode : instat.st_mode) & S_IRWXUGO); if ((set_time | set_utc) && new_time.tv_sec != -1) { @@ -1917,7 +1920,7 @@ output_files (struct stat const *st) from_st, file_to_output->to, file_to_output->mode, file_to_output->backup); if (file_to_output->to && from_needs_removal) - unlink (file_to_output->from); + safe_unlink (file_to_output->from); if (st && st->st_dev == from_st->st_dev && st->st_ino == from_st->st_ino) { @@ -1947,7 +1950,7 @@ forget_output_files (void) { const struct file_to_output *file_to_output = elt; - unlink (file_to_output->from); + safe_unlink (file_to_output->from); } gl_list_iterator_free (&iter); gl_list_clear (files_to_output); @@ -1971,7 +1974,7 @@ remove_if_needed (char const *name, bool *needs_removal) { if (*needs_removal) { - unlink (name); + safe_unlink (name); *needs_removal = false; } } diff --git a/src/pch.c b/src/pch.c index 028d51f..fd8885e 100644 --- a/src/pch.c +++ b/src/pch.c @@ -32,6 +32,7 @@ #if HAVE_SETMODE_DOS # include #endif +#include #define INITHUNKMAX 125 /* initial dynamic allocation size */ @@ -389,7 +390,6 @@ skip_hex_digits (char const *str) static bool name_is_valid (char const *name) { - char const *n; int i; bool is_valid = true; @@ -434,6 +434,7 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) int version_controlled[3]; enum diff retval; mode_t file_type; + size_t indent = -1; for (i = OLD; i <= INDEX; i++) if (p_name[i]) { @@ -480,11 +481,12 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) file_offset previous_line = this_line; bool last_line_was_command = this_is_a_command; bool stars_last_line = stars_this_line; - size_t indent = 0; + size_t indent_last_line = indent; char ed_command_letter; bool strip_trailing_cr; size_t chars_read; + indent = 0; this_line = file_tell (pfp); chars_read = pget_line (0, 0, false, false); if (chars_read == (size_t) -1) @@ -763,7 +765,8 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) if ((diff_type == NO_DIFF || diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) - && stars_last_line && strnEQ (s, "*** ", 4)) { + && stars_last_line && indent_last_line == indent + && strnEQ (s, "*** ", 4)) { s += 4; if (s[0] == '0' && !ISDIGIT (s[1])) p_says_nonexistent[OLD] = 1 + ! p_timestamp[OLD].tv_sec; @@ -1013,7 +1016,7 @@ prefix_components (char *filename, bool checkdirs) if (checkdirs) { *f = '\0'; - stat_result = stat (filename, &stat_buf); + stat_result = safe_stat (filename, &stat_buf); *f = '/'; if (! (stat_result == 0 && S_ISDIR (stat_buf.st_mode))) break; diff --git a/src/safe.c b/src/safe.c new file mode 100644 index 0000000..eec6ce5 --- /dev/null +++ b/src/safe.c @@ -0,0 +1,463 @@ +/* safe path traversal functions for 'patch' */ + +/* Copyright (C) 2015 Free Software Foundation, Inc. + + Written by Tim Waugh and + Andreas Gruenbacher . + + This program is free software: you can redistribute 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 . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dirname.h" + +#include +#include +#include + +#define XTERN extern +#include "common.h" + +/* Path lookup results are cached in a hash table + LRU list. When the + cache is full, the oldest entries are removed. */ + +unsigned long dirfd_cache_misses; + +struct cached_dirfd { + /* lru list */ + struct cached_dirfd *prev, *next; + + /* key (openat arguments) */ + int dirfd; + char *name; + + /* value (openat result) */ + int fd; +}; + +static Hash_table *cached_dirfds = NULL; +static size_t max_cached_fds; +static struct cached_dirfd lru_list = { + .prev = &lru_list, + .next = &lru_list, +}; + +static size_t hash_cached_dirfd (const void *entry, size_t table_size) +{ + const struct cached_dirfd *d = entry; + size_t strhash = hash_string (d->name, table_size); + return (strhash * 31 + d->dirfd) % table_size; +} + +static bool compare_cached_dirfds (const void *_a, + const void *_b) +{ + const struct cached_dirfd *a = _a; + const struct cached_dirfd *b = _b; + + return (a->dirfd == b->dirfd && + !strcmp (a->name, b->name)); +} + +static void free_cached_dirfd (struct cached_dirfd *d) +{ + close (d->fd); + free (d->name); + free (d); +} + +static void init_dirfd_cache (void) +{ + struct rlimit nofile; + + max_cached_fds = 8; + if (getrlimit (RLIMIT_NOFILE, &nofile) == 0) + max_cached_fds = MAX (nofile.rlim_cur / 4, max_cached_fds); + + cached_dirfds = hash_initialize (max_cached_fds, + NULL, + hash_cached_dirfd, + compare_cached_dirfds, + NULL); + + if (!cached_dirfds) + xalloc_die (); +} + +static void lru_list_add (struct cached_dirfd *entry, struct cached_dirfd *head) +{ + struct cached_dirfd *next = head->next; + entry->prev = head; + entry->next = next; + head->next = next->prev = entry; +} + +static void lru_list_del (struct cached_dirfd *entry) +{ + struct cached_dirfd *prev = entry->prev; + struct cached_dirfd *next = entry->next; + prev->next = next; + next->prev = prev; +} + +static struct cached_dirfd *lookup_cached_dirfd (int dirfd, const char *name) +{ + struct cached_dirfd *entry = NULL; + + if (cached_dirfds) + { + struct cached_dirfd key; + key.dirfd = dirfd; + key.name = (char *) name; + entry = hash_lookup (cached_dirfds, &key); + if (entry) + { + /* Move this most recently used entry to the head of the lru list */ + lru_list_del (entry); + lru_list_add (entry, &lru_list); + } + } + + return entry; +} + +static void remove_cached_dirfd (struct cached_dirfd *entry) +{ + lru_list_del (entry); + hash_delete (cached_dirfds, entry); + free_cached_dirfd (entry); +} + +static void insert_cached_dirfd (struct cached_dirfd *entry, int keepfd) +{ + if (cached_dirfds == NULL) + init_dirfd_cache (); + + /* Trim off the least recently used entries */ + while (hash_get_n_entries (cached_dirfds) >= max_cached_fds) + { + struct cached_dirfd *last = lru_list.prev; + assert (last != &lru_list); + if (last->fd == keepfd) + { + last = last->prev; + assert (last != &lru_list); + } + remove_cached_dirfd (last); + } + + assert (hash_insert (cached_dirfds, entry) == entry); + lru_list_add (entry, &lru_list); +} + +static void invalidate_cached_dirfd (int dirfd, const char *name) +{ + struct cached_dirfd key, *entry; + if (!cached_dirfds) + return; + + key.dirfd = dirfd; + key.name = (char *) name; + entry = hash_lookup (cached_dirfds, &key); + if (entry) + remove_cached_dirfd (entry); +} + +static int openat_cached (int dirfd, const char *name, int keepfd) +{ + int fd; + struct cached_dirfd *entry = lookup_cached_dirfd (dirfd, name); + + if (entry) + return entry->fd; + dirfd_cache_misses++; + + /* Actually get the new directory file descriptor. Don't follow + symbolic links. */ + fd = openat (dirfd, name, O_DIRECTORY | O_NOFOLLOW); + + /* Don't cache errors. */ + if (fd < 0) + return fd; + + /* Store new cache entry */ + entry = xmalloc (sizeof (struct cached_dirfd)); + entry->dirfd = dirfd; + entry->name = xstrdup (name); + entry->fd = fd; + insert_cached_dirfd (entry, keepfd); + + return fd; +} + +/* Resolve the next path component in PATH inside DIRFD. */ +static int traverse_next (int dirfd, const char **path, int keepfd) +{ + const char *p = *path; + char *name; + + while (*p && ! ISSLASH (*p)) + p++; + if (**path == '.' && *path + 1 == p) + goto skip; + name = alloca (p - *path + 1); + memcpy(name, *path, p - *path); + name[p - *path] = 0; + + dirfd = openat_cached (dirfd, name, keepfd); + if (dirfd < 0 && dirfd != AT_FDCWD) + { + *path = p; + return -1; + } +skip: + while (ISSLASH (*p)) + p++; + *path = p; + return dirfd; +} + +/* Traverse PATHNAME. Updates PATHNAME to point to the last path component and + returns a file descriptor to its parent directory (which can be AT_FDCWD). + When KEEPFD is given, make sure that the cache entry for DIRFD is not + removed from the cache (and KEEPFD remains open) even if the cache grows + beyond MAX_CACHED_FDS entries. */ +static int traverse_another_path (const char **pathname, int keepfd) +{ + unsigned long misses = dirfd_cache_misses; + const char *path = *pathname, *last; + int dirfd = AT_FDCWD; + + if (! *path || IS_ABSOLUTE_FILE_NAME (path)) + return dirfd; + + /* Find the last pathname component */ + last = strrchr (path, 0) - 1; + if (ISSLASH (*last)) + { + while (last != path) + if (! ISSLASH (*--last)) + break; + } + while (last != path && ! ISSLASH (*(last - 1))) + last--; + if (last == path) + return dirfd; + + if (debug & 32) + printf ("Resolving path \"%.*s\"", (int) (last - path), path); + + while (path != last) + { + dirfd = traverse_next (dirfd, &path, keepfd); + if (dirfd < 0 && dirfd != AT_FDCWD) + { + if (debug & 32) + { + printf (" (failed)\n"); + fflush (stdout); + } + if (errno == ELOOP) + { + fprintf (stderr, "Refusing to follow symbolic link %.*s\n", + (int) (path - *pathname), *pathname); + fatal_exit (0); + } + return dirfd; + } + } + *pathname = last; + if (debug & 32) + { + misses = dirfd_cache_misses - misses; + if (! misses) + printf(" (cached)\n"); + else + printf (" (%lu miss%s)\n", misses, misses == 1 ? "" : "es"); + fflush (stdout); + } + return dirfd; +} + +/* Just traverse PATHNAME; see traverse_another_path(). */ +static int traverse_path (const char **pathname) +{ + return traverse_another_path (pathname, -1); +} + +static int safe_xstat (const char *pathname, struct stat *buf, int flags) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return fstatat (dirfd, pathname, buf, flags); +} + +/* Replacement for stat() */ +int safe_stat (const char *pathname, struct stat *buf) +{ + return safe_xstat (pathname, buf, 0); +} + +/* Replacement for lstat() */ +int safe_lstat (const char *pathname, struct stat *buf) +{ + return safe_xstat (pathname, buf, AT_SYMLINK_NOFOLLOW); +} + +/* Replacement for open() */ +int safe_open (const char *pathname, int flags, mode_t mode) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return openat (dirfd, pathname, flags, mode); +} + +/* Replacement for rename() */ +int safe_rename (const char *oldpath, const char *newpath) +{ + int olddirfd, newdirfd; + int ret; + + olddirfd = traverse_path (&oldpath); + if (olddirfd != AT_FDCWD && olddirfd < 0) + return olddirfd; + + newdirfd = traverse_another_path (&newpath, olddirfd); + if (newdirfd != AT_FDCWD && newdirfd < 0) + return newdirfd; + + ret = renameat (olddirfd, oldpath, newdirfd, newpath); + invalidate_cached_dirfd (olddirfd, oldpath); + invalidate_cached_dirfd (newdirfd, newpath); + return ret; +} + +/* Replacement for mkdir() */ +int safe_mkdir (const char *pathname, mode_t mode) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return mkdirat (dirfd, pathname, mode); +} + +/* Replacement for rmdir() */ +int safe_rmdir (const char *pathname) +{ + int dirfd; + int ret; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + + ret = unlinkat (dirfd, pathname, AT_REMOVEDIR); + invalidate_cached_dirfd (dirfd, pathname); + return ret; +} + +/* Replacement for unlink() */ +int safe_unlink (const char *pathname) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return unlinkat (dirfd, pathname, 0); +} + +/* Replacement for symlink() */ +int safe_symlink (const char *target, const char *linkpath) +{ + int dirfd; + + dirfd = traverse_path (&linkpath); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return symlinkat (target, dirfd, linkpath); +} + +/* Replacement for chmod() */ +int safe_chmod (const char *pathname, mode_t mode) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return fchmodat (dirfd, pathname, mode, 0); +} + +/* Replacement for lchown() */ +int safe_lchown (const char *pathname, uid_t owner, gid_t group) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return fchownat (dirfd, pathname, owner, group, AT_SYMLINK_NOFOLLOW); +} + +/* Replacement for lutimens() */ +int safe_lutimens (const char *pathname, struct timespec const times[2]) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return utimensat (dirfd, pathname, times, AT_SYMLINK_NOFOLLOW); +} + +/* Replacement for readlink() */ +ssize_t safe_readlink(const char *pathname, char *buf, size_t bufsiz) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return readlinkat (dirfd, pathname, buf, bufsiz); +} + +/* Replacement for access() */ +int safe_access(const char *pathname, int mode) +{ + int dirfd; + + dirfd = traverse_path (&pathname); + if (dirfd < 0 && dirfd != AT_FDCWD) + return dirfd; + return faccessat (dirfd, pathname, mode, 0); +} diff --git a/src/safe.h b/src/safe.h new file mode 100644 index 0000000..1a0ff70 --- /dev/null +++ b/src/safe.h @@ -0,0 +1,33 @@ +/* safe path traversal functions for 'patch' */ + +/* Copyright (C) 2015 Free Software Foundation, Inc. + + Written by Tim Waugh and + Andreas Gruenbacher . + + This program is free software: you can redistribute 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 . */ + +int safe_stat (const char *pathname, struct stat *buf); +int safe_lstat (const char *pathname, struct stat *buf); +int safe_open (const char *pathname, int flags, mode_t mode); +int safe_rename (const char *oldpath, const char *newpath); +int safe_mkdir (const char *pathname, mode_t mode); +int safe_rmdir (const char *pathname); +int safe_unlink (const char *pathname); +int safe_symlink (const char *target, const char *linkpath); +int safe_chmod (const char *pathname, mode_t mode); +int safe_lchown (const char *pathname, uid_t owner, gid_t group); +int safe_lutimens (const char *pathname, struct timespec const times[2]); +ssize_t safe_readlink(const char *pathname, char *buf, size_t bufsiz); +int safe_access(const char *pathname, int mode); diff --git a/src/util.c b/src/util.c index ae05caa..fae628a 100644 --- a/src/util.c +++ b/src/util.c @@ -52,6 +52,8 @@ # include "verror.h" #endif +#include + static void makedirs (char const *); typedef struct @@ -216,6 +218,9 @@ copy_attr (char const *src_path, char const *dst_path) .quote = copy_attr_quote, .quote_free = copy_attr_free }; + /* FIXME: We are copying between files we know we can safely access by + * pathname. A safe_ version of attr_copy_file() might still be slightly + * more efficient for deep paths. */ return attr_copy_file (src_path, dst_path, copy_attr_check, &ctx); } @@ -244,7 +249,7 @@ set_file_attributes (char const *to, enum file_attributes attr, times[0] = get_stat_atime (st); times[1] = get_stat_mtime (st); } - if (lutimens (to, times) != 0) + if (safe_lutimens (to, times) != 0) pfatal ("Failed to set the timestamps of %s %s", S_ISLNK (mode) ? "symbolic link" : "file", quotearg (to)); @@ -267,10 +272,10 @@ set_file_attributes (char const *to, enum file_attributes attr, /* May fail if we are not privileged to set the file owner, or we are not in group instat.st_gid. Ignore those errors. */ if ((uid != -1 || gid != -1) - && lchown (to, uid, gid) != 0 + && safe_lchown (to, uid, gid) != 0 && (errno != EPERM || (uid != -1 - && lchown (to, (uid = -1), gid) != 0 + && safe_lchown (to, (uid = -1), gid) != 0 && errno != EPERM))) pfatal ("Failed to set the %s of %s %s", (uid == -1) ? "owner" : "owning group", @@ -289,7 +294,7 @@ set_file_attributes (char const *to, enum file_attributes attr, systems where we could. */ if (lchmod (to, mode)) #else - if (! S_ISLNK (mode) && chmod (to, mode) != 0) + if (! S_ISLNK (mode) && safe_chmod (to, mode) != 0) #endif pfatal ("Failed to set the permissions of %s %s", S_ISLNK (mode) ? "symbolic link" : "file", @@ -382,8 +387,8 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) say ("Creating empty file %s\n", quotearg (bakname)); try_makedirs_errno = ENOENT; - unlink (bakname); - while ((fd = creat (bakname, 0666)) < 0) + safe_unlink (bakname); + while ((fd = safe_open (bakname, O_CREAT | O_WRONLY | O_TRUNC, 0666)) < 0) { if (errno != try_makedirs_errno) pfatal ("Can't create file %s", quotearg (bakname)); @@ -400,7 +405,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) if (debug & 4) say ("Renaming file %s to %s\n", quotearg_n (0, to), quotearg_n (1, bakname)); - while (rename (to, bakname) != 0) + while (safe_rename (to, bakname) != 0) { if (errno == try_makedirs_errno) { @@ -411,7 +416,7 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) { create_backup_copy (to, bakname, to_st, try_makedirs_errno == 0); - unlink (to); + safe_unlink (to); break; } else @@ -423,23 +428,6 @@ create_backup (char const *to, const struct stat *to_st, bool leave_original) } } -/* Only allow symlink targets which are relative and free of ".." components: - * otherwise, the operating system may follow one of those symlinks in a - * pathname component, leading to a path traversal vulnerability. - * - * An alternative to disallowing many kinds of symlinks would be to implement - * path traversal in user space using openat() without following symlinks - * altogether. - */ -static bool -symlink_target_is_valid (char const *target, char const *to) -{ - bool is_valid = filename_is_safe (target); - - /* Allow any symlink target if we are in the filesystem root. */ - return is_valid || cwd_is_root (to); -} - /* Move a file FROM (where *FROM_NEEDS_REMOVAL is nonzero if FROM needs removal when cleaning up at the end of execution, and where *FROMST is FROM's status if known), @@ -475,7 +463,7 @@ move_file (char const *from, bool *from_needs_removal, char *buffer = xmalloc (PATH_MAX); int fd, size = 0, i; - if ((fd = open (from, O_RDONLY | O_BINARY)) < 0) + if ((fd = safe_open (from, O_RDONLY | O_BINARY, 0)) < 0) pfatal ("Can't reopen file %s", quotearg (from)); while ((i = read (fd, buffer + size, PATH_MAX - size)) > 0) size += i; @@ -483,31 +471,20 @@ move_file (char const *from, bool *from_needs_removal, read_fatal (); buffer[size] = 0; - /* If we are allowed to create a file with an absolute path name, - anywhere, we also don't need to worry about symlinks that can - leave the working directory. */ - if (! (IS_ABSOLUTE_FILE_NAME (to) - || symlink_target_is_valid (buffer, to))) - { - fprintf (stderr, "symbolic link target '%s' is invalid\n", - buffer); - fatal_exit (0); - } - if (! backup) { - if (unlink (to) == 0) + if (safe_unlink (to) == 0) to_dir_known_to_exist = true; } - if (symlink (buffer, to) != 0) + if (safe_symlink (buffer, to) != 0) { if (errno == ENOENT && ! to_dir_known_to_exist) makedirs (to); - if (symlink (buffer, to) != 0) + if (safe_symlink (buffer, to) != 0) pfatal ("Can't create %s %s", "symbolic link", to); } free (buffer); - if (lstat (to, &to_st) != 0) + if (safe_lstat (to, &to_st) != 0) pfatal ("Can't get file attributes of %s %s", "symbolic link", to); insert_file_id (&to_st, CREATED); } @@ -517,7 +494,7 @@ move_file (char const *from, bool *from_needs_removal, say ("Renaming file %s to %s\n", quotearg_n (0, from), quotearg_n (1, to)); - if (rename (from, to) != 0) + if (safe_rename (from, to) != 0) { bool to_dir_known_to_exist = false; @@ -526,7 +503,7 @@ move_file (char const *from, bool *from_needs_removal, { makedirs (to); to_dir_known_to_exist = true; - if (rename (from, to) == 0) + if (safe_rename (from, to) == 0) goto rename_succeeded; } @@ -535,7 +512,7 @@ move_file (char const *from, bool *from_needs_removal, struct stat tost; if (! backup) { - if (unlink (to) == 0) + if (safe_unlink (to) == 0) to_dir_known_to_exist = true; else if (errno != ENOENT) pfatal ("Can't remove file %s", quotearg (to)); @@ -564,7 +541,7 @@ move_file (char const *from, bool *from_needs_removal, { if (debug & 4) say ("Removing file %s\n", quotearg (to)); - if (unlink (to) != 0 && errno != ENOENT) + if (safe_unlink (to) != 0 && errno != ENOENT) pfatal ("Can't remove file %s", quotearg (to)); } } @@ -583,8 +560,8 @@ create_file (char const *file, int open_flags, mode_t mode, do { if (! (O_CREAT && O_TRUNC)) - close (creat (file, mode)); - fd = open (file, O_CREAT | O_TRUNC | open_flags, mode); + close (safe_open (file, O_CREAT | O_WRONLY | O_TRUNC, mode)); + fd = safe_open (file, O_CREAT | O_TRUNC | open_flags, mode); if (fd < 0) { char *f; @@ -605,7 +582,7 @@ copy_to_fd (const char *from, int tofd) int fromfd; ssize_t i; - if ((fromfd = open (from, O_RDONLY | O_BINARY)) < 0) + if ((fromfd = safe_open (from, O_RDONLY | O_BINARY, 0)) < 0) pfatal ("Can't reopen file %s", quotearg (from)); while ((i = read (fromfd, buf, bufsize)) != 0) { @@ -635,11 +612,11 @@ copy_file (char const *from, char const *to, struct stat *tost, { char *buffer = xmalloc (PATH_MAX); - if (readlink (from, buffer, PATH_MAX) < 0) + if (safe_readlink (from, buffer, PATH_MAX) < 0) pfatal ("Can't read %s %s", "symbolic link", from); - if (symlink (buffer, to) != 0) + if (safe_symlink (buffer, to) != 0) pfatal ("Can't create %s %s", "symbolic link", to); - if (tost && lstat (to, tost) != 0) + if (tost && safe_lstat (to, tost) != 0) pfatal ("Can't get file attributes of %s %s", "symbolic link", to); free (buffer); } @@ -663,7 +640,7 @@ append_to_file (char const *from, char const *to) { int tofd; - if ((tofd = open (to, O_WRONLY | O_BINARY | O_APPEND)) < 0) + if ((tofd = safe_open (to, O_WRONLY | O_BINARY | O_APPEND, 0)) < 0) pfatal ("Can't reopen file %s", quotearg (to)); copy_to_fd (from, tofd); if (close (tofd) != 0) @@ -730,8 +707,8 @@ version_controller (char const *filename, bool readonly, sprintf (trybuf, "%s/", dir); -#define try1(f,a1) (sprintf (trybuf + dirlen, f, a1), stat (trybuf, &cstat) == 0) -#define try2(f,a1,a2) (sprintf (trybuf + dirlen, f, a1,a2), stat (trybuf, &cstat) == 0) +#define try1(f,a1) (sprintf (trybuf + dirlen, f, a1), safe_stat (trybuf, &cstat) == 0) +#define try2(f,a1,a2) (sprintf (trybuf + dirlen, f, a1,a2), safe_stat (trybuf, &cstat) == 0) /* Check that RCS file is not working file. Some hosts don't report file name length errors. */ @@ -862,7 +839,7 @@ version_get (char const *filename, char const *cs, bool exists, bool readonly, cs, readonly ? "" : " with lock"); if (systemic (getbuf) != 0) fatal ("Can't get file %s from %s", quotearg (filename), cs); - if (stat (filename, filestat) != 0) + if (safe_stat (filename, filestat) != 0) pfatal ("%s", quotearg (filename)); } @@ -1301,6 +1278,9 @@ makedirs (char const *name) char *f; char *flim = replace_slashes (filename); + /* FIXME: Now with the pathname lookup cache, there is no reason for + deferring the creation of directories. Callers should be updated. */ + if (flim) { /* Create any missing directories, replacing NULs by '/'s. @@ -1311,7 +1291,7 @@ makedirs (char const *name) for (f = filename; f <= flim; f++) if (!*f) { - mkdir (filename, + safe_mkdir (filename, S_IRUSR|S_IWUSR|S_IXUSR |S_IRGRP|S_IWGRP|S_IXGRP |S_IROTH|S_IWOTH|S_IXOTH); @@ -1341,7 +1321,7 @@ removedirs (char const *name) || ISSLASH (filename[i - 3]))))))) { filename[i] = '\0'; - if (rmdir (filename) == 0 && verbosity == VERBOSE) + if (safe_rmdir (filename) == 0 && verbosity == VERBOSE) say ("Removed empty directory %s\n", quotearg (filename)); filename[i] = '/'; } @@ -1656,10 +1636,15 @@ make_tempfile (char const **name, char letter, char const *real_name, { int fd; + /* gen_tempname(..., GT_NOCREATE) calls lstat() to check if a file + already exists. In the worst case, this leads to a template that + follows a symbolic link and that we cannot use; safe_open() will + detect that. */ + if (gen_tempname (template, 0, flags, GT_NOCREATE)) pfatal ("Can't create temporary file %s", template); retry: - fd = open (template, O_CREAT | O_EXCL | flags, mode); + fd = safe_open (template, O_CREAT | O_EXCL | flags, mode); if (fd == -1) { if (errno == try_makedirs_errno) @@ -1682,7 +1667,7 @@ make_tempfile (char const **name, char letter, char const *real_name, int stat_file (char const *filename, struct stat *st) { int (*xstat)(char const *, struct stat *) = - follow_symlinks ? stat : lstat; + follow_symlinks ? safe_stat : safe_lstat; return xstat (filename, st) == 0 ? 0 : errno; } diff --git a/src/util.h b/src/util.h index 6b3308a..ab46540 100644 --- a/src/util.h +++ b/src/util.h @@ -18,7 +18,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include #include #include #include diff --git a/tests/Makefile.am b/tests/Makefile.am index cfc4f37..91c9dce 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,6 +34,7 @@ TESTS = \ file-modes \ filename-choice \ git-binary-diff \ + garbage \ global-reject-files \ inname \ line-numbers \ @@ -42,6 +43,7 @@ TESTS = \ mixed-patch-types \ munged-context-format \ need-filename \ + no-mode-change-git-diff \ no-newline-triggers-assert \ preserve-c-function-names \ preserve-mode-and-timestamp \ @@ -52,7 +54,8 @@ TESTS = \ remember-reject-files \ remove-directories \ symlinks \ - unmodified-files + unmodified-files \ + deep-directories XFAIL_TESTS = \ dash-o-append diff --git a/tests/Makefile.in b/tests/Makefile.in index e21ab79..838b98e 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -100,6 +100,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/absolute-header.m4 $(top_srcdir)/m4/alloca.m4 \ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \ $(top_srcdir)/m4/canonicalize.m4 \ + $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/close.m4 \ $(top_srcdir)/m4/closedir.m4 $(top_srcdir)/m4/codeset.m4 \ $(top_srcdir)/m4/configmake.m4 $(top_srcdir)/m4/d-ino.m4 \ @@ -109,52 +110,61 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/environ.m4 \ $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \ $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/extensions.m4 \ - $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \ - $(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \ + $(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fchdir.m4 \ + $(top_srcdir)/m4/fchmodat.m4 $(top_srcdir)/m4/fchownat.m4 \ + $(top_srcdir)/m4/fcntl-o.m4 $(top_srcdir)/m4/fcntl.m4 \ + $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/filenamecat.m4 \ $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fstat.m4 \ + $(top_srcdir)/m4/fstatat.m4 $(top_srcdir)/m4/getcwd.m4 \ $(top_srcdir)/m4/getdtablesize.m4 $(top_srcdir)/m4/getopt.m4 \ $(top_srcdir)/m4/gettime.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/include_next.m4 $(top_srcdir)/m4/intmax_t.m4 \ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/largefile.m4 \ - $(top_srcdir)/m4/lchmod.m4 $(top_srcdir)/m4/localcharset.m4 \ + $(top_srcdir)/m4/lchown.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/longlong.m4 \ $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \ $(top_srcdir)/m4/malloca.m4 $(top_srcdir)/m4/manywarnings.m4 \ $(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbsinit.m4 \ $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/memchr.m4 \ + $(top_srcdir)/m4/mempcpy.m4 $(top_srcdir)/m4/memrchr.m4 \ $(top_srcdir)/m4/minmax.m4 $(top_srcdir)/m4/mkdir.m4 \ - $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/mmap-anon.m4 \ + $(top_srcdir)/m4/mkdirat.m4 $(top_srcdir)/m4/mktime.m4 \ + $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \ $(top_srcdir)/m4/msvc-inval.m4 \ $(top_srcdir)/m4/msvc-nothrow.m4 $(top_srcdir)/m4/multiarch.m4 \ $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/off_t.m4 \ + $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \ $(top_srcdir)/m4/opendir.m4 $(top_srcdir)/m4/parse-datetime.m4 \ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/printf.m4 \ $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \ $(top_srcdir)/m4/raise.m4 $(top_srcdir)/m4/readdir.m4 \ - $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/realloc.m4 \ - $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/rmdir.m4 \ + $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readlinkat.m4 \ + $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rename.m4 \ + $(top_srcdir)/m4/renameat.m4 $(top_srcdir)/m4/rmdir.m4 \ $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \ - $(top_srcdir)/m4/secure_getenv.m4 $(top_srcdir)/m4/setenv.m4 \ - $(top_srcdir)/m4/setmode.m4 $(top_srcdir)/m4/signal_h.m4 \ - $(top_srcdir)/m4/size_max.m4 $(top_srcdir)/m4/ssize_t.m4 \ - $(top_srcdir)/m4/stat-time.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/stdint_h.m4 $(top_srcdir)/m4/stdio_h.m4 \ - $(top_srcdir)/m4/stdlib_h.m4 $(top_srcdir)/m4/strerror.m4 \ + $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/secure_getenv.m4 \ + $(top_srcdir)/m4/setenv.m4 $(top_srcdir)/m4/setmode.m4 \ + $(top_srcdir)/m4/signal_h.m4 $(top_srcdir)/m4/size_max.m4 \ + $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/stat-time.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/stdint_h.m4 \ + $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \ + $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \ $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/strndup.m4 \ $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/symlink.m4 \ - $(top_srcdir)/m4/sys_socket_h.m4 \ + $(top_srcdir)/m4/symlinkat.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/time_h.m4 $(top_srcdir)/m4/time_r.m4 \ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \ $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \ - $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/utimbuf.m4 \ - $(top_srcdir)/m4/utimens.m4 $(top_srcdir)/m4/utimes.m4 \ + $(top_srcdir)/m4/unlink.m4 $(top_srcdir)/m4/unlinkat.m4 \ + $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \ + $(top_srcdir)/m4/utimensat.m4 $(top_srcdir)/m4/utimes.m4 \ $(top_srcdir)/m4/vasnprintf.m4 $(top_srcdir)/m4/vasprintf.m4 \ $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \ $(top_srcdir)/m4/wchar_h.m4 $(top_srcdir)/m4/wchar_t.m4 \ @@ -771,6 +781,7 @@ HAVE_LINK = @HAVE_LINK@ HAVE_LINKAT = @HAVE_LINKAT@ HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@ HAVE_LSTAT = @HAVE_LSTAT@ +HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@ HAVE_MBRLEN = @HAVE_MBRLEN@ HAVE_MBRTOWC = @HAVE_MBRTOWC@ HAVE_MBSINIT = @HAVE_MBSINIT@ @@ -1127,6 +1138,7 @@ 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_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@ UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@ UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ VERSION = @VERSION@ @@ -1214,6 +1226,7 @@ TESTS = \ file-modes \ filename-choice \ git-binary-diff \ + garbage \ global-reject-files \ inname \ line-numbers \ @@ -1222,6 +1235,7 @@ TESTS = \ mixed-patch-types \ munged-context-format \ need-filename \ + no-mode-change-git-diff \ no-newline-triggers-assert \ preserve-c-function-names \ preserve-mode-and-timestamp \ @@ -1232,7 +1246,8 @@ TESTS = \ remember-reject-files \ remove-directories \ symlinks \ - unmodified-files + unmodified-files \ + deep-directories XFAIL_TESTS = \ dash-o-append @@ -1549,6 +1564,13 @@ git-binary-diff.log: git-binary-diff --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +garbage.log: garbage + @p='garbage'; \ + b='garbage'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) global-reject-files.log: global-reject-files @p='global-reject-files'; \ b='global-reject-files'; \ @@ -1605,6 +1627,13 @@ need-filename.log: need-filename --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +no-mode-change-git-diff.log: no-mode-change-git-diff + @p='no-mode-change-git-diff'; \ + b='no-mode-change-git-diff'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) no-newline-triggers-assert.log: no-newline-triggers-assert @p='no-newline-triggers-assert'; \ b='no-newline-triggers-assert'; \ @@ -1682,6 +1711,13 @@ unmodified-files.log: unmodified-files --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +deep-directories.log: deep-directories + @p='deep-directories'; \ + b='deep-directories'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ diff --git a/tests/asymmetric-hunks b/tests/asymmetric-hunks index 6929c4a..d6979d9 100644 --- a/tests/asymmetric-hunks +++ b/tests/asymmetric-hunks @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/backup-prefix-suffix b/tests/backup-prefix-suffix index a51142c..e37d602 100644 --- a/tests/backup-prefix-suffix +++ b/tests/backup-prefix-suffix @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/bad-usage b/tests/bad-usage index 022eeda..551553a 100644 --- a/tests/bad-usage +++ b/tests/bad-usage @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/concat-git-diff b/tests/concat-git-diff index c78da53..f8bf911 100644 --- a/tests/concat-git-diff +++ b/tests/concat-git-diff @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/copy-rename b/tests/copy-rename index 40f53d1..fd5fd64 100644 --- a/tests/copy-rename +++ b/tests/copy-rename @@ -8,7 +8,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/corrupt-reject-files b/tests/corrupt-reject-files index 17215aa..ad001f8 100644 --- a/tests/corrupt-reject-files +++ b/tests/corrupt-reject-files @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/create-delete b/tests/create-delete index 404d99e..2ec80df 100644 --- a/tests/create-delete +++ b/tests/create-delete @@ -6,8 +6,8 @@ . $srcdir/test-lib.sh -require_cat -require_sed +require cat +require sed use_local_patch use_tmpdir diff --git a/tests/criss-cross b/tests/criss-cross index 7b5a706..5e7b611 100644 --- a/tests/criss-cross +++ b/tests/criss-cross @@ -8,7 +8,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/crlf-handling b/tests/crlf-handling index b704dc8..239149c 100644 --- a/tests/crlf-handling +++ b/tests/crlf-handling @@ -8,8 +8,8 @@ . $srcdir/test-lib.sh -require_gnu_diff -require_sed +require gnu_diff +require sed use_local_patch use_tmpdir diff --git a/tests/dash-o-append b/tests/dash-o-append index 1633699..c6c2d4a 100644 --- a/tests/dash-o-append +++ b/tests/dash-o-append @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir diff --git a/tests/deep-directories b/tests/deep-directories new file mode 100755 index 0000000..d6a41a6 --- /dev/null +++ b/tests/deep-directories @@ -0,0 +1,28 @@ +# Copyright (C) 2015 Free Software Foundation, Inc. +# +# Copying and distribution of this file, with or without modification, +# in any medium, are permitted without royalty provided the copyright +# notice and this notice are preserved. + +. $srcdir/test-lib.sh + +require cat +use_local_patch +use_tmpdir + +# ============================================================== +# Exercise the directory file descriptor cache + +# Artificially limit to 8 cache entries +ulimit -n 32 >& /dev/null || exit 77 + +cat > ab.diff < bad.diff < f +chmod 755 f + +cat > simple.diff < symlink-target.diff < symlink-target.diff < follow-symlink.diff < bad-symlink-target1.diff < bad-symlink-target2.diff < symlink.orig && cat target2' < d/ab.diff < /dev/null 2> /dev/null; then - echo "This test requires the cat utility" >&2 - exit 77 - fi -} - require_gnu_diff() { case "`diff --version 2> /dev/null`" in *GNU*) @@ -24,9 +17,12 @@ require_gnu_diff() { esac } -require_sed() { - if ! type sed > /dev/null 2> /dev/null; then - echo "This test requires the sed utility" >&2 +require() { + utility="$1" + if type require_${utility} > /dev/null 2> /dev/null; then + require_${utility} + elif ! type "${utility}" > /dev/null 2> /dev/null; then + echo "This test requires the ${utility} utility" >&2 exit 77 fi } @@ -163,7 +159,7 @@ if ! type seq > /dev/null 2> /dev/null; then )} fi -require_cat +require cat clean_env checks_succeeded=0 diff --git a/tests/unmodified-files b/tests/unmodified-files index a9e00c6..fd5eee6 100644 --- a/tests/unmodified-files +++ b/tests/unmodified-files @@ -6,7 +6,7 @@ . $srcdir/test-lib.sh -require_cat +require cat use_local_patch use_tmpdir -- 2.34.1