diff mcabber/src/compl.c @ 98:f20831f7d349

[/trunk] Changeset 112 by mikael * Completion system enabled for commands. It almost works! ;-)
author mikael
date Wed, 20 Apr 2005 20:35:48 +0000
parents 9e6b7897ec37
children 93dcc4e15d4a
line wrap: on
line diff
--- a/mcabber/src/compl.c	Wed Apr 20 20:30:09 2005 +0000
+++ b/mcabber/src/compl.c	Wed Apr 20 20:35:48 2005 +0000
@@ -79,7 +79,8 @@
   for (sl_cat=compl_cat; sl_cat; sl_cat = g_slist_next(sl_cat)) {
     char *word = sl_cat->data;
     if (!strncmp(prefix, word, len)) {
-      c->list = g_slist_append(c->list, g_strdup(word+len)); // TODO sort
+      if (strlen(word) != len)
+        c->list = g_slist_append(c->list, g_strdup(word+len)); // TODO sort
     }
   }
   c->next = c->list;
@@ -89,6 +90,8 @@
 //  done_completion();
 void done_completion(void)
 {
+  if (!InputCompl)  return;
+
   // TODO free everything
   g_slist_free(InputCompl->list);
   g_free(InputCompl);
@@ -100,6 +103,7 @@
 //guint cancel_completion(compl *c)
 guint cancel_completion(void)
 {
+  if (!InputCompl)  return 0;
   return InputCompl->len_compl;
 }
 
@@ -108,6 +112,9 @@
 {
   compl* c = InputCompl;
   char *r;
+
+  if (!InputCompl)  return NULL;
+
   if (!c->next) {
     c->next = c->list;  // back to the beginning
     c->len_compl = 0;