Repository navigation
Conversation
fill() and getText() still compared the last buffered char against 0xFFFF, while LA() uses std::char_traits<wchar_t>::eof(). With a 32-bit wchar_t, WEOF is 0xFFFFFFFF, so a literal U+FFFF in the input stopped buffering and, while a marker was held, everything after it was reported as EOF. Use one constant derived from WEOF for all three checks. Signed-off-by: Bhavya H <bhavya@labs.digiscrypt.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnbufferedCharStream::fill()andgetText()still detect end of input by comparing the last buffered char against0xFFFF, while #3420 movedLA()tostd::char_traits<wchar_t>::eof(). On Linux and macOSwchar_tis 32 bits andwistream::get()reports end of input asWEOF(0xFFFFFFFF), so it is a literal U+FFFF in the input that makesfill()stop buffering.Lexer::nextToken()always holds a marker, so right after that characterLA(1)returns EOF, the lexer setshitEOF, and the rest of the input is dropped without a syntax error: a parser reading throughUnbufferedCharStreamaccepts just the prefix, while the same text throughANTLRInputStreamis lexed in full. With the in-treeXPathLexer(where�is a validNameStartChar),a�b/ccomes out asRULE_REF EOFthrough the unbuffered stream andRULE_REF ROOT RULE_REF EOFthroughANTLRInputStream. All three checks now use one constant derived fromstd::char_traits<wchar_t>::eof(), so Windows (16-bitwchar_t, whereWEOFis0xFFFF) behaves as before and the-Wsign-comparewarning from #4517 goes away. The newUnbufferedCharStreamTestfails ondevand passes with the fix, and the runtime builds warning-free in Debug (regular and unity) with Apple clang; I could not run gcc, MSVC or the Java-driven runtime-testsuite locally, though its C++ harness does not use this stream.This fix was found and prepared with AI assistance and reviewed by me before submitting.