mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Use strchr?
This commit is contained in:
parent
fe7220bb20
commit
3286d9ac93
1 changed files with 19 additions and 26 deletions
|
@ -543,38 +543,31 @@ static void COM_ExecuteString(char *ptext)
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char *write = buf, *read = a->value, *seek = read;
|
char *write = buf, *read = a->value, *seek = read;
|
||||||
|
|
||||||
while (*seek != '\0')
|
while ((seek = strchr(seek, '$')) != NULL)
|
||||||
{
|
{
|
||||||
if (*seek == '$')
|
memcpy(write, read, seek-read);
|
||||||
|
write += seek-read;
|
||||||
|
|
||||||
|
seek++;
|
||||||
|
|
||||||
|
if (*seek >= '1' && *seek <= '9')
|
||||||
{
|
{
|
||||||
memcpy(write, read, seek-read);
|
if (com_argc > (size_t)(*seek - '0'))
|
||||||
write += seek-read;
|
{
|
||||||
|
memcpy(write, com_argv[*seek - '0'], strlen(com_argv[*seek - '0']));
|
||||||
|
write += strlen(com_argv[*seek - '0']);
|
||||||
|
}
|
||||||
seek++;
|
seek++;
|
||||||
|
|
||||||
if (*seek >= '1' && *seek <= '9')
|
|
||||||
{
|
|
||||||
if (com_argc > (size_t)(*seek - '0'))
|
|
||||||
{
|
|
||||||
memcpy(write, com_argv[*seek - '0'], strlen(com_argv[*seek - '0']));
|
|
||||||
write += strlen(com_argv[*seek - '0']);
|
|
||||||
}
|
|
||||||
seek++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*write = '$';
|
|
||||||
write++;
|
|
||||||
}
|
|
||||||
|
|
||||||
read = seek;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
seek++;
|
{
|
||||||
|
*write = '$';
|
||||||
|
write++;
|
||||||
|
}
|
||||||
|
|
||||||
|
read = seek;
|
||||||
}
|
}
|
||||||
memcpy(write, read, seek-read);
|
WRITESTRING(write, read);
|
||||||
write += seek-read;
|
|
||||||
*write = '\0';
|
|
||||||
|
|
||||||
recursion++;
|
recursion++;
|
||||||
COM_BufInsertText(buf);
|
COM_BufInsertText(buf);
|
||||||
|
|
Loading…
Reference in a new issue