summaryrefslogtreecommitdiff
path: root/lib/nstrftime.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: run 'make update-copyright'Simon Josefsson2023-01-011-1/+1
|
* Rely on new stdbool behaviorPaul Eggert2022-09-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prefer the C23 style to the C99 style, since the stdbool module now supports C23. * lib/acl-internal.h, lib/acl.h, lib/argmatch.c, lib/argmatch.h: * lib/argp-help.c, lib/argv-iter.h, lib/asyncsafe-spin.c: * lib/backup-internal.h, lib/backupfile.c, lib/base32.h: * lib/base64.h, lib/basename-lgpl.c, lib/bitset/base.h: * lib/c-ctype.h, lib/c-strcasestr.c, lib/canonicalize-lgpl.c: * lib/canonicalize.c, lib/chdir-long.c, lib/chown.c: * lib/classpath.h, lib/clean-temp-private.h: * lib/clean-temp-simple.c, lib/clean-temp-simple.h: * lib/clean-temp.c, lib/clean-temp.h, lib/cloexec.h: * lib/close-stream.c, lib/closein.c, lib/closeout.c, lib/closeout.h: * lib/csharpcomp.h, lib/csharpexec.h, lib/cycle-check.c: * lib/cycle-check.h, lib/des.h, lib/dfa.h, lib/diffseq.h: * lib/dirname.h, lib/exclude.c, lib/exclude.h, lib/execute.c: * lib/execute.h, lib/execvpe.c, lib/fatal-signal.c, lib/fchdir.c: * lib/file-set.h, lib/filevercmp.c, lib/findprog-in.c: * lib/findprog.c, lib/findprog.h, lib/fma.c, lib/fnmatch.c: * lib/fopen.c, lib/freadable.h, lib/freading.h, lib/freopen-safer.c: * lib/fstrcmp.c, lib/fsusage.h, lib/fts.c, lib/fwritable.h: * lib/fwriteerror.c, lib/fwriting.h, lib/gen-uni-tables.c: * lib/getaddrinfo.c, lib/getcwd.c, lib/getloadavg.c: * lib/getndelim2.c, lib/getpass.c, lib/getrandom.c: * lib/git-merge-changelog.c, lib/gl_list.h, lib/gl_map.h: * lib/gl_omap.h, lib/gl_oset.h, lib/gl_set.h, lib/glob.c: * lib/glthread/cond.h, lib/hamt.h, lib/hard-locale.h: * lib/hash-triple.h, lib/hash.h, lib/human.h, lib/i-ring.h: * lib/isapipe.c, lib/javacomp.h, lib/javaexec.h, lib/javaversion.c: * lib/lchown.c, lib/localeinfo.h, lib/localename.c: * lib/long-options.h, lib/malloc/dynarray.h, lib/mbchar.h: * lib/mbfile.h, lib/mbiter.h, lib/mbmemcasecoll.h, lib/mbscasestr.c: * lib/mbsstr.c, lib/mbuiter.h, lib/mkdir-p.h, lib/modechange.h: * lib/mountlist.h, lib/nanosleep.c, lib/nonblocking.h: * lib/nstrftime.c, lib/openat.c, lib/openat.h, lib/os2-spawn.c: * lib/parse-datetime.h, lib/pipe-filter-aux.c, lib/pipe-filter-gi.c: * lib/pipe-filter-ii.c, lib/pipe-filter.h, lib/posixtm.h: * lib/priv-set.c, lib/progreloc.c, lib/propername.c: * lib/pthread-spin.c, lib/quotearg.c, lib/readtokens.c: * lib/readtokens0.h, lib/readutmp.c, lib/regex-quote.h: * lib/regex_internal.h, lib/relocwrapper.c, lib/rename.c: * lib/renameatu.c, lib/rpmatch.c, lib/same.c, lib/same.h: * lib/save-cwd.c, lib/savewd.c, lib/savewd.h, lib/spawn-pipe.h: * lib/spawni.c, lib/stack.h, lib/stat.c, lib/stdckdint.in.h: * lib/strcasestr.c, lib/strfmon_l.c, lib/striconveh.c: * lib/striconveha.h, lib/string-buffer.h, lib/strptime.c: * lib/strstr.c, lib/strtod.c, lib/supersede.h, lib/system-quote.c: * lib/tempname.c, lib/term-style-control.c: * lib/term-style-control.h, lib/textstyle.in.h, lib/time_rz.c: * lib/tmpdir.c, lib/tmpdir.h, lib/tmpfile.c, lib/unicase.in.h: * lib/unicase/caseprop.h, lib/unicase/invariant.h: * lib/unicase/u16-casemap.c, lib/unicase/u16-ct-totitle.c: * lib/unicase/u16-is-invariant.c, lib/unicase/u32-casemap.c: * lib/unicase/u32-ct-totitle.c, lib/unicase/u32-is-invariant.c: * lib/unicase/u8-casemap.c, lib/unicase/u8-ct-totitle.c: * lib/unicase/u8-is-invariant.c, lib/unictype.in.h: * lib/unigbrk.in.h, lib/unigbrk/u16-grapheme-breaks.c: * lib/unigbrk/u32-grapheme-breaks.c: * lib/unigbrk/u8-grapheme-breaks.c: * lib/unigbrk/uc-grapheme-breaks.c, lib/uniname/uniname.c: * lib/unistr.in.h, lib/unlinkdir.h, lib/userspec.h, lib/utime.c: * lib/utimecmp.c, lib/utimens.c, lib/wait-process.h: * lib/windows-cond.c, lib/windows-spawn.c, lib/windows-spawn.h: * lib/windows-timedrwlock.c, lib/write-any-file.h, lib/xbinary-io.c: * lib/xstrtod.h, lib/yesno.h: * tests/nap.h, tests/qemu.h, tests/test-areadlink-with-size.c: * tests/test-areadlink.c, tests/test-areadlinkat-with-size.c: * tests/test-areadlinkat.c, tests/test-base32.c: * tests/test-base64.c, tests/test-ceil2.c, tests/test-ceilf2.c: * tests/test-chown.c, tests/test-dirname.c, tests/test-dup-safer.c: * tests/test-dup3.c, tests/test-exclude.c: * tests/test-execute-child.c, tests/test-execute-main.c: * tests/test-execute-script.c, tests/test-explicit_bzero.c: * tests/test-fchownat.c, tests/test-fcntl-safer.c: * tests/test-fcntl.c, tests/test-fdutimensat.c: * tests/test-filenamecat.c, tests/test-floor2.c: * tests/test-floorf2.c, tests/test-fstatat.c, tests/test-fstrcmp.c: * tests/test-futimens.c, tests/test-getlogin.h, tests/test-getopt.h: * tests/test-hard-locale.c, tests/test-hash.c: * tests/test-idpriv-drop.c, tests/test-idpriv-droptemp.c: * tests/test-immutable.c, tests/test-intprops.c: * tests/test-lchown.c, tests/test-link.c, tests/test-linkat.c: * tests/test-lstat.c, tests/test-mbmemcasecmp.c: * tests/test-mbmemcasecoll.c, tests/test-mkdir.c: * tests/test-mkdirat.c, tests/test-mkfifo.c, tests/test-mkfifoat.c: * tests/test-mknod.c, tests/test-nonblocking-pipe-child.c: * tests/test-nonblocking-pipe-main.c: * tests/test-nonblocking-socket-child.c: * tests/test-nonblocking-socket-main.c, tests/test-open.c: * tests/test-openat.c, tests/test-pipe.c, tests/test-pipe2.c: * tests/test-poll.c, tests/test-posix_spawn-chdir.c: * tests/test-posix_spawn-dup2-stdin.c: * tests/test-posix_spawn-dup2-stdout.c: * tests/test-posix_spawn-fchdir.c, tests/test-posix_spawn-open1.c: * tests/test-posix_spawn-open2.c, tests/test-quotearg-simple.c: * tests/test-quotearg.c, tests/test-readlink.c: * tests/test-readlinkat.c, tests/test-readtokens.c: * tests/test-rename.c, tests/test-renameat.c: * tests/test-renameatu.c, tests/test-rmdir.c, tests/test-round2.c: * tests/test-select.h, tests/test-spawn-pipe-child.c: * tests/test-spawn-pipe-main.c, tests/test-spawn-pipe-script.c: * tests/test-stack.c, tests/test-stat.c, tests/test-supersede.c: * tests/test-symlink.c, tests/test-symlinkat.c: * tests/test-system-quote-main.c: * tests/test-term-style-control-hello.c: * tests/test-term-style-control-yes.c, tests/test-timespec.c: * tests/test-trunc2.c, tests/test-truncf2.c, tests/test-unlink.c: * tests/test-unlinkat.c, tests/test-userspec.c, tests/test-utime.c: * tests/test-utimens.c, tests/test-utimensat.c: * tests/unictype/test-categ_byname.c: * tests/unigbrk/test-uc-is-grapheme-break.c: Don’t include stdbool.h. * modules/acl, modules/xgetcwd: Don’t depend on stdbool, as these modules don’t use bool. * modules/argp, modules/bitset, modules/diffseq, modules/file-has-acl: * modules/gen-uni-tables, modules/getrandom: * modules/hash-triple-simple, modules/posix_spawn-internal: * modules/strcasestr, modules/supersede, modules/system-quote: * modules/uniconv/base, modules/uniname/uniname, modules/utime: * modules/windows-timedrwlock: Depend on stdbool, as these modules use bool.
* nstrftime: pacify nvc 22.1 unreachable statementPaul Eggert2022-01-141-1/+0
| | | | | * lib/nstrftime.c (__strftime_internal): Omit unreachable ‘break;’.
* license: fix GPLv3 texts to use a comma instead of semicolon.Bernhard Voelker2022-01-051-1/+1
| | | | | | | | | See: https://www.gnu.org/licenses/gpl-3.0.html#howto Run: $ git grep -l 'Foundation; either version 3' \ | xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/' * All files using GPLv3: Adjust via the above command.
* maint: run 'make update-copyright'Paul Eggert2022-01-011-1/+1
|
* nstrftime: improve handling of invalid formatsPaul Eggert2021-12-281-8/+6
| | | | | | | | * lib/nstrftime.c (__strftime_internal): Without this change, ‘date +'%0_-+^#1%A'’ would output ‘%A’; with it, it outputs something like ‘%0_-+^#1Tuesday’ which is easier to debug and to write wrappers for (such as the nstrftime/fprintftime usage in GNU ‘date’).
* nstrftime: simplify by using libc-config.h.Paul Eggert2021-12-181-7/+2
| | | | | | | | * lib/nstrftime.c [!_LIBC]: Include libc-config.h instead of config.h. (iso_week_days): Simplify via libc-config.h’s __inline. (my_strftime): Simplify via libc-config.h’s libc_hidden_def. * modules/nstrftime (Depends-on): Add libc-config.
* Put LGPLv3+ notices in source files where appropriate.Bruno Haible2021-06-041-10/+9
| | | | | * lib/**.{h,c}: Use LGPLv3+ notice whenever the module description says so.
* nstrftime, time_rz: Avoid using an obsolete Autoconf macro.Bruno Haible2021-01-041-3/+3
| | | | | | | | | | | Reported by Mike Gran <spk121@yahoo.com> in <https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00067.html>. * lib/time-internal.h: Test HAVE_STRUCT_TM_TM_ZONE, not HAVE_TM_ZONE. * lib/time_rz.c: Likewise. * lib/nstrftime.c: Set and test HAVE_STRUCT_TM_TM_ZONE, not HAVE_TM_ZONE. * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Update comments.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* nstrftime: Guide inlining also on clang.Bruno Haible2020-08-161-1/+1
| | | | * lib/nstrftime.c (iso_week_days): Inline also on clang.
* nstrftime: be more predictable about errnoPaul Eggert2020-08-151-1/+13
| | | | | | | | | | | | This aligns nstrftime better with draft POSIX 202x strftime. * lib/nstrftime.c: Include errno.h. (width_add, __strftime_internal): Set errno on failure, and preserve it on success. Check for mktime_z failure. * modules/nstrftime (Depends-on): Add errno. * modules/nstrftime-tests (Depends-on): Add atoll, intprops. * tests/test-nstrftime.c: Include intprops.h, limits.h. (errno_test): New test function. (main): Call it.
* nstrftime: Assume tzset exists.Bruno Haible2020-08-141-4/+2
| | | | | | * lib/nstrftime.c (HAVE_TZSET): Remove macro. (__strftime_internal): Test my_strftime, not HAVE_TZSET. * m4/nstrftime.m4 (gl_FUNC_GNU_STRFTIME): Don't test for tzset.
* tzset: Remove workaround for Solaris 2.6.Bruno Haible2020-07-261-9/+0
| | | | | | | | | | | | | | * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Remove macro. (gl_FUNC_TZSET): Don't invoke it. Don't define TZSET_CLOBBERS_LOCALTIME. Don't require gl_LOCALTIME_BUFFER_DEFAULTS. * lib/localtime-buffer.h: Don't test TZSET_CLOBBERS_LOCALTIME. * lib/localtime-buffer.c: Likewise. * lib/localtime.c: Likewise. * lib/tzset.c: Don't include localtime-buffer.h. (tzset): Don't test TZSET_CLOBBERS_LOCALTIME. * lib/nstrftime.c (__strftime_internal): Assume HAVE_RUN_TZSET_TEST is 1. * modules/tzset (Depends-on): Remove localtime-buffer.
* attribute: minor fixupsPaul Eggert2020-05-031-1/+1
| | | | | Suggested by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2020-05/msg00049.html
* attribute: new modulePaul Eggert2020-05-031-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* nstrftime: tweak division performancePaul Eggert2019-12-231-6/+8
| | | | | * lib/nstrftime.c (SHR, tm_diff, __strftime_internal): Redo with neither ‘%’ nor conditional branches.
* nstrftime: avoid a shadowing warningJim Meyering2019-12-191-2/+2
| | | | | * lib/nstrftime.c (libc_hidden_def): Rename inner "i" to "j", to avoid shadowing an "i" declared hundreds of lines above.
* nstrftime: better width support for %N, %zPaul Eggert2019-12-061-79/+59
| | | | | | | | | | | | | | * lib/nstrftime.c (width_add, width_add1, width_cpy): New macros, which generalize ‘add’, ‘add1’, ‘cpy’ by adding a new WIDTH parameter. (add, add1, cpy): Use these macros. (width_add): Do not treat digits == 0 as a special case, do not pad if padding is ‘-’, and do not use a negative width. (__strftime_internal): Redo formatting of nanoseconds and numeric timezones to avoid buffer misuse in unusual cases, and so that widths make more sense. Add support for widths greater than 9 to the %N format; they are zero filled on the right. * tests/test-nstrftime.c (posixtm_test): Add a %12N test.
* nstrftime: speed up integer overflow checkingPaul Eggert2019-10-231-15/+4
| | | | | | | | * lib/nstrftime.c: Include intprops.h. (INT_STRLEN_BOUND): Remove, as we can use intprops.h’s defn. (__strftime_internal): Use INT_MULTIPLY_WRAPV and INT_ADD_WRAPV instead of doing it by hand. * modules/nstrftime (Depends-on): Add intprops.
* nstrftime: support the ‘+’ flagPaul Eggert2019-02-241-28/+56
| | | | | | | * lib/nstrftime.c (add, __strftime_internal): Add support for the ‘+’ flag introduced in POSIX.1-2017. (__strftime_internal): New arg ‘width’. All uses changed. (DO_YEARISH, DO_MAYBE_SIGNED_NUMBER): New macros.
* nstrftime: tweak arg orderPaul Eggert2019-02-231-9/+9
| | | | | | * lib/nstrftime.c (__strftime_internal): Interchange arg order. All callers changed. Suggested by TAMUKI Shoichi in: https://lists.gnu.org/r/bug-gnulib/2019-02/msg00052.html
* nstrftime: merge glibc strftime changesPaul Eggert2019-02-211-11/+16
| | | | | | | | | | | This incorporates: 2019-02-11 Fix a few whitespace arrangement inconsistencies 2019-01-24 strftime: Pass flags from "%EY" to "%Ey" [BZ #24096] 2019-01-24 Set the default width of "%Ey" to 2 [BZ #23758] 2019-01-11 strftime: use the "L_" macro with character literals * lib/nstrftime.c (__strftime_internal): New arg yr_spec. All callers changed. Default width of %Ey is now 2. This is needed for proper handling of Japanese dates starting on 2019-05-01.
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* nstrftime: simplify test for mktime failurePaul Eggert2018-11-031-20/+2
| | | | * lib/nstrftime.c (__strftime_internal): Simplify.
* Merge strftime.c changes from glibcPaul Eggert2018-01-231-5/+19
| | | | | | | | | | | | This incorporates: 2017-11-14 [BZ #10871] Implement alternative month names 2017-11-14 [BZ #10871] Abbreviated alternative month names (%Ob) 2017-06-20 Use locale_t, not __locale_t, throughout glibc * lib/nstrftime.c (ABALTMON_1) [!COMPILE_WIDE]: New macro. (LOCALE_PARAM) [_LIBC && USE_IN_EXTENDED_LOCALE_MODEL]: Use locale_t, not __locale_t. (a_altmonth, f_altmonth, aam_len) [_NL_CURRENT]: New macros. (__strftime_internal): Add support for alternate months.
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* Rename module 'strftime' to 'nstrftime'.Bruno Haible2017-07-241-0/+1506
* m4/nstrftime.m4: Renamed from m4/strftime.m4. * lib/nstrftime.c: Renamed from lib/strftime.c. * modules/nstrftime: Renamed from modules/strftime. (Files, Makefile.am): Update. * tests/test-nstrftime.c: Renamed from tests/test-strftime.c. Fix comment. * modules/nstrftime-tests: Renamed from modules/strftime-tests. (Files, Makefile.am): Update. * modules/strftime: New file, an obsolete indirection. * doc/posix-functions/strftime.texi: Update reference. * config/srclist.txt: Update info.