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/io.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/io.c')
-rw-r--r-- | src/io.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -559,6 +559,7 @@ void io_load_app(struct item_filter *filter) char type, state = 0L; char note[MAX_NOTESIZ + 1], *notep; unsigned line = 0; + char *scan_error; t = time(NULL); localtime_r(&t, <); @@ -573,6 +574,8 @@ void io_load_app(struct item_filter *filter) for (;;) { is_appointment = is_event = is_recursive = 0; line++; + scan_error = NULL; + c = getc(data_file); if (c == EOF) break; @@ -691,26 +694,26 @@ void io_load_app(struct item_filter *filter) io_load_error(path_apts, line, _("syntax error in item state")); - if (is_recursive) { - recur_apoint_scan(data_file, start, end, state, + if (is_recursive) + scan_error = recur_apoint_scan(data_file, start, end, state, notep, filter, &rpt); - } else { - apoint_scan(data_file, start, end, state, + else + scan_error = apoint_scan(data_file, start, end, state, notep, filter); - } } else if (is_event) { ungetc(c, data_file); - if (is_recursive) { - recur_event_scan(data_file, start, id, notep, + if (is_recursive) + scan_error = recur_event_scan(data_file, start, id, notep, filter, &rpt); - } else { - event_scan(data_file, start, id, notep, filter); - } + else + scan_error = event_scan(data_file, start, id, notep, filter); } else { io_load_error(path_apts, line, _("wrong format in the appointment or event")); /* NOTREACHED */ } + if (scan_error) + io_load_error(path_apts, line, scan_error); } file_close(data_file, __FILE_POS__); } |