mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Fixed line count
This commit is contained in:
parent
8f49e2afa2
commit
5000ad7f39
1 changed files with 6 additions and 4 deletions
10
wc/wc.rs
10
wc/wc.rs
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue