Update from Gnulib by running admin/merge-gnulib

* lib/strftime.c: New file, copied from Gnulib.
This commit is contained in:
Paul Eggert 2024-02-14 21:18:25 -08:00
parent 7c32f3bcd6
commit 377e4212e9
16 changed files with 2210 additions and 1585 deletions

View file

@ -3,9 +3,9 @@
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
\def\texinfoversion{2023-09-19.19}
\def\texinfoversion{2024-02-10.22}
%
% Copyright 1985, 1986, 1988, 1990-2023 Free Software Foundation, Inc.
% Copyright 1985, 1986, 1988, 1990-2024 Free Software Foundation, Inc.
%
% This texinfo.tex file is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
@ -5238,14 +5238,14 @@ $$%
% the current value of \escapechar.
\def\escapeisbackslash{\escapechar=`\\}
% Use \ in index files by default. texi2dvi didn't support @ as the escape
% character (as it checked for "\entry" in the files, and not "@entry"). When
% the new version of texi2dvi has had a chance to become more prevalent, then
% the escape character can change back to @ again. This should be an easy
% change to make now because both @ and \ are only used as escape characters in
% index files, never standing for themselves.
% Uncomment to use \ in index files by default. Old texi2dvi (before 2019)
% didn't support @ as the escape character (as it checked for "\entry" in
% the files, and not "@entry").
% In the future we can remove this flag and simplify the code for
% index files and backslashes, once the support is no longer likely to be
% useful.
%
\set txiindexescapeisbackslash
% \set txiindexescapeisbackslash
% Write the entry in \indextext to the index file.
%
@ -6137,8 +6137,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% normally unnmhead0 calls unnumberedzzz:
\outer\parseargdef\unnumbered{\unnmhead0{#1}}
\def\unnumberedzzz#1{%
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
\global\advance\unnumberedno by 1
\global\advance\unnumberedno by 1
%
% Since an unnumbered has no number, no prefix for figures.
\global\let\chaplevelprefix = \empty
@ -6194,8 +6193,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% normally calls unnumberedseczzz:
\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
\def\unnumberedseczzz#1{%
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
\global\advance\unnumberedno by 1
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno}%
}
% Subsections.
@ -6218,9 +6217,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% normally calls unnumberedsubseczzz:
\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
\def\unnumberedsubseczzz#1{%
\global\subsubsecno=0 \global\advance\subsecno by 1
\sectionheading{#1}{subsec}{Ynothing}%
{\the\unnumberedno.\the\secno.\the\subsecno}%
\global\advance\unnumberedno by 1
\sectionheading{#1}{subsec}{Ynothing}{\the\unnumberedno}%
}
% Subsubsections.
@ -6244,9 +6242,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
% normally unnumberedsubsubseczzz:
\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
\def\unnumberedsubsubseczzz#1{%
\global\advance\subsubsecno by 1
\sectionheading{#1}{subsubsec}{Ynothing}%
{\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
\global\advance\unnumberedno by 1
\sectionheading{#1}{subsubsec}{Ynothing}{\the\unnumberedno}%
}
% These macros control what the section commands do, according
@ -8205,8 +8202,6 @@ might help (with 'rm \jobname.?? \jobname.??s')%
\let\commondummyword\unmacrodo
\xdef\macrolist{\macrolist}%
\endgroup
\else
\errmessage{Macro #1 not defined}%
\fi
}

View file

@ -47,6 +47,7 @@
# --avoid=iswdigit \
# --avoid=iswxdigit \
# --avoid=langinfo \
# --avoid=localename \
# --avoid=lock \
# --avoid=mbrtowc \
# --avoid=mbsinit \
@ -2745,7 +2746,9 @@ ifeq (,$(OMIT_GNULIB_MODULE_nstrftime))
libgnu_a_SOURCES += nstrftime.c
EXTRA_DIST += strftime.h
EXTRA_DIST += strftime.c strftime.h
EXTRA_libgnu_a_SOURCES += strftime.c
endif
## end gnulib module nstrftime

View file

@ -130,7 +130,7 @@
# define BOOL_WIDTH 1
# define BOOL_MAX 1
# elif ! defined BOOL_MAX
# define BOOL_MAX ((((1U << (BOOL_WIDTH - 1)) - 1) << 1) + 1)
# define BOOL_MAX 1
# endif
#endif

File diff suppressed because it is too large Load diff

2051
lib/strftime.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -21,17 +21,68 @@
extern "C" {
#endif
/* Just like strftime, but with two more arguments:
POSIX requires that strftime use the local timezone information.
Use the timezone __TZ instead. Use __NS as the number of
nanoseconds in the %N directive.
/* Formats the broken-down time *__TP, with additional __NS nanoseconds,
into the buffer __S of size __MAXSIZE, according to the rules of the
LC_TIME category of the current locale.
On error, set errno and return 0. Otherwise, return the number of
bytes generated (not counting the trailing NUL), preserving errno
if the number is 0. This errno behavior is in draft POSIX 202x
plus some requested changes to POSIX. */
size_t nstrftime (char *restrict, size_t, char const *, struct tm const *,
timezone_t __tz, int __ns);
Uses the time zone __TZ.
If *__TP represents local time, __TZ should be set to
tzalloc (getenv ("TZ")).
If *__TP represents universal time (a.k.a. GMT), __TZ should be set to
(timezone_t) 0.
The format string __FORMAT, including GNU extensions, is described in
the GNU libc's strftime() documentation:
<https://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html>
Additionally, the following conversion is supported:
%N The number of nanoseconds, passed as __NS argument.
Here's a summary of the available conversions (= format directives):
literal characters %n %t %%
date:
century %C
year %Y %y
week-based year %G %g
month (in year) %m %B %b %h
week in year %U %W %V
day in year %j
day (in month) %d %e
day in week %u %w %A %a
year, month, day %x %F %D
time:
half-day %p %P
hour %H %k %I %l
minute (in hour) %M
hour, minute %R
second (in minute) %S
hour, minute, second %r %T %X
second (since epoch) %s
date and time: %c
time zone: %z %Z
nanosecond %N
Stores the result, as a string with a trailing NUL character, at the
beginning of the array __S[0..__MAXSIZE-1], if it fits, and returns
the length of that string, not counting the trailing NUL. In this case,
errno is preserved if the return value is 0.
If it does not fit, this function sets errno to ERANGE and returns 0.
Upon other errors, this function sets errno and returns 0 as well.
Note: The errno behavior is in draft POSIX 202x plus some requested
changes to POSIX.
This function is like strftime, but with two more arguments:
* __TZ instead of the local timezone information,
* __NS as the number of nanoseconds in the %N directive.
*/
size_t nstrftime (char *restrict __s, size_t __maxsize,
char const *__format,
struct tm const *__tp, timezone_t __tz, int __ns);
/* Like nstrftime, except that it uses the "C" locale instead of the
current locale. */
size_t c_nstrftime (char *restrict __s, size_t __maxsize,
char const *__format,
struct tm const *__tp, timezone_t __tz, int __ns);
#ifdef __cplusplus
}

View file

@ -438,11 +438,7 @@ _GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
_GL_CXXALIASWARN (ctime);
# endif
# elif defined GNULIB_POSIXCHECK
# undef ctime
# if HAVE_RAW_DECL_CTIME
_GL_WARN_ON_USE (ctime, "ctime has portability problems - "
"use gnulib module ctime for portability");
# endif
/* No need to warn about portability, as a more serious warning is below. */
# endif
/* Convert *TP to a date and time string. See

View file

@ -21,6 +21,11 @@
#include <time.h>
/* The replacement functions in this file are only used on native Windows.
They are multithread-safe, because the gmtime() and localtime() functions
on native Windows both in the ucrt and in the older MSVCRT return a
pointer to a 'struct tm' in thread-local memory. */
static struct tm *
copy_tm_result (struct tm *dest, struct tm const *src)
{

View file

@ -32,6 +32,10 @@
_GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
linkage.
_GL_WARN_ON_USE should not be used more than once for a given function
in a given compilation unit (because this may generate a warning even
if the function is never called).
However, one of the reasons that a function is a portability trap is
if it has the wrong signature. Declaring FUNCTION with a different
signature in C is a compilation error, so this macro must use the

View file

@ -29,8 +29,7 @@
is SIZE_MAX - 1. */
#define __xalloc_oversized(n, s) \
((s) != 0 \
&& ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \
< (n)))
&& (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) < (n))
/* Return 1 if and only if an array of N objects, each of size S,
cannot exist reliably because its total size in bytes would exceed

View file

@ -1,4 +1,4 @@
# gnulib-common.m4 serial 91
# gnulib-common.m4 serial 92
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -76,42 +76,48 @@ AC_DEFUN([gl_COMMON_BODY], [
#endif])
AH_VERBATIM([attribute],
[/* Attributes. */
#if (defined __has_attribute \
&& (!defined __clang_minor__ \
|| (defined __apple_build_version__ \
? 7000000 <= __apple_build_version__ \
: 5 <= __clang_major__)))
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
#else
# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_diagnose_if 0
# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
# ifdef _ICC
# define _GL_ATTR_may_alias 0
/* Define _GL_HAS_ATTRIBUTE only once, because on FreeBSD, with gcc < 5, if
<config.h> gets included once again after <sys/cdefs.h>, __has_attribute(x)
expands to 0 always, and redefining _GL_HAS_ATTRIBUTE would turn off all
attributes. */
#ifndef _GL_HAS_ATTRIBUTE
# if (defined __has_attribute \
&& (!defined __clang_minor__ \
|| (defined __apple_build_version__ \
? 7000000 <= __apple_build_version__ \
: 5 <= __clang_major__)))
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
# else
# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_diagnose_if 0
# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
# ifdef _ICC
# define _GL_ATTR_may_alias 0
# else
# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
# endif
# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
# endif
# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
#endif
/* Use __has_c_attribute if available. However, do not use with

View file

@ -1024,7 +1024,7 @@ AC_DEFUN([gl_INIT],
if test $ac_use_included_regex = yes; then
func_gl_gnulib_m4code_fd38c7e463b54744b77b98aeafb4fa7c
fi
if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test $ac_cv_type_long_long_int = yes; then
if test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; then
func_gl_gnulib_m4code_strtoll
fi
if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
@ -1422,6 +1422,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/stdlib.in.h
lib/stpcpy.c
lib/str-two-way.h
lib/strftime.c
lib/strftime.h
lib/string.in.h
lib/strnlen.c

View file

@ -1,4 +1,4 @@
# serial 46
# serial 47
dnl From Jim Meyering.
dnl Check for the nanosleep function.
@ -119,6 +119,10 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
# Guess it halfway works when the kernel is Linux.
linux*)
gl_cv_func_nanosleep='guessing no (mishandles large arguments)' ;;
# Midipix generally emulates the Linux system calls,
# but here it handles large arguments correctly.
midipix*)
gl_cv_func_nanosleep='guessing yes' ;;
# Guess no on native Windows.
mingw* | windows*)
gl_cv_func_nanosleep='guessing no' ;;

View file

@ -1,4 +1,4 @@
# serial 37
# serial 38
# Copyright (C) 1996-1997, 1999-2007, 2009-2024 Free Software Foundation, Inc.
#
@ -16,7 +16,4 @@ AC_DEFUN([gl_FUNC_GNU_STRFTIME],
AC_REQUIRE([AC_STRUCT_TIMEZONE])
AC_REQUIRE([gl_TM_GMTOFF])
AC_DEFINE([my_strftime], [nstrftime],
[Define to the name of the strftime replacement function.])
])

View file

@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl serial 15
dnl serial 16
AC_DEFUN([gl_UTIMENS],
[
@ -36,12 +36,13 @@ AC_DEFUN([gl_UTIMENS],
[gl_cv_func_futimesat_works=yes],
[gl_cv_func_futimesat_works=no],
[case "$host_os" in
# Guess yes on Linux systems.
linux-* | linux) gl_cv_func_futimesat_works="guessing yes" ;;
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_futimesat_works="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_futimesat_works="$gl_cross_guess_normal" ;;
# Guess yes on Linux systems
# and on systems that emulate the Linux system calls.
linux* | midipix*) gl_cv_func_futimesat_works="guessing yes" ;;
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_futimesat_works="guessing yes" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_futimesat_works="$gl_cross_guess_normal" ;;
esac
])
rm -f conftest.file])

View file

@ -1,4 +1,4 @@
# serial 11
# serial 12
# See if we need to provide utimensat replacement.
dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
@ -83,6 +83,9 @@ AC_DEFUN([gl_FUNC_UTIMENSAT],
# Guess yes on Linux or glibc systems.
linux-* | linux | *-gnu* | gnu*)
gl_cv_func_utimensat_works="guessing yes" ;;
# Guess yes on systems that emulate the Linux system calls.
midipix*)
gl_cv_func_utimensat_works="guessing yes" ;;
# Guess 'nearly' on AIX.
aix*)
gl_cv_func_utimensat_works="guessing nearly" ;;