mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 05:57:46 +00:00
Update slicing syntax ([] -> [..])
This commit is contained in:
parent
9ae9a48387
commit
8098d172d7
4 changed files with 14 additions and 14 deletions
|
@ -49,7 +49,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
println!(" {0} [OPTION]... [FILE]...", program);
|
println!(" {0} [OPTION]... [FILE]...", program);
|
||||||
println!("");
|
println!("");
|
||||||
print(&getopts::usage("Concatenate FILE(s), or standard input, to \
|
print(&getopts::usage("Concatenate FILE(s), or standard input, to \
|
||||||
standard output.", &opts)[]);
|
standard output.", &opts)[..]);
|
||||||
println!("");
|
println!("");
|
||||||
println!("With no FILE, or when FILE is -, read standard input.");
|
println!("With no FILE, or when FILE is -, read standard input.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -95,7 +95,7 @@ fn write_lines(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
||||||
|
|
||||||
let mut line_counter: usize = 1;
|
let mut line_counter: usize = 1;
|
||||||
|
|
||||||
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) {
|
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) {
|
||||||
|
|
||||||
let mut in_buf = [0; 1024 * 31];
|
let mut in_buf = [0; 1024 * 31];
|
||||||
let mut out_buf = [0; 1024 * 64];
|
let mut out_buf = [0; 1024 * 64];
|
||||||
|
@ -162,7 +162,7 @@ fn write_bytes(files: Vec<String>, number: NumberingMode, squeeze_blank: bool,
|
||||||
|
|
||||||
let mut line_counter: usize = 1;
|
let mut line_counter: usize = 1;
|
||||||
|
|
||||||
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) {
|
for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) {
|
||||||
|
|
||||||
// Flush all 1024 iterations.
|
// Flush all 1024 iterations.
|
||||||
let mut flush_counter = range(0us, 1024);
|
let mut flush_counter = range(0us, 1024);
|
||||||
|
@ -234,7 +234,7 @@ fn write_fast(files: Vec<String>) {
|
||||||
let mut writer = stdout_raw();
|
let mut writer = stdout_raw();
|
||||||
let mut in_buf = [0; 1024 * 64];
|
let mut in_buf = [0; 1024 * 64];
|
||||||
|
|
||||||
for (mut reader, _) in files.iter().filter_map(|p| open(&p[])) {
|
for (mut reader, _) in files.iter().filter_map(|p| open(&p[..])) {
|
||||||
while let Ok(n) = reader.read(&mut in_buf) {
|
while let Ok(n) = reader.read(&mut in_buf) {
|
||||||
if n == 0 { break }
|
if n == 0 { break }
|
||||||
// This interface is completely broken.
|
// This interface is completely broken.
|
||||||
|
|
|
@ -141,7 +141,7 @@ mod platform {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let program = &args[0][];
|
let program = &args[0][..];
|
||||||
|
|
||||||
let options = [
|
let options = [
|
||||||
optflag("h", "help", "display this help and exit"),
|
optflag("h", "help", "display this help and exit"),
|
||||||
|
|
14
src/wc/wc.rs
14
src/wc/wc.rs
|
@ -38,7 +38,7 @@ struct Result {
|
||||||
static NAME: &'static str = "wc";
|
static NAME: &'static str = "wc";
|
||||||
|
|
||||||
pub fn uumain(args: Vec<String>) -> i32 {
|
pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let program = &args[0][];
|
let program = &args[0][..];
|
||||||
let opts = [
|
let opts = [
|
||||||
getopts::optflag("c", "bytes", "print the byte counts"),
|
getopts::optflag("c", "bytes", "print the byte counts"),
|
||||||
getopts::optflag("m", "chars", "print the character counts"),
|
getopts::optflag("m", "chars", "print the character counts"),
|
||||||
|
@ -60,7 +60,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
println!("Usage:");
|
println!("Usage:");
|
||||||
println!(" {0} [OPTION]... [FILE]...", program);
|
println!(" {0} [OPTION]... [FILE]...", program);
|
||||||
println!("");
|
println!("");
|
||||||
print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[]);
|
print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[..]);
|
||||||
println!("");
|
println!("");
|
||||||
println!("With no FILE, or when FILE is -, read standard input.");
|
println!("With no FILE, or when FILE is -, read standard input.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,10 +74,10 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
let files = if matches.free.is_empty() {
|
let files = if matches.free.is_empty() {
|
||||||
vec!["-".to_string()].into_cow()
|
vec!["-".to_string()].into_cow()
|
||||||
} else {
|
} else {
|
||||||
matches.free[].into_cow()
|
matches.free[..].into_cow()
|
||||||
};
|
};
|
||||||
|
|
||||||
match wc(&files[], &matches) {
|
match wc(&files[..], &matches) {
|
||||||
Ok(()) => ( /* pass */ ),
|
Ok(()) => ( /* pass */ ),
|
||||||
Err(e) => return e
|
Err(e) => return e
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> {
|
||||||
let mut max_str_len: usize = 0;
|
let mut max_str_len: usize = 0;
|
||||||
|
|
||||||
for path in files.iter() {
|
for path in files.iter() {
|
||||||
let mut reader = try!(open(&path[]));
|
let mut reader = try!(open(&path[..]));
|
||||||
|
|
||||||
let mut line_count: usize = 0;
|
let mut line_count: usize = 0;
|
||||||
let mut word_count: usize = 0;
|
let mut word_count: usize = 0;
|
||||||
|
@ -128,7 +128,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> {
|
||||||
|
|
||||||
// try and convert the bytes to UTF-8 first
|
// try and convert the bytes to UTF-8 first
|
||||||
let current_char_count;
|
let current_char_count;
|
||||||
match from_utf8(&raw_line[]) {
|
match from_utf8(&raw_line[..]) {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
word_count += line.words().count();
|
word_count += line.words().count();
|
||||||
current_char_count = line.chars().count();
|
current_char_count = line.chars().count();
|
||||||
|
@ -170,7 +170,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> {
|
||||||
}
|
}
|
||||||
|
|
||||||
for result in results.iter() {
|
for result in results.iter() {
|
||||||
print_stats(&result.filename[], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len);
|
print_stats(&result.filename[..], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
if files.len() > 1 {
|
if files.len() > 1 {
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
println!("Usage:");
|
println!("Usage:");
|
||||||
println!(" {0} [STRING]... [OPTION]...", program);
|
println!(" {0} [STRING]... [OPTION]...", program);
|
||||||
println!("");
|
println!("");
|
||||||
print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[]);
|
print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[..]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if matches.opt_present("version") {
|
if matches.opt_present("version") {
|
||||||
|
@ -55,7 +55,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||||
matches.free.connect(" ").into_cow()
|
matches.free.connect(" ").into_cow()
|
||||||
};
|
};
|
||||||
|
|
||||||
exec(&string[]);
|
exec(&string[..]);
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue