mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
wc: fix for latest Rust when applied with @Heather's fix
This commit is contained in:
parent
2fa4f23d86
commit
0b83a0fa61
1 changed files with 4 additions and 4 deletions
8
wc/wc.rs
8
wc/wc.rs
|
@ -12,8 +12,8 @@
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
|
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::{print, stdin, stderr, File, result, BufferedReader};
|
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
use std::io::{print, stdin, stderr, File, BufferedReader};
|
||||||
use extra::getopts::{groups, Matches};
|
use extra::getopts::{groups, Matches};
|
||||||
|
|
||||||
struct Result {
|
struct Result {
|
||||||
|
@ -108,8 +108,8 @@ pub fn wc(files: ~[~str], matches: &Matches) {
|
||||||
loop {
|
loop {
|
||||||
// reading from a TTY seems to raise a condition on, rather than return Some(0) like a file.
|
// reading from a TTY seems to raise a condition on, rather than return Some(0) like a file.
|
||||||
// hence the option wrapped in a result here
|
// hence the option wrapped in a result here
|
||||||
match result(| | reader.read_until(LF)) {
|
match reader.read_until(LF) {
|
||||||
Ok(Some(raw_line)) => {
|
Ok(raw_line) => {
|
||||||
// GNU 'wc' only counts lines that end in LF as lines
|
// GNU 'wc' only counts lines that end in LF as lines
|
||||||
if raw_line.iter().last().unwrap() == &LF {
|
if raw_line.iter().last().unwrap() == &LF {
|
||||||
line_count += 1;
|
line_count += 1;
|
||||||
|
@ -223,7 +223,7 @@ fn open(path: ~str) -> Option<BufferedReader<~Reader>> {
|
||||||
return Some(BufferedReader::new(reader));
|
return Some(BufferedReader::new(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
match result(|| File::open(&std::path::Path::new(path.as_slice()))) {
|
match File::open(&std::path::Path::new(path.as_slice())) {
|
||||||
Ok(fd) => {
|
Ok(fd) => {
|
||||||
let reader = ~fd as ~Reader;
|
let reader = ~fd as ~Reader;
|
||||||
return Some(BufferedReader::new(reader));
|
return Some(BufferedReader::new(reader));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue