mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Merge pull request #382 from ebfe/fix-build-master
Fix build with rust master
This commit is contained in:
commit
61239f998c
7 changed files with 23 additions and 15 deletions
2
deps/rust-crypto
vendored
2
deps/rust-crypto
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 0dfeac1338c3c01e2d2e26936f342459fae69ee3
|
||||
Subproject commit 24f91a8194440af39a017ef25a13c1db1d4a8f4f
|
|
@ -137,7 +137,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
|||
(write!(&mut writer, "{0:6u}\t", line_counter)).unwrap();
|
||||
line_counter += 1;
|
||||
}
|
||||
match in_buf.tailn(pos).iter().position(|c| *c == '\n' as u8) {
|
||||
match in_buf.slice_from(pos).iter().position(|c| *c == '\n' as u8) {
|
||||
Some(p) => {
|
||||
writer.write(in_buf.slice(pos, pos + p)).unwrap();
|
||||
if show_ends {
|
||||
|
@ -151,7 +151,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
|||
at_line_start = true;
|
||||
},
|
||||
None => {
|
||||
writer.write(in_buf.tailn(pos)).unwrap();
|
||||
writer.write(in_buf.slice_from(pos)).unwrap();
|
||||
at_line_start = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ impl std::from_str::FromStr for Range {
|
|||
fn from_str(s: &str) -> Option<Range> {
|
||||
use std::uint::MAX;
|
||||
|
||||
let mut parts = s.splitn('-', 1);
|
||||
let mut parts = s.splitn(1, '-');
|
||||
|
||||
match (parts.next(), parts.next()) {
|
||||
(Some(nm), None) => {
|
||||
|
|
4
src/env/env.rs
vendored
4
src/env/env.rs
vendored
|
@ -76,7 +76,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
if wait_cmd {
|
||||
// we still accept NAME=VAL here but not other options
|
||||
let mut sp = opt.as_slice().splitn('=', 1);
|
||||
let mut sp = opt.as_slice().splitn(1, '=');
|
||||
let name = sp.next();
|
||||
let value = sp.next();
|
||||
|
||||
|
@ -147,7 +147,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
}
|
||||
} else {
|
||||
// is it a NAME=VALUE like opt ?
|
||||
let mut sp = opt.as_slice().splitn('=', 1);
|
||||
let mut sp = opt.as_slice().splitn(1, '=');
|
||||
let name = sp.next();
|
||||
let value = sp.next();
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ extern crate libc;
|
|||
|
||||
use std::f64;
|
||||
use std::io::{print, timer};
|
||||
use std::u64;
|
||||
use std::time::duration::{mod, Duration};
|
||||
|
||||
#[path = "../common/util.rs"]
|
||||
mod util;
|
||||
|
@ -77,5 +77,11 @@ fn sleep(args: Vec<String>) {
|
|||
};
|
||||
result + num
|
||||
});
|
||||
timer::sleep(if sleep_time == f64::INFINITY { u64::MAX } else { (sleep_time * 1000.0) as u64 });
|
||||
let sleep_dur = if sleep_time == f64::INFINITY {
|
||||
duration::MAX
|
||||
} else {
|
||||
let (days, secs, millis) = (sleep_time / 86400., sleep_time % 86400., (sleep_time * 1_000.) % 1_000.);
|
||||
Duration::days(days as i32) + Duration::seconds(secs as i32) + Duration::milliseconds(millis as i32)
|
||||
};
|
||||
timer::sleep(sleep_dur);
|
||||
}
|
||||
|
|
|
@ -21,12 +21,13 @@ use getopts::{optopt, optflag, getopts, usage};
|
|||
use std::collections::Deque;
|
||||
use std::collections::ringbuf::RingBuf;
|
||||
use std::io::timer::sleep;
|
||||
use std::time::duration::Duration;
|
||||
|
||||
static PROGRAM: &'static str = "tail";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> int {
|
||||
let mut line_count = 10u;
|
||||
let mut sleep_sec = 1000u64;
|
||||
let mut sleep_msec = 1000u64;
|
||||
|
||||
// handle obsolete -number syntax
|
||||
let options = match obsolete(args.tail()) {
|
||||
|
@ -64,7 +65,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
Some(n) => {
|
||||
let parsed : Option<u64> = from_str(n.as_slice());
|
||||
match parsed {
|
||||
Some(m) => { sleep_sec = m*1000 }
|
||||
Some(m) => { sleep_msec = m*1000 }
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
if files.is_empty() {
|
||||
let mut buffer = BufferedReader::new(stdin());
|
||||
tail(&mut buffer, line_count, follow, sleep_sec);
|
||||
tail(&mut buffer, line_count, follow, sleep_msec);
|
||||
} else {
|
||||
let mut multiple = false;
|
||||
let mut firstime = true;
|
||||
|
@ -106,7 +107,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
let path = Path::new(file.as_slice());
|
||||
let reader = File::open(&path).unwrap();
|
||||
let mut buffer = BufferedReader::new(reader);
|
||||
tail(&mut buffer, line_count, follow, sleep_sec);
|
||||
tail(&mut buffer, line_count, follow, sleep_msec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +148,7 @@ fn obsolete (options: &[String]) -> (Vec<String>, Option<uint>) {
|
|||
(options, None)
|
||||
}
|
||||
|
||||
fn tail<T: Reader> (reader: &mut BufferedReader<T>, line_count:uint, follow:bool, sleep_sec:u64) {
|
||||
fn tail<T: Reader> (reader: &mut BufferedReader<T>, line_count:uint, follow:bool, sleep_msec:u64) {
|
||||
// read through each line and store them in a ringbuffer that always contains
|
||||
// line_count lines. When reaching the end of file, output the lines in the
|
||||
// ringbuf.
|
||||
|
@ -169,7 +170,8 @@ fn tail<T: Reader> (reader: &mut BufferedReader<T>, line_count:uint, follow:bool
|
|||
|
||||
// if we follow the file, sleep a bit and print the rest if the file has grown.
|
||||
while follow {
|
||||
sleep(sleep_sec);
|
||||
let (days, secs, millis) = ((sleep_msec / 1000) / 86400, (sleep_msec / 1000) % 86400, sleep_msec % 1000);
|
||||
sleep(Duration::days(days as i32) + Duration::seconds(secs as i32) + Duration::milliseconds(millis as i32));
|
||||
for io_line in reader.lines() {
|
||||
match io_line {
|
||||
Ok(line) => print!("{}", line),
|
||||
|
|
|
@ -123,7 +123,7 @@ fn open(path: String) -> io::BufferedReader<Box<Reader>> {
|
|||
fn is_tabstop(tabstops: &[uint], col: uint) -> bool {
|
||||
match tabstops {
|
||||
[tabstop] => col % tabstop == 0,
|
||||
tabstops => tabstops.bsearch(|&e| e.cmp(&col)).is_some()
|
||||
tabstops => tabstops.binary_search(|&e| e.cmp(&col)).found().is_some()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue