[PATCH] Remove old style *_exists commands

Replace the usages of the old style *_exists commands:
  cmd_exists()   -> Cmd_Exists()
  alias_exists() -> Cmd_Alias_Exists() (new function)
  cvar_exists()  -> Cvar_Find()

This allows us to remove the rb_find_exact functions.

diff -urN a/NQ/cmd.c head/NQ/cmd.c
--- a/NQ/cmd.c	2006-02-25 12:18:01.000000000 +1030
+++ head/NQ/cmd.c	2006-02-25 12:41:47.000000000 +1030
@@ -606,6 +606,11 @@
     return Cmd_FindCommand(cmd_name) != NULL;
 }
 
+qboolean
+Cmd_Alias_Exists(char *cmd_name)
+{
+    return Cmd_Alias_Find(cmd_name) != NULL;
+}
 
 
 /*
diff -urN a/NQ/cmd.h head/NQ/cmd.h
--- a/NQ/cmd.h	2006-02-19 12:33:24.000000000 +1030
+++ head/NQ/cmd.h	2006-02-25 10:48:10.000000000 +1030
@@ -108,7 +108,7 @@
 // The cmd_name is referenced later, so it should not be in temp memory
 
 qboolean Cmd_Exists(char *cmd_name);
-
+qboolean Cmd_Alias_Exists(char *cmd_name);
 // used by the cvar code to check for cvar / command name overlap
 
 int Cmd_Argc(void);
diff -urN a/QW/client/cmd.h head/QW/client/cmd.h
--- a/QW/client/cmd.h	2006-02-19 12:33:24.000000000 +1030
+++ head/QW/client/cmd.h	2006-02-25 12:42:46.000000000 +1030
@@ -98,7 +98,7 @@
 // as a clc_stringcmd instead of executed locally
 
 qboolean Cmd_Exists(char *cmd_name);
-
+qboolean Cmd_Alias_Exists(char *cmd_name);
 // used by the cvar code to check for cvar / command name overlap
 
 int Cmd_Argc(void);
diff -urN a/QW/common/cmd.c head/QW/common/cmd.c
--- a/QW/common/cmd.c	2006-02-25 12:18:01.000000000 +1030
+++ head/QW/common/cmd.c	2006-02-25 12:41:43.000000000 +1030
@@ -616,6 +616,12 @@
     return Cmd_FindCommand(cmd_name) != NULL;
 }
 
+qboolean
+Cmd_Alias_Exists(char *cmd_name)
+{
+    return Cmd_Alias_Find(cmd_name) != NULL;
+}
+
 
 #ifndef SERVERONLY		// FIXME
 /*
diff -urN a/common/keys.c head/common/keys.c
--- a/common/keys.c	2006-02-19 12:19:11.000000000 +1030
+++ head/common/keys.c	2006-02-25 11:18:07.000000000 +1030
@@ -202,7 +202,7 @@
 	    cmd[i] = s[i];
     cmd[i] = 0;
 
-    return command_exists(cmd) || cvar_exists(cmd) || alias_exists(cmd);
+    return Cmd_Exists(cmd) || Cvar_FindVar(cmd) || Cmd_Alias_Exists(cmd);
 }
 
 
@@ -240,7 +240,7 @@
 	    strncpy(cmd, s, len);
 	    cmd[len] = 0;
 
-	    if (command_exists(cmd)) {
+	    if (Cmd_Exists(cmd)) {
 		s += len;
 		while (*s == ' ')
 		    s++;
@@ -282,7 +282,7 @@
 	    strncpy(cmd, s, len);
 	    cmd[len] = 0;
 
-	    if (command_exists(cmd)) {
+	    if (Cmd_Exists(cmd)) {
 		struct stree_root *root;
 
 		s += len;
diff -urN a/common/shell.c head/common/shell.c
--- a/common/shell.c	2006-02-25 12:38:51.000000000 +1030
+++ head/common/shell.c	2006-02-25 11:17:36.000000000 +1030
@@ -470,55 +470,6 @@
 static struct rb_root completions = RB_ROOT;
 
 /*
- * FIXME: document assumptions about args; see caller below
- */
-static struct completion *
-rb_find_exact_r(struct rb_node *n, const char *str, unsigned long type)
-{
-    if (n) {
-	struct completion *c, *ret = NULL; /* FIXME - null right here? */
-
-	c = completion_entry(n);
-	if (!strcasecmp(str, c->string)) {
-	    ret = rb_find_exact_r(n->rb_left, str, type);
-	    if (!ret && (c->cmd_type & type))
-		ret = c;
-	    if (!ret)
-		ret = rb_find_exact_r(n->rb_right, str, type);
-	}
-	return ret;
-    }
-    return NULL;
-}
-
-
-/*
- * Find exact string
- */
-static int
-rb_find_exact(const char *str, unsigned long type, struct rb_root *root)
-{
-    struct rb_node *n = root->rb_node;
-    struct completion *c;
-    int cmp;
-
-    /* Do the first part iteratively */
-    while (n) {
-	c = completion_entry(n);
-	cmp = strcasecmp(str, c->string);
-	if (cmp < 0)
-	    n = n->rb_left;
-	else if (cmp > 0)
-	    n = n->rb_right;
-	else
-	    break;
-    }
-    /* now take care of the type matching */
-    return (rb_find_exact_r(n, str, type) != NULL);
-}
-
-
-/*
  * str, type - the insertion key (only use one type 'flag' here)
  * root - root of the tree being inserted into
  * node - the node being inserted
@@ -723,12 +674,6 @@
     return rb_find_completion(str, CMD_COMMAND, &completions);
 }
 
-int
-command_exists(const char *str)
-{
-    return rb_find_exact(str, CMD_COMMAND, &completions);
-}
-
 /* Alias completions */
 
 void
@@ -749,13 +694,6 @@
     return rb_find_completion(str, CMD_ALIAS, &completions);
 }
 
-int
-alias_exists(const char *str)
-{
-    return rb_find_exact(str, CMD_ALIAS, &completions);
-}
-
-
 /* Cvar completions */
 
 void
@@ -776,12 +714,6 @@
     return rb_find_completion(str, CMD_CVAR, &completions);
 }
 
-int
-cvar_exists(const char *str)
-{
-    return Cvar_FindVar(str) != NULL;
-}
-
 /* ------------------------------------------------------------------------ */
 
 /*
diff -urN a/include/shell.h head/include/shell.h
--- a/include/shell.h	2006-02-25 12:38:51.000000000 +1030
+++ head/include/shell.h	2006-02-25 11:16:37.000000000 +1030
@@ -148,17 +148,14 @@
 void insert_alias_completion(const char *str);
 unsigned find_alias_completions(const char *str);
 char *find_alias_completion(const char *str);
-int alias_exists(const char *str);
 
 void insert_command_completion(const char *str);
 unsigned find_command_completions(const char *str);
 char *find_command_completion(const char *str);
-int command_exists(const char *str);
 
 void insert_cvar_completion(const char *str);
 unsigned find_cvar_completions(const char *str);
 char *find_cvar_completion(const char *str);
-int cvar_exists(const char *str);
 
 /* Search all three completion caches combined */
 unsigned find_completions(const char *str);
