From 5402e699234bb79d99f5e455480b99229cd3aa2b Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 13:48:42 +0100 Subject: [PATCH] mkfifo, paste, shuf: fix build --- src/mkfifo/mkfifo.rs | 15 +++++++-------- src/paste/paste.rs | 6 +++--- src/shuf/shuf.rs | 10 +++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 7ef335874..5ef8f254e 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -12,6 +12,7 @@ extern crate getopts; extern crate libc; +use std::ffi::CString; use std::num::FromStrRadix; use std::os; use libc::funcs::posix88::stat_::mkfifo; @@ -23,7 +24,7 @@ mod util; static NAME : &'static str = "mkfifo"; static VERSION : &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let opts = [ getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"), getopts::optflag("h", "help", "display this help and exit"), @@ -66,13 +67,11 @@ pub fn uumain(args: Vec) -> int { let mut exit_status = 0; for f in matches.free.iter() { - f.with_c_str(|name| { - let err = unsafe { mkfifo(name, mode) }; - if err == -1 { - show_error!("creating '{}': {}", f, os::error_string(os::errno())); - exit_status = 1; - } - }); + let err = unsafe { mkfifo(CString::from_slice(f.as_bytes()).as_ptr(), mode) }; + if err == -1 { + show_error!("creating '{}': {}", f, os::error_string(os::errno())); + exit_status = 1; + } } exit_status diff --git a/src/paste/paste.rs b/src/paste/paste.rs index a4ecbe8e6..b2cff4916 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -22,7 +22,7 @@ mod util; static NAME: &'static str = "paste"; static VERSION: &'static str = "1.0.0"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ @@ -60,10 +60,10 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { let mut files: Vec>> = filenames.into_iter().map(|name| io::BufferedReader::new( if name.as_slice() == "-" { - box io::stdio::stdin_raw() as Box + Box::new(io::stdio::stdin_raw()) as Box } else { let r = crash_if_err!(1, io::File::open(&Path::new(name))); - box r as Box + Box::new(r) as Box } ) ).collect(); diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 946967d27..3d2cd1d4c 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -32,7 +32,7 @@ enum Mode { static NAME: &'static str = "shuf"; static VERSION: &'static str = "0.0.1"; -pub fn uumain(args: Vec) -> int { +pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); let opts = [ @@ -157,16 +157,16 @@ enum WrappedRng { impl WrappedRng { fn next_u32(&mut self) -> u32 { match self { - &WrappedRng::RngFile(ref mut r) => r.next_u32(), - &WrappedRng::RngDefault(ref mut r) => r.next_u32(), + &mut WrappedRng::RngFile(ref mut r) => r.next_u32(), + &mut WrappedRng::RngDefault(ref mut r) => r.next_u32(), } } } fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, outname: Option, random: Option) -> IoResult<()> { let mut output = match outname { - Some(name) => box io::BufferedWriter::new(try!(io::File::create(&Path::new(name)))) as Box, - None => box io::stdout() as Box + Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box, + None => Box::new(io::stdout()) as Box }; let mut rng = match random { Some(name) => WrappedRng::RngFile(rand::reader::ReaderRng::new(try!(io::File::open(&Path::new(name))))),