modules/parse-datetime


Log

Author Commit Date CI Message
Paul Eggert 4499147b 2017-09-25T18:12:06 parse-datetime: fix dependency * modules/parse-datetime (Depends-on): Depend on nstrftime, not strftime.
Paul Eggert 30784c47 2017-04-22T02:11:26 parse-datetime: overflow and debug cleanups This long patch was triggered by this bug report from Ruediger Meier: http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00028.html I fixed the bug he noted, then found some others nearby, and then still others. Oh my goodness, there were a lot of bugs. I cleaned up some of the code to follow GNU standards while I was at it. * lib/parse-datetime.y (ISDIGIT): Remove; all callers changed to use c_isdigit. (EPOCH_YEAR): Remove; unused. (TM_YEAR_BASE): Now an enum rather than a macro. (HOUR, debug_strfdatetime): Multiply hour by 3600, not 60, to get time zone offset, since timezones now are in terms of seconds and not minutes. (long_time_t): Remove. All uses replaced by time_t or intmax_t as appropriate. Verify that intmax_t is wide enough. (time_overflow, time_zone_str): New functions, used to deal more reliably with overflow. (dbg_printf): Add printf attribute, to help catch integer width errors. (textint, relative_time, parser_control, time_zone_hhmm, set_hhmmss) (%union, to_hour, yylex, parse_datetime2): Use intmax_t instead of long int and/or long_time_t. All uses changed. (DBGBUFSIZE): Move earlier. (relative_time, set_hhmmss, parser_control): Just use int for nanoseconds and for time zones; that’s wide enough. (parser_control): Use bool for members like year_seen that can be booleans instead of counters. All uses changed. Remove debug_default_input_timezone; no longer needed. All uses removed. (apply_relative_time): Return a bool overflow flag. All uses changed to check for overflow. (apply_relative_time, zone, date, relunit, relunit_snumber) (signed_seconds, unsigned_seconds, yylex, parse_datetime2): Check for integer overflow portably. (str_days): Use just int for N, as it’s wide enough. Prefer 2D char arrays to arrays of char * when it looks like 2D is a win on typical platforms. Prefer snprintf to strncpy/strncat, for simplicity; all buffers are smaller than INT_MAX so this is safe. (TIME_ZONE_BUFSiZE, TM_YEAR_BUFSIZE): New constants. (debug_print_current_time): Don’t assume tv_nsec is of type long, as this is not true on x32. Output "." before any nanoseconds. (debug_print_current_time, parse_datetime2): Output local zones using a more-consistent format. (debug_print_current_time, date, parse_datetime2): (main) [TEST]: Don’t assume time_t is the same width as long. (print_rel_part): New function, replacing ... (PRINT_REL_PART): ... this macro, which was removed. All uses changed. (debug_print_relative_time): Use bool for boolean. (local_zone): dsts_seen now counts only tDST instances. (date): Fix printf of size_t to use %z. Do not assume numeric tokens have negative values merely because the context suggests a syntax with "-" separating tokens. (time_zone_hhmm): Return bool success indicator, which checks for overflow. Store result into PC->time_zone instead. All callers changed. (tm_year_str): New function. Return a bool success indicator and store the result into a buffer. All callers changed. Output the numerically correct string even if adding 1900 to the year would overflow. (to_tm_year): New function, replacing the old to_year. All callers changed. (tm_diff): Sync with glibc. (lookup_word): Use to_uchar instead of doing it by hand. (TZBUFSIZE): Now local to the only function that needs it. (debug_strfdatetime): Simplify now that time zones are int seconds. (debug_strfdate): Work even if tm_year + 1900 would overflow. (get_effective_timezone): Remove. All uses removed. (parse_datetime2): Use fprintf in pieces instead of snprintfing to a fixed-size buffer. Don’t assume that gmtime succeeds iff localtime succeeds. Use tm_gmtoff if available. Simplify how ‘goto fail;’ works in conjunction with the ‘ok’ flag. * m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don’t define TIME_T_FITS_IN_LONG_INT, as it is no longer needed. * modules/parse-datetime (Depends-on): Add inttypes.
Pádraig Brady 405cd675 2017-03-08T19:44:46 parse-datetime: remove extraneous generated source file * modules/parse-datetime: Remove the tmp generated source.
Paul Eggert 4e6e16b3 2017-01-20T17:11:55 parse-datetime: handle timezones reentrantly This API change was prompted by a report by Pádraig Brady in: https://bug.debian.org/851934#10 To help fix the bug, make parse_datetime2 more reentrant. * NEWS: Document this incompatible change. * lib/parse-datetime.h, lib/parse-datetime.y (parse_datetime2): Add two arguments, the timezone and the timezone name. All callers changed. If TZ="..." is specified, use it for calculating defaults. * lib/parse-datetime.y: Don't include xalloc.h or use xmalloc, as this code should be usable in a library. (mktime_ok, get_effective_timezone): Accept timezone arg too. All callers changed. (get_tz): Remove. (get_effective_timezone): Check for failures. * modules/parse-datetime: Add time_r, time_rz. Remove xalloc.
Pádraig Brady 440ea67a 2017-01-17T09:08:14 parse-datetime: fix dependence on AC_PROG_SED * modules/parse-datetime: Use `sed` directly like all other modules. Reported by J William Piggott
Pádraig Brady 73ecb533 2017-01-03T00:52:13 parse-datetime: fix generated paths for coverage files * modules/parse-datetime: Adjust the paths for parse-datetime.y within parse-datetime.c, so that gcc generates appropriate .gcno files, allowing lcov to proceed without error. Previously it would error trying to find "lib/lib/parse-datetime.y".
Assaf Gordon 5d36768c 2016-08-14T21:29:50 parse-datetime: improve debug implementation Follow-up to commit 12ad79069 ("add optional debug printing"). Improve parse-datetime's debug implementation: remove macros, replace global debug flag variable with a function parameter, use nstrftime for formatting. See: https://lists.gnu.org/archive/html/bug-gnulib/2016-08/msg00021.html * lib/parse-datetime.h: (parse_datetime_debug): Remove global extern declaration. (parse_datetime2): New function, accepts 'flags' parameter, supporting debug flag. Existing interface 'parse_datetime' left unmodified. * lib/parse-datetime.c: (parse_datetime_debug): Remove global variable. (struct parser_control): add 'parse_datetime_debug' member variable. (parse_datetime): Call new function 'parse_datetime2' without debug. (parse_datetime2): Adapted from previous 'parse_datetime', initialize pc.parse_datetime_debug variable as needed. (to_year): Accept new flags parameter, instead of using global variable. (debug_print_current_time,debug_print_relative_time,debug_mktime_not_ok): use struct 'debug' variable instead of global variable. (DEBUG,DEBUG_PRINT_CURRENT_TIME,DEBUG_PRINT_RELATIVE_TIME, DEBUG_MKTIME_NOT_OK,PROGRESS,PROGRESS0): Remove macros. Call correspnding functions directly instead of using macros. * modules/parse-datetime: Add gnulib's strftime module.
Assaf Gordon 12ad7906 2016-08-06T20:08:32 parse-datetime: add optional debug printing Print parsing information, warnings, and errors to stderr. * lib/parse-datetime.h (parse_datetimte_debug): New global variable. * lib/parse-datetime.y: (DEBUG_*): Macros calling debug functions if debugging is enabled. (PROGRESS*): Same as DEBUG, for progress reporting. (dbg_printf): Print message to stderr, with 'date' prefix. (struct parser_control): Add 'debug_*_seen' variables. (str_days): Converts day ordinal/number to string (e.g. 'last wed'). (debug_print_current_time, debug_print_relateive_time): Prints the current/relative date/time value of parser_control. (YACC parser syntax): Print parsed parts with DEBUG_* macros. (to_year): Warn about 2-digit year parsing. (yylex): Warn about unrecognized words. (get_effective_timezone): Returns current timezone in minutes. (debug_strf{time,date,datetime}): Convert 'struct tm' to string as clearly and unambigiously as possible. (debug_mktime_not_ok): Print detailed information about failed date/time values. (parse_datetime): Add DEBUG messages for failures, warnings. Add PROGRESS messages for status messages. * modules/parse-datetime: Add 'timegm', 'gettext-h' dependencies.
Giuseppe Scrivano 2cda6583 2015-11-24T10:00:31 parse-datetime: relax license to LGPLv2+, for OSTree * modules/parse-datetime (License): Change from GPL to LGPLv2+.
Eric Blake 2bb63bfb 2010-10-05T11:40:11 parse-datetime: better name than get_date * NEWS: Reword the deprecation notice. * modules/get_date: Rename to modules/parse-datetime. * modules/get_date-tests: Rename to modules/parse-datetime-tests. * m4/get_date.m4: Rename to m4/parse-datetime.m4. * lib/get_date.y: Rename to lib/parse-datetime.y. * tests/test-get_date.c: Rename to tests/test-parse-datetime.c. * doc/get_date.texi: Rename to doc/parse-datetime.texi. * doc/getdate.texi: Provide fallback wrapper. * lib/getdate.h: Move guts, and wrap... * lib/parse-datetime.h: ...new file. * lib/parse-datetime.y (get_date): Rename... (parse_datetime): ...to this. * m4/parse-datetime.m4 (gl_GET_DATE): Rename... (gl_PARSE_DATETIME): ...to this. * doc/posix-functions/getdate.texi (get_date): Provide fallback documentation. * modules/getdate (Files): Provide fallback docs and header. (Notice, Depends-on): Update references. * tests/test-parse-datetime.c: Likewise. * DEPENDENCIES: Likewise. * MODULES.html.sh (Date and time <time.h>): Likewise. * doc/parse-datetime.texi (Date input formats) (Authors of parse_datetime): Likewise. * modules/parse-datetime (Files, configure.ac, Makefile.am) (Include): Likewise. * modules/parse-datetime-tests (Files, Makefile.am): Likewise. * gnulib-tool: Likewise. * m4/bison.m4 (gl_BISON): Likewise. Suggested by Bruno Haible. Signed-off-by: Eric Blake <eblake@redhat.com>