From 8cd7295a1952b4b4a5e2b590a6fe45c8c2be0096 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 17:23:54 +0100 Subject: [PATCH 01/12] test, tr, tsort: fix build --- src/test/test.rs | 5 +++-- src/tr/tr.rs | 20 +++++++++++--------- src/tsort/tsort.rs | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/test/test.rs b/src/test/test.rs index 72dcc6a6d..be9721b0d 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -12,6 +12,7 @@ extern crate libc; use std::collections::HashMap; +use std::ffi::CString; use std::os::{args_as_bytes}; use std::str::{from_utf8}; @@ -334,7 +335,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool { Write = 0o2, Execute = 0o1, } - let perm = |stat: stat, p: Permission| { + let perm = |&: stat: stat, p: Permission| { use libc::{getgid, getuid}; let (uid, gid) = unsafe { (getuid(), getgid()) }; if uid == stat.st_uid { @@ -346,7 +347,7 @@ fn path(path: &[u8], cond: PathCondition) -> bool { } }; - let path = unsafe { path.to_c_str_unchecked() }; + let path = CString::from_slice(path); let mut stat = unsafe { std::mem::zeroed() }; if cond == PathCondition::SymLink { if unsafe { lstat(path.as_ptr(), &mut stat) } == 0 { diff --git a/src/tr/tr.rs b/src/tr/tr.rs index da862aa6c..23aa63855 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -92,13 +92,15 @@ fn delete(set: Vec, complement: bool) { let mut out = stdout(); for &c in set.iter() { - bset.insert(c as uint); + bset.insert(c as usize); } - let is_allowed = if complement { - |c: char| bset.contains(&(c as uint)) - } else { - |c: char| !bset.contains(&(c as uint)) + let is_allowed = |&: c : char| { + if complement { + bset.contains(&(c as usize)) + } else { + !bset.contains(&(c as usize)) + } }; for c in BufferedReader::new(stdin_raw()).chars() { @@ -111,7 +113,7 @@ fn delete(set: Vec, complement: bool) { } fn tr(set1: &[char], set2: &[char]) { - const BUFFER_LEN: uint = 1024; + const BUFFER_LEN: usize = 1024; let mut map = VecMap::new(); let mut stdout = stdout(); @@ -120,16 +122,16 @@ fn tr(set1: &[char], set2: &[char]) { let set2_len = set2.len(); for i in range(0, set1.len()) { if i >= set2_len { - map.insert(set1[i] as uint, set2[set2_len - 1]); + map.insert(set1[i] as usize, set2[set2_len - 1]); } else { - map.insert(set1[i] as uint, set2[i]); + map.insert(set1[i] as usize, set2[i]); } } for c in BufferedReader::new(stdin_raw()).chars() { match c { Ok(inc) => { - let trc = match map.get(&(inc as uint)) { + let trc = match map.get(&(inc as usize)) { Some(t) => *t, None => inc, }; diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 340db735f..42d92f180 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -80,7 +80,7 @@ pub fn uumain(args: Vec) -> isize { loop { match reader.read_line() { Ok(line) => { - let ab: Vec<&str> = line.as_slice().trim_right_chars('\n').split(' ').collect(); + let ab: Vec<&str> = line.as_slice().trim_right_matches('\n').split(' ').collect(); if ab.len() > 2 { crash!(1, "{}: input contains an odd number of tokens", input); } @@ -159,7 +159,7 @@ impl Graph { } while !start_nodes.is_empty() { - let n = start_nodes.remove(0).unwrap(); + let n = start_nodes.remove(0); self.result.push(n.clone()); From 8d889fc5c9af158453a4f1dd0bd2c26075e558f0 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 17:55:29 +0100 Subject: [PATCH 02/12] uptime, users, whoami: fix build --- src/uptime/uptime.rs | 11 +++++------ src/users/users.rs | 10 ++++------ src/whoami/whoami.rs | 6 ++---- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 06720acc0..5e127c853 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -17,6 +17,7 @@ extern crate getopts; extern crate libc; extern crate "time" as rtime; +use std::ffi::CString; use std::mem::transmute; use std::io::{print, File}; use std::ptr::null; @@ -105,11 +106,9 @@ fn print_loadavg() { #[cfg(unix)] fn process_utmpx() -> (Option, uint) { - DEFAULT_FILE.with_c_str(|filename| { - unsafe { - utmpxname(filename); - } - }); + unsafe { + utmpxname(CString::from_slice(DEFAULT_FILE.as_bytes()).as_ptr()); + } let mut nusers = 0; let mut boot_time = None; @@ -172,7 +171,7 @@ fn get_uptime(boot_time: Option) -> i64 { _ => return match boot_time { Some(t) => { let now = rtime::get_time().sec; - let time = t.to_i64().unwrap(); + let time = t as i64; ((now - time) * 100) as i64 // Return in ms }, _ => -1 diff --git a/src/users/users.rs b/src/users/users.rs index 6fa4adec4..57782e61c 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -17,7 +17,7 @@ extern crate getopts; extern crate libc; -use std::ffi::c_str_to_bytes; +use std::ffi::{CString, c_str_to_bytes}; use std::io::print; use std::mem; use std::ptr; @@ -89,11 +89,9 @@ pub fn uumain(args: Vec) -> isize { } fn exec(filename: &str) { - filename.with_c_str(|filename| { - unsafe { - utmpxname(filename); - } - }); + unsafe { + utmpxname(CString::from_slice(filename.as_bytes()).as_ptr()); + } let mut users = vec!(); diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index bcb81bb7d..78422f5d2 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -35,9 +35,7 @@ mod platform { let passwd: *const c_passwd = getpwuid(geteuid()); let pw_name: *const libc::c_char = (*passwd).pw_name; - let name = String::from_raw_buf(pw_name as *const u8); - - name + String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&pw_name)).to_string() } } @@ -56,7 +54,7 @@ mod platform { if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 { crash!(1, "username is too long"); } - String::from_raw_buf(buffer.as_ptr() as *const u8) + String::from_utf8_lossy(::std::ffi::c_str_to_bytes(&buffer.as_ptr())).to_string() } } From cc854698d7b8f4c67d55e5adeecaabbd44fb4f31 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 18:15:04 +0100 Subject: [PATCH 03/12] relpath, tee, split, unexpand: fix build --- src/relpath/relpath.rs | 15 ++++----- src/split/split.rs | 69 ++++++++++++++++++++-------------------- src/tee/tee.rs | 21 ++++++------ src/unexpand/unexpand.rs | 20 ++++++------ 4 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 8b03c4779..2b194332f 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -64,14 +64,13 @@ pub fn uumain(args: Vec) -> isize { } let mut suffix_pos = 0; - absfrom.components() - .zip(absto.components()) - .take_while( - |&(f, t)| if f == t { - suffix_pos += 1; true - } else { - false - }).last(); + for (f, t) in absfrom.components().zip(absto.components()) { + if f == t { + suffix_pos += 1; + } else { + break; + } + } let mut result = Path::new(""); absfrom.components().skip(suffix_pos).map(|_| result.push("..")).last(); diff --git a/src/split/split.rs b/src/split/split.rs index c0a154ad7..1ba74c5e8 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -111,7 +111,7 @@ pub fn uumain(args: Vec) -> isize { struct Settings { prefix: String, numeric_suffix: bool, - suffix_length: uint, + suffix_length: usize, input: String, strategy: String, strategy_param: String, @@ -124,30 +124,29 @@ struct SplitControl { } trait Splitter { - // Factory pattern - fn new(_hint: Option, &Settings) -> Box; - // Consume the current_line and return the consumed string fn consume(&mut self, &mut SplitControl) -> String; } struct LineSplitter { - saved_lines_to_write: uint, - lines_to_write: uint, + saved_lines_to_write: usize, + lines_to_write: usize, } - -impl Splitter for LineSplitter { - fn new(_: Option, settings: &Settings) -> Box { +impl LineSplitter { + fn new(settings: &Settings) -> Box { let n = match settings.strategy_param.as_slice().parse() { Some(a) => a, _ => crash!(1, "invalid number of lines") }; - box LineSplitter { + Box::new(LineSplitter { saved_lines_to_write: n, lines_to_write: n, - } as Box + }) as Box } +} + +impl Splitter for LineSplitter { fn consume(&mut self, control: &mut SplitControl) -> String { self.lines_to_write -= 1; if self.lines_to_write == 0 { @@ -159,42 +158,44 @@ impl Splitter for LineSplitter { } struct ByteSplitter { - saved_bytes_to_write: uint, - bytes_to_write: uint, + saved_bytes_to_write: usize, + bytes_to_write: usize, break_on_line_end: bool, require_whole_line: bool, } -impl Splitter for ByteSplitter { - fn new(_: Option, settings: &Settings) -> Box { +impl ByteSplitter { + fn new(settings: &Settings) -> Box { let mut strategy_param : Vec = settings.strategy_param.chars().collect(); let suffix = strategy_param.pop().unwrap(); let multiplier = match suffix { - '0'...'9' => 1u, - 'b' => 512u, - 'k' => 1024u, - 'm' => 1024u * 1024u, + '0'...'9' => 1us, + 'b' => 512us, + 'k' => 1024us, + 'm' => 1024us * 1024us, _ => crash!(1, "invalid number of bytes") }; let n = if suffix.is_alphabetic() { - match strategy_param.as_slice().iter().map(|c| *c).collect::().as_slice().parse::() { + match strategy_param.as_slice().iter().map(|c| *c).collect::().as_slice().parse::() { Some(a) => a, _ => crash!(1, "invalid number of bytes") } } else { - match settings.strategy_param.as_slice().parse::() { + match settings.strategy_param.as_slice().parse::() { Some(a) => a, _ => crash!(1, "invalid number of bytes") } }; - box ByteSplitter { + Box::new(ByteSplitter { saved_bytes_to_write: n * multiplier, bytes_to_write: n * multiplier, break_on_line_end: if settings.strategy == "b" { false } else { true }, require_whole_line: false, - } as Box + }) as Box } +} +impl Splitter for ByteSplitter { fn consume(&mut self, control: &mut SplitControl) -> String { let line = control.current_line.clone(); let n = std::cmp::min(line.as_slice().chars().count(), self.bytes_to_write); @@ -217,13 +218,13 @@ impl Splitter for ByteSplitter { } // (1, 3) -> "aab" -fn str_prefix(i: uint, width: uint) -> String { +fn str_prefix(i: usize, width: usize) -> String { let mut c = "".to_string(); let mut n = i; let mut w = width; while w > 0 { w -= 1; - let div = Int::pow(26 as uint, w); + let div = Int::pow(26 as usize, w); let r = n / div; n -= r * div; c.push(char::from_u32((r as u32) + 97).unwrap()); @@ -232,13 +233,13 @@ fn str_prefix(i: uint, width: uint) -> String { } // (1, 3) -> "001" -fn num_prefix(i: uint, width: uint) -> String { +fn num_prefix(i: usize, width: usize) -> String { let mut c = "".to_string(); let mut n = i; let mut w = width; while w > 0 { w -= 1; - let div = Int::pow(10 as uint, w); + let div = Int::pow(10 as usize, w); let r = n / div; n -= r * div; c.push(char::from_digit(r, 10).unwrap()); @@ -246,23 +247,23 @@ fn num_prefix(i: uint, width: uint) -> String { c } -fn split(settings: &Settings) -> int { +fn split(settings: &Settings) -> isize { let mut reader = io::BufferedReader::new( if settings.input.as_slice() == "-" { - box io::stdio::stdin_raw() as Box + Box::new(io::stdio::stdin_raw()) as Box } else { let r = match io::File::open(&Path::new(settings.input.clone())) { Ok(a) => a, Err(_) => crash!(1, "cannot open '{}' for reading: No such file or directory", settings.input) }; - box r as Box + Box::new(r) as Box } ); let mut splitter: Box = match settings.strategy.as_slice() { - "l" => Splitter::new(None::, settings), - "b" | "C" => Splitter::new(None::, settings), + "l" => LineSplitter::new(settings), + "b" | "C" => ByteSplitter::new(settings), a @ _ => crash!(1, "strategy {} not supported", a) }; @@ -271,7 +272,7 @@ fn split(settings: &Settings) -> int { request_new_file: true, // Request new file }; - let mut writer = io::BufferedWriter::new(box io::stdio::stdout_raw() as Box); + let mut writer = io::BufferedWriter::new(Box::new(io::stdio::stdout_raw()) as Box); let mut fileno = 0; loop { if control.current_line.as_slice().chars().count() == 0 { @@ -293,7 +294,7 @@ fn split(settings: &Settings) -> int { crash_if_err!(1, writer.flush()); } fileno += 1; - writer = io::BufferedWriter::new(box io::File::open_mode(&Path::new(filename.as_slice()), io::Open, io::Write) as Box); + writer = io::BufferedWriter::new(Box::new(io::File::open_mode(&Path::new(filename.as_slice()), io::Open, io::Write)) as Box); control.request_new_file = false; if settings.verbose { println!("creating file '{}'", filename); diff --git a/src/tee/tee.rs b/src/tee/tee.rs index bbb1bc865..d2374af1d 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -1,5 +1,4 @@ #![crate_name = "tee"] -#![feature(phase)] /* * This file is part of the uutils coreutils package. * @@ -66,7 +65,7 @@ fn options(args: &[String]) -> Result { append: m.opt_present("append"), ignore_interrupts: m.opt_present("ignore-interrupts"), print_and_exit: to_print, - files: box names.iter().map(|name| Path::new(name.clone())).collect() + files: Box::new(names.iter().map(|name| Path::new(name.clone())).collect()) }) }).map_err(|message| warn(message.as_slice())) } @@ -81,7 +80,7 @@ fn exec(options: Options) -> Result<(), ()> { fn tee(options: Options) -> Result<(), ()> { let writers = options.files.iter().map(|path| open(path, options.append)).collect(); let output = &mut MultiWriter::new(writers); - let input = &mut NamedReader { inner: box stdin() as Box }; + let input = &mut NamedReader { inner: Box::new(stdin()) as Box }; if copy(input, output).is_err() || output.flush().is_err() { Err(()) } else { @@ -91,15 +90,15 @@ fn tee(options: Options) -> Result<(), ()> { fn open(path: &Path, append: bool) -> Box { let inner = if *path == Path::new("-") { - box stdout() as Box + Box::new(stdout()) as Box } else { let mode = if append { Append } else { Truncate }; match File::open_mode(path, mode, Write) { - Ok(file) => box file as Box, - Err(_) => box NullWriter as Box + Ok(file) => Box::new(file) as Box, + Err(_) => Box::new(NullWriter) as Box } }; - box NamedWriter { inner: inner, path: box path.clone() } as Box + Box::new(NamedWriter { inner: inner, path: Box::new(path.clone()) }) as Box } struct NamedWriter { @@ -112,7 +111,7 @@ impl Writer for NamedWriter { with_path(&*self.path.clone(), || { let val = self.inner.write(buf); if val.is_err() { - self.inner = box NullWriter as Box; + self.inner = Box::new(NullWriter) as Box; } val }) @@ -122,7 +121,7 @@ impl Writer for NamedWriter { with_path(&*self.path.clone(), || { let val = self.inner.flush(); if val.is_err() { - self.inner = box NullWriter as Box; + self.inner = Box::new(NullWriter) as Box; } val }) @@ -134,14 +133,14 @@ struct NamedReader { } impl Reader for NamedReader { - fn read(&mut self, buf: &mut [u8]) -> IoResult { + fn read(&mut self, buf: &mut [u8]) -> IoResult { with_path(&Path::new("stdin"), || { self.inner.read(buf) }) } } -fn with_path(path: &Path, cb: F) -> IoResult where F: Fn() -> IoResult { +fn with_path(path: &Path, mut cb: F) -> IoResult where F: FnMut() -> IoResult { match cb() { Err(f) => { warn(format!("{}: {}", path.display(), f.to_string()).as_slice()); Err(f) } okay => okay diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index 65fa1927e..c862e27e5 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -21,9 +21,9 @@ mod util; static NAME: &'static str = "unexpand"; static VERSION: &'static str = "0.0.1"; -static DEFAULT_TABSTOP: uint = 8; +static DEFAULT_TABSTOP: usize = 8; -fn tabstops_parse(s: String) -> Vec { +fn tabstops_parse(s: String) -> Vec { let words = s.as_slice().split(',').collect::>(); let nums = words.into_iter() @@ -31,7 +31,7 @@ fn tabstops_parse(s: String) -> Vec { .unwrap_or_else( || crash!(1, "{}\n", "tab size contains invalid character(s)")) ) - .collect::>(); + .collect::>(); if nums.iter().any(|&n| n == 0) { crash!(1, "{}\n", "tab size cannot be 0"); @@ -47,7 +47,7 @@ fn tabstops_parse(s: String) -> Vec { struct Options { files: Vec, - tabstops: Vec, + tabstops: Vec, aflag: bool } @@ -108,24 +108,24 @@ pub fn uumain(args: Vec) -> isize { fn open(path: String) -> io::BufferedReader> { let mut file_buf; if path.as_slice() == "-" { - io::BufferedReader::new(box io::stdio::stdin_raw() as Box) + io::BufferedReader::new(Box::new(io::stdio::stdin_raw()) as Box) } else { file_buf = match io::File::open(&Path::new(path.as_slice())) { Ok(a) => a, _ => crash!(1, "{}: {}\n", path, "No such file or directory") }; - io::BufferedReader::new(box file_buf as Box) + io::BufferedReader::new(Box::new(file_buf) as Box) } } -fn is_tabstop(tabstops: &[uint], col: uint) -> bool { +fn is_tabstop(tabstops: &[usize], col: usize) -> bool { match tabstops { [tabstop] => col % tabstop == 0, - tabstops => tabstops.binary_search(|&e| e.cmp(&col)).found().is_some() + tabstops => tabstops.binary_search_by(|&e| e.cmp(&col)).is_ok() } } -fn to_next_stop(tabstops: &[uint], col: uint) -> Option { +fn to_next_stop(tabstops: &[usize], col: usize) -> Option { match tabstops { [tabstop] => Some(tabstop - col % tabstop), tabstops => tabstops.iter().skip_while(|&t| *t <= col).next() @@ -134,7 +134,7 @@ fn to_next_stop(tabstops: &[uint], col: uint) -> Option { } fn unexpandspan(mut output: &mut io::LineBufferedWriter, - tabstops: &[uint], nspaces: uint, col: uint, init: bool) { + tabstops: &[usize], nspaces: usize, col: usize, init: bool) { let mut cur = col - nspaces; if nspaces > 1 || init { loop { From 782fad46679effa98d0926057e28487c51a35b87 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:07:08 +0100 Subject: [PATCH 04/12] int/uint -> isize/usize --- mkuutils.rs | 4 ++-- src/cat/cat.rs | 12 +++++----- src/cksum/cksum.rs | 2 +- src/cksum/crc_table.rs | 2 +- src/cksum/gen_table.rs | 6 ++--- src/common/signals.rs | 8 +++---- src/common/time.rs | 8 +++---- src/common/utmpx.rs | 24 ++++++++++---------- src/cut/buffer.rs | 14 ++++++------ src/cut/cut.rs | 16 +++++++------- src/cut/ranges.rs | 20 ++++++++--------- src/du/du.rs | 8 +++---- src/echo/echo.rs | 24 ++++++++++---------- src/expand/expand.rs | 12 +++++----- src/fmt/fmt.rs | 12 +++++----- src/fmt/linebreak.rs | 24 ++++++++++---------- src/fmt/parasplit.rs | 42 +++++++++++++++++------------------ src/fold/fold.rs | 10 ++++----- src/head/head.rs | 14 ++++++------ src/hostid/hostid.rs | 2 +- src/hostname/hostname.rs | 2 +- src/kill/kill.rs | 8 +++---- src/mkdir/mkdir.rs | 2 +- src/mv/mv.rs | 4 ++-- src/nl/helper.rs | 2 +- src/nl/nl.rs | 4 ++-- src/realpath/realpath.rs | 2 +- src/rm/rm.rs | 6 ++--- src/rmdir/rmdir.rs | 4 ++-- src/seq/seq.rs | 6 ++--- src/shuf/shuf.rs | 20 ++++++++--------- src/sort/sort.rs | 2 +- src/sync/sync.rs | 4 ++-- src/tail/tail.rs | 48 ++++++++++++++++++++-------------------- src/test/test.rs | 12 +++++----- src/timeout/timeout.rs | 8 +++---- src/truncate/truncate.rs | 2 +- src/tty/tty.rs | 2 +- src/uniq/uniq.rs | 6 ++--- src/uptime/uptime.rs | 8 +++---- src/uutils/uutils.rs | 4 ++-- src/wc/wc.rs | 42 +++++++++++++++++------------------ 42 files changed, 231 insertions(+), 231 deletions(-) diff --git a/mkuutils.rs b/mkuutils.rs index 0cd4ed112..7572dad2c 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -32,8 +32,8 @@ fn main() { crates.push_str("extern crate uutest;\n"); util_map.push_str("map.insert(\"test\", uutest::uumain);\n"); } - "true" => util_map.push_str("fn uutrue(_: Vec) -> int { 0 }\nmap.insert(\"true\", uutrue);\n"), - "false" => util_map.push_str("fn uufalse(_: Vec) -> int { 1 }\nmap.insert(\"false\", uufalse);\n"), + "true" => util_map.push_str("fn uutrue(_: Vec) -> isize { 0 }\nmap.insert(\"true\", uutrue);\n"), + "false" => util_map.push_str("fn uufalse(_: Vec) -> isize { 1 }\nmap.insert(\"false\", uufalse);\n"), "sync" => { crates.push_str("extern crate uusync;\n"); util_map.push_str("map.insert(\"sync\", uusync::uumain);\n"); diff --git a/src/cat/cat.rs b/src/cat/cat.rs index 33b410cd5..dc6eff13a 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -91,7 +91,7 @@ enum NumberingMode { fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, show_ends: bool) { - let mut line_counter: uint = 1; + let mut line_counter: usize = 1; for path in files.iter() { let (mut reader, interactive) = match open(path.as_slice()) { @@ -164,7 +164,7 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, show_ends: bool, show_nonprint: bool, show_tabs: bool) { - let mut line_counter: uint = 1; + let mut line_counter: usize = 1; for path in files.iter() { let (mut reader, interactive) = match open(path.as_slice()) { @@ -173,7 +173,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, }; // Flush all 1024 iterations. - let mut flush_counter = range(0u, 1024); + let mut flush_counter = range(0us, 1024); let mut in_buf = [0; 1024 * 32]; let mut out_buf = [0; 1024 * 64]; @@ -187,7 +187,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, for &byte in in_buf.slice_to(n).iter() { if flush_counter.next().is_none() { writer.possibly_flush(); - flush_counter = range(0u, 1024); + flush_counter = range(0us, 1024); } if byte == '\n' as u8 { if !at_line_start || !squeeze_blank { @@ -293,8 +293,8 @@ fn open(path: &str) -> Option<(Box, bool)> { struct UnsafeWriter<'a, W> { inner: W, buf: &'a mut [u8], - pos: uint, - threshold: uint, + pos: usize, + threshold: usize, } impl<'a, W: Writer> UnsafeWriter<'a, W> { diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index c1a5a3e89..7200b133e 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -44,7 +44,7 @@ fn crc_final(mut crc: u32, mut length: usize) -> u32 { #[inline] fn cksum(fname: &str) -> IoResult<(u32, usize)> { let mut crc = 0u32; - let mut size = 0u; + let mut size = 0us; let mut stdin_buf; let mut file_buf; diff --git a/src/cksum/crc_table.rs b/src/cksum/crc_table.rs index feecc82ec..72de84ef3 100644 --- a/src/cksum/crc_table.rs +++ b/src/cksum/crc_table.rs @@ -1,3 +1,3 @@ /* auto-generated (DO NOT EDIT) */ -pub static CRC_TABLE: [u32; 256] = [0, 79764919, 159529838, 222504665, 319059676, 398814059, 445009330, 507990021, 638119352, 583659535, 797628118, 726387553, 890018660, 835552979, 1015980042, 944750013, 1276238704, 1221641927, 1167319070, 1095957929, 1595256236, 1540665371, 1452775106, 1381403509, 1780037320, 1859660671, 1671105958, 1733955601, 2031960084, 2111593891, 1889500026, 1952343757, 2552477408, 2632100695, 2443283854, 2506133561, 2334638140, 2414271883, 2191915858, 2254759653, 3190512472, 3135915759, 3081330742, 3009969537, 2905550212, 2850959411, 2762807018, 2691435357, 3560074640, 3505614887, 3719321342, 3648080713, 3342211916, 3287746299, 3467911202, 3396681109, 4063920168, 4143685023, 4223187782, 4286162673, 3779000052, 3858754371, 3904687514, 3967668269, 881225847, 809987520, 1023691545, 969234094, 662832811, 591600412, 771767749, 717299826, 311336399, 374308984, 453813921, 533576470, 25881363, 88864420, 134795389, 214552010, 2023205639, 2086057648, 1897238633, 1976864222, 1804852699, 1867694188, 1645340341, 1724971778, 1587496639, 1516133128, 1461550545, 1406951526, 1302016099, 1230646740, 1142491917, 1087903418, 2896545431, 2825181984, 2770861561, 2716262478, 3215044683, 3143675388, 3055782693, 3001194130, 2326604591, 2389456536, 2200899649, 2280525302, 2578013683, 2640855108, 2418763421, 2498394922, 3769900519, 3832873040, 3912640137, 3992402750, 4088425275, 4151408268, 4197601365, 4277358050, 3334271071, 3263032808, 3476998961, 3422541446, 3585640067, 3514407732, 3694837229, 3640369242, 1762451694, 1842216281, 1619975040, 1682949687, 2047383090, 2127137669, 1938468188, 2001449195, 1325665622, 1271206113, 1183200824, 1111960463, 1543535498, 1489069629, 1434599652, 1363369299, 622672798, 568075817, 748617968, 677256519, 907627842, 853037301, 1067152940, 995781531, 51762726, 131386257, 177728840, 240578815, 269590778, 349224269, 429104020, 491947555, 4046411278, 4126034873, 4172115296, 4234965207, 3794477266, 3874110821, 3953728444, 4016571915, 3609705398, 3555108353, 3735388376, 3664026991, 3290680682, 3236090077, 3449943556, 3378572211, 3174993278, 3120533705, 3032266256, 2961025959, 2923101090, 2868635157, 2813903052, 2742672763, 2604032198, 2683796849, 2461293480, 2524268063, 2284983834, 2364738477, 2175806836, 2238787779, 1569362073, 1498123566, 1409854455, 1355396672, 1317987909, 1246755826, 1192025387, 1137557660, 2072149281, 2135122070, 1912620623, 1992383480, 1753615357, 1816598090, 1627664531, 1707420964, 295390185, 358241886, 404320391, 483945776, 43990325, 106832002, 186451547, 266083308, 932423249, 861060070, 1041341759, 986742920, 613929101, 542559546, 756411363, 701822548, 3316196985, 3244833742, 3425377559, 3370778784, 3601682597, 3530312978, 3744426955, 3689838204, 3819031489, 3881883254, 3928223919, 4007849240, 4037393693, 4100235434, 4180117107, 4259748804, 2310601993, 2373574846, 2151335527, 2231098320, 2596047829, 2659030626, 2470359227, 2550115596, 2947551409, 2876312838, 2788305887, 2733848168, 3165939309, 3094707162, 3040238851, 2985771188]; +pub static CRC_TABLE: [u32; 256] = [0u32, 79764919u32, 159529838u32, 222504665u32, 319059676u32, 398814059u32, 445009330u32, 507990021u32, 638119352u32, 583659535u32, 797628118u32, 726387553u32, 890018660u32, 835552979u32, 1015980042u32, 944750013u32, 1276238704u32, 1221641927u32, 1167319070u32, 1095957929u32, 1595256236u32, 1540665371u32, 1452775106u32, 1381403509u32, 1780037320u32, 1859660671u32, 1671105958u32, 1733955601u32, 2031960084u32, 2111593891u32, 1889500026u32, 1952343757u32, 2552477408u32, 2632100695u32, 2443283854u32, 2506133561u32, 2334638140u32, 2414271883u32, 2191915858u32, 2254759653u32, 3190512472u32, 3135915759u32, 3081330742u32, 3009969537u32, 2905550212u32, 2850959411u32, 2762807018u32, 2691435357u32, 3560074640u32, 3505614887u32, 3719321342u32, 3648080713u32, 3342211916u32, 3287746299u32, 3467911202u32, 3396681109u32, 4063920168u32, 4143685023u32, 4223187782u32, 4286162673u32, 3779000052u32, 3858754371u32, 3904687514u32, 3967668269u32, 881225847u32, 809987520u32, 1023691545u32, 969234094u32, 662832811u32, 591600412u32, 771767749u32, 717299826u32, 311336399u32, 374308984u32, 453813921u32, 533576470u32, 25881363u32, 88864420u32, 134795389u32, 214552010u32, 2023205639u32, 2086057648u32, 1897238633u32, 1976864222u32, 1804852699u32, 1867694188u32, 1645340341u32, 1724971778u32, 1587496639u32, 1516133128u32, 1461550545u32, 1406951526u32, 1302016099u32, 1230646740u32, 1142491917u32, 1087903418u32, 2896545431u32, 2825181984u32, 2770861561u32, 2716262478u32, 3215044683u32, 3143675388u32, 3055782693u32, 3001194130u32, 2326604591u32, 2389456536u32, 2200899649u32, 2280525302u32, 2578013683u32, 2640855108u32, 2418763421u32, 2498394922u32, 3769900519u32, 3832873040u32, 3912640137u32, 3992402750u32, 4088425275u32, 4151408268u32, 4197601365u32, 4277358050u32, 3334271071u32, 3263032808u32, 3476998961u32, 3422541446u32, 3585640067u32, 3514407732u32, 3694837229u32, 3640369242u32, 1762451694u32, 1842216281u32, 1619975040u32, 1682949687u32, 2047383090u32, 2127137669u32, 1938468188u32, 2001449195u32, 1325665622u32, 1271206113u32, 1183200824u32, 1111960463u32, 1543535498u32, 1489069629u32, 1434599652u32, 1363369299u32, 622672798u32, 568075817u32, 748617968u32, 677256519u32, 907627842u32, 853037301u32, 1067152940u32, 995781531u32, 51762726u32, 131386257u32, 177728840u32, 240578815u32, 269590778u32, 349224269u32, 429104020u32, 491947555u32, 4046411278u32, 4126034873u32, 4172115296u32, 4234965207u32, 3794477266u32, 3874110821u32, 3953728444u32, 4016571915u32, 3609705398u32, 3555108353u32, 3735388376u32, 3664026991u32, 3290680682u32, 3236090077u32, 3449943556u32, 3378572211u32, 3174993278u32, 3120533705u32, 3032266256u32, 2961025959u32, 2923101090u32, 2868635157u32, 2813903052u32, 2742672763u32, 2604032198u32, 2683796849u32, 2461293480u32, 2524268063u32, 2284983834u32, 2364738477u32, 2175806836u32, 2238787779u32, 1569362073u32, 1498123566u32, 1409854455u32, 1355396672u32, 1317987909u32, 1246755826u32, 1192025387u32, 1137557660u32, 2072149281u32, 2135122070u32, 1912620623u32, 1992383480u32, 1753615357u32, 1816598090u32, 1627664531u32, 1707420964u32, 295390185u32, 358241886u32, 404320391u32, 483945776u32, 43990325u32, 106832002u32, 186451547u32, 266083308u32, 932423249u32, 861060070u32, 1041341759u32, 986742920u32, 613929101u32, 542559546u32, 756411363u32, 701822548u32, 3316196985u32, 3244833742u32, 3425377559u32, 3370778784u32, 3601682597u32, 3530312978u32, 3744426955u32, 3689838204u32, 3819031489u32, 3881883254u32, 3928223919u32, 4007849240u32, 4037393693u32, 4100235434u32, 4180117107u32, 4259748804u32, 2310601993u32, 2373574846u32, 2151335527u32, 2231098320u32, 2596047829u32, 2659030626u32, 2470359227u32, 2550115596u32, 2947551409u32, 2876312838u32, 2788305887u32, 2733848168u32, 3165939309u32, 3094707162u32, 3040238851u32, 2985771188u32]; diff --git a/src/cksum/gen_table.rs b/src/cksum/gen_table.rs index 622af56ec..f1ef74ed4 100644 --- a/src/cksum/gen_table.rs +++ b/src/cksum/gen_table.rs @@ -10,7 +10,7 @@ use std::io; -static CRC_TABLE_LEN: uint = 256; +static CRC_TABLE_LEN: usize = 256; fn main() { let mut table = Vec::with_capacity(CRC_TABLE_LEN); @@ -20,7 +20,7 @@ fn main() { let mut file = io::File::open_mode(&Path::new("crc_table.rs"), io::Truncate, io::Write).unwrap(); let output = format!("/* auto-generated (DO NOT EDIT) */ -pub static CRC_TABLE: [u32; {}] = {};", CRC_TABLE_LEN, table); +pub static CRC_TABLE: [u32; {}] = {:?};", CRC_TABLE_LEN, table); file.write_line(output.as_slice()).unwrap(); } @@ -28,7 +28,7 @@ pub static CRC_TABLE: [u32; {}] = {};", CRC_TABLE_LEN, table); fn crc_entry(input: u8) -> u32 { let mut crc = (input as u32) << 24; - for _ in range(0u, 8) { + for _ in range(0, 8) { if crc & 0x80000000 != 0 { crc <<= 1; crc ^= 0x04c11db7; diff --git a/src/common/signals.rs b/src/common/signals.rs index 4442a4af9..37b567d5f 100644 --- a/src/common/signals.rs +++ b/src/common/signals.rs @@ -9,10 +9,10 @@ #![allow(dead_code)] -pub static DEFAULT_SIGNAL:uint = 15; +pub static DEFAULT_SIGNAL:usize= 15; -pub struct Signal<'a> { pub name:&'a str, pub value: uint} +pub struct Signal<'a> { pub name:&'a str, pub value: usize} /* @@ -139,7 +139,7 @@ pub static ALL_SIGNALS:[Signal<'static>; 31] = [ Signal{ name: "USR2", value:31 }, ]; -pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { +pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { if signal_name_or_value == "0" { return Some(0); } @@ -153,6 +153,6 @@ pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { } #[inline(always)] -pub fn is_signal(num: uint) -> bool { +pub fn is_signal(num: usize) -> bool { num < ALL_SIGNALS.len() } diff --git a/src/common/time.rs b/src/common/time.rs index a85f43900..3b140528d 100644 --- a/src/common/time.rs +++ b/src/common/time.rs @@ -14,10 +14,10 @@ pub fn from_str(string: &str) -> Result { } let slice = string.slice_to(len - 1); let (numstr, times) = match string.char_at(len - 1) { - 's' | 'S' => (slice, 1u), - 'm' | 'M' => (slice, 60u), - 'h' | 'H' => (slice, 60u * 60), - 'd' | 'D' => (slice, 60u * 60 * 24), + 's' | 'S' => (slice, 1us), + 'm' | 'M' => (slice, 60us), + 'h' | 'H' => (slice, 60us * 60), + 'd' | 'D' => (slice, 60us * 60 * 24), val => { if !val.is_alphabetic() { (string, 1) diff --git a/src/common/utmpx.rs b/src/common/utmpx.rs index e68e0c40c..a210dfff4 100644 --- a/src/common/utmpx.rs +++ b/src/common/utmpx.rs @@ -10,10 +10,10 @@ mod utmpx { pub static DEFAULT_FILE: &'static str = "/var/run/utmp"; - pub const UT_LINESIZE: uint = 32; - pub const UT_NAMESIZE: uint = 32; - pub const UT_IDSIZE: uint = 4; - pub const UT_HOSTSIZE: uint = 256; + pub const UT_LINESIZE: usize = 32; + pub const UT_NAMESIZE: usize = 32; + pub const UT_IDSIZE: usize = 4; + pub const UT_HOSTSIZE: usize = 256; pub const EMPTY: libc::c_short = 0; pub const RUN_LVL: libc::c_short = 1; @@ -56,10 +56,10 @@ mod utmpx { pub static DEFAULT_FILE: &'static str = "/var/run/utmpx"; - pub const UT_LINESIZE: uint = 32; - pub const UT_NAMESIZE: uint = 256; - pub const UT_IDSIZE: uint = 4; - pub const UT_HOSTSIZE: uint = 256; + pub const UT_LINESIZE: usize = 32; + pub const UT_NAMESIZE: usize = 256; + pub const UT_IDSIZE: usize = 4; + pub const UT_HOSTSIZE: usize = 256; pub const EMPTY: libc::c_short = 0; pub const RUN_LVL: libc::c_short = 1; @@ -97,10 +97,10 @@ mod utmpx { pub static DEFAULT_FILE : &'static str = ""; - pub const UT_LINESIZE : uint = 16; - pub const UT_NAMESIZE : uint = 32; - pub const UT_IDSIZE : uint = 8; - pub const UT_HOSTSIZE : uint = 128; + pub const UT_LINESIZE : usize = 16; + pub const UT_NAMESIZE : usize = 32; + pub const UT_IDSIZE : usize = 8; + pub const UT_HOSTSIZE : usize = 128; pub const EMPTY : libc::c_short = 0; pub const BOOT_TIME : libc::c_short = 1; diff --git a/src/cut/buffer.rs b/src/cut/buffer.rs index ef6ce58a5..d1de6169c 100644 --- a/src/cut/buffer.rs +++ b/src/cut/buffer.rs @@ -4,14 +4,14 @@ use std::io::{IoResult, IoError}; pub struct BufReader { reader: R, buffer: [u8; 4096], - start: uint, - end: uint, // exclusive + start: usize, + end: usize, // exclusive } #[allow(non_snake_case)] pub mod Bytes { pub trait Select { - fn select<'a>(&'a mut self, bytes: uint) -> Selected<'a>; + fn select<'a>(&'a mut self, bytes: usize) -> Selected<'a>; } pub enum Selected<'a> { @@ -37,7 +37,7 @@ impl BufReader { } #[inline] - fn read(&mut self) -> IoResult { + fn read(&mut self) -> IoResult { let buffer_fill = self.buffer.slice_from_mut(self.end); match self.reader.read(buffer_fill) { @@ -50,7 +50,7 @@ impl BufReader { } #[inline] - fn maybe_fill_buf(&mut self) -> IoResult { + fn maybe_fill_buf(&mut self) -> IoResult { if self.end == self.start { self.start = 0; self.end = 0; @@ -61,7 +61,7 @@ impl BufReader { } } - pub fn consume_line(&mut self) -> uint { + pub fn consume_line(&mut self) -> usize { let mut bytes_consumed = 0; loop { @@ -91,7 +91,7 @@ impl BufReader { } impl Bytes::Select for BufReader { - fn select<'a>(&'a mut self, bytes: uint) -> Bytes::Selected<'a> { + fn select<'a>(&'a mut self, bytes: usize) -> Bytes::Selected<'a> { match self.maybe_fill_buf() { Err(IoError { kind: std::io::EndOfFile, .. }) => (), Err(err) => panic!("read error: {}", err.desc), diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 3a934b37a..3fc634a54 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -53,7 +53,7 @@ fn list_to_ranges(list: &str, complement: bool) -> Result, String> { fn cut_bytes(reader: R, ranges: &Vec, - opts: &Options) -> int { + opts: &Options) -> isize { use buffer::Bytes::Select; use buffer::Bytes::Selected::{NewlineFound, Complete, Partial, EndOfFile}; @@ -134,7 +134,7 @@ fn cut_bytes(reader: R, fn cut_characters(reader: R, ranges: &Vec, - opts: &Options) -> int { + opts: &Options) -> isize { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -195,7 +195,7 @@ fn cut_characters(reader: R, struct Searcher<'a> { haystack: &'a [u8], needle: &'a [u8], - position: uint + position: usize } impl<'a> Searcher<'a> { @@ -209,9 +209,9 @@ impl<'a> Searcher<'a> { } impl<'a> Iterator for Searcher<'a> { - type Item = (uint, uint); + type Item = (usize, usize); - fn next(&mut self) -> Option<(uint, uint)> { + fn next(&mut self) -> Option<(usize, usize)> { if self.needle.len() == 1 { for offset in range(self.position, self.haystack.len()) { if self.haystack[offset] == self.needle[0] { @@ -242,7 +242,7 @@ fn cut_fields_delimiter(reader: R, ranges: &Vec, delim: &String, only_delimited: bool, - out_delim: &String) -> int { + out_delim: &String) -> isize { let mut buf_in = BufferedReader::new(reader); let mut out = BufferedWriter::new(stdio::stdout_raw()); @@ -316,7 +316,7 @@ fn cut_fields_delimiter(reader: R, fn cut_fields(reader: R, ranges: &Vec, - opts: &FieldOptions) -> int { + opts: &FieldOptions) -> isize { match opts.out_delimeter { Some(ref delim) => { return cut_fields_delimiter(reader, ranges, &opts.delimiter, @@ -395,7 +395,7 @@ fn cut_fields(reader: R, 0 } -fn cut_files(mut filenames: Vec, mode: Mode) -> int { +fn cut_files(mut filenames: Vec, mode: Mode) -> isize { let mut stdin_read = false; let mut exit_code = 0; diff --git a/src/cut/ranges.rs b/src/cut/ranges.rs index 8a0401ef0..1c834f89e 100644 --- a/src/cut/ranges.rs +++ b/src/cut/ranges.rs @@ -11,31 +11,31 @@ use std; #[derive(PartialEq,Eq,PartialOrd,Ord,Show)] pub struct Range { - pub low: uint, - pub high: uint, + pub low: usize, + pub high: usize, } impl std::str::FromStr for Range { fn from_str(s: &str) -> Option { - use std::uint::MAX; + use std::usize::MAX; let mut parts = s.splitn(1, '-'); match (parts.next(), parts.next()) { (Some(nm), None) => { - nm.parse::().and_then(|nm| if nm > 0 { Some(nm) } else { None }) + nm.parse::().and_then(|nm| if nm > 0 { Some(nm) } else { None }) .map(|nm| Range { low: nm, high: nm }) } (Some(n), Some(m)) if m.len() == 0 => { - n.parse::().and_then(|low| if low > 0 { Some(low) } else { None }) + n.parse::().and_then(|low| if low > 0 { Some(low) } else { None }) .map(|low| Range { low: low, high: MAX }) } (Some(n), Some(m)) if n.len() == 0 => { - m.parse::().and_then(|high| if high >= 1 { Some(high) } else { None }) + m.parse::().and_then(|high| if high >= 1 { Some(high) } else { None }) .map(|high| Range { low: 1, high: high }) } (Some(n), Some(m)) => { - match (n.parse::(), m.parse::()) { + match (n.parse::(), m.parse::()) { (Some(low), Some(high)) if low > 0 && low <= high => { Some(Range { low: low, high: high }) } @@ -77,7 +77,7 @@ impl Range { } pub fn complement(ranges: &Vec) -> Vec { - use std::uint; + use std::usize; let mut complements = Vec::with_capacity(ranges.len() + 1); @@ -97,10 +97,10 @@ pub fn complement(ranges: &Vec) -> Vec { } } (Some(last), None) => { - if last.high < uint::MAX { + if last.high < usize::MAX { complements.push(Range { low: last.high + 1, - high: uint::MAX + high: usize::MAX }); } } diff --git a/src/du/du.rs b/src/du/du.rs index d7619f2cf..ec8e32856 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -32,7 +32,7 @@ static VERSION: &'static str = "1.0.0"; struct Options { all: bool, program_name: String, - max_depth: Option, + max_depth: Option, total: bool, separate_dirs: bool, } @@ -43,7 +43,7 @@ struct Stat { } // this takes `my_stat` to avoid having to stat files multiple times. fn du(path: &Path, mut my_stat: Stat, - options: Arc, depth: uint) -> Vec> { + options: Arc, depth: usize) -> Vec> { let mut stats = vec!(); let mut futures = vec!(); @@ -193,7 +193,7 @@ ers of 1000).", let summarize = matches.opt_present("summarize"); let max_depth_str = matches.opt_str("max-depth"); - let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::()); + let max_depth = max_depth_str.as_ref().and_then(|s| s.parse::()); match (max_depth_str, max_depth) { (Some(ref s), _) if summarize => { show_error!("summarizing conflicts with --max-depth={}", *s); @@ -245,7 +245,7 @@ ers of 1000).", letters.push(c); } } - let number = numbers.parse::().unwrap(); + let number = numbers.parse::().unwrap(); let multiple = match letters.as_slice() { "K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024, "T" => 1024 * 1024 * 1024 * 1024, "P" => 1024 * 1024 * 1024 * 1024 * 1024, diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 017a83b2b..2ba4f39da 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -30,8 +30,8 @@ struct EchoOptions { } #[inline(always)] -fn to_char(bytes: &Vec, base: uint) -> char { - from_str_radix::(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char +fn to_char(bytes: &Vec, base: usize) -> char { + from_str_radix::(from_utf8(bytes.as_slice()).unwrap(), base).unwrap() as u8 as char } #[inline(always)] @@ -51,19 +51,19 @@ fn isodigit(c: u8) -> bool { } } -fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) { - let (max_digits, is_legal_digit) : (uint, fn(u8) -> bool) = match base { - 8u => (3, isodigit), - 16u => (2, isxdigit), +fn convert_str(string: &[u8], index: usize, base: usize) -> (char, usize) { + let (max_digits, is_legal_digit) : (usize, fn(u8) -> bool) = match base { + 8us => (3, isodigit), + 16us => (2, isxdigit), _ => panic!(), }; let mut bytes = vec!(); - for offset in range(0u, max_digits) { - if string.len() <= index + offset as uint { + for offset in range(0us, max_digits) { + if string.len() <= index + offset as usize { break; } - let c = string[index + offset as uint]; + let c = string[index + offset as usize]; if is_legal_digit(c) { bytes.push(c as u8); } else { @@ -201,7 +201,7 @@ pub fn uumain(args: Vec) -> isize { 't' => print!("\t"), 'v' => print!("\x0B"), 'x' => { - let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16u); + let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 16us); if num_char_used == 0 { print!("\\x"); } else { @@ -212,7 +212,7 @@ pub fn uumain(args: Vec) -> isize { } }, '0' => { - let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8u); + let (c, num_char_used) = convert_str(string.as_bytes(), index + 1, 8us); if num_char_used == 0 { print!("\0"); } else { @@ -223,7 +223,7 @@ pub fn uumain(args: Vec) -> isize { } } _ => { - let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8u); + let (esc_c, num_char_used) = convert_str(string.as_bytes(), index, 8us); if num_char_used == 0 { print!("\\{}", c); } else { diff --git a/src/expand/expand.rs b/src/expand/expand.rs index b65105d54..94ae03e92 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -22,17 +22,17 @@ mod util; static NAME: &'static str = "expand"; static VERSION: &'static str = "0.0.1"; -static DEFAULT_TABSTOP: uint = 8; +static DEFAULT_TABSTOP: usize = 8; -fn tabstops_parse(s: String) -> Vec { +fn tabstops_parse(s: String) -> Vec { let words = s.as_slice().split(',').collect::>(); let nums = words.into_iter() - .map(|sn| sn.parse::() + .map(|sn| sn.parse::() .unwrap_or_else( || crash!(1, "{}\n", "tab size contains invalid character(s)")) ) - .collect::>(); + .collect::>(); if nums.iter().any(|&n| n == 0) { crash!(1, "{}\n", "tab size cannot be 0"); @@ -48,7 +48,7 @@ fn tabstops_parse(s: String) -> Vec { struct Options { files: Vec, - tabstops: Vec, + tabstops: Vec, iflag: bool } @@ -117,7 +117,7 @@ fn open(path: String) -> io::BufferedReader> { } } -fn to_next_stop(tabstops: &[uint], col: uint) -> uint { +fn to_next_stop(tabstops: &[usize], col: usize) -> usize { match tabstops.as_slice() { [tabstop] => tabstop - col % tabstop, tabstops => match tabstops.iter().skip_while(|&t| *t <= col).next() { diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 2021ef7a0..51673ee0c 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -49,9 +49,9 @@ struct FmtOptions { xanti_prefix : bool, uniform : bool, quick : bool, - width : uint, - goal : uint, - tabwidth : uint, + width : usize, + goal : usize, + tabwidth : usize, } pub fn uumain(args: Vec) -> isize { @@ -140,7 +140,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("w") { Some(s) => { fmt_opts.width = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid WIDTH specification: `{}'", s); } }; @@ -152,7 +152,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("g") { Some(s) => { fmt_opts.goal = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid GOAL specification: `{}'", s); } }; @@ -168,7 +168,7 @@ pub fn uumain(args: Vec) -> isize { match matches.opt_str("T") { Some(s) => { fmt_opts.tabwidth = - match s.parse::() { + match s.parse::() { Some(t) => t, None => { crash!(1, "Invalid TABWIDTH specification: `{}'", s); } }; diff --git a/src/fmt/linebreak.rs b/src/fmt/linebreak.rs index f7f6b6c27..9e1451085 100644 --- a/src/fmt/linebreak.rs +++ b/src/fmt/linebreak.rs @@ -16,16 +16,16 @@ use std::mem; struct BreakArgs<'a> { opts : &'a FmtOptions, - init_len : uint, + init_len : usize, indent_str : &'a str, - indent_len : uint, + indent_len : usize, uniform : bool, ostream : &'a mut Box } impl<'a> BreakArgs<'a> { #[inline(always)] - fn compute_width<'b>(&self, winfo: &WordInfo<'b>, posn: uint, fresh: bool) -> uint { + fn compute_width<'b>(&self, winfo: &WordInfo<'b>, posn: usize, fresh: bool) -> usize { if fresh { 0 } else { @@ -100,7 +100,7 @@ fn break_simple<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &mut BreakArgs } #[inline(always)] -fn accum_words_simple<'a>(args: &mut BreakArgs<'a>, (l, prev_punct): (uint, bool), winfo: &'a WordInfo<'a>) -> (uint, bool) { +fn accum_words_simple<'a>(args: &mut BreakArgs<'a>, (l, prev_punct): (usize, bool), winfo: &'a WordInfo<'a>) -> (usize, bool) { // compute the length of this word, considering how tabs will expand at this position on the line let wlen = winfo.word_nchars + args.compute_width(winfo, l, false); @@ -174,12 +174,12 @@ fn break_knuth_plass<'a, T: Clone + Iterator<&'a WordInfo<'a>>>(mut iter: T, arg } struct LineBreak<'a> { - prev : uint, + prev : usize, linebreak : Option<&'a WordInfo<'a>>, break_before : bool, demerits : i64, prev_rat : f32, - length : uint, + length : usize, fresh : bool } @@ -200,7 +200,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA let next_active_breaks = &mut vec!(); let stretch = (args.opts.width - args.opts.goal) as int; - let minlength = args.opts.goal - stretch as uint; + let minlength = args.opts.goal - stretch as usize; let mut new_linebreaks = vec!(); let mut is_sentence_start = false; let mut least_demerits = 0; @@ -311,7 +311,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA } #[inline(always)] -fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(&'a WordInfo<'a>, bool)> { +fn build_best_path<'a>(paths: &Vec>, active: &Vec) -> Vec<(&'a WordInfo<'a>, bool)> { let mut breakwords = vec!(); // of the active paths, we select the one with the fewest demerits let mut best_idx = match active.iter().min_by(|&&a| paths[a].demerits) { @@ -378,7 +378,7 @@ fn compute_demerits(delta_len: int, stretch: int, wlen: int, prev_rat: f32) -> ( } #[inline(always)] -fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_idx: uint, w: &'a WordInfo<'a>, slen: uint, min: uint) -> LineBreak<'a> { +fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_idx: usize, w: &'a WordInfo<'a>, slen: usize, min: usize) -> LineBreak<'a> { let (break_before, line_length) = if active.fresh { // never break before a word if that word would be the first on a line @@ -410,7 +410,7 @@ fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_i // Number of spaces to add before a word, based on mode, newline, sentence start. #[inline(always)] -fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> uint { +fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> usize { if uniform || newline { if start || (newline && punct) { 2 @@ -425,7 +425,7 @@ fn compute_slen(uniform: bool, newline: bool, start: bool, punct: bool) -> uint // If we're on a fresh line, slen=0 and we slice off leading whitespace. // Otherwise, compute slen and leave whitespace alone. #[inline(always)] -fn slice_if_fresh<'a>(fresh: bool, word: &'a str, start: uint, uniform: bool, newline: bool, sstart: bool, punct: bool) -> (uint, &'a str) { +fn slice_if_fresh<'a>(fresh: bool, word: &'a str, start: usize, uniform: bool, newline: bool, sstart: bool, punct: bool) -> (usize, &'a str) { if fresh { (0, word.slice_from(start)) } else { @@ -442,7 +442,7 @@ fn write_newline(indent: &str, ostream: &mut Box) { // Write the word, along with slen spaces. #[inline(always)] -fn write_with_spaces(word: &str, slen: uint, ostream: &mut Box) { +fn write_with_spaces(word: &str, slen: usize, ostream: &mut Box) { if slen == 2 { silent_unwrap!(ostream.write(" ".as_bytes())); } else if slen == 1 { diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index 776ae9198..b36a58ac2 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -15,8 +15,8 @@ use FileOrStdReader; use FmtOptions; #[inline(always)] -fn char_width(c: char) -> uint { - if (c as uint) < 0xA0 { +fn char_width(c: char) -> usize { + if (c as usize) < 0xA0 { // if it is ASCII, call it exactly 1 wide (including control chars) // calling control chars' widths 1 is consistent with OpenBSD fmt 1 @@ -59,10 +59,10 @@ impl Line { #[derive(Show)] struct FileLine { line : String, - indent_end : uint, // the end of the indent, always the start of the text - pfxind_end : uint, // the end of the PREFIX's indent, that is, the spaces before the prefix - indent_len : uint, // display length of indent taking into account tabs - prefix_len : uint, // PREFIX indent length taking into account tabs + indent_end : usize, // the end of the indent, always the start of the text + pfxind_end : usize, // the end of the PREFIX's indent, that is, the spaces before the prefix + indent_len : usize, // display length of indent taking into account tabs + prefix_len : usize, // PREFIX indent length taking into account tabs } // iterator that produces a stream of Lines from a file @@ -77,7 +77,7 @@ impl<'a> FileLines<'a> { } // returns true if this line should be formatted - fn match_prefix(&self, line: &str) -> (bool, uint) { + fn match_prefix(&self, line: &str) -> (bool, usize) { if !self.opts.use_prefix { return (true, 0u); } FileLines::match_prefix_generic(self.opts.prefix.as_slice(), line, self.opts.xprefix) @@ -93,7 +93,7 @@ impl<'a> FileLines<'a> { } } - fn match_prefix_generic(pfx: &str, line: &str, exact: bool) -> (bool, uint) { + fn match_prefix_generic(pfx: &str, line: &str, exact: bool) -> (bool, usize) { if line.starts_with(pfx) { return (true, 0); } @@ -112,7 +112,7 @@ impl<'a> FileLines<'a> { (false, 0) } - fn compute_indent(&self, string: &str, prefix_end: uint) -> (uint, uint, uint) { + fn compute_indent(&self, string: &str, prefix_end: usize) -> (usize, usize, usize) { let mut prefix_len = 0; let mut indent_len = 0; let mut indent_end = 0; @@ -199,11 +199,11 @@ impl<'a> Iterator for FileLines<'a> { pub struct Paragraph { lines : Vec, // the lines of the file pub init_str : String, // string representing the init, that is, the first line's indent - pub init_len : uint, // printable length of the init string considering TABWIDTH - init_end : uint, // byte location of end of init in first line String + pub init_len : usize, // printable length of the init string considering TABWIDTH + init_end : usize, // byte location of end of init in first line String pub indent_str : String, // string representing indent - pub indent_len : uint, // length of above - indent_end : uint, // byte location of end of indent (in crown and tagged mode, only applies to 2nd line and onward) + pub indent_len : usize, // length of above + indent_end : usize, // byte location of end of indent (in crown and tagged mode, only applies to 2nd line and onward) pub mail_header : bool // we need to know if this is a mail header because we do word splitting differently in that case } @@ -243,7 +243,7 @@ impl<'a> ParagraphStream<'a> { // header field must be nonzero length if colon_posn == 0 { return false; } - return l_slice.slice_to(colon_posn).chars().all(|x| match x as uint { + return l_slice.slice_to(colon_posn).chars().all(|x| match x as usize { y if y < 33 || y > 126 => false, _ => true }); @@ -446,13 +446,13 @@ impl<'a> ParaWords<'a> { struct WordSplit<'a> { opts : &'a FmtOptions, string : &'a str, - length : uint, - position : uint, + length : usize, + position : usize, prev_punct : bool } impl<'a> WordSplit<'a> { - fn analyze_tabs(&self, string: &str) -> (Option, uint, Option) { + fn analyze_tabs(&self, string: &str) -> (Option, usize, Option) { // given a string, determine (length before tab) and (printed length after first tab) // if there are no tabs, beforetab = -1 and aftertab is the printed length let mut beforetab = None; @@ -494,10 +494,10 @@ impl<'a> WordSplit<'a> { pub struct WordInfo<'a> { pub word : &'a str, - pub word_start : uint, - pub word_nchars : uint, - pub before_tab : Option, - pub after_tab : uint, + pub word_start : usize, + pub word_nchars : usize, + pub before_tab : Option, + pub after_tab : usize, pub sentence_start : bool, pub ends_punct : bool, pub new_line : bool diff --git a/src/fold/fold.rs b/src/fold/fold.rs index c7c6deaeb..ffda8c552 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -62,7 +62,7 @@ pub fn uumain(args: Vec) -> isize { } }; let width = match poss_width { - Some(inp_width) => match inp_width.parse::() { + Some(inp_width) => match inp_width.parse::() { Some(width) => width, None => crash!(1, "illegal width value (\"{}\")", inp_width) }, @@ -91,7 +91,7 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { } #[inline] -fn fold(filenames: Vec, bytes: bool, spaces: bool, width: uint) { +fn fold(filenames: Vec, bytes: bool, spaces: bool, width: usize) { for filename in filenames.iter() { let filename: &str = filename.as_slice(); let mut stdin_buf; @@ -110,7 +110,7 @@ fn fold(filenames: Vec, bytes: bool, spaces: bool, width: uint) { } #[inline] -fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, width: uint) { +fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, width: usize) { let mut file = file; for line in file.lines() { let line_string = safe_unwrap!(line); @@ -156,7 +156,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, match rfind_whitespace(slice) { Some(m) => { let routput = slice.slice_chars(m + 1, slice.chars().count()); - let ncount = routput.chars().fold(0u, |out, ch: char| { + let ncount = routput.chars().fold(0us, |out, ch: char| { out + match ch { '\t' => 8, '\x08' => if out > 0 { -1 } else { 0 }, @@ -215,7 +215,7 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, } #[inline] -fn rfind_whitespace(slice: &str) -> Option { +fn rfind_whitespace(slice: &str) -> Option { for (i, ch) in slice.chars().rev().enumerate() { if ch.is_whitespace() { return Some(slice.chars().count() - (i + 1)); diff --git a/src/head/head.rs b/src/head/head.rs index 965bd2364..c5f0347ad 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -27,8 +27,8 @@ mod util; static NAME: &'static str = "head"; pub fn uumain(args: Vec) -> isize { - let mut line_count = 10u; - let mut byte_count = 0u; + let mut line_count = 10us; + let mut byte_count = 0us; // handle obsolete -number syntax let options = match obsolete(args.tail()) { @@ -68,7 +68,7 @@ pub fn uumain(args: Vec) -> isize { show_error!("cannot specify both --bytes and --lines."); return 1; } - match n.parse::() { + match n.parse::() { Some(m) => { line_count = m } None => { show_error!("invalid line count '{}'", n); @@ -77,7 +77,7 @@ pub fn uumain(args: Vec) -> isize { } } None => match given_options.opt_str("c") { - Some(count) => match count.parse::() { + Some(count) => match count.parse::() { Some(m) => byte_count = m, None => { show_error!("invalid byte count '{}'", count); @@ -131,7 +131,7 @@ pub fn uumain(args: Vec) -> isize { // // In case is found, the options vector will get rid of that object so that // getopts works correctly. -fn obsolete(options: &[String]) -> (Vec, Option) { +fn obsolete(options: &[String]) -> (Vec, Option) { let mut options: Vec = options.to_vec(); let mut a = 0; let b = options.len(); @@ -149,7 +149,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse::(); return (options, Some(number.unwrap())); } } @@ -162,7 +162,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { } // TODO: handle errors on read -fn head(reader: &mut BufferedReader, count: uint, use_bytes: bool) -> bool { +fn head(reader: &mut BufferedReader, count: usize, use_bytes: bool) -> bool { if use_bytes { for byte in reader.bytes().take(count) { if !pipe_print!("{}", byte.unwrap() as char) { diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index 63ac56798..f84ff8987 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -33,7 +33,7 @@ mod util; static NAME: &'static str = "hostid"; static VERSION: &'static str = "0.0.1"; -static EXIT_ERR: int = 1; +static EXIT_ERR: isize = 1; pub enum Mode { HostId, diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 65674873a..572882355 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -130,7 +130,7 @@ fn help_menu(program: &str, options: &[getopts::OptGroup]) { } fn xgethostname() -> String { - let namelen = 256u; + let namelen = 256us; let mut name : Vec = repeat(0).take(namelen).collect(); let err = unsafe { gethostname (name.as_mut_ptr() as *mut libc::c_char, diff --git a/src/kill/kill.rs b/src/kill/kill.rs index f42176237..68d73c2bc 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -39,8 +39,8 @@ mod signals; static NAME: &'static str = "kill"; static VERSION: &'static str = "0.0.1"; -static EXIT_OK: int = 0; -static EXIT_ERR: int = 1; +static EXIT_OK: isize = 0; +static EXIT_ERR: isize = 1; pub enum Mode { Kill, @@ -184,7 +184,7 @@ fn help(progname: &str, usage: &str) { println!("{}", get_help_text(progname, usage)); } -fn kill(signalname: &str, pids: std::vec::Vec) -> int { +fn kill(signalname: &str, pids: std::vec::Vec) -> isize { let mut status = 0; let optional_signal_value = signals::signal_by_name_or_value(signalname); let signal_value = match optional_signal_value { @@ -194,7 +194,7 @@ fn kill(signalname: &str, pids: std::vec::Vec) -> int { for pid in pids.iter() { match pid.as_slice().parse() { Some(x) => { - let result = Process::kill(x, signal_value as int); + let result = Process::kill(x, signal_value as isize); match result { Ok(_) => (), Err(f) => { diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 120c5bd2d..174759974 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -93,7 +93,7 @@ fn print_help(opts: &[getopts::OptGroup]) { /** * Create the list of new directories */ -fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), int> { +fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool) -> Result<(), isize> { let mut result = Ok(()); let mut parent_dirs = Vec::new(); diff --git a/src/mv/mv.rs b/src/mv/mv.rs index e2d68ae0b..73024b138 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -186,7 +186,7 @@ fn help(progname: &str, usage: &str) { println!("{}", msg); } -fn exec(files: &[Path], b: Behaviour) -> int { +fn exec(files: &[Path], b: Behaviour) -> isize { match b.target_dir { Some(ref name) => return move_files_into_dir(files, &Path::new(name.as_slice()), &b), None => {} @@ -244,7 +244,7 @@ fn exec(files: &[Path], b: Behaviour) -> int { 0 } -fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> int { +fn move_files_into_dir(files: &[Path], target_dir: &Path, b: &Behaviour) -> isize { if !target_dir.is_dir() { show_error!("target ‘{}’ is not a directory", target_dir.display()); return 1; diff --git a/src/nl/helper.rs b/src/nl/helper.rs index c68a5d4f6..0b6c4cdf4 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -83,7 +83,7 @@ pub fn parse_options(settings: &mut ::Settings, opts: &getopts::Matches) -> Vec< match opts.opt_str("w") { None => {} Some(val) => { - let conv: Option = val.as_slice().parse(); + let conv: Option = val.as_slice().parse(); match conv { None => { errs.push(String::from_str("Illegal value for -w")); diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 747ae0bbe..415e43571 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -42,7 +42,7 @@ struct Settings { starting_line_number: u64, line_increment: u64, join_blank_lines: u64, - number_width: uint, // Used with String::from_char, hence uint. + number_width: usize, // Used with String::from_char, hence usize. // The format of the number and the (default value for) // renumbering each page. number_format: NumberFormat, @@ -278,7 +278,7 @@ fn nl (reader: &mut BufferedReader, settings: &Settings) { // way, start counting empties from zero once more. empty_line_count = 0; // A line number is to be printed. - let mut w: uint = 0; + let mut w: usize = 0; if settings.number_width > line_no_width { w = settings.number_width - line_no_width; } diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 80a7c08cf..3871b1156 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -77,7 +77,7 @@ fn resolve_path(path: &str, strip: bool, zero: bool, quiet: bool) -> bool { Some(x) => x, }; - let mut links_left = 256i; + let mut links_left = 256is; for part in abs.components() { result.push(part); diff --git a/src/rm/rm.rs b/src/rm/rm.rs index ec45e221e..ccc28d046 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -125,7 +125,7 @@ pub fn uumain(args: Vec) -> isize { } // TODO: implement one-file-system -fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), int> { +fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: bool, preserve_root: bool, recursive: bool, dir: bool, verbose: bool) -> Result<(), isize> { let mut r = Ok(()); for filename in files.iter() { @@ -167,7 +167,7 @@ fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: r } -fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> { +fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) @@ -187,7 +187,7 @@ fn remove_dir(path: &Path, name: &str, interactive: InteractiveMode, verbose: bo Ok(()) } -fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), int> { +fn remove_file(path: &Path, name: &str, interactive: InteractiveMode, verbose: bool) -> Result<(), isize> { let response = if interactive == InteractiveMode::InteractiveAlways { prompt_file(path, name) diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index e16501042..1eba92797 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -65,7 +65,7 @@ pub fn uumain(args: Vec) -> isize { 0 } -fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), int>{ +fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize>{ let mut r = Ok(()); for dir in dirs.iter() { @@ -86,7 +86,7 @@ fn remove(dirs: Vec, ignore: bool, parents: bool, verbose: bool) -> Resu r } -fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), int> { +fn remove_dir(path: &Path, dir: &str, ignore: bool, parents: bool, verbose: bool) -> Result<(), isize> { let mut walk_dir = match fs::walk_dir(path) { Ok(m) => m, Err(f) => { diff --git a/src/seq/seq.rs b/src/seq/seq.rs index 9e4cf2c25..ada3cbc53 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -36,7 +36,7 @@ fn escape_sequences(s: &str) -> String { replace("\\t", "\t") } -fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, int> { +fn parse_options(args: Vec, options: &mut SeqOptions) -> Result, isize> { let mut seq_args = vec!(); let program = args[0].clone(); let mut iter = args.into_iter().skip(1); @@ -215,8 +215,8 @@ fn done_printing(next: f64, step: f64, last: f64) -> bool { } } -fn print_seq(first: f64, step: f64, last: f64, largest_dec: uint, separator: String, terminator: String, pad: bool, padding: uint) { - let mut i = 0i; +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 value = first + i as f64 * step; while !done_printing(value, step, last) { let istr = value.to_string(); diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 3d2cd1d4c..29163453c 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -17,7 +17,7 @@ use std::io; use std::io::IoResult; use std::iter::{range_inclusive, RangeInclusive}; use std::rand::{self, Rng}; -use std::uint; +use std::usize; #[path = "../common/util.rs"] #[macro_use] @@ -26,7 +26,7 @@ mod util; enum Mode { Default, Echo, - InputRange(RangeInclusive) + InputRange(RangeInclusive) } static NAME: &'static str = "shuf"; @@ -95,14 +95,14 @@ With no FILE, or when FILE is -, read standard input.", let repeat = matches.opt_present("repeat"); let zero = matches.opt_present("zero-terminated"); let count = match matches.opt_str("head-count") { - Some(cnt) => match cnt.parse::() { + Some(cnt) => match cnt.parse::() { Some(val) => val, None => { show_error!("'{}' is not a valid count", cnt); return 1; } }, - None => uint::MAX + None => usize::MAX }; let output = matches.opt_str("output"); let random = matches.opt_str("random-source"); @@ -118,7 +118,7 @@ With no FILE, or when FILE is -, read standard input.", 0 } -fn shuf(input: Vec, mode: Mode, repeat: bool, zero: bool, count: uint, output: Option, random: Option) -> IoResult<()> { +fn shuf(input: Vec, mode: Mode, repeat: bool, zero: bool, count: usize, output: Option, random: Option) -> IoResult<()> { match mode { Mode::Echo => shuf_lines(input, repeat, zero, count, output, random), Mode::InputRange(range) => shuf_lines(range.map(|num| num.to_string()).collect(), repeat, zero, count, output, random), @@ -163,7 +163,7 @@ impl WrappedRng { } } -fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, outname: Option, random: Option) -> IoResult<()> { +fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: usize, outname: Option, random: Option) -> IoResult<()> { let mut output = match outname { Some(name) => Box::new(io::BufferedWriter::new(try!(io::File::create(&Path::new(name))))) as Box, None => Box::new(io::stdout()) as Box @@ -175,7 +175,7 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, out let mut len = lines.len(); let max = if repeat { count } else { cmp::min(count, len) }; for _ in range(0, max) { - let idx = rng.next_u32() as uint % len; + let idx = rng.next_u32() as usize % len; try!(write!(output, "{}{}", lines[idx], if zero { '\0' } else { '\n' })); if !repeat { lines.remove(idx); @@ -185,16 +185,16 @@ fn shuf_lines(mut lines: Vec, repeat: bool, zero: bool, count: uint, out Ok(()) } -fn parse_range(input_range: String) -> Result, (String, int)> { +fn parse_range(input_range: String) -> Result, (String, isize)> { let split: Vec<&str> = input_range.as_slice().split('-').collect(); if split.len() != 2 { Err(("invalid range format".to_string(), 1)) } else { - let begin = match split[0].parse::() { + let begin = match split[0].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[0]), 1)) }; - let end = match split[1].parse::() { + let end = match split[1].parse::() { Some(m) => m, None => return Err((format!("{} is not a valid number", split[1]), 1)) }; diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 68be324c8..27fe680f9 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -132,7 +132,7 @@ fn frac_compare(a: &String, b: &String) -> Ordering { } } if char_a.is_digit(10) && char_b.is_digit(10) { - (char_a as int).cmp(&(char_b as int)) + (char_a as isize).cmp(&(char_b as isize)) } else if char_a.is_digit(10) { skip_zeros(char_a, a_chars, Ordering::Greater) } else if char_b.is_digit(10) { diff --git a/src/sync/sync.rs b/src/sync/sync.rs index daad1ba4c..8d3c51307 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -28,7 +28,7 @@ mod platform { fn sync() -> libc::c_void; } - pub unsafe fn do_sync() -> int { + pub unsafe fn do_sync() -> isize { sync(); 0 } @@ -177,7 +177,7 @@ fn help(program: &str, options: &[getopts::OptGroup]) { print!("{}", usage("Force changed blocks to disk, update the super block.", options)); } -fn uusync() -> int { +fn uusync() -> isize { unsafe { platform::do_sync() } diff --git a/src/tail/tail.rs b/src/tail/tail.rs index 532f263cc..c9b240063 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -32,8 +32,8 @@ static VERSION: &'static str = "0.0.1"; pub fn uumain(args: Vec) -> isize { let mut beginning = false; let mut lines = true; - let mut byte_count = 0u; - let mut line_count = 10u; + let mut byte_count = 0us; + let mut line_count = 10us; let mut sleep_msec = 1000u64; // handle obsolete -number syntax @@ -147,33 +147,33 @@ pub fn uumain(args: Vec) -> isize { 0 } -fn parse_size(mut size_slice: &str) -> Option { +fn parse_size(mut size_slice: &str) -> Option { let mut base = if size_slice.len() > 0 && size_slice.char_at(size_slice.len() - 1) == 'B' { size_slice = size_slice.slice_to(size_slice.len() - 1); - 1000u + 1000us } else { - 1024u + 1024us }; let exponent = if size_slice.len() > 0 { let mut has_suffix = true; let exp = match size_slice.char_at(size_slice.len() - 1) { - 'K' => 1u, - 'M' => 2u, - 'G' => 3u, - 'T' => 4u, - 'P' => 5u, - 'E' => 6u, - 'Z' => 7u, - 'Y' => 8u, + 'K' => 1us, + 'M' => 2us, + 'G' => 3us, + 'T' => 4us, + 'P' => 5us, + 'E' => 6us, + 'Z' => 7us, + 'Y' => 8us, 'b' => { - base = 512u; - 1u + base = 512us; + 1us } _ => { has_suffix = false; - 0u + 0us } }; if has_suffix { @@ -181,14 +181,14 @@ fn parse_size(mut size_slice: &str) -> Option { } exp } else { - 0u + 0us }; - let mut multiplier = 1u; - for _ in range(0u, exponent) { + let mut multiplier = 1us; + for _ in range(0us, exponent) { multiplier *= base; } - if base == 1000u && exponent == 0u { + if base == 1000us && exponent == 0us { // sole B is not a valid suffix None } else { @@ -204,7 +204,7 @@ fn parse_size(mut size_slice: &str) -> Option { // // In case is found, the options vector will get rid of that object so that // getopts works correctly. -fn obsolete(options: &[String]) -> (Vec, Option) { +fn obsolete(options: &[String]) -> (Vec, Option) { let mut options: Vec = options.to_vec(); let mut a = 0; let b = options.len(); @@ -222,7 +222,7 @@ fn obsolete(options: &[String]) -> (Vec, Option) { // If this is the last number if pos == len - 1 { options.remove(a); - let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); + let number: Option = from_utf8(current.slice(1,len)).unwrap().parse(); return (options, Some(number.unwrap())); } } @@ -243,7 +243,7 @@ macro_rules! tail_impl ( let mut data = $reader.$kindfn().skip( if $beginning { let temp = $count; - $count = ::std::uint::MAX; + $count = ::std::usize::MAX; temp - 1 } else { 0 @@ -267,7 +267,7 @@ macro_rules! tail_impl ( }) ); -fn tail(reader: &mut BufferedReader, mut line_count: uint, mut byte_count: uint, beginning: bool, lines: bool, follow: bool, sleep_msec: u64) { +fn tail(reader: &mut BufferedReader, mut line_count: usize, mut byte_count: usize, beginning: bool, lines: bool, follow: bool, sleep_msec: u64) { if lines { tail_impl!(String, lines, print_string, reader, line_count, beginning); } else { diff --git a/src/test/test.rs b/src/test/test.rs index be9721b0d..8d5742785 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -39,7 +39,7 @@ pub fn uumain(_: Vec) -> isize { _ => args.slice(1, args.len()), }; let mut error = false; - let retval = 1 - parse_expr(args, &mut error) as int; + let retval = 1 - parse_expr(args, &mut error) as isize; if error { 2 } else { @@ -160,7 +160,7 @@ fn dispatch(args: &mut &[&[u8]], error: &mut bool) -> bool { val } -fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = two(*args, error); if *error { *error = false; @@ -170,7 +170,7 @@ fn dispatch_two(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { } } -fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = three(*args, error); if *error { *error = false; @@ -180,7 +180,7 @@ fn dispatch_three(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { } } -fn dispatch_four(args: &mut &[&[u8]], error: &mut bool) -> (bool, uint) { +fn dispatch_four(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { let val = four(*args, error); if *error { *error = false; @@ -226,7 +226,7 @@ fn parse_expr_helper<'a>(hashmap: &HashMap<&'a [u8], Precedence>, *error = true; &min_prec }); - while !*error && args.len() > 0 && prec as uint >= min_prec as uint { + while !*error && args.len() > 0 && prec as usize >= min_prec as usize { let op = args[0]; *args = (*args).slice_from(1); let mut rhs = dispatch(args, error); @@ -235,7 +235,7 @@ fn parse_expr_helper<'a>(hashmap: &HashMap<&'a [u8], Precedence>, *error = true; &min_prec }); - if subprec as uint <= prec as uint || *error { + if subprec as usize <= prec as usize || *error { break; } rhs = parse_expr_helper(hashmap, args, rhs, subprec, error); diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index 3462b8cb3..eb89dd435 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -32,7 +32,7 @@ extern { static NAME: &'static str = "timeout"; static VERSION: &'static str = "1.0.0"; -static ERR_EXIT_STATUS: int = 125; +static ERR_EXIT_STATUS: isize = 125; pub fn uumain(args: Vec) -> isize { let program = args[0].clone(); @@ -100,7 +100,7 @@ Usage: 0 } -fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_after: f64, foreground: bool, preserve_status: bool) -> int { +fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_after: f64, foreground: bool, preserve_status: bool) -> isize { if !foreground { unsafe { setpgid(0, 0) }; } @@ -128,7 +128,7 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_aft ExitSignal(stat) => stat }, Err(_) => { - return_if_err!(ERR_EXIT_STATUS, process.signal(signal as int)); + return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize)); process.set_timeout(Some((kill_after * 1000f64) as u64)); match process.wait() { Ok(status) => { @@ -146,7 +146,7 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: uint, kill_aft // XXX: this may not be right return 124; } - return_if_err!(ERR_EXIT_STATUS, process.signal(signals::signal_by_name_or_value("KILL").unwrap() as int)); + return_if_err!(ERR_EXIT_STATUS, process.signal(signals::signal_by_name_or_value("KILL").unwrap() as isize)); process.set_timeout(None); return_if_err!(ERR_EXIT_STATUS, process.wait()); 137 diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 76cac158a..533b9de6a 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -99,7 +99,7 @@ file based on its current size: 0 } -fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), int> { +fn truncate(no_create: bool, _: bool, reference: Option, size: Option, filenames: Vec) -> Result<(), isize> { let (refsize, mode) = match reference { Some(rfilename) => { let rfile = match File::open(&Path::new(rfilename.clone())) { diff --git a/src/tty/tty.rs b/src/tty/tty.rs index fd366c861..2d1e3dcc4 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -74,7 +74,7 @@ pub fn uumain(args: Vec) -> isize { } }; - exit_code as int + exit_code as isize } fn usage () { diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 1246234f0..98a43d6aa 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -29,8 +29,8 @@ struct Uniq { all_repeated: bool, delimiters: String, show_counts: bool, - slice_start: Option, - slice_stop: Option, + slice_start: Option, + slice_stop: Option, ignore_case: bool, } @@ -96,7 +96,7 @@ impl Uniq { first_line_printed } - fn print_line(&self, writer: &mut io::BufferedWriter, line: &String, count: uint, print_delimiter: bool) { + fn print_line(&self, writer: &mut io::BufferedWriter, line: &String, count: usize, print_delimiter: bool) { let output_line = if self.show_counts { format!("{:7} {}", count, line) } else { diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index 5e127c853..ff5f7630a 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -98,14 +98,14 @@ fn print_loadavg() { else { print!("load average: "); for n in range(0, loads) { - print!("{:.2}{}", avg[n as uint], if n == loads - 1 { "\n" } + print!("{:.2}{}", avg[n as usize], if n == loads - 1 { "\n" } else { ", " } ); } } } #[cfg(unix)] -fn process_utmpx() -> (Option, uint) { +fn process_utmpx() -> (Option, usize) { unsafe { utmpxname(CString::from_slice(DEFAULT_FILE.as_bytes()).as_ptr()); } @@ -142,11 +142,11 @@ fn process_utmpx() -> (Option, uint) { } #[cfg(windows)] -fn process_utmpx() -> (Option, uint) { +fn process_utmpx() -> (Option, usize) { (None, 0) // TODO: change 0 to number of users } -fn print_nusers(nusers: uint) { +fn print_nusers(nusers: usize) { if nusers == 1 { print!("1 user, "); } else if nusers > 1 { diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 056a31d64..c42f43bb5 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -19,13 +19,13 @@ use std::collections::hash_map::HashMap; static NAME: &'static str = "uutils"; static VERSION: &'static str = "1.0.0"; -fn util_map() -> HashMap<&'static str, fn(Vec) -> int> { +fn util_map() -> HashMap<&'static str, fn(Vec) -> isize> { let mut map = HashMap::new(); @UTIL_MAP@ map } -fn usage(cmap: &HashMap<&'static str, fn(Vec) -> int>) { +fn usage(cmap: &HashMap<&'static str, fn(Vec) -> isize>) { println!("{} {}", NAME, VERSION); println!(""); println!("Usage:"); diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 84498e02a..81de3567a 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -26,11 +26,11 @@ mod util; struct Result { filename: String, - bytes: uint, - chars: uint, - lines: uint, - words: uint, - max_line_length: uint, + bytes: usize, + chars: usize, + lines: usize, + words: usize, + max_line_length: usize, } static NAME: &'static str = "wc"; @@ -94,25 +94,25 @@ fn is_word_seperator(byte: u8) -> bool { byte == SPACE || byte == TAB || byte == CR || byte == SYN || byte == FF } -pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), int> { - let mut total_line_count: uint = 0; - let mut total_word_count: uint = 0; - let mut total_char_count: uint = 0; - let mut total_byte_count: uint = 0; - let mut total_longest_line_length: uint = 0; +pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), isize> { + let mut total_line_count: usize = 0; + let mut total_word_count: usize = 0; + let mut total_char_count: usize = 0; + let mut total_byte_count: usize = 0; + let mut total_longest_line_length: usize = 0; let mut results = vec!(); - let mut max_str_len: uint = 0; + let mut max_str_len: usize = 0; for path in files.iter() { let mut reader = try!(open(path.as_slice())); - let mut line_count: uint = 0; - let mut word_count: uint = 0; - let mut byte_count: uint = 0; - let mut char_count: uint = 0; - let mut current_char_count: uint = 0; - let mut longest_line_length: uint = 0; + let mut line_count: usize = 0; + let mut word_count: usize = 0; + let mut byte_count: usize = 0; + let mut char_count: usize = 0; + let mut current_char_count: usize = 0; + let mut longest_line_length: usize = 0; loop { // reading from a TTY seems to raise a condition on, rather than return Some(0) like a file. @@ -191,8 +191,8 @@ pub fn wc(files: Vec, matches: &Matches) -> StdResult<(), int> { Ok(()) } -fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: uint, - byte_count: uint, longest_line_length: uint, matches: &Matches, max_str_len: uint) { +fn print_stats(filename: &str, line_count: usize, word_count: usize, char_count: usize, + byte_count: usize, longest_line_length: usize, matches: &Matches, max_str_len: usize) { if matches.opt_present("lines") { print!("{:1$}", line_count, max_str_len); } @@ -228,7 +228,7 @@ fn print_stats(filename: &str, line_count: uint, word_count: uint, char_count: u } } -fn open(path: &str) -> StdResult>, int> { +fn open(path: &str) -> StdResult>, isize> { if "-" == path { let reader = Box::new(stdin_raw()) as Box; return Ok(BufferedReader::new(reader)); From 8e430d6952f66bc6d0fdc7843cb8ce7373595c7d Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:25:33 +0100 Subject: [PATCH 05/12] nl: fix build --- src/nl/helper.rs | 3 ++- src/nl/nl.rs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nl/helper.rs b/src/nl/helper.rs index 0b6c4cdf4..7b8cc66d9 100644 --- a/src/nl/helper.rs +++ b/src/nl/helper.rs @@ -8,7 +8,8 @@ fn parse_style(chars: &[char]) -> Result<::NumberingStyle, String> { ['t'] => { Ok(::NumberingStyle::NumberForNonEmpty) }, ['n'] => { Ok(::NumberingStyle::NumberForNone) }, ['p', rest..] => { - match regex::Regex::new(String::from_chars(rest).as_slice()) { + let s : String = rest.iter().map(|c| *c).collect(); + match regex::Regex::new(s.as_slice()) { Ok(re) => Ok(::NumberingStyle::NumberForRegularExpression(re)), Err(_) => Err(String::from_str("Illegal regular expression")), } diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 415e43571..3fe6ea9b2 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -8,14 +8,16 @@ * file that was distributed with this source code. * */ +#![feature(plugin)] -#[macro_use] extern crate regex_macros; +#[plugin] extern crate regex_macros; extern crate regex; extern crate getopts; use std::io::{stdin}; use std::io::BufferedReader; use std::io::fs::File; +use std::iter::repeat; use std::num::Int; use std::path::Path; use getopts::{optopt, optflag, getopts, usage, OptGroup}; @@ -282,7 +284,7 @@ fn nl (reader: &mut BufferedReader, settings: &Settings) { if settings.number_width > line_no_width { w = settings.number_width - line_no_width; } - let fill = String::from_char(w, fill_char); + let fill : String = repeat(fill_char).take(w).collect(); match settings.number_format { NumberFormat::Left => { println!("{1}{0}{2}{3}", fill, line_no, settings.number_separator, line) From e142b4f23ede56a4cb95f2121a4bf56d6896d528 Mon Sep 17 00:00:00 2001 From: Arcterus Date: Fri, 9 Jan 2015 17:20:40 -0800 Subject: [PATCH 06/12] env, expand, fmt: fix build --- src/env/env.rs | 1 + src/expand/expand.rs | 2 ++ src/fmt/fmt.rs | 3 +++ src/fmt/linebreak.rs | 16 ++++++++-------- src/fmt/parasplit.rs | 21 ++++++++++++++------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/env/env.rs b/src/env/env.rs index cc67f1ab4..d2efd5e86 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -12,6 +12,7 @@ /* last synced with: env (GNU coreutils) 8.13 */ #![allow(non_camel_case_types)] +#![feature(box_syntax)] struct options { ignore_env: bool, diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 94ae03e92..716591391 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +#![feature(box_syntax)] + extern crate getopts; extern crate libc; diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 51673ee0c..0ca41b8d5 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -8,8 +8,11 @@ * file that was distributed with this source code. */ +#![feature(box_syntax)] + extern crate core; extern crate getopts; +extern crate unicode; use std::cmp; use std::io::{BufferedReader, BufferedWriter, File, IoResult}; diff --git a/src/fmt/linebreak.rs b/src/fmt/linebreak.rs index 9e1451085..f4d06b44d 100644 --- a/src/fmt/linebreak.rs +++ b/src/fmt/linebreak.rs @@ -94,7 +94,7 @@ pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut Box>>(iter: T, args: &mut BreakArgs<'a>) { +fn break_simple<'a, T: Iterator>>(iter: T, args: &mut BreakArgs<'a>) { iter.fold((args.init_len, false), |l, winfo| accum_words_simple(args, l, winfo)); silent_unwrap!(args.ostream.write_char('\n')); } @@ -120,7 +120,7 @@ fn accum_words_simple<'a>(args: &mut BreakArgs<'a>, (l, prev_punct): (usize, boo // Knuth, D.E., and Plass, M.F. "Breaking Paragraphs into Lines." in Software, // Practice and Experience. Vol. 11, No. 11, November 1981. // http://onlinelibrary.wiley.com/doi/10.1002/spe.4380111102/pdf -fn break_knuth_plass<'a, T: Clone + Iterator<&'a WordInfo<'a>>>(mut iter: T, args: &mut BreakArgs<'a>) { +fn break_knuth_plass<'a, T: Clone + Iterator>>(mut iter: T, args: &mut BreakArgs<'a>) { // run the algorithm to get the breakpoints let breakpoints = find_kp_breakpoints(iter.clone(), args); @@ -183,7 +183,7 @@ struct LineBreak<'a> { fresh : bool } -fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakArgs<'a>) -> Vec<(&'a WordInfo<'a>, bool)> { +fn find_kp_breakpoints<'a, T: Iterator>>(iter: T, args: &BreakArgs<'a>) -> Vec<(&'a WordInfo<'a>, bool)> { let mut iter = iter.peekable(); // set up the initial null linebreak let mut linebreaks = vec!(LineBreak { @@ -199,7 +199,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA let active_breaks = &mut vec!(0); let next_active_breaks = &mut vec!(); - let stretch = (args.opts.width - args.opts.goal) as int; + let stretch = (args.opts.width - args.opts.goal) as isize; let minlength = args.opts.goal - stretch as usize; let mut new_linebreaks = vec!(); let mut is_sentence_start = false; @@ -256,7 +256,7 @@ fn find_kp_breakpoints<'a, T: Iterator<&'a WordInfo<'a>>>(iter: T, args: &BreakA // there is no penalty for the final line's length (0, 0.0) } else { - compute_demerits((args.opts.goal - tlen) as int, stretch, w.word_nchars as int, active.prev_rat) + compute_demerits((args.opts.goal - tlen) as isize, stretch, w.word_nchars as isize, active.prev_rat) }; // do not even consider adding a line that has too many demerits @@ -344,7 +344,7 @@ const DR_MULT: f32 = 600.0; const DL_MULT: f32 = 300.0; #[inline(always)] -fn compute_demerits(delta_len: int, stretch: int, wlen: int, prev_rat: f32) -> (i64, f32) { +fn compute_demerits(delta_len: isize, stretch: isize, wlen: isize, prev_rat: f32) -> (i64, f32) { // how much stretch are we using? let ratio = if delta_len == 0 { @@ -386,8 +386,8 @@ fn restart_active_breaks<'a>(args: &BreakArgs<'a>, active: &LineBreak<'a>, act_i } else { // choose the lesser evil: breaking too early, or breaking too late let wlen = w.word_nchars + args.compute_width(w, active.length, active.fresh); - let underlen: int = (min - active.length) as int; - let overlen: int = ((wlen + slen + active.length) - args.opts.width) as int; + let underlen = (min - active.length) as isize; + let overlen = ((wlen + slen + active.length) - args.opts.width) as isize; if overlen > underlen { // break early, put this word on the next line (true, args.indent_len + w.word_nchars) diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index b36a58ac2..749c160fc 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -11,6 +11,7 @@ use core::iter::Peekable; use std::io::Lines; use std::slice::Iter; use std::str::CharRange; +use unicode::str::UnicodeStr; use FileOrStdReader; use FmtOptions; @@ -78,7 +79,7 @@ impl<'a> FileLines<'a> { // returns true if this line should be formatted fn match_prefix(&self, line: &str) -> (bool, usize) { - if !self.opts.use_prefix { return (true, 0u); } + if !self.opts.use_prefix { return (true, 0); } FileLines::match_prefix_generic(self.opts.prefix.as_slice(), line, self.opts.xprefix) } @@ -100,7 +101,7 @@ impl<'a> FileLines<'a> { if !exact { // we do it this way rather than byte indexing to support unicode whitespace chars - let mut i = 0u; + let mut i = 0; while (i < line.len()) && line.char_at(i).is_whitespace() { i = match line.char_range_at(i) { CharRange { ch: _ , next: nxi } => nxi }; if line.slice_from(i).starts_with(pfx) { @@ -138,7 +139,9 @@ impl<'a> FileLines<'a> { } } -impl<'a> Iterator for FileLines<'a> { +impl<'a> Iterator for FileLines<'a> { + type Item = Line; + fn next(&mut self) -> Option { let n = match self.lines.next() { @@ -252,7 +255,9 @@ impl<'a> ParagraphStream<'a> { } } -impl<'a> Iterator> for ParagraphStream<'a> { +impl<'a> Iterator for ParagraphStream<'a> { + type Item = Result; + fn next(&mut self) -> Option> { // return a NoFormatLine in an Err; it should immediately be output let noformat = @@ -410,7 +415,7 @@ impl<'a> ParaWords<'a> { // no extra spacing for mail headers; always exactly 1 space // safe to trim_left on every line of a mail header, since the // first line is guaranteed not to have any spaces - self.words.extend(self.para.lines.iter().flat_map(|x| x.as_slice().words()).map(|x| WordInfo { + self.words.extend(self.para.lines.iter().flat_map(|x| StrExt::words(x.as_slice())).map(|x| WordInfo { word : x, word_start : 0, word_nchars : x.len(), // OK for mail headers; only ASCII allowed (unicode is escaped) @@ -480,7 +485,7 @@ impl<'a> WordSplit<'a> { impl<'a> WordSplit<'a> { fn new<'b>(opts: &'b FmtOptions, string: &'b str) -> WordSplit<'b> { // wordsplits *must* start at a non-whitespace character - let trim_string = string.trim_left(); + let trim_string = StrExt::trim_left(string); WordSplit { opts: opts, string: trim_string, length: string.len(), position: 0, prev_punct: false } } @@ -504,7 +509,9 @@ pub struct WordInfo<'a> { } // returns (&str, is_start_of_sentence) -impl<'a> Iterator> for WordSplit<'a> { +impl<'a> Iterator for WordSplit<'a> { + type Item = WordInfo<'a>; + fn next(&mut self) -> Option> { if self.position >= self.length { return None From 1604c361b9d40da942b9344dbbf883d505401a5c Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:38:03 +0100 Subject: [PATCH 07/12] make: copy additional dependencies of rust-crypto --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 706f38efd..f56c504e6 100644 --- a/Makefile +++ b/Makefile @@ -224,6 +224,7 @@ $(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS # Dependencies $(BUILDDIR)/.rust-crypto: $(BUILDDIR)/.rust-time | $(BUILDDIR) cd $(BASEDIR)/deps/rust-crypto && $(CARGO) build --release + cp -r $(BASEDIR)/deps/rust-crypto/target/release/deps/lib{time,rustc-serialize}*.rlib $(BUILDDIR) cp -r $(BASEDIR)/deps/rust-crypto/target/release/libcrypto*.rlib $(BUILDDIR)/libcrypto.rlib @touch $@ From fd2536fc578c07a91bd724a74ababf4aeed2e3cb Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:54:42 +0100 Subject: [PATCH 08/12] mv, sort, truncate: fix test build --- test/mv.rs | 14 ++++---------- test/sort.rs | 4 ++-- test/truncate.rs | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/test/mv.rs b/test/mv.rs index b5d5916a8..2302afbca 100644 --- a/test/mv.rs +++ b/test/mv.rs @@ -30,11 +30,11 @@ fn run(cmd: &mut Command) -> CmdResult { stdout: from_utf8(prog.output.as_slice()).unwrap().to_owned(), } } -fn run_interactive(cmd: &mut Command, f: |&mut PipeStream|) -> CmdResult { +fn run_interactive(cmd: &mut Command, input: &[u8])-> CmdResult { let stdin_cfg = process::CreatePipe(true, false); let mut command = cmd.stdin(stdin_cfg).spawn().unwrap(); - f(command.stdin.as_mut().unwrap()); + command.stdin.as_mut().unwrap().write(input); let prog = command.wait_with_output().unwrap(); CmdResult { @@ -140,10 +140,7 @@ fn test_mv_interactive() { touch(file_b); - let ia1 = |stdin: &mut PipeStream| { - stdin.write(b"n").unwrap(); - }; - let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia1); + let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"n"); assert_empty_stderr!(result1); assert!(result1.success); @@ -152,10 +149,7 @@ fn test_mv_interactive() { assert!(Path::new(file_b).is_file()); - let ia2 = |stdin: &mut PipeStream| { - stdin.write(b"Yesh").unwrap(); - }; - let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia2); + let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"Yesh"); assert_empty_stderr!(result2); assert!(result2.success); diff --git a/test/sort.rs b/test/sort.rs index 292a63e44..eeaf65f0f 100644 --- a/test/sort.rs +++ b/test/sort.rs @@ -29,7 +29,7 @@ fn numeric5() { numeric_helper(5); } -fn numeric_helper(test_num: int) { +fn numeric_helper(test_num: isize) { let mut cmd = Command::new(PROGNAME); cmd.arg("-n"); let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() { @@ -42,5 +42,5 @@ fn numeric_helper(test_num: int) { Ok(answer) => answer, Err(err) => panic!("{}", err), }; - assert_eq!(String::from_utf8(po.output), String::from_utf8(answer)); + assert_eq!(String::from_utf8(po.output).unwrap(), String::from_utf8(answer).unwrap()); } diff --git a/test/truncate.rs b/test/truncate.rs index 2bdcea8a0..067716fd2 100644 --- a/test/truncate.rs +++ b/test/truncate.rs @@ -34,7 +34,7 @@ fn test_decrease_file_size() { } file.seek(0, io::SeekEnd).unwrap(); if file.tell().unwrap() != 6 { - println!("{}", file.tell()); + println!("{:?}", file.tell()); panic!(); } io::fs::unlink(&Path::new(TFILE2)).unwrap(); From 4d6cbfa39367db09f7b2dced4eddea798ae11316 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 20:31:55 +0100 Subject: [PATCH 09/12] Disable unstable warnings for now --- mkmain.rs | 3 +++ mkuutils.rs | 2 ++ src/base64/base64.rs | 1 + src/basename/basename.rs | 1 + src/cat/cat.rs | 2 ++ src/chmod/chmod.rs | 1 + src/chroot/chroot.rs | 2 ++ src/cksum/cksum.rs | 1 + src/comm/comm.rs | 1 + src/cp/cp.rs | 1 + src/cut/cut.rs | 1 + src/dirname/dirname.rs | 1 + src/du/du.rs | 1 + src/echo/echo.rs | 1 + src/env/env.rs | 1 + src/expand/expand.rs | 1 + src/factor/factor.rs | 1 + src/false/false.rs | 1 + src/fmt/fmt.rs | 2 ++ src/fold/fold.rs | 1 + src/groups/groups.rs | 2 ++ src/hashsum/hashsum.rs | 1 + src/head/head.rs | 2 ++ src/hostid/hostid.rs | 1 + src/hostname/hostname.rs | 2 ++ src/id/id.rs | 1 + src/kill/kill.rs | 1 + src/link/link.rs | 1 + src/logname/logname.rs | 1 + src/mkdir/mkdir.rs | 1 + src/mkfifo/mkfifo.rs | 1 + src/mv/mv.rs | 1 + src/nice/nice.rs | 1 + src/nl/nl.rs | 2 ++ src/nohup/nohup.rs | 1 + src/nproc/nproc.rs | 1 + src/paste/paste.rs | 1 + src/printenv/printenv.rs | 1 + src/pwd/pwd.rs | 1 + src/realpath/realpath.rs | 1 + src/relpath/relpath.rs | 1 + src/rm/rm.rs | 1 + src/rmdir/rmdir.rs | 1 + src/seq/seq.rs | 1 + src/shuf/shuf.rs | 1 + src/sleep/sleep.rs | 1 + src/sort/sort.rs | 1 + src/split/split.rs | 1 + src/sum/sum.rs | 1 + src/sync/sync.rs | 2 ++ src/tac/tac.rs | 1 + src/tail/tail.rs | 2 ++ src/tee/tee.rs | 2 ++ src/test/test.rs | 1 + src/timeout/timeout.rs | 1 + src/touch/touch.rs | 1 + src/tr/tr.rs | 1 + src/true/true.rs | 1 + src/truncate/truncate.rs | 1 + src/tsort/tsort.rs | 1 + src/tty/tty.rs | 2 +- src/uname/uname.rs | 1 + src/unexpand/unexpand.rs | 1 + src/uniq/uniq.rs | 2 ++ src/unlink/unlink.rs | 1 + src/uptime/uptime.rs | 1 + src/users/users.rs | 1 + src/uutils/uutils.rs | 1 + src/wc/wc.rs | 1 + src/whoami/whoami.rs | 1 + src/yes/yes.rs | 1 + test/cat.rs | 2 ++ test/cp.rs | 2 ++ test/mkdir.rs | 2 ++ test/mv.rs | 2 ++ test/nl.rs | 2 ++ test/seq.rs | 2 ++ test/sort.rs | 2 ++ test/test.rs | 2 ++ test/tr.rs | 2 ++ test/truncate.rs | 2 ++ test/unexpand.rs | 2 ++ 82 files changed, 107 insertions(+), 1 deletion(-) diff --git a/mkmain.rs b/mkmain.rs index 34a0abbad..54efa3654 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -1,8 +1,11 @@ +#![allow(unstable)] + use std::io::{File, Truncate, ReadWrite}; use std::os; use std::path::Path; static TEMPLATE: &'static str = "\ +#![allow(unstable)] extern crate @UTIL_CRATE@; use std::os; diff --git a/mkuutils.rs b/mkuutils.rs index 7572dad2c..c886f16d7 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::{File, Truncate, Write}; use std::os; use std::path::Path; diff --git a/src/base64/base64.rs b/src/base64/base64.rs index 5af887749..d677554dc 100644 --- a/src/base64/base64.rs +++ b/src/base64/base64.rs @@ -1,4 +1,5 @@ #![crate_name = "base64"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/basename/basename.rs b/src/basename/basename.rs index 71892a516..869fb3e67 100644 --- a/src/basename/basename.rs +++ b/src/basename/basename.rs @@ -1,4 +1,5 @@ #![crate_name = "basename"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/cat/cat.rs b/src/cat/cat.rs index dc6eff13a..4c5df43e6 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -1,4 +1,6 @@ #![crate_name = "cat"] +#![allow(unstable)] + #![feature(box_syntax, unsafe_destructor)] /* diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index 2f57e33b7..a34dd201e 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -1,4 +1,5 @@ #![crate_name = "chmod"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/chroot/chroot.rs b/src/chroot/chroot.rs index db7e4a2bb..64a65d154 100644 --- a/src/chroot/chroot.rs +++ b/src/chroot/chroot.rs @@ -1,4 +1,6 @@ #![crate_name = "chroot"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/cksum/cksum.rs b/src/cksum/cksum.rs index 7200b133e..08ea19131 100644 --- a/src/cksum/cksum.rs +++ b/src/cksum/cksum.rs @@ -1,4 +1,5 @@ #![crate_name = "cksum"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/comm/comm.rs b/src/comm/comm.rs index 16f04072b..aef40bbfb 100644 --- a/src/comm/comm.rs +++ b/src/comm/comm.rs @@ -1,4 +1,5 @@ #![crate_name = "comm"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/cp/cp.rs b/src/cp/cp.rs index a9d8e4f5b..6416f71bc 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -1,4 +1,5 @@ #![crate_name = "cp"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/cut/cut.rs b/src/cut/cut.rs index 3fc634a54..b5f3b2be9 100644 --- a/src/cut/cut.rs +++ b/src/cut/cut.rs @@ -1,4 +1,5 @@ #![crate_name = "cut"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/dirname/dirname.rs b/src/dirname/dirname.rs index 6f88a8268..56869fc80 100644 --- a/src/dirname/dirname.rs +++ b/src/dirname/dirname.rs @@ -1,4 +1,5 @@ #![crate_name = "dirname"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/du/du.rs b/src/du/du.rs index ec8e32856..740a82e31 100644 --- a/src/du/du.rs +++ b/src/du/du.rs @@ -1,4 +1,5 @@ #![crate_name = "du"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/echo/echo.rs b/src/echo/echo.rs index 2ba4f39da..661162d7a 100644 --- a/src/echo/echo.rs +++ b/src/echo/echo.rs @@ -1,4 +1,5 @@ #![crate_name = "echo"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/env/env.rs b/src/env/env.rs index d2efd5e86..595711e4c 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -1,4 +1,5 @@ #![crate_name = "env"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/expand/expand.rs b/src/expand/expand.rs index 716591391..a1fcce9b9 100644 --- a/src/expand/expand.rs +++ b/src/expand/expand.rs @@ -1,4 +1,5 @@ #![crate_name = "expand"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/factor/factor.rs b/src/factor/factor.rs index b66bf2055..7581af446 100644 --- a/src/factor/factor.rs +++ b/src/factor/factor.rs @@ -1,4 +1,5 @@ #![crate_name = "factor"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/false/false.rs b/src/false/false.rs index 68c3ed16e..abb81295c 100644 --- a/src/false/false.rs +++ b/src/false/false.rs @@ -1,4 +1,5 @@ #![crate_name = "uufalse"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 0ca41b8d5..c6e42b89d 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -1,4 +1,6 @@ #![crate_name = "fmt"] +#![allow(unstable)] + /* * This file is part of `fmt` from the uutils coreutils package. * diff --git a/src/fold/fold.rs b/src/fold/fold.rs index ffda8c552..778303d87 100644 --- a/src/fold/fold.rs +++ b/src/fold/fold.rs @@ -1,4 +1,5 @@ #![crate_name = "fold"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/groups/groups.rs b/src/groups/groups.rs index 29c3a755b..f22773f60 100644 --- a/src/groups/groups.rs +++ b/src/groups/groups.rs @@ -1,4 +1,6 @@ #![crate_name = "groups"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/hashsum/hashsum.rs b/src/hashsum/hashsum.rs index e055b8f2b..c88e0f008 100644 --- a/src/hashsum/hashsum.rs +++ b/src/hashsum/hashsum.rs @@ -1,4 +1,5 @@ #![crate_name = "hashsum"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/head/head.rs b/src/head/head.rs index c5f0347ad..e4c7bab52 100644 --- a/src/head/head.rs +++ b/src/head/head.rs @@ -1,4 +1,6 @@ #![crate_name = "head"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/hostid/hostid.rs b/src/hostid/hostid.rs index f84ff8987..7fc737330 100644 --- a/src/hostid/hostid.rs +++ b/src/hostid/hostid.rs @@ -1,4 +1,5 @@ #![crate_name = "hostid"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/hostname/hostname.rs b/src/hostname/hostname.rs index 572882355..034a8899a 100644 --- a/src/hostname/hostname.rs +++ b/src/hostname/hostname.rs @@ -1,4 +1,6 @@ #![crate_name = "hostname"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/id/id.rs b/src/id/id.rs index 829d48140..1de0a46c0 100644 --- a/src/id/id.rs +++ b/src/id/id.rs @@ -1,4 +1,5 @@ #![crate_name = "id"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/kill/kill.rs b/src/kill/kill.rs index 68d73c2bc..85c4c645d 100644 --- a/src/kill/kill.rs +++ b/src/kill/kill.rs @@ -1,4 +1,5 @@ #![crate_name = "kill"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/link/link.rs b/src/link/link.rs index 4f0da2ede..633ee950d 100644 --- a/src/link/link.rs +++ b/src/link/link.rs @@ -1,4 +1,5 @@ #![crate_name = "link"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/logname/logname.rs b/src/logname/logname.rs index ddd8d332c..ea5569f4f 100644 --- a/src/logname/logname.rs +++ b/src/logname/logname.rs @@ -1,4 +1,5 @@ #![crate_name = "logname"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/mkdir/mkdir.rs b/src/mkdir/mkdir.rs index 174759974..b3c84c8fc 100644 --- a/src/mkdir/mkdir.rs +++ b/src/mkdir/mkdir.rs @@ -1,4 +1,5 @@ #![crate_name = "mkdir"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/mkfifo/mkfifo.rs b/src/mkfifo/mkfifo.rs index 5ef8f254e..c990d4cee 100644 --- a/src/mkfifo/mkfifo.rs +++ b/src/mkfifo/mkfifo.rs @@ -1,4 +1,5 @@ #![crate_name = "mkfifo"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/mv/mv.rs b/src/mv/mv.rs index 73024b138..cff5af46c 100644 --- a/src/mv/mv.rs +++ b/src/mv/mv.rs @@ -1,4 +1,5 @@ #![crate_name = "mv"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/nice/nice.rs b/src/nice/nice.rs index 6a7e4a7ca..eb8b1115b 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -1,4 +1,5 @@ #![crate_name = "nice"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 3fe6ea9b2..020ecbc9f 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -1,4 +1,6 @@ #![crate_name = "nl"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/nohup/nohup.rs b/src/nohup/nohup.rs index 1a72e3b68..25d4aca6d 100644 --- a/src/nohup/nohup.rs +++ b/src/nohup/nohup.rs @@ -1,4 +1,5 @@ #![crate_name = "nohup"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/nproc/nproc.rs b/src/nproc/nproc.rs index 3f1b26f06..bf050c2fb 100644 --- a/src/nproc/nproc.rs +++ b/src/nproc/nproc.rs @@ -1,4 +1,5 @@ #![crate_name = "nproc"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/paste/paste.rs b/src/paste/paste.rs index b2cff4916..0de8907c9 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -1,4 +1,5 @@ #![crate_name = "paste"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/printenv/printenv.rs b/src/printenv/printenv.rs index 054353d91..c8108d177 100644 --- a/src/printenv/printenv.rs +++ b/src/printenv/printenv.rs @@ -1,4 +1,5 @@ #![crate_name = "printenv"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index 508112ab2..15892c68c 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -1,4 +1,5 @@ #![crate_name = "pwd"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/realpath/realpath.rs b/src/realpath/realpath.rs index 3871b1156..692a92b6a 100644 --- a/src/realpath/realpath.rs +++ b/src/realpath/realpath.rs @@ -1,4 +1,5 @@ #![crate_name= "realpath"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/relpath/relpath.rs b/src/relpath/relpath.rs index 2b194332f..f16b38c9f 100644 --- a/src/relpath/relpath.rs +++ b/src/relpath/relpath.rs @@ -1,4 +1,5 @@ #![crate_name = "relpath"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/rm/rm.rs b/src/rm/rm.rs index ccc28d046..941fc1e66 100644 --- a/src/rm/rm.rs +++ b/src/rm/rm.rs @@ -1,4 +1,5 @@ #![crate_name = "rm"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/rmdir/rmdir.rs b/src/rmdir/rmdir.rs index 1eba92797..568a7fee3 100644 --- a/src/rmdir/rmdir.rs +++ b/src/rmdir/rmdir.rs @@ -1,4 +1,5 @@ #![crate_name = "rmdir"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/seq/seq.rs b/src/seq/seq.rs index ada3cbc53..7e55a8876 100644 --- a/src/seq/seq.rs +++ b/src/seq/seq.rs @@ -1,4 +1,5 @@ #![crate_name = "seq"] +#![allow(unstable)] // TODO: Make -w flag work with decimals // TODO: Support -f flag diff --git a/src/shuf/shuf.rs b/src/shuf/shuf.rs index 29163453c..82f2f795e 100644 --- a/src/shuf/shuf.rs +++ b/src/shuf/shuf.rs @@ -1,4 +1,5 @@ #![crate_name = "shuf"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/sleep/sleep.rs b/src/sleep/sleep.rs index 21efa36e5..c90112bfd 100644 --- a/src/sleep/sleep.rs +++ b/src/sleep/sleep.rs @@ -1,4 +1,5 @@ #![crate_name = "sleep"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/sort/sort.rs b/src/sort/sort.rs index 27fe680f9..ad9c25deb 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -1,4 +1,5 @@ #![crate_name = "sort"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/split/split.rs b/src/split/split.rs index 1ba74c5e8..963122142 100644 --- a/src/split/split.rs +++ b/src/split/split.rs @@ -1,4 +1,5 @@ #![crate_name = "split"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/sum/sum.rs b/src/sum/sum.rs index 4706498fe..dab56c98c 100644 --- a/src/sum/sum.rs +++ b/src/sum/sum.rs @@ -1,4 +1,5 @@ #![crate_name = "sum"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/sync/sync.rs b/src/sync/sync.rs index 8d3c51307..8d5ad739e 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -1,4 +1,6 @@ #![crate_name = "uusync"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/tac/tac.rs b/src/tac/tac.rs index bea2790ac..2ae8771d5 100644 --- a/src/tac/tac.rs +++ b/src/tac/tac.rs @@ -1,4 +1,5 @@ #![crate_name = "tac"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/tail/tail.rs b/src/tail/tail.rs index c9b240063..86fc4d67e 100644 --- a/src/tail/tail.rs +++ b/src/tail/tail.rs @@ -1,4 +1,6 @@ #![crate_name = "tail"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/tee/tee.rs b/src/tee/tee.rs index d2374af1d..98a6a0cb7 100644 --- a/src/tee/tee.rs +++ b/src/tee/tee.rs @@ -1,4 +1,6 @@ #![crate_name = "tee"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/test/test.rs b/src/test/test.rs index 8d5742785..530d9369c 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -1,4 +1,5 @@ #![crate_name = "uutest"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index eb89dd435..ad68435a4 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -1,4 +1,5 @@ #![crate_name = "timeout"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/touch/touch.rs b/src/touch/touch.rs index f32c1c72f..8b40d59fb 100644 --- a/src/touch/touch.rs +++ b/src/touch/touch.rs @@ -1,4 +1,5 @@ #![crate_name = "touch"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/tr/tr.rs b/src/tr/tr.rs index 23aa63855..da40f35f8 100644 --- a/src/tr/tr.rs +++ b/src/tr/tr.rs @@ -1,4 +1,5 @@ #![crate_name = "tr"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/true/true.rs b/src/true/true.rs index f43220f82..fa4216ee8 100644 --- a/src/true/true.rs +++ b/src/true/true.rs @@ -1,4 +1,5 @@ #![crate_name= "uutrue"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/truncate/truncate.rs b/src/truncate/truncate.rs index 533b9de6a..955b0c66a 100644 --- a/src/truncate/truncate.rs +++ b/src/truncate/truncate.rs @@ -1,4 +1,5 @@ #![crate_name = "truncate"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 42d92f180..6ed75f64c 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -1,4 +1,5 @@ #![crate_name = "tsort"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/tty/tty.rs b/src/tty/tty.rs index 2d1e3dcc4..77fa59d34 100644 --- a/src/tty/tty.rs +++ b/src/tty/tty.rs @@ -1,5 +1,5 @@ #![crate_name = "tty"] - +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 7e4b44e12..928bf1342 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -1,4 +1,5 @@ #![crate_name = "uname"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/unexpand/unexpand.rs b/src/unexpand/unexpand.rs index c862e27e5..8f6b97def 100644 --- a/src/unexpand/unexpand.rs +++ b/src/unexpand/unexpand.rs @@ -1,4 +1,5 @@ #![crate_name = "unexpand"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/uniq/uniq.rs b/src/uniq/uniq.rs index 98a43d6aa..72a44835c 100644 --- a/src/uniq/uniq.rs +++ b/src/uniq/uniq.rs @@ -1,4 +1,6 @@ #![crate_name = "uniq"] +#![allow(unstable)] + /* * This file is part of the uutils coreutils package. * diff --git a/src/unlink/unlink.rs b/src/unlink/unlink.rs index 100e5c493..1ab563ce7 100644 --- a/src/unlink/unlink.rs +++ b/src/unlink/unlink.rs @@ -1,4 +1,5 @@ #![crate_name = "unlink"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/uptime/uptime.rs b/src/uptime/uptime.rs index ff5f7630a..c10f67e31 100644 --- a/src/uptime/uptime.rs +++ b/src/uptime/uptime.rs @@ -1,4 +1,5 @@ #![crate_name = "uptime"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/users/users.rs b/src/users/users.rs index 57782e61c..03878656e 100644 --- a/src/users/users.rs +++ b/src/users/users.rs @@ -1,4 +1,5 @@ #![crate_name = "users"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index c42f43bb5..4b9e5a470 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -1,4 +1,5 @@ #![crate_name = "uutils"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/wc/wc.rs b/src/wc/wc.rs index 81de3567a..0309f84bf 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -1,4 +1,5 @@ #![crate_name = "wc"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/whoami/whoami.rs b/src/whoami/whoami.rs index 78422f5d2..e9827a623 100644 --- a/src/whoami/whoami.rs +++ b/src/whoami/whoami.rs @@ -1,4 +1,5 @@ #![crate_name = "whoami"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 07634c229..5e3364c38 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -1,4 +1,5 @@ #![crate_name = "yes"] +#![allow(unstable)] /* * This file is part of the uutils coreutils package. diff --git a/test/cat.rs b/test/cat.rs index 61b997383..b82c45abe 100644 --- a/test/cat.rs +++ b/test/cat.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::str; diff --git a/test/cp.rs b/test/cp.rs index 889ec867b..6a9478cc9 100644 --- a/test/cp.rs +++ b/test/cp.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::io::File; use std::io::fs::{unlink, PathExtensions}; diff --git a/test/mkdir.rs b/test/mkdir.rs index f8e543f8b..527fa6b45 100644 --- a/test/mkdir.rs +++ b/test/mkdir.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::io::fs::{rmdir, PathExtensions}; use std::borrow::ToOwned; diff --git a/test/mv.rs b/test/mv.rs index 2302afbca..d789e7941 100644 --- a/test/mv.rs +++ b/test/mv.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + extern crate time; use std::io::{process, fs, FilePermission}; diff --git a/test/nl.rs b/test/nl.rs index 9498c7320..61e3c3b78 100644 --- a/test/nl.rs +++ b/test/nl.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::str; diff --git a/test/seq.rs b/test/seq.rs index 5c046e43b..3dce8cc52 100644 --- a/test/seq.rs +++ b/test/seq.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::str; diff --git a/test/sort.rs b/test/sort.rs index eeaf65f0f..3aa69c8ac 100644 --- a/test/sort.rs +++ b/test/sort.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; use std::io::File; use std::string::String; diff --git a/test/test.rs b/test/test.rs index 18eab2996..c1fe3536f 100644 --- a/test/test.rs +++ b/test/test.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; static EXE: &'static str = "./test"; diff --git a/test/tr.rs b/test/tr.rs index b0c8cffed..7c792ec06 100644 --- a/test/tr.rs +++ b/test/tr.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; static PROGNAME: &'static str = "./tr"; diff --git a/test/truncate.rs b/test/truncate.rs index 067716fd2..b61c50a1e 100644 --- a/test/truncate.rs +++ b/test/truncate.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io; use std::io::process::Command; diff --git a/test/unexpand.rs b/test/unexpand.rs index a53d68cfd..94ac39f31 100644 --- a/test/unexpand.rs +++ b/test/unexpand.rs @@ -1,3 +1,5 @@ +#![allow(unstable)] + use std::io::process::Command; static PROGNAME: &'static str = "./unexpand"; From 6aef8cc38c3f31176f9a13d3654c0929012ad0b7 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 20:32:59 +0100 Subject: [PATCH 10/12] Don't link to regex_macros --- src/chmod/chmod.rs | 2 +- src/nl/nl.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chmod/chmod.rs b/src/chmod/chmod.rs index a34dd201e..015dc0433 100644 --- a/src/chmod/chmod.rs +++ b/src/chmod/chmod.rs @@ -16,7 +16,7 @@ extern crate getopts; extern crate libc; extern crate regex; -#[plugin] extern crate regex_macros; +#[plugin] #[no_link] extern crate regex_macros; use std::ffi::CString; use std::io::fs; diff --git a/src/nl/nl.rs b/src/nl/nl.rs index 020ecbc9f..d39f77334 100644 --- a/src/nl/nl.rs +++ b/src/nl/nl.rs @@ -12,7 +12,7 @@ */ #![feature(plugin)] -#[plugin] extern crate regex_macros; +#[plugin] #[no_link] extern crate regex_macros; extern crate regex; extern crate getopts; From 58bd009a9eb3df7df95f27b54e0337866369d28b Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 20:40:07 +0100 Subject: [PATCH 11/12] Remove unused imports --- src/nice/nice.rs | 1 - src/sort/sort.rs | 1 - test/mv.rs | 1 - 3 files changed, 3 deletions(-) diff --git a/src/nice/nice.rs b/src/nice/nice.rs index eb8b1115b..1e16f0c15 100644 --- a/src/nice/nice.rs +++ b/src/nice/nice.rs @@ -16,7 +16,6 @@ extern crate libc; use std::ffi::CString; use std::io::IoError; use std::os; -use std::ptr; use libc::{c_char, c_int, execvp}; const NAME: &'static str = "nice"; diff --git a/src/sort/sort.rs b/src/sort/sort.rs index ad9c25deb..5e5aeac9d 100644 --- a/src/sort/sort.rs +++ b/src/sort/sort.rs @@ -15,7 +15,6 @@ extern crate getopts; use std::cmp::Ordering; -use std::fmt::Show; use std::io::{print, File, BufferedReader}; use std::io::stdio::stdin_raw; use std::str::Chars; diff --git a/test/mv.rs b/test/mv.rs index d789e7941..6dddb4c7f 100644 --- a/test/mv.rs +++ b/test/mv.rs @@ -5,7 +5,6 @@ extern crate time; use std::io::{process, fs, FilePermission}; use std::io::process::Command; use std::io::fs::PathExtensions; -use std::io::pipe::PipeStream; use std::str::from_utf8; use std::borrow::ToOwned; From c3fb3fe23ff94f0cfdb7a21ad5791fd700be51f5 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 20:38:57 +0100 Subject: [PATCH 12/12] make: disable deps/time build and use rust-crypto/deps/time instead --- Makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index f56c504e6..800672a38 100644 --- a/Makefile +++ b/Makefile @@ -222,16 +222,17 @@ $(BUILDDIR)/uutils: $(SRCDIR)/uutils/uutils.rs $(BUILDDIR)/mkuutils $(RLIB_PATHS $(if $(ENABLE_STRIP),strip $@) # Dependencies -$(BUILDDIR)/.rust-crypto: $(BUILDDIR)/.rust-time | $(BUILDDIR) +$(BUILDDIR)/.rust-crypto: | $(BUILDDIR) cd $(BASEDIR)/deps/rust-crypto && $(CARGO) build --release - cp -r $(BASEDIR)/deps/rust-crypto/target/release/deps/lib{time,rustc-serialize}*.rlib $(BUILDDIR) + cp -r $(BASEDIR)/deps/rust-crypto/target/release/deps/librustc-serialize*.rlib $(BUILDDIR) + cp -r $(BASEDIR)/deps/rust-crypto/target/release/deps/libtime*.rlib $(BUILDDIR)/libtime.rlib cp -r $(BASEDIR)/deps/rust-crypto/target/release/libcrypto*.rlib $(BUILDDIR)/libcrypto.rlib @touch $@ -$(BUILDDIR)/.rust-time: - cd $(BASEDIR)/deps/time && $(CARGO) build --release - cp -r $(BASEDIR)/deps/time/target/release/libtime*.rlib $(BUILDDIR)/libtime.rlib - @touch $@ +#$(BUILDDIR)/.rust-time: +# cd $(BASEDIR)/deps/time && $(CARGO) build --release +# cp -r $(BASEDIR)/deps/time/target/release/libtime*.rlib $(BUILDDIR)/libtime.rlib +# @touch $@ $(BUILDDIR)/.rust-regex: cd $(BASEDIR)/deps/regex/regex_macros && $(CARGO) build --release @@ -248,7 +249,7 @@ $(BUILDDIR)/mkuutils: mkuutils.rs | $(BUILDDIR) $(SRCDIR)/cksum/crc_table.rs: $(SRCDIR)/cksum/gen_table.rs cd $(SRCDIR)/cksum && $(RUSTC) $(RUSTCFLAGS) gen_table.rs && ./gen_table && $(RM) gen_table -deps: $(BUILDDIR)/.rust-crypto $(BUILDDIR)/.rust-time $(BUILDDIR)/.rust-regex $(SRCDIR)/cksum/crc_table.rs +deps: $(BUILDDIR)/.rust-crypto $(BUILDDIR)/.rust-regex $(SRCDIR)/cksum/crc_table.rs crates: echo $(EXES)