From 516a793375424ea2bbdc891bf0c917a8f7b388a1 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 30 Mar 2012 21:34:53 +0200 Subject: Do not use LLIST_*_CONT for appointments This no longer works since we allow appointments lasting longer than 24 hours. This means that there might be an appointment that starts after another one and lasts until the selected day, even though the former doesn't. A simple example, where the old LLIST_TS_FOREACH_CONT approach fails, is: 03/29/2012 @ 19:00 -> 03/30/2012 @ 10:00 |Long event 03/29/2012 @ 21:00 -> 03/29/2012 @ 23:15 |Event 1 (shown) 03/30/2012 @ 14:00 -> 03/30/2012 @ 15:00 |Event 2 (not shown) Instead, allow incoherent appointments and only break if the current appointment *starts after* the selected day. Reported-by: Baptiste Jonglez Signed-off-by: Lukas Fleischer --- src/day.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/day.c b/src/day.c index 3748b7c..009df47 100644 --- a/src/day.c +++ b/src/day.c @@ -195,9 +195,13 @@ day_store_apoints (long date) int a_nb = 0; LLIST_TS_LOCK (&alist_p); - LLIST_TS_FIND_FOREACH_CONT (&alist_p, date, apoint_inday, i) + LLIST_TS_FIND_FOREACH (&alist_p, date, apoint_inday, i) { struct apoint *apt = LLIST_TS_GET_DATA (i); + + if (apt->start >= date + DAYINSEC) + break; + day_add_apoint (APPT, apt->mesg, apt->note, apt->start, apt->dur, apt->state, 0); a_nb++; @@ -547,12 +551,15 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices) LLIST_TS_UNLOCK (&recur_alist_p); LLIST_TS_LOCK (&alist_p); - LLIST_TS_FIND_FOREACH_CONT (&alist_p, date, apoint_inday, i) + LLIST_TS_FIND_FOREACH (&alist_p, date, apoint_inday, i) { struct apoint *apt = LLIST_TS_GET_DATA (i); long start = get_item_time (apt->start); long end = get_item_time (apt->start + apt->dur); + if (apt->start >= date + DAYINSEC) + break; + if (!fill_slices (slices, slicesno, SLICENUM (start), SLICENUM (end))) { LLIST_TS_UNLOCK (&alist_p); -- cgit v1.2.3-54-g00ecf