* pygnulib/GLImport.py (GLImport.relative_to_destdir)
(GLImport.relative_to_currdir): Use os.path.isabs() instead of checking
for a slash.
* pygnulib/constants.py (symlink_relative, as_link_value_at_dest)
(hardlink): Use os.path.isabs() instead of checking for a slash or drive
prefix.
Bruno Haible [Sun, 9 Jun 2024 17:16:01 +0000 (19:16 +0200)]
c32rtomb: Add a sanity check, working around Solaris 11 OmniOS.
* m4/c32rtomb.m4 (gl_CHECK_FUNC_C32RTOMB): New macro, extracted from
gl_FUNC_C32RTOMB.
(gl_C32RTOMB_SANITYCHECK): New macro.
(gl_FUNC_C32RTOMB): Require gl_CHECK_FUNC_C32RTOMB and
gl_C32RTOMB_SANITYCHECK. If HAVE_WORKING_C32RTOMB is 0, set
REPLACE_C32RTOMB.
* lib/c32rtomb.c (c32rtomb): Together with HAVE_WORKING_MBRTOC32, test
also HAVE_WORKING_C32RTOMB.
* m4/mbrtoc32.m4 (gl_PREREQ_MBRTOC32): Require gl_C32RTOMB_SANITYCHECK.
* lib/mbrtoc32.c (mbrtoc32): Together with HAVE_WORKING_MBRTOC32, test
also HAVE_WORKING_C32RTOMB.
* modules/mbrtoc32 (Files): Add m4/c32rtomb.m4.
* lib/btoc32.c (btoc32): Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* lib/mbsrtoc32s.c: Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* lib/mbsnrtoc32s.c: Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* lib/c32tob.c (c32tob): Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* modules/c32tob (Files): Add m4/c32rtomb.m4.
(configure.ac): Require gl_C32RTOMB_SANITYCHECK.
* lib/c32srtombs.c: Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* lib/c32snrtombs.c: Together with HAVE_WORKING_MBRTOC32, test also
HAVE_WORKING_C32RTOMB.
* lib/c32to-impl.h (FUNC): Together with HAVE_WORKING_MBRTOC32, test
also HAVE_WORKING_C32RTOMB.
* modules/c32tolower (Files): Add m4/c32rtomb.m4.
(configure.ac): Require gl_C32RTOMB_SANITYCHECK.
* modules/c32toupper (Files): Add m4/c32rtomb.m4.
(configure.ac): Require gl_C32RTOMB_SANITYCHECK.
* lib/c32width.c (c32width): Together with HAVE_WORKING_MBRTOC32, test
also HAVE_WORKING_C32RTOMB.
* modules/c32width (Files): Add m4/c32rtomb.m4.
(configure.ac): Require gl_C32RTOMB_SANITYCHECK.
Paul Eggert [Thu, 6 Jun 2024 19:54:21 +0000 (12:54 -0700)]
tzname: document some limitations
Unfortunately tzname is a vestigial interface that doesn't work
<https://data.iana.org/time-zones/theory.html#vestigial>.
It's relatively useless in portable code and is planned to be removed
from POSIX <https://austingroupbugs.net/view.php?id=1816>.
Document this better here.
Bruno Haible [Thu, 6 Jun 2024 10:14:46 +0000 (12:14 +0200)]
tzname, daylight, timezone: Update documentation.
* doc/posix-functions/tzname.texi: Update info about native Windows.
* doc/posix-functions/daylight.texi: Update info about OpenBSD, Cygwin,
native Windows.
* doc/posix-functions/timezone.texi: Update info about FreeBSD, OpenBSD,
native Windows.
* pygnulib/GLImport.py (GLImport.execute): Use re.search() instead of
re.findall() since we only care about finding one match. Remove
unnecessary bool() calls.
Bruno Haible [Thu, 6 Jun 2024 00:33:41 +0000 (02:33 +0200)]
setenv: On native Windows, don't modify _environ directly.
* m4/setenv.m4 (gl_PREREQ_SETENV): Check for _putenv.
* lib/setenv.c: On native Windows, include <windows.h> and define
SetEnvironmentVariable.
(setenv) [HAVE_DECL__PUTENV]: New implementation for platforms with
_putenv.
* modules/setenv (Depends-on): Add malloc-posix.
Paul Eggert [Wed, 5 Jun 2024 15:27:55 +0000 (08:27 -0700)]
nstrftime: don’t assume <locale.h>
* lib/strftime.c: Include <locale.h> only if needed, since Emacs
attempts to be portable to platforms lacking <locale.h> so it
avoids localename-unsafe-limited and defines
REQUIRE_GNUISH_STRFTIME_AM_PM to false.
Bruno Haible [Wed, 5 Jun 2024 14:32:02 +0000 (16:32 +0200)]
nstrftime: Make %c work on native Windows again.
* lib/strftime.c: Include <locale.h> always. Include <wchar.h> on native
Windows.
(__strftime_internal): On native Windows, inspect the locale name like
hard_locale would do.
* modules/nstrftime (Link): Remove section.
* tests/test-nstrftime.h (locales_test): Disallow alternative that is
not culturally acceptable for French.
Paul Eggert [Tue, 4 Jun 2024 18:50:07 +0000 (11:50 -0700)]
endian: port better to Android NDK r26
* lib/endian.in.h (be16toh, be32toh, be64toh, htobe16, htobe32)
(htobe64, le16toh, le32toh, le64toh, htole16, htole32, htole64):
When @HAVE_ENDIAN_H@, define each NAME to rpl_NAME so that they
don’t interact incorrectly with system-defined implementations.
Problem reported by Po Lu for Android NDK r26 in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00040.html
and this patch is an updated version of Collin Funk’s patch in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00041.html
Collin Funk [Tue, 4 Jun 2024 18:21:04 +0000 (11:21 -0700)]
boot-time, readutmp: Fix missing MinGW include (regr. 2024-05-24).
Reported by Eli Zaretskii in:
<https://lists.gnu.org/archive/html/bug-gnulib/2024-06/msg00044.html>.
* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Remove unnecessary
<sysinfoapi.h> include. Some systems do not have this header and
<windows.h> should have the correct declarations.
* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Likewise.
Paul Eggert [Tue, 4 Jun 2024 05:00:59 +0000 (22:00 -0700)]
nstrftime: remove dependency on hard-locale
GNU Emacs would rather keep dependencies to a minimum,
and hard-locale brings in some other stuff.
* lib/strftime.c: Include locale.h only if (USE_C_LOCALE &&
HAVE_STRFTIME_L) || ((defined __NetBSD__ || defined __sun) &&
REQUIRE_GNUISH_STRFTIME_AM_PM). Do not include hard-locale.h.
(libc_hidden_def): On native MS-Windows, use the C locale %c
format regardless of language. I hope that’s good enough.
If not, let’s try to think of a way of solving the problem
that doesn’t require using hard_locale.
* modules/nstrftime (Depends-on): Remove hard-locale.
* modules/nstrftime-tests (test_nstrftime_LDADD):
Remove $(HARD_LOCALE_LIB).
* tests/test-nstrftime.h (locales_test):
Add a test that I hope works on French MS-Windows.
Paul Eggert [Tue, 4 Jun 2024 05:00:58 +0000 (22:00 -0700)]
ieee754-h: port to Android NDK r26
Problem reported by Po Lu in:
https://lists.gnu.org/r/bug-gnulib/2024-06/msg00015.html
* lib/ieee754.in.h (_IEEE754_BYTE_ORDER, _IEEE754_BIG_ENDIAN)
(_IEEE754_LITTLE_ENDIAN, _IEEE754_FLOAT_WORD_ORDER): New macros.
All uses of __BYTE_ORDER, __BIG_ENDIAN, __LITTLE_ENDIAN,
__FLOAT_WORD_ORDER changed to use these new macros.
[!_GL_GNULIB_HEADER]: Include bits/endian.h, not endian.h,
as that’s what glibc does now.
[_GL_GNULIB_HEADER]: Include endian.h instead of rolling our own.
(__BEGIN_DECLS, __END_DECLS): Remove. All uses replaced
by definiens.
* modules/ieee754-h (Depends-on): Add endian.
Bruno Haible [Tue, 4 Jun 2024 01:59:37 +0000 (03:59 +0200)]
readlinkat: Work around a Cygwin 3.3.6 bug.
* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Set REPLACE_READLINKAT to 1 on
Cygwin.
* lib/readlinkat.c (rpl_readlinkat): On Cygwin, for /dev/* files, don't
return results that start with a backslash.
* doc/posix-functions/readlinkat.texi: Mention the Cygwin bug.
Bruno Haible [Mon, 3 Jun 2024 23:48:04 +0000 (01:48 +0200)]
readlink: Work around a Cygwin 3.3.6 bug.
* m4/readlink.m4 (gl_FUNC_READLINK): Set REPLACE_READLINK to 1 on Cygwin.
* lib/readlink.c (rpl_readlink): On Cygwin, for /dev/* files, don't
return results that start with a backslash.
* tests/test-readlink.h (test_readlink): Add a test of /dev/null.
* tests/test-canonicalize-lgpl.c (main): Likewise.
* tests/test-canonicalize.c (main): Likewise.
* doc/posix-functions/readlink.texi: Mention the Cygwin bug.
Bruno Haible [Mon, 3 Jun 2024 15:20:20 +0000 (17:20 +0200)]
acl-permissions: Fix test-file-has-acl-2.sh failure on Cygwin.
* lib/acl-internal.c: Include <sys/types.h>, <grp.h>, <string.h>.
(acl_access_nontrivial): On Cygwin, ignore group:SYSTEM:*,
group:Administrators:*, mask::* entries.
* doc/acl-resources.txt: Add one more reference.
Bruno Haible [Mon, 3 Jun 2024 13:34:21 +0000 (15:34 +0200)]
dprintf-posix tests: Skip the memory leak test on macOS.
* tests/test-dprintf-posix2.c: Skip the test on macOS.
(main): Return a different exit code at each point. Allow 100 KB extra
memory consumption.
* tests/test-dprintf-posix2.sh: Update.
Collin Funk [Mon, 3 Jun 2024 11:57:14 +0000 (04:57 -0700)]
gnulib-tool.py: Use a set to optimize.
* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Call set() on the result of
_extract_lib_SOURCES() to ensure computing the difference between
another set is O(n).
* pygnulib/GLModuleSystem.py (_LIB_SOURCES_PATTERN): New variable.
(_extract_lib_SOURCES): New function.
(GLModule.getAutomakeSnippet_Unconditional): Use the new function.
(GLModuleTable.add_dummy): Likewise. Add a second break statement to
stop unnecessary looping.
Bruno Haible [Sun, 2 Jun 2024 16:34:36 +0000 (18:34 +0200)]
isnanf, isnand, isnanl: Fix link errors on AIX 7.1 with xlc.
* lib/isnanf-nolibm.h (HAVE_ISNANF_NOLIBM): New macro.
* lib/isnand-nolibm.h (HAVE_ISNAND_NOLIBM): New macro.
* lib/isnanl-nolibm.h (HAVE_ISNANL_NOLIBM): New macro.
* lib/math.h (isnanf): Don't define via isnan if HAVE_ISNANF_NOLIBM is
defined.
(isnand): Don't define via isnan if HAVE_ISNAND_NOLIBM is defined.
(isnanl): Don't define via isnan if HAVE_ISNANL_NOLIBM is defined.
Collin Funk [Sun, 2 Jun 2024 08:06:32 +0000 (01:06 -0700)]
gnulib-tool.py: Fix crash when no ACLOCAL_AMFLAGS is found.
* pygnulib/main.py (main) [import]: Use a regular expression to match
the ACLOCAL_AMFLAGS Makefile.am variable. Properly handle the case where
none is found.
Bruno Haible [Fri, 31 May 2024 17:01:24 +0000 (19:01 +0200)]
windows-once: Fix race (regression yesterday).
* lib/windows-once.h (glwthread_once_t): Change type of inited to LONG.
* lib/windows-once.c (glwthread_once): Increment inited from 1 to 2, to
ensure that DeleteCriticalSection gets invoked only once.
Bruno Haible [Thu, 30 May 2024 18:06:58 +0000 (20:06 +0200)]
assert-h, verify: Fix compilation error with g++ (4.8.5) -std=gnu++11.
Reported by Harmen <harmen@stoppels.ch> at
<https://savannah.gnu.org/bugs/index.php?65811>.
* lib/verify.h (static_assert): In C++ mode with g++ < 6 and
-std=gnu++11, define in a way that supports also the 1-argument
invocations and the invocations inside C++ struct and class.
Bruno Haible [Thu, 30 May 2024 14:33:55 +0000 (16:33 +0200)]
attribute: Try harder to avoid syntax errors.
* m4/gnulib-common.m4 (gl_COMMON_BODY): Define
_GL_ATTRIBUTE_REPRODUCIBLE and _GL_ATTRIBUTE_UNSEQUENCED to empty if
_GL_BRACKET_BEFORE_ATTRIBUTE is defined.
Bruno Haible [Thu, 30 May 2024 08:55:40 +0000 (10:55 +0200)]
call_once: Work around Cygwin 3.5.3 bug.
* m4/call_once.m4 (gl_FUNC_CALL_ONCE): Require AC_CANONICAL_HOST.
On Cygwin, set REPLACE_CALL_ONCE to 1.
* lib/call_once.c (call_once): On Cygwin, use a cast, to avoid a
compiler warning.
* modules/call_once (Depends-on): Add pthread-once.
* doc/posix-functions/call_once.texi: Mention the Cygwin bug.
Bruno Haible [Thu, 30 May 2024 08:23:22 +0000 (10:23 +0200)]
windows-once: Free allocated resources when done.
Based on an observation regarding Cygwin's pthread_once implementation
by Takashi Yano <takashi.yano@nifty.ne.jp> at
<https://cygwin.com/pipermail/cygwin/2024-January/255182.html> and
<https://cygwin.com/pipermail/cygwin-patches/2024q1/012600.html>
* lib/windows-once.h (glwthread_once_t): Add field 'num_threads'.
(GLWTHREAD_ONCE_INIT): Initialize it to zero.
* lib/windows-once.c (glwthread_once): Increment num_threads while the
thread uses the lock. Let the last thread that uses the lock destroy it.
Bruno Haible [Wed, 29 May 2024 12:13:33 +0000 (14:13 +0200)]
mbfile tests: Avoid test failure on mingw.
* tests/test-mbfile.c: Include <string.h>, localcharset.h.
(main): Verify that setlocale() has installed an UTF-8 locale.
* modules/mbfile-tests (Depends-on): Add localcharset.
Collin Funk [Wed, 29 May 2024 04:55:12 +0000 (21:55 -0700)]
gnulib-tool.py: Simplify creation of module shell ids.
* pygnulib/GLModuleSystem.py (GLModule.shell_id_chars): Remove class
variable.
(GLModule.shell_id_pattern): New class variable.
(GLModule.getShellId): New function.
(GLModule.getShellFunc, GLModule.getShellVar)
(GLModule.getConditionalName): Use it.
Bruno Haible [Tue, 28 May 2024 20:35:54 +0000 (22:35 +0200)]
pthread-once: Work around Cygwin 3.5.3 bug.
* m4/pthread-once.m4 (gl_PTHREAD_ONCE): On Cygwin, set
REPLACE_PTHREAD_ONCE to 1.
* lib/pthread-once.c (pthread_once): Add an implementation for Cygwin.
* doc/posix-functions/pthread_once.texi: Mention the Cygwin bug.
Paul Eggert [Tue, 28 May 2024 15:36:28 +0000 (08:36 -0700)]
attribute: const/pure defaults to unsequenced/reproducible
Also, update the commentary to reflect the fact that unsequenced
and reproducible functions can inspect and update storage
addressed by their arguments, and clarify the business about
returning once, and about REPRODUCIBLE and UNSEQUENCED applying to
pointers to functions and to function types. It’s not clear that
we should encourage the use of REPRODUCIBLE and UNSEQUENCED yet,
as the support is not there and the likely benefits are small.
* m4/gnulib-common.m4 (_GL_ATTRIBUTE_CONST): Default to
_GL_ATTRIBUTE_UNSEQUENCED if the const attribute is lacking,
as every const function is also unsequenced.
(_GL_ATTRIBUTE_PURE): Similarly, default to _GL_ATTRIBUTE_REPRODUCIBLE
as every pure function is reproducible.
Bruno Haible [Mon, 27 May 2024 22:35:03 +0000 (00:35 +0200)]
nstrftime, c-nstrftime tests: Avoid test failures on native Windows.
* doc/posix-functions/tzset.texi: Add a reference.
* tests/test-nstrftime.h (TZ): Use time zone names that are supported by
native Windows.
(LT): Disable a test of New Zealand DST.
Bruno Haible [Mon, 27 May 2024 21:29:36 +0000 (23:29 +0200)]
nstrftime, c-nstrftime: Make %r work on native Windows.
* doc/posix-functions/strftime.texi: Mention the %r problem.
* lib/strftime.c (__strftime_internal): On native Windows, for %r, use
the English AM/PM format.
Bruno Haible [Mon, 27 May 2024 21:01:50 +0000 (23:01 +0200)]
nstrftime, c-nstrftime: Make %c work on native Windows.
* doc/posix-functions/strftime.texi: Mention the %c problem.
* lib/strftime.c: Include <locale.h> always. Include hard-locale.h.
(__strftime_internal): For %c, use a subformat that contains the weekday
name (or abbrev.) and the month name (or abbrev.).
* modules/nstrftime (Depends-on): Add hard-locale.
(Link): New section.
* modules/nstrftime-tests (Makefile.am): Link test-nstrftime with
$(HARD_LOCALE_LIB).
Bruno Haible [Mon, 27 May 2024 15:42:20 +0000 (17:42 +0200)]
parse-datetime tests: Avoid failure on native Windows.
* tests/test-parse-datetime.c (SOME_TIMEPOINT): New macro.
(main): Use it. On native Windows, use Windows time zone names.
Invoke tzset() after setting TZ.
* doc/posix-functions/gmtime.texi: Mention the native Windows problem.
* doc/posix-functions/localtime.texi: Likewise.
Bruno Haible [Mon, 27 May 2024 11:13:38 +0000 (13:13 +0200)]
tests: Don't test on the broken NetBSD 10.0 zh_CN.GB18030 locale.
* tests/test-mbrtowc.c (main): Add tests for one-by-one input in the
UTF-8 and GB18030 encodings.
* m4/locale-zh.m4 (gt_LOCALE_ZH_CN): Add a sanity check with mbrtowc.
Collin Funk [Sat, 25 May 2024 02:23:25 +0000 (19:23 -0700)]
boot-time, readutmp: Add a Native Windows boot time fallback.
* lib/boot-time-aux.h (initialize, get_windows_boot_time_fallback): New
functions.
* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Include Windows headers and
<sys/time.h>.
(get_boot_time_uncached): Use the fallback.
* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Include Windows headers and
<sys/time.h>.
(read_utmp_from_file): Use the fallback.
* modules/boot-time (Depends-on): Add gettimeofday.