Merge branch 'master' into jgrpp

This commit is contained in:
Jonathan G Rennison
2017-06-25 11:55:27 +01:00
8 changed files with 86 additions and 32 deletions

View File

@@ -435,7 +435,10 @@ void IConsoleCmdExec(const char *cmdstr)
* enclosed in "" are taken as one token. We can only go as far as the amount
* of characters in our stream or the max amount of tokens we can handle */
for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) {
if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break;
if (tstream_i >= lengthof(tokenstream)) {
IConsoleError("command line too long");
return;
}
switch (*cmdptr) {
case ' ': // Token separator
@@ -453,6 +456,10 @@ void IConsoleCmdExec(const char *cmdstr)
case '"': // Tokens enclosed in "" are one token
longtoken = !longtoken;
if (!foundtoken) {
if (t_index >= lengthof(tokens)) {
IConsoleError("command line too long");
return;
}
tokens[t_index++] = &tokenstream[tstream_i];
foundtoken = true;
}
@@ -467,6 +474,10 @@ void IConsoleCmdExec(const char *cmdstr)
tokenstream[tstream_i++] = *cmdptr;
if (!foundtoken) {
if (t_index >= lengthof(tokens)) {
IConsoleError("command line too long");
return;
}
tokens[t_index++] = &tokenstream[tstream_i - 1];
foundtoken = true;
}
@@ -474,7 +485,7 @@ void IConsoleCmdExec(const char *cmdstr)
}
}
for (uint i = 0; tokens[i] != NULL; i++) {
for (uint i = 0; i < lengthof(tokens) && tokens[i] != NULL; i++) {
DEBUG(console, 8, "Token %d is: '%s'", i, tokens[i]);
}