Skip to content

Commit

Permalink
Try #10:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Jan 6, 2019
2 parents 86ac76c + eb7affc commit 1f81ad6
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 29 deletions.
152 changes: 152 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# TemplateCIConfig { bench: BenchEntry(MatrixEntry { run: false, version: "nightly", install_commandline: None, commandline: "cargo bench" }), clippy: ClippyEntry(MatrixEntry { run: true, version: "stable", install_commandline: Some("rustup component add clippy"), commandline: "cargo clippy -- -D warnings" }), rustfmt: RustfmtEntry(MatrixEntry { run: true, version: "stable", install_commandline: Some("rustup component add rustfmt"), commandline: "cargo fmt -v -- --check" }), additional_matrix_entries: {}, cache: "cargo", os: "linux", dist: "xenial", versions: ["stable", "nightly"], test_commandline: "cargo test --verbose --all" }
version: "2.1"

executors:
stable:
docker:
- image: liuchong/rustup:stable
nightly:
docker:
- image: liuchong/rustup:nightly
beta:
docker:
- image: liuchong/rustup:beta

commands:
cargo_test:
description: "Run `cargo test`"
steps:
- run:
name: "Clean out rust-toolchain"
command: "rm -f rust-toolchain"
- run:
name: "Toolchain debug info"
command: "rustc --version"
- run:
name: Test
command: "cargo test"

jobs:
test:
parameters:
version:
type: executor
executor: << parameters.version >>
steps:
- checkout
- cargo_test

rustfmt:
parameters:
version:
type: executor
executor: << parameters.version >>
steps:
- checkout
- run:
name: Install
command: rustup component add rustfmt
- run:
name: Rustfmt
command: cargo fmt -v -- --check

clippy:
parameters:
version:
type: executor
executor: << parameters.version >>
steps:
- checkout
- run:
name: Install
command: rustup component add clippy
- run:
name: Clippy
command: cargo clippy -- -D warnings

bench:
parameters:
version:
type: executor
executor: << parameters.version >>
steps:
- checkout
- run:
name: Bench
command: cargo bench

ci_success:
docker:
- image: alpine:latest
steps:
- run:
name: Success
command: "echo yay"

workflows:
continuous_integration:
jobs:
- test:
name: test-stable
version: stable
filters: {
"branches": {
"ignore": [
"/.*\\.tmp/"
]
},
"tags": {
"only": [
"/^v\\d+\\.\\d+\\.\\d+.*$/"
]
}
}
- test:
name: test-nightly
version: nightly
filters: {
"branches": {
"ignore": [
"/.*\\.tmp/"
]
},
"tags": {
"only": [
"/^v\\d+\\.\\d+\\.\\d+.*$/"
]
}
}
- rustfmt:
version: stable
filters: {
"branches": {
"ignore": [
"/.*\\.tmp/"
]
},
"tags": {
"only": [
"/^v\\d+\\.\\d+\\.\\d+.*$/"
]
}
}
- clippy:
version: stable
filters: {
"branches": {
"ignore": [
"/.*\\.tmp/"
]
},
"tags": {
"only": [
"/^v\\d+\\.\\d+\\.\\d+.*$/"
]
}
}
- ci_success:
requires:
- test-stable
- test-nightly
- rustfmt
- clippy
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ pro-release-commit-message = "Start next development iteration {{version}}"
tag-message = "Release {{prefix}}{{version}}"
dev-version-ext = "dev"
tag-prefix = "v"

[badges]
circle-ci = { repository = "antifuchs/chars", branch = "master" }
maintenance = { status = "passively-maintained" }
8 changes: 8 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Don't forget to update permissions and add this repo in
# https://app.bors.tech/repositories so bors can see the new repo!

status = [
"ci/circleci: ci_success",
]
timeout_sec = 300
delete_merged_branches = true
11 changes: 6 additions & 5 deletions generator/src/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ fn split_name_line(line: &str) -> Vec<String> {
static ref RIGHT_QUOTE: Regex = Regex::new("\"\\s*,\\s*$").unwrap();
static ref BACKSLASH_SOMETHING: Regex = Regex::new(r"\\(.)").unwrap();
}
let line = line.trim_left();
let line = line.trim_start();
let line = RIGHT_QUOTE.replace_all(line, "$1");
let line = line.trim_left_matches('"');
let line = line.trim_start_matches('"');
QUOTES
.split(line)
.map(|s| BACKSLASH_SOMETHING.replace_all(s, "$1").to_owned())
Expand Down Expand Up @@ -109,7 +109,7 @@ fn process_ascii_nametable(input: &File) -> Result<Vec<ASCIIEntry>, io::Error> {
static ref BEGINNING: Regex = Regex::new(r"^[A-Za-z ]*:\s*").unwrap();
}
let line = BEGINNING.replace_all(line, "");
let line = line.trim_left();
let line = line.trim_start();
if entry.mnemonics.is_empty() {
entry.mnemonics = split_name_line(line);
} else {
Expand Down Expand Up @@ -150,7 +150,7 @@ pub struct Information {
pub note: Option<&'static str>,
}
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
"#;

pub fn write_ascii_name_data(
Expand All @@ -172,7 +172,8 @@ pub fn write_ascii_name_data(
&mut out,
"pub static PRINTABLE_CHARS: &'static [Information; {}] = &[",
table.len()
).unwrap();
)
.unwrap();
for entry in table.clone() {
writeln!(&mut out, " {}", entry.for_display()).unwrap();
}
Expand Down
5 changes: 3 additions & 2 deletions generator/src/fst_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn build_stopwords() -> BTreeSet<&'static str> {
"for",
"symbol",
"<control>",
].into_iter(),
]
.into_iter(),
)
}

