Daiki Ueno [Thu, 28 May 2020 09:40:49 +0000 (11:40 +0200)]
fopen-gnu: make 'b' flag can be used with 'e' on Windows
* lib/fopen.c (rpl_fopen): Pass O_BINARY to open, if a 'b' flag is
specified on Windows.
* tests/test-fopen-gnu.c (DATA): New define.
(main): Add test for reading binary files with an 'e' flag.
Bruno Haible [Thu, 28 May 2020 00:31:53 +0000 (02:31 +0200)]
Don't assume that UNICODE is not defined.
Some Windows types, such as TCHAR, LPTSTR, LPCTSTR, are defined
differently if the application defines the macro UNICODE.
Reported by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00184.html>.
* lib/link.c (CreateHardLinkFuncType): Use LPCSTR, not LPCTSTR.
* lib/localename.c (enum_locales_fn): Use LPSTR, not LPTSTR.
* lib/stat-w32.c (GetFinalPathNameByHandleFuncType): Likewise.
Bruno Haible [Thu, 28 May 2020 00:06:51 +0000 (02:06 +0200)]
Improve pattern for defining _WIN32_WINNT.
Newer versions of the Windows API may not only add, but also remove API
functions. Therefore, when the user is e.g. building for Windows 10, we
should not set _WIN32_WINNT to e.g. Windows 8, as this may enable the
use of APIs that were present in Windows 8 but removed in Windows 10.
Suggested by Steve Lhomme <robux4@ycbcr.xyz> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00318.html>.
* lib/ftruncate.c (_WIN32_WINNT): Don't set to a smaller value.
* lib/sethostname.c (_WIN32_WINNT): Likewise.
* lib/stat-w32.c (_WIN32_WINNT): Likewise.
Daiki Ueno [Tue, 26 May 2020 08:22:37 +0000 (10:22 +0200)]
read-file: add RF_SENSITIVE flag
* lib/read-file.h (RF_SENSITIVE): New define.
* lib/read-file.c (fread_file, read_file): Take into account of
RF_SENSITIVE flag.
* modules/read-file (Depends-on): Add explicit_bzero.
This adds an alternative behavior of those functions to explicitly
clear the internal memory block when it becomes unused. This is
useful for reading sensitive information from a file.
Bruno Haible [Tue, 26 May 2020 20:27:51 +0000 (22:27 +0200)]
count-one-bits: Fix MSVC specific code.
Reported by Gisle Vanem <gisle.vanem@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00309.html>.
* lib/count-one-bits.h (COUNT_ONE_BITS_GENERIC): Don't define if we're
using GCC.
[_MSC_VER]: Use correct syntax for #pragma intrinsic.
(__popcnt64): In 32-bit mode, define as an inline function.
(COUNT_ONE_BITS): Rename first argument to GCC_BUILTIN.
Bruno Haible [Sun, 24 May 2020 18:38:53 +0000 (20:38 +0200)]
fopen-gnu: New module.
Suggested by Tim Rühsen <tim.ruehsen@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00119.html>.
* lib/fopen.c (rpl_fopen): When the fopen-gnu module is enabled and the
mode contains an 'x' or 'e' flag, use open() followed by fdopen().
* m4/fopen.m4 (gl_FUNC_FOPEN_GNU): New macro.
* modules/fopen-gnu: New file.
* doc/posix-functions/fopen.texi: Document the 'fopen-gnu' module.
Bruno Haible [Sun, 24 May 2020 18:27:39 +0000 (20:27 +0200)]
open, openat: Really support O_CLOEXEC.
* lib/open.c (open): When have_cloexec is still undecided, do pass a
O_CLOEXEC flag to orig_open.
* lib/openat.c (rpl_openat): When have_cloexec is still undecided, do
pass a O_CLOEXEC flag to orig_openat.
* tests/test-open.h (test_open): Verify that O_CLOEXEC is honoured.
* modules/open-tests (Depends-on): Add fcntl.
* modules/openat-tests (Depends-on): Likewise.
* modules/fcntl-safer-tests (Depends-on): Likewise.
Bruno Haible [Sun, 24 May 2020 11:57:59 +0000 (13:57 +0200)]
fopen: Fix the trailing slash workaround.
* lib/fopen.c (rpl_fopen): Parse the mode string. Recognize "r+" as a
write access. Pass the right flags to open().
* tests/test-fopen.h (test_fopen): Add a few more tests on directories.
Paul Eggert [Sun, 24 May 2020 02:06:16 +0000 (19:06 -0700)]
assure: new macro ‘affirm’
* lib/assure.h: Include verify.h.
(affirm): New macro, after a suggestion by Marc Nieper-Wißkirchen in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00263.html
and commentary by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00278.html
* modules/assure (Depends-on:): Add verify.
Bruno Haible [Sat, 23 May 2020 19:17:22 +0000 (21:17 +0200)]
isnanf, isnanl, isnan: Don't use nonexistent builtins with clang.
* m4/isnanf.m4 (gl_HAVE_ISNANF_NO_LIBM, gl_HAVE_ISNANF_IN_LIBM,
gl_ISNANF_WORKS): Don't use __builtin_isnanf on clang versions that
don't have it.
* m4/isnanl.m4 (gl_HAVE_ISNANL_NO_LIBM, gl_HAVE_ISNANL_IN_LIBM,
gl_FUNC_ISNANL_WORKS): Don't use __builtin_isnanl on clang versions that
don't have it.
* lib/isnanf-nolibm.h (__has_builtin): New macro.
(isnanf): Don't use __builtin_isnanf on clang versions that don't have
it.
* lib/isnanl-nolibm.h (__has_builtin): New macro.
(isnanl): Don't use __builtin_isnanl on clang versions that don't have
it.
* lib/math.in.h (__has_builtin): New macro.
(isnanf): Don't use __builtin_isnanf on clang versions that don't have
it.
(isnanl): Don't use __builtin_isnanl on clang versions that don't have
it.
(isnan): Don't use the builtins on clang versions that don't have
__builtin_isnanf and __builtin_isnanl.
Bruno Haible [Sat, 23 May 2020 10:19:34 +0000 (12:19 +0200)]
findprog-in: Ignore directories.
Reported by Frederick Eaton via Dmitry Goncharov in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00003.html>.
* lib/findprog-in.c (find_in_given_path): When the file found is a
directory, set errno to EACCES and, during a PATH search, continue
searching.
* modules/findprog-in (Depends-on): Add sys_stat, stat.
Asher Gordon [Fri, 22 May 2020 17:39:01 +0000 (13:39 -0400)]
gendocs: Clarify licenses for templates.
* doc/gendocs_template: Add a GNU All-Permissive license notice and
bump Parent-Version.
* doc/gendocs_template_min: Add a GNU All-Permissive license notice
and copy the explanatory comment about the license notice at the
bottom from gendocs_template.
Bruno Haible [Thu, 21 May 2020 19:43:32 +0000 (21:43 +0200)]
group-member: Relicense under LGPLv2+.
Jim Meyering's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00218.html>.
Paul Eggert's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00225.html>.
Eric Blake's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00217.html>.
* modules/group-member (License): Change to LGPLv2+.
vcs-to-changelog: Rename vcs_to_changelog.py to use hyphens.
This was needed earlier because modules had to import the main script,
but that is no longer true. Rename the script so that it is
consistent with all other scripts in gnulib and uses hyphens.
* build-aux/vcs_to_changelog.py: Rename to...
* build-aux/vcs-to-changelog.py: ... this.
* doc/vcs-to-changelog.texi (VCS To ChangeLog): Update reference.
* modules/vcs-to-changelog: Likewise.
Bruno Haible [Sun, 17 May 2020 17:27:08 +0000 (19:27 +0200)]
Clarify intended usage of the license file modules.
Reported by Asher Gordon <AsDaGo@posteo.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00126.html>.
* doc/licenses-texi.texi (License Texinfo sources): Mention the
GNU AGPL. Explain the intended usage of the modules.
* modules/fdl (Notice): Discourage use as a module.
* modules/fdl-1.3 (Notice): Likewise.
Paul Eggert [Tue, 12 May 2020 16:24:05 +0000 (09:24 -0700)]
xalloc: pacify -Wanalyzer-possible-null-argument
Problem reported for GCC 10.1.0 by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00118.html
* lib/xmalloc.c (HAVE_GNU_MALLOC, HAVE_GNU_REALLOC): New constants.
(xmalloc): Suppress unnecessary check if HAVE_GNU_MALLOC.
(xrealloc): Suppress unnecssary check if HAVE_GNU_REALLOC.
Paul Eggert [Mon, 11 May 2020 17:46:07 +0000 (10:46 -0700)]
careadlinkat: fix GCC 10 workaround
* lib/careadlinkat.c (careadlinkat) [GCC_LINT]:
Massage the code so that it’s closer to what it was before
the GCC 10.1.0 workaround was introduced. This fixes
a loop when !buffer and the bug workaround is in effect.
Remove unnecessary casts. Defend in a different way
against (buffer && !buffer_size), by adding at least 1
to buf_size each time through the loop.
Bruno Haible [Sun, 10 May 2020 16:14:38 +0000 (18:14 +0200)]
string: Fix compilation error in C++ mode.
* lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): In C mode, use plain
_GL_WARN_ON_USE.
* lib/string.in.h (strchr, strpbrk, strrchr): Use _GL_WARN_ON_USE_CXX
instead of _GL_WARN_ON_USE.
Paul Eggert [Sat, 9 May 2020 19:00:08 +0000 (12:00 -0700)]
attribute: remove ATTRIBUTE_DEPRECATED
* lib/attribute.h: Improve recently-added comments, mostly
by shortening them (use active voice, etc.).
(ATTRIBUTE_DEPRECATED): Remove, as it duplicates DEPRECATED.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00089.html
* lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Don't override the definition
that usually comes from m4/gnulib-common.m4.
* lib/monetary.in.h (_GL_ATTRIBUTE_FORMAT): Likewise.
* lib/dirent.in.h (_GL_ATTRIBUTE_PURE): Don't override the definition
that usually comes from m4/gnulib-common.m4.
* lib/stdlib.in.h (_GL_ATTRIBUTE_PURE): Likewise.
* lib/string.in.h (_GL_ATTRIBUTE_PURE): Likewise.
* lib/wchar.in.h (_GL_ATTRIBUTE_PURE): Likewise.
Bruno Haible [Sat, 9 May 2020 00:55:06 +0000 (02:55 +0200)]
c32rtomb: Avoid compilation failure on Haiku.
* m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Test for c32rtomb without excluding
inline definitions.
* doc/posix-functions/c32rtomb.texi: Mention the Haiku problem.
Bruno Haible [Sat, 9 May 2020 00:52:48 +0000 (02:52 +0200)]
mbrtoc32: Avoid compilation failure on Haiku.
* m4/mbrtoc32.m4 (gl_CHECK_FUNC_MBRTOC32): New macro.
(gl_FUNC_MBRTOC32, gl_MBRTOC32_SANITYCHECK): Use it instead of
AC_CHECK_FUNCS_ONCE.
* doc/posix-functions/mbrtoc32.texi: Mention the Haiku problem.
Paul Eggert [Wed, 6 May 2020 22:51:10 +0000 (15:51 -0700)]
Fix version-etc glitch on OpenIndiana
Problem reported by Mats Erik Andersson in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00067.html
* lib/version-etc.h (_GL_ATTRIBUTE_SENTINEL): Remove defn
that now clashes with gnulib-common.h. All uses changed.
Paul Eggert [Sat, 2 May 2020 01:12:12 +0000 (18:12 -0700)]
attribute: new module
This simplifies use of GCC and C2X attributes like ‘deprecated’.
* MODULES.html.sh: Add attribute.
* doc/attribute.texi, lib/attribute.h, modules/attribute: New files.
* doc/gnulib.texi (Particular Modules): Add Attributes.
* lib/backupfile.c, lib/fnmatch.c, lib/freopen-safer.c:
* lib/mbrtoc32.c, lib/mbrtowc.c, lib/nstrftime.c, lib/quotearg.c:
* lib/savewd.c, lib/unistr/u8-uctomb-aux.c, lib/unistr/u8-uctomb.c:
* lib/vasnprintf.c:
Include attribute.h, and let it define FALLTHROUGH.
* lib/bitset/base.h, lib/c-stack.c (__attribute__): Remove macro.
* lib/bitset/base.h (ATTRIBUTE_UNUSED): Define in terms of
_GL_ATTRIBUTE_MAYBE_UNUSED, for forwards compatibility to C2X.
* lib/dfa.c (FALLTHROUGH): Define consistently with gl_COMMON_BODY.
This is a copy since Gawk doesn’t use Gnulib.
* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Remove definition that
is incompatible with gl_COMMON_BODY’s. All uses changed.
* lib/fts.c: Include attribte.h, for FALLTHROUGH.
Keep the existing FALLTHROUGH definition since Glibc might use it,
and it does no harm to Gnulib’s FALLTHROUGH.
* lib/fts_.h, lib/inttostr.h:
(__GNUC_PREREQ): Remove; no longer needed.
(__attribute_warn_unused_result__): Remove. All uses
replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/gl_list.h, lib/gl_map.h, lib/gl_omap.h, lib/gl_oset.h:
* lib/gl_set.h: Prefer _GL_ATTRIBUTE_NODISCARD to an ifdeffed
__attribute__ ((__warn_unused_result__)), for forward
compatibility to C2X.
* lib/hash.h (_GL_ATTRIBUTE_WUR): Remove. All uses replaced by
_GL_ATTRIBUTE_NODISCARD.
(_GL_ATTRIBUTE_DEPRECATED): Remove, since gl_COMMON_BODY defines it.
* lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Remove. All uses
replaced by gl_COMMON_BODY’s implementation, which has a
slightly different signature.
* lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK):
Remove. All uses replaced by _GL_ATTRIBUTE_NODISCARD.
* lib/unused-parameter.h (_GL_UNUSED_PARAMETER):
Define in terms of _GL_ATTRIBUTE_MAYBE_UNUSED.
No doubt all uses should be replaced, at some point.
* m4/gnulib-common.m4 (_GL_GNUC_PREREQ): New macro.
(_Noreturn): Use it.
(_GL_HAS_ATTRIBUTE, _GL_ATTRIBUTE_ALLOC_SIZE)
(_GL_ATTRIBUTE_ALWAYS_INLINE, _GL_ATTRIBUTE_ARTIFICIAL)
(_GL_ATTRIBUTE_COLD)
(_GL_ATTRIBUTE_DEPRECATED, _GL_ATTRIBUTE_ERROR)
(_GL_ATTRIBUTE_WARNING, _GL_ATTRIBUTE_EXTERNALLY_VISIBLE)
(_GL_ATTRIBUTE_FALLTHROUGH, _GL_ATTRIBUTE_FORMAT)
(_GL_ATTRIBUTE_LEAF, _GL_ATTRIBUTE_MAY_ALIAS)
(_GL_ATTRIBUTE_MAYBE_UNUSED)
(_GL_ATTRIBUTE_NODISCARD, _GL_ATTRIBUTE_NOINLINE)
(_GL_ATTRIBUTE_NONNULL, _GL_ATTRIBUTE_NONSTRING)
(_GL_ATTRIBUTE_NOTHROW, _GL_ATTRIBUTE_PACKED, _GL_ATTRIBUTE_PURE)
(_GL_ATTRIBUTE_SENTINEL): New macros.
* modules/backup-rename, modules/backupfile, modules/c-vasnprintf:
* modules/fnmatch, modules/freopen-safer, modules/fts:
* modules/mbrtoc32, modules/mbrtowc, modules/nstrftime:
* modules/quotearg, modules/savewd:
* modules/unistdio/u16-u16-vasnprintf:
* modules/unistdio/u16-vasnprintf:
* modules/unistdio/u32-u32-vasnprintf:
* modules/unistdio/u32-vasnprintf:
* modules/unistdio/u8-u8-vasnprintf:
* modules/unistdio/u8-vasnprintf:
* modules/unistdio/ulc-vasnprintf:
* modules/unistr/u8-uctomb, modules/vasnprintf:
(Depends-on:): Add attribute module.
Akim Demaille [Sun, 3 May 2020 06:54:58 +0000 (08:54 +0200)]
bison: rely on bison's %require to check a version requirement
See https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00021.html.
* m4/bison.m4 (gl_PROG_BISON): Let bison itself decide if it it recent
enough of not.
So far it is the only know Yacc tool that supports '%require'.
Other yaccs will actually even choke on seeing the -o option after the
input file name.
* m4/parse-datetime.m4: Simplify gl_PROG_BISON invocation.
Bruno Haible [Sat, 2 May 2020 15:23:01 +0000 (17:23 +0200)]
bison-i18n: Add support for cross-compilation.
Reported by Hongxu Jia <hongxu.jia@windriver.com> in
<https://lists.gnu.org/archive/html/bison-patches/2016-02/msg00000.html>
via Akim Demaille <akim@lrde.epita.fr>.
* m4/bison-i18n.m4 (BISON_I18N): Accept a configure option
--with-bison-prefix=PREFIX and use it to determine BISON_LOCALEDIR.
Don't use bison's --print-localedir option when cross-compiling.
Also, fix an error message and a comment.