Changeset - r22663:f48d1ccb07da
[Not reviewed]
master
0 1 0
frosch - 7 years ago 2017-06-22 16:32:50
frosch@openttd.org
(svn r27884) -Fix: Console command parser failed when the command had many parameters, and also did not print any error messages about it.
1 file changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/console.cpp
Show inline comments
 
@@ -434,7 +434,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
 
@@ -452,6 +455,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;
 
			}
 
@@ -466,6 +473,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;
 
			}
0 comments (0 inline, 0 general)