Expand All @@ -28,7 +29,7 @@ fn add_component(result: &mut Vec<String>, component: &str) {
static ref STOPS: BTreeSet<&'static str> = build_stopwords();
}
let component = component.to_lowercase();
let component = component.trim_right_matches(',');
let component = component.trim_end_matches(',');

if STOPS.contains(component) || component.len() == 1 {
return;
Expand Down
45 changes: 25 additions & 20 deletions generator/src/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum LineType {
}

fn process_line(names: &mut fst_generator::Names, line: &str) -> Result<LineType, Error> {
if line.starts_with('#') || line.trim_left() == "" {
if line.starts_with('#') || line.trim_start() == "" {
return Ok(LineType::None);
}
let fields: Vec<&str> = line.splitn(15, ';').collect();
Expand Down Expand Up @@ -95,7 +95,8 @@ fn test_processing() {
process_line(
&mut sorted_names,
"03BB;GREEK SMALL LETTER LAMDA;Ll;0;L;;;;;N;GREEK SMALL LETTER LAMBDA;;039B;;039B"
).unwrap()
)
.unwrap()
);
let have = BTreeSet::from_iter(sorted_names.iter().map(|(name, chs)| {
let v: Vec<char> = chs.into_iter().map(|ch| ch.to_owned()).collect();
Expand Down Expand Up @@ -140,15 +141,17 @@ fn test_processing() {
process_line(
&mut sorted_names,
"00AE;REGISTERED SIGN;So;0;ON;;;;;N;REGISTERED TRADE MARK SIGN;;;;"
).unwrap()
)
.unwrap()
);
assert_eq!(
LineType::Simple,
process_line(
&mut sorted_names,
"0214;LATIN CAPITAL LETTER U WITH DOUBLE GRAVE;Lu;0;L;0055 \
030F;;;;N;;;;0215;e"
).unwrap()
)
.unwrap()
);

// CJK blocks:
Expand All @@ -157,14 +160,16 @@ fn test_processing() {
process_line(
&mut sorted_names,
"3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;"
).unwrap()
)
.unwrap()
);
assert_eq!(
LineType::BlockEnd(0x4DB5),
process_line(
&mut sorted_names,
"4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;"
).unwrap()
)
.unwrap()
);

let have = BTreeSet::from_iter(sorted_names.iter().map(|(name, chs)| {
Expand Down Expand Up @@ -209,16 +214,18 @@ pub fn read_names(names: &mut fst_generator::Names, file: &Path) -> Result<(), E
let line = lines.next().ok_or(Error::Block(start))??;
match try!(process_line(names, &line)) {
LineType::Simple | LineType::None | LineType::BlockStart(_) => {
return Err(Error::Block(start))
return Err(Error::Block(start));
}
// TODO: update to inclusive range syntax when it's stable:
LineType::BlockEnd(end) => for i in start..end + 1 {
if let Some(ch) = char::from_u32(i as u32) {
if let Some(name) = unicode_names2::name(ch) {
names.insert(vec![name.to_string()], ch);
LineType::BlockEnd(end) => {
for i in start..end + 1 {
if let Some(ch) = char::from_u32(i as u32) {
if let Some(name) = unicode_names2::name(ch) {
names.insert(vec![name.to_string()], ch);
}
}
}
},
}
}
}
LineType::BlockEnd(end) => {
Expand All @@ -244,10 +251,11 @@ pub fn write_name_data(names: &fst_generator::Names, output: &Path) -> Result<()
key.push(*c)
}

let num: u64 = (0xff << 32) | *results.entry(key).or_insert_with(|| {
counter += 1;
counter - 1
});
let num: u64 = (0xff << 32)
| *results.entry(key).or_insert_with(|| {
counter += 1;
counter - 1
});
try!(map_builder.insert(name, num));
} else {
try!(map_builder.insert(name, *chs.iter().next().unwrap() as u64));
Expand All @@ -263,10 +271,7 @@ pub fn write_name_data(names: &fst_generator::Names, output: &Path) -> Result<()
ambiguous_chars[i as usize] = chars;
}
try!(writeln!(&mut rust_out, "/// Generated with `make names`"));
try!(writeln!(
&mut rust_out,
"#[cfg_attr(rustfmt, rustfmt_skip)]"
));
try!(writeln!(&mut rust_out, "#[rustfmt::skip]"));
try!(writeln!(
&mut rust_out,
"pub static AMBIGUOUS_CHARS: &'static [&'static str; {}] = &[",
Expand Down
2 changes: 1 addition & 1 deletion src/ascii/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Information {
pub note: Option<&'static str>,
}

#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
pub static PRINTABLE_CHARS: &'static [Information; 128] = &[
Information{value:'\u{0}', mnemonics:&["NUL"], synonyms:&["Null", "\\0"], note:None},
Information{value:'\u{1}', mnemonics:&["SOH"], synonyms:&["Start Of Header"], note:None},
Expand Down
2 changes: 1 addition & 1 deletion src/unicode/names.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Generated with `make names`
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
pub static AMBIGUOUS_CHARS: &'static [&'static str; 4711] = &[
",༂༃༊༓༗\u{f18}༶\u{f39}འ\u{fb0}࿃࿊࿋࿌࿐𑨩𑩺\u{11a95}𑲈",
"འ\u{fb0}𑨩𑩺\u{11a95}𑲈",
Expand Down

0 comments on commit 1f81ad6

Please sign in to comment.