commit 1927f056fabfa553dfb81630e017b8be6f02f477
parent ad8780c9e6a9535dbd8292b9995b39b5331cb3d1
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Fri, 16 Jul 2021 21:50:00 -0700
Add pattern negation
You may now prefix patterns with '!' to invert the match. You may
escape it with '\'.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/aps/match.c b/aps/match.c
@@ -21,6 +21,10 @@
int
match(char *s, char *pattern)
{
+ if (pattern[0] == '!')
+ return fnmatch(pattern + 1, s, 0) != 0;
+ if (pattern[0] == '\\' && pattern[1] != '\\')
+ ++pattern;
return fnmatch(pattern, s, 0) == 0;
}