Rollup merge of #89614 - cuviper:unicode-14, r=joshtriplett

Update to Unicode 14.0

The Unicode Standard [announced Version 14.0](https://home.unicode.org/announcing-the-unicode-standard-version-14-0/) on September 14, 2021, and this pull request updates the generated tables in `core` accordingly.

This did require a little prep-work in `unicode-table-generator`. First, #81358 had modified the generated file instead of the tool, so that change is now reflected in the tool as well. Next, I found that the "Alphabetic" property in version 14 was panicking when generating a bitset, "cannot pack 264 into 8 bits". We've been using the skiplist for that anyway, so I changed this to fail gracefully. Finally, I confirmed that the tool still created the exact same tables for 13 before moving to 14.
This commit is contained in:
Guillaume Gomez 2021-10-09 17:08:40 +02:00 committed by GitHub
commit 21a5101e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 674 additions and 564 deletions

View File

@ -44,10 +44,10 @@ pub(crate) fn is_printable(x: char) -> bool {
} else if x < 0x20000 {
check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1)
} else {
if 0x2a6de <= x && x < 0x2a700 {
if 0x2a6e0 <= x && x < 0x2a700 {
return false;
}
if 0x2b735 <= x && x < 0x2b740 {
if 0x2b739 <= x && x < 0x2b740 {
return false;
}
if 0x2b81e <= x && x < 0x2b820 {
@ -77,13 +77,13 @@ pub(crate) fn is_printable(x: char) -> bool {
(0x00, 1),
(0x03, 5),
(0x05, 6),
(0x06, 3),
(0x06, 2),
(0x07, 6),
(0x08, 8),
(0x08, 7),
(0x09, 17),
(0x0a, 28),
(0x0b, 25),
(0x0c, 20),
(0x0c, 26),
(0x0d, 16),
(0x0e, 13),
(0x0f, 4),
@ -91,16 +91,15 @@ pub(crate) fn is_printable(x: char) -> bool {
(0x12, 18),
(0x13, 9),
(0x16, 1),
(0x17, 5),
(0x18, 2),
(0x17, 4),
(0x18, 1),
(0x19, 3),
(0x1a, 7),
(0x1b, 1),
(0x1c, 2),
(0x1d, 1),
(0x1f, 22),
(0x20, 3),
(0x2b, 3),
(0x2c, 2),
(0x2d, 11),
(0x2e, 1),
(0x30, 3),
@ -112,49 +111,48 @@ pub(crate) fn is_printable(x: char) -> bool {
(0xab, 8),
(0xfa, 2),
(0xfb, 5),
(0xfd, 4),
(0xfd, 2),
(0xfe, 3),
(0xff, 9),
];
#[rustfmt::skip]
const SINGLETONS0L: &[u8] = &[
0xad, 0x78, 0x79, 0x8b, 0x8d, 0xa2, 0x30, 0x57,
0x58, 0x8b, 0x8c, 0x90, 0x1c, 0x1d, 0xdd, 0x0e,
0x0f, 0x4b, 0x4c, 0xfb, 0xfc, 0x2e, 0x2f, 0x3f,
0x5c, 0x5d, 0x5f, 0xb5, 0xe2, 0x84, 0x8d, 0x8e,
0x91, 0x92, 0xa9, 0xb1, 0xba, 0xbb, 0xc5, 0xc6,
0xc9, 0xca, 0xde, 0xe4, 0xe5, 0xff, 0x00, 0x04,
0x11, 0x12, 0x29, 0x31, 0x34, 0x37, 0x3a, 0x3b,
0x3d, 0x49, 0x4a, 0x5d, 0x84, 0x8e, 0x92, 0xa9,
0xb1, 0xb4, 0xba, 0xbb, 0xc6, 0xca, 0xce, 0xcf,
0xe4, 0xe5, 0x00, 0x04, 0x0d, 0x0e, 0x11, 0x12,
0x29, 0x31, 0x34, 0x3a, 0x3b, 0x45, 0x46, 0x49,
0x4a, 0x5e, 0x64, 0x65, 0x84, 0x91, 0x9b, 0x9d,
0xc9, 0xce, 0xcf, 0x0d, 0x11, 0x29, 0x45, 0x49,
0x57, 0x64, 0x65, 0x8d, 0x91, 0xa9, 0xb4, 0xba,
0xbb, 0xc5, 0xc9, 0xdf, 0xe4, 0xe5, 0xf0, 0x0d,
0x11, 0x45, 0x49, 0x64, 0x65, 0x80, 0x84, 0xb2,
0xbc, 0xbe, 0xbf, 0xd5, 0xd7, 0xf0, 0xf1, 0x83,
0x85, 0x8b, 0xa4, 0xa6, 0xbe, 0xbf, 0xc5, 0xc7,
0xce, 0xcf, 0xda, 0xdb, 0x48, 0x98, 0xbd, 0xcd,
0xc6, 0xce, 0xcf, 0x49, 0x4e, 0x4f, 0x57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8, 0xc9, 0xd0, 0xd1, 0xd8, 0xd9, 0xe7,
0xfe, 0xff,
0x42, 0x45, 0x90, 0x91, 0x53, 0x67, 0x75, 0xc8,
0xc9, 0xd0, 0xd1, 0xd8, 0xd9, 0xe7, 0xfe, 0xff,
];
#[rustfmt::skip]
const SINGLETONS1U: &[(u8, u8)] = &[
@ -162,6 +160,8 @@ pub(crate) fn is_printable(x: char) -> bool {
(0x01, 1),
(0x03, 1),
(0x04, 2),
(0x05, 7),
(0x07, 2),
(0x08, 8),
(0x09, 2),
(0x0a, 5),
@ -178,9 +178,11 @@ pub(crate) fn is_printable(x: char) -> bool {
(0x1c, 5),
(0x1d, 8),
(0x24, 1),
(0x6a, 3),
(0x6a, 4),
(0x6b, 2),
(0xaf, 3),
(0xbc, 2),
(0xcf, 2),
(0xd1, 2),
(0xd4, 12),
(0xd5, 9),
@ -189,38 +191,40 @@ pub(crate) fn is_printable(x: char) -> bool {
(0xda, 1),
(0xe0, 5),
(0xe1, 2),
(0xe7, 4),
(0xe8, 2),
(0xee, 32),
(0xf0, 4),
(0xf8, 2),
(0xf9, 2),
(0xfa, 2),
(0xfb, 1),
];
#[rustfmt::skip]
const SINGLETONS1L: &[u8] = &[
0x0c, 0x27, 0x3b, 0x3e, 0x4e, 0x4f, 0x8f, 0x9e,
0x9e, 0x9f, 0x06, 0x07, 0x09, 0x36, 0x3d, 0x3e,
0x56, 0xf3, 0xd0, 0xd1, 0x04, 0x14, 0x18, 0x36,
0x37, 0x56, 0x57, 0x7f, 0xaa, 0xae, 0xaf, 0xbd,
0x35, 0xe0, 0x12, 0x87, 0x89, 0x8e, 0x9e, 0x04,
0x0d, 0x0e, 0x11, 0x12, 0x29, 0x31, 0x34, 0x3a,
0x45, 0x46, 0x49, 0x4a, 0x4e, 0x4f, 0x64, 0x65,
0x5c, 0xb6, 0xb7, 0x1b, 0x1c, 0x07, 0x08, 0x0a,
0x0b, 0x14, 0x17, 0x36, 0x39, 0x3a, 0xa8, 0xa9,
0x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0x3e, 0x66, 0x69, 0x8f, 0x92,
0x6f, 0x5f, 0xbf, 0xee, 0xef, 0x5a, 0x62, 0xf4,
0xfc, 0xff, 0x9a, 0x9b, 0x2e, 0x2f, 0x27, 0x28,
0x55, 0x9d, 0xa0, 0xa1, 0xa3, 0xa4, 0xa7, 0xa8,
0xad, 0xba, 0xbc, 0xc4, 0x06, 0x0b, 0x0c, 0x15,
0x1d, 0x3a, 0x3f, 0x45, 0x51, 0xa6, 0xa7, 0xcc,
0xcd, 0xa0, 0x07, 0x19, 0x1a, 0x22, 0x25, 0x3e,
0x3f, 0xe7, 0xec, 0xef, 0xff, 0xc5, 0xc6, 0x04,
0x20, 0x23, 0x25, 0x26, 0x28, 0x33, 0x38, 0x3a,
0x48, 0x4a, 0x4c, 0x50, 0x53, 0x55, 0x56, 0x58,
0x5a, 0x5c, 0x5e, 0x60, 0x63, 0x65, 0x66, 0x6b,
0x73, 0x78, 0x7d, 0x7f, 0x8a, 0xa4, 0xaa, 0xaf,
0xb0, 0xc0, 0xd0, 0xae, 0xaf, 0x6e, 0x6f, 0x93,
];
#[rustfmt::skip]
const NORMAL0: &[u8] = &[
@ -231,9 +235,9 @@ pub(crate) fn is_printable(x: char) -> bool {
0x1b, 0x04,
0x06, 0x11,
0x81, 0xac, 0x0e,
0x80, 0xab, 0x35,
0x28, 0x0b,
0x80, 0xe0, 0x03,
0x80, 0xab, 0x05,
0x1f, 0x09,
0x81, 0x1b, 0x03,
0x19, 0x08,
0x01, 0x04,
0x2f, 0x04,
@ -257,13 +261,11 @@ pub(crate) fn is_printable(x: char) -> bool {
0x0b, 0x06,
0x01, 0x0e,
0x15, 0x05,
0x3a, 0x03,
0x11, 0x07,
0x06, 0x05,
0x10, 0x07,
0x4e, 0x07,
0x1b, 0x07,
0x57, 0x07,
0x02, 0x07,
0x15, 0x0d,
0x02, 0x06,
0x16, 0x0d,
0x50, 0x04,
0x43, 0x03,
0x2d, 0x03,
@ -280,8 +282,8 @@ pub(crate) fn is_printable(x: char) -> bool {
0x1a, 0x06,
0x82, 0xfd, 0x03,
0x59, 0x07,
0x15, 0x0b,
0x17, 0x09,
0x16, 0x09,
0x18, 0x09,
0x14, 0x0c,
0x14, 0x0c,
0x6a, 0x06,
@ -299,10 +301,9 @@ pub(crate) fn is_printable(x: char) -> bool {
0x0b, 0x03,
0x80, 0xac, 0x06,
0x0a, 0x06,
0x21, 0x3f,
0x4c, 0x04,
0x2d, 0x03,
0x74, 0x08,
0x2f, 0x31,
0x4d, 0x03,
0x80, 0xa4, 0x08,
0x3c, 0x03,
0x0f, 0x03,
0x3c, 0x07,
@ -312,7 +313,7 @@ pub(crate) fn is_printable(x: char) -> bool {
0x18, 0x08,
0x2f, 0x11,
0x2d, 0x03,
0x20, 0x10,
0x21, 0x0f,
0x21, 0x0f,
0x80, 0x8c, 0x04,
0x82, 0x97, 0x19,
@ -322,19 +323,19 @@ pub(crate) fn is_printable(x: char) -> bool {
0x3b, 0x07,
0x02, 0x0e,
0x18, 0x09,
0x80, 0xb3, 0x2d,
0x80, 0xbe, 0x22,
0x74, 0x0c,
0x80, 0xd6, 0x1a,
0x0c, 0x05,
0x80, 0xff, 0x05,
0x80, 0xdf, 0x0c,
0xee, 0x0d, 0x03,
0x84, 0x8d, 0x03,
0xf2, 0x9d, 0x03,
0x37, 0x09,
0x81, 0x5c, 0x14,
0x80, 0xb8, 0x08,
0x80, 0xcb, 0x2a,
0x38, 0x03,
0x80, 0xcb, 0x05,
0x0a, 0x18,
0x3b, 0x03,
0x0a, 0x06,
0x38, 0x08,
0x46, 0x08,
@ -354,9 +355,9 @@ pub(crate) fn is_printable(x: char) -> bool {
0x81, 0xda, 0x26,
0x07, 0x0c,
0x05, 0x05,
0x80, 0xa5, 0x11,
0x81, 0x6d, 0x10,
0x78, 0x28,
0x80, 0xa6, 0x10,
0x81, 0xf5, 0x07,
0x01, 0x20,
0x2a, 0x06,
0x4c, 0x04,
0x80, 0x8d, 0x04,
@ -386,10 +387,11 @@ pub(crate) fn is_printable(x: char) -> bool {
0x24, 0x04,
0x28, 0x08,
0x34, 0x0b,
0x01, 0x80, 0x90,
0x4e, 0x43,
0x81, 0x37, 0x09,
0x16, 0x0a,
0x08, 0x80, 0x98,
0x08, 0x18,
0x3b, 0x45,
0x39, 0x03,
0x63, 0x08,
0x09, 0x30,
@ -417,12 +419,13 @@ pub(crate) fn is_printable(x: char) -> bool {
0x0a, 0x81, 0x26,
0x52, 0x4e,
0x28, 0x08,
0x2a, 0x56,
0x2a, 0x16,
0x1a, 0x26,
0x1c, 0x14,
0x17, 0x09,
0x4e, 0x04,
0x1e, 0x0f,
0x43, 0x0e,
0x24, 0x09,
0x44, 0x0d,
0x19, 0x07,
0x0a, 0x06,
0x48, 0x08,
@ -443,18 +446,18 @@ pub(crate) fn is_printable(x: char) -> bool {
0x45, 0x0b,
0x0a, 0x06,
0x0d, 0x13,
0x39, 0x07,
0x3a, 0x06,
0x0a, 0x36,
0x2c, 0x04,
0x10, 0x80, 0xc0,
0x17, 0x80, 0xb9,
0x3c, 0x64,
0x53, 0x0c,
0x48, 0x09,
0x0a, 0x46,
0x45, 0x1b,
0x48, 0x08,
0x53, 0x1d,
0x39, 0x81, 0x07,
0x53, 0x0d,
0x49, 0x81, 0x07,
0x46, 0x0a,
0x1d, 0x03,
0x47, 0x49,
@ -468,12 +471,13 @@ pub(crate) fn is_printable(x: char) -> bool {
0x32, 0x0d,
0x83, 0x9b, 0x66,
0x75, 0x0b,
0x80, 0xc4, 0x8a, 0xbc,
0x80, 0xc4, 0x8a, 0x4c,
0x63, 0x0d,
0x84, 0x2f, 0x8f, 0xd1,
0x82, 0x47, 0xa1, 0xb9,
0x82, 0x39, 0x07,
0x2a, 0x04,
0x02, 0x60,
0x5c, 0x06,
0x26, 0x0a,
0x46, 0x0a,
0x28, 0x05,
@ -486,32 +490,36 @@ pub(crate) fn is_printable(x: char) -> bool {
0x02, 0x0e,
0x97, 0xf8, 0x08,
0x84, 0xd6, 0x2a,
0x09, 0xa2, 0xf7,
0x81, 0x1f, 0x31,
0x09, 0xa2, 0xe7,
0x81, 0x33, 0x2d,
0x03, 0x11,
0x04, 0x08,
0x81, 0x8c, 0x89, 0x04,
0x6b, 0x05,
0x0d, 0x03,
0x09, 0x07,
0x10, 0x93, 0x60,
0x10, 0x92, 0x60,
0x47, 0x09,
0x74, 0x3c,
0x80, 0xf6, 0x0a,
0x73, 0x08,
0x6e, 0x17,
0x70, 0x15,
0x46, 0x80, 0x9a,
0x14, 0x0c,
0x57, 0x09,
0x19, 0x80, 0x87,
0x81, 0x47, 0x03,
0x85, 0x42, 0x0f,
0x15, 0x85, 0x50,
0x15, 0x84, 0x50,
0x1f, 0x80, 0xe1,
0x2b, 0x80, 0xd5,
0x2d, 0x03,
0x1a, 0x04,
0x02, 0x81, 0x70,
0x02, 0x81, 0x40,
0x1f, 0x11,
0x3a, 0x05,
0x01, 0x85, 0x00,
0x80, 0xd7, 0x29,
0x01, 0x84, 0xe0,
0x80, 0xf7, 0x29,
0x4c, 0x04,
0x0a, 0x04,
0x02, 0x83, 0x11,
@ -531,12 +539,13 @@ pub(crate) fn is_printable(x: char) -> bool {
0x09, 0x07,
0x02, 0x0e,
0x06, 0x80, 0x9a,
0x83, 0xd8, 0x08,
0x0d, 0x03,
0x83, 0xd8, 0x05,
0x10, 0x03,
0x0d, 0x03,
0x74, 0x0c,
0x59, 0x07,
0x0c, 0x14,
0x0c, 0x04,
0x01, 0x0f,
0x0c, 0x04,
0x38, 0x08,
0x0a, 0x06,
@ -544,12 +553,14 @@ pub(crate) fn is_printable(x: char) -> bool {
0x22, 0x4e,
0x81, 0x54, 0x0c,
0x15, 0x03,
0x03, 0x05,
0x05, 0x03,
0x07, 0x09,
0x19, 0x07,
0x1d, 0x03,
0x0b, 0x05,
0x06, 0x0a,
0x0a, 0x06,
0x08, 0x08,
0x07, 0x09,
0x03, 0x0d,
0x07, 0x29,
0x80, 0xcb, 0x25,
0x0a, 0x84, 0x06,
];

File diff suppressed because it is too large Load Diff

View File

@ -41,18 +41,26 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
static HEADER: &str = "
static HEADER: &str = r"
pub fn to_lower(c: char) -> [char; 3] {
match bsearch_case_table(c, LOWERCASE_TABLE) {
None => [c, '\\0', '\\0'],
Some(index) => LOWERCASE_TABLE[index].1,
if c.is_ascii() {
[(c as u8).to_ascii_lowercase() as char, '\0', '\0']
} else {
match bsearch_case_table(c, LOWERCASE_TABLE) {
None => [c, '\0', '\0'],
Some(index) => LOWERCASE_TABLE[index].1,
}
}
}
pub fn to_upper(c: char) -> [char; 3] {
match bsearch_case_table(c, UPPERCASE_TABLE) {
None => [c, '\\0', '\\0'],
Some(index) => UPPERCASE_TABLE[index].1,
if c.is_ascii() {
[(c as u8).to_ascii_uppercase() as char, '\0', '\0']
} else {
match bsearch_case_table(c, UPPERCASE_TABLE) {
None => [c, '\0', '\0'],
Some(index) => UPPERCASE_TABLE[index].1,
}
}
}

View File

@ -23,7 +23,7 @@ fn blank_line(&mut self) {
writeln!(&mut self.file).unwrap();
}
fn emit_bitset(&mut self, ranges: &[Range<u32>]) {
fn emit_bitset(&mut self, ranges: &[Range<u32>]) -> Result<(), String> {
let last_code_point = ranges.last().unwrap().end;
// bitset for every bit in the codepoint range
//
@ -44,7 +44,7 @@ fn emit_bitset(&mut self, ranges: &[Range<u32>]) {
let unique_words =
words.iter().cloned().collect::<BTreeSet<_>>().into_iter().collect::<Vec<_>>();
if unique_words.len() > u8::MAX as usize {
panic!("cannot pack {} into 8 bits", unique_words.len());
return Err(format!("cannot pack {} into 8 bits", unique_words.len()));
}
// needed for the chunk mapping to work
assert_eq!(unique_words[0], 0, "has a zero word");
@ -105,6 +105,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(&mut self.file, " &BITSET_MAPPING,").unwrap();
writeln!(&mut self.file, " )").unwrap();
writeln!(&mut self.file, "}}").unwrap();
Ok(())
}
fn emit_chunk_map(&mut self, zero_at: u8, compressed_words: &[u8], chunk_length: usize) {
@ -154,12 +156,12 @@ pub fn emit_codepoints(emitter: &mut RawEmitter, ranges: &[Range<u32>]) {
emitter.blank_line();
let mut bitset = emitter.clone();
bitset.emit_bitset(&ranges);
let bitset_ok = bitset.emit_bitset(&ranges).is_ok();
let mut skiplist = emitter.clone();
skiplist.emit_skiplist(&ranges);
if bitset.bytes_used <= skiplist.bytes_used {
if bitset_ok && bitset.bytes_used <= skiplist.bytes_used {
*emitter = bitset;
emitter.desc = String::from("bitset");
} else {