From 3827d74a9e89ff22654b4c0fb895fe2d33fc9209 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 28 Apr 2021 18:02:20 -0400 Subject: Match multiple types with -t --- scoop.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scoop.c') diff --git a/scoop.c b/scoop.c index 6c2957b..f1c0ed2 100644 --- a/scoop.c +++ b/scoop.c @@ -344,6 +344,14 @@ static enum Type parseType(const char *input) { errx(EX_USAGE, "no such type %s", input); } +static int parseTypes(char *list) { + int mask = 0; + while (list) { + mask |= 1 << parseType(strsep(&list, ",")); + } + return mask; +} + int main(int argc, char *argv[]) { bool tty = isatty(STDOUT_FILENO); @@ -466,8 +474,8 @@ int main(int argc, char *argv[]) { sort = true; } break; case 't': { - append(where, SQL(AND events.type = :type)); - binds[n++] = Bind(":type", NULL, parseType(optarg)); + append(where, SQL(AND (1 << events.type) & :types)); + binds[n++] = Bind(":types", NULL, parseTypes(optarg)); } break; case 'u': { append(where, SQL(AND names.user = :user)); -- cgit 1.4.1 ref='/aoc/tree/2020/day06.c?id=225daece7f6724ac741e4b3856995b52f0c01535'>tree commit diff homepage
path: root/2020/day06.c (unfollow)
Commit message (Expand)Author
2020-12-06Solve day 6 part 2June McEnroe