Upgrade to latest Rust

Also, remove dependency on the Regex library by replacing the one place it was used with standard code that should hopefully be faster anyway.
This commit is contained in:
Ben S 2015-01-05 14:41:43 +00:00
parent ba36d4f7f0
commit d400231de5
3 changed files with 51 additions and 37 deletions

37
Cargo.lock generated
View File

@ -2,21 +2,25 @@
name = "exa"
version = "0.1.0"
dependencies = [
"ansi_term 0.4.0 (git+https://github.com/ogham/rust-ansi-term.git)",
"natord 1.0.2 (git+https://github.com/lifthrasiir/rust-natord.git)",
"ansi_term 0.4.1 (git+https://github.com/ogham/rust-ansi-term.git)",
"natord 1.0.3 (git+https://github.com/lifthrasiir/rust-natord.git)",
"number_prefix 0.2.0 (git+https://github.com/ogham/rust-number-prefix.git)",
"users 0.1.1 (git+https://github.com/ogham/rust-users.git)",
"users 0.2.0 (git+https://github.com/ogham/rust-users.git)",
]
[[package]]
name = "ansi_term"
version = "0.4.0"
source = "git+https://github.com/ogham/rust-ansi-term.git#df6fcf773bae488c2c3a1456295531d6803e638a"
version = "0.4.1"
source = "git+https://github.com/ogham/rust-ansi-term.git#6db0b81cf4517e482293351c133cf07cced8c703"
dependencies = [
"regex 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"regex_macros 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "natord"
version = "1.0.2"
source = "git+https://github.com/lifthrasiir/rust-natord.git#6a42c8c168646c9de390af734a2e9dbe48bfdb91"
version = "1.0.3"
source = "git+https://github.com/lifthrasiir/rust-natord.git#b3a70271270effd7233fc36aef97215015d53af4"
[[package]]
name = "number_prefix"
@ -24,7 +28,20 @@ version = "0.2.0"
source = "git+https://github.com/ogham/rust-number-prefix.git#e4b56f7661c7d1b414b62af36a0e592f77911e4f"
[[package]]
name = "users"
version = "0.1.1"
source = "git+https://github.com/ogham/rust-users.git#c2911ab96a2b2459333029dde3728bfb5847ef04"
name = "regex"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "regex_macros"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"regex 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "users"
version = "0.2.0"
source = "git+https://github.com/ogham/rust-users.git#63d2760c52ee0a8c1e5592dea088dc90fc069f26"

View File

@ -1,6 +1,5 @@
#![feature(phase, globs)]
extern crate regex;
#[phase(plugin)] extern crate regex_macros;
#![feature(globs)]
extern crate ansi_term;
extern crate number_prefix;
extern crate unicode;

View File

@ -1,6 +1,5 @@
use std::io::{fs, IoResult};
use std::io;
use std::str::CowString;
use ansi_term::{ANSIString, Colour, Style};
use ansi_term::Style::Plain;
@ -49,16 +48,15 @@ impl<'a> File<'a> {
dir: parent,
stat: stat,
name: filename.to_string(),
ext: File::ext(filename),
ext: File::ext(filename.as_slice()),
}
}
fn ext(name: CowString) -> Option<String> {
fn ext(name: &'a str) -> Option<String> {
// The extension is the series of characters after a dot at
// the end of a filename. This deliberately also counts
// dotfiles - the ".git" folder has the extension "git".
let re = regex!(r"\.([^.]+)$");
re.captures(name.as_slice()).map(|caps| caps.at(1).to_string())
name.rfind('.').map(|pos| name.slice_from(pos + 1).to_string())
}
pub fn is_dotfile(&self) -> bool {
@ -209,7 +207,7 @@ impl<'a> File<'a> {
dir: self.dir,
stat: stat,
name: filename.to_string(),
ext: File::ext(filename.clone()),
ext: File::ext(filename.as_slice()),
});
// Statting a path usually fails because the file at the