Fix the infinite loop when an input file lacks EOF

The input scanner can be trapped in an infinite loop if the given input
file does not have EOF (and is not ended with a 'whitespace').

The problem is caused by unget(), which keeps rolling back the scanner
pointer without hitting an EOF at the end of the file. This makes getch()
function keep returning the last character of the file and never ends,
and the effect of advance() is always counteracted by unget().
This commit is contained in:
qining
2016-04-11 19:12:17 -04:00
parent ba00f67d2f
commit 19647a32b9
4 changed files with 14 additions and 5 deletions

View File

@@ -0,0 +1,2 @@
noEOF