fix *write*! macro args

This commit is contained in:
Michael Gehring 2014-11-22 07:27:54 +01:00
parent ab344d8e7c
commit 2027a7a981
6 changed files with 19 additions and 19 deletions

View file

@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
match File::open(&std::path::Path::new(path)) {
Ok(f) => Some((box f as Box<Reader>, false)),
Err(e) => {
(writeln!(stderr(), "cat: {0}: {1}", path, e.to_string())).unwrap();
(writeln!(&mut stderr(), "cat: {0}: {1}", path, e.to_string())).unwrap();
None
},
}

View file

@ -88,7 +88,7 @@ macro_rules! return_if_err(
#[macro_export]
macro_rules! pipe_print(
($($args:expr),+) => (
match write!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
match write!(&mut ::std::io::stdout(), $($args),+) {
Ok(_) => true,
Err(f) => {
if f.kind == ::std::io::BrokenPipe {
@ -104,7 +104,7 @@ macro_rules! pipe_print(
#[macro_export]
macro_rules! pipe_println(
($($args:expr),+) => (
match writeln!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
match writeln!(&mut ::std::io::stdout(), $($args),+) {
Ok(_) => true,
Err(f) => {
if f.kind == ::std::io::BrokenPipe {

4
src/env/env.rs vendored
View file

@ -181,8 +181,8 @@ pub fn uumain(args: Vec<String>) -> int {
}
}
for ref name in opts.unsets.iter() {
std::os::unsetenv(name.as_slice())
for name in opts.unsets.iter() {
std::os::unsetenv((name).as_slice())
}
for &(ref name, ref val) in opts.sets.iter() {

View file

@ -139,26 +139,26 @@ fn expand(options: Options) {
Ok('\t') if init || !options.iflag => {
let nb_spaces = to_next_stop(options.tabstops.as_slice(), col);
col += nb_spaces;
safe_write!(output, "{:1$}", "", nb_spaces);
safe_write!(&mut output, "{:1$}", "", nb_spaces);
}
Ok('\x08') => {
if col > 0 {
col -= 1;
}
init = false;
safe_write!(output, "{}", '\x08');
safe_write!(&mut output, "{}", '\x08');
}
Ok('\n') => {
col = 0;
init = true;
safe_write!(output, "{}", '\n');
safe_write!(&mut output, "{}", '\n');
}
Ok(c) => {
col += 1;
if c != ' ' {
init = false;
}
safe_write!(output, "{}", c);
safe_write!(&mut output, "{}", c);
}
Err(_) => break
}

View file

@ -72,5 +72,5 @@ pub fn uumain(args: Vec<String>) -> int {
}
fn usage () {
safe_writeln!(&mut stderr() as &mut Writer, "usage: tty [-s]");
safe_writeln!(&mut stderr(), "usage: tty [-s]");
}

View file

@ -135,21 +135,21 @@ fn to_next_stop(tabstops: &[uint], col: uint) -> Option<uint> {
}
}
fn unexpandspan(output: &mut io::LineBufferedWriter<io::stdio::StdWriter>,
fn unexpandspan(mut output: &mut io::LineBufferedWriter<io::stdio::StdWriter>,
tabstops: &[uint], nspaces: uint, col: uint, init: bool) {
let mut cur = col - nspaces;
if nspaces > 1 || init {
loop {
match to_next_stop(tabstops, cur) {
Some(to_next) if cur + to_next <= col => {
safe_write!(output, "{}", '\t');
safe_write!(&mut output, "{}", '\t');
cur += to_next;
}
_ => break
}
}
}
safe_write!(output, "{:1$}", "", col - cur);
safe_write!(&mut output, "{:1$}", "", col - cur);
}
fn unexpand(options: Options) {
@ -167,7 +167,7 @@ fn unexpand(options: Options) {
nspaces += 1;
} else {
nspaces = 0;
safe_write!(output, "{}", ' ');
safe_write!(&mut output, "{}", ' ');
}
col += 1;
}
@ -175,7 +175,7 @@ fn unexpand(options: Options) {
if is_tabstop(ts, col) {
nspaces = 0;
col += 1;
safe_write!(output, "{}", '\t');
safe_write!(&mut output, "{}", '\t');
}
match to_next_stop(ts, col) {
Some(to_next) => {
@ -186,7 +186,7 @@ fn unexpand(options: Options) {
col += 1;
unexpandspan(&mut output, ts, nspaces, col, init);
nspaces = 0;
safe_write!(output, "{}", '\t');
safe_write!(&mut output, "{}", '\t');
}
}
}
@ -197,7 +197,7 @@ fn unexpand(options: Options) {
nspaces = 0;
if col > 0 { col -= 1; }
init = false;
safe_write!(output, "{}", '\x08');
safe_write!(&mut output, "{}", '\x08');
}
Ok('\n') => {
if init || options.aflag {
@ -206,7 +206,7 @@ fn unexpand(options: Options) {
nspaces = 0;
col = 0;
init = true;
safe_write!(output, "{}", '\n');
safe_write!(&mut output, "{}", '\n');
}
Ok(c) => {
if init || options.aflag {
@ -215,7 +215,7 @@ fn unexpand(options: Options) {
nspaces = 0;
col += 1;
init = false;
safe_write!(output, "{}", c);
safe_write!(&mut output, "{}", c);
}
Err(_) => break
}