From bf3dba2ae2b3c1f0e06191b6878dc7f22570f8f6 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Sun, 8 Dec 2019 09:16:24 +0100 Subject: 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 --- src/io.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/io.c') diff --git a/src/io.c b/src/io.c index 725b31b..b9c2d3b 100644 --- a/src/io.c +++ b/src/io.c @@ -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__); } -- cgit v1.2.3-54-g00ecf