-
Notifications
You must be signed in to change notification settings - Fork 102
Fix hang on UTF-16 LE BOM file #636
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
base: master
Are you sure you want to change the base?
Changes from all commits
14a44eb
4cc9e60
b928752
bcb50ec
9f371ac
47f267c
ed1fef4
ebe842f
b004fad
202f265
dd90001
b530236
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,8 +275,10 @@ class simplecpp::TokenList::Stream { | |
| return ch; | ||
| } | ||
|
|
||
| unsigned char peekChar() { | ||
| auto ch = static_cast<unsigned char>(peek()); | ||
| int peekChar() { | ||
| int ch = peek(); | ||
| if (ch == EOF) | ||
| return ch; | ||
|
|
||
| // For UTF-16 encoded files the BOM is 0xfeff/0xfffe. If the | ||
| // character is non-ASCII character then replace it with 0xff | ||
|
|
@@ -285,7 +287,7 @@ class simplecpp::TokenList::Stream { | |
| const auto ch2 = static_cast<unsigned char>(peek()); | ||
| unget(); | ||
| const int ch16 = makeUtf16Char(ch, ch2); | ||
| ch = static_cast<unsigned char>(((ch16 >= 0x80) ? 0xff : ch16)); | ||
| ch = (ch16 >= 0x80) ? 0xff : ch16; | ||
| } | ||
|
|
||
| // Handling of newlines.. | ||
|
|
@@ -598,7 +600,7 @@ std::string simplecpp::TokenList::stringify(bool linenrs) const | |
| return ret.str(); | ||
| } | ||
|
|
||
| static bool isNameChar(unsigned char ch) | ||
| static bool isNameChar(int ch) | ||
| { | ||
| return std::isalnum(ch) || ch == '_' || ch == '$'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the input to std::isalnum must be 0-0xff
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm the documentation says:
so we are safe right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's how I read it too. |
||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.