day_store_items(): Return the number of items found
Return the total number of items found instead of the pad length, since this is used to store items in non-interactive mode as well now. The pad length can still be calculated by using the appointment and event count parameters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
f3858d899c
commit
b97c2a09cf
@ -295,14 +295,14 @@ app_arg(int add_line, struct date *day, long date, const char *fmt_apt,
|
|||||||
|
|
||||||
int n = day_store_items(date, NULL, NULL, regex);
|
int n = day_store_items(date, NULL, NULL, regex);
|
||||||
|
|
||||||
if (n > 1) {
|
if (n > 0) {
|
||||||
if (add_line)
|
if (add_line)
|
||||||
fputs("\n", stdout);
|
fputs("\n", stdout);
|
||||||
arg_print_date(date);
|
arg_print_date(date);
|
||||||
day_write_stdout(date, fmt_apt, fmt_rapt, fmt_ev, fmt_rev);
|
day_write_stdout(date, fmt_apt, fmt_rapt, fmt_ev, fmt_rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return n - 1;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
23
src/day.c
23
src/day.c
@ -283,28 +283,23 @@ int
|
|||||||
day_store_items(long date, unsigned *pnb_events, unsigned *pnb_apoints,
|
day_store_items(long date, unsigned *pnb_events, unsigned *pnb_apoints,
|
||||||
regex_t *regex)
|
regex_t *regex)
|
||||||
{
|
{
|
||||||
int pad_length;
|
|
||||||
int nb_events, nb_recur_events;
|
int nb_events, nb_recur_events;
|
||||||
int nb_apoints, nb_recur_apoints;
|
int nb_apoints, nb_recur_apoints;
|
||||||
|
|
||||||
day_free_list();
|
day_free_list();
|
||||||
day_init_list();
|
day_init_list();
|
||||||
|
|
||||||
nb_recur_events = day_store_recur_events(date, regex);
|
nb_recur_events = day_store_recur_events(date, regex);
|
||||||
nb_events = day_store_events(date, regex);
|
nb_events = day_store_events(date, regex);
|
||||||
if (pnb_events)
|
|
||||||
*pnb_events = nb_events;
|
|
||||||
nb_recur_apoints = day_store_recur_apoints(date, regex);
|
nb_recur_apoints = day_store_recur_apoints(date, regex);
|
||||||
nb_apoints = day_store_apoints(date, regex);
|
nb_apoints = day_store_apoints(date, regex);
|
||||||
if (pnb_apoints)
|
|
||||||
*pnb_apoints = nb_apoints;
|
|
||||||
pad_length = (nb_recur_events + nb_events + 1 +
|
|
||||||
3 * (nb_recur_apoints + nb_apoints));
|
|
||||||
if (pnb_apoints)
|
|
||||||
*pnb_apoints += nb_recur_apoints;
|
|
||||||
if (pnb_events)
|
|
||||||
*pnb_events += nb_recur_events;
|
|
||||||
|
|
||||||
return pad_length;
|
if (pnb_apoints)
|
||||||
|
*pnb_apoints = nb_apoints + nb_recur_apoints;
|
||||||
|
if (pnb_events)
|
||||||
|
*pnb_events = nb_events + nb_recur_events;
|
||||||
|
|
||||||
|
return nb_events + nb_recur_events + nb_apoints + nb_recur_apoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -331,8 +326,8 @@ struct day_items_nb *day_process_storage(struct date *slctd_date,
|
|||||||
delwin(apad.ptrwin);
|
delwin(apad.ptrwin);
|
||||||
|
|
||||||
/* Store the events and appointments (recursive and normal items). */
|
/* Store the events and appointments (recursive and normal items). */
|
||||||
apad.length = day_store_items(date, &inday->nb_events, &inday->nb_apoints,
|
day_store_items(date, &inday->nb_events, &inday->nb_apoints, NULL);
|
||||||
NULL);
|
apad.length = (inday->nb_events + 1 + 3 * inday->nb_apoints);
|
||||||
|
|
||||||
/* Create the new pad with its new length. */
|
/* Create the new pad with its new length. */
|
||||||
if (day_changed)
|
if (day_changed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user