From b97c2a09cffa9963fd0f5086e5da6031b1d48342 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 25 Jun 2012 22:13:42 +0200 Subject: 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 --- src/args.c | 4 ++-- src/day.c | 19 +++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/args.c b/src/args.c index e375fd7..2a286dd 100644 --- a/src/args.c +++ b/src/args.c @@ -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); - if (n > 1) { + if (n > 0) { if (add_line) fputs("\n", stdout); arg_print_date(date); day_write_stdout(date, fmt_apt, fmt_rapt, fmt_ev, fmt_rev); } - return n - 1; + return n; } /* diff --git a/src/day.c b/src/day.c index fb3a9e7..23aa757 100644 --- a/src/day.c +++ b/src/day.c @@ -283,28 +283,23 @@ int day_store_items(long date, unsigned *pnb_events, unsigned *pnb_apoints, regex_t *regex) { - int pad_length; int nb_events, nb_recur_events; int nb_apoints, nb_recur_apoints; day_free_list(); day_init_list(); + nb_recur_events = day_store_recur_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_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; + *pnb_apoints = nb_apoints + nb_recur_apoints; if (pnb_events) - *pnb_events += nb_recur_events; + *pnb_events = nb_events + nb_recur_events; - return pad_length; + 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); /* Store the events and appointments (recursive and normal items). */ - apad.length = day_store_items(date, &inday->nb_events, &inday->nb_apoints, - NULL); + day_store_items(date, &inday->nb_events, &inday->nb_apoints, NULL); + apad.length = (inday->nb_events + 1 + 3 * inday->nb_apoints); /* Create the new pad with its new length. */ if (day_changed) -- cgit v1.2.3