1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

base64, cat: fix build for Rust alpha

This commit is contained in:
Arcterus 2015-01-09 16:16:05 -08:00
parent 37ada52d0d
commit 4e0360c495
3 changed files with 29 additions and 31 deletions

View file

@ -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<String>) -> int {
pub fn uumain(args: Vec<String>) -> 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<String>) -> 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<String>) -> 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,

View file

@ -1,5 +1,5 @@
#![crate_name = "cat"]
#![feature(unsafe_destructor)]
#![feature(box_syntax, unsafe_destructor)]
/*
* This file is part of the uutils coreutils package.

View file

@ -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())
}