From be117de7e76552463df132dbd326e064cf7a66de Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 25 Jan 2015 02:20:08 -0500 Subject: [PATCH] wc: reset current_char_count after each line. --- src/wc/wc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 0309f84bf..d35f953a1 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -112,7 +112,6 @@ pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), isize> { let mut word_count: usize = 0; let mut byte_count: usize = 0; let mut char_count: usize = 0; - let mut current_char_count: usize = 0; let mut longest_line_length: usize = 0; loop { @@ -128,6 +127,7 @@ pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), isize> { byte_count += raw_line.len(); // try and convert the bytes to UTF-8 first + let mut current_char_count = 0; match from_utf8(raw_line.as_slice()) { Ok(line) => { word_count += line.words().count();