]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cmd.c
Print cvar aliases in apropos and cvarlist output properly
[xonotic/darkplaces.git] / cmd.c
diff --git a/cmd.c b/cmd.c
index 81f9660307731973755a28ab27a03a31c3d734dc..d2369157273c4a0c7a794989e0c6a56999f69de1 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -1429,7 +1429,6 @@ static void Cmd_Apropos_f(cmd_state_t *cmd)
        int count;
        qboolean ispattern;
        char vabuf[1024];
-       char *cvar_name;
 
        if (Cmd_Argc(cmd) > 1)
                partial = Cmd_Args(cmd);
@@ -1446,26 +1445,22 @@ static void Cmd_Apropos_f(cmd_state_t *cmd)
        count = 0;
        for (cvar = cmd->cvars->vars; cvar; cvar = cvar->next)
        {
-               if (!matchpattern_with_separator(cvar->name, partial, true, "", false) &&
-                   !matchpattern_with_separator(cvar->description, partial, true, "", false))
+               if (matchpattern_with_separator(cvar->name, partial, true, "", false) ||
+                   matchpattern_with_separator(cvar->description, partial, true, "", false))
                {
-                       for (int i = 0; i < cvar->aliasindex; i++)
-                       {
-                               if (!matchpattern_with_separator(cvar->aliases[i], partial, true, "", false)) {
-                                       continue;
-                               } else {
-                                       cvar_name = cvar->aliases[i];
-                                       goto print;
-                               }
-                       }       
-                       continue;
-               } else {
-                       cvar_name = (char *)cvar->name;
-print:
                        Con_Printf ("cvar ");
-                       Cvar_PrintHelp(cvar, cvar_name, true);
+                       Cvar_PrintHelp(cvar, cvar->name, true);
                        count++;
                }
+               for (int i = 0; i < cvar->aliasindex; i++)
+               {
+                       if (matchpattern_with_separator(cvar->aliases[i], partial, true, "", false))
+                       {
+                               Con_Printf ("cvar ");
+                               Cvar_PrintHelp(cvar, cvar->aliases[i], true);
+                               count++;
+                       }
+               }
        }
        for (func = cmd->userdefined->csqc_functions; func; func = func->next)
        {