Skip to content

Commit 3b1d3e5

Browse files
committed
librustc: Fix merge fallout.
1 parent 90d3da9 commit 3b1d3e5

File tree

6 files changed

+244
-168
lines changed

6 files changed

+244
-168
lines changed

src/libextra/rl.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,59 @@ pub mod rustrt {
3030

3131
macro_rules! locked {
3232
($expr:expr) => {
33-
// FIXME #9105: can't use a static mutex in pure Rust yet.
34-
rustrt::rust_take_linenoise_lock();
35-
let x = $expr;
36-
rustrt::rust_drop_linenoise_lock();
37-
x
33+
{
34+
// FIXME #9105: can't use a static mutex in pure Rust yet.
35+
rustrt::rust_take_linenoise_lock();
36+
let x = $expr;
37+
rustrt::rust_drop_linenoise_lock();
38+
x
39+
}
3840
}
3941
}
4042

4143
/// Add a line to history
4244
pub fn add_history(line: &str) -> bool {
4345
do line.with_c_str |buf| {
44-
(locked!(rustrt::linenoiseHistoryAdd(buf))) == 1 as c_int
46+
unsafe {
47+
(locked!(rustrt::linenoiseHistoryAdd(buf))) == 1 as c_int
48+
}
4549
}
4650
}
4751

4852
/// Set the maximum amount of lines stored
4953
pub fn set_history_max_len(len: int) -> bool {
50-
(locked!(rustrt::linenoiseHistorySetMaxLen(len as c_int))) == 1 as c_int
54+
unsafe {
55+
(locked!(rustrt::linenoiseHistorySetMaxLen(len as c_int))) == 1
56+
as c_int
57+
}
5158
}
5259

5360
/// Save line history to a file
5461
pub fn save_history(file: &str) -> bool {
5562
do file.with_c_str |buf| {
5663
// 0 on success, -1 on failure
57-
(locked!(rustrt::linenoiseHistorySave(buf))) == 0 as c_int
64+
unsafe {
65+
(locked!(rustrt::linenoiseHistorySave(buf))) == 0 as c_int
66+
}
5867
}
5968
}
6069

6170
/// Load line history from a file
6271
pub fn load_history(file: &str) -> bool {
6372
do file.with_c_str |buf| {
6473
// 0 on success, -1 on failure
65-
(locked!(rustrt::linenoiseHistoryLoad(buf))) == 0 as c_int
74+
unsafe {
75+
(locked!(rustrt::linenoiseHistoryLoad(buf))) == 0 as c_int
76+
}
6677
}
6778
}
6879

6980
/// Print out a prompt and then wait for input and return it
7081
pub fn read(prompt: &str) -> Option<~str> {
7182
do prompt.with_c_str |buf| {
72-
let line = locked!(rustrt::linenoise(buf));
83+
let line = unsafe {
84+
locked!(rustrt::linenoise(buf))
85+
};
7386

7487
if line.is_null() { None }
7588
else {

0 commit comments

Comments
 (0)