From 9ce586146825200c819662ea8dcb44cc03d2cd53 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 6 Aug 2014 09:26:46 +0200 Subject: Add pattern filter option This adds a new item filter option --filter-pattern and removes the whole -S parameter logic, while making -S an alias for --filter-pattern. Signed-off-by: Lukas Fleischer --- src/day.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'src/day.c') diff --git a/src/day.c b/src/day.c index bf97cec..2ff5050 100644 --- a/src/day.c +++ b/src/day.c @@ -218,7 +218,7 @@ void day_item_fork(struct day_item *day_in, struct day_item *day_out) * dedicated to the selected day. * Returns the number of events for the selected day. */ -static int day_store_events(long date, regex_t * regex) +static int day_store_events(long date) { llist_item_t *i; union aptev_ptr p; @@ -227,9 +227,6 @@ static int day_store_events(long date, regex_t * regex) LLIST_FIND_FOREACH_CONT(&eventlist, &date, event_inday, i) { struct event *ev = LLIST_TS_GET_DATA(i); - if (regex && regexec(regex, ev->mesg, 0, 0, 0) != 0) - continue; - p.ev = ev; day_add_item(EVNT, ev->day, p); e_nb++; @@ -245,7 +242,7 @@ static int day_store_events(long date, regex_t * regex) * dedicated to the selected day. * Returns the number of recurrent events for the selected day. */ -static int day_store_recur_events(long date, regex_t * regex) +static int day_store_recur_events(long date) { llist_item_t *i; union aptev_ptr p; @@ -254,9 +251,6 @@ static int day_store_recur_events(long date, regex_t * regex) LLIST_FIND_FOREACH(&recur_elist, &date, recur_event_inday, i) { struct recur_event *rev = LLIST_TS_GET_DATA(i); - if (regex && regexec(regex, rev->mesg, 0, 0, 0) != 0) - continue; - p.rev = rev; day_add_item(RECUR_EVNT, rev->day, p); e_nb++; @@ -272,7 +266,7 @@ static int day_store_recur_events(long date, regex_t * regex) * structure dedicated to the selected day. * Returns the number of appointments for the selected day. */ -static int day_store_apoints(long date, regex_t * regex) +static int day_store_apoints(long date) { llist_item_t *i; union aptev_ptr p; @@ -282,9 +276,6 @@ static int day_store_apoints(long date, regex_t * regex) LLIST_TS_FIND_FOREACH(&alist_p, &date, apoint_inday, i) { struct apoint *apt = LLIST_TS_GET_DATA(i); - if (regex && regexec(regex, apt->mesg, 0, 0, 0) != 0) - continue; - p.apt = apt; if (apt->start >= date + DAYINSEC) @@ -305,7 +296,7 @@ static int day_store_apoints(long date, regex_t * regex) * structure dedicated to the selected day. * Returns the number of recurrent appointments for the selected day. */ -static int day_store_recur_apoints(long date, regex_t * regex) +static int day_store_recur_apoints(long date) { llist_item_t *i; union aptev_ptr p; @@ -315,9 +306,6 @@ static int day_store_recur_apoints(long date, regex_t * regex) LLIST_TS_FIND_FOREACH(&recur_alist_p, &date, recur_apoint_inday, i) { struct recur_apoint *rapt = LLIST_TS_GET_DATA(i); - if (regex && regexec(regex, rapt->mesg, 0, 0, 0) != 0) - continue; - p.rapt = rapt; unsigned real_start; @@ -340,7 +328,7 @@ static int day_store_recur_apoints(long date, regex_t * regex) * The number of events and appointments in the current day are also updated. */ void -day_store_items(long date, regex_t * regex, int include_captions) +day_store_items(long date, int include_captions) { unsigned apts, events; union aptev_ptr p = { NULL }; @@ -351,10 +339,10 @@ day_store_items(long date, regex_t * regex, int include_captions) if (include_captions) day_add_item(DAY_HEADING, 0, p); - events = day_store_recur_events(date, regex); - events += day_store_events(date, regex); - apts = day_store_recur_apoints(date, regex); - apts += day_store_apoints(date, regex); + events = day_store_recur_events(date); + events += day_store_events(date); + apts = day_store_recur_apoints(date); + apts += day_store_apoints(date); if (include_captions && events > 0 && apts > 0) day_add_item(DAY_SEPARATOR, 0, p); @@ -385,7 +373,7 @@ void day_process_storage(struct date *slctd_date, unsigned day_changed) delwin(apad.ptrwin); /* Store the events and appointments (recursive and normal items). */ - day_store_items(date, NULL, 1); + day_store_items(date, 1); } /* -- cgit v1.2.3-54-g00ecf