Preserve quote and etc in aliases

This commit is contained in:
fickleheart 2019-04-13 10:25:56 -05:00
parent 3286d9ac93
commit 451ff30a7a

View file

@ -594,8 +594,6 @@ static void COM_ExecuteString(char *ptext)
static void COM_Alias_f(void) static void COM_Alias_f(void)
{ {
cmdalias_t *a; cmdalias_t *a;
char cmd[1024];
size_t i, c;
if (COM_Argc() < 3) if (COM_Argc() < 3)
{ {
@ -608,19 +606,9 @@ static void COM_Alias_f(void)
com_alias = a; com_alias = a;
a->name = Z_StrDup(COM_Argv(1)); a->name = Z_StrDup(COM_Argv(1));
// Just use arg 2 if it's the only other argument, in case the alias is wrapped in quotes (backward compat, or multiple commands in one string).
// copy the rest of the command line // Otherwise pull the whole string and seek to the end of the alias name. The strctr is in case the alias is quoted.
cmd[0] = 0; // start out with a null string a->value = Z_StrDup(COM_Argc() == 3 ? COM_Argv(2) : (strchr(COM_Args() + strlen(a->name), ' ') + 1));
c = COM_Argc();
for (i = 2; i < c; i++)
{
strcat(cmd, COM_Argv(i));
if (i != c)
strcat(cmd, " ");
}
strcat(cmd, "\n");
a->value = Z_StrDup(cmd);
} }
/** Prints a line of text to the console. /** Prints a line of text to the console.