Skip to content
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 Issue 14105 - strideImpl fails for 0xFF #2951

Merged
merged 1 commit into from
Feb 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions std/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ body
{
import core.bitop : bsr;
immutable msbs = 7 - bsr(~c);
if (msbs < 2 || msbs > 4)
if (!~c || msbs < 2 || msbs > 4)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct me if I'm wrong: isn't !~c equal to c == 0. you comment sort of also implies that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's equivalent to ~c == 0.

throw new UTFException("Invalid UTF-8 sequence", index);
return msbs;
}
Expand Down Expand Up @@ -263,7 +263,7 @@ unittest // invalid start bytes
{
import std.exception: assertThrown;
immutable char[] invalidStartBytes = [
//0b1111_1000, // indicating a sequence length of 5
0b1111_1000, // indicating a sequence length of 5
0b1111_1100, // 6
0b1111_1110, // 7
0b1111_1111, // 8
Expand Down