diff options
-rw-r--r-- | common/stringop.c | 14 | ||||
-rw-r--r-- | include/stringop.h | 2 | ||||
-rw-r--r-- | sway/commands/bind.c | 2 |
3 files changed, 17 insertions, 1 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) { | |||
401 | found: | 401 | found: |
402 | return start; | 402 | return start; |
403 | } | 403 | } |
404 | |||
405 | const char *strcasestr(const char *haystack, const char *needle) { | ||
406 | size_t needle_len = strlen(needle); | ||
407 | const char *pos = haystack; | ||
408 | const char *end = pos + strlen(haystack) - needle_len; | ||
409 | |||
410 | while (pos <= end) { | ||
411 | if (strncasecmp(pos, needle, needle_len) == 0) { | ||
412 | return pos; | ||
413 | } | ||
414 | ++pos; | ||
415 | } | ||
416 | return NULL; | ||
417 | } | ||
diff --git a/include/stringop.h b/include/stringop.h index e7f58011..01bbdaa9 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -46,4 +46,6 @@ char *cmdsep(char **stringp, const char *delim); | |||
46 | // Split string into 2 by delim, handle quotes | 46 | // Split string into 2 by delim, handle quotes |
47 | char *argsep(char **stringp, const char *delim); | 47 | char *argsep(char **stringp, const char *delim); |
48 | 48 | ||
49 | const char *strcasestr(const char *haystack, const char *needle); | ||
50 | |||
49 | #endif | 51 | #endif |
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index e73b0aea..b134c92f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -310,7 +310,7 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) | |||
310 | bool reload = false; | 310 | bool reload = false; |
311 | // if this is a reload command we need to make a duplicate of the | 311 | // if this is a reload command we need to make a duplicate of the |
312 | // binding since it will be gone after the reload has completed. | 312 | // binding since it will be gone after the reload has completed. |
313 | if (strncasecmp(binding->command, "reload", 6) == 0) { | 313 | if (strcasestr(binding->command, "reload")) { |
314 | reload = true; | 314 | reload = true; |
315 | binding_copy = sway_binding_dup(binding); | 315 | binding_copy = sway_binding_dup(binding); |
316 | if (!binding_copy) { | 316 | if (!binding_copy) { |