(svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
authortron
Thu, 17 Feb 2005 17:38:17 +0000
changeset 1379 02eb430be95e
parent 1378 ebb8d52f0352
child 1380 7faf03f67dc3
(svn r1883) -Fix: [1109400] Better test if a string actually contains any console command
console.c
console_cmds.c
--- a/console.c	Thu Feb 17 15:53:47 2005 +0000
+++ b/console.c	Thu Feb 17 17:38:17 2005 +0000
@@ -1094,8 +1094,16 @@
 	uint i;
 	uint l;
 
-	if (strlen(cmdstr) == 0) // only execute if there is something typed obviously
-		return;
+	for (; strchr("\n\r \t", *cmdstr) != NULL; ++cmdstr) {
+		switch (*cmdstr) {
+			case '\0':
+			case '#':
+				return;
+
+			default:
+				break;
+		}
+	}
 
 	if (_stdlib_con_developer)
 		IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr);
--- a/console_cmds.c	Thu Feb 17 15:53:47 2005 +0000
+++ b/console_cmds.c	Thu Feb 17 17:38:17 2005 +0000
@@ -611,9 +611,7 @@
 
 	fgets(cmd, sizeof(cmd), _script_file);
 	while (!feof(_script_file) && _script_running) {
-		strtok(cmd, "\r\n#");
-		if (strlen(cmd) > 0 && cmd[0] != '#')
-			IConsoleCmdExec(cmd);
+		IConsoleCmdExec(cmd);
 		fgets(cmd, sizeof(cmd), _script_file);
 	}