1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-30 12:37:49 +00:00

Merge pull request #348 from Arcterus/wc-buffering

wc: stop buffering stdin twice
This commit is contained in:
Heather 2014-07-10 07:50:33 +04:00
commit f9dc6111b8

View file

@ -15,7 +15,7 @@ extern crate getopts;
extern crate libc; extern crate libc;
use std::str::from_utf8; use std::str::from_utf8;
use std::io::{print, stdin, File, BufferedReader}; use std::io::{print, stdin_raw, File, BufferedReader};
use StdResult = std::result::Result; use StdResult = std::result::Result;
use getopts::Matches; use getopts::Matches;
@ -87,6 +87,7 @@ static TAB: u8 = '\t' as u8;
static SYN: u8 = 0x16 as u8; static SYN: u8 = 0x16 as u8;
static FF: u8 = 0x0C as u8; static FF: u8 = 0x0C as u8;
#[inline(always)]
fn is_word_seperator(byte: u8) -> bool { fn is_word_seperator(byte: u8) -> bool {
byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF
} }
@ -230,7 +231,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u
fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> { fn open(path: String) -> StdResult<BufferedReader<Box<Reader>>, int> {
if "-" == path.as_slice() { if "-" == path.as_slice() {
let reader = box stdin() as Box<Reader>; let reader = box stdin_raw() as Box<Reader>;
return Ok(BufferedReader::new(reader)); return Ok(BufferedReader::new(reader));
} }