mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 05:27:45 +00:00
fix *write*! macro args
This commit is contained in:
parent
ab344d8e7c
commit
2027a7a981
6 changed files with 19 additions and 19 deletions
|
@ -284,7 +284,7 @@ fn open(path: &str) -> Option<(Box<Reader>, bool)> {
|
||||||
match File::open(&std::path::Path::new(path)) {
|
match File::open(&std::path::Path::new(path)) {
|
||||||
Ok(f) => Some((box f as Box<Reader>, false)),
|
Ok(f) => Some((box f as Box<Reader>, false)),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
(writeln!(stderr(), "cat: {0}: {1}", path, e.to_string())).unwrap();
|
(writeln!(&mut stderr(), "cat: {0}: {1}", path, e.to_string())).unwrap();
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ macro_rules! return_if_err(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! pipe_print(
|
macro_rules! pipe_print(
|
||||||
($($args:expr),+) => (
|
($($args:expr),+) => (
|
||||||
match write!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
|
match write!(&mut ::std::io::stdout(), $($args),+) {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
if f.kind == ::std::io::BrokenPipe {
|
if f.kind == ::std::io::BrokenPipe {
|
||||||
|
@ -104,7 +104,7 @@ macro_rules! pipe_print(
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! pipe_println(
|
macro_rules! pipe_println(
|
||||||
($($args:expr),+) => (
|
($($args:expr),+) => (
|
||||||
match writeln!(&mut ::std::io::stdout() as &mut Writer, $($args),+) {
|
match writeln!(&mut ::std::io::stdout(), $($args),+) {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(f) => {
|
Err(f) => {
|
||||||
if f.kind == ::std::io::BrokenPipe {
|
if f.kind == ::std::io::BrokenPipe {
|
||||||
|
|
4
src/env/env.rs
vendored
4
src/env/env.rs
vendored
|
@ -181,8 +181,8 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ref name in opts.unsets.iter() {
|
for name in opts.unsets.iter() {
|
||||||
std::os::unsetenv(name.as_slice())
|
std::os::unsetenv((name).as_slice())
|
||||||
}
|
}
|
||||||
|
|
||||||
for &(ref name, ref val) in opts.sets.iter() {
|
for &(ref name, ref val) in opts.sets.iter() {
|
||||||
|
|
|
@ -139,26 +139,26 @@ fn expand(options: Options) {
|
||||||
Ok('\t') if init || !options.iflag => {
|
Ok('\t') if init || !options.iflag => {
|
||||||
let nb_spaces = to_next_stop(options.tabstops.as_slice(), col);
|
let nb_spaces = to_next_stop(options.tabstops.as_slice(), col);
|
||||||
col += nb_spaces;
|
col += nb_spaces;
|
||||||
safe_write!(output, "{:1$}", "", nb_spaces);
|
safe_write!(&mut output, "{:1$}", "", nb_spaces);
|
||||||
}
|
}
|
||||||
Ok('\x08') => {
|
Ok('\x08') => {
|
||||||
if col > 0 {
|
if col > 0 {
|
||||||
col -= 1;
|
col -= 1;
|
||||||
}
|
}
|
||||||
init = false;
|
init = false;
|
||||||
safe_write!(output, "{}", '\x08');
|
safe_write!(&mut output, "{}", '\x08');
|
||||||
}
|
}
|
||||||
Ok('\n') => {
|
Ok('\n') => {
|
||||||
col = 0;
|
col = 0;
|
||||||
init = true;
|
init = true;
|
||||||
safe_write!(output, "{}", '\n');
|
safe_write!(&mut output, "{}", '\n');
|
||||||
}
|
}
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
col += 1;
|
col += 1;
|
||||||
if c != ' ' {
|
if c != ' ' {
|
||||||
init = false;
|
init = false;
|
||||||
}
|
}
|
||||||
safe_write!(output, "{}", c);
|
safe_write!(&mut output, "{}", c);
|
||||||
}
|
}
|
||||||
Err(_) => break
|
Err(_) => break
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,5 +72,5 @@ pub fn uumain(args: Vec<String>) -> int {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage () {
|
fn usage () {
|
||||||
safe_writeln!(&mut stderr() as &mut Writer, "usage: tty [-s]");
|
safe_writeln!(&mut stderr(), "usage: tty [-s]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
tabstops: &[uint], nspaces: uint, col: uint, init: bool) {
|
||||||
let mut cur = col - nspaces;
|
let mut cur = col - nspaces;
|
||||||
if nspaces > 1 || init {
|
if nspaces > 1 || init {
|
||||||
loop {
|
loop {
|
||||||
match to_next_stop(tabstops, cur) {
|
match to_next_stop(tabstops, cur) {
|
||||||
Some(to_next) if cur + to_next <= col => {
|
Some(to_next) if cur + to_next <= col => {
|
||||||
safe_write!(output, "{}", '\t');
|
safe_write!(&mut output, "{}", '\t');
|
||||||
cur += to_next;
|
cur += to_next;
|
||||||
}
|
}
|
||||||
_ => break
|
_ => break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safe_write!(output, "{:1$}", "", col - cur);
|
safe_write!(&mut output, "{:1$}", "", col - cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unexpand(options: Options) {
|
fn unexpand(options: Options) {
|
||||||
|
@ -167,7 +167,7 @@ fn unexpand(options: Options) {
|
||||||
nspaces += 1;
|
nspaces += 1;
|
||||||
} else {
|
} else {
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
safe_write!(output, "{}", ' ');
|
safe_write!(&mut output, "{}", ' ');
|
||||||
}
|
}
|
||||||
col += 1;
|
col += 1;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ fn unexpand(options: Options) {
|
||||||
if is_tabstop(ts, col) {
|
if is_tabstop(ts, col) {
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
col += 1;
|
col += 1;
|
||||||
safe_write!(output, "{}", '\t');
|
safe_write!(&mut output, "{}", '\t');
|
||||||
}
|
}
|
||||||
match to_next_stop(ts, col) {
|
match to_next_stop(ts, col) {
|
||||||
Some(to_next) => {
|
Some(to_next) => {
|
||||||
|
@ -186,7 +186,7 @@ fn unexpand(options: Options) {
|
||||||
col += 1;
|
col += 1;
|
||||||
unexpandspan(&mut output, ts, nspaces, col, init);
|
unexpandspan(&mut output, ts, nspaces, col, init);
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
safe_write!(output, "{}", '\t');
|
safe_write!(&mut output, "{}", '\t');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ fn unexpand(options: Options) {
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
if col > 0 { col -= 1; }
|
if col > 0 { col -= 1; }
|
||||||
init = false;
|
init = false;
|
||||||
safe_write!(output, "{}", '\x08');
|
safe_write!(&mut output, "{}", '\x08');
|
||||||
}
|
}
|
||||||
Ok('\n') => {
|
Ok('\n') => {
|
||||||
if init || options.aflag {
|
if init || options.aflag {
|
||||||
|
@ -206,7 +206,7 @@ fn unexpand(options: Options) {
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
col = 0;
|
col = 0;
|
||||||
init = true;
|
init = true;
|
||||||
safe_write!(output, "{}", '\n');
|
safe_write!(&mut output, "{}", '\n');
|
||||||
}
|
}
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
if init || options.aflag {
|
if init || options.aflag {
|
||||||
|
@ -215,7 +215,7 @@ fn unexpand(options: Options) {
|
||||||
nspaces = 0;
|
nspaces = 0;
|
||||||
col += 1;
|
col += 1;
|
||||||
init = false;
|
init = false;
|
||||||
safe_write!(output, "{}", c);
|
safe_write!(&mut output, "{}", c);
|
||||||
}
|
}
|
||||||
Err(_) => break
|
Err(_) => break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue