CLI: filter options have no effect for dates before the epoch

With the exception of filter.type_mask, a filter is only applied if set
explicitly on the command line with a filter option. Whether that is the
case, is determined by comparison with the initialization value. For
date related filters (start_from/to, end_from/to) that is -1, hence the
criterion is != -1, not >= 0.

In generel, a filter initialization value should be invalid (i.e. one
that cannot be set explicitly). As times before the epoch (1 January
1970 00:00:00 UTC) are negative, -1 is a valid Unix time. However, as it
cannot be set from the command line, it is probably no problem?

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lars Henriksen 2018-11-18 18:32:11 +01:00 committed by Lukas Fleischer
parent 4ba2cc46d7
commit 7851f46fbb
3 changed files with 16 additions and 16 deletions

View File

@ -234,13 +234,13 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end,
return NULL; return NULL;
if (filter->regex && regexec(filter->regex, buf, 0, 0, 0)) if (filter->regex && regexec(filter->regex, buf, 0, 0, 0))
return NULL; return NULL;
if (filter->start_from >= 0 && tstart < filter->start_from) if (filter->start_from != -1 && tstart < filter->start_from)
return NULL; return NULL;
if (filter->start_to >= 0 && tstart > filter->start_to) if (filter->start_to != -1 && tstart > filter->start_to)
return NULL; return NULL;
if (filter->end_from >= 0 && tend < filter->end_from) if (filter->end_from != -1 && tend < filter->end_from)
return NULL; return NULL;
if (filter->end_to >= 0 && tend > filter->end_to) if (filter->end_to != -1 && tend > filter->end_to)
return NULL; return NULL;
} }

View File

@ -183,13 +183,13 @@ struct event *event_scan(FILE * f, struct tm start, int id, char *note,
return NULL; return NULL;
if (filter->regex && regexec(filter->regex, buf, 0, 0, 0)) if (filter->regex && regexec(filter->regex, buf, 0, 0, 0))
return NULL; return NULL;
if (filter->start_from >= 0 && tstart < filter->start_from) if (filter->start_from != -1 && tstart < filter->start_from)
return NULL; return NULL;
if (filter->start_to >= 0 && tstart > filter->start_to) if (filter->start_to != -1 && tstart > filter->start_to)
return NULL; return NULL;
if (filter->end_from >= 0 && tend < filter->end_from) if (filter->end_from != -1 && tend < filter->end_from)
return NULL; return NULL;
if (filter->end_to >= 0 && tend > filter->end_to) if (filter->end_to != -1 && tend > filter->end_to)
return NULL; return NULL;
} }

View File

@ -397,13 +397,13 @@ struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start,
return NULL; return NULL;
if (filter->regex && regexec(filter->regex, buf, 0, 0, 0)) if (filter->regex && regexec(filter->regex, buf, 0, 0, 0))
return NULL; return NULL;
if (filter->start_from >= 0 && tstart < filter->start_from) if (filter->start_from != -1 && tstart < filter->start_from)
return NULL; return NULL;
if (filter->start_to >= 0 && tstart > filter->start_to) if (filter->start_to != -1 && tstart > filter->start_to)
return NULL; return NULL;
if (filter->end_from >= 0 && tend < filter->end_from) if (filter->end_from != -1 && tend < filter->end_from)
return NULL; return NULL;
if (filter->end_to >= 0 && tend > filter->end_to) if (filter->end_to != -1 && tend > filter->end_to)
return NULL; return NULL;
} }
@ -470,13 +470,13 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
return NULL; return NULL;
if (filter->regex && regexec(filter->regex, buf, 0, 0, 0)) if (filter->regex && regexec(filter->regex, buf, 0, 0, 0))
return NULL; return NULL;
if (filter->start_from >= 0 && tstart < filter->start_from) if (filter->start_from != -1 && tstart < filter->start_from)
return NULL; return NULL;
if (filter->start_to >= 0 && tstart > filter->start_to) if (filter->start_to != -1 && tstart > filter->start_to)
return NULL; return NULL;
if (filter->end_from >= 0 && tend < filter->end_from) if (filter->end_from != -1 && tend < filter->end_from)
return NULL; return NULL;
if (filter->end_to >= 0 && tend > filter->end_to) if (filter->end_to != -1 && tend > filter->end_to)
return NULL; return NULL;
} }