* admin/merge-gnulib (AVOIDED_MODULES): Add chmod.
'
AVOIDED_MODULES='
- btowc close crypto/af_alg dup fchdir fstat langinfo lock
+ btowc chmod close crypto/af_alg dup fchdir fstat langinfo lock
mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo
openat-die opendir pthread-h raise
save-cwd select setenv sigprocmask stat stdarg stdbool
# shellcheck disable=SC2006,SC2268 # see below for rationale
-timestamp='2022-05-08'
+timestamp='2022-05-25'
# 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
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
GUESS=i586-pc-haiku
;;
- x86_64:Haiku:*:*)
- GUESS=x86_64-unknown-haiku
+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC
+ GUESS=powerpc-apple-haiku
+ ;;
+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
+ GUESS=$UNAME_MACHINE-unknown-haiku
;;
SX-4:SUPER-UX:*:*)
GUESS=sx4-nec-superux$UNAME_RELEASE
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2021 Free Software Foundation, Inc.
+# Copyright 1992-2022 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
-timestamp='2021-12-25'
+timestamp='2022-01-03'
# 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
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2021 Free Software Foundation, Inc.
+Copyright 1992-2022 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."
% If SUBTOPIC is present, precede it with a space, and call \doind.
% (At some time during the 20th century, this made a two-level entry in an
% index such as the operation index. Nobody seemed to notice the change in
-% behavior though.)
+% behaviour though.)
\def\dosubind#1#2#3{%
\def\thirdarg{#3}%
\ifx\thirdarg\empty
# if NEED_FCHMODAT_NONSYMLINK_FIX
if (flags == AT_SYMLINK_NOFOLLOW)
{
- struct stat st;
+# if HAVE_READLINKAT
+ char readlink_buf[1];
-# if defined O_PATH && defined AT_EMPTY_PATH
+# ifdef O_PATH
/* Open a file descriptor with O_NOFOLLOW, to make sure we don't
follow symbolic links, if /proc is mounted. O_PATH is used to
avoid a failure if the file is not readable.
if (fd < 0)
return fd;
- /* Up to Linux 5.3 at least, when FILE refers to a symbolic link, the
- chmod call below will change the permissions of the symbolic link
- - which is undesired - and on many file systems (ext4, btrfs, jfs,
- xfs, ..., but not reiserfs) fail with error EOPNOTSUPP - which is
- misleading. Therefore test for a symbolic link explicitly.
- Use fstatat because fstat does not work on O_PATH descriptors
- before Linux 3.6. */
- if (fstatat (fd, "", &st, AT_EMPTY_PATH) != 0)
+ int err;
+ if (0 <= readlinkat (fd, "", readlink_buf, sizeof readlink_buf))
+ err = EOPNOTSUPP;
+ else if (errno == EINVAL)
{
- int stat_errno = errno;
- close (fd);
- errno = stat_errno;
- return -1;
- }
- if (S_ISLNK (st.st_mode))
- {
- close (fd);
- errno = EOPNOTSUPP;
- return -1;
+ static char const fmt[] = "/proc/self/fd/%d";
+ char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
+ sprintf (buf, fmt, fd);
+ err = chmod (buf, mode) == 0 ? 0 : errno == ENOENT ? -1 : errno;
}
+ else
+ err = errno == ENOENT ? -1 : errno;
-# if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__
- static char const fmt[] = "/proc/self/fd/%d";
- char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
- sprintf (buf, fmt, fd);
- int chmod_result = chmod (buf, mode);
- int chmod_errno = errno;
close (fd);
- if (chmod_result == 0)
- return chmod_result;
- if (chmod_errno != ENOENT)
- {
- errno = chmod_errno;
- return chmod_result;
- }
+
+ errno = err;
+ if (0 <= err)
+ return err == 0 ? 0 : -1;
# endif
- /* /proc is not mounted or would not work as in GNU/Linux. */
-# else
- int fstatat_result = fstatat (dir, file, &st, AT_SYMLINK_NOFOLLOW);
- if (fstatat_result != 0)
- return fstatat_result;
- if (S_ISLNK (st.st_mode))
+ /* O_PATH + /proc is not supported. */
+
+ if (0 <= readlinkat (dir, file, readlink_buf, sizeof readlink_buf))
{
errno = EOPNOTSUPP;
return -1;
/* Return the length of a prefix of S that corresponds to the suffix
defined by this extended regular expression in the C locale:
(\.[A-Za-z~][A-Za-z0-9~]*)*$
+ Use the longest suffix matching this regular expression,
+ except do not use all of S as a suffix if S is nonempty.
If *LEN is -1, S is a string; set *LEN to S's length.
Otherwise, *LEN should be nonnegative, S is a char array,
and *LEN does not change. */
file_prefixlen (char const *s, ptrdiff_t *len)
{
size_t n = *len; /* SIZE_MAX if N == -1. */
+ idx_t prefixlen = 0;
- for (idx_t i = 0; ; i++)
+ for (idx_t i = 0; ; )
{
- idx_t prefixlen = i;
- while (i + 1 < n && s[i] == '.' && (c_isalpha (s[i + 1])
- || s[i + 1] == '~'))
- for (i += 2; i < n && (c_isalnum (s[i]) || s[i] == '~'); i++)
- continue;
-
if (*len < 0 ? !s[i] : i == n)
{
*len = i;
return prefixlen;
}
+
+ i++;
+ prefixlen = i;
+ while (i + 1 < n && s[i] == '.' && (c_isalpha (s[i + 1])
+ || s[i + 1] == '~'))
+ for (i += 2; i < n && (c_isalnum (s[i]) || s[i] == '~'); i++)
+ continue;
}
}
without them, using version sort without special priority;
if they do not compare equal, this comparison result is used and
the suffixes are effectively ignored. Otherwise, the entire
- strings are compared using version sort.
+ strings are compared using version sort. When removing a suffix
+ from a nonempty string, remove the maximal-length suffix such that
+ the remaining string is nonempty.
This function is intended to be a replacement for strverscmp. */
int filevercmp (char const *a, char const *b) _GL_ATTRIBUTE_PURE;
# --macro-prefix=gl \
# --no-vc-files \
# --avoid=btowc \
+# --avoid=chmod \
# --avoid=close \
# --avoid=crypto/af_alg \
# --avoid=dup \
GL_GNULIB_CALLOC_POSIX = @GL_GNULIB_CALLOC_POSIX@
GL_GNULIB_CANONICALIZE_FILE_NAME = @GL_GNULIB_CANONICALIZE_FILE_NAME@
GL_GNULIB_CHDIR = @GL_GNULIB_CHDIR@
+GL_GNULIB_CHMOD = @GL_GNULIB_CHMOD@
GL_GNULIB_CHOWN = @GL_GNULIB_CHOWN@
GL_GNULIB_CLOSE = @GL_GNULIB_CLOSE@
GL_GNULIB_CLOSEDIR = @GL_GNULIB_CLOSEDIR@
REPLACE_CALLOC_FOR_CALLOC_GNU = @REPLACE_CALLOC_FOR_CALLOC_GNU@
REPLACE_CALLOC_FOR_CALLOC_POSIX = @REPLACE_CALLOC_FOR_CALLOC_POSIX@
REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
+REPLACE_CHMOD = @REPLACE_CHMOD@
REPLACE_CHOWN = @REPLACE_CHOWN@
REPLACE_CLOSE = @REPLACE_CLOSE@
REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
SHELL = @SHELL@
SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
+SMALL_JA_DIC = @SMALL_JA_DIC@
SQLITE3_LIBS = @SQLITE3_LIBS@
STDALIGN_H = @STDALIGN_H@
STDDEF_H = @STDDEF_H@
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
-e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
-e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
+ -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \
-e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \
-e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \
-e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \
-e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
-e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
-e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+ -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|g' \
-e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
-e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
-e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
-#ifdef __osf__
-/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
- eliminates this include because of the preliminary #include <sys/stat.h>
- above. */
-# include "sys/stat.h"
-#else
-# include <sys/stat.h>
-#endif
-
#include <intprops.h>
/* Work like chmod, except when FILE is a symbolic link.
int
lchmod (char const *file, mode_t mode)
{
-#if defined O_PATH && defined AT_EMPTY_PATH
+ char readlink_buf[1];
+
+#ifdef O_PATH
/* Open a file descriptor with O_NOFOLLOW, to make sure we don't
follow symbolic links, if /proc is mounted. O_PATH is used to
avoid a failure if the file is not readable.
if (fd < 0)
return fd;
- /* Up to Linux 5.3 at least, when FILE refers to a symbolic link, the
- chmod call below will change the permissions of the symbolic link
- - which is undesired - and on many file systems (ext4, btrfs, jfs,
- xfs, ..., but not reiserfs) fail with error EOPNOTSUPP - which is
- misleading. Therefore test for a symbolic link explicitly.
- Use fstatat because fstat does not work on O_PATH descriptors
- before Linux 3.6. */
- struct stat st;
- if (fstatat (fd, "", &st, AT_EMPTY_PATH) != 0)
+ int err;
+ if (0 <= readlinkat (fd, "", readlink_buf, sizeof readlink_buf))
+ err = EOPNOTSUPP;
+ else if (errno == EINVAL)
{
- int stat_errno = errno;
- close (fd);
- errno = stat_errno;
- return -1;
- }
- if (S_ISLNK (st.st_mode))
- {
- close (fd);
- errno = EOPNOTSUPP;
- return -1;
+ static char const fmt[] = "/proc/self/fd/%d";
+ char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
+ sprintf (buf, fmt, fd);
+ err = chmod (buf, mode) == 0 ? 0 : errno == ENOENT ? -1 : errno;
}
+ else
+ err = errno == ENOENT ? -1 : errno;
-# if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__
- static char const fmt[] = "/proc/self/fd/%d";
- char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
- sprintf (buf, fmt, fd);
- int chmod_result = chmod (buf, mode);
- int chmod_errno = errno;
close (fd);
- if (chmod_result == 0)
- return chmod_result;
- if (chmod_errno != ENOENT)
+
+ errno = err;
+ if (0 <= err)
+ return err == 0 ? 0 : -1;
+#endif
+
+ size_t len = strlen (file);
+ if (len && file[len - 1] == '/')
{
- errno = chmod_errno;
- return chmod_result;
+ struct stat st;
+ if (lstat (file, &st) < 0)
+ return -1;
+ if (!S_ISDIR (st.st_mode))
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
}
-# endif
- /* /proc is not mounted or would not work as in GNU/Linux. */
-
-#elif HAVE_LSTAT
- struct stat st;
- int lstat_result = lstat (file, &st);
- if (lstat_result != 0)
- return lstat_result;
- if (S_ISLNK (st.st_mode))
+
+ /* O_PATH + /proc is not supported. */
+
+ if (0 <= readlink (file, readlink_buf, sizeof readlink_buf))
{
errno = EOPNOTSUPP;
return -1;
}
-#endif
/* Fall back on chmod, despite a possible race. */
return chmod (file, mode);
it under the terms of either:
* the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your
+ Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */
-static RETURN_TYPE
+static RETURN_TYPE _GL_ATTRIBUTE_PURE
two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
const unsigned char *needle, size_t needle_len)
{
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
sublinear performance is not possible. */
-static RETURN_TYPE
+static RETURN_TYPE _GL_ATTRIBUTE_PURE
two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
const unsigned char *needle, size_t needle_len)
{
# undef _GL_ATTRIBUTE_DEALLOC_FREE
# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
# else
-# if defined _MSC_VER
-_GL_EXTERN_C void __cdecl free (void *);
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
# else
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
_GL_EXTERN_C void free (void *) throw ();
# endif
# endif
#else
-# if defined _MSC_VER
-_GL_EXTERN_C void __cdecl free (void *);
+# if defined _MSC_VER && !defined free
+_GL_EXTERN_C
+# if defined _DLL
+ __declspec (dllimport)
+# endif
+ void __cdecl free (void *);
# else
# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
_GL_EXTERN_C void free (void *) throw ();
#endif
-#if @GNULIB_MDA_CHMOD@
+#if @GNULIB_CHMOD@
+# if @REPLACE_CHMOD@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chmod
+# define chmod rpl_chmod
+# endif
+_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
+# elif defined _WIN32 && !defined __CYGWIN__
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef chmod
+# define chmod _chmod
+# endif
+/* Need to cast, because in mingw the last argument is 'int mode'. */
+_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
+# else
+_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
+# endif
+_GL_CXXALIASWARN (chmod);
+#elif defined GNULIB_POSIXCHECK
+# undef chmod
+# if HAVE_RAW_DECL_CHMOD
+_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
+ "use gnulib module chmod for portability");
+# endif
+#elif @GNULIB_MDA_CHMOD@
/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
platforms by defining GNULIB_NAMESPACE::chmod always. */
-# fchmodat.m4 serial 6
+# fchmodat.m4 serial 7
dnl Copyright (C) 2004-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
# Prerequisites of lib/fchmodat.c.
AC_DEFUN([gl_PREREQ_FCHMODAT],
[
- AC_CHECK_FUNCS_ONCE([lchmod])
+ AC_CHECK_FUNCS_ONCE([readlinkat])
:
])
-#serial 8
+#serial 10
dnl Copyright (C) 2005-2006, 2008-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl Persuade glibc <sys/stat.h> to declare lchmod().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-
- AC_CHECK_FUNCS_ONCE([lchmod lstat])
+ AC_CHECK_FUNCS_ONCE([lchmod])
if test "$ac_cv_func_lchmod" = no; then
HAVE_LCHMOD=0
fi
-# sys_stat_h.m4 serial 41 -*- Autoconf -*-
+# sys_stat_h.m4 serial 42 -*- Autoconf -*-
dnl Copyright (C) 2006-2022 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
- ]], [fchmodat fstat fstatat futimens getumask lchmod lstat
+ ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat
mkdirat mkfifo mkfifoat mknod mknodat stat utimensat])
AC_REQUIRE([AC_C_RESTRICT])
[
m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [
gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT])
HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
+ REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD])
REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT])
REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])