1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

os::set_exit_status(isize) -> env::set_exit_status(i32)

This commit is contained in:
Michael Gehring 2015-02-06 14:48:07 +01:00
parent 19bb2e1ccd
commit e7b647171f
74 changed files with 133 additions and 129 deletions

View file

@ -1,17 +1,19 @@
#![feature(core, io, os, path)]
#![feature(core, env, io, os, path)]
use std::env;
use std::old_io::{File, Truncate, ReadWrite};
use std::os;
use std::old_path::Path;
static TEMPLATE: &'static str = "\
#![feature(os)]
#![feature(env, os)]
extern crate \"@UTIL_CRATE@\" as uu@UTIL_CRATE@;
use std::env;
use std::os;
use uu@UTIL_CRATE@::uumain;
fn main() {
os::set_exit_status(uumain(os::args()));
env::set_exit_status(uumain(os::args()));
}
";
@ -19,7 +21,7 @@ fn main() {
let args = os::args();
if args.len() != 3 {
println!("usage: mkbuild <crate> <outfile>");
os::set_exit_status(1);
env::set_exit_status(1);
return;
}

View file

@ -1,5 +1,6 @@
#![feature(core, io, os, path)]
#![feature(core, env, io, os, path)]
use std::env;
use std::old_io::{File, Truncate, Write};
use std::os;
use std::old_path::Path;
@ -8,7 +9,7 @@ fn main() {
let args = os::args();
if args.len() < 3 {
println!("usage: mkuutils <outfile> <crates>");
os::set_exit_status(1);
env::set_exit_status(1);
return;
}
@ -30,11 +31,11 @@ fn main() {
hashsum = true;
}
}
"true" => util_map.push_str("fn uutrue(_: Vec<String>) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"),
"false" => util_map.push_str("fn uufalse(_: Vec<String>) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"),
"true" => util_map.push_str("fn uutrue(_: Vec<String>) -> i32 { 0 }\nmap.insert(\"true\", uutrue);\n"),
"false" => util_map.push_str("fn uufalse(_: Vec<String>) -> i32 { 1 }\nmap.insert(\"false\", uufalse);\n"),
_ => {
crates.push_str(format!("extern crate \"{0}\" as uu{0};\n", prog).as_slice());
util_map.push_str(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec<String>) -> isize);\n", prog = prog).as_slice());
util_map.push_str(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec<String>) -> i32);\n", prog = prog).as_slice());
}
}
}

View file

@ -35,7 +35,7 @@ mod util;
static NAME: &'static str = "base64";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
optflag("d", "decode", "decode data"),
optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"),

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "basename";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = strip_dir(args[0].as_slice());
//

View file

