summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/format.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-05-29 15:43:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-05-29 15:43:49 +0000
commit84e187eda30be43257c04bd27568a9f1a2d4bd44 (patch)
tree3ac5bd32776c70004704c1e8192b29546d6d5768 /usr.bin/tmux/format.c
parent5053aa89ecc12a668a028e67dbd619911d05e07f (diff)
Add m: for fnmatch(3) format matching.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r--usr.bin/tmux/format.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 407b36a67a6..fd20dfacfff 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.138 2017/05/12 22:43:15 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.139 2017/05/29 15:43:48 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -21,6 +21,7 @@
#include <ctype.h>
#include <errno.h>
+#include <fnmatch.h>
#include <libgen.h>
#include <netdb.h>
#include <stdarg.h>
@@ -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);