From 4e0360c4956225c605c88f0cb9f4c9f35fd93542 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Fri, 9 Jan 2015 16:16:05 -0800 Subject: [PATCH] base64, cat: fix build for Rust alpha --- src/base64/base64.rs | 14 ++++++-------- src/cat/cat.rs | 2 +- src/common/util.rs | 44 ++++++++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/base64/base64.rs b/src/base64/base64.rs index b8eed44d4..5af887749 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -15,6 +15,7 @@ extern crate libc; #[macro_use] extern crate log; use std::ascii::AsciiExt; +use std::error::Error; use std::io::{println, File, stdout}; use std::io::stdio::stdin_raw; @@ -33,7 +34,7 @@ mod util; static NAME: &'static str = "base64"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ optflag("d", "decode", "decode data"), optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"), @@ -46,8 +47,7 @@ pub fn uumain(args: Vec) -> int { let matches = match getopts(args.tail(), &opts) { Ok(m) => m, Err(e) => { - error!("error: {}", e); - panic!() + crash!(1, "error: {}", e); } }; @@ -67,8 +67,7 @@ pub fn uumain(args: Vec) -> int { Some(s) => match s.parse() { Some(s) => s, None => { - error!("error: {}", "Argument to option 'wrap' improperly formatted."); - panic!() + crash!(1, "error: {}", "Argument to option 'wrap' improperly formatted."); } }, None => 76 @@ -129,13 +128,12 @@ fn decode(input: &mut Reader, ignore_garbage: bool) { } } Err(s) => { - error!("error: {}", s); - panic!() + crash!(1, "error: {} ({})", s.description(), s.detail().unwrap_or("".to_string())); } } } -fn encode(input: &mut Reader, line_wrap: uint) { +fn encode(input: &mut Reader, line_wrap: usize) { let b64_conf = base64::Config { char_set: base64::Standard, newline: base64::Newline::LF, diff --git a/src/cat/cat.rs b/src/cat/cat.rs index d90591513..7c15a1a2b 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -1,5 +1,5 @@ #![crate_name = "cat"] -#![feature(unsafe_destructor)] +#![feature(box_syntax, unsafe_destructor)] /* * This file is part of the uutils coreutils package. diff --git a/src/common/util.rs b/src/common/util.rs index 2aaf848ba..7ee97b5f2 100644 --- a/src/common/util.rs +++ b/src/common/util.rs @@ -10,42 +10,42 @@ extern crate libc; macro_rules! show_error( - ($($args:expr),+) => ({ + ($($args:tt)+) => ({ pipe_write!(&mut ::std::io::stderr(), "{}: error: ", ::NAME); - pipe_writeln!(&mut ::std::io::stderr(), $($args),+); + pipe_writeln!(&mut ::std::io::stderr(), $($args)+); }) ); #[macro_export] macro_rules! show_warning( - ($($args:expr),+) => ({ + ($($args:tt)+) => ({ pipe_write!(&mut ::std::io::stderr(), "{}: warning: ", ::NAME); - pipe_writeln!(&mut ::std::io::stderr(), $($args),+); + pipe_writeln!(&mut ::std::io::stderr(), $($args)+); }) ); #[macro_export] macro_rules! show_info( - ($($args:expr),+) => ({ + ($($args:tt)+) => ({ pipe_write!(&mut ::std::io::stderr(), "{}: ", ::NAME); - pipe_writeln!(&mut ::std::io::stderr(), $($args),+); + pipe_writeln!(&mut ::std::io::stderr(), $($args)+); }) ); #[macro_export] macro_rules! eprint( - ($($args:expr),+) => (pipe_write!(&mut ::std::io::stderr(), $($args),+)) + ($($args:tt)+) => (pipe_write!(&mut ::std::io::stderr(), $($args)+)) ); #[macro_export] macro_rules! eprintln( - ($($args:expr),+) => (pipe_writeln!(&mut ::std::io::stderr(), $($args),+)) + ($($args:tt)+) => (pipe_writeln!(&mut ::std::io::stderr(), $($args)+)) ); #[macro_export] macro_rules! crash( - ($exitcode:expr, $($args:expr),+) => ({ - show_error!($($args),+); + ($exitcode:expr, $($args:tt)+) => ({ + show_error!($($args)+); unsafe { ::util::libc::exit($exitcode as ::util::libc::c_int); } }) ); @@ -84,8 +84,8 @@ macro_rules! return_if_err( #[macro_export] macro_rules! pipe_print( - ($($args:expr),+) => ( - match write!(&mut ::std::io::stdout(), $($args),+) { + ($($args:tt)+) => ( + match write!(&mut ::std::io::stdout(), $($args)+) { Ok(_) => true, Err(f) => { if f.kind == ::std::io::BrokenPipe { @@ -100,8 +100,8 @@ macro_rules! pipe_print( #[macro_export] macro_rules! pipe_println( - ($($args:expr),+) => ( - match writeln!(&mut ::std::io::stdout(), $($args),+) { + ($($args:tt)+) => ( + match writeln!(&mut ::std::io::stdout(), $($args)+) { Ok(_) => true, Err(f) => { if f.kind == ::std::io::BrokenPipe { @@ -116,8 +116,8 @@ macro_rules! pipe_println( #[macro_export] macro_rules! pipe_write( - ($fd:expr, $($args:expr),+) => ( - match write!($fd, $($args),+) { + ($fd:expr, $($args:tt)+) => ( + match write!($fd, $($args)+) { Ok(_) => true, Err(f) => { if f.kind == ::std::io::BrokenPipe { @@ -132,8 +132,8 @@ macro_rules! pipe_write( #[macro_export] macro_rules! pipe_writeln( - ($fd:expr, $($args:expr),+) => ( - match writeln!($fd, $($args),+) { + ($fd:expr, $($args:tt)+) => ( + match writeln!($fd, $($args)+) { Ok(_) => true, Err(f) => { if f.kind == ::std::io::BrokenPipe { @@ -148,8 +148,8 @@ macro_rules! pipe_writeln( #[macro_export] macro_rules! safe_write( - ($fd:expr, $($args:expr),+) => ( - match write!($fd, $($args),+) { + ($fd:expr, $($args:tt)+) => ( + match write!($fd, $($args)+) { Ok(_) => {} Err(f) => panic!(f.to_string()) } @@ -158,8 +158,8 @@ macro_rules! safe_write( #[macro_export] macro_rules! safe_writeln( - ($fd:expr, $($args:expr),+) => ( - match writeln!($fd, $($args),+) { + ($fd:expr, $($args:tt)+) => ( + match writeln!($fd, $($args)+) { Ok(_) => {} Err(f) => panic!(f.to_string()) }