diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-25 22:13:42 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-30 14:34:34 +0200 |
commit | b97c2a09cffa9963fd0f5086e5da6031b1d48342 (patch) | |
tree | cc034e41ecca4268fb509f0039ecd46259bf5c59 | |
parent | f3858d899c9b29e38521e4eab46dcd97dc3fb57f (diff) | |
download | calcurse-b97c2a09cffa9963fd0f5086e5da6031b1d48342.zip |
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>
-rw-r--r-- | src/args.c | 4 | ||||
-rw-r--r-- | src/day.c | 19 |
2 files changed, 9 insertions, 14 deletions
@@ -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; } /* @@ -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) |