diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-01 11:45:48 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-09-01 11:45:48 +1000 |
commit | 7e81e58e7d1f540e448f3827751f75bf54b1fe9f (patch) | |
tree | 924c61d27afcd3120f99137662d8f83a39769d1e /common | |
parent | Fix crash on reload (diff) | |
download | sway-7e81e58e7d1f540e448f3827751f75bf54b1fe9f.tar.gz sway-7e81e58e7d1f540e448f3827751f75bf54b1fe9f.tar.zst sway-7e81e58e7d1f540e448f3827751f75bf54b1fe9f.zip |
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.c | 14 |
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) { | |||
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 | } | ||