Skip to content

Commit

Permalink
Engage new tables for ucd/normal
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Aug 11, 2017
1 parent 42db673 commit 2a7c441
Show file tree
Hide file tree
Showing 23 changed files with 6,218 additions and 11,232 deletions.
4 changes: 0 additions & 4 deletions etc/refresh-tables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ cargo run --release --package=unic-gen -- --download --generate idna ucd normal
echo
echo "Generating idna tables with python"
python2 tools/gen_idna_tables.py

echo
echo "Generating remaining ucd tables with python"
python2 tools/gen_ucd_tables.py
8 changes: 8 additions & 0 deletions gen/src/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ pub mod ucd;
/// The standard auto-generated source disclaimer.
const PREAMBLE: &'static str = "// WARNING: Auto-generated by the `unic-gen` crate.\n\
// WARNING: DO NOT EDIT MANUALLY!";

fn capitalize(str: &str) -> String {
let mut chars = str.chars();
match chars.next() {
None => String::new(),
Some(ch) => ch.to_uppercase().collect::<String>() + chars.as_str(),
}
}
10 changes: 4 additions & 6 deletions gen/src/generate/ucd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ pub fn generate() -> io::Result<()> {
fs::create_dir_all(path)?;
core::generate(path, &ucd_version, &unicode_data)?;

// let path = Path::new("unic/ucd/normal/src/tables");
// let _ = fs::remove_dir_all(path);
// fs::create_dir_all(path)?;
// normal::generate(path, &ucd_version, &unicode_data)?;
use std::io::Write;
writeln!(::std::io::stderr(), "Use Python generation for ucd/normal")?;
let path = Path::new("unic/ucd/normal/src/tables");
let _ = fs::remove_dir_all(path);
fs::create_dir_all(path)?;
normal::generate(path, &ucd_version, &unicode_data)?;

Ok(())
}
7 changes: 6 additions & 1 deletion gen/src/generate/ucd/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use super::{UnicodeData, UnicodeDataEntry, UnicodeVersion};

use generate::PREAMBLE;
use generate::char_property::{ToBSearchSet, ToRangeBSearchMap, ToSingleBSearchMap};
use generate::capitalize;

struct GeneralCategoryMarkData(BTreeSet<char>);

Expand Down Expand Up @@ -166,6 +167,10 @@ impl<'a, 'b> From<&'a CanonicalDecompositionData<'b>> for CanonicalCompositionDa
.push((follow, composed));
}

for value in map.values_mut() {
value.sort_by_key(|it| it.0)
}

CanonicalCompositionData(map)
}
}
Expand All @@ -180,7 +185,7 @@ impl<'a> CompatibilityDecompositionData<'a> {
"{}\n{}",
PREAMBLE,
self.0.to_single_bsearch_map(|val, f| {
write!(f, "(\"{}\", &[", val.0)?;
write!(f, "({}, &[", capitalize(&val.0.to_lowercase()))?;
for char in val.1.iter() {
write!(f, "'{}',", char.escape_unicode()).unwrap();
}
Expand Down
Loading

0 comments on commit 2a7c441

Please sign in to comment.