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

Merge pull request #525 from ebfe/fix-warnings

Fix (some) deprecation warnings
This commit is contained in:
Heather 2015-02-22 22:08:22 +03:00
commit 34161ba8c5
77 changed files with 301 additions and 302 deletions

View file

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

View file

@ -1,14 +1,14 @@
#![feature(core, io, os, path)] #![feature(core, env, old_io, old_path)]
use std::env;
use std::old_io::{File, Truncate, Write}; use std::old_io::{File, Truncate, Write};
use std::os;
use std::old_path::Path; use std::old_path::Path;
fn main() { fn main() {
let args = os::args(); let args : Vec<String> = env::args().collect();
if args.len() < 3 { if args.len() < 3 {
println!("usage: mkuutils <outfile> <crates>"); println!("usage: mkuutils <outfile> <crates>");
os::set_exit_status(1); env::set_exit_status(1);
return; return;
} }
@ -30,11 +30,11 @@ fn main() {
hashsum = true; hashsum = true;
} }
} }
"true" => util_map.push_str("fn uutrue(_: Vec<String>) -> isize { 0 }\nmap.insert(\"true\", uutrue);\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>) -> isize { 1 }\nmap.insert(\"false\", uufalse);\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()); 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

@ -1,5 +1,5 @@
#![crate_name = "base64"] #![crate_name = "base64"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -35,7 +35,7 @@ mod util;
static NAME: &'static str = "base64"; static NAME: &'static str = "base64";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
optflag("d", "decode", "decode data"), optflag("d", "decode", "decode data"),
optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"), optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"),

View file

@ -1,5 +1,5 @@
#![crate_name = "basename"] #![crate_name = "basename"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "basename"; static NAME: &'static str = "basename";
static VERSION: &'static str = "1.0.0"; 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()); let program = strip_dir(args[0].as_slice());
// //

View file

