mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Update for rust RFC 52 changes
This commit is contained in:
parent
7d353ce86b
commit
2ef74e2783
14 changed files with 26 additions and 26 deletions
|
@ -333,7 +333,7 @@ fn fail() -> ! {
|
|||
|
||||
impl<'a, W: Writer> Writer for UnsafeWriter<'a, W> {
|
||||
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
|
||||
let dst = self.buf.mut_slice_from(self.pos);
|
||||
let dst = self.buf.slice_from_mut(self.pos);
|
||||
if buf.len() > dst.len() {
|
||||
fail();
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use self::libc::funcs::posix88::unistd::getgroups;
|
|||
use std::vec::Vec;
|
||||
|
||||
use std::os;
|
||||
use std::ptr::{mut_null, read};
|
||||
use std::ptr::{null_mut, read};
|
||||
use std::string::raw::from_buf;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
|
@ -183,7 +183,7 @@ unsafe fn get_group_list_internal(name: *const c_char, gid: gid_t, groups: *mut
|
|||
}
|
||||
|
||||
pub fn get_groups() -> Result<Vec<gid_t>, int> {
|
||||
let ngroups = unsafe { getgroups(0, mut_null()) };
|
||||
let ngroups = unsafe { getgroups(0, null_mut()) };
|
||||
if ngroups == -1 {
|
||||
return Err(os::errno());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ impl<R: Reader> BufReader<R> {
|
|||
|
||||
#[inline]
|
||||
fn read(&mut self) -> IoResult<uint> {
|
||||
let buffer_fill = self.buffer.mut_slice_from(self.end);
|
||||
let buffer_fill = self.buffer.slice_from_mut(self.end);
|
||||
|
||||
match self.reader.read(buffer_fill) {
|
||||
Ok(nread) => {
|
||||
|
|
10
src/du/du.rs
10
src/du/du.rs
|
@ -56,7 +56,7 @@ fn du(path: &Path, mut my_stat: Stat,
|
|||
}
|
||||
};
|
||||
|
||||
for f in read.move_iter() {
|
||||
for f in read.into_iter() {
|
||||
let this_stat = Stat{path: f.clone(), fstat: safe_unwrap!(fs::lstat(&f))};
|
||||
if this_stat.fstat.kind == TypeDirectory {
|
||||
let oa_clone = options.clone();
|
||||
|
@ -71,8 +71,8 @@ fn du(path: &Path, mut my_stat: Stat,
|
|||
}
|
||||
}
|
||||
|
||||
for future in futures.mut_iter() {
|
||||
for stat in future.get().move_iter().rev() {
|
||||
for future in futures.iter_mut() {
|
||||
for stat in future.get().into_iter().rev() {
|
||||
if !options.separate_dirs && stat.path.dir_path() == my_stat.path {
|
||||
my_stat.fstat.size += stat.fstat.size;
|
||||
my_stat.fstat.unstable.blocks += stat.fstat.unstable.blocks;
|
||||
|
@ -310,10 +310,10 @@ Try '{} --help' for more information.", s, program);
|
|||
};
|
||||
|
||||
let mut grand_total = 0;
|
||||
for path_str in strs.move_iter() {
|
||||
for path_str in strs.into_iter() {
|
||||
let path = Path::new(path_str);
|
||||
let stat = safe_unwrap!(fs::lstat(&path));
|
||||
let iter = du(&path, Stat{path: path.clone(), fstat: stat}, options_arc.clone(), 0).move_iter();
|
||||
let iter = du(&path, Stat{path: path.clone(), fstat: stat}, options_arc.clone(), 0).into_iter();
|
||||
let (_, len) = iter.size_hint();
|
||||
let len = len.unwrap();
|
||||
for (index, stat) in iter.enumerate() {
|
||||
|
|
|
@ -81,7 +81,7 @@ fn convert_str(string: &[u8], index: uint, base: uint) -> (char, uint) {
|
|||
fn parse_options(args: Vec<String>, options: &mut EchoOptions) -> Option<Vec<String>> {
|
||||
let mut echo_args = vec!();
|
||||
let program = args[0].clone();
|
||||
'argloop: for arg in args.move_iter().skip(1) {
|
||||
'argloop: for arg in args.into_iter().skip(1) {
|
||||
match arg.as_slice() {
|
||||
"--help" | "-h" => {
|
||||
print_help(&program);
|
||||
|
|
|
@ -28,7 +28,7 @@ static DEFAULT_TABSTOP: uint = 8;
|
|||
fn tabstops_parse(s: String) -> Vec<uint> {
|
||||
let words = s.as_slice().split(',').collect::<Vec<&str>>();
|
||||
|
||||
let nums = words.move_iter()
|
||||
let nums = words.into_iter()
|
||||
.map(|sn| from_str::from_str::<uint>(sn)
|
||||
.unwrap_or_else(
|
||||
|| crash!(1, "{}\n", "tab size contains invalid character(s)"))
|
||||
|
@ -131,7 +131,7 @@ fn to_next_stop(tabstops: &[uint], col: uint) -> uint {
|
|||
fn expand(options: Options) {
|
||||
let mut output = io::stdout();
|
||||
|
||||
for file in options.files.move_iter() {
|
||||
for file in options.files.into_iter() {
|
||||
let mut col = 0;
|
||||
let mut init = true;
|
||||
for c in open(file).chars() {
|
||||
|
|
|
@ -57,7 +57,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
|
||||
fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
||||
let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.move_iter().map(|name|
|
||||
let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.into_iter().map(|name|
|
||||
io::BufferedReader::new(
|
||||
if name.as_slice() == "-" {
|
||||
box io::stdio::stdin_raw() as Box<Reader>
|
||||
|
@ -69,7 +69,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
|||
let delimiters: Vec<String> = delimiters.chars().map(|x| x.to_string()).collect();
|
||||
let mut delim_count = 0;
|
||||
if serial {
|
||||
for file in files.mut_iter() {
|
||||
for file in files.iter_mut() {
|
||||
let mut output = String::new();
|
||||
loop {
|
||||
match file.read_line() {
|
||||
|
@ -92,7 +92,7 @@ fn paste(filenames: Vec<String>, serial: bool, delimiters: &str) {
|
|||
loop {
|
||||
let mut output = "".to_string();
|
||||
let mut eof_count = 0;
|
||||
for (i, file) in files.mut_iter().enumerate() {
|
||||
for (i, file) in files.iter_mut().enumerate() {
|
||||
if eof[i] {
|
||||
eof_count += 1;
|
||||
} else {
|
||||
|
|
|
@ -63,7 +63,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
pub fn exec(args: Vec<String>, separator: &str) {
|
||||
if args.is_empty() {
|
||||
let vars = os::env();
|
||||
for (env_var, value) in vars.move_iter() {
|
||||
for (env_var, value) in vars.into_iter() {
|
||||
print!("{0:s}={1:s}", env_var, value);
|
||||
print(separator);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ fn escape_sequences(s: &str) -> String {
|
|||
fn parse_options(args: Vec<String>, options: &mut SeqOptions) -> Result<Vec<String>, int> {
|
||||
let mut seq_args = vec!();
|
||||
let program = args[0].clone();
|
||||
let mut iter = args.move_iter().skip(1);
|
||||
let mut iter = args.into_iter().skip(1);
|
||||
loop {
|
||||
match iter.next() {
|
||||
Some(arg) => match arg.as_slice() {
|
||||
|
|
|
@ -125,7 +125,7 @@ fn shuf(input: Vec<String>, mode: Mode, repeat: bool, zero: bool, count: uint, o
|
|||
Echo => shuf_lines(input, repeat, zero, count, output, random),
|
||||
InputRange(range) => shuf_lines(range.map(|num| num.to_string()).collect(), repeat, zero, count, output, random),
|
||||
Default => {
|
||||
let lines: Vec<String> = input.move_iter().flat_map(|filename| {
|
||||
let lines: Vec<String> = input.into_iter().flat_map(|filename| {
|
||||
let slice = filename.as_slice();
|
||||
let mut file_buf;
|
||||
let mut stdin_buf;
|
||||
|
@ -144,7 +144,7 @@ fn shuf(input: Vec<String>, mode: Mode, repeat: bool, zero: bool, count: uint, o
|
|||
line.pop_char();
|
||||
lines.push(line);
|
||||
}
|
||||
lines.move_iter()
|
||||
lines.into_iter()
|
||||
}).collect();
|
||||
shuf_lines(lines, repeat, zero, count, output, random)
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
|
||||
fn tac(filenames: Vec<String>, before: bool, _: bool, separator: &str) {
|
||||
for filename in filenames.move_iter() {
|
||||
for filename in filenames.into_iter() {
|
||||
let mut file = io::BufferedReader::new(
|
||||
if filename.as_slice() == "-" {
|
||||
box io::stdio::stdin_raw() as Box<Reader>
|
||||
|
|
|
@ -59,7 +59,7 @@ fn options(args: &[String]) -> Result<Options, ()> {
|
|||
let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}",
|
||||
version, program, arguments, usage(brief, opts),
|
||||
comment);
|
||||
let names = m.free.clone().move_iter().collect::<Vec<String>>().append_one("-".to_string());
|
||||
let names = m.free.clone().into_iter().collect::<Vec<String>>().append_one("-".to_string());
|
||||
let to_print = if m.opt_present("help") { Some(help) }
|
||||
else if m.opt_present("version") { Some(version) }
|
||||
else { None };
|
||||
|
|
|
@ -28,7 +28,7 @@ static DEFAULT_TABSTOP: uint = 8;
|
|||
fn tabstops_parse(s: String) -> Vec<uint> {
|
||||
let words = s.as_slice().split(',').collect::<Vec<&str>>();
|
||||
|
||||
let nums = words.move_iter()
|
||||
let nums = words.into_iter()
|
||||
.map(|sn| from_str::from_str::<uint>(sn)
|
||||
.unwrap_or_else(
|
||||
|| crash!(1, "{}\n", "tab size contains invalid character(s)"))
|
||||
|
@ -156,7 +156,7 @@ fn unexpand(options: Options) {
|
|||
let mut output = io::stdout();
|
||||
let ts = options.tabstops.as_slice();
|
||||
|
||||
for file in options.files.move_iter() {
|
||||
for file in options.files.into_iter() {
|
||||
let mut col = 0;
|
||||
let mut nspaces = 0;
|
||||
let mut init = true;
|
||||
|
|
|
@ -19,7 +19,7 @@ extern crate libc;
|
|||
|
||||
use std::mem::transmute;
|
||||
use std::io::{print, File};
|
||||
use std::ptr::{mut_null, null};
|
||||
use std::ptr::{null_mut, null};
|
||||
use std::from_str::from_str;
|
||||
use libc::{time_t, c_double, c_int, c_char};
|
||||
use c_types::c_tm;
|
||||
|
@ -143,7 +143,7 @@ fn print_nusers(nusers: uint) {
|
|||
}
|
||||
|
||||
fn print_time() {
|
||||
let local_time = unsafe { *localtime(&time(mut_null())) };
|
||||
let local_time = unsafe { *localtime(&time(null_mut())) };
|
||||
|
||||
if local_time.tm_hour >= 0 && local_time.tm_min >= 0 &&
|
||||
local_time.tm_sec >= 0 {
|
||||
|
@ -160,7 +160,7 @@ fn get_uptime(boot_time: Option<time_t>) -> i64 {
|
|||
Ok(s) => s,
|
||||
_ => return match boot_time {
|
||||
Some(t) => {
|
||||
let now = unsafe { time(mut_null()) };
|
||||
let now = unsafe { time(null_mut()) };
|
||||
((now - t) * 100) as i64 // Return in ms
|
||||
},
|
||||
_ => -1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue