Skip to content

Commit

Permalink
regex-debug: add character count
Browse files Browse the repository at this point in the history
This adds a total character count to the output of the utf8-ranges
sub-command.
  • Loading branch information
BurntSushi committed Mar 18, 2018
1 parent 47d1aee commit 2b1fc27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions regex-debug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,20 @@ fn cmd_utf8_ranges(args: &Args) -> Result<()> {
format!("unexpected HIR, expected Unicode class").into(),
),
};
let mut char_count = 0;
for (i, range) in cls.iter().enumerate() {
if i > 0 {
println!("----------------------------");
}
char_count += (range.end() as u32) - (range.start() as u32) + 1;
for seq in Utf8Sequences::new(range.start(), range.end()) {
for (i, utf8_range) in seq.into_iter().enumerate() {
if i > 0 {
print!("|");
}
for utf8_range in seq.into_iter() {
print!("[{:02X}-{:02X}]", utf8_range.start, utf8_range.end);
}
println!();
}
}
println!("codepoint count: {}", char_count);
Ok(())
}

Expand Down

0 comments on commit 2b1fc27

Please sign in to comment.