mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #27 from Heather/master
Apply rust language updates from 2013-12-05
This commit is contained in:
commit
5ceb499e81
3 changed files with 6 additions and 6 deletions
|
@ -182,7 +182,7 @@ fn open(path: ~str) -> Option<~Reader> {
|
||||||
return Some(~stdin() as ~Reader);
|
return Some(~stdin() as ~Reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
match result(|| File::open(&std::path::Path::init(path.as_slice()))) {
|
match result(|| File::open(&std::path::Path::new(path.as_slice()))) {
|
||||||
Ok(fd) => return Some(~fd as ~Reader),
|
Ok(fd) => return Some(~fd as ~Reader),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
writeln!(&mut stderr() as &mut Writer,
|
writeln!(&mut stderr() as &mut Writer,
|
||||||
|
|
|
@ -59,8 +59,8 @@ directory).", opts));
|
||||||
|
|
||||||
if !matches.free.is_empty() {
|
if !matches.free.is_empty() {
|
||||||
for path in matches.free.iter() {
|
for path in matches.free.iter() {
|
||||||
let p = std::path::Path::init(path.clone());
|
let p = std::path::Path::new(path.clone());
|
||||||
print(std::str::from_utf8_slice(p.dirname()));
|
print(std::str::from_utf8(p.dirname()));
|
||||||
print(separator);
|
print(separator);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
6
wc/wc.rs
6
wc/wc.rs
|
@ -14,7 +14,7 @@ extern mod extra;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::io::{stdin, stderr, File, result};
|
use std::io::{stdin, stderr, File, result};
|
||||||
use std::io::buffered::BufferedReader;
|
use std::io::buffered::BufferedReader;
|
||||||
use std::str::from_utf8_slice_opt;
|
use std::str::from_utf8_opt;
|
||||||
use extra::getopts::{groups, Matches};
|
use extra::getopts::{groups, Matches};
|
||||||
|
|
||||||
struct Result {
|
struct Result {
|
||||||
|
@ -119,7 +119,7 @@ pub fn wc(files: ~[~str], matches: &Matches) {
|
||||||
byte_count += raw_line.iter().len();
|
byte_count += raw_line.iter().len();
|
||||||
|
|
||||||
// try and convert the bytes to UTF-8 first
|
// try and convert the bytes to UTF-8 first
|
||||||
match from_utf8_slice_opt(raw_line) {
|
match from_utf8_opt(raw_line) {
|
||||||
Some(line) => {
|
Some(line) => {
|
||||||
word_count += line.words().len();
|
word_count += line.words().len();
|
||||||
current_char_count = line.chars().len();
|
current_char_count = line.chars().len();
|
||||||
|
@ -221,7 +221,7 @@ fn open(path: ~str) -> Option<BufferedReader<~Reader>> {
|
||||||
return Some(BufferedReader::new(reader));
|
return Some(BufferedReader::new(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
match result(|| File::open(&std::path::Path::init(path.as_slice()))) {
|
match result(|| File::open(&std::path::Path::new(path.as_slice()))) {
|
||||||
Ok(fd) => {
|
Ok(fd) => {
|
||||||
let reader = ~fd as ~Reader;
|
let reader = ~fd as ~Reader;
|
||||||
return Some(BufferedReader::new(reader));
|
return Some(BufferedReader::new(reader));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue