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 <baptiste@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-03-30 21:34:53 +02:00
parent d31cda5424
commit 516a793375

View File

@ -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);