summaryrefslogtreecommitdiff
path: root/src/recur.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-11 22:26:46 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-13 17:39:44 +0100
commit7f8c62bf57b85234c248316505a503602792839a (patch)
treeef8ff6e778840192ee7cfb6c06579602ed6942cb /src/recur.c
parentdd85a7374675c3f91e215c2e318b2c5045a01f53 (diff)
downloadcalcurse-7f8c62bf57b85234c248316505a503602792839a.zip
Add an option to filter by object hash
Implement a new --filter-hash option to filter by object identifiers. Each object having an identifier that has the specified pattern as a prefix is matched. Patterns starting with an exclamation mark (!) are interpreted as negative patterns. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/recur.c')
-rw-r--r--src/recur.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/recur.c b/src/recur.c
index ddfddb4..921b5c9 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -336,6 +336,7 @@ struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start,
{
char buf[BUFSIZ], *nl;
time_t tstart, tend, tuntil;
+ struct recur_apoint *rapt;
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
!check_date(end.tm_year, end.tm_mon, end.tm_mday) ||
@@ -393,8 +394,20 @@ struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start,
return NULL;
}
- return recur_apoint_new(buf, note, tstart, tend - tstart, state,
+ rapt = recur_apoint_new(buf, note, tstart, tend - tstart, state,
recur_char2def(type), freq, tuntil, exc);
+
+ /* Filter by hash. */
+ if (filter && filter->hash) {
+ char *hash = recur_apoint_hash(rapt);
+ if (!hash_matches(filter->hash, hash)) {
+ recur_apoint_erase(rapt);
+ rapt = NULL;
+ }
+ mem_free(hash);
+ }
+
+ return rapt;
}
/* Load the recursive events from file */
@@ -405,6 +418,7 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
{
char buf[BUFSIZ], *nl;
time_t tstart, tend, tuntil;
+ struct recur_event *rev;
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
!check_time(start.tm_hour, start.tm_min) ||
@@ -453,8 +467,20 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
return NULL;
}
- return recur_event_new(buf, note, tstart, id, recur_char2def(type),
- freq, tuntil, exc);
+ rev = recur_event_new(buf, note, tstart, id, recur_char2def(type),
+ freq, tuntil, exc);
+
+ /* Filter by hash. */
+ if (filter && filter->hash) {
+ char *hash = recur_event_hash(rev);
+ if (!hash_matches(filter->hash, hash)) {
+ recur_event_erase(rev);
+ rev = NULL;
+ }
+ mem_free(hash);
+ }
+
+ return rev;
}
char *recur_apoint_tostr(struct recur_apoint *o)