From 12575014995582b30165d80efa1096eee7622a81 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 29 May 2017 15:43:48 +0000 Subject: Add m: for fnmatch(3) format matching. --- format.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'format.c') diff --git a/format.c b/format.c index a0c654fb..24836b0b 100644 --- a/format.c +++ b/format.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -868,6 +869,12 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, /* Is there a length limit or whatnot? */ switch (copy[0]) { + case 'm': + if (copy[1] != ':') + break; + compare = -2; + copy += 2; + break; case '!': if (copy[1] == '=' && copy[2] == ':') { compare = -1; @@ -943,6 +950,8 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen, value = xstrdup("1"); else if (compare == -1 && strcmp(left, right) != 0) value = xstrdup("1"); + else if (compare == -2 && fnmatch(left, right, 0) == 0) + value = xstrdup("1"); else value = xstrdup("0"); free(right); -- cgit