summaryrefslogtreecommitdiffstats
path: root/libgnu
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-07-17 09:14:31 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-07-20 14:45:07 +0000
commit6166020e5f1acc87c3f00f0d2f15f073971be545 (patch)
tree14720ecb9d6e28847c78fa77a931a5328e8afe31 /libgnu
parent191f0057b0b978a0e5bf9168acdcc381b4196494 (diff)
Update gnulib modules, replacing canonicalize with canonicalize-lgpl
We need realpath() now, as upstream has changed to use that. Updating single gnulib modules is not really possible, so we update everything. Change-Id: I32943a1c8af7c1ecce625dca173a942cc58d9c38 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'libgnu')
-rw-r--r--libgnu/alignof.h4
-rw-r--r--libgnu/alloca.in.h4
-rw-r--r--libgnu/areadlink-with-size.c104
-rw-r--r--libgnu/areadlink.h33
-rw-r--r--libgnu/arg-nonnull.h4
-rw-r--r--libgnu/argp-ba.c8
-rw-r--r--libgnu/argp-eexst.c4
-rw-r--r--libgnu/argp-fmtstream.c4
-rw-r--r--libgnu/argp-fmtstream.h4
-rw-r--r--libgnu/argp-fs-xinl.c4
-rw-r--r--libgnu/argp-help.c13
-rw-r--r--libgnu/argp-namefrob.h4
-rw-r--r--libgnu/argp-parse.c19
-rw-r--r--libgnu/argp-pin.c4
-rw-r--r--libgnu/argp-pv.c8
-rw-r--r--libgnu/argp-pvh.c4
-rw-r--r--libgnu/argp-xinl.c4
-rw-r--r--libgnu/argp.h4
-rw-r--r--libgnu/asnprintf.c4
-rw-r--r--libgnu/assure.h4
-rw-r--r--libgnu/at-func.c4
-rw-r--r--libgnu/basename-lgpl.c4
-rw-r--r--libgnu/basename.c58
-rw-r--r--libgnu/bitrotate.h4
-rw-r--r--libgnu/c++defs.h8
-rw-r--r--libgnu/canonicalize-lgpl.c428
-rw-r--r--libgnu/canonicalize.c354
-rw-r--r--libgnu/canonicalize.h48
-rw-r--r--libgnu/chdir-long.c4
-rw-r--r--libgnu/chdir-long.h4
-rw-r--r--libgnu/cloexec.c6
-rw-r--r--libgnu/cloexec.h6
-rw-r--r--libgnu/close.c8
-rw-r--r--libgnu/closedir.c4
-rw-r--r--libgnu/config.charset682
-rw-r--r--libgnu/creat-safer.c4
-rw-r--r--libgnu/cycle-check.c4
-rw-r--r--libgnu/cycle-check.h4
-rw-r--r--libgnu/dirent--.h24
-rw-r--r--libgnu/dirent-private.h4
-rw-r--r--libgnu/dirent-safer.h22
-rw-r--r--libgnu/dirent.in.h4
-rw-r--r--libgnu/dirfd.c4
-rw-r--r--libgnu/dirname-lgpl.c4
-rw-r--r--libgnu/dirname.c38
-rw-r--r--libgnu/dirname.h6
-rw-r--r--libgnu/dosname.h9
-rw-r--r--libgnu/dup-safer-flag.c38
-rw-r--r--libgnu/dup-safer.c4
-rw-r--r--libgnu/dup.c8
-rw-r--r--libgnu/dup2.c52
-rw-r--r--libgnu/errno.in.h8
-rw-r--r--libgnu/error.c31
-rw-r--r--libgnu/error.h4
-rw-r--r--libgnu/exitfail.c4
-rw-r--r--libgnu/exitfail.h4
-rw-r--r--libgnu/fchdir.c4
-rw-r--r--libgnu/fcntl--.h4
-rw-r--r--libgnu/fcntl-safer.h4
-rw-r--r--libgnu/fcntl.c14
-rw-r--r--libgnu/fcntl.in.h11
-rw-r--r--libgnu/fd-hook.c6
-rw-r--r--libgnu/fd-hook.h6
-rw-r--r--libgnu/fd-safer-flag.c52
-rw-r--r--libgnu/fd-safer.c4
-rw-r--r--libgnu/fdopendir.c4
-rw-r--r--libgnu/ffs.c6
-rw-r--r--libgnu/file-set.c74
-rw-r--r--libgnu/file-set.h15
-rw-r--r--libgnu/filename.h6
-rw-r--r--libgnu/filenamecat-lgpl.c61
-rw-r--r--libgnu/filenamecat.h4
-rw-r--r--libgnu/flexmember.h23
-rw-r--r--libgnu/float+.h4
-rw-r--r--libgnu/float.c4
-rw-r--r--libgnu/float.in.h10
-rw-r--r--libgnu/fnmatch.c12
-rw-r--r--libgnu/fnmatch.in.h4
-rw-r--r--libgnu/fnmatch_loop.c12
-rw-r--r--libgnu/fstat.c72
-rw-r--r--libgnu/fstatat.c20
-rw-r--r--libgnu/fts-cycle.c4
-rw-r--r--libgnu/fts.c416
-rw-r--r--libgnu/fts_.h10
-rw-r--r--libgnu/getcwd-lgpl.c4
-rw-r--r--libgnu/getcwd.c446
-rw-r--r--libgnu/getdelim.c8
-rw-r--r--libgnu/getdtablesize.c19
-rw-r--r--libgnu/getline.c4
-rw-r--r--libgnu/getopt-cdefs.in.h8
-rw-r--r--libgnu/getopt-core.h4
-rw-r--r--libgnu/getopt-ext.h4
-rw-r--r--libgnu/getopt-pfx-core.h13
-rw-r--r--libgnu/getopt-pfx-ext.h15
-rw-r--r--libgnu/getopt.c7
-rw-r--r--libgnu/getopt.in.h8
-rw-r--r--libgnu/getopt1.c4
-rw-r--r--libgnu/getopt_int.h4
-rw-r--r--libgnu/getprogname.c22
-rw-r--r--libgnu/getprogname.h4
-rw-r--r--libgnu/gettext.h12
-rw-r--r--libgnu/gettimeofday.c154
-rw-r--r--libgnu/gnulib.am379
-rw-r--r--libgnu/hard-locale.c4
-rw-r--r--libgnu/hard-locale.h4
-rw-r--r--libgnu/hash-pjw.c40
-rw-r--r--libgnu/hash-pjw.h23
-rw-r--r--libgnu/hash-triple.c77
-rw-r--r--libgnu/hash-triple.h24
-rw-r--r--libgnu/hash.c4
-rw-r--r--libgnu/hash.h4
-rw-r--r--libgnu/i-ring.c4
-rw-r--r--libgnu/i-ring.h4
-rw-r--r--libgnu/intprops.h36
-rw-r--r--libgnu/itold.c4
-rw-r--r--libgnu/langinfo.in.h32
-rw-r--r--libgnu/limits.in.h4
-rw-r--r--libgnu/link.c6
-rw-r--r--libgnu/localcharset.c1083
-rw-r--r--libgnu/localcharset.h100
-rw-r--r--libgnu/lseek.c14
-rw-r--r--libgnu/lstat.c43
-rw-r--r--libgnu/malloc.c4
-rw-r--r--libgnu/malloca.c105
-rw-r--r--libgnu/malloca.h127
-rw-r--r--libgnu/mbrtowc.c101
-rw-r--r--libgnu/mbsinit.c38
-rw-r--r--libgnu/mbsrtowcs-impl.h4
-rw-r--r--libgnu/mbsrtowcs-state.c6
-rw-r--r--libgnu/mbsrtowcs.c4
-rw-r--r--libgnu/memchr.c4
-rw-r--r--libgnu/mempcpy.c4
-rw-r--r--libgnu/memrchr.c4
-rw-r--r--libgnu/msvc-inval.c4
-rw-r--r--libgnu/msvc-inval.h8
-rw-r--r--libgnu/msvc-nothrow.c8
-rw-r--r--libgnu/msvc-nothrow.h6
-rw-r--r--libgnu/obstack.c4
-rw-r--r--libgnu/obstack.h4
-rw-r--r--libgnu/obstack_printf.c4
-rw-r--r--libgnu/open-safer.c4
-rw-r--r--libgnu/open.c35
-rw-r--r--libgnu/openat-die.c4
-rw-r--r--libgnu/openat-priv.h4
-rw-r--r--libgnu/openat-proc.c4
-rw-r--r--libgnu/openat-safer.c4
-rw-r--r--libgnu/openat.c38
-rw-r--r--libgnu/openat.h4
-rw-r--r--libgnu/opendir-safer.c76
-rw-r--r--libgnu/opendir.c4
-rw-r--r--libgnu/pathmax.h8
-rw-r--r--libgnu/pipe-safer.c4
-rw-r--r--libgnu/pread.c4
-rw-r--r--libgnu/printf-args.c4
-rw-r--r--libgnu/printf-args.h4
-rw-r--r--libgnu/printf-parse.c6
-rw-r--r--libgnu/printf-parse.h4
-rw-r--r--libgnu/pwrite.c4
-rw-r--r--libgnu/qsort.c4
-rw-r--r--libgnu/qsort_r.c4
-rw-r--r--libgnu/raise.c8
-rw-r--r--libgnu/rawmemchr.c4
-rw-r--r--libgnu/read.c16
-rw-r--r--libgnu/readdir.c4
-rw-r--r--libgnu/readlink.c4
-rw-r--r--libgnu/realloc.c4
-rw-r--r--libgnu/ref-add.sin29
-rw-r--r--libgnu/ref-del.sin24
-rw-r--r--libgnu/rewinddir.c49
-rw-r--r--libgnu/same-inode.h24
-rw-r--r--libgnu/same.c123
-rw-r--r--libgnu/same.h25
-rw-r--r--libgnu/save-cwd.c10
-rw-r--r--libgnu/save-cwd.h4
-rw-r--r--libgnu/signal.in.h8
-rw-r--r--libgnu/size_max.h4
-rw-r--r--libgnu/sleep.c6
-rw-r--r--libgnu/stat-time.c3
-rw-r--r--libgnu/stat-time.h252
-rw-r--r--libgnu/stat-w32.c421
-rw-r--r--libgnu/stat-w32.h37
-rw-r--r--libgnu/stat.c421
-rw-r--r--libgnu/stdalign.in.h6
-rw-r--r--libgnu/stdbool.in.h10
-rw-r--r--libgnu/stddef.in.h22
-rw-r--r--libgnu/stdint.in.h4
-rw-r--r--libgnu/stdio.in.h16
-rw-r--r--libgnu/stdlib.in.h32
-rw-r--r--libgnu/stpcpy.c4
-rw-r--r--libgnu/stpncpy.c4
-rw-r--r--libgnu/strcasecmp.c4
-rw-r--r--libgnu/strchrnul.c4
-rw-r--r--libgnu/strdup.c4
-rw-r--r--libgnu/streq.h4
-rw-r--r--libgnu/strerror-override.c4
-rw-r--r--libgnu/strerror-override.h4
-rw-r--r--libgnu/strerror.c4
-rw-r--r--libgnu/string.in.h21
-rw-r--r--libgnu/strings.in.h4
-rw-r--r--libgnu/stripslash.c4
-rw-r--r--libgnu/strncasecmp.c4
-rw-r--r--libgnu/strndup.c4
-rw-r--r--libgnu/strnlen.c4
-rw-r--r--libgnu/strnlen1.c4
-rw-r--r--libgnu/strnlen1.h4
-rw-r--r--libgnu/strsep.c4
-rw-r--r--libgnu/sys_stat.in.h188
-rw-r--r--libgnu/sys_time.in.h220
-rw-r--r--libgnu/sys_types.in.h61
-rw-r--r--libgnu/sys_utsname.in.h4
-rw-r--r--libgnu/sys_wait.in.h10
-rw-r--r--libgnu/sysexits.in.h6
-rw-r--r--libgnu/time.in.h63
-rw-r--r--libgnu/unistd--.h4
-rw-r--r--libgnu/unistd-safer.h4
-rw-r--r--libgnu/unistd.in.h72
-rw-r--r--libgnu/vasnprintf.c65
-rw-r--r--libgnu/vasnprintf.h4
-rw-r--r--libgnu/verify.h4
-rw-r--r--libgnu/vsnprintf.c4
-rw-r--r--libgnu/warn-on-use.h4
-rw-r--r--libgnu/wchar.in.h55
-rw-r--r--libgnu/wctype.in.h26
-rw-r--r--libgnu/write.c16
-rw-r--r--libgnu/xalloc-die.c41
-rw-r--r--libgnu/xalloc-oversized.h6
-rw-r--r--libgnu/xalloc.h266
-rw-r--r--libgnu/xgetcwd.c41
-rw-r--r--libgnu/xgetcwd.h17
-rw-r--r--libgnu/xmalloc.c122
-rw-r--r--libgnu/xsize.h4
-rw-r--r--libgnu/xstrndup.c36
-rw-r--r--libgnu/xstrndup.h23
233 files changed, 4330 insertions, 4995 deletions
diff --git a/libgnu/alignof.h b/libgnu/alignof.h
index e64e2c70..26d71dd2 100644
--- a/libgnu/alignof.h
+++ b/libgnu/alignof.h
@@ -1,5 +1,5 @@
/* Determine alignment of types.
- Copyright (C) 2003-2004, 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _ALIGNOF_H
#define _ALIGNOF_H
diff --git a/libgnu/alloca.in.h b/libgnu/alloca.in.h
index c3dc38a5..5ad8af8b 100644
--- a/libgnu/alloca.in.h
+++ b/libgnu/alloca.in.h
@@ -1,6 +1,6 @@
/* Memory allocation on the stack.
- Copyright (C) 1995, 1999, 2001-2004, 2006-2017 Free Software Foundation,
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2018 Free Software Foundation,
Inc.
This program is free software; you can redistribute it and/or modify it
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with this program; if not, see
- <http://www.gnu.org/licenses/>.
+ <https://www.gnu.org/licenses/>.
*/
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
diff --git a/libgnu/areadlink-with-size.c b/libgnu/areadlink-with-size.c
deleted file mode 100644
index cc08317e..00000000
--- a/libgnu/areadlink-with-size.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* readlink wrapper to return the link name in malloc'd storage.
- Unlike xreadlink and xreadlink_with_size, don't ever call exit.
-
- Copyright (C) 2001, 2003-2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Jim Meyering <jim@meyering.net> */
-
-#include <config.h>
-
-#include "areadlink.h"
-
-#include <errno.h>
-#include <limits.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#ifndef SSIZE_MAX
-# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
-#endif
-
-/* SYMLINK_MAX is used only for an initial memory-allocation sanity
- check, so it's OK to guess too small on hosts where there is no
- arbitrary limit to symbolic link length. */
-#ifndef SYMLINK_MAX
-# define SYMLINK_MAX 1024
-#endif
-
-#define MAXSIZE (SIZE_MAX < SSIZE_MAX ? SIZE_MAX : SSIZE_MAX)
-
-/* Call readlink to get the symbolic link value of FILE.
- SIZE is a hint as to how long the link is expected to be;
- typically it is taken from st_size. It need not be correct.
- Return a pointer to that NUL-terminated string in malloc'd storage.
- If readlink fails, malloc fails, or if the link value is longer
- than SSIZE_MAX, return NULL (caller may use errno to diagnose). */
-
-char *
-areadlink_with_size (char const *file, size_t size)
-{
- /* Some buggy file systems report garbage in st_size. Defend
- against them by ignoring outlandish st_size values in the initial
- memory allocation. */
- size_t symlink_max = SYMLINK_MAX;
- size_t INITIAL_LIMIT_BOUND = 8 * 1024;
- size_t initial_limit = (symlink_max < INITIAL_LIMIT_BOUND
- ? symlink_max + 1
- : INITIAL_LIMIT_BOUND);
-
- /* The initial buffer size for the link value. */
- size_t buf_size = size < initial_limit ? size + 1 : initial_limit;
-
- while (1)
- {
- ssize_t r;
- size_t link_length;
- char *buffer = malloc (buf_size);
-
- if (buffer == NULL)
- return NULL;
- r = readlink (file, buffer, buf_size);
- link_length = r;
-
- /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
- with errno == ERANGE if the buffer is too small. */
- if (r < 0 && errno != ERANGE)
- {
- int saved_errno = errno;
- free (buffer);
- errno = saved_errno;
- return NULL;
- }
-
- if (link_length < buf_size)
- {
- buffer[link_length] = 0;
- return buffer;
- }
-
- free (buffer);
- if (buf_size <= MAXSIZE / 2)
- buf_size *= 2;
- else if (buf_size < MAXSIZE)
- buf_size = MAXSIZE;
- else
- {
- errno = ENOMEM;
- return NULL;
- }
- }
-}
diff --git a/libgnu/areadlink.h b/libgnu/areadlink.h
deleted file mode 100644
index cb3b5e29..00000000
--- a/libgnu/areadlink.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Read symbolic links without size limitation.
-
- Copyright (C) 2001, 2003-2004, 2007, 2009-2017 Free Software Foundation,
- Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Jim Meyering <jim@meyering.net> */
-
-#include <stddef.h>
-
-extern char *areadlink (char const *filename);
-extern char *areadlink_with_size (char const *filename, size_t size_hint);
-
-#if GNULIB_AREADLINKAT
-extern char *areadlinkat (int fd, char const *filename);
-#endif
-
-#if GNULIB_AREADLINKAT_WITH_SIZE
-extern char *areadlinkat_with_size (int fd, char const *filename,
- size_t size_hint);
-#endif
diff --git a/libgnu/arg-nonnull.h b/libgnu/arg-nonnull.h
index 1e62cc89..5f034083 100644
--- a/libgnu/arg-nonnull.h
+++ b/libgnu/arg-nonnull.h
@@ -1,5 +1,5 @@
/* A C macro for declaring that specific arguments must not be NULL.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
that the values passed as arguments n, ..., m must be non-NULL pointers.
diff --git a/libgnu/argp-ba.c b/libgnu/argp-ba.c
index 73f07bd6..7474356b 100644
--- a/libgnu/argp-ba.c
+++ b/libgnu/argp-ba.c
@@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
- Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* If set by the user program, it should point to string that is the
bug-reporting address for the program. It will be printed by argp_help if
@@ -24,8 +24,8 @@
const char *argp_program_bug_address
/* This variable should be zero-initialized. On most systems, putting it into
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
- <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
- <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
+ <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
+ <https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
#if defined __ELF__
/* On ELF systems, variables in BSS behave well. */
#else
diff --git a/libgnu/argp-eexst.c b/libgnu/argp-eexst.c
index 7ee89984..6a5efde6 100644
--- a/libgnu/argp-eexst.c
+++ b/libgnu/argp-eexst.c
@@ -1,5 +1,5 @@
/* Default definition for ARGP_ERR_EXIT_STATUS
- Copyright (C) 1997, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2009-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/argp-fmtstream.c b/libgnu/argp-fmtstream.c
index fe0d608a..13c6bf98 100644
--- a/libgnu/argp-fmtstream.c
+++ b/libgnu/argp-fmtstream.c
@@ -1,5 +1,5 @@
/* Word-wrapping and line-truncating streams
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
don't have that. */
diff --git a/libgnu/argp-fmtstream.h b/libgnu/argp-fmtstream.h
index 7ca2492a..2e1976dd 100644
--- a/libgnu/argp-fmtstream.h
+++ b/libgnu/argp-fmtstream.h
@@ -1,5 +1,5 @@
/* Word-wrapping and line-truncating streams.
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* This package emulates glibc 'line_wrap_stream' semantics for systems that
don't have that. If the system does have it, it is just a wrapper for
diff --git a/libgnu/argp-fs-xinl.c b/libgnu/argp-fs-xinl.c
index 362b5557..b8d8342a 100644
--- a/libgnu/argp-fs-xinl.c
+++ b/libgnu/argp-fs-xinl.c
@@ -1,5 +1,5 @@
/* Real definitions for extern inline functions in argp-fmtstream.h
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/argp-help.c b/libgnu/argp-help.c
index 5567eeea..de98f214 100644
--- a/libgnu/argp-help.c
+++ b/libgnu/argp-help.c
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing help output
- Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
@@ -880,7 +880,8 @@ hol_append (struct hol *hol, struct hol *more)
/* Fix up the short options pointers from HOL. */
for (e = entries, left = hol->num_entries; left > 0; e++, left--)
- e->short_options += (short_options - hol->short_options);
+ e->short_options
+ = short_options + (e->short_options - hol->short_options);
/* Now add the short options from MORE, fixing up its entries
too. */
@@ -1460,7 +1461,7 @@ argp_args_usage (const struct argp *argp, const struct argp_state *state,
}
/* Print the documentation for ARGP to STREAM; if POST is false, then
- everything preceeding a '\v' character in the documentation strings (or
+ everything preceding a '\v' character in the documentation strings (or
the whole string, for those with none) is printed, otherwise, everything
following the '\v' character (nothing for strings without). Each separate
bit of documentation is separated a blank line, and if PRE_BLANK is true,
@@ -1873,8 +1874,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
char const *s = NULL;
putc_unlocked (':', stream);
putc_unlocked (' ', stream);
-# if HAVE_DECL_STRERROR_R
-# if STRERROR_R_CHAR_P
+# if GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R
+# if !GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P
s = __strerror_r (errnum, buf, sizeof buf);
# else
if (__strerror_r (errnum, buf, sizeof buf) == 0)
diff --git a/libgnu/argp-namefrob.h b/libgnu/argp-namefrob.h
index baea162a..526cd529 100644
--- a/libgnu/argp-namefrob.h
+++ b/libgnu/argp-namefrob.h
@@ -1,5 +1,5 @@
/* Name frobnication for compiling argp outside of glibc
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if !_LIBC
/* This code is written for inclusion in gnu-libc, and uses names in the
diff --git a/libgnu/argp-parse.c b/libgnu/argp-parse.c
index 3f723bc8..ae55e9e1 100644
--- a/libgnu/argp-parse.c
+++ b/libgnu/argp-parse.c
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing, layered over getopt
- Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -740,12 +740,15 @@ parser_parse_opt (struct parser *parser, int opt, char *val)
}
}
else
- /* A long option. We use shifts instead of masking for extracting
- the user value in order to preserve the sign. */
- err =
- group_parse (&parser->groups[group_key - 1], &parser->state,
- (opt << GROUP_BITS) >> GROUP_BITS,
- parser->opt_data.optarg);
+ /* A long option. Preserve the sign in the user key, without
+ invoking undefined behavior. Assume two's complement. */
+ {
+ int user_key =
+ ((opt & (1 << (USER_BITS - 1))) ? ~USER_MASK : 0) | (opt & USER_MASK);
+ err =
+ group_parse (&parser->groups[group_key - 1], &parser->state,
+ user_key, parser->opt_data.optarg);
+ }
if (err == EBADKEY)
/* At least currently, an option not recognized is an error in the
diff --git a/libgnu/argp-pin.c b/libgnu/argp-pin.c
index 64d831d5..e68691c2 100644
--- a/libgnu/argp-pin.c
+++ b/libgnu/argp-pin.c
@@ -1,5 +1,5 @@
/* Full and short program names for argp module
- Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/argp-pv.c b/libgnu/argp-pv.c
index ce132675..fc4c4d50 100644
--- a/libgnu/argp-pv.c
+++ b/libgnu/argp-pv.c
@@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION.
- Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* If set by the user program to a non-zero value, then a default option
--version is added (unless the ARGP_NO_HELP flag is used), which will
@@ -23,8 +23,8 @@
const char *argp_program_version
/* This variable should be zero-initialized. On most systems, putting it into
BSS is sufficient. Not so on Mac OS X 10.3 and 10.4, see
- <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
- <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
+ <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>
+ <https://lists.gnu.org/r/bug-gnulib/2009-08/msg00096.html>. */
#if defined __ELF__
/* On ELF systems, variables in BSS behave well. */
#else
diff --git a/libgnu/argp-pvh.c b/libgnu/argp-pvh.c
index f7e50f32..9114d8e1 100644
--- a/libgnu/argp-pvh.c
+++ b/libgnu/argp-pvh.c
@@ -1,5 +1,5 @@
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
- Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/argp-xinl.c b/libgnu/argp-xinl.c
index 73dd62a9..6ee111e7 100644
--- a/libgnu/argp-xinl.c
+++ b/libgnu/argp-xinl.c
@@ -1,5 +1,5 @@
/* Real definitions for extern inline functions in argp.h
- Copyright (C) 1997-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/argp.h b/libgnu/argp.h
index 2a7bf5c3..1019fb3c 100644
--- a/libgnu/argp.h
+++ b/libgnu/argp.h
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing, layered over getopt.
- Copyright (C) 1995-2017 Free Software Foundation, Inc.
+ Copyright (C) 1995-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _ARGP_H
#define _ARGP_H
diff --git a/libgnu/asnprintf.c b/libgnu/asnprintf.c
index 14ab3e87..2298455b 100644
--- a/libgnu/asnprintf.c
+++ b/libgnu/asnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002, 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/assure.h b/libgnu/assure.h
index 2fc30432..de6c38db 100644
--- a/libgnu/assure.h
+++ b/libgnu/assure.h
@@ -1,6 +1,6 @@
/* Run-time assert-like macros.
- Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ Copyright (C) 2014-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/at-func.c b/libgnu/at-func.c
index 9eaa9932..55e4b8c0 100644
--- a/libgnu/at-func.c
+++ b/libgnu/at-func.c
@@ -1,5 +1,5 @@
/* Define at-style functions like fstatat, unlinkat, fchownat, etc.
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/basename-lgpl.c b/libgnu/basename-lgpl.c
index 54d3cc0a..33f9994f 100644
--- a/libgnu/basename-lgpl.c
+++ b/libgnu/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-2017 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/basename.c b/libgnu/basename.c
deleted file mode 100644
index 03536354..00000000
--- a/libgnu/basename.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* basename.c -- return the last element in a file name
-
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2017 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "dirname.h"
-
-#include <string.h>
-#include "xalloc.h"
-#include "xstrndup.h"
-
-char *
-base_name (char const *name)
-{
- char const *base = last_component (name);
- size_t length;
-
- /* If there is no last component, then name is a file system root or the
- empty string. */
- if (! *base)
- return xstrndup (name, base_len (name));
-
- /* Collapse a sequence of trailing slashes into one. */
- length = base_len (base);
- if (ISSLASH (base[length]))
- length++;
-
- /* On systems with drive letters, "a/b:c" must return "./b:c" rather
- than "b:c" to avoid confusion with a drive letter. On systems
- with pure POSIX semantics, this is not an issue. */
- if (FILE_SYSTEM_PREFIX_LEN (base))
- {
- char *p = xmalloc (length + 3);
- p[0] = '.';
- p[1] = '/';
- memcpy (p + 2, base, length);
- p[length + 2] = '\0';
- return p;
- }
-
- /* Finally, copy the basename. */
- return xstrndup (base, length);
-}
diff --git a/libgnu/bitrotate.h b/libgnu/bitrotate.h
index ea14afbe..9eb6a6f4 100644
--- a/libgnu/bitrotate.h
+++ b/libgnu/bitrotate.h
@@ -1,5 +1,5 @@
/* bitrotate.h - Rotate bits in integers
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson <simon@josefsson.org>, 2008. */
diff --git a/libgnu/c++defs.h b/libgnu/c++defs.h
index f03f3591..72ff1ffa 100644
--- a/libgnu/c++defs.h
+++ b/libgnu/c++defs.h
@@ -1,5 +1,5 @@
/* C++ compatible function declaration macros.
- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+ Copyright (C) 2010-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_CXXDEFS_H
#define _GL_CXXDEFS_H
@@ -266,7 +266,7 @@
_GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN_1(func,namespace) \
_GL_CXXALIASWARN_2 (func, namespace)
-/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !__OPTIMIZE__
# define _GL_CXXALIASWARN_2(func,namespace) \
@@ -294,7 +294,7 @@
GNULIB_NAMESPACE)
# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
_GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
-/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
+/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
we enable the warning only when not optimizing. */
# if !__OPTIMIZE__
# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
diff --git a/libgnu/canonicalize-lgpl.c b/libgnu/canonicalize-lgpl.c
new file mode 100644
index 00000000..7831b3f1
--- /dev/null
+++ b/libgnu/canonicalize-lgpl.c
@@ -0,0 +1,428 @@
+/* Return the canonical absolute name of a given file.
+ Copyright (C) 1996-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
+ optimizes away the name == NULL test below. */
+# define _GL_ARG_NONNULL(params)
+
+# define _GL_USE_STDLIB_ALLOC 1
+# include <config.h>
+#endif
+
+#if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
+
+/* Specification. */
+#include <stdlib.h>
+
+#include <alloca.h>
+#include <string.h>
+#include <unistd.h>
+#include <limits.h>
+#if HAVE_SYS_PARAM_H || defined _LIBC
+# include <sys/param.h>
+#endif
+#include <sys/stat.h>
+#include <errno.h>
+#include <stddef.h>
+
+#ifdef _LIBC
+# include <shlib-compat.h>
+#else
+# define SHLIB_COMPAT(lib, introduced, obsoleted) 0
+# define versioned_symbol(lib, local, symbol, version) extern int dummy
+# define compat_symbol(lib, local, symbol, version)
+# define weak_alias(local, symbol)
+# define __canonicalize_file_name canonicalize_file_name
+# define __realpath realpath
+# include "pathmax.h"
+# include "malloca.h"
+# include "dosname.h"
+# if HAVE_GETCWD
+# if IN_RELOCWRAPPER
+ /* When building the relocatable program wrapper, use the system's getcwd
+ function, not the gnulib override, otherwise we would get a link error.
+ */
+# undef getcwd
+# endif
+# if defined VMS && !defined getcwd
+ /* We want the directory in Unix syntax, not in VMS syntax.
+ The gnulib override of 'getcwd' takes 2 arguments; the original VMS
+ 'getcwd' takes 3 arguments. */
+# define __getcwd(buf, max) getcwd (buf, max, 0)
+# else
+# define __getcwd getcwd
+# endif
+# else
+# define __getcwd(buf, max) getwd (buf)
+# endif
+# define __readlink readlink
+# define __set_errno(e) errno = (e)
+# ifndef MAXSYMLINKS
+# ifdef SYMLOOP_MAX
+# define MAXSYMLINKS SYMLOOP_MAX
+# else
+# define MAXSYMLINKS 20
+# endif
+# endif
+#endif
+
+#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
+# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
+#endif
+
+/* Define this independently so that stdint.h is not a prerequisite. */
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
+#if !FUNC_REALPATH_WORKS || defined _LIBC
+
+static void
+alloc_failed (void)
+{
+#if defined _WIN32 && ! defined __CYGWIN__
+ /* Avoid errno problem without using the malloc or realloc modules; see:
+ https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
+ errno = ENOMEM;
+#endif
+}
+
+/* Return the canonical absolute name of file NAME. A canonical name
+ does not contain any ".", ".." components nor any repeated path
+ separators ('/') or symlinks. All path components must exist. If
+ RESOLVED is null, the result is malloc'd; otherwise, if the
+ canonical name is PATH_MAX chars or more, returns null with 'errno'
+ set to ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars,
+ returns the name in RESOLVED. If the name cannot be resolved and
+ RESOLVED is non-NULL, it contains the path of the first component
+ that cannot be resolved. If the path can be resolved, RESOLVED
+ holds the same value as the value returned. */
+
+char *
+__realpath (const char *name, char *resolved)
+{
+ char *rpath, *dest, *extra_buf = NULL;
+ const char *start, *end, *rpath_limit;
+ long int path_max;
+ int num_links = 0;
+ size_t prefix_len;
+
+ if (name == NULL)
+ {
+ /* As per Single Unix Specification V2 we must return an error if
+ either parameter is a null pointer. We extend this to allow
+ the RESOLVED parameter to be NULL in case the we are expected to
+ allocate the room for the return value. */
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ if (name[0] == '\0')
+ {
+ /* As per Single Unix Specification V2 we must return an error if
+ the name argument points to an empty string. */
+ __set_errno (ENOENT);
+ return NULL;
+ }
+
+#ifdef PATH_MAX
+ path_max = PATH_MAX;
+#else
+ path_max = pathconf (name, _PC_PATH_MAX);
+ if (path_max <= 0)
+ path_max = 8192;
+#endif
+
+ if (resolved == NULL)
+ {
+ rpath = malloc (path_max);
+ if (rpath == NULL)
+ {
+ alloc_failed ();
+ return NULL;
+ }
+ }
+ else
+ rpath = resolved;
+ rpath_limit = rpath + path_max;
+
+ /* This is always zero for Posix hosts, but can be 2 for MS-Windows
+ and MS-DOS X:/foo/bar file names. */
+ prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+
+ if (!IS_ABSOLUTE_FILE_NAME (name))
+ {
+ if (!__getcwd (rpath, path_max))
+ {
+ rpath[0] = '\0';
+ goto error;
+ }
+ dest = strchr (rpath, '\0');
+ start = name;
+ prefix_len = FILE_SYSTEM_PREFIX_LEN (rpath);
+ }
+ else
+ {
+ dest = rpath;
+ if (prefix_len)
+ {
+ memcpy (rpath, name, prefix_len);
+ dest += prefix_len;
+ }
+ *dest++ = '/';
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
+ {
+ if (ISSLASH (name[1]) && !ISSLASH (name[2]) && !prefix_len)
+ *dest++ = '/';
+ *dest = '\0';
+ }
+ start = name + prefix_len;
+ }
+
+ for (end = start; *start; start = end)
+ {
+#ifdef _LIBC
+ struct stat64 st;
+#else
+ struct stat st;
+#endif
+
+ /* Skip sequence of multiple path-separators. */
+ while (ISSLASH (*start))
+ ++start;
+
+ /* Find end of path component. */
+ for (end = start; *end && !ISSLASH (*end); ++end)
+ /* Nothing. */;
+
+ if (end - start == 0)
+ break;
+ else if (end - start == 1 && start[0] == '.')
+ /* nothing */;
+ else if (end - start == 2 && start[0] == '.' && start[1] == '.')
+ {
+ /* Back up to previous component, ignore if at root already. */
+ if (dest > rpath + prefix_len + 1)
+ for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
+ continue;
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT
+ && dest == rpath + 1 && !prefix_len
+ && ISSLASH (*dest) && !ISSLASH (dest[1]))
+ dest++;
+ }
+ else
+ {
+ size_t new_size;
+
+ if (!ISSLASH (dest[-1]))
+ *dest++ = '/';
+
+ if (dest + (end - start) >= rpath_limit)
+ {
+ ptrdiff_t dest_offset = dest - rpath;
+ char *new_rpath;
+
+ if (resolved)
+ {
+ __set_errno (ENAMETOOLONG);
+ if (dest > rpath + prefix_len + 1)
+ dest--;
+ *dest = '\0';
+ goto error;
+ }
+ new_size = rpath_limit - rpath;
+ if (end - start + 1 > path_max)
+ new_size += end - start + 1;
+ else
+ new_size += path_max;
+ new_rpath = (char *) realloc (rpath, new_size);
+ if (new_rpath == NULL)
+ {
+ alloc_failed ();
+ goto error;
+ }
+ rpath = new_rpath;
+ rpath_limit = rpath + new_size;
+
+ dest = rpath + dest_offset;
+ }
+
+#ifdef _LIBC
+ dest = __mempcpy (dest, start, end - start);
+#else
+ memcpy (dest, start, end - start);
+ dest += end - start;
+#endif
+ *dest = '\0';
+
+ /* FIXME: if lstat fails with errno == EOVERFLOW,
+ the entry exists. */
+#ifdef _LIBC
+ if (__lxstat64 (_STAT_VER, rpath, &st) < 0)
+#else
+ if (lstat (rpath, &st) < 0)
+#endif
+ goto error;
+
+ if (S_ISLNK (st.st_mode))
+ {
+ char *buf;
+ size_t len;
+ ssize_t n;
+
+ if (++num_links > MAXSYMLINKS)
+ {
+ __set_errno (ELOOP);
+ goto error;
+ }
+
+ buf = malloca (path_max);
+ if (!buf)
+ {
+ __set_errno (ENOMEM);
+ goto error;
+ }
+
+ n = __readlink (rpath, buf, path_max - 1);
+ if (n < 0)
+ {
+ int saved_errno = errno;
+ freea (buf);
+ __set_errno (saved_errno);
+ goto error;
+ }
+ buf[n] = '\0';
+
+ if (!extra_buf)
+ {
+ extra_buf = malloca (path_max);
+ if (!extra_buf)
+ {
+ freea (buf);
+ __set_errno (ENOMEM);
+ goto error;
+ }
+ }
+
+ len = strlen (end);
+ /* Check that n + len + 1 doesn't overflow and is <= path_max. */
+ if (n >= SIZE_MAX - len || n + len >= path_max)
+ {
+ freea (buf);
+ __set_errno (ENAMETOOLONG);
+ goto error;
+ }
+
+ /* Careful here, end may be a pointer into extra_buf... */
+ memmove (&extra_buf[n], end, len + 1);
+ name = end = memcpy (extra_buf, buf, n);
+
+ if (IS_ABSOLUTE_FILE_NAME (buf))
+ {
+ size_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
+
+ if (pfxlen)
+ memcpy (rpath, buf, pfxlen);
+ dest = rpath + pfxlen;
+ *dest++ = '/'; /* It's an absolute symlink */
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
+ {
+ if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
+ *dest++ = '/';
+ *dest = '\0';
+ }
+ /* Install the new prefix to be in effect hereafter. */
+ prefix_len = pfxlen;
+ }
+ else
+ {
+ /* Back up to previous component, ignore if at root
+ already: */
+ if (dest > rpath + prefix_len + 1)
+ for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
+ continue;
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
+ && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
+ dest++;
+ }
+ }
+ else if (!S_ISDIR (st.st_mode) && *end != '\0')
+ {
+ __set_errno (ENOTDIR);
+ goto error;
+ }
+ }
+ }
+ if (dest > rpath + prefix_len + 1 && ISSLASH (dest[-1]))
+ --dest;
+ if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 && !prefix_len
+ && ISSLASH (*dest) && !ISSLASH (dest[1]))
+ dest++;
+ *dest = '\0';
+
+ if (extra_buf)
+ freea (extra_buf);
+
+ return rpath;
+
+error:
+ {
+ int saved_errno = errno;
+ if (extra_buf)
+ freea (extra_buf);
+ if (resolved == NULL)
+ free (rpath);
+ __set_errno (saved_errno);
+ }
+ return NULL;
+}
+versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
+#endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
+
+
+#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3)
+char *
+attribute_compat_text_section
+__old_realpath (const char *name, char *resolved)
+{
+ if (resolved == NULL)
+ {
+ __set_errno (EINVAL);
+ return NULL;
+ }
+
+ return __realpath (name, resolved);
+}
+compat_symbol (libc, __old_realpath, realpath, GLIBC_2_0);
+#endif
+
+
+char *
+__canonicalize_file_name (const char *name)
+{
+ return __realpath (name, NULL);
+}
+weak_alias (__canonicalize_file_name, canonicalize_file_name)
+
+#else
+
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
+
+#endif
diff --git a/libgnu/canonicalize.c b/libgnu/canonicalize.c
deleted file mode 100644
index a2f533ff..00000000
--- a/libgnu/canonicalize.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "canonicalize.h"
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include "areadlink.h"
-#include "file-set.h"
-#include "hash-triple.h"
-#include "pathmax.h"
-#include "xalloc.h"
-#include "xgetcwd.h"
-#include "dosname.h"
-
-#define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
-
-/* In this file, we cannot handle file names longer than PATH_MAX.
- On systems with no file name length limit, use a fallback. */
-#ifndef PATH_MAX
-# define PATH_MAX 8192
-#endif
-
-#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
-# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
-#endif
-
-#if ISSLASH ('\\')
-# define SLASHES "/\\"
-#else
-# define SLASHES "/"
-#endif
-
-#if !((HAVE_CANONICALIZE_FILE_NAME && FUNC_REALPATH_WORKS) \
- || GNULIB_CANONICALIZE_LGPL)
-/* Return the canonical absolute name of file NAME. A canonical name
- does not contain any ".", ".." components nor any repeated file name
- separators ('/') or symlinks. All components must exist.
- The result is malloc'd. */
-
-char *
-canonicalize_file_name (const char *name)
-{
- return canonicalize_filename_mode (name, CAN_EXISTING);
-}
-#endif /* !HAVE_CANONICALIZE_FILE_NAME */
-
-/* Return true if we've already seen the triple, <FILENAME, dev, ino>.
- If *HT is not initialized, initialize it. */
-static bool
-seen_triple (Hash_table **ht, char const *filename, struct stat const *st)
-{
- if (*ht == NULL)
- {
- size_t initial_capacity = 7;
- *ht = hash_initialize (initial_capacity,
- NULL,
- triple_hash,
- triple_compare_ino_str,
- triple_free);
- if (*ht == NULL)
- xalloc_die ();
- }
-
- if (seen_file (*ht, filename, st))
- return true;
-
- record_file (*ht, filename, st);
- return false;
-}
-
-/* Return the canonical absolute name of file NAME, while treating
- missing elements according to CAN_MODE. A canonical name
- does not contain any ".", ".." components nor any repeated file name
- separators ('/') or, depending on other CAN_MODE flags, symlinks.
- Whether components must exist or not depends on canonicalize mode.
- The result is malloc'd. */
-
-char *
-canonicalize_filename_mode (const char *name, canonicalize_mode_t can_mode)
-{
- char *rname, *dest, *extra_buf = NULL;
- char const *start;
- char const *end;
- char const *rname_limit;
- size_t extra_len = 0;
- Hash_table *ht = NULL;
- int saved_errno;
- int can_flags = can_mode & ~CAN_MODE_MASK;
- bool logical = can_flags & CAN_NOLINKS;
- size_t prefix_len;
-
- can_mode &= CAN_MODE_MASK;
-
- if (MULTIPLE_BITS_SET (can_mode))
- {
- errno = EINVAL;
- return NULL;
- }
-
- if (name == NULL)
- {
- errno = EINVAL;
- return NULL;
- }
-
- if (name[0] == '\0')
- {
- errno = ENOENT;
- return NULL;
- }
-
- /* This is always zero for Posix hosts, but can be 2 for MS-Windows
- and MS-DOS X:/foo/bar file names. */
- prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
-
- if (!IS_ABSOLUTE_FILE_NAME (name))
- {
- rname = xgetcwd ();
- if (!rname)
- return NULL;
- dest = strchr (rname, '\0');
- if (dest - rname < PATH_MAX)
- {
- char *p = xrealloc (rname, PATH_MAX);
- dest = p + (dest - rname);
- rname = p;
- rname_limit = rname + PATH_MAX;
- }
- else
- {
- rname_limit = dest;
- }
- start = name;
- prefix_len = FILE_SYSTEM_PREFIX_LEN (rname);
- }
- else
- {
- rname = xmalloc (PATH_MAX);
- rname_limit = rname + PATH_MAX;
- dest = rname;
- if (prefix_len)
- {
- memcpy (rname, name, prefix_len);
- dest += prefix_len;
- }
- *dest++ = '/';
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
- {
- if (ISSLASH (name[1]) && !ISSLASH (name[2]) && !prefix_len)
- *dest++ = '/';
- *dest = '\0';
- }
- start = name + prefix_len;
- }
-
- for ( ; *start; start = end)
- {
- /* Skip sequence of multiple file name separators. */
- while (ISSLASH (*start))
- ++start;
-
- /* Find end of component. */
- for (end = start; *end && !ISSLASH (*end); ++end)
- /* Nothing. */;
-
- if (end - start == 0)
- break;
- else if (end - start == 1 && start[0] == '.')
- /* nothing */;
- else if (end - start == 2 && start[0] == '.' && start[1] == '.')
- {
- /* Back up to previous component, ignore if at root already. */
- if (dest > rname + prefix_len + 1)
- for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
- continue;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
- && !prefix_len && ISSLASH (*dest) && !ISSLASH (dest[1]))
- dest++;
- }
- else
- {
- struct stat st;
-
- if (!ISSLASH (dest[-1]))
- *dest++ = '/';
-
- if (dest + (end - start) >= rname_limit)
- {
- ptrdiff_t dest_offset = dest - rname;
- size_t new_size = rname_limit - rname;
-
- if (end - start + 1 > PATH_MAX)
- new_size += end - start + 1;
- else
- new_size += PATH_MAX;
- rname = xrealloc (rname, new_size);
- rname_limit = rname + new_size;
-
- dest = rname + dest_offset;
- }
-
- dest = memcpy (dest, start, end - start);
- dest += end - start;
- *dest = '\0';
-
- if (logical && (can_mode == CAN_MISSING))
- {
- /* Avoid the stat in this case as it's inconsequential.
- i.e. we're neither resolving symlinks or testing
- component existence. */
- st.st_mode = 0;
- }
- else if ((logical ? stat (rname, &st) : lstat (rname, &st)) != 0)
- {
- saved_errno = errno;
- if (can_mode == CAN_EXISTING)
- goto error;
- if (can_mode == CAN_ALL_BUT_LAST)
- {
- if (end[strspn (end, SLASHES)] || saved_errno != ENOENT)
- goto error;
- continue;
- }
- st.st_mode = 0;
- }
-
- if (S_ISLNK (st.st_mode))
- {
- char *buf;
- size_t n, len;
-
- /* Detect loops. We cannot use the cycle-check module here,
- since it's actually possible to encounter the same symlink
- more than once in a given traversal. However, encountering
- the same symlink,NAME pair twice does indicate a loop. */
- if (seen_triple (&ht, name, &st))
- {
- if (can_mode == CAN_MISSING)
- continue;
- saved_errno = ELOOP;
- goto error;
- }
-
- buf = areadlink_with_size (rname, st.st_size);
- if (!buf)
- {
- if (can_mode == CAN_MISSING && errno != ENOMEM)
- continue;
- saved_errno = errno;
- goto error;
- }
-
- n = strlen (buf);
- len = strlen (end);
-
- if (!extra_len)
- {
- extra_len =
- ((n + len + 1) > PATH_MAX) ? (n + len + 1) : PATH_MAX;
- extra_buf = xmalloc (extra_len);
- }
- else if ((n + len + 1) > extra_len)
- {
- extra_len = n + len + 1;
- extra_buf = xrealloc (extra_buf, extra_len);
- }
-
- /* Careful here, end may be a pointer into extra_buf... */
- memmove (&extra_buf[n], end, len + 1);
- name = end = memcpy (extra_buf, buf, n);
-
- if (IS_ABSOLUTE_FILE_NAME (buf))
- {
- size_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
-
- if (pfxlen)
- memcpy (rname, buf, pfxlen);
- dest = rname + pfxlen;
- *dest++ = '/'; /* It's an absolute symlink */
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
- {
- if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
- *dest++ = '/';
- *dest = '\0';
- }
- /* Install the new prefix to be in effect hereafter. */
- prefix_len = pfxlen;
- }
- else
- {
- /* Back up to previous component, ignore if at root
- already: */
- if (dest > rname + prefix_len + 1)
- for (--dest; dest > rname && !ISSLASH (dest[-1]); --dest)
- continue;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1
- && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
- dest++;
- }
-
- free (buf);
- }
- else
- {
- if (!S_ISDIR (st.st_mode) && *end && (can_mode != CAN_MISSING))
- {
- saved_errno = ENOTDIR;
- goto error;
- }
- }
- }
- }
- if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
- --dest;
- if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rname + 1 && !prefix_len
- && ISSLASH (*dest) && !ISSLASH (dest[1]))
- dest++;
- *dest = '\0';
- if (rname_limit != dest + 1)
- rname = xrealloc (rname, dest - rname + 1);
-
- free (extra_buf);
- if (ht)
- hash_free (ht);
- return rname;
-
-error:
- free (extra_buf);
- free (rname);
- if (ht)
- hash_free (ht);
- errno = saved_errno;
- return NULL;
-}
diff --git a/libgnu/canonicalize.h b/libgnu/canonicalize.h
deleted file mode 100644
index 772eeccf..00000000
--- a/libgnu/canonicalize.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef CANONICALIZE_H_
-# define CANONICALIZE_H_
-
-#include <stdlib.h> /* for canonicalize_file_name */
-
-#define CAN_MODE_MASK (CAN_EXISTING | CAN_ALL_BUT_LAST | CAN_MISSING)
-
-enum canonicalize_mode_t
- {
- /* All components must exist. */
- CAN_EXISTING = 0,
-
- /* All components excluding last one must exist. */
- CAN_ALL_BUT_LAST = 1,
-
- /* No requirements on components existence. */
- CAN_MISSING = 2,
-
- /* Don't expand symlinks. */
- CAN_NOLINKS = 4
- };
-typedef enum canonicalize_mode_t canonicalize_mode_t;
-
-/* Return the canonical absolute name of file NAME, while treating
- missing elements according to CAN_MODE. A canonical name
- does not contain any `.', `..' components nor any repeated file name
- separators ('/') or, depending on other CAN_MODE flags, symlinks.
- Whether components must exist or not depends on canonicalize mode.
- The result is malloc'd. */
-char *canonicalize_filename_mode (const char *, canonicalize_mode_t);
-
-#endif /* !CANONICALIZE_H_ */
diff --git a/libgnu/chdir-long.c b/libgnu/chdir-long.c
index d6c35c92..d70f0b20 100644
--- a/libgnu/chdir-long.c
+++ b/libgnu/chdir-long.c
@@ -1,5 +1,5 @@
/* provide a chdir function that tries not to fail due to ENAMETOOLONG
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/chdir-long.h b/libgnu/chdir-long.h
index 6f5d331e..34d24bce 100644
--- a/libgnu/chdir-long.h
+++ b/libgnu/chdir-long.h
@@ -1,5 +1,5 @@
/* provide a chdir function that tries not to fail due to ENAMETOOLONG
- Copyright (C) 2004-2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/cloexec.c b/libgnu/cloexec.c
index a5ad0b58..238ab188 100644
--- a/libgnu/cloexec.c
+++ b/libgnu/cloexec.c
@@ -1,6 +1,6 @@
-/* closexec.c - set or clear the close-on-exec descriptor flag
+/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 1991, 2004-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1991, 2004-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
The code is taken from glibc/manual/llio.texi */
diff --git a/libgnu/cloexec.h b/libgnu/cloexec.h
index 2990e828..59028058 100644
--- a/libgnu/cloexec.h
+++ b/libgnu/cloexec.h
@@ -1,6 +1,6 @@
-/* closexec.c - set or clear the close-on-exec descriptor flag
+/* cloexec.c - set or clear the close-on-exec descriptor flag
- Copyright (C) 2004, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
diff --git a/libgnu/close.c b/libgnu/close.c
index 3e451871..01c326a2 100644
--- a/libgnu/close.c
+++ b/libgnu/close.c
@@ -1,5 +1,5 @@
/* close replacement.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -22,7 +22,9 @@
#include <errno.h>
#include "fd-hook.h"
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef close
diff --git a/libgnu/closedir.c b/libgnu/closedir.c
index 71fa0b00..562a3ec0 100644
--- a/libgnu/closedir.c
+++ b/libgnu/closedir.c
@@ -1,5 +1,5 @@
/* Stop reading the entries of a directory.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/config.charset b/libgnu/config.charset
deleted file mode 100644
index 8bedbf36..00000000
--- a/libgnu/config.charset
+++ /dev/null
@@ -1,682 +0,0 @@
-#! /bin/sh
-# Output a system dependent table of character encoding aliases.
-#
-# Copyright (C) 2000-2004, 2006-2017 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# The table consists of lines of the form
-# ALIAS CANONICAL
-#
-# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
-# ALIAS is compared in a case sensitive way.
-#
-# CANONICAL is the GNU canonical name for this character encoding.
-# It must be an encoding supported by libiconv. Support by GNU libc is
-# also desirable. CANONICAL is case insensitive. Usually an upper case
-# MIME charset name is preferred.
-# The current list of GNU canonical charset names is as follows.
-#
-# name MIME? used by which systems
-# (darwin = Mac OS X, woe32 = native Windows)
-#
-# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
-# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
-# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
-# ISO-8859-3 Y glibc solaris cygwin
-# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
-# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
-# ISO-8859-6 Y glibc aix hpux solaris cygwin
-# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
-# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
-# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
-# ISO-8859-13 glibc netbsd openbsd darwin cygwin
-# ISO-8859-14 glibc cygwin
-# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
-# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
-# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
-# KOI8-T glibc
-# CP437 dos
-# CP775 dos
-# CP850 aix osf dos
-# CP852 dos
-# CP855 dos
-# CP856 aix
-# CP857 dos
-# CP861 dos
-# CP862 dos
-# CP864 dos
-# CP865 dos
-# CP866 freebsd netbsd openbsd darwin dos
-# CP869 dos
-# CP874 woe32 dos
-# CP922 aix
-# CP932 aix cygwin woe32 dos
-# CP943 aix
-# CP949 osf darwin woe32 dos
-# CP950 woe32 dos
-# CP1046 aix
-# CP1124 aix
-# CP1125 dos
-# CP1129 aix
-# CP1131 darwin
-# CP1250 woe32
-# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32
-# CP1252 aix woe32
-# CP1253 woe32
-# CP1254 woe32
-# CP1255 glibc woe32
-# CP1256 woe32
-# CP1257 woe32
-# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
-# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
-# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
-# EUC-TW glibc aix hpux irix osf solaris netbsd
-# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
-# BIG5-HKSCS glibc solaris darwin
-# GBK glibc aix osf solaris darwin cygwin woe32 dos
-# GB18030 glibc solaris netbsd darwin
-# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
-# JOHAB glibc solaris woe32
-# TIS-620 glibc aix hpux osf solaris cygwin
-# VISCII Y glibc
-# TCVN5712-1 glibc
-# ARMSCII-8 glibc darwin
-# GEORGIAN-PS glibc cygwin
-# PT154 glibc
-# HP-ROMAN8 hpux
-# HP-ARABIC8 hpux
-# HP-GREEK8 hpux
-# HP-HEBREW8 hpux
-# HP-TURKISH8 hpux
-# HP-KANA8 hpux
-# DEC-KANJI osf
-# DEC-HANYU osf
-# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
-#
-# Note: Names which are not marked as being a MIME name should not be used in
-# Internet protocols for information interchange (mail, news, etc.).
-#
-# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
-# must understand both names and treat them as equivalent.
-#
-# The first argument passed to this file is the canonical host specification,
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-
-host="$1"
-os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
-echo "# This file contains a table of character encoding aliases,"
-echo "# suitable for operating system '${os}'."
-echo "# It was automatically generated from config.charset."
-# List of references, updated during installation:
-echo "# Packages using this file: "
-case "$os" in
- linux-gnulibc1*)
- # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "C ASCII"
- echo "POSIX ASCII"
- for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
- en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
- en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
- es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
- et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
- fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
- it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
- sv_FI sv_SE; do
- echo "$l ISO-8859-1"
- echo "$l.iso-8859-1 ISO-8859-1"
- echo "$l.iso-8859-15 ISO-8859-15"
- echo "$l.iso-8859-15@euro ISO-8859-15"
- echo "$l@euro ISO-8859-15"
- echo "$l.cp-437 CP437"
- echo "$l.cp-850 CP850"
- echo "$l.cp-1252 CP1252"
- echo "$l.cp-1252@euro CP1252"
- #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
- echo "$l.utf-8 UTF-8"
- echo "$l.utf-8@euro UTF-8"
- done
- for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
- sl_SI sr sr_CS sr_YU; do
- echo "$l ISO-8859-2"
- echo "$l.iso-8859-2 ISO-8859-2"
- echo "$l.cp-852 CP852"
- echo "$l.cp-1250 CP1250"
- echo "$l.utf-8 UTF-8"
- done
- for l in mk mk_MK ru ru_RU; do
- echo "$l ISO-8859-5"
- echo "$l.iso-8859-5 ISO-8859-5"
- echo "$l.koi8-r KOI8-R"
- echo "$l.cp-866 CP866"
- echo "$l.cp-1251 CP1251"
- echo "$l.utf-8 UTF-8"
- done
- for l in ar ar_SA; do
- echo "$l ISO-8859-6"
- echo "$l.iso-8859-6 ISO-8859-6"
- echo "$l.cp-864 CP864"
- #echo "$l.cp-868 CP868" # not a commonly used encoding
- echo "$l.cp-1256 CP1256"
- echo "$l.utf-8 UTF-8"
- done
- for l in el el_GR gr gr_GR; do
- echo "$l ISO-8859-7"
- echo "$l.iso-8859-7 ISO-8859-7"
- echo "$l.cp-869 CP869"
- echo "$l.cp-1253 CP1253"
- echo "$l.cp-1253@euro CP1253"
- echo "$l.utf-8 UTF-8"
- echo "$l.utf-8@euro UTF-8"
- done
- for l in he he_IL iw iw_IL; do
- echo "$l ISO-8859-8"
- echo "$l.iso-8859-8 ISO-8859-8"
- echo "$l.cp-862 CP862"
- echo "$l.cp-1255 CP1255"
- echo "$l.utf-8 UTF-8"
- done
- for l in tr tr_TR; do
- echo "$l ISO-8859-9"
- echo "$l.iso-8859-9 ISO-8859-9"
- echo "$l.cp-857 CP857"
- echo "$l.cp-1254 CP1254"
- echo "$l.utf-8 UTF-8"
- done
- for l in lt lt_LT lv lv_LV; do
- #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
- echo "$l ISO-8859-13"
- done
- for l in ru_UA uk uk_UA; do
- echo "$l KOI8-U"
- done
- for l in zh zh_CN; do
- #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
- echo "$l GB2312"
- done
- for l in ja ja_JP ja_JP.EUC; do
- echo "$l EUC-JP"
- done
- for l in ko ko_KR; do
- echo "$l EUC-KR"
- done
- for l in th th_TH; do
- echo "$l TIS-620"
- done
- for l in fa fa_IR; do
- #echo "$l ISIRI-3342" # a broken encoding
- echo "$l.utf-8 UTF-8"
- done
- ;;
- linux* | *-gnu*)
- # With glibc-2.1 or newer, we don't need any canonicalization,
- # because glibc has iconv and both glibc and libiconv support all
- # GNU canonical names directly. Therefore, the Makefile does not
- # need to install the alias file at all.
- # The following applies only to glibc-2.0.x and older libcs.
- echo "ISO_646.IRV:1983 ASCII"
- ;;
- aix*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-6 ISO-8859-6"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "IBM-850 CP850"
- echo "IBM-856 CP856"
- echo "IBM-921 ISO-8859-13"
- echo "IBM-922 CP922"
- echo "IBM-932 CP932"
- echo "IBM-943 CP943"
- echo "IBM-1046 CP1046"
- echo "IBM-1124 CP1124"
- echo "IBM-1129 CP1129"
- echo "IBM-1252 CP1252"
- echo "IBM-eucCN GB2312"
- echo "IBM-eucJP EUC-JP"
- echo "IBM-eucKR EUC-KR"
- echo "IBM-eucTW EUC-TW"
- echo "big5 BIG5"
- echo "GBK GBK"
- echo "TIS-620 TIS-620"
- echo "UTF-8 UTF-8"
- ;;
- hpux*)
- echo "iso88591 ISO-8859-1"
- echo "iso88592 ISO-8859-2"
- echo "iso88595 ISO-8859-5"
- echo "iso88596 ISO-8859-6"
- echo "iso88597 ISO-8859-7"
- echo "iso88598 ISO-8859-8"
- echo "iso88599 ISO-8859-9"
- echo "iso885915 ISO-8859-15"
- echo "roman8 HP-ROMAN8"
- echo "arabic8 HP-ARABIC8"
- echo "greek8 HP-GREEK8"
- echo "hebrew8 HP-HEBREW8"
- echo "turkish8 HP-TURKISH8"
- echo "kana8 HP-KANA8"
- echo "tis620 TIS-620"
- echo "big5 BIG5"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "hp15CN GB2312"
- #echo "ccdc ?" # what is this?
- echo "SJIS SHIFT_JIS"
- echo "utf8 UTF-8"
- ;;
- irix*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-9 ISO-8859-9"
- echo "eucCN GB2312"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- ;;
- osf*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "cp850 CP850"
- echo "big5 BIG5"
- echo "dechanyu DEC-HANYU"
- echo "dechanzi GB2312"
- echo "deckanji DEC-KANJI"
- echo "deckorean EUC-KR"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "GBK GBK"
- echo "KSC5601 CP949"
- echo "sdeckanji EUC-JP"
- echo "SJIS SHIFT_JIS"
- echo "TACTIS TIS-620"
- echo "UTF-8 UTF-8"
- ;;
- solaris*)
- echo "646 ASCII"
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-3 ISO-8859-3"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-6 ISO-8859-6"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "koi8-r KOI8-R"
- echo "ansi-1251 CP1251"
- echo "BIG5 BIG5"
- echo "Big5-HKSCS BIG5-HKSCS"
- echo "gb2312 GB2312"
- echo "GBK GBK"
- echo "GB18030 GB18030"
- echo "cns11643 EUC-TW"
- echo "5601 EUC-KR"
- echo "ko_KR.johap92 JOHAB"
- echo "eucJP EUC-JP"
- echo "PCK SHIFT_JIS"
- echo "TIS620.2533 TIS-620"
- #echo "sun_eu_greek ?" # what is this?
- echo "UTF-8 UTF-8"
- ;;
- freebsd*)
- # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "C ASCII"
- echo "US-ASCII ASCII"
- for l in la_LN lt_LN; do
- echo "$l.ASCII ASCII"
- done
- for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
- fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
- lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
- echo "$l.ISO_8859-1 ISO-8859-1"
- echo "$l.DIS_8859-15 ISO-8859-15"
- done
- for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
- echo "$l.ISO_8859-2 ISO-8859-2"
- done
- for l in la_LN lt_LT; do
- echo "$l.ISO_8859-4 ISO-8859-4"
- done
- for l in ru_RU ru_SU; do
- echo "$l.KOI8-R KOI8-R"
- echo "$l.ISO_8859-5 ISO-8859-5"
- echo "$l.CP866 CP866"
- done
- echo "uk_UA.KOI8-U KOI8-U"
- echo "zh_TW.BIG5 BIG5"
- echo "zh_TW.Big5 BIG5"
- echo "zh_CN.EUC GB2312"
- echo "ja_JP.EUC EUC-JP"
- echo "ja_JP.SJIS SHIFT_JIS"
- echo "ja_JP.Shift_JIS SHIFT_JIS"
- echo "ko_KR.EUC EUC-KR"
- ;;
- netbsd*)
- echo "646 ASCII"
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-13 ISO-8859-13"
- echo "ISO8859-15 ISO-8859-15"
- echo "eucCN GB2312"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "BIG5 BIG5"
- echo "SJIS SHIFT_JIS"
- ;;
- openbsd*)
- echo "646 ASCII"
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-13 ISO-8859-13"
- echo "ISO8859-15 ISO-8859-15"
- ;;
- darwin[56]*)
- # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "C ASCII"
- for l in en_AU en_CA en_GB en_US la_LN; do
- echo "$l.US-ASCII ASCII"
- done
- for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
- fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
- nl_NL no_NO pt_PT sv_SE; do
- echo "$l ISO-8859-1"
- echo "$l.ISO8859-1 ISO-8859-1"
- echo "$l.ISO8859-15 ISO-8859-15"
- done
- for l in la_LN; do
- echo "$l.ISO8859-1 ISO-8859-1"
- echo "$l.ISO8859-15 ISO-8859-15"
- done
- for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
- echo "$l.ISO8859-2 ISO-8859-2"
- done
- for l in la_LN lt_LT; do
- echo "$l.ISO8859-4 ISO-8859-4"
- done
- for l in ru_RU; do
- echo "$l.KOI8-R KOI8-R"
- echo "$l.ISO8859-5 ISO-8859-5"
- echo "$l.CP866 CP866"
- done
- for l in bg_BG; do
- echo "$l.CP1251 CP1251"
- done
- echo "uk_UA.KOI8-U KOI8-U"
- echo "zh_TW.BIG5 BIG5"
- echo "zh_TW.Big5 BIG5"
- echo "zh_CN.EUC GB2312"
- echo "ja_JP.EUC EUC-JP"
- echo "ja_JP.SJIS SHIFT_JIS"
- echo "ko_KR.EUC EUC-KR"
- ;;
- darwin*)
- # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
- # useless:
- # - It returns the empty string when LANG is set to a locale of the
- # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
- # LC_CTYPE file.
- # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
- # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
- # - The documentation says:
- # "... all code that calls BSD system routines should ensure
- # that the const *char parameters of these routines are in UTF-8
- # encoding. All BSD system functions expect their string
- # parameters to be in UTF-8 encoding and nothing else."
- # It also says
- # "An additional caveat is that string parameters for files,
- # paths, and other file-system entities must be in canonical
- # UTF-8. In a canonical UTF-8 Unicode string, all decomposable
- # characters are decomposed ..."
- # but this is not true: You can pass non-decomposed UTF-8 strings
- # to file system functions, and it is the OS which will convert
- # them to decomposed UTF-8 before accessing the file system.
- # - The Apple Terminal application displays UTF-8 by default.
- # - However, other applications are free to use different encodings:
- # - xterm uses ISO-8859-1 by default.
- # - TextEdit uses MacRoman by default.
- # We prefer UTF-8 over decomposed UTF-8-MAC because one should
- # minimize the use of decomposed Unicode. Unfortunately, through the
- # Darwin file system, decomposed UTF-8 strings are leaked into user
- # space nevertheless.
- # Then there are also the locales with encodings other than US-ASCII
- # and UTF-8. These locales can be occasionally useful to users (e.g.
- # when grepping through ISO-8859-1 encoded text files), when all their
- # file names are in US-ASCII.
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-13 ISO-8859-13"
- echo "ISO8859-15 ISO-8859-15"
- echo "KOI8-R KOI8-R"
- echo "KOI8-U KOI8-U"
- echo "CP866 CP866"
- echo "CP949 CP949"
- echo "CP1131 CP1131"
- echo "CP1251 CP1251"
- echo "eucCN GB2312"
- echo "GB2312 GB2312"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "Big5 BIG5"
- echo "Big5HKSCS BIG5-HKSCS"
- echo "GBK GBK"
- echo "GB18030 GB18030"
- echo "SJIS SHIFT_JIS"
- echo "ARMSCII-8 ARMSCII-8"
- echo "PT154 PT154"
- #echo "ISCII-DEV ?"
- echo "* UTF-8"
- ;;
- beos* | haiku*)
- # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
- echo "* UTF-8"
- ;;
- msdosdjgpp*)
- # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "#"
- echo "# The encodings given here may not all be correct."
- echo "# If you find that the encoding given for your language and"
- echo "# country is not the one your DOS machine actually uses, just"
- echo "# correct it in this file, and send a mail to"
- echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
- echo "# and Bruno Haible <bruno@clisp.org>."
- echo "#"
- echo "C ASCII"
- # ISO-8859-1 languages
- echo "ca CP850"
- echo "ca_ES CP850"
- echo "da CP865" # not CP850 ??
- echo "da_DK CP865" # not CP850 ??
- echo "de CP850"
- echo "de_AT CP850"
- echo "de_CH CP850"
- echo "de_DE CP850"
- echo "en CP850"
- echo "en_AU CP850" # not CP437 ??
- echo "en_CA CP850"
- echo "en_GB CP850"
- echo "en_NZ CP437"
- echo "en_US CP437"
- echo "en_ZA CP850" # not CP437 ??
- echo "es CP850"
- echo "es_AR CP850"
- echo "es_BO CP850"
- echo "es_CL CP850"
- echo "es_CO CP850"
- echo "es_CR CP850"
- echo "es_CU CP850"
- echo "es_DO CP850"
- echo "es_EC CP850"
- echo "es_ES CP850"
- echo "es_GT CP850"
- echo "es_HN CP850"
- echo "es_MX CP850"
- echo "es_NI CP850"
- echo "es_PA CP850"
- echo "es_PY CP850"
- echo "es_PE CP850"
- echo "es_SV CP850"
- echo "es_UY CP850"
- echo "es_VE CP850"
- echo "et CP850"
- echo "et_EE CP850"
- echo "eu CP850"
- echo "eu_ES CP850"
- echo "fi CP850"
- echo "fi_FI CP850"
- echo "fr CP850"
- echo "fr_BE CP850"
- echo "fr_CA CP850"
- echo "fr_CH CP850"
- echo "fr_FR CP850"
- echo "ga CP850"
- echo "ga_IE CP850"
- echo "gd CP850"
- echo "gd_GB CP850"
- echo "gl CP850"
- echo "gl_ES CP850"
- echo "id CP850" # not CP437 ??
- echo "id_ID CP850" # not CP437 ??
- echo "is CP861" # not CP850 ??
- echo "is_IS CP861" # not CP850 ??
- echo "it CP850"
- echo "it_CH CP850"
- echo "it_IT CP850"
- echo "lt CP775"
- echo "lt_LT CP775"
- echo "lv CP775"
- echo "lv_LV CP775"
- echo "nb CP865" # not CP850 ??
- echo "nb_NO CP865" # not CP850 ??
- echo "nl CP850"
- echo "nl_BE CP850"
- echo "nl_NL CP850"
- echo "nn CP865" # not CP850 ??
- echo "nn_NO CP865" # not CP850 ??
- echo "no CP865" # not CP850 ??
- echo "no_NO CP865" # not CP850 ??
- echo "pt CP850"
- echo "pt_BR CP850"
- echo "pt_PT CP850"
- echo "sv CP850"
- echo "sv_SE CP850"
- # ISO-8859-2 languages
- echo "cs CP852"
- echo "cs_CZ CP852"
- echo "hr CP852"
- echo "hr_HR CP852"
- echo "hu CP852"
- echo "hu_HU CP852"
- echo "pl CP852"
- echo "pl_PL CP852"
- echo "ro CP852"
- echo "ro_RO CP852"
- echo "sk CP852"
- echo "sk_SK CP852"
- echo "sl CP852"
- echo "sl_SI CP852"
- echo "sq CP852"
- echo "sq_AL CP852"
- echo "sr CP852" # CP852 or CP866 or CP855 ??
- echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
- echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
- # ISO-8859-3 languages
- echo "mt CP850"
- echo "mt_MT CP850"
- # ISO-8859-5 languages
- echo "be CP866"
- echo "be_BE CP866"
- echo "bg CP866" # not CP855 ??
- echo "bg_BG CP866" # not CP855 ??
- echo "mk CP866" # not CP855 ??
- echo "mk_MK CP866" # not CP855 ??
- echo "ru CP866"
- echo "ru_RU CP866"
- echo "uk CP1125"
- echo "uk_UA CP1125"
- # ISO-8859-6 languages
- echo "ar CP864"
- echo "ar_AE CP864"
- echo "ar_DZ CP864"
- echo "ar_EG CP864"
- echo "ar_IQ CP864"
- echo "ar_IR CP864"
- echo "ar_JO CP864"
- echo "ar_KW CP864"
- echo "ar_MA CP864"
- echo "ar_OM CP864"
- echo "ar_QA CP864"
- echo "ar_SA CP864"
- echo "ar_SY CP864"
- # ISO-8859-7 languages
- echo "el CP869"
- echo "el_GR CP869"
- # ISO-8859-8 languages
- echo "he CP862"
- echo "he_IL CP862"
- # ISO-8859-9 languages
- echo "tr CP857"
- echo "tr_TR CP857"
- # Japanese
- echo "ja CP932"
- echo "ja_JP CP932"
- # Chinese
- echo "zh_CN GBK"
- echo "zh_TW CP950" # not CP938 ??
- # Korean
- echo "kr CP949" # not CP934 ??
- echo "kr_KR CP949" # not CP934 ??
- # Thai
- echo "th CP874"
- echo "th_TH CP874"
- # Other
- echo "eo CP850"
- echo "eo_EO CP850"
- ;;
-esac
diff --git a/libgnu/creat-safer.c b/libgnu/creat-safer.c
index e48cadc3..35f706b5 100644
--- a/libgnu/creat-safer.c
+++ b/libgnu/creat-safer.c
@@ -1,6 +1,6 @@
/* Invoke creat, but avoid some glitches.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/cycle-check.c b/libgnu/cycle-check.c
index 6add64b5..1ef08e68 100644
--- a/libgnu/cycle-check.c
+++ b/libgnu/cycle-check.c
@@ -1,6 +1,6 @@
/* help detect directory cycles efficiently
- Copyright (C) 2003-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering */
diff --git a/libgnu/cycle-check.h b/libgnu/cycle-check.h
index 0c9a68b6..e10ab029 100644
--- a/libgnu/cycle-check.h
+++ b/libgnu/cycle-check.h
@@ -1,6 +1,6 @@
/* help detect directory cycles efficiently
- Copyright (C) 2003-2004, 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2004, 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering */
diff --git a/libgnu/dirent--.h b/libgnu/dirent--.h
deleted file mode 100644
index 5f477e85..00000000
--- a/libgnu/dirent--.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Like dirent.h, but redefine some names to avoid glitches.
-
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Eric Blake. */
-
-#include "dirent-safer.h"
-
-#undef opendir
-#define opendir opendir_safer
-#define GNULIB_defined_opendir 1
diff --git a/libgnu/dirent-private.h b/libgnu/dirent-private.h
index 4a0b1c5b..69edcc52 100644
--- a/libgnu/dirent-private.h
+++ b/libgnu/dirent-private.h
@@ -1,5 +1,5 @@
/* Private details of the DIR type.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _DIRENT_PRIVATE_H
#define _DIRENT_PRIVATE_H 1
diff --git a/libgnu/dirent-safer.h b/libgnu/dirent-safer.h
deleted file mode 100644
index a5957974..00000000
--- a/libgnu/dirent-safer.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Invoke dirent-like functions, but avoid some glitches.
-
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Eric Blake. */
-
-#include <dirent.h>
-
-DIR *opendir_safer (const char *name);
diff --git a/libgnu/dirent.in.h b/libgnu/dirent.in.h
index f5917875..2ab25af6 100644
--- a/libgnu/dirent.in.h
+++ b/libgnu/dirent.in.h
@@ -1,5 +1,5 @@
/* A GNU-like <dirent.h>.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_DIRENT_H
diff --git a/libgnu/dirfd.c b/libgnu/dirfd.c
index 6b1a7b27..19c80468 100644
--- a/libgnu/dirfd.c
+++ b/libgnu/dirfd.c
@@ -1,6 +1,6 @@
/* dirfd.c -- return the file descriptor associated with an open DIR*
- Copyright (C) 2001, 2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/dirname-lgpl.c b/libgnu/dirname-lgpl.c
index b549ca97..a40f6a90 100644
--- a/libgnu/dirname-lgpl.c
+++ b/libgnu/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-2017 Free Software
+ Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/dirname.c b/libgnu/dirname.c
deleted file mode 100644
index ed575574..00000000
--- a/libgnu/dirname.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* dirname.c -- return all but the last element in a file name
-
- Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2017 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "dirname.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include "xalloc.h"
-
-/* Just like mdir_name (dirname-lgpl.c), except, rather than
- returning NULL upon malloc failure, here, we report the
- "memory exhausted" condition and exit. */
-
-char *
-dir_name (char const *file)
-{
- char *result = mdir_name (file);
- if (!result)
- xalloc_die ();
- return result;
-}
diff --git a/libgnu/dirname.h b/libgnu/dirname.h
index dbf920b1..8b511116 100644
--- a/libgnu/dirname.h
+++ b/libgnu/dirname.h
@@ -1,6 +1,6 @@
/* Take file names apart into directory and base names.
- Copyright (C) 1998, 2001, 2003-2006, 2009-2017 Free Software Foundation,
+ Copyright (C) 1998, 2001, 2003-2006, 2009-2018 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef DIRNAME_H_
# define DIRNAME_H_ 1
@@ -36,7 +36,7 @@ extern "C" {
#endif
# if GNULIB_DIRNAME
-char *base_name (char const *file);
+char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC;
char *dir_name (char const *file);
# endif
diff --git a/libgnu/dosname.h b/libgnu/dosname.h
index dd5c1777..fef3b6da 100644
--- a/libgnu/dosname.h
+++ b/libgnu/dosname.h
@@ -1,6 +1,6 @@
/* File names on MS-DOS/Windows systems.
- Copyright (C) 2000-2001, 2004-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2000-2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,16 +13,15 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
From Paul Eggert and Jim Meyering. */
#ifndef _DOSNAME_H
#define _DOSNAME_H
-#if (defined _WIN32 || defined __WIN32__ || \
- defined __MSDOS__ || defined __CYGWIN__ || \
- defined __EMX__ || defined __DJGPP__)
+#if (defined _WIN32 || defined __CYGWIN__ \
+ || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
/* This internal macro assumes ASCII, but all hosts that support drive
letters use ASCII. */
# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
diff --git a/libgnu/dup-safer-flag.c b/libgnu/dup-safer-flag.c
new file mode 100644
index 00000000..aa28194d
--- /dev/null
+++ b/libgnu/dup-safer-flag.c
@@ -0,0 +1,38 @@
+/* Duplicate a file descriptor result, avoiding clobbering
+ STD{IN,OUT,ERR}_FILENO, with specific flags.
+
+ Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Eric Blake. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistd-safer.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
+ STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like
+ fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */
+
+int
+dup_safer_flag (int fd, int flag)
+{
+ return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD,
+ STDERR_FILENO + 1);
+}
diff --git a/libgnu/dup-safer.c b/libgnu/dup-safer.c
index d00997c1..1f1679ea 100644
--- a/libgnu/dup-safer.c
+++ b/libgnu/dup-safer.c
@@ -1,6 +1,6 @@
/* Invoke dup, but avoid some glitches.
- Copyright (C) 2001, 2004-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/dup.c b/libgnu/dup.c
index 819e9e37..51136db8 100644
--- a/libgnu/dup.c
+++ b/libgnu/dup.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -22,7 +22,9 @@
#include <errno.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef dup
diff --git a/libgnu/dup2.c b/libgnu/dup2.c
index c0c7cadf..c7d17672 100644
--- a/libgnu/dup2.c
+++ b/libgnu/dup2.c
@@ -1,6 +1,6 @@
/* Duplicate an open file descriptor to a specified file descriptor.
- Copyright (C) 1999, 2004-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2004-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Paul Eggert */
@@ -29,16 +29,45 @@
# undef dup2
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+static int
+dup2_nothrow (int fd, int desired_fd)
+{
+ int result;
+
+ TRY_MSVC_INVAL
+ {
+ result = dup2 (fd, desired_fd);
+ }
+ CATCH_MSVC_INVAL
+ {
+ errno = EBADF;
+ result = -1;
+ }
+ DONE_MSVC_INVAL;
+
+ return result;
+}
+# else
+# define dup2_nothrow dup2
+# endif
static int
ms_windows_dup2 (int fd, int desired_fd)
@@ -59,23 +88,14 @@ ms_windows_dup2 (int fd, int desired_fd)
}
/* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
- http://bugs.winehq.org/show_bug.cgi?id=21289 */
+ https://bugs.winehq.org/show_bug.cgi?id=21289 */
if (desired_fd < 0)
{
errno = EBADF;
return -1;
}
- TRY_MSVC_INVAL
- {
- result = dup2 (fd, desired_fd);
- }
- CATCH_MSVC_INVAL
- {
- errno = EBADF;
- result = -1;
- }
- DONE_MSVC_INVAL;
+ result = dup2_nothrow (fd, desired_fd);
if (result == 0)
result = desired_fd;
diff --git a/libgnu/errno.in.h b/libgnu/errno.in.h
index 13194f9d..b95c4e9c 100644
--- a/libgnu/errno.in.h
+++ b/libgnu/errno.in.h
@@ -1,6 +1,6 @@
/* A POSIX-like <errno.h>.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_ERRNO_H
@@ -30,7 +30,7 @@
/* On native Windows platforms, many macros are not defined. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
/* These are the same values as defined by MSVC 10, for interoperability. */
@@ -248,7 +248,7 @@
interoperability. */
# define EOWNERDEAD 58
# define ENOTRECOVERABLE 59
-# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# elif defined _WIN32 && ! defined __CYGWIN__
/* We have a conflict here: pthreads-win32 defines these values
differently than MSVC 10. It's hairy to decide which one to use. */
# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
diff --git a/libgnu/error.c b/libgnu/error.c
index 535d8a2a..adc87339 100644
--- a/libgnu/error.c
+++ b/libgnu/error.c
@@ -1,5 +1,5 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1990-1998, 2000-2007, 2009-2018 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
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
@@ -93,33 +93,37 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
# include <fcntl.h>
# include <unistd.h>
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# endif
/* The gnulib override of fcntl is not needed in this file. */
# undef fcntl
-# if !HAVE_DECL_STRERROR_R
+# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
# ifndef HAVE_DECL_STRERROR_R
"this configure-time declaration test was not run"
# endif
# if STRERROR_R_CHAR_P
-char *strerror_r ();
+char *strerror_r (int errnum, char *buf, size_t buflen);
# else
-int strerror_r ();
+int strerror_r (int errnum, char *buf, size_t buflen);
# endif
# endif
#define program_name getprogname ()
-# if HAVE_STRERROR_R || defined strerror_r
+# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
-# endif /* HAVE_STRERROR_R || defined strerror_r */
+# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
#endif /* not _LIBC */
#if !_LIBC
@@ -127,7 +131,7 @@ int strerror_r ();
static int
is_open (int fd)
{
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
/* On native Windows: The initial state of unassigned standard file
descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
There is no fcntl, and the gnulib replacement fcntl does not support
@@ -172,9 +176,9 @@ print_errno_message (int errnum)
{
char const *s;
-#if defined HAVE_STRERROR_R || _LIBC
+#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
char errbuf[1024];
-# if _LIBC || STRERROR_R_CHAR_P
+# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
s = __strerror_r (errnum, errbuf, sizeof errbuf);
# else
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
@@ -268,7 +272,6 @@ error_tail (int status, int errnum, const char *message, va_list args)
else
#endif
vfprintf (stderr, message, args);
- va_end (args);
++error_message_count;
if (errnum)
@@ -318,6 +321,7 @@ error (int status, int errnum, const char *message, ...)
va_start (args, message);
error_tail (status, errnum, message, args);
+ va_end (args);
#ifdef _LIBC
_IO_funlockfile (stderr);
@@ -388,6 +392,7 @@ error_at_line (int status, int errnum, const char *file_name,
va_start (args, message);
error_tail (status, errnum, message, args);
+ va_end (args);
#ifdef _LIBC
_IO_funlockfile (stderr);
diff --git a/libgnu/error.h b/libgnu/error.h
index ef024d9d..36401e1a 100644
--- a/libgnu/error.h
+++ b/libgnu/error.h
@@ -1,5 +1,5 @@
/* Declaration for error-reporting function
- Copyright (C) 1995-1997, 2003, 2006, 2008-2017 Free Software Foundation,
+ Copyright (C) 1995-1997, 2003, 2006, 2008-2018 Free Software Foundation,
Inc.
This file is part of the GNU C Library.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _ERROR_H
#define _ERROR_H 1
diff --git a/libgnu/exitfail.c b/libgnu/exitfail.c
index 524eb5c3..19c5cba0 100644
--- a/libgnu/exitfail.c
+++ b/libgnu/exitfail.c
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002-2003, 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/exitfail.h b/libgnu/exitfail.h
index 895511f4..a42057b1 100644
--- a/libgnu/exitfail.h
+++ b/libgnu/exitfail.h
@@ -1,6 +1,6 @@
/* Failure exit status
- Copyright (C) 2002, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,6 +13,6 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
extern int volatile exit_failure;
diff --git a/libgnu/fchdir.c b/libgnu/fchdir.c
index 63a90f5f..6b0f97e7 100644
--- a/libgnu/fchdir.c
+++ b/libgnu/fchdir.c
@@ -1,5 +1,5 @@
/* fchdir replacement.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/fcntl--.h b/libgnu/fcntl--.h
index ba87d797..d63d24fc 100644
--- a/libgnu/fcntl--.h
+++ b/libgnu/fcntl--.h
@@ -1,6 +1,6 @@
/* Like fcntl.h, but redefine some names to avoid glitches.
- Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/fcntl-safer.h b/libgnu/fcntl-safer.h
index 252fe73c..e31e4f94 100644
--- a/libgnu/fcntl-safer.h
+++ b/libgnu/fcntl-safer.h
@@ -1,6 +1,6 @@
/* Invoke fcntl-like functions, but avoid some glitches.
- Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/fcntl.c b/libgnu/fcntl.c
index afe15468..be658356 100644
--- a/libgnu/fcntl.c
+++ b/libgnu/fcntl.c
@@ -1,6 +1,6 @@
/* Provide file descriptor control.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake <ebb9@byu.net>. */
@@ -32,13 +32,17 @@
#endif
#undef fcntl
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* Get declarations of the native Windows API functions. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
# define OPEN_MAX_MAX 0x10000
@@ -372,7 +376,7 @@ rpl_fcntl (int fd, int action, /* arg */...)
#if !HAVE_FCNTL
case F_GETFD:
{
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
HANDLE handle = (HANDLE) _get_osfhandle (fd);
DWORD flags;
if (handle == INVALID_HANDLE_VALUE
diff --git a/libgnu/fcntl.in.h b/libgnu/fcntl.in.h
index 4a1d40af..a1e7d35c 100644
--- a/libgnu/fcntl.in.h
+++ b/libgnu/fcntl.in.h
@@ -1,6 +1,6 @@
/* Like <fcntl.h>, but with non-working flags defined to 0.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Paul Eggert */
@@ -68,7 +68,7 @@
/* Native Windows platforms declare open(), creat() in <io.h>. */
#if (@GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+ && (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
@@ -213,7 +213,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
#endif
#ifndef O_CLOEXEC
-# define O_CLOEXEC 0
+# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
+# define GNULIB_defined_O_CLOEXEC 1
+#else
+# define GNULIB_defined_O_CLOEXEC 0
#endif
#ifndef O_DIRECT
diff --git a/libgnu/fd-hook.c b/libgnu/fd-hook.c
index ab5847ac..95a0662b 100644
--- a/libgnu/fd-hook.c
+++ b/libgnu/fd-hook.c
@@ -1,5 +1,5 @@
-/* Hook for making making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+/* Hook for making file descriptor functions close(), ioctl() extensible.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2009.
This program is free software: you can redistribute it and/or modify it
@@ -13,7 +13,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/fd-hook.h b/libgnu/fd-hook.h
index fe0d1b04..dbc5b67a 100644
--- a/libgnu/fd-hook.h
+++ b/libgnu/fd-hook.h
@@ -1,5 +1,5 @@
-/* Hook for making making file descriptor functions close(), ioctl() extensible.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+/* Hook for making file descriptor functions close(), ioctl() extensible.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef FD_HOOK_H
diff --git a/libgnu/fd-safer-flag.c b/libgnu/fd-safer-flag.c
new file mode 100644
index 00000000..b7574848
--- /dev/null
+++ b/libgnu/fd-safer-flag.c
@@ -0,0 +1,52 @@
+/* Adjust a file descriptor result so that it avoids clobbering
+ STD{IN,OUT,ERR}_FILENO, with specific flags.
+
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert and Eric Blake. */
+
+#include <config.h>
+
+/* Specification. */
+#include "unistd-safer.h"
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Return FD, unless FD would be a copy of standard input, output, or
+ error; in that case, return a duplicate of FD, closing FD. If FLAG
+ contains O_CLOEXEC, the returned FD will have close-on-exec
+ semantics. On failure to duplicate, close FD, set errno, and
+ return -1. Preserve errno if FD is negative, so that the caller
+ can always inspect errno when the returned value is negative.
+
+ This function is usefully wrapped around functions that return file
+ descriptors, e.g., fd_safer_flag (open ("file", O_RDONLY | flag), flag). */
+
+int
+fd_safer_flag (int fd, int flag)
+{
+ if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
+ {
+ int f = dup_safer_flag (fd, flag);
+ int e = errno;
+ close (fd);
+ errno = e;
+ fd = f;
+ }
+
+ return fd;
+}
diff --git a/libgnu/fd-safer.c b/libgnu/fd-safer.c
index da091285..1ea9a498 100644
--- a/libgnu/fd-safer.c
+++ b/libgnu/fd-safer.c
@@ -1,6 +1,6 @@
/* Return a safer copy of a file descriptor.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/fdopendir.c b/libgnu/fdopendir.c
index 03be92ad..9adefd21 100644
--- a/libgnu/fdopendir.c
+++ b/libgnu/fdopendir.c
@@ -1,5 +1,5 @@
/* provide a replacement fdopendir function
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/ffs.c b/libgnu/ffs.c
index d10a7332..e66c5a13 100644
--- a/libgnu/ffs.c
+++ b/libgnu/ffs.c
@@ -1,5 +1,5 @@
/* ffs.c -- find the first set bit in a word.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake. */
@@ -29,7 +29,7 @@ ffs (int i)
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
return __builtin_ffs (i);
#else
- /* http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup
+ /* <https://github.com/gibsjose/BitHacks>
gives this deBruijn constant for a branch-less computation, although
that table counted trailing zeros rather than bit position. This
requires 32-bit int, we fall back to a naive algorithm on the rare
diff --git a/libgnu/file-set.c b/libgnu/file-set.c
deleted file mode 100644
index d71006fa..00000000
--- a/libgnu/file-set.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Specialized functions to manipulate a set of files.
- Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-#include "file-set.h"
-
-#include "hash-triple.h"
-#include "xalloc.h"
-
-/* Record file, FILE, and dev/ino from *STATS, in the hash table, HT.
- If HT is NULL, return immediately.
- If memory allocation fails, exit immediately. */
-void
-record_file (Hash_table *ht, char const *file, struct stat const *stats)
-{
- struct F_triple *ent;
-
- if (ht == NULL)
- return;
-
- ent = xmalloc (sizeof *ent);
- ent->name = xstrdup (file);
- ent->st_ino = stats->st_ino;
- ent->st_dev = stats->st_dev;
-
- {
- struct F_triple *ent_from_table = hash_insert (ht, ent);
- if (ent_from_table == NULL)
- {
- /* Insertion failed due to lack of memory. */
- xalloc_die ();
- }
-
- if (ent_from_table != ent)
- {
- /* There was alread a matching entry in the table, so ENT was
- not inserted. Free it. */
- triple_free (ent);
- }
- }
-}
-
-/* Return true if there is an entry in hash table, HT,
- for the file described by FILE and STATS. */
-bool
-seen_file (Hash_table const *ht, char const *file,
- struct stat const *stats)
-{
- struct F_triple new_ent;
-
- if (ht == NULL)
- return false;
-
- new_ent.name = (char *) file;
- new_ent.st_ino = stats->st_ino;
- new_ent.st_dev = stats->st_dev;
-
- return !!hash_lookup (ht, &new_ent);
-}
diff --git a/libgnu/file-set.h b/libgnu/file-set.h
deleted file mode 100644
index 4e47d95a..00000000
--- a/libgnu/file-set.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdbool.h>
-
-#include "hash.h"
-
-extern void record_file (Hash_table *ht, char const *file,
- struct stat const *stats)
-#if defined __GNUC__ && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3)
- __attribute__ ((nonnull (2, 3)))
-#endif
-;
-
-extern bool seen_file (Hash_table const *ht, char const *file,
- struct stat const *stats);
diff --git a/libgnu/filename.h b/libgnu/filename.h
index 0ea7e956..a7ad7e7e 100644
--- a/libgnu/filename.h
+++ b/libgnu/filename.h
@@ -1,5 +1,5 @@
/* Basic filename support macros.
- Copyright (C) 2001-2004, 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2004, 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _FILENAME_H
#define _FILENAME_H
@@ -28,7 +28,7 @@ extern "C" {
it may be concatenated to a directory pathname.
IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
*/
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
/* Native Windows, Cygwin, OS/2, DOS */
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
# define HAS_DEVICE(P) \
diff --git a/libgnu/filenamecat-lgpl.c b/libgnu/filenamecat-lgpl.c
index 6dade120..f50ecc13 100644
--- a/libgnu/filenamecat-lgpl.c
+++ b/libgnu/filenamecat-lgpl.c
@@ -1,6 +1,6 @@
/* Concatenate two arbitrary file names.
- Copyright (C) 1996-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1996-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
@@ -31,55 +31,54 @@
# 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
+/* Concatenate two file name components, DIR and BASE, 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.
+ DIR; ls ./BASE)" refer to the same file. If necessary, put
+ a separator between DIR and BASE in the result. Typically this
+ separator is "/", but in rare cases it might be ".".
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.
+ *BASE_IN_RESULT to point to the copy of BASE at the end of the
+ returned concatenation.
Return NULL if malloc fails. */
char *
-mfile_name_concat (char const *dir, char const *abase, char **base_in_result)
+mfile_name_concat (char const *dir, char const *base, 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 sep = '\0';
+ if (dirbaselen)
+ {
+ /* DIR is not a file system root, so separate with / if needed. */
+ if (! ISSLASH (dir[dirlen - 1]) && ! ISSLASH (*base))
+ sep = '/';
+ }
+ else if (ISSLASH (*base))
+ {
+ /* DIR is a file system root and BASE begins with a slash, so
+ separate with ".". For example, if DIR is "/" and BASE is
+ "/foo" then return "/./foo", as "//foo" would be wrong on
+ some POSIX systems. A fancier algorithm could omit "." in
+ some cases but is not worth the trouble. */
+ sep = '.';
+ }
+
+ char *p_concat = malloc (dirlen + (sep != '\0') + baselen + 1);
char *p;
if (p_concat == NULL)
return NULL;
p = mempcpy (p_concat, dir, dirlen);
- *p = DIRECTORY_SEPARATOR;
- p += needs_separator;
+ *p = sep;
+ p += sep != '\0';
if (base_in_result)
- *base_in_result = p - IS_ABSOLUTE_FILE_NAME (abase);
+ *base_in_result = p;
p = mempcpy (p, base, baselen);
*p = '\0';
diff --git a/libgnu/filenamecat.h b/libgnu/filenamecat.h
index feb906af..fee61532 100644
--- a/libgnu/filenamecat.h
+++ b/libgnu/filenamecat.h
@@ -1,6 +1,6 @@
/* Concatenate two arbitrary file names.
- Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2017 Free Software
+ Copyright (C) 1996-1997, 2003, 2005, 2007, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/flexmember.h b/libgnu/flexmember.h
index c71ea651..7e3f5983 100644
--- a/libgnu/flexmember.h
+++ b/libgnu/flexmember.h
@@ -1,19 +1,22 @@
/* Sizes of structs with flexible array members.
- Copyright 2016-2017 Free Software Foundation, Inc.
+ Copyright 2016-2018 Free Software Foundation, Inc.
- This 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 file is part of the GNU C Library.
- This program is distributed in the hope that it will be useful,
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>.
Written by Paul Eggert. */
diff --git a/libgnu/float+.h b/libgnu/float+.h
index ba8ecb7b..2cb858f6 100644
--- a/libgnu/float+.h
+++ b/libgnu/float+.h
@@ -1,5 +1,5 @@
/* Supplemental information about the floating-point formats.
- Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _FLOATPLUS_H
#define _FLOATPLUS_H
diff --git a/libgnu/float.c b/libgnu/float.c
index b9103ecf..7caca837 100644
--- a/libgnu/float.c
+++ b/libgnu/float.c
@@ -1,5 +1,5 @@
/* Auxiliary definitions for <float.h>.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/float.in.h b/libgnu/float.in.h
index 3e012003..2cdbd122 100644
--- a/libgnu/float.in.h
+++ b/libgnu/float.in.h
@@ -1,6 +1,6 @@
/* A correct <float.h>.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_FLOAT_H
@@ -62,8 +62,8 @@
/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
precision in the compiler but 64 bits of precision at runtime. See
- <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>. */
-#if defined __i386__ && defined __FreeBSD__
+ <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>. */
+#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
/* Number of mantissa units, in base FLT_RADIX. */
# undef LDBL_MANT_DIG
# define LDBL_MANT_DIG 64
@@ -81,7 +81,7 @@
# define LDBL_MAX_EXP 16384
/* Minimum positive normalized number. */
# undef LDBL_MIN
-# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */
+# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
/* Maximum representable finite number. */
# undef LDBL_MAX
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
diff --git a/libgnu/fnmatch.c b/libgnu/fnmatch.c
index 709d4ff1..0fa0a3db 100644
--- a/libgnu/fnmatch.c
+++ b/libgnu/fnmatch.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993, 1996-2007, 2009-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993, 1996-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -11,7 +11,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
@@ -65,6 +65,14 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
#include "flexmember.h"
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
#define NO_LEADING_PERIOD(flags) \
((flags & (FNM_FILE_NAME | FNM_PERIOD)) == (FNM_FILE_NAME | FNM_PERIOD))
diff --git a/libgnu/fnmatch.in.h b/libgnu/fnmatch.in.h
index 1782ad2d..2464449b 100644
--- a/libgnu/fnmatch.in.h
+++ b/libgnu/fnmatch.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2017 Free
+/* Copyright (C) 1991-1993, 1996-1999, 2001-2003, 2005, 2007, 2009-2018 Free
Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
diff --git a/libgnu/fnmatch_loop.c b/libgnu/fnmatch_loop.c
index 97a1b9ae..dcf5a151 100644
--- a/libgnu/fnmatch_loop.c
+++ b/libgnu/fnmatch_loop.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1993, 1996-2006, 2009-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1991-1993, 1996-2006, 2009-2018 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
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Match STRING against the file name pattern PATTERN, returning zero if
it matches, nonzero if not. */
@@ -960,7 +960,7 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
new_no_leading_period = true;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH;
default:
normal_match:
if (n == string_end || c != FOLD ((UCHAR) *n))
@@ -1114,8 +1114,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
case L_('*'):
if (FCT (p, string, string_end, no_leading_period, flags) == 0)
return 0;
- /* FALLTHROUGH */
-
+ FALLTHROUGH;
case L_('+'):
do
{
@@ -1151,8 +1150,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
case L_('?'):
if (FCT (p, string, string_end, no_leading_period, flags) == 0)
return 0;
- /* FALLTHROUGH */
-
+ FALLTHROUGH;
case L_('@'):
do
/* I cannot believe it but 'strcat' is actually acceptable
diff --git a/libgnu/fstat.c b/libgnu/fstat.c
index a5aabc56..41ee7618 100644
--- a/libgnu/fstat.c
+++ b/libgnu/fstat.c
@@ -1,5 +1,5 @@
/* fstat() replacement.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* 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_fstat doesn't recurse to
@@ -23,54 +23,41 @@
/* Get the original definition of fstat. It might be defined as a macro. */
#include <sys/types.h>
#include <sys/stat.h>
-#if _GL_WINDOWS_64_BIT_ST_SIZE
-# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
-# define stat _stati64
-# undef fstat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
-# define fstat _fstati64
-#endif
#undef __need_system_sys_stat_h
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
+#endif
+
+#if !defined WINDOWS_NATIVE
+
static int
orig_fstat (int fd, struct stat *buf)
{
return fstat (fd, buf);
}
+#endif
+
/* Specification. */
/* 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"
+#include "stat-time.h"
+
#include <errno.h>
#include <unistd.h>
-
-#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-# include "msvc-inval.h"
-#endif
-
-#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-static int
-fstat_nothrow (int fd, struct stat *buf)
-{
- int result;
-
- TRY_MSVC_INVAL
- {
- result = orig_fstat (fd, buf);
- }
- CATCH_MSVC_INVAL
- {
- result = -1;
- errno = EBADF;
- }
- DONE_MSVC_INVAL;
-
- return result;
-}
-#else
-# define fstat_nothrow orig_fstat
+#ifdef WINDOWS_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
+# include "stat-w32.h"
#endif
int
@@ -84,5 +71,20 @@ rpl_fstat (int fd, struct stat *buf)
return stat (name, buf);
#endif
- return fstat_nothrow (fd, buf);
+#ifdef WINDOWS_NATIVE
+ /* Fill the fields ourselves, because the original fstat function returns
+ values for st_atime, st_mtime, st_ctime that depend on the current time
+ zone. See
+ <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
+ HANDLE h = (HANDLE) _get_osfhandle (fd);
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
+ return _gl_fstat_by_handle (h, NULL, buf);
+#else
+ return stat_time_normalize (orig_fstat (fd, buf), buf);
+#endif
}
diff --git a/libgnu/fstatat.c b/libgnu/fstatat.c
index 70799beb..63ceceb6 100644
--- a/libgnu/fstatat.c
+++ b/libgnu/fstatat.c
@@ -1,6 +1,6 @@
/* Work around an fstatat bug on Solaris 9.
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert and Jim Meyering. */
@@ -28,7 +28,7 @@
#include <sys/stat.h>
#undef __need_system_sys_stat_h
-#if HAVE_FSTATAT
+#if HAVE_FSTATAT && HAVE_WORKING_FSTATAT_ZERO_FLAG
static int
orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
{
@@ -41,6 +41,8 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
above. */
#include "sys/stat.h"
+#include "stat-time.h"
+
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@@ -51,6 +53,12 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0
# endif
+static int
+normal_fstatat (int fd, char const *file, struct stat *st, int flag)
+{
+ return stat_time_normalize (orig_fstatat (fd, file, st, flag), st);
+}
+
/* 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.
@@ -63,7 +71,7 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags)
int
rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
{
- int result = orig_fstatat (fd, file, st, flag);
+ int result = normal_fstatat (fd, file, st, flag);
size_t len;
if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0)
@@ -79,7 +87,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
errno = ENOTDIR;
return -1;
}
- result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
+ result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
}
/* Fix stat behavior. */
if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')
@@ -111,7 +119,7 @@ stat_func (char const *name, struct stat *st)
# endif
/* Replacement for Solaris' function by the same name.
- <http://www.google.com/search?q=fstatat+site:docs.sun.com>
+ <https://www.google.com/search?q=fstatat+site:docs.oracle.com>
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),
diff --git a/libgnu/fts-cycle.c b/libgnu/fts-cycle.c
index 9c6a1b08..2d3205f9 100644
--- a/libgnu/fts-cycle.c
+++ b/libgnu/fts-cycle.c
@@ -1,6 +1,6 @@
/* Detect cycles in file tree walks.
- Copyright (C) 2003-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2006, 2009-2018 Free Software Foundation, Inc.
Written by Jim Meyering.
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include "cycle-check.h"
#include "hash.h"
diff --git a/libgnu/fts.c b/libgnu/fts.c
index fabaa97d..1ccc78c1 100644
--- a/libgnu/fts.c
+++ b/libgnu/fts.c
@@ -1,6 +1,6 @@
/* Traverse a file hierarchy.
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -71,11 +71,6 @@ static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
#if ! _LIBC
# include "fcntl--.h"
-# include "dirent--.h"
-# include "unistd--.h"
-/* FIXME - use fcntl(F_DUPFD_CLOEXEC)/openat(O_CLOEXEC) once they are
- supported. */
-# include "cloexec.h"
# include "flexmember.h"
# include "openat.h"
# include "same-inode.h"
@@ -203,6 +198,14 @@ enum Fts_stat
while (false)
#endif
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
static FTSENT *fts_alloc (FTS *, const char *, size_t) internal_function;
static FTSENT *fts_build (FTS *, int) internal_function;
static void fts_lfree (FTSENT *) internal_function;
@@ -297,14 +300,13 @@ static DIR *
internal_function
opendirat (int fd, char const *dir, int extra_flags, int *pdir_fd)
{
- int new_fd = openat (fd, dir,
- (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK
- | extra_flags));
+ int open_flags = (O_RDONLY | O_CLOEXEC | O_DIRECTORY | O_NOCTTY
+ | O_NONBLOCK | extra_flags);
+ int new_fd = openat (fd, dir, open_flags);
DIR *dirp;
if (new_fd < 0)
return NULL;
- set_cloexec_flag (new_fd, true);
dirp = fdopendir (new_fd);
if (dirp)
*pdir_fd = new_fd;
@@ -367,15 +369,13 @@ static int
internal_function
diropen (FTS const *sp, char const *dir)
{
- int open_flags = (O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK
+ int open_flags = (O_SEARCH | O_CLOEXEC | O_DIRECTORY | O_NOCTTY | O_NONBLOCK
| (ISSET (FTS_PHYSICAL) ? O_NOFOLLOW : 0)
| (ISSET (FTS_NOATIME) ? O_NOATIME : 0));
int fd = (ISSET (FTS_CWDFD)
? openat (sp->fts_cwd_fd, dir, open_flags)
: open (dir, open_flags));
- if (0 <= fd)
- set_cloexec_flag (fd, true);
return fd;
}
@@ -471,6 +471,7 @@ fts_open (char * const *argv,
if ((parent = fts_alloc(sp, "", 0)) == NULL)
goto mem2;
parent->fts_level = FTS_ROOTPARENTLEVEL;
+ parent->fts_n_dirs_remaining = -1;
}
/* The classic fts implementation would call fts_stat with
@@ -545,6 +546,7 @@ fts_open (char * const *argv,
goto mem3;
sp->fts_cur->fts_link = root;
sp->fts_cur->fts_info = FTS_INIT;
+ sp->fts_cur->fts_level = 1;
if (! setup_dir (sp))
goto mem3;
@@ -657,42 +659,145 @@ fts_close (FTS *sp)
return (0);
}
+/* Minimum link count of a traditional Unix directory. When leaf
+ optimization is OK and MIN_DIR_NLINK <= st_nlink, then st_nlink is
+ an upper bound on the number of subdirectories (counting "." and
+ ".."). */
+enum { MIN_DIR_NLINK = 2 };
+
+/* Whether leaf optimization is OK for a directory. */
+enum leaf_optimization
+ {
+ /* st_nlink is not reliable for this directory's subdirectories. */
+ NO_LEAF_OPTIMIZATION,
+
+ /* Leaf optimization is OK, but is not useful for avoiding stat calls. */
+ OK_LEAF_OPTIMIZATION,
+
+ /* Leaf optimization is not only OK: it is useful for avoiding
+ stat calls, because dirent.d_type does not work. */
+ NOSTAT_LEAF_OPTIMIZATION
+ };
+
#if defined __linux__ \
&& HAVE_SYS_VFS_H && HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE
# include <sys/vfs.h>
/* Linux-specific constants from coreutils' src/fs.h */
-# define S_MAGIC_TMPFS 0x1021994
+# define S_MAGIC_AFS 0x5346414F
+# define S_MAGIC_CIFS 0xFF534D42
# define S_MAGIC_NFS 0x6969
+# define S_MAGIC_PROC 0x9FA0
# define S_MAGIC_REISERFS 0x52654973
+# define S_MAGIC_TMPFS 0x1021994
# define S_MAGIC_XFS 0x58465342
-# define S_MAGIC_PROC 0x9FA0
-/* Return false if it is easy to determine the file system type of
- the directory on which DIR_FD is open, and sorting dirents on
- inode numbers is known not to improve traversal performance with
- that type of file system. Otherwise, return true. */
+# ifdef HAVE___FSWORD_T
+typedef __fsword_t fsword;
+# else
+typedef long int fsword;
+# endif
+
+/* Map a stat.st_dev number to a file system type number f_ftype. */
+struct dev_type
+{
+ dev_t st_dev;
+ fsword f_type;
+};
+
+/* Use a tiny initial size. If a traversal encounters more than
+ a few devices, the cost of growing/rehashing this table will be
+ rendered negligible by the number of inodes processed. */
+enum { DEV_TYPE_HT_INITIAL_SIZE = 13 };
+
+static size_t
+dev_type_hash (void const *x, size_t table_size)
+{
+ struct dev_type const *ax = x;
+ uintmax_t dev = ax->st_dev;
+ return dev % table_size;
+}
+
static bool
-dirent_inode_sort_may_be_useful (int dir_fd)
+dev_type_compare (void const *x, void const *y)
+{
+ struct dev_type const *ax = x;
+ struct dev_type const *ay = y;
+ return ax->st_dev == ay->st_dev;
+}
+
+/* Return the file system type of P with file descriptor FD, or 0 if not known.
+ If FD is negative, P's file descriptor is unavailable.
+ Try to cache known values. */
+
+static fsword
+filesystem_type (FTSENT const *p, int fd)
+{
+ FTS *sp = p->fts_fts;
+ Hash_table *h = sp->fts_leaf_optimization_works_ht;
+ struct dev_type *ent;
+ struct statfs fs_buf;
+
+ /* If we're not in CWDFD mode, don't bother with this optimization,
+ since the caller is not serious about performance. */
+ if (!ISSET (FTS_CWDFD))
+ return 0;
+
+ if (! h)
+ h = sp->fts_leaf_optimization_works_ht
+ = hash_initialize (DEV_TYPE_HT_INITIAL_SIZE, NULL, dev_type_hash,
+ dev_type_compare, free);
+ if (h)
+ {
+ struct dev_type tmp;
+ tmp.st_dev = p->fts_statp->st_dev;
+ ent = hash_lookup (h, &tmp);
+ if (ent)
+ return ent->f_type;
+ }
+
+ /* Look-up failed. Query directly and cache the result. */
+ if (fd < 0 || fstatfs (fd, &fs_buf) != 0)
+ return 0;
+
+ if (h)
+ {
+ struct dev_type *t2 = malloc (sizeof *t2);
+ if (t2)
+ {
+ t2->st_dev = p->fts_statp->st_dev;
+ t2->f_type = fs_buf.f_type;
+
+ ent = hash_insert (h, t2);
+ if (ent)
+ fts_assert (ent == t2);
+ else
+ free (t2);
+ }
+ }
+
+ return fs_buf.f_type;
+}
+
+/* Return true if sorting dirents on inode numbers is known to improve
+ traversal performance for the directory P with descriptor DIR_FD.
+ Return false otherwise. When in doubt, return true.
+ DIR_FD is negative if unavailable. */
+static bool
+dirent_inode_sort_may_be_useful (FTSENT const *p, int dir_fd)
{
/* Skip the sort only if we can determine efficiently
that skipping it is the right thing to do.
The cost of performing an unnecessary sort is negligible,
while the cost of *not* performing it can be O(N^2) with
a very large constant. */
- struct statfs fs_buf;
-
- /* If fstatfs fails, assume sorting would be useful. */
- if (fstatfs (dir_fd, &fs_buf) != 0)
- return true;
- /* FIXME: what about when f_type is not an integral type?
- deal with that if/when it's encountered. */
- switch (fs_buf.f_type)
+ switch (filesystem_type (p, dir_fd))
{
- case S_MAGIC_TMPFS:
+ case S_MAGIC_CIFS:
case S_MAGIC_NFS:
+ case S_MAGIC_TMPFS:
/* On a file system of any of these types, sorting
is unnecessary, and hence wasteful. */
return false;
@@ -702,134 +807,64 @@ dirent_inode_sort_may_be_useful (int dir_fd)
}
}
-/* Given a file descriptor DIR_FD open on a directory D,
- return true if it is valid to apply the leaf-optimization
- technique of counting directories in D via stat.st_nlink. */
-static bool
-leaf_optimization_applies (int dir_fd)
+/* Given an FTS entry P for a directory with descriptor DIR_FD,
+ return true if it is both useful and valid to apply leaf optimization.
+ The optimization is useful only for file systems that lack usable
+ dirent.d_type info. The optimization is valid if an st_nlink value
+ of at least MIN_DIR_NLINK is an upper bound on the number of
+ subdirectories of D, counting "." and ".." as subdirectories.
+ DIR_FD is negative if unavailable. */
+static enum leaf_optimization
+leaf_optimization (FTSENT const *p, int dir_fd)
{
- struct statfs fs_buf;
-
- /* If fstatfs fails, assume we can't use the optimization. */
- if (fstatfs (dir_fd, &fs_buf) != 0)
- return false;
-
- /* FIXME: do we need to detect AFS mount points? I doubt it,
- unless fstatfs can report S_MAGIC_REISERFS for such a directory. */
-
- switch (fs_buf.f_type)
+ switch (filesystem_type (p, dir_fd))
{
- /* List here the file system types that lack usable dirent.d_type
+ /* List here the file system types that may lack usable dirent.d_type
info, yet for which the optimization does apply. */
case S_MAGIC_REISERFS:
- case S_MAGIC_XFS:
- return true;
-
- /* Explicitly list here any other file system type for which the
- optimization is not applicable, but need documentation. */
+ case S_MAGIC_XFS: /* XFS lacked it until 2013-08-22 commit. */
+ return NOSTAT_LEAF_OPTIMIZATION;
+
+ case 0:
+ /* Leaf optimization is unsafe if the file system type is unknown. */
+ FALLTHROUGH;
+ case S_MAGIC_AFS:
+ /* Although AFS mount points are not counted in st_nlink, they
+ act like directories. See <https://bugs.debian.org/143111>. */
+ FALLTHROUGH;
+ case S_MAGIC_CIFS:
+ /* Leaf optimization causes 'find' to abort. See
+ <https://lists.gnu.org/r/bug-gnulib/2018-04/msg00015.html>. */
+ FALLTHROUGH;
case S_MAGIC_NFS:
/* NFS provides usable dirent.d_type but not necessarily for all entries
of large directories, so as per <https://bugzilla.redhat.com/1252549>
NFS should return true. However st_nlink values are not accurate on
all implementations as per <https://bugzilla.redhat.com/1299169>. */
- /* fall through */
+ FALLTHROUGH;
case S_MAGIC_PROC:
- /* Per <http://bugs.debian.org/143111> /proc may have
- bogus stat.st_nlink values. */
- /* fall through */
+ /* Per <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=143111> /proc
+ may have bogus stat.st_nlink values. */
+ return NO_LEAF_OPTIMIZATION;
+
default:
- return false;
+ return OK_LEAF_OPTIMIZATION;
}
}
#else
static bool
-dirent_inode_sort_may_be_useful (int dir_fd _GL_UNUSED) { return true; }
-static bool
-leaf_optimization_applies (int dir_fd _GL_UNUSED) { return false; }
-#endif
-
-/* link-count-optimization entry:
- map a stat.st_dev number to a boolean: leaf_optimization_works */
-struct LCO_ent
-{
- dev_t st_dev;
- bool opt_ok;
-};
-
-/* Use a tiny initial size. If a traversal encounters more than
- a few devices, the cost of growing/rehashing this table will be
- rendered negligible by the number of inodes processed. */
-enum { LCO_HT_INITIAL_SIZE = 13 };
-
-static size_t
-LCO_hash (void const *x, size_t table_size)
+dirent_inode_sort_may_be_useful (FTSENT const *p _GL_UNUSED,
+ int dir_fd _GL_UNUSED)
{
- struct LCO_ent const *ax = x;
- return (uintmax_t) ax->st_dev % table_size;
+ return true;
}
-
-static bool
-LCO_compare (void const *x, void const *y)
+static enum leaf_optimization
+leaf_optimization (FTSENT const *p _GL_UNUSED, int dir_fd _GL_UNUSED)
{
- struct LCO_ent const *ax = x;
- struct LCO_ent const *ay = y;
- return ax->st_dev == ay->st_dev;
-}
-
-/* Ask the same question as leaf_optimization_applies, but query
- the cache first (FTS.fts_leaf_optimization_works_ht), and if necessary,
- update that cache. */
-static bool
-link_count_optimize_ok (FTSENT const *p)
-{
- FTS *sp = p->fts_fts;
- Hash_table *h = sp->fts_leaf_optimization_works_ht;
- struct LCO_ent tmp;
- struct LCO_ent *ent;
- bool opt_ok;
- struct LCO_ent *t2;
-
- /* If we're not in CWDFD mode, don't bother with this optimization,
- since the caller is not serious about performance. */
- if (!ISSET(FTS_CWDFD))
- return false;
-
- /* map st_dev to the boolean, leaf_optimization_works */
- if (h == NULL)
- {
- h = sp->fts_leaf_optimization_works_ht
- = hash_initialize (LCO_HT_INITIAL_SIZE, NULL, LCO_hash,
- LCO_compare, free);
- if (h == NULL)
- return false;
- }
- tmp.st_dev = p->fts_statp->st_dev;
- ent = hash_lookup (h, &tmp);
- if (ent)
- return ent->opt_ok;
-
- /* Look-up failed. Query directly and cache the result. */
- t2 = malloc (sizeof *t2);
- if (t2 == NULL)
- return false;
-
- /* Is it ok to perform the optimization in the dir, FTS_CWD_FD? */
- opt_ok = leaf_optimization_applies (sp->fts_cwd_fd);
- t2->opt_ok = opt_ok;
- t2->st_dev = p->fts_statp->st_dev;
-
- ent = hash_insert (h, t2);
- if (ent == NULL)
- {
- /* insertion failed */
- free (t2);
- return false;
- }
- fts_assert (ent == t2);
-
- return opt_ok;
+ return NO_LEAF_OPTIMIZATION;
}
+#endif
/*
* Special case of "/" at the end of the file name so that slashes aren't
@@ -1016,13 +1051,11 @@ check_for_dir:
if (p->fts_statp->st_size == FTS_STAT_REQUIRED)
{
FTSENT *parent = p->fts_parent;
- if (FTS_ROOTLEVEL < p->fts_level
- /* ->fts_n_dirs_remaining is not valid
- for command-line-specified names. */
- && parent->fts_n_dirs_remaining == 0
+ if (parent->fts_n_dirs_remaining == 0
&& ISSET(FTS_NOSTAT)
&& ISSET(FTS_PHYSICAL)
- && link_count_optimize_ok (parent))
+ && (leaf_optimization (parent, sp->fts_cwd_fd)
+ == NOSTAT_LEAF_OPTIMIZATION))
{
/* nothing more needed */
}
@@ -1031,7 +1064,8 @@ check_for_dir:
p->fts_info = fts_stat(sp, p, false);
if (S_ISDIR(p->fts_statp->st_mode)
&& p->fts_level != FTS_ROOTLEVEL
- && parent->fts_n_dirs_remaining)
+ && 0 < parent->fts_n_dirs_remaining
+ && parent->fts_n_dirs_remaining != (nlink_t) -1)
parent->fts_n_dirs_remaining--;
}
}
@@ -1300,13 +1334,12 @@ fts_build (register FTS *sp, int type)
bool descend;
bool doadjust;
ptrdiff_t level;
- nlink_t nlinks;
- bool nostat;
size_t len, maxlen, new_len;
char *cp;
int dir_fd;
FTSENT *cur = sp->fts_cur;
bool continue_readdir = !!cur->fts_dirp;
+ bool sort_by_inode = false;
size_t max_entries;
/* When cur->fts_dirp is non-NULL, that means we should
@@ -1372,24 +1405,6 @@ fts_build (register FTS *sp, int type)
max_entries = sp->fts_compar ? SIZE_MAX : FTS_MAX_READDIR_ENTRIES;
/*
- * Nlinks is the number of possible entries of type directory in the
- * directory if we're cheating on stat calls, 0 if we're not doing
- * any stat calls at all, (nlink_t) -1 if we're statting everything.
- */
- if (type == BNAMES) {
- nlinks = 0;
- /* Be quiet about nostat, GCC. */
- nostat = false;
- } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) {
- nlinks = (cur->fts_statp->st_nlink
- - (ISSET(FTS_SEEDOT) ? 0 : 2));
- nostat = true;
- } else {
- nlinks = -1;
- nostat = false;
- }
-
- /*
* If we're going to need to stat anything or we want to descend
* and stay in the directory, chdir. If this fails we keep going,
* but set a flag so we don't chdir after the post-order visit.
@@ -1410,15 +1425,22 @@ fts_build (register FTS *sp, int type)
the required dirp and dir_fd. */
descend = true;
}
- else if (nlinks || type == BREAD) {
+ else
+ {
+ /* Try to descend unless it is a names-only fts_children,
+ or the directory is known to lack subdirectories. */
+ descend = (type != BNAMES
+ && ! (ISSET (FTS_NOSTAT) && ISSET (FTS_PHYSICAL)
+ && ! ISSET (FTS_SEEDOT)
+ && cur->fts_statp->st_nlink == MIN_DIR_NLINK
+ && (leaf_optimization (cur, dir_fd)
+ != NO_LEAF_OPTIMIZATION)));
+ if (descend || type == BREAD)
+ {
if (ISSET(FTS_CWDFD))
- {
- dir_fd = dup (dir_fd);
- if (0 <= dir_fd)
- set_cloexec_flag (dir_fd, true);
- }
+ dir_fd = fcntl (dir_fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
if (dir_fd < 0 || fts_safe_changedir(sp, cur, dir_fd, NULL)) {
- if (nlinks && type == BREAD)
+ if (descend && type == BREAD)
cur->fts_errno = errno;
cur->fts_flags |= FTS_DONTCHDIR;
descend = false;
@@ -1428,8 +1450,8 @@ fts_build (register FTS *sp, int type)
cur->fts_dirp = NULL;
} else
descend = true;
- } else
- descend = false;
+ }
+ }
/*
* Figure out the max file name length that can be stored in the
@@ -1460,7 +1482,6 @@ fts_build (register FTS *sp, int type)
tail = NULL;
nitems = 0;
while (cur->fts_dirp) {
- bool is_dir;
size_t d_namelen;
__set_errno (0);
struct dirent *dp = readdir(cur->fts_dirp);
@@ -1561,19 +1582,10 @@ mem1: saved_errno = errno;
to caller, when possible. */
set_stat_type (p->fts_statp, D_TYPE (dp));
fts_set_stat_required(p, !skip_stat);
- is_dir = (ISSET(FTS_PHYSICAL)
- && DT_MUST_BE(dp, DT_DIR));
} else {
p->fts_info = fts_stat(sp, p, false);
- is_dir = (p->fts_info == FTS_D
- || p->fts_info == FTS_DC
- || p->fts_info == FTS_DOT);
}
- /* Decrement link count if applicable. */
- if (nlinks > 0 && is_dir)
- nlinks -= nostat;
-
/* We walk in directory order so "ls -f" doesn't get upset. */
p->fts_link = NULL;
if (head == NULL)
@@ -1582,6 +1594,19 @@ mem1: saved_errno = errno;
tail->fts_link = p;
tail = p;
}
+
+ /* If there are many entries, no sorting function has been
+ specified, and this file system is of a type that may be
+ slow with a large number of entries, arrange to sort the
+ directory entries on increasing inode numbers.
+
+ The NITEMS comparison uses ==, not >, because the test
+ needs to be tried at most once once, and NITEMS will exceed
+ the threshold after it is incremented below. */
+ if (nitems == _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD
+ && !sp->fts_compar)
+ sort_by_inode = dirent_inode_sort_may_be_useful (cur, dir_fd);
+
++nitems;
if (max_entries <= nitems) {
/* When there are too many dir entries, leave
@@ -1639,14 +1664,7 @@ mem1: saved_errno = errno;
return (NULL);
}
- /* If there are many entries, no sorting function has been specified,
- and this file system is of a type that may be slow with a large
- number of entries, then sort the directory entries on increasing
- inode numbers. */
- if (nitems > _FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD
- && !sp->fts_compar
- && ISSET (FTS_CWDFD)
- && dirent_inode_sort_may_be_useful (sp->fts_cwd_fd)) {
+ if (sort_by_inode) {
sp->fts_compar = fts_compare_ino;
head = fts_sort (sp, head, nitems);
sp->fts_compar = NULL;
@@ -1769,7 +1787,7 @@ fd_ring_check (FTS const *sp)
I_ring fd_w = sp->fts_fd_ring;
int cwd_fd = sp->fts_cwd_fd;
- cwd_fd = dup (cwd_fd);
+ cwd_fd = fcntl (cwd_fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
char *dot = getcwdat (cwd_fd, NULL, 0);
error (0, 0, "===== check ===== cwd: %s", dot);
free (dot);
@@ -1778,7 +1796,8 @@ fd_ring_check (FTS const *sp)
int fd = i_ring_pop (&fd_w);
if (0 <= fd)
{
- int parent_fd = openat (cwd_fd, "..", O_SEARCH | O_NOATIME);
+ int open_flags = O_SEARCH | O_CLOEXEC | O_NOATIME;
+ int parent_fd = openat (cwd_fd, "..", open_flags);
if (parent_fd < 0)
{
// Warn?
@@ -1807,7 +1826,6 @@ internal_function
fts_stat(FTS *sp, register FTSENT *p, bool follow)
{
struct stat *sbp = p->fts_statp;
- int saved_errno;
if (p->fts_level == FTS_ROOTLEVEL && ISSET(FTS_COMFOLLOW))
follow = true;
@@ -1819,13 +1837,12 @@ fts_stat(FTS *sp, register FTSENT *p, bool follow)
*/
if (ISSET(FTS_LOGICAL) || follow) {
if (stat(p->fts_accpath, sbp)) {
- saved_errno = errno;
if (errno == ENOENT
&& lstat(p->fts_accpath, sbp) == 0) {
__set_errno (0);
return (FTS_SLNONE);
}
- p->fts_errno = saved_errno;
+ p->fts_errno = errno;
goto err;
}
} else if (fstatat(sp->fts_cwd_fd, p->fts_accpath, sbp,
@@ -1836,8 +1853,11 @@ err: memset(sbp, 0, sizeof(struct stat));
}
if (S_ISDIR(sbp->st_mode)) {
- p->fts_n_dirs_remaining = (sbp->st_nlink
- - (ISSET(FTS_SEEDOT) ? 0 : 2));
+ p->fts_n_dirs_remaining
+ = ((sbp->st_nlink < MIN_DIR_NLINK
+ || p->fts_level <= FTS_ROOTLEVEL)
+ ? -1
+ : sbp->st_nlink - (ISSET (FTS_SEEDOT) ? 0 : MIN_DIR_NLINK));
if (ISDOT(p->fts_name)) {
/* Command-line "." and ".." are real directories. */
return (p->fts_level == FTS_ROOTLEVEL ? FTS_D : FTS_DOT);
diff --git a/libgnu/fts_.h b/libgnu/fts_.h
index 46fd0df5..70cc9e3d 100644
--- a/libgnu/fts_.h
+++ b/libgnu/fts_.h
@@ -1,6 +1,6 @@
/* Traverse a file hierarchy.
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/*
* Copyright (c) 1989, 1993
@@ -220,7 +220,11 @@ typedef struct _ftsent {
ptrdiff_t fts_level; /* depth (-1 to N) */
size_t fts_namelen; /* strlen(fts_name) */
- nlink_t fts_n_dirs_remaining; /* count down from st_nlink */
+
+ /* If not (nlink_t) -1, an upper bound on the number of
+ remaining subdirectories of interest. If this becomes
+ zero, some work can be avoided. */
+ nlink_t fts_n_dirs_remaining;
# define FTS_D 1 /* preorder directory */
# define FTS_DC 2 /* directory that causes cycles */
diff --git a/libgnu/getcwd-lgpl.c b/libgnu/getcwd-lgpl.c
index 34603c19..9f0e0072 100644
--- a/libgnu/getcwd-lgpl.c
+++ b/libgnu/getcwd-lgpl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2018 Free Software Foundation, Inc.
This file is part of gnulib.
This program is free software: you can redistribute it and/or modify
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/getcwd.c b/libgnu/getcwd.c
deleted file mode 100644
index d91cf377..00000000
--- a/libgnu/getcwd.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/* Copyright (C) 1991-1999, 2004-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#if !_LIBC
-# include <config.h>
-# include <unistd.h>
-#endif
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-#include <fcntl.h> /* For AT_FDCWD on Solaris 9. */
-
-/* If this host provides the openat function or if we're using the
- gnulib replacement function with a native fdopendir, then enable
- code below to make getcwd more efficient and robust. */
-#if defined HAVE_OPENAT || (defined GNULIB_OPENAT && defined HAVE_FDOPENDIR)
-# define HAVE_OPENAT_SUPPORT 1
-#else
-# define HAVE_OPENAT_SUPPORT 0
-#endif
-
-#ifndef __set_errno
-# define __set_errno(val) (errno = (val))
-#endif
-
-#include <dirent.h>
-#ifndef _D_EXACT_NAMLEN
-# define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
-#endif
-#ifndef _D_ALLOC_NAMLEN
-# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
-#endif
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if _LIBC
-# ifndef mempcpy
-# define mempcpy __mempcpy
-# endif
-#endif
-
-#ifndef MAX
-# define MAX(a, b) ((a) < (b) ? (b) : (a))
-#endif
-#ifndef MIN
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-#include "pathmax.h"
-
-/* In this file, PATH_MAX only serves as a threshold for choosing among two
- algorithms. */
-#ifndef PATH_MAX
-# define PATH_MAX 8192
-#endif
-
-#if D_INO_IN_DIRENT
-# define MATCHING_INO(dp, ino) ((dp)->d_ino == (ino))
-#else
-# define MATCHING_INO(dp, ino) true
-#endif
-
-#if !_LIBC
-# define __getcwd rpl_getcwd
-# define __lstat lstat
-# define __closedir closedir
-# define __opendir opendir
-# define __readdir readdir
-#endif
-
-/* The results of opendir() in this file are not used with dirfd and fchdir,
- and we do not leak fds to any single-threaded code that could use stdio,
- therefore save some unnecessary recursion in fchdir.c.
- FIXME - if the kernel ever adds support for multi-thread safety for
- avoiding standard fds, then we should use opendir_safer and
- openat_safer. */
-#ifdef GNULIB_defined_opendir
-# undef opendir
-#endif
-#ifdef GNULIB_defined_closedir
-# undef closedir
-#endif
-
-/* 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 or
- SIZE was too small. If successful, returns BUF. In GNU, 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. */
-
-char *
-__getcwd (char *buf, size_t size)
-{
- /* Lengths of big file name components and entire file names, and a
- deep level of file name nesting. These numbers are not upper
- bounds; they are merely large values suitable for initial
- allocations, designed to be large enough for most real-world
- uses. */
- enum
- {
- BIG_FILE_NAME_COMPONENT_LENGTH = 255,
- BIG_FILE_NAME_LENGTH = MIN (4095, PATH_MAX - 1),
- DEEP_NESTING = 100
- };
-
-#if HAVE_OPENAT_SUPPORT
- int fd = AT_FDCWD;
- bool fd_needs_closing = false;
-#else
- char dots[DEEP_NESTING * sizeof ".." + BIG_FILE_NAME_COMPONENT_LENGTH + 1];
- char *dotlist = dots;
- size_t dotsize = sizeof dots;
- size_t dotlen = 0;
-#endif
- DIR *dirstream = NULL;
- dev_t rootdev, thisdev;
- ino_t rootino, thisino;
- char *dir;
- register char *dirp;
- struct stat st;
- size_t allocated = size;
- size_t used;
-
-#if HAVE_MINIMALLY_WORKING_GETCWD
- /* If AT_FDCWD is not defined, the algorithm below is O(N**2) and
- this is much slower than the system getcwd (at least on
- GNU/Linux). So trust the system getcwd's results unless they
- look suspicious.
-
- Use the system getcwd even if we have openat support, since the
- system getcwd works even when a parent is unreadable, while the
- openat-based approach does not.
-
- But on AIX 5.1..7.1, the system getcwd is not even minimally
- working: If the current directory name is slightly longer than
- PATH_MAX, it omits the first directory component and returns
- this wrong result with errno = 0. */
-
-# undef getcwd
- dir = getcwd (buf, size);
- if (dir || (size && errno == ERANGE))
- return dir;
-
- /* Solaris getcwd (NULL, 0) fails with errno == EINVAL, but it has
- internal magic that lets it work even if an ancestor directory is
- inaccessible, which is better in many cases. So in this case try
- again with a buffer that's almost always big enough. */
- if (errno == EINVAL && buf == NULL && size == 0)
- {
- char big_buffer[BIG_FILE_NAME_LENGTH + 1];
- dir = getcwd (big_buffer, sizeof big_buffer);
- if (dir)
- return strdup (dir);
- }
-
-# if HAVE_PARTLY_WORKING_GETCWD
- /* The system getcwd works, except it sometimes fails when it
- shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT. */
- if (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT)
- return NULL;
-# endif
-#endif
-
- if (size == 0)
- {
- if (buf != NULL)
- {
- __set_errno (EINVAL);
- return NULL;
- }
-
- allocated = BIG_FILE_NAME_LENGTH + 1;
- }
-
- if (buf == NULL)
- {
- dir = malloc (allocated);
- if (dir == NULL)
- return NULL;
- }
- else
- dir = buf;
-
- dirp = dir + allocated;
- *--dirp = '\0';
-
- if (__lstat (".", &st) < 0)
- goto lose;
- thisdev = st.st_dev;
- thisino = st.st_ino;
-
- if (__lstat ("/", &st) < 0)
- goto lose;
- rootdev = st.st_dev;
- rootino = st.st_ino;
-
- while (!(thisdev == rootdev && thisino == rootino))
- {
- struct dirent *d;
- dev_t dotdev;
- ino_t dotino;
- bool mount_point;
- int parent_status;
- size_t dirroom;
- size_t namlen;
- bool use_d_ino = true;
-
- /* Look at the parent directory. */
-#if HAVE_OPENAT_SUPPORT
- fd = openat (fd, "..", O_RDONLY);
- if (fd < 0)
- goto lose;
- fd_needs_closing = true;
- parent_status = fstat (fd, &st);
-#else
- dotlist[dotlen++] = '.';
- dotlist[dotlen++] = '.';
- dotlist[dotlen] = '\0';
- parent_status = __lstat (dotlist, &st);
-#endif
- if (parent_status != 0)
- goto lose;
-
- if (dirstream && __closedir (dirstream) != 0)
- {
- dirstream = NULL;
- goto lose;
- }
-
- /* Figure out if this directory is a mount point. */
- dotdev = st.st_dev;
- dotino = st.st_ino;
- mount_point = dotdev != thisdev;
-
- /* Search for the last directory. */
-#if HAVE_OPENAT_SUPPORT
- dirstream = fdopendir (fd);
- if (dirstream == NULL)
- goto lose;
- fd_needs_closing = false;
-#else
- dirstream = __opendir (dotlist);
- if (dirstream == NULL)
- goto lose;
- dotlist[dotlen++] = '/';
-#endif
- for (;;)
- {
- /* Clear errno to distinguish EOF from error if readdir returns
- NULL. */
- __set_errno (0);
- d = __readdir (dirstream);
-
- /* When we've iterated through all directory entries without finding
- one with a matching d_ino, rewind the stream and consider each
- name again, but this time, using lstat. This is necessary in a
- chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where
- .., ../.., ../../.., etc. all had the same device number, yet the
- d_ino values for entries in / did not match those obtained
- via lstat. */
- if (d == NULL && errno == 0 && use_d_ino)
- {
- use_d_ino = false;
- rewinddir (dirstream);
- d = __readdir (dirstream);
- }
-
- if (d == NULL)
- {
- if (errno == 0)
- /* EOF on dirstream, which can mean e.g., that the current
- directory has been removed. */
- __set_errno (ENOENT);
- goto lose;
- }
- if (d->d_name[0] == '.' &&
- (d->d_name[1] == '\0' ||
- (d->d_name[1] == '.' && d->d_name[2] == '\0')))
- continue;
-
- if (use_d_ino)
- {
- bool match = (MATCHING_INO (d, thisino) || mount_point);
- if (! match)
- continue;
- }
-
- {
- int entry_status;
-#if HAVE_OPENAT_SUPPORT
- entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
-#else
- /* Compute size needed for this file name, or for the file
- name ".." in the same directory, whichever is larger.
- Room for ".." might be needed the next time through
- the outer loop. */
- size_t name_alloc = _D_ALLOC_NAMLEN (d);
- size_t filesize = dotlen + MAX (sizeof "..", name_alloc);
-
- if (filesize < dotlen)
- goto memory_exhausted;
-
- if (dotsize < filesize)
- {
- /* My, what a deep directory tree you have, Grandma. */
- size_t newsize = MAX (filesize, dotsize * 2);
- size_t i;
- if (newsize < dotsize)
- goto memory_exhausted;
- if (dotlist != dots)
- free (dotlist);
- dotlist = malloc (newsize);
- if (dotlist == NULL)
- goto lose;
- dotsize = newsize;
-
- i = 0;
- do
- {
- dotlist[i++] = '.';
- dotlist[i++] = '.';
- dotlist[i++] = '/';
- }
- while (i < dotlen);
- }
-
- memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d));
- entry_status = __lstat (dotlist, &st);
-#endif
- /* We don't fail here if we cannot stat() a directory entry.
- This can happen when (network) file systems fail. If this
- entry is in fact the one we are looking for we will find
- out soon as we reach the end of the directory without
- having found anything. */
- if (entry_status == 0 && S_ISDIR (st.st_mode)
- && st.st_dev == thisdev && st.st_ino == thisino)
- break;
- }
- }
-
- dirroom = dirp - dir;
- namlen = _D_EXACT_NAMLEN (d);
-
- if (dirroom <= namlen)
- {
- if (size != 0)
- {
- __set_errno (ERANGE);
- goto lose;
- }
- else
- {
- char *tmp;
- size_t oldsize = allocated;
-
- allocated += MAX (allocated, namlen);
- if (allocated < oldsize
- || ! (tmp = realloc (dir, allocated)))
- goto memory_exhausted;
-
- /* Move current contents up to the end of the buffer.
- This is guaranteed to be non-overlapping. */
- dirp = memcpy (tmp + allocated - (oldsize - dirroom),
- tmp + dirroom,
- oldsize - dirroom);
- dir = tmp;
- }
- }
- dirp -= namlen;
- memcpy (dirp, d->d_name, namlen);
- *--dirp = '/';
-
- thisdev = dotdev;
- thisino = dotino;
- }
-
- if (dirstream && __closedir (dirstream) != 0)
- {
- dirstream = NULL;
- goto lose;
- }
-
- if (dirp == &dir[allocated - 1])
- *--dirp = '/';
-
-#if ! HAVE_OPENAT_SUPPORT
- if (dotlist != dots)
- free (dotlist);
-#endif
-
- used = dir + allocated - dirp;
- memmove (dir, dirp, used);
-
- if (size == 0)
- /* Ensure that the buffer is only as large as necessary. */
- buf = realloc (dir, used);
-
- if (buf == NULL)
- /* Either buf was NULL all along, or 'realloc' failed but
- we still have the original string. */
- buf = dir;
-
- return buf;
-
- memory_exhausted:
- __set_errno (ENOMEM);
- lose:
- {
- int save = errno;
- if (dirstream)
- __closedir (dirstream);
-#if HAVE_OPENAT_SUPPORT
- if (fd_needs_closing)
- close (fd);
-#else
- if (dotlist != dots)
- free (dotlist);
-#endif
- if (buf == NULL)
- free (dir);
- __set_errno (save);
- }
- return NULL;
-}
-
-#ifdef weak_alias
-weak_alias (__getcwd, getcwd)
-#endif
diff --git a/libgnu/getdelim.c b/libgnu/getdelim.c
index e2e08853..cc1e9fe3 100644
--- a/libgnu/getdelim.c
+++ b/libgnu/getdelim.c
@@ -1,5 +1,5 @@
/* getdelim.c --- Implementation of replacement getdelim function.
- Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2017 Free Software
+ Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or
@@ -13,7 +13,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Ported from glibc by Simon Josefsson. */
@@ -50,9 +50,9 @@
static void
alloc_failed (void)
{
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* Avoid errno problem without using the realloc module; see:
- http://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00025.html */
+ https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
errno = ENOMEM;
#endif
}
diff --git a/libgnu/getdtablesize.c b/libgnu/getdtablesize.c
index 7fabb51e..ac05bc48 100644
--- a/libgnu/getdtablesize.c
+++ b/libgnu/getdtablesize.c
@@ -1,5 +1,5 @@
-/* getdtablesize() function for platforms that don't have it.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+/* getdtablesize() function: Return maximum possible file descriptor value + 1.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,18 +13,20 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
# include <stdio.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static int
@@ -44,7 +46,8 @@ _setmaxstdio_nothrow (int newmax)
return result;
}
-# define _setmaxstdio _setmaxstdio_nothrow
+# else
+# define _setmaxstdio_nothrow _setmaxstdio
# endif
/* Cache for the previous getdtablesize () result. Safe to cache because
@@ -76,9 +79,9 @@ getdtablesize (void)
freed when we call _setmaxstdio with the original value. */
int orig_max_stdio = _getmaxstdio ();
unsigned int bound;
- for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
+ for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
;
- _setmaxstdio (orig_max_stdio);
+ _setmaxstdio_nothrow (orig_max_stdio);
dtablesize = bound;
}
return dtablesize;
diff --git a/libgnu/getline.c b/libgnu/getline.c
index 8b7c9f7a..59397ea6 100644
--- a/libgnu/getline.c
+++ b/libgnu/getline.c
@@ -1,5 +1,5 @@
/* getline.c --- Implementation of replacement getline function.
- Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson. */
diff --git a/libgnu/getopt-cdefs.in.h b/libgnu/getopt-cdefs.in.h
index c71a4f11..12b5a877 100644
--- a/libgnu/getopt-cdefs.in.h
+++ b/libgnu/getopt-cdefs.in.h
@@ -1,22 +1,22 @@
/* getopt-on-non-glibc compatibility macros.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
- gnulib is free software; you can redistribute it and/or modify it
+ This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
- gnulib is distributed in the hope that it will be useful, but
+ This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with gnulib; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_CDEFS_H
#define _GETOPT_CDEFS_H 1
diff --git a/libgnu/getopt-core.h b/libgnu/getopt-core.h
index d315891a..e51b6c78 100644
--- a/libgnu/getopt-core.h
+++ b/libgnu/getopt-core.h
@@ -1,5 +1,5 @@
/* Declarations for getopt (basic, portable features only).
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_CORE_H
#define _GETOPT_CORE_H 1
diff --git a/libgnu/getopt-ext.h b/libgnu/getopt-ext.h
index e4da22f5..cb41206f 100644
--- a/libgnu/getopt-ext.h
+++ b/libgnu/getopt-ext.h
@@ -1,5 +1,5 @@
/* Declarations for getopt (GNU extensions).
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_EXT_H
#define _GETOPT_EXT_H 1
diff --git a/libgnu/getopt-pfx-core.h b/libgnu/getopt-pfx-core.h
index 4dc427dc..c62f9e26 100644
--- a/libgnu/getopt-pfx-core.h
+++ b/libgnu/getopt-pfx-core.h
@@ -1,22 +1,22 @@
/* getopt (basic, portable features) gnulib wrapper header.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
- gnulib is free software; you can redistribute it and/or modify it
+ This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
- gnulib is distributed in the hope that it will be useful, but
+ This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with gnulib; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_PFX_CORE_H
#define _GETOPT_PFX_CORE_H 1
@@ -47,6 +47,11 @@
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
+
+/* The system's getopt.h may have already included getopt-core.h to
+ declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
+ getopt-core.h declares them with prefixes. */
+# undef _GETOPT_CORE_H
#endif
#include <getopt-core.h>
diff --git a/libgnu/getopt-pfx-ext.h b/libgnu/getopt-pfx-ext.h
index bc6052a1..753f1290 100644
--- a/libgnu/getopt-pfx-ext.h
+++ b/libgnu/getopt-pfx-ext.h
@@ -1,22 +1,22 @@
/* getopt (GNU extensions) gnulib wrapper header.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library.
- gnulib is free software; you can redistribute it and/or modify it
+ This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
- gnulib is distributed in the hope that it will be useful, but
+ This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with gnulib; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_PFX_EXT_H
#define _GETOPT_PFX_EXT_H 1
@@ -40,9 +40,16 @@
# undef getopt_long
# undef getopt_long_only
# undef option
+# undef _getopt_internal
# define getopt_long __GETOPT_ID (getopt_long)
# define getopt_long_only __GETOPT_ID (getopt_long_only)
# define option __GETOPT_ID (option)
+# define _getopt_internal __GETOPT_ID (getopt_internal)
+
+/* The system's getopt.h may have already included getopt-ext.h to
+ declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that
+ getopt-ext.h declares them with prefixes. */
+# undef _GETOPT_EXT_H
#endif
/* Standalone applications get correct prototypes for getopt_long and
diff --git a/libgnu/getopt.c b/libgnu/getopt.c
index a7db39b6..11e36eef 100644
--- a/libgnu/getopt.c
+++ b/libgnu/getopt.c
@@ -1,5 +1,5 @@
/* Getopt for GNU.
- Copyright (C) 1987-2017 Free Software Foundation, Inc.
+ Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
@@ -45,7 +45,8 @@
# define _(msgid) gettext (msgid)
/* When used standalone, flockfile and funlockfile might not be
available. */
-# ifndef _POSIX_THREAD_SAFE_FUNCTIONS
+# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
+ || (defined _WIN32 && ! defined __CYGWIN__))
# define flockfile(fp) /* nop */
# define funlockfile(fp) /* nop */
# endif
diff --git a/libgnu/getopt.in.h b/libgnu/getopt.in.h
index 4ce1eb48..5fb58ddb 100644
--- a/libgnu/getopt.in.h
+++ b/libgnu/getopt.in.h
@@ -1,22 +1,22 @@
/* Declarations for getopt.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of gnulib.
Unlike most of the getopt implementation, it is NOT shared
with the GNU C Library, which supplies a different version of
this file.
- gnulib is free software; you can redistribute it and/or modify it
+ This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of
the License, or (at your option) any later version.
- gnulib is distributed in the hope that it will be useful, but
+ This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
- License along with gnulib; if not, see <http://www.gnu.org/licenses/>. */
+ License along with gnulib; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_GETOPT_H
diff --git a/libgnu/getopt1.c b/libgnu/getopt1.c
index 2bc59260..9c7fff4c 100644
--- a/libgnu/getopt1.c
+++ b/libgnu/getopt1.c
@@ -1,5 +1,5 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
- Copyright (C) 1987-2017 Free Software Foundation, Inc.
+ Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
diff --git a/libgnu/getopt_int.h b/libgnu/getopt_int.h
index a5562195..b0e9a6d0 100644
--- a/libgnu/getopt_int.h
+++ b/libgnu/getopt_int.h
@@ -1,5 +1,5 @@
/* Internal declarations for getopt.
- Copyright (C) 1989-2017 Free Software Foundation, Inc.
+ Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library and is also part of gnulib.
Patches to this file should be submitted to both projects.
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H 1
diff --git a/libgnu/getprogname.c b/libgnu/getprogname.c
index 52954847..c824b47c 100644
--- a/libgnu/getprogname.c
+++ b/libgnu/getprogname.c
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ Copyright (C) 2016-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -64,7 +64,7 @@ getprogname (void)
/* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
return last_component (program_invocation_name);
# elif HAVE_GETEXECNAME /* Solaris */
- /* http://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
+ /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
const char *p = getexecname ();
if (!p)
p = "?";
@@ -74,7 +74,7 @@ getprogname (void)
const char *p = __argv && __argv[0] ? __argv[0] : "?";
return last_component (p);
# elif HAVE_VAR___PROGNAME /* OpenBSD, QNX */
- /* http://man.openbsd.org/style.9 */
+ /* https://man.openbsd.org/style.9 */
/* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
/* Be careful to declare this only when we absolutely need it
(OpenBSD 5.1), rather than when it's available. Otherwise,
@@ -85,9 +85,8 @@ getprogname (void)
return p && p[0] ? p : "?";
# elif _AIX /* AIX */
/* Idea by Bastien ROUCARIÈS,
- http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00095.html
- Reference: http://
- ibm.biz/knowctr#ssw_aix_53/com.ibm.aix.basetechref/doc/basetrf1/getprocs.htm
+ https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html
+ Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm
*/
static char *p;
static int first = 1;
@@ -165,7 +164,7 @@ getprogname (void)
if (ioctl_ok)
{
char *name = buf.pr_fname;
- char *namesize = sizeof buf.pr_fname;
+ size_t namesize = sizeof buf.pr_fname;
char *namenul = memchr (name, '\0', namesize);
size_t namelen = namenul ? namenul - name : namesize;
char *namecopy = malloc (namelen + 1);
@@ -183,3 +182,10 @@ getprogname (void)
}
#endif
+
+/*
+ * Hey Emacs!
+ * Local Variables:
+ * coding: utf-8
+ * End:
+ */
diff --git a/libgnu/getprogname.h b/libgnu/getprogname.h
index 9ab924ca..ee6688fc 100644
--- a/libgnu/getprogname.h
+++ b/libgnu/getprogname.h
@@ -1,5 +1,5 @@
/* Program name management.
- Copyright (C) 2016-2017 Free Software Foundation, Inc.
+ Copyright (C) 2016-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_GETPROGNAME_H
#define _GL_GETPROGNAME_H
diff --git a/libgnu/gettext.h b/libgnu/gettext.h
index 0465d7ad..f2d7458f 100644
--- a/libgnu/gettext.h
+++ b/libgnu/gettext.h
@@ -1,5 +1,5 @@
/* Convenience header for conditional use of GNU <libintl.h>.
- Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2017 Free Software
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -13,13 +13,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
-/* NLS can be disabled through the configure --disable-nls option. */
-#if ENABLE_NLS
+/* NLS can be disabled through the configure --disable-nls option
+ or through "#define ENABLE NLS 0" before including this file. */
+#if defined ENABLE_NLS && ENABLE_NLS
/* Get declarations of GNU message catalog functions. */
# include <libintl.h>
@@ -184,7 +185,8 @@ npgettext_aux (const char *domain,
#include <string.h>
#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
- /* || __STDC_VERSION__ >= 199901L */ )
+ /* || __STDC_VERSION__ == 199901L
+ || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
#else
# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
diff --git a/libgnu/gettimeofday.c b/libgnu/gettimeofday.c
deleted file mode 100644
index 18dcbda4..00000000
--- a/libgnu/gettimeofday.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Provide gettimeofday for systems that don't have it or for which it's broken.
-
- Copyright (C) 2001-2003, 2005-2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-/* Specification. */
-#include <sys/time.h>
-
-#include <time.h>
-
-#if HAVE_SYS_TIMEB_H
-# include <sys/timeb.h>
-#endif
-
-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
-
-/* Work around the bug in some systems whereby gettimeofday clobbers
- the static buffer that localtime uses for its return value. The
- gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
- this problem. The tzset replacement is necessary for at least
- Solaris 2.5, 2.5.1, and 2.6. */
-
-static struct tm tm_zero_buffer;
-static struct tm *localtime_buffer_addr = &tm_zero_buffer;
-
-# undef localtime
-extern struct tm *localtime (time_t const *);
-
-# undef gmtime
-extern struct tm *gmtime (time_t const *);
-
-/* This is a wrapper for localtime. It is used only on systems for which
- gettimeofday clobbers the static buffer used for localtime's result.
-
- On the first call, record the address of the static buffer that
- localtime uses for its result. */
-
-struct tm *
-rpl_localtime (time_t const *timep)
-{
- struct tm *tm = localtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-/* Same as above, since gmtime and localtime use the same buffer. */
-struct tm *
-rpl_gmtime (time_t const *timep)
-{
- struct tm *tm = gmtime (timep);
-
- if (localtime_buffer_addr == &tm_zero_buffer)
- localtime_buffer_addr = tm;
-
- return tm;
-}
-
-#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
-
-#if TZSET_CLOBBERS_LOCALTIME
-
-# undef tzset
-extern void tzset (void);
-
-/* This is a wrapper for tzset, for systems on which tzset may clobber
- the static buffer used for localtime's result. */
-void
-rpl_tzset (void)
-{
- /* Save and restore the contents of the buffer used for localtime's
- result around the call to tzset. */
- struct tm save = *localtime_buffer_addr;
- tzset ();
- *localtime_buffer_addr = save;
-}
-#endif
-
-/* This is a wrapper for gettimeofday. It is used only on systems
- that lack this function, or whose implementation of this function
- causes problems. */
-
-int
-gettimeofday (struct timeval *restrict tv, void *restrict tz)
-{
-#undef gettimeofday
-#if HAVE_GETTIMEOFDAY
-# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
- /* Save and restore the contents of the buffer used for localtime's
- result around the call to gettimeofday. */
- struct tm save = *localtime_buffer_addr;
-# endif
-
-# if defined timeval /* 'struct timeval' overridden by gnulib? */
-# undef timeval
- struct timeval otv;
- int result = gettimeofday (&otv, (struct timezone *) tz);
- if (result == 0)
- {
- tv->tv_sec = otv.tv_sec;
- tv->tv_usec = otv.tv_usec;
- }
-# else
- int result = gettimeofday (tv, (struct timezone *) tz);
-# endif
-
-# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
- *localtime_buffer_addr = save;
-# endif
-
- return result;
-
-#else
-
-# if HAVE__FTIME
-
- struct _timeb timebuf;
- _ftime (&timebuf);
- tv->tv_sec = timebuf.time;
- tv->tv_usec = timebuf.millitm * 1000;
-
-# else
-
-# if !defined OK_TO_USE_1S_CLOCK
-# error "Only 1-second nominal clock resolution found. Is that intended?" \
- "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
-# endif
- tv->tv_sec = time (NULL);
- tv->tv_usec = 0;
-
-# endif
-
- return 0;
-
-#endif
-}
diff --git a/libgnu/gnulib.am b/libgnu/gnulib.am
index 1d371500..04f938e6 100644
--- a/libgnu/gnulib.am
+++ b/libgnu/gnulib.am
@@ -1,6 +1,6 @@
## DO NOT EDIT! GENERATED AUTOMATICALLY!
## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2017 Free Software Foundation, Inc.
+# Copyright (C) 2002-2018 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
@@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this file. If not, see <http://www.gnu.org/licenses/>.
+# along with this file. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License,
# this file may be distributed as part of a program that
@@ -21,7 +21,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=libgnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=config --makefile-name=gnulib.am --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp canonicalize error fcntl ffs fnmatch-gnu fts getline langinfo link mempcpy memrchr obstack obstack-printf pread pwrite qsort_r rawmemchr stpcpy stpncpy strsep sys_utsname sys_wait
+# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=libgnu --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=config --makefile-name=gnulib.am --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files argp canonicalize-lgpl error fcntl ffs fnmatch-gnu fstatat fts getline langinfo link mempcpy memrchr obstack obstack-printf pread pwrite qsort_r rawmemchr stpcpy stpncpy strsep sys_utsname sys_wait
MOSTLYCLEANFILES += core *.stackdump
@@ -84,14 +84,6 @@ EXTRA_DIST += alloca.in.h
## end gnulib module alloca-opt
-## begin gnulib module areadlink-with-size
-
-libgnu_a_SOURCES += areadlink-with-size.c
-
-EXTRA_DIST += areadlink.h
-
-## end gnulib module areadlink-with-size
-
## begin gnulib module argp
libgnu_a_SOURCES += argp.h argp-ba.c argp-eexst.c argp-fmtstream.c argp-fmtstream.h argp-fs-xinl.c argp-help.c argp-namefrob.h argp-parse.c argp-pin.c argp-pv.c argp-pvh.c argp-xinl.c
@@ -122,13 +114,14 @@ libgnu_a_SOURCES += bitrotate.h bitrotate.c
## end gnulib module bitrotate
-## begin gnulib module canonicalize
+## begin gnulib module canonicalize-lgpl
-libgnu_a_SOURCES += canonicalize.c
-EXTRA_DIST += canonicalize.h
+EXTRA_DIST += canonicalize-lgpl.c
-## end gnulib module canonicalize
+EXTRA_libgnu_a_SOURCES += canonicalize-lgpl.c
+
+## end gnulib module canonicalize-lgpl
## begin gnulib module chdir-long
@@ -143,8 +136,10 @@ EXTRA_libgnu_a_SOURCES += chdir-long.c
## begin gnulib module cloexec
+if gl_GNULIB_ENABLED_cloexec
libgnu_a_SOURCES += cloexec.c
+endif
EXTRA_DIST += cloexec.h
## end gnulib module cloexec
@@ -169,53 +164,6 @@ EXTRA_libgnu_a_SOURCES += closedir.c
## end gnulib module closedir
-## begin gnulib module configmake
-
-if gl_GNULIB_ENABLED_configmake
-# Listed in the same order as the GNU makefile conventions, and
-# provided by autoconf 2.59c+ or 2.70.
-# The Automake-defined pkg* macros are appended, in the order
-# listed in the Automake 1.10a+ documentation.
-configmake.h: Makefile
- $(AM_V_GEN)rm -f $@-t && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- echo '#define PREFIX "$(prefix)"'; \
- echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
- echo '#define BINDIR "$(bindir)"'; \
- echo '#define SBINDIR "$(sbindir)"'; \
- echo '#define LIBEXECDIR "$(libexecdir)"'; \
- echo '#define DATAROOTDIR "$(datarootdir)"'; \
- echo '#define DATADIR "$(datadir)"'; \
- echo '#define SYSCONFDIR "$(sysconfdir)"'; \
- echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
- echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
- echo '#define RUNSTATEDIR "$(runstatedir)"'; \
- echo '#define INCLUDEDIR "$(includedir)"'; \
- echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
- echo '#define DOCDIR "$(docdir)"'; \
- echo '#define INFODIR "$(infodir)"'; \
- echo '#define HTMLDIR "$(htmldir)"'; \
- echo '#define DVIDIR "$(dvidir)"'; \
- echo '#define PDFDIR "$(pdfdir)"'; \
- echo '#define PSDIR "$(psdir)"'; \
- echo '#define LIBDIR "$(libdir)"'; \
- echo '#define LISPDIR "$(lispdir)"'; \
- echo '#define LOCALEDIR "$(localedir)"'; \
- echo '#define MANDIR "$(mandir)"'; \
- echo '#define MANEXT "$(manext)"'; \
- echo '#define PKGDATADIR "$(pkgdatadir)"'; \
- echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
- echo '#define PKGLIBDIR "$(pkglibdir)"'; \
- echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
- } | sed '/""/d' > $@-t && \
- mv -f $@-t $@
-
-BUILT_SOURCES += configmake.h
-CLEANFILES += configmake.h configmake.h-t
-
-endif
-## end gnulib module configmake
-
## begin gnulib module cycle-check
libgnu_a_SOURCES += cycle-check.c
@@ -279,33 +227,17 @@ EXTRA_DIST += dirent.in.h
## end gnulib module dirent
-## begin gnulib module dirent-safer
-
-libgnu_a_SOURCES += opendir-safer.c
-
-EXTRA_DIST += dirent--.h dirent-safer.h
-
-## end gnulib module dirent-safer
-
## begin gnulib module dirfd
+if gl_GNULIB_ENABLED_dirfd
+endif
EXTRA_DIST += dirfd.c
EXTRA_libgnu_a_SOURCES += dirfd.c
## end gnulib module dirfd
-## begin gnulib module dirname
-
-libgnu_a_SOURCES += dirname.c basename.c
-
-EXTRA_DIST += stripslash.c
-
-EXTRA_libgnu_a_SOURCES += stripslash.c
-
-## end gnulib module dirname
-
## begin gnulib module dirname-lgpl
libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c
@@ -323,7 +255,9 @@ EXTRA_DIST += dosname.h
## begin gnulib module dup
+if gl_GNULIB_ENABLED_dup
+endif
EXTRA_DIST += dup.c
EXTRA_libgnu_a_SOURCES += dup.c
@@ -332,7 +266,9 @@ EXTRA_libgnu_a_SOURCES += dup.c
## begin gnulib module dup2
+if gl_GNULIB_ENABLED_dup2
+endif
EXTRA_DIST += dup2.c
EXTRA_libgnu_a_SOURCES += dup2.c
@@ -461,6 +397,14 @@ EXTRA_DIST += fd-hook.h
## end gnulib module fd-hook
+## begin gnulib module fd-safer-flag
+
+if gl_GNULIB_ENABLED_64142d6558df0059920a9be1d634dadf
+libgnu_a_SOURCES += fd-safer-flag.c dup-safer-flag.c
+
+endif
+## end gnulib module fd-safer-flag
+
## begin gnulib module fdopendir
@@ -479,14 +423,6 @@ EXTRA_libgnu_a_SOURCES += ffs.c
## end gnulib module ffs
-## begin gnulib module file-set
-
-libgnu_a_SOURCES += file-set.c
-
-EXTRA_DIST += file-set.h
-
-## end gnulib module file-set
-
## begin gnulib module filename
if gl_GNULIB_ENABLED_filename
@@ -573,17 +509,15 @@ EXTRA_libgnu_a_SOURCES += fnmatch.c fnmatch_loop.c
## begin gnulib module fstat
-EXTRA_DIST += fstat.c
+EXTRA_DIST += fstat.c stat-w32.c stat-w32.h
-EXTRA_libgnu_a_SOURCES += fstat.c
+EXTRA_libgnu_a_SOURCES += fstat.c stat-w32.c
## end gnulib module fstat
## begin gnulib module fstatat
-if gl_GNULIB_ENABLED_fstatat
-endif
EXTRA_DIST += at-func.c fstatat.c
EXTRA_libgnu_a_SOURCES += at-func.c fstatat.c
@@ -599,15 +533,6 @@ EXTRA_libgnu_a_SOURCES += fts-cycle.c fts.c
## end gnulib module fts
-## begin gnulib module getcwd
-
-
-EXTRA_DIST += getcwd.c
-
-EXTRA_libgnu_a_SOURCES += getcwd.c
-
-## end gnulib module getcwd
-
## begin gnulib module getcwd-lgpl
if gl_GNULIB_ENABLED_3d094ef542bfdd238a5194e172bfe5f6
@@ -698,15 +623,6 @@ libgnu_a_SOURCES += gettext.h
## end gnulib module gettext-h
-## begin gnulib module gettimeofday
-
-
-EXTRA_DIST += gettimeofday.c
-
-EXTRA_libgnu_a_SOURCES += gettimeofday.c
-
-## end gnulib module gettimeofday
-
## begin gnulib module hard-locale
if gl_GNULIB_ENABLED_30838f5439487421042f2225bed3af76
@@ -725,20 +641,6 @@ EXTRA_DIST += hash.h
## end gnulib module hash
-## begin gnulib module hash-pjw
-
-libgnu_a_SOURCES += hash-pjw.h hash-pjw.c
-
-## end gnulib module hash-pjw
-
-## begin gnulib module hash-triple
-
-libgnu_a_SOURCES += hash-triple.c
-
-EXTRA_DIST += hash-triple.h
-
-## end gnulib module hash-triple
-
## begin gnulib module i-ring
libgnu_a_SOURCES += i-ring.c
@@ -774,6 +676,7 @@ langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
-e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \
-e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
-e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
+ -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
-e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
-e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
-e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
@@ -829,76 +732,10 @@ EXTRA_libgnu_a_SOURCES += link.c
## begin gnulib module localcharset
if gl_GNULIB_ENABLED_localcharset
-libgnu_a_SOURCES += localcharset.h localcharset.c
-
-# We need the following in order to install a simple file in $(libdir)
-# which is shared with other installed packages. We use a list of referencing
-# packages so that "make uninstall" will remove the file if and only if it
-# is not used by another installed package.
-# On systems with glibc-2.1 or newer, the file is redundant, therefore we
-# avoid installing it.
-
-all-local: charset.alias ref-add.sed ref-del.sed
-
-charset_alias = $(DESTDIR)$(libdir)/charset.alias
-charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
-install-exec-local: install-exec-localcharset
-install-exec-localcharset: all-local
- if test $(GLIBC21) = no; then \
- case '$(host_os)' in \
- darwin[56]*) \
- need_charset_alias=true ;; \
- darwin* | cygwin* | mingw* | pw32* | cegcc*) \
- need_charset_alias=false ;; \
- *) \
- need_charset_alias=true ;; \
- esac ; \
- else \
- need_charset_alias=false ; \
- fi ; \
- if $$need_charset_alias; then \
- $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
- fi ; \
- if test -f $(charset_alias); then \
- sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
- $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
- rm -f $(charset_tmp) ; \
- else \
- if $$need_charset_alias; then \
- sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
- $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
- rm -f $(charset_tmp) ; \
- fi ; \
- fi
-
-uninstall-local: uninstall-localcharset
-uninstall-localcharset: all-local
- if test -f $(charset_alias); then \
- sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
- if grep '^# Packages using this file: $$' $(charset_tmp) \
- > /dev/null; then \
- rm -f $(charset_alias); \
- else \
- $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
- fi; \
- rm -f $(charset_tmp); \
- fi
-
-charset.alias: config.charset
- $(AM_V_GEN)rm -f t-$@ $@ && \
- $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
- mv t-$@ $@
-
-SUFFIXES += .sed .sin
-.sin.sed:
- $(AM_V_GEN)rm -f t-$@ $@ && \
- sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
- mv t-$@ $@
-
-CLEANFILES += charset.alias ref-add.sed ref-del.sed
+libgnu_a_SOURCES += localcharset.c
endif
-EXTRA_DIST += config.charset ref-add.sin ref-del.sin
+EXTRA_DIST += localcharset.h
## end gnulib module localcharset
@@ -940,6 +777,16 @@ EXTRA_libgnu_a_SOURCES += malloc.c
## end gnulib module malloc-posix
+## begin gnulib module malloca
+
+if gl_GNULIB_ENABLED_malloca
+libgnu_a_SOURCES += malloca.c
+
+endif
+EXTRA_DIST += malloca.h
+
+## end gnulib module malloca
+
## begin gnulib module mbrtowc
if gl_GNULIB_ENABLED_mbrtowc
@@ -1092,7 +939,9 @@ EXTRA_libgnu_a_SOURCES += opendir.c
## begin gnulib module pathmax
+if gl_GNULIB_ENABLED_pathmax
+endif
EXTRA_DIST += pathmax.h
## end gnulib module pathmax
@@ -1166,7 +1015,9 @@ EXTRA_libgnu_a_SOURCES += readdir.c
## begin gnulib module readlink
+if gl_GNULIB_ENABLED_readlink
+endif
EXTRA_DIST += readlink.c
EXTRA_libgnu_a_SOURCES += readlink.c
@@ -1184,25 +1035,6 @@ EXTRA_libgnu_a_SOURCES += realloc.c
## end gnulib module realloc-posix
-## begin gnulib module rewinddir
-
-if gl_GNULIB_ENABLED_rewinddir
-
-endif
-EXTRA_DIST += dirent-private.h rewinddir.c
-
-EXTRA_libgnu_a_SOURCES += rewinddir.c
-
-## end gnulib module rewinddir
-
-## begin gnulib module same
-
-libgnu_a_SOURCES += same.c
-
-EXTRA_DIST += same.h
-
-## end gnulib module same
-
## begin gnulib module same-inode
@@ -1235,8 +1067,8 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \
- -e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \
- -e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \
+ -e 's/@''GNULIB_PTHREAD_SIGMASK''@/$(GNULIB_PTHREAD_SIGMASK)/g' \
+ -e 's/@''GNULIB_RAISE''@/$(GNULIB_RAISE)/g' \
-e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \
-e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \
-e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \
@@ -1329,13 +1161,25 @@ EXTRA_DIST += warn-on-use.h
## begin gnulib module stat
+if gl_GNULIB_ENABLED_stat
-EXTRA_DIST += stat.c
+endif
+EXTRA_DIST += stat-w32.c stat-w32.h stat.c
-EXTRA_libgnu_a_SOURCES += stat.c
+EXTRA_libgnu_a_SOURCES += stat-w32.c stat.c
## end gnulib module stat
+## begin gnulib module stat-time
+
+if gl_GNULIB_ENABLED_0137e3d3638b33e5819d132d0b23165c
+libgnu_a_SOURCES += stat-time.c
+
+endif
+EXTRA_DIST += stat-time.h
+
+## end gnulib module stat-time
+
## begin gnulib module stdalign
BUILT_SOURCES += $(STDALIGN_H)
@@ -1630,6 +1474,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
+ -e 's/@''GNULIB_REALLOCARRAY''@/$(GNULIB_REALLOCARRAY)/g' \
-e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
-e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
-e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
@@ -1648,6 +1493,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+ -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
-e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
@@ -1660,10 +1506,12 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
-e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+ -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
-e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
-e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
-e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+ -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
-e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
-e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
@@ -1789,6 +1637,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
+ -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GNULIB_EXPLICIT_BZERO)/g' \
-e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
-e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
-e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
@@ -1827,7 +1676,8 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
-e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
< $(srcdir)/string.in.h | \
- sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
+ sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
+ -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
-e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
-e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
-e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
@@ -1848,20 +1698,20 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
- -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
- -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
- -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
- -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
- -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
-e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
-e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
-e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
- -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
+ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
+ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
@@ -1890,7 +1740,7 @@ strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
- -e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \
+ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \
-e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
@@ -1959,6 +1809,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
-e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
+ -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
-e 's/@''GNULIB_FCHMODAT''@/$(GNULIB_FCHMODAT)/g' \
-e 's/@''GNULIB_FSTAT''@/$(GNULIB_FSTAT)/g' \
-e 's/@''GNULIB_FSTATAT''@/$(GNULIB_FSTATAT)/g' \
@@ -1972,6 +1823,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
-e 's/@''GNULIB_MKNODAT''@/$(GNULIB_MKNODAT)/g' \
-e 's/@''GNULIB_STAT''@/$(GNULIB_STAT)/g' \
-e 's/@''GNULIB_UTIMENSAT''@/$(GNULIB_UTIMENSAT)/g' \
+ -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GNULIB_OVERRIDES_STRUCT_STAT)/g' \
-e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
-e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
-e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
@@ -2005,40 +1857,6 @@ EXTRA_DIST += sys_stat.in.h
## end gnulib module sys_stat
-## begin gnulib module sys_time
-
-BUILT_SOURCES += sys/time.h
-
-# We need the following in order to create <sys/time.h> when the system
-# doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
- $(AM_V_at)$(MKDIR_P) sys
- $(AM_V_GEN)rm -f $@-t $@ && \
- { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- sed -e 's|@''GUARD_PREFIX''@|GL|g' \
- -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
- -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
- -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
- -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
- -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
- -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
- -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
- -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \
- -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
- -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
- -e 's/@''REPLACE_STRUCT_TIMEVAL''@/$(REPLACE_STRUCT_TIMEVAL)/g' \
- -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
- -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
- -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
- < $(srcdir)/sys_time.in.h; \
- } > $@-t && \
- mv $@-t $@
-MOSTLYCLEANFILES += sys/time.h sys/time.h-t
-
-EXTRA_DIST += sys_time.in.h
-
-## end gnulib module sys_time
-
## begin gnulib module sys_types
BUILT_SOURCES += sys/types.h
@@ -2055,6 +1873,7 @@ sys/types.h: sys_types.in.h $(top_builddir)/config.status
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
-e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
+ -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
< $(srcdir)/sys_types.in.h; \
} > $@-t && \
mv $@-t $@
@@ -2166,24 +1985,31 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
- -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \
+ -e 's/@''GNULIB_CTIME''@/$(GNULIB_CTIME)/g' \
+ -e 's/@''GNULIB_LOCALTIME''@/$(GNULIB_LOCALTIME)/g' \
-e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
-e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
+ -e 's/@''GNULIB_STRFTIME''@/$(GNULIB_STRFTIME)/g' \
-e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
-e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
-e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
-e 's/@''GNULIB_TIME_RZ''@/$(GNULIB_TIME_RZ)/g' \
+ -e 's/@''GNULIB_TZSET''@/$(GNULIB_TZSET)/g' \
-e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
+ -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \
+ -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
-e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
-e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+ -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
-e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+ -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
-e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
@@ -2258,6 +2084,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
-e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
-e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
+ -e 's/@''GNULIB_TRUNCATE''@/$(GNULIB_TRUNCATE)/g' \
-e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
-e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
-e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
@@ -2306,6 +2133,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
-e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
+ -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
-e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
@@ -2314,6 +2142,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
+ -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
-e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
@@ -2336,6 +2165,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
-e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
-e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
+ -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
-e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
@@ -2403,6 +2233,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
-e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
-e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
-e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
-e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
@@ -2443,6 +2274,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \
-e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \
-e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \
+ -e 's/@''GNULIB_WCSFTIME''@/$(GNULIB_WCSFTIME)/g' \
< $(srcdir)/wchar.in.h | \
sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
-e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
@@ -2482,6 +2314,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
-e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
-e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
+ -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
-e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
| \
@@ -2498,6 +2331,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
-e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
+ -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|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)'; \
@@ -2526,6 +2360,7 @@ wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+ -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
-e 's/@''GNULIB_OVERRIDES_WINT_T''@/$(GNULIB_OVERRIDES_WINT_T)/g' \
-e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
-e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
@@ -2563,20 +2398,6 @@ EXTRA_libgnu_a_SOURCES += write.c
## end gnulib module write
-## begin gnulib module xalloc
-
-libgnu_a_SOURCES += xmalloc.c
-
-EXTRA_DIST += xalloc.h
-
-## end gnulib module xalloc
-
-## begin gnulib module xalloc-die
-
-libgnu_a_SOURCES += xalloc-die.c
-
-## end gnulib module xalloc-die
-
## begin gnulib module xalloc-oversized
@@ -2584,26 +2405,12 @@ EXTRA_DIST += xalloc-oversized.h
## end gnulib module xalloc-oversized
-## begin gnulib module xgetcwd
-
-libgnu_a_SOURCES += xgetcwd.c
-
-EXTRA_DIST += xgetcwd.h
-
-## end gnulib module xgetcwd
-
## begin gnulib module xsize
libgnu_a_SOURCES += xsize.h xsize.c
## end gnulib module xsize
-## begin gnulib module xstrndup
-
-libgnu_a_SOURCES += xstrndup.h xstrndup.c
-
-## end gnulib module xstrndup
-
mostlyclean-local: mostlyclean-generic
@for dir in '' $(MOSTLYCLEANDIRS); do \
diff --git a/libgnu/hard-locale.c b/libgnu/hard-locale.c
index 57ed42bf..49bc6caf 100644
--- a/libgnu/hard-locale.c
+++ b/libgnu/hard-locale.c
@@ -1,6 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
- Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2017 Free Software
+ Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/hard-locale.h b/libgnu/hard-locale.h
index ba424afc..22eecc5e 100644
--- a/libgnu/hard-locale.h
+++ b/libgnu/hard-locale.h
@@ -1,6 +1,6 @@
/* Determine whether a locale is hard.
- Copyright (C) 1999, 2003-2004, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2003-2004, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef HARD_LOCALE_H_
# define HARD_LOCALE_H_ 1
diff --git a/libgnu/hash-pjw.c b/libgnu/hash-pjw.c
deleted file mode 100644
index a886b499..00000000
--- a/libgnu/hash-pjw.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* hash-pjw.c -- compute a hash value from a NUL-terminated string.
-
- Copyright (C) 2001, 2003, 2006, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "hash-pjw.h"
-
-#include <limits.h>
-
-#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
-
-/* A hash function for NUL-terminated char* strings using
- the method described by Bruno Haible.
- See http://www.haible.de/bruno/hashfunc.html. */
-
-size_t
-hash_pjw (const void *x, size_t tablesize)
-{
- const char *s;
- size_t h = 0;
-
- for (s = x; *s; s++)
- h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
-
- return h % tablesize;
-}
diff --git a/libgnu/hash-pjw.h b/libgnu/hash-pjw.h
deleted file mode 100644
index 2e7d2307..00000000
--- a/libgnu/hash-pjw.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* hash-pjw.h -- declaration for a simple hash function
- Copyright (C) 2001, 2003, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <stddef.h>
-
-/* Compute a hash code for a NUL-terminated string starting at X,
- and return the hash code modulo TABLESIZE.
- The result is platform dependent: it depends on the size of the 'size_t'
- type and on the signedness of the 'char' type. */
-extern size_t hash_pjw (void const *x, size_t tablesize) _GL_ATTRIBUTE_PURE;
diff --git a/libgnu/hash-triple.c b/libgnu/hash-triple.c
deleted file mode 100644
index f8921618..00000000
--- a/libgnu/hash-triple.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Hash functions for file-related triples: name, device, inode.
- Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-#include "hash-triple.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "hash-pjw.h"
-#include "same.h"
-#include "same-inode.h"
-
-#define STREQ(a, b) (strcmp (a, b) == 0)
-
-/* Hash an F_triple, and *do* consider the file name. */
-size_t
-triple_hash (void const *x, size_t table_size)
-{
- struct F_triple const *p = x;
- size_t tmp = hash_pjw (p->name, table_size);
-
- /* Ignoring the device number here should be fine. */
- return (tmp ^ p->st_ino) % table_size;
-}
-
-/* Hash an F_triple, without considering the file name. */
-size_t
-triple_hash_no_name (void const *x, size_t table_size)
-{
- struct F_triple const *p = x;
-
- /* Ignoring the device number here should be fine. */
- return p->st_ino % table_size;
-}
-
-/* Compare two F_triple structs. */
-bool
-triple_compare (void const *x, void const *y)
-{
- struct F_triple const *a = x;
- struct F_triple const *b = y;
- return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
-}
-
-bool
-triple_compare_ino_str (void const *x, void const *y)
-{
- struct F_triple const *a = x;
- struct F_triple const *b = y;
- return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
-}
-
-/* Free an F_triple. */
-void
-triple_free (void *x)
-{
- struct F_triple *a = x;
- free (a->name);
- free (a);
-}
diff --git a/libgnu/hash-triple.h b/libgnu/hash-triple.h
deleted file mode 100644
index 0658d817..00000000
--- a/libgnu/hash-triple.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef HASH_TRIPLE_H
-#define HASH_TRIPLE_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdbool.h>
-
-/* Describe a just-created or just-renamed destination file. */
-struct F_triple
-{
- char *name;
- ino_t st_ino;
- dev_t st_dev;
-};
-
-extern size_t triple_hash (void const *x, size_t table_size) _GL_ATTRIBUTE_PURE;
-extern size_t triple_hash_no_name (void const *x, size_t table_size)
- _GL_ATTRIBUTE_PURE;
-extern bool triple_compare (void const *x, void const *y);
-extern bool triple_compare_ino_str (void const *x, void const *y)
- _GL_ATTRIBUTE_PURE;
-extern void triple_free (void *x);
-
-#endif
diff --git a/libgnu/hash.c b/libgnu/hash.c
index 04f64d15..98a8ea3d 100644
--- a/libgnu/hash.c
+++ b/libgnu/hash.c
@@ -1,6 +1,6 @@
/* hash - hashing table processing.
- Copyright (C) 1998-2004, 2006-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1998-2004, 2006-2007, 2009-2018 Free Software Foundation, Inc.
Written by Jim Meyering, 1992.
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* A generic hash table package. */
diff --git a/libgnu/hash.h b/libgnu/hash.h
index cc5e2b44..562f5e67 100644
--- a/libgnu/hash.h
+++ b/libgnu/hash.h
@@ -1,5 +1,5 @@
/* hash - hashing table processing.
- Copyright (C) 1998-1999, 2001, 2003, 2009-2017 Free Software Foundation,
+ Copyright (C) 1998-1999, 2001, 2003, 2009-2018 Free Software Foundation,
Inc.
Written by Jim Meyering <meyering@ascend.com>, 1998.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* A generic hash table package. */
diff --git a/libgnu/i-ring.c b/libgnu/i-ring.c
index b69a0c2c..a7f703c0 100644
--- a/libgnu/i-ring.c
+++ b/libgnu/i-ring.c
@@ -1,5 +1,5 @@
/* a simple ring buffer
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/i-ring.h b/libgnu/i-ring.h
index 38ad9cc9..45b4f1e4 100644
--- a/libgnu/i-ring.h
+++ b/libgnu/i-ring.h
@@ -1,5 +1,5 @@
/* definitions for a simple ring buffer
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <stdbool.h>
#include "verify.h"
diff --git a/libgnu/intprops.h b/libgnu/intprops.h
index 1ea9647e..15e470cb 100644
--- a/libgnu/intprops.h
+++ b/libgnu/intprops.h
@@ -1,6 +1,6 @@
/* intprops.h -- properties of integer types
- Copyright (C) 2001-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
@@ -21,13 +21,12 @@
#define _GL_INTPROPS_H
#include <limits.h>
-#include <verify.h>
/* Return a value with the common real type of E and V and the value of V. */
#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
+ <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
/* The extra casts in the following macros work around compiler bugs,
@@ -80,24 +79,7 @@
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your host.
- As a sanity check, test the assumption for some signed types that
- <limits.h> bounds. */
-verify (TYPE_MINIMUM (signed char) == SCHAR_MIN);
-verify (TYPE_MAXIMUM (signed char) == SCHAR_MAX);
-verify (TYPE_MINIMUM (short int) == SHRT_MIN);
-verify (TYPE_MAXIMUM (short int) == SHRT_MAX);
-verify (TYPE_MINIMUM (int) == INT_MIN);
-verify (TYPE_MAXIMUM (int) == INT_MAX);
-verify (TYPE_MINIMUM (long int) == LONG_MIN);
-verify (TYPE_MAXIMUM (long int) == LONG_MAX);
-#ifdef LLONG_MAX
-verify (TYPE_MINIMUM (long long int) == LLONG_MIN);
-verify (TYPE_MAXIMUM (long long int) == LLONG_MAX);
-#endif
-/* Similarly, sanity-check one ISO/IEC TS 18661-1:2014 macro if defined. */
-#ifdef UINT_WIDTH
-verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
-#endif
+ This assumption is tested by the intprops-tests module. */
/* Does the __typeof__ keyword work? This could be done by
'configure', but for now it's easier to do it by hand. */
@@ -197,7 +179,7 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
See above for restrictions. Avoid && and || as they tickle
bugs in Sun C 5.11 2010/08/13 and other compilers; see
- <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
+ <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
((b) < 0 \
? ((a) < 0 \
@@ -237,7 +219,11 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
: (max) >> (b) < (a))
/* True if __builtin_add_overflow (A, B, P) works when P is non-null. */
-#define _GL_HAS_BUILTIN_OVERFLOW (5 <= __GNUC__)
+#if 5 <= __GNUC__ && !defined __ICC
+# define _GL_HAS_BUILTIN_OVERFLOW 1
+#else
+# define _GL_HAS_BUILTIN_OVERFLOW 0
+#endif
/* True if __builtin_add_overflow_p (A, B, C) works. */
#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
@@ -457,7 +443,7 @@ verify (TYPE_WIDTH (unsigned int) == UINT_WIDTH);
implementation-defined result or signal for values outside T's
range. However, code that works around this theoretical problem
runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
- http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html
+ https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
As the compiler bug is real, don't try to work around the
theoretical problem. */
diff --git a/libgnu/itold.c b/libgnu/itold.c
index 9eb9507f..6a43bd8d 100644
--- a/libgnu/itold.c
+++ b/libgnu/itold.c
@@ -1,5 +1,5 @@
/* Replacement for 'int' to 'long double' conversion routine.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/langinfo.in.h b/libgnu/langinfo.in.h
index 7981cbf7..96c237ae 100644
--- a/libgnu/langinfo.in.h
+++ b/libgnu/langinfo.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <langinfo.h>.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/*
* POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
@@ -86,6 +86,18 @@ typedef int nl_item;
# define MON_10 (MON_1 + 9)
# define MON_11 (MON_1 + 10)
# define MON_12 (MON_1 + 11)
+# define ALTMON_1 10200
+# define ALTMON_2 (ALTMON_1 + 1)
+# define ALTMON_3 (ALTMON_1 + 2)
+# define ALTMON_4 (ALTMON_1 + 3)
+# define ALTMON_5 (ALTMON_1 + 4)
+# define ALTMON_6 (ALTMON_1 + 5)
+# define ALTMON_7 (ALTMON_1 + 6)
+# define ALTMON_8 (ALTMON_1 + 7)
+# define ALTMON_9 (ALTMON_1 + 8)
+# define ALTMON_10 (ALTMON_1 + 9)
+# define ALTMON_11 (ALTMON_1 + 10)
+# define ALTMON_12 (ALTMON_1 + 11)
# define ABMON_1 10035
# define ABMON_2 (ABMON_1 + 1)
# define ABMON_3 (ABMON_1 + 2)
@@ -138,6 +150,22 @@ typedef int nl_item;
# define GNULIB_defined_T_FMT_AMPM 1
# endif
+# if !@HAVE_LANGINFO_ALTMON@
+# define ALTMON_1 10200
+# define ALTMON_2 (ALTMON_1 + 1)
+# define ALTMON_3 (ALTMON_1 + 2)
+# define ALTMON_4 (ALTMON_1 + 3)
+# define ALTMON_5 (ALTMON_1 + 4)
+# define ALTMON_6 (ALTMON_1 + 5)
+# define ALTMON_7 (ALTMON_1 + 6)
+# define ALTMON_8 (ALTMON_1 + 7)
+# define ALTMON_9 (ALTMON_1 + 8)
+# define ALTMON_10 (ALTMON_1 + 9)
+# define ALTMON_11 (ALTMON_1 + 10)
+# define ALTMON_12 (ALTMON_1 + 11)
+# define GNULIB_defined_ALTMON 1
+# endif
+
# if !@HAVE_LANGINFO_ERA@
# define ERA 10047
# define ERA_D_FMT 10048
diff --git a/libgnu/limits.in.h b/libgnu/limits.in.h
index 08d3c328..2c809d97 100644
--- a/libgnu/limits.in.h
+++ b/libgnu/limits.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <limits.h>.
- Copyright 2016-2017 Free Software Foundation, Inc.
+ Copyright 2016-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_LIMITS_H
diff --git a/libgnu/link.c b/libgnu/link.c
index e821e2df..e7508b79 100644
--- a/libgnu/link.c
+++ b/libgnu/link.c
@@ -1,6 +1,6 @@
/* Emulate link on platforms that lack it, namely native Windows platforms.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -25,7 +25,7 @@
#include <sys/stat.h>
#if !HAVE_LINK
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
diff --git a/libgnu/localcharset.c b/libgnu/localcharset.c
index 9d0a1b82..58c5718c 100644
--- a/libgnu/localcharset.c
+++ b/libgnu/localcharset.c
@@ -1,6 +1,6 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2000-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
@@ -22,7 +22,6 @@
/* Specification. */
#include "localcharset.h"
-#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
@@ -32,7 +31,7 @@
# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
#endif
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 && !defined __CYGWIN__
# define WINDOWS_NATIVE
# include <locale.h>
#endif
@@ -45,11 +44,10 @@
#endif
#if !defined WINDOWS_NATIVE
-# include <unistd.h>
# if HAVE_LANGINFO_CODESET
# include <langinfo.h>
# else
-# if 0 /* see comment below */
+# if 0 /* see comment regarding use of setlocale(), below */
# include <locale.h>
# endif
# endif
@@ -71,317 +69,613 @@
# include <xlocale.h>
#endif
-#if ENABLE_RELOCATABLE
-# include "relocatable.h"
-#else
-# define relocate(pathname) (pathname)
-#endif
-
-/* Get LIBDIR. */
-#ifndef LIBDIR
-# include "configmake.h"
-#endif
-
-/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */
-#ifndef O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
-
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
- /* Native Windows, Cygwin, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-#endif
-#ifndef DIRECTORY_SEPARATOR
-# define DIRECTORY_SEPARATOR '/'
-#endif
+#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
-#ifndef ISSLASH
-# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
-#endif
+/* On these platforms, we use a mapping from non-canonical encoding name
+ to GNU canonical encoding name. */
-#if HAVE_DECL_GETC_UNLOCKED
-# undef getc
-# define getc getc_unlocked
-#endif
+/* With glibc-2.1 or newer, we don't need any canonicalization,
+ because glibc has iconv and both glibc and libiconv support all
+ GNU canonical names directly. */
+# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__)
-/* The following static variable is declared 'volatile' to avoid a
- possible multithread problem in the function get_charset_aliases. If we
- are running in a threaded environment, and if two threads initialize
- 'charset_aliases' simultaneously, both will produce the same value,
- and everything will be ok if the two assignments to 'charset_aliases'
- are atomic. But I don't know what will happen if the two assignments mix. */
-#if __STDC__ != 1
-# define volatile /* empty */
-#endif
-/* Pointer to the contents of the charset.alias file, if it has already been
- read, else NULL. Its format is:
- ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
-static const char * volatile charset_aliases;
-
-/* Return a pointer to the contents of the charset.alias file. */
-static const char *
-get_charset_aliases (void)
+struct table_entry
{
- const char *cp;
-
- cp = charset_aliases;
- if (cp == NULL)
- {
-#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__ || defined OS2)
- const char *dir;
- const char *base = "charset.alias";
- char *file_name;
-
- /* Make it possible to override the charset.alias location. This is
- necessary for running the testsuite before "make install". */
- dir = getenv ("CHARSETALIASDIR");
- if (dir == NULL || dir[0] == '\0')
- dir = relocate (LIBDIR);
-
- /* Concatenate dir and base into freshly allocated file_name. */
- {
- size_t dir_len = strlen (dir);
- size_t base_len = strlen (base);
- int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
- file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
- if (file_name != NULL)
- {
- memcpy (file_name, dir, dir_len);
- if (add_slash)
- file_name[dir_len] = DIRECTORY_SEPARATOR;
- memcpy (file_name + dir_len + add_slash, base, base_len + 1);
- }
- }
-
- if (file_name == NULL)
- /* Out of memory. Treat the file as empty. */
- cp = "";
- else
- {
- int fd;
-
- /* Open the file. Reject symbolic links on platforms that support
- O_NOFOLLOW. This is a security feature. Without it, an attacker
- could retrieve parts of the contents (namely, the tail of the
- first line that starts with "* ") of an arbitrary file by placing
- a symbolic link to that file under the name "charset.alias" in
- some writable directory and defining the environment variable
- CHARSETALIASDIR to point to that directory. */
- fd = open (file_name,
- O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
- if (fd < 0)
- /* File not found. Treat it as empty. */
- cp = "";
- else
- {
- FILE *fp;
-
- fp = fdopen (fd, "r");
- if (fp == NULL)
- {
- /* Out of memory. Treat the file as empty. */
- close (fd);
- cp = "";
- }
- else
- {
- /* Parse the file's contents. */
- char *res_ptr = NULL;
- size_t res_size = 0;
-
- for (;;)
- {
- int c;
- char buf1[50+1];
- char buf2[50+1];
- size_t l1, l2;
- char *old_res_ptr;
-
- c = getc (fp);
- if (c == EOF)
- break;
- if (c == '\n' || c == ' ' || c == '\t')
- continue;
- if (c == '#')
- {
- /* Skip comment, to end of line. */
- do
- c = getc (fp);
- while (!(c == EOF || c == '\n'));
- if (c == EOF)
- break;
- continue;
- }
- ungetc (c, fp);
- if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
- break;
- l1 = strlen (buf1);
- l2 = strlen (buf2);
- old_res_ptr = res_ptr;
- if (res_size == 0)
- {
- res_size = l1 + 1 + l2 + 1;
- res_ptr = (char *) malloc (res_size + 1);
- }
- else
- {
- res_size += l1 + 1 + l2 + 1;
- res_ptr = (char *) realloc (res_ptr, res_size + 1);
- }
- if (res_ptr == NULL)
- {
- /* Out of memory. */
- res_size = 0;
- free (old_res_ptr);
- break;
- }
- strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
- strcpy (res_ptr + res_size - (l2 + 1), buf2);
- }
- fclose (fp);
- if (res_size == 0)
- cp = "";
- else
- {
- *(res_ptr + res_size) = '\0';
- cp = res_ptr;
- }
- }
- }
+ const char alias[11+1];
+ const char canonical[11+1];
+};
+
+/* Table of platform-dependent mappings, sorted in ascending order. */
+static const struct table_entry alias_table[] =
+ {
+# if defined __FreeBSD__ /* FreeBSD */
+ /*{ "ARMSCII-8", "ARMSCII-8" },*/
+ { "Big5", "BIG5" },
+ { "C", "ASCII" },
+ /*{ "CP1131", "CP1131" },*/
+ /*{ "CP1251", "CP1251" },*/
+ /*{ "CP866", "CP866" },*/
+ /*{ "GB18030", "GB18030" },*/
+ /*{ "GB2312", "GB2312" },*/
+ /*{ "GBK", "GBK" },*/
+ /*{ "ISCII-DEV", "?" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ /*{ "KOI8-R", "KOI8-R" },*/
+ /*{ "KOI8-U", "KOI8-U" },*/
+ { "SJIS", "SHIFT_JIS" },
+ { "US-ASCII", "ASCII" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined __NetBSD__ /* NetBSD */
+ { "646", "ASCII" },
+ /*{ "ARMSCII-8", "ARMSCII-8" },*/
+ /*{ "BIG5", "BIG5" },*/
+ { "Big5-HKSCS", "BIG5-HKSCS" },
+ /*{ "CP1251", "CP1251" },*/
+ /*{ "CP866", "CP866" },*/
+ /*{ "GB18030", "GB18030" },*/
+ /*{ "GB2312", "GB2312" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ /*{ "KOI8-R", "KOI8-R" },*/
+ /*{ "KOI8-U", "KOI8-U" },*/
+ /*{ "PT154", "PT154" },*/
+ { "SJIS", "SHIFT_JIS" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# if defined __OpenBSD__ /* OpenBSD */
+ { "646", "ASCII" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" }
+# define alias_table_defined
+# endif
+# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+ /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
+ useless:
+ - It returns the empty string when LANG is set to a locale of the
+ form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
+ LC_CTYPE file.
+ - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
+ the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
+ - The documentation says:
+ "... all code that calls BSD system routines should ensure
+ that the const *char parameters of these routines are in UTF-8
+ encoding. All BSD system functions expect their string
+ parameters to be in UTF-8 encoding and nothing else."
+ It also says
+ "An additional caveat is that string parameters for files,
+ paths, and other file-system entities must be in canonical
+ UTF-8. In a canonical UTF-8 Unicode string, all decomposable
+ characters are decomposed ..."
+ but this is not true: You can pass non-decomposed UTF-8 strings
+ to file system functions, and it is the OS which will convert
+ them to decomposed UTF-8 before accessing the file system.
+ - The Apple Terminal application displays UTF-8 by default.
+ - However, other applications are free to use different encodings:
+ - xterm uses ISO-8859-1 by default.
+ - TextEdit uses MacRoman by default.
+ We prefer UTF-8 over decomposed UTF-8-MAC because one should
+ minimize the use of decomposed Unicode. Unfortunately, through the
+ Darwin file system, decomposed UTF-8 strings are leaked into user
+ space nevertheless.
+ Then there are also the locales with encodings other than US-ASCII
+ and UTF-8. These locales can be occasionally useful to users (e.g.
+ when grepping through ISO-8859-1 encoded text files), when all their
+ file names are in US-ASCII.
+ */
+ { "ARMSCII-8", "ARMSCII-8" },
+ { "Big5", "BIG5" },
+ { "Big5HKSCS", "BIG5-HKSCS" },
+ { "CP1131", "CP1131" },
+ { "CP1251", "CP1251" },
+ { "CP866", "CP866" },
+ { "CP949", "CP949" },
+ { "GB18030", "GB18030" },
+ { "GB2312", "GB2312" },
+ { "GBK", "GBK" },
+ /*{ "ISCII-DEV", "?" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "KOI8-R", "KOI8-R" },
+ { "KOI8-U", "KOI8-U" },
+ { "PT154", "PT154" },
+ { "SJIS", "SHIFT_JIS" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined _AIX /* AIX */
+ /*{ "GBK", "GBK" },*/
+ { "IBM-1046", "CP1046" },
+ { "IBM-1124", "CP1124" },
+ { "IBM-1129", "CP1129" },
+ { "IBM-1252", "CP1252" },
+ { "IBM-850", "CP850" },
+ { "IBM-856", "CP856" },
+ { "IBM-921", "ISO-8859-13" },
+ { "IBM-922", "CP922" },
+ { "IBM-932", "CP932" },
+ { "IBM-943", "CP943" },
+ { "IBM-eucCN", "GB2312" },
+ { "IBM-eucJP", "EUC-JP" },
+ { "IBM-eucKR", "EUC-KR" },
+ { "IBM-eucTW", "EUC-TW" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-6", "ISO-8859-6" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "TIS-620", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "big5", "BIG5" }
+# define alias_table_defined
+# endif
+# if defined __hpux /* HP-UX */
+ { "SJIS", "SHIFT_JIS" },
+ { "arabic8", "HP-ARABIC8" },
+ { "big5", "BIG5" },
+ { "cp1251", "CP1251" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" },
+ { "gb18030", "GB18030" },
+ { "greek8", "HP-GREEK8" },
+ { "hebrew8", "HP-HEBREW8" },
+ { "hkbig5", "BIG5-HKSCS" },
+ { "hp15CN", "GB2312" },
+ { "iso88591", "ISO-8859-1" },
+ { "iso885913", "ISO-8859-13" },
+ { "iso885915", "ISO-8859-15" },
+ { "iso88592", "ISO-8859-2" },
+ { "iso88594", "ISO-8859-4" },
+ { "iso88595", "ISO-8859-5" },
+ { "iso88596", "ISO-8859-6" },
+ { "iso88597", "ISO-8859-7" },
+ { "iso88598", "ISO-8859-8" },
+ { "iso88599", "ISO-8859-9" },
+ { "kana8", "HP-KANA8" },
+ { "koi8r", "KOI8-R" },
+ { "roman8", "HP-ROMAN8" },
+ { "tis620", "TIS-620" },
+ { "turkish8", "HP-TURKISH8" },
+ { "utf8", "UTF-8" }
+# define alias_table_defined
+# endif
+# if defined __sgi /* IRIX */
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "eucCN", "GB2312" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# if defined __osf__ /* OSF/1 */
+ /*{ "GBK", "GBK" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "KSC5601", "CP949" },
+ { "SJIS", "SHIFT_JIS" },
+ { "TACTIS", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "big5", "BIG5" },
+ { "cp850", "CP850" },
+ { "dechanyu", "DEC-HANYU" },
+ { "dechanzi", "GB2312" },
+ { "deckanji", "DEC-KANJI" },
+ { "deckorean", "EUC-KR" },
+ { "eucJP", "EUC-JP" },
+ { "eucKR", "EUC-KR" },
+ { "eucTW", "EUC-TW" },
+ { "sdeckanji", "EUC-JP" }
+# define alias_table_defined
+# endif
+# if defined __sun /* Solaris */
+ { "5601", "EUC-KR" },
+ { "646", "ASCII" },
+ /*{ "BIG5", "BIG5" },*/
+ { "Big5-HKSCS", "BIG5-HKSCS" },
+ { "GB18030", "GB18030" },
+ /*{ "GBK", "GBK" },*/
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-11", "TIS-620" },
+ { "ISO8859-13", "ISO-8859-13" },
+ { "ISO8859-15", "ISO-8859-15" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-3", "ISO-8859-3" },
+ { "ISO8859-4", "ISO-8859-4" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-6", "ISO-8859-6" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "PCK", "SHIFT_JIS" },
+ { "TIS620.2533", "TIS-620" },
+ /*{ "UTF-8", "UTF-8" },*/
+ { "ansi-1251", "CP1251" },
+ { "cns11643", "EUC-TW" },
+ { "eucJP", "EUC-JP" },
+ { "gb2312", "GB2312" },
+ { "koi8-r", "KOI8-R" }
+# define alias_table_defined
+# endif
+# if defined __minix /* Minix */
+ { "646", "ASCII" }
+# define alias_table_defined
+# endif
+# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */
+ { "CP1361", "JOHAB" },
+ { "CP20127", "ASCII" },
+ { "CP20866", "KOI8-R" },
+ { "CP20936", "GB2312" },
+ { "CP21866", "KOI8-RU" },
+ { "CP28591", "ISO-8859-1" },
+ { "CP28592", "ISO-8859-2" },
+ { "CP28593", "ISO-8859-3" },
+ { "CP28594", "ISO-8859-4" },
+ { "CP28595", "ISO-8859-5" },
+ { "CP28596", "ISO-8859-6" },
+ { "CP28597", "ISO-8859-7" },
+ { "CP28598", "ISO-8859-8" },
+ { "CP28599", "ISO-8859-9" },
+ { "CP28605", "ISO-8859-15" },
+ { "CP38598", "ISO-8859-8" },
+ { "CP51932", "EUC-JP" },
+ { "CP51936", "GB2312" },
+ { "CP51949", "EUC-KR" },
+ { "CP51950", "EUC-TW" },
+ { "CP54936", "GB18030" },
+ { "CP65001", "UTF-8" },
+ { "CP936", "GBK" }
+# define alias_table_defined
+# endif
+# if defined OS2 /* OS/2 */
+ /* The list of encodings is taken from "List of OS/2 Codepages"
+ by Alex Taylor:
+ <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
+ See also "IBM Globalization - Code page identifiers":
+ <https://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */
+ { "CP1089", "ISO-8859-6" },
+ { "CP1208", "UTF-8" },
+ { "CP1381", "GB2312" },
+ { "CP1386", "GBK" },
+ { "CP3372", "EUC-JP" },
+ { "CP813", "ISO-8859-7" },
+ { "CP819", "ISO-8859-1" },
+ { "CP878", "KOI8-R" },
+ { "CP912", "ISO-8859-2" },
+ { "CP913", "ISO-8859-3" },
+ { "CP914", "ISO-8859-4" },
+ { "CP915", "ISO-8859-5" },
+ { "CP916", "ISO-8859-8" },
+ { "CP920", "ISO-8859-9" },
+ { "CP921", "ISO-8859-13" },
+ { "CP923", "ISO-8859-15" },
+ { "CP954", "EUC-JP" },
+ { "CP964", "EUC-TW" },
+ { "CP970", "EUC-KR" }
+# define alias_table_defined
+# endif
+# if defined VMS /* OpenVMS */
+ /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
+ "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
+ section 10.7 "Handling Different Character Sets". */
+ { "DECHANYU", "DEC-HANYU" },
+ { "DECHANZI", "GB2312" },
+ { "DECKANJI", "DEC-KANJI" },
+ { "DECKOREAN", "EUC-KR" },
+ { "ISO8859-1", "ISO-8859-1" },
+ { "ISO8859-2", "ISO-8859-2" },
+ { "ISO8859-5", "ISO-8859-5" },
+ { "ISO8859-7", "ISO-8859-7" },
+ { "ISO8859-8", "ISO-8859-8" },
+ { "ISO8859-9", "ISO-8859-9" },
+ { "SDECKANJI", "EUC-JP" },
+ { "SJIS", "SHIFT_JIS" },
+ { "eucJP", "EUC-JP" },
+ { "eucTW", "EUC-TW" }
+# define alias_table_defined
+# endif
+# ifndef alias_table_defined
+ /* Just a dummy entry, to avoid a C syntax error. */
+ { "", "" }
+# endif
+ };
- free (file_name);
- }
+# endif
#else
-# if defined DARWIN7
- /* To avoid the trouble of installing a file that is shared by many
- GNU packages -- many packaging systems have problems with this --,
- simply inline the aliases here. */
- cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
- "ISO8859-2" "\0" "ISO-8859-2" "\0"
- "ISO8859-4" "\0" "ISO-8859-4" "\0"
- "ISO8859-5" "\0" "ISO-8859-5" "\0"
- "ISO8859-7" "\0" "ISO-8859-7" "\0"
- "ISO8859-9" "\0" "ISO-8859-9" "\0"
- "ISO8859-13" "\0" "ISO-8859-13" "\0"
- "ISO8859-15" "\0" "ISO-8859-15" "\0"
- "KOI8-R" "\0" "KOI8-R" "\0"
- "KOI8-U" "\0" "KOI8-U" "\0"
- "CP866" "\0" "CP866" "\0"
- "CP949" "\0" "CP949" "\0"
- "CP1131" "\0" "CP1131" "\0"
- "CP1251" "\0" "CP1251" "\0"
- "eucCN" "\0" "GB2312" "\0"
- "GB2312" "\0" "GB2312" "\0"
- "eucJP" "\0" "EUC-JP" "\0"
- "eucKR" "\0" "EUC-KR" "\0"
- "Big5" "\0" "BIG5" "\0"
- "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
- "GBK" "\0" "GBK" "\0"
- "GB18030" "\0" "GB18030" "\0"
- "SJIS" "\0" "SHIFT_JIS" "\0"
- "ARMSCII-8" "\0" "ARMSCII-8" "\0"
- "PT154" "\0" "PT154" "\0"
- /*"ISCII-DEV" "\0" "?" "\0"*/
- "*" "\0" "UTF-8" "\0";
-# endif
+/* On these platforms, we use a mapping from locale name to GNU canonical
+ encoding name. */
-# if defined VMS
- /* To avoid the troubles of an extra file charset.alias_vms in the
- sources of many GNU packages, simply inline the aliases here. */
- /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
- "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
- section 10.7 "Handling Different Character Sets". */
- cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
- "ISO8859-2" "\0" "ISO-8859-2" "\0"
- "ISO8859-5" "\0" "ISO-8859-5" "\0"
- "ISO8859-7" "\0" "ISO-8859-7" "\0"
- "ISO8859-8" "\0" "ISO-8859-8" "\0"
- "ISO8859-9" "\0" "ISO-8859-9" "\0"
- /* Japanese */
- "eucJP" "\0" "EUC-JP" "\0"
- "SJIS" "\0" "SHIFT_JIS" "\0"
- "DECKANJI" "\0" "DEC-KANJI" "\0"
- "SDECKANJI" "\0" "EUC-JP" "\0"
- /* Chinese */
- "eucTW" "\0" "EUC-TW" "\0"
- "DECHANYU" "\0" "DEC-HANYU" "\0"
- "DECHANZI" "\0" "GB2312" "\0"
- /* Korean */
- "DECKOREAN" "\0" "EUC-KR" "\0";
+struct table_entry
+{
+ const char locale[17+1];
+ const char canonical[11+1];
+};
+
+/* Table of platform-dependent mappings, sorted in ascending order. */
+static const struct table_entry locale_table[] =
+ {
+# if defined __FreeBSD__ /* FreeBSD 4.2 */
+ { "cs_CZ.ISO_8859-2", "ISO-8859-2" },
+ { "da_DK.DIS_8859-15", "ISO-8859-15" },
+ { "da_DK.ISO_8859-1", "ISO-8859-1" },
+ { "de_AT.DIS_8859-15", "ISO-8859-15" },
+ { "de_AT.ISO_8859-1", "ISO-8859-1" },
+ { "de_CH.DIS_8859-15", "ISO-8859-15" },
+ { "de_CH.ISO_8859-1", "ISO-8859-1" },
+ { "de_DE.DIS_8859-15", "ISO-8859-15" },
+ { "de_DE.ISO_8859-1", "ISO-8859-1" },
+ { "en_AU.DIS_8859-15", "ISO-8859-15" },
+ { "en_AU.ISO_8859-1", "ISO-8859-1" },
+ { "en_CA.DIS_8859-15", "ISO-8859-15" },
+ { "en_CA.ISO_8859-1", "ISO-8859-1" },
+ { "en_GB.DIS_8859-15", "ISO-8859-15" },
+ { "en_GB.ISO_8859-1", "ISO-8859-1" },
+ { "en_US.DIS_8859-15", "ISO-8859-15" },
+ { "en_US.ISO_8859-1", "ISO-8859-1" },
+ { "es_ES.DIS_8859-15", "ISO-8859-15" },
+ { "es_ES.ISO_8859-1", "ISO-8859-1" },
+ { "fi_FI.DIS_8859-15", "ISO-8859-15" },
+ { "fi_FI.ISO_8859-1", "ISO-8859-1" },
+ { "fr_BE.DIS_8859-15", "ISO-8859-15" },
+ { "fr_BE.ISO_8859-1", "ISO-8859-1" },
+ { "fr_CA.DIS_8859-15", "ISO-8859-15" },
+ { "fr_CA.ISO_8859-1", "ISO-8859-1" },
+ { "fr_CH.DIS_8859-15", "ISO-8859-15" },
+ { "fr_CH.ISO_8859-1", "ISO-8859-1" },
+ { "fr_FR.DIS_8859-15", "ISO-8859-15" },
+ { "fr_FR.ISO_8859-1", "ISO-8859-1" },
+ { "hr_HR.ISO_8859-2", "ISO-8859-2" },
+ { "hu_HU.ISO_8859-2", "ISO-8859-2" },
+ { "is_IS.DIS_8859-15", "ISO-8859-15" },
+ { "is_IS.ISO_8859-1", "ISO-8859-1" },
+ { "it_CH.DIS_8859-15", "ISO-8859-15" },
+ { "it_CH.ISO_8859-1", "ISO-8859-1" },
+ { "it_IT.DIS_8859-15", "ISO-8859-15" },
+ { "it_IT.ISO_8859-1", "ISO-8859-1" },
+ { "ja_JP.EUC", "EUC-JP" },
+ { "ja_JP.SJIS", "SHIFT_JIS" },
+ { "ja_JP.Shift_JIS", "SHIFT_JIS" },
+ { "ko_KR.EUC", "EUC-KR" },
+ { "la_LN.ASCII", "ASCII" },
+ { "la_LN.DIS_8859-15", "ISO-8859-15" },
+ { "la_LN.ISO_8859-1", "ISO-8859-1" },
+ { "la_LN.ISO_8859-2", "ISO-8859-2" },
+ { "la_LN.ISO_8859-4", "ISO-8859-4" },
+ { "lt_LN.ASCII", "ASCII" },
+ { "lt_LN.DIS_8859-15", "ISO-8859-15" },
+ { "lt_LN.ISO_8859-1", "ISO-8859-1" },
+ { "lt_LN.ISO_8859-2", "ISO-8859-2" },
+ { "lt_LT.ISO_8859-4", "ISO-8859-4" },
+ { "nl_BE.DIS_8859-15", "ISO-8859-15" },
+ { "nl_BE.ISO_8859-1", "ISO-8859-1" },
+ { "nl_NL.DIS_8859-15", "ISO-8859-15" },
+ { "nl_NL.ISO_8859-1", "ISO-8859-1" },
+ { "no_NO.DIS_8859-15", "ISO-8859-15" },
+ { "no_NO.ISO_8859-1", "ISO-8859-1" },
+ { "pl_PL.ISO_8859-2", "ISO-8859-2" },
+ { "pt_PT.DIS_8859-15", "ISO-8859-15" },
+ { "pt_PT.ISO_8859-1", "ISO-8859-1" },
+ { "ru_RU.CP866", "CP866" },
+ { "ru_RU.ISO_8859-5", "ISO-8859-5" },
+ { "ru_RU.KOI8-R", "KOI8-R" },
+ { "ru_SU.CP866", "CP866" },
+ { "ru_SU.ISO_8859-5", "ISO-8859-5" },
+ { "ru_SU.KOI8-R", "KOI8-R" },
+ { "sl_SI.ISO_8859-2", "ISO-8859-2" },
+ { "sv_SE.DIS_8859-15", "ISO-8859-15" },
+ { "sv_SE.ISO_8859-1", "ISO-8859-1" },
+ { "uk_UA.KOI8-U", "KOI8-U" },
+ { "zh_CN.EUC", "GB2312" },
+ { "zh_TW.BIG5", "BIG5" },
+ { "zh_TW.Big5", "BIG5" }
+# define locale_table_defined
# endif
-
-# if defined WINDOWS_NATIVE || defined __CYGWIN__
- /* To avoid the troubles of installing a separate file in the same
- directory as the DLL and of retrieving the DLL's directory at
- runtime, simply inline the aliases here. */
-
- cp = "CP936" "\0" "GBK" "\0"
- "CP1361" "\0" "JOHAB" "\0"
- "CP20127" "\0" "ASCII" "\0"
- "CP20866" "\0" "KOI8-R" "\0"
- "CP20936" "\0" "GB2312" "\0"
- "CP21866" "\0" "KOI8-RU" "\0"
- "CP28591" "\0" "ISO-8859-1" "\0"
- "CP28592" "\0" "ISO-8859-2" "\0"
- "CP28593" "\0" "ISO-8859-3" "\0"
- "CP28594" "\0" "ISO-8859-4" "\0"
- "CP28595" "\0" "ISO-8859-5" "\0"
- "CP28596" "\0" "ISO-8859-6" "\0"
- "CP28597" "\0" "ISO-8859-7" "\0"
- "CP28598" "\0" "ISO-8859-8" "\0"
- "CP28599" "\0" "ISO-8859-9" "\0"
- "CP28605" "\0" "ISO-8859-15" "\0"
- "CP38598" "\0" "ISO-8859-8" "\0"
- "CP51932" "\0" "EUC-JP" "\0"
- "CP51936" "\0" "GB2312" "\0"
- "CP51949" "\0" "EUC-KR" "\0"
- "CP51950" "\0" "EUC-TW" "\0"
- "CP54936" "\0" "GB18030" "\0"
- "CP65001" "\0" "UTF-8" "\0";
+# if defined __DJGPP__ /* DOS / DJGPP 2.03 */
+ /* The encodings given here may not all be correct.
+ If you find that the encoding given for your language and
+ country is not the one your DOS machine actually uses, just
+ correct it in this file, and send a mail to
+ Juan Manuel Guerrero <juan.guerrero@gmx.de>
+ and <bug-gnulib@gnu.org>. */
+ { "C", "ASCII" },
+ { "ar", "CP864" },
+ { "ar_AE", "CP864" },
+ { "ar_DZ", "CP864" },
+ { "ar_EG", "CP864" },
+ { "ar_IQ", "CP864" },
+ { "ar_IR", "CP864" },
+ { "ar_JO", "CP864" },
+ { "ar_KW", "CP864" },
+ { "ar_MA", "CP864" },
+ { "ar_OM", "CP864" },
+ { "ar_QA", "CP864" },
+ { "ar_SA", "CP864" },
+ { "ar_SY", "CP864" },
+ { "be", "CP866" },
+ { "be_BE", "CP866" },
+ { "bg", "CP866" }, /* not CP855 ?? */
+ { "bg_BG", "CP866" }, /* not CP855 ?? */
+ { "ca", "CP850" },
+ { "ca_ES", "CP850" },
+ { "cs", "CP852" },
+ { "cs_CZ", "CP852" },
+ { "da", "CP865" }, /* not CP850 ?? */
+ { "da_DK", "CP865" }, /* not CP850 ?? */
+ { "de", "CP850" },
+ { "de_AT", "CP850" },
+ { "de_CH", "CP850" },
+ { "de_DE", "CP850" },
+ { "el", "CP869" },
+ { "el_GR", "CP869" },
+ { "en", "CP850" },
+ { "en_AU", "CP850" }, /* not CP437 ?? */
+ { "en_CA", "CP850" },
+ { "en_GB", "CP850" },
+ { "en_NZ", "CP437" },
+ { "en_US", "CP437" },
+ { "en_ZA", "CP850" }, /* not CP437 ?? */
+ { "eo", "CP850" },
+ { "eo_EO", "CP850" },
+ { "es", "CP850" },
+ { "es_AR", "CP850" },
+ { "es_BO", "CP850" },
+ { "es_CL", "CP850" },
+ { "es_CO", "CP850" },
+ { "es_CR", "CP850" },
+ { "es_CU", "CP850" },
+ { "es_DO", "CP850" },
+ { "es_EC", "CP850" },
+ { "es_ES", "CP850" },
+ { "es_GT", "CP850" },
+ { "es_HN", "CP850" },
+ { "es_MX", "CP850" },
+ { "es_NI", "CP850" },
+ { "es_PA", "CP850" },
+ { "es_PE", "CP850" },
+ { "es_PY", "CP850" },
+ { "es_SV", "CP850" },
+ { "es_UY", "CP850" },
+ { "es_VE", "CP850" },
+ { "et", "CP850" },
+ { "et_EE", "CP850" },
+ { "eu", "CP850" },
+ { "eu_ES", "CP850" },
+ { "fi", "CP850" },
+ { "fi_FI", "CP850" },
+ { "fr", "CP850" },
+ { "fr_BE", "CP850" },
+ { "fr_CA", "CP850" },
+ { "fr_CH", "CP850" },
+ { "fr_FR", "CP850" },
+ { "ga", "CP850" },
+ { "ga_IE", "CP850" },
+ { "gd", "CP850" },
+ { "gd_GB", "CP850" },
+ { "gl", "CP850" },
+ { "gl_ES", "CP850" },
+ { "he", "CP862" },
+ { "he_IL", "CP862" },
+ { "hr", "CP852" },
+ { "hr_HR", "CP852" },
+ { "hu", "CP852" },
+ { "hu_HU", "CP852" },
+ { "id", "CP850" }, /* not CP437 ?? */
+ { "id_ID", "CP850" }, /* not CP437 ?? */
+ { "is", "CP861" }, /* not CP850 ?? */
+ { "is_IS", "CP861" }, /* not CP850 ?? */
+ { "it", "CP850" },
+ { "it_CH", "CP850" },
+ { "it_IT", "CP850" },
+ { "ja", "CP932" },
+ { "ja_JP", "CP932" },
+ { "kr", "CP949" }, /* not CP934 ?? */
+ { "kr_KR", "CP949" }, /* not CP934 ?? */
+ { "lt", "CP775" },
+ { "lt_LT", "CP775" },
+ { "lv", "CP775" },
+ { "lv_LV", "CP775" },
+ { "mk", "CP866" }, /* not CP855 ?? */
+ { "mk_MK", "CP866" }, /* not CP855 ?? */
+ { "mt", "CP850" },
+ { "mt_MT", "CP850" },
+ { "nb", "CP865" }, /* not CP850 ?? */
+ { "nb_NO", "CP865" }, /* not CP850 ?? */
+ { "nl", "CP850" },
+ { "nl_BE", "CP850" },
+ { "nl_NL", "CP850" },
+ { "nn", "CP865" }, /* not CP850 ?? */
+ { "nn_NO", "CP865" }, /* not CP850 ?? */
+ { "no", "CP865" }, /* not CP850 ?? */
+ { "no_NO", "CP865" }, /* not CP850 ?? */
+ { "pl", "CP852" },
+ { "pl_PL", "CP852" },
+ { "pt", "CP850" },
+ { "pt_BR", "CP850" },
+ { "pt_PT", "CP850" },
+ { "ro", "CP852" },
+ { "ro_RO", "CP852" },
+ { "ru", "CP866" },
+ { "ru_RU", "CP866" },
+ { "sk", "CP852" },
+ { "sk_SK", "CP852" },
+ { "sl", "CP852" },
+ { "sl_SI", "CP852" },
+ { "sq", "CP852" },
+ { "sq_AL", "CP852" },
+ { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */
+ { "sv", "CP850" },
+ { "sv_SE", "CP850" },
+ { "th", "CP874" },
+ { "th_TH", "CP874" },
+ { "tr", "CP857" },
+ { "tr_TR", "CP857" },
+ { "uk", "CP1125" },
+ { "uk_UA", "CP1125" },
+ { "zh_CN", "GBK" },
+ { "zh_TW", "CP950" } /* not CP938 ?? */
+# define locale_table_defined
# endif
-# if defined OS2
- /* To avoid the troubles of installing a separate file in the same
- directory as the DLL and of retrieving the DLL's directory at
- runtime, simply inline the aliases here. */
-
- /* The list of encodings is taken from "List of OS/2 Codepages"
- by Alex Taylor:
- <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
- See also "IBM Globalization - Code page identifiers":
- <http://www-01.ibm.com/software/globalization/cp/cp_cpgid.html>. */
- cp = "CP813" "\0" "ISO-8859-7" "\0"
- "CP878" "\0" "KOI8-R" "\0"
- "CP819" "\0" "ISO-8859-1" "\0"
- "CP912" "\0" "ISO-8859-2" "\0"
- "CP913" "\0" "ISO-8859-3" "\0"
- "CP914" "\0" "ISO-8859-4" "\0"
- "CP915" "\0" "ISO-8859-5" "\0"
- "CP916" "\0" "ISO-8859-8" "\0"
- "CP920" "\0" "ISO-8859-9" "\0"
- "CP921" "\0" "ISO-8859-13" "\0"
- "CP923" "\0" "ISO-8859-15" "\0"
- "CP954" "\0" "EUC-JP" "\0"
- "CP964" "\0" "EUC-TW" "\0"
- "CP970" "\0" "EUC-KR" "\0"
- "CP1089" "\0" "ISO-8859-6" "\0"
- "CP1208" "\0" "UTF-8" "\0"
- "CP1381" "\0" "GB2312" "\0"
- "CP1386" "\0" "GBK" "\0"
- "CP3372" "\0" "EUC-JP" "\0";
+# ifndef locale_table_defined
+ /* Just a dummy entry, to avoid a C syntax error. */
+ { "", "" }
# endif
-#endif
+ };
- charset_aliases = cp;
- }
+#endif
- return cp;
-}
/* Determine the current locale's character encoding, and canonicalize it
- into one of the canonical names listed in config.charset.
+ into one of the canonical names listed in localcharset.h.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
@@ -393,9 +687,8 @@ const char *
locale_charset (void)
{
const char *codeset;
- const char *aliases;
-#if !(defined WINDOWS_NATIVE || defined OS2)
+#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
# if HAVE_LANGINFO_CODESET
@@ -458,37 +751,11 @@ locale_charset (void)
}
# endif
-# else
-
- /* On old systems which lack it, use setlocale or getenv. */
- const char *locale = NULL;
-
- /* But most old systems don't have a complete set of locales. Some
- (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't
- use setlocale here; it would return "C" when it doesn't support the
- locale name the user has set. */
-# if 0
- locale = setlocale (LC_CTYPE, NULL);
-# endif
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_ALL");
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_CTYPE");
- if (locale == NULL || locale[0] == '\0')
- locale = getenv ("LANG");
- }
- }
-
- /* On some old systems, one used to set locale = "iso8859_1". On others,
- you set it to "language_COUNTRY.charset". In any case, we resolve it
- through the charset.alias file. */
- codeset = locale;
-
-# endif
+ if (codeset == NULL)
+ /* The canonical name cannot be determined. */
+ codeset = "";
-#elif defined WINDOWS_NATIVE
+# elif defined WINDOWS_NATIVE
static char buf[2 + 10 + 1];
@@ -522,7 +789,7 @@ locale_charset (void)
}
codeset = buf;
-#elif defined OS2
+# elif defined OS2
const char *locale;
static char buf[2 + 10 + 1];
@@ -579,28 +846,144 @@ locale_charset (void)
}
}
-#endif
+# else
- if (codeset == NULL)
- /* The canonical name cannot be determined. */
- codeset = "";
+# error "Add code for other platforms here."
- /* Resolve alias. */
- for (aliases = get_charset_aliases ();
- *aliases != '\0';
- aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
- if (strcmp (codeset, aliases) == 0
- || (aliases[0] == '*' && aliases[1] == '\0'))
+# endif
+
+ /* Resolve alias. */
+ {
+# ifdef alias_table_defined
+ /* On some platforms, UTF-8 locales are the most frequently used ones.
+ Speed up the common case and slow down the less common cases by
+ testing for this case first. */
+# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
+ if (strcmp (codeset, "UTF-8") == 0)
+ goto done_table_lookup;
+ else
+# endif
{
- codeset = aliases + strlen (aliases) + 1;
- break;
+ const struct table_entry * const table = alias_table;
+ size_t const table_size =
+ sizeof (alias_table) / sizeof (struct table_entry);
+ /* The table is sorted. Perform a binary search. */
+ size_t hi = table_size;
+ size_t lo = 0;
+ while (lo < hi)
+ {
+ /* Invariant:
+ for i < lo, strcmp (table[i].alias, codeset) < 0,
+ for i >= hi, strcmp (table[i].alias, codeset) > 0. */
+ size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
+ int cmp = strcmp (table[mid].alias, codeset);
+ if (cmp < 0)
+ lo = mid + 1;
+ else if (cmp > 0)
+ hi = mid;
+ else
+ {
+ /* Found an i with
+ strcmp (table[i].alias, codeset) == 0. */
+ codeset = table[mid].canonical;
+ goto done_table_lookup;
+ }
+ }
}
+ if (0)
+ done_table_lookup: ;
+ else
+# endif
+ {
+ /* Did not find it in the table. */
+ /* On Mac OS X, all modern locales use the UTF-8 encoding.
+ BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
+# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
+ codeset = "UTF-8";
+# else
+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
+ the empty string as denoting "the locale's character encoding",
+ thus GNU libiconv would call this function a second time. */
+ if (codeset[0] == '\0')
+ codeset = "ASCII";
+# endif
+ }
+ }
- /* Don't return an empty string. GNU libc and GNU libiconv interpret
- the empty string as denoting "the locale's character encoding",
- thus GNU libiconv would call this function a second time. */
- if (codeset[0] == '\0')
- codeset = "ASCII";
+#else
+
+ /* On old systems which lack it, use setlocale or getenv. */
+ const char *locale = NULL;
+
+ /* But most old systems don't have a complete set of locales. Some
+ (like DJGPP) have only the C locale. Therefore we don't use setlocale
+ here; it would return "C" when it doesn't support the locale name the
+ user has set. */
+# if 0
+ locale = setlocale (LC_CTYPE, NULL);
+# endif
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ {
+ locale = getenv ("LC_CTYPE");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv ("LANG");
+ if (locale == NULL)
+ locale = "";
+ }
+ }
+
+ /* Map locale name to canonical encoding name. */
+ {
+# ifdef locale_table_defined
+ const struct table_entry * const table = locale_table;
+ size_t const table_size =
+ sizeof (locale_table) / sizeof (struct table_entry);
+ /* The table is sorted. Perform a binary search. */
+ size_t hi = table_size;
+ size_t lo = 0;
+ while (lo < hi)
+ {
+ /* Invariant:
+ for i < lo, strcmp (table[i].locale, locale) < 0,
+ for i >= hi, strcmp (table[i].locale, locale) > 0. */
+ size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
+ int cmp = strcmp (table[mid].locale, locale);
+ if (cmp < 0)
+ lo = mid + 1;
+ else if (cmp > 0)
+ hi = mid;
+ else
+ {
+ /* Found an i with
+ strcmp (table[i].locale, locale) == 0. */
+ codeset = table[mid].canonical;
+ goto done_table_lookup;
+ }
+ }
+ if (0)
+ done_table_lookup: ;
+ else
+# endif
+ {
+ /* Did not find it in the table. */
+ /* On Mac OS X, all modern locales use the UTF-8 encoding.
+ BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
+# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
+ codeset = "UTF-8";
+# else
+ /* The canonical name cannot be determined. */
+ /* Don't return an empty string. GNU libc and GNU libiconv interpret
+ the empty string as denoting "the locale's character encoding",
+ thus GNU libiconv would call this function a second time. */
+ codeset = "ASCII";
+# endif
+ }
+ }
+
+#endif
#ifdef DARWIN7
/* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
diff --git a/libgnu/localcharset.h b/libgnu/localcharset.h
index a2e2a7be..e4ba2960 100644
--- a/libgnu/localcharset.h
+++ b/libgnu/localcharset.h
@@ -1,5 +1,5 @@
/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2000-2003, 2009-2018 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
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H
@@ -25,12 +25,106 @@ extern "C" {
/* Determine the current locale's character encoding, and canonicalize it
- into one of the canonical names listed in config.charset.
+ into one of the canonical names listed below.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
extern const char * locale_charset (void);
+/* About GNU canonical names for character encodings:
+
+ Every canonical name must be supported by GNU libiconv. Support by GNU libc
+ is also desirable.
+
+ The name is case insensitive. Usually an upper case MIME charset name is
+ preferred.
+
+ The current list of these GNU canonical names is:
+
+ name MIME? used by which systems
+ (darwin = Mac OS X, windows = native Windows)
+
+ ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
+ ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-3 Y glibc solaris cygwin
+ ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
+ ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-6 Y glibc aix hpux solaris cygwin
+ ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-8 Y glibc aix hpux osf solaris cygwin
+ ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin
+ ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
+ ISO-8859-14 glibc cygwin
+ ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
+ KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
+ KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
+ KOI8-T glibc
+ CP437 dos
+ CP775 dos
+ CP850 aix osf dos
+ CP852 dos
+ CP855 dos
+ CP856 aix
+ CP857 dos
+ CP861 dos
+ CP862 dos
+ CP864 dos
+ CP865 dos
+ CP866 freebsd netbsd openbsd darwin dos
+ CP869 dos
+ CP874 windows dos
+ CP922 aix
+ CP932 aix cygwin windows dos
+ CP943 aix
+ CP949 osf darwin windows dos
+ CP950 windows dos
+ CP1046 aix
+ CP1124 aix
+ CP1125 dos
+ CP1129 aix
+ CP1131 freebsd darwin
+ CP1250 windows
+ CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
+ CP1252 aix windows
+ CP1253 windows
+ CP1254 windows
+ CP1255 glibc windows
+ CP1256 windows
+ CP1257 windows
+ GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin
+ EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+ EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
+ EUC-TW glibc aix hpux irix osf solaris netbsd
+ BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
+ BIG5-HKSCS glibc hpux solaris netbsd darwin
+ GBK glibc aix osf solaris freebsd darwin cygwin windows dos
+ GB18030 glibc hpux solaris freebsd netbsd darwin
+ SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
+ JOHAB glibc solaris windows
+ TIS-620 glibc aix hpux osf solaris cygwin
+ VISCII Y glibc
+ TCVN5712-1 glibc
+ ARMSCII-8 glibc freebsd netbsd darwin
+ GEORGIAN-PS glibc cygwin
+ PT154 glibc netbsd cygwin
+ HP-ROMAN8 hpux
+ HP-ARABIC8 hpux
+ HP-GREEK8 hpux
+ HP-HEBREW8 hpux
+ HP-TURKISH8 hpux
+ HP-KANA8 hpux
+ DEC-KANJI osf
+ DEC-HANYU osf
+ UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
+
+ Note: Names which are not marked as being a MIME name should not be used in
+ Internet protocols for information interchange (mail, news, etc.).
+
+ Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
+ must understand both names and treat them as equivalent.
+ */
+
#ifdef __cplusplus
}
diff --git a/libgnu/lseek.c b/libgnu/lseek.c
index 3b2fdf2e..9125b980 100644
--- a/libgnu/lseek.c
+++ b/libgnu/lseek.c
@@ -1,5 +1,5 @@
/* An lseek() function that detects pipes.
- Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,19 +12,23 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* Windows platforms. */
/* Get GetFileType. */
# include <windows.h>
/* Get _get_osfhandle. */
-# include "msvc-nothrow.h"
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
#else
# include <sys/stat.h>
#endif
@@ -35,7 +39,7 @@
off_t
rpl_lseek (int fd, off_t offset, int whence)
{
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
HANDLE h = (HANDLE) _get_osfhandle (fd);
if (h == INVALID_HANDLE_VALUE)
diff --git a/libgnu/lstat.c b/libgnu/lstat.c
index f4dc43ec..5873bbd6 100644
--- a/libgnu/lstat.c
+++ b/libgnu/lstat.c
@@ -1,6 +1,6 @@
/* Work around a bug of lstat on some systems
- Copyright (C) 1997-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
@@ -47,6 +47,8 @@ orig_lstat (const char *filename, struct stat *buf)
above. */
# include "sys/stat.h"
+# include "stat-time.h"
+
# include <string.h>
# include <errno.h>
@@ -66,32 +68,33 @@ orig_lstat (const char *filename, struct stat *buf)
int
rpl_lstat (const char *file, struct stat *sbuf)
{
- size_t len;
- int lstat_result = orig_lstat (file, sbuf);
-
- if (lstat_result != 0)
- return lstat_result;
+ 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. */
- len = strlen (file);
- if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode))
- return 0;
-
- /* At this point, a trailing slash is only permitted on
- symlink-to-dir; but it should have found information on the
- directory, not the symlink. Call stat() to get info about the
- link's referent. Our replacement stat guarantees valid results,
- even if the symlink is not pointing to a directory. */
- if (!S_ISLNK (sbuf->st_mode))
+ if (result == 0)
{
- errno = ENOTDIR;
- return -1;
+ 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 stat (file, sbuf);
+ return result;
}
#endif /* HAVE_LSTAT */
diff --git a/libgnu/malloc.c b/libgnu/malloc.c
index eeaf12ba..471c3abb 100644
--- a/libgnu/malloc.c
+++ b/libgnu/malloc.c
@@ -1,6 +1,6 @@
/* malloc() function that is glibc compatible.
- Copyright (C) 1997-1998, 2006-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-1998, 2006-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering and Bruno Haible */
diff --git a/libgnu/malloca.c b/libgnu/malloca.c
new file mode 100644
index 00000000..c54e1e0f
--- /dev/null
+++ b/libgnu/malloca.c
@@ -0,0 +1,105 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003, 2006-2007, 2009-2018 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+#define _GL_USE_STDLIB_ALLOC 1
+#include <config.h>
+
+/* Specification. */
+#include "malloca.h"
+
+#include "verify.h"
+
+/* The speed critical point in this file is freea() applied to an alloca()
+ result: it must be fast, to match the speed of alloca(). The speed of
+ mmalloca() and freea() in the other case are not critical, because they
+ are only invoked for big memory sizes.
+ Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
+ malloca() can return three types of pointers:
+ - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
+ - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
+ allocation.
+ - NULL comes from a failed heap allocation. */
+
+/* Type for holding very small pointer differences. */
+typedef unsigned char small_t;
+/* Verify that it is wide enough. */
+verify (2 * sa_alignment_max - 1 <= (small_t) -1);
+
+void *
+mmalloca (size_t n)
+{
+#if HAVE_ALLOCA
+ /* Allocate one more word, used to determine the address to pass to freea(),
+ and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
+ size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1;
+
+ if (nplus >= n)
+ {
+ char *mem = (char *) malloc (nplus);
+
+ if (mem != NULL)
+ {
+ char *p =
+ (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1)
+ & ~(uintptr_t)(2 * sa_alignment_max - 1))
+ + sa_alignment_max);
+ /* Here p >= mem + sizeof (small_t),
+ and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
+ hence p + n <= mem + nplus.
+ So, the memory range [p, p+n) lies in the allocated memory range
+ [mem, mem + nplus). */
+ ((small_t *) p)[-1] = p - mem;
+ /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
+ return p;
+ }
+ }
+ /* Out of memory. */
+ return NULL;
+#else
+# if !MALLOC_0_IS_NONNULL
+ if (n == 0)
+ n = 1;
+# endif
+ return malloc (n);
+#endif
+}
+
+#if HAVE_ALLOCA
+void
+freea (void *p)
+{
+ /* Check argument. */
+ if ((uintptr_t) p & (sa_alignment_max - 1))
+ {
+ /* p was not the result of a malloca() call. Invalid argument. */
+ abort ();
+ }
+ /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
+ if ((uintptr_t) p & sa_alignment_max)
+ {
+ void *mem = (char *) p - ((small_t *) p)[-1];
+ free (mem);
+ }
+}
+#endif
+
+/*
+ * Hey Emacs!
+ * Local Variables:
+ * coding: utf-8
+ * End:
+ */
diff --git a/libgnu/malloca.h b/libgnu/malloca.h
new file mode 100644
index 00000000..1e47813f
--- /dev/null
+++ b/libgnu/malloca.h
@@ -0,0 +1,127 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
+ Written by Bruno Haible <bruno@clisp.org>, 2003.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _MALLOCA_H
+#define _MALLOCA_H
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+#include "xalloc-oversized.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
+ alloca(N); otherwise it returns NULL. It either returns N bytes of
+ memory allocated on the stack, that lasts until the function returns,
+ or NULL.
+ Use of safe_alloca should be avoided:
+ - inside arguments of function calls - undefined behaviour,
+ - in inline functions - the allocation may actually last until the
+ calling function returns.
+*/
+#if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ allocate anything larger than 4096 bytes. Also care for the possibility
+ of a few compiler-allocated temporary stack slots.
+ This must be a macro, not a function. */
+# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
+#else
+# define safe_alloca(N) ((void) (N), NULL)
+#endif
+
+/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
+ memory allocated on the stack, that must be freed using freea() before
+ the function returns. Upon failure, it returns NULL. */
+#if HAVE_ALLOCA
+# define malloca(N) \
+ ((N) < 4032 - (2 * sa_alignment_max - 1) \
+ ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
+ + (2 * sa_alignment_max - 1)) \
+ & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
+ : mmalloca (N))
+#else
+# define malloca(N) \
+ mmalloca (N)
+#endif
+extern void * mmalloca (size_t n);
+
+/* Free a block of memory allocated through malloca(). */
+#if HAVE_ALLOCA
+extern void freea (void *p);
+#else
+# define freea free
+#endif
+
+/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
+ It allocates an array of N objects, each with S bytes of memory,
+ on the stack. S must be positive and N must be nonnegative.
+ The array must be freed using freea() before the function returns. */
+#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s)))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* ------------------- Auxiliary, non-public definitions ------------------- */
+
+/* Determine the alignment of a type at compile time. */
+#if defined __GNUC__ || defined __IBM__ALIGNOF__
+# define sa_alignof __alignof__
+#elif defined __cplusplus
+ template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
+# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2)
+#elif defined __hpux
+ /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#elif defined _AIX
+ /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#else
+# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+enum
+{
+/* The desired alignment of memory allocations is the maximum alignment
+ among all elementary types. */
+ sa_alignment_long = sa_alignof (long),
+ sa_alignment_double = sa_alignof (double),
+#if HAVE_LONG_LONG_INT
+ sa_alignment_longlong = sa_alignof (long long),
+#endif
+ sa_alignment_longdouble = sa_alignof (long double),
+ sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
+#if HAVE_LONG_LONG_INT
+ | (sa_alignment_longlong - 1)
+#endif
+ | (sa_alignment_longdouble - 1)
+ ) + 1
+};
+
+#endif /* _MALLOCA_H */
diff --git a/libgnu/mbrtowc.c b/libgnu/mbrtowc.c
index d4809f6b..2f6df287 100644
--- a/libgnu/mbrtowc.c
+++ b/libgnu/mbrtowc.c
@@ -1,5 +1,5 @@
/* Convert multibyte character to wide character.
- Copyright (C) 1999-2002, 2005-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999-2002, 2005-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -35,6 +35,61 @@
# include "streq.h"
# include "verify.h"
+# ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+# endif
+
+/* Returns a classification of special values of the encoding of the current
+ locale. */
+typedef enum {
+ enc_other, /* other */
+ enc_utf8, /* UTF-8 */
+ enc_eucjp, /* EUC-JP */
+ enc_94, /* EUC-KR, GB2312, BIG5 */
+ enc_euctw, /* EUC-TW */
+ enc_gb18030, /* GB18030 */
+ enc_sjis /* SJIS */
+} enc_t;
+static inline enc_t
+locale_enc (void)
+{
+ const char *encoding = locale_charset ();
+ if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+ return enc_utf8;
+ if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+ return enc_eucjp;
+ if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+ || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+ || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+ return enc_94;
+ if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+ return enc_euctw;
+ if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+ return enc_gb18030;
+ if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+ return enc_sjis;
+ return enc_other;
+}
+
+#if GNULIB_WCHAR_SINGLE
+/* When we know that the locale does not change, provide a speedup by
+ caching the value of locale_enc. */
+static int cached_locale_enc = -1;
+static inline enc_t
+locale_enc_cached (void)
+{
+ if (cached_locale_enc < 0)
+ cached_locale_enc = locale_enc ();
+ return cached_locale_enc;
+}
+#else
+/* By default, don't make assumptions, hence no caching. */
+# define locale_enc_cached locale_enc
+#endif
verify (sizeof (mbstate_t) >= 4);
@@ -74,10 +129,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
break;
case 3:
buf[2] = pstate[3];
- /*FALLTHROUGH*/
+ FALLTHROUGH;
case 2:
buf[1] = pstate[2];
- /*FALLTHROUGH*/
+ FALLTHROUGH;
case 1:
buf[0] = pstate[1];
p = buf;
@@ -98,7 +153,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
/* Here m > 0. */
# if __GLIBC__ || defined __UCLIBC__
- /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
+ /* Work around bug <https://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
mbtowc (NULL, NULL, 0);
# endif
{
@@ -130,10 +185,9 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
if (m >= 4 || m >= MB_CUR_MAX)
goto invalid;
/* Here MB_CUR_MAX > 1 and 0 < m < 4. */
- {
- const char *encoding = locale_charset ();
-
- if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+ switch (locale_enc_cached ())
+ {
+ case enc_utf8: /* UTF-8 */
{
/* Cf. unistr/u8-mblen.c. */
unsigned char c = (unsigned char) p[0];
@@ -190,8 +244,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
/* As a reference for this code, you can use the GNU libiconv
implementation. Look for uses of the RET_TOOFEW macro. */
- if (STREQ_OPT (encoding,
- "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+ case enc_eucjp: /* EUC-JP */
{
if (m == 1)
{
@@ -214,12 +267,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
- if (STREQ_OPT (encoding,
- "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
- || STREQ_OPT (encoding,
- "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
- || STREQ_OPT (encoding,
- "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+
+ case enc_94: /* EUC-KR, GB2312, BIG5 */
{
if (m == 1)
{
@@ -230,8 +279,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
- if (STREQ_OPT (encoding,
- "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+
+ case enc_euctw: /* EUC-TW */
{
if (m == 1)
{
@@ -249,8 +298,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
- if (STREQ_OPT (encoding,
- "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+
+ case enc_gb18030: /* GB18030 */
{
if (m == 1)
{
@@ -283,7 +332,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
}
goto invalid;
}
- if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+
+ case enc_sjis: /* SJIS */
{
if (m == 1)
{
@@ -296,9 +346,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
goto invalid;
}
- /* An unknown multibyte encoding. */
- goto incomplete;
- }
+ default:
+ /* An unknown multibyte encoding. */
+ goto incomplete;
+ }
incomplete:
{
diff --git a/libgnu/mbsinit.c b/libgnu/mbsinit.c
index 58e0441a..e23a5ad3 100644
--- a/libgnu/mbsinit.c
+++ b/libgnu/mbsinit.c
@@ -1,5 +1,5 @@
/* Test for initial conversion state.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -22,17 +22,7 @@
#include "verify.h"
-#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-
-/* On native Windows, 'mbstate_t' is defined as 'int'. */
-
-int
-mbsinit (const mbstate_t *ps)
-{
- return ps == NULL || *ps == 0;
-}
-
-#else
+#if GNULIB_defined_mbstate_t
/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
and wcrtomb(), wcsrtombs().
@@ -45,6 +35,7 @@ mbsinit (const mbstate_t *ps)
We define the meaning of mbstate_t as follows:
- In mb -> wc direction, mbstate_t's first byte contains the number of
buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
+ See mbrtowc.c.
- In wc -> mb direction, mbstate_t contains no information. In other
words, it is always in the initial state. */
@@ -58,4 +49,25 @@ mbsinit (const mbstate_t *ps)
return pstate == NULL || pstate[0] == 0;
}
+#else
+
+int
+mbsinit (const mbstate_t *ps)
+{
+# if defined _WIN32 && !defined __CYGWIN__
+ /* Native Windows. */
+# ifdef __MINGW32__
+ /* On mingw, 'mbstate_t' is defined as 'int'. */
+ return ps == NULL || *ps == 0;
+# else
+ /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4-bytes matter. */
+ return ps == NULL || *(const unsigned int *)ps == 0;
+# endif
+# else
+ /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */
+ /* Maybe this definition works, maybe not... */
+ return ps == NULL || *(const char *)ps == 0;
+# endif
+}
+
#endif
diff --git a/libgnu/mbsrtowcs-impl.h b/libgnu/mbsrtowcs-impl.h
index d787c07e..2588a888 100644
--- a/libgnu/mbsrtowcs-impl.h
+++ b/libgnu/mbsrtowcs-impl.h
@@ -1,5 +1,5 @@
/* Convert string to wide string.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
size_t
mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
diff --git a/libgnu/mbsrtowcs-state.c b/libgnu/mbsrtowcs-state.c
index 4c213e45..2ab2618b 100644
--- a/libgnu/mbsrtowcs-state.c
+++ b/libgnu/mbsrtowcs-state.c
@@ -1,5 +1,5 @@
/* Convert string to wide string.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -23,7 +23,7 @@
mbstate_t _gl_mbsrtowcs_state
/* The state must initially be in the "initial state"; so, zero-initialize it.
On most systems, putting it into BSS is sufficient. Not so on Mac OS X 10.3,
- see <http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>.
+ see <https://lists.gnu.org/r/bug-gnulib/2009-01/msg00329.html>.
When it needs an initializer, use 0 or {0} as initializer? 0 only works
when mbstate_t is a scalar type (such as when gnulib defines it, or on
AIX, IRIX, mingw). {0} works as an initializer in all cases: for a struct
diff --git a/libgnu/mbsrtowcs.c b/libgnu/mbsrtowcs.c
index 7896e948..1da1ce5a 100644
--- a/libgnu/mbsrtowcs.c
+++ b/libgnu/mbsrtowcs.c
@@ -1,5 +1,5 @@
/* Convert string to wide string.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/memchr.c b/libgnu/memchr.c
index 34812609..0b475465 100644
--- a/libgnu/memchr.c
+++ b/libgnu/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2017
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2018
Free Software Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -21,7 +21,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>. */
+along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
diff --git a/libgnu/mempcpy.c b/libgnu/mempcpy.c
index e9a0678a..a9ed1121 100644
--- a/libgnu/mempcpy.c
+++ b/libgnu/mempcpy.c
@@ -1,5 +1,5 @@
/* Copy memory area and return pointer after last written byte.
- Copyright (C) 2003, 2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/memrchr.c b/libgnu/memrchr.c
index fefe16cc..99acfd9c 100644
--- a/libgnu/memrchr.c
+++ b/libgnu/memrchr.c
@@ -1,6 +1,6 @@
/* memrchr -- find the last occurrence of a byte in a memory block
- Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2017 Free Software
+ Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2018 Free Software
Foundation, Inc.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -20,7 +20,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if defined _LIBC
# include <memcopy.h>
diff --git a/libgnu/msvc-inval.c b/libgnu/msvc-inval.c
index 7139e93f..0f19a09a 100644
--- a/libgnu/msvc-inval.c
+++ b/libgnu/msvc-inval.c
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/msvc-inval.h b/libgnu/msvc-inval.h
index 6e216d64..8e7ff303 100644
--- a/libgnu/msvc-inval.h
+++ b/libgnu/msvc-inval.h
@@ -1,5 +1,5 @@
/* Invalid parameter handler for MSVC runtime libraries.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _MSVC_INVAL_H
#define _MSVC_INVAL_H
@@ -95,7 +95,7 @@ extern void gl_msvc_inval_ensure_handler (void);
/* Gnulib can define its own status codes, as described in the page
"Raising Software Exceptions" on microsoft.com
- <http://msdn.microsoft.com/en-us/library/het71c37.aspx>.
+ <https://msdn.microsoft.com/en-us/library/het71c37.aspx>.
Our status codes are composed of
- 0xE0000000, mandatory for all user-defined status codes,
- 0x474E550, a API identifier ("GNU"),
@@ -106,7 +106,7 @@ extern void gl_msvc_inval_ensure_handler (void);
# if defined _MSC_VER
/* A compiler that supports __try/__except, as described in the page
"try-except statement" on microsoft.com
- <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>.
+ <https://msdn.microsoft.com/en-us/library/s58ftw19.aspx>.
With __try/__except, we can use the multithread-safe exception handling. */
# ifdef __cplusplus
diff --git a/libgnu/msvc-nothrow.c b/libgnu/msvc-nothrow.c
index d127eb47..785733e4 100644
--- a/libgnu/msvc-nothrow.c
+++ b/libgnu/msvc-nothrow.c
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -24,7 +24,9 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include "msvc-inval.h"
+#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+#endif
#undef _get_osfhandle
diff --git a/libgnu/msvc-nothrow.h b/libgnu/msvc-nothrow.h
index c70efc79..a9671c3b 100644
--- a/libgnu/msvc-nothrow.h
+++ b/libgnu/msvc-nothrow.h
@@ -1,6 +1,6 @@
/* Wrappers that don't throw invalid parameter notifications
with MSVC runtime libraries.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _MSVC_NOTHROW_H
#define _MSVC_NOTHROW_H
@@ -25,7 +25,7 @@
This file defines wrappers that turn such an invalid parameter notification
into an error code. */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* Get original declaration of _get_osfhandle. */
# include <io.h>
diff --git a/libgnu/obstack.c b/libgnu/obstack.c
index 54b675d4..02be6cf9 100644
--- a/libgnu/obstack.c
+++ b/libgnu/obstack.c
@@ -1,5 +1,5 @@
/* obstack.c - subroutines used implicitly by object stack macros
- Copyright (C) 1988-2017 Free Software Foundation, Inc.
+ Copyright (C) 1988-2018 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
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#ifdef _LIBC
diff --git a/libgnu/obstack.h b/libgnu/obstack.h
index dd29019a..2a11e731 100644
--- a/libgnu/obstack.h
+++ b/libgnu/obstack.h
@@ -1,5 +1,5 @@
/* obstack.h - object stack macros
- Copyright (C) 1988-2017 Free Software Foundation, Inc.
+ Copyright (C) 1988-2018 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
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
/* Summary:
diff --git a/libgnu/obstack_printf.c b/libgnu/obstack_printf.c
index 85a0a059..4504e03c 100644
--- a/libgnu/obstack_printf.c
+++ b/libgnu/obstack_printf.c
@@ -1,5 +1,5 @@
/* Formatted output to obstacks.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/open-safer.c b/libgnu/open-safer.c
index 9ac06a8c..711806c8 100644
--- a/libgnu/open-safer.c
+++ b/libgnu/open-safer.c
@@ -1,6 +1,6 @@
/* Invoke open, but avoid some glitches.
- Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/open.c b/libgnu/open.c
index 193dc45f..792e258b 100644
--- a/libgnu/open.c
+++ b/libgnu/open.c
@@ -1,5 +1,5 @@
/* Open a descriptor to a file.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
@@ -38,6 +38,8 @@ orig_open (const char *filename, int flags, mode_t mode)
this include because of the preliminary #include <fcntl.h> above. */
#include "fcntl.h"
+#include "cloexec.h"
+
#include <errno.h>
#include <stdarg.h>
#include <string.h>
@@ -52,6 +54,13 @@ orig_open (const char *filename, int flags, mode_t mode)
int
open (const char *filename, int flags, ...)
{
+ /* 0 = unknown, 1 = yes, -1 = no. */
+#if GNULIB_defined_O_CLOEXEC
+ int have_cloexec = -1;
+#else
+ static int have_cloexec;
+#endif
+
mode_t mode;
int fd;
@@ -77,7 +86,7 @@ open (const char *filename, int flags, ...)
flags &= ~O_NONBLOCK;
#endif
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
if (strcmp (filename, "/dev/null") == 0)
filename = "NUL";
#endif
@@ -115,7 +124,25 @@ open (const char *filename, int flags, ...)
}
#endif
- fd = orig_open (filename, flags, mode);
+ fd = orig_open (filename,
+ flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode);
+
+ if (flags & O_CLOEXEC)
+ {
+ if (! have_cloexec)
+ {
+ if (0 <= fd)
+ have_cloexec = 1;
+ else if (errno == EINVAL)
+ {
+ fd = orig_open (filename, flags & ~O_CLOEXEC, mode);
+ have_cloexec = -1;
+ }
+ }
+ if (have_cloexec < 0 && 0 <= fd)
+ set_cloexec_flag (fd, true);
+ }
+
#if REPLACE_FCHDIR
/* Implementing fchdir and fdopendir requires the ability to open a
diff --git a/libgnu/openat-die.c b/libgnu/openat-die.c
index 20d970af..26df87af 100644
--- a/libgnu/openat-die.c
+++ b/libgnu/openat-die.c
@@ -1,6 +1,6 @@
/* Report a save- or restore-cwd failure in our openat replacement and then exit.
- Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/openat-priv.h b/libgnu/openat-priv.h
index 2598719e..5d53df12 100644
--- a/libgnu/openat-priv.h
+++ b/libgnu/openat-priv.h
@@ -1,6 +1,6 @@
/* Internals for openat-like functions.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/openat-proc.c b/libgnu/openat-proc.c
index 101449bb..87137eec 100644
--- a/libgnu/openat-proc.c
+++ b/libgnu/openat-proc.c
@@ -1,6 +1,6 @@
/* Create /proc/self/fd-related names for subfiles of open directories.
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/openat-safer.c b/libgnu/openat-safer.c
index c5dc4554..7490d1e2 100644
--- a/libgnu/openat-safer.c
+++ b/libgnu/openat-safer.c
@@ -1,6 +1,6 @@
/* Invoke openat, but avoid some glitches.
- Copyright (C) 2005-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert for open, ported by Eric Blake for openat. */
diff --git a/libgnu/openat.c b/libgnu/openat.c
index e739b714..341c5113 100644
--- a/libgnu/openat.c
+++ b/libgnu/openat.c
@@ -1,5 +1,5 @@
/* provide a replacement openat function
- Copyright (C) 2004-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
@@ -41,6 +41,8 @@ orig_openat (int fd, char const *filename, int flags, mode_t mode)
#include "openat.h"
+#include "cloexec.h"
+
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
@@ -50,10 +52,18 @@ orig_openat (int fd, char const *filename, int flags, mode_t mode)
#if HAVE_OPENAT
-/* Like openat, but work around Solaris 9 bugs with trailing slash. */
+/* Like openat, but support O_CLOEXEC and work around Solaris 9 bugs
+ with trailing slash. */
int
rpl_openat (int dfd, char const *filename, int flags, ...)
{
+ /* 0 = unknown, 1 = yes, -1 = no. */
+#if GNULIB_defined_O_CLOEXEC
+ int have_cloexec = -1;
+#else
+ static int have_cloexec;
+#endif
+
mode_t mode;
int fd;
@@ -103,7 +113,25 @@ rpl_openat (int dfd, char const *filename, int flags, ...)
}
# endif
- fd = orig_openat (dfd, filename, flags, mode);
+ fd = orig_openat (dfd, filename,
+ flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode);
+
+ if (flags & O_CLOEXEC)
+ {
+ if (! have_cloexec)
+ {
+ if (0 <= fd)
+ have_cloexec = 1;
+ else if (errno == EINVAL)
+ {
+ fd = orig_openat (dfd, filename, flags & ~O_CLOEXEC, mode);
+ have_cloexec = -1;
+ }
+ }
+ if (have_cloexec < 0 && 0 <= fd)
+ set_cloexec_flag (fd, true);
+ }
+
# if OPEN_TRAILING_SLASH_BUG
/* If the filename ends in a slash and fd does not refer to a directory,
@@ -146,7 +174,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...)
# include "save-cwd.h"
/* Replacement for Solaris' openat function.
- <http://www.google.com/search?q=openat+site:docs.sun.com>
+ <https://www.google.com/search?q=openat+site:docs.oracle.com>
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),
diff --git a/libgnu/openat.h b/libgnu/openat.h
index a036081e..945e0328 100644
--- a/libgnu/openat.h
+++ b/libgnu/openat.h
@@ -1,5 +1,5 @@
/* provide a replacement openat function
- Copyright (C) 2004-2006, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004-2006, 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
diff --git a/libgnu/opendir-safer.c b/libgnu/opendir-safer.c
deleted file mode 100644
index b05ff549..00000000
--- a/libgnu/opendir-safer.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Invoke opendir, but avoid some glitches.
-
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Eric Blake. */
-
-#include <config.h>
-
-#include "dirent-safer.h"
-
-#include <errno.h>
-#include <unistd.h>
-#include "unistd-safer.h"
-
-/* Like opendir, but do not clobber stdin, stdout, or stderr. */
-
-DIR *
-opendir_safer (char const *name)
-{
- DIR *dp = opendir (name);
-
- if (dp)
- {
- int fd = dirfd (dp);
-
- if (0 <= fd && fd <= STDERR_FILENO)
- {
- /* If fdopendir is native (as on Linux), then it is safe to
- assume dirfd(fdopendir(n))==n. If we are using the
- gnulib module fdopendir, then this guarantee is not met,
- but fdopendir recursively calls opendir_safer up to 3
- times to at least get a safe fd. If fdopendir is not
- present but dirfd is accurate (as on cygwin 1.5.x), then
- we recurse up to 3 times ourselves. Finally, if dirfd
- always fails (as on mingw), then we are already safe. */
- DIR *newdp;
- int e;
-#if HAVE_FDOPENDIR || GNULIB_FDOPENDIR
- int f = dup_safer (fd);
- if (f < 0)
- {
- e = errno;
- newdp = NULL;
- }
- else
- {
- newdp = fdopendir (f);
- e = errno;
- if (! newdp)
- close (f);
- }
-#else /* !FDOPENDIR */
- newdp = opendir_safer (name);
- e = errno;
-#endif
- closedir (dp);
- errno = e;
- dp = newdp;
- }
- }
-
- return dp;
-}
diff --git a/libgnu/opendir.c b/libgnu/opendir.c
index 694a7828..b77f5404 100644
--- a/libgnu/opendir.c
+++ b/libgnu/opendir.c
@@ -1,5 +1,5 @@
/* Start reading the entries of a directory.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/pathmax.h b/libgnu/pathmax.h
index aa0730e2..7052e6a8 100644
--- a/libgnu/pathmax.h
+++ b/libgnu/pathmax.h
@@ -1,5 +1,5 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
- Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2017 Free Software
+ Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _PATHMAX_H
# define _PATHMAX_H
@@ -65,10 +65,10 @@
# define PATH_MAX 1024
# endif
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
section "Maximum Path Length Limitation",
- <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
+ <https://msdn.microsoft.com/en-us/library/aa365247.aspx#maxpath>
explains that the maximum size of a filename, including the terminating
NUL byte, is 260 = 3 + 256 + 1.
This is the same value as
diff --git a/libgnu/pipe-safer.c b/libgnu/pipe-safer.c
index d24a1ebd..1669d909 100644
--- a/libgnu/pipe-safer.c
+++ b/libgnu/pipe-safer.c
@@ -1,5 +1,5 @@
/* Invoke pipe, but avoid some glitches.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/pread.c b/libgnu/pread.c
index 42b9b53f..61aaa3b1 100644
--- a/libgnu/pread.c
+++ b/libgnu/pread.c
@@ -1,5 +1,5 @@
/* replacement pread function
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/printf-args.c b/libgnu/printf-args.c
index fec7e621..1079e0a9 100644
--- a/libgnu/printf-args.c
+++ b/libgnu/printf-args.c
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2017 Free Software
+ Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
/* This file can be parametrized with the following macros:
ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
diff --git a/libgnu/printf-args.h b/libgnu/printf-args.h
index 36cab2af..111e8a56 100644
--- a/libgnu/printf-args.h
+++ b/libgnu/printf-args.h
@@ -1,5 +1,5 @@
/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2017 Free Software
+ Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
diff --git a/libgnu/printf-parse.c b/libgnu/printf-parse.c
index b9e04aef..e6251458 100644
--- a/libgnu/printf-parse.c
+++ b/libgnu/printf-parse.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003, 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999-2000, 2002-2003, 2006-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
/* This file can be parametrized with the following macros:
CHAR_T The element type of the format string.
@@ -419,7 +419,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
cp++;
}
#endif
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
/* On native Windows, PRIdMAX is defined as "I64d".
We cannot change it to "lld" because PRIdMAX must also
be understood by the system's printf routines. */
diff --git a/libgnu/printf-parse.h b/libgnu/printf-parse.h
index b9bfa85b..16d817ec 100644
--- a/libgnu/printf-parse.h
+++ b/libgnu/printf-parse.h
@@ -1,5 +1,5 @@
/* Parse printf format string.
- Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2017 Free Software
+ Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _PRINTF_PARSE_H
#define _PRINTF_PARSE_H
diff --git a/libgnu/pwrite.c b/libgnu/pwrite.c
index d12bfe19..30e94915 100644
--- a/libgnu/pwrite.c
+++ b/libgnu/pwrite.c
@@ -1,6 +1,6 @@
/* Write block to given position in file without changing file pointer.
POSIX version.
- Copyright (C) 1997-1999, 2002, 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 1997-1999, 2002, 2011-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/qsort.c b/libgnu/qsort.c
index 8cfe67f9..5d70e471 100644
--- a/libgnu/qsort.c
+++ b/libgnu/qsort.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Douglas C. Schmidt (schmidt@ics.uci.edu).
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
/* If you consider tuning this algorithm, you should consult first:
Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
diff --git a/libgnu/qsort_r.c b/libgnu/qsort_r.c
index 43129760..4386dee5 100644
--- a/libgnu/qsort_r.c
+++ b/libgnu/qsort_r.c
@@ -1,6 +1,6 @@
/* Reentrant sort function.
- Copyright 2014-2017 Free Software Foundation, Inc.
+ Copyright 2014-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/raise.c b/libgnu/raise.c
index d3325a63..3a29339a 100644
--- a/libgnu/raise.c
+++ b/libgnu/raise.c
@@ -1,6 +1,6 @@
/* Provide a non-threads replacement for the POSIX raise function.
- Copyright (C) 2002-2003, 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering and Bruno Haible */
@@ -27,7 +27,9 @@
# include <errno.h>
-# include "msvc-inval.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
# undef raise
diff --git a/libgnu/rawmemchr.c b/libgnu/rawmemchr.c
index bba95b62..912bfeb3 100644
--- a/libgnu/rawmemchr.c
+++ b/libgnu/rawmemchr.c
@@ -1,5 +1,5 @@
/* Searching in a string.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/read.c b/libgnu/read.c
index 08108f7f..17d9d745 100644
--- a/libgnu/read.c
+++ b/libgnu/read.c
@@ -1,5 +1,5 @@
/* POSIX compatible read() function.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2011.
This program is free software: you can redistribute it and/or modify
@@ -13,14 +13,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#include <unistd.h>
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
# include <errno.h>
# include <io.h>
@@ -28,8 +28,14 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-inval.h"
-# include "msvc-nothrow.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# undef read
diff --git a/libgnu/readdir.c b/libgnu/readdir.c
index d1773afe..c1c564d2 100644
--- a/libgnu/readdir.c
+++ b/libgnu/readdir.c
@@ -1,5 +1,5 @@
/* Read the next entry of a directory.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/readlink.c b/libgnu/readlink.c
index bf0cedc5..924e00d2 100644
--- a/libgnu/readlink.c
+++ b/libgnu/readlink.c
@@ -1,5 +1,5 @@
/* Stub for readlink().
- Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/realloc.c b/libgnu/realloc.c
index 526b4879..7620b6a9 100644
--- a/libgnu/realloc.c
+++ b/libgnu/realloc.c
@@ -1,6 +1,6 @@
/* realloc() function that is glibc compatible.
- Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2017 Free Software
+ Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* written by Jim Meyering and Bruno Haible */
diff --git a/libgnu/ref-add.sin b/libgnu/ref-add.sin
deleted file mode 100644
index 3913e997..00000000
--- a/libgnu/ref-add.sin
+++ /dev/null
@@ -1,29 +0,0 @@
-# Add this package to a list of references stored in a text file.
-#
-# Copyright (C) 2000, 2009-2017 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
- s/# Packages using this file://
- ta
- :a
- s/ @PACKAGE@ / @PACKAGE@ /
- tb
- s/ $/ @PACKAGE@ /
- :b
- s/^/# Packages using this file:/
-}
diff --git a/libgnu/ref-del.sin b/libgnu/ref-del.sin
deleted file mode 100644
index eeff9474..00000000
--- a/libgnu/ref-del.sin
+++ /dev/null
@@ -1,24 +0,0 @@
-# Remove this package from a list of references stored in a text file.
-#
-# Copyright (C) 2000, 2009-2017 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, see <http://www.gnu.org/licenses/>.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
- s/# Packages using this file://
- s/ @PACKAGE@ / /
- s/^/# Packages using this file:/
-}
diff --git a/libgnu/rewinddir.c b/libgnu/rewinddir.c
deleted file mode 100644
index b144c5a7..00000000
--- a/libgnu/rewinddir.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Restart reading the entries of a directory from the beginning.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <dirent.h>
-
-#include <errno.h>
-
-#include "dirent-private.h"
-
-void
-rewinddir (DIR *dirp)
-{
- /* Like in closedir(). */
- if (dirp->current != INVALID_HANDLE_VALUE)
- FindClose (dirp->current);
-
- /* Like in opendir(). */
- dirp->status = -1;
- dirp->current = FindFirstFile (dirp->dir_name_mask, &dirp->entry);
- if (dirp->current == INVALID_HANDLE_VALUE)
- {
- switch (GetLastError ())
- {
- case ERROR_FILE_NOT_FOUND:
- dirp->status = -2;
- break;
- default:
- /* Save the error code for the next readdir() call. */
- dirp->status = ENOENT;
- break;
- }
- }
-}
diff --git a/libgnu/same-inode.h b/libgnu/same-inode.h
index 7cece6dd..68377954 100644
--- a/libgnu/same-inode.h
+++ b/libgnu/same-inode.h
@@ -1,6 +1,6 @@
/* Determine whether two stat buffers are known to refer to the same file.
- Copyright (C) 2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,21 +13,31 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef SAME_INODE_H
# define SAME_INODE_H 1
-# ifdef __VMS
+# include <sys/types.h>
+
+# if defined __VMS && __CRTL_VER < 80200000
# define SAME_INODE(a, b) \
((a).st_ino[0] == (b).st_ino[0] \
&& (a).st_ino[1] == (b).st_ino[1] \
&& (a).st_ino[2] == (b).st_ino[2] \
&& (a).st_dev == (b).st_dev)
-# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* On MinGW, struct stat lacks necessary info, so always return 0.
- Callers can use !a.st_ino to deduce that the information is unknown. */
-# define SAME_INODE(a, b) 0
+# elif defined _WIN32 && ! defined __CYGWIN__
+ /* Native Windows. */
+# if _GL_WINDOWS_STAT_INODES
+ /* stat() and fstat() set st_dev and st_ino to 0 if information about
+ the inode is not available. */
+# define SAME_INODE(a, b) \
+ (!((a).st_ino == 0 && (a).st_dev == 0) \
+ && (a).st_ino == (b).st_ino && (a).st_dev == (b).st_dev)
+# else
+ /* stat() and fstat() set st_ino to 0 always. */
+# define SAME_INODE(a, b) 0
+# endif
# else
# define SAME_INODE(a, b) \
((a).st_ino == (b).st_ino \
diff --git a/libgnu/same.c b/libgnu/same.c
deleted file mode 100644
index b0f25c75..00000000
--- a/libgnu/same.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Determine whether two file names refer to the same file.
-
- Copyright (C) 1997-2000, 2002-2006, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* written by Jim Meyering */
-
-#include <config.h>
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <errno.h>
-
-#include <string.h>
-
-#include <limits.h>
-#ifndef _POSIX_NAME_MAX
-# define _POSIX_NAME_MAX 14
-#endif
-
-#include "same.h"
-#include "dirname.h"
-#include "error.h"
-#include "same-inode.h"
-
-#ifndef MIN
-# define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/* Return nonzero if SOURCE and DEST point to the same name in the same
- directory. */
-
-bool
-same_name (const char *source, const char *dest)
-{
- /* Compare the basenames. */
- char const *source_basename = last_component (source);
- char const *dest_basename = last_component (dest);
- size_t source_baselen = base_len (source_basename);
- size_t dest_baselen = base_len (dest_basename);
- bool identical_basenames =
- (source_baselen == dest_baselen
- && memcmp (source_basename, dest_basename, dest_baselen) == 0);
- bool compare_dirs = identical_basenames;
- bool same = false;
-
-#if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX
- /* This implementation silently truncates components of file names. If
- the base names might be truncated, check whether the truncated
- base names are the same, while checking the directories. */
- size_t slen_max = HAVE_LONG_FILE_NAMES ? 255 : _POSIX_NAME_MAX;
- size_t min_baselen = MIN (source_baselen, dest_baselen);
- if (slen_max <= min_baselen
- && memcmp (source_basename, dest_basename, slen_max) == 0)
- compare_dirs = true;
-#endif
-
- if (compare_dirs)
- {
- struct stat source_dir_stats;
- struct stat dest_dir_stats;
- char *source_dirname, *dest_dirname;
-
- /* Compare the parent directories (via the device and inode numbers). */
- source_dirname = dir_name (source);
- dest_dirname = dir_name (dest);
-
- if (stat (source_dirname, &source_dir_stats))
- {
- /* Shouldn't happen. */
- error (1, errno, "%s", source_dirname);
- }
-
- if (stat (dest_dirname, &dest_dir_stats))
- {
- /* Shouldn't happen. */
- error (1, errno, "%s", dest_dirname);
- }
-
- same = SAME_INODE (source_dir_stats, dest_dir_stats);
-
-#if ! _POSIX_NO_TRUNC && HAVE_PATHCONF && defined _PC_NAME_MAX
- if (same && ! identical_basenames)
- {
- long name_max = (errno = 0, pathconf (dest_dirname, _PC_NAME_MAX));
- if (name_max < 0)
- {
- if (errno)
- {
- /* Shouldn't happen. */
- error (1, errno, "%s", dest_dirname);
- }
- same = false;
- }
- else
- same = (name_max <= min_baselen
- && memcmp (source_basename, dest_basename, name_max) == 0);
- }
-#endif
-
- free (source_dirname);
- free (dest_dirname);
- }
-
- return same;
-}
diff --git a/libgnu/same.h b/libgnu/same.h
deleted file mode 100644
index 822cb6f0..00000000
--- a/libgnu/same.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Determine whether two file names refer to the same file.
-
- Copyright (C) 1997-2000, 2003-2004, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef SAME_H_
-# define SAME_H_ 1
-
-# include <stdbool.h>
-
-bool same_name (const char *source, const char *dest);
-
-#endif /* SAME_H_ */
diff --git a/libgnu/save-cwd.c b/libgnu/save-cwd.c
index 11416cee..1de4fb36 100644
--- a/libgnu/save-cwd.c
+++ b/libgnu/save-cwd.c
@@ -1,6 +1,6 @@
/* save-cwd.c -- Save and restore current working directory.
- Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2017 Free Software
+ Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2018 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
@@ -30,7 +30,6 @@
#include "chdir-long.h"
#include "unistd--.h"
-#include "cloexec.h"
#if GNULIB_FCNTL_SAFER
# include "fcntl--.h"
@@ -64,16 +63,15 @@ save_cwd (struct saved_cwd *cwd)
{
cwd->name = NULL;
- cwd->desc = open (".", O_SEARCH);
+ cwd->desc = open (".", O_SEARCH | O_CLOEXEC);
if (!GNULIB_FCNTL_SAFER)
- cwd->desc = fd_safer (cwd->desc);
+ cwd->desc = fd_safer_flag (cwd->desc, O_CLOEXEC);
if (cwd->desc < 0)
{
cwd->name = getcwd (NULL, 0);
return cwd->name ? 0 : -1;
}
- set_cloexec_flag (cwd->desc, true);
return 0;
}
diff --git a/libgnu/save-cwd.h b/libgnu/save-cwd.h
index a1b25124..a521f7f5 100644
--- a/libgnu/save-cwd.h
+++ b/libgnu/save-cwd.h
@@ -1,6 +1,6 @@
/* Save and restore current working directory.
- Copyright (C) 1995, 1997-1998, 2003, 2009-2017 Free Software Foundation,
+ Copyright (C) 1995, 1997-1998, 2003, 2009-2018 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
diff --git a/libgnu/signal.in.h b/libgnu/signal.in.h
index 1ffba37e..7d4927b8 100644
--- a/libgnu/signal.in.h
+++ b/libgnu/signal.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <signal.h>.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
@@ -137,7 +137,7 @@ _GL_FUNCDECL_RPL (pthread_sigmask, int,
_GL_CXXALIAS_RPL (pthread_sigmask, int,
(int how, const sigset_t *new_mask, sigset_t *old_mask));
# else
-# if !@HAVE_PTHREAD_SIGMASK@
+# if !(@HAVE_PTHREAD_SIGMASK@ || defined pthread_sigmask)
_GL_FUNCDECL_SYS (pthread_sigmask, int,
(int how, const sigset_t *new_mask, sigset_t *old_mask));
# endif
@@ -200,7 +200,7 @@ typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
/* When also using extern inline, suppress the use of static inline in
standard headers of problematic Apple configurations, as Libc at
least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
- <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+ <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
Perhaps Apple will fix this some day. */
#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
&& (defined __i386__ || defined __x86_64__))
diff --git a/libgnu/size_max.h b/libgnu/size_max.h
index f0c00b47..00500b5a 100644
--- a/libgnu/size_max.h
+++ b/libgnu/size_max.h
@@ -1,5 +1,5 @@
/* size_max.h -- declare SIZE_MAX through system headers
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef GNULIB_SIZE_MAX_H
#define GNULIB_SIZE_MAX_H
diff --git a/libgnu/sleep.c b/libgnu/sleep.c
index 8a8fe7c2..8b753909 100644
--- a/libgnu/sleep.c
+++ b/libgnu/sleep.c
@@ -1,5 +1,5 @@
/* Pausing execution of the current thread.
- Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2007.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -24,7 +24,7 @@
#include "verify.h"
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
diff --git a/libgnu/stat-time.c b/libgnu/stat-time.c
new file mode 100644
index 00000000..81b83ddb
--- /dev/null
+++ b/libgnu/stat-time.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
+#include "stat-time.h"
diff --git a/libgnu/stat-time.h b/libgnu/stat-time.h
new file mode 100644
index 00000000..8e787bd3
--- /dev/null
+++ b/libgnu/stat-time.h
@@ -0,0 +1,252 @@
+/* stat-related time functions.
+
+ Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Paul Eggert. */
+
+#ifndef STAT_TIME_H
+#define STAT_TIME_H 1
+
+#include "intprops.h"
+
+#include <errno.h>
+#include <stddef.h>
+#include <sys/stat.h>
+#include <time.h>
+
+#ifndef _GL_INLINE_HEADER_BEGIN
+ #error "Please include config.h first."
+#endif
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_STAT_TIME_INLINE
+# define _GL_STAT_TIME_INLINE _GL_INLINE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
+ struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
+ ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
+ if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
+ for access, status change, data modification, or birth (creation)
+ time respectively.
+
+ These macros are private to stat-time.h. */
+#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
+# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
+# else
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
+# endif
+#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
+# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
+#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
+# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
+#endif
+
+/* Return the nanosecond component of *ST's access time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_atime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_atim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's status change time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_ctime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_ctim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's data modification time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_mtime_ns (struct stat const *st)
+{
+# if defined STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim).tv_nsec;
+# elif defined STAT_TIMESPEC_NS
+ return STAT_TIMESPEC_NS (st, st_mtim);
+# else
+ return 0;
+# endif
+}
+
+/* Return the nanosecond component of *ST's birth time. */
+_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
+get_stat_birthtime_ns (struct stat const *st _GL_UNUSED)
+{
+# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
+ return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
+# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ return STAT_TIMESPEC_NS (st, st_birthtim);
+# else
+ return 0;
+# endif
+}
+
+/* Return *ST's access time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_atime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_atim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_atime;
+ t.tv_nsec = get_stat_atime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's status change time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_ctime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_ctim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = get_stat_ctime_ns (st);
+ return t;
+#endif
+}
+
+/* Return *ST's data modification time. */
+_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
+get_stat_mtime (struct stat const *st)
+{
+#ifdef STAT_TIMESPEC
+ return STAT_TIMESPEC (st, st_mtim);
+#else
+ struct timespec t;
+ t.tv_sec = st->st_mtime;
+ t.tv_nsec = get_stat_mtime_ns (st);
+ return t;
+#endif
+}
+
+/* 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_ATTRIBUTE_PURE
+get_stat_birthtime (struct stat const *st _GL_UNUSED)
+{
+ struct timespec t;
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
+ t = STAT_TIMESPEC (st, st_birthtim);
+#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
+ t.tv_sec = st->st_birthtime;
+ t.tv_nsec = st->st_birthtimensec;
+#elif defined _WIN32 && ! defined __CYGWIN__
+ /* Native Windows platforms (but not Cygwin) put the "file creation
+ time" in st_ctime (!). See
+ <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>. */
+# if _GL_WINDOWS_STAT_TIMESPEC
+ t = st->st_ctim;
+# else
+ t.tv_sec = st->st_ctime;
+ t.tv_nsec = 0;
+# endif
+#else
+ /* Birth time is not supported. */
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+#endif
+
+#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
+ || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+ /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
+ using zero. Attempt to work around this problem. Alas, this can
+ report failure even for valid timestamps. Also, NetBSD
+ sometimes returns junk in the birth time fields; work around this
+ bug if it is detected. */
+ if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
+ {
+ t.tv_sec = -1;
+ t.tv_nsec = -1;
+ }
+#endif
+
+ return t;
+}
+
+/* If a stat-like function returned RESULT, normalize the timestamps
+ in *ST, in case this platform suffers from the Solaris 11 bug where
+ tv_nsec might be negative. Return the adjusted RESULT, setting
+ errno to EOVERFLOW if normalization overflowed. This function
+ is intended to be private to this .h file. */
+_GL_STAT_TIME_INLINE int
+stat_time_normalize (int result, struct stat *st _GL_UNUSED)
+{
+#if defined __sun && defined STAT_TIMESPEC
+ if (result == 0)
+ {
+ long int timespec_resolution = 1000000000;
+ short int const ts_off[] = { offsetof (struct stat, st_atim),
+ offsetof (struct stat, st_mtim),
+ offsetof (struct stat, st_ctim) };
+ int i;
+ for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
+ {
+ struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
+ long int q = ts->tv_nsec / timespec_resolution;
+ long int r = ts->tv_nsec % timespec_resolution;
+ if (r < 0)
+ {
+ r += timespec_resolution;
+ q--;
+ }
+ ts->tv_nsec = r;
+ /* Overflow is possible, as Solaris 11 stat can yield
+ tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
+ INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
+ if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec))
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+ }
+ }
+#endif
+ return result;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+_GL_INLINE_HEADER_END
+
+#endif
diff --git a/libgnu/stat-w32.c b/libgnu/stat-w32.c
new file mode 100644
index 00000000..802b38a8
--- /dev/null
+++ b/libgnu/stat-w32.c
@@ -0,0 +1,421 @@
+/* Core of implementation of fstat and stat for native Windows.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible. */
+
+#include <config.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+
+/* Ensure that <windows.h> defines FILE_ID_INFO. */
+#undef _WIN32_WINNT
+#define _WIN32_WINNT _WIN32_WINNT_WIN8
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+#include <windows.h>
+
+/* Specification. */
+#include "stat-w32.h"
+
+#include "pathmax.h"
+#include "verify.h"
+
+#if _GL_WINDOWS_STAT_INODES == 2
+/* GetFileInformationByHandleEx was introduced only in Windows Vista. */
+typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,
+ FILE_INFO_BY_HANDLE_CLASS fiClass,
+ LPVOID lpBuffer,
+ DWORD dwBufferSize);
+static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL;
+#endif
+/* GetFinalPathNameByHandle was introduced only in Windows Vista. */
+typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile,
+ LPTSTR lpFilePath,
+ DWORD lenFilePath,
+ DWORD dwFlags);
+static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL;
+static BOOL initialized = FALSE;
+
+static void
+initialize (void)
+{
+ HMODULE kernel32 = LoadLibrary ("kernel32.dll");
+ if (kernel32 != NULL)
+ {
+#if _GL_WINDOWS_STAT_INODES == 2
+ GetFileInformationByHandleExFunc =
+ (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx");
+#endif
+ GetFinalPathNameByHandleFunc =
+ (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA");
+ }
+ initialized = TRUE;
+}
+
+/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+struct timespec
+_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
+{
+ struct timespec result;
+ /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
+ unsigned long long since_1601 =
+ ((unsigned long long) ft->dwHighDateTime << 32)
+ | (unsigned long long) ft->dwLowDateTime;
+ if (since_1601 == 0)
+ {
+ result.tv_sec = 0;
+ result.tv_nsec = 0;
+ }
+ else
+ {
+ /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
+ leap years, in total 134774 days. */
+ unsigned long long since_1970 =
+ since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
+ result.tv_sec = since_1970 / (unsigned long long) 10000000;
+ result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100;
+ }
+ return result;
+}
+#else
+time_t
+_gl_convert_FILETIME_to_POSIX (const FILETIME *ft)
+{
+ /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
+ unsigned long long since_1601 =
+ ((unsigned long long) ft->dwHighDateTime << 32)
+ | (unsigned long long) ft->dwLowDateTime;
+ if (since_1601 == 0)
+ return 0;
+ else
+ {
+ /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
+ leap years, in total 134774 days. */
+ unsigned long long since_1970 =
+ since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
+ return since_1970 / (unsigned long long) 10000000;
+ }
+}
+#endif
+
+/* Fill *BUF with information about the file designated by H.
+ PATH is the file name, if known, otherwise NULL.
+ Return 0 if successful, or -1 with errno set upon failure. */
+int
+_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
+{
+ /* GetFileType
+ <https://msdn.microsoft.com/en-us/library/aa364960.aspx> */
+ DWORD type = GetFileType (h);
+ if (type == FILE_TYPE_DISK)
+ {
+ if (!initialized)
+ initialize ();
+
+ /* st_mode can be determined through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileBasicInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364217.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ BY_HANDLE_FILE_INFORMATION info;
+ if (! GetFileInformationByHandle (h, &info))
+ goto failed;
+
+ /* Test for error conditions before starting to fill *buf. */
+ if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+#if _GL_WINDOWS_STAT_INODES
+ /* st_ino can be determined through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ as 64 bits, or through
+ GetFileInformationByHandleEx with argument FileIdInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/hh802691.aspx>
+ as 128 bits.
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */
+ /* Experiments show that GetFileInformationByHandleEx does not provide
+ much more information than GetFileInformationByHandle:
+ * The dwVolumeSerialNumber from GetFileInformationByHandle is equal
+ to the low 32 bits of the 64-bit VolumeSerialNumber from
+ GetFileInformationByHandleEx, and is apparently sufficient for
+ identifying the device.
+ * The nFileIndex from GetFileInformationByHandle is equal to the low
+ 64 bits of the 128-bit FileId from GetFileInformationByHandleEx,
+ and the high 64 bits of this 128-bit FileId are zero.
+ * On a FAT file system, GetFileInformationByHandleEx fails with error
+ ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle
+ succeeds.
+ * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with
+ error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
+ succeeds. */
+# if _GL_WINDOWS_STAT_INODES == 2
+ if (GetFileInformationByHandleExFunc != NULL)
+ {
+ FILE_ID_INFO id;
+ if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
+ {
+ buf->st_dev = id.VolumeSerialNumber;
+ verify (sizeof (ino_t) == sizeof (id.FileId));
+ memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t));
+ goto ino_done;
+ }
+ else
+ {
+ switch (GetLastError ())
+ {
+ case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */
+ case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */
+ goto fallback;
+ default:
+ goto failed;
+ }
+ }
+ }
+ fallback: ;
+ /* Fallback for older Windows versions. */
+ buf->st_dev = info.dwVolumeSerialNumber;
+ buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
+ buf->st_ino._gl_ino[1] = 0;
+ ino_done: ;
+# else /* _GL_WINDOWS_STAT_INODES == 1 */
+ buf->st_dev = info.dwVolumeSerialNumber;
+ buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
+# endif
+#else
+ /* st_ino is not wide enough for identifying a file on a device.
+ Without st_ino, st_dev is pointless. */
+ buf->st_dev = 0;
+ buf->st_ino = 0;
+#endif
+
+ /* st_mode. */
+ unsigned int mode =
+ /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
+ ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
+ | S_IREAD_UGO
+ | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
+ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ /* Determine whether the file is executable by looking at the file
+ name suffix.
+ If the file name is already known, use it. Otherwise, for
+ non-empty files, it can be determined through
+ GetFinalPathNameByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364962.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileNameInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364388.aspx>
+ Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
+ {
+ char fpath[PATH_MAX];
+ if (path != NULL
+ || (GetFinalPathNameByHandleFunc != NULL
+ && GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE)
+ < sizeof (fpath)
+ && (path = fpath, 1)))
+ {
+ const char *last_dot = NULL;
+ const char *p;
+ for (p = path; *p != '\0'; p++)
+ if (*p == '.')
+ last_dot = p;
+ if (last_dot != NULL)
+ {
+ const char *suffix = last_dot + 1;
+ if (_stricmp (suffix, "exe") == 0
+ || _stricmp (suffix, "bat") == 0
+ || _stricmp (suffix, "cmd") == 0
+ || _stricmp (suffix, "com") == 0)
+ mode |= S_IEXEC_UGO;
+ }
+ }
+ else
+ /* Cannot determine file name. Pretend that it is executable. */
+ mode |= S_IEXEC_UGO;
+ }
+ }
+ buf->st_mode = mode;
+
+ /* st_nlink can be determined through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileStandardInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364401.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks);
+
+ /* There's no easy way to map the Windows SID concept to an integer. */
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+
+ /* st_rdev is irrelevant for normal files and directories. */
+ buf->st_rdev = 0;
+
+ /* st_size can be determined through
+ GetFileSizeEx
+ <https://msdn.microsoft.com/en-us/library/aa364957.aspx>
+ or through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileStandardInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364401.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+ if (sizeof (buf->st_size) <= 4)
+ /* Range check already done above. */
+ buf->st_size = info.nFileSizeLow;
+ else
+ buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
+
+ /* st_atime, st_mtime, st_ctime can be determined through
+ GetFileTime
+ <https://msdn.microsoft.com/en-us/library/ms724320.aspx>
+ or through
+ GetFileAttributesEx
+ <https://msdn.microsoft.com/en-us/library/aa364946.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365739.aspx>
+ or through
+ GetFileInformationByHandle
+ <https://msdn.microsoft.com/en-us/library/aa364952.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363788.aspx>
+ or through
+ GetFileInformationByHandleEx with argument FileBasicInfo
+ <https://msdn.microsoft.com/en-us/library/aa364953.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364217.aspx>
+ The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
+ buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
+ buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
+#else
+ buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
+ buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
+ buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
+#endif
+
+ return 0;
+ }
+ else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE)
+ {
+ buf->st_dev = 0;
+#if _GL_WINDOWS_STAT_INODES == 2
+ buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
+#else
+ buf->st_ino = 0;
+#endif
+ buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR);
+ buf->st_nlink = 1;
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+ buf->st_rdev = 0;
+ if (type == FILE_TYPE_PIPE)
+ {
+ /* PeekNamedPipe
+ <https://msdn.microsoft.com/en-us/library/aa365779.aspx> */
+ DWORD bytes_available;
+ if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL))
+ buf->st_size = bytes_available;
+ else
+ buf->st_size = 0;
+ }
+ else
+ buf->st_size = 0;
+#if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0;
+ buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0;
+ buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0;
+#else
+ buf->st_atime = 0;
+ buf->st_mtime = 0;
+ buf->st_ctime = 0;
+#endif
+ return 0;
+ }
+ else
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ failed:
+ {
+ DWORD error = GetLastError ();
+ #if 0
+ fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error);
+ #endif
+ switch (error)
+ {
+ case ERROR_ACCESS_DENIED:
+ case ERROR_SHARING_VIOLATION:
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+ return -1;
+ }
+}
+
+#else
+
+/* This declaration is solely to ensure that after preprocessing
+ this file is never empty. */
+typedef int dummy;
+
+#endif
diff --git a/libgnu/stat-w32.h b/libgnu/stat-w32.h
new file mode 100644
index 00000000..9a3ecc14
--- /dev/null
+++ b/libgnu/stat-w32.h
@@ -0,0 +1,37 @@
+/* Core of implementation of fstat and stat for native Windows.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+ This 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 <https://www.gnu.org/licenses/>. */
+
+#ifndef _STAT_W32_H
+#define _STAT_W32_H 1
+
+/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
+#if _GL_WINDOWS_STAT_TIMESPEC
+extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft);
+#else
+extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft);
+#endif
+
+/* Fill *BUF with information about the file designated by H.
+ PATH is the file name, if known, otherwise NULL.
+ Return 0 if successful, or -1 with errno set upon failure. */
+extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf);
+
+/* Bitmasks for st_mode. */
+#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
+#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
+#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
+
+#endif /* _STAT_W32_H */
diff --git a/libgnu/stat.c b/libgnu/stat.c
index 7e7c2f6f..18c0caa1 100644
--- a/libgnu/stat.c
+++ b/libgnu/stat.c
@@ -1,5 +1,5 @@
/* Work around platform bugs in stat.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,9 +12,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
-/* written by Eric Blake */
+/* Written by Eric Blake and Bruno Haible. */
/* 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_stat doesn't recurse to
@@ -27,47 +27,68 @@
#include <sys/stat.h>
#undef __need_system_sys_stat_h
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# if _GL_WINDOWS_64_BIT_ST_SIZE
-# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
-# define stat _stati64
-# define REPLACE_FUNC_STAT_DIR 1
-# undef REPLACE_FUNC_STAT_FILE
-# elif REPLACE_FUNC_STAT_FILE
-/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
- Bypass it. */
-# define stat _stat
-# define REPLACE_FUNC_STAT_DIR 1
-# undef REPLACE_FUNC_STAT_FILE
-# endif
+#if defined _WIN32 && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
#endif
+#if !defined WINDOWS_NATIVE
+
static int
orig_stat (const char *filename, struct stat *buf)
{
return stat (filename, buf);
}
+#endif
+
/* Specification. */
/* 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"
+#include "stat-time.h"
+
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <string.h>
-#include "dosname.h"
+#include "filename.h"
+#include "malloca.h"
#include "verify.h"
-#if REPLACE_FUNC_STAT_DIR
-# include "pathmax.h"
- /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
- have a constant PATH_MAX. */
-# ifndef PATH_MAX
-# error "Please port this replacement to your platform"
-# endif
+#ifdef WINDOWS_NATIVE
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include "stat-w32.h"
+#endif
+
+#ifdef WINDOWS_NATIVE
+/* Return TRUE if the given file name denotes an UNC root. */
+static BOOL
+is_unc_root (const char *rname)
+{
+ /* Test whether it has the syntax '\\server\share'. */
+ if (ISSLASH (rname[0]) && ISSLASH (rname[1]))
+ {
+ /* It starts with two slashes. Find the next slash. */
+ const char *p = rname + 2;
+ const char *q = p;
+ while (*q != '\0' && !ISSLASH (*q))
+ q++;
+ if (q > p && *q != '\0')
+ {
+ /* Found the next slash at q. */
+ q++;
+ const char *r = q;
+ while (*r != '\0' && !ISSLASH (*r))
+ r++;
+ if (r > q && *r == '\0')
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
#endif
/* Store information about NAME into ST. Work around bugs with
@@ -77,62 +98,332 @@ orig_stat (const char *filename, struct stat *buf)
correctly. */
int
-rpl_stat (char const *name, struct stat *st)
+rpl_stat (char const *name, struct stat *buf)
{
- int result = orig_stat (name, st);
-#if REPLACE_FUNC_STAT_FILE
- /* Solaris 9 mistakenly succeeds when given a non-directory with a
- trailing slash. */
- if (result == 0 && !S_ISDIR (st->st_mode))
+#ifdef WINDOWS_NATIVE
+ /* Fill the fields ourselves, because the original stat function returns
+ values for st_atime, st_mtime, st_ctime that depend on the current time
+ zone. See
+ <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
+ /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work
+ around length limitations
+ <https://msdn.microsoft.com/en-us/library/aa365247.aspx> ? */
+
+ /* POSIX <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
+ specifies: "More than two leading <slash> characters shall be treated as
+ a single <slash> character." */
+ if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2]))
+ {
+ name += 2;
+ while (ISSLASH (name[1]))
+ name++;
+ }
+
+ size_t len = strlen (name);
+ size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0);
+
+ /* Remove trailing slashes (except the very first one, at position
+ drive_prefix_len), but remember their presence. */
+ size_t rlen;
+ bool check_dir = false;
+
+ rlen = len;
+ while (rlen > drive_prefix_len && ISSLASH (name[rlen-1]))
{
- size_t len = strlen (name);
- if (ISSLASH (name[len - 1]))
+ check_dir = true;
+ if (rlen == drive_prefix_len + 1)
+ break;
+ rlen--;
+ }
+
+ /* Handle '' and 'C:'. */
+ if (!check_dir && rlen == drive_prefix_len)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* Handle '\\'. */
+ if (rlen == 1 && ISSLASH (name[0]) && len >= 2)
+ {
+ errno = ENOENT;
+ return -1;
+ }
+
+ const char *rname;
+ char *malloca_rname;
+ if (rlen == len)
+ {
+ rname = name;
+ malloca_rname = NULL;
+ }
+ else
+ {
+ malloca_rname = malloca (rlen + 1);
+ if (malloca_rname == NULL)
{
- errno = ENOTDIR;
+ errno = ENOMEM;
return -1;
}
+ memcpy (malloca_rname, name, rlen);
+ malloca_rname[rlen] = '\0';
+ rname = malloca_rname;
}
-#endif /* REPLACE_FUNC_STAT_FILE */
-#if REPLACE_FUNC_STAT_DIR
- if (result == -1 && errno == ENOENT)
+ /* There are two ways to get at the requested information:
+ - by scanning the parent directory and examining the relevant
+ directory entry,
+ - by opening the file directly.
+ The first approach fails for root directories (e.g. 'C:\') and
+ UNC root directories (e.g. '\\server\share').
+ The second approach fails for some system files (e.g. 'C:\pagefile.sys'
+ and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION.
+ The second approach gives more information (in particular, correct
+ st_dev, st_ino, st_nlink fields).
+ So we use the second approach and, as a fallback except for root and
+ UNC root directories, also the first approach. */
+ {
+ int ret;
+
{
- /* Due to mingw's oddities, there are some directories (like
- c:\) where stat() only succeeds with a trailing slash, and
- other directories (like c:\windows) where stat() only
- succeeds without a trailing slash. But we want the two to be
- synonymous, since chdir() manages either style. Likewise, Mingw also
- reports ENOENT for names longer than PATH_MAX, when we want
- ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
- Fortunately, mingw PATH_MAX is small enough for stack
- allocation. */
- char fixed_name[PATH_MAX + 1] = {0};
- size_t len = strlen (name);
- bool check_dir = false;
- verify (PATH_MAX <= 4096);
- if (PATH_MAX <= len)
- errno = ENAMETOOLONG;
- else if (len)
+ /* Approach based on the file. */
+
+ /* Open a handle to the file.
+ CreateFile
+ <https://msdn.microsoft.com/en-us/library/aa363858.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa363874.aspx> */
+ HANDLE h =
+ CreateFile (rname,
+ FILE_READ_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
+ in case as different) makes sense only when applied to *all*
+ filesystem operations. */
+ FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
+ NULL);
+ if (h != INVALID_HANDLE_VALUE)
+ {
+ ret = _gl_fstat_by_handle (h, rname, buf);
+ CloseHandle (h);
+ goto done;
+ }
+ }
+
+ /* Test for root and UNC root directories. */
+ if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len]))
+ || is_unc_root (rname))
+ goto failed;
+
+ /* Fallback. */
+ {
+ /* Approach based on the directory entry. */
+
+ if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL)
+ {
+ /* Other Windows API functions would fail with error
+ ERROR_INVALID_NAME. */
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* Get the details about the directory entry. This can be done through
+ FindFirstFile
+ <https://msdn.microsoft.com/en-us/library/aa364418.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365740.aspx>
+ or through
+ FindFirstFileEx with argument FindExInfoBasic
+ <https://msdn.microsoft.com/en-us/library/aa364419.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa364415.aspx>
+ <https://msdn.microsoft.com/en-us/library/aa365740.aspx> */
+ WIN32_FIND_DATA info;
+ HANDLE h = FindFirstFile (rname, &info);
+ if (h == INVALID_HANDLE_VALUE)
+ goto failed;
+
+ /* Test for error conditions before starting to fill *buf. */
+ if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
+ {
+ FindClose (h);
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+ errno = EOVERFLOW;
+ return -1;
+ }
+
+# if _GL_WINDOWS_STAT_INODES
+ buf->st_dev = 0;
+# if _GL_WINDOWS_STAT_INODES == 2
+ buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
+# else /* _GL_WINDOWS_STAT_INODES == 1 */
+ buf->st_ino = 0;
+# endif
+# else
+ /* st_ino is not wide enough for identifying a file on a device.
+ Without st_ino, st_dev is pointless. */
+ buf->st_dev = 0;
+ buf->st_ino = 0;
+# endif
+
+ /* st_mode. */
+ unsigned int mode =
+ /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
+ ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
+ | S_IREAD_UGO
+ | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
+ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
- strcpy (fixed_name, name);
- if (ISSLASH (fixed_name[len - 1]))
+ /* Determine whether the file is executable by looking at the file
+ name suffix. */
+ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
{
- check_dir = true;
- while (len && ISSLASH (fixed_name[len - 1]))
- fixed_name[--len] = '\0';
- if (!len)
- fixed_name[0] = '/';
+ const char *last_dot = NULL;
+ const char *p;
+ for (p = info.cFileName; *p != '\0'; p++)
+ if (*p == '.')
+ last_dot = p;
+ if (last_dot != NULL)
+ {
+ const char *suffix = last_dot + 1;
+ if (_stricmp (suffix, "exe") == 0
+ || _stricmp (suffix, "bat") == 0
+ || _stricmp (suffix, "cmd") == 0
+ || _stricmp (suffix, "com") == 0)
+ mode |= S_IEXEC_UGO;
+ }
}
- else
- fixed_name[len++] = '/';
- result = orig_stat (fixed_name, st);
- if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
+ }
+ buf->st_mode = mode;
+
+ /* st_nlink. Ignore hard links here. */
+ buf->st_nlink = 1;
+
+ /* There's no easy way to map the Windows SID concept to an integer. */
+ buf->st_uid = 0;
+ buf->st_gid = 0;
+
+ /* st_rdev is irrelevant for normal files and directories. */
+ buf->st_rdev = 0;
+
+ /* st_size. */
+ if (sizeof (buf->st_size) <= 4)
+ /* Range check already done above. */
+ buf->st_size = info.nFileSizeLow;
+ else
+ buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
+
+ /* st_atime, st_mtime, st_ctime. */
+# if _GL_WINDOWS_STAT_TIMESPEC
+ buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
+ buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
+ buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
+# else
+ buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
+ buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
+ buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
+# endif
+
+ FindClose (h);
+
+ ret = 0;
+ }
+
+ done:
+ if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode))
+ {
+ errno = ENOTDIR;
+ ret = -1;
+ }
+ if (malloca_rname != NULL)
+ {
+ int saved_errno = errno;
+ freea (malloca_rname);
+ errno = saved_errno;
+ }
+ return ret;
+ }
+
+ failed:
+ {
+ DWORD error = GetLastError ();
+ #if 0
+ fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error);
+ #endif
+
+ if (malloca_rname != NULL)
+ freea (malloca_rname);
+
+ switch (error)
+ {
+ /* Some of these errors probably cannot happen with the specific flags
+ that we pass to CreateFile. But who knows... */
+ case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */
+ case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */
+ case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */
+ case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */
+ case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */
+ case ERROR_DIRECTORY:
+ errno = ENOENT;
+ break;
+
+ case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */
+ case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */
+ /* XXX map to EACCESS or EPERM? */
+ errno = EACCES;
+ break;
+
+ case ERROR_OUTOFMEMORY:
+ errno = ENOMEM;
+ break;
+
+ case ERROR_WRITE_PROTECT:
+ errno = EROFS;
+ break;
+
+ case ERROR_WRITE_FAULT:
+ case ERROR_READ_FAULT:
+ case ERROR_GEN_FAILURE:
+ errno = EIO;
+ break;
+
+ case ERROR_BUFFER_OVERFLOW:
+ case ERROR_FILENAME_EXCED_RANGE:
+ errno = ENAMETOOLONG;
+ break;
+
+ case ERROR_DELETE_PENDING: /* XXX map to EACCESS or EPERM? */
+ errno = EPERM;
+ break;
+
+ default:
+ errno = EINVAL;
+ break;
+ }
+
+ return -1;
+ }
+#else
+ int result = orig_stat (name, buf);
+ if (result == 0)
+ {
+# if REPLACE_FUNC_STAT_FILE
+ /* Solaris 9 mistakenly succeeds when given a non-directory with a
+ trailing slash. */
+ if (!S_ISDIR (buf->st_mode))
+ {
+ size_t len = strlen (name);
+ if (ISSLASH (name[len - 1]))
{
- result = -1;
errno = ENOTDIR;
+ return -1;
}
}
+# endif /* REPLACE_FUNC_STAT_FILE */
+ result = stat_time_normalize (result, buf);
}
-#endif /* REPLACE_FUNC_STAT_DIR */
return result;
+#endif
}
diff --git a/libgnu/stdalign.in.h b/libgnu/stdalign.in.h
index ea248231..bbfa9ac3 100644
--- a/libgnu/stdalign.in.h
+++ b/libgnu/stdalign.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C11 <stdalign.h>.
- Copyright 2011-2017 Free Software Foundation, Inc.
+ Copyright 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert and Bruno Haible. */
@@ -53,7 +53,7 @@
#undef _Alignof
/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
- <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
+ <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
|| (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9)))
# ifdef __cplusplus
diff --git a/libgnu/stdbool.in.h b/libgnu/stdbool.in.h
index 1067ed2e..ebf1a2f3 100644
--- a/libgnu/stdbool.in.h
+++ b/libgnu/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2018 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_STDBOOL_H
#define _GL_STDBOOL_H
@@ -82,9 +82,9 @@ typedef bool _Bool;
/* If @HAVE__BOOL@:
Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
the built-in _Bool type is used. See
- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+ https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+ https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html
+ https://lists.gnu.org/r/bug-coreutils/2005-10/msg00086.html
Similar bugs are likely with other compilers as well; this file
wouldn't be used if <stdbool.h> was working.
So we override the _Bool type.
diff --git a/libgnu/stddef.in.h b/libgnu/stddef.in.h
index 5b496a68..8329a9bf 100644
--- a/libgnu/stddef.in.h
+++ b/libgnu/stddef.in.h
@@ -1,6 +1,6 @@
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake. */
@@ -85,24 +85,28 @@
a hack in case the configure-time test was done with g++ even though
we are currently compiling with gcc. */
#if ! (@HAVE_MAX_ALIGN_T@ || defined _GCC_MAX_ALIGN_T)
+# if !GNULIB_defined_max_align_t
/* On the x86, the maximum storage alignment of double, long, etc. is 4,
but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
and the C11 standard allows this. Work around this problem by
using __alignof__ (which returns 8 for double) rather than _Alignof
(which returns 4), and align each union member accordingly. */
-# ifdef __GNUC__
-# define _GL_STDDEF_ALIGNAS(type) \
- __attribute__ ((__aligned__ (__alignof__ (type))))
-# else
-# define _GL_STDDEF_ALIGNAS(type) /* */
-# endif
+# ifdef __GNUC__
+# define _GL_STDDEF_ALIGNAS(type) \
+ __attribute__ ((__aligned__ (__alignof__ (type))))
+# else
+# define _GL_STDDEF_ALIGNAS(type) /* */
+# endif
typedef union
{
char *__p _GL_STDDEF_ALIGNAS (char *);
double __d _GL_STDDEF_ALIGNAS (double);
long double __ld _GL_STDDEF_ALIGNAS (long double);
long int __i _GL_STDDEF_ALIGNAS (long int);
-} max_align_t;
+} rpl_max_align_t;
+# define max_align_t rpl_max_align_t
+# define GNULIB_defined_max_align_t 1
+# endif
#endif
# endif /* _@GUARD_PREFIX@_STDDEF_H */
diff --git a/libgnu/stdint.in.h b/libgnu/stdint.in.h
index 5fbec343..94e7c81c 100644
--- a/libgnu/stdint.in.h
+++ b/libgnu/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2018 Free Software Foundation, Inc.
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
This file is part of gnulib.
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/*
* ISO C 99 <stdint.h> for platforms that lack it.
diff --git a/libgnu/stdio.in.h b/libgnu/stdio.in.h
index d706377f..ff7c9c83 100644
--- a/libgnu/stdio.in.h
+++ b/libgnu/stdio.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdio.h>.
- Copyright (C) 2004, 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
@@ -111,9 +111,9 @@
#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
_GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
-/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
+/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
/* But in any case avoid namespace pollution on glibc systems. */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
&& ! defined __GLIBC__
# include <unistd.h>
#endif
@@ -122,7 +122,7 @@
it before we #define perror rpl_perror. */
/* But in any case avoid namespace pollution on glibc systems. */
#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
&& ! defined __GLIBC__
# include <stdlib.h>
#endif
@@ -133,7 +133,7 @@
it before we #define rename rpl_rename. */
/* But in any case avoid namespace pollution on glibc systems. */
#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
+ && (defined _WIN32 && ! defined __CYGWIN__) \
&& ! defined __GLIBC__
# include <io.h>
#endif
@@ -152,7 +152,7 @@
/* When also using extern inline, suppress the use of static inline in
standard headers of problematic Apple configurations, as Libc at
least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
- <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+ <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
Perhaps Apple will fix this some day. */
#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
&& defined __GNUC__ && defined __STDC__)
@@ -610,7 +610,7 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
(const void *ptr, size_t s, size_t n, FILE *stream));
/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
- <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
+ <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
which sometimes causes an unwanted diagnostic for fwrite calls.
This affects only function declaration attributes under certain
versions of gcc and clang, and is not needed for C++. */
diff --git a/libgnu/stdlib.in.h b/libgnu/stdlib.in.h
index b5cf9d36..3bf35bf6 100644
--- a/libgnu/stdlib.in.h
+++ b/libgnu/stdlib.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <stdlib.h>.
- Copyright (C) 1995, 2001-2004, 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2001-2004, 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
@@ -47,11 +47,14 @@
/* Solaris declares getloadavg() in <sys/loadavg.h>. */
#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
+/* OpenIndiana has a bug: <sys/time.h> must be included before
+ <sys/loadavg.h>. */
+# include <sys/time.h>
# include <sys/loadavg.h>
#endif
/* Native Windows platforms declare mktemp() in <io.h>. */
-#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
@@ -87,7 +90,7 @@ struct random_data
# endif
#endif
-#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
@@ -597,7 +600,7 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
#endif
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_INITSTATE@
_GL_FUNCDECL_SYS (initstate, char *,
(unsigned int seed, char *buf, size_t buf_size)
_GL_ARG_NONNULL ((2)));
@@ -614,7 +617,7 @@ _GL_WARN_ON_USE (initstate, "initstate is unportable - "
#endif
#if @GNULIB_RANDOM@
-# if !@HAVE_RANDOM@
+# if !@HAVE_RANDOM@ || !@HAVE_DECL_SETSTATE@
_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
@@ -765,6 +768,23 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
"use gnulib module realloc-posix for portability");
#endif
+
+#if @GNULIB_REALLOCARRAY@
+# if ! @HAVE_REALLOCARRAY@
+_GL_FUNCDECL_SYS (reallocarray, void *,
+ (void *ptr, size_t nmemb, size_t size));
+# endif
+_GL_CXXALIAS_SYS (reallocarray, void *,
+ (void *ptr, size_t nmemb, size_t size));
+_GL_CXXALIASWARN (reallocarray);
+#elif defined GNULIB_POSIXCHECK
+# undef reallocarray
+# if HAVE_RAW_DECL_REALLOCARRAY
+_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
+ "use gnulib module reallocarray for portability");
+# endif
+#endif
+
#if @GNULIB_REALPATH@
# if @REPLACE_REALPATH@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
diff --git a/libgnu/stpcpy.c b/libgnu/stpcpy.c
index 154d95f8..61239e9f 100644
--- a/libgnu/stpcpy.c
+++ b/libgnu/stpcpy.c
@@ -1,5 +1,5 @@
/* stpcpy.c -- copy a string and return pointer to end of new string
- Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2017 Free Software
+ Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2018 Free Software
Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
@@ -16,7 +16,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/stpncpy.c b/libgnu/stpncpy.c
index d46541c9..804c3c28 100644
--- a/libgnu/stpncpy.c
+++ b/libgnu/stpncpy.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2017 Free Software
+/* Copyright (C) 1993, 1995-1997, 2002-2003, 2005-2007, 2009-2018 Free Software
* Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
@@ -15,7 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* This is almost copied from strncpy.c, written by Torbjorn Granlund. */
diff --git a/libgnu/strcasecmp.c b/libgnu/strcasecmp.c
index 8548f4dc..49f22c59 100644
--- a/libgnu/strcasecmp.c
+++ b/libgnu/strcasecmp.c
@@ -1,5 +1,5 @@
/* Case-insensitive string comparison function.
- Copyright (C) 1998-1999, 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strchrnul.c b/libgnu/strchrnul.c
index 2d40658e..8b3cd88b 100644
--- a/libgnu/strchrnul.c
+++ b/libgnu/strchrnul.c
@@ -1,5 +1,5 @@
/* Searching in a string.
- Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strdup.c b/libgnu/strdup.c
index 0c096e33..ce43940b 100644
--- a/libgnu/strdup.c
+++ b/libgnu/strdup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2017 Free Software
+/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2018 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _LIBC
# include <config.h>
diff --git a/libgnu/streq.h b/libgnu/streq.h
index d40fc48f..bde1b956 100644
--- a/libgnu/streq.h
+++ b/libgnu/streq.h
@@ -1,5 +1,5 @@
/* Optimized string comparison.
- Copyright (C) 2001-2002, 2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>. */
diff --git a/libgnu/strerror-override.c b/libgnu/strerror-override.c
index fb2c74f7..d3ad21e7 100644
--- a/libgnu/strerror-override.c
+++ b/libgnu/strerror-override.c
@@ -1,6 +1,6 @@
/* strerror-override.c --- POSIX compatible system error routine
- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+ Copyright (C) 2010-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
diff --git a/libgnu/strerror-override.h b/libgnu/strerror-override.h
index c22d303c..a96fd089 100644
--- a/libgnu/strerror-override.h
+++ b/libgnu/strerror-override.h
@@ -1,6 +1,6 @@
/* strerror-override.h --- POSIX compatible system error routine
- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+ Copyright (C) 2010-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _GL_STRERROR_OVERRIDE_H
# define _GL_STRERROR_OVERRIDE_H
diff --git a/libgnu/strerror.c b/libgnu/strerror.c
index afeb9c8c..36397bb8 100644
--- a/libgnu/strerror.c
+++ b/libgnu/strerror.c
@@ -1,6 +1,6 @@
/* strerror.c --- POSIX compatible system error routine
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/string.in.h b/libgnu/string.in.h
index 9a6b311d..29f4ba6b 100644
--- a/libgnu/string.in.h
+++ b/libgnu/string.in.h
@@ -1,6 +1,6 @@
/* A GNU-like <string.h>.
- Copyright (C) 1995-1996, 2001-2017 Free Software Foundation, Inc.
+ Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
@@ -74,6 +74,23 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
+/* Clear a block of memory. The compiler will not delete a call to
+ this function, even if the block is dead after the call. */
+#if @GNULIB_EXPLICIT_BZERO@
+# if ! @HAVE_EXPLICIT_BZERO@
+_GL_FUNCDECL_SYS (explicit_bzero, void,
+ (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
+_GL_CXXALIASWARN (explicit_bzero);
+#elif defined GNULIB_POSIXCHECK
+# undef explicit_bzero
+# if HAVE_RAW_DECL_EXPLICIT_BZERO
+_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
+ "use gnulib module explicit_bzero for portability");
+# endif
+#endif
+
/* Find the index of the least-significant set bit. */
#if @GNULIB_FFSL@
# if !@HAVE_FFSL@
diff --git a/libgnu/strings.in.h b/libgnu/strings.in.h
index 0374c947..b9d0a67a 100644
--- a/libgnu/strings.in.h
+++ b/libgnu/strings.in.h
@@ -1,6 +1,6 @@
/* A substitute <strings.h>.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_STRINGS_H
diff --git a/libgnu/stripslash.c b/libgnu/stripslash.c
index 2d9d166d..60c6781c 100644
--- a/libgnu/stripslash.c
+++ b/libgnu/stripslash.c
@@ -1,6 +1,6 @@
/* stripslash.c -- remove redundant trailing slashes from a file name
- Copyright (C) 1990, 2001, 2003-2006, 2009-2017 Free Software Foundation,
+ Copyright (C) 1990, 2001, 2003-2006, 2009-2018 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strncasecmp.c b/libgnu/strncasecmp.c
index 2bb02d9a..f750679e 100644
--- a/libgnu/strncasecmp.c
+++ b/libgnu/strncasecmp.c
@@ -1,5 +1,5 @@
/* strncasecmp.c -- case insensitive string comparator
- Copyright (C) 1998-1999, 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 1998-1999, 2005-2007, 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strndup.c b/libgnu/strndup.c
index 546e58cb..b5c18dda 100644
--- a/libgnu/strndup.c
+++ b/libgnu/strndup.c
@@ -1,6 +1,6 @@
/* A replacement function, for systems that lack strndup.
- Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2017 Free Software
+ Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2018 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strnlen.c b/libgnu/strnlen.c
index 4cb1ca37..f0b1b8b2 100644
--- a/libgnu/strnlen.c
+++ b/libgnu/strnlen.c
@@ -1,5 +1,5 @@
/* Find the length of STRING, but scan at most MAXLEN characters.
- Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2007, 2009-2018 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strnlen1.c b/libgnu/strnlen1.c
index 63f78a6a..4459f6b1 100644
--- a/libgnu/strnlen1.c
+++ b/libgnu/strnlen1.c
@@ -1,5 +1,5 @@
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
diff --git a/libgnu/strnlen1.h b/libgnu/strnlen1.h
index 86cb177c..896a1801 100644
--- a/libgnu/strnlen1.h
+++ b/libgnu/strnlen1.h
@@ -1,5 +1,5 @@
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
- Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _STRNLEN1_H
#define _STRNLEN1_H
diff --git a/libgnu/strsep.c b/libgnu/strsep.c
index 609494c2..7618142b 100644
--- a/libgnu/strsep.c
+++ b/libgnu/strsep.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2007, 2009-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2007, 2009-2018 Free Software Foundation, Inc.
Written by Yoann Vandoorselaere <yoann@prelude-ids.org>.
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/sys_stat.in.h b/libgnu/sys_stat.in.h
index d5ca3434..6ae6ac5f 100644
--- a/libgnu/sys_stat.in.h
+++ b/libgnu/sys_stat.in.h
@@ -1,5 +1,5 @@
-/* Provide a more complete sys/stat header file.
- Copyright (C) 2005-2017 Free Software Foundation, Inc.
+/* Provide a more complete sys/stat.h header file.
+ Copyright (C) 2005-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
@@ -57,13 +57,13 @@
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). Native Windows platforms declare mkdir
in <io.h> and/or <direct.h>, not in <unistd.h>. */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
# include <io.h> /* mingw32, mingw64 */
# include <direct.h> /* mingw64, MSVC 9 */
#endif
/* Native Windows platforms declare umask() in <io.h>. */
-#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
@@ -72,6 +72,75 @@
# define stat _stati64
#endif
+/* Optionally, override 'struct stat' on native Windows. */
+#if @GNULIB_OVERRIDES_STRUCT_STAT@
+
+# undef stat
+# if @GNULIB_STAT@
+# define stat rpl_stat
+# else
+ /* Provoke a clear link error if stat() is used as a function and
+ module 'stat' is not in use. */
+# define stat stat_used_without_requesting_gnulib_module_stat
+# endif
+
+# if !GNULIB_defined_struct_stat
+struct stat
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+# if 0
+ uid_t st_uid;
+# else /* uid_t is not defined by default on native Windows. */
+ short st_uid;
+# endif
+# if 0
+ gid_t st_gid;
+# else /* gid_t is not defined by default on native Windows. */
+ short st_gid;
+# endif
+ dev_t st_rdev;
+ off_t st_size;
+# if 0
+ blksize_t st_blksize;
+ blkcnt_t st_blocks;
+# endif
+
+# if @WINDOWS_STAT_TIMESPEC@
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+# else
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+# endif
+};
+# if @WINDOWS_STAT_TIMESPEC@
+# define st_atime st_atim.tv_sec
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+ /* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_STAT_TIMESPEC 1
+# endif
+# define GNULIB_defined_struct_stat 1
+# endif
+
+/* Other possible values of st_mode. */
+# if 0
+# define _S_IFBLK 0x6000
+# endif
+# if 0
+# define _S_IFLNK 0xA000
+# endif
+# if 0
+# define _S_IFSOCK 0xC000
+# endif
+
+#endif
+
#ifndef S_IFIFO
# ifdef _S_IFIFO
# define S_IFIFO _S_IFIFO
@@ -345,6 +414,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
# endif
_GL_CXXALIASWARN (fstat);
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef fstat
+# define fstat fstat_used_without_requesting_gnulib_module_fstat
#elif @WINDOWS_64_BIT_ST_SIZE@
/* Above, we define stat to _stati64. */
# define fstat _fstati64
@@ -378,6 +450,9 @@ _GL_CXXALIAS_SYS (fstatat, int,
(int fd, char const *name, struct stat *st, int flags));
# endif
_GL_CXXALIASWARN (fstatat);
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef fstatat
+# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
#elif defined GNULIB_POSIXCHECK
# undef fstatat
# if HAVE_RAW_DECL_FSTATAT
@@ -476,6 +551,9 @@ _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
# if @HAVE_LSTAT@
_GL_CXXALIASWARN (lstat);
# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+# undef lstat
+# define lstat lstat_used_without_requesting_gnulib_module_lstat
#elif defined GNULIB_POSIXCHECK
# undef lstat
# if HAVE_RAW_DECL_LSTAT
@@ -498,7 +576,7 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
Additionally, it declares _mkdir (and depending on compile flags, an
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
which are included above. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
# if !GNULIB_defined_rpl_mkdir
static int
@@ -625,63 +703,69 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
#if @GNULIB_STAT@
# if @REPLACE_STAT@
-/* We can't use the object-like #define stat rpl_stat, because of
- struct stat. This means that rpl_stat will not be used if the user
- does (stat)(a,b). Oh well. */
-# if defined _AIX && defined stat && defined _LARGE_FILES
- /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
- so we have to replace stat64() instead of stat(). */
-# undef stat64
-# define stat64(name, st) rpl_stat (name, st)
-# elif @WINDOWS_64_BIT_ST_SIZE@
- /* Above, we define stat to _stati64. */
-# if defined __MINGW32__ && defined _stati64
-# ifndef _USE_32BIT_TIME_T
- /* The system headers define _stati64 to _stat64. */
-# undef _stat64
-# define _stat64(name, st) rpl_stat (name, st)
+# if !@GNULIB_OVERRIDES_STRUCT_STAT@
+ /* We can't use the object-like #define stat rpl_stat, because of
+ struct stat. This means that rpl_stat will not be used if the user
+ does (stat)(a,b). Oh well. */
+# if defined _AIX && defined stat && defined _LARGE_FILES
+ /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+ so we have to replace stat64() instead of stat(). */
+# undef stat64
+# define stat64(name, st) rpl_stat (name, st)
+# elif @WINDOWS_64_BIT_ST_SIZE@
+ /* Above, we define stat to _stati64. */
+# if defined __MINGW32__ && defined _stati64
+# ifndef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# elif defined _MSC_VER && defined _stati64
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define _stati64 to _stat32i64. */
+# undef _stat32i64
+# define _stat32i64(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define _stati64 to _stat64. */
+# undef _stat64
+# define _stat64(name, st) rpl_stat (name, st)
+# endif
+# else
+# undef _stati64
+# define _stati64(name, st) rpl_stat (name, st)
# endif
-# elif defined _MSC_VER && defined _stati64
+# elif defined __MINGW32__ && defined stat
# ifdef _USE_32BIT_TIME_T
- /* The system headers define _stati64 to _stat32i64. */
+ /* The system headers define stat to _stat32i64. */
# undef _stat32i64
# define _stat32i64(name, st) rpl_stat (name, st)
# else
- /* The system headers define _stati64 to _stat64. */
+ /* The system headers define stat to _stat64. */
# undef _stat64
# define _stat64(name, st) rpl_stat (name, st)
# endif
-# else
-# undef _stati64
-# define _stati64(name, st) rpl_stat (name, st)
-# endif
-# elif defined __MINGW32__ && defined stat
-# ifdef _USE_32BIT_TIME_T
- /* The system headers define stat to _stat32i64. */
-# undef _stat32i64
-# define _stat32i64(name, st) rpl_stat (name, st)
-# else
- /* The system headers define stat to _stat64. */
-# undef _stat64
-# define _stat64(name, st) rpl_stat (name, st)
-# endif
-# elif defined _MSC_VER && defined stat
-# ifdef _USE_32BIT_TIME_T
- /* The system headers define stat to _stat32. */
-# undef _stat32
-# define _stat32(name, st) rpl_stat (name, st)
-# else
- /* The system headers define stat to _stat64i32. */
-# undef _stat64i32
-# define _stat64i32(name, st) rpl_stat (name, st)
-# endif
-# else /* !(_AIX ||__MINGW32__ || _MSC_VER) */
-# undef stat
-# define stat(name, st) rpl_stat (name, st)
-# endif /* !_LARGE_FILES */
+# elif defined _MSC_VER && defined stat
+# ifdef _USE_32BIT_TIME_T
+ /* The system headers define stat to _stat32. */
+# undef _stat32
+# define _stat32(name, st) rpl_stat (name, st)
+# else
+ /* The system headers define stat to _stat64i32. */
+# undef _stat64i32
+# define _stat64i32(name, st) rpl_stat (name, st)
+# endif
+# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
+# undef stat
+# define stat(name, st) rpl_stat (name, st)
+# endif /* !_LARGE_FILES */
+# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
_GL_ARG_NONNULL ((1, 2));
# endif
+#elif @GNULIB_OVERRIDES_STRUCT_STAT@
+/* see above:
+ #define stat stat_used_without_requesting_gnulib_module_stat
+ */
#elif defined GNULIB_POSIXCHECK
# undef stat
# if HAVE_RAW_DECL_STAT
diff --git a/libgnu/sys_time.in.h b/libgnu/sys_time.in.h
deleted file mode 100644
index 57739bc4..00000000
--- a/libgnu/sys_time.in.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Provide a more complete sys/time.h.
-
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Paul Eggert. */
-
-#ifndef _@GUARD_PREFIX@_SYS_TIME_H
-
-#if __GNUC__ >= 3
-@PRAGMA_SYSTEM_HEADER@
-#endif
-@PRAGMA_COLUMNS@
-
-/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
- recursively via <sys/select.h>.
- Simply delegate to the system's header in this case; it is a no-op.
- Without this extra ifdef, the C++ gettimeofday declaration below
- would be a forward declaration in gnulib's nested <sys/time.h>. */
-#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
-# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-#else
-
-/* The include_next requires a split double-inclusion guard. */
-#if @HAVE_SYS_TIME_H@
-# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-#endif
-
-#ifndef _@GUARD_PREFIX@_SYS_TIME_H
-#define _@GUARD_PREFIX@_SYS_TIME_H
-
-#if ! @HAVE_SYS_TIME_H@
-# include <time.h>
-#endif
-
-/* On native Windows with MSVC, get the 'struct timeval' type.
- Also, on native Windows with a 64-bit time_t, where we are overriding the
- 'struct timeval' type, get all declarations of system functions whose
- signature contains 'struct timeval'. */
-#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
-# define _GL_INCLUDING_WINSOCK2_H
-# include <winsock2.h>
-# undef _GL_INCLUDING_WINSOCK2_H
-#endif
-
-/* 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. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
-
-# if @REPLACE_STRUCT_TIMEVAL@
-# define timeval rpl_timeval
-# endif
-
-# if !GNULIB_defined_struct_timeval
-struct timeval
-{
- time_t tv_sec;
- long int tv_usec;
-};
-# define GNULIB_defined_struct_timeval 1
-# endif
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#if @GNULIB_GETTIMEOFDAY@
-# if @REPLACE_GETTIMEOFDAY@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
-# endif
-_GL_FUNCDECL_RPL (gettimeofday, int,
- (struct timeval *restrict, void *restrict)
- _GL_ARG_NONNULL ((1)));
-_GL_CXXALIAS_RPL (gettimeofday, int,
- (struct timeval *restrict, void *restrict));
-# else
-# if !@HAVE_GETTIMEOFDAY@
-_GL_FUNCDECL_SYS (gettimeofday, int,
- (struct timeval *restrict, void *restrict)
- _GL_ARG_NONNULL ((1)));
-# endif
-/* Need to cast, because on glibc systems, by default, the second argument is
- struct timezone *. */
-_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
- (struct timeval *restrict, void *restrict));
-# endif
-_GL_CXXALIASWARN (gettimeofday);
-# if defined __cplusplus && defined GNULIB_NAMESPACE
-namespace GNULIB_NAMESPACE {
- typedef ::timeval
-#undef timeval
- timeval;
-}
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef gettimeofday
-# if HAVE_RAW_DECL_GETTIMEOFDAY
-_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
- "use gnulib module gettimeofday for portability");
-# endif
-#endif
-
-/* Hide some function declarations from <winsock2.h>. */
-
-#if defined _MSC_VER && @HAVE_WINSOCK2_H@
-# if !defined _@GUARD_PREFIX@_UNISTD_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef close
-# define close close_used_without_including_unistd_h
-# else
- _GL_WARN_ON_USE (close,
- "close() used without including <unistd.h>");
-# endif
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef gethostname
-# define gethostname gethostname_used_without_including_unistd_h
-# else
- _GL_WARN_ON_USE (gethostname,
- "gethostname() used without including <unistd.h>");
-# endif
-# endif
-# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef socket
-# define socket socket_used_without_including_sys_socket_h
-# undef connect
-# define connect connect_used_without_including_sys_socket_h
-# undef accept
-# define accept accept_used_without_including_sys_socket_h
-# undef bind
-# define bind bind_used_without_including_sys_socket_h
-# undef getpeername
-# define getpeername getpeername_used_without_including_sys_socket_h
-# undef getsockname
-# define getsockname getsockname_used_without_including_sys_socket_h
-# undef getsockopt
-# define getsockopt getsockopt_used_without_including_sys_socket_h
-# undef listen
-# define listen listen_used_without_including_sys_socket_h
-# undef recv
-# define recv recv_used_without_including_sys_socket_h
-# undef send
-# define send send_used_without_including_sys_socket_h
-# undef recvfrom
-# define recvfrom recvfrom_used_without_including_sys_socket_h
-# undef sendto
-# define sendto sendto_used_without_including_sys_socket_h
-# undef setsockopt
-# define setsockopt setsockopt_used_without_including_sys_socket_h
-# undef shutdown
-# define shutdown shutdown_used_without_including_sys_socket_h
-# else
- _GL_WARN_ON_USE (socket,
- "socket() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (connect,
- "connect() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (accept,
- "accept() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (bind,
- "bind() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (getpeername,
- "getpeername() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (getsockname,
- "getsockname() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (getsockopt,
- "getsockopt() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (listen,
- "listen() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (recv,
- "recv() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (send,
- "send() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (recvfrom,
- "recvfrom() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (sendto,
- "sendto() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (setsockopt,
- "setsockopt() used without including <sys/socket.h>");
- _GL_WARN_ON_USE (shutdown,
- "shutdown() used without including <sys/socket.h>");
-# endif
-# endif
-# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef select
-# define select select_used_without_including_sys_select_h
-# else
- _GL_WARN_ON_USE (select,
- "select() used without including <sys/select.h>");
-# endif
-# endif
-#endif
-
-#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
-#endif /* _CYGWIN_SYS_TIME_H */
-#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
diff --git a/libgnu/sys_types.in.h b/libgnu/sys_types.in.h
index 30ebfbdd..7f8c1c42 100644
--- a/libgnu/sys_types.in.h
+++ b/libgnu/sys_types.in.h
@@ -1,6 +1,6 @@
/* Provide a more complete sys/types.h.
- Copyright (C) 2011-2017 Free Software Foundation, Inc.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,13 +13,24 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
+#if defined _WIN32 && !defined __CYGWIN__ \
+ && (defined __need_off_t || defined __need___off64_t \
+ || defined __need_ssize_t || defined __need_time_t)
+
+/* Special invocation convention inside mingw header files. */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
+
+#else
+/* Normal invocation convention. */
+
#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
/* The include_next requires a split double-inclusion guard. */
@@ -42,12 +53,54 @@
# define _GL_WINDOWS_64_BIT_OFF_T 1
#endif
+/* Override dev_t and ino_t if distinguishable inodes support is requested
+ on native Windows. */
+#if @WINDOWS_STAT_INODES@
+
+# if @WINDOWS_STAT_INODES@ == 2
+/* Experimental, not useful in Windows 10. */
+
+/* Define dev_t to a 64-bit type. */
+# if !defined GNULIB_defined_dev_t
+typedef unsigned long long int rpl_dev_t;
+# undef dev_t
+# define dev_t rpl_dev_t
+# define GNULIB_defined_dev_t 1
+# endif
+
+/* Define ino_t to a 128-bit type. */
+# if !defined GNULIB_defined_ino_t
+/* MSVC does not have a 128-bit integer type.
+ GCC has a 128-bit integer type __int128, but only on 64-bit targets. */
+typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t;
+# undef ino_t
+# define ino_t rpl_ino_t
+# define GNULIB_defined_ino_t 1
+# endif
+
+# else /* @WINDOWS_STAT_INODES@ == 1 */
+
+/* Define ino_t to a 64-bit type. */
+# if !defined GNULIB_defined_ino_t
+typedef unsigned long long int rpl_ino_t;
+# undef ino_t
+# define ino_t rpl_ino_t
+# define GNULIB_defined_ino_t 1
+# endif
+
+# endif
+
+/* Indicator, for gnulib internal purposes. */
+# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@
+
+#endif
+
/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
/* But avoid namespace pollution on glibc systems. */
-#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
- && ! defined __GLIBC__
+#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__
# include <stddef.h>
#endif
#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
+#endif /* __need_XXX */
diff --git a/libgnu/sys_utsname.in.h b/libgnu/sys_utsname.in.h
index b287e883..2acae6ba 100644
--- a/libgnu/sys_utsname.in.h
+++ b/libgnu/sys_utsname.in.h
@@ -1,5 +1,5 @@
/* Substitute for <sys/utsname.h>.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_SYS_UTSNAME_H
diff --git a/libgnu/sys_wait.in.h b/libgnu/sys_wait.in.h
index 1458d26b..46129300 100644
--- a/libgnu/sys_wait.in.h
+++ b/libgnu/sys_wait.in.h
@@ -1,5 +1,5 @@
/* A POSIX-like <sys/wait.h>.
- Copyright (C) 2001-2003, 2005-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003, 2005-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_SYS_WAIT_H
@@ -23,7 +23,7 @@
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
-#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+#if !(defined _WIN32 && ! defined __CYGWIN__)
# @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
#endif
@@ -39,7 +39,7 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+#if !(defined _WIN32 && ! defined __CYGWIN__)
/* Unix API. */
/* The following macros apply to an argument x, that is a status of a process,
@@ -111,7 +111,7 @@
/* Declarations of functions. */
#if @GNULIB_WAITPID@
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
# endif
_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
diff --git a/libgnu/sysexits.in.h b/libgnu/sysexits.in.h
index e631b9c8..9ea88be2 100644
--- a/libgnu/sysexits.in.h
+++ b/libgnu/sysexits.in.h
@@ -1,5 +1,5 @@
/* exit() exit codes for some BSD system programs.
- Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Simon Josefsson based on sysexits(3) man page */
@@ -27,7 +27,7 @@
/* IRIX 6.5 has an <unistd.h> that defines a macro EX_OK with a nonzero
value. Override it. See
- <http://lists.gnu.org/archive/html/bug-gnulib/2007-03/msg00361.html> */
+ <https://lists.gnu.org/r/bug-gnulib/2007-03/msg00361.html> */
# ifdef __sgi
# include <unistd.h>
# undef EX_OK
diff --git a/libgnu/time.in.h b/libgnu/time.in.h
index fef89807..cda16c69 100644
--- a/libgnu/time.in.h
+++ b/libgnu/time.in.h
@@ -1,6 +1,6 @@
/* A more-standard <time.h>.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
@@ -120,6 +120,24 @@ _GL_CXXALIAS_SYS (nanosleep, int,
_GL_CXXALIASWARN (nanosleep);
# endif
+/* Initialize time conversion information. */
+# if @GNULIB_TZSET@
+# if @REPLACE_TZSET@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tzset
+# define tzset rpl_tzset
+# endif
+_GL_FUNCDECL_RPL (tzset, void, (void));
+_GL_CXXALIAS_RPL (tzset, void, (void));
+# else
+# if ! @HAVE_TZSET@
+_GL_FUNCDECL_SYS (tzset, void, (void));
+# endif
+_GL_CXXALIAS_SYS (tzset, void, (void));
+# endif
+_GL_CXXALIASWARN (tzset);
+# endif
+
/* Return the 'time_t' representation of TP and normalize TP. */
# if @GNULIB_MKTIME@
# if @REPLACE_MKTIME@
@@ -187,14 +205,14 @@ _GL_CXXALIASWARN (gmtime_r);
/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
<http://www.opengroup.org/susv3xsh/localtime.html> and
<http://www.opengroup.org/susv3xsh/gmtime.html>. */
-# if @GNULIB_GETTIMEOFDAY@
+# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
# if @REPLACE_LOCALTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef localtime
# define localtime rpl_localtime
# endif
_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
- _GL_ARG_NONNULL ((1)));
+ _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
# else
_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
@@ -202,7 +220,7 @@ _GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
_GL_CXXALIASWARN (localtime);
# endif
-# if @GNULIB_GETTIMEOFDAY@
+# if 0 || @REPLACE_GMTIME@
# if @REPLACE_GMTIME@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gmtime
@@ -233,6 +251,41 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
_GL_CXXALIASWARN (strptime);
# endif
+/* Convert *TP to a date and time string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
+# if @GNULIB_CTIME@
+# if @REPLACE_CTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define ctime rpl_ctime
+# endif
+_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
+# else
+_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
+# endif
+_GL_CXXALIASWARN (ctime);
+# endif
+
+/* Convert *TP to a date and time string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
+# if @GNULIB_STRFTIME@
+# if @REPLACE_STRFTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define strftime rpl_strftime
+# endif
+_GL_FUNCDECL_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+_GL_CXXALIAS_RPL (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp));
+# else
+_GL_CXXALIAS_SYS (strftime, size_t, (char *__buf, size_t __bufsize,
+ const char *__fmt, const struct tm *__tp));
+# endif
+_GL_CXXALIASWARN (strftime);
+# endif
+
# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
typedef struct tm_zone *timezone_t;
_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
diff --git a/libgnu/unistd--.h b/libgnu/unistd--.h
index dd1f068b..a6c5266f 100644
--- a/libgnu/unistd--.h
+++ b/libgnu/unistd--.h
@@ -1,6 +1,6 @@
/* Like unistd.h, but redefine some names to avoid glitches.
- Copyright (C) 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
diff --git a/libgnu/unistd-safer.h b/libgnu/unistd-safer.h
index 78302004..5baf339a 100644
--- a/libgnu/unistd-safer.h
+++ b/libgnu/unistd-safer.h
@@ -1,6 +1,6 @@
/* Invoke unistd-like functions, but avoid some glitches.
- Copyright (C) 2001, 2003, 2005, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2003, 2005, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert and Eric Blake. */
diff --git a/libgnu/unistd.in.h b/libgnu/unistd.in.h
index cb9321e5..b6a348f5 100644
--- a/libgnu/unistd.in.h
+++ b/libgnu/unistd.in.h
@@ -1,5 +1,5 @@
/* Substitute for and wrapper around <unistd.h>.
- Copyright (C) 2003-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_UNISTD_H
@@ -61,7 +61,7 @@
/* But avoid namespace pollution on glibc systems. */
#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
|| ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) \
+ && (defined _WIN32 && ! defined __CYGWIN__)) \
|| ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
&& defined __CYGWIN__)) \
&& ! defined __GLIBC__
@@ -94,13 +94,13 @@
lseek(), read(), unlink(), write() in <io.h>. */
#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
|| defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+ && (defined _WIN32 && ! defined __CYGWIN__))
# include <io.h> /* mingw32, mingw64 */
# include <direct.h> /* mingw64, MSVC 9 */
#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
|| @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
|| defined GNULIB_POSIXCHECK) \
- && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
+ && (defined _WIN32 && ! defined __CYGWIN__)
# include <io.h>
#endif
@@ -134,9 +134,8 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-/* Get getopt(), optarg, optind, opterr, optopt.
- But avoid namespace pollution on glibc systems. */
-#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
+/* Get getopt(), optarg, optind, opterr, optopt. */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
# include <getopt-cdefs.h>
# include <getopt-pfx-core.h>
#endif
@@ -379,7 +378,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
Close NEWFD first if it is open.
Return newfd if successful, otherwise -1 and errno set.
See the Linux man page at
- <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
+ <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
# if @HAVE_DUP3@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define dup3 rpl_dup3
@@ -401,6 +400,13 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
#if @GNULIB_ENVIRON@
+# if defined __CYGWIN__ && !defined __i386__
+/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
+ the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
+ This leads to a link error on 64-bit Cygwin when the option
+ -Wl,--disable-auto-import is in use. */
+_GL_EXTERN_C __declspec(dllimport) char **environ;
+# endif
# if !@HAVE_DECL_ENVIRON@
/* Set of environment variables and values. An array of strings of the form
"VARIABLE=VALUE", terminated with a NULL. */
@@ -462,13 +468,25 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
#if @GNULIB_FACCESSAT@
-# if !@HAVE_FACCESSAT@
+# if @REPLACE_FACCESSAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef faccessat
+# define faccessat rpl_faccessat
+# endif
+_GL_FUNCDECL_RPL (faccessat, int,
+ (int fd, char const *name, int mode, int flag)
+ _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (faccessat, int,
+ (int fd, char const *name, int mode, int flag));
+# else
+# if !@HAVE_FACCESSAT@
_GL_FUNCDECL_SYS (faccessat, int,
(int fd, char const *file, int mode, int flag)
_GL_ARG_NONNULL ((2)));
-# endif
+# endif
_GL_CXXALIAS_SYS (faccessat, int,
(int fd, char const *file, int mode, int flag));
+# endif
_GL_CXXALIASWARN (faccessat);
#elif defined GNULIB_POSIXCHECK
# undef faccessat
@@ -1149,7 +1167,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
Store the read-end as fd[0] and the write-end as fd[1].
Return 0 upon success, or -1 with errno set upon failure.
See also the Linux man page at
- <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
+ <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
# if @HAVE_PIPE2@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define pipe2 rpl_pipe2
@@ -1457,6 +1475,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
#endif
+#if @GNULIB_TRUNCATE@
+/* Change the size of the file designated by FILENAME to become equal to LENGTH.
+ Return 0 if successful, otherwise -1 and errno set.
+ See the POSIX:2008 specification
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
+# if @REPLACE_TRUNCATE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef truncate
+# define truncate rpl_truncate
+# endif
+_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
+# else
+# if !@HAVE_DECL_TRUNCATE@
+_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
+# endif
+_GL_CXXALIASWARN (truncate);
+#elif defined GNULIB_POSIXCHECK
+# undef truncate
+# if HAVE_RAW_DECL_TRUNCATE
+_GL_WARN_ON_USE (truncate, "truncate is unportable - "
+ "use gnulib module truncate for portability");
+# endif
+#endif
+
+
#if @GNULIB_TTYNAME_R@
/* Store at most BUFLEN characters of the pathname of the terminal FD is
open on in BUF. Return 0 on success, otherwise an error number. */
diff --git a/libgnu/vasnprintf.c b/libgnu/vasnprintf.c
index d654689d..3b441d03 100644
--- a/libgnu/vasnprintf.c
+++ b/libgnu/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2017 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
/* This file can be parametrized with the following macros:
VASNPRINTF The name of the function being defined.
@@ -118,6 +118,14 @@
# include "fpucw.h"
#endif
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+# define FALLTHROUGH ((void) 0)
+# else
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
/* Default parameters. */
#ifndef VASNPRINTF
# if WIDE_CHAR_VERSION
@@ -156,6 +164,7 @@
# define SNPRINTF snwprintf
# else
# define SNPRINTF _snwprintf
+# define USE_MSVC__SNPRINTF 1
# endif
# else
/* Unix. */
@@ -181,7 +190,9 @@
/* Here we need to call the native snprintf, not rpl_snprintf. */
# undef snprintf
# else
+ /* MSVC versions < 14 did not have snprintf, only _snprintf. */
# define SNPRINTF _snprintf
+# define USE_MSVC__SNPRINTF 1
# endif
# else
/* Unix. */
@@ -208,7 +219,7 @@
#undef remainder
#define remainder rem
-#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION
# if (HAVE_STRNLEN && !defined _AIX)
# define local_strnlen strnlen
# else
@@ -224,7 +235,7 @@ local_strnlen (const char *string, size_t maxlen)
# endif
#endif
-#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
+#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
# if HAVE_WCSLEN
# define local_wcslen wcslen
# else
@@ -247,7 +258,7 @@ local_wcslen (const wchar_t *s)
# endif
#endif
-#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
# if HAVE_WCSNLEN
# define local_wcsnlen wcsnlen
# else
@@ -1517,7 +1528,7 @@ is_borderline (const char *digits, size_t precision)
#endif
-#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
/* Use a different function name, to make it possible that the 'wchar_t'
parametrization and the 'char' parametrization get compiled in the same
@@ -2392,7 +2403,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
}
#endif
-#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
else if (dp->conversion == 's'
# if WIDE_CHAR_VERSION
&& a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -4232,7 +4243,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
static const wchar_t decimal_format[] =
/* Produce the same number of exponent digits
as the native printf implementation. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
{ '%', '+', '.', '3', 'd', '\0' };
# else
{ '%', '+', '.', '2', 'd', '\0' };
@@ -4246,7 +4257,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
static const char decimal_format[] =
/* Produce the same number of exponent digits
as the native printf implementation. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
"%+.3d";
# else
"%+.2d";
@@ -4425,7 +4436,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
static const wchar_t decimal_format[] =
/* Produce the same number of exponent digits
as the native printf implementation. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
{ '%', '+', '.', '3', 'd', '\0' };
# else
{ '%', '+', '.', '2', 'd', '\0' };
@@ -4439,7 +4450,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
static const char decimal_format[] =
/* Produce the same number of exponent digits
as the native printf implementation. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
"%+.3d";
# else
"%+.2d";
@@ -4497,7 +4508,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
*p++ = '+';
/* Produce the same number of exponent digits as
the native printf implementation. */
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
*p++ = '0';
# endif
*p++ = '0';
@@ -4591,10 +4602,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
int has_width;
#endif
-#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
size_t width;
#endif
-#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
int has_precision;
size_t precision;
#endif
@@ -4623,7 +4634,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
has_width = 0;
#endif
-#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
width = 0;
if (dp->width_start != dp->width_end)
{
@@ -4657,7 +4668,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
#endif
-#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
has_precision = 0;
precision = 6;
if (dp->precision_start != dp->precision_end)
@@ -4825,7 +4836,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
case TYPE_ULONGLONGINT:
-# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# if defined _WIN32 && ! defined __CYGWIN__
*fbp++ = 'I';
*fbp++ = '6';
*fbp++ = '4';
@@ -4834,7 +4845,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
*fbp++ = 'l';
# endif
#endif
- /*FALLTHROUGH*/
+ FALLTHROUGH;
case TYPE_LONGINT:
case TYPE_ULONGINT:
#if HAVE_WINT_T
@@ -4858,7 +4869,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#endif
*fbp = dp->conversion;
#if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
+ && !defined __UCLIBC__) \
+ || (defined __APPLE__ && defined __MACH__) \
+ || (defined _WIN32 && ! defined __CYGWIN__))
fbp[1] = '%';
fbp[2] = 'n';
fbp[3] = '\0';
@@ -4872,6 +4886,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
in format strings in writable memory may crash the program
(if compiled with _FORTIFY_SOURCE=2), so we should avoid it
in this situation. */
+ /* On Mac OS X 10.3 or newer, we know that snprintf's return
+ value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99
+ and gl_SNPRINTF_TRUNCATION_C99 pass.
+ Therefore we can avoid using %n in this situation.
+ On Mac OS X 10.13 or newer, the use of %n in format strings
+ in writable memory by default crashes the program, so we
+ should avoid it in this situation. */
/* On native Windows systems (such as mingw), we can avoid using
%n because:
- Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
@@ -4884,8 +4905,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
On native Windows systems (such as mingw) where the OS is
Windows Vista, the use of %n in format strings by default
crashes the program. See
- <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
- <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
+ <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
+ <https://msdn.microsoft.com/en-us/library/ms175782.aspx>
So we should avoid %n in this situation. */
fbp[1] = '\0';
# endif
@@ -5127,7 +5148,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Look at the snprintf() return value. */
if (retcount < 0)
{
-# if !HAVE_SNPRINTF_RETVAL_C99
+# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
/* HP-UX 10.20 snprintf() is doubly deficient:
It doesn't understand the '%n' directive,
*and* it returns -1 (rather than the length
diff --git a/libgnu/vasnprintf.h b/libgnu/vasnprintf.h
index c2278257..3eaaa7e5 100644
--- a/libgnu/vasnprintf.h
+++ b/libgnu/vasnprintf.h
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2004, 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2002-2004, 2007-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _VASNPRINTF_H
#define _VASNPRINTF_H
diff --git a/libgnu/verify.h b/libgnu/verify.h
index dcba9c8c..bc7f99db 100644
--- a/libgnu/verify.h
+++ b/libgnu/verify.h
@@ -1,6 +1,6 @@
/* Compile-time assert-like macros.
- Copyright (C) 2005-2006, 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
diff --git a/libgnu/vsnprintf.c b/libgnu/vsnprintf.c
index 6a19f4cc..e11ab6cd 100644
--- a/libgnu/vsnprintf.c
+++ b/libgnu/vsnprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 2004, 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2006-2018 Free Software Foundation, Inc.
Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
This program is free software; you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
- with this program; if not, see <http://www.gnu.org/licenses/>. */
+ with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
diff --git a/libgnu/warn-on-use.h b/libgnu/warn-on-use.h
index 3c0eb579..e76c3842 100644
--- a/libgnu/warn-on-use.h
+++ b/libgnu/warn-on-use.h
@@ -1,5 +1,5 @@
/* A C macro for emitting warnings if a function is used.
- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+ Copyright (C) 2010-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
for FUNCTION which will then trigger a compiler warning containing
diff --git a/libgnu/wchar.in.h b/libgnu/wchar.in.h
index c8f99f52..51a5dda1 100644
--- a/libgnu/wchar.in.h
+++ b/libgnu/wchar.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
- Copyright (C) 2007-2017 Free Software Foundation, Inc.
+ Copyright (C) 2007-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Eric Blake. */
@@ -31,7 +31,7 @@
@PRAGMA_COLUMNS@
#if (((defined __need_mbstate_t || defined __need_wint_t) \
- && !defined __MINGW32__ && !defined __KLIBC__) \
+ && !defined __MINGW32__) \
|| (defined __hpux \
&& ((defined _INTTYPES_INCLUDED && !defined strtoimax) \
|| defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
@@ -113,12 +113,16 @@
# define WEOF -1
# endif
#else
-/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>.
- This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
- "unchanged by default argument promotions". Override it. */
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
+ <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
+ wint_t must be "unchanged by default argument promotions". Override it. */
# if @GNULIB_OVERRIDES_WINT_T@
# if !GNULIB_defined_wint_t
-# include <crtdefs.h>
+# if @HAVE_CRTDEFS_H@
+# include <crtdefs.h>
+# else
+# include <stddef.h>
+# endif
typedef unsigned int rpl_wint_t;
# undef wint_t
# define wint_t rpl_wint_t
@@ -448,11 +452,6 @@ _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
# if !@HAVE_DECL_WCWIDTH@
/* wcwidth exists but is not declared. */
_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
-# elif defined __KLIBC__
-/* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
- static inline function. The implementation of wcwidth in wcwidth.c
- causes a "conflicting types" error. */
-# undef wcwidth
# endif
_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
# endif
@@ -1036,6 +1035,38 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
#endif
+/* Convert *TP to a date and time wide string. See
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
+#if @GNULIB_WCSFTIME@
+# if @REPLACE_WCSFTIME@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef wcsftime
+# define wcsftime rpl_wcsftime
+# endif
+_GL_FUNCDECL_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+_GL_CXXALIAS_RPL (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp));
+# else
+# if !@HAVE_WCSFTIME@
+_GL_FUNCDECL_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp)
+ _GL_ARG_NONNULL ((1, 3, 4)));
+# endif
+_GL_CXXALIAS_SYS (wcsftime, size_t, (wchar_t *__buf, size_t __bufsize,
+ const wchar_t *__fmt, const struct tm *__tp));
+# endif
+_GL_CXXALIASWARN (wcsftime);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsftime
+# if HAVE_RAW_DECL_WCSFTIME
+_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
+ "use gnulib module wcsftime for portability");
+# endif
+#endif
+
+
#endif /* _@GUARD_PREFIX@_WCHAR_H */
#endif /* _@GUARD_PREFIX@_WCHAR_H */
#endif
diff --git a/libgnu/wctype.in.h b/libgnu/wctype.in.h
index d106cf2d..3c6e5f29 100644
--- a/libgnu/wctype.in.h
+++ b/libgnu/wctype.in.h
@@ -1,6 +1,6 @@
/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
- Copyright (C) 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
/* Written by Bruno Haible and Paul Eggert. */
@@ -56,11 +56,13 @@
# include <wchar.h>
#endif
-/* mingw has declarations of towupper and towlower in <ctype.h> as
- well <wctype.h>. Include <ctype.h> in advance to avoid rpl_ prefix
- being added to the declarations. */
-#ifdef __MINGW32__
+/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
+ isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
+ <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
+ declarations. */
+#if defined _WIN32 && ! defined __CYGWIN__
# include <ctype.h>
+# include <wchar.h>
#endif
/* Include the original <wctype.h> if it exists.
@@ -105,12 +107,16 @@ _GL_INLINE_HEADER_BEGIN
# define WEOF -1
# endif
#else
-/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>.
- This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
- "unchanged by default argument promotions". Override it. */
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
+ <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
+ wint_t must be "unchanged by default argument promotions". Override it. */
# if @GNULIB_OVERRIDES_WINT_T@
# if !GNULIB_defined_wint_t
-# include <crtdefs.h>
+# if @HAVE_CRTDEFS_H@
+# include <crtdefs.h>
+# else
+# include <stddef.h>
+# endif
typedef unsigned int rpl_wint_t;
# undef wint_t
# define wint_t rpl_wint_t
diff --git a/libgnu/write.c b/libgnu/write.c
index 6a3b623e..06166241 100644
--- a/libgnu/write.c
+++ b/libgnu/write.c
@@ -1,5 +1,5 @@
/* POSIX compatible write() function.
- Copyright (C) 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2008-2018 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2008.
This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
@@ -25,7 +25,7 @@
GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
error EINVAL. */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#if defined _WIN32 && ! defined __CYGWIN__
# include <errno.h>
# include <signal.h>
@@ -34,8 +34,14 @@
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
-# include "msvc-inval.h"
-# include "msvc-nothrow.h"
+# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
+# include "msvc-inval.h"
+# endif
+# if GNULIB_MSVC_NOTHROW
+# include "msvc-nothrow.h"
+# else
+# include <io.h>
+# endif
# undef write
diff --git a/libgnu/xalloc-die.c b/libgnu/xalloc-die.c
deleted file mode 100644
index 3a64aa5c..00000000
--- a/libgnu/xalloc-die.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Report a memory allocation failure and exit.
-
- Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2017 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "xalloc.h"
-
-#include <stdlib.h>
-
-#include "error.h"
-#include "exitfail.h"
-
-#include "gettext.h"
-#define _(msgid) gettext (msgid)
-
-void
-xalloc_die (void)
-{
- error (exit_failure, 0, "%s", _("memory exhausted"));
-
- /* _Noreturn cannot be given to error, since it may return if
- its first argument is 0. To help compilers understand the
- xalloc_die does not return, call abort. Also, the abort is a
- safety feature if exit_failure is 0 (which shouldn't happen). */
- abort ();
-}
diff --git a/libgnu/xalloc-oversized.h b/libgnu/xalloc-oversized.h
index ff0efc6b..3426e10f 100644
--- a/libgnu/xalloc-oversized.h
+++ b/libgnu/xalloc-oversized.h
@@ -1,6 +1,6 @@
/* xalloc-oversized.h -- memory allocation size checking
- Copyright (C) 1990-2000, 2003-2004, 2006-2017 Free Software Foundation, Inc.
+ Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef XALLOC_OVERSIZED_H_
#define XALLOC_OVERSIZED_H_
@@ -44,7 +44,7 @@ typedef size_t __xalloc_count_type;
#if 7 <= __GNUC__
# define xalloc_oversized(n, s) \
__builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
-#elif 5 <= __GNUC__ && !__STRICT_ANSI__
+#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__
# define xalloc_oversized(n, s) \
(__builtin_constant_p (n) && __builtin_constant_p (s) \
? __xalloc_oversized (n, s) \
diff --git a/libgnu/xalloc.h b/libgnu/xalloc.h
deleted file mode 100644
index 484b67f1..00000000
--- a/libgnu/xalloc.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* xalloc.h -- malloc with out-of-memory checking
-
- Copyright (C) 1990-2000, 2003-2004, 2006-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef XALLOC_H_
-#define XALLOC_H_
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "xalloc-oversized.h"
-
-#ifndef _GL_INLINE_HEADER_BEGIN
- #error "Please include config.h first."
-#endif
-_GL_INLINE_HEADER_BEGIN
-#ifndef XALLOC_INLINE
-# define XALLOC_INLINE _GL_INLINE
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#if __GNUC__ >= 3
-# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#else
-# define _GL_ATTRIBUTE_MALLOC
-#endif
-
-#if ! defined __clang__ && \
- (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
-#else
-# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
-#endif
-
-/* This function is always triggered when memory is exhausted.
- It must be defined by the application, either explicitly
- or by using gnulib's xalloc-die module. This is the
- function to call when one wants the program to die because of a
- memory allocation failure. */
-extern _Noreturn void xalloc_die (void);
-
-void *xmalloc (size_t s)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-void *xzalloc (size_t s)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-void *xcalloc (size_t n, size_t s)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
-void *xrealloc (void *p, size_t s)
- _GL_ATTRIBUTE_ALLOC_SIZE ((2));
-void *x2realloc (void *p, size_t *pn);
-void *xmemdup (void const *p, size_t s)
- _GL_ATTRIBUTE_ALLOC_SIZE ((2));
-char *xstrdup (char const *str)
- _GL_ATTRIBUTE_MALLOC;
-
-/* In the following macros, T must be an elementary or structure/union or
- typedef'ed type, or a pointer to such a type. To apply one of the
- following macros to a function pointer or array type, you need to typedef
- it first and use the typedef name. */
-
-/* Allocate an object of type T dynamically, with error checking. */
-/* extern t *XMALLOC (typename t); */
-#define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
-
-/* Allocate memory for N elements of type T, with error checking. */
-/* extern t *XNMALLOC (size_t n, typename t); */
-#define XNMALLOC(n, t) \
- ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
-
-/* Allocate an object of type T dynamically, with error checking,
- and zero it. */
-/* extern t *XZALLOC (typename t); */
-#define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
-
-/* Allocate memory for N elements of type T, with error checking,
- and zero it. */
-/* extern t *XCALLOC (size_t n, typename t); */
-#define XCALLOC(n, t) \
- ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
-
-
-/* Allocate an array of N objects, each with S bytes of memory,
- dynamically, with error checking. S must be nonzero. */
-
-XALLOC_INLINE void *xnmalloc (size_t n, size_t s)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
-XALLOC_INLINE void *
-xnmalloc (size_t n, size_t s)
-{
- if (xalloc_oversized (n, s))
- xalloc_die ();
- return xmalloc (n * s);
-}
-
-/* Change the size of an allocated block of memory P to an array of N
- objects each of S bytes, with error checking. S must be nonzero. */
-
-XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
- _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
-XALLOC_INLINE void *
-xnrealloc (void *p, size_t n, size_t s)
-{
- if (xalloc_oversized (n, s))
- xalloc_die ();
- return xrealloc (p, n * s);
-}
-
-/* If P is null, allocate a block of at least *PN such objects;
- otherwise, reallocate P so that it contains more than *PN objects
- each of S bytes. S must be nonzero. Set *PN to the new number of
- objects, and return the pointer to the new block. *PN is never set
- to zero, and the returned pointer is never null.
-
- Repeated reallocations are guaranteed to make progress, either by
- allocating an initial block with a nonzero size, or by allocating a
- larger block.
-
- In the following implementation, nonzero sizes are increased by a
- factor of approximately 1.5 so that repeated reallocations have
- O(N) overall cost rather than O(N**2) cost, but the
- specification for this function does not guarantee that rate.
-
- Here is an example of use:
-
- int *p = NULL;
- size_t used = 0;
- size_t allocated = 0;
-
- void
- append_int (int value)
- {
- if (used == allocated)
- p = x2nrealloc (p, &allocated, sizeof *p);
- p[used++] = value;
- }
-
- This causes x2nrealloc to allocate a block of some nonzero size the
- first time it is called.
-
- To have finer-grained control over the initial size, set *PN to a
- nonzero value before calling this function with P == NULL. For
- example:
-
- int *p = NULL;
- size_t used = 0;
- size_t allocated = 0;
- size_t allocated1 = 1000;
-
- void
- append_int (int value)
- {
- if (used == allocated)
- {
- p = x2nrealloc (p, &allocated1, sizeof *p);
- allocated = allocated1;
- }
- p[used++] = value;
- }
-
- */
-
-XALLOC_INLINE void *
-x2nrealloc (void *p, size_t *pn, size_t s)
-{
- size_t n = *pn;
-
- if (! p)
- {
- if (! n)
- {
- /* The approximate size to use for initial small allocation
- requests, when the invoking code specifies an old size of
- zero. This is the largest "small" request for the GNU C
- library malloc. */
- enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
-
- n = DEFAULT_MXFAST / s;
- n += !n;
- }
- }
- else
- {
- /* Set N = floor (1.5 * N) + 1 so that progress is made even if N == 0.
- Check for overflow, so that N * S stays in both ptrdiff_t and
- size_t range. The check may be slightly conservative, but an
- exact check isn't worth the trouble. */
- if ((PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX) / 3 * 2 / s
- <= n)
- xalloc_die ();
- n += n / 2 + 1;
- }
-
- *pn = n;
- return xrealloc (p, n * s);
-}
-
-/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
- except it returns char *. */
-
-XALLOC_INLINE char *xcharalloc (size_t n)
- _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
-XALLOC_INLINE char *
-xcharalloc (size_t n)
-{
- return XNMALLOC (n, char);
-}
-
-#ifdef __cplusplus
-}
-
-/* C++ does not allow conversions from void * to other pointer types
- without a cast. Use templates to work around the problem when
- possible. */
-
-template <typename T> inline T *
-xrealloc (T *p, size_t s)
-{
- return (T *) xrealloc ((void *) p, s);
-}
-
-template <typename T> inline T *
-xnrealloc (T *p, size_t n, size_t s)
-{
- return (T *) xnrealloc ((void *) p, n, s);
-}
-
-template <typename T> inline T *
-x2realloc (T *p, size_t *pn)
-{
- return (T *) x2realloc ((void *) p, pn);
-}
-
-template <typename T> inline T *
-x2nrealloc (T *p, size_t *pn, size_t s)
-{
- return (T *) x2nrealloc ((void *) p, pn, s);
-}
-
-template <typename T> inline T *
-xmemdup (T const *p, size_t s)
-{
- return (T *) xmemdup ((void const *) p, s);
-}
-
-#endif
-
-_GL_INLINE_HEADER_END
-
-#endif /* !XALLOC_H_ */
diff --git a/libgnu/xgetcwd.c b/libgnu/xgetcwd.c
deleted file mode 100644
index 04d51cba..00000000
--- a/libgnu/xgetcwd.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* xgetcwd.c -- return current directory with unlimited length
-
- Copyright (C) 2001, 2003-2004, 2006-2007, 2009-2017 Free Software
- Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-/* Written by Jim Meyering. */
-
-#include <config.h>
-
-#include "xgetcwd.h"
-
-#include <errno.h>
-#include <unistd.h>
-
-#include "xalloc.h"
-
-/* Return the current directory, newly allocated.
- Upon an out-of-memory error, call xalloc_die.
- Upon any other type of error, return NULL. */
-
-char *
-xgetcwd (void)
-{
- char *cwd = getcwd (NULL, 0);
- if (! cwd && errno == ENOMEM)
- xalloc_die ();
- return cwd;
-}
diff --git a/libgnu/xgetcwd.h b/libgnu/xgetcwd.h
deleted file mode 100644
index 638daf80..00000000
--- a/libgnu/xgetcwd.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/* prototype for xgetcwd
- Copyright (C) 1995, 2001, 2003, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-extern char *xgetcwd (void);
diff --git a/libgnu/xmalloc.c b/libgnu/xmalloc.c
deleted file mode 100644
index a4d308d2..00000000
--- a/libgnu/xmalloc.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* xmalloc.c -- malloc with out of memory checking
-
- Copyright (C) 1990-2000, 2002-2006, 2008-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#define XALLOC_INLINE _GL_EXTERN_INLINE
-
-#include "xalloc.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-/* 1 if calloc is known to be compatible with GNU calloc. This
- matters if we are not also using the calloc module, which defines
- HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */
-#if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__)
-enum { HAVE_GNU_CALLOC = 1 };
-#else
-enum { HAVE_GNU_CALLOC = 0 };
-#endif
-
-/* Allocate N bytes of memory dynamically, with error checking. */
-
-void *
-xmalloc (size_t n)
-{
- void *p = malloc (n);
- if (!p && n != 0)
- xalloc_die ();
- return p;
-}
-
-/* Change the size of an allocated block of memory P to N bytes,
- with error checking. */
-
-void *
-xrealloc (void *p, size_t n)
-{
- if (!n && p)
- {
- /* The GNU and C99 realloc behaviors disagree here. Act like
- GNU, even if the underlying realloc is C99. */
- free (p);
- return NULL;
- }
-
- p = realloc (p, n);
- if (!p && n)
- xalloc_die ();
- return p;
-}
-
-/* If P is null, allocate a block of at least *PN bytes; otherwise,
- reallocate P so that it contains more than *PN bytes. *PN must be
- nonzero unless P is null. Set *PN to the new block's size, and
- return the pointer to the new block. *PN is never set to zero, and
- the returned pointer is never null. */
-
-void *
-x2realloc (void *p, size_t *pn)
-{
- return x2nrealloc (p, pn, 1);
-}
-
-/* Allocate S bytes of zeroed memory dynamically, with error checking.
- There's no need for xnzalloc (N, S), since it would be equivalent
- to xcalloc (N, S). */
-
-void *
-xzalloc (size_t s)
-{
- return memset (xmalloc (s), 0, s);
-}
-
-/* Allocate zeroed memory for N elements of S bytes, with error
- checking. S must be nonzero. */
-
-void *
-xcalloc (size_t n, size_t s)
-{
- void *p;
- /* Test for overflow, since objects with size greater than
- PTRDIFF_MAX cause pointer subtraction to go awry. Omit size-zero
- tests if HAVE_GNU_CALLOC, since GNU calloc never returns NULL if
- successful. */
- if (xalloc_oversized (n, s)
- || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
- xalloc_die ();
- return p;
-}
-
-/* Clone an object P of size S, with error checking. There's no need
- for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
- need for an arithmetic overflow check. */
-
-void *
-xmemdup (void const *p, size_t s)
-{
- return memcpy (xmalloc (s), p, s);
-}
-
-/* Clone STRING. */
-
-char *
-xstrdup (char const *string)
-{
- return xmemdup (string, strlen (string) + 1);
-}
diff --git a/libgnu/xsize.h b/libgnu/xsize.h
index daf78d60..8aeb3b7a 100644
--- a/libgnu/xsize.h
+++ b/libgnu/xsize.h
@@ -1,6 +1,6 @@
/* xsize.h -- Checked size_t computations.
- Copyright (C) 2003, 2008-2017 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2008-2018 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
#ifndef _XSIZE_H
#define _XSIZE_H
diff --git a/libgnu/xstrndup.c b/libgnu/xstrndup.c
deleted file mode 100644
index 8fbef7f0..00000000
--- a/libgnu/xstrndup.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Duplicate a bounded initial segment of a string, with out-of-memory
- checking.
- Copyright (C) 2003, 2006-2007, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "xstrndup.h"
-
-#include <string.h>
-#include "xalloc.h"
-
-/* Return a newly allocated copy of at most N bytes of STRING.
- In other words, return a copy of the initial segment of length N of
- STRING. */
-char *
-xstrndup (const char *string, size_t n)
-{
- char *s = strndup (string, n);
- if (! s)
- xalloc_die ();
- return s;
-}
diff --git a/libgnu/xstrndup.h b/libgnu/xstrndup.h
deleted file mode 100644
index d901c2c3..00000000
--- a/libgnu/xstrndup.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Duplicate a bounded initial segment of a string, with out-of-memory
- checking.
- Copyright (C) 2003, 2009-2017 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <stddef.h>
-
-/* Return a newly allocated copy of at most N bytes of STRING.
- In other words, return a copy of the initial segment of length N of
- STRING. */
-extern char *xstrndup (const char *string, size_t n);