summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/args.c3
-rw-r--r--src/calcurse.h3
-rw-r--r--src/recur.c39
3 files changed, 18 insertions, 27 deletions
diff --git a/src/args.c b/src/args.c
index 52496cd..8443454 100644
--- a/src/args.c
+++ b/src/args.c
@@ -231,8 +231,7 @@ static void next_arg(void)
next_app.got_app = 0;
next_app.txt = NULL;
- next_app = *recur_apoint_check_next(&next_app, current_time,
- get_today());
+ recur_apoint_check_next(&next_app, current_time, get_today());
next_app = *apoint_check_next(&next_app, current_time);
if (next_app.got_app) {
diff --git a/src/calcurse.h b/src/calcurse.h
index a026896..4e92808 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -1049,8 +1049,7 @@ void recur_apoint_add_exc(struct recur_apoint *, long);
void recur_event_erase(struct recur_event *);
void recur_apoint_erase(struct recur_apoint *);
void recur_exc_scan(llist_t *, FILE *);
-struct notify_app *recur_apoint_check_next(struct notify_app *, long,
- long);
+void recur_apoint_check_next(struct notify_app *, time_t, time_t);
void recur_apoint_switch_notify(struct recur_apoint *);
void recur_event_paste_item(struct recur_event *, long);
void recur_apoint_paste_item(struct recur_apoint *, long);
diff --git a/src/recur.c b/src/recur.c
index e481c08..31f84ae 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -922,36 +922,31 @@ void recur_exc_scan(llist_t * lexc, FILE * data_file)
}
}
-static int recur_apoint_starts_before(struct recur_apoint *rapt, long *time)
-{
- return rapt->start < *time;
-}
-
/*
- * Look in the appointment list if we have an item which starts before the item
- * stored in the notify_app structure (which is the next item to be notified).
+ * Look in the appointment list if we have an item which starts after start and
+ * before the item stored in the notify_app structure (which is the next item
+ * to be notified). Note, the search may change the notify_app structure.
*/
-struct notify_app *recur_apoint_check_next(struct notify_app *app,
- long start, long day)
+void recur_apoint_check_next(struct notify_app *app, time_t start, time_t day)
{
llist_item_t *i;
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) {
+ LLIST_TS_FOREACH(&recur_alist_p, i) {
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
- /*
- * Check whether the recurrent appointment contains an
- * occurrence which is the next item to be notified.
- */
+ /* Tomorrow? */
+ if (recur_apoint_find_occurrence
+ (rapt, day + DAYINSEC, &real_recur_start_time)
+ && real_recur_start_time > start
+ && real_recur_start_time < app->time) {
+ app->time = real_recur_start_time;
+ app->txt = mem_strdup(rapt->mesg);
+ app->state = rapt->state;
+ app->got_app = 1;
+ }
+ /* Today? */
if (recur_apoint_find_occurrence
(rapt, day, &real_recur_start_time)
&& real_recur_start_time > start
@@ -963,8 +958,6 @@ struct notify_app *recur_apoint_check_next(struct notify_app *app,
}
}
LLIST_TS_UNLOCK(&recur_alist_p);
-
- return app;
}
/* Switch recurrent item notification state. */