summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-08-27 16:24:21 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-08-27 16:24:21 +0000
commitba5349d9cbb187d99ae3f0b43965c9f939cd61c5 (patch)
tree5c35f36634ef81772a32c3e0f26bb6536e274851 /src
parentce72bdb9f028f80ab9a65708ddb5885b80e50a05 (diff)
downloadweechat-ba5349d9cbb187d99ae3f0b43965c9f939cd61c5.zip
Fixed completion bug when many commands starts with same letters
Diffstat (limited to 'src')
-rw-r--r--src/common/completion.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/common/completion.c b/src/common/completion.c
index 324fc7f7d..2450dd315 100644
--- a/src/common/completion.c
+++ b/src/common/completion.c
@@ -118,7 +118,7 @@ completion_get_command_infos (t_completion *completion,
char **template, int *max_arg)
{
t_weechat_alias *ptr_alias;
- char *ptr_command, *pos;
+ char *ptr_command, *ptr_command2, *pos;
int i, length;
#ifdef PLUGINS
t_weechat_plugin *ptr_plugin;
@@ -138,11 +138,13 @@ completion_get_command_infos (t_completion *completion,
else
ptr_command = completion->base_command;
- pos = strchr (ptr_command, ' ');
+ ptr_command2 = strdup (ptr_command);
+ if (!ptr_command2)
+ return;
+
+ pos = strchr (ptr_command2, ' ');
if (pos)
- length = pos - ptr_command;
- else
- length = strlen (ptr_command);
+ pos[0] = '\0';
#ifdef PLUGINS
/* look for plugin command handler */
@@ -153,11 +155,12 @@ completion_get_command_infos (t_completion *completion,
ptr_handler; ptr_handler = ptr_handler->next_handler)
{
if ((ptr_handler->type == HANDLER_COMMAND)
- && (ascii_strncasecmp (ptr_handler->command,
- ptr_command, length) == 0))
+ && (ascii_strcasecmp (ptr_handler->command,
+ ptr_command2) == 0))
{
*template = ptr_handler->completion_template;
*max_arg = MAX_ARGS;
+ free (ptr_command2);
return;
}
}
@@ -167,11 +170,12 @@ completion_get_command_infos (t_completion *completion,
/* look for WeeChat internal command */
for (i = 0; weechat_commands[i].command_name; i++)
{
- if (ascii_strncasecmp (weechat_commands[i].command_name,
- ptr_command, length) == 0)
+ if (ascii_strcasecmp (weechat_commands[i].command_name,
+ ptr_command2) == 0)
{
*template = weechat_commands[i].completion_template;
*max_arg = weechat_commands[i].max_arg;
+ free (ptr_command2);
return;
}
}
@@ -180,15 +184,17 @@ completion_get_command_infos (t_completion *completion,
for (i = 0; irc_commands[i].command_name; i++)
{
if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
- && (ascii_strncasecmp (irc_commands[i].command_name,
- ptr_command, length) == 0))
+ && (ascii_strcasecmp (irc_commands[i].command_name,
+ ptr_command2) == 0))
{
*template = irc_commands[i].completion_template;
*max_arg = irc_commands[i].max_arg;
+ free (ptr_command2);
return;
}
}
+ free (ptr_command2);
return;
}