diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-13 22:13:40 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-13 22:13:40 +0200 |
commit | 4406087ee57867ff42c8913314c8dd3c15a561f4 (patch) | |
tree | 0b4cf39406dbb3e706944c6803d32dc6fe663ff7 /src | |
parent | 32edff0fa50551dee049cc808552757752ef81c3 (diff) | |
download | weechat-4406087ee57867ff42c8913314c8dd3c15a561f4.zip |
core: fix completion %(plugins_commands) when there are more than one argument before in the command line
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-completion.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c index 6e3066fee..4bb0c37be 100644 --- a/src/core/wee-completion.c +++ b/src/core/wee-completion.c @@ -829,7 +829,8 @@ completion_list_add_plugins_commands_cb (void *data, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { - char *pos_space, *plugin_name; + char **argv; + int argc; struct t_weechat_plugin *ptr_plugin; struct t_hook *ptr_hook; @@ -840,23 +841,20 @@ completion_list_add_plugins_commands_cb (void *data, if (completion->args) { - pos_space = strchr (completion->args, ' '); - if (pos_space) - plugin_name = string_strndup (completion->args, - pos_space - completion->args); - else - plugin_name = strdup (completion->args); + argv = string_split (completion->args, " ", 0, 0, &argc); + if (!argv) + return WEECHAT_RC_OK; - if (plugin_name) + if (argc > 0) { ptr_plugin = NULL; - if (string_strcasecmp (plugin_name, PLUGIN_CORE) != 0) + if (string_strcasecmp (argv[argc - 1], PLUGIN_CORE) != 0) { /* * plugin name is different from "core", then search it in * plugin list */ - ptr_plugin = plugin_search (plugin_name); + ptr_plugin = plugin_search (argv[argc - 1]); if (!ptr_plugin) return WEECHAT_RC_OK; } @@ -873,8 +871,8 @@ completion_list_add_plugins_commands_cb (void *data, 0, WEECHAT_LIST_POS_SORT); } } - free (plugin_name); } + string_free_split( argv); } return WEECHAT_RC_OK; |