[PATCH] Old completions cleanup, part 2

Remove all inserts for the old completion tree and remove the rest of the api
and functions from shell.[ch].

diff -urN a/NQ/cmd.c head/NQ/cmd.c
--- a/NQ/cmd.c	2006-02-25 13:12:38.000000000 +1030
+++ head/NQ/cmd.c	2006-02-25 13:59:24.000000000 +1030
@@ -384,7 +384,6 @@
 	strcpy(a->name, s);
 	a->stree.string = a->name;
 	STree_Insert(&cmdalias_tree, &a->stree);
-	insert_alias_completion(a->name);
     }
 
 // copy the rest of the command line
@@ -580,8 +579,6 @@
     cmd->completion = NULL;
     cmd->stree.string = cmd->name;
     STree_Insert(&cmd_tree, &cmd->stree);
-
-    insert_command_completion(cmd_name);
 }
 
 void
diff -urN a/QW/common/cmd.c head/QW/common/cmd.c
--- a/QW/common/cmd.c	2006-02-25 13:12:38.000000000 +1030
+++ head/QW/common/cmd.c	2006-02-25 13:59:09.000000000 +1030
@@ -394,7 +394,6 @@
 	strcpy(a->name, s);
 	a->stree.string = a->name;
 	STree_Insert(&cmdalias_tree, &a->stree);
-	insert_alias_completion(a->name);
     }
 
 // copy the rest of the command line
@@ -590,8 +589,6 @@
     cmd->completion = NULL;
     cmd->stree.string = cmd->name;
     STree_Insert(&cmd_tree, &cmd->stree);
-
-    insert_command_completion(cmd_name);
 }
 
 void
diff -urN a/common/cvar.c head/common/cvar.c
--- a/common/cvar.c	2006-02-25 13:12:38.000000000 +1030
+++ head/common/cvar.c	2006-02-25 14:00:38.000000000 +1030
@@ -251,19 +251,15 @@
     value[511] = '\0';
     variable->string = Z_Malloc(1);
 
+    /*
+     * FIXME (BARF) - readonly cvars need to be initialised
+     *                developer 1 allows set
+     */
     /* set it through the function to be consistant */
-    /* FIXME (BARF) - readonly cvars need to be initialised; developer 1 allows set */
     old_developer = developer.value;
     developer.value = 1;
     Cvar_Set(variable->name, value);
     developer.value = old_developer;
-
-    /* Add the name to the completion cache */
-    insert_cvar_completion(variable->name);
-
-    /* Insert into own completion cache */
-    //variable->index.string = variable->name;
-    //rb_insert_completion(&cvar_completions, &variable->index);
 }
 
 /*
diff -urN a/common/shell.c head/common/shell.c
--- a/common/shell.c	2006-02-25 13:57:46.000000000 +1030
+++ head/common/shell.c	2006-02-25 14:01:51.000000000 +1030
@@ -463,78 +463,3 @@
 
     STree_ForEach_Cleanup__(in);
 }
-
-
-static struct rb_root completions = RB_ROOT;
-
-/*
- * str, type - the insertion key (only use one type 'flag' here)
- * root - root of the tree being inserted into
- * node - the node being inserted
- */
-static struct completion *
-rb_insert_completion__(const char *str, unsigned long type,
-		       struct rb_root *root, struct rb_node *node)
-{
-    struct rb_node **p = &root->rb_node;
-    struct rb_node *parent = NULL;
-    struct completion *c;
-    int cmp;
-
-    while (*p) {
-	parent = *p;
-	c = completion_entry(parent);
-	cmp = strcasecmp(str, c->string);
-	if (cmp < 0)
-	    p = &(*p)->rb_left;
-	else if (cmp > 0)
-	    p = &(*p)->rb_right;
-	else if (type < c->cmd_type)
-	    p = &(*p)->rb_left;
-	else if (type > c->cmd_type)
-	    p = &(*p)->rb_right;
-	else
-	    return c; /* Already match in cache */
-    }
-    rb_link_node(node, parent, p);
-
-    return NULL;
-}
-
-static void
-rb_insert_completion(const char *str, unsigned long type, struct rb_root *root)
-{
-    struct completion *c, *ret;
-
-    c = Z_Malloc(sizeof(struct completion));
-    c->string = str;
-    c->cmd_type = type;
-
-    ret = rb_insert_completion__(str, type, root, &c->rb_cmd_cache);
-
-    /* FIXME: insertion failure is important ; return error code and handle */
-    if (ret == NULL)
-	rb_insert_color(&c->rb_cmd_cache, root);
-    else {
-	Con_DPrintf("** Attempted to insert duplicate completion: %s\n", str);
-	Z_Free(c);
-    }
-}
-
-void
-insert_command_completion(const char *str)
-{
-    rb_insert_completion(str, CMD_COMMAND, &completions);
-}
-
-void
-insert_alias_completion(const char *str)
-{
-    rb_insert_completion(str, CMD_ALIAS, &completions);
-}
-
-void
-insert_cvar_completion(const char *str)
-{
-    rb_insert_completion(str, CMD_CVAR, &completions);
-}
diff -urN a/include/cvar.h head/include/cvar.h
--- a/include/cvar.h	2006-02-25 13:12:38.000000000 +1030
+++ head/include/cvar.h	2006-02-25 14:05:27.000000000 +1030
@@ -89,17 +89,12 @@
     float value;
     cvar_callback callback;
     unsigned flags;
-
-    struct completion index; /* for searching through vars and commands */
     struct stree_node stree; /* string tree for cvar names */
 } cvar_t;
 
 #define CVAR_DEVELOPER (1U << 0) /* can't set during normal play */
 #define CVAR_OBSOLETE  (1U << 1) /* cvar has no effect; basically removed */
 
-/* Get a pointer to the cvar from the completion pointer */
-#define cvar_for_completion(ptr) container_of(ptr, struct cvar_s, index)
-
 /*
  * register a cvar that already has the name, string, and optionally the
  * archive elements set.
diff -urN a/include/shell.h head/include/shell.h
--- a/include/shell.h	2006-02-25 13:57:46.000000000 +1030
+++ head/include/shell.h	2006-02-25 14:01:18.000000000 +1030
@@ -115,35 +115,4 @@
 #define STree_ForEach_break(root__) \
 	({ STree_ForEach_Cleanup__(root__); break; })
 
-/*
- * Set up some basic completion helpers
- * FIXME - document the API
- */
-
-/* An rb-tree of completion strings */
-struct completion {
-    const char *string;			/* command name */
-    unsigned long cmd_type;		/* flags for command type */
-    struct rb_node rb_cmd_cache;
-};
-
-/* completion_entry - Gets the completion ptr from the internal rb_node ptr */
-#define completion_entry(ptr) \
-	container_of(ptr, struct completion, rb_cmd_cache)
-
-/*
- * Command types
- *
- * There is a priority here to be compatible with id's original work. Command
- * names and cvar names are unique, but aliases can overlap. In that case and
- * alias can override a cvar, but not commands.
- */
-#define CMD_COMMAND	(1UL << 0)
-#define CMD_ALIAS	(1UL << 1)
-#define CMD_CVAR	(1UL << 2)
-
-void insert_alias_completion(const char *str);
-void insert_command_completion(const char *str);
-void insert_cvar_completion(const char *str);
-
 #endif /* SHELL_H */
