From bf78dff9137dd705bfd15319a2ce0318fc122852 Mon Sep 17 00:00:00 2001 From: MaliCopter Date: Sat, 10 Oct 2026 16:55:11 +0200 Subject: [PATCH 1/2] Rewrote Ruleregex patch for cleaner code --- dwm.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index ab3a84c..3ac731c 100644 --- a/dwm.c +++ b/dwm.c @@ -274,6 +274,21 @@ static Window root, wmcheckwin; struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; /* function implementations */ +int +applyregex(const char *name, const char *pattern) +{ + regex_t re; + int result; + + if (regcomp(&re, pattern, REG_EXTENDED) != 0) goto fail; + result = regexec(&re, name, 0, NULL, 0); + regfree(&re); + if (result == 0) return 1; + + fail: + return strstr(name, pattern) != NULL; +} + void applyrules(Client *c) { @@ -292,9 +307,9 @@ applyrules(Client *c) for (i = 0; i < LENGTH(rules); i++) { r = &rules[i]; - if ((!r->title || strstr(c->name, r->title)) - && (!r->class || strstr(class, r->class)) - && (!r->instance || strstr(instance, r->instance))) + if ((!r->title || applyregex(c->name, r->title)) + && (!r->class || applyregex(class, r->class)) + && (!r->instance || applyregex(instance, r->instance))) { c->isfloating = r->isfloating; c->tags |= r->tags; -- 2.55.0 From a83e54e545d4766dcc18c27be35e7689d9a9ca95 Mon Sep 17 00:00:00 2001 From: MaliCopter Date: Sun, 11 Oct 2026 13:54:15 +0200 Subject: [PATCH 2/2] dwm ruleregex (hopefully) final fix --- dwm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 3ac731c..aea3cc4 100644 --- a/dwm.c +++ b/dwm.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -280,13 +281,13 @@ applyregex(const char *name, const char *pattern) regex_t re; int result; - if (regcomp(&re, pattern, REG_EXTENDED) != 0) goto fail; + result = regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB); + if (result != 0) return strstr(name, pattern) != NULL; result = regexec(&re, name, 0, NULL, 0); regfree(&re); if (result == 0) return 1; - fail: - return strstr(name, pattern) != NULL; + return 0; } void -- 2.55.0