From 2084f353e3d224bbc21148f25ab2f2539892d386 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 9 Feb 2017 08:32:29 +0100 Subject: Fix notification of recurrent appointments The recur_apoint_starts_before() filter function expected the second parameter to be passed by value, whereas its only caller passed the value by reference. For consistency with apoint_starts_after(), change the signature and the implementation of recur_apoint_starts_before() such that the parameter is passed by reference. Also, add a comment to the only caller of recur_apoint_starts_before() to clarify on why recur_apoint_starts_before() is used. Fixes GitHub issue #25. Signed-off-by: Lukas Fleischer --- src/recur.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/recur.c b/src/recur.c index 7f253f0..95a45ca 100644 --- a/src/recur.c +++ b/src/recur.c @@ -917,9 +917,9 @@ void recur_exc_scan(llist_t * lexc, FILE * data_file) } } -static int recur_apoint_starts_before(struct recur_apoint *rapt, long time) +static int recur_apoint_starts_before(struct recur_apoint *rapt, long *time) { - return rapt->start < time; + return rapt->start < *time; } /* @@ -933,6 +933,12 @@ struct notify_app *recur_apoint_check_next(struct notify_app *app, time_t real_recur_start_time; LLIST_TS_LOCK(&recur_alist_p); + /* + * Iterate over all recurrent items starting before the current "next" + * appointment. We cannot filter by start time because a recurrent item + * can actually start (several days) before the current "next" item and + * still have an occurrence which is the next item to be notified. + */ LLIST_TS_FIND_FOREACH(&recur_alist_p, &app->time, recur_apoint_starts_before, i) { struct recur_apoint *rapt = LLIST_TS_GET_DATA(i); -- cgit v1.2.3-70-g09d2