int count;
qboolean ispattern;
char vabuf[1024];
- char *cvar_name;
if (Cmd_Argc(cmd) > 1)
partial = Cmd_Args(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)
{
cvar_state_t *cvars = cmd->cvars;
cvar_t *cvar;
const char *partial;
- size_t len;
int count;
qboolean ispattern;
+ char vabuf[1024];
if (Cmd_Argc(cmd) > 1)
{
partial = Cmd_Argv(cmd, 1);
- len = strlen(partial);
ispattern = (strchr(partial, '*') || strchr(partial, '?'));
+ if(!ispattern)
+ partial = va(vabuf, sizeof(vabuf), "%s*", partial);
}
else
{
- partial = NULL;
- len = 0;
+ partial = va(vabuf, sizeof(vabuf), "*");
ispattern = false;
}
count = 0;
for (cvar = cvars->vars; cvar; cvar = cvar->next)
{
- if (len && (ispattern ? !matchpattern_with_separator(cvar->name, partial, false, "", false) : strncmp (partial,cvar->name,len)))
- continue;
-
- Cvar_PrintHelp(cvar, cvar->name, true);
- count++;
+ if (matchpattern_with_separator(cvar->name, partial, false, "", false))
+ {
+ Cvar_PrintHelp(cvar, cvar->name, true);
+ count++;
+ }
+ for (int i = 0; i < cvar->aliasindex; i++)
+ {
+ if (matchpattern_with_separator(cvar->aliases[i], partial, false, "", false))
+ {
+ Cvar_PrintHelp(cvar, cvar->aliases[i], true);
+ count++;
+ }
+ }
}
- if (len)
+ if (Cmd_Argc(cmd) > 1)
{
if(ispattern)
Con_Printf("%i cvar%s matching \"%s\"\n", count, (count > 1) ? "s" : "", partial);
else
- Con_Printf("%i cvar%s beginning with \"%s\"\n", count, (count > 1) ? "s" : "", partial);
+ Con_Printf("%i cvar%s beginning with \"%s\"\n", count, (count > 1) ? "s" : "", Cmd_Argv(cmd,1));
}
else
Con_Printf("%i cvar(s)\n", count);