summaryrefslogtreecommitdiff
path: root/lib/mktime.c
Commit message (Collapse)AuthorAgeFilesLines
* mktime: improve heuristic for ca-1986 Indiana DSTPaul Eggert2022-02-191-8/+20
| | | | | | | | | | | | | | | | Problem reported by Mark Krenz <https://bugs.gnu.org/48085>. * lib/mktime.c (__mktime_internal): Be more generous about accepting arguments with the wrong value of tm_isdst, by falling back to a one-hour DST difference if we find no nearby DST that is unusual. This fixes a problem where "1986-04-28 00:00 EDT" was rejected when TZ="America/Indianapolis" because the nearest DST timestamp occurred in 1970, a temporal distance too great for the old heuristic. This also also narrows the search a bit, which is a minor performance win. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Check for putenv failures and for Bug#48085. * tests/test-parse-datetime.c (main): Test for setenv failures and for Bug#48085.
* maint: run 'make update-copyright'Paul Eggert2022-01-011-1/+1
|
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* Revert autoupdate's revert.Bruno Haible2020-08-151-1/+1
| | | | * config/srclist.txt: Mark mktime.c as needing sync with glibc.
* autoupdateKarl Berry2020-08-151-1/+1
|
* mktime, mktime-internal: Assume tzset exists.Bruno Haible2020-08-141-1/+1
| | | | | * lib/mktime.c (my_tzset): Assume HAVE_TZSET is 1. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): Don't test for tzset.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* mktime: tweak division performancePaul Eggert2019-12-231-3/+3
| | | | | | * config/srclist.txt: Do not sync mktime.c for now. * lib/mktime.c (shr, ydhms_diff): Redo with neither ‘%’ nor conditional branches.
* autoupdateKarl Berry2019-11-011-1/+1
|
* autoupdateKarl Berry2019-09-241-1/+1
|
* Update some URLsPaul Eggert2019-09-221-1/+1
| | | | | | This is a clerical change that mostly changes http: to https: in URLs where either will work. It also updates some URLs that have moved, removes some URLs that no longer work, and fixes related text.
* autoupdate (removing trailing white space from config.guess)Paul Eggert2019-04-301-27/+44
|
* all: Update URLs to msdn.microsoft.com.Bruno Haible2019-03-141-1/+1
| | | | | * lib/stat-w32.c et al.: Update URLs after most of msdn.microsoft.com was moved to docs.microsoft.com.
* autoupdatePaul Eggert2018-12-311-1/+1
|
* autoupdatePaul Eggert2018-11-161-266/+125
|
* autoupdatePaul Eggert2018-10-081-1/+1
|
* mktime: fix _LIBC typoPaul Eggert2018-09-191-1/+1
| | | | * lib/mktime.c (mktime): Fix typo (misspelled "_LIBC").
* mktime: simplify in prep for glibc mergePaul Eggert2018-09-091-5/+1
| | | | | | * lib/mktime.c, lib/timegm.c [_LIBC]: Include mktime-internal.h (a small file just for glibc) instead of using a typedef.
* mktime: fix unlikely race+overflow bugPaul Eggert2018-09-021-1/+2
| | | | | | | | Problem reported by Alexandre Oliva in: https://sourceware.org/bugzilla/show_bug.cgi?id=16346 * lib/mktime.c (__mktime_internal): Access *OFFSET only once, to avoid an unlikely race if the compiler delays a load and if this cascades into a signed integer overflow.
* mktime, timegm: simplify glibc time64_tPaul Eggert2018-09-011-1/+1
| | | | | | | | | * lib/mktime.c, lib/timegm.c (mktime_offset_t) [_LIBC]: Now long int, not time_t, since long int is the longstanding type for this in glibc and there is no need to change it even if time_t becomes 64 bits - even int would do, though this would be a change to the glibc generated code. When this change is merged into glibc, it should simplify the time_t vs time64_t situation.
* mktime, timegm: simplify merge to glibcPaul Eggert2018-09-011-60/+63
| | | | | | | | | | | | | | | | | | | | Move code around to make a merge to glibc easier to audit. This should not change behavior. * lib/mktime.c: Include more standard files unconditionally. (NEED_MKTIME_INTERNAL, NEED_MKTIME_WINDOWS) (NEED_MKTIME_WORKING): Give default values to pacify -Wundef, which glibc uses. Default NEED_MKTIME_WORKING to DEBUG_MKTIME, to simplify later conditionals; default the others to zero. In uses of these conditionals, explicitly spell out how _LIBC affects things, so it’s easier to review from a glibc viewpoint. (my_tzset, __tzset) [!_LIBC]: New function and macro, to better compartmentalize tzset issues. Move system-dependent tzsettish code here from mktime. (mktime): Move tzsettish code to my_tzset, and move localtime_offset to within mktime so that it doesn’t need a separate ifdef. * lib/mktime-internal.h (__gmtime_r, __localtime_r, __mktime_internal): Move these macros here from lib/mktime.c and lib/gmtime.c.
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* tzset: Expand comment about TZ problem on native Windows.Bruno Haible2017-05-091-3/+22
| | | | | | | | | | * lib/tzset.c (tzset): Elaborate comment, based on explanations by Paul Eggert. * lib/ctime.c (rpl_ctime): Likewise. * lib/localtime.c (rpl_localtime): Likewise. * lib/mktime.c (mktime): Likewise. * lib/strftime-fixes.c (rpl_strftime): Likewise. * lib/wcsftime.c (rpl_wcsftime): Likewise.
* mktime: Work around TZ problem on native Windows.Bruno Haible2017-04-301-3/+44
| | | | | | | | | | | | | | | | | | | | * lib/mktime.c: Add #ifs to make the algorithmic workaround independent from the native Windows workaround. * m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): New macro, extracted from gl_FUNC_MKTIME. If guessing, set gl_cv_func_working_mktime to 'guessing no'. (gl_FUNC_MKTIME): Require it. Require AC_CANONICAL_HOST. Set REPLACE_MKTIME to 1 on native Windows. Define NEED_MKTIME_WORKING, NEED_MKTIME_WINDOWS. (gl_FUNC_MKTIME_INTERNAL): Require gl_FUNC_MKTIME_WORKS, not gl_FUNC_MKTIME. Set WANT_MKTIME_INTERNAL, not REPLACE_MKTIME. Define NEED_MKTIME_INTERNAL. * m4/timegm.m4 (gl_FUNC_TIMEGM): Require gl_FUNC_MKTIME_WORKS, not gl_FUNC_MKTIME. Cope with 'guessing yes' value. * modules/mktime-internal (configure.ac): Test WANT_MKTIME_INTERNAL, not REPLACE_MKTIME. * doc/posix-functions/mktime.texi: Mention the native Windows workaround.
* maint: time stamp -> timestampPaul Eggert2017-01-091-1/+1
| | | | Use the spelling "timestamp", as that is what POSIX uses.
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* mktime: call tzset as per POSIXPaul Eggert2016-07-031-0/+2
| | | | | | | Problem reported by Ludovic Courtès in: http://lists.gnu.org/archive/html/bug-gnulib/2016-06/msg00068.html * lib/mktime.c (mktime) [!_LIBC && HAVE_TZSET]: Call tzset. * m4/mktime.m4 (gl_FUNC_MKTIME): Check for tzset.
* mktime: spelling fix in commentPaul Eggert2016-05-011-1/+1
| | | | * lib/mktime.c: Fix spelling.
* mktime: port to stricter signed overflow checkingPaul Eggert2016-05-011-200/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | * lib/mktime.c: Omit 'pragma GCC optimize ("wrapv")'. (long_int): Require width for INT_MAX * 3 * (seconds per year), instead of merely for INT_MAX * 2. In practice platforms that do the latter also do the former. (TIME_T_MIN, TIME_T_MAX, TIME_T_MIDPOINT, SHR): Remove. (shr): New static function, replacing SHR. All uses changed. (mktime_min, mktime_max): New constants, replacing TIME_T_MIN and TIME_T_MAX. All uses changed. (ydhms_diff, guess_time_tm, ranged_convert, __mktime_internal): Use long_int, not time_t. (long_int_avg): New static function, replacing time_t_avg. All uses changed. Round toward positive infinity, as that generates slightly better code. (time_t_add_ok, time_t_int_add_ok): Remove. All uses replaced by INT_ADD_WRAPV. (guess_time_tm): Accept time, not a pointer to it. All uses changed. (convert_time): New static function. (ranged_convert): Use it (ranged_convert): Check for *T out of [mktime_min, mktime_max] range. Use simpler test for loop exit. (__mktime_internal): Store negative of guessed offset, to simplify overflow checking. Remove no-longer-needed test for small time_t overflows.
* mktime: speed up DEBUG_MKTIME benchmarksPaul Eggert2016-05-011-12/+15
| | | | | | | | | | | Call tzset just once, at the start, rather than for every test case. This lets us measure the CPU cost of mktime as opposed to that of tzset. This is relevant when TZ is not set and glibc is being used. This speeds up tests by a factor of 40 on my Fedora 23 x86-64 platform. * lib/mktime.c (main) [DEBUG_MKTIME]: Call localtime at the start, to call tzset and as a sanity check. Later on, use localtime_r instead of localtime.
* mktime: resurrect DEBUG_MKTIME testingPaul Eggert2016-05-011-1/+2
| | | | | * lib/mktime.c [DEBUG_MKTIME]: Do not include <config.h>. Include <string.h>, for strcmp.
* mktime: simplify DEBUG_MKTIMEPaul Eggert2016-05-011-5/+7
| | | | | * lib/mktime.c (DEBUG_MKTIME): Define to 0 if not defined. Simplify later usage accordingly.
* Port mktime_internal offset to unsigned time_tPaul Eggert2016-05-011-7/+5
| | | | | | | | | | | | This avoids some assumptions about wraparound arithmetic on signed integer overflow. * lib/mktime-internal.h (mktime_offset_t): New type. (mktime_internal): Use it in decl. * lib/mktime.c, lib/timegm.c (mktime_offset_t) [_LIBC]: New type. * lib/mktime.c (__mktime_internal, localtime_offset): * lib/timegm.c (timegm): Use it. * m4/mktime.m4 (gl_TIME_T_IS_SIGNED): New macro. (gl_FUNC_MKTIME): Require it.
* mktime: improve integer overflow checkingPaul Eggert2016-04-131-78/+34
| | | | | | | | | | | | | * lib/mktime.c: Include stdbool.h, intprops.h, verify.h. (WRAPV): Remove; no longer needed. (verify): Remove. Replace all uses with call to verify.h 'verify'. (TYPE_IS_INTEGER, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. Use intprops.h defns instead. (leapyear, isdst_differ, time_t_add_ok, time_t_int_ok): Use bool for Boolean, for clarity. (time_t_add_ok, time_t_int_add_ok): Use INT_ADD_WRAPV to detect integer overflow. * modules/mktime (Depends-on): Add intprops, stdbool, verify.
* intprops, mktime, strtol: assume two's complementPaul Eggert2016-04-131-20/+11
| | | | | | | | | | | | | | | | | | These macros were not portable to every conforming C11 ones' complement platform. It's not worth the hassle of porting to some platforms that use ones' complement or signed magnitude, as such platforms are almost purely theoretical nowadays and porting even to some of them makes the code harder to review for little practical benefit. Problem reported by Florian Weimer in: https://sourceware.org/ml/libc-alpha/2016-04/msg00295.html * lib/intprops.h (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT) (TYPE_SIGNED_MAGNITUDE, _GL_INT_TWOS_COMPLEMENT): * lib/mktime.c (TYPE_TWOS_COMPLEMENT): * lib/strtol.c (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT) (TYPE_SIGNED_MAGNITUDE): Remove. All uses rewritten to assume two's complement, which is all we can reasonably test nowadays anyway. * top/maint.mk (_intprops_names): Remove the removed macros.
* mktime: rename macro to avoid glibc clashMartin Sebor2016-01-121-6/+6
| | | | | * lib/mktime.c [DEBUG] (DEBUG): Rename to DEBUG_MKTIME. See: https://sourceware.org/ml/libc-alpha/2016-01/msg00267.html
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* mktime: merge #if/#ifdef usage from glibcPaul Eggert2014-06-271-2/+2
| | | | | | | * lib/mktime.c: Use "#if defined DEBUG && DEBUG", not "#if DEBUG", as that works with both Glibc's and Gnulib's style. See thread starting at Siddhesh Poyarekar's bug report at: http://lists.gnu.org/archive/html/bug-gnulib/2014-06/msg00102.html
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* mktime: avoid 'static inline'Paul Eggert2012-08-191-2/+2
| | | | | * lib/mktime.c (leapyear, ydhms_diff): Now static, not static inline. * m4/mktime.m4 (gl_PREREQ_MKTIME): Do not require AC_C_INLINE.
* * lib/mktime.c: Revert autoupdate, which fetched the wrong version.Paul Eggert2012-05-251-80/+155
|
* autoupdateKarl Berry2012-05-251-155/+80
|
* mktime: sync from glibcPaul Eggert2012-05-231-194/+197
| | | | | | | | | | | * config/srclist.txt: Uncomment mktime.c. * lib/mktime.c: Sync from glibc master. This incorporates 3 changes. First, indent with tabs, since glibc uses tabs and doesn't want to change and we'd rather be identical to glibc. Also, two small coding changes: (isdst_differ): Use &&, not &, as && is the usual style. (__mktime_internal): Rename local var from abs_diff to approx_abs_diff for clarity.
* maint: replace FSF snail-mail addresses with URLsPaul Eggert2012-02-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * config/argz.mk, lib/accept4.c, lib/alignof.h, lib/alloca.in.h: * lib/alphasort.c, lib/arcfour.c, lib/arcfour.h, lib/arctwo.c: * lib/arctwo.h, lib/argz.c, lib/arpa_inet.in.h, lib/asnprintf.c: * lib/asprintf.c, lib/assert.in.h, lib/base32.c, lib/base32.h: * lib/base64.c, lib/base64.h, lib/c-ctype.c, lib/c-ctype.h: * lib/c-strcase.h, lib/c-strcasecmp.c, lib/c-strncasecmp.c: * lib/check-version.c, lib/check-version.h, lib/config.charset: * lib/ctype.in.h, lib/des.c, lib/des.h, lib/dup3.c, lib/errno.in.h: * lib/float+.h, lib/fnmatch.c, lib/fnmatch.in.h, lib/fnmatch_loop.c: * lib/fseeko.c, lib/gai_strerror.c, lib/gc-gnulib.c: * lib/gc-libgcrypt.c, lib/gc-pbkdf2-sha1.c, lib/gc.h: * lib/getaddrinfo.c, lib/getdelim.c, lib/getfilecon.c, lib/getline.c: * lib/getlogin_r.c, lib/getpass.c, lib/getpass.h, lib/gettext.h: * lib/gettimeofday.c, lib/glob.in.h, lib/glthread/cond.c: * lib/glthread/cond.h, lib/glthread/lock.c, lib/glthread/lock.h: * lib/glthread/thread.c, lib/glthread/thread.h: * lib/glthread/threadlib.c, lib/glthread/yield.h, lib/hmac-md5.c: * lib/hmac-sha1.c, lib/hmac.h, lib/iconv.c, lib/iconv.in.h: * lib/iconv_close.c, lib/iconv_open.c, lib/inet_ntop.c, lib/isfinite.c: * lib/isinf.c, lib/iswblank.c, lib/langinfo.in.h, lib/link.c: * lib/localcharset.c, lib/localcharset.h, lib/lseek.c, lib/malloc.c: * lib/malloca.c, lib/malloca.h, lib/md2.c, lib/md2.h, lib/md4.c: * lib/md4.h, lib/md5.c, lib/md5.h, lib/memmem.c, lib/mempcpy.c: * lib/memset.c, lib/memxor.c, lib/memxor.h, lib/minmax.h, lib/mktime.c: * lib/msvc-inval.c, lib/msvc-inval.h, lib/msvc-nothrow.c: * lib/msvc-nothrow.h, lib/netdb.in.h, lib/netinet_in.in.h, lib/nproc.c: * lib/nproc.h, lib/obstack_printf.c, lib/pathmax.h, lib/pipe.c: * lib/pipe2.c, lib/poll.c, lib/poll.in.h, lib/printf-args.c: * lib/printf-args.h, lib/printf-parse.c, lib/printf-parse.h: * lib/pselect.c, lib/pthread.in.h, lib/pty-private.h, lib/pty.in.h: * lib/read-file.c, lib/read-file.h, lib/ref-add.sin, lib/ref-del.sin: * lib/regcomp.c, lib/regex.c, lib/regex.h, lib/regex_internal.c: * lib/regex_internal.h, lib/regexec.c, lib/rijndael-alg-fst.c: * lib/rijndael-alg-fst.h, lib/rijndael-api-fst.c: * lib/rijndael-api-fst.h, lib/rint.c, lib/rintf.c, lib/rintl.c: * lib/round.c, lib/roundf.c, lib/roundl.c, lib/scandir.c, lib/select.c: * lib/sha1.c, lib/sha1.h, lib/size_max.h, lib/snprintf.c: * lib/stdalign.in.h, lib/stdarg.in.h, lib/stdbool.in.h: * lib/stddef.in.h, lib/stdint.in.h, lib/stdio.in.h, lib/str-kmp.h: * lib/str-two-way.h, lib/strcasecmp.c, lib/strcasestr.c, lib/strdup.c: * lib/striconv.c, lib/striconv.h, lib/string.in.h, lib/strings.in.h: * lib/strncasecmp.c, lib/strndup.c, lib/strnlen.c, lib/strpbrk.c: * lib/strptime.c, lib/strsep.c, lib/strstr.c, lib/strverscmp.c: * lib/sys_file.in.h, lib/sys_ioctl.in.h, lib/sys_select.in.h: * lib/sys_socket.in.h, lib/sys_stat.in.h, lib/sys_time.in.h: * lib/sys_times.in.h, lib/sys_types.in.h, lib/sys_uio.in.h: * lib/sys_utsname.in.h, lib/sys_wait.in.h, lib/tcgetsid.c: * lib/termios.in.h, lib/time.in.h, lib/time_r.c, lib/timegm.c: * lib/times.c, lib/unictype/3level.h, lib/unictype/3levelbit.h: * lib/unistd.in.h, lib/vasnprintf.c, lib/vasnprintf.h, lib/vasprintf.c: * lib/vsnprintf.c, lib/waitpid.c, lib/wchar.in.h, lib/wctype.in.h: * lib/xsize.h, tests/test-closein.c, tests/test-des.c: * tests/test-fclose.c, tests/test-fgetc.c, tests/test-filevercmp.c: * tests/test-fputc.c, tests/test-fread.c, tests/test-fwrite.c: * tests/test-gc-arcfour.c, tests/test-gc-arctwo.c, tests/test-gc-des.c: * tests/test-gc-hmac-md5.c, tests/test-gc-hmac-sha1.c: * tests/test-gc-md2.c, tests/test-gc-md4.c, tests/test-gc-md5.c: * tests/test-gc-pbkdf2-sha1.c, tests/test-gc-rijndael.c: * tests/test-gc-sha1.c, tests/test-gc.c, tests/test-getdelim.c: * tests/test-getline.c, tests/test-getndelim2.c, tests/test-md2.c: * tests/test-md4.c, tests/test-parse-datetime.c, tests/test-perror.c: * tests/test-perror2.c, tests/test-pipe.c, tests/test-pipe2.c: * tests/test-poll.c, tests/test-quotearg-simple.c: * tests/test-quotearg.c, tests/test-quotearg.h: * tests/test-round-ieee.c, tests/test-round1.c: * tests/test-roundf-ieee.c, tests/test-roundf1.c: * tests/test-roundl-ieee.c, tests/test-roundl.c: * tests/test-safe-alloc.c, tests/test-sigpipe.c: * tests/test-spawn-pipe-child.c, tests/test-spawn-pipe-main.c: * tests/test-strerror.c, tests/test-strerror_r.c: * tests/test-strsignal.c, tests/test-strverscmp.c: * tests/test-xmemdup0.c: Replace FSF snail mail addresses with URLs, as per GNU coding standards. See glibc bug <http://sourceware.org/bugzilla/show_bug.cgi?id=13673>.
* mktime: Avoid compilation error on Solaris 11.Bruno Haible2012-01-081-18/+20
| | | | * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.
* In commentary, do not use ` to quote.Paul Eggert2012-01-051-3/+3
|
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".