Merge remote-tracking branch 'origin/master' into new-integer-protocols

This commit is contained in:
Max Moiseev
2017-01-09 17:38:04 -08:00
330 changed files with 7129 additions and 5856 deletions

View File

@@ -284,7 +284,7 @@ public struct UTF8 : UnicodeCodec {
static func _decodeOne(_ buffer: UInt32) -> (result: UInt32?, length: UInt8) {
// Note the buffer is read least significant byte first: [ #3 #2 #1 #0 ].
if buffer & 0x80 == 0 { // 1-byte sequence (ASCII), buffer: [ CU0 ].
if buffer & 0x80 == 0 { // 1-byte sequence (ASCII), buffer: [ ... ... ... CU0 ].
let value = buffer & 0xff
return (value, 1)
}
@@ -308,7 +308,7 @@ public struct UTF8 : UnicodeCodec {
let bit1 = (lut1 &>> index) & 1
switch (bit1, bit0) {
case (0, 0): // 2-byte sequence, buffer: [ CU1 CU0 ].
case (0, 0): // 2-byte sequence, buffer: [ ... ... CU1 CU0 ].
// Require 10xx xxxx 110x xxxx.
if _slowPath(buffer & 0xc0e0 != 0x80c0) { return (nil, 1) }
// Disallow xxxx xxxx xxx0 000x (<= 7 bits case).
@@ -318,7 +318,7 @@ public struct UTF8 : UnicodeCodec {
| (buffer & 0x001f) &<< (6 as UInt32)
return (value, 2)
case (0, 1): // 3-byte sequence, buffer: [ CU2 CU1 CU0 ].
case (0, 1): // 3-byte sequence, buffer: [ ... CU2 CU1 CU0 ].
// Disallow xxxx xxxx xx0x xxxx xxxx 0000 (<= 11 bits case).
if _slowPath(buffer & 0x00200f == 0x000000) { return (nil, 1) }
// Disallow xxxx xxxx xx1x xxxx xxxx 1101 (surrogate code points).