aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPhilip Kaludercic2022-07-31 14:27:28 +0200
committerPhilip Kaludercic2022-07-31 14:27:28 +0200
commit118033294136a8fb3a14347ce190b447dd2ff2fe (patch)
tree3d036aa53a16c1283883b0955cbed77be3295310 /lib
parentedd73bd0d5474b71cbd4261c6a722be8f652bb9a (diff)
parentac237334c7672377721e4d27e8ecd6b09d453568 (diff)
downloademacs-118033294136a8fb3a14347ce190b447dd2ff2fe.tar.gz
emacs-118033294136a8fb3a14347ce190b447dd2ff2fe.zip
Merge remote-tracking branch 'origin/master' into feature/package+vc
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-errno-valid.c2
-rw-r--r--lib/acl-internal.c2
-rw-r--r--lib/acl-internal.h2
-rw-r--r--lib/acl.h2
-rw-r--r--lib/acl_entries.c2
-rw-r--r--lib/at-func.c2
-rw-r--r--lib/cdefs.h19
-rw-r--r--lib/close-stream.c2
-rw-r--r--lib/close-stream.h2
-rw-r--r--lib/copy-file-range.c34
-rw-r--r--lib/diffseq.h2
-rw-r--r--lib/dtoastr.c2
-rw-r--r--lib/dtotimespec.c2
-rw-r--r--lib/faccessat.c2
-rw-r--r--lib/fchmodat.c61
-rw-r--r--lib/fcntl.in.h4
-rw-r--r--lib/fdopendir.c2
-rw-r--r--lib/file-has-acl.c2
-rw-r--r--lib/filemode.c2
-rw-r--r--lib/filemode.h2
-rw-r--r--lib/filevercmp.c193
-rw-r--r--lib/filevercmp.h70
-rw-r--r--lib/fpending.c2
-rw-r--r--lib/fpending.h2
-rw-r--r--lib/fstatat.c2
-rw-r--r--lib/fsusage.c2
-rw-r--r--lib/fsusage.h2
-rw-r--r--lib/ftoastr.c2
-rw-r--r--lib/ftoastr.h2
-rw-r--r--lib/futimens.c2
-rw-r--r--lib/get-permissions.c2
-rw-r--r--lib/getloadavg.c2
-rw-r--r--lib/gettime.c2
-rw-r--r--lib/gnulib.mk.in435
-rw-r--r--lib/intprops.h8
-rw-r--r--lib/lchmod.c86
-rw-r--r--lib/libc-config.h11
-rw-r--r--lib/md5.h3
-rw-r--r--lib/memrchr.c2
-rw-r--r--lib/mini-gmp-gnulib.c5
-rw-r--r--lib/mini-gmp.c4
-rw-r--r--lib/mktime.c28
-rw-r--r--lib/nanosleep.c195
-rw-r--r--lib/nstrftime.c3
-rw-r--r--lib/openat-priv.h2
-rw-r--r--lib/openat-proc.c2
-rw-r--r--lib/openat.h4
-rw-r--r--lib/qcopy-acl.c2
-rw-r--r--lib/readlinkat.c2
-rw-r--r--lib/regcomp.c16
-rw-r--r--lib/regex_internal.c22
-rw-r--r--lib/regexec.c5
-rw-r--r--lib/save-cwd.h2
-rw-r--r--lib/set-permissions.c2
-rw-r--r--lib/sha1.h3
-rw-r--r--lib/sha256.h3
-rw-r--r--lib/sha512.h3
-rw-r--r--lib/sig2str.c2
-rw-r--r--lib/sig2str.h2
-rw-r--r--lib/stdlib.in.h4
-rw-r--r--lib/str-two-way.h4
-rw-r--r--lib/strftime.h2
-rw-r--r--lib/string.in.h106
-rw-r--r--lib/strtoimax.c2
-rw-r--r--lib/strtol.c2
-rw-r--r--lib/strtoll.c2
-rw-r--r--lib/symlink.c2
-rw-r--r--lib/sys_stat.in.h28
-rw-r--r--lib/time-internal.h2
-rw-r--r--lib/time_rz.c2
-rw-r--r--lib/timespec-add.c2
-rw-r--r--lib/timespec-sub.c2
-rw-r--r--lib/timespec.c2
-rw-r--r--lib/timespec.h2
-rw-r--r--lib/unistd.in.h16
-rw-r--r--lib/unlocked-io.h2
-rw-r--r--lib/utimens.c2
-rw-r--r--lib/utimens.h2
-rw-r--r--lib/utimensat.c2
-rw-r--r--lib/verify.h5
-rw-r--r--lib/vla.h2
81 files changed, 982 insertions, 500 deletions
diff --git a/lib/acl-errno-valid.c b/lib/acl-errno-valid.c
index 39717c35174..a364e413256 100644
--- a/lib/acl-errno-valid.c
+++ b/lib/acl-errno-valid.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index 75a80bf0df2..be244c67a2a 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 582f9e1c1a1..93533762dd0 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/acl.h b/lib/acl.h
index 8b933c20b94..f4d0df80618 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/acl_entries.c b/lib/acl_entries.c
index e4c014ce715..677de23e0cb 100644
--- a/lib/acl_entries.c
+++ b/lib/acl_entries.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/at-func.c b/lib/at-func.c
index 92d65f6341f..afcc819beb0 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
diff --git a/lib/cdefs.h b/lib/cdefs.h
index abf13a90862..7b8ed5b344b 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -41,7 +41,9 @@
41 Similarly for __has_builtin, etc. */ 41 Similarly for __has_builtin, etc. */
42#if (defined __has_attribute \ 42#if (defined __has_attribute \
43 && (!defined __clang_minor__ \ 43 && (!defined __clang_minor__ \
44 || 3 < __clang_major__ + (5 <= __clang_minor__))) 44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__))))
45# define __glibc_has_attribute(attr) __has_attribute (attr) 47# define __glibc_has_attribute(attr) __has_attribute (attr)
46#else 48#else
47# define __glibc_has_attribute(attr) 0 49# define __glibc_has_attribute(attr) 0
@@ -143,7 +145,8 @@
143#define __bos0(ptr) __builtin_object_size (ptr, 0) 145#define __bos0(ptr) __builtin_object_size (ptr, 0)
144 146
145/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ 147/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
146#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0) 148#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
149 || __GNUC_PREREQ (12, 0))
147# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) 150# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
148# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) 151# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
149#else 152#else
@@ -161,13 +164,13 @@
161 || (__builtin_constant_p (__l) && (__l) > 0)) 164 || (__builtin_constant_p (__l) && (__l) > 0))
162 165
163/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ 166/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
164 condition can be folded to a constant and if it is true. The -1 check is 167 condition can be folded to a constant and if it is true, or unknown (-1) */
165 redundant because since it implies that __glibc_safe_len_cond is true. */
166#define __glibc_safe_or_unknown_len(__l, __s, __osz) \ 168#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
167 (__glibc_unsigned_or_positive (__l) \ 169 ((__osz) == (__SIZE_TYPE__) -1 \
168 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ 170 || (__glibc_unsigned_or_positive (__l) \
169 __s, __osz)) \ 171 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
170 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz)) 172 (__s), (__osz))) \
173 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
171 174
172/* Conversely, we know at compile time that the length is unsafe if the 175/* Conversely, we know at compile time that the length is unsafe if the
173 __L * __S <= __OBJSZ condition can be folded to a constant and if it is 176 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
diff --git a/lib/close-stream.c b/lib/close-stream.c
index 54f3e3c3d0c..9b0e97b271d 100644
--- a/lib/close-stream.c
+++ b/lib/close-stream.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/close-stream.h b/lib/close-stream.h
index 537506c4896..2b4c8ed8f5b 100644
--- a/lib/close-stream.h
+++ b/lib/close-stream.h
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/copy-file-range.c b/lib/copy-file-range.c
index 96f1ec7c5e8..1ec7f4de67c 100644
--- a/lib/copy-file-range.c
+++ b/lib/copy-file-range.c
@@ -20,11 +20,45 @@
20 20
21#include <errno.h> 21#include <errno.h>
22 22
23#if defined __linux__ && HAVE_COPY_FILE_RANGE
24# include <sys/utsname.h>
25#endif
26
23ssize_t 27ssize_t
24copy_file_range (int infd, off_t *pinoff, 28copy_file_range (int infd, off_t *pinoff,
25 int outfd, off_t *poutoff, 29 int outfd, off_t *poutoff,
26 size_t length, unsigned int flags) 30 size_t length, unsigned int flags)
27{ 31{
32#undef copy_file_range
33
34#if defined __linux__ && HAVE_COPY_FILE_RANGE
35 /* The implementation of copy_file_range (which first appeared in
36 Linux kernel release 4.5) had many issues before release 5.3
37 <https://lwn.net/Articles/789527/>, so fail with ENOSYS for Linux
38 kernels 5.2 and earlier.
39
40 This workaround, and the configure-time check for Linux, can be
41 removed when such kernels (released March 2016 through September
42 2019) are no longer a consideration. As of January 2021, the
43 furthest-future planned kernel EOL is December 2024 for kernel
44 release 4.19. */
45
46 static signed char ok;
47
48 if (! ok)
49 {
50 struct utsname name;
51 uname (&name);
52 char *p = name.release;
53 ok = ((p[1] != '.' || '5' < p[0]
54 || (p[0] == '5' && (p[3] != '.' || '2' < p[2])))
55 ? 1 : -1);
56 }
57
58 if (0 < ok)
59 return copy_file_range (infd, pinoff, outfd, poutoff, length, flags);
60#endif
61
28 /* There is little need to emulate copy_file_range with read+write, 62 /* There is little need to emulate copy_file_range with read+write,
29 since programs that use copy_file_range must fall back on 63 since programs that use copy_file_range must fall back on
30 read+write anyway. */ 64 read+write anyway. */
diff --git a/lib/diffseq.h b/lib/diffseq.h
index 0c901a6ecfd..0f76ea1d5ad 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -5,7 +5,7 @@
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
diff --git a/lib/dtoastr.c b/lib/dtoastr.c
index eaade8fa016..71af14c9df4 100644
--- a/lib/dtoastr.c
+++ b/lib/dtoastr.c
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index 225a2be67c4..b62a8bd6cfc 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/faccessat.c b/lib/faccessat.c
index 2c0c07aac10..c1737d03a10 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
diff --git a/lib/fchmodat.c b/lib/fchmodat.c
index 506e6badd7d..164e2c4a95f 100644
--- a/lib/fchmodat.c
+++ b/lib/fchmodat.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -83,9 +83,10 @@ fchmodat (int dir, char const *file, mode_t mode, int flags)
83# if NEED_FCHMODAT_NONSYMLINK_FIX 83# if NEED_FCHMODAT_NONSYMLINK_FIX
84 if (flags == AT_SYMLINK_NOFOLLOW) 84 if (flags == AT_SYMLINK_NOFOLLOW)
85 { 85 {
86 struct stat st; 86# if HAVE_READLINKAT
87 char readlink_buf[1];
87 88
88# if defined O_PATH && defined AT_EMPTY_PATH 89# ifdef O_PATH
89 /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 90 /* Open a file descriptor with O_NOFOLLOW, to make sure we don't
90 follow symbolic links, if /proc is mounted. O_PATH is used to 91 follow symbolic links, if /proc is mounted. O_PATH is used to
91 avoid a failure if the file is not readable. 92 avoid a failure if the file is not readable.
@@ -94,49 +95,29 @@ fchmodat (int dir, char const *file, mode_t mode, int flags)
94 if (fd < 0) 95 if (fd < 0)
95 return fd; 96 return fd;
96 97
97 /* Up to Linux 5.3 at least, when FILE refers to a symbolic link, the 98 int err;
98 chmod call below will change the permissions of the symbolic link 99 if (0 <= readlinkat (fd, "", readlink_buf, sizeof readlink_buf))
99 - which is undesired - and on many file systems (ext4, btrfs, jfs, 100 err = EOPNOTSUPP;
100 xfs, ..., but not reiserfs) fail with error EOPNOTSUPP - which is 101 else if (errno == EINVAL)
101 misleading. Therefore test for a symbolic link explicitly.
102 Use fstatat because fstat does not work on O_PATH descriptors
103 before Linux 3.6. */
104 if (fstatat (fd, "", &st, AT_EMPTY_PATH) != 0)
105 { 102 {
106 int stat_errno = errno; 103 static char const fmt[] = "/proc/self/fd/%d";
107 close (fd); 104 char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
108 errno = stat_errno; 105 sprintf (buf, fmt, fd);
109 return -1; 106 err = chmod (buf, mode) == 0 ? 0 : errno == ENOENT ? -1 : errno;
110 }
111 if (S_ISLNK (st.st_mode))
112 {
113 close (fd);
114 errno = EOPNOTSUPP;
115 return -1;
116 } 107 }
108 else
109 err = errno == ENOENT ? -1 : errno;
117 110
118# if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__
119 static char const fmt[] = "/proc/self/fd/%d";
120 char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
121 sprintf (buf, fmt, fd);
122 int chmod_result = chmod (buf, mode);
123 int chmod_errno = errno;
124 close (fd); 111 close (fd);
125 if (chmod_result == 0) 112
126 return chmod_result; 113 errno = err;
127 if (chmod_errno != ENOENT) 114 if (0 <= err)
128 { 115 return err == 0 ? 0 : -1;
129 errno = chmod_errno;
130 return chmod_result;
131 }
132# endif 116# endif
133 /* /proc is not mounted or would not work as in GNU/Linux. */
134 117
135# else 118 /* O_PATH + /proc is not supported. */
136 int fstatat_result = fstatat (dir, file, &st, AT_SYMLINK_NOFOLLOW); 119
137 if (fstatat_result != 0) 120 if (0 <= readlinkat (dir, file, readlink_buf, sizeof readlink_buf))
138 return fstatat_result;
139 if (S_ISLNK (st.st_mode))
140 { 121 {
141 errno = EOPNOTSUPP; 122 errno = EOPNOTSUPP;
142 return -1; 123 return -1;
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 3e0c302af33..9270ced8973 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -435,6 +435,10 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
435# define AT_EACCESS 4 435# define AT_EACCESS 4
436#endif 436#endif
437 437
438/* Ignore this flag if not supported. */
439#ifndef AT_NO_AUTOMOUNT
440# define AT_NO_AUTOMOUNT 0
441#endif
438 442
439#endif /* _@GUARD_PREFIX@_FCNTL_H */ 443#endif /* _@GUARD_PREFIX@_FCNTL_H */
440#endif /* _@GUARD_PREFIX@_FCNTL_H */ 444#endif /* _@GUARD_PREFIX@_FCNTL_H */
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
index a61bad66e23..c2b0e1ed347 100644
--- a/lib/fdopendir.c
+++ b/lib/fdopendir.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index 2b6f91ff20a..e02f0626ad3 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/filemode.c b/lib/filemode.c
index cb508ad12d1..a8cbea844c8 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -5,7 +5,7 @@
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
diff --git a/lib/filemode.h b/lib/filemode.h
index 7c645c16b51..bf38181cdcd 100644
--- a/lib/filemode.h
+++ b/lib/filemode.h
@@ -5,7 +5,7 @@
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index b3e6e2f3cb8..7e54793e613 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -1,11 +1,12 @@
1/* 1/* Compare file names containing version numbers.
2
2 Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> 3 Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
3 Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au> 4 Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au>
4 Copyright (C) 2008-2022 Free Software Foundation, Inc. 5 Copyright (C) 2008-2022 Free Software Foundation, Inc.
5 6
6 This file is free software: you can redistribute it and/or modify 7 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 8 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 9 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 10 License, or (at your option) any later version.
10 11
11 This file is distributed in the hope that it will be useful, 12 This file is distributed in the hope that it will be useful,
@@ -19,60 +20,69 @@
19#include <config.h> 20#include <config.h>
20#include "filevercmp.h" 21#include "filevercmp.h"
21 22
22#include <sys/types.h>
23#include <stdlib.h>
24#include <stdbool.h> 23#include <stdbool.h>
25#include <string.h>
26#include <c-ctype.h> 24#include <c-ctype.h>
27#include <limits.h> 25#include <limits.h>
28 26#include <idx.h>
29/* Match a file suffix defined by this regular expression: 27#include <verify.h>
30 /(\.[A-Za-z~][A-Za-z0-9~]*)*$/ 28
31 Scan the string *STR and return a pointer to the matching suffix, or 29/* Return the length of a prefix of S that corresponds to the suffix
32 NULL if not found. Upon return, *STR points to terminating NUL. */ 30 defined by this extended regular expression in the C locale:
33static const char * 31 (\.[A-Za-z~][A-Za-z0-9~]*)*$
34match_suffix (const char **str) 32 Use the longest suffix matching this regular expression,
33 except do not use all of S as a suffix if S is nonempty.
34 If *LEN is -1, S is a string; set *LEN to S's length.
35 Otherwise, *LEN should be nonnegative, S is a char array,
36 and *LEN does not change. */
37static idx_t
38file_prefixlen (char const *s, ptrdiff_t *len)
35{ 39{
36 const char *match = NULL; 40 size_t n = *len; /* SIZE_MAX if N == -1. */
37 bool read_alpha = false; 41 idx_t prefixlen = 0;
38 while (**str) 42
43 for (idx_t i = 0; ; )
39 { 44 {
40 if (read_alpha) 45 if (*len < 0 ? !s[i] : i == n)
41 {
42 read_alpha = false;
43 if (!c_isalpha (**str) && '~' != **str)
44 match = NULL;
45 }
46 else if ('.' == **str)
47 { 46 {
48 read_alpha = true; 47 *len = i;
49 if (!match) 48 return prefixlen;
50 match = *str;
51 } 49 }
52 else if (!c_isalnum (**str) && '~' != **str) 50
53 match = NULL; 51 i++;
54 (*str)++; 52 prefixlen = i;
53 while (i + 1 < n && s[i] == '.' && (c_isalpha (s[i + 1])
54 || s[i + 1] == '~'))
55 for (i += 2; i < n && (c_isalnum (s[i]) || s[i] == '~'); i++)
56 continue;
55 } 57 }
56 return match;
57} 58}
58 59
59/* verrevcmp helper function */ 60/* Return a version sort comparison value for S's byte at position POS.
61 S has length LEN. If POS == LEN, sort before all non-'~' bytes. */
62
60static int 63static int
61order (unsigned char c) 64order (char const *s, idx_t pos, idx_t len)
62{ 65{
66 if (pos == len)
67 return -1;
68
69 unsigned char c = s[pos];
63 if (c_isdigit (c)) 70 if (c_isdigit (c))
64 return 0; 71 return 0;
65 else if (c_isalpha (c)) 72 else if (c_isalpha (c))
66 return c; 73 return c;
67 else if (c == '~') 74 else if (c == '~')
68 return -1; 75 return -2;
69 else 76 else
70 return (int) c + UCHAR_MAX + 1; 77 {
78 verify (UCHAR_MAX <= (INT_MAX - 1 - 2) / 2);
79 return c + UCHAR_MAX + 1;
80 }
71} 81}
72 82
73/* slightly modified verrevcmp function from dpkg 83/* slightly modified verrevcmp function from dpkg
74 S1, S2 - compared string 84 S1, S2 - compared char array
75 S1_LEN, S2_LEN - length of strings to be scanned 85 S1_LEN, S2_LEN - length of arrays to be scanned
76 86
77 This implements the algorithm for comparison of version strings 87 This implements the algorithm for comparison of version strings
78 specified by Debian and now widely adopted. The detailed 88 specified by Debian and now widely adopted. The detailed
@@ -81,37 +91,38 @@ order (unsigned char c)
81 implements that from s5.6.12 of Debian Policy v3.8.0.1 91 implements that from s5.6.12 of Debian Policy v3.8.0.1
82 https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */ 92 https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version */
83static int _GL_ATTRIBUTE_PURE 93static int _GL_ATTRIBUTE_PURE
84verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len) 94verrevcmp (const char *s1, idx_t s1_len, const char *s2, idx_t s2_len)
85{ 95{
86 size_t s1_pos = 0; 96 idx_t s1_pos = 0;
87 size_t s2_pos = 0; 97 idx_t s2_pos = 0;
88 while (s1_pos < s1_len || s2_pos < s2_len) 98 while (s1_pos < s1_len || s2_pos < s2_len)
89 { 99 {
90 int first_diff = 0; 100 int first_diff = 0;
91 while ((s1_pos < s1_len && !c_isdigit (s1[s1_pos])) 101 while ((s1_pos < s1_len && !c_isdigit (s1[s1_pos]))
92 || (s2_pos < s2_len && !c_isdigit (s2[s2_pos]))) 102 || (s2_pos < s2_len && !c_isdigit (s2[s2_pos])))
93 { 103 {
94 int s1_c = (s1_pos == s1_len) ? 0 : order (s1[s1_pos]); 104 int s1_c = order (s1, s1_pos, s1_len);
95 int s2_c = (s2_pos == s2_len) ? 0 : order (s2[s2_pos]); 105 int s2_c = order (s2, s2_pos, s2_len);
96 if (s1_c != s2_c) 106 if (s1_c != s2_c)
97 return s1_c - s2_c; 107 return s1_c - s2_c;
98 s1_pos++; 108 s1_pos++;
99 s2_pos++; 109 s2_pos++;
100 } 110 }
101 while (s1[s1_pos] == '0') 111 while (s1_pos < s1_len && s1[s1_pos] == '0')
102 s1_pos++; 112 s1_pos++;
103 while (s2[s2_pos] == '0') 113 while (s2_pos < s2_len && s2[s2_pos] == '0')
104 s2_pos++; 114 s2_pos++;
105 while (c_isdigit (s1[s1_pos]) && c_isdigit (s2[s2_pos])) 115 while (s1_pos < s1_len && s2_pos < s2_len
116 && c_isdigit (s1[s1_pos]) && c_isdigit (s2[s2_pos]))
106 { 117 {
107 if (!first_diff) 118 if (!first_diff)
108 first_diff = s1[s1_pos] - s2[s2_pos]; 119 first_diff = s1[s1_pos] - s2[s2_pos];
109 s1_pos++; 120 s1_pos++;
110 s2_pos++; 121 s2_pos++;
111 } 122 }
112 if (c_isdigit (s1[s1_pos])) 123 if (s1_pos < s1_len && c_isdigit (s1[s1_pos]))
113 return 1; 124 return 1;
114 if (c_isdigit (s2[s2_pos])) 125 if (s2_pos < s2_len && c_isdigit (s2[s2_pos]))
115 return -1; 126 return -1;
116 if (first_diff) 127 if (first_diff)
117 return first_diff; 128 return first_diff;
@@ -124,58 +135,56 @@ verrevcmp (const char *s1, size_t s1_len, const char *s2, size_t s2_len)
124int 135int
125filevercmp (const char *s1, const char *s2) 136filevercmp (const char *s1, const char *s2)
126{ 137{
127 const char *s1_pos; 138 return filenvercmp (s1, -1, s2, -1);
128 const char *s2_pos; 139}
129 const char *s1_suffix, *s2_suffix;
130 size_t s1_len, s2_len;
131 int result;
132
133 /* easy comparison to see if strings are identical */
134 int simple_cmp = strcmp (s1, s2);
135 if (simple_cmp == 0)
136 return 0;
137 140
138 /* special handle for "", "." and ".." */ 141/* Compare versions A (of length ALEN) and B (of length BLEN).
139 if (!*s1) 142 See filevercmp.h for function description. */
140 return -1; 143int
141 if (!*s2) 144filenvercmp (char const *a, ptrdiff_t alen, char const *b, ptrdiff_t blen)
142 return 1; 145{
143 if (0 == strcmp (".", s1)) 146 /* Special case for empty versions. */
144 return -1; 147 bool aempty = alen < 0 ? !a[0] : !alen;
145 if (0 == strcmp (".", s2)) 148 bool bempty = blen < 0 ? !b[0] : !blen;
146 return 1; 149 if (aempty)
147 if (0 == strcmp ("..", s1)) 150 return -!bempty;
148 return -1; 151 if (bempty)
149 if (0 == strcmp ("..", s2))
150 return 1; 152 return 1;
151 153
152 /* special handle for other hidden files */ 154 /* Special cases for leading ".": "." sorts first, then "..", then
153 if (*s1 == '.' && *s2 != '.') 155 other names with leading ".", then other names. */
154 return -1; 156 if (a[0] == '.')
155 if (*s1 != '.' && *s2 == '.')
156 return 1;
157 if (*s1 == '.' && *s2 == '.')
158 { 157 {
159 s1++; 158 if (b[0] != '.')
160 s2++; 159 return -1;
161 }
162 160
163 /* "cut" file suffixes */ 161 bool adot = alen < 0 ? !a[1] : alen == 1;
164 s1_pos = s1; 162 bool bdot = blen < 0 ? !b[1] : blen == 1;
165 s2_pos = s2; 163 if (adot)
166 s1_suffix = match_suffix (&s1_pos); 164 return -!bdot;
167 s2_suffix = match_suffix (&s2_pos); 165 if (bdot)
168 s1_len = (s1_suffix ? s1_suffix : s1_pos) - s1; 166 return 1;
169 s2_len = (s2_suffix ? s2_suffix : s2_pos) - s2; 167
170 168 bool adotdot = a[1] == '.' && (alen < 0 ? !a[2] : alen == 2);
171 /* restore file suffixes if strings are identical after "cut" */ 169 bool bdotdot = b[1] == '.' && (blen < 0 ? !b[2] : blen == 2);
172 if ((s1_suffix || s2_suffix) && (s1_len == s2_len) 170 if (adotdot)
173 && 0 == strncmp (s1, s2, s1_len)) 171 return -!bdotdot;
174 { 172 if (bdotdot)
175 s1_len = s1_pos - s1; 173 return 1;
176 s2_len = s2_pos - s2;
177 } 174 }
175 else if (b[0] == '.')
176 return 1;
177
178 /* Cut file suffixes. */
179 idx_t aprefixlen = file_prefixlen (a, &alen);
180 idx_t bprefixlen = file_prefixlen (b, &blen);
181
182 /* If both suffixes are empty, a second pass would return the same thing. */
183 bool one_pass_only = aprefixlen == alen && bprefixlen == blen;
184
185 int result = verrevcmp (a, aprefixlen, b, bprefixlen);
178 186
179 result = verrevcmp (s1, s1_len, s2, s2_len); 187 /* Return the initial result if nonzero, or if no second pass is needed.
180 return result == 0 ? simple_cmp : result; 188 Otherwise, restore the suffixes and try again. */
189 return result || one_pass_only ? result : verrevcmp (a, alen, b, blen);
181} 190}
diff --git a/lib/filevercmp.h b/lib/filevercmp.h
index 98020e66674..57949760b25 100644
--- a/lib/filevercmp.h
+++ b/lib/filevercmp.h
@@ -1,11 +1,12 @@
1/* 1/* Compare file names containing version numbers.
2
2 Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> 3 Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
3 Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au> 4 Copyright (C) 2001 Anthony Towns <aj@azure.humbug.org.au>
4 Copyright (C) 2008-2022 Free Software Foundation, Inc. 5 Copyright (C) 2008-2022 Free Software Foundation, Inc.
5 6
6 This file is free software: you can redistribute it and/or modify 7 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 8 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 9 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 10 License, or (at your option) any later version.
10 11
11 This file is distributed in the hope that it will be useful, 12 This file is distributed in the hope that it will be useful,
@@ -19,24 +20,59 @@
19#ifndef FILEVERCMP_H 20#ifndef FILEVERCMP_H
20#define FILEVERCMP_H 21#define FILEVERCMP_H
21 22
22/* Compare version strings: 23#include <stddef.h>
24
25/* Compare strings A and B as file names containing version numbers,
26 and return an integer that is negative, zero, or positive depending
27 on whether A compares less than, equal to, or greater than B.
28
29 Use the following version sort algorithm:
30
31 1. Compare the strings' maximal-length non-digit prefixes lexically.
32 If there is a difference return that difference.
33 Otherwise discard the prefixes and continue with the next step.
34
35 2. Compare the strings' maximal-length digit prefixes, using
36 numeric comparison of the numbers represented by each prefix.
37 (Treat an empty prefix as zero; this can happen only at string end.)
38 If there is a difference, return that difference.
39 Otherwise discard the prefixes and continue with the next step.
40
41 3. If both strings are empty, return 0. Otherwise continue with step 1.
42
43 In version sort, lexical comparison is left to right, byte by byte,
44 using the byte's numeric value (0-255), except that:
45
46 1. ASCII letters sort before other bytes.
47 2. A tilde sorts before anything, even an empty string.
48
49 In addition to the version sort rules, the following strings have
50 special priority and sort before all other strings (listed in order):
23 51
24 This function compares strings S1 and S2: 52 1. The empty string.
25 1) By PREFIX in the same way as strcmp. 53 2. ".".
26 2) Then by VERSION (most similarly to version compare of Debian's dpkg). 54 3. "..".
27 Leading zeros in version numbers are ignored. 55 4. Strings starting with "." sort before other strings.
28 3) If both (PREFIX and VERSION) are equal, strcmp function is used for
29 comparison. So this function can return 0 if (and only if) strings S1
30 and S2 are identical.
31 56
32 It returns number >0 for S1 > S2, 0 for S1 == S2 and number <0 for S1 < S2. 57 Before comparing two strings where both begin with non-".",
58 or where both begin with "." but neither is "." or "..",
59 suffixes matching the C-locale extended regular expression
60 (\.[A-Za-z~][A-Za-z0-9~]*)*$ are removed and the strings compared
61 without them, using version sort without special priority;
62 if they do not compare equal, this comparison result is used and
63 the suffixes are effectively ignored. Otherwise, the entire
64 strings are compared using version sort. When removing a suffix
65 from a nonempty string, remove the maximal-length suffix such that
66 the remaining string is nonempty.
33 67
34 This function compares strings, in a way that if VER1 and VER2 are version 68 This function is intended to be a replacement for strverscmp. */
35 numbers and PREFIX and SUFFIX (SUFFIX defined as (\.[A-Za-z~][A-Za-z0-9~]*)*) 69int filevercmp (char const *a, char const *b) _GL_ATTRIBUTE_PURE;
36 are strings then VER1 < VER2 implies filevercmp (PREFIX VER1 SUFFIX,
37 PREFIX VER2 SUFFIX) < 0.
38 70
39 This function is intended to be a replacement for strverscmp. */ 71/* Like filevercmp, except compare the byte arrays A (of length ALEN)
40int filevercmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE; 72 and B (of length BLEN) so that A and B can contain '\0', which
73 sorts just before '\1'. But if ALEN is -1 treat A as a string
74 terminated by '\0', and similarly for BLEN. */
75int filenvercmp (char const *a, ptrdiff_t alen, char const *b, ptrdiff_t blen)
76 _GL_ATTRIBUTE_PURE;
41 77
42#endif /* FILEVERCMP_H */ 78#endif /* FILEVERCMP_H */
diff --git a/lib/fpending.c b/lib/fpending.c
index 617f3977f8f..6408cff4647 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/fpending.h b/lib/fpending.h
index 2b45e9031bb..43542c5b8ad 100644
--- a/lib/fpending.h
+++ b/lib/fpending.h
@@ -5,7 +5,7 @@
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
diff --git a/lib/fstatat.c b/lib/fstatat.c
index 56de0cab4b2..6e8344964bc 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/fsusage.c b/lib/fsusage.c
index 734f0fc7460..18f790f6e7b 100644
--- a/lib/fsusage.c
+++ b/lib/fsusage.c
@@ -5,7 +5,7 @@
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This file is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
diff --git a/lib/fsusage.h b/lib/fsusage.h
index f4f50aba29c..0443d19f922 100644
--- a/lib/fsusage.h
+++ b/lib/fsusage.h
@@ -5,7 +5,7 @@
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This file is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index 4349c8c5611..91057529221 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 065574a9ff4..bac32a387e2 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/futimens.c b/lib/futimens.c
index 97228242b1e..bc3e41a9439 100644
--- a/lib/futimens.c
+++ b/lib/futimens.c
@@ -3,7 +3,7 @@
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the 6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This file is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index a17b791c8d8..ff79adae72f 100644
--- a/lib/get-permissions.c
+++ b/lib/get-permissions.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 53d1b81a3ba..37e82808671 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -8,7 +8,7 @@
8 8
9 This program is free software: you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
diff --git a/lib/gettime.c b/lib/gettime.c
index a44a69dfc43..541af18bbfa 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index a8a6cd782d5..2ffe89d4239 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -3,7 +3,7 @@
3# 3#
4# This file is free software; you can redistribute it and/or modify 4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or 6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version. 7# (at your option) any later version.
8# 8#
9# This file is distributed in the hope that it will be useful, 9# This file is distributed in the hope that it will be useful,
@@ -35,6 +35,7 @@
35# --macro-prefix=gl \ 35# --macro-prefix=gl \
36# --no-vc-files \ 36# --no-vc-files \
37# --avoid=btowc \ 37# --avoid=btowc \
38# --avoid=chmod \
38# --avoid=close \ 39# --avoid=close \
39# --avoid=crypto/af_alg \ 40# --avoid=crypto/af_alg \
40# --avoid=dup \ 41# --avoid=dup \
@@ -129,6 +130,7 @@
129# minmax \ 130# minmax \
130# mkostemp \ 131# mkostemp \
131# mktime \ 132# mktime \
133# nanosleep \
132# nproc \ 134# nproc \
133# nstrftime \ 135# nstrftime \
134# pathmax \ 136# pathmax \
@@ -191,6 +193,10 @@ BUILD_DETAILS = @BUILD_DETAILS@
191BYTESWAP_H = @BYTESWAP_H@ 193BYTESWAP_H = @BYTESWAP_H@
192CAIRO_CFLAGS = @CAIRO_CFLAGS@ 194CAIRO_CFLAGS = @CAIRO_CFLAGS@
193CAIRO_LIBS = @CAIRO_LIBS@ 195CAIRO_LIBS = @CAIRO_LIBS@
196CAIRO_XCB_CFLAGS = @CAIRO_XCB_CFLAGS@
197CAIRO_XCB_LIBS = @CAIRO_XCB_LIBS@
198CAIRO_XLIB_CFLAGS = @CAIRO_XLIB_CFLAGS@
199CAIRO_XLIB_LIBS = @CAIRO_XLIB_LIBS@
194CC = @CC@ 200CC = @CC@
195CFLAGS = @CFLAGS@ 201CFLAGS = @CFLAGS@
196CFLAGS_SOUND = @CFLAGS_SOUND@ 202CFLAGS_SOUND = @CFLAGS_SOUND@
@@ -203,7 +209,6 @@ CPP = @CPP@
203CPPFLAGS = @CPPFLAGS@ 209CPPFLAGS = @CPPFLAGS@
204CRYPTOLIB = @CRYPTOLIB@ 210CRYPTOLIB = @CRYPTOLIB@
205CXX = @CXX@ 211CXX = @CXX@
206CXXCPP = @CXXCPP@
207CXXFLAGS = @CXXFLAGS@ 212CXXFLAGS = @CXXFLAGS@
208CYGWIN_OBJ = @CYGWIN_OBJ@ 213CYGWIN_OBJ = @CYGWIN_OBJ@
209C_SWITCH_MACHINE = @C_SWITCH_MACHINE@ 214C_SWITCH_MACHINE = @C_SWITCH_MACHINE@
@@ -247,7 +252,60 @@ GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
247GETOPT_H = @GETOPT_H@ 252GETOPT_H = @GETOPT_H@
248GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@ 253GFILENOTIFY_CFLAGS = @GFILENOTIFY_CFLAGS@
249GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@ 254GFILENOTIFY_LIBS = @GFILENOTIFY_LIBS@
255GL_CFLAG_ALLOW_WARNINGS = @GL_CFLAG_ALLOW_WARNINGS@
256GL_CFLAG_GNULIB_WARNINGS = @GL_CFLAG_GNULIB_WARNINGS@
250GL_COND_LIBTOOL_CONDITION = @GL_COND_LIBTOOL_CONDITION@ 257GL_COND_LIBTOOL_CONDITION = @GL_COND_LIBTOOL_CONDITION@
258GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION = @GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION@
259GL_COND_OBJ_COPY_FILE_RANGE_CONDITION = @GL_COND_OBJ_COPY_FILE_RANGE_CONDITION@
260GL_COND_OBJ_DIRFD_CONDITION = @GL_COND_OBJ_DIRFD_CONDITION@
261GL_COND_OBJ_DUP2_CONDITION = @GL_COND_OBJ_DUP2_CONDITION@
262GL_COND_OBJ_EUIDACCESS_CONDITION = @GL_COND_OBJ_EUIDACCESS_CONDITION@
263GL_COND_OBJ_EXECINFO_CONDITION = @GL_COND_OBJ_EXECINFO_CONDITION@
264GL_COND_OBJ_EXPLICIT_BZERO_CONDITION = @GL_COND_OBJ_EXPLICIT_BZERO_CONDITION@
265GL_COND_OBJ_FACCESSAT_CONDITION = @GL_COND_OBJ_FACCESSAT_CONDITION@
266GL_COND_OBJ_FCHMODAT_CONDITION = @GL_COND_OBJ_FCHMODAT_CONDITION@
267GL_COND_OBJ_FCNTL_CONDITION = @GL_COND_OBJ_FCNTL_CONDITION@
268GL_COND_OBJ_FDOPENDIR_CONDITION = @GL_COND_OBJ_FDOPENDIR_CONDITION@
269GL_COND_OBJ_FPENDING_CONDITION = @GL_COND_OBJ_FPENDING_CONDITION@
270GL_COND_OBJ_FREE_CONDITION = @GL_COND_OBJ_FREE_CONDITION@
271GL_COND_OBJ_FSTATAT_CONDITION = @GL_COND_OBJ_FSTATAT_CONDITION@
272GL_COND_OBJ_FSUSAGE_CONDITION = @GL_COND_OBJ_FSUSAGE_CONDITION@
273GL_COND_OBJ_FSYNC_CONDITION = @GL_COND_OBJ_FSYNC_CONDITION@
274GL_COND_OBJ_FUTIMENS_CONDITION = @GL_COND_OBJ_FUTIMENS_CONDITION@
275GL_COND_OBJ_GETDTABLESIZE_CONDITION = @GL_COND_OBJ_GETDTABLESIZE_CONDITION@
276GL_COND_OBJ_GETGROUPS_CONDITION = @GL_COND_OBJ_GETGROUPS_CONDITION@
277GL_COND_OBJ_GETLOADAVG_CONDITION = @GL_COND_OBJ_GETLOADAVG_CONDITION@
278GL_COND_OBJ_GETOPT_CONDITION = @GL_COND_OBJ_GETOPT_CONDITION@
279GL_COND_OBJ_GETRANDOM_CONDITION = @GL_COND_OBJ_GETRANDOM_CONDITION@
280GL_COND_OBJ_GETTIMEOFDAY_CONDITION = @GL_COND_OBJ_GETTIMEOFDAY_CONDITION@
281GL_COND_OBJ_GROUP_MEMBER_CONDITION = @GL_COND_OBJ_GROUP_MEMBER_CONDITION@
282GL_COND_OBJ_LCHMOD_CONDITION = @GL_COND_OBJ_LCHMOD_CONDITION@
283GL_COND_OBJ_LSTAT_CONDITION = @GL_COND_OBJ_LSTAT_CONDITION@
284GL_COND_OBJ_MEMPCPY_CONDITION = @GL_COND_OBJ_MEMPCPY_CONDITION@
285GL_COND_OBJ_MEMRCHR_CONDITION = @GL_COND_OBJ_MEMRCHR_CONDITION@
286GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION = @GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION@
287GL_COND_OBJ_MKOSTEMP_CONDITION = @GL_COND_OBJ_MKOSTEMP_CONDITION@
288GL_COND_OBJ_NANOSLEEP_CONDITION = @GL_COND_OBJ_NANOSLEEP_CONDITION@
289GL_COND_OBJ_OPEN_CONDITION = @GL_COND_OBJ_OPEN_CONDITION@
290GL_COND_OBJ_PSELECT_CONDITION = @GL_COND_OBJ_PSELECT_CONDITION@
291GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION = @GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION@
292GL_COND_OBJ_RAWMEMCHR_CONDITION = @GL_COND_OBJ_RAWMEMCHR_CONDITION@
293GL_COND_OBJ_READLINKAT_CONDITION = @GL_COND_OBJ_READLINKAT_CONDITION@
294GL_COND_OBJ_READLINK_CONDITION = @GL_COND_OBJ_READLINK_CONDITION@
295GL_COND_OBJ_REGEX_CONDITION = @GL_COND_OBJ_REGEX_CONDITION@
296GL_COND_OBJ_SIG2STR_CONDITION = @GL_COND_OBJ_SIG2STR_CONDITION@
297GL_COND_OBJ_SIGDESCR_NP_CONDITION = @GL_COND_OBJ_SIGDESCR_NP_CONDITION@
298GL_COND_OBJ_STDIO_READ_CONDITION = @GL_COND_OBJ_STDIO_READ_CONDITION@
299GL_COND_OBJ_STDIO_WRITE_CONDITION = @GL_COND_OBJ_STDIO_WRITE_CONDITION@
300GL_COND_OBJ_STPCPY_CONDITION = @GL_COND_OBJ_STPCPY_CONDITION@
301GL_COND_OBJ_STRNLEN_CONDITION = @GL_COND_OBJ_STRNLEN_CONDITION@
302GL_COND_OBJ_STRTOIMAX_CONDITION = @GL_COND_OBJ_STRTOIMAX_CONDITION@
303GL_COND_OBJ_STRTOLL_CONDITION = @GL_COND_OBJ_STRTOLL_CONDITION@
304GL_COND_OBJ_SYMLINK_CONDITION = @GL_COND_OBJ_SYMLINK_CONDITION@
305GL_COND_OBJ_TIMEGM_CONDITION = @GL_COND_OBJ_TIMEGM_CONDITION@
306GL_COND_OBJ_TIME_RZ_CONDITION = @GL_COND_OBJ_TIME_RZ_CONDITION@
307GL_COND_OBJ_TIME_R_CONDITION = @GL_COND_OBJ_TIME_R_CONDITION@
308GL_COND_OBJ_UTIMENSAT_CONDITION = @GL_COND_OBJ_UTIMENSAT_CONDITION@
251GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@ 309GL_GENERATE_ALLOCA_H_CONDITION = @GL_GENERATE_ALLOCA_H_CONDITION@
252GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@ 310GL_GENERATE_BYTESWAP_H_CONDITION = @GL_GENERATE_BYTESWAP_H_CONDITION@
253GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@ 311GL_GENERATE_ERRNO_H_CONDITION = @GL_GENERATE_ERRNO_H_CONDITION@
@@ -270,6 +328,7 @@ GL_GNULIB_CALLOC_GNU = @GL_GNULIB_CALLOC_GNU@
270GL_GNULIB_CALLOC_POSIX = @GL_GNULIB_CALLOC_POSIX@ 328GL_GNULIB_CALLOC_POSIX = @GL_GNULIB_CALLOC_POSIX@
271GL_GNULIB_CANONICALIZE_FILE_NAME = @GL_GNULIB_CANONICALIZE_FILE_NAME@ 329GL_GNULIB_CANONICALIZE_FILE_NAME = @GL_GNULIB_CANONICALIZE_FILE_NAME@
272GL_GNULIB_CHDIR = @GL_GNULIB_CHDIR@ 330GL_GNULIB_CHDIR = @GL_GNULIB_CHDIR@
331GL_GNULIB_CHMOD = @GL_GNULIB_CHMOD@
273GL_GNULIB_CHOWN = @GL_GNULIB_CHOWN@ 332GL_GNULIB_CHOWN = @GL_GNULIB_CHOWN@
274GL_GNULIB_CLOSE = @GL_GNULIB_CLOSE@ 333GL_GNULIB_CLOSE = @GL_GNULIB_CLOSE@
275GL_GNULIB_CLOSEDIR = @GL_GNULIB_CLOSEDIR@ 334GL_GNULIB_CLOSEDIR = @GL_GNULIB_CLOSEDIR@
@@ -873,6 +932,7 @@ LIB_EXECINFO = @LIB_EXECINFO@
873LIB_GETRANDOM = @LIB_GETRANDOM@ 932LIB_GETRANDOM = @LIB_GETRANDOM@
874LIB_HAS_ACL = @LIB_HAS_ACL@ 933LIB_HAS_ACL = @LIB_HAS_ACL@
875LIB_MATH = @LIB_MATH@ 934LIB_MATH = @LIB_MATH@
935LIB_NANOSLEEP = @LIB_NANOSLEEP@
876LIB_PTHREAD = @LIB_PTHREAD@ 936LIB_PTHREAD = @LIB_PTHREAD@
877LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ 937LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
878LIB_TIMER_TIME = @LIB_TIMER_TIME@ 938LIB_TIMER_TIME = @LIB_TIMER_TIME@
@@ -971,9 +1031,11 @@ REPLACE_ALIGNED_ALLOC = @REPLACE_ALIGNED_ALLOC@
971REPLACE_CALLOC_FOR_CALLOC_GNU = @REPLACE_CALLOC_FOR_CALLOC_GNU@ 1031REPLACE_CALLOC_FOR_CALLOC_GNU = @REPLACE_CALLOC_FOR_CALLOC_GNU@
972REPLACE_CALLOC_FOR_CALLOC_POSIX = @REPLACE_CALLOC_FOR_CALLOC_POSIX@ 1032REPLACE_CALLOC_FOR_CALLOC_POSIX = @REPLACE_CALLOC_FOR_CALLOC_POSIX@
973REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@ 1033REPLACE_CANONICALIZE_FILE_NAME = @REPLACE_CANONICALIZE_FILE_NAME@
1034REPLACE_CHMOD = @REPLACE_CHMOD@
974REPLACE_CHOWN = @REPLACE_CHOWN@ 1035REPLACE_CHOWN = @REPLACE_CHOWN@
975REPLACE_CLOSE = @REPLACE_CLOSE@ 1036REPLACE_CLOSE = @REPLACE_CLOSE@
976REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@ 1037REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
1038REPLACE_COPY_FILE_RANGE = @REPLACE_COPY_FILE_RANGE@
977REPLACE_CREAT = @REPLACE_CREAT@ 1039REPLACE_CREAT = @REPLACE_CREAT@
978REPLACE_CTIME = @REPLACE_CTIME@ 1040REPLACE_CTIME = @REPLACE_CTIME@
979REPLACE_DIRFD = @REPLACE_DIRFD@ 1041REPLACE_DIRFD = @REPLACE_DIRFD@
@@ -1137,6 +1199,7 @@ SETTINGS_LIBS = @SETTINGS_LIBS@
1137SHELL = @SHELL@ 1199SHELL = @SHELL@
1138SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@ 1200SIG_ATOMIC_T_SUFFIX = @SIG_ATOMIC_T_SUFFIX@
1139SIZE_T_SUFFIX = @SIZE_T_SUFFIX@ 1201SIZE_T_SUFFIX = @SIZE_T_SUFFIX@
1202SMALL_JA_DIC = @SMALL_JA_DIC@
1140SQLITE3_LIBS = @SQLITE3_LIBS@ 1203SQLITE3_LIBS = @SQLITE3_LIBS@
1141STDALIGN_H = @STDALIGN_H@ 1204STDALIGN_H = @STDALIGN_H@
1142STDDEF_H = @STDDEF_H@ 1205STDDEF_H = @STDDEF_H@
@@ -1179,6 +1242,8 @@ WINDRES = @WINDRES@
1179WINT_T_SUFFIX = @WINT_T_SUFFIX@ 1242WINT_T_SUFFIX = @WINT_T_SUFFIX@
1180XARGS_LIMIT = @XARGS_LIMIT@ 1243XARGS_LIMIT = @XARGS_LIMIT@
1181XCB_LIBS = @XCB_LIBS@ 1244XCB_LIBS = @XCB_LIBS@
1245XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@
1246XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@
1182XCRUN = @XCRUN@ 1247XCRUN = @XCRUN@
1183XDBE_CFLAGS = @XDBE_CFLAGS@ 1248XDBE_CFLAGS = @XDBE_CFLAGS@
1184XDBE_LIBS = @XDBE_LIBS@ 1249XDBE_LIBS = @XDBE_LIBS@
@@ -1197,6 +1262,10 @@ XOBJ = @XOBJ@
1197XRANDR_CFLAGS = @XRANDR_CFLAGS@ 1262XRANDR_CFLAGS = @XRANDR_CFLAGS@
1198XRANDR_LIBS = @XRANDR_LIBS@ 1263XRANDR_LIBS = @XRANDR_LIBS@
1199XRENDER_LIBS = @XRENDER_LIBS@ 1264XRENDER_LIBS = @XRENDER_LIBS@
1265XSHAPE_CFLAGS = @XSHAPE_CFLAGS@
1266XSHAPE_LIBS = @XSHAPE_LIBS@
1267XSYNC_CFLAGS = @XSYNC_CFLAGS@
1268XSYNC_LIBS = @XSYNC_LIBS@
1200XWIDGETS_OBJ = @XWIDGETS_OBJ@ 1269XWIDGETS_OBJ = @XWIDGETS_OBJ@
1201X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@ 1270X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@
1202ac_ct_CC = @ac_ct_CC@ 1271ac_ct_CC = @ac_ct_CC@
@@ -1251,8 +1320,10 @@ gl_GNULIB_ENABLED_rawmemchr_CONDITION = @gl_GNULIB_ENABLED_rawmemchr_CONDITION@
1251gl_GNULIB_ENABLED_scratch_buffer_CONDITION = @gl_GNULIB_ENABLED_scratch_buffer_CONDITION@ 1320gl_GNULIB_ENABLED_scratch_buffer_CONDITION = @gl_GNULIB_ENABLED_scratch_buffer_CONDITION@
1252gl_GNULIB_ENABLED_strtoll_CONDITION = @gl_GNULIB_ENABLED_strtoll_CONDITION@ 1321gl_GNULIB_ENABLED_strtoll_CONDITION = @gl_GNULIB_ENABLED_strtoll_CONDITION@
1253gl_GNULIB_ENABLED_utimens_CONDITION = @gl_GNULIB_ENABLED_utimens_CONDITION@ 1322gl_GNULIB_ENABLED_utimens_CONDITION = @gl_GNULIB_ENABLED_utimens_CONDITION@
1323gl_LIBOBJDEPS = @gl_LIBOBJDEPS@
1254gl_LIBOBJS = @gl_LIBOBJS@ 1324gl_LIBOBJS = @gl_LIBOBJS@
1255gl_LTLIBOBJS = @gl_LTLIBOBJS@ 1325gl_LTLIBOBJS = @gl_LTLIBOBJS@
1326gltests_LIBOBJDEPS = @gltests_LIBOBJDEPS@
1256gltests_LIBOBJS = @gltests_LIBOBJS@ 1327gltests_LIBOBJS = @gltests_LIBOBJS@
1257gltests_LTLIBOBJS = @gltests_LTLIBOBJS@ 1328gltests_LTLIBOBJS = @gltests_LTLIBOBJS@
1258gltests_WITNESS = @gltests_WITNESS@ 1329gltests_WITNESS = @gltests_WITNESS@
@@ -1303,6 +1374,7 @@ x_default_search_path = @x_default_search_path@
1303noinst_LIBRARIES += libgnu.a 1374noinst_LIBRARIES += libgnu.a
1304 1375
1305libgnu_a_SOURCES = 1376libgnu_a_SOURCES =
1377libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
1306libgnu_a_LIBADD = $(gl_LIBOBJS) 1378libgnu_a_LIBADD = $(gl_LIBOBJS)
1307libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 1379libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
1308EXTRA_libgnu_a_SOURCES = 1380EXTRA_libgnu_a_SOURCES =
@@ -1432,10 +1504,9 @@ endif
1432## begin gnulib module canonicalize-lgpl 1504## begin gnulib module canonicalize-lgpl
1433ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl)) 1505ifeq (,$(OMIT_GNULIB_MODULE_canonicalize-lgpl))
1434 1506
1435 1507ifneq (,$(GL_COND_OBJ_CANONICALIZE_LGPL_CONDITION))
1436EXTRA_DIST += canonicalize-lgpl.c 1508libgnu_a_SOURCES += canonicalize-lgpl.c
1437 1509endif
1438EXTRA_libgnu_a_SOURCES += canonicalize-lgpl.c
1439 1510
1440endif 1511endif
1441## end gnulib module canonicalize-lgpl 1512## end gnulib module canonicalize-lgpl
@@ -1475,10 +1546,9 @@ endif
1475## begin gnulib module copy-file-range 1546## begin gnulib module copy-file-range
1476ifeq (,$(OMIT_GNULIB_MODULE_copy-file-range)) 1547ifeq (,$(OMIT_GNULIB_MODULE_copy-file-range))
1477 1548
1478 1549ifneq (,$(GL_COND_OBJ_COPY_FILE_RANGE_CONDITION))
1479EXTRA_DIST += copy-file-range.c 1550libgnu_a_SOURCES += copy-file-range.c
1480 1551endif
1481EXTRA_libgnu_a_SOURCES += copy-file-range.c
1482 1552
1483endif 1553endif
1484## end gnulib module copy-file-range 1554## end gnulib module copy-file-range
@@ -1621,13 +1691,12 @@ endif
1621ifeq (,$(OMIT_GNULIB_MODULE_dirfd)) 1691ifeq (,$(OMIT_GNULIB_MODULE_dirfd))
1622 1692
1623ifneq (,$(gl_GNULIB_ENABLED_dirfd_CONDITION)) 1693ifneq (,$(gl_GNULIB_ENABLED_dirfd_CONDITION))
1624 1694ifneq (,$(GL_COND_OBJ_DIRFD_CONDITION))
1695libgnu_a_SOURCES += dirfd.c
1625endif 1696endif
1626EXTRA_DIST += dirfd.c
1627
1628EXTRA_libgnu_a_SOURCES += dirfd.c
1629 1697
1630endif 1698endif
1699endif
1631## end gnulib module dirfd 1700## end gnulib module dirfd
1632 1701
1633## begin gnulib module dtoastr 1702## begin gnulib module dtoastr
@@ -1653,10 +1722,9 @@ endif
1653## begin gnulib module dup2 1722## begin gnulib module dup2
1654ifeq (,$(OMIT_GNULIB_MODULE_dup2)) 1723ifeq (,$(OMIT_GNULIB_MODULE_dup2))
1655 1724
1656 1725ifneq (,$(GL_COND_OBJ_DUP2_CONDITION))
1657EXTRA_DIST += dup2.c 1726libgnu_a_SOURCES += dup2.c
1658 1727endif
1659EXTRA_libgnu_a_SOURCES += dup2.c
1660 1728
1661endif 1729endif
1662## end gnulib module dup2 1730## end gnulib module dup2
@@ -1747,13 +1815,12 @@ endif
1747ifeq (,$(OMIT_GNULIB_MODULE_euidaccess)) 1815ifeq (,$(OMIT_GNULIB_MODULE_euidaccess))
1748 1816
1749ifneq (,$(gl_GNULIB_ENABLED_euidaccess_CONDITION)) 1817ifneq (,$(gl_GNULIB_ENABLED_euidaccess_CONDITION))
1750 1818ifneq (,$(GL_COND_OBJ_EUIDACCESS_CONDITION))
1819libgnu_a_SOURCES += euidaccess.c
1751endif 1820endif
1752EXTRA_DIST += euidaccess.c
1753
1754EXTRA_libgnu_a_SOURCES += euidaccess.c
1755 1821
1756endif 1822endif
1823endif
1757## end gnulib module euidaccess 1824## end gnulib module euidaccess
1758 1825
1759## begin gnulib module execinfo 1826## begin gnulib module execinfo
@@ -1773,9 +1840,11 @@ execinfo.h: $(top_builddir)/config.status
1773endif 1840endif
1774MOSTLYCLEANFILES += execinfo.h execinfo.h-t 1841MOSTLYCLEANFILES += execinfo.h execinfo.h-t
1775 1842
1776EXTRA_DIST += execinfo.c execinfo.in.h 1843ifneq (,$(GL_COND_OBJ_EXECINFO_CONDITION))
1844libgnu_a_SOURCES += execinfo.c
1845endif
1777 1846
1778EXTRA_libgnu_a_SOURCES += execinfo.c 1847EXTRA_DIST += execinfo.in.h
1779 1848
1780endif 1849endif
1781## end gnulib module execinfo 1850## end gnulib module execinfo
@@ -1783,10 +1852,9 @@ endif
1783## begin gnulib module explicit_bzero 1852## begin gnulib module explicit_bzero
1784ifeq (,$(OMIT_GNULIB_MODULE_explicit_bzero)) 1853ifeq (,$(OMIT_GNULIB_MODULE_explicit_bzero))
1785 1854
1786 1855ifneq (,$(GL_COND_OBJ_EXPLICIT_BZERO_CONDITION))
1787EXTRA_DIST += explicit_bzero.c 1856libgnu_a_SOURCES += explicit_bzero.c
1788 1857endif
1789EXTRA_libgnu_a_SOURCES += explicit_bzero.c
1790 1858
1791endif 1859endif
1792## end gnulib module explicit_bzero 1860## end gnulib module explicit_bzero
@@ -1794,10 +1862,13 @@ endif
1794## begin gnulib module faccessat 1862## begin gnulib module faccessat
1795ifeq (,$(OMIT_GNULIB_MODULE_faccessat)) 1863ifeq (,$(OMIT_GNULIB_MODULE_faccessat))
1796 1864
1865ifneq (,$(GL_COND_OBJ_FACCESSAT_CONDITION))
1866libgnu_a_SOURCES += faccessat.c
1867endif
1797 1868
1798EXTRA_DIST += at-func.c faccessat.c 1869EXTRA_DIST += at-func.c
1799 1870
1800EXTRA_libgnu_a_SOURCES += at-func.c faccessat.c 1871EXTRA_libgnu_a_SOURCES += at-func.c
1801 1872
1802endif 1873endif
1803## end gnulib module faccessat 1874## end gnulib module faccessat
@@ -1805,10 +1876,13 @@ endif
1805## begin gnulib module fchmodat 1876## begin gnulib module fchmodat
1806ifeq (,$(OMIT_GNULIB_MODULE_fchmodat)) 1877ifeq (,$(OMIT_GNULIB_MODULE_fchmodat))
1807 1878
1879ifneq (,$(GL_COND_OBJ_FCHMODAT_CONDITION))
1880libgnu_a_SOURCES += fchmodat.c
1881endif
1808 1882
1809EXTRA_DIST += at-func.c fchmodat.c 1883EXTRA_DIST += at-func.c
1810 1884
1811EXTRA_libgnu_a_SOURCES += at-func.c fchmodat.c 1885EXTRA_libgnu_a_SOURCES += at-func.c
1812 1886
1813endif 1887endif
1814## end gnulib module fchmodat 1888## end gnulib module fchmodat
@@ -1816,10 +1890,9 @@ endif
1816## begin gnulib module fcntl 1890## begin gnulib module fcntl
1817ifeq (,$(OMIT_GNULIB_MODULE_fcntl)) 1891ifeq (,$(OMIT_GNULIB_MODULE_fcntl))
1818 1892
1819 1893ifneq (,$(GL_COND_OBJ_FCNTL_CONDITION))
1820EXTRA_DIST += fcntl.c 1894libgnu_a_SOURCES += fcntl.c
1821 1895endif
1822EXTRA_libgnu_a_SOURCES += fcntl.c
1823 1896
1824endif 1897endif
1825## end gnulib module fcntl 1898## end gnulib module fcntl
@@ -1866,10 +1939,9 @@ endif
1866## begin gnulib module fdopendir 1939## begin gnulib module fdopendir
1867ifeq (,$(OMIT_GNULIB_MODULE_fdopendir)) 1940ifeq (,$(OMIT_GNULIB_MODULE_fdopendir))
1868 1941
1869 1942ifneq (,$(GL_COND_OBJ_FDOPENDIR_CONDITION))
1870EXTRA_DIST += fdopendir.c 1943libgnu_a_SOURCES += fdopendir.c
1871 1944endif
1872EXTRA_libgnu_a_SOURCES += fdopendir.c
1873 1945
1874endif 1946endif
1875## end gnulib module fdopendir 1947## end gnulib module fdopendir
@@ -1925,10 +1997,11 @@ endif
1925## begin gnulib module fpending 1997## begin gnulib module fpending
1926ifeq (,$(OMIT_GNULIB_MODULE_fpending)) 1998ifeq (,$(OMIT_GNULIB_MODULE_fpending))
1927 1999
2000ifneq (,$(GL_COND_OBJ_FPENDING_CONDITION))
2001libgnu_a_SOURCES += fpending.c
2002endif
1928 2003
1929EXTRA_DIST += fpending.c fpending.h stdio-impl.h 2004EXTRA_DIST += fpending.h stdio-impl.h
1930
1931EXTRA_libgnu_a_SOURCES += fpending.c
1932 2005
1933endif 2006endif
1934## end gnulib module fpending 2007## end gnulib module fpending
@@ -1936,10 +2009,9 @@ endif
1936## begin gnulib module free-posix 2009## begin gnulib module free-posix
1937ifeq (,$(OMIT_GNULIB_MODULE_free-posix)) 2010ifeq (,$(OMIT_GNULIB_MODULE_free-posix))
1938 2011
1939 2012ifneq (,$(GL_COND_OBJ_FREE_CONDITION))
1940EXTRA_DIST += free.c 2013libgnu_a_SOURCES += free.c
1941 2014endif
1942EXTRA_libgnu_a_SOURCES += free.c
1943 2015
1944endif 2016endif
1945## end gnulib module free-posix 2017## end gnulib module free-posix
@@ -1947,10 +2019,13 @@ endif
1947## begin gnulib module fstatat 2019## begin gnulib module fstatat
1948ifeq (,$(OMIT_GNULIB_MODULE_fstatat)) 2020ifeq (,$(OMIT_GNULIB_MODULE_fstatat))
1949 2021
2022ifneq (,$(GL_COND_OBJ_FSTATAT_CONDITION))
2023libgnu_a_SOURCES += fstatat.c
2024endif
1950 2025
1951EXTRA_DIST += at-func.c fstatat.c 2026EXTRA_DIST += at-func.c
1952 2027
1953EXTRA_libgnu_a_SOURCES += at-func.c fstatat.c 2028EXTRA_libgnu_a_SOURCES += at-func.c
1954 2029
1955endif 2030endif
1956## end gnulib module fstatat 2031## end gnulib module fstatat
@@ -1958,10 +2033,11 @@ endif
1958## begin gnulib module fsusage 2033## begin gnulib module fsusage
1959ifeq (,$(OMIT_GNULIB_MODULE_fsusage)) 2034ifeq (,$(OMIT_GNULIB_MODULE_fsusage))
1960 2035
2036ifneq (,$(GL_COND_OBJ_FSUSAGE_CONDITION))
2037libgnu_a_SOURCES += fsusage.c
2038endif
1961 2039
1962EXTRA_DIST += fsusage.c fsusage.h 2040EXTRA_DIST += fsusage.h
1963
1964EXTRA_libgnu_a_SOURCES += fsusage.c
1965 2041
1966endif 2042endif
1967## end gnulib module fsusage 2043## end gnulib module fsusage
@@ -1969,10 +2045,9 @@ endif
1969## begin gnulib module fsync 2045## begin gnulib module fsync
1970ifeq (,$(OMIT_GNULIB_MODULE_fsync)) 2046ifeq (,$(OMIT_GNULIB_MODULE_fsync))
1971 2047
1972 2048ifneq (,$(GL_COND_OBJ_FSYNC_CONDITION))
1973EXTRA_DIST += fsync.c 2049libgnu_a_SOURCES += fsync.c
1974 2050endif
1975EXTRA_libgnu_a_SOURCES += fsync.c
1976 2051
1977endif 2052endif
1978## end gnulib module fsync 2053## end gnulib module fsync
@@ -1980,10 +2055,9 @@ endif
1980## begin gnulib module futimens 2055## begin gnulib module futimens
1981ifeq (,$(OMIT_GNULIB_MODULE_futimens)) 2056ifeq (,$(OMIT_GNULIB_MODULE_futimens))
1982 2057
1983 2058ifneq (,$(GL_COND_OBJ_FUTIMENS_CONDITION))
1984EXTRA_DIST += futimens.c 2059libgnu_a_SOURCES += futimens.c
1985 2060endif
1986EXTRA_libgnu_a_SOURCES += futimens.c
1987 2061
1988endif 2062endif
1989## end gnulib module futimens 2063## end gnulib module futimens
@@ -2013,35 +2087,32 @@ endif
2013ifeq (,$(OMIT_GNULIB_MODULE_getdtablesize)) 2087ifeq (,$(OMIT_GNULIB_MODULE_getdtablesize))
2014 2088
2015ifneq (,$(gl_GNULIB_ENABLED_getdtablesize_CONDITION)) 2089ifneq (,$(gl_GNULIB_ENABLED_getdtablesize_CONDITION))
2016 2090ifneq (,$(GL_COND_OBJ_GETDTABLESIZE_CONDITION))
2091libgnu_a_SOURCES += getdtablesize.c
2017endif 2092endif
2018EXTRA_DIST += getdtablesize.c
2019
2020EXTRA_libgnu_a_SOURCES += getdtablesize.c
2021 2093
2022endif 2094endif
2095endif
2023## end gnulib module getdtablesize 2096## end gnulib module getdtablesize
2024 2097
2025## begin gnulib module getgroups 2098## begin gnulib module getgroups
2026ifeq (,$(OMIT_GNULIB_MODULE_getgroups)) 2099ifeq (,$(OMIT_GNULIB_MODULE_getgroups))
2027 2100
2028ifneq (,$(gl_GNULIB_ENABLED_getgroups_CONDITION)) 2101ifneq (,$(gl_GNULIB_ENABLED_getgroups_CONDITION))
2029 2102ifneq (,$(GL_COND_OBJ_GETGROUPS_CONDITION))
2103libgnu_a_SOURCES += getgroups.c
2030endif 2104endif
2031EXTRA_DIST += getgroups.c
2032
2033EXTRA_libgnu_a_SOURCES += getgroups.c
2034 2105
2035endif 2106endif
2107endif
2036## end gnulib module getgroups 2108## end gnulib module getgroups
2037 2109
2038## begin gnulib module getloadavg 2110## begin gnulib module getloadavg
2039ifeq (,$(OMIT_GNULIB_MODULE_getloadavg)) 2111ifeq (,$(OMIT_GNULIB_MODULE_getloadavg))
2040 2112
2041 2113ifneq (,$(GL_COND_OBJ_GETLOADAVG_CONDITION))
2042EXTRA_DIST += getloadavg.c 2114libgnu_a_SOURCES += getloadavg.c
2043 2115endif
2044EXTRA_libgnu_a_SOURCES += getloadavg.c
2045 2116
2046endif 2117endif
2047## end gnulib module getloadavg 2118## end gnulib module getloadavg
@@ -2083,9 +2154,11 @@ endif
2083 2154
2084MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t 2155MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
2085 2156
2086EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.c getopt.in.h getopt1.c getopt_int.h 2157ifneq (,$(GL_COND_OBJ_GETOPT_CONDITION))
2158libgnu_a_SOURCES += getopt.c getopt1.c
2159endif
2087 2160
2088EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c 2161EXTRA_DIST += getopt-cdefs.in.h getopt-core.h getopt-ext.h getopt-pfx-core.h getopt-pfx-ext.h getopt.in.h getopt_int.h
2089 2162
2090endif 2163endif
2091## end gnulib module getopt-posix 2164## end gnulib module getopt-posix
@@ -2093,10 +2166,9 @@ endif
2093## begin gnulib module getrandom 2166## begin gnulib module getrandom
2094ifeq (,$(OMIT_GNULIB_MODULE_getrandom)) 2167ifeq (,$(OMIT_GNULIB_MODULE_getrandom))
2095 2168
2096 2169ifneq (,$(GL_COND_OBJ_GETRANDOM_CONDITION))
2097EXTRA_DIST += getrandom.c 2170libgnu_a_SOURCES += getrandom.c
2098 2171endif
2099EXTRA_libgnu_a_SOURCES += getrandom.c
2100 2172
2101endif 2173endif
2102## end gnulib module getrandom 2174## end gnulib module getrandom
@@ -2122,10 +2194,9 @@ endif
2122## begin gnulib module gettimeofday 2194## begin gnulib module gettimeofday
2123ifeq (,$(OMIT_GNULIB_MODULE_gettimeofday)) 2195ifeq (,$(OMIT_GNULIB_MODULE_gettimeofday))
2124 2196
2125 2197ifneq (,$(GL_COND_OBJ_GETTIMEOFDAY_CONDITION))
2126EXTRA_DIST += gettimeofday.c 2198libgnu_a_SOURCES += gettimeofday.c
2127 2199endif
2128EXTRA_libgnu_a_SOURCES += gettimeofday.c
2129 2200
2130endif 2201endif
2131## end gnulib module gettimeofday 2202## end gnulib module gettimeofday
@@ -2143,13 +2214,12 @@ endif
2143ifeq (,$(OMIT_GNULIB_MODULE_group-member)) 2214ifeq (,$(OMIT_GNULIB_MODULE_group-member))
2144 2215
2145ifneq (,$(gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION)) 2216ifneq (,$(gl_GNULIB_ENABLED_a9786850e999ae65a836a6041e8e5ed1_CONDITION))
2146 2217ifneq (,$(GL_COND_OBJ_GROUP_MEMBER_CONDITION))
2218libgnu_a_SOURCES += group-member.c
2147endif 2219endif
2148EXTRA_DIST += group-member.c
2149
2150EXTRA_libgnu_a_SOURCES += group-member.c
2151 2220
2152endif 2221endif
2222endif
2153## end gnulib module group-member 2223## end gnulib module group-member
2154 2224
2155## begin gnulib module idx 2225## begin gnulib module idx
@@ -2249,13 +2319,12 @@ endif
2249ifeq (,$(OMIT_GNULIB_MODULE_lchmod)) 2319ifeq (,$(OMIT_GNULIB_MODULE_lchmod))
2250 2320
2251ifneq (,$(gl_GNULIB_ENABLED_lchmod_CONDITION)) 2321ifneq (,$(gl_GNULIB_ENABLED_lchmod_CONDITION))
2252 2322ifneq (,$(GL_COND_OBJ_LCHMOD_CONDITION))
2323libgnu_a_SOURCES += lchmod.c
2253endif 2324endif
2254EXTRA_DIST += lchmod.c
2255
2256EXTRA_libgnu_a_SOURCES += lchmod.c
2257 2325
2258endif 2326endif
2327endif
2259## end gnulib module lchmod 2328## end gnulib module lchmod
2260 2329
2261## begin gnulib module libc-config 2330## begin gnulib module libc-config
@@ -2291,9 +2360,13 @@ gmp.h: $(top_builddir)/config.status
2291endif 2360endif
2292MOSTLYCLEANFILES += gmp.h gmp.h-t 2361MOSTLYCLEANFILES += gmp.h gmp.h-t
2293 2362
2294EXTRA_DIST += mini-gmp-gnulib.c mini-gmp.c mini-gmp.h 2363ifneq (,$(GL_COND_OBJ_MINI_GMP_GNULIB_CONDITION))
2364libgnu_a_SOURCES += mini-gmp-gnulib.c
2365endif
2295 2366
2296EXTRA_libgnu_a_SOURCES += mini-gmp-gnulib.c mini-gmp.c 2367EXTRA_DIST += mini-gmp.c mini-gmp.h
2368
2369EXTRA_libgnu_a_SOURCES += mini-gmp.c
2297 2370
2298endif 2371endif
2299## end gnulib module libgmp 2372## end gnulib module libgmp
@@ -2329,10 +2402,9 @@ endif
2329## begin gnulib module lstat 2402## begin gnulib module lstat
2330ifeq (,$(OMIT_GNULIB_MODULE_lstat)) 2403ifeq (,$(OMIT_GNULIB_MODULE_lstat))
2331 2404
2332 2405ifneq (,$(GL_COND_OBJ_LSTAT_CONDITION))
2333EXTRA_DIST += lstat.c 2406libgnu_a_SOURCES += lstat.c
2334 2407endif
2335EXTRA_libgnu_a_SOURCES += lstat.c
2336 2408
2337endif 2409endif
2338## end gnulib module lstat 2410## end gnulib module lstat
@@ -2377,10 +2449,9 @@ endif
2377## begin gnulib module mempcpy 2449## begin gnulib module mempcpy
2378ifeq (,$(OMIT_GNULIB_MODULE_mempcpy)) 2450ifeq (,$(OMIT_GNULIB_MODULE_mempcpy))
2379 2451
2380 2452ifneq (,$(GL_COND_OBJ_MEMPCPY_CONDITION))
2381EXTRA_DIST += mempcpy.c 2453libgnu_a_SOURCES += mempcpy.c
2382 2454endif
2383EXTRA_libgnu_a_SOURCES += mempcpy.c
2384 2455
2385endif 2456endif
2386## end gnulib module mempcpy 2457## end gnulib module mempcpy
@@ -2388,10 +2459,9 @@ endif
2388## begin gnulib module memrchr 2459## begin gnulib module memrchr
2389ifeq (,$(OMIT_GNULIB_MODULE_memrchr)) 2460ifeq (,$(OMIT_GNULIB_MODULE_memrchr))
2390 2461
2391 2462ifneq (,$(GL_COND_OBJ_MEMRCHR_CONDITION))
2392EXTRA_DIST += memrchr.c 2463libgnu_a_SOURCES += memrchr.c
2393 2464endif
2394EXTRA_libgnu_a_SOURCES += memrchr.c
2395 2465
2396endif 2466endif
2397## end gnulib module memrchr 2467## end gnulib module memrchr
@@ -2407,10 +2477,9 @@ endif
2407## begin gnulib module mkostemp 2477## begin gnulib module mkostemp
2408ifeq (,$(OMIT_GNULIB_MODULE_mkostemp)) 2478ifeq (,$(OMIT_GNULIB_MODULE_mkostemp))
2409 2479
2410 2480ifneq (,$(GL_COND_OBJ_MKOSTEMP_CONDITION))
2411EXTRA_DIST += mkostemp.c 2481libgnu_a_SOURCES += mkostemp.c
2412 2482endif
2413EXTRA_libgnu_a_SOURCES += mkostemp.c
2414 2483
2415endif 2484endif
2416## end gnulib module mkostemp 2485## end gnulib module mkostemp
@@ -2439,6 +2508,16 @@ EXTRA_libgnu_a_SOURCES += mktime.c
2439endif 2508endif
2440## end gnulib module mktime-internal 2509## end gnulib module mktime-internal
2441 2510
2511## begin gnulib module nanosleep
2512ifeq (,$(OMIT_GNULIB_MODULE_nanosleep))
2513
2514ifneq (,$(GL_COND_OBJ_NANOSLEEP_CONDITION))
2515libgnu_a_SOURCES += nanosleep.c
2516endif
2517
2518endif
2519## end gnulib module nanosleep
2520
2442## begin gnulib module nproc 2521## begin gnulib module nproc
2443ifeq (,$(OMIT_GNULIB_MODULE_nproc)) 2522ifeq (,$(OMIT_GNULIB_MODULE_nproc))
2444 2523
@@ -2463,13 +2542,12 @@ endif
2463ifeq (,$(OMIT_GNULIB_MODULE_open)) 2542ifeq (,$(OMIT_GNULIB_MODULE_open))
2464 2543
2465ifneq (,$(gl_GNULIB_ENABLED_open_CONDITION)) 2544ifneq (,$(gl_GNULIB_ENABLED_open_CONDITION))
2466 2545ifneq (,$(GL_COND_OBJ_OPEN_CONDITION))
2546libgnu_a_SOURCES += open.c
2467endif 2547endif
2468EXTRA_DIST += open.c
2469
2470EXTRA_libgnu_a_SOURCES += open.c
2471 2548
2472endif 2549endif
2550endif
2473## end gnulib module open 2551## end gnulib module open
2474 2552
2475## begin gnulib module openat-h 2553## begin gnulib module openat-h
@@ -2503,10 +2581,9 @@ endif
2503## begin gnulib module pselect 2581## begin gnulib module pselect
2504ifeq (,$(OMIT_GNULIB_MODULE_pselect)) 2582ifeq (,$(OMIT_GNULIB_MODULE_pselect))
2505 2583
2506 2584ifneq (,$(GL_COND_OBJ_PSELECT_CONDITION))
2507EXTRA_DIST += pselect.c 2585libgnu_a_SOURCES += pselect.c
2508 2586endif
2509EXTRA_libgnu_a_SOURCES += pselect.c
2510 2587
2511endif 2588endif
2512## end gnulib module pselect 2589## end gnulib module pselect
@@ -2514,10 +2591,9 @@ endif
2514## begin gnulib module pthread_sigmask 2591## begin gnulib module pthread_sigmask
2515ifeq (,$(OMIT_GNULIB_MODULE_pthread_sigmask)) 2592ifeq (,$(OMIT_GNULIB_MODULE_pthread_sigmask))
2516 2593
2517 2594ifneq (,$(GL_COND_OBJ_PTHREAD_SIGMASK_CONDITION))
2518EXTRA_DIST += pthread_sigmask.c 2595libgnu_a_SOURCES += pthread_sigmask.c
2519 2596endif
2520EXTRA_libgnu_a_SOURCES += pthread_sigmask.c
2521 2597
2522endif 2598endif
2523## end gnulib module pthread_sigmask 2599## end gnulib module pthread_sigmask
@@ -2534,11 +2610,12 @@ endif
2534ifeq (,$(OMIT_GNULIB_MODULE_rawmemchr)) 2610ifeq (,$(OMIT_GNULIB_MODULE_rawmemchr))
2535 2611
2536ifneq (,$(gl_GNULIB_ENABLED_rawmemchr_CONDITION)) 2612ifneq (,$(gl_GNULIB_ENABLED_rawmemchr_CONDITION))
2537 2613ifneq (,$(GL_COND_OBJ_RAWMEMCHR_CONDITION))
2614libgnu_a_SOURCES += rawmemchr.c
2538endif 2615endif
2539EXTRA_DIST += rawmemchr.c rawmemchr.valgrind
2540 2616
2541EXTRA_libgnu_a_SOURCES += rawmemchr.c 2617endif
2618EXTRA_DIST += rawmemchr.valgrind
2542 2619
2543endif 2620endif
2544## end gnulib module rawmemchr 2621## end gnulib module rawmemchr
@@ -2546,10 +2623,9 @@ endif
2546## begin gnulib module readlink 2623## begin gnulib module readlink
2547ifeq (,$(OMIT_GNULIB_MODULE_readlink)) 2624ifeq (,$(OMIT_GNULIB_MODULE_readlink))
2548 2625
2549 2626ifneq (,$(GL_COND_OBJ_READLINK_CONDITION))
2550EXTRA_DIST += readlink.c 2627libgnu_a_SOURCES += readlink.c
2551 2628endif
2552EXTRA_libgnu_a_SOURCES += readlink.c
2553 2629
2554endif 2630endif
2555## end gnulib module readlink 2631## end gnulib module readlink
@@ -2557,10 +2633,13 @@ endif
2557## begin gnulib module readlinkat 2633## begin gnulib module readlinkat
2558ifeq (,$(OMIT_GNULIB_MODULE_readlinkat)) 2634ifeq (,$(OMIT_GNULIB_MODULE_readlinkat))
2559 2635
2636ifneq (,$(GL_COND_OBJ_READLINKAT_CONDITION))
2637libgnu_a_SOURCES += readlinkat.c
2638endif
2560 2639
2561EXTRA_DIST += at-func.c readlinkat.c 2640EXTRA_DIST += at-func.c
2562 2641
2563EXTRA_libgnu_a_SOURCES += at-func.c readlinkat.c 2642EXTRA_libgnu_a_SOURCES += at-func.c
2564 2643
2565endif 2644endif
2566## end gnulib module readlinkat 2645## end gnulib module readlinkat
@@ -2594,10 +2673,13 @@ endif
2594## begin gnulib module regex 2673## begin gnulib module regex
2595ifeq (,$(OMIT_GNULIB_MODULE_regex)) 2674ifeq (,$(OMIT_GNULIB_MODULE_regex))
2596 2675
2676ifneq (,$(GL_COND_OBJ_REGEX_CONDITION))
2677libgnu_a_SOURCES += regex.c
2678endif
2597 2679
2598EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c 2680EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c
2599 2681
2600EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c 2682EXTRA_libgnu_a_SOURCES += regcomp.c regex_internal.c regexec.c
2601 2683
2602endif 2684endif
2603## end gnulib module regex 2685## end gnulib module regex
@@ -2641,10 +2723,11 @@ endif
2641## begin gnulib module sig2str 2723## begin gnulib module sig2str
2642ifeq (,$(OMIT_GNULIB_MODULE_sig2str)) 2724ifeq (,$(OMIT_GNULIB_MODULE_sig2str))
2643 2725
2726ifneq (,$(GL_COND_OBJ_SIG2STR_CONDITION))
2727libgnu_a_SOURCES += sig2str.c
2728endif
2644 2729
2645EXTRA_DIST += sig2str.c sig2str.h 2730EXTRA_DIST += sig2str.h
2646
2647EXTRA_libgnu_a_SOURCES += sig2str.c
2648 2731
2649endif 2732endif
2650## end gnulib module sig2str 2733## end gnulib module sig2str
@@ -2652,10 +2735,9 @@ endif
2652## begin gnulib module sigdescr_np 2735## begin gnulib module sigdescr_np
2653ifeq (,$(OMIT_GNULIB_MODULE_sigdescr_np)) 2736ifeq (,$(OMIT_GNULIB_MODULE_sigdescr_np))
2654 2737
2655 2738ifneq (,$(GL_COND_OBJ_SIGDESCR_NP_CONDITION))
2656EXTRA_DIST += sigdescr_np.c 2739libgnu_a_SOURCES += sigdescr_np.c
2657 2740endif
2658EXTRA_libgnu_a_SOURCES += sigdescr_np.c
2659 2741
2660endif 2742endif
2661## end gnulib module sigdescr_np 2743## end gnulib module sigdescr_np
@@ -3004,6 +3086,13 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
3004 $(AM_V_at)mv $@-t $@ 3086 $(AM_V_at)mv $@-t $@
3005MOSTLYCLEANFILES += stdio.h stdio.h-t 3087MOSTLYCLEANFILES += stdio.h stdio.h-t
3006 3088
3089ifneq (,$(GL_COND_OBJ_STDIO_READ_CONDITION))
3090libgnu_a_SOURCES += stdio-read.c
3091endif
3092ifneq (,$(GL_COND_OBJ_STDIO_WRITE_CONDITION))
3093libgnu_a_SOURCES += stdio-write.c
3094endif
3095
3007EXTRA_DIST += stdio.in.h 3096EXTRA_DIST += stdio.in.h
3008 3097
3009endif 3098endif
@@ -3163,10 +3252,9 @@ endif
3163## begin gnulib module stpcpy 3252## begin gnulib module stpcpy
3164ifeq (,$(OMIT_GNULIB_MODULE_stpcpy)) 3253ifeq (,$(OMIT_GNULIB_MODULE_stpcpy))
3165 3254
3166 3255ifneq (,$(GL_COND_OBJ_STPCPY_CONDITION))
3167EXTRA_DIST += stpcpy.c 3256libgnu_a_SOURCES += stpcpy.c
3168 3257endif
3169EXTRA_libgnu_a_SOURCES += stpcpy.c
3170 3258
3171endif 3259endif
3172## end gnulib module stpcpy 3260## end gnulib module stpcpy
@@ -3287,10 +3375,9 @@ endif
3287## begin gnulib module strnlen 3375## begin gnulib module strnlen
3288ifeq (,$(OMIT_GNULIB_MODULE_strnlen)) 3376ifeq (,$(OMIT_GNULIB_MODULE_strnlen))
3289 3377
3290 3378ifneq (,$(GL_COND_OBJ_STRNLEN_CONDITION))
3291EXTRA_DIST += strnlen.c 3379libgnu_a_SOURCES += strnlen.c
3292 3380endif
3293EXTRA_libgnu_a_SOURCES += strnlen.c
3294 3381
3295endif 3382endif
3296## end gnulib module strnlen 3383## end gnulib module strnlen
@@ -3298,10 +3385,9 @@ endif
3298## begin gnulib module strtoimax 3385## begin gnulib module strtoimax
3299ifeq (,$(OMIT_GNULIB_MODULE_strtoimax)) 3386ifeq (,$(OMIT_GNULIB_MODULE_strtoimax))
3300 3387
3301 3388ifneq (,$(GL_COND_OBJ_STRTOIMAX_CONDITION))
3302EXTRA_DIST += strtoimax.c 3389libgnu_a_SOURCES += strtoimax.c
3303 3390endif
3304EXTRA_libgnu_a_SOURCES += strtoimax.c
3305 3391
3306endif 3392endif
3307## end gnulib module strtoimax 3393## end gnulib module strtoimax
@@ -3310,11 +3396,14 @@ endif
3310ifeq (,$(OMIT_GNULIB_MODULE_strtoll)) 3396ifeq (,$(OMIT_GNULIB_MODULE_strtoll))
3311 3397
3312ifneq (,$(gl_GNULIB_ENABLED_strtoll_CONDITION)) 3398ifneq (,$(gl_GNULIB_ENABLED_strtoll_CONDITION))
3399ifneq (,$(GL_COND_OBJ_STRTOLL_CONDITION))
3400libgnu_a_SOURCES += strtoll.c
3401endif
3313 3402
3314endif 3403endif
3315EXTRA_DIST += strtol.c strtoll.c 3404EXTRA_DIST += strtol.c
3316 3405
3317EXTRA_libgnu_a_SOURCES += strtol.c strtoll.c 3406EXTRA_libgnu_a_SOURCES += strtol.c
3318 3407
3319endif 3408endif
3320## end gnulib module strtoll 3409## end gnulib module strtoll
@@ -3322,10 +3411,9 @@ endif
3322## begin gnulib module symlink 3411## begin gnulib module symlink
3323ifeq (,$(OMIT_GNULIB_MODULE_symlink)) 3412ifeq (,$(OMIT_GNULIB_MODULE_symlink))
3324 3413
3325 3414ifneq (,$(GL_COND_OBJ_SYMLINK_CONDITION))
3326EXTRA_DIST += symlink.c 3415libgnu_a_SOURCES += symlink.c
3327 3416endif
3328EXTRA_libgnu_a_SOURCES += symlink.c
3329 3417
3330endif 3418endif
3331## end gnulib module symlink 3419## end gnulib module symlink
@@ -3413,6 +3501,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
3413 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ 3501 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
3414 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \ 3502 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
3415 -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \ 3503 -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
3504 -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \
3416 -e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \ 3505 -e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \
3417 -e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \ 3506 -e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \
3418 -e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \ 3507 -e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \
@@ -3444,6 +3533,7 @@ sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNU
3444 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \ 3533 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
3445 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \ 3534 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
3446 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \ 3535 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
3536 -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|g' \
3447 -e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \ 3537 -e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
3448 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \ 3538 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
3449 -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \ 3539 -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
@@ -3602,10 +3692,9 @@ endif
3602## begin gnulib module time_r 3692## begin gnulib module time_r
3603ifeq (,$(OMIT_GNULIB_MODULE_time_r)) 3693ifeq (,$(OMIT_GNULIB_MODULE_time_r))
3604 3694
3605 3695ifneq (,$(GL_COND_OBJ_TIME_R_CONDITION))
3606EXTRA_DIST += time_r.c 3696libgnu_a_SOURCES += time_r.c
3607 3697endif
3608EXTRA_libgnu_a_SOURCES += time_r.c
3609 3698
3610endif 3699endif
3611## end gnulib module time_r 3700## end gnulib module time_r
@@ -3613,10 +3702,11 @@ endif
3613## begin gnulib module time_rz 3702## begin gnulib module time_rz
3614ifeq (,$(OMIT_GNULIB_MODULE_time_rz)) 3703ifeq (,$(OMIT_GNULIB_MODULE_time_rz))
3615 3704
3705ifneq (,$(GL_COND_OBJ_TIME_RZ_CONDITION))
3706libgnu_a_SOURCES += time_rz.c
3707endif
3616 3708
3617EXTRA_DIST += time-internal.h time_rz.c 3709EXTRA_DIST += time-internal.h
3618
3619EXTRA_libgnu_a_SOURCES += time_rz.c
3620 3710
3621endif 3711endif
3622## end gnulib module time_rz 3712## end gnulib module time_rz
@@ -3624,10 +3714,11 @@ endif
3624## begin gnulib module timegm 3714## begin gnulib module timegm
3625ifeq (,$(OMIT_GNULIB_MODULE_timegm)) 3715ifeq (,$(OMIT_GNULIB_MODULE_timegm))
3626 3716
3717ifneq (,$(GL_COND_OBJ_TIMEGM_CONDITION))
3718libgnu_a_SOURCES += timegm.c
3719endif
3627 3720
3628EXTRA_DIST += mktime-internal.h timegm.c 3721EXTRA_DIST += mktime-internal.h
3629
3630EXTRA_libgnu_a_SOURCES += timegm.c
3631 3722
3632endif 3723endif
3633## end gnulib module timegm 3724## end gnulib module timegm
@@ -3821,6 +3912,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
3821 sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \ 3912 sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
3822 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 3913 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
3823 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 3914 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
3915 -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
3824 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 3916 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
3825 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 3917 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
3826 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \ 3918 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
@@ -3909,10 +4001,13 @@ endif
3909## begin gnulib module utimensat 4001## begin gnulib module utimensat
3910ifeq (,$(OMIT_GNULIB_MODULE_utimensat)) 4002ifeq (,$(OMIT_GNULIB_MODULE_utimensat))
3911 4003
4004ifneq (,$(GL_COND_OBJ_UTIMENSAT_CONDITION))
4005libgnu_a_SOURCES += utimensat.c
4006endif
3912 4007
3913EXTRA_DIST += at-func.c utimensat.c 4008EXTRA_DIST += at-func.c
3914 4009
3915EXTRA_libgnu_a_SOURCES += at-func.c utimensat.c 4010EXTRA_libgnu_a_SOURCES += at-func.c
3916 4011
3917endif 4012endif
3918## end gnulib module utimensat 4013## end gnulib module utimensat
@@ -3954,3 +4049,7 @@ mostlyclean-local: mostlyclean-generic
3954 fi; \ 4049 fi; \
3955 done; \ 4050 done; \
3956 : 4051 :
4052distclean-local: distclean-gnulib-libobjs
4053distclean-gnulib-libobjs:
4054 -rm -f @gl_LIBOBJDEPS@
4055maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/lib/intprops.h b/lib/intprops.h
index 68d6daa5706..d4a917f72a0 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -229,11 +229,15 @@
229 229
230/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow 230/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
231 (A, B, P) work when P is non-null. */ 231 (A, B, P) work when P is non-null. */
232#if defined __has_builtin 232#ifdef __EDG__
233/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
234 <https://bugs.gnu.org/53256>. */
235# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
236#elif defined __has_builtin
233# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow) 237# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
234/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x, 238/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
235 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */ 239 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
236#elif 7 <= __GNUC__ && !defined __EDG__ 240#elif 7 <= __GNUC__
237# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1 241# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
238#else 242#else
239# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0 243# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
diff --git a/lib/lchmod.c b/lib/lchmod.c
index 479ed776cba..8410a2d835f 100644
--- a/lib/lchmod.c
+++ b/lib/lchmod.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -25,17 +25,9 @@
25#include <errno.h> 25#include <errno.h>
26#include <fcntl.h> 26#include <fcntl.h>
27#include <stdio.h> 27#include <stdio.h>
28#include <string.h>
28#include <unistd.h> 29#include <unistd.h>
29 30
30#ifdef __osf__
31/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
32 eliminates this include because of the preliminary #include <sys/stat.h>
33 above. */
34# include "sys/stat.h"
35#else
36# include <sys/stat.h>
37#endif
38
39#include <intprops.h> 31#include <intprops.h>
40 32
41/* Work like chmod, except when FILE is a symbolic link. 33/* Work like chmod, except when FILE is a symbolic link.
@@ -45,7 +37,9 @@
45int 37int
46lchmod (char const *file, mode_t mode) 38lchmod (char const *file, mode_t mode)
47{ 39{
48#if defined O_PATH && defined AT_EMPTY_PATH 40 char readlink_buf[1];
41
42#ifdef O_PATH
49 /* Open a file descriptor with O_NOFOLLOW, to make sure we don't 43 /* Open a file descriptor with O_NOFOLLOW, to make sure we don't
50 follow symbolic links, if /proc is mounted. O_PATH is used to 44 follow symbolic links, if /proc is mounted. O_PATH is used to
51 avoid a failure if the file is not readable. 45 avoid a failure if the file is not readable.
@@ -54,56 +48,46 @@ lchmod (char const *file, mode_t mode)
54 if (fd < 0) 48 if (fd < 0)
55 return fd; 49 return fd;
56 50
57 /* Up to Linux 5.3 at least, when FILE refers to a symbolic link, the 51 int err;
58 chmod call below will change the permissions of the symbolic link 52 if (0 <= readlinkat (fd, "", readlink_buf, sizeof readlink_buf))
59 - which is undesired - and on many file systems (ext4, btrfs, jfs, 53 err = EOPNOTSUPP;
60 xfs, ..., but not reiserfs) fail with error EOPNOTSUPP - which is 54 else if (errno == EINVAL)
61 misleading. Therefore test for a symbolic link explicitly.
62 Use fstatat because fstat does not work on O_PATH descriptors
63 before Linux 3.6. */
64 struct stat st;
65 if (fstatat (fd, "", &st, AT_EMPTY_PATH) != 0)
66 { 55 {
67 int stat_errno = errno; 56 static char const fmt[] = "/proc/self/fd/%d";
68 close (fd); 57 char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
69 errno = stat_errno; 58 sprintf (buf, fmt, fd);
70 return -1; 59 err = chmod (buf, mode) == 0 ? 0 : errno == ENOENT ? -1 : errno;
71 }
72 if (S_ISLNK (st.st_mode))
73 {
74 close (fd);
75 errno = EOPNOTSUPP;
76 return -1;
77 } 60 }
61 else
62 err = errno == ENOENT ? -1 : errno;
78 63
79# if defined __linux__ || defined __ANDROID__ || defined __CYGWIN__
80 static char const fmt[] = "/proc/self/fd/%d";
81 char buf[sizeof fmt - sizeof "%d" + INT_BUFSIZE_BOUND (int)];
82 sprintf (buf, fmt, fd);
83 int chmod_result = chmod (buf, mode);
84 int chmod_errno = errno;
85 close (fd); 64 close (fd);
86 if (chmod_result == 0) 65
87 return chmod_result; 66 errno = err;
88 if (chmod_errno != ENOENT) 67 if (0 <= err)
68 return err == 0 ? 0 : -1;
69#endif
70
71 size_t len = strlen (file);
72 if (len && file[len - 1] == '/')
89 { 73 {
90 errno = chmod_errno; 74 struct stat st;
91 return chmod_result; 75 if (lstat (file, &st) < 0)
76 return -1;
77 if (!S_ISDIR (st.st_mode))
78 {
79 errno = ENOTDIR;
80 return -1;
81 }
92 } 82 }
93# endif 83
94 /* /proc is not mounted or would not work as in GNU/Linux. */ 84 /* O_PATH + /proc is not supported. */
95 85
96#elif HAVE_LSTAT 86 if (0 <= readlink (file, readlink_buf, sizeof readlink_buf))
97 struct stat st;
98 int lstat_result = lstat (file, &st);
99 if (lstat_result != 0)
100 return lstat_result;
101 if (S_ISLNK (st.st_mode))
102 { 87 {
103 errno = EOPNOTSUPP; 88 errno = EOPNOTSUPP;
104 return -1; 89 return -1;
105 } 90 }
106#endif
107 91
108 /* Fall back on chmod, despite a possible race. */ 92 /* Fall back on chmod, despite a possible race. */
109 return chmod (file, mode); 93 return chmod (file, mode);
diff --git a/lib/libc-config.h b/lib/libc-config.h
index 8fec4893787..a56665b1ce3 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -121,6 +121,7 @@
121# undef __attr_dealloc 121# undef __attr_dealloc
122# undef __attr_dealloc_free 122# undef __attr_dealloc_free
123# undef __attribute__ 123# undef __attribute__
124# undef __attribute_alloc_align__
124# undef __attribute_alloc_size__ 125# undef __attribute_alloc_size__
125# undef __attribute_artificial__ 126# undef __attribute_artificial__
126# undef __attribute_const__ 127# undef __attribute_const__
@@ -129,6 +130,7 @@
129# undef __attribute_format_arg__ 130# undef __attribute_format_arg__
130# undef __attribute_format_strfmon__ 131# undef __attribute_format_strfmon__
131# undef __attribute_malloc__ 132# undef __attribute_malloc__
133# undef __attribute_maybe_unused__
132# undef __attribute_noinline__ 134# undef __attribute_noinline__
133# undef __attribute_nonstring__ 135# undef __attribute_nonstring__
134# undef __attribute_pure__ 136# undef __attribute_pure__
@@ -142,16 +144,24 @@
142# undef __extern_always_inline 144# undef __extern_always_inline
143# undef __extern_inline 145# undef __extern_inline
144# undef __flexarr 146# undef __flexarr
147# undef __fortified_attr_access
145# undef __fortify_function 148# undef __fortify_function
146# undef __glibc_c99_flexarr_available 149# undef __glibc_c99_flexarr_available
150# undef __glibc_fortify
151# undef __glibc_fortify_n
147# undef __glibc_has_attribute 152# undef __glibc_has_attribute
148# undef __glibc_has_builtin 153# undef __glibc_has_builtin
149# undef __glibc_has_extension 154# undef __glibc_has_extension
155# undef __glibc_likely
150# undef __glibc_macro_warning 156# undef __glibc_macro_warning
151# undef __glibc_macro_warning1 157# undef __glibc_macro_warning1
152# undef __glibc_objsize 158# undef __glibc_objsize
153# undef __glibc_objsize0 159# undef __glibc_objsize0
160# undef __glibc_safe_len_cond
161# undef __glibc_safe_or_unknown_len
154# undef __glibc_unlikely 162# undef __glibc_unlikely
163# undef __glibc_unsafe_len
164# undef __glibc_unsigned_or_positive
155# undef __inline 165# undef __inline
156# undef __ptr_t 166# undef __ptr_t
157# undef __restrict 167# undef __restrict
@@ -159,6 +169,7 @@
159# undef __va_arg_pack 169# undef __va_arg_pack
160# undef __va_arg_pack_len 170# undef __va_arg_pack_len
161# undef __warnattr 171# undef __warnattr
172# undef __wur
162 173
163/* Include our copy of glibc <sys/cdefs.h>. */ 174/* Include our copy of glibc <sys/cdefs.h>. */
164# include <cdefs.h> 175# include <cdefs.h>
diff --git a/lib/md5.h b/lib/md5.h
index 5b92eac5ec8..611c230b817 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -24,6 +24,9 @@
24#include <stdint.h> 24#include <stdint.h>
25 25
26# if HAVE_OPENSSL_MD5 26# if HAVE_OPENSSL_MD5
27# ifndef OPENSSL_API_COMPAT
28# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
29# endif
27# include <openssl/md5.h> 30# include <openssl/md5.h>
28# endif 31# endif
29 32
diff --git a/lib/memrchr.c b/lib/memrchr.c
index e853996ad0a..90fdb86f1f1 100644
--- a/lib/memrchr.c
+++ b/lib/memrchr.c
@@ -11,7 +11,7 @@
11 11
12 This file is free software: you can redistribute it and/or modify 12 This file is free software: you can redistribute it and/or modify
13 it under the terms of the GNU Lesser General Public License as 13 it under the terms of the GNU Lesser General Public License as
14 published by the Free Software Foundation; either version 3 of the 14 published by the Free Software Foundation, either version 3 of the
15 License, or (at your option) any later version. 15 License, or (at your option) any later version.
16 16
17 This file is distributed in the hope that it will be useful, 17 This file is distributed in the hope that it will be useful,
diff --git a/lib/mini-gmp-gnulib.c b/lib/mini-gmp-gnulib.c
index 7620da38dbb..7d09c80e9e9 100644
--- a/lib/mini-gmp-gnulib.c
+++ b/lib/mini-gmp-gnulib.c
@@ -6,7 +6,7 @@
6 It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+". 6 It is dual-licensed under "the GNU LGPLv3+ or the GNU GPLv2+".
7 You can redistribute it and/or modify it under either 7 You can redistribute it and/or modify it under either
8 - the terms of the GNU Lesser General Public License as published 8 - the terms of the GNU Lesser General Public License as published
9 by the Free Software Foundation; either version 3, or (at your 9 by the Free Software Foundation, either version 3, or (at your
10 option) any later version, or 10 option) any later version, or
11 - the terms of the GNU General Public License as published by the 11 - the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2, or (at your option) 12 Free Software Foundation; either version 2, or (at your option)
@@ -40,7 +40,8 @@
40#endif 40#endif
41 41
42/* Pacify GCC -Wunused-variable for variables used only in 'assert' calls. */ 42/* Pacify GCC -Wunused-variable for variables used only in 'assert' calls. */
43#if defined NDEBUG && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 43#if (defined NDEBUG \
44 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__))
44# pragma GCC diagnostic ignored "-Wunused-variable" 45# pragma GCC diagnostic ignored "-Wunused-variable"
45#endif 46#endif
46 47
diff --git a/lib/mini-gmp.c b/lib/mini-gmp.c
index 8577b59ef6d..95f067f82d6 100644
--- a/lib/mini-gmp.c
+++ b/lib/mini-gmp.c
@@ -90,6 +90,7 @@ see https://www.gnu.org/licenses/. */
90#define gmp_assert_nocarry(x) do { \ 90#define gmp_assert_nocarry(x) do { \
91 mp_limb_t __cy = (x); \ 91 mp_limb_t __cy = (x); \
92 assert (__cy == 0); \ 92 assert (__cy == 0); \
93 (void) (__cy); \
93 } while (0) 94 } while (0)
94 95
95#define gmp_clz(count, x) do { \ 96#define gmp_clz(count, x) do { \
@@ -1937,9 +1938,8 @@ mpz_neg (mpz_t r, const mpz_t u)
1937void 1938void
1938mpz_swap (mpz_t u, mpz_t v) 1939mpz_swap (mpz_t u, mpz_t v)
1939{ 1940{
1940 MP_SIZE_T_SWAP (u->_mp_size, v->_mp_size);
1941 MP_SIZE_T_SWAP (u->_mp_alloc, v->_mp_alloc); 1941 MP_SIZE_T_SWAP (u->_mp_alloc, v->_mp_alloc);
1942 MP_PTR_SWAP (u->_mp_d, v->_mp_d); 1942 MPN_PTR_SWAP (u->_mp_d, u->_mp_size, v->_mp_d, v->_mp_size);
1943} 1943}
1944 1944
1945 1945
diff --git a/lib/mktime.c b/lib/mktime.c
index aa12e28e168..7dc9d67ef9d 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -429,8 +429,13 @@ __mktime_internal (struct tm *tp,
429 time with the right value, and use its UTC offset. 429 time with the right value, and use its UTC offset.
430 430
431 Heuristic: probe the adjacent timestamps in both directions, 431 Heuristic: probe the adjacent timestamps in both directions,
432 looking for the desired isdst. This should work for all real 432 looking for the desired isdst. If none is found within a
433 time zone histories in the tz database. */ 433 reasonable duration bound, assume a one-hour DST difference.
434 This should work for all real time zone histories in the tz
435 database. */
436
437 /* +1 if we wanted standard time but got DST, -1 if the reverse. */
438 int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
434 439
435 /* Distance between probes when looking for a DST boundary. In 440 /* Distance between probes when looking for a DST boundary. In
436 tzdata2003a, the shortest period of DST is 601200 seconds 441 tzdata2003a, the shortest period of DST is 601200 seconds
@@ -441,12 +446,14 @@ __mktime_internal (struct tm *tp,
441 periods when probing. */ 446 periods when probing. */
442 int stride = 601200; 447 int stride = 601200;
443 448
444 /* The longest period of DST in tzdata2003a is 536454000 seconds 449 /* In TZDB 2021e, the longest period of DST (or of non-DST), in
445 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest 450 which the DST (or adjacent DST) difference is not one hour,
446 period of non-DST is much longer, but it makes no real sense 451 is 457243209 seconds: e.g., America/Cambridge_Bay with leap
447 to search for more than a year of non-DST, so use the DST 452 seconds, starting 1965-10-31 00:00 in a switch from
448 max. */ 453 double-daylight time (-05) to standard time (-07), and
449 int duration_max = 536454000; 454 continuing to 1980-04-27 02:00 in a switch from standard time
455 (-07) to daylight time (-06). */
456 int duration_max = 457243209;
450 457
451 /* Search in both directions, so the maximum distance is half 458 /* Search in both directions, so the maximum distance is half
452 the duration; add the stride to avoid off-by-1 problems. */ 459 the duration; add the stride to avoid off-by-1 problems. */
@@ -483,6 +490,11 @@ __mktime_internal (struct tm *tp,
483 } 490 }
484 } 491 }
485 492
493 /* No unusual DST offset was found nearby. Assume one-hour DST. */
494 t += 60 * 60 * dst_difference;
495 if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
496 goto offset_found;
497
486 __set_errno (EOVERFLOW); 498 __set_errno (EOVERFLOW);
487 return -1; 499 return -1;
488 } 500 }
diff --git a/lib/nanosleep.c b/lib/nanosleep.c
new file mode 100644
index 00000000000..446794edc0b
--- /dev/null
+++ b/lib/nanosleep.c
@@ -0,0 +1,195 @@
1/* Provide a replacement for the POSIX nanosleep function.
2
3 Copyright (C) 1999-2000, 2002, 2004-2022 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Jim Meyering
19 and Bruno Haible for the native Windows part */
20
21#include <config.h>
22
23#include <time.h>
24
25#include "intprops.h"
26#include "verify.h"
27
28#include <stdbool.h>
29#include <stdio.h>
30#include <sys/types.h>
31#include <sys/select.h>
32#include <signal.h>
33
34#include <errno.h>
35
36#include <unistd.h>
37
38
39enum { BILLION = 1000 * 1000 * 1000 };
40
41#if HAVE_BUG_BIG_NANOSLEEP
42
43int
44nanosleep (const struct timespec *requested_delay,
45 struct timespec *remaining_delay)
46# undef nanosleep
47{
48 /* nanosleep mishandles large sleeps due to internal overflow problems.
49 The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
50 can't sleep more than 24.85 days (2^31 milliseconds). Similarly,
51 cygwin 1.5.x, which can't sleep more than 49.7 days (2^32 milliseconds).
52 Solve this by breaking the sleep up into smaller chunks. */
53
54 if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
55 {
56 errno = EINVAL;
57 return -1;
58 }
59
60 {
61 /* Verify that time_t is large enough. */
62 verify (TYPE_MAXIMUM (time_t) / 24 / 24 / 60 / 60);
63 const time_t limit = 24 * 24 * 60 * 60;
64 time_t seconds = requested_delay->tv_sec;
65 struct timespec intermediate;
66 intermediate.tv_nsec = requested_delay->tv_nsec;
67
68 while (limit < seconds)
69 {
70 int result;
71 intermediate.tv_sec = limit;
72 result = nanosleep (&intermediate, remaining_delay);
73 seconds -= limit;
74 if (result)
75 {
76 if (remaining_delay)
77 remaining_delay->tv_sec += seconds;
78 return result;
79 }
80 intermediate.tv_nsec = 0;
81 }
82 intermediate.tv_sec = seconds;
83 return nanosleep (&intermediate, remaining_delay);
84 }
85}
86
87#elif defined _WIN32 && ! defined __CYGWIN__
88/* Native Windows platforms. */
89
90# define WIN32_LEAN_AND_MEAN
91# include <windows.h>
92
93/* The Windows API function Sleep() has a resolution of about 15 ms and takes
94 at least 5 ms to execute. We use this function for longer time periods.
95 Additionally, we use busy-looping over short time periods, to get a
96 resolution of about 0.01 ms. In order to measure such short timespans,
97 we use the QueryPerformanceCounter() function. */
98
99int
100nanosleep (const struct timespec *requested_delay,
101 struct timespec *remaining_delay)
102{
103 static bool initialized;
104 /* Number of performance counter increments per nanosecond,
105 or zero if it could not be determined. */
106 static double ticks_per_nanosecond;
107
108 if (requested_delay->tv_nsec < 0 || BILLION <= requested_delay->tv_nsec)
109 {
110 errno = EINVAL;
111 return -1;
112 }
113
114 /* For requested delays of one second or more, 15ms resolution is
115 sufficient. */
116 if (requested_delay->tv_sec == 0)
117 {
118 if (!initialized)
119 {
120 /* Initialize ticks_per_nanosecond. */
121 LARGE_INTEGER ticks_per_second;
122
123 if (QueryPerformanceFrequency (&ticks_per_second))
124 ticks_per_nanosecond =
125 (double) ticks_per_second.QuadPart / 1000000000.0;
126
127 initialized = true;
128 }
129 if (ticks_per_nanosecond)
130 {
131 /* QueryPerformanceFrequency worked. We can use
132 QueryPerformanceCounter. Use a combination of Sleep and
133 busy-looping. */
134 /* Number of milliseconds to pass to the Sleep function.
135 Since Sleep can take up to 8 ms less or 8 ms more than requested
136 (or maybe more if the system is loaded), we subtract 10 ms. */
137 int sleep_millis = (int) requested_delay->tv_nsec / 1000000 - 10;
138 /* Determine how many ticks to delay. */
139 LONGLONG wait_ticks = requested_delay->tv_nsec * ticks_per_nanosecond;
140 /* Start. */
141 LARGE_INTEGER counter_before;
142 if (QueryPerformanceCounter (&counter_before))
143 {
144 /* Wait until the performance counter has reached this value.
145 We don't need to worry about overflow, because the performance
146 counter is reset at reboot, and with a frequency of 3.6E6
147 ticks per second 63 bits suffice for over 80000 years. */
148 LONGLONG wait_until = counter_before.QuadPart + wait_ticks;
149 /* Use Sleep for the longest part. */
150 if (sleep_millis > 0)
151 Sleep (sleep_millis);
152 /* Busy-loop for the rest. */
153 for (;;)
154 {
155 LARGE_INTEGER counter_after;
156 if (!QueryPerformanceCounter (&counter_after))
157 /* QueryPerformanceCounter failed, but succeeded earlier.
158 Should not happen. */
159 break;
160 if (counter_after.QuadPart >= wait_until)
161 /* The requested time has elapsed. */
162 break;
163 }
164 goto done;
165 }
166 }
167 }
168 /* Implementation for long delays and as fallback. */
169 Sleep (requested_delay->tv_sec * 1000 + requested_delay->tv_nsec / 1000000);
170
171 done:
172 /* Sleep is not interruptible. So there is no remaining delay. */
173 if (remaining_delay != NULL)
174 {
175 remaining_delay->tv_sec = 0;
176 remaining_delay->tv_nsec = 0;
177 }
178 return 0;
179}
180
181#else
182/* Other platforms lacking nanosleep.
183 It's not clear whether these are still practical porting targets.
184 For now, just fall back on pselect. */
185
186/* Suspend execution for at least *REQUESTED_DELAY seconds. The
187 *REMAINING_DELAY part isn't implemented yet. */
188
189int
190nanosleep (const struct timespec *requested_delay,
191 struct timespec *remaining_delay)
192{
193 return pselect (0, NULL, NULL, NULL, requested_delay, NULL);
194}
195#endif
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 190ff4d8f20..c1dd5542478 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -3,7 +3,7 @@
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the 6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This file is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
@@ -1158,7 +1158,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
1158 1158
1159 case L_('q'): /* GNU extension. */ 1159 case L_('q'): /* GNU extension. */
1160 DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1); 1160 DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1);
1161 break;
1162 1161
1163 case L_('R'): 1162 case L_('R'):
1164 subfmt = L_("%H:%M"); 1163 subfmt = L_("%H:%M");
diff --git a/lib/openat-priv.h b/lib/openat-priv.h
index 451cac10cc6..5d60810709d 100644
--- a/lib/openat-priv.h
+++ b/lib/openat-priv.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index d5f4296d478..3bacf7dbd13 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/openat.h b/lib/openat.h
index dcb2864ffc8..56919ef8dc4 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -98,12 +98,14 @@ lchmodat (int fd, char const *file, mode_t mode)
98# define STATAT_INLINE _GL_INLINE 98# define STATAT_INLINE _GL_INLINE
99# endif 99# endif
100 100
101_GL_ATTRIBUTE_DEPRECATED
101STATAT_INLINE int 102STATAT_INLINE int
102statat (int fd, char const *name, struct stat *st) 103statat (int fd, char const *name, struct stat *st)
103{ 104{
104 return fstatat (fd, name, st, 0); 105 return fstatat (fd, name, st, 0);
105} 106}
106 107
108_GL_ATTRIBUTE_DEPRECATED
107STATAT_INLINE int 109STATAT_INLINE int
108lstatat (int fd, char const *name, struct stat *st) 110lstatat (int fd, char const *name, struct stat *st)
109{ 111{
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
index 42ae68ffc1d..37fb179260d 100644
--- a/lib/qcopy-acl.c
+++ b/lib/qcopy-acl.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/readlinkat.c b/lib/readlinkat.c
index f3d39604d2e..ab45e140b59 100644
--- a/lib/readlinkat.c
+++ b/lib/readlinkat.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
diff --git a/lib/regcomp.c b/lib/regcomp.c
index b607c85320f..122c3de58c3 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -2038,15 +2038,25 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2038 } 2038 }
2039 switch (c) 2039 switch (c)
2040 { 2040 {
2041 case '-':
2042 token->type = OP_CHARSET_RANGE;
2043 break;
2044 case ']': 2041 case ']':
2045 token->type = OP_CLOSE_BRACKET; 2042 token->type = OP_CLOSE_BRACKET;
2046 break; 2043 break;
2047 case '^': 2044 case '^':
2048 token->type = OP_NON_MATCH_LIST; 2045 token->type = OP_NON_MATCH_LIST;
2049 break; 2046 break;
2047 case '-':
2048 /* In V7 Unix grep and Unix awk and mawk, [...---...]
2049 (3 adjacent minus signs) stands for a single minus sign.
2050 Support that without breaking anything else. */
2051 if (! (re_string_cur_idx (input) + 2 < re_string_length (input)
2052 && re_string_peek_byte (input, 1) == '-'
2053 && re_string_peek_byte (input, 2) == '-'))
2054 {
2055 token->type = OP_CHARSET_RANGE;
2056 break;
2057 }
2058 re_string_skip_bytes (input, 2);
2059 FALLTHROUGH;
2050 default: 2060 default:
2051 token->type = CHARACTER; 2061 token->type = CHARACTER;
2052 } 2062 }
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 3945ee7ecbf..0e6919f3400 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1396,24 +1396,22 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1396 if (__glibc_unlikely (new_nodes == NULL)) 1396 if (__glibc_unlikely (new_nodes == NULL))
1397 return -1; 1397 return -1;
1398 dfa->nodes = new_nodes; 1398 dfa->nodes = new_nodes;
1399 dfa->nodes_alloc = new_nodes_alloc;
1399 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); 1400 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
1401 if (new_nexts != NULL)
1402 dfa->nexts = new_nexts;
1400 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); 1403 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
1404 if (new_indices != NULL)
1405 dfa->org_indices = new_indices;
1401 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); 1406 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
1407 if (new_edests != NULL)
1408 dfa->edests = new_edests;
1402 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); 1409 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
1410 if (new_eclosures != NULL)
1411 dfa->eclosures = new_eclosures;
1403 if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL 1412 if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
1404 || new_edests == NULL || new_eclosures == NULL)) 1413 || new_edests == NULL || new_eclosures == NULL))
1405 { 1414 return -1;
1406 re_free (new_nexts);
1407 re_free (new_indices);
1408 re_free (new_edests);
1409 re_free (new_eclosures);
1410 return -1;
1411 }
1412 dfa->nexts = new_nexts;
1413 dfa->org_indices = new_indices;
1414 dfa->edests = new_edests;
1415 dfa->eclosures = new_eclosures;
1416 dfa->nodes_alloc = new_nodes_alloc;
1417 } 1415 }
1418 dfa->nodes[dfa->nodes_len] = token; 1416 dfa->nodes[dfa->nodes_len] = token;
1419 dfa->nodes[dfa->nodes_len].constraint = 0; 1417 dfa->nodes[dfa->nodes_len].constraint = 0;
diff --git a/lib/regexec.c b/lib/regexec.c
index aea1e7da52c..521cb028415 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1308,8 +1308,8 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1308 re_node_set *eps_via_nodes) 1308 re_node_set *eps_via_nodes)
1309{ 1309{
1310 reg_errcode_t err; 1310 reg_errcode_t err;
1311 Idx num = fs->num++; 1311 Idx num = fs->num;
1312 if (fs->num == fs->alloc) 1312 if (num == fs->alloc)
1313 { 1313 {
1314 struct re_fail_stack_ent_t *new_array; 1314 struct re_fail_stack_ent_t *new_array;
1315 new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t, 1315 new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
@@ -1324,6 +1324,7 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1324 fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs); 1324 fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs);
1325 if (fs->stack[num].regs == NULL) 1325 if (fs->stack[num].regs == NULL)
1326 return REG_ESPACE; 1326 return REG_ESPACE;
1327 fs->num = num + 1;
1327 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); 1328 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
1328 memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs); 1329 memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs);
1329 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); 1330 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
diff --git a/lib/save-cwd.h b/lib/save-cwd.h
index 7aa124c42f8..90e8a0747ce 100644
--- a/lib/save-cwd.h
+++ b/lib/save-cwd.h
@@ -5,7 +5,7 @@
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index 7a7c5e4ed0e..c1a4b82a0d0 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/sha1.h b/lib/sha1.h
index 098678d8da6..bc3470a508d 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -23,6 +23,9 @@
23# include <stdint.h> 23# include <stdint.h>
24 24
25# if HAVE_OPENSSL_SHA1 25# if HAVE_OPENSSL_SHA1
26# ifndef OPENSSL_API_COMPAT
27# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
28# endif
26# include <openssl/sha.h> 29# include <openssl/sha.h>
27# endif 30# endif
28 31
diff --git a/lib/sha256.h b/lib/sha256.h
index dc9d87e615f..533173a59e8 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -22,6 +22,9 @@
22# include <stdint.h> 22# include <stdint.h>
23 23
24# if HAVE_OPENSSL_SHA256 24# if HAVE_OPENSSL_SHA256
25# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif
25# include <openssl/sha.h> 28# include <openssl/sha.h>
26# endif 29# endif
27 30
diff --git a/lib/sha512.h b/lib/sha512.h
index f38819faf0f..1eb18702278 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -22,6 +22,9 @@
22# include "u64.h" 22# include "u64.h"
23 23
24# if HAVE_OPENSSL_SHA512 24# if HAVE_OPENSSL_SHA512
25# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif
25# include <openssl/sha.h> 28# include <openssl/sha.h>
26# endif 29# endif
27 30
diff --git a/lib/sig2str.c b/lib/sig2str.c
index f2f01d1f6fc..8e2fc0c0754 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/sig2str.h b/lib/sig2str.h
index a507170b64a..a45af7f9686 100644
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index d52c2f79638..a86643c3ca3 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -184,7 +184,11 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
184# undef free 184# undef free
185# define free rpl_free 185# define free rpl_free
186# endif 186# endif
187# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
189# else
187_GL_FUNCDECL_RPL (free, void, (void *ptr)); 190_GL_FUNCDECL_RPL (free, void, (void *ptr));
191# endif
188_GL_CXXALIAS_RPL (free, void, (void *ptr)); 192_GL_CXXALIAS_RPL (free, void, (void *ptr));
189# else 193# else
190_GL_CXXALIAS_SYS (free, void, (void *ptr)); 194_GL_CXXALIAS_SYS (free, void, (void *ptr));
diff --git a/lib/str-two-way.h b/lib/str-two-way.h
index 7ee344aea14..b00017c0b4b 100644
--- a/lib/str-two-way.h
+++ b/lib/str-two-way.h
@@ -231,7 +231,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. 231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ 233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */
234static RETURN_TYPE 234static RETURN_TYPE _GL_ATTRIBUTE_PURE
235two_way_short_needle (const unsigned char *haystack, size_t haystack_len, 235two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
236 const unsigned char *needle, size_t needle_len) 236 const unsigned char *needle, size_t needle_len)
237{ 237{
@@ -325,7 +325,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and 326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
327 sublinear performance is not possible. */ 327 sublinear performance is not possible. */
328static RETURN_TYPE 328static RETURN_TYPE _GL_ATTRIBUTE_PURE
329two_way_long_needle (const unsigned char *haystack, size_t haystack_len, 329two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
330 const unsigned char *needle, size_t needle_len) 330 const unsigned char *needle, size_t needle_len)
331{ 331{
diff --git a/lib/strftime.h b/lib/strftime.h
index 9e5cdc3f32c..a9847084f01 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/string.in.h b/lib/string.in.h
index 03e6a17a36d..3996da9fcb5 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -122,17 +122,33 @@ _GL_EXTERN_C void rpl_free (void *);
122# undef _GL_ATTRIBUTE_DEALLOC_FREE 122# undef _GL_ATTRIBUTE_DEALLOC_FREE
123# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 123# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
124# else 124# else
125# if defined _MSC_VER 125# if defined _MSC_VER && !defined free
126_GL_EXTERN_C void __cdecl free (void *); 126_GL_EXTERN_C
127# if defined _DLL
128 __declspec (dllimport)
129# endif
130 void __cdecl free (void *);
127# else 131# else
132# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
133_GL_EXTERN_C void free (void *) throw ();
134# else
128_GL_EXTERN_C void free (void *); 135_GL_EXTERN_C void free (void *);
136# endif
129# endif 137# endif
130# endif 138# endif
131#else 139#else
132# if defined _MSC_VER 140# if defined _MSC_VER && !defined free
133_GL_EXTERN_C void __cdecl free (void *); 141_GL_EXTERN_C
142# if defined _DLL
143 __declspec (dllimport)
144# endif
145 void __cdecl free (void *);
134# else 146# else
147# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
148_GL_EXTERN_C void free (void *) throw ();
149# else
135_GL_EXTERN_C void free (void *); 150_GL_EXTERN_C void free (void *);
151# endif
136# endif 152# endif
137#endif 153#endif
138 154
@@ -230,10 +246,11 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
230 void const *, (void const *__s, int __c, size_t __n)); 246 void const *, (void const *__s, int __c, size_t __n));
231# endif 247# endif
232# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 248# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
233 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 249 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
234_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 250 || defined __clang__)
251_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
235_GL_CXXALIASWARN1 (memchr, void const *, 252_GL_CXXALIASWARN1 (memchr, void const *,
236 (void const *__s, int __c, size_t __n)); 253 (void const *__s, int __c, size_t __n) throw ());
237# elif __GLIBC__ >= 2 254# elif __GLIBC__ >= 2
238_GL_CXXALIASWARN (memchr); 255_GL_CXXALIASWARN (memchr);
239# endif 256# endif
@@ -315,9 +332,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
315 void *, (void const *, int, size_t), 332 void *, (void const *, int, size_t),
316 void const *, (void const *, int, size_t)); 333 void const *, (void const *, int, size_t));
317# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 334# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
318 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 335 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
319_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 336 || defined __clang__)
320_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 337_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
338_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
321# else 339# else
322_GL_CXXALIASWARN (memrchr); 340_GL_CXXALIASWARN (memrchr);
323# endif 341# endif
@@ -345,9 +363,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
345 void *, (void const *__s, int __c_in), 363 void *, (void const *__s, int __c_in),
346 void const *, (void const *__s, int __c_in)); 364 void const *, (void const *__s, int __c_in));
347# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 365# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
348 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 366 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
349_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 367 || defined __clang__)
350_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 368_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
369_GL_CXXALIASWARN1 (rawmemchr, void const *,
370 (void const *__s, int __c_in) throw ());
351# else 371# else
352_GL_CXXALIASWARN (rawmemchr); 372_GL_CXXALIASWARN (rawmemchr);
353# endif 373# endif
@@ -449,9 +469,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
449 char const *, (char const *__s, int __c_in)); 469 char const *, (char const *__s, int __c_in));
450# endif 470# endif
451# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 471# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
452 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 472 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
453_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 473 || defined __clang__)
454_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 474_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
475_GL_CXXALIASWARN1 (strchrnul, char const *,
476 (char const *__s, int __c_in) throw ());
455# else 477# else
456_GL_CXXALIASWARN (strchrnul); 478_GL_CXXALIASWARN (strchrnul);
457# endif 479# endif
@@ -563,22 +585,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
563# undef strndup 585# undef strndup
564# define strndup rpl_strndup 586# define strndup rpl_strndup
565# endif 587# endif
566_GL_FUNCDECL_RPL (strndup, char *, (char const *__s, size_t __n) 588_GL_FUNCDECL_RPL (strndup, char *,
567 _GL_ARG_NONNULL ((1))); 589 (char const *__s, size_t __n)
590 _GL_ARG_NONNULL ((1))
591 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
568_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); 592_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
569# else 593# else
570# if ! @HAVE_DECL_STRNDUP@ 594# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
571_GL_FUNCDECL_SYS (strndup, char *, (char const *__s, size_t __n) 595_GL_FUNCDECL_SYS (strndup, char *,
572 _GL_ARG_NONNULL ((1))); 596 (char const *__s, size_t __n)
597 _GL_ARG_NONNULL ((1))
598 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
573# endif 599# endif
574_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); 600_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
575# endif 601# endif
576_GL_CXXALIASWARN (strndup); 602_GL_CXXALIASWARN (strndup);
577#elif defined GNULIB_POSIXCHECK 603#else
578# undef strndup 604# if __GNUC__ >= 11 && !defined strndup
579# if HAVE_RAW_DECL_STRNDUP 605/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
606_GL_FUNCDECL_SYS (strndup, char *,
607 (char const *__s, size_t __n)
608 _GL_ARG_NONNULL ((1))
609 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
610# endif
611# if defined GNULIB_POSIXCHECK
612# undef strndup
613# if HAVE_RAW_DECL_STRNDUP
580_GL_WARN_ON_USE (strndup, "strndup is unportable - " 614_GL_WARN_ON_USE (strndup, "strndup is unportable - "
581 "use gnulib module strndup for portability"); 615 "use gnulib module strndup for portability");
616# endif
582# endif 617# endif
583#endif 618#endif
584 619
@@ -638,10 +673,11 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
638 char *, (char const *__s, char const *__accept), 673 char *, (char const *__s, char const *__accept),
639 const char *, (char const *__s, char const *__accept)); 674 const char *, (char const *__s, char const *__accept));
640# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 675# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
641 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 676 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
642_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 677 || defined __clang__)
678_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
643_GL_CXXALIASWARN1 (strpbrk, char const *, 679_GL_CXXALIASWARN1 (strpbrk, char const *,
644 (char const *__s, char const *__accept)); 680 (char const *__s, char const *__accept) throw ());
645# elif __GLIBC__ >= 2 681# elif __GLIBC__ >= 2
646_GL_CXXALIASWARN (strpbrk); 682_GL_CXXALIASWARN (strpbrk);
647# endif 683# endif
@@ -746,10 +782,12 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
746 const char *, (const char *haystack, const char *needle)); 782 const char *, (const char *haystack, const char *needle));
747# endif 783# endif
748# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 784# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
749 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 785 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
750_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 786 || defined __clang__)
787_GL_CXXALIASWARN1 (strstr, char *,
788 (char *haystack, const char *needle) throw ());
751_GL_CXXALIASWARN1 (strstr, const char *, 789_GL_CXXALIASWARN1 (strstr, const char *,
752 (const char *haystack, const char *needle)); 790 (const char *haystack, const char *needle) throw ());
753# elif __GLIBC__ >= 2 791# elif __GLIBC__ >= 2
754_GL_CXXALIASWARN (strstr); 792_GL_CXXALIASWARN (strstr);
755# endif 793# endif
@@ -795,10 +833,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
795 const char *, (const char *haystack, const char *needle)); 833 const char *, (const char *haystack, const char *needle));
796# endif 834# endif
797# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 835# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
798 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 836 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
799_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 837 || defined __clang__)
838_GL_CXXALIASWARN1 (strcasestr, char *,
839 (char *haystack, const char *needle) throw ());
800_GL_CXXALIASWARN1 (strcasestr, const char *, 840_GL_CXXALIASWARN1 (strcasestr, const char *,
801 (const char *haystack, const char *needle)); 841 (const char *haystack, const char *needle) throw ());
802# else 842# else
803_GL_CXXALIASWARN (strcasestr); 843_GL_CXXALIASWARN (strcasestr);
804# endif 844# endif
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index d562746ee78..cad12d0d9be 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -5,7 +5,7 @@
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This file is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
diff --git a/lib/strtol.c b/lib/strtol.c
index 457f7a5d649..6c2e9333abc 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -8,7 +8,7 @@
8 8
9 This file is free software: you can redistribute it and/or modify 9 This file is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as 10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 3 of the 11 published by the Free Software Foundation, either version 3 of the
12 License, or (at your option) any later version. 12 License, or (at your option) any later version.
13 13
14 This file is distributed in the hope that it will be useful, 14 This file is distributed in the hope that it will be useful,
diff --git a/lib/strtoll.c b/lib/strtoll.c
index 5124168c1bb..acea42ee003 100644
--- a/lib/strtoll.c
+++ b/lib/strtoll.c
@@ -5,7 +5,7 @@
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This file is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
diff --git a/lib/symlink.c b/lib/symlink.c
index 51850b2732c..26310af7b12 100644
--- a/lib/symlink.c
+++ b/lib/symlink.c
@@ -3,7 +3,7 @@
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the 6 published by the Free Software Foundation, either version 3 of the
7 License, or (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This file is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 28ddd42f818..714c3cb189e 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -391,7 +391,33 @@ struct stat
391#endif 391#endif
392 392
393 393
394#if @GNULIB_MDA_CHMOD@ 394#if @GNULIB_CHMOD@
395# if @REPLACE_CHMOD@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397# undef chmod
398# define chmod rpl_chmod
399# endif
400_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
401 _GL_ARG_NONNULL ((1)));
402_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
403# elif defined _WIN32 && !defined __CYGWIN__
404# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405# undef chmod
406# define chmod _chmod
407# endif
408/* Need to cast, because in mingw the last argument is 'int mode'. */
409_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
410# else
411_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
412# endif
413_GL_CXXALIASWARN (chmod);
414#elif defined GNULIB_POSIXCHECK
415# undef chmod
416# if HAVE_RAW_DECL_CHMOD
417_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
418 "use gnulib module chmod for portability");
419# endif
420#elif @GNULIB_MDA_CHMOD@
395/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not 421/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
396 required. In C++ with GNULIB_NAMESPACE, avoid differences between 422 required. In C++ with GNULIB_NAMESPACE, avoid differences between
397 platforms by defining GNULIB_NAMESPACE::chmod always. */ 423 platforms by defining GNULIB_NAMESPACE::chmod always. */
diff --git a/lib/time-internal.h b/lib/time-internal.h
index e1bb56e53ec..c8a2a8ce6bc 100644
--- a/lib/time-internal.h
+++ b/lib/time-internal.h
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/time_rz.c b/lib/time_rz.c
index d0ae717f308..1a91d3778e7 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index cd0b5f5f5be..0f270e5bc8c 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 2b2aaa59373..36747833e39 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/timespec.c b/lib/timespec.c
index 82630c2f5a0..9d136cb803b 100644
--- a/lib/timespec.c
+++ b/lib/timespec.c
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/timespec.h b/lib/timespec.h
index e130d2c6e25..9e358289a2a 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -5,7 +5,7 @@
5 5
6 This file is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as 7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 3 of the 8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This file is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 3386f0b0f75..57df09ecdf4 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -415,16 +415,30 @@ _GL_CXXALIASWARN (close);
415 415
416 416
417#if @GNULIB_COPY_FILE_RANGE@ 417#if @GNULIB_COPY_FILE_RANGE@
418# if !@HAVE_COPY_FILE_RANGE@ 418# if @REPLACE_COPY_FILE_RANGE@
419# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
420# undef copy_file_range
421# define copy_file_range rpl_copy_file_range
422# endif
423_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
424 int ofd, off_t *opos,
425 size_t len, unsigned flags));
426_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
427 int ofd, off_t *opos,
428 size_t len, unsigned flags));
429# else
430# if !@HAVE_COPY_FILE_RANGE@
419_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, 431_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
420 int ofd, off_t *opos, 432 int ofd, off_t *opos,
421 size_t len, unsigned flags)); 433 size_t len, unsigned flags));
434# endif
422_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos, 435_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
423 int ofd, off_t *opos, 436 int ofd, off_t *opos,
424 size_t len, unsigned flags)); 437 size_t len, unsigned flags));
425# endif 438# endif
426_GL_CXXALIASWARN (copy_file_range); 439_GL_CXXALIASWARN (copy_file_range);
427#elif defined GNULIB_POSIXCHECK 440#elif defined GNULIB_POSIXCHECK
441# undef copy_file_range
428# if HAVE_RAW_DECL_COPY_FILE_RANGE 442# if HAVE_RAW_DECL_COPY_FILE_RANGE
429_GL_WARN_ON_USE (copy_file_range, 443_GL_WARN_ON_USE (copy_file_range,
430 "copy_file_range is unportable - " 444 "copy_file_range is unportable - "
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index ce52f8f9773..7461d740959 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
diff --git a/lib/utimens.c b/lib/utimens.c
index f4907ae4e61..2fa12518507 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/utimens.h b/lib/utimens.h
index c3054da0c67..2ccc06e5ed6 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -4,7 +4,7 @@
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 3 of the 7 published by the Free Software Foundation, either version 3 of the
8 License, or (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This file is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
diff --git a/lib/utimensat.c b/lib/utimensat.c
index 2e4c7bf9660..f81b0c790ef 100644
--- a/lib/utimensat.c
+++ b/lib/utimensat.c
@@ -3,7 +3,7 @@
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
diff --git a/lib/verify.h b/lib/verify.h
index 07b2f4866f2..c5c63ae97c6 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -34,7 +34,7 @@
34#ifndef __cplusplus 34#ifndef __cplusplus
35# if (201112L <= __STDC_VERSION__ \ 35# if (201112L <= __STDC_VERSION__ \
36 || (!defined __STRICT_ANSI__ \ 36 || (!defined __STRICT_ANSI__ \
37 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 4 <= __clang_major__))) 37 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__)))
38# define _GL_HAVE__STATIC_ASSERT 1 38# define _GL_HAVE__STATIC_ASSERT 1
39# endif 39# endif
40# if (202000L <= __STDC_VERSION__ \ 40# if (202000L <= __STDC_VERSION__ \
@@ -215,6 +215,9 @@ template <int w>
215# define _GL_VERIFY(R, DIAGNOSTIC, ...) \ 215# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
216 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 216 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
217 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 217 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
218# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
219# pragma GCC diagnostic ignored "-Wnested-externs"
220# endif
218#endif 221#endif
219 222
220/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 223/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
diff --git a/lib/vla.h b/lib/vla.h
index adc8f8f68b6..ce02428f53a 100644
--- a/lib/vla.h
+++ b/lib/vla.h
@@ -4,7 +4,7 @@
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,