summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-01-16 11:52:22 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-01-16 11:52:22 +0000
commit88930e50dd06fcad997fa9380227084b319181a9 (patch)
treefe3d62f54f0f7f477ed5ff381b0f2606ec61a7f9 /src
parent555999534ee0d4782f61a5e1e7b546830f5d5662 (diff)
downloadweechat-88930e50dd06fcad997fa9380227084b319181a9.zip
Improved completion (now completes commands args), fixed color bug (gray removed, replaced by default), fixed crash when unknown section with option(s) in config file, fixed IRC commands: /op, /deop, /voice, /devoice
Diffstat (limited to 'src')
-rw-r--r--src/common/Makefile.am2
-rw-r--r--src/common/command.c332
-rw-r--r--src/common/command.h17
-rw-r--r--src/common/completion.c652
-rw-r--r--src/common/completion.h29
-rw-r--r--src/common/weechat.c2
-rw-r--r--src/common/weeconfig.c185
-rw-r--r--src/common/weelist.c162
-rw-r--r--src/common/weelist.h37
-rw-r--r--src/gui/curses/gui-display.c104
-rw-r--r--src/gui/curses/gui-input.c38
-rw-r--r--src/gui/gui-common.c11
-rw-r--r--src/irc/irc-commands.c10
-rw-r--r--src/irc/irc-send.c8
-rw-r--r--src/plugins/perl/wee-perl.c4
-rw-r--r--src/plugins/plugins.c3
16 files changed, 1180 insertions, 416 deletions
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 31346a741..8d425fd59 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -25,6 +25,8 @@ lib_weechat_main_a_SOURCES = weechat.c \
command.h \
completion.c \
completion.h \
+ weelist.c \
+ weelist.h \
weeconfig.c \
weeconfig.h \
history.c \
diff --git a/src/common/command.c b/src/common/command.c
index 5d3bf7def..547657965 100644
--- a/src/common/command.c
+++ b/src/common/command.c
@@ -29,6 +29,7 @@
#include "weechat.h"
#include "command.h"
+#include "weelist.h"
#include "weeconfig.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
@@ -111,111 +112,17 @@ t_weechat_command weechat_commands[] =
t_weechat_alias *weechat_alias = NULL;
t_weechat_alias *weechat_last_alias = NULL;
-t_index_command *index_commands;
-t_index_command *last_index_command;
+t_weelist *index_commands;
+t_weelist *last_index_command;
/*
- * index_command_search: search a command
- */
-
-t_index_command *
-index_command_search (char *command)
-{
- t_index_command *ptr_index;
-
- for (ptr_index = index_commands; ptr_index; ptr_index = ptr_index->next_index)
- {
- if (strcasecmp (command, ptr_index->command_name) == 0)
- return ptr_index;
- }
- return NULL;
-}
-
-/*
- * index_command_find_pos: find position for a command index (for sorting index)
- */
-
-t_index_command *
-index_command_find_pos (char *command)
-{
- t_index_command *ptr_index;
-
- for (ptr_index = index_commands; ptr_index; ptr_index = ptr_index->next_index)
- {
- if (strcasecmp (command, ptr_index->command_name) < 0)
- return ptr_index;
- }
- return NULL;
-}
-
-/*
- * index_command_insert_sorted: insert index into sorted list
- */
-
-void
-index_command_insert_sorted (t_index_command *index)
-{
- t_index_command *pos_index;
-
- pos_index = index_command_find_pos (index->command_name);
-
- if (index_commands)
- {
- if (pos_index)
- {
- /* insert index into the list (before index found) */
- index->prev_index = pos_index->prev_index;
- index->next_index = pos_index;
- if (pos_index->prev_index)
- pos_index->prev_index->next_index = index;
- else
- index_commands = index;
- pos_index->prev_index = index;
- }
- else
- {
- /* add index to the end */
- index->prev_index = last_index_command;
- index->next_index = NULL;
- last_index_command->next_index = index;
- last_index_command = index;
- }
- }
- else
- {
- index->prev_index = NULL;
- index->next_index = NULL;
- index_commands = index;
- last_index_command = index;
- }
-}
-
-/*
- * index_command_new: create new index command and add it to index list
- */
-
-t_index_command *
-index_command_new (char *command_name)
-{
- t_index_command *new_index;
-
- if ((new_index = ((t_index_command *) malloc (sizeof (t_index_command)))))
- {
- new_index->command_name = strdup (command_name);
- index_command_insert_sorted (new_index);
- return new_index;
- }
- return NULL;
-}
-
-/*
- * index_command_build: build an index of commands (internal, irc and alias)
+ * command_index_build: build an index of commands (internal, irc and alias)
* This list will be sorted, and used for completion
*/
void
-index_command_build ()
+command_index_build ()
{
int i;
@@ -224,49 +131,21 @@ index_command_build ()
i = 0;
while (weechat_commands[i].command_name)
{
- (void) index_command_new (weechat_commands[i].command_name);
+ (void) weelist_add (&index_commands, &last_index_command,
+ weechat_commands[i].command_name);
i++;
}
i = 0;
while (irc_commands[i].command_name)
{
if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
- (void) index_command_new (irc_commands[i].command_name);
+ (void) weelist_add (&index_commands, &last_index_command,
+ irc_commands[i].command_name);
i++;
}
}
/*
- * index_command_free: free an index command and reomve it from list
- */
-
-void
-index_command_free (t_index_command *index)
-{
- t_index_command *new_index_commands;
-
- /* remove index command from list */
- if (last_index_command == index)
- last_index_command = index->prev_index;
- if (index->prev_index)
- {
- (index->prev_index)->next_index = index->next_index;
- new_index_commands = index_commands;
- }
- else
- new_index_commands = index->next_index;
-
- if (index->next_index)
- (index->next_index)->prev_index = index->prev_index;
-
- /* free data */
- if (index->command_name)
- free (index->command_name);
- free (index);
- index_commands = new_index_commands;
-}
-
-/*
* alias_search: search an alias
*/
@@ -352,8 +231,9 @@ alias_new (char *alias_name, char *alias_command)
char *pos;
t_weechat_alias *new_alias;
- if (index_command_search (alias_name))
+ if (weelist_search (index_commands, alias_name))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s alias or command \"%s\" already exists!\n"),
WEECHAT_ERROR, alias_name);
return NULL;
@@ -363,12 +243,14 @@ alias_new (char *alias_name, char *alias_command)
pos[0] = '\0';
if (alias_search (alias_command))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s alias cannot run another alias!\n"),
WEECHAT_ERROR);
return NULL;
}
- if (!index_command_search (alias_command))
+ if (!weelist_search (index_commands, alias_command))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s target command \"%s\" does not exist!\n"),
WEECHAT_ERROR, alias_command);
return NULL;
@@ -529,6 +411,15 @@ exec_weechat_command (t_irc_server *server, char *string)
/* look for end of command */
ptr_args = NULL;
+
+ pos = &command[strlen (command) - 1];
+ if (pos[0] == ' ')
+ {
+ while ((pos > command) && (pos[0] == ' '))
+ pos--;
+ pos[1] = '\0';
+ }
+
pos = strchr (command, ' ');
if (pos)
{
@@ -554,6 +445,8 @@ exec_weechat_command (t_irc_server *server, char *string)
{
if (weechat_commands[i].min_arg ==
weechat_commands[i].max_arg)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s wrong argument count for %s command \"%s\" "
"(expected: %d arg%s)\n"),
@@ -562,7 +455,10 @@ exec_weechat_command (t_irc_server *server, char *string)
weechat_commands[i].max_arg,
(weechat_commands[i].max_arg >
1) ? "s" : "");
+ }
else
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s wrong argument count for %s command \"%s\" "
"(expected: between %d and %d arg%s)\n"),
@@ -572,6 +468,7 @@ exec_weechat_command (t_irc_server *server, char *string)
weechat_commands[i].max_arg,
(weechat_commands[i].max_arg >
1) ? "s" : "");
+ }
}
else
{
@@ -582,9 +479,12 @@ exec_weechat_command (t_irc_server *server, char *string)
return_code = (int) (weechat_commands[i].cmd_function_1arg)
(ptr_args);
if (return_code < 0)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s %s command \"%s\" failed\n"),
WEECHAT_ERROR, PACKAGE_NAME, command + 1);
+ }
}
if (argv)
{
@@ -606,6 +506,8 @@ exec_weechat_command (t_irc_server *server, char *string)
|| (argc > irc_commands[i].max_arg))
{
if (irc_commands[i].min_arg == irc_commands[i].max_arg)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf
(NULL,
_("%s wrong argument count for IRC command \"%s\" "
@@ -614,7 +516,10 @@ exec_weechat_command (t_irc_server *server, char *string)
command + 1,
irc_commands[i].max_arg,
(irc_commands[i].max_arg > 1) ? "s" : "");
+ }
else
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf
(NULL,
_("%s wrong argument count for IRC command \"%s\" "
@@ -623,15 +528,18 @@ exec_weechat_command (t_irc_server *server, char *string)
command + 1,
irc_commands[i].min_arg, irc_commands[i].max_arg,
(irc_commands[i].max_arg > 1) ? "s" : "");
+ }
}
else
{
if ((irc_commands[i].need_connection) &&
((!server) || (!server->is_connected)))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s command \"%s\" needs a server connection!\n"),
WEECHAT_ERROR, irc_commands[i].command_name);
+ free (command);
return 0;
}
if (irc_commands[i].cmd_function_args)
@@ -641,9 +549,12 @@ exec_weechat_command (t_irc_server *server, char *string)
return_code = (int) (irc_commands[i].cmd_function_1arg)
(server, ptr_args);
if (return_code < 0)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s IRC command \"%s\" failed\n"),
WEECHAT_ERROR, command + 1);
+ }
}
if (argv)
{
@@ -688,6 +599,7 @@ exec_weechat_command (t_irc_server *server, char *string)
return 1;
}
}
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unknown command \"%s\" (type /help for help)\n"),
WEECHAT_ERROR,
@@ -757,14 +669,20 @@ user_command (t_irc_server *server, char *command)
COLOR_WIN_CHAT, "%s\n", command);
}
else
+ {
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
gui_printf (server->buffer,
_("%s cannot find nick for sending message\n"),
WEECHAT_ERROR);
+ }
}
}
else
+ {
+ irc_display_prefix ((server) ? server->buffer : NULL, PREFIX_ERROR);
gui_printf ((server) ? server->buffer : NULL,
_("This window is not a channel!\n"));
+ }
}
}
@@ -790,18 +708,31 @@ weechat_cmd_alias (char *arguments)
pos++;
if (!pos[0])
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s missing arguments for \"%s\" command\n"),
WEECHAT_ERROR, "alias");
return -1;
}
if (!alias_new (arguments, pos))
return -1;
- (void) index_command_new (arguments);
- gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"),
- arguments, pos);
+ if (weelist_add (&index_commands, &last_index_command, arguments))
+ {
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf (NULL, _("Alias \"%s\" => \"%s\" created\n"),
+ arguments, pos);
+ }
+ else
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
+ gui_printf (NULL, _("Failed to create alias \"%s\" => \"%s\" "
+ "(not enough memory)\n"),
+ arguments, pos);
+ return -1;
+ }
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s missing arguments for \"%s\" command\n"),
WEECHAT_ERROR, "alias");
return -1;
@@ -812,17 +743,22 @@ weechat_cmd_alias (char *arguments)
/* List all aliases */
if (weechat_alias)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, _("List of aliases:\n"));
for (ptr_alias = weechat_alias; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, " %s => %s\n",
ptr_alias->alias_name,
ptr_alias->alias_command + 1);
}
}
else
+ {
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, _("No alias defined.\n"));
+ }
}
return 0;
}
@@ -891,6 +827,7 @@ weechat_cmd_buffer (int argc, char **argv)
if (argc < 2)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s missing arguments for \"%s\" command\n"),
WEECHAT_ERROR, "buffer");
return -1;
@@ -913,6 +850,7 @@ weechat_cmd_buffer (int argc, char **argv)
else
{
/* invalid number */
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer number\n"),
WEECHAT_ERROR);
return -1;
@@ -925,7 +863,8 @@ weechat_cmd_buffer (int argc, char **argv)
if ((!gui_current_window->buffer->next_buffer)
&& (gui_current_window->buffer == gui_buffers))
{
- gui_printf (gui_current_window->buffer,
+ irc_display_prefix (NULL, PREFIX_ERROR);
+ gui_printf (NULL,
_("%s can not close the single buffer\n"),
WEECHAT_ERROR);
return -1;
@@ -934,7 +873,8 @@ weechat_cmd_buffer (int argc, char **argv)
{
if (SERVER(gui_current_window->buffer)->channels)
{
- gui_printf (gui_current_window->buffer,
+ irc_display_prefix (NULL, PREFIX_ERROR);
+ gui_printf (NULL,
_("%s can not close server buffer while channels "
"are opened\n"),
WEECHAT_ERROR);
@@ -982,6 +922,7 @@ weechat_cmd_buffer (int argc, char **argv)
if ((number < 0) || (number > 3))
{
/* invalid highlight level */
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between 0 and 3)\n"),
WEECHAT_ERROR);
return -1;
@@ -991,6 +932,7 @@ weechat_cmd_buffer (int argc, char **argv)
else
{
/* invalid number */
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect notify level (must be between 0 and 3)\n"),
WEECHAT_ERROR);
return -1;
@@ -1007,6 +949,7 @@ weechat_cmd_buffer (int argc, char **argv)
{
if (!gui_switch_to_buffer_by_number (gui_current_window, (int) number))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s buffer \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, argv[0], "buffer");
@@ -1016,6 +959,7 @@ weechat_cmd_buffer (int argc, char **argv)
else
{
/* invalid number */
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect buffer number\n"),
WEECHAT_ERROR);
return -1;
@@ -1039,6 +983,7 @@ weechat_cmd_clear (int argc, char **argv)
gui_buffer_clear_all ();
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("unknown parameter \"%s\" for \"%s\" command\n"),
argv[0], "clear");
@@ -1067,6 +1012,7 @@ weechat_cmd_connect (int argc, char **argv)
{
if (ptr_server->is_connected)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s already connected to server \"%s\"!\n"),
WEECHAT_ERROR, argv[0]);
@@ -1086,6 +1032,7 @@ weechat_cmd_connect (int argc, char **argv)
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found\n"),
WEECHAT_ERROR, argv[0]);
@@ -1111,19 +1058,24 @@ weechat_cmd_disconnect (int argc, char **argv)
{
if ((!ptr_server->is_connected) && (ptr_server->reconnect_start == 0))
{
+ irc_display_prefix (ptr_server->buffer, PREFIX_ERROR);
gui_printf (ptr_server->buffer,
_("%s not connected to server \"%s\"!\n"),
WEECHAT_ERROR, argv[0]);
return -1;
}
if (ptr_server->reconnect_start > 0)
+ {
+ irc_display_prefix (ptr_server->buffer, PREFIX_INFO);
gui_printf (ptr_server->buffer,
_("Auto-reconnection is cancelled\n"));
+ }
server_disconnect (ptr_server, 0);
gui_draw_buffer_status (gui_current_window->buffer, 1);
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found\n"),
WEECHAT_ERROR, argv[0]);
@@ -1143,18 +1095,29 @@ weechat_cmd_help (int argc, char **argv)
if (argc == 0)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL,
- _("> List of %s internal commands:\n"), PACKAGE_NAME);
+ _("> List of %s internal commands:\n"),
+ PACKAGE_NAME);
for (i = 0; weechat_commands[i].command_name; i++)
- gui_printf (NULL, " %s - %s\n",
- weechat_commands[i].command_name,
+ {
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s",
+ weechat_commands[i].command_name);
+ gui_printf (NULL, " - %s\n",
_(weechat_commands[i].command_description));
+ }
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, _("> List of IRC commands:\n"));
for (i = 0; irc_commands[i].command_name; i++)
if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
- gui_printf (NULL, " %s - %s\n",
- irc_commands[i].command_name,
+ {
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s",
+ irc_commands[i].command_name);
+ gui_printf (NULL, " - %s\n",
_(irc_commands[i].command_description));
+ }
}
if (argc == 1)
{
@@ -1162,42 +1125,48 @@ weechat_cmd_help (int argc, char **argv)
{
if (strcasecmp (weechat_commands[i].command_name, argv[0]) == 0)
{
- gui_printf
- (NULL,
- _("> Help on %s internal command \"%s\":\n"),
- PACKAGE_NAME, weechat_commands[i].command_name);
- gui_printf (NULL,
- _("Syntax: /%s %s\n"),
- weechat_commands[i].command_name,
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf (NULL, _("> Help on %s internal command \""), PACKAGE_NAME);
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s",
+ weechat_commands[i].command_name);
+ gui_printf (NULL, "\":\n");
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf (NULL, _("Syntax: "));
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "/%s",
+ weechat_commands[i].command_name);
+ gui_printf (NULL, " %s\n",
(weechat_commands[i].arguments) ?
_(weechat_commands[i].arguments) : "");
if (weechat_commands[i].arguments_description)
- {
gui_printf (NULL, "%s\n",
_(weechat_commands[i].arguments_description));
- }
return 0;
}
}
for (i = 0; irc_commands[i].command_name; i++)
{
- if (strcasecmp (irc_commands[i].command_name, argv[0]) == 0)
+ if ((strcasecmp (irc_commands[i].command_name, argv[0]) == 0)
+ && (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg))
{
- gui_printf (NULL,
- _("> Help on IRC command \"%s\":\n"),
- irc_commands[i].command_name);
- gui_printf (NULL, _("Syntax: /%s %s\n"),
- irc_commands[i].command_name,
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf (NULL, _("> Help on IRC command \""));
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s",
+ irc_commands[i].command_name);
+ gui_printf (NULL, "\":\n");
+ irc_display_prefix (NULL, PREFIX_INFO);
+ gui_printf (NULL, _("Syntax: "));
+ gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "/%s",
+ irc_commands[i].command_name);
+ gui_printf (NULL, "%s\n",
(irc_commands[i].arguments) ?
_(irc_commands[i].arguments) : "");
if (irc_commands[i].arguments_description)
- {
gui_printf (NULL, "%s\n",
_(irc_commands[i].arguments_description));
- }
return 0;
}
}
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("No help available, \"%s\" is an unknown command\n"),
argv[0]);
@@ -1321,17 +1290,20 @@ weechat_cmd_perl (int argc, char **argv)
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "perl");
}
break;
default:
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s wrong argument count for \"%s\" command\n"),
WEECHAT_ERROR, "perl");
}
#else
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("WeeChat was build without Perl support.\n"
"Please rebuild WeeChat with "
@@ -1403,15 +1375,19 @@ weechat_cmd_server (int argc, char **argv)
{
if (argc < 2)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing servername for \"%s\" command\n"),
WEECHAT_ERROR, "server del");
return -1;
}
if (argc > 2)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s too much arguments for \"%s\" command, ignoring arguments\n"),
WEECHAT_WARNING, "server del");
+ }
/* look for server by name */
server_found = NULL;
@@ -1426,6 +1402,7 @@ weechat_cmd_server (int argc, char **argv)
}
if (!server_found)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found for \"%s\" command\n"),
WEECHAT_ERROR, argv[1], "server del");
@@ -1449,6 +1426,7 @@ weechat_cmd_server (int argc, char **argv)
if (argc < 3)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing parameters for \"%s\" command\n"),
WEECHAT_ERROR, "server");
@@ -1458,6 +1436,7 @@ weechat_cmd_server (int argc, char **argv)
if (server_name_already_exists (argv[0]))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" already exists, can't create it!\n"),
WEECHAT_ERROR, argv[0]);
@@ -1482,6 +1461,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i == (argc - 1))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-pwd");
@@ -1494,6 +1474,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i >= (argc - 3))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing nick(s) for \"%s\" parameter\n"),
WEECHAT_ERROR, "-nicks");
@@ -1508,6 +1489,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i == (argc - 1))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-username");
@@ -1520,6 +1502,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i == (argc - 1))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-realname");
@@ -1532,6 +1515,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i == (argc - 1))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing command for \"%s\" parameter\n"),
WEECHAT_ERROR, "-command");
@@ -1544,6 +1528,7 @@ weechat_cmd_server (int argc, char **argv)
{
if (i == (argc - 1))
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s missing password for \"%s\" parameter\n"),
WEECHAT_ERROR, "-autojoin");
@@ -1573,6 +1558,7 @@ weechat_cmd_server (int argc, char **argv)
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unable to create server\n"),
WEECHAT_ERROR);
@@ -1601,6 +1587,7 @@ weechat_set_cmd_display_option (t_config_option *option, char *prefix, void *val
{
char *color_name, *pos_nickserv, *pos_pwd, *value2;
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, " %s%s%s",
(prefix) ? prefix : "",
(prefix) ? "." : "",
@@ -1700,14 +1687,18 @@ weechat_cmd_set (char *arguments)
pos[0] = '\0';
ptr_server = server_search (option);
if (!ptr_server)
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s server \"%s\" not found\n"),
WEECHAT_ERROR, option);
+ }
else
{
switch (config_set_server_value (ptr_server, pos + 1, value))
{
case 0:
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "[");
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s",
config_sections[CONFIG_SECTION_SERVER].section_name);
@@ -1730,10 +1721,12 @@ weechat_cmd_set (char *arguments)
config_change_buffer_content ();
break;
case -1:
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s config option \"%s\" not found\n"),
WEECHAT_ERROR, pos + 1);
break;
case -2:
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect value for option \"%s\"\n"),
WEECHAT_ERROR, pos + 1);
break;
@@ -1748,6 +1741,7 @@ weechat_cmd_set (char *arguments)
{
if (ptr_option->handler_change == NULL)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s option \"%s\" can not be changed while WeeChat is running\n"),
WEECHAT_ERROR, option);
@@ -1764,12 +1758,16 @@ weechat_cmd_set (char *arguments)
weechat_set_cmd_display_option (ptr_option, NULL, NULL);
}
else
+ {
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s incorrect value for option \"%s\"\n"),
WEECHAT_ERROR, option);
+ }
}
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s config option \"%s\" not found\n"),
WEECHAT_ERROR, option);
}
@@ -1792,6 +1790,7 @@ weechat_cmd_set (char *arguments)
{
if (!section_displayed)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "[");
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL,
"%s",
@@ -1820,6 +1819,7 @@ weechat_cmd_set (char *arguments)
{
if (!section_displayed)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "[");
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s",
config_sections[CONFIG_SECTION_SERVER].section_name);
@@ -1842,6 +1842,7 @@ weechat_cmd_set (char *arguments)
}
if (number_found == 0)
{
+ irc_display_prefix (NULL, PREFIX_INFO);
if (option)
gui_printf (NULL, _("No config option found with \"%s\"\n"),
option);
@@ -1850,6 +1851,7 @@ weechat_cmd_set (char *arguments)
}
else
{
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%d ", number_found);
if (option)
gui_printf (NULL, _("config option(s) found with \"%s\"\n"),
@@ -1868,21 +1870,23 @@ weechat_cmd_set (char *arguments)
int
weechat_cmd_unalias (char *arguments)
{
- t_index_command *ptr_index;
+ t_weelist *ptr_weelist;
t_weechat_alias *ptr_alias;
- ptr_index = index_command_search (arguments);
- if (!ptr_index)
+ ptr_weelist = weelist_search (index_commands, arguments);
+ if (!ptr_weelist)
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, _("%s alias or command \"%s\" not found\n"),
WEECHAT_ERROR, arguments);
return -1;
}
- index_command_free (ptr_index);
+ weelist_remove (&index_commands, &last_index_command, ptr_weelist);
ptr_alias = alias_search (arguments);
if (ptr_alias)
alias_free (ptr_alias);
+ irc_display_prefix (NULL, PREFIX_INFO);
gui_printf (NULL, _("Alias \"%s\" removed\n"),
arguments);
return 0;
@@ -1898,6 +1902,7 @@ weechat_cmd_window (int argc, char **argv)
if ((argc == 0) || ((argc == 1) && (strcasecmp (argv[0], "list") == 0)))
{
/* list opened windows */
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL, "window list -- NOT DEVELOPED!\n");
}
else
@@ -1914,6 +1919,7 @@ weechat_cmd_window (int argc, char **argv)
}
else
{
+ irc_display_prefix (NULL, PREFIX_ERROR);
gui_printf (NULL,
_("%s unknown option for \"%s\" command\n"),
WEECHAT_ERROR, "window");
diff --git a/src/common/command.h b/src/common/command.h
index 586cb7737..44a2a913b 100644
--- a/src/common/command.h
+++ b/src/common/command.h
@@ -21,6 +21,7 @@
#ifndef __WEECHAT_COMMAND_H
#define __WEECHAT_COMMAND_H 1
+#include "weelist.h"
#include "../irc/irc.h"
#define MAX_ARGS 8192
@@ -48,21 +49,13 @@ struct t_weechat_alias
t_weechat_alias *next_alias;
};
-typedef struct t_index_command t_index_command;
-
-struct t_index_command
-{
- char *command_name;
- t_index_command *prev_index;
- t_index_command *next_index;
-};
+extern t_weechat_command weechat_commands[];
extern t_weechat_alias *weechat_alias;
-extern t_index_command *index_commands;
+extern t_weelist *index_commands;
+extern t_weelist *last_index_command;
-extern t_index_command *index_command_search (char *);
-extern t_index_command *index_command_new (char *);
-extern void index_command_build ();
+extern void command_index_build ();
extern t_weechat_alias *alias_new (char *, char *);
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
diff --git a/src/common/completion.c b/src/common/completion.c
index 8f6a6d2ba..d7632f13e 100644
--- a/src/common/completion.c
+++ b/src/common/completion.c
@@ -29,8 +29,10 @@
#include "weechat.h"
#include "completion.h"
-#include "../irc/irc.h"
#include "command.h"
+#include "weelist.h"
+#include "weeconfig.h"
+#include "../irc/irc.h"
/*
@@ -40,8 +42,14 @@
void
completion_init (t_completion *completion)
{
+ completion->context = COMPLETION_NULL;
+ completion->base_command = NULL;
+ completion->base_command_arg = 0;
completion->position = -1;
completion->base_word = NULL;
+
+ completion->completion_list = NULL;
+ completion->last_completion = NULL;
}
/*
@@ -51,8 +59,463 @@ completion_init (t_completion *completion)
void
completion_free (t_completion *completion)
{
+ if (completion->base_command)
+ free (completion->base_command);
+ completion->base_command = NULL;
+
if (completion->base_word)
free (completion->base_word);
+ completion->base_word = NULL;
+
+ while (completion->completion_list)
+ weelist_remove (&completion->completion_list,
+ &completion->last_completion,
+ completion->completion_list);
+ completion->completion_list = NULL;
+ completion->last_completion = NULL;
+}
+
+/*
+ * completion_stop: stop completion (for example after 1 arg of command with 1 arg)
+ */
+
+void
+completion_stop (t_completion *completion)
+{
+ completion->context = COMPLETION_NULL;
+ completion->position = -1;
+}
+
+/*
+ * completion_build_list: build data list according to command and argument #
+ */
+
+void
+completion_build_list (t_completion *completion, void *channel)
+{
+ t_weelist *ptr_list;
+ int i, j;
+ t_irc_server *ptr_server;
+ t_irc_channel *ptr_channel;
+ char option_name[256];
+ t_weechat_alias *ptr_alias;
+
+ /* WeeChat internal commands */
+
+ /* no completion for some commands */
+ if ((strcasecmp (completion->base_command, "server") == 0)
+ || (strcasecmp (completion->base_command, "save") == 0))
+ {
+ completion_stop (completion);
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "alias") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ for (ptr_list = index_commands; ptr_list; ptr_list = ptr_list->next_weelist)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ptr_list->data);
+ }
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "buffer") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "close");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "list");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "move");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "notify");
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "clear") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "-all");
+ return;
+ }
+ if (((strcasecmp (completion->base_command, "connect") == 0)
+ || (strcasecmp (completion->base_command, "connect") == 0))
+ && (completion->base_command_arg == 1))
+ {
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ptr_server->name);
+ }
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "help") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ for (i = 0; weechat_commands[i].command_name; i++)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ weechat_commands[i].command_name);
+ }
+ for (i = 0; irc_commands[i].command_name; i++)
+ {
+ if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg)
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ irc_commands[i].command_name);
+ }
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "perl") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "load");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "autoload");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "unload");
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "set") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
+ {
+ if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
+ {
+ for (j = 0; weechat_options[i][j].option_name; j++)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ weechat_options[i][j].option_name);
+ }
+ }
+ }
+ for (ptr_server = irc_servers; ptr_server;
+ ptr_server = ptr_server->next_server)
+ {
+ for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++)
+ {
+ snprintf (option_name, sizeof (option_name), "%s.%s",
+ ptr_server->name,
+ weechat_options[CONFIG_SECTION_SERVER][i].option_name);
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ option_name);
+ }
+ }
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "unalias") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ptr_alias->alias_name);
+ }
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "window") == 0)
+ && (completion->base_command_arg == 2))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "close");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "list");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "splith");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "splitv");
+ return;
+ }
+
+ /* IRC commands */
+
+ /* no completion for some commands */
+ if ((strcasecmp (completion->base_command, "admin") == 0)
+ || (strcasecmp (completion->base_command, "die") == 0)
+ || (strcasecmp (completion->base_command, "info") == 0)
+ || (strcasecmp (completion->base_command, "join") == 0)
+ || (strcasecmp (completion->base_command, "links") == 0)
+ || (strcasecmp (completion->base_command, "list") == 0)
+ || (strcasecmp (completion->base_command, "lusers") == 0)
+ || (strcasecmp (completion->base_command, "me") == 0)
+ || (strcasecmp (completion->base_command, "motd") == 0)
+ || (strcasecmp (completion->base_command, "oper") == 0)
+ || (strcasecmp (completion->base_command, "ping") == 0)
+ || (strcasecmp (completion->base_command, "pong") == 0)
+ || (strcasecmp (completion->base_command, "quote") == 0)
+ || (strcasecmp (completion->base_command, "rehash") == 0)
+ || (strcasecmp (completion->base_command, "restart") == 0)
+ || (strcasecmp (completion->base_command, "service") == 0)
+ || (strcasecmp (completion->base_command, "servlist") == 0)
+ || (strcasecmp (completion->base_command, "squery") == 0)
+ || (strcasecmp (completion->base_command, "squit") == 0)
+ || (strcasecmp (completion->base_command, "stats") == 0)
+ || (strcasecmp (completion->base_command, "summon") == 0)
+ || (strcasecmp (completion->base_command, "time") == 0)
+ || (strcasecmp (completion->base_command, "trace") == 0)
+ || (strcasecmp (completion->base_command, "users") == 0)
+ || (strcasecmp (completion->base_command, "wallops") == 0)
+ || (strcasecmp (completion->base_command, "who") == 0))
+ {
+ completion_stop (completion);
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "away") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ if (cfg_irc_default_msg_away && cfg_irc_default_msg_away[0])
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ cfg_irc_default_msg_away);
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "ctcp") == 0)
+ && (completion->base_command_arg == 2))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "action");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "version");
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "dcc") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "chat");
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ "send");
+ return;
+ }
+ if (strcasecmp (completion->base_command, "invite") == 0)
+ {
+ /* arg1: nickname */
+ if (completion->base_command_arg == 1)
+ return;
+
+ /* arg > 2: not allowed */
+ if (completion->base_command_arg > 2)
+ {
+ completion_stop (completion);
+ return;
+ }
+
+ /* arg2: channel */
+ if (SERVER(gui_current_window->buffer))
+ {
+ for (ptr_channel = SERVER(gui_current_window->buffer)->channels;
+ ptr_channel; ptr_channel = ptr_channel->next_channel)
+ {
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ptr_channel->name);
+ }
+ }
+ return;
+ }
+ if (strcasecmp (completion->base_command, "kick") == 0)
+ {
+ if (completion->base_command_arg != 1)
+ completion_stop (completion);
+ return;
+ }
+ if (strcasecmp (completion->base_command, "kill") == 0)
+ {
+ if (completion->base_command_arg != 1)
+ completion_stop (completion);
+ return;
+ }
+ if (strcasecmp (completion->base_command, "notice") == 0)
+ {
+ if (completion->base_command_arg != 1)
+ completion_stop (completion);
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "part") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0])
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ cfg_irc_default_msg_part);
+ return;
+ }
+ if (strcasecmp (completion->base_command, "query") == 0)
+ {
+ if (completion->base_command_arg != 1)
+ completion_stop (completion);
+ return;
+ }
+ if ((strcasecmp (completion->base_command, "quit") == 0)
+ && (completion->base_command_arg == 1))
+ {
+ if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0])
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ cfg_irc_default_msg_quit);
+ return;
+ }
+ if (strcasecmp (completion->base_command, "topic") == 0)
+ {
+ if (completion->base_command_arg == 1)
+ {
+ if (!channel || !((t_irc_channel *)channel)->topic
+ || !((t_irc_channel *)channel)->topic[0])
+ completion_stop (completion);
+ else
+ weelist_add (&completion->completion_list,
+ &completion->last_completion,
+ ((t_irc_channel *)channel)->topic);
+ }
+ else
+ completion_stop (completion);
+ return;
+ }
+}
+
+/*
+ * completion_find_context: find context for completion
+ */
+
+void
+completion_find_context (t_completion *completion, void *channel, char *buffer,
+ int size, int pos)
+{
+ int i, command, command_arg, pos_start, pos_end;
+
+ /* look for context */
+ completion_free (completion);
+ command = (buffer[0] == '/') ? 1 : 0;
+ command_arg = 0;
+ i = 0;
+ while (i < pos)
+ {
+ if (buffer[i] == ' ')
+ {
+ command_arg++;
+ i++;
+ while ((i < pos) && (buffer[i] == ' ')) i++;
+ }
+ else
+ i++;
+ }
+ if (command)
+ {
+ if (command_arg > 0)
+ {
+ completion->context = COMPLETION_COMMAND_ARG;
+ completion->base_command_arg = command_arg;
+ }
+ else
+ {
+ completion->context = COMPLETION_COMMAND;
+ completion->base_command_arg = 0;
+ }
+ }
+ else
+ {
+ if (channel)
+ completion->context = COMPLETION_NICK;
+ else
+ completion->context = COMPLETION_NULL;
+ }
+
+ /* look for word to complete (base word) */
+ completion->base_word_pos = 0;
+ completion->position_replace = pos;
+
+ if (size > 0)
+ {
+ i = pos;
+ pos_start = i;
+ if (buffer[i] == ' ')
+ {
+ if ((i > 0) && (buffer[i-1] != ' '))
+ {
+ i--;
+ while ((i >= 0) && (buffer[i] != ' '))
+ i--;
+ pos_start = i + 1;
+ }
+ }
+ else
+ {
+ while ((i >= 0) && (buffer[i] != ' '))
+ i--;
+ pos_start = i + 1;
+ }
+ i = pos;
+ while ((i < size) && (buffer[i] != ' '))
+ i++;
+ pos_end = i - 1;
+
+ completion->base_word_pos = pos_start;
+
+ if (pos_start <= pos_end)
+ {
+ if (completion->context == COMPLETION_COMMAND)
+ completion->position_replace = pos_start + 1;
+ else
+ completion->position_replace = pos_start;
+
+ completion->base_word = (char *) malloc (pos_end - pos_start + 2);
+ for (i = pos_start; i <= pos_end; i++)
+ completion->base_word[i - pos_start] = buffer[i];
+ completion->base_word[pos_end - pos_start + 1] = '\0';
+ }
+ }
+
+ if (!completion->base_word)
+ completion->base_word = strdup ("");
+
+ /* find command (for command argument completion only) */
+ if (completion->context == COMPLETION_COMMAND_ARG)
+ {
+ pos_start = 0;
+ while ((pos_start < size) && (buffer[pos_start] != '/'))
+ pos_start++;
+ if (buffer[pos_start] == '/')
+ {
+ pos_start++;
+ pos_end = pos_start;
+ while ((pos_end < size) && (buffer[pos_end] != ' '))
+ pos_end++;
+ if (buffer[pos_end] == ' ')
+ pos_end--;
+
+ completion->base_command = (char *) malloc (pos_end - pos_start + 2);
+ for (i = pos_start; i <= pos_end; i++)
+ completion->base_command[i - pos_start] = buffer[i];
+ completion->base_command[pos_end - pos_start + 1] = '\0';
+ completion_build_list (completion, channel);
+ }
+ }
}
/*
@@ -62,23 +525,37 @@ completion_free (t_completion *completion)
void
completion_command (t_completion *completion)
{
- int length, word_found_seen;
- t_index_command *ptr_index;
+ int length, word_found_seen, other_completion;
+ t_weelist *ptr_weelist, *ptr_weelist2;
length = strlen (completion->base_word) - 1;
word_found_seen = 0;
- for (ptr_index = index_commands; ptr_index; ptr_index = ptr_index->next_index)
+ other_completion = 0;
+ for (ptr_weelist = index_commands; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
{
- if (strncasecmp (ptr_index->command_name, completion->base_word + 1, length) == 0)
+ if (strncasecmp (ptr_weelist->data, completion->base_word + 1, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
- completion->word_found = ptr_index->command_name;
+ completion->word_found = ptr_weelist->data;
+ for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
+ ptr_weelist2 = ptr_weelist2->next_weelist)
+ {
+ if (strncasecmp (ptr_weelist2->data,
+ completion->base_word + 1, length) == 0)
+ other_completion++;
+ }
+ if (other_completion == 0)
+ completion->position = -1;
+ else
+ if (completion->position < 0)
+ completion->position = 0;
return;
}
+ other_completion++;
}
if (completion->word_found &&
- (strcasecmp (ptr_index->command_name, completion->word_found) == 0))
+ (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
@@ -95,11 +572,15 @@ completion_command (t_completion *completion)
void
completion_nick (t_completion *completion, t_irc_channel *channel)
{
- int length, word_found_seen;
- t_irc_nick *ptr_nick;
+ int length, word_found_seen, other_completion;
+ t_irc_nick *ptr_nick, *ptr_nick2;
+ if (!channel)
+ return;
+
length = strlen (completion->base_word);
word_found_seen = 0;
+ other_completion = 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
@@ -107,8 +588,21 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_nick->nick;
+ for (ptr_nick2 = ptr_nick->next_nick; ptr_nick2;
+ ptr_nick2 = ptr_nick2->next_nick)
+ {
+ if (strncasecmp (ptr_nick2->nick,
+ completion->base_word, length) == 0)
+ other_completion++;
+ }
+ if (other_completion == 0)
+ completion->position = -1;
+ else
+ if (completion->position < 0)
+ completion->position = 0;
return;
}
+ other_completion++;
}
if (completion->word_found &&
(strcasecmp (ptr_nick->nick, completion->word_found) == 0))
@@ -122,90 +616,104 @@ completion_nick (t_completion *completion, t_irc_channel *channel)
}
/*
- * completion_search: complete word according to context
+ * completion_command_arg: complete a command argument
*/
void
-completion_search (t_completion *completion, void *channel,
- char *buffer, int size, int pos)
+completion_command_arg (t_completion *completion, t_irc_channel *channel)
{
- int i, pos_start, pos_end;
- char *old_word_found;
+ int length, word_found_seen, other_completion;
+ t_weelist *ptr_weelist, *ptr_weelist2;
- /* TODO: complete when no word is there with command according to context */
- if (size == 0)
+ length = strlen (completion->base_word);
+ word_found_seen = 0;
+ other_completion = 0;
+ for (ptr_weelist = completion->completion_list; ptr_weelist;
+ ptr_weelist = ptr_weelist->next_weelist)
+ {
+ if (strncasecmp (ptr_weelist->data, completion->base_word, length) == 0)
+ {
+ if ((!completion->word_found) || word_found_seen)
+ {
+ completion->word_found = ptr_weelist->data;
+ for (ptr_weelist2 = ptr_weelist->next_weelist; ptr_weelist2;
+ ptr_weelist2 = ptr_weelist2->next_weelist)
+ {
+ if (strncasecmp (ptr_weelist2->data,
+ completion->base_word, length) == 0)
+ other_completion++;
+ }
+ if (other_completion == 0)
+ completion->position = -1;
+ else
+ if (completion->position < 0)
+ completion->position = 0;
+ return;
+ }
+ other_completion++;
+ }
+ if (completion->word_found &&
+ (strcasecmp (ptr_weelist->data, completion->word_found) == 0))
+ word_found_seen = 1;
+ }
+ if (completion->word_found)
{
completion->word_found = NULL;
- return;
+ completion_command_arg (completion, channel);
}
+}
+
+/*
+ * completion_search: complete word according to context
+ */
+
+void
+completion_search (t_completion *completion, void *channel,
+ char *buffer, int size, int pos)
+{
+ char *old_word_found;
- /* if new complation => look for base word */
+ /* if new completion => look for base word */
if (pos != completion->position)
{
completion->word_found = NULL;
-
- if ((pos == size) || (buffer[pos-1] != ' '))
- pos--;
- if ((pos > 0) && (buffer[pos] == ' '))
- return;
-
- i = pos;
- while ((i >= 0) && (buffer[i] != ' '))
- i--;
- pos_start = i + 1;
- i = pos;
- while ((i < size) && (buffer[i] != ' '))
- i++;
- pos_end = i - 1;
-
- if (pos_start > pos_end)
- return;
-
- completion->base_word_pos = pos_start;
-
- if (completion->base_word)
- free (completion->base_word);
- completion->base_word = (char *) malloc (pos_end - pos_start + 2);
-
- for (i = pos_start; i <= pos_end; i++)
- completion->base_word[i - pos_start] = buffer[i];
- completion->base_word[pos_end - pos_start + 1] = '\0';
-
- if (completion->base_word[0] == '/')
- completion->position_replace = pos_start + 1;
- else
- completion->position_replace = pos_start;
+ completion_find_context (completion, channel, buffer, size, pos);
}
/* completion */
old_word_found = completion->word_found;
- if (completion->base_word[0] == '/')
+ switch (completion->context)
{
- completion_command (completion);
- if (completion->word_found)
- {
- if (old_word_found)
- completion->diff_size = strlen (completion->word_found) -
- strlen (old_word_found);
+ case COMPLETION_NULL:
+ /* should never be executed */
+ return;
+ case COMPLETION_NICK:
+ if (channel)
+ completion_nick (completion, (t_irc_channel *)channel);
else
- completion->diff_size = strlen (completion->word_found) -
- strlen (completion->base_word) + 1;
- }
+ return;
+ break;
+ case COMPLETION_COMMAND:
+ completion_command (completion);
+ break;
+ case COMPLETION_COMMAND_ARG:
+ if (completion->completion_list)
+ completion_command_arg (completion, (t_irc_channel *)channel);
+ else
+ completion_nick (completion, (t_irc_channel *)channel);
+ break;
}
- else
+ if (completion->word_found)
{
- if (channel)
+ if (old_word_found)
+ completion->diff_size = strlen (completion->word_found) -
+ strlen (old_word_found);
+ else
{
- completion_nick (completion, (t_irc_channel *)channel);
- if (completion->word_found)
- {
- if (old_word_found)
- completion->diff_size = strlen (completion->word_found) -
- strlen (old_word_found);
- else
- completion->diff_size = strlen (completion->word_found) -
- strlen (completion->base_word);
- }
+ completion->diff_size = strlen (completion->word_found) -
+ strlen (completion->base_word);
+ if (completion->context == COMPLETION_COMMAND)
+ completion->diff_size++;
}
}
}
diff --git a/src/common/completion.h b/src/common/completion.h
index a040b03e0..9798a03a1 100644
--- a/src/common/completion.h
+++ b/src/common/completion.h
@@ -21,16 +21,33 @@
#ifndef __WEECHAT_COMPLETION_H
#define __WEECHAT_COMPLETION_H 1
+#include "weelist.h"
+
+#define COMPLETION_NULL 0
+#define COMPLETION_NICK 1
+#define COMPLETION_COMMAND 2
+#define COMPLETION_COMMAND_ARG 3
+
typedef struct t_completion t_completion;
struct t_completion
{
- char *base_word; /* word to complete (when Tab was pressed) */
- int base_word_pos; /* beggining of base word */
- int position; /* position where we shoud complete */
- char *word_found; /* word found (to replace base word) */
- int position_replace; /* position where word should be replaced */
- int diff_size; /* size difference (< 0 = char(s) deleted) */
+ /* completion context */
+ int context; /* context: null, nick, command, cmd arg */
+ char *base_command; /* command with arg to complete (can be NULL) */
+ int base_command_arg; /* # arg to complete (if context is cmd arg) */
+ char *base_word; /* word to complete (when Tab was pressed) */
+ int base_word_pos; /* beggining of base word */
+ int position; /* position where Tab was pressed */
+
+ /* for command argument completion */
+ t_weelist *completion_list; /* data list for completion */
+ t_weelist *last_completion; /* last data element for completion */
+
+ /* completion found */
+ char *word_found; /* word found (to replace base word) */
+ int position_replace; /* position where word has to be replaced */
+ int diff_size; /* size difference (< 0 = char(s) deleted) */
};
extern void completion_init (t_completion *);
diff --git a/src/common/weechat.c b/src/common/weechat.c
index 0243383aa..95a468bfa 100644
--- a/src/common/weechat.c
+++ b/src/common/weechat.c
@@ -525,7 +525,7 @@ main (int argc, char *argv[])
wee_parse_args (argc, argv); /* parse command line args */
wee_create_home_dirs (); /* create WeeChat directories */
wee_init_log (); /* init log file */
- index_command_build (); /* build commands index for completion */
+ command_index_build (); /* build commands index for completion */
switch (config_read ()) /* read configuration */
{
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c
index c57d20b74..6875e8df9 100644
--- a/src/common/weeconfig.c
+++ b/src/common/weeconfig.c
@@ -218,7 +218,7 @@ t_config_option weechat_options_colors[] =
{ "col_title", N_("color for title bar"),
N_("color for title bar"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_title, NULL, &config_change_color },
+ "default", NULL, &cfg_col_title, NULL, &config_change_color },
{ "col_title_bg", N_("background for title bar"),
N_("background for title bar"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -228,11 +228,11 @@ t_config_option weechat_options_colors[] =
{ "col_chat", N_("color for chat text"),
N_("color for chat text"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_chat, NULL, &config_change_color },
+ "default", NULL, &cfg_col_chat, NULL, &config_change_color },
{ "col_chat_time", N_("color for time"),
N_("color for time in chat window"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_chat_time, NULL, &config_change_color },
+ "default", NULL, &cfg_col_chat_time, NULL, &config_change_color },
{ "col_chat_time_sep", N_("color for time separator"),
N_("color for time separator (chat window)"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -274,7 +274,7 @@ t_config_option weechat_options_colors[] =
{ "col_status", N_("color for status bar"),
N_("color for status bar"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_status, NULL, &config_change_color },
+ "default", NULL, &cfg_col_status, NULL, &config_change_color },
{ "col_status_delimiters", N_("color for status bar delimiters"),
N_("color for status bar delimiters"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -290,7 +290,7 @@ t_config_option weechat_options_colors[] =
{ "col_status_data_other", N_("color for window with new data (not messages)"),
N_("color for window with new data (not messages) (status bar)"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_status_data_other, NULL, &config_change_color },
+ "default", NULL, &cfg_col_status_data_other, NULL, &config_change_color },
{ "col_status_more", N_("color for \"*MORE*\" text"),
N_("color for window with new data (status bar)"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -318,7 +318,7 @@ t_config_option weechat_options_colors[] =
{ "col_input", N_("color for input text"),
N_("color for input text"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_input, NULL, &config_change_color },
+ "default", NULL, &cfg_col_input, NULL, &config_change_color },
{ "col_input_channel", N_("color for input text (channel name)"),
N_("color for input text (channel name)"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -336,7 +336,7 @@ t_config_option weechat_options_colors[] =
{ "col_nick", N_("color for nicknames"),
N_("color for nicknames"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_nick, NULL, &config_change_color },
+ "default", NULL, &cfg_col_nick, NULL, &config_change_color },
{ "col_nick_op", N_("color for operator symbol"),
N_("color for operator symbol"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -360,7 +360,7 @@ t_config_option weechat_options_colors[] =
{ "col_nick_private", N_("color for other nick in private window"),
N_("color for other nick in private window"),
OPTION_TYPE_COLOR, 0, 0, 0,
- "gray", NULL, &cfg_col_nick_private, NULL, &config_change_color },
+ "default", NULL, &cfg_col_nick_private, NULL, &config_change_color },
{ "col_nick_bg", N_("background for nicknames"),
N_("background for nicknames"),
OPTION_TYPE_COLOR, 0, 0, 0,
@@ -1017,7 +1017,7 @@ config_default_values ()
if (int_value < 0)
gui_printf (NULL,
_("%s unable to assign default int with string (\"%s\")\n"),
- weechat_options[i][j].default_string);
+ WEECHAT_WARNING, weechat_options[i][j].default_string);
else
*weechat_options[i][j].ptr_int =
int_value;
@@ -1028,7 +1028,7 @@ config_default_values ()
weechat_options[i][j].default_string))
gui_printf (NULL,
_("%s unable to assign default color (\"%s\")\n"),
- weechat_options[i][j].default_string);
+ WEECHAT_WARNING, weechat_options[i][j].default_string);
break;
case OPTION_TYPE_STRING:
*weechat_options[i][j].ptr_string =
@@ -1130,96 +1130,105 @@ config_read ()
}
else
{
- pos = strchr (line, '=');
- if (pos == NULL)
+ if (section == CONFIG_SECTION_NONE)
+ {
gui_printf (NULL,
- _("%s %s, line %d: invalid syntax, missing \"=\"\n"),
+ _("%s %s, line %d: invalid section for option, line is ignored\n"),
WEECHAT_WARNING, filename, line_number);
+ }
else
{
- pos[0] = '\0';
- pos++;
- pos2 = strchr (pos, '\r');
- if (pos2 != NULL)
- pos2[0] = '\0';
- pos2 = strchr (pos, '\n');
- if (pos2 != NULL)
- pos2[0] = '\0';
-
- if (section == CONFIG_SECTION_ALIAS)
- {
- if (alias_new (line, pos))
- index_command_new (line);
- }
+ pos = strchr (line, '=');
+ if (pos == NULL)
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid syntax, missing \"=\"\n"),
+ WEECHAT_WARNING, filename, line_number);
else
{
- option_number = -1;
- for (i = 0;
- weechat_options[section][i].option_name; i++)
+ pos[0] = '\0';
+ pos++;
+ pos2 = strchr (pos, '\r');
+ if (pos2 != NULL)
+ pos2[0] = '\0';
+ pos2 = strchr (pos, '\n');
+ if (pos2 != NULL)
+ pos2[0] = '\0';
+
+ if (section == CONFIG_SECTION_ALIAS)
{
- if (strcmp
- (weechat_options[section][i].option_name,
- ptr_line) == 0)
- {
- option_number = i;
- break;
- }
+ if (alias_new (line, pos))
+ weelist_add (&index_commands, &last_index_command, line);
}
- if (option_number < 0)
- gui_printf (NULL,
- _("%s %s, line %d: invalid option \"%s\"\n"),
- WEECHAT_WARNING, filename, line_number, ptr_line);
else
{
- if (config_option_set_value (&weechat_options[section][option_number], pos) < 0)
+ option_number = -1;
+ for (i = 0;
+ weechat_options[section][i].option_name; i++)
+ {
+ if (strcmp
+ (weechat_options[section][i].option_name,
+ ptr_line) == 0)
+ {
+ option_number = i;
+ break;
+ }
+ }
+ if (option_number < 0)
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid option \"%s\"\n"),
+ WEECHAT_WARNING, filename, line_number, ptr_line);
+ else
{
- switch (weechat_options[section]
- [option_number].option_type)
+ if (config_option_set_value (&weechat_options[section][option_number], pos) < 0)
{
- case OPTION_TYPE_BOOLEAN:
- gui_printf (NULL,
- _("%s %s, line %d: invalid value for"
- "option '%s'\n"
- "Expected: boolean value: "
- "'off' or 'on'\n"),
- WEECHAT_WARNING, filename,
- line_number, ptr_line);
- break;
- case OPTION_TYPE_INT:
- gui_printf (NULL,
- _("%s %s, line %d: invalid value for "
- "option '%s'\n"
- "Expected: integer between %d "
- "and %d\n"),
- WEECHAT_WARNING, filename,
- line_number, ptr_line,
- weechat_options[section][option_number].min,
- weechat_options[section][option_number].max);
- break;
- case OPTION_TYPE_INT_WITH_STRING:
- gui_printf (NULL,
- _("%s %s, line %d: invalid value for "
- "option '%s'\n"
- "Expected: one of these strings: "),
- WEECHAT_WARNING, filename,
- line_number, ptr_line);
- i = 0;
- while (weechat_options[section][option_number].array_values[i])
- {
- gui_printf (NULL, "\"%s\" ",
- weechat_options[section][option_number].array_values[i]);
- i++;
- }
- gui_printf (NULL, "\n");
- break;
- case OPTION_TYPE_COLOR:
- gui_printf (NULL,
- _("%s %s, line %d: invalid color "
- "name for option '%s'\n"),
- WEECHAT_WARNING, filename,
- line_number,
- ptr_line);
- break;
+ switch (weechat_options[section]
+ [option_number].option_type)
+ {
+ case OPTION_TYPE_BOOLEAN:
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid value for"
+ "option '%s'\n"
+ "Expected: boolean value: "
+ "'off' or 'on'\n"),
+ WEECHAT_WARNING, filename,
+ line_number, ptr_line);
+ break;
+ case OPTION_TYPE_INT:
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid value for "
+ "option '%s'\n"
+ "Expected: integer between %d "
+ "and %d\n"),
+ WEECHAT_WARNING, filename,
+ line_number, ptr_line,
+ weechat_options[section][option_number].min,
+ weechat_options[section][option_number].max);
+ break;
+ case OPTION_TYPE_INT_WITH_STRING:
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid value for "
+ "option '%s'\n"
+ "Expected: one of these strings: "),
+ WEECHAT_WARNING, filename,
+ line_number, ptr_line);
+ i = 0;
+ while (weechat_options[section][option_number].array_values[i])
+ {
+ gui_printf (NULL, "\"%s\" ",
+ weechat_options[section][option_number].array_values[i]);
+ i++;
+ }
+ gui_printf (NULL, "\n");
+ break;
+ case OPTION_TYPE_COLOR:
+ gui_printf (NULL,
+ _("%s %s, line %d: invalid color "
+ "name for option '%s'\n"),
+ WEECHAT_WARNING, filename,
+ line_number,
+ ptr_line);
+ break;
+ }
}
}
}
diff --git a/src/common/weelist.c b/src/common/weelist.c
new file mode 100644
index 000000000..e4bf30ef9
--- /dev/null
+++ b/src/common/weelist.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2003-2005 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* weelist.c: sorted lists management */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "weechat.h"
+#include "weelist.h"
+
+
+/*
+ * weelist_search: search date in a list
+ */
+
+t_weelist *
+weelist_search (t_weelist *weelist, char *data)
+{
+ t_weelist *ptr_weelist;
+
+ for (ptr_weelist = weelist; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
+ {
+ if (strcasecmp (data, ptr_weelist->data) == 0)
+ return ptr_weelist;
+ }
+ /* word not found in list */
+ return NULL;
+}
+
+/*
+ * weelist_find_pos: find position for data (keeping list sorted)
+ */
+
+t_weelist *
+weelist_find_pos (t_weelist *weelist, char *data)
+{
+ t_weelist *ptr_weelist;
+
+ for (ptr_weelist = weelist; ptr_weelist; ptr_weelist = ptr_weelist->next_weelist)
+ {
+ if (strcasecmp (data, ptr_weelist->data) < 0)
+ return ptr_weelist;
+ }
+ /* position not found, best position is at the end */
+ return NULL;
+}
+
+/*
+ * weelist_insert: insert an element to the list (at good position)
+ */
+
+void
+weelist_insert (t_weelist **weelist, t_weelist **last_weelist, t_weelist *element)
+{
+ t_weelist *pos_weelist;
+
+ pos_weelist = weelist_find_pos (*weelist, element->data);
+
+ if (*weelist)
+ {
+ if (pos_weelist)
+ {
+ /* insert data into the list (before position found) */
+ element->prev_weelist = pos_weelist->prev_weelist;
+ element->next_weelist = pos_weelist;
+ if (pos_weelist->prev_weelist)
+ pos_weelist->prev_weelist->next_weelist = element;
+ else
+ *weelist = element;
+ pos_weelist->prev_weelist = element;
+ }
+ else
+ {
+ /* add data to the end */
+ element->prev_weelist = *last_weelist;
+ element->next_weelist = NULL;
+ (*last_weelist)->next_weelist = element;
+ *last_weelist = element;
+ }
+ }
+ else
+ {
+ element->prev_weelist = NULL;
+ element->next_weelist = NULL;
+ *weelist = element;
+ *last_weelist = element;
+ }
+}
+
+/*
+ * weelist_add: create new data and add it to list
+ */
+
+t_weelist *
+weelist_add (t_weelist **weelist, t_weelist **last_weelist, char *data)
+{
+ t_weelist *new_weelist;
+
+ if (!data || (!data[0]))
+ return NULL;
+
+ if ((new_weelist = ((t_weelist *) malloc (sizeof (t_weelist)))))
+ {
+ new_weelist->data = strdup (data);
+ weelist_insert (weelist, last_weelist, new_weelist);
+ return new_weelist;
+ }
+ /* failed to allocate new element */
+ return NULL;
+}
+
+/*
+ * weelist_remove: free an element in a list
+ */
+
+void
+weelist_remove (t_weelist **weelist, t_weelist **last_weelist, t_weelist *element)
+{
+ t_weelist *new_weelist;
+
+ /* remove element from list */
+ if (*last_weelist == element)
+ *last_weelist = element->prev_weelist;
+ if (element->prev_weelist)
+ {
+ (element->prev_weelist)->next_weelist = element->next_weelist;
+ new_weelist = *weelist;
+ }
+ else
+ new_weelist = element->next_weelist;
+
+ if (element->next_weelist)
+ (element->next_weelist)->prev_weelist = element->prev_weelist;
+
+ /* free data */
+ if (element->data)
+ free (element->data);
+ free (element);
+ *weelist = new_weelist;
+}
diff --git a/src/common/weelist.h b/src/common/weelist.h
new file mode 100644
index 000000000..14a869968
--- /dev/null
+++ b/src/common/weelist.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2003-2005 by FlashCode <flashcode@flashtux.org>
+ * See README for License detail, AUTHORS for developers list.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef __WEECHAT_LIST_H
+#define __WEECHAT_LIST_H 1
+
+typedef struct t_weelist t_weelist;
+
+struct t_weelist
+{
+ char *data;
+ t_weelist *prev_weelist;
+ t_weelist *next_weelist;
+};
+
+t_weelist *weelist_search (t_weelist *, char *);
+t_weelist *weelist_add (t_weelist **, t_weelist **, char *);
+void weelist_remove (t_weelist **, t_weelist **, t_weelist *);
+
+#endif /* weelist.h */
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 767e30fc8..3c89eeeea 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -41,22 +41,21 @@
t_gui_color gui_colors[] =
-{ { "default", -1 | A_NORMAL },
- { "black", COLOR_BLACK | A_NORMAL },
- { "red", COLOR_RED | A_NORMAL },
- { "lightred", COLOR_RED | A_BOLD },
- { "green", COLOR_GREEN | A_NORMAL },
- { "lightgreen", COLOR_GREEN | A_BOLD },
- { "brown", COLOR_YELLOW | A_NORMAL },
- { "yellow", COLOR_YELLOW | A_BOLD },
- { "blue", COLOR_BLUE | A_NORMAL },
- { "lightblue", COLOR_BLUE | A_BOLD },
- { "magenta", COLOR_MAGENTA | A_NORMAL },
+{ { "default", -1 | A_NORMAL },
+ { "black", COLOR_BLACK | A_NORMAL },
+ { "red", COLOR_RED | A_NORMAL },
+ { "lightred", COLOR_RED | A_BOLD },
+ { "green", COLOR_GREEN | A_NORMAL },
+ { "lightgreen", COLOR_GREEN | A_BOLD },
+ { "brown", COLOR_YELLOW | A_NORMAL },
+ { "yellow", COLOR_YELLOW | A_BOLD },
+ { "blue", COLOR_BLUE | A_NORMAL },
+ { "lightblue", COLOR_BLUE | A_BOLD },
+ { "magenta", COLOR_MAGENTA | A_NORMAL },
{ "lightmagenta", COLOR_MAGENTA | A_BOLD },
- { "cyan", COLOR_CYAN | A_NORMAL },
- { "lightcyan", COLOR_CYAN | A_BOLD },
- { "gray", COLOR_WHITE },
- { "white", COLOR_WHITE | A_BOLD },
+ { "cyan", COLOR_CYAN | A_NORMAL },
+ { "lightcyan", COLOR_CYAN | A_BOLD },
+ { "white", COLOR_WHITE | A_BOLD },
{ NULL, 0 }
};
@@ -892,6 +891,9 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
char format_more[32];
int i, first_mode;
+ /* make gcc happy */
+ (void) buffer;
+
if (!gui_ok)
return;
@@ -1797,43 +1799,43 @@ gui_init_colors ()
init_pair (COLOR_DCC_ABORTED,
cfg_col_dcc_aborted & A_CHARTEXT, cfg_col_chat_bg);
- color_attr[COLOR_WIN_TITLE - 1] = cfg_col_title & A_BOLD;
- color_attr[COLOR_WIN_CHAT - 1] = cfg_col_chat & A_BOLD;
- color_attr[COLOR_WIN_CHAT_TIME - 1] = cfg_col_chat_time & A_BOLD;
- color_attr[COLOR_WIN_CHAT_TIME_SEP - 1] = cfg_col_chat_time_sep & A_BOLD;
- color_attr[COLOR_WIN_CHAT_DARK - 1] = cfg_col_chat_dark & A_BOLD;
- color_attr[COLOR_WIN_CHAT_PREFIX1 - 1] = cfg_col_chat_prefix1 & A_BOLD;
- color_attr[COLOR_WIN_CHAT_PREFIX2 - 1] = cfg_col_chat_prefix2 & A_BOLD;
- color_attr[COLOR_WIN_CHAT_NICK - 1] = cfg_col_chat_nick & A_BOLD;
- color_attr[COLOR_WIN_CHAT_HOST - 1] = cfg_col_chat_host & A_BOLD;
- color_attr[COLOR_WIN_CHAT_CHANNEL - 1] = cfg_col_chat_channel & A_BOLD;
- color_attr[COLOR_WIN_CHAT_DARK - 1] = cfg_col_chat_dark & A_BOLD;
- color_attr[COLOR_WIN_CHAT_HIGHLIGHT - 1] = cfg_col_chat_highlight & A_BOLD;
- color_attr[COLOR_WIN_STATUS - 1] = cfg_col_status & A_BOLD;
- color_attr[COLOR_WIN_STATUS_DELIMITERS - 1] = cfg_col_status_delimiters & A_BOLD;
- color_attr[COLOR_WIN_STATUS_DATA_MSG - 1] = cfg_col_status_data_msg & A_BOLD;
- color_attr[COLOR_WIN_STATUS_DATA_HIGHLIGHT - 1] = cfg_col_status_data_highlight & A_BOLD;
- color_attr[COLOR_WIN_STATUS_DATA_OTHER - 1] = cfg_col_status_data_other & A_BOLD;
- color_attr[COLOR_WIN_STATUS_MORE - 1] = cfg_col_status_more & A_BOLD;
- color_attr[COLOR_WIN_INFOBAR - 1] = cfg_col_infobar & A_BOLD;
- color_attr[COLOR_WIN_INFOBAR_HIGHLIGHT - 1] = cfg_col_infobar_highlight & A_BOLD;
- color_attr[COLOR_WIN_INPUT - 1] = cfg_col_input & A_BOLD;
- color_attr[COLOR_WIN_INPUT_CHANNEL - 1] = cfg_col_input_channel & A_BOLD;
- color_attr[COLOR_WIN_INPUT_NICK - 1] = cfg_col_input_nick & A_BOLD;
- color_attr[COLOR_WIN_NICK - 1] = cfg_col_nick & A_BOLD;
- color_attr[COLOR_WIN_NICK_OP - 1] = cfg_col_nick_op & A_BOLD;
- color_attr[COLOR_WIN_NICK_HALFOP - 1] = cfg_col_nick_halfop & A_BOLD;
- color_attr[COLOR_WIN_NICK_VOICE - 1] = cfg_col_nick_voice & A_BOLD;
+ color_attr[COLOR_WIN_TITLE - 1] = (cfg_col_title >= 0) ? cfg_col_title & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT - 1] = (cfg_col_chat >= 0) ? cfg_col_chat & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_TIME - 1] = (cfg_col_chat_time >= 0) ? cfg_col_chat_time & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_TIME_SEP - 1] = (cfg_col_chat_time_sep >= 0) ? cfg_col_chat_time_sep & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_DARK - 1] = (cfg_col_chat_dark >= 0) ? cfg_col_chat_dark & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_PREFIX1 - 1] = (cfg_col_chat_prefix1 >= 0) ? cfg_col_chat_prefix1 & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_PREFIX2 - 1] = (cfg_col_chat_prefix2 >= 0) ? cfg_col_chat_prefix2 & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_NICK - 1] = (cfg_col_chat_nick >= 0) ? cfg_col_chat_nick & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_HOST - 1] = (cfg_col_chat_host >= 0) ? cfg_col_chat_host & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_CHANNEL - 1] = (cfg_col_chat_channel >= 0) ? cfg_col_chat_channel & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_DARK - 1] = (cfg_col_chat_dark >= 0) ? cfg_col_chat_dark & A_BOLD : 0;
+ color_attr[COLOR_WIN_CHAT_HIGHLIGHT - 1] = (cfg_col_chat_highlight >= 0) ? cfg_col_chat_highlight & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS - 1] = (cfg_col_status >= 0) ? cfg_col_status & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS_DELIMITERS - 1] = (cfg_col_status_delimiters >= 0) ? cfg_col_status_delimiters & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS_DATA_MSG - 1] = (cfg_col_status_data_msg >= 0) ? cfg_col_status_data_msg & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS_DATA_HIGHLIGHT - 1] = (cfg_col_status_data_highlight >= 0) ? cfg_col_status_data_highlight & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS_DATA_OTHER - 1] = (cfg_col_status_data_other >= 0) ? cfg_col_status_data_other & A_BOLD : 0;
+ color_attr[COLOR_WIN_STATUS_MORE - 1] = (cfg_col_status_more >= 0) ? cfg_col_status_more & A_BOLD : 0;
+ color_attr[COLOR_WIN_INFOBAR - 1] = (cfg_col_infobar >= 0) ? cfg_col_infobar & A_BOLD : 0;
+ color_attr[COLOR_WIN_INFOBAR_HIGHLIGHT - 1] = (cfg_col_infobar_highlight >= 0) ? cfg_col_infobar_highlight & A_BOLD : 0;
+ color_attr[COLOR_WIN_INPUT - 1] = (cfg_col_input >= 0) ? cfg_col_input & A_BOLD : 0;
+ color_attr[COLOR_WIN_INPUT_CHANNEL - 1] = (cfg_col_input_channel >= 0) ? cfg_col_input_channel & A_BOLD : 0;
+ color_attr[COLOR_WIN_INPUT_NICK - 1] = (cfg_col_input_nick >= 0) ? cfg_col_input_nick & A_BOLD : 0;
+ color_attr[COLOR_WIN_NICK - 1] = (cfg_col_nick >= 0) ? cfg_col_nick & A_BOLD : 0;
+ color_attr[COLOR_WIN_NICK_OP - 1] = (cfg_col_nick_op >= 0) ? cfg_col_nick_op & A_BOLD : 0;
+ color_attr[COLOR_WIN_NICK_HALFOP - 1] = (cfg_col_nick_halfop >= 0) ? cfg_col_nick_halfop & A_BOLD : 0;
+ color_attr[COLOR_WIN_NICK_VOICE - 1] = (cfg_col_nick_voice >= 0) ? cfg_col_nick_voice & A_BOLD : 0;
color_attr[COLOR_WIN_NICK_SEP - 1] = 0;
- color_attr[COLOR_WIN_NICK_SELF - 1] = cfg_col_nick_self & A_BOLD;
- color_attr[COLOR_WIN_NICK_PRIVATE - 1] = cfg_col_nick_private & A_BOLD;
- color_attr[COLOR_DCC_SELECTED - 1] = cfg_col_dcc_selected & A_BOLD;
- color_attr[COLOR_DCC_WAITING - 1] = cfg_col_dcc_waiting & A_BOLD;
- color_attr[COLOR_DCC_CONNECTING - 1] = cfg_col_dcc_connecting & A_BOLD;
- color_attr[COLOR_DCC_ACTIVE - 1] = cfg_col_dcc_active & A_BOLD;
- color_attr[COLOR_DCC_DONE - 1] = cfg_col_dcc_done & A_BOLD;
- color_attr[COLOR_DCC_FAILED - 1] = cfg_col_dcc_failed & A_BOLD;
- color_attr[COLOR_DCC_ABORTED - 1] = cfg_col_dcc_aborted & A_BOLD;
+ color_attr[COLOR_WIN_NICK_SELF - 1] = (cfg_col_nick_self >= 0) ? cfg_col_nick_self & A_BOLD : 0;
+ color_attr[COLOR_WIN_NICK_PRIVATE - 1] = (cfg_col_nick_private >= 0) ? cfg_col_nick_private & A_BOLD : 0;
+ color_attr[COLOR_DCC_SELECTED - 1] = (cfg_col_dcc_selected >= 0) ? cfg_col_dcc_selected & A_BOLD : 0;
+ color_attr[COLOR_DCC_WAITING - 1] = (cfg_col_dcc_waiting >= 0) ? cfg_col_dcc_waiting & A_BOLD : 0;
+ color_attr[COLOR_DCC_CONNECTING - 1] = (cfg_col_dcc_connecting >= 0) ? cfg_col_dcc_connecting & A_BOLD : 0;
+ color_attr[COLOR_DCC_ACTIVE - 1] = (cfg_col_dcc_active >= 0) ? cfg_col_dcc_active & A_BOLD : 0;
+ color_attr[COLOR_DCC_DONE - 1] = (cfg_col_dcc_done >= 0) ? cfg_col_dcc_done & A_BOLD : 0;
+ color_attr[COLOR_DCC_FAILED - 1] = (cfg_col_dcc_failed >= 0) ? cfg_col_dcc_failed & A_BOLD : 0;
+ color_attr[COLOR_DCC_ABORTED - 1] = (cfg_col_dcc_aborted >= 0) ? cfg_col_dcc_aborted & A_BOLD : 0;
}
}
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index 54ed0dccc..eec1532ff 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -311,16 +311,16 @@ gui_read_keyb ()
gui_current_window->buffer->input_buffer,
gui_current_window->buffer->input_buffer_size,
gui_current_window->buffer->input_buffer_pos);
+
if (gui_current_window->buffer->completion.word_found)
{
/* replace word with new completed word into input buffer */
- gui_current_window->buffer->input_buffer_size +=
- gui_current_window->buffer->completion.diff_size;
- gui_optimize_input_buffer_size (gui_current_window->buffer);
- gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
-
if (gui_current_window->buffer->completion.diff_size > 0)
{
+ gui_current_window->buffer->input_buffer_size +=
+ gui_current_window->buffer->completion.diff_size;
+ gui_optimize_input_buffer_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
for (i = gui_current_window->buffer->input_buffer_size - 1;
i >= gui_current_window->buffer->completion.position_replace +
(int)strlen (gui_current_window->buffer->completion.word_found); i--)
@@ -336,6 +336,10 @@ gui_read_keyb ()
gui_current_window->buffer->input_buffer[i] =
gui_current_window->buffer->input_buffer[i -
gui_current_window->buffer->completion.diff_size];
+ gui_current_window->buffer->input_buffer_size +=
+ gui_current_window->buffer->completion.diff_size;
+ gui_optimize_input_buffer_size (gui_current_window->buffer);
+ gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_size] = '\0';
}
strncpy (gui_current_window->buffer->input_buffer + gui_current_window->buffer->completion.position_replace,
@@ -344,35 +348,45 @@ gui_read_keyb ()
gui_current_window->buffer->input_buffer_pos =
gui_current_window->buffer->completion.position_replace +
strlen (gui_current_window->buffer->completion.word_found);
- gui_current_window->buffer->completion.position =
- gui_current_window->buffer->input_buffer_pos;
+
+ /* position is < 0 this means only one word was found to complete,
+ so reinit to stop completion */
+ if (gui_current_window->buffer->completion.position >= 0)
+ gui_current_window->buffer->completion.position =
+ gui_current_window->buffer->input_buffer_pos;
/* add space or completor to the end of completion, if needed */
- if (gui_current_window->buffer->completion.base_word[0] == '/')
+ if ((gui_current_window->buffer->completion.context == COMPLETION_COMMAND)
+ || (gui_current_window->buffer->completion.context == COMPLETION_COMMAND_ARG))
{
if (gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_pos] != ' ')
gui_buffer_insert_string (gui_current_window->buffer,
" ",
gui_current_window->buffer->input_buffer_pos);
- gui_current_window->buffer->completion.position++;
+ if (gui_current_window->buffer->completion.position >= 0)
+ gui_current_window->buffer->completion.position++;
gui_current_window->buffer->input_buffer_pos++;
}
else
{
- if (gui_current_window->buffer->completion.base_word_pos == 0)
+ /* add nick completor if position 0 and completing nick */
+ if ((gui_current_window->buffer->completion.base_word_pos == 0)
+ && (gui_current_window->buffer->completion.context == COMPLETION_NICK))
{
if (strncmp (gui_current_window->buffer->input_buffer + gui_current_window->buffer->input_buffer_pos,
cfg_look_completor, strlen (cfg_look_completor)) != 0)
gui_buffer_insert_string (gui_current_window->buffer,
cfg_look_completor,
gui_current_window->buffer->input_buffer_pos);
- gui_current_window->buffer->completion.position += strlen (cfg_look_completor);
+ if (gui_current_window->buffer->completion.position >= 0)
+ gui_current_window->buffer->completion.position += strlen (cfg_look_completor);
gui_current_window->buffer->input_buffer_pos += strlen (cfg_look_completor);
if (gui_current_window->buffer->input_buffer[gui_current_window->buffer->input_buffer_pos] != ' ')
gui_buffer_insert_string (gui_current_window->buffer,
" ",
gui_current_window->buffer->input_buffer_pos);
- gui_current_window->buffer->completion.position++;
+ if (gui_current_window->buffer->completion.position >= 0)
+ gui_current_window->buffer->completion.position++;
gui_current_window->buffer->input_buffer_pos++;
}
}
diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c
index 17576ff5f..36cb5dda0 100644
--- a/src/gui/gui-common.c
+++ b/src/gui/gui-common.c
@@ -145,8 +145,8 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
((t_irc_server *)(server))->buffer = gui_buffers;
if (channel)
((t_irc_channel *)(channel))->buffer = gui_buffers;
- SERVER(gui_buffers) = server;
- CHANNEL(gui_buffers) = channel;
+ gui_buffers->server = server;
+ gui_buffers->channel = channel;
if (cfg_log_auto_server)
log_start (gui_buffers);
return gui_buffers;
@@ -158,8 +158,8 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc,
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
/* assign server and channel to buffer */
- SERVER(new_buffer) = server;
- CHANNEL(new_buffer) = channel;
+ new_buffer->server = server;
+ new_buffer->channel = channel;
new_buffer->dcc = dcc;
/* assign buffer to server and channel */
if (server && !channel)
@@ -381,6 +381,9 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another)
if (hotlist_initial_buffer == buffer)
hotlist_initial_buffer = NULL;
+ if (buffer_before_dcc == buffer)
+ buffer_before_dcc = NULL;
+
if (switch_to_another)
{
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c
index 87b0da101..5b2a2d6c1 100644
--- a/src/irc/irc-commands.c
+++ b/src/irc/irc-commands.c
@@ -52,10 +52,10 @@ t_irc_command irc_commands[] =
2, 3, 1, NULL, irc_cmd_send_dcc, NULL },
{ "deop", N_("removes channel operator status from nickname(s)"),
N_("nickname [nickname]"), "",
- 1, 1, 1, irc_cmd_send_deop, NULL, NULL },
+ 1, MAX_ARGS, 1, irc_cmd_send_deop, NULL, NULL },
{ "devoice", N_("removes voice from nickname(s)"),
N_("nickname [nickname]"), "",
- 1, 1, 1, irc_cmd_send_devoice, NULL, NULL },
+ 1, MAX_ARGS, 1, irc_cmd_send_devoice, NULL, NULL },
{ "die", N_("shutdown the server"),
"", "",
0, 0, 1, NULL, irc_cmd_send_die, NULL },
@@ -136,7 +136,7 @@ t_irc_command irc_commands[] =
2, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL },
{ "names", N_("list nicknames on channels"),
N_("[channel[,channel]]"), N_("channel: channel name"),
- 0, MAX_ARGS, 1, NULL, irc_cmd_send_names, NULL },
+ 0, 1, 1, NULL, irc_cmd_send_names, NULL },
{ "nick", N_("change current nickname"),
N_("nickname"), N_("nickname: new nickname for current IRC server"),
1, 1, 1, irc_cmd_send_nick, NULL, irc_cmd_recv_nick },
@@ -145,7 +145,7 @@ t_irc_command irc_commands[] =
2, MAX_ARGS, 1, NULL, irc_cmd_send_notice, irc_cmd_recv_notice },
{ "op", N_("gives channel operator status to nickname(s)"),
N_("nickname [nickname]"), "",
- 1, 1, 1, irc_cmd_send_op, NULL, NULL },
+ 1, MAX_ARGS, 1, irc_cmd_send_op, NULL, NULL },
{ "oper", N_("get operator privileges"),
N_("user password"),
N_("user/password: used to get privileges on current IRC server"),
@@ -229,7 +229,7 @@ t_irc_command irc_commands[] =
0, 1, 1, NULL, irc_cmd_send_version, NULL },
{ "voice", N_("gives voice to nickname(s)"),
N_("nickname [nickname]"), "",
- 1, 1, 1, irc_cmd_send_voice, NULL, NULL },
+ 1, MAX_ARGS, 1, irc_cmd_send_voice, NULL, NULL },
{ "wallops", N_("send a message to all currently connected users who have "
"set the 'w' user mode for themselves"),
N_("text"), N_("text to send"),
diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c
index 47447f22a..80c22ff5c 100644
--- a/src/irc/irc-send.c
+++ b/src/irc/irc-send.c
@@ -248,6 +248,14 @@ int
irc_cmd_send_dcc (t_irc_server *server, char *arguments)
{
/* TODO: write this command! */
+
+ /* make gcc happy */
+ (void) server;
+ (void) arguments;
+
+ irc_display_prefix (server->buffer, PREFIX_ERROR);
+ gui_printf (server->buffer, _("This command is not developed!\n"));
+
return 0;
}
diff --git a/src/plugins/perl/wee-perl.c b/src/plugins/perl/wee-perl.c
index c33e1bc40..555250cde 100644
--- a/src/plugins/perl/wee-perl.c
+++ b/src/plugins/perl/wee-perl.c
@@ -313,8 +313,8 @@ static XS (XS_IRC_add_command_handler)
name = SvPV (ST (0), integer);
function = SvPV (ST (1), integer);
- if (!index_command_search (name))
- index_command_new (name);
+ if (!weelist_search (index_commands, name))
+ weelist_add (&index_commands, &last_index_command, name);
ptr_plugin_handler = plugin_handler_search (plugin_cmd_handlers, name);
if (ptr_plugin_handler)
{
diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c
index e9b238aed..cafcd1970 100644
--- a/src/plugins/plugins.c
+++ b/src/plugins/plugins.c
@@ -337,6 +337,9 @@ plugin_exec_command (char *user_command, char *arguments, char *server)
void
plugin_unload (int plugin_type, char *scriptname)
{
+ /* make gcc happy */
+ (void) scriptname;
+
#ifdef PLUGINS
switch (plugin_type)
{