Skip to content

Commit f6ecbe8

Browse files
committed
Fix rpath bug.
1 parent a736669 commit f6ecbe8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/comp/back/rpath.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ mod test {
218218
#[test]
219219
fn test_prefix_rpath() {
220220
let res = get_install_prefix_rpath("/usr/lib", "triple");
221-
assert str::ends_with(res, #env("CFG_PREFIX")
222-
+ "/lib/rustc/triple/lib");
221+
let d = fs::connect(#env("CFG_PREFIX"), "/lib/rustc/triple/lib");
222+
assert str::ends_with(res, d);
223223
}
224224

225225
#[test]

src/libstd/fs.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,20 @@ Function: connect
8181
8282
Connects to path segments
8383
84-
Given paths `pre` and `post` this function will return a path
85-
that is equal to `post` appended to `pre`, inserting a path separator
86-
between the two as needed.
84+
Given paths `pre` and `post, removes any trailing path separator on `pre` and
85+
any leading path separator on `post`, and returns the concatenation of the two
86+
with a single path separator between them.
8787
*/
88-
fn connect(pre: path, post: path) -> path {
89-
let len = str::byte_len(pre);
90-
ret if pre[len - 1u] == os_fs::path_sep as u8 {
9188

92-
// Trailing '/'?
93-
pre + post
94-
} else { pre + path_sep() + post };
89+
fn connect(pre: path, post: path) -> path {
90+
let pre_ = pre;
91+
let post_ = post;
92+
let sep = os_fs::path_sep as u8;
93+
let pre_len = str::byte_len(pre);
94+
let post_len = str::byte_len(post);
95+
if pre_len > 1u && pre[pre_len-1u] == sep { str::pop_byte(pre_); }
96+
if post_len > 1u && post[0] == sep { str::shift_byte(post_); }
97+
ret pre_ + path_sep() + post_;
9598
}
9699

97100
/*

0 commit comments

Comments
 (0)