aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-09-01 11:45:48 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-09-01 11:45:48 +1000
commit7e81e58e7d1f540e448f3827751f75bf54b1fe9f (patch)
tree924c61d27afcd3120f99137662d8f83a39769d1e /common
parentebe65a4d481341d38b99e8fb36e66832888bc085 (diff)
Allow reload command to exist anywhere in the command string
This fixes a crash if you have commands where reload appears in the middle or at the end, such as `bindsym r mode default, reload`.
Diffstat (limited to 'common')
-rw-r--r--common/stringop.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/stringop.c b/common/stringop.c
index d9ae9925..d2c91c24 100644
--- a/common/stringop.c
+++ b/common/stringop.c
@@ -401,3 +401,17 @@ char *argsep(char **stringp, const char *delim) {
found:
return start;
}
+
+const char *strcasestr(const char *haystack, const char *needle) {
+ size_t needle_len = strlen(needle);
+ const char *pos = haystack;
+ const char *end = pos + strlen(haystack) - needle_len;
+
+ while (pos <= end) {
+ if (strncasecmp(pos, needle, needle_len) == 0) {
+ return pos;
+ }
+ ++pos;
+ }
+ return NULL;
+}