Corrected an apparently non-functional call to feof(); random

end-of-file will now properly terminate instead of re-reading
the same line.
This commit is contained in:
Tim Edwards
2015-08-31 10:04:20 -04:00
parent 14e5a86a02
commit b743fa2ccc
4 changed files with 215 additions and 1 deletions
+8 -1
View File
@@ -204,8 +204,15 @@ static struct filestack *OpenFiles = NULL;
int GetNextLineNoNewline()
{
char *newbuf;
int testc;
if (feof(infile)) return -1;
// This is more reliable than feof() ...
testc = getc(infile);
if (testc == -1) return -1;
ungetc(testc, infile);
if (linesize == 0) {
/* Allocate memory for line */
linesize = 500;
@@ -295,7 +302,7 @@ void SpiceTokNoNewline(void)
ungetc(contline, infile);
return;
}
GetNextLineNoNewline();
if (GetNextLineNoNewline() == -1) break;
}
}