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/apoint.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/apoint.c')
-rw-r--r-- | src/apoint.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/apoint.c b/src/apoint.c index 77ff8a0..4cb77f6 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -195,7 +195,7 @@ void apoint_write(struct apoint *o, FILE * f) mem_free(str); } -struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, +char *apoint_scan(FILE * f, struct tm start, struct tm end, char state, char *note, struct item_filter *filter) { char buf[BUFSIZ], *newline; @@ -203,15 +203,15 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, struct apoint *apt = NULL; int cond; - EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) || - !check_date(end.tm_year, end.tm_mon, end.tm_mday) || - !check_time(start.tm_hour, start.tm_min) || - !check_time(end.tm_hour, end.tm_min), - _("date error in appointment")); + if (!check_date(start.tm_year, start.tm_mon, start.tm_mday) || + !check_date(end.tm_year, end.tm_mon, end.tm_mday) || + !check_time(start.tm_hour, start.tm_min) || + !check_time(end.tm_hour, end.tm_min)) + return _("illegal date in appointment"); /* Read the appointment description */ if (!fgets(buf, sizeof buf, f)) - return NULL; + return _("error in appointment description"); newline = strchr(buf, '\n'); if (newline) @@ -226,8 +226,8 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, tstart = mktime(&start); tend = mktime(&end); - EXIT_IF(tstart == -1 || tend == -1 || tstart > tend, - _("date error in appointment")); + if (tstart == -1 || tend == -1 || tstart > tend) + return _("date error in appointment"); /* Filter item. */ if (filter) { @@ -255,8 +255,7 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, } if (!apt) apt = apoint_new(buf, note, tstart, tend - tstart, state); - - return apt; + return NULL; } void apoint_delete(struct apoint *apt) |