1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 21:17:46 +00:00

wc: reset current_char_count after each line.

This commit is contained in:
Steven Allen 2015-01-25 02:20:08 -05:00
parent 6c897dc76c
commit be117de7e7

View file

@ -112,7 +112,6 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), isize> {
let mut word_count: usize = 0; let mut word_count: usize = 0;
let mut byte_count: usize = 0; let mut byte_count: usize = 0;
let mut char_count: usize = 0; let mut char_count: usize = 0;
let mut current_char_count: usize = 0;
let mut longest_line_length: usize = 0; let mut longest_line_length: usize = 0;
loop { loop {
@ -128,6 +127,7 @@ pub fn wc(files: Vec<String>, matches: &Matches) -> StdResult<(), isize> {
byte_count += raw_line.len(); byte_count += raw_line.len();
// try and convert the bytes to UTF-8 first // try and convert the bytes to UTF-8 first
let mut current_char_count = 0;
match from_utf8(raw_line.as_slice()) { match from_utf8(raw_line.as_slice()) {
Ok(line) => { Ok(line) => {
word_count += line.words().count(); word_count += line.words().count();