(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 17a62e07dde8
parent 1381 6cfd0991443d
child 1383 c69740efce83
(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;