diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2019-12-08 09:16:24 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-04-28 07:32:44 -0400 |
commit | bf3dba2ae2b3c1f0e06191b6878dc7f22570f8f6 (patch) | |
tree | 1a5c183b753861cf3e3fb37ba181787f3da3da3f /src/event.c | |
parent | ce81c0fa6362f0092f40eab1cddf0a6339c473c5 (diff) | |
download | calcurse-bf3dba2ae2b3c1f0e06191b6878dc7f22570f8f6.tar.gz calcurse-bf3dba2ae2b3c1f0e06191b6878dc7f22570f8f6.zip |
Improve data load error reporting
The last part of loading appointments and events is performed by four
"scan" functions called from io_load_app(). Failure in this part of data
load does not use io_load_error().
The four "scan" functions are changed to return an error message on
failure and NULL otherwise (the previous return value was not used).
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/event.c')
-rw-r--r-- | src/event.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/event.c b/src/event.c index 375dd66..e0da4c1 100644 --- a/src/event.c +++ b/src/event.c @@ -149,7 +149,7 @@ void event_write(struct event *o, FILE * f) } /* Load the events from file */ -struct event *event_scan(FILE * f, struct tm start, int id, char *note, +char *event_scan(FILE * f, struct tm start, int id, char *note, struct item_filter *filter) { char buf[BUFSIZ], *nl; @@ -157,13 +157,13 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note, struct event *ev = NULL; int cond; - EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) || - !check_time(start.tm_hour, start.tm_min), - _("date error in event")); + if (!check_date(start.tm_year, start.tm_mon, start.tm_mday) || + !check_time(start.tm_hour, start.tm_min)) + return _("illegal date in event"); /* Read the event description */ if (!fgets(buf, sizeof buf, f)) - return NULL; + return _("error in appointment description"); nl = strchr(buf, '\n'); if (nl) { @@ -177,8 +177,9 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note, start.tm_mon--; tstart = mktime(&start); - EXIT_IF(tstart == -1, _("date error in the event\n")); - tend = tstart + DAYINSEC - 1; + if (tstart == -1) + return _("date error in event\n"); + tend = ENDOFDAY(tstart); /* Filter item. */ if (filter) { @@ -205,8 +206,7 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note, } if (!ev) ev = event_new(buf, note, tstart, id); - - return ev; + return NULL; } /* Delete an event from the list. */ |