From 1804109f4b622f9ac42ec0b3d956d7a475dc0000 Mon Sep 17 00:00:00 2001 From: tron Date: Fri, 18 Feb 2005 08:36:11 +0000 Subject: (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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'console_cmds.c') diff --git a/console_cmds.c b/console_cmds.c index ab0364bfd..aea87fa40 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -609,10 +609,12 @@ DEF_CONSOLE_CMD(ConExec) _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; -- cgit v1.2.3-54-g00ecf