1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Fixed line count

This commit is contained in:
Boden Garman 2013-11-30 12:13:39 +11:00
parent 8f49e2afa2
commit 5000ad7f39

View file

@ -60,12 +60,10 @@ fn main() {
}
if (matches.opt_present("version")) {
println("cat 1.0.0");
println("wc 1.0.0");
return;
}
let mut files = matches.free.clone();
if files.is_empty() {
files = ~[~"-"];
@ -113,7 +111,11 @@ pub fn wc(files: ~[~str], matches: &Matches) {
// hence the option wrapped in a result here
match result(| | reader.read_until(LF)) {
Ok(Some(raw_line)) => {
line_count += 1;
// GNU 'wc' only counts lines that end in LF as lines
if (raw_line.iter().last().unwrap() == &LF) {
line_count += 1;
}
byte_count += raw_line.iter().len();
// try and convert the bytes to UTF-8 first