From 8ead9337d1b010913df304565540db2578e7a566 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Mon, 29 Apr 2024 19:27:45 +0200 Subject: [PATCH] Enable extended pattern matching So that the exclude options can also work as include using special pattern syntax. For example, to only include /dev/ttyUSB* devices simply do: $ tio --exclude-devices=!(/dev/ttyUSB*) --list See the man page of fnmatch() for all available extended pattern options. --- src/misc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/misc.c b/src/misc.c index 1d1acea..082488a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -19,6 +19,7 @@ * 02110-1301, USA. */ +#define _GNU_SOURCE // For FNM_EXTMATCH #include "config.h" #include #include @@ -197,7 +198,7 @@ bool match_patterns(const char *string, const char *patterns) while (pattern != NULL) { // Check if the string matches the current pattern - if (fnmatch(pattern, string, 0) == 0) + if (fnmatch(pattern, string, FNM_EXTMATCH) == 0) { free(patterns_copy); return true;