-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the infinite loop when an input file lacks EOF #228
Fix the infinite loop when an input file lacks EOF #228
Conversation
Doesn't this mean there was a get that returned EndOfInput, but that result was ignored? If so, this may be getting fixed in the wrong place. |
Actually I'd say yes. In the switch/case statements of preprocessor/PpScanner.cpp, The problem is the I was thinking whether I should add this Suggestion? |
9bb993a
to
bff94a0
Compare
Hi @johnkslang , should I add |
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().
bff94a0
to
e4d0bc5
Compare
Hi @johnkslang , Is this PR ready to go? Thanks |
e4d0bc5
to
94a89d5
Compare
The proposed solution seems quite reasonable to me. But I think we need to update the descriptions of the get(), peek(), ungetch() to clarify their end-of-input edge case behaviours. |
I'm fine with it as long as it's truly a catchall for higher-level code that doesn't always, but eventually checks for end-of-input. |
will work on the comments soon. |
…tizationModes_and_OverflowModes Add missing capabilities to QuantizationModes and OverflowModes enumerants
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().