diff options
author | Dave Davenport <qball@blame.services> | 2022-10-03 16:58:45 +0200 |
---|---|---|
committer | Dave Davenport <qball@blame.services> | 2022-10-03 16:58:45 +0200 |
commit | 35d066efe245fe188fadd7ea59f04551b004c726 (patch) | |
tree | b81ffd40b7614bef55827b8f589fb2a3417fe726 | |
parent | 5a979b0afe868d3489013619a22394af96298509 (diff) |
[Script] Split mode string only once on :, allowing : in right part.
Issue: #1718
-rw-r--r-- | source/modes/script.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/source/modes/script.c b/source/modes/script.c index 5dee3779..5a705c36 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -535,20 +535,15 @@ Mode *script_mode_parse_setup(const char *str) { return sw; } Mode *sw = g_malloc0(sizeof(*sw)); - char *endp = NULL; - char *parse = g_strdup(str); unsigned int index = 0; const char *const sep = ":"; - for (char *token = strtok_r(parse, sep, &endp); token != NULL; - token = strtok_r(NULL, sep, &endp)) { - if (index == 0) { - sw->name = g_strdup(token); - } else if (index == 1) { - sw->ed = (void *)rofi_expand_path(token); - } - index++; + char **tokens = g_strsplit(str, sep, 2); + if ( tokens ){ + index = g_strv_length(tokens); + sw->name = g_strdup(tokens[0]); + sw->ed = (void*)rofi_expand_path(tokens[1]); + g_strfreev(tokens); } - g_free(parse); if (index == 2) { sw->free = script_switcher_free; sw->_init = script_mode_init; |