@ -1,5 +1,5 @@
#![crate_name = "cat"] #![crate_name = "cat"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
#![feature(box_syntax, unsafe_destructor)] #![feature(box_syntax, unsafe_destructor)]
@ -21,7 +21,7 @@ use std::old_io::stdio::{stdout_raw, stdin_raw, stderr};
use std::old_io::{IoResult}; use std::old_io::{IoResult};
use std::ptr::{copy_nonoverlapping_memory}; 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 program = &args[0];
let opts = [ let opts = [
getopts::optflag("A", "show-all", "equivalent to -vET"), getopts::optflag("A", "show-all", "equivalent to -vET"),
@ -49,7 +49,7 @@ pub fn uumain(args: Vec<String>) -> isize {
println!(" {0} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print(&getopts::usage("Concatenate FILE(s), or standard input, to \ print(&getopts::usage("Concatenate FILE(s), or standard input, to \
standard output.", &opts)[]); standard output.", &opts)[..]);
println!(""); println!("");
println!("With no FILE, or when FILE is -, read standard input."); println!("With no FILE, or when FILE is -, read standard input.");
return 0; return 0;
@ -95,7 +95,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
let mut line_counter: usize = 1; let mut line_counter: usize = 1;
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) {
let mut in_buf = [0; 1024 * 31]; let mut in_buf = [0; 1024 * 31];
let mut out_buf = [0; 1024 * 64]; let mut out_buf = [0; 1024 * 64];
@ -162,10 +162,10 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
let mut line_counter: usize = 1; let mut line_counter: usize = 1;
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) {
// Flush all 1024 iterations. // Flush all 1024 iterations.
let mut flush_counter = range(0us, 1024); let mut flush_counter = range(0usize, 1024);
let mut in_buf = [0; 1024 * 32]; let mut in_buf = [0; 1024 * 32];
let mut out_buf = [0; 1024 * 64]; let mut out_buf = [0; 1024 * 64];
@ -177,7 +177,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
for &byte in in_buf[..n].iter() { for &byte in in_buf[..n].iter() {
if flush_counter.next().is_none() { if flush_counter.next().is_none() {
writer.possibly_flush(); writer.possibly_flush();
flush_counter = range(0us, 1024); flush_counter = range(0usize, 1024);
} }
if byte == '\n' as u8 { if byte == '\n' as u8 {
if !at_line_start || !squeeze_blank { if !at_line_start || !squeeze_blank {
@ -234,7 +234,7 @@ fn write_fast(files: Vec<String>) {
let mut writer = stdout_raw(); let mut writer = stdout_raw();
let mut in_buf = [0; 1024 * 64]; let mut in_buf = [0; 1024 * 64];
for (mut reader, _) in files.iter().filter_map(|p| open(&p[])) { for (mut reader, _) in files.iter().filter_map(|p| open(&p[..])) {
while let Ok(n) = reader.read(&mut in_buf) { while let Ok(n) = reader.read(&mut in_buf) {
if n == 0 { break } if n == 0 { break }
// This interface is completely broken. // This interface is completely broken.

View file

@ -1,5 +1,5 @@
#![crate_name = "chmod"] #![crate_name = "chmod"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -33,7 +33,7 @@ mod util;
const NAME: &'static str = "chmod"; const NAME: &'static str = "chmod";
const VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -146,7 +146,7 @@ fn verify_mode(mode: &str) -> Result<(), String> {
Ok(()) 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(()); let mut r = Ok(());
for filename in files.iter() { for filename in files.iter() {
@ -182,8 +182,8 @@ fn chmod(files: Vec<String>, changes: bool, quiet: bool, verbose: bool, preserve
r 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()); let path = CString::new(name).unwrap();
match fmode { match fmode {
Some(mode) => { Some(mode) => {
if unsafe { libc::chmod(path.as_ptr(), mode) } == 0 { if unsafe { libc::chmod(path.as_ptr(), mode) } == 0 {

View file

@ -1,5 +1,5 @@
#![crate_name = "chroot"] #![crate_name = "chroot"]
#![feature(collections, core, io, os, path, rustc_private, std_misc)] #![feature(collections, core, old_io, os, old_path, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -16,7 +16,7 @@ extern crate libc;
use getopts::{optflag, optopt, getopts, usage}; use getopts::{optflag, optopt, getopts, usage};
use c_types::{get_pw_from_args, get_group}; use c_types::{get_pw_from_args, get_group};
use libc::funcs::posix88::unistd::{execvp, setuid, setgid}; use libc::funcs::posix88::unistd::{execvp, setuid, setgid};
use std::ffi::{c_str_to_bytes, CString}; use std::ffi::{CStr, CString};
use std::old_io::fs::PathExtensions; use std::old_io::fs::PathExtensions;
use std::iter::FromIterator; use std::iter::FromIterator;
@ -40,7 +40,7 @@ extern {
static NAME: &'static str = "chroot"; static NAME: &'static str = "chroot";
static VERSION: &'static str = "1.0.0"; 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 program = &args[0];
let options = [ let options = [
@ -95,10 +95,10 @@ pub fn uumain(args: Vec<String>) -> isize {
set_context(&newroot, &opts); set_context(&newroot, &opts);
unsafe { unsafe {
let executable = CString::from_slice(command[0].as_bytes()).as_bytes_with_nul().as_ptr(); let executable = CString::new(command[0]).unwrap().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(); let mut command_parts: Vec<*const u8> = command.iter().map(|x| CString::new(x.as_bytes()).unwrap().as_bytes_with_nul().as_ptr()).collect();
command_parts.push(std::ptr::null()); 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
} }
} }
@ -131,7 +131,7 @@ fn enter_chroot(root: &Path) {
let root_str = root.display(); let root_str = root.display();
std::os::change_dir(root).unwrap(); std::os::change_dir(root).unwrap();
let err = unsafe { let err = unsafe {
chroot(CString::from_slice(b".").as_bytes_with_nul().as_ptr() as *const libc::c_char) chroot(CString::new(b".").unwrap().as_bytes_with_nul().as_ptr() as *const libc::c_char)
}; };
if err != 0 { if err != 0 {
crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice()) crash!(1, "cannot chroot to {}: {}", root_str, strerror(err).as_slice())
@ -196,7 +196,7 @@ fn set_user(user: &str) {
fn strerror(errno: i32) -> String { fn strerror(errno: i32) -> String {
unsafe { unsafe {
let err = libc::funcs::c95::string::strerror(errno) as *const libc::c_char; let err = libc::funcs::c95::string::strerror(errno) as *const libc::c_char;
let bytes= c_str_to_bytes(&err); let bytes= CStr::from_ptr(err).to_bytes();
String::from_utf8_lossy(bytes).to_string() String::from_utf8_lossy(bytes).to_string()
} }
} }

View file

@ -1,5 +1,5 @@
#![crate_name = "cksum"] #![crate_name = "cksum"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -45,7 +45,7 @@ fn crc_final(mut crc: u32, mut length: usize) -> u32 {
#[inline] #[inline]
fn cksum(fname: &str) -> IoResult<(u32, usize)> { fn cksum(fname: &str) -> IoResult<(u32, usize)> {
let mut crc = 0u32; let mut crc = 0u32;
let mut size = 0us; let mut size = 0usize;
let mut stdin_buf; let mut stdin_buf;
let mut file_buf; let mut file_buf;
@ -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 = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "comm"] #![crate_name = "comm"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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 = [ let opts = [
getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"), getopts::optflag("1", "", "suppress column 1 (lines uniq to FILE1)"),
getopts::optflag("2", "", "suppress column 2 (lines uniq to FILE2)"), getopts::optflag("2", "", "suppress column 2 (lines uniq to FILE2)"),

View file

@ -15,7 +15,7 @@ use self::libc::int32_t;
use self::libc::funcs::posix88::unistd::getgroups; use self::libc::funcs::posix88::unistd::getgroups;
use std::ffi::{c_str_to_bytes, CString}; use std::ffi::{CStr, CString};
use std::iter::repeat; use std::iter::repeat;
use std::vec::Vec; use std::vec::Vec;
@ -133,7 +133,7 @@ pub fn get_pw_from_args(free: &Vec<String>) -> Option<c_passwd> {
// Passed the username as a string // Passed the username as a string
} else { } else {
let pw_pointer = unsafe { let pw_pointer = unsafe {
let cstr = CString::from_slice(username.as_bytes()); let cstr = CString::new(username).unwrap();
getpwnam(cstr.as_bytes_with_nul().as_ptr() as *const i8) getpwnam(cstr.as_bytes_with_nul().as_ptr() as *const i8)
}; };
if !pw_pointer.is_null() { if !pw_pointer.is_null() {
@ -152,7 +152,7 @@ pub fn get_group(groupname: &str) -> Option<c_group> {
unsafe { getgrgid(groupname.parse().unwrap()) } unsafe { getgrgid(groupname.parse().unwrap()) }
} else { } else {
unsafe { unsafe {
let cstr = CString::from_slice(groupname.as_bytes()); let cstr = CString::new(groupname).unwrap();
getgrnam(cstr.as_bytes_with_nul().as_ptr() as *const c_char) getgrnam(cstr.as_bytes_with_nul().as_ptr() as *const c_char)
} }
}; };
@ -231,7 +231,7 @@ pub fn group(possible_pw: Option<c_passwd>, nflag: bool) {
if !group.is_null() { if !group.is_null() {
let name = unsafe { let name = unsafe {
let gname = read(group).gr_name; let gname = read(group).gr_name;
let bytes= c_str_to_bytes(&gname); let bytes= CStr::from_ptr(gname).to_bytes();
String::from_utf8_lossy(bytes).to_string() String::from_utf8_lossy(bytes).to_string()
}; };
print!("{} ", name); print!("{} ", name);

View file

@ -14,10 +14,10 @@ pub fn from_str(string: &str) -> Result<f64, String> {
} }
let slice = &string[..len - 1]; let slice = &string[..len - 1];
let (numstr, times) = match string.char_at(len - 1) { let (numstr, times) = match string.char_at(len - 1) {
's' | 'S' => (slice, 1us), 's' | 'S' => (slice, 1usize),
'm' | 'M' => (slice, 60us), 'm' | 'M' => (slice, 60usize),
'h' | 'H' => (slice, 60us * 60), 'h' | 'H' => (slice, 60usize * 60),
'd' | 'D' => (slice, 60us * 60 * 24), 'd' | 'D' => (slice, 60usize * 60 * 24),
val => { val => {
if !val.is_alphabetic() { if !val.is_alphabetic() {
(string, 1) (string, 1)

View file

@ -1,5 +1,5 @@
#![crate_name = "cp"] #![crate_name = "cp"]
#![feature(collections, core, io, os, path, rustc_private)] #![feature(collections, core, old_io, os, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -32,7 +32,7 @@ pub enum Mode {
impl Copy for Mode {} impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
optflag("h", "help", "display this help and exit"), optflag("h", "help", "display this help and exit"),
optflag("", "version", "output version information and exit"), optflag("", "version", "output version information and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "cut"] #![crate_name = "cut"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -54,7 +54,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result<Vec<Range>, String> {
fn cut_bytes<R: Reader>(reader: R, fn cut_bytes<R: Reader>(reader: R,
ranges: &Vec<Range>, ranges: &Vec<Range>,
opts: &Options) -> isize { opts: &Options) -> i32 {
use buffer::Bytes::Select; use buffer::Bytes::Select;
use buffer::Bytes::Selected::{NewlineFound, Complete, Partial, EndOfFile}; 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, fn cut_characters<R: Reader>(reader: R,
ranges: &Vec<Range>, ranges: &Vec<Range>,
opts: &Options) -> isize { opts: &Options) -> i32 {
let mut buf_in = BufferedReader::new(reader); let mut buf_in = BufferedReader::new(reader);
let mut out = BufferedWriter::new(stdio::stdout_raw()); let mut out = BufferedWriter::new(stdio::stdout_raw());
@ -242,7 +242,7 @@ fn cut_fields_delimiter<R: Reader>(reader: R,
ranges: &Vec<Range>, ranges: &Vec<Range>,
delim: &String, delim: &String,
only_delimited: bool, only_delimited: bool,
out_delim: &String) -> isize { out_delim: &String) -> i32 {
let mut buf_in = BufferedReader::new(reader); let mut buf_in = BufferedReader::new(reader);
let mut out = BufferedWriter::new(stdio::stdout_raw()); 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, fn cut_fields<R: Reader>(reader: R,
ranges: &Vec<Range>, ranges: &Vec<Range>,
opts: &FieldOptions) -> isize { opts: &FieldOptions) -> i32 {
match opts.out_delimeter { match opts.out_delimeter {
Some(ref delim) => { Some(ref delim) => {
return cut_fields_delimiter(reader, ranges, &opts.delimiter, return cut_fields_delimiter(reader, ranges, &opts.delimiter,
@ -395,7 +395,7 @@ fn cut_fields<R: Reader>(reader: R,
0 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 stdin_read = false;
let mut exit_code = 0; let mut exit_code = 0;
@ -447,7 +447,7 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> isize {
exit_code exit_code
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
optopt("b", "bytes", "select only these bytes", "LIST"), optopt("b", "bytes", "select only these bytes", "LIST"),
optopt("c", "characters", "select only these characters", "LIST"), optopt("c", "characters", "select only these characters", "LIST"),

View file

@ -1,5 +1,5 @@
#![crate_name = "dirname"] #![crate_name = "dirname"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -16,7 +16,7 @@ use std::old_io::print;
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("z", "zero", "separate output with NUL rather than newline"), getopts::optflag("z", "zero", "separate output with NUL rather than newline"),

View file

@ -1,5 +1,5 @@
#![crate_name = "du"] #![crate_name = "du"]
#![feature(collections, core, io, path, rustc_private, std_misc, unicode)] #![feature(collections, core, old_io, old_path, rustc_private, std_misc, unicode)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -90,7 +90,7 @@ fn du(path: &Path, mut my_stat: Stat,
stats stats
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice(); let program = args[0].as_slice();
let opts = [ let opts = [
// In task // In task

View file

@ -1,5 +1,5 @@
#![crate_name = "echo"] #![crate_name = "echo"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -60,7 +60,7 @@ fn convert_str(string: &[u8], index: usize, base: u32) -> (char, usize) {
}; };
let mut bytes = vec!(); let mut bytes = vec!();
for offset in range(0us, max_digits) { for offset in range(0usize, max_digits) {
if string.len() <= index + offset as usize { if string.len() <= index + offset as usize {
break; break;
} }
@ -163,7 +163,7 @@ fn print_version() {
println!("echo version: {}", VERSION); println!("echo version: {}", VERSION);
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let mut options = EchoOptions { let mut options = EchoOptions {
newline: false, newline: false,
escape: false escape: false

6
src/env/env.rs vendored
View file

@ -1,5 +1,5 @@
#![crate_name = "env"] #![crate_name = "env"]
#![feature(core, io, os)] #![feature(core, old_io, os)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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(); let prog = args[0].as_slice();
// to handle arguments the same way than GNU env, we can't use getopts // 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() { match Command::new(prog).args(args).stdin(InheritFd(0)).stdout(InheritFd(1)).stderr(InheritFd(2)).status() {
Ok(exit) => Ok(exit) =>
return match exit { return match exit {
std::old_io::process::ExitStatus(s) => s, std::old_io::process::ExitStatus(s) => s as i32,
_ => 1 _ => 1
}, },
Err(_) => return 1 Err(_) => return 1

View file

@ -1,5 +1,5 @@
#![crate_name = "expand"] #![crate_name = "expand"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -75,7 +75,7 @@ impl Options {
} }
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optflag("i", "initial", "do not convert tabs after non blanks"), getopts::optflag("i", "initial", "do not convert tabs after non blanks"),
getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"), getopts::optopt("t", "tabs", "have tabs NUMBER characters apart, not 8", "NUMBER"),

View file

@ -1,5 +1,5 @@
#![crate_name = "factor"] #![crate_name = "factor"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -64,7 +64,7 @@ fn print_factors_str(num_str: &str) {
print_factors(num); print_factors(num);
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].as_slice(); let program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "show this help message"), getopts::optflag("h", "help", "show this help message"),

View file

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

View file

@ -59,7 +59,7 @@ struct FmtOptions {
tabwidth : usize, tabwidth : usize,
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ 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."), 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

@ -1,5 +1,5 @@
#![crate_name = "fold"] #![crate_name = "fold"]
#![feature(collections, core, io, path, rustc_private, unicode)] #![feature(collections, core, old_io, old_path, rustc_private, unicode)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "fold"; static NAME: &'static str = "fold";
static VERSION: &'static str = "1.0.0"; 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 (args, obs_width) = handle_obsolete(args.as_slice());
let program = args[0].clone(); let program = args[0].clone();
@ -157,7 +157,7 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
match rfind_whitespace(slice) { match rfind_whitespace(slice) {
Some(m) => { Some(m) => {
let routput = slice.slice_chars(m + 1, slice.chars().count()); let routput = slice.slice_chars(m + 1, slice.chars().count());
let ncount = routput.chars().fold(0us, |out, ch: char| { let ncount = routput.chars().fold(0usize, |out, ch: char| {
out + match ch { out + match ch {
'\t' => 8, '\t' => 8,
'\x08' => if out > 0 { -1 } else { 0 }, '\x08' => if out > 0 { -1 } else { 0 },

View file

@ -25,7 +25,7 @@ use c_types::{get_pw_from_args, group};
static NAME: &'static str = "groups"; static NAME: &'static str = "groups";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let options = [ let options = [

View file

@ -1,5 +1,5 @@
#![crate_name = "hashsum"] #![crate_name = "hashsum"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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 program = args[0].clone();
let binary = Path::new(program.as_slice()); let binary = Path::new(program.as_slice());
let binary_name = binary.filename_str().unwrap(); 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)); 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 bad_format = 0;
let mut failed = 0; let mut failed = 0;
let binary_marker = if binary { let binary_marker = if binary {

View file

@ -1,5 +1,5 @@
#![crate_name = "head"] #![crate_name = "head"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -28,9 +28,9 @@ mod util;
static NAME: &'static str = "head"; 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 line_count = 10usize;
let mut byte_count = 0us; let mut byte_count = 0usize;
// handle obsolete -number syntax // handle obsolete -number syntax
let options = match obsolete(args.tail()) { let options = match obsolete(args.tail()) {

View file

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

View file

@ -1,5 +1,5 @@
#![crate_name = "hostname"] #![crate_name = "hostname"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -43,7 +43,7 @@ extern {
fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int; 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 program = &args[0];
let options = [ let options = [
@ -132,7 +132,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) {
} }
fn xgethostname() -> String { fn xgethostname() -> String {
let namelen = 256us; let namelen = 256usize;
let mut name : Vec<u8> = repeat(0).take(namelen).collect(); let mut name : Vec<u8> = repeat(0).take(namelen).collect();
let err = unsafe { let err = unsafe {
gethostname (name.as_mut_ptr() as *mut libc::c_char, gethostname (name.as_mut_ptr() as *mut libc::c_char,

View file

@ -18,7 +18,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::c_str_to_bytes; use std::ffi::CStr;
use std::ptr::read; use std::ptr::read;
use libc::{ use libc::{
uid_t, uid_t,
@ -85,7 +85,7 @@ extern {
static NAME: &'static str = "id"; 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 args_t = args.tail();
let options = [ let options = [
@ -139,7 +139,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let gr = unsafe { getgrgid(id) }; let gr = unsafe { getgrgid(id) };
if nflag && !gr.is_null() { if nflag && !gr.is_null() {
let gr_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }; let gr_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() };
println!("{}", gr_name); println!("{}", gr_name);
} else { } else {
println!("{}", id); println!("{}", id);
@ -159,7 +159,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let pw = unsafe { getpwuid(id) }; let pw = unsafe { getpwuid(id) };
if nflag && !pw.is_null() { if nflag && !pw.is_null() {
let pw_name = unsafe { let pw_name = unsafe {
String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string()
}; };
println!("{}", pw_name); println!("{}", pw_name);
} else { } else {
@ -197,16 +197,16 @@ fn pretty(possible_pw: Option<c_passwd>) {
if possible_pw.is_some() { if possible_pw.is_some() {
let pw = possible_pw.unwrap(); let pw = possible_pw.unwrap();
let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name)).to_string() }; let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name).to_bytes()).to_string() };
print!("uid\t{}\ngroups\t", pw_name); print!("uid\t{}\ngroups\t", pw_name);
group(possible_pw, true); group(possible_pw, true);
} else { } else {
let login = unsafe { String::from_utf8_lossy(c_str_to_bytes(&(getlogin() as *const i8))).to_string() }; let login = unsafe { String::from_utf8_lossy(CStr::from_ptr((getlogin() as *const i8)).to_bytes()).to_string() };
let rid = unsafe { getuid() }; let rid = unsafe { getuid() };
let pw = unsafe { getpwuid(rid) }; let pw = unsafe { getpwuid(rid) };
let is_same_user = unsafe { let is_same_user = unsafe {
String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() == login String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() == login
}; };
if pw.is_null() || is_same_user { if pw.is_null() || is_same_user {
@ -216,7 +216,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
if !pw.is_null() { if !pw.is_null() {
println!( println!(
"uid\t{}", "uid\t{}",
unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }) unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() })
} else { } else {
println!("uid\t{}\n", rid); println!("uid\t{}\n", rid);
} }
@ -227,7 +227,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
if !pw.is_null() { if !pw.is_null() {
println!( println!(
"euid\t{}", "euid\t{}",
unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }); unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() });
} else { } else {
println!("euid\t{}", eid); println!("euid\t{}", eid);
} }
@ -240,7 +240,7 @@ fn pretty(possible_pw: Option<c_passwd>) {
if !gr.is_null() { if !gr.is_null() {
println!( println!(
"rgid\t{}", "rgid\t{}",
unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }); unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() });
} else { } else {
println!("rgid\t{}", rid); println!("rgid\t{}", rid);
} }
@ -259,12 +259,12 @@ fn pline(possible_pw: Option<c_passwd>) {
possible_pw.unwrap() possible_pw.unwrap()
}; };
let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name )).to_string()}; let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name ).to_bytes()).to_string()};
let pw_passwd = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_passwd)).to_string()}; let pw_passwd = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_passwd).to_bytes()).to_string()};
let pw_class = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_class )).to_string()}; let pw_class = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_class ).to_bytes()).to_string()};
let pw_gecos = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_gecos )).to_string()}; let pw_gecos = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_gecos ).to_bytes()).to_string()};
let pw_dir = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_dir )).to_string()}; let pw_dir = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_dir ).to_bytes()).to_string()};
let pw_shell = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_shell )).to_string()}; let pw_shell = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_shell ).to_bytes()).to_string()};
println!( println!(
"{}:{}:{}:{}:{}:{}:{}:{}:{}:{}", "{}:{}:{}:{}:{}:{}:{}:{}:{}:{}",
@ -288,11 +288,11 @@ fn pline(possible_pw: Option<c_passwd>) {
possible_pw.unwrap() possible_pw.unwrap()
}; };
let pw_name = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_name )).to_string()}; let pw_name = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_name ).to_bytes()).to_string()};
let pw_passwd = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_passwd)).to_string()}; let pw_passwd = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_passwd).to_bytes()).to_string()};
let pw_gecos = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_gecos )).to_string()}; let pw_gecos = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_gecos ).to_bytes()).to_string()};
let pw_dir = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_dir )).to_string()}; let pw_dir = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_dir ).to_bytes()).to_string()};
let pw_shell = unsafe { String::from_utf8_lossy(c_str_to_bytes(&pw.pw_shell )).to_string()}; let pw_shell = unsafe { String::from_utf8_lossy(CStr::from_ptr(pw.pw_shell ).to_bytes()).to_string()};
println!( println!(
"{}:{}:{}:{}:{}:{}:{}", "{}:{}:{}:{}:{}:{}:{}",
@ -352,7 +352,7 @@ fn id_print(possible_pw: Option<c_passwd>,
print!( print!(
"uid={}({})", "uid={}({})",
uid, uid,
unsafe { String::from_utf8_lossy(c_str_to_bytes(&possible_pw.unwrap().pw_name)).to_string() }); unsafe { String::from_utf8_lossy(CStr::from_ptr(possible_pw.unwrap().pw_name).to_bytes()).to_string() });
} else { } else {
print!("uid={}", unsafe { getuid() }); print!("uid={}", unsafe { getuid() });
} }
@ -362,7 +362,7 @@ fn id_print(possible_pw: Option<c_passwd>,
if !gr.is_null() { if !gr.is_null() {
print!( print!(
"({})", "({})",
unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(gr).gr_name)).to_string() }); unsafe { String::from_utf8_lossy(CStr::from_ptr(read(gr).gr_name).to_bytes()).to_string() });
} }
let euid = unsafe { geteuid() }; let euid = unsafe { geteuid() };
@ -372,7 +372,7 @@ fn id_print(possible_pw: Option<c_passwd>,
if !pw.is_null() { if !pw.is_null() {
print!( print!(
"({})", "({})",
unsafe { String::from_utf8_lossy(c_str_to_bytes(&read(pw).pw_name)).to_string() }); unsafe { String::from_utf8_lossy(CStr::from_ptr(read(pw).pw_name).to_bytes()).to_string() });
} }
} }
@ -382,7 +382,7 @@ fn id_print(possible_pw: Option<c_passwd>,
unsafe { unsafe {
let grp = getgrgid(egid); let grp = getgrgid(egid);
if !grp.is_null() { if !grp.is_null() {
print!("({})", String::from_utf8_lossy(c_str_to_bytes(&read(grp).gr_name)).to_string()); print!("({})", String::from_utf8_lossy(CStr::from_ptr(read(grp).gr_name).to_bytes()).to_string());
} }
} }
} }
@ -397,7 +397,7 @@ fn id_print(possible_pw: Option<c_passwd>,
let group = unsafe { getgrgid(gr) }; let group = unsafe { getgrgid(gr) };
if !group.is_null() { if !group.is_null() {
let name = unsafe { let name = unsafe {
String::from_utf8_lossy(c_str_to_bytes(&read(group).gr_name)).to_string() String::from_utf8_lossy(CStr::from_ptr(read(group).gr_name).to_bytes()).to_string()
}; };
print!("({})", name); print!("({})", name);
} }

View file

@ -1,5 +1,5 @@
#![crate_name = "kill"] #![crate_name = "kill"]
#![feature(collections, core, io, rustc_private, unicode)] #![feature(collections, core, old_io, rustc_private, unicode)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -40,8 +40,8 @@ mod signals;
static NAME: &'static str = "kill"; static NAME: &'static str = "kill";
static VERSION: &'static str = "0.0.1"; static VERSION: &'static str = "0.0.1";
static EXIT_OK: isize = 0; static EXIT_OK: i32 = 0;
static EXIT_ERR: isize = 1; static EXIT_ERR: i32 = 1;
pub enum Mode { pub enum Mode {
Kill, Kill,
@ -53,7 +53,7 @@ pub enum Mode {
impl Copy for Mode {} impl Copy for Mode {}
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
optflag("h", "help", "display this help and exit"), optflag("h", "help", "display this help and exit"),
optflag("V", "version", "output version information 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)); 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 mut status = 0;
let optional_signal_value = signals::signal_by_name_or_value(signalname); let optional_signal_value = signals::signal_by_name_or_value(signalname);
let signal_value = match optional_signal_value { let signal_value = match optional_signal_value {

View file

@ -1,5 +1,5 @@
#![crate_name = "link"] #![crate_name = "link"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -22,7 +22,7 @@ mod util;
static NAME : &'static str = "link"; static NAME : &'static str = "link";
static VERSION : &'static str = "1.0.0"; static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "logname"] #![crate_name = "logname"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -17,7 +17,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::c_str_to_bytes; use std::ffi::CStr;
use std::old_io::print; use std::old_io::print;
use libc::c_char; use libc::c_char;
@ -34,7 +34,7 @@ fn get_userlogin() -> Option<String> {
if login.is_null() { if login.is_null() {
None None
} else { } else {
Some(String::from_utf8_lossy(c_str_to_bytes(&login)).to_string()) Some(String::from_utf8_lossy(CStr::from_ptr(login).to_bytes()).to_string())
} }
} }
} }
@ -46,7 +46,7 @@ fn version() {
println!("{} {}", NAME, VERSION); println!("{} {}", NAME, VERSION);
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone(); let program = args[0].clone();
// //

View file

@ -1,5 +1,5 @@
#![crate_name = "mkdir"] #![crate_name = "mkdir"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -27,7 +27,7 @@ static VERSION: &'static str = "1.0.0";
/** /**
* Handles option parsing * Handles option parsing
*/ */
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
// Linux-specific options, not implemented // Linux-specific options, not implemented
@ -94,7 +94,7 @@ fn print_help(opts: &[getopts::OptGroup]) {
/** /**
* Create the list of new directories * 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 result = Ok(());
let mut parent_dirs = Vec::new(); let mut parent_dirs = Vec::new();

View file

@ -1,5 +1,5 @@
#![crate_name = "mkfifo"] #![crate_name = "mkfifo"]
#![feature(collections, core, rustc_private, std_misc)] #![feature(collections, core, os, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -25,7 +25,7 @@ mod util;
static NAME : &'static str = "mkfifo"; static NAME : &'static str = "mkfifo";
static VERSION : &'static str = "1.0.0"; static VERSION : &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"), getopts::optopt("m", "mode", "file permissions for the fifo", "(default 0666)"),
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
@ -68,7 +68,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let mut exit_status = 0; let mut exit_status = 0;
for f in matches.free.iter() { for f in matches.free.iter() {
let err = unsafe { mkfifo(CString::from_slice(f.as_bytes()).as_ptr(), mode) }; let err = unsafe { mkfifo(CString::new(f.as_bytes()).unwrap().as_ptr(), mode) };
if err == -1 { if err == -1 {
show_error!("creating '{}': {}", f, os::error_string(os::errno())); show_error!("creating '{}': {}", f, os::error_string(os::errno()));
exit_status = 1; exit_status = 1;

View file

@ -1,5 +1,5 @@
#![crate_name = "mv"] #![crate_name = "mv"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -62,7 +62,7 @@ pub enum BackupMode {
impl Copy for 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 program = args[0].as_slice();
let opts = [ let opts = [
optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"), optflagopt("", "backup", "make a backup of each existing destination file", "CONTROL"),
@ -187,7 +187,7 @@ fn help(progname: &str, usage: &str) {
println!("{}", msg); println!("{}", msg);
} }
fn exec(files: &[Path], b: Behaviour) -> isize { fn exec(files: &[Path], b: Behaviour) -> i32 {
match b.target_dir { match b.target_dir {
Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b), Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b),
None => {} None => {}
@ -245,7 +245,7 @@ fn exec(files: &[Path], b: Behaviour) -> isize {
0 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() { if !target_dir.is_dir() {
show_error!("target {} is not a directory", target_dir.display()); show_error!("target {} is not a directory", target_dir.display());
return 1; return 1;

View file

@ -1,5 +1,5 @@
#![crate_name = "nice"] #![crate_name = "nice"]
#![feature(collections, core, os, rustc_private, std_misc)] #![feature(collections, core, old_io, os, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -33,7 +33,7 @@ extern {
fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; 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 = [ let opts = [
getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"), getopts::optopt("n", "adjustment", "add N to the niceness (default is 10)", "N"),
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
@ -102,7 +102,7 @@ pub fn uumain(args: Vec<String>) -> isize {
show_warning!("{}", IoError::last_error()); show_warning!("{}", IoError::last_error());
} }
let cstrs : Vec<CString> = matches.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect(); let cstrs : Vec<CString> = matches.free.iter().map(|x| CString::new(x.as_bytes()).unwrap()).collect();
let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect();
args.push(0 as *const c_char); args.push(0 as *const c_char);
unsafe { execvp(args[0], args.as_mut_ptr()); } unsafe { execvp(args[0], args.as_mut_ptr()); }

View file

@ -1,5 +1,5 @@
#![crate_name = "nl"] #![crate_name = "nl"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
#![plugin(regex_macros)] #![plugin(regex_macros)]
/* /*
@ -77,7 +77,7 @@ enum NumberFormat {
RightZero, RightZero,
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let possible_options = [ let possible_options = [
optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"), optopt("b", "body-numbering", "use STYLE for numbering body lines", "STYLE"),
optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"), optopt("d", "section-delimiter", "use CC for separating logical pages", "CC"),

View file

@ -1,5 +1,5 @@
#![crate_name = "nohup"] #![crate_name = "nohup"]
#![feature(collections, core, io, os, path, rustc_private, std_misc)] #![feature(collections, core, old_io, os, old_path, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -38,7 +38,7 @@ extern {
#[cfg(any(target_os = "linux", target_os = "freebsd"))] #[cfg(any(target_os = "linux", target_os = "freebsd"))]
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int { std::ptr::null() } 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 program = &args[0];
let options = [ let options = [
@ -69,10 +69,10 @@ pub fn uumain(args: Vec<String>) -> isize {
if unsafe { _vprocmgr_detach_from_console(0) } != std::ptr::null() { crash!(2, "Cannot detach from console")}; if unsafe { _vprocmgr_detach_from_console(0) } != std::ptr::null() { crash!(2, "Cannot detach from console")};
let cstrs : Vec<CString> = opts.free.iter().map(|x| CString::from_slice(x.as_bytes())).collect(); let cstrs : Vec<CString> = opts.free.iter().map(|x| CString::new(x.as_bytes()).unwrap()).collect();
let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect(); let mut args : Vec<*const c_char> = cstrs.iter().map(|s| s.as_ptr()).collect();
args.push(std::ptr::null()); 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() { fn replace_fds() {

View file

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

View file

@ -1,5 +1,5 @@
#![crate_name = "od"] #![crate_name = "od"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -19,7 +19,7 @@ use std::old_io::File;
#[derive(Debug)] #[derive(Debug)]
enum Radix { Decimal, Hexadecimal, Octal, Binary } enum Radix { Decimal, Hexadecimal, Octal, Binary }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optopt("A", "address-radix", getopts::optopt("A", "address-radix",
"Select the base in which file offsets are printed.", "RADIX"), "Select the base in which file offsets are printed.", "RADIX"),

View file

@ -1,5 +1,5 @@
#![crate_name = "paste"] #![crate_name = "paste"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "paste"; static NAME: &'static str = "paste";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -1,5 +1,5 @@
#![crate_name = "printenv"] #![crate_name = "printenv"]
#![feature(collections, core, io, os, rustc_private)] #![feature(collections, core, old_io, os, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "printenv"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"), getopts::optflag("0", "null", "end each output line with 0 byte rather than newline"),

View file

@ -1,5 +1,5 @@
#![crate_name = "pwd"] #![crate_name = "pwd"]
#![feature(collections, core, io, os, rustc_private)] #![feature(collections, core, old_io, os, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "pwd"; static NAME: &'static str = "pwd";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("", "help", "display this help and exit"), getopts::optflag("", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "readlink"] #![crate_name = "readlink"]
#![feature(collections, core, io, os, path, rustc_private)] #![feature(collections, core, old_io, os, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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 program = args[0].as_slice();
let opts = [ let opts = [
optflag("f", "canonicalize", optflag("f", "canonicalize",

View file

@ -1,5 +1,5 @@
#![crate_name= "realpath"] #![crate_name= "realpath"]
#![feature(collections, core, io, os, path, rustc_private)] #![feature(collections, core, old_io, os, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -20,7 +20,7 @@ use getopts::{optflag, getopts, usage};
static NAME: &'static str = "realpath"; static NAME: &'static str = "realpath";
static VERSION: &'static str = "1.0.0"; 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 program = &args[0];
let options = [ let options = [
optflag("h", "help", "Show help and exit"), optflag("h", "help", "Show help and exit"),
@ -78,7 +78,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool {
Some(x) => x, Some(x) => x,
}; };
let mut links_left = 256is; let mut links_left = 256isize;
for part in abs.components() { for part in abs.components() {
result.push(part); result.push(part);

View file

@ -1,5 +1,5 @@
#![crate_name = "relpath"] #![crate_name = "relpath"]
#![feature(collections, core, os, path, rustc_private)] #![feature(collections, core, os, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -20,7 +20,7 @@ use getopts::{optflag, optopt, getopts, usage};
static NAME: &'static str = "relpath"; static NAME: &'static str = "relpath";
static VERSION: &'static str = "1.0.0"; 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 program = &args[0];
let options = [ let options = [
optflag("h", "help", "Show help and exit"), optflag("h", "help", "Show help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "rm"] #![crate_name = "rm"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -31,7 +31,7 @@ impl Copy for InteractiveMode {}
static NAME: &'static str = "rm"; static NAME: &'static str = "rm";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone(); let program = args[0].clone();
// TODO: make getopts support -R in addition to -r // 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 // 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(()); let mut r = Ok(());
for filename in files.iter() { for filename in files.iter() {
@ -168,7 +168,7 @@ fn remove(files: Vec<String>, force: bool, interactive: InteractiveMode, one_fs:
r 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 = let response =
if interactive == InteractiveMode::InteractiveAlways { if interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, name) prompt_file(path, name)
@ -188,7 +188,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo
Ok(()) 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 = let response =
if interactive == InteractiveMode::InteractiveAlways { if interactive == InteractiveMode::InteractiveAlways {
prompt_file(path, name) prompt_file(path, name)

View file

@ -1,5 +1,5 @@
#![crate_name = "rmdir"] #![crate_name = "rmdir"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "rmdir"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -66,7 +66,7 @@ pub fn uumain(args: Vec<String>) -> isize {
0 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(()); let mut r = Ok(());
for dir in dirs.iter() { for dir in dirs.iter() {
@ -87,7 +87,7 @@ fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Resu
r 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) { let mut walk_dir = match fs::walk_dir(path) {
Ok(m) => m, Ok(m) => m,
Err(f) => { Err(f) => {

View file

@ -37,7 +37,7 @@ fn escape_sequences(s: &str) -> String {
replace("\\t", "\t") 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 mut seq_args = vec!();
let program = args[0].clone(); let program = args[0].clone();
let mut iter = args.into_iter().skip(1); let mut iter = args.into_iter().skip(1);
@ -146,7 +146,7 @@ fn print_version() {
println!("seq 1.0.0\n"); 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 program = args[0].clone();
let mut options = SeqOptions { let mut options = SeqOptions {
separator: "\n".to_string(), separator: "\n".to_string(),
@ -217,7 +217,7 @@ fn done_printing(next: f64, step: f64, last: f64) -> bool {
} }
fn print_seq(first: f64, step: f64, last: f64, largest_dec: usize, separator: String, terminator: String, pad: bool, padding: usize) { fn print_seq(first: f64, step: f64, last: f64, largest_dec: usize, separator: String, terminator: String, pad: bool, padding: usize) {
let mut i = 0is; let mut i = 0isize;
let mut value = first + i as f64 * step; let mut value = first + i as f64 * step;
while !done_printing(value, step, last) { while !done_printing(value, step, last) {
let istr = value.to_string(); let istr = value.to_string();

View file

@ -1,5 +1,5 @@
#![crate_name = "shuf"] #![crate_name = "shuf"]
#![feature(collections, core, io, path, rand, rustc_private)] #![feature(collections, core, old_io, old_path, rand, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -33,7 +33,7 @@ enum Mode {
static NAME: &'static str = "shuf"; static NAME: &'static str = "shuf";
static VERSION: &'static str = "0.0.1"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -186,7 +186,7 @@ fn shuf_lines(mut lines: Vec<String>, repeat: bool, zero: bool, count: usize, ou
Ok(()) 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(); let split: Vec<&str> = input_range.as_slice().split('-').collect();
if split.len() != 2 { if split.len() != 2 {
Err(("invalid range format".to_string(), 1)) Err(("invalid range format".to_string(), 1))

View file

@ -1,5 +1,5 @@
#![crate_name = "sleep"] #![crate_name = "sleep"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -26,7 +26,7 @@ mod time;
static NAME: &'static str = "sleep"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -1,5 +1,5 @@
#![crate_name = "sort"] #![crate_name = "sort"]
#![feature(collections, core, io, path, rustc_private, unicode)] #![feature(collections, core, old_io, old_path, rustc_private, unicode)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -29,7 +29,7 @@ static VERSION: &'static str = "0.0.1";
static DECIMAL_PT: char = '.'; static DECIMAL_PT: char = '.';
static THOUSANDS_SEP: 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("n", "numeric-sort", "compare according to string numerical value"), getopts::optflag("n", "numeric-sort", "compare according to string numerical value"),

View file

@ -1,5 +1,5 @@
#![crate_name = "split"] #![crate_name = "split"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "split"; static NAME: &'static str = "split";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"), getopts::optopt("a", "suffix-length", "use suffixes of length N (default 2)", "N"),
getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"), getopts::optopt("b", "bytes", "put SIZE bytes per output file", "SIZE"),
@ -170,10 +170,10 @@ impl ByteSplitter {
let mut strategy_param : Vec<char> = settings.strategy_param.chars().collect(); let mut strategy_param : Vec<char> = settings.strategy_param.chars().collect();
let suffix = strategy_param.pop().unwrap(); let suffix = strategy_param.pop().unwrap();
let multiplier = match suffix { let multiplier = match suffix {
'0'...'9' => 1us, '0'...'9' => 1usize,
'b' => 512us, 'b' => 512usize,
'k' => 1024us, 'k' => 1024usize,
'm' => 1024us * 1024us, 'm' => 1024usize * 1024usize,
_ => crash!(1, "invalid number of bytes") _ => crash!(1, "invalid number of bytes")
}; };
let n = if suffix.is_alphabetic() { let n = if suffix.is_alphabetic() {
@ -248,7 +248,7 @@ fn num_prefix(i: usize, width: usize) -> String {
c c
} }
fn split(settings: &Settings) -> isize { fn split(settings: &Settings) -> i32 {
let mut reader = io::BufferedReader::new( let mut reader = io::BufferedReader::new(
if settings.input.as_slice() == "-" { if settings.input.as_slice() == "-" {
Box::new(io::stdio::stdin_raw()) as Box<Reader> Box::new(io::stdio::stdin_raw()) as Box<Reader>

View file

@ -1,6 +1,6 @@
#![crate_name = "libstdbuf"] #![crate_name = "libstdbuf"]
#![crate_type = "staticlib"] #![crate_type = "staticlib"]
#![feature(core, os)] #![feature(core, libc, os)]
extern crate libc; extern crate libc;
use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf}; use libc::{c_int, size_t, c_char, FILE, _IOFBF, _IONBF, _IOLBF, setvbuf};

View file

@ -1,5 +1,5 @@
#![crate_name = "stdbuf"] #![crate_name = "stdbuf"]
#![feature(core, io, os, path, rustc_private, unicode)] #![feature(core, old_io, os, old_path, rustc_private, unicode)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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 = [ let optgrps = [
optopt("i", "input", "adjust standard input stream buffering", "MODE"), optopt("i", "input", "adjust standard input stream buffering", "MODE"),
optopt("o", "output", "adjust standard output 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() { match process.wait() {
Ok(status) => { Ok(status) => {
match 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), ProcessExit::ExitSignal(i) => crash!(1, "process killed by signal {}", i),
} }
}, },

View file

@ -1,5 +1,5 @@
#![crate_name = "sum"] #![crate_name = "sum"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("r", "", "use the BSD compatible algorithm (default)"), getopts::optflag("r", "", "use the BSD compatible algorithm (default)"),

View file

@ -140,8 +140,8 @@ mod platform {
} }
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0][]; let program = &args[0][..];
let options = [ let options = [
optflag("h", "help", "display this help and exit"), optflag("h", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "tac"] #![crate_name = "tac"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -22,7 +22,7 @@ mod util;
static NAME: &'static str = "tac"; static NAME: &'static str = "tac";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [

View file

@ -1,5 +1,5 @@
#![crate_name = "tail"] #![crate_name = "tail"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -31,11 +31,11 @@ mod util;
static NAME: &'static str = "tail"; static NAME: &'static str = "tail";
static VERSION: &'static str = "0.0.1"; 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 beginning = false;
let mut lines = true; let mut lines = true;
let mut byte_count = 0us; let mut byte_count = 0usize;
let mut line_count = 10us; let mut line_count = 10usize;
let mut sleep_msec = 1000u64; let mut sleep_msec = 1000u64;
// handle obsolete -number syntax // handle obsolete -number syntax
@ -153,29 +153,29 @@ fn parse_size(mut size_slice: &str) -> Option<usize> {
let mut base = let mut base =
if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' { if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' {
size_slice = &size_slice[..size_slice.len() - 1]; size_slice = &size_slice[..size_slice.len() - 1];
1000us 1000usize
} else { } else {
1024us 1024usize
}; };
let exponent = let exponent =
if size_slice.len() > 0 { if size_slice.len() > 0 {
let mut has_suffix = true; let mut has_suffix = true;
let exp = match size_slice.char_at(size_slice.len() - 1) { let exp = match size_slice.char_at(size_slice.len() - 1) {
'K' => 1us, 'K' => 1usize,
'M' => 2us, 'M' => 2usize,
'G' => 3us, 'G' => 3usize,
'T' => 4us, 'T' => 4usize,
'P' => 5us, 'P' => 5usize,
'E' => 6us, 'E' => 6usize,
'Z' => 7us, 'Z' => 7usize,
'Y' => 8us, 'Y' => 8usize,
'b' => { 'b' => {
base = 512us; base = 512usize;
1us 1usize
} }
_ => { _ => {
has_suffix = false; has_suffix = false;
0us 0usize
} }
}; };
if has_suffix { if has_suffix {
@ -183,14 +183,14 @@ fn parse_size(mut size_slice: &str) -> Option<usize> {
} }
exp exp
} else { } else {
0us 0usize
}; };
let mut multiplier = 1us; let mut multiplier = 1usize;
for _ in range(0us, exponent) { for _ in range(0usize, exponent) {
multiplier *= base; multiplier *= base;
} }
if base == 1000us && exponent == 0us { if base == 1000usize && exponent == 0usize {
// sole B is not a valid suffix // sole B is not a valid suffix
None None
} else { } else {

View file

@ -1,5 +1,5 @@
#![crate_name = "tee"] #![crate_name = "tee"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -16,13 +16,12 @@ extern crate getopts;
use std::old_io::{println, stdin, stdout, Append, File, Truncate, Write}; use std::old_io::{println, stdin, stdout, Append, File, Truncate, Write};
use std::old_io::{IoResult}; use std::old_io::{IoResult};
use std::old_io::util::{copy, NullWriter, MultiWriter}; use std::old_io::util::{copy, NullWriter, MultiWriter};
use std::os;
use getopts::{getopts, optflag, usage}; use getopts::{getopts, optflag, usage};
static NAME: &'static str = "tee"; static NAME: &'static str = "tee";
static VERSION: &'static str = "1.0.0"; 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) { match options(args.as_slice()).and_then(exec) {
Ok(_) => 0, Ok(_) => 0,
Err(_) => 1 Err(_) => 1
@ -150,5 +149,5 @@ fn with_path<F, T>(path: &Path, mut cb: F) -> IoResult<T> where F: FnMut() -> Io
} }
fn warn(message: &str) { fn warn(message: &str) {
error!("{}: {}", os::args()[0], message); error!("tee: {}", message);
} }

View file

@ -20,7 +20,7 @@ use std::str::{from_utf8};
static NAME: &'static str = "test"; static NAME: &'static str = "test";
// TODO: decide how to handle non-UTF8 input for all the utils // 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 = args_as_bytes();
let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect();
if args.len() == 0 { if args.len() == 0 {
@ -40,7 +40,7 @@ pub fn uumain(_: Vec<String>) -> isize {
_ => &args[1..args.len()], _ => &args[1..args.len()],
}; };
let mut error = false; 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 { if error {
2 2
} else { } else {
@ -348,7 +348,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool {
} }
}; };
let path = CString::from_slice(path); let path = CString::new(path).unwrap();
let mut stat = unsafe { std::mem::zeroed() }; let mut stat = unsafe { std::mem::zeroed() };
if cond == PathCondition::SymLink { if cond == PathCondition::SymLink {
if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 { if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 {

View file

@ -1,5 +1,5 @@
#![crate_name = "timeout"] #![crate_name = "timeout"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, io, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -33,9 +33,9 @@ extern {
static NAME: &'static str = "timeout"; static NAME: &'static str = "timeout";
static VERSION: &'static str = "1.0.0"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -101,7 +101,7 @@ Usage:
0 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 { if !foreground {
unsafe { setpgid(0, 0) }; 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... process.set_timeout(Some((duration * 1000f64) as u64)); // FIXME: this ignores the f64...
match process.wait() { match process.wait() {
Ok(status) => match status { Ok(status) => match status {
ExitStatus(stat) => stat, ExitStatus(stat) => stat as i32,
ExitSignal(stat) => stat ExitSignal(stat) => stat as i32
}, },
Err(_) => { Err(_) => {
return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize)); 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) => { Ok(status) => {
if preserve_status { if preserve_status {
match status { match status {
ExitStatus(stat) => stat, ExitStatus(stat) => stat as i32,
ExitSignal(stat) => stat ExitSignal(stat) => stat as i32
} }
} else { } else {
124 124

View file

@ -1,5 +1,5 @@
#![crate_name = "touch"] #![crate_name = "touch"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -23,7 +23,7 @@ mod util;
static NAME: &'static str = "touch"; static NAME: &'static str = "touch";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optflag("a", "", "change only the access time"), getopts::optflag("a", "", "change only the access time"),
getopts::optflag("c", "no-create", "do not create any files"), getopts::optflag("c", "no-create", "do not create any files"),

View file

@ -1,5 +1,5 @@
#![crate_name = "tr"] #![crate_name = "tr"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, core, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -161,7 +161,7 @@ fn usage(opts: &[OptGroup]) {
print(getopts::usage("Translate or delete characters.", opts).as_slice()); 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 = [ let opts = [
getopts::optflag("c", "complement", "use the complement of SET1"), getopts::optflag("c", "complement", "use the complement of SET1"),
getopts::optflag("C", "", "same as -c"), getopts::optflag("C", "", "same as -c"),

View file

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

View file

@ -1,5 +1,5 @@
#![crate_name = "truncate"] #![crate_name = "truncate"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -34,7 +34,7 @@ enum TruncateMode {
static NAME: &'static str = "truncate"; 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 program = args[0].clone();
let opts = [ let opts = [
@ -100,7 +100,7 @@ file based on its current size:
0 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 { let (refsize, mode) = match reference {
Some(rfilename) => { Some(rfilename) => {
let rfile = match File::open(&Path::new(rfilename.clone())) { let rfile = match File::open(&Path::new(rfilename.clone())) {

View file

@ -1,5 +1,5 @@
#![crate_name = "tsort"] #![crate_name = "tsort"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "tsort"; static NAME: &'static str = "tsort";
static VERSION: &'static str = "1.0.0"; static VERSION: &'static str = "1.0.0";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
getopts::optflag("V", "version", "output version information and exit"), getopts::optflag("V", "version", "output version information and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "tty"] #![crate_name = "tty"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -17,7 +17,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::c_str_to_bytes; use std::ffi::CStr;
use std::old_io::println; use std::old_io::println;
use std::old_io::stdio::stderr; use std::old_io::stdio::stderr;
use getopts::{optflag,getopts}; use getopts::{optflag,getopts};
@ -33,7 +33,7 @@ extern {
static NAME: &'static str = "tty"; static NAME: &'static str = "tty";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let options = [ let options = [
optflag("s", "silent", "print nothing, only return an exit status") optflag("s", "silent", "print nothing, only return an exit status")
]; ];
@ -52,7 +52,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let tty = unsafe { let tty = unsafe {
let ptr = ttyname(libc::STDIN_FILENO); let ptr = ttyname(libc::STDIN_FILENO);
if !ptr.is_null() { if !ptr.is_null() {
String::from_utf8_lossy(c_str_to_bytes(&ptr)).to_string() String::from_utf8_lossy(CStr::from_ptr(ptr).to_bytes()).to_string()
} else { } else {
"".to_string() "".to_string()
} }
@ -74,7 +74,7 @@ pub fn uumain(args: Vec<String>) -> isize {
} }
}; };
exit_code as isize exit_code
} }
fn usage () { fn usage () {

View file

@ -1,5 +1,5 @@
#![crate_name = "uname"] #![crate_name = "uname"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -17,7 +17,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::c_str_to_bytes; use std::ffi::CStr;
use std::mem::uninitialized; use std::mem::uninitialized;
use std::old_io::print; use std::old_io::print;
use c_types::utsname; use c_types::utsname;
@ -38,7 +38,7 @@ extern {
} }
unsafe fn string_from_c_str(ptr: *const i8) -> String { unsafe fn string_from_c_str(ptr: *const i8) -> String {
String::from_utf8_lossy(c_str_to_bytes(&ptr)).to_string() String::from_utf8_lossy(CStr::from_ptr(ptr).to_bytes()).to_string()
} }
unsafe fn getuname() -> utsrust { unsafe fn getuname() -> utsrust {
@ -56,7 +56,7 @@ unsafe fn getuname() -> utsrust {
static NAME: &'static str = "uname"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "unexpand"] #![crate_name = "unexpand"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -73,7 +73,7 @@ impl Options {
} }
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let opts = [ let opts = [
getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"), getopts::optflag("a", "all", "convert all blanks, instead of just initial blanks"),
getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"), getopts::optflag("", "first-only", "convert only leading sequences of blanks (overrides -a)"),

View file

@ -1,5 +1,5 @@
#![crate_name = "uniq"] #![crate_name = "uniq"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -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_path = Path::new(args[0].clone());
let program = program_path.filename_str().unwrap_or(NAME); let program = program_path.filename_str().unwrap_or(NAME);

View file

@ -1,5 +1,5 @@
#![crate_name = "unlink"] #![crate_name = "unlink"]
#![feature(collections, core, io, path, rustc_private)] #![feature(collections, core, old_io, old_path, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -25,7 +25,7 @@ mod util;
static NAME: &'static str = "unlink"; 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 program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "uptime"] #![crate_name = "uptime"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, core, old_io, old_path, rustc_private, std_misc, str_words)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -55,7 +55,7 @@ unsafe extern fn utmpxname(_file: *const c_char) -> c_int {
0 0
} }
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = args[0].clone(); let program = args[0].clone();
let opts = [ let opts = [
getopts::optflag("v", "version", "output version information and exit"), getopts::optflag("v", "version", "output version information and exit"),
@ -108,7 +108,7 @@ fn print_loadavg() {
#[cfg(unix)] #[cfg(unix)]
fn process_utmpx() -> (Option<time_t>, usize) { fn process_utmpx() -> (Option<time_t>, usize) {
unsafe { unsafe {
utmpxname(CString::from_slice(DEFAULT_FILE.as_bytes()).as_ptr()); utmpxname(CString::new(DEFAULT_FILE).unwrap().as_ptr());
} }
let mut nusers = 0; let mut nusers = 0;

View file

@ -1,5 +1,5 @@
#![crate_name = "users"] #![crate_name = "users"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -18,7 +18,7 @@
extern crate getopts; extern crate getopts;
extern crate libc; extern crate libc;
use std::ffi::{CString, c_str_to_bytes}; use std::ffi::{CStr, CString};
use std::old_io::print; use std::old_io::print;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
@ -52,7 +52,7 @@ unsafe extern fn utmpxname(_file: *const libc::c_char) -> libc::c_int {
static NAME: &'static str = "users"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
@ -91,7 +91,7 @@ pub fn uumain(args: Vec<String>) -> isize {
fn exec(filename: &str) { fn exec(filename: &str) {
unsafe { unsafe {
utmpxname(CString::from_slice(filename.as_bytes()).as_ptr()); utmpxname(CString::new(filename).unwrap().as_ptr());
} }
let mut users = vec!(); let mut users = vec!();
@ -107,7 +107,7 @@ fn exec(filename: &str) {
} }
if (*line).ut_type == USER_PROCESS { if (*line).ut_type == USER_PROCESS {
let user = String::from_utf8_lossy(c_str_to_bytes(mem::transmute(&(*line).ut_user))).to_string(); let user = String::from_utf8_lossy(CStr::from_ptr(mem::transmute(&(*line).ut_user)).to_bytes()).to_string();
users.push(user); users.push(user);
} }
} }

View file

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

View file

@ -1,5 +1,5 @@
#![crate_name = "wc"] #![crate_name = "wc"]
#![feature(collections, core, io, path, rustc_private, std_misc)] #![feature(collections, old_io, old_path, rustc_private, str_words)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -37,8 +37,8 @@ struct Result {
static NAME: &'static str = "wc"; static NAME: &'static str = "wc";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0][]; let program = &args[0][..];
let opts = [ let opts = [
getopts::optflag("c", "bytes", "print the byte counts"), getopts::optflag("c", "bytes", "print the byte counts"),
getopts::optflag("m", "chars", "print the character counts"), getopts::optflag("m", "chars", "print the character counts"),
@ -60,7 +60,7 @@ pub fn uumain(args: Vec<String>) -> isize {
println!("Usage:"); println!("Usage:");
println!(" {0} [OPTION]... [FILE]...", program); println!(" {0} [OPTION]... [FILE]...", program);
println!(""); println!("");
print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[]); print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[..]);
println!(""); println!("");
println!("With no FILE, or when FILE is -, read standard input."); println!("With no FILE, or when FILE is -, read standard input.");
return 0; return 0;
@ -74,10 +74,10 @@ pub fn uumain(args: Vec<String>) -> isize {
let files = if matches.free.is_empty() { let files = if matches.free.is_empty() {
vec!["-".to_string()].into_cow() vec!["-".to_string()].into_cow()
} else { } else {
matches.free[].into_cow() matches.free[..].into_cow()
}; };
match wc(&files[], &matches) { match wc(&files[..], &matches) {
Ok(()) => ( /* pass */ ), Ok(()) => ( /* pass */ ),
Err(e) => return e Err(e) => return e
} }
@ -97,7 +97,7 @@ fn is_word_seperator(byte: u8) -> bool {
byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF 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_line_count: usize = 0;
let mut total_word_count: usize = 0; let mut total_word_count: usize = 0;
let mut total_char_count: usize = 0; let mut total_char_count: usize = 0;
@ -108,7 +108,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), isize> {
let mut max_str_len: usize = 0; let mut max_str_len: usize = 0;
for path in files.iter() { for path in files.iter() {
let mut reader = try!(open(&path[])); let mut reader = try!(open(&path[..]));
let mut line_count: usize = 0; let mut line_count: usize = 0;
let mut word_count: usize = 0; let mut word_count: usize = 0;
@ -128,7 +128,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), isize> {
// try and convert the bytes to UTF-8 first // try and convert the bytes to UTF-8 first
let current_char_count; let current_char_count;
match from_utf8(&raw_line[]) { match from_utf8(&raw_line[..]) {
Ok(line) => { Ok(line) => {
word_count += line.words().count(); word_count += line.words().count();
current_char_count = line.chars().count(); current_char_count = line.chars().count();
@ -170,7 +170,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), isize> {
} }
for result in results.iter() { for result in results.iter() {
print_stats(&result.filename[], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len); print_stats(&result.filename[..], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len);
} }
if files.len() > 1 { if files.len() > 1 {
@ -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 { if "-" == path {
let reader = Box::new(stdin_raw()) as Box<Reader>; let reader = Box::new(stdin_raw()) as Box<Reader>;
return Ok(BufferedReader::new(reader)); return Ok(BufferedReader::new(reader));

View file

@ -1,5 +1,5 @@
#![crate_name = "whoami"] #![crate_name = "whoami"]
#![feature(collections, core, io, rustc_private, std_misc)] #![feature(collections, core, old_io, rustc_private, std_misc)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -36,7 +36,7 @@ mod platform {
let passwd: *const c_passwd = getpwuid(geteuid()); let passwd: *const c_passwd = getpwuid(geteuid());
let pw_name: *const libc::c_char = (*passwd).pw_name; let pw_name: *const libc::c_char = (*passwd).pw_name;
String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&pw_name)).to_string() String::from_utf8_lossy(::std::ffi::CStr::from_ptr(pw_name).to_bytes()).to_string()
} }
} }
@ -55,13 +55,13 @@ mod platform {
if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 { if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 {
crash!(1, "username is too long"); crash!(1, "username is too long");
} }
String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&buffer.as_ptr())).to_string() String::from_utf8_lossy(::std::ffi::CStr::from_ptr(buffer.as_ptr()).to_bytes()).to_string()
} }
} }
static NAME: &'static str = "whoami"; 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 program = args[0].as_slice();
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),

View file

@ -1,5 +1,5 @@
#![crate_name = "yes"] #![crate_name = "yes"]
#![feature(collections, core, io, rustc_private)] #![feature(collections, old_io, rustc_private)]
/* /*
* This file is part of the uutils coreutils package. * This file is part of the uutils coreutils package.
@ -24,7 +24,7 @@ mod util;
static NAME: &'static str = "yes"; static NAME: &'static str = "yes";
pub fn uumain(args: Vec<String>) -> isize { pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0]; let program = &args[0];
let opts = [ let opts = [
getopts::optflag("h", "help", "display this help and exit"), getopts::optflag("h", "help", "display this help and exit"),
@ -42,7 +42,7 @@ pub fn uumain(args: Vec<String>) -> isize {
println!("Usage:"); println!("Usage:");
println!(" {0} [STRING]... [OPTION]...", program); println!(" {0} [STRING]... [OPTION]...", program);
println!(""); println!("");
print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[]); print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[..]);
return 0; return 0;
} }
if matches.opt_present("version") { if matches.opt_present("version") {
@ -55,7 +55,7 @@ pub fn uumain(args: Vec<String>) -> isize {
matches.free.connect(" ").into_cow() matches.free.connect(" ").into_cow()
}; };
exec(&string[]); exec(&string[..]);
0 0
} }