Skip to content

Commit

Permalink
Merge pull request uutils#1307 from PaulCapron/master
Browse files Browse the repository at this point in the history
Remove some useless BufReader wrappers around stdin
  • Loading branch information
Arcterus authored Feb 21, 2019
2 parents 1dc7d8c + 324cbad commit 39b5760
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cp/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use clap::{App, Arg, ArgMatches};
use quick_error::ResultExt;
use std::collections::HashSet;
use std::fs;
use std::io::{stdin, stdout, BufRead, BufReader, Write};
use std::io::{stdin, stdout, Write};
use std::io;
use std::path::{Path, PathBuf, StripPrefixError};
use std::str::FromStr;
Expand Down Expand Up @@ -120,7 +120,7 @@ macro_rules! prompt_yes(
print!(" [y/N]: ");
crash_if_err!(1, stdout().flush());
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.char_indices().nth(0) {
Some((_, x)) => x == 'y' || x == 'Y',
_ => false
Expand Down
5 changes: 3 additions & 2 deletions src/factor/factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use rand::distributions::{Distribution, Uniform};
use rand::{SeedableRng, thread_rng};
use rand::rngs::SmallRng;
use std::cmp::{max, min};
use std::io::{stdin, BufRead, BufReader};
use std::io::{stdin, BufRead};
use std::num::Wrapping;
use std::mem::swap;

Expand Down Expand Up @@ -163,7 +163,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);

if matches.free.is_empty() {
for line in BufReader::new(stdin()).lines() {
let stdin = stdin();
for line in stdin.lock().lines() {
for number in line.unwrap().split_whitespace() {
print_factors_str(number);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ln/ln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern crate uucore;

use std::fs;
use std::io::{stdin, BufRead, BufReader, Result};
use std::io::{stdin, Result};
#[cfg(any(unix, target_os = "redox"))]
use std::os::unix::fs::symlink;
#[cfg(windows)]
Expand Down Expand Up @@ -303,7 +303,7 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> {

fn read_yes() -> bool {
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.char_indices().nth(0) {
Some((_, x)) => x == 'y' || x == 'Y',
_ => false,
Expand Down
4 changes: 2 additions & 2 deletions src/mv/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern crate uucore;

use std::fs;
use std::env;
use std::io::{stdin, BufRead, BufReader, Result};
use std::io::{stdin, Result};
use std::path::{Path, PathBuf};

static NAME: &str = "mv";
Expand Down Expand Up @@ -374,7 +374,7 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {

fn read_yes() -> bool {
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.chars().nth(0) {
Some(x) => x == 'y' || x == 'Y',
_ => false,
Expand Down

0 comments on commit 39b5760

Please sign in to comment.