@ -21,7 +21,7 @@ use std::old_io::stdio::{stdout_raw, stdin_raw, stderr};
use std::old_io::{IoResult};
use std::ptr::{copy_nonoverlapping_memory};
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let opts = [
getopts::optflag("A", "show-all", "equivalent to -vET"),

View file

@ -33,7 +33,7 @@ mod util;
const NAME: &'static str = "chmod";
const VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
@ -146,7 +146,7 @@ fn verify_mode(mode: &str) -> Result<(), String> {
Ok(())
}
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), isize> {
fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve_root: bool, recursive: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), i32> {
let mut r = Ok(());
for filename in files.iter() {
@ -182,7 +182,7 @@ fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve
r
}
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), isize> {
fn chmod_file(file: &Path, name: &str, changes: bool, quiet: bool, verbose: bool, fmode: Option<libc::mode_t>, cmode: Option<&String>) -> Result<(), i32> {
let path = CString::from_slice(name.as_bytes());
match fmode {
Some(mode) => {

View file

@ -40,7 +40,7 @@ extern {
static NAME: &'static str = "chroot";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let options = [
@ -98,7 +98,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr();
let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::from_slice(x.as_bytes()).as_bytes_with_nul().as_ptr()).collect();
command_parts.push(std::ptr::null());
execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as isize
execvp(executable as *const libc::c_char, command_parts.as_ptr() as *mut *const libc::c_char) as i32
}
}

View file

@ -75,7 +75,7 @@ fn cksum(fname: &str) -> IoResult<(u32, usize)> {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),

View file

@ -108,7 +108,7 @@ fn open_file(name: &str) -> IoResult<LineReader> {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"),
getopts::optflag("2", "", "suppress column 2 (lines uniq to FILE2)"),

View file

@ -32,7 +32,7 @@ pub enum Mode {
impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
optflag("h", "help", "display this help and exit"),
optflag("", "version", "output version information and exit"),

View file

@ -54,7 +54,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result<Vec<Range>, String> {
fn cut_bytes<R: Reader>(reader: R,
ranges: &Vec<Range>,
opts: &Options) -> isize {
opts: &Options) -> i32 {
use buffer::Bytes::Select;
use buffer::Bytes::Selected::{NewlineFound, Complete, Partial, EndOfFile};
@ -135,7 +135,7 @@ fn cut_bytes<R: Reader>(reader: R,
fn cut_characters<R: Reader>(reader: R,
ranges: &Vec<Range>,
opts: &Options) -> isize {
opts: &Options) -> i32 {
let mut buf_in = BufferedReader::new(reader);
let mut out = BufferedWriter::new(stdio::stdout_raw());
@ -242,7 +242,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
ranges: &Vec<Range>,
delim: &String,
only_delimited: bool,
out_delim: &String) -> isize {
out_delim: &String) -> i32 {
let mut buf_in = BufferedReader::new(reader);
let mut out = BufferedWriter::new(stdio::stdout_raw());
@ -316,7 +316,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
fn cut_fields<R: Reader>(reader: R,
ranges: &Vec<Range>,
opts: &FieldOptions) -> isize {
opts: &FieldOptions) -> i32 {
match opts.out_delimeter {
Some(ref delim) => {
return cut_fields_delimiter(reader, ranges, &opts.delimiter,
@ -395,7 +395,7 @@ fn cut_fields<R: Reader>(reader: R,
0
}
fn cut_files(mut filenames: Vec<String>, mode: Mode) -> isize {
fn cut_files(mut filenames: Vec<String>, mode: Mode) -> i32 {
let mut stdin_read = false;
let mut exit_code = 0;
@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> isize {
exit_code
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
optopt("b", "bytes", "select only these bytes", "LIST"),
optopt("c", "characters", "select only these characters", "LIST"),

View file

@ -16,7 +16,7 @@ use std::old_io::print;
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
getopts::optflag("z", "zero", "separate output with NUL rather than newline"),

View file

@ -90,7 +90,7 @@ fn du(path: &Path, mut my_stat: Stat,
stats
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
// In task

View file

@ -163,7 +163,7 @@ fn print_version() {
println!("echo version: {}", VERSION);
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let mut options = EchoOptions {
newline: false,
escape: false

4
src/env/env.rs vendored
View file

@ -53,7 +53,7 @@ fn print_env(null: bool) {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let prog = args[0].as_slice();
// to handle arguments the same way than GNU env, we can't use getopts
@ -198,7 +198,7 @@ pub fn uumain(args: Vec<String>) -> isize {
match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() {
Ok(exit) =>
return match exit {
std::old_io::process::ExitStatus(s) => s,
std::old_io::process::ExitStatus(s) => s as i32,
_ => 1
},
Err(_) => return 1

View file

@ -75,7 +75,7 @@ impl Options {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("i", "initial", "do not convert tabs after non blanks"),
getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"),

View file

@ -64,7 +64,7 @@ fn print_factors_str(num_str: &str) {
print_factors(num);
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("h", "help", "show this help message"),

View file

@ -9,6 +9,6 @@
* file that was distributed with this source code.
*/
pub fn uumain(_: Vec<String>) -> isize {
pub fn uumain(_: Vec<String>) -> i32 {
1
}

View file

@ -59,7 +59,7 @@ struct FmtOptions {
tabwidth : usize,
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("c", "crown-margin", "First and second line of paragraph may have different indentations, in which case the first line's indentation is preserved, and each subsequent line's indentation matches the second line."),

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "fold";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let (args, obs_width) = handle_obsolete(args.as_slice());
let program = args[0].clone();

View file

@ -25,7 +25,7 @@ use c_types::{get_pw_from_args, group};
static NAME: &'static str = "groups";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let options = [

View file

@ -90,7 +90,7 @@ fn detect_algo(program: &str, matches: &getopts::Matches) -> (&'static str, Box<
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let binary = Path::new(program.as_slice());
let binary_name = binary.filename_str().unwrap();
@ -168,7 +168,7 @@ fn usage(program: &str, binary_name: &str, opts: &[getopts::OptGroup]) {
pipe_print!("{}", getopts::usage("Compute and check message digests.", opts));
}
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), isize> {
fn hashsum(algoname: &str, mut digest: Box<Digest>, files: Vec<String>, binary: bool, check: bool, tag: bool, status: bool, quiet: bool, strict: bool, warn: bool) -> Result<(), i32> {
let mut bad_format = 0;
let mut failed = 0;
let binary_marker = if binary {

View file

@ -28,7 +28,7 @@ mod util;
static NAME: &'static str = "head";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let mut line_count = 10us;
let mut byte_count = 0us;

View file

@ -34,7 +34,7 @@ mod util;
static NAME: &'static str = "hostid";
static VERSION: &'static str = "0.0.1";
static EXIT_ERR: isize = 1;
static EXIT_ERR: i32 = 1;
pub enum Mode {
HostId,
@ -49,7 +49,7 @@ extern {
pub fn gethostid() -> c_long;
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
optflag("", "help", "display this help and exit"),

View file

@ -43,7 +43,7 @@ extern {
fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int;
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let options = [

View file

@ -85,7 +85,7 @@ extern {
static NAME: &'static str = "id";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let args_t = args.tail();
let options = [

View file

@ -40,8 +40,8 @@ mod signals;
static NAME: &'static str = "kill";
static VERSION: &'static str = "0.0.1";
static EXIT_OK: isize = 0;
static EXIT_ERR: isize = 1;
static EXIT_OK: i32 = 0;
static EXIT_ERR: i32 = 1;
pub enum Mode {
Kill,
@ -53,7 +53,7 @@ pub enum Mode {
impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
optflag("h", "help", "display this help and exit"),
optflag("V", "version", "output version information and exit"),
@ -185,7 +185,7 @@ fn help(progname: &str, usage: &str) {
println!("{}", get_help_text(progname, usage));
}
fn kill(signalname: &str, pids: std::vec::Vec<String>) -> isize {
fn kill(signalname: &str, pids: std::vec::Vec<String>) -> i32 {
let mut status = 0;
let optional_signal_value = signals::signal_by_name_or_value(signalname);
let signal_value = match optional_signal_value {

View file

@ -22,7 +22,7 @@ mod util;
static NAME : &'static str = "link";
static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),

View file

@ -46,7 +46,7 @@ fn version() {
println!("{} {}", NAME, VERSION);
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
//

View file

@ -27,7 +27,7 @@ static VERSION: &'static str = "1.0.0";
/**
* Handles option parsing
*/
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
// Linux-specific options, not implemented
@ -94,7 +94,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
/**
* Create the list of new directories
*/
fn exec(dirs: Vec<String>, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), isize> {
fn exec(dirs: Vec<String>, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), i32> {
let mut result = Ok(());
let mut parent_dirs = Vec::new();

View file

@ -25,7 +25,7 @@ mod util;
static NAME : &'static str = "mkfifo";
static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"),
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -62,7 +62,7 @@ pub enum BackupMode {
impl Copy for BackupMode {}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"),
@ -187,7 +187,7 @@ fn help(progname: &str, usage: &str) {
println!("{}", msg);
}
fn exec(files: &[Path], b: Behaviour) -> isize {
fn exec(files: &[Path], b: Behaviour) -> i32 {
match b.target_dir {
Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b),
None => {}
@ -245,7 +245,7 @@ fn exec(files: &[Path], b: Behaviour) -> isize {
0
}
fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> isize {
fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> i32 {
if !target_dir.is_dir() {
show_error!("target {} is not a directory", target_dir.display());
return 1;

View file

@ -33,7 +33,7 @@ extern {
fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int;
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"),
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -77,7 +77,7 @@ enum NumberFormat {
RightZero,
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let possible_options = [
optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"),
optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"),

View file

@ -38,7 +38,7 @@ extern {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() }
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let options = [
@ -72,7 +72,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let cstrs : Vec<CString> = opts.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect();
let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect();
args.push(std::ptr::null());
unsafe { execvp(args[0], args.as_mut_ptr()) as isize }
unsafe { execvp(args[0], args.as_mut_ptr())}
}
fn replace_fds() {

View file

@ -21,7 +21,7 @@ static VERSION : &'static str = "0.0.0";
#[macro_use]
mod util;
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("", "all", "print the number of cores available to the system"),
getopts::optopt("", "ignore", "ignore up to N cores", "N"),

View file

@ -19,7 +19,7 @@ use std::old_io::File;
#[derive(Debug)]
enum Radix { Decimal, Hexadecimal, Octal, Binary }
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optopt("A", "address-radix",
"Select the base in which file offsets are printed.", "RADIX"),

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "paste";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "printenv";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "pwd";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
getopts::optflag("", "help", "display this help and exit"),

View file

@ -110,7 +110,7 @@ fn canonicalize(original: &Path, can_mode: &CanonicalizeMode) -> io::IoResult<Pa
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
optflag("f", "canonicalize",

View file

@ -20,7 +20,7 @@ use getopts::{optflag, getopts, usage};
static NAME: &'static str = "realpath";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let options = [
optflag("h", "help", "Show help and exit"),

View file

@ -20,7 +20,7 @@ use getopts::{optflag, optopt, getopts, usage};
static NAME: &'static str = "relpath";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let options = [
optflag("h", "help", "Show help and exit"),

View file

@ -31,7 +31,7 @@ impl Copy for InteractiveMode {}
static NAME: &'static str = "rm";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
// TODO: make getopts support -R in addition to -r
@ -126,7 +126,7 @@ pub fn uumain(args: Vec<String>) -> isize {
}
// TODO: implement one-file-system
fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), isize> {
fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), i32> {
let mut r = Ok(());
for filename in files.iter() {
@ -168,7 +168,7 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
r
}
fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> {
fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), i32> {
let response =
if interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, name)
@ -188,7 +188,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo
Ok(())
}
fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> {
fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), i32> {
let response =
if interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, name)

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "rmdir";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
@ -66,7 +66,7 @@ pub fn uumain(args: Vec<String>) -> isize {
0
}
fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize>{
fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Result<(), i32>{
let mut r = Ok(());
for dir in dirs.iter() {
@ -87,7 +87,7 @@ fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Resu
r
}
fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize> {
fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), i32> {
let mut walk_dir = match fs::walk_dir(path) {
Ok(m) => m,
Err(f) => {

View file

@ -37,7 +37,7 @@ fn escape_sequences(s: &str) -> String {
replace("\\t", "\t")
}
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, isize> {
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, i32> {
let mut seq_args = vec!();
let program = args[0].clone();
let mut iter = args.into_iter().skip(1);
@ -146,7 +146,7 @@ fn print_version() {
println!("seq 1.0.0\n");
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let mut options = SeqOptions {
separator: "\n".to_string(),

View file

@ -33,7 +33,7 @@ enum Mode {
static NAME: &'static str = "shuf";
static VERSION: &'static str = "0.0.1";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
@ -186,7 +186,7 @@ fn shuf_lines(mut lines: Vec<String>, repeat: bool, zero: bool, count: usize, ou
Ok(())
}
fn parse_range(input_range: String) -> Result<RangeInclusive<usize>, (String, isize)> {
fn parse_range(input_range: String) -> Result<RangeInclusive<usize>, (String, i32)> {
let split: Vec<&str> = input_range.as_slice().split('-').collect();
if split.len() != 2 {
Err(("invalid range format".to_string(), 1))

View file

@ -26,7 +26,7 @@ mod time;
static NAME: &'static str = "sleep";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [

View file

@ -29,7 +29,7 @@ static VERSION: &'static str = "0.0.1";
static DECIMAL_PT: char = '.';
static THOUSANDS_SEP: char = ',';
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("n", "numeric-sort", "compare according to string numerical value"),

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "split";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"),
getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"),
@ -248,7 +248,7 @@ fn num_prefix(i: usize, width: usize) -> String {
c
}
fn split(settings: &Settings) -> isize {
fn split(settings: &Settings) -> i32 {
let mut reader = io::BufferedReader::new(
if settings.input.as_slice() == "-" {
Box::new(io::stdio::stdin_raw()) as Box<Reader>

View file

@ -205,7 +205,7 @@ fn get_preload_env() -> (String, String) {
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let optgrps = [
optopt("i", "input", "adjust standard input stream buffering", "MODE"),
optopt("o", "output", "adjust standard output stream buffering", "MODE"),
@ -251,7 +251,7 @@ pub fn uumain(args: Vec<String>) -> isize {
match process.wait() {
Ok(status) => {
match status {
ProcessExit::ExitStatus(i) => return i,
ProcessExit::ExitStatus(i) => return i as i32,
ProcessExit::ExitSignal(i) => crash!(1, "process killed by signal {}", i),
}
},

View file

@ -76,7 +76,7 @@ fn open(name: &str) -> IoResult<Box<Reader>> {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),

View file

@ -140,7 +140,7 @@ mod platform {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0][];
let options = [

View file

@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "tac";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [

View file

@ -31,7 +31,7 @@ mod util;
static NAME: &'static str = "tail";
static VERSION: &'static str = "0.0.1";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let mut beginning = false;
let mut lines = true;
let mut byte_count = 0us;

View file

@ -22,7 +22,7 @@ use getopts::{getopts, optflag, usage};
static NAME: &'static str = "tee";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
match options(args.as_slice()).and_then(exec) {
Ok(_) => 0,
Err(_) => 1

View file

@ -20,7 +20,7 @@ use std::str::{from_utf8};
static NAME: &'static str = "test";
// TODO: decide how to handle non-UTF8 input for all the utils
pub fn uumain(_: Vec<String>) -> isize {
pub fn uumain(_: Vec<String>) -> i32 {
let args = args_as_bytes();
let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect();
if args.len() == 0 {
@ -40,7 +40,7 @@ pub fn uumain(_: Vec<String>) -> isize {
_ => &args[1..args.len()],
};
let mut error = false;
let retval = 1 - parse_expr(args, &mut error) as isize;
let retval = 1 - parse_expr(args, &mut error) as i32;
if error {
2
} else {

View file

@ -33,9 +33,9 @@ extern {
static NAME: &'static str = "timeout";
static VERSION: &'static str = "1.0.0";
static ERR_EXIT_STATUS: isize = 125;
static ERR_EXIT_STATUS: i32 = 125;
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
@ -101,7 +101,7 @@ Usage:
0
}
fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> isize {
fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> i32 {
if !foreground {
unsafe { setpgid(0, 0) };
}
@ -125,8 +125,8 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af
process.set_timeout(Some((duration * 1000f64) as u64)); // FIXME: this ignores the f64...
match process.wait() {
Ok(status) => match status {
ExitStatus(stat) => stat,
ExitSignal(stat) => stat
ExitStatus(stat) => stat as i32,
ExitSignal(stat) => stat as i32
},
Err(_) => {
return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize));
@ -135,8 +135,8 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af
Ok(status) => {
if preserve_status {
match status {
ExitStatus(stat) => stat,
ExitSignal(stat) => stat
ExitStatus(stat) => stat as i32,
ExitSignal(stat) => stat as i32
}
} else {
124

View file

@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "touch";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("a", "", "change only the access time"),
getopts::optflag("c", "no-create", "do not create any files"),

View file

@ -161,7 +161,7 @@ fn usage(opts: &[OptGroup]) {
print(getopts::usage("Translate or delete characters.", opts).as_slice());
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("c", "complement", "use the complement of SET1"),
getopts::optflag("C", "", "same as -c"),

View file

@ -9,6 +9,6 @@
* file that was distributed with this source code.
*/
pub fn uumain(_: Vec<String>) -> isize {
pub fn uumain(_: Vec<String>) -> i32 {
0
}

View file

@ -34,7 +34,7 @@ enum TruncateMode {
static NAME: &'static str = "truncate";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
@ -100,7 +100,7 @@ file based on its current size:
0
}
fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<String>, filenames: Vec<String>) -> Result<(), isize> {
fn truncate(no_create: bool, _: bool, reference: Option<String>, size: Option<String>, filenames: Vec<String>) -> Result<(), i32> {
let (refsize, mode) = match reference {
Some(rfilename) => {
let rfile = match File::open(&Path::new(rfilename.clone())) {

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "tsort";
static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"),

View file

@ -33,7 +33,7 @@ extern {
static NAME: &'static str = "tty";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let options = [
optflag("s", "silent", "print nothing, only return an exit status")
];
@ -74,7 +74,7 @@ pub fn uumain(args: Vec<String>) -> isize {
}
};
exit_code as isize
exit_code
}
fn usage () {

View file

@ -56,7 +56,7 @@ unsafe fn getuname() -> utsrust {
static NAME: &'static str = "uname";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -73,7 +73,7 @@ impl Options {
}
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let opts = [
getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"),
getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"),

View file

@ -119,7 +119,7 @@ fn opt_parsed<T: FromStr>(opt_name: &str, matches: &getopts::Matches) -> Option<
})
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program_path = Path::new(args[0].clone());
let program = program_path.filename_str().unwrap_or(NAME);

View file

@ -25,7 +25,7 @@ mod util;
static NAME: &'static str = "unlink";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -55,7 +55,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int {
0
}
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone();
let opts = [
getopts::optflag("v", "version", "output version information and exit"),

View file

@ -52,7 +52,7 @@ unsafe extern fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
static NAME: &'static str = "users";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "uutils"]
#![feature(core, os, path, rustc_private)]
#![feature(core, env, os, path, rustc_private)]
/*
* This file is part of the uutils coreutils package.
@ -14,19 +14,20 @@ extern crate getopts;
@CRATES@
use std::env;
use std::os;
use std::collections::hash_map::HashMap;
static NAME: &'static str = "uutils";
static VERSION: &'static str = "1.0.0";
fn util_map() -> HashMap<&'static str, fn(Vec<String>) -> isize> {
fn util_map() -> HashMap<&'static str, fn(Vec<String>) -> i32> {
let mut map = HashMap::new();
@UTIL_MAP@
map
}
fn usage(cmap: &HashMap<&'static str, fn(Vec<String>) -> isize>) {
fn usage(cmap: &HashMap<&'static str, fn(Vec<String>) -> i32>) {
println!("{} {}", NAME, VERSION);
println!("");
println!("Usage:");
@ -49,7 +50,7 @@ fn main() {
match umap.get(binary_as_util) {
Some(&uumain) => {
os::set_exit_status(uumain(args));
env::set_exit_status(uumain(args));
return
}
None => (),
@ -62,7 +63,7 @@ fn main() {
// what busybox uses the -suffix pattern for.
} else {
println!("{}: applet not found", binary_as_util);
os::set_exit_status(1);
env::set_exit_status(1);
return
}
@ -73,7 +74,7 @@ fn main() {
match umap.get(util) {
Some(&uumain) => {
os::set_exit_status(uumain(args.clone()));
env::set_exit_status(uumain(args.clone()));
return
}
None => {
@ -83,22 +84,22 @@ fn main() {
let util = args[1].as_slice();
match umap.get(util) {
Some(&uumain) => {
os::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()]));
env::set_exit_status(uumain(vec![util.to_string(), "--help".to_string()]));
return
}
None => {
println!("{}: applet not found", util);
os::set_exit_status(1);
env::set_exit_status(1);
return
}
}
}
usage(&umap);
os::set_exit_status(0);
env::set_exit_status(0);
return
} else {
println!("{}: applet not found", util);
os::set_exit_status(1);
env::set_exit_status(1);
return
}
}
@ -106,7 +107,7 @@ fn main() {
} else {
// no arguments provided
usage(&umap);
os::set_exit_status(0);
env::set_exit_status(0);
return
}
}

View file

@ -37,7 +37,7 @@ struct Result {
static NAME: &'static str = "wc";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0][];
let opts = [
getopts::optflag("c", "bytes", "print the byte counts"),
@ -97,7 +97,7 @@ fn is_word_seperator(byte: u8) -> bool {
byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF
}
pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), isize> {
pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> {
let mut total_line_count: usize = 0;
let mut total_word_count: usize = 0;
let mut total_char_count: usize = 0;
@ -217,7 +217,7 @@ fn print_stats(filename: &str, line_count: usize, word_count: usize, char_count:
}
}
fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, isize> {
fn open(path: &str) -> StdResult<BufferedReader<Box<Reader+'static>>, i32> {
if "-" == path {
let reader = Box::new(stdin_raw()) as Box<Reader>;
return Ok(BufferedReader::new(reader));

View file

@ -61,7 +61,7 @@ mod platform {
static NAME: &'static str = "whoami";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice();
let opts = [
getopts::optflag("h", "help", "display this help and exit"),

View file

@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "yes";
pub fn uumain(args: Vec<String>) -> isize {
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0];
let opts = [
getopts::optflag("h", "help", "display this help and exit"),