Paul Eggert [Fri, 2 Jun 2023 21:02:53 +0000 (14:02 -0700)]
propername-lite: new module
propername_lite acts like propername_utf8 but needs less
infrastructure, e.g., it does not worry about memory allocation.
* MODULES.html.sh (func_all_modules): Mention it.
* lib/propername.h (proper_name_lite): New decl.
* lib/propername-lite.c, modules/propername-lite: New files.
* pygnulib/GLEmiter.py (GLEmiter.po_Makevars):
Treat proper_name_lite like proper_name_utf8.
* lib/javacomp.c: Include verify.h.
(is_envjavac_gcj43_usable, is_envjavac_oldgcj_14_13_usable,
is_envjavac_nongcj_usable, compile_java_class): Assert that the
xasprintf results are non-NULL. This is possible since all involved
format strings are valid and don't use %ls, and all argument strings
are small compared to INT_MAX.
* modules/javacomp (Depends-on): Add verify.
Paul Eggert [Tue, 30 May 2023 21:38:41 +0000 (14:38 -0700)]
error: don’t call ‘exit’
Let the underlying functions call ‘exit’, instead of having the
Gnulib replacement macros do it. Use ‘unreachable’ to tell the
compiler that those functions exit when the status is nonzero.
This saves a function call.
* lib/error.in.h: Include stddef.h, not stdlib.h.
(__gl_error_call): Rely on the function to exit, using
‘unreachable’ to tell the compiler that the function does not return.
* modules/error (Depends-on): Add stddef.
Paul Eggert [Tue, 30 May 2023 19:49:20 +0000 (12:49 -0700)]
error: don’t evaluate status arg twice
This avoids potential issues if the first argument has a side effect.
* lib/error.in.h (__gl_error_call): New macro, which evaluates its
status arg only once, by using a statement expression if GNU C -
the only platform we need to worry about pacifying - and by simply
calling ‘error’ otherwise.
(error, error_at_line): Use it.
Jim Meyering [Sun, 28 May 2023 16:41:08 +0000 (09:41 -0700)]
file-has-acl: avoid warning from bleeding-edge GCC
* lib/file-has-acl.c: Include attribute.h.
(have_xattr): Declare with ATTRIBUTE_PURE,
to avoid new warning from GCC14-to-be.
* modules/file-has-acl (Depends-on): Add attribute.
Spotted while building coreutils with this:
gcc version 14.0.0 20230526 (experimental)
Bruno Haible [Sat, 27 May 2023 20:39:59 +0000 (22:39 +0200)]
error: Support the compiler's control flow analysis better.
* lib/error.in.h: Remove @PRAGMA_SYSTEM_HEADER@. Include <stdlib.h>.
(error): Define as a macro that explicitly invokes exit().
(error_at_line): Likewise.
* lib/error.c (_GL_NO_INLINE_ERROR): Define before including error.h.
* modules/error-h (configure.ac): Don't invoke gl_CONDITIONAL_HEADER.
(Makefile.am): Generate error.h always. Don't substitute
PRAGMA_SYSTEM_HEADER.
* m4/error_h.m4 (gl_ERROR_H): Set COMPILE_ERROR_C instead of
GL_GENERATE_ERROR_H.
* modules/error (configure.ac, Depends-on): Test COMPILE_ERROR_C instead
of GL_GENERATE_ERROR_H.
* lib/copy-file.c: Revert the last change.
Bruno Haible [Fri, 26 May 2023 22:18:57 +0000 (00:18 +0200)]
flexmember: Make it easier to use.
* lib/flexmember.h (FLEXNSIZEOF): New macro.
* lib/hamt.c (alloc_bucket, alloc_subtrie): Fix FLEXSIZEOF invocation.
Use FLEXNSIZEOF instead of FLEXSIZEOF.
* lib/ssfmalloc.h (init_small_block_page_pool): Use FLEXNSIZEOF instead
of FLEXSIZEOF.
Paul Eggert [Wed, 24 May 2023 17:10:18 +0000 (10:10 -0700)]
manywarnings: speed up nomfi test
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Simplify and speed up
on current platforms, by seeing first whether
-Wno-missing-field-initializers is needed (it isn’t), so that
later we don’t need to determine whether it’s supported.
Paul Eggert [Wed, 24 May 2023 16:23:01 +0000 (09:23 -0700)]
Simplify -Wno-missing-field-initializers checking
* m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): Don’t worry about
-Wmissing-field-initializers, as this is no longer needed now that
gl_MANYWARN_ALL_GCC is fixed.
Paul Eggert [Wed, 24 May 2023 16:20:48 +0000 (09:20 -0700)]
manywarnings: port better to GCC 11.2 and earlier
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-diffutils/2023-05/msg00015.html
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Also test for GCC bug 82283
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82283>.
Paul Eggert [Tue, 23 May 2023 19:56:40 +0000 (12:56 -0700)]
nstrftime: wmemmove → __wmemmove in glibc part
https://sourceware.org/pipermail/libc-alpha/2023-May/148435.html
* lib/nstrftime.c (__strftime_internal) [COMPILE_WIDE]:
Use __wmemmove, not wmemmove, to keep in better sync with draft glibc.
Bruno Haible [Mon, 22 May 2023 12:32:42 +0000 (14:32 +0200)]
git-merge-changelog: Code style changes.
* lib/git-merge-changelog.c: Don't make side effects to variables
inside parenthesized expressions. Write (size_t)(-1), for consistency
with gl_list.h.
(compute_mapping): Rename variable in2 to jrev.
Paul Eggert [Mon, 22 May 2023 01:25:45 +0000 (18:25 -0700)]
strtol: match 'configure' to 'make check'
Inferred from report by Tomasz Kłoczko <https://bugs.gnu.org/63632>.
* m4/strtol.m4 (gl_FUNC_STRTOL):
* m4/strtoll.m4 (gl_FUNC_STRTOLL):
Also test "0b", since the test cases check it.
Paul Eggert [Sun, 21 May 2023 20:25:25 +0000 (13:25 -0700)]
git-merge-changelog: prefer idx_t
* lib/git-merge-changelog.c: Include idx.h.
(struct entry, entry_create, entry_hashcode)
(struct changelog_file, read_changelog_file)
(entries_mapping_get, entries_mapping_reverse_get)
(compute_mapping, struct edit, struct differences)
(compute_differences, find_paragraph_end)
(try_split_merged_entry, struct conflict, conflict_write, main):
Prefer idx_t to ptrdiff_t and size_t when the value is a
nonnegative index or size. Change a few for-loops so that
the index never goes negative.
* modules/git-merge-changelog (Depends-on): Add idx.
Bruno Haible [Sun, 21 May 2023 12:42:27 +0000 (14:42 +0200)]
limits-h tests: Check the value of SSIZE_MAX.
* tests/test-limits-h.c (limits12): New variable.
Include <sys/types.h> and check the value of SSIZE_MAX.
* modules/limits-h-tests (Depends-on): Add sys_types.
Paul Eggert [Sat, 20 May 2023 20:46:19 +0000 (13:46 -0700)]
limits-h: define SSIZE_MAX
* doc/posix-headers/limits.texi (limits.h): Document this.
* lib/limits.in.h (SSIZE_MAX): Define if not already defined.
* m4/limits-h.m4 (gl_LIMITS_H): Also generate limits.h
if <limits.h> does not define SSIZE_MAX.
Paul Eggert [Fri, 19 May 2023 15:57:29 +0000 (08:57 -0700)]
diffseq: don’t assume integers lack padding
* NEWS: Mention this.
* lib/diffseq.h (OFFSET_MAX): Don’t define;
this is now the user’s responsibility.
* lib/fstrcmp.c (OFFSET_MAX): Define to PTRDIFF_MAX.
Bruno Haible [Thu, 18 May 2023 20:51:17 +0000 (22:51 +0200)]
vasnprintf, c-vasnprintf: Silence gcc warnings.
* lib/vasnprintf.c (scale10_round_decimal_decoded): Remove memory==NULL
test.
(scale10_round_decimal_long_double, scale10_round_decimal_double): Test
for memory==NULL here. Remove use of IF_LINT.
Bruno Haible [Thu, 18 May 2023 14:03:00 +0000 (16:03 +0200)]
gnulib-tool: Ignore .orig and .rej files under modules/.
* gnulib-tool (func_sanitize_modulelist): Exclude also files whose name
ends in .orig or .rej.
* pygnulib/GLModuleSystem.py (GLModuleSystem.file_is_module): Likewise.
Paul Eggert [Wed, 17 May 2023 17:27:40 +0000 (10:27 -0700)]
nstrftime: suggest to glibc how to avoid alloca
* lib/nstrftime.c (widen) [COMPILE_WIDE]: Remove.
(__strftime_internal) [COMPILE_WIDE): Instead of converting the
multibyte time zone abbreviation into a potentially unbounded
alloca buffer, convert it directly into the output buffer.
Although this code is not used in Gnulib, this can help the glibc
developers avoid the problem on the glibc side.
Paul Eggert [Mon, 15 May 2023 15:40:27 +0000 (08:40 -0700)]
file-has-acl: improve port to Fedora 39
Problem reported by Ondrej Valousek in:
https://lists.gnu.org/r/bug-gnulib/2023-05/msg00078.html
* lib/file-has-acl.c: Include minmax.h.
[USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR]: Include stdckdint.h.
(file_has_acl) [USE_ACL && HAVE_LINUX_XATTR_H && HAVE_LISTXATTR]:
If the file has NFSv4 ACLs, ignore any POSIX ACLs, for Fedora 39.
Return a bit faster when listxattr returns 0.
Don’t loop forever if an attacker is fiddling with ACLs.
* modules/file-has-acl (Depends-on): Add minmax, stdckdint.
* lib/gettimeofday.c (gettimeofday): List the initializers of both
tv_sec and tv_usec.
* lib/glthread/thread.c (gl_thread_self): List the initializers of both
tv_sec and tv_nsec.
* lib/pthread-cond.c (pthread_cond_wait): Likewise.
* lib/thrd.c (rpl_thrd_current): Likewise.
* lib/pthread-rwlock.c (MIN): New macro.
(pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock): List the
initializers of both tv_sec and tv_nsec. Don't modify the duration after
having initialized it.
* lib/pthread_mutex_timedlock.c (MIN): New macro.
(pthread_mutex_timedlock): List the initializers of both tv_sec and
tv_nsec. Don't modify the duration after having initialized it.
Paul Eggert [Mon, 15 May 2023 06:27:51 +0000 (23:27 -0700)]
timespec: fill in other members
This problem was found when compiling GNU Emacs with
--enable-gcc-warnings on a platform where tv_sec is 64 bits and
tv_nsec is 32 bits, and struct timespec has padding. GCC
-Wuse-of-uninitialized-value complained when a struct timespec
initialized only via assigning to tv_sec and tv_nsec was copied
via assignment (this was in lib/timespec.h’s make_timespec).
Although behavior is well-defined on this platform, the warning is
annoying and the behavior might not be well-defined on theoretical
platforms where struct timespec has other members. To work around
this, initialize all the struct’s members.
* lib/getsockopt.c (rpl_getsockopt):
* lib/gettime.c (gettime):
* lib/gettimeofday.c (gettimeofday):
* lib/glthread/thread.c (gl_thread_self):
* lib/nanosleep.c (nanosleep):
* lib/parse-datetime.y (digits_to_date_time, set_hhmmss)
(signed_seconds, unsigned_seconds, yylex, parse_datetime_body):
* lib/poll.c (poll):
* lib/pselect.c (pselect):
* lib/pthread-cond.c (endlessly, pthread_cond_timedwait):
* lib/pthread-rwlock.c (pthread_rwlock_timedrdlock)
(pthread_rwlock_timedwrlock):
* lib/pthread_mutex_timedlock.c (pthread_mutex_timedlock):
* lib/select.c (rpl_select):
* lib/settime.c (settime):
* lib/stat-time.h (get_stat_atime, get_stat_ctime)
(get_stat_mtime, get_stat_birthtime):
* lib/thrd.c (rpl_thrd_current):
* lib/timespec.h (make_timespec):
* lib/timespec_getres.c (timespec_getres):
* lib/utimecmp.c (utimecmpat):
* lib/utimens.c (fdutimens):
When filling in a struct timespec or similar time-related structure
that might be copied elsewhere, also assign to any storage other
than tv_sec and tv_nsec, to avoid undefined behavior on (likely
theoretical) platforms where struct timespec has other members,
and also to avoid warnings from GCC and/or valgrind.
Paul Eggert [Sun, 14 May 2023 04:47:10 +0000 (21:47 -0700)]
stdio: use _GL_ATTRIBUTE_MALLOC
* lib/stdio.in.h (fdopen, fopen, popen, tmpfile): Declare with
_GL_ATTRIBUTE_MALLOC, for consistency with glibc, and so that
building the fopen module with ‘gcc -O2 -Wsuggest-attribute=malloc
-Wsystem-headers -Werror’ does not fail with “stdio.h: In function
‘rpl_fopen’: stdio.h:970:1: error: function might be candidate for
attribute ‘malloc’ [-Werror=suggest-attribute=malloc]”, a problem
I noticed on both Fedora 38 and Ubuntu 23.04.
sigsegv: Add tentative support for Hurd/x86_64. Reported by
Samuel Thibault <samuel.thibault@ens-lyon.org>.
Paul Eggert [Fri, 12 May 2023 18:56:17 +0000 (11:56 -0700)]
file-has-acl: port to Fedora 39
Fedora 39 getxattr with XATTR_NAME_POSIX_ACL_ACCESS either
succeeds or fails with ENODATA, so it is no longer possible to
detect from its failure that the filesystem might support NFSv4 ACLs.
Problem reported by Ondrej Valousek in:
https://lists.gnu.org/r/bug-gnulib/2023-04/msg00228.html
Instead, use listxattr to determine whether NFSv4 ACLs are in play.
This typically saves syscalls anyway.
* lib/file-has-acl.c: In #if, use (HAVE_LINUX_XATTR_H &&
HAVE_LISTXATTR) instead of GETXATTR_WITH_POSIX_ACLS.
The following changes apply when (USE_ACL && HAVE_LINUX_XATTR_H &&
HAVE_LISTXATTR):
Include minmax.h.
(have_xattr): New function.
(file_has_acl): Try listxattr first; typically this means we need
to do no other syscall. Call getxattr only if there are NFSv4
ACLs but not POSIX ACLs.
* m4/acl.m4 (gl_FILE_HAS_ACL): Simplify by merely testing for
linux/xattr.h and listxattr. All uses changed.
Bruno Haible [Thu, 4 May 2023 21:27:12 +0000 (23:27 +0200)]
c32swidth: New module.
* lib/uchar.in.h (c32swidth): New declaration.
* lib/wcswidth-impl.h: Use macros FUNC, UNIT, CHARACTER_WIDTH.
* lib/wcswidth.c: Define FUNC, UNIT, CHARACTER_WIDTH before including
wcswidth-impl.h.
* lib/c32swidth.c: New file.
* modules/c32swidth: New file.
* m4/uchar_h.m4 (gl_UCHAR_H_REQUIRE_DEFAULTS): Initialize
GNULIB_C32SWIDTH.
* modules/uchar (Makefile.am): Substitute GNULIB_C32SWIDTH.
Bruno Haible [Wed, 3 May 2023 15:09:20 +0000 (17:09 +0200)]
vasnprintf, vasnwprintf: Make '0' flag handling more ISO C compliant.
* lib/vasnprintf.c (VASNPRINTF): When doing the padding ourselves,
ignore the '0' flag if a precision is specified and the conversion is
one of d, i, o, u, x, X, b, B.
* tests/test-vasnprintf-posix.c (test_function): Update expected results
accordingly.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnwprintf-posix.c (test_function): Likewise.
Paul Eggert [Mon, 1 May 2023 18:19:05 +0000 (11:19 -0700)]
extern-inline: port to pcc
* m4/extern-inline.m4 (gl_EXTERN_INLINE): Port to pcc
1.2.0.DEVEL 20220331, which doesn’t support extern inline
even though it claims to be GCC 4.3 and to support C11.