Closed Paril closed 1 year ago
/*
===============
Sys_ParseCommandLine
===============
*/
static void Sys_ParseCommandLine(char *line)
{
sys_argc = 1;
sys_argv[0] = APPLICATION;
const char *ptr = line;
while (true)
{
const char *token = COM_Parse(&ptr);
if (!token || !*token)
{
break;
}
size_t token_len = strlen(token) + 1;
sys_argv[sys_argc] = malloc(token_len);
Q_strlcpy(sys_argv[sys_argc], token, token_len);
sys_argc++;
}
}
I wrote this little replacement for what I'm working on - I don't know if this is suitable for you. I don't like using malloc
here, but Z
isn't initialized yet so I can't used the tagged allocator. Could just use a large block of static memory I guess.
Thanks, should be fixed now. Wonder why no one has reported this before.
This is on the latest github commit as time of writing (65061f5)
Trying to launch with a command such as:
+set test "a b c"
will cause parsing to split the quoted token incorrectly; attempting to print the value of test results in"a
, when the result should be "a b c".It seems like this bug is in a lot of clients (as it probably stems from Quake II's initial faulty implementation);
"a
)"
doesn't have an end quote?)a b c
)The last option seems like the more sensible one to take since paths on Windows tend to have spaces.