Skip to content

Commit

Permalink
Cleanup replacements.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Mar 13, 2024
1 parent 8b2be47 commit af76b82
Show file tree
Hide file tree
Showing 4 changed files with 1,001 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustrict"
authors = ["Finn Bear"]
version = "0.7.21"
version = "0.7.22"
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/finnbear/rustrict/"
Expand Down Expand Up @@ -73,7 +73,7 @@ serde = {version = "1", features=["derive"], optional = true}
rand = "0.8"
csv = "1.1"
censor_crate = {package = "censor", version = "0.3.0"}
rustrict_old = {package = "rustrict", version = "0.7.17"}
rustrict_old = {package = "rustrict", version = "0.7.21"}
serial_test = "0.5"
bincode = "1.3.3"
serde_json = "1"
9 changes: 5 additions & 4 deletions src/replacement_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ fn main() {
// Extra confusables.
include_str!("replacements_extra.csv")
.split("\n")
.filter(|line| !line.is_empty())
.map(|line| {
.enumerate()
.filter(|(_, line)| !line.is_empty())
.map(|(n, line)| {
let comma = line.find(",").unwrap();
let before_comma = &line[..comma];
let c = if before_comma.chars().count() == 1 {
before_comma.chars().next().unwrap()
} else {
let escape = before_comma
.strip_prefix("\\u{")
.expect(before_comma)
.expect(&format!("line {}", n + 1))
.strip_suffix("}")
.unwrap();
let escape_int = u32::from_str_radix(escape, 16).unwrap();
Expand All @@ -112,7 +113,7 @@ fn main() {
if c_string != c_string_2 {
println!("Warning (Mn): {c_string} -> {c_string_2}");
}
assert_eq!(c_string_2.chars().count(), 1);
assert_eq!(c_string_2.chars().count(), 1, "line {}", n + 1);

(
c_string_2.chars().next().unwrap(),
Expand Down
Loading

0 comments on commit af76b82

Please sign in to comment.