(svn r1886) Correctly process the last line of a script, even if it's not newline terminated. Also print an error message if something goes wrong while reading from the script file
authortron
Fri, 18 Feb 2005 08:36:11 +0000
changeset 1382 2a2ac927a256
parent 1381 3837b6c64508
child 1383 ea1505a974f9
(svn r1886) Correctly process the last line of a script, even if it's not newline terminated. Also print an error message if something goes wrong while reading from the script file
console_cmds.c
--- a/console_cmds.c	Fri Feb 18 08:32:25 2005 +0000
+++ b/console_cmds.c	Fri Feb 18 08:36:11 2005 +0000
@@ -609,10 +609,12 @@
 
 	_script_running = true;
 
-	fgets(cmd, sizeof(cmd), _script_file);
-	while (!feof(_script_file) && _script_running) {
+	while (_script_running && fgets(cmd, sizeof(cmd), _script_file) != NULL) {
 		IConsoleCmdExec(cmd);
-		fgets(cmd, sizeof(cmd), _script_file);
+	}
+
+	if (ferror(_script_file)) {
+		IConsoleError("Encountered errror while trying to read from script file");
 	}
 
 	_script_running = false;