# HG changeset patch # User Myhailo Danylenko # Date 1258411915 -7200 # Node ID 44bbdc96123419b4ae32a7a6123fc520f3340986 # Parent 63d8473df2c369e993d0cd84c18bab3d74e20556 Allow commands shading diff -r 63d8473df2c3 -r 44bbdc961234 mcabber/src/commands.c --- a/mcabber/src/commands.c Mon Nov 16 19:26:41 2009 +0200 +++ b/mcabber/src/commands.c Tue Nov 17 00:51:55 2009 +0200 @@ -106,21 +106,18 @@ GSList *loaded_modules = NULL; -static gint cmd_del_comparator (cmd *a, const char *name) -{ - return strcmp(a->name, name); -} - gpointer cmd_del(const char *name) { - GSList *command = g_slist_find_custom (Commands, name, (GCompareFunc) cmd_del_comparator); - if (command) { - cmd *cmnd = command->data; - gpointer userdata = cmnd->userdata; - Commands = g_slist_delete_link(Commands, command); - compl_del_category_word(COMPL_CMD, cmnd->name); - g_free(cmnd); - return userdata; + GSList *sl_cmd; + for (sl_cmd = Commands; sl_cmd; sl_cmd = sl_cmd->next) { + cmd *command = (cmd *) sl_cmd->data; + if (!strcmp (command->name, name)) { + gpointer userdata = command->userdata; + Commands = g_slist_delete_link(Commands, sl_cmd); + compl_del_category_word(COMPL_CMD, command->name); + g_free(command); + return userdata; + } } return NULL; } @@ -144,7 +141,7 @@ #ifdef MODULES_ENABLE n_cmd->userdata = userdata; #endif - Commands = g_slist_append(Commands, n_cmd); + Commands = g_slist_prepend(Commands, n_cmd); // Add to completion CMD category compl_add_category_word(COMPL_CMD, name); }