mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Use raw stdin/stdio.
Buffered one is expensive and serves no purpose. (cherry picked from commit ace707d5044026b1167b3326692c8c8f118e05e4)
This commit is contained in:
parent
fb8e502980
commit
3ab1865177
1 changed files with 4 additions and 3 deletions
|
@ -15,7 +15,8 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
|
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::{print, stdin, stdout, File};
|
use std::io::{print, File};
|
||||||
|
use std::io::stdio::{stdout_raw, stdin_raw};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args = os::args();
|
let args = os::args();
|
||||||
|
@ -95,7 +96,7 @@ fn is_newline_char(byte: u8) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) {
|
pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_ends: bool, show_tabs: bool, squeeze_blank: bool) {
|
||||||
let mut writer = stdout();
|
let mut writer = stdout_raw();
|
||||||
|
|
||||||
if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
|
if NumberNone != number || show_nonprint || show_ends || show_tabs || squeeze_blank {
|
||||||
let mut counter: uint = 1;
|
let mut counter: uint = 1;
|
||||||
|
@ -192,7 +193,7 @@ pub fn exec(files: ~[~str], number: NumberingMode, show_nonprint: bool, show_end
|
||||||
|
|
||||||
fn open(path: ~str) -> Option<~Reader> {
|
fn open(path: ~str) -> Option<~Reader> {
|
||||||
if "-" == path {
|
if "-" == path {
|
||||||
return Some(~stdin() as ~Reader);
|
return Some(~stdin_raw() as ~Reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
match File::open(&std::path::Path::new(path.as_slice())) {
|
match File::open(&std::path::Path::new(path.as_slice())) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue