Bruno Haible [Wed, 16 Aug 2017 08:13:42 +0000 (10:13 +0200)]
rename, renameat: Update doc regarding NetBSD.
* doc/posix-functions/rename.texi: Clarify that when using
-D_XOPEN_SOURCE=500 on NetBSD 7.0, the hard link bug is gone.
* doc/posix-functions/renameat.texi: Be more precise about NetBSD
version.
Paul Eggert [Tue, 15 Aug 2017 23:47:22 +0000 (16:47 -0700)]
futimens: don’t assume struct timespec layout
* m4/futimens.m4 (gl_FUNC_FUTIMENS):
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT):
* tests/test-fdutimensat.c (main):
* tests/test-futimens.h (test_futimens):
* tests/test-lutimens.h (test_lutimens):
* tests/test-utimens.h (test_utimens):
* tests/test-utimensat.c (main):
Don’t assume that struct timespec is a two-member structure in
tv_sec, tv_nsec order. Although this is true on all platforms we
know about, POSIX does not guarantee it.
Paul Eggert [Tue, 15 Aug 2017 22:53:50 +0000 (15:53 -0700)]
rename: document+test NetBSD rename
Test failure reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00104.html
This is an area where NetBSD is better-behaved than POSIX,
so allow the NetBSD behavior in tests.
* doc/posix-functions/rename.texi:
* doc/posix-functions/renameat.texi: Document NetBSD behavior.
* tests/test-rename.h (test_rename): Allow NetBSD behavior.
Bruno Haible [Tue, 15 Aug 2017 19:18:44 +0000 (21:18 +0200)]
duplocale: Work around NetBSD 7.0 bug.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Test against the NetBSD 7.0 bug.
* lib/duplocale.c: Add comment about NetBSD problem.
* doc/posix-functions/duplocale.texi: Mention the NetBSD problem.
Bruno Haible [Tue, 15 Aug 2017 18:23:00 +0000 (20:23 +0200)]
duplocale tests: Verify use with *_l functions.
* modules/duplocale-tests (configure.ac): Test for uselocale and
some *_l functions.
* tests/test-duplocale.c (test_with_uselocale): New function, extracted
from main.
(get_locale_dependent_values_from, test_with_locale_parameter): New
functions.
(main): Test both test_with_uselocale and test_with_locale_parameter.
Paul Eggert [Mon, 14 Aug 2017 20:04:46 +0000 (13:04 -0700)]
open: support O_CLOEXEC
* NEWS, doc/posix-functions/open.texi:
* doc/posix-functions/openat.texi: Document this.
* lib/fcntl.in.h (O_CLOEXEC): Default to a nonzero value.
(GNULIB_defined_O_CLOEXEC): New symbol.
* lib/open.c: Include cloexec.h.
(open): Support O_CLOEXEC.
* lib/openat.c: Include cloexec.h.
(rpl_openat): Support O_CLOEXEC.
* lib/popen-safer.c: Do not include cloexec.h.
(open_noinherit): Remove.
(popen_safer): Use O_CLOEXEC instead of set_cloexec_flag.
* lib/save-cwd.c: Do not include cloexec.h.
(save_cwd): Use O_CLOEXEC instead of set_cloexec_flag.
* m4/open-cloexec.m4: New file.
* m4/open.m4 (gl_FUNC_OPEN): Require gl_PREPROC_O_CLOEXEC.
Replace 'open' if O_CLOEXEC is not present.
* m4/openat.m4 (gl_FUNC_OPENAT): Require gl_PREPROC_O_CLOEXEC.
Replace 'openat' if O_CLOEXEC is not present.
* modules/freopen (Depends-on): Depend on 'open' if replacing freopen.
* modules/open (Files): Add m4/open-cloexec.m4.
(Depends-on): Depend on cloexec if replacing 'open'.
* modules/openat (Files): Add m4/open-cloexec.m4.
(Depends-on): Depend on cloexec if replacing openat.
* modules/popen-safer (Depends-on): Remove cloexec.
* modules/save-cwd (Depends-on): Remove cloexec, and add
fd-safer-flag and 'open'.
Darshit Shah [Sun, 13 Aug 2017 17:13:33 +0000 (10:13 -0700)]
reallocarray: New module
reallocarray is a new function in glibc 2.26 to safely allocate an array
of memory locations with integer overflow protection.
* MODULES.html.sh: Add reallocarray.
* doc/glibc-functions/reallocarray.texi: Documentation for reallocarray.
* lib/reallocarray.c: New file to implement module reallocarray.
* lib/stdlib.in.h: Add function declarations for reallocarray.
* m4/reallocarray.m4: New file.
* m4/stdlib_h.m4: Declare reallocarray.
* modules/reallocarray: New file.
* modules/reallocarray-test: New file.
* modules/stdlib: Coerce stdlib.h to export reallocarray.
* tests/test-reallocarray.c: New test.
Paul Eggert [Sat, 12 Aug 2017 18:34:50 +0000 (11:34 -0700)]
dirent-safer: fix cloexec race
* lib/opendir-safer.c: Include fcntl.h instead of unistd-safer.h.
(opendir_safer): Use F_DUPFD_CLOEXEC.
* modules/dirent-safer (Depends-on): Add fcntl. Remove unistd-safer.
* tests/test-dirent-safer.c: Do not include unistd-safer.h,
as it is no longer a prerequisite. Use F_DUPFD_CLOEXEC
instead of dup_safer.
Paul Eggert [Sat, 12 Aug 2017 18:20:41 +0000 (11:20 -0700)]
fts: fix cloexec races
* lib/fts.c [!_LIBC]: Do not include dirent--.h, unistd--.h, cloexec.h.
(opendirat, diropen): Use O_CLOEXEC instead of set_cloexec_flag.
(fts_build): Use F_DUPD_CLOEXEC rinstad of set_cloexec_flag.
(fd_ring_check): Set cloexec flag on new file descriptors.
(fts_build, fd_ring_check): While we’re at it, make sure the
resulting file descriptor is not 0, 1, or 2, since that is easy.
* modules/fts (Depends-on): Remove cloexec, dirent-safer, dup,
fcntl-safer, unistd-safer. Add fcntl.
Paul Eggert [Thu, 10 Aug 2017 13:06:06 +0000 (06:06 -0700)]
fts: port recent changes to CentOS 6
Problem reported by Tom G. Christensen in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00064.html
* lib/fts.c (fsword): New type.
(struct dev_type, filesystem_type): Use it.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Check for __fsword_t.
Also, check for f_type only if fstatfs and sys/vfs.h work.
Reuben Thomas [Mon, 7 Aug 2017 20:08:13 +0000 (22:08 +0200)]
manywarnings: Add support for C++.
* build-aux/g++-warning.spec: New file.
* m4/manywarnings-c++.m4: New file.
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C++)): New macro, that
redirects to manywarnings-c++.m4.
* modules/manywarnings (Files): Add m4/manywarnings-c++.m4.
Paul Eggert [Mon, 7 Aug 2017 06:24:10 +0000 (23:24 -0700)]
git-version-gen: another fix for tags with "-"
* build-aux/git-version-gen: Improve fix for tags containing "-".
Suggested by Markus Armbruster in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00034.html
Bruno Haible [Sun, 6 Aug 2017 22:40:41 +0000 (00:40 +0200)]
warnings, manywarnings: Add support for multiple languages, not just C.
* warnings.m4 (gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL): Renamed from
gl_UNKNOWN_WARNINGS_ARE_ERRORS.
(gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)): New macro.
(gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)): New macro.
(gl_UNKNOWN_WARNINGS_ARE_ERRORS): Dispatch to
gl_UNKNOWN_WARNINGS_ARE_ERRORS(_AC_LANG).
(gl_WARN_ADD): Require the gl_UNKNOWN_WARNINGS_ARE_ERRORS specialization
of the current language. If C++ is the current language, modify
WARN_CXXFLAGS instead of WARN_CFLAGS.
* manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)): New macro, extracted from
gl_MANYWARN_ALL_GCC.
(gl_MANYWARN_ALL_GCC): Dispatch to gl_MANYWARN_ALL_GCC(_AC_LANG).
Really old versions of git-describe (before v1.5.0, Feb 2007) don't
have the number of commits in their long format output, i.e. where
modern 'git describe --abbrev=4 --match="v*"' prints
"v0.1-1494-g124b9", they print "v0.1-1494-g124b9". git-version-gen
recognizes both patterns, and normalizes the old format to the new
one.
Unfortunately, this normalization code gets confused when the tag
contains '-'. Reproducer:
We take exact tag "v0.2-rc1" for the old format, extract the presumed
tag "v0.2" from it, then run "git rev-list v0.2..HEAD" to count
commits since tha tag. Fails, because tag "v0.2" does not exist.
* git-version-gen: We could perhaps drop support for versions from more
than a decade ago. But tightening the pattern match is easy enough,
so do that. Still breaks when you use version tags ending in something
matching -g????, but you arguably get what you deserve then.
Paul Eggert [Fri, 4 Aug 2017 22:14:59 +0000 (15:14 -0700)]
manywarnings: port to 64-bit GCC builds of Emacs
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Compute max safe
object size rather than hardwiring 2147483647. This is needed to
build GNU Emacs, which has one conditional (and used
only-in-theory) call to malloc with a literal greater than 2147483647.
Paul Eggert [Thu, 3 Aug 2017 23:28:18 +0000 (16:28 -0700)]
renameat2: port to RHEL 7 + NFS
* lib/renameat2.c (renameat2) [SYS_renameat2]:
Port to RHEL 7 + NFS. Problem reported by Ted Zlatanov in:
http://lists.gnu.org/archive/html/emacs-devel/2017-08/msg00082.html
Paul Eggert [Wed, 2 Aug 2017 18:06:33 +0000 (11:06 -0700)]
renameat2: port to non-renameat platforms
Problem reported for MSVC-2015 by Gisle Vanem in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-08/msg00001.html
* lib/renameat2.c [!HAVE_RENAMEAT]: Include <sys/stat.h> here too.
(renameat2) [!HAVE_RENAMEAT]: Fix typo in arg passing.
Paul Eggert [Tue, 1 Aug 2017 16:52:40 +0000 (09:52 -0700)]
manywarnings: port to 32-bit GCC bug
Problem reported by Pino Toscano in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00150.html
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Use 2**31 - 1,
not 2**63 - 1, to work around the following GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81650
Paul Eggert [Sun, 30 Jul 2017 22:38:56 +0000 (15:38 -0700)]
canonicalize: fix EOVERFLOW commentary
Problem reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00147.html
* lib/canonicalize.c (canonicalize_filename_mode):
* lib/canonicalize-lgpl.c (__realpath): Fix comments.
Paul Eggert [Sun, 30 Jul 2017 20:06:41 +0000 (13:06 -0700)]
Don't interpret EOVERFLOW to mean nonexistence
* lib/fts.c (fts_stat): If lstat fails, report its errno, which
may be EOVERFLOW; this is likely more useful than reporting the
stat errno.
* lib/glob.c (link_stat): Rename from link_exists2_p and
return -1/0 instead of 0/1. Caller changed.
* lib/glob.c (link_exists_p):
* lib/renameat2.c (rename_noreplace, renameat2):
* lib/tempname.c (try_nocreate):
If errno == EOVERFLOW then the directory entry exists, so do not
act as if it does not exist.
Paul Eggert [Sun, 30 Jul 2017 17:53:32 +0000 (10:53 -0700)]
backup-rename: new module
It is like backupfile, except it avoids some race conditions,
and it does not output to stderr or exit.
* MODULES.html.sh: Add backup-rename.
* lib/backup-find.c, lib/backup-internal.h, lib/backup-rename.c:
* modules/backup-rename: New files.
* lib/backupfile.c: Turn this into an internals file, which
contains code common to backupfile and backup_rename. Do not
include argmatch.h or xalloc.h: include xalloc-oversized.h.
Include renameat2.h and fcntl.h.
(BACKUP_NOMEM): New constant.
(numbered_backup): New args BASE_OFFSET and *DIRPP. Do not exit
on memory exhaustion; just return BACKUP_NOMEM. Caller changed.
(backupfile_internal): Rename from find_backup_file_name.
Support new arg RENAME.
(backup_args, backup_types, get_version, xget_version):
Move to lib/backup-find.c.
* lib/backupfile.h (backup_file_rename): New decl.
* modules/backupfile (Files): Add lib/backup-internal.h,
lib/backup-find.c.
(Depends-on): Add dirfd, fcntl, renameat2.
(lib_SOURCES): Add backup-find.c.
Reuben Thomas [Sun, 30 Jul 2017 11:16:11 +0000 (13:16 +0200)]
relocatable: Make the license on the sources the GPL.
* lib/relocatable.h, lib/relocatable.c: Change the copyright notice from
LGPL, which was a special case so that the relocatable source files
could be used without gnulib-tool, to GPL. They can still be used under
the LGPL, using the --lgpl option to gnulib-tool.
Bruno Haible [Sun, 30 Jul 2017 10:39:01 +0000 (12:39 +0200)]
host-cpu-c-abi: Detect ILP32 ABI on IA-64 HP-UX.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Distinguish ia64-ilp32
from ia64. For arm64, test only __aarch64__, as __ARM_64BIT_STATE and
__ARM_PCS_AAPCS64 are not reliable indicators: they are not defined on
Ubuntu 14.04 (gcc 4.8.4) and Debian 8 (gcc 4.9.2).
Paul Eggert [Thu, 27 Jul 2017 23:36:03 +0000 (16:36 -0700)]
renameat2: port to Solaris 10
* lib/renameat2.c (rename_noreplace): Use lstat, not faccessat
with AT_SYMLINK_NOFOLLOW (which is not portable).
(renameat): Undef before using, to avoid endless recursion when
the replacement renameat calls renameat2 which calls the
replacement renameat.
(renameat2): Use lstatat, not faccessat with AT_SYMLINK_NOFOLLOW.
* modules/renameat2 (Depends-on): Remove faccessat.
* modules/renameat-tests (test_renameat_LDADD):
* modules/renameat2-tests (test_renameat2_LDADD):
Remove $(LIB_EACCESS).
Paul Eggert [Thu, 27 Jul 2017 19:08:39 +0000 (12:08 -0700)]
renameat2: new module
Although the Linux syscall renameat2 is not in glibc (yet?), it is
useful to have access to its RENAME_NOREPLACE flag.
* MODULES.html.sh (func_all_modules): Add renameat2.
* lib/renameat2.c, lib/renameat2.h, modules/renameat2:
* modules/renameat2-tests, tests/test-renameat2.c: New files.
* lib/renameat.c (renameat): Move most of the implementation
to renameat2, and just call renameat2.
* modules/renameat (Files): Remove lib/at-func2.c.
(Depends-on): Depend only on renameat2.
(Include): Remove <fcntl.h>.
* modules/renameat-tests (test_renameat_LDADD): Add $(LIB_EACCESS),
since renameat (via renameat2) might use faccessat.
Erik Skultety [Thu, 27 Jul 2017 11:47:23 +0000 (13:47 +0200)]
vc-list-files: Adjust the script to support git worktrees
Git's worktree feature creates a ".git" which refers to references from
the original (main) repository. This makes vc-list-files to fail for
worktrees since it checks for both file's existence and the file being a
directory. Checking for existence should be okay in this case, since the
script doesn't touch anything within ".git" directly. Instead, it
invokes git commands, which work from within a worktree nicely.
Paul Eggert [Wed, 26 Jul 2017 18:57:37 +0000 (11:57 -0700)]
maint: bring MODULES.html.sh up to date
Somehow a few months ago we stopped updating MODULES.html.sh.
I don’t recall explicitly deciding this, so I updated it now.
Alternatively I suppose we could remove it.
* MODULES.html.sh: Add builtin-expect, c99, ctime, explicit_bzero,
localtime, localtime-buffer, noreturn, nstrftime, strftime-fixes,
truncate, utime, utime-h, windows-stat-inodes,
windows-stat-override, windows-stat-timespec, year2038. Sort.
Paul Eggert [Tue, 25 Jul 2017 06:54:00 +0000 (23:54 -0700)]
fts: three levels of leaf optimization
* lib/fts.c (enum leaf_optimization): New type with three values.
(S_MAGIC_AFS): New macro. Sort them.
(leaf_optimization): Rename from leaf_optimization_applies, and
return enum leaf_optimization instead of bool. All uses changed.
Add cases for unknown type and for AFS.
(fts_build): Don’t rely on link counts if NO_LEAF_OPTIMIZATION.
Paul Eggert [Tue, 25 Jul 2017 06:44:05 +0000 (23:44 -0700)]
fts: cache dirent_inode_sort_may_be_useful too
* lib/fts.c (struct dev_type): New struct.
(DEV_TYPE_HT_INITIAL_SIZE): New constant.
(dev_type_hash, dev_type_compare, filesystem_type): New functions.
(dirent_inode_sort_may_be_useful, leaf_optimization_applies):
Now takes FTSENT const *, not int. All uses changed. Use
filesystem_type to cache.
(link_count_optimize_ok): Remove. Caller changed to use
leaf_optimization_applies, which now uses shared cache.
Paul Eggert [Tue, 25 Jul 2017 06:21:57 +0000 (23:21 -0700)]
fts: nlink_t signedness fixups
* lib/fts.c (fts_open): Set rootparent n_dirs_remaining to -1
so that root need not be a special case later.
(fts_read): Remove now-redundant test for fts_level.
Do not assume that nlink_t is signed.
(fts_build): Remove useless decrement of nlinks.
(fts_stat): Avoid unlikely signed integer overflow later, if
nlink_t is signed.
Paul Eggert [Sun, 16 Jul 2017 14:26:16 +0000 (07:26 -0700)]
explicit_bzero: new module
The explicit_bzero function has been added to glibc.
This module is intended to supports its use in GNU programs.
* doc/glibc-functions/explicit_bzero.texi, lib/explicit_bzero.c:
* m4/explicit_bzero.m4, modules/explicit_bzero:
New files.
* doc/gnulib.texi (Glibc string.h): Link to new doc.
* lib/string.in.h (explicit_bzero): Declare.
* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Add defaults for it.
* modules/string (string.h): Substitute its vars.
Bruno Haible [Sun, 16 Jul 2017 12:21:55 +0000 (14:21 +0200)]
unicase/locale-language: Fix link dependencies.
* modules/unicase/locale-language (Link): New section.
* modules/unicase/locale-language-tests (Makefile.am): Link
test-locale-language program with $(LIBTHREAD).
Bruno Haible [Sat, 15 Jul 2017 15:00:37 +0000 (17:00 +0200)]
getdtablesize: Add minimal support for OpenVMS.
Reported by John E. Malmberg <wb8tyw@qsl.net>.
* modules/getdtablesize (Description): Fix.
* lib/getdtablesize.c: Fix comment.
* m4/getdtablesize.m4 (gl_FUNC_GETDTABLESIZE): Don't replace the
getdtablesize() function, even though the test fails.
* doc/glibc-functions/getdtablesize.texi: Reference SUSv2. Describe
limitation on OpenVMS.
Paul Eggert [Mon, 10 Jul 2017 18:56:48 +0000 (11:56 -0700)]
getlogin: don’t assume one name per uid
Problem reported by Wolfgang F. Muthmann (Bug#27640).
* modules/getlogin-tests (Files): Add tests/test-getlogin_r.c.
(ttyname): Remove test.
* modules/getlogin_r-tests (ttyname): Remove test.
* tests/test-getlogin.c: Replace this near-clone of test-getlogin_r.c
with ‘#define TEST_LOGIN’ followed by ‘#include "test-getlogin_r.c"’.
* tests/test-getlogin_r.c: If TEST_GETLOGIN is defined, test
getlogin rather than getlogin_r. This avoids code duplication.
(main): Use isatty and fstat rather than ttyname and stat.
Use getpwnam instead of getpwuid, to be portable to test platforms
that have multiple login names for the same uid.
Paul Eggert [Fri, 7 Jul 2017 21:10:20 +0000 (14:10 -0700)]
vasnprintf: port to macOS 10.13
Problem reported by comex in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html
* lib/vasnprintf.c (VASNPRINTF): Don’t use %n on macOS.
Paul Eggert [Thu, 6 Jul 2017 21:08:24 +0000 (14:08 -0700)]
parse-datetime: fix uninit var bug
Reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00038.html
* lib/parse-datetime.y (parse_datetime2): Do not use
uninitialized.
Paul Eggert [Sun, 25 Jun 2017 06:48:31 +0000 (23:48 -0700)]
xalloc-oversized: port to icc
* lib/xalloc-oversized.h (xalloc_oversized): Do not use
__builtin_mul_overflow if ICC is defined, as this results in
"undefined reference to `__builtin_mul_overflow'" with icc 17.0.2 20170213.
Bruno Haible [Mon, 19 Jun 2017 14:54:55 +0000 (16:54 +0200)]
sched: Fix compilation failure on OpenVMS.
* m4/sched_h.m4 (gl_SCHED_H): Require AC_CANONICAL_HOST. On OpenVMS,
test whether <pthread.h> exists and defines struct sched_param.
* lib/sched.in.h: On OpenVMS, include <pthread.h>.
Paul Eggert [Sat, 17 Jun 2017 19:16:27 +0000 (12:16 -0700)]
diffseq: port to GCC 7 with --enable-gcc-warnings
* lib/diffseq.h (diag): Use an if, not an ifdef, for most of the
heuristic check. This way, GCC 7 with --enable-gcc-warnings does
not complain about big_snake being defined but not used.
Bruno Haible [Thu, 15 Jun 2017 20:58:28 +0000 (22:58 +0200)]
gettext-h: Update theoretical condition for use of variable size arrays.
Reported by Paul Eggert.
* lib/gettext.h (_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS): Extend comment
to include the theoretical condition for availability of variable size
arrays, if we could trust the value of __STDC_VERSION__.