Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for latest rustc #9

Merged
merged 1 commit into from
Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Paths {
fn check_windows_verbatim(_: &Path) -> bool { false }

// calculate root this way to handle volume-relative Windows paths correctly
let mut root = os::getcwd();
let mut root = os::getcwd().unwrap();
let pat_root = Path::new(pattern).root_path();
if pat_root.is_some() {
if check_windows_verbatim(pat_root.as_ref().unwrap()) {
Expand Down Expand Up @@ -375,25 +375,24 @@ impl Pattern {
m => return m,
}

if file.is_empty() {
return EntirePatternDoesntMatch;
}
let (c, next) = match file.slice_shift_char() {
None => return EntirePatternDoesntMatch,
Some(pair) => pair
};

let (some_c, next) = file.slice_shift_char();
if require_literal(some_c.unwrap()) {
if require_literal(c) {
return SubPatternDoesntMatch;
}
prev_char.set(some_c);
prev_char.set(Some(c));
file = next;
}
}
_ => {
if file.is_empty() {
return EntirePatternDoesntMatch;
}
let (c, next) = match file.slice_shift_char() {
None => return EntirePatternDoesntMatch,
Some(pair) => pair
};

let (some_c, next) = file.slice_shift_char();
let c = some_c.unwrap();
let matches = match *token {
AnyChar => {
!require_literal(c)
Expand All @@ -420,7 +419,7 @@ impl Pattern {
if !matches {
return SubPatternDoesntMatch;
}
prev_char.set(some_c);
prev_char.set(Some(c));
file = next;
}
}
Expand Down Expand Up @@ -626,7 +625,7 @@ mod test {
assert!(glob("//").next().is_some());

// check windows absolute paths with host/device components
let root_with_device = os::getcwd().root_path().unwrap().join("*");
let root_with_device = os::getcwd().unwrap().root_path().unwrap().join("*");
// FIXME (#9639): This needs to handle non-utf8 paths
assert!(glob(root_with_device.as_str().unwrap()).next().is_some());
}
Expand Down
8 changes: 4 additions & 4 deletions tests/glob-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
}

fn abs_path(path: &str) -> Path {
os::getcwd().join(&Path::new(path))
os::getcwd().unwrap().join(&Path::new(path))
}

fn glob_vec(pattern: &str) -> Vec<Path> {
Expand All @@ -45,7 +45,7 @@ fn main() {

let root = TempDir::new("glob-tests");
let root = root.ok().expect("Should have created a temp directory");
assert!(os::change_dir(root.path()));
assert!(os::change_dir(root.path()).is_ok());

mk_file("aaa", true);
mk_file("aaa/apple", true);
Expand All @@ -72,8 +72,8 @@ fn main() {
mk_file("xyz/z", false);

assert_eq!(glob_vec(""), Vec::new());
assert_eq!(glob_vec("."), vec!(os::getcwd()));
assert_eq!(glob_vec(".."), vec!(os::getcwd().join("..")));
assert_eq!(glob_vec("."), vec!(os::getcwd().unwrap()));
assert_eq!(glob_vec(".."), vec!(os::getcwd().unwrap().join("..")));

assert_eq!(glob_vec("aaa"), vec!(abs_path("aaa")));
assert_eq!(glob_vec("aaa/"), vec!(abs_path("aaa")));
Expand Down