about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorBruce A. MacNaughton <bruce.macnaughton@contrastsecurity.com>2022-07-19 18:03:18 -0700
committerBruce A. MacNaughton <bruce.macnaughton@contrastsecurity.com>2022-07-19 18:03:18 -0700
commit89ace470dcc0d4e08c1fd530e938893f87dcd436 (patch)
treeb2ca4972e955614ad9280d2deb4d50e4c22d0fb7 /src/tools
parentd4819632e2d0e135cff3e1987b77ca584e22a41a (diff)
downloadrust-89ace470dcc0d4e08c1fd530e938893f87dcd436.tar.gz
rust-89ace470dcc0d4e08c1fd530e938893f87dcd436.zip
formatted
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/unicode-table-generator/src/cascading_map.rs51
-rw-r--r--src/tools/unicode-table-generator/src/main.rs2
-rw-r--r--src/tools/unicode-table-generator/src/raw_emitter.rs1
3 files changed, 20 insertions, 34 deletions
diff --git a/src/tools/unicode-table-generator/src/cascading_map.rs b/src/tools/unicode-table-generator/src/cascading_map.rs
index 780d32e969c..d4efdef2e80 100644
--- a/src/tools/unicode-table-generator/src/cascading_map.rs
+++ b/src/tools/unicode-table-generator/src/cascading_map.rs
@@ -4,32 +4,24 @@ use std::collections::HashMap;
 use std::fmt::Write as _;
 use std::ops::Range;
 
-
 impl RawEmitter {
     pub fn emit_cascading_map(&mut self, ranges: &[Range<u32>]) -> bool {
-
         let mut map: [u8; 256] = [
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         ];
 
-        let points = ranges.iter().flat_map(
-            |r| (r.start..r.end).into_iter().collect::<Vec<u32>>()
-        ).collect::<Vec<u32>>();
+        let points = ranges
+            .iter()
+            .flat_map(|r| (r.start..r.end).into_iter().collect::<Vec<u32>>())
+            .collect::<Vec<u32>>();
 
         println!("there are {} points", points.len());
 
@@ -46,7 +38,8 @@ impl RawEmitter {
         let mut bit_for_high_byte = 1u8;
         let mut arms = Vec::<String>::new();
 
-        let mut high_bytes: Vec<usize> = codepoints_by_high_bytes.keys().map(|k| k.clone()).collect();
+        let mut high_bytes: Vec<usize> =
+            codepoints_by_high_bytes.keys().map(|k| k.clone()).collect();
         high_bytes.sort();
         for high_byte in high_bytes {
             let codepoints = codepoints_by_high_bytes.get_mut(&high_byte).unwrap();
@@ -61,21 +54,15 @@ impl RawEmitter {
             }
             arms.push(format!(
                 "{} => WHITESPACE_MAP[c as usize & 0xff] & {} != 0",
-                high_byte,
-                bit_for_high_byte)
-            );
+                high_byte, bit_for_high_byte
+            ));
             bit_for_high_byte <<= 1;
         }
 
-        writeln!(
-            &mut self.file,
-            "static WHITESPACE_MAP: [u8; 256] = [{}];",
-            fmt_list(map.iter())
-        )
-        .unwrap();
+        writeln!(&mut self.file, "static WHITESPACE_MAP: [u8; 256] = [{}];", fmt_list(map.iter()))
+            .unwrap();
         self.bytes_used += 256;
 
-
         writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap();
         writeln!(&mut self.file, "    match c as u32 >> 8 {{").unwrap();
         for arm in arms {
diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs
index b40afcf4bf2..a3327a3c2ff 100644
--- a/src/tools/unicode-table-generator/src/main.rs
+++ b/src/tools/unicode-table-generator/src/main.rs
@@ -75,10 +75,10 @@ use std::collections::{BTreeMap, HashMap};
 use std::ops::Range;
 use ucd_parse::Codepoints;
 
+mod cascading_map;
 mod case_mapping;
 mod raw_emitter;
 mod skiplist;
-mod cascading_map;
 mod unicode_download;
 
 use raw_emitter::{emit_codepoints, emit_whitespace, RawEmitter};
diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs
index f5960c45920..5aca86ba089 100644
--- a/src/tools/unicode-table-generator/src/raw_emitter.rs
+++ b/src/tools/unicode-table-generator/src/raw_emitter.rs
@@ -177,7 +177,6 @@ pub fn emit_whitespace(emitter: &mut RawEmitter, ranges: &[Range<u32>]) {
     cascading.emit_cascading_map(&ranges);
     *emitter = cascading;
     emitter.desc = String::from("cascading");
-
 }
 
 struct Canonicalized {