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>
This commit is contained in:
committed by
Lukas Fleischer
parent
ce81c0fa63
commit
bf3dba2ae2
23
src/io.c
23
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__);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user