static int tokens[256];
static int tokens_startpos[256];
static int tokens_endpos[256];
+static char tokenize_string[VM_STRINGTEMP_LENGTH];
void VM_tokenize (void)
{
const char *p;
- const char *string;
VM_SAFEPARMCOUNT(1,VM_tokenize);
- string = PRVM_G_STRING(OFS_PARM0);
- p = string;
+ strlcpy(tokenize_string, PRVM_G_STRING(OFS_PARM0), sizeof(tokenize_string));
+ p = tokenize_string;
num_tokens = 0;
for(;;)
while(*p && ISWHITESPACE(*p))
++p;
- tokens_startpos[num_tokens] = p - string;
+ tokens_startpos[num_tokens] = p - tokenize_string;
if(!COM_ParseToken_VM_Tokenize(&p, false))
break;
- tokens_endpos[num_tokens] = p - string;
+ tokens_endpos[num_tokens] = p - tokenize_string;
tokens[num_tokens] = PRVM_SetTempString(com_token);
++num_tokens;
}
void VM_tokenize_console (void)
{
const char *p;
- const char *string;
VM_SAFEPARMCOUNT(1,VM_tokenize);
- string = PRVM_G_STRING(OFS_PARM0);
- p = string;
+ strlcpy(tokenize_string, PRVM_G_STRING(OFS_PARM0), sizeof(tokenize_string));
+ p = tokenize_string;
num_tokens = 0;
for(;;)
while(*p && ISWHITESPACE(*p))
++p;
- tokens_startpos[num_tokens] = p - string;
+ tokens_startpos[num_tokens] = p - tokenize_string;
if(!COM_ParseToken_Console(&p))
break;
- tokens_endpos[num_tokens] = p - string;
+ tokens_endpos[num_tokens] = p - tokenize_string;
tokens[num_tokens] = PRVM_SetTempString(com_token);
++num_tokens;
}
const char *p;
const char *token;
char tokentext[MAX_INPUTLINE];
- const char *string;
VM_SAFEPARMCOUNTRANGE(2, 8,VM_tokenizebyseparator);
- string = PRVM_G_STRING(OFS_PARM0);
- p = string;
+ strlcpy(tokenize_string, PRVM_G_STRING(OFS_PARM0), sizeof(tokenize_string));
+ p = tokenize_string;
numseparators = 0;
for (j = 1;j < prog->argc;j++)
while (num_tokens < (int)(sizeof(tokens)/sizeof(tokens[0])))
{
token = tokentext + j;
- tokens_startpos[num_tokens] = p - string;
+ tokens_startpos[num_tokens] = p - tokenize_string;
while (*p)
{
for (k = 0;k < numseparators;k++)
tokentext[j++] = *p;
p++;
}
- tokens_endpos[num_tokens] = p - string;
+ tokens_endpos[num_tokens] = p - tokenize_string;
if (j >= (int)sizeof(tokentext))
break;
tokentext[j++] = 0;