Skip to content

Commit d8a2e71

Browse files
committed
---
yaml --- r: 81860 b: refs/heads/master c: 2265416 h: refs/heads/master v: v3
1 parent 7c71cb6 commit d8a2e71

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b6f74e696f790c18f6a2f720529a6c93514a8da2
2+
refs/heads/master: 22654165c697cac912159daedbfb731fbc7c175d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729

trunk/configure

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,6 @@ do
848848
# Disable term-info, linkage of which comes in multiple forms,
849849
# making our snapshots incompatible (#9334)
850850
LLVM_OPTS="$LLVM_OPTS --disable-terminfo"
851-
# Try to have LLVM pull in as few dependencies as possible (#9397)
852-
LLVM_OPTS="$LLVM_OPTS --disable-zlib --disable-libffi"
853851

854852
case "$CFG_C_COMPILER" in
855853
("ccache clang")

trunk/src/libstd/path.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,21 @@ pub trait GenericPath : Clone + Eq + ToStr {
233233
result
234234
}
235235

236+
237+
/// Returns `true` iff `child` is a suffix of `parent`. See the test
238+
/// case for examples.
239+
pub fn is_parent_of(parent: &Path, child: &Path) -> bool {
240+
if !parent.is_absolute() || child.is_absolute()
241+
|| parent.components.len() < child.components.len()
242+
|| parent.components.is_empty() {
243+
return false;
244+
}
245+
let child_components = child.components().len();
246+
let parent_components = parent.components().len();
247+
let to_drop = parent.components.len() - child_components;
248+
parent.components.slice(to_drop, parent_components) == child.components
249+
}
250+
236251
fn components<'a>(&'a self) -> &'a [~str];
237252
}
238253

@@ -1450,4 +1465,34 @@ mod tests {
14501465

14511466
}
14521467

1468+
1469+
#[test]
1470+
fn test_is_parent_of() {
1471+
assert!(is_parent_of(&PosixPath("/a/b/c/d/e"), &PosixPath("c/d/e")));
1472+
assert!(!is_parent_of(&PosixPath("a/b/c/d/e"), &PosixPath("c/d/e")));
1473+
assert!(!is_parent_of(&PosixPath("/a/b/c/d/e"), &PosixPath("/c/d/e")));
1474+
assert!(!is_parent_of(&PosixPath(""), &PosixPath("")));
1475+
assert!(!is_parent_of(&PosixPath(""), &PosixPath("a/b/c")));
1476+
assert!(is_parent_of(&PosixPath("/a/b/c"), &PosixPath("")));
1477+
assert!(is_parent_of(&PosixPath("/a/b/c"), &PosixPath("a/b/c")));
1478+
assert!(!is_parent_of(&PosixPath("/a/b/c"), &PosixPath("d/e/f")));
1479+
1480+
let abcde = WindowsPath("C:\\a\\b\\c\\d\\e");
1481+
let rel_abcde = WindowsPath("a\\b\\c\\d\\e");
1482+
let cde = WindowsPath("c\\d\\e");
1483+
let slashcde = WindowsPath("C:\\c\\d\\e");
1484+
let empty = WindowsPath("");
1485+
let abc = WindowsPath("C:\\a\\b\\c");
1486+
let rel_abc = WindowsPath("a\\b\\c");
1487+
let def = WindowsPath("d\\e\\f");
1488+
1489+
assert!(is_parent_of(&abcde, &cde));
1490+
assert!(!is_parent_of(&rel_abcde, &cde));
1491+
assert!(!is_parent_of(&abcde, &slashcde));
1492+
assert!(!is_parent_of(&empty, &empty));
1493+
assert!(is_parent_of(&abc, &empty);
1494+
assert!(is_parent_of(&abc, &rel_abc));
1495+
assert!(!is_parent_of(&abc, &def));
1496+
}
1497+
14531498
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2013-09-23
4+
2013-09-22

0 commit comments

Comments
 (0)