[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Run gnulib-tool --add-import mkstemp.
From: |
Gavin D. Smith |
Subject: |
branch master updated: Run gnulib-tool --add-import mkstemp. |
Date: |
Sat, 03 Dec 2022 09:54:35 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new ae3ffd4032 Run gnulib-tool --add-import mkstemp.
ae3ffd4032 is described below
commit ae3ffd40322e7f17b7e8ce32ac34417643ffb588
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Dec 3 14:54:25 2022 +0000
Run gnulib-tool --add-import mkstemp.
---
ChangeLog | 4 +
gnulib/lib/Makefile.am | 91 +++++++++++++++
gnulib/lib/dirname-lgpl.c | 86 ++++++++++++++
gnulib/lib/dirname.h | 53 +++++++++
gnulib/lib/getrandom.c | 190 ++++++++++++++++++++++++++++++
gnulib/lib/lstat.c | 104 +++++++++++++++++
gnulib/lib/mkdir.c | 93 +++++++++++++++
gnulib/lib/mkstemp.c | 50 ++++++++
gnulib/lib/stripslash.c | 45 +++++++
gnulib/lib/sys_random.in.h | 100 ++++++++++++++++
gnulib/lib/tempname.c | 286 +++++++++++++++++++++++++++++++++++++++++++++
gnulib/lib/tempname.h | 72 ++++++++++++
gnulib/m4/clock_time.m4 | 32 +++++
gnulib/m4/getrandom.m4 | 68 +++++++++++
gnulib/m4/gnulib-cache.m4 | 2 +
gnulib/m4/gnulib-comp.m4 | 133 +++++++++++++++++++++
gnulib/m4/lstat.m4 | 79 +++++++++++++
gnulib/m4/mkdir.m4 | 87 ++++++++++++++
gnulib/m4/mkstemp.m4 | 87 ++++++++++++++
gnulib/m4/sys_random_h.m4 | 68 +++++++++++
gnulib/m4/tempname.m4 | 19 +++
21 files changed, 1749 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4d7f21fb1c..fe89ee200e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2022-12-03 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Run gnulib-tool --add-import mkstemp.
+
2022-12-03 Gavin Smith <gavinsmith0123@gmail.com>
Atomic dir update
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
index d5e191280e..9730e81079 100644
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -46,6 +46,7 @@
# mbsstr \
# mbswidth \
# memrchr \
+# mkstemp \
# regex \
# stdarg \
# strcasestr \
@@ -232,6 +233,16 @@ endif
endif
## end gnulib module close
+## begin gnulib module dirname-lgpl
+
+if gl_GNULIB_ENABLED_a691da99c1d83b83238e45f41a696f5c
+libgnu_a_SOURCES += dirname-lgpl.c stripslash.c
+
+endif
+EXTRA_DIST += dirname.h
+
+## end gnulib module dirname-lgpl
+
## begin gnulib module dup2
if gl_GNULIB_ENABLED_dup2
@@ -532,6 +543,16 @@ libgnu_a_SOURCES += getprogname.h getprogname.c
## end gnulib module getprogname
+## begin gnulib module getrandom
+
+if gl_GNULIB_ENABLED_getrandom
+if GL_COND_OBJ_GETRANDOM
+libgnu_a_SOURCES += getrandom.c
+endif
+
+endif
+## end gnulib module getrandom
+
## begin gnulib module gettext-h
libgnu_a_SOURCES += gettext.h
@@ -782,6 +803,16 @@ libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
endif
## end gnulib module lock
+## begin gnulib module lstat
+
+if gl_GNULIB_ENABLED_lstat
+if GL_COND_OBJ_LSTAT
+libgnu_a_SOURCES += lstat.c
+endif
+
+endif
+## end gnulib module lstat
+
## begin gnulib module malloc-gnu
@@ -932,6 +963,24 @@ libgnu_a_SOURCES += minmax.h
## end gnulib module minmax
+## begin gnulib module mkdir
+
+if gl_GNULIB_ENABLED_mkdir
+if GL_COND_OBJ_MKDIR
+libgnu_a_SOURCES += mkdir.c
+endif
+
+endif
+## end gnulib module mkdir
+
+## begin gnulib module mkstemp
+
+if GL_COND_OBJ_MKSTEMP
+libgnu_a_SOURCES += mkstemp.c
+endif
+
+## end gnulib module mkstemp
+
## begin gnulib module msvc-inval
if gl_GNULIB_ENABLED_f691f076f650964c9f5598c3ee487616
@@ -1797,6 +1846,38 @@ EXTRA_libgnu_a_SOURCES += strstr.c
## end gnulib module strstr-simple
+## begin gnulib module sys_random
+
+if gl_GNULIB_ENABLED_sys_random
+BUILT_SOURCES += sys/random.h
+
+# We need the following in order to create <sys/random.h> when the system
+# doesn't have one.
+sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H)
$(ARG_NONNULL_H) $(WARN_ON_USE_H)
+ $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
+ $(AM_V_at)$(SED_HEADER_STDOUT) \
+ -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_SYS_RANDOM_H''@|$(NEXT_SYS_RANDOM_H)|g' \
+ -e 's|@''HAVE_SYS_RANDOM_H''@|$(HAVE_SYS_RANDOM_H)|g' \
+ -e 's/@''GNULIB_GETRANDOM''@/$(GL_GNULIB_GETRANDOM)/g' \
+ -e 's/@''HAVE_GETRANDOM''@/$(HAVE_GETRANDOM)/g' \
+ -e 's/@''REPLACE_GETRANDOM''@/$(REPLACE_GETRANDOM)/g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ $(srcdir)/sys_random.in.h > $@-t
+ $(AM_V_at)mv $@-t $@
+MOSTLYCLEANFILES += sys/random.h sys/random.h-t
+MOSTLYCLEANDIRS += sys
+
+endif
+EXTRA_DIST += sys_random.in.h
+
+## end gnulib module sys_random
+
## begin gnulib module sys_stat
if gl_GNULIB_ENABLED_sys_stat
@@ -1896,6 +1977,16 @@ EXTRA_DIST += sys_types.in.h
## end gnulib module sys_types
+## begin gnulib module tempname
+
+if gl_GNULIB_ENABLED_tempname
+libgnu_a_SOURCES += tempname.c
+
+endif
+EXTRA_DIST += tempname.h
+
+## end gnulib module tempname
+
## begin gnulib module threadlib
if gl_GNULIB_ENABLED_threadlib
diff --git a/gnulib/lib/dirname-lgpl.c b/gnulib/lib/dirname-lgpl.c
new file mode 100644
index 0000000000..d54f6a910f
--- /dev/null
+++ b/gnulib/lib/dirname-lgpl.c
@@ -0,0 +1,86 @@
+/* dirname.c -- return all but the last element in a file name
+
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2022 Free Software
+ Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* Return the length of the prefix of FILE that will be used by
+ dir_name. If FILE is in the working directory, this returns zero
+ even though 'dir_name (FILE)' will return ".". Works properly even
+ if there are trailing slashes (by effectively ignoring them). */
+
+size_t
+dir_len (char const *file)
+{
+ size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
+ size_t length;
+
+ /* Advance prefix_length beyond important leading slashes. */
+ prefix_length += (prefix_length != 0
+ ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && ISSLASH (file[prefix_length]))
+ : (ISSLASH (file[0])
+ ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && ISSLASH (file[1]) && ! ISSLASH (file[2])
+ ? 2 : 1))
+ : 0));
+
+ /* Strip the basename and any redundant slashes before it. */
+ for (length = last_component (file) - file;
+ prefix_length < length; length--)
+ if (! ISSLASH (file[length - 1]))
+ break;
+ return length;
+}
+
+
+/* In general, we can't use the builtin 'dirname' function if available,
+ since it has different meanings in different environments.
+ In some environments the builtin 'dirname' modifies its argument.
+
+ Return the leading directories part of FILE, allocated with malloc.
+ Works properly even if there are trailing slashes (by effectively
+ ignoring them). Return NULL on failure.
+
+ If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
+ lstat (base_name (FILE)); } will access the same file. Likewise,
+ if the sequence { chdir (dir_name (FILE));
+ rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
+ to "foo" in the same directory FILE was in. */
+
+char *
+mdir_name (char const *file)
+{
+ size_t length = dir_len (file);
+ bool append_dot = (length == 0
+ || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+ && length == FILE_SYSTEM_PREFIX_LEN (file)
+ && file[2] != '\0' && ! ISSLASH (file[2])));
+ char *dir = malloc (length + append_dot + 1);
+ if (!dir)
+ return NULL;
+ memcpy (dir, file, length);
+ if (append_dot)
+ dir[length++] = '.';
+ dir[length] = '\0';
+ return dir;
+}
diff --git a/gnulib/lib/dirname.h b/gnulib/lib/dirname.h
new file mode 100644
index 0000000000..573fa6c1c7
--- /dev/null
+++ b/gnulib/lib/dirname.h
@@ -0,0 +1,53 @@
+/* Take file names apart into directory and base names.
+
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2022 Free Software Foundation,
+ Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef DIRNAME_H_
+# define DIRNAME_H_ 1
+
+# include <stdlib.h>
+# include "filename.h"
+# include "basename-lgpl.h"
+
+# ifndef DIRECTORY_SEPARATOR
+# define DIRECTORY_SEPARATOR '/'
+# endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+# if GNULIB_DIRNAME
+char *base_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+char *dir_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+# endif
+
+char *mdir_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
+size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
+
+bool strip_trailing_slashes (char *file);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* not DIRNAME_H_ */
diff --git a/gnulib/lib/getrandom.c b/gnulib/lib/getrandom.c
new file mode 100644
index 0000000000..c05a48167e
--- /dev/null
+++ b/gnulib/lib/getrandom.c
@@ -0,0 +1,190 @@
+/* Obtain a series of random bytes.
+
+ Copyright 2020-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include <sys/random.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# if HAVE_BCRYPT_H
+# include <bcrypt.h>
+# else
+# define NTSTATUS LONG
+typedef void * BCRYPT_ALG_HANDLE;
+# define BCRYPT_USE_SYSTEM_PREFERRED_RNG 0x00000002
+# if HAVE_LIB_BCRYPT
+extern NTSTATUS WINAPI BCryptGenRandom (BCRYPT_ALG_HANDLE, UCHAR *, ULONG,
ULONG);
+# endif
+# endif
+# if !HAVE_LIB_BCRYPT
+# include <wincrypt.h>
+# ifndef CRYPT_VERIFY_CONTEXT
+# define CRYPT_VERIFY_CONTEXT 0xF0000000
+# endif
+# endif
+#endif
+
+#include "minmax.h"
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+/* Don't assume that UNICODE is not defined. */
+# undef LoadLibrary
+# define LoadLibrary LoadLibraryA
+# undef CryptAcquireContext
+# define CryptAcquireContext CryptAcquireContextA
+
+# if !HAVE_LIB_BCRYPT
+
+/* Avoid warnings from gcc -Wcast-function-type. */
+# define GetProcAddress \
+ (void *) GetProcAddress
+
+/* BCryptGenRandom with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag works only
+ starting with Windows 7. */
+typedef NTSTATUS (WINAPI * BCryptGenRandomFuncType) (BCRYPT_ALG_HANDLE, UCHAR
*, ULONG, ULONG);
+static BCryptGenRandomFuncType BCryptGenRandomFunc = NULL;
+static BOOL initialized = FALSE;
+
+static void
+initialize (void)
+{
+ HMODULE bcrypt = LoadLibrary ("bcrypt.dll");
+ if (bcrypt != NULL)
+ {
+ BCryptGenRandomFunc =
+ (BCryptGenRandomFuncType) GetProcAddress (bcrypt, "BCryptGenRandom");
+ }
+ initialized = TRUE;
+}
+
+# else
+
+# define BCryptGenRandomFunc BCryptGenRandom
+
+# endif
+
+#else
+/* These devices exist on all platforms except native Windows. */
+
+/* Name of a device through which the kernel returns high quality random
+ numbers, from an entropy pool. When the pool is empty, the call blocks
+ until entropy sources have added enough bits of entropy. */
+# ifndef NAME_OF_RANDOM_DEVICE
+# define NAME_OF_RANDOM_DEVICE "/dev/random"
+# endif
+
+/* Name of a device through which the kernel returns random or pseudo-random
+ numbers. It uses an entropy pool, but, in order to avoid blocking, adds
+ bits generated by a pseudo-random number generator, as needed. */
+# ifndef NAME_OF_NONCE_DEVICE
+# define NAME_OF_NONCE_DEVICE "/dev/urandom"
+# endif
+
+#endif
+
+/* Set BUFFER (of size LENGTH) to random bytes under the control of FLAGS.
+ Return the number of bytes written (> 0).
+ Upon error, return -1 and set errno. */
+ssize_t
+getrandom (void *buffer, size_t length, unsigned int flags)
+#undef getrandom
+{
+#if defined _WIN32 && ! defined __CYGWIN__
+ /* BCryptGenRandom, defined in <bcrypt.h>
+
<https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom>
+ with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag
+ works in Windows 7 and newer. */
+ static int bcrypt_not_working /* = 0 */;
+ if (!bcrypt_not_working)
+ {
+# if !HAVE_LIB_BCRYPT
+ if (!initialized)
+ initialize ();
+# endif
+ if (BCryptGenRandomFunc != NULL
+ && BCryptGenRandomFunc (NULL, buffer, length,
+ BCRYPT_USE_SYSTEM_PREFERRED_RNG)
+ == 0 /*STATUS_SUCCESS*/)
+ return length;
+ bcrypt_not_working = 1;
+ }
+# if !HAVE_LIB_BCRYPT
+ /* CryptGenRandom, defined in <wincrypt.h>
+
<https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom>
+ works in older releases as well, but is now deprecated.
+ CryptAcquireContext, defined in <wincrypt.h>
+
<https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta>
*/
+ {
+ static int crypt_initialized /* = 0 */;
+ static HCRYPTPROV provider;
+ if (!crypt_initialized)
+ {
+ if (CryptAcquireContext (&provider, NULL, NULL, PROV_RSA_FULL,
+ CRYPT_VERIFY_CONTEXT))
+ crypt_initialized = 1;
+ else
+ crypt_initialized = -1;
+ }
+ if (crypt_initialized >= 0)
+ {
+ if (!CryptGenRandom (provider, length, buffer))
+ {
+ errno = EIO;
+ return -1;
+ }
+ return length;
+ }
+ }
+# endif
+ errno = ENOSYS;
+ return -1;
+#elif HAVE_GETRANDOM
+ return getrandom (buffer, length, flags);
+#else
+ static int randfd[2] = { -1, -1 };
+ bool devrandom = (flags & GRND_RANDOM) != 0;
+ int fd = randfd[devrandom];
+
+ if (fd < 0)
+ {
+ static char const randdevice[][MAX (sizeof NAME_OF_NONCE_DEVICE,
+ sizeof NAME_OF_RANDOM_DEVICE)]
+ = { NAME_OF_NONCE_DEVICE, NAME_OF_RANDOM_DEVICE };
+ int oflags = (O_RDONLY + O_CLOEXEC
+ + (flags & GRND_NONBLOCK ? O_NONBLOCK : 0));
+ fd = open (randdevice[devrandom], oflags);
+ if (fd < 0)
+ {
+ if (errno == ENOENT || errno == ENOTDIR)
+ errno = ENOSYS;
+ return -1;
+ }
+ randfd[devrandom] = fd;
+ }
+
+ return read (fd, buffer, length);
+#endif
+}
diff --git a/gnulib/lib/lstat.c b/gnulib/lib/lstat.c
new file mode 100644
index 0000000000..472bfbceb9
--- /dev/null
+++ b/gnulib/lib/lstat.c
@@ -0,0 +1,104 @@
+/* Work around a bug of lstat on some systems
+
+ Copyright (C) 1997-2006, 2008-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+ the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
+ rpl_lstat. */
+#define __need_system_sys_stat_h
+#include <config.h>
+
+#if !HAVE_LSTAT
+/* On systems that lack symlinks, our replacement <sys/stat.h> already
+ defined lstat as stat, so there is nothing further to do other than
+ avoid an empty file. */
+typedef int dummy;
+#else /* HAVE_LSTAT */
+
+/* Get the original definition of lstat. It might be defined as a macro. */
+# include <sys/types.h>
+# include <sys/stat.h>
+# undef __need_system_sys_stat_h
+
+static int
+orig_lstat (const char *filename, struct stat *buf)
+{
+ return lstat (filename, buf);
+}
+
+/* Specification. */
+# 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 "stat-time.h"
+
+# include <string.h>
+# include <errno.h>
+
+/* lstat works differently on Linux and Solaris systems. POSIX (see
+ "pathname resolution" in the glossary) requires that programs like
+ 'ls' take into consideration the fact that FILE has a trailing slash
+ when FILE is a symbolic link. On Linux and Solaris 10 systems, the
+ lstat function already has the desired semantics (in treating
+ 'lstat ("symlink/", sbuf)' just like 'lstat ("symlink/.", sbuf)',
+ but on Solaris 9 and earlier it does not.
+
+ If FILE has a trailing slash and specifies a symbolic link,
+ then use stat() to get more info on the referent of FILE.
+ If the referent is a non-directory, then set errno to ENOTDIR
+ and return -1. Otherwise, return stat's result. */
+
+int
+rpl_lstat (const char *file, struct stat *sbuf)
+{
+ int result = orig_lstat (file, sbuf);
+
+ /* This replacement file can blindly check against '/' rather than
+ using the ISSLASH macro, because all platforms with '\\' either
+ lack symlinks (mingw) or have working lstat (cygwin) and thus do
+ not compile this file. 0 len should have already been filtered
+ out above, with a failure return of ENOENT. */
+ if (result == 0)
+ {
+ if (S_ISDIR (sbuf->st_mode) || file[strlen (file) - 1] != '/')
+ result = stat_time_normalize (result, sbuf);
+ else
+ {
+ /* At this point, a trailing slash is permitted only on
+ symlink-to-dir; but it should have found information on the
+ directory, not the symlink. Call 'stat' to get info about the
+ link's referent. Our replacement stat guarantees valid results,
+ even if the symlink is not pointing to a directory. */
+ if (!S_ISLNK (sbuf->st_mode))
+ {
+ errno = ENOTDIR;
+ return -1;
+ }
+ result = stat (file, sbuf);
+ }
+ }
+ return result;
+}
+
+#endif /* HAVE_LSTAT */
diff --git a/gnulib/lib/mkdir.c b/gnulib/lib/mkdir.c
new file mode 100644
index 0000000000..4901701813
--- /dev/null
+++ b/gnulib/lib/mkdir.c
@@ -0,0 +1,93 @@
+/* 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-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* written by Jim Meyering */
+
+#include <config.h>
+
+/* Specification. */
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "dirname.h"
+
+/* Disable the definition of mkdir to rpl_mkdir (from the <sys/stat.h>
+ substitute) in this file. Otherwise, we'd get an endless recursion. */
+#undef mkdir
+
+/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
+ Additionally, it declares _mkdir (and depending on compile flags, an
+ alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+ which are included in the <sys/stat.h> override. */
+#if defined _WIN32 && ! defined __CYGWIN__
+# define mkdir(name,mode) _mkdir (name)
+# define maybe_unused _GL_UNUSED
+#else
+# define maybe_unused /* empty */
+#endif
+
+/* This function is required at least for NetBSD 1.5.2. */
+
+int
+rpl_mkdir (char const *dir, maybe_unused mode_t mode)
+{
+ int ret_val;
+ char *tmp_dir;
+ size_t len = strlen (dir);
+
+ if (len && dir[len - 1] == '/')
+ {
+ tmp_dir = strdup (dir);
+ if (!tmp_dir)
+ {
+ /* Rather than rely on strdup-posix, we set errno ourselves. */
+ errno = ENOMEM;
+ return -1;
+ }
+ strip_trailing_slashes (tmp_dir);
+ }
+ else
+ {
+ tmp_dir = (char *) dir;
+ }
+#if FUNC_MKDIR_DOT_BUG
+ /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */
+ {
+ char *last = last_component (tmp_dir);
+ if (*last == '.' && (last[1] == '\0'
+ || (last[1] == '.' && last[2] == '\0')))
+ {
+ struct stat st;
+ if (stat (tmp_dir, &st) == 0 || errno == EOVERFLOW)
+ errno = EEXIST;
+ return -1;
+ }
+ }
+#endif /* FUNC_MKDIR_DOT_BUG */
+
+ ret_val = mkdir (tmp_dir, mode);
+
+ if (tmp_dir != dir)
+ free (tmp_dir);
+
+ return ret_val;
+}
diff --git a/gnulib/lib/mkstemp.c b/gnulib/lib/mkstemp.c
new file mode 100644
index 0000000000..7e0a214ff7
--- /dev/null
+++ b/gnulib/lib/mkstemp.c
@@ -0,0 +1,50 @@
+/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2022 Free Software
+ Foundation, Inc.
+ This file is derived from the one in the GNU C Library.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+
+#if !_LIBC
+# include "tempname.h"
+# define __gen_tempname gen_tempname
+# ifndef __GT_FILE
+# define __GT_FILE GT_FILE
+# endif
+#endif
+
+#include <stdio.h>
+
+#ifndef __GT_FILE
+# define __GT_FILE 0
+#endif
+
+/* Generate a unique temporary file name from XTEMPLATE.
+ The last six characters of XTEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the file name unique.
+ Then open the file and return a fd.
+
+ If you are creating temporary files which will later be removed,
+ consider using the clean-temp module, which avoids several pitfalls
+ of using mkstemp directly. */
+int
+mkstemp (char *xtemplate)
+{
+ return __gen_tempname (xtemplate, 0, 0, __GT_FILE);
+}
diff --git a/gnulib/lib/stripslash.c b/gnulib/lib/stripslash.c
new file mode 100644
index 0000000000..aee89b78dc
--- /dev/null
+++ b/gnulib/lib/stripslash.c
@@ -0,0 +1,45 @@
+/* stripslash.c -- remove redundant trailing slashes from a file name
+
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2022 Free Software Foundation,
+ Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "dirname.h"
+
+/* Remove trailing slashes from FILE. Return true if a trailing slash
+ was removed. This is useful when using file name completion from a
+ shell that adds a "/" after directory names (such as tcsh and
+ bash), because on symlinks to directories, several system calls
+ have different semantics according to whether a trailing slash is
+ present. */
+
+bool
+strip_trailing_slashes (char *file)
+{
+ char *base = last_component (file);
+ char *base_lim;
+ bool had_slash;
+
+ /* last_component returns "" for file system roots, but we need to turn
+ "///" into "/". */
+ if (! *base)
+ base = file;
+ base_lim = base + base_len (base);
+ had_slash = (*base_lim != '\0');
+ *base_lim = '\0';
+ return had_slash;
+}
diff --git a/gnulib/lib/sys_random.in.h b/gnulib/lib/sys_random.in.h
new file mode 100644
index 0000000000..c91bcd2cd0
--- /dev/null
+++ b/gnulib/lib/sys_random.in.h
@@ -0,0 +1,100 @@
+/* Substitute for <sys/random.h>.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+@PRAGMA_COLUMNS@
+
+#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
+
+#if @HAVE_SYS_RANDOM_H@
+
+/* On uClibc < 1.0.35, <sys/random.h> assumes prior inclusion of <stddef.h>.
+ Do not use __UCLIBC__ here, as it might not be defined yet.
+ But avoid namespace pollution on glibc systems. */
+# ifndef __GLIBC__
+# include <stddef.h>
+# endif
+/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
+ On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
+ includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
+# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+# include <sys/types.h>
+# include <stdlib.h>
+# endif
+
+/* The include_next requires a split double-inclusion guard. */
+# @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@
+
+#endif
+
+#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
+#define _@GUARD_PREFIX@_SYS_RANDOM_H
+
+#include <sys/types.h>
+
+/* Define the GRND_* constants. */
+#ifndef GRND_NONBLOCK
+# define GRND_NONBLOCK 1
+# define GRND_RANDOM 2
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+
+/* Declare overridden functions. */
+
+
+#if @GNULIB_GETRANDOM@
+/* Fill a buffer with random bytes. */
+# if @REPLACE_GETRANDOM@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef getrandom
+# define getrandom rpl_getrandom
+# endif
+_GL_FUNCDECL_RPL (getrandom, ssize_t,
+ (void *buffer, size_t length, unsigned int flags)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getrandom, ssize_t,
+ (void *buffer, size_t length, unsigned int flags));
+# else
+# if !@HAVE_GETRANDOM@
+_GL_FUNCDECL_SYS (getrandom, ssize_t,
+ (void *buffer, size_t length, unsigned int flags)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (getrandom, ssize_t,
+ (void *buffer, size_t length, unsigned int flags));
+# endif
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 25) > 2
+_GL_CXXALIASWARN (getrandom);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getrandom
+# if HAVE_RAW_DECL_GETRANDOM
+_GL_WARN_ON_USE (getrandom, "getrandom is unportable - "
+ "use gnulib module getrandom for portability");
+# endif
+#endif
+
+
+#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
+#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
diff --git a/gnulib/lib/tempname.c b/gnulib/lib/tempname.c
new file mode 100644
index 0000000000..dbff638f70
--- /dev/null
+++ b/gnulib/lib/tempname.c
@@ -0,0 +1,286 @@
+/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+# include <libc-config.h>
+# include "tempname.h"
+#endif
+
+#include <errno.h>
+
+#include <stdio.h>
+#ifndef TMP_MAX
+# define TMP_MAX 238328
+#endif
+#ifndef __GT_FILE
+# define __GT_FILE 0
+# define __GT_DIR 1
+# define __GT_NOCREATE 2
+#endif
+#if !_LIBC && (GT_FILE != __GT_FILE || GT_DIR != __GT_DIR \
+ || GT_NOCREATE != __GT_NOCREATE)
+# error report this to bug-gnulib@gnu.org
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <stdint.h>
+#include <sys/random.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#if _LIBC
+# define struct_stat64 struct __stat64_t64
+#else
+# define struct_stat64 struct stat
+# define __gen_tempname gen_tempname
+# define __mkdir mkdir
+# define __open open
+# define __lstat64_time64(file, buf) lstat (file, buf)
+# define __getrandom getrandom
+# define __clock_gettime64 clock_gettime
+# define __timespec64 timespec
+#endif
+
+/* Use getrandom if it works, falling back on a 64-bit linear
+ congruential generator that starts with Var's value
+ mixed in with a clock's low-order bits if available. */
+typedef uint_fast64_t random_value;
+#define RANDOM_VALUE_MAX UINT_FAST64_MAX
+#define BASE_62_DIGITS 10 /* 62**10 < UINT_FAST64_MAX */
+#define BASE_62_POWER (62LL * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62 * 62)
+
+/* Return the result of mixing the entropy from R and S.
+ Assume that R and S are not particularly random,
+ and that the result should look randomish to an untrained eye. */
+
+static random_value
+mix_random_values (random_value r, random_value s)
+{
+ /* As this code is used only when high-quality randomness is neither
+ available nor necessary, there is no need for fancier polynomials
+ such as those in the Linux kernel's 'random' driver. */
+ return (2862933555777941757 * r + 3037000493) ^ s;
+}
+
+/* Set *R to a random value.
+ Return true if *R is set to high-quality value taken from getrandom.
+ Otherwise return false, falling back to a low-quality *R that might
+ depend on S.
+
+ This function returns false only when getrandom fails.
+ On GNU systems this should happen only early in the boot process,
+ when the fallback should be good enough for programs using tempname
+ because any attacker likely has root privileges already. */
+
+static bool
+random_bits (random_value *r, random_value s)
+{
+ /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */
+ if (__getrandom (r, sizeof *r, GRND_NONBLOCK) == sizeof *r)
+ return true;
+
+ /* If getrandom did not work, use ersatz entropy based on low-order
+ clock bits. On GNU systems getrandom should fail only
+ early in booting, when ersatz should be good enough.
+ Do not use ASLR-based entropy, as that would leak ASLR info into
+ the resulting file name which is typically public.
+
+ Of course we are in a state of sin here. */
+
+ random_value v = s;
+
+#if _LIBC || (defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME)
+ struct __timespec64 tv;
+ __clock_gettime64 (CLOCK_REALTIME, &tv);
+ v = mix_random_values (v, tv.tv_sec);
+ v = mix_random_values (v, tv.tv_nsec);
+#endif
+
+ *r = mix_random_values (v, clock ());
+ return false;
+}
+
+#if _LIBC
+static int try_tempname_len (char *, int, void *, int (*) (char *, void *),
+ size_t);
+#endif
+
+static int
+try_file (char *tmpl, void *flags)
+{
+ int *openflags = flags;
+ return __open (tmpl,
+ (*openflags & ~O_ACCMODE)
+ | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+}
+
+static int
+try_dir (char *tmpl, _GL_UNUSED void *flags)
+{
+ return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
+}
+
+static int
+try_nocreate (char *tmpl, _GL_UNUSED void *flags)
+{
+ struct_stat64 st;
+
+ if (__lstat64_time64 (tmpl, &st) == 0 || errno == EOVERFLOW)
+ __set_errno (EEXIST);
+ return errno == ENOENT ? 0 : -1;
+}
+
+/* These are the characters used in temporary file names. */
+static const char letters[] =
+"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+/* Generate a temporary file name based on TMPL. TMPL must match the
+ rules for mk[s]temp (i.e., end in at least X_SUFFIX_LEN "X"s,
+ possibly with a suffix).
+ The name constructed does not exist at the time of the call to
+ this function. TMPL is overwritten with the result.
+
+ KIND may be one of:
+ __GT_NOCREATE: simply verify that the name does not exist
+ at the time of the call.
+ __GT_FILE: create the file using open(O_CREAT|O_EXCL)
+ and return a read-write fd. The file is mode 0600.
+ __GT_DIR: create a directory, which will be mode 0700.
+
+ */
+#ifdef _LIBC
+static
+#endif
+int
+gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len)
+{
+ static int (*const tryfunc[]) (char *, void *) =
+ {
+ [__GT_FILE] = try_file,
+ [__GT_DIR] = try_dir,
+ [__GT_NOCREATE] = try_nocreate
+ };
+ return try_tempname_len (tmpl, suffixlen, &flags, tryfunc[kind],
+ x_suffix_len);
+}
+
+#ifdef _LIBC
+static
+#endif
+int
+try_tempname_len (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *), size_t x_suffix_len)
+{
+ size_t len;
+ char *XXXXXX;
+ unsigned int count;
+ int fd = -1;
+ int save_errno = errno;
+
+ /* A lower bound on the number of temporary files to attempt to
+ generate. The maximum total number of temporary file names that
+ can exist for a given template is 62**6. It should never be
+ necessary to try all of these combinations. Instead if a reasonable
+ number of names is tried (we define reasonable as 62**3) fail to
+ give the system administrator the chance to remove the problems.
+ This value requires that X_SUFFIX_LEN be at least 3. */
+#define ATTEMPTS_MIN (62 * 62 * 62)
+
+ /* The number of times to attempt to generate a temporary file. To
+ conform to POSIX, this must be no smaller than TMP_MAX. */
+#if ATTEMPTS_MIN < TMP_MAX
+ unsigned int attempts = TMP_MAX;
+#else
+ unsigned int attempts = ATTEMPTS_MIN;
+#endif
+
+ /* A random variable. */
+ random_value v = 0;
+
+ /* A value derived from the random variable, and how many random
+ base-62 digits can currently be extracted from VDIGBUF. */
+ random_value vdigbuf;
+ int vdigits = 0;
+
+ /* Least biased value for V. If V is less than this, V can generate
+ BASE_62_DIGITS unbiased digits. Otherwise the digits are biased. */
+ random_value const biased_min
+ = RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER;
+
+ len = strlen (tmpl);
+ if (len < x_suffix_len + suffixlen
+ || strspn (&tmpl[len - x_suffix_len - suffixlen], "X") < x_suffix_len)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ /* This is where the Xs start. */
+ XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
+
+ for (count = 0; count < attempts; ++count)
+ {
+ for (size_t i = 0; i < x_suffix_len; i++)
+ {
+ if (vdigits == 0)
+ {
+ /* Worry about bias only if the bits are high quality. */
+ while (random_bits (&v, v) && biased_min <= v)
+ continue;
+
+ vdigbuf = v;
+ vdigits = BASE_62_DIGITS;
+ }
+
+ XXXXXX[i] = letters[vdigbuf % 62];
+ vdigbuf /= 62;
+ vdigits--;
+ }
+
+ fd = tryfunc (tmpl, args);
+ if (fd >= 0)
+ {
+ __set_errno (save_errno);
+ return fd;
+ }
+ else if (errno != EEXIST)
+ return -1;
+ }
+
+ /* We got out of the loop because we ran out of combinations to try. */
+ __set_errno (EEXIST);
+ return -1;
+}
+
+int
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
+{
+ return gen_tempname_len (tmpl, suffixlen, flags, kind, 6);
+}
+
+#if !_LIBC
+int
+try_tempname (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *))
+{
+ return try_tempname_len (tmpl, suffixlen, args, tryfunc, 6);
+}
+#endif
diff --git a/gnulib/lib/tempname.h b/gnulib/lib/tempname.h
new file mode 100644
index 0000000000..5e3c5e1550
--- /dev/null
+++ b/gnulib/lib/tempname.h
@@ -0,0 +1,72 @@
+/* Create a temporary file or directory.
+
+ Copyright (C) 2006, 2009-2022 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* header written by Eric Blake */
+
+#ifndef GL_TEMPNAME_H
+# define GL_TEMPNAME_H
+
+# include <stdio.h>
+
+# ifdef __GT_FILE
+# define GT_FILE __GT_FILE
+# define GT_DIR __GT_DIR
+# define GT_NOCREATE __GT_NOCREATE
+# else
+# define GT_FILE 0
+# define GT_DIR 1
+# define GT_NOCREATE 2
+# endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Generate a temporary file name based on TMPL. TMPL must match the
+ rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
+ The name constructed does not exist at the time of the call to
+ gen_tempname. TMPL is overwritten with the result.
+
+ KIND may be one of:
+ GT_NOCREATE: simply verify that the name does not exist
+ at the time of the call.
+ GT_FILE: create a large file using open(O_CREAT|O_EXCL)
+ and return a read-write fd. The file is mode 0600.
+ GT_DIR: create a directory, which will be mode 0700.
+
+ */
+extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
+/* Similar, except X_SUFFIX_LEN gives the number of Xs. */
+extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
+ size_t x_suffix_len);
+
+/* Similar to gen_tempname, but TRYFUNC is called for each temporary
+ name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
+ returns with this value. Otherwise, if errno is set to EEXIST, another
+ name is tried, or else TRY_GEN_TEMPNAME returns -1. */
+extern int try_tempname (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *));
+/* Similar, except X_SUFFIX_LEN gives the number of Xs. */
+extern int try_tempname_len (char *tmpl, int suffixlen, void *args,
+ int (*tryfunc) (char *, void *),
+ size_t x_suffix_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GL_TEMPNAME_H */
diff --git a/gnulib/m4/clock_time.m4 b/gnulib/m4/clock_time.m4
new file mode 100644
index 0000000000..2253553313
--- /dev/null
+++ b/gnulib/m4/clock_time.m4
@@ -0,0 +1,32 @@
+# clock_time.m4 serial 11
+dnl Copyright (C) 2002-2006, 2009-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 with or without modifications, as long as this notice is preserved.
+
+# Check for clock_getres, clock_gettime and clock_settime,
+# and set LIB_CLOCK_GETTIME.
+# For a program named, say foo, you should add a line like the following
+# in the corresponding Makefile.am file:
+# foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
+
+AC_DEFUN([gl_CLOCK_TIME],
+[
+ dnl Persuade glibc and Solaris <time.h> to declare these functions.
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+ # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
+ # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
+
+ # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all*
+ # programs in the package would end up linked with that potentially-shared
+ # library, inducing unnecessary run-time overhead.
+ LIB_CLOCK_GETTIME=
+ AC_SUBST([LIB_CLOCK_GETTIME])
+ gl_saved_libs=$LIBS
+ AC_SEARCH_LIBS([clock_gettime], [rt posix4],
+ [test "$ac_cv_search_clock_gettime" = "none required" ||
+ LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
+ AC_CHECK_FUNCS([clock_getres clock_gettime clock_settime])
+ LIBS=$gl_saved_libs
+])
diff --git a/gnulib/m4/getrandom.m4 b/gnulib/m4/getrandom.m4
new file mode 100644
index 0000000000..6ca715005d
--- /dev/null
+++ b/gnulib/m4/getrandom.m4
@@ -0,0 +1,68 @@
+# getrandom.m4 serial 8
+dnl Copyright 2020-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 with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl_FUNC_GETRANDOM],
+[
+ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
+ AC_CHECK_FUNCS_ONCE([getrandom])
+ if test "$ac_cv_func_getrandom" != yes; then
+ HAVE_GETRANDOM=0
+ else
+ dnl On Solaris 11.4 the return type is 'int', not 'ssize_t'.
+ AC_CACHE_CHECK([whether getrandom is compatible with its GNU+BSD
signature],
+ [gl_cv_func_getrandom_ok],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[/* Additional includes are needed before <sys/random.h> on uClibc
+ and Mac OS X. */
+ #include <sys/types.h>
+ #include <stdlib.h>
+ #include <sys/random.h>
+ ssize_t getrandom (void *, size_t, unsigned int);
+ ]],
+ [[]])
+ ],
+ [gl_cv_func_getrandom_ok=yes],
+ [gl_cv_func_getrandom_ok=no])
+ ])
+ if test $gl_cv_func_getrandom_ok = no; then
+ REPLACE_GETRANDOM=1
+ fi
+ fi
+
+ case "$host_os" in
+ mingw*)
+ AC_CHECK_HEADERS([bcrypt.h], [], [],
+ [[#include <windows.h>
+ ]])
+ AC_CACHE_CHECK([whether the bcrypt library is guaranteed to be present],
+ [gl_cv_lib_assume_bcrypt],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <windows.h>]],
+ [[#if !(_WIN32_WINNT >= _WIN32_WINNT_WIN7)
+ cannot assume it
+ #endif
+ ]])
+ ],
+ [gl_cv_lib_assume_bcrypt=yes],
+ [gl_cv_lib_assume_bcrypt=no])
+ ])
+ if test $gl_cv_lib_assume_bcrypt = yes; then
+ AC_DEFINE([HAVE_LIB_BCRYPT], [1],
+ [Define to 1 if the bcrypt library is guaranteed to be present.])
+ LIB_GETRANDOM='-lbcrypt'
+ else
+ LIB_GETRANDOM='-ladvapi32'
+ fi
+ ;;
+ *)
+ LIB_GETRANDOM= ;;
+ esac
+ AC_SUBST([LIB_GETRANDOM])
+])
diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4
index 64f14ffcc2..18f658723f 100644
--- a/gnulib/m4/gnulib-cache.m4
+++ b/gnulib/m4/gnulib-cache.m4
@@ -51,6 +51,7 @@
# mbsstr \
# mbswidth \
# memrchr \
+# mkstemp \
# regex \
# stdarg \
# strcasestr \
@@ -75,6 +76,7 @@ gl_MODULES([
mbsstr
mbswidth
memrchr
+ mkstemp
regex
stdarg
strcasestr
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index 5db26957ef..7b4d9c8de7 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -53,8 +53,10 @@ AC_DEFUN([gl_EARLY],
# Code from module c99:
# Code from module calloc-gnu:
# Code from module calloc-posix:
+ # Code from module clock-time:
# Code from module cloexec:
# Code from module close:
+ # Code from module dirname-lgpl:
# Code from module double-slash-root:
# Code from module dup2:
# Code from module dynarray:
@@ -75,6 +77,7 @@ AC_DEFUN([gl_EARLY],
# Code from module getopt-gnu:
# Code from module getopt-posix:
# Code from module getprogname:
+ # Code from module getrandom:
# Code from module gettext-h:
# Code from module hard-locale:
# Code from module havelib:
@@ -97,6 +100,7 @@ AC_DEFUN([gl_EARLY],
# Code from module locale:
# Code from module localeconv:
# Code from module lock:
+ # Code from module lstat:
# Code from module malloc-gnu:
# Code from module malloc-posix:
# Code from module malloca:
@@ -116,6 +120,8 @@ AC_DEFUN([gl_EARLY],
# Code from module mempcpy:
# Code from module memrchr:
# Code from module minmax:
+ # Code from module mkdir:
+ # Code from module mkstemp:
# Code from module msvc-inval:
# Code from module msvc-nothrow:
# Code from module multiarch:
@@ -162,8 +168,10 @@ AC_DEFUN([gl_EARLY],
# Code from module strnlen1:
# Code from module strstr:
# Code from module strstr-simple:
+ # Code from module sys_random:
# Code from module sys_stat:
# Code from module sys_types:
+ # Code from module tempname:
# Code from module threadlib:
gl_THREADLIB_EARLY
# Code from module time:
@@ -335,6 +343,13 @@ AC_DEFUN([gl_INIT],
])
gl_STRING_MODULE_INDICATOR([memrchr])
gl_MINMAX
+ gl_FUNC_MKSTEMP
+ gl_CONDITIONAL([GL_COND_OBJ_MKSTEMP],
+ [test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1])
+ AM_COND_IF([GL_COND_OBJ_MKSTEMP], [
+ gl_PREREQ_MKSTEMP
+ ])
+ gl_STDLIB_MODULE_INDICATOR([mkstemp])
gl_MULTIARCH
gl_FUNC_OPEN
gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
@@ -492,8 +507,10 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_attribute=false
gl_gnulib_enabled_btowc=false
gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=false
+ gl_gnulib_enabled_c58c2549aa84fceb9f0ca39c3eb5c7bd=false
gl_gnulib_enabled_cloexec=false
gl_gnulib_enabled_close=false
+ gl_gnulib_enabled_a691da99c1d83b83238e45f41a696f5c=false
gl_gnulib_enabled_dup2=false
gl_gnulib_enabled_dynarray=false
gl_gnulib_enabled_errno=false
@@ -503,6 +520,7 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955=false
gl_gnulib_enabled_fstat=false
gl_gnulib_enabled_getdtablesize=false
+ gl_gnulib_enabled_getrandom=false
gl_gnulib_enabled_30838f5439487421042f2225bed3af76=false
gl_gnulib_enabled_intprops=false
gl_gnulib_enabled_langinfo=false
@@ -511,8 +529,10 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_locale=false
gl_gnulib_enabled_localeconv=false
gl_gnulib_enabled_lock=false
+ gl_gnulib_enabled_lstat=false
gl_gnulib_enabled_mbtowc=false
gl_gnulib_enabled_mempcpy=false
+ gl_gnulib_enabled_mkdir=false
gl_gnulib_enabled_f691f076f650964c9f5598c3ee487616=false
gl_gnulib_enabled_676220fa4366efa9bdbfccf11a857c07=false
gl_gnulib_enabled_nl_langinfo=false
@@ -527,7 +547,9 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_strndup=false
gl_gnulib_enabled_strstr=false
gl_gnulib_enabled_f84f170cca5f5b09d22686d5b833aa41=false
+ gl_gnulib_enabled_sys_random=false
gl_gnulib_enabled_sys_stat=false
+ gl_gnulib_enabled_tempname=false
gl_gnulib_enabled_threadlib=false
gl_gnulib_enabled_time=false
gl_gnulib_enabled_unitypes=false
@@ -570,6 +592,13 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=true
fi
}
+ func_gl_gnulib_m4code_c58c2549aa84fceb9f0ca39c3eb5c7bd ()
+ {
+ if ! $gl_gnulib_enabled_c58c2549aa84fceb9f0ca39c3eb5c7bd; then
+ gl_CLOCK_TIME
+ gl_gnulib_enabled_c58c2549aa84fceb9f0ca39c3eb5c7bd=true
+ fi
+ }
func_gl_gnulib_m4code_cloexec ()
{
if ! $gl_gnulib_enabled_cloexec; then
@@ -594,6 +623,12 @@ AC_DEFUN([gl_INIT],
fi
fi
}
+ func_gl_gnulib_m4code_a691da99c1d83b83238e45f41a696f5c ()
+ {
+ if ! $gl_gnulib_enabled_a691da99c1d83b83238e45f41a696f5c; then
+ gl_gnulib_enabled_a691da99c1d83b83238e45f41a696f5c=true
+ fi
+ }
func_gl_gnulib_m4code_dup2 ()
{
if ! $gl_gnulib_enabled_dup2; then
@@ -728,6 +763,18 @@ AC_DEFUN([gl_INIT],
fi
fi
}
+ func_gl_gnulib_m4code_getrandom ()
+ {
+ if ! $gl_gnulib_enabled_getrandom; then
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ gl_FUNC_GETRANDOM
+ gl_CONDITIONAL([GL_COND_OBJ_GETRANDOM],
+ [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1])
+ gl_SYS_RANDOM_MODULE_INDICATOR([getrandom])
+ gl_gnulib_enabled_getrandom=true
+ func_gl_gnulib_m4code_sys_random
+ fi
+ }
func_gl_gnulib_m4code_30838f5439487421042f2225bed3af76 ()
{
if ! $gl_gnulib_enabled_30838f5439487421042f2225bed3af76; then
@@ -813,6 +860,25 @@ AC_DEFUN([gl_INIT],
fi
fi
}
+ func_gl_gnulib_m4code_lstat ()
+ {
+ if ! $gl_gnulib_enabled_lstat; then
+ gl_FUNC_LSTAT
+ gl_CONDITIONAL([GL_COND_OBJ_LSTAT], [test $REPLACE_LSTAT = 1])
+ AM_COND_IF([GL_COND_OBJ_LSTAT], [
+ gl_PREREQ_LSTAT
+ ])
+ gl_SYS_STAT_MODULE_INDICATOR([lstat])
+ gl_gnulib_enabled_lstat=true
+ if test $REPLACE_LSTAT = 1; then
+ func_gl_gnulib_m4code_stat
+ fi
+ if test $REPLACE_LSTAT = 1; then
+ func_gl_gnulib_m4code_0137e3d3638b33e5819d132d0b23165c
+ fi
+ func_gl_gnulib_m4code_sys_stat
+ fi
+ }
func_gl_gnulib_m4code_mbtowc ()
{
if ! $gl_gnulib_enabled_mbtowc; then
@@ -838,6 +904,22 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_mempcpy=true
fi
}
+ func_gl_gnulib_m4code_mkdir ()
+ {
+ if ! $gl_gnulib_enabled_mkdir; then
+ gl_FUNC_MKDIR
+ gl_CONDITIONAL([GL_COND_OBJ_MKDIR], [test $REPLACE_MKDIR = 1])
+ gl_SYS_STAT_MODULE_INDICATOR([mkdir])
+ gl_gnulib_enabled_mkdir=true
+ if test $REPLACE_MKDIR = 1; then
+ func_gl_gnulib_m4code_a691da99c1d83b83238e45f41a696f5c
+ fi
+ if test $REPLACE_MKDIR = 1; then
+ func_gl_gnulib_m4code_stat
+ fi
+ func_gl_gnulib_m4code_sys_stat
+ fi
+ }
func_gl_gnulib_m4code_f691f076f650964c9f5598c3ee487616 ()
{
if ! $gl_gnulib_enabled_f691f076f650964c9f5598c3ee487616; then
@@ -1009,6 +1091,15 @@ AC_DEFUN([gl_INIT],
fi
fi
}
+ func_gl_gnulib_m4code_sys_random ()
+ {
+ if ! $gl_gnulib_enabled_sys_random; then
+ gl_SYS_RANDOM_H
+ gl_SYS_RANDOM_H_REQUIRE_DEFAULTS
+ AC_PROG_MKDIR_P
+ gl_gnulib_enabled_sys_random=true
+ fi
+ }
func_gl_gnulib_m4code_sys_stat ()
{
if ! $gl_gnulib_enabled_sys_stat; then
@@ -1019,6 +1110,21 @@ AC_DEFUN([gl_INIT],
func_gl_gnulib_m4code_time
fi
}
+ func_gl_gnulib_m4code_tempname ()
+ {
+ if ! $gl_gnulib_enabled_tempname; then
+ gl_FUNC_GEN_TEMPNAME
+ gl_MODULE_INDICATOR([tempname])
+ gl_gnulib_enabled_tempname=true
+ func_gl_gnulib_m4code_c58c2549aa84fceb9f0ca39c3eb5c7bd
+ func_gl_gnulib_m4code_getrandom
+ func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467
+ func_gl_gnulib_m4code_lstat
+ func_gl_gnulib_m4code_mkdir
+ func_gl_gnulib_m4code_sys_stat
+ func_gl_gnulib_m4code_time
+ fi
+ }
func_gl_gnulib_m4code_threadlib ()
{
if ! $gl_gnulib_enabled_threadlib; then
@@ -1180,6 +1286,9 @@ AC_DEFUN([gl_INIT],
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
func_gl_gnulib_m4code_streq
fi
+ if test $HAVE_MKSTEMP = 0 || test $REPLACE_MKSTEMP = 1; then
+ func_gl_gnulib_m4code_tempname
+ fi
if test $REPLACE_OPEN = 1; then
func_gl_gnulib_m4code_cloexec
fi
@@ -1256,8 +1365,10 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_attribute], [$gl_gnulib_enabled_attribute])
AM_CONDITIONAL([gl_GNULIB_ENABLED_btowc], [$gl_gnulib_enabled_btowc])
AM_CONDITIONAL([gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547],
[$gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_c58c2549aa84fceb9f0ca39c3eb5c7bd],
[$gl_gnulib_enabled_c58c2549aa84fceb9f0ca39c3eb5c7bd])
AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec])
AM_CONDITIONAL([gl_GNULIB_ENABLED_close], [$gl_gnulib_enabled_close])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_a691da99c1d83b83238e45f41a696f5c],
[$gl_gnulib_enabled_a691da99c1d83b83238e45f41a696f5c])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dup2], [$gl_gnulib_enabled_dup2])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dynarray], [$gl_gnulib_enabled_dynarray])
AM_CONDITIONAL([gl_GNULIB_ENABLED_errno], [$gl_gnulib_enabled_errno])
@@ -1267,6 +1378,7 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_ef07dc4b3077c11ea9cef586db4e5955],
[$gl_gnulib_enabled_ef07dc4b3077c11ea9cef586db4e5955])
AM_CONDITIONAL([gl_GNULIB_ENABLED_fstat], [$gl_gnulib_enabled_fstat])
AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize],
[$gl_gnulib_enabled_getdtablesize])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_getrandom], [$gl_gnulib_enabled_getrandom])
AM_CONDITIONAL([gl_GNULIB_ENABLED_30838f5439487421042f2225bed3af76],
[$gl_gnulib_enabled_30838f5439487421042f2225bed3af76])
AM_CONDITIONAL([gl_GNULIB_ENABLED_intprops], [$gl_gnulib_enabled_intprops])
AM_CONDITIONAL([gl_GNULIB_ENABLED_langinfo], [$gl_gnulib_enabled_langinfo])
@@ -1275,8 +1387,10 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_locale], [$gl_gnulib_enabled_locale])
AM_CONDITIONAL([gl_GNULIB_ENABLED_localeconv],
[$gl_gnulib_enabled_localeconv])
AM_CONDITIONAL([gl_GNULIB_ENABLED_lock], [$gl_gnulib_enabled_lock])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_lstat], [$gl_gnulib_enabled_lstat])
AM_CONDITIONAL([gl_GNULIB_ENABLED_mbtowc], [$gl_gnulib_enabled_mbtowc])
AM_CONDITIONAL([gl_GNULIB_ENABLED_mempcpy], [$gl_gnulib_enabled_mempcpy])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_mkdir], [$gl_gnulib_enabled_mkdir])
AM_CONDITIONAL([gl_GNULIB_ENABLED_f691f076f650964c9f5598c3ee487616],
[$gl_gnulib_enabled_f691f076f650964c9f5598c3ee487616])
AM_CONDITIONAL([gl_GNULIB_ENABLED_676220fa4366efa9bdbfccf11a857c07],
[$gl_gnulib_enabled_676220fa4366efa9bdbfccf11a857c07])
AM_CONDITIONAL([gl_GNULIB_ENABLED_nl_langinfo],
[$gl_gnulib_enabled_nl_langinfo])
@@ -1291,7 +1405,9 @@ AC_DEFUN([gl_INIT],
AM_CONDITIONAL([gl_GNULIB_ENABLED_strndup], [$gl_gnulib_enabled_strndup])
AM_CONDITIONAL([gl_GNULIB_ENABLED_strstr], [$gl_gnulib_enabled_strstr])
AM_CONDITIONAL([gl_GNULIB_ENABLED_f84f170cca5f5b09d22686d5b833aa41],
[$gl_gnulib_enabled_f84f170cca5f5b09d22686d5b833aa41])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_sys_random],
[$gl_gnulib_enabled_sys_random])
AM_CONDITIONAL([gl_GNULIB_ENABLED_sys_stat], [$gl_gnulib_enabled_sys_stat])
+ AM_CONDITIONAL([gl_GNULIB_ENABLED_tempname], [$gl_gnulib_enabled_tempname])
AM_CONDITIONAL([gl_GNULIB_ENABLED_threadlib], [$gl_gnulib_enabled_threadlib])
AM_CONDITIONAL([gl_GNULIB_ENABLED_time], [$gl_gnulib_enabled_time])
AM_CONDITIONAL([gl_GNULIB_ENABLED_unitypes], [$gl_gnulib_enabled_unitypes])
@@ -1497,6 +1613,8 @@ AC_DEFUN([gl_FILE_LIST], [
lib/cloexec.c
lib/cloexec.h
lib/close.c
+ lib/dirname-lgpl.c
+ lib/dirname.h
lib/dup2.c
lib/dynarray.h
lib/errno.in.h
@@ -1526,6 +1644,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/getopt_int.h
lib/getprogname.c
lib/getprogname.h
+ lib/getrandom.c
lib/gettext.h
lib/glthread/lock.c
lib/glthread/lock.h
@@ -1551,6 +1670,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/localcharset.h
lib/locale.in.h
lib/localeconv.c
+ lib/lstat.c
lib/malloc.c
lib/malloc/dynarray-skeleton.c
lib/malloc/dynarray.h
@@ -1587,6 +1707,8 @@ AC_DEFUN([gl_FILE_LIST], [
lib/mempcpy.c
lib/memrchr.c
lib/minmax.h
+ lib/mkdir.c
+ lib/mkstemp.c
lib/msvc-inval.c
lib/msvc-inval.h
lib/msvc-nothrow.c
@@ -1636,14 +1758,18 @@ AC_DEFUN([gl_FILE_LIST], [
lib/strerror.c
lib/string.in.h
lib/strings.in.h
+ lib/stripslash.c
lib/strncasecmp.c
lib/strndup.c
lib/strnlen.c
lib/strnlen1.c
lib/strnlen1.h
lib/strstr.c
+ lib/sys_random.in.h
lib/sys_stat.in.h
lib/sys_types.in.h
+ lib/tempname.c
+ lib/tempname.h
lib/time.in.h
lib/unictype/bitmap.h
lib/unistd.c
@@ -1689,6 +1815,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/builtin-expect.m4
m4/c-bool.m4
m4/calloc.m4
+ m4/clock_time.m4
m4/close.m4
m4/codeset.m4
m4/double-slash-root.m4
@@ -1708,6 +1835,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/getdtablesize.m4
m4/getopt.m4
m4/getprogname.m4
+ m4/getrandom.m4
m4/gnulib-common.m4
m4/host-cpu-c-abi.m4
m4/iconv.m4
@@ -1732,6 +1860,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/locale_h.m4
m4/localeconv.m4
m4/lock.m4
+ m4/lstat.m4
m4/malloc.m4
m4/malloca.m4
m4/math_h.m4
@@ -1747,6 +1876,8 @@ AC_DEFUN([gl_FILE_LIST], [
m4/mempcpy.m4
m4/memrchr.m4
m4/minmax.m4
+ m4/mkdir.m4
+ m4/mkstemp.m4
m4/mmap-anon.m4
m4/mode_t.m4
m4/msvc-inval.m4
@@ -1787,9 +1918,11 @@ AC_DEFUN([gl_FILE_LIST], [
m4/strndup.m4
m4/strnlen.m4
m4/strstr.m4
+ m4/sys_random_h.m4
m4/sys_socket_h.m4
m4/sys_stat_h.m4
m4/sys_types_h.m4
+ m4/tempname.m4
m4/threadlib.m4
m4/time_h.m4
m4/unistd_h.m4
diff --git a/gnulib/m4/lstat.m4 b/gnulib/m4/lstat.m4
new file mode 100644
index 0000000000..d987060bd1
--- /dev/null
+++ b/gnulib/m4/lstat.m4
@@ -0,0 +1,79 @@
+# serial 33
+
+# Copyright (C) 1997-2001, 2003-2022 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+dnl From Jim Meyering.
+
+AC_DEFUN([gl_FUNC_LSTAT],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+ dnl If lstat does not exist, the replacement <sys/stat.h> does
+ dnl "#define lstat stat", and lstat.c is a no-op.
+ AC_CHECK_FUNCS_ONCE([lstat])
+ if test $ac_cv_func_lstat = yes; then
+ AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
+ case $host_os,$gl_cv_func_lstat_dereferences_slashed_symlink in
+ solaris* | *no)
+ REPLACE_LSTAT=1
+ ;;
+ esac
+ else
+ HAVE_LSTAT=0
+ fi
+])
+
+# Prerequisites of lib/lstat.c.
+AC_DEFUN([gl_PREREQ_LSTAT], [:])
+
+AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
+[
+ dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
+ dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
+ [gl_cv_func_lstat_dereferences_slashed_symlink],
+ [rm -f conftest.sym conftest.file
+ echo >conftest.file
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT],
+ [[struct stat sbuf;
+ if (symlink ("conftest.file", "conftest.sym") != 0)
+ return 1;
+ /* 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;
+ ]])],
+ [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
+ [gl_cv_func_lstat_dereferences_slashed_symlink=no],
+ [case "$host_os" in
+ linux-* | linux)
+ # Guess yes on Linux systems.
+ gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
+ *-gnu* | gnu*)
+ # Guess yes on glibc systems.
+ gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
+ mingw*)
+ # Guess no on native Windows.
+ gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
+ *)
+ # If we don't know, obey --enable-cross-guesses.
+
gl_cv_func_lstat_dereferences_slashed_symlink="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ rm -f conftest.sym conftest.file
+ ])
+ case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
+ *yes)
+ AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
+ [Define to 1 if 'lstat' dereferences a symlink specified
+ with a trailing slash.])
+ ;;
+ esac
+])
diff --git a/gnulib/m4/mkdir.m4 b/gnulib/m4/mkdir.m4
new file mode 100644
index 0000000000..8b78ce960c
--- /dev/null
+++ b/gnulib/m4/mkdir.m4
@@ -0,0 +1,87 @@
+# serial 17
+
+# Copyright (C) 2001, 2003-2004, 2006, 2008-2022 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.
+
+# On some systems, mkdir ("foo/", 0700) fails because of the trailing slash.
+# On others, mkdir ("foo/./", 0700) mistakenly succeeds.
+# On such systems, arrange to use a wrapper function.
+AC_DEFUN([gl_FUNC_MKDIR],
+[dnl
+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CHECK_HEADERS_ONCE([unistd.h])
+ AC_CACHE_CHECK([whether mkdir handles trailing slash],
+ [gl_cv_func_mkdir_trailing_slash_works],
+ [rm -rf conftest.dir
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ ]GL_MDA_DEFINES],
+ [[return mkdir ("conftest.dir/", 0700);]])],
+ [gl_cv_func_mkdir_trailing_slash_works=yes],
+ [gl_cv_func_mkdir_trailing_slash_works=no],
+ [case "$host_os" in
+ # Guess yes on Linux systems.
+ linux-* | linux) gl_cv_func_mkdir_trailing_slash_works="guessing
yes" ;;
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) gl_cv_func_mkdir_trailing_slash_works="guessing
yes" ;;
+ # Guess yes on MSVC, no on mingw.
+ mingw*) AC_EGREP_CPP([Known], [
+#ifdef _MSC_VER
+ Known
+#endif
+ ],
+ [gl_cv_func_mkdir_trailing_slash_works="guessing
yes"],
+ [gl_cv_func_mkdir_trailing_slash_works="guessing
no"])
+ ;;
+ # If we don't know, obey --enable-cross-guesses.
+ *)
gl_cv_func_mkdir_trailing_slash_works="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ rm -rf conftest.dir
+ ])
+ case "$gl_cv_func_mkdir_trailing_slash_works" in
+ *yes) ;;
+ *)
+ REPLACE_MKDIR=1
+ ;;
+ esac
+
+ AC_CACHE_CHECK([whether mkdir handles trailing dot],
+ [gl_cv_func_mkdir_trailing_dot_works],
+ [rm -rf conftest.dir
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ ]GL_MDA_DEFINES],
+ [[return !mkdir ("conftest.dir/./", 0700);]])],
+ [gl_cv_func_mkdir_trailing_dot_works=yes],
+ [gl_cv_func_mkdir_trailing_dot_works=no],
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;;
+ # Guess yes on musl systems.
+ *-musl*) gl_cv_func_mkdir_trailing_dot_works="guessing yes" ;;
+ # Guess no on native Windows.
+ mingw*) gl_cv_func_mkdir_trailing_dot_works="guessing no" ;;
+ # If we don't know, obey --enable-cross-guesses.
+ *)
gl_cv_func_mkdir_trailing_dot_works="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ rm -rf conftest.dir
+ ]
+ )
+ case "$gl_cv_func_mkdir_trailing_dot_works" in
+ *yes) ;;
+ *)
+ REPLACE_MKDIR=1
+ AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly
+ creates a directory given with a trailing dot component.])
+ ;;
+ esac
+])
diff --git a/gnulib/m4/mkstemp.m4 b/gnulib/m4/mkstemp.m4
new file mode 100644
index 0000000000..322f4bcd74
--- /dev/null
+++ b/gnulib/m4/mkstemp.m4
@@ -0,0 +1,87 @@
+#serial 28
+
+# Copyright (C) 2001, 2003-2007, 2009-2022 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.
+
+# On some hosts (e.g., HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a
+# silly limit that it can create no more than 26 files from a given template.
+# Other systems lack mkstemp altogether.
+# On OSF1/Tru64 V4.0F, the system-provided mkstemp function can create
+# only 32 files per process.
+# On some hosts, mkstemp creates files with mode 0666, which is a security
+# problem and a violation of POSIX 2008.
+# On systems like the above, arrange to use the replacement function.
+AC_DEFUN([gl_FUNC_MKSTEMP],
+[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+ AC_CHECK_FUNCS_ONCE([mkstemp])
+ if test $ac_cv_func_mkstemp = yes; then
+ AC_CACHE_CHECK([for working mkstemp],
+ [gl_cv_func_working_mkstemp],
+ [
+ mkdir conftest.mkstemp
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [AC_INCLUDES_DEFAULT
+ GL_MDA_DEFINES],
+ [[int result = 0;
+ int i;
+ off_t large = (off_t) 4294967295u;
+ if (large < 0)
+ large = 2147483647;
+ umask (0);
+ for (i = 0; i < 70; i++)
+ {
+ char templ[] = "conftest.mkstemp/coXXXXXX";
+ int (*mkstemp_function) (char *) = mkstemp;
+ int fd = mkstemp_function (templ);
+ if (fd < 0)
+ result |= 1;
+ else
+ {
+ struct stat st;
+ if (lseek (fd, large, SEEK_SET) != large)
+ result |= 2;
+ if (fstat (fd, &st) < 0)
+ result |= 4;
+ else if (st.st_mode & 0077)
+ result |= 8;
+ if (close (fd))
+ result |= 16;
+ }
+ }
+ return result;]])],
+ [gl_cv_func_working_mkstemp=yes],
+ [gl_cv_func_working_mkstemp=no],
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu* | gnu*) gl_cv_func_working_mkstemp="guessing yes" ;;
+ # Guess yes on musl systems.
+ *-musl*) gl_cv_func_working_mkstemp="guessing yes" ;;
+ # Guess no on native Windows.
+ mingw*) gl_cv_func_working_mkstemp="guessing no" ;;
+ # If we don't know, obey --enable-cross-guesses.
+ *)
gl_cv_func_working_mkstemp="$gl_cross_guess_normal" ;;
+ esac
+ ])
+ rm -rf conftest.mkstemp
+ ])
+ case "$gl_cv_func_working_mkstemp" in
+ *yes) ;;
+ *)
+ REPLACE_MKSTEMP=1
+ ;;
+ esac
+ else
+ HAVE_MKSTEMP=0
+ fi
+])
+
+# Prerequisites of lib/mkstemp.c.
+AC_DEFUN([gl_PREREQ_MKSTEMP],
+[
+])
diff --git a/gnulib/m4/sys_random_h.m4 b/gnulib/m4/sys_random_h.m4
new file mode 100644
index 0000000000..a5ba85c67c
--- /dev/null
+++ b/gnulib/m4/sys_random_h.m4
@@ -0,0 +1,68 @@
+# sys_random_h.m4 serial 8
+dnl Copyright (C) 2020-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 with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_SYS_RANDOM_H],
+[
+ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
+ dnl <sys/random.h> is always overridden, because of GNULIB_POSIXCHECK.
+ gl_CHECK_NEXT_HEADERS([sys/random.h])
+ if test $ac_cv_header_sys_random_h = yes; then
+ HAVE_SYS_RANDOM_H=1
+ else
+ HAVE_SYS_RANDOM_H=0
+ fi
+ AC_SUBST([HAVE_SYS_RANDOM_H])
+
+ m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
+ if test $ac_cv_header_sys_random_h = yes; then
+ UNISTD_H_HAVE_SYS_RANDOM_H=1
+ fi
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+#if HAVE_SYS_RANDOM_H
+/* Additional includes are needed before <sys/random.h> on uClibc
+ and Mac OS X. */
+# include <sys/types.h>
+# include <stdlib.h>
+# include <sys/random.h>
+#endif
+ ]],
+ [getrandom])
+])
+
+# gl_SYS_RANDOM_MODULE_INDICATOR([modulename])
+# sets the shell variable that indicates the presence of the given module
+# to a C preprocessor expression that will evaluate to 1.
+# This macro invocation must not occur in macros that are AC_REQUIREd.
+AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR],
+[
+ dnl Ensure to expand the default settings once only.
+ gl_SYS_RANDOM_H_REQUIRE_DEFAULTS
+ gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+ dnl Define it also as a C macro, for the benefit of the unit tests.
+ gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+# Initializes the default values for AC_SUBSTed shell variables.
+# This macro must not be AC_REQUIREd. It must only be invoked, and only
+# outside of macros or in macros that are not AC_REQUIREd.
+AC_DEFUN([gl_SYS_RANDOM_H_REQUIRE_DEFAULTS],
+[
+
m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS], [
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETRANDOM])
+ ])
+
m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS])
+ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
+])
+
+AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS],
+[
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM])
+ REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM])
+])
diff --git a/gnulib/m4/tempname.m4 b/gnulib/m4/tempname.m4
new file mode 100644
index 0000000000..22ccec1f8d
--- /dev/null
+++ b/gnulib/m4/tempname.m4
@@ -0,0 +1,19 @@
+#serial 5
+
+# Copyright (C) 2006-2007, 2009-2022 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.
+
+# glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose
+# it as a public API, and provide it on systems that are lacking.
+AC_DEFUN([gl_FUNC_GEN_TEMPNAME],
+[
+ gl_PREREQ_TEMPNAME
+])
+
+# Prerequisites of lib/tempname.c.
+AC_DEFUN([gl_PREREQ_TEMPNAME],
+[
+ :
+])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Run gnulib-tool --add-import mkstemp.,
Gavin D. Smith <=