diff options
author | Assaf Gordon <assafgordon@gmail.com> | 2016-08-14 21:29:50 -0400 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-08-19 21:43:13 +0100 |
commit | 5d36768ce2b907af7861d9eb87ae0fc89330def1 (patch) | |
tree | 347e490790738218981be695645be50b93aca12b /lib/parse-datetime.h | |
parent | 6e2966216e4e0605508c5f5abd27c8dc44ff6b73 (diff) | |
download | gnulib-5d36768ce2b907af7861d9eb87ae0fc89330def1.tar.gz |
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.
Diffstat (limited to 'lib/parse-datetime.h')
-rw-r--r-- | lib/parse-datetime.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/parse-datetime.h b/lib/parse-datetime.h index b849db3944..1c8d310c2b 100644 --- a/lib/parse-datetime.h +++ b/lib/parse-datetime.h @@ -19,6 +19,11 @@ #include <stdbool.h> #include <time.h> -extern bool parse_datetime_debug; - bool parse_datetime (struct timespec *, char const *, struct timespec const *); + +/* parse_datetime2 flag: if set, print debug/progress information to STDERR */ +#define PARSE_DATETIME_DEBUG 1 + +/* same as above, supporting additional flags */ +bool parse_datetime2 (struct timespec *, char const *, struct timespec const *, + unsigned int flags); |