1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

Update from Gnulib by running admin/merge-gnulib

This commit is contained in:
Paul Eggert 2025-05-08 18:54:14 -07:00
parent 7617c7a6e4
commit e929d6df77
3 changed files with 48 additions and 26 deletions

View file

@ -497,7 +497,7 @@
# endif # endif
#endif #endif
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is /* ISO C99 also allows declaring arrays as non-overlapping. The syntax is
array_name[restrict] array_name[restrict]
GCC 3.1 and clang support this. GCC 3.1 and clang support this.
This syntax is not usable in C++ mode. */ This syntax is not usable in C++ mode. */

View file

@ -14,10 +14,14 @@
You should have received a copy of the GNU Lesser General Public License You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */ along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* If FPRINTFTIME is set to 1, this file defines a function with a
'FILE *fp' parameter instead of two 'char *s, size_t max' parameters. */
#ifndef FPRINTFTIME #ifndef FPRINTFTIME
# define FPRINTFTIME 0 # define FPRINTFTIME 0
#endif #endif
/* If USE_C_LOCALE is set to 1, this file defines a function that uses the
"C" locale, regardless of the current locale. */
#ifndef USE_C_LOCALE #ifndef USE_C_LOCALE
# define USE_C_LOCALE 0 # define USE_C_LOCALE 0
#endif #endif
@ -38,6 +42,14 @@
# include "time-internal.h" # include "time-internal.h"
#endif #endif
/* Whether the system supports no localized output at all, that is, whether
strftime's output does not depend on the current locale. */
#if defined __ANDROID__
# define HAVE_ONLY_C_LOCALE 1
#else
# define HAVE_ONLY_C_LOCALE 0
#endif
/* Whether to require GNU behavior for AM and PM indicators, even on /* Whether to require GNU behavior for AM and PM indicators, even on
other platforms. This matters only in non-C locales. other platforms. This matters only in non-C locales.
The default is to require it; you can override this via The default is to require it; you can override this via
@ -46,12 +58,12 @@
#ifndef REQUIRE_GNUISH_STRFTIME_AM_PM #ifndef REQUIRE_GNUISH_STRFTIME_AM_PM
# define REQUIRE_GNUISH_STRFTIME_AM_PM true # define REQUIRE_GNUISH_STRFTIME_AM_PM true
#endif #endif
#if USE_C_LOCALE #if HAVE_ONLY_C_LOCALE || USE_C_LOCALE
# undef REQUIRE_GNUISH_STRFTIME_AM_PM # undef REQUIRE_GNUISH_STRFTIME_AM_PM
# define REQUIRE_GNUISH_STRFTIME_AM_PM false # define REQUIRE_GNUISH_STRFTIME_AM_PM false
#endif #endif
#if USE_C_LOCALE #if HAVE_ONLY_C_LOCALE || USE_C_LOCALE
# include "c-ctype.h" # include "c-ctype.h"
#else #else
# include <ctype.h> # include <ctype.h>
@ -302,7 +314,7 @@ enum pad_style
# define TOUPPER(Ch, L) __toupper_l (Ch, L) # define TOUPPER(Ch, L) __toupper_l (Ch, L)
# define TOLOWER(Ch, L) __tolower_l (Ch, L) # define TOLOWER(Ch, L) __tolower_l (Ch, L)
# else # else
# if USE_C_LOCALE # if HAVE_ONLY_C_LOCALE || USE_C_LOCALE
# define TOUPPER(Ch, L) c_toupper (Ch) # define TOUPPER(Ch, L) c_toupper (Ch)
# define TOLOWER(Ch, L) c_tolower (Ch) # define TOLOWER(Ch, L) c_tolower (Ch)
# else # else
@ -379,7 +391,8 @@ memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM)
#define HAVE_NATIVE_TIME_Z \ #define HAVE_NATIVE_TIME_Z \
(USE_C_LOCALE && HAVE_STRFTIME_L ? HAVE_STRFTIME_LZ : HAVE_STRFTIME_Z) (USE_C_LOCALE && HAVE_STRFTIME_L ? HAVE_STRFTIME_LZ : HAVE_STRFTIME_Z)
#if USE_C_LOCALE && HAVE_STRFTIME_L #if (!HAVE_ONLY_C_LOCALE || !HAVE_STRUCT_TM_TM_ZONE) \
&& USE_C_LOCALE && HAVE_STRFTIME_L
/* Cache for the C locale object. /* Cache for the C locale object.
Marked volatile so that different threads see the same value Marked volatile so that different threads see the same value
@ -398,7 +411,10 @@ c_locale (void)
#endif #endif
#if HAVE_NATIVE_TIME_Z #if !defined _LIBC \
&& (!(HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)) \
|| !HAVE_STRUCT_TM_TM_ZONE) \
&& HAVE_NATIVE_TIME_Z
/* On NetBSD a null tz has undefined behavior, so use a non-null tz. /* On NetBSD a null tz has undefined behavior, so use a non-null tz.
Cache the UTC time zone object in a volatile variable for improved Cache the UTC time zone object in a volatile variable for improved
@ -818,7 +834,7 @@ iso_week_days (int yday, int wday)
} }
#if !defined _NL_CURRENT && (USE_C_LOCALE && !HAVE_STRFTIME_L) #if !defined _NL_CURRENT && (HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L))
static CHAR_T const c_weekday_names[][sizeof "Wednesday"] = static CHAR_T const c_weekday_names[][sizeof "Wednesday"] =
{ {
L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"), L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"),
@ -861,7 +877,8 @@ static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t)
extra_args_spec LOCALE_PARAM); extra_args_spec LOCALE_PARAM);
#if !defined _LIBC \ #if !defined _LIBC \
&& (!(USE_C_LOCALE && !HAVE_STRFTIME_L) || !HAVE_STRUCT_TM_TM_ZONE) && (!(HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)) \
|| !HAVE_STRUCT_TM_TM_ZONE)
/* Make sure we're calling the actual underlying strftime. /* Make sure we're calling the actual underlying strftime.
In some cases, time.h contains something like In some cases, time.h contains something like
@ -1028,7 +1045,12 @@ get_tm_zone (timezone_t tz, char *ubuf, int ubufsize, int modifier,
*TP is computed with a totally different time zone. *TP is computed with a totally different time zone.
This is bogus: though POSIX allows bad behavior like this, This is bogus: though POSIX allows bad behavior like this,
POSIX does not require it. Do the right thing instead. */ POSIX does not require it. Do the right thing instead. */
return tp->tm_zone; const char *ret = tp->tm_zone;
# if defined __ANDROID__
if (!ret)
ret = "";
# endif
return ret;
#else #else
if (!tz) if (!tz)
return "UTC"; return "UTC";
@ -1125,7 +1147,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
# define am_len STRLEN (a_month) # define am_len STRLEN (a_month)
# define aam_len STRLEN (a_altmonth) # define aam_len STRLEN (a_altmonth)
# define ap_len STRLEN (ampm) # define ap_len STRLEN (ampm)
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
/* The English abbreviated weekday names are just the first 3 characters of the /* The English abbreviated weekday names are just the first 3 characters of the
English full weekday names. */ English full weekday names. */
# define a_wkday \ # define a_wkday \
@ -1383,7 +1405,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
to_uppcase = true; to_uppcase = true;
to_lowcase = false; to_lowcase = false;
} }
#if defined _NL_CURRENT || (USE_C_LOCALE && !HAVE_STRFTIME_L) #if defined _NL_CURRENT || HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
cpy (aw_len, a_wkday); cpy (aw_len, a_wkday);
break; break;
#else #else
@ -1398,7 +1420,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
to_uppcase = true; to_uppcase = true;
to_lowcase = false; to_lowcase = false;
} }
#if defined _NL_CURRENT || (USE_C_LOCALE && !HAVE_STRFTIME_L) #if defined _NL_CURRENT || HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
cpy (STRLEN (f_wkday), f_wkday); cpy (STRLEN (f_wkday), f_wkday);
break; break;
#else #else
@ -1420,7 +1442,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
else else
cpy (am_len, a_month); cpy (am_len, a_month);
break; break;
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
cpy (am_len, a_month); cpy (am_len, a_month);
break; break;
#else #else
@ -1444,7 +1466,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
else else
cpy (STRLEN (f_month), f_month); cpy (STRLEN (f_month), f_month);
break; break;
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
cpy (STRLEN (f_month), f_month); cpy (STRLEN (f_month), f_month);
break; break;
#else #else
@ -1461,7 +1483,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
NLW(ERA_D_T_FMT))) NLW(ERA_D_T_FMT)))
!= '\0'))) != '\0')))
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
subfmt = L_("%a %b %e %H:%M:%S %Y"); subfmt = L_("%a %b %e %H:%M:%S %Y");
#elif defined _WIN32 && !defined __CYGWIN__ #elif defined _WIN32 && !defined __CYGWIN__
/* On native Windows, "%c" is "%d/%m/%Y %H:%M:%S" by default. */ /* On native Windows, "%c" is "%d/%m/%Y %H:%M:%S" by default. */
@ -1500,7 +1522,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
} }
break; break;
#if !defined _LIBC && !(USE_C_LOCALE && !HAVE_STRFTIME_L) #if !defined _LIBC && !(HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L))
underlying_strftime: underlying_strftime:
{ {
char ubuf[1024]; /* enough for any single format in practice */ char ubuf[1024]; /* enough for any single format in practice */
@ -1600,7 +1622,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
# endif # endif
break; break;
} }
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
#else #else
goto underlying_strftime; goto underlying_strftime;
#endif #endif
@ -1624,7 +1646,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
!= L_('\0')))) != L_('\0'))))
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
goto subformat; goto subformat;
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
subfmt = L_("%m/%d/%y"); subfmt = L_("%m/%d/%y");
goto subformat; goto subformat;
#else #else
@ -1702,7 +1724,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
break; break;
} }
} }
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
#else #else
goto underlying_strftime; goto underlying_strftime;
#endif #endif
@ -1850,7 +1872,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
to_uppcase = false; to_uppcase = false;
to_lowcase = true; to_lowcase = true;
} }
#if defined _NL_CURRENT || (USE_C_LOCALE && !HAVE_STRFTIME_L) #if defined _NL_CURRENT || HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
cpy (ap_len, ampm); cpy (ap_len, ampm);
break; break;
#else #else
@ -1871,7 +1893,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
== L_('\0')) == L_('\0'))
subfmt = L_("%I:%M:%S %p"); subfmt = L_("%I:%M:%S %p");
goto subformat; goto subformat;
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
subfmt = L_("%I:%M:%S %p"); subfmt = L_("%I:%M:%S %p");
goto subformat; goto subformat;
#elif ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ \ #elif ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ \
@ -1933,7 +1955,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
!= L_('\0')))) != L_('\0'))))
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT));
goto subformat; goto subformat;
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
subfmt = L_("%H:%M:%S"); subfmt = L_("%H:%M:%S");
goto subformat; goto subformat;
#else #else
@ -2043,7 +2065,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
pad = yr_spec; pad = yr_spec;
goto subformat; goto subformat;
} }
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
#else #else
goto underlying_strftime; goto underlying_strftime;
#endif #endif
@ -2067,7 +2089,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
DO_NUMBER (2, (era->offset DO_NUMBER (2, (era->offset
+ delta * era->absolute_direction)); + delta * era->absolute_direction));
} }
#elif USE_C_LOCALE && !HAVE_STRFTIME_L #elif HAVE_ONLY_C_LOCALE || (USE_C_LOCALE && !HAVE_STRFTIME_L)
#else #else
goto underlying_strftime; goto underlying_strftime;
#endif #endif

View file

@ -1630,7 +1630,7 @@ dnl
dnl This macro sets two variables: dnl This macro sets two variables:
dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
dnl - ac_cv_func_<func> to yes / no / no dnl - ac_cv_func_<func> to yes / no / no
dnl The first variable allows to distinguish all three cases. dnl The first variable allows distinguishing all three cases.
dnl The second variable is set, so that an invocation dnl The second variable is set, so that an invocation
dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]]) dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
dnl can be used as a drop-in replacement for dnl can be used as a drop-in replacement for
@ -1683,7 +1683,7 @@ dnl
dnl This macro sets two variables: dnl This macro sets two variables:
dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version" dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
dnl - ac_cv_func_<func> to yes / no / no dnl - ac_cv_func_<func> to yes / no / no
dnl The first variable allows to distinguish all three cases. dnl The first variable allows distinguishing all three cases.
dnl The second variable is set, so that an invocation dnl The second variable is set, so that an invocation
dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]]) dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]])
dnl can be used as a drop-in replacement for dnl can be used as a drop-in replacement for