Skip to content

Commit 417209f

Browse files
committed
---
yaml --- r: 81056 b: refs/heads/snap-stage3 c: 3b1d3e5 h: refs/heads/master v: v3
1 parent c7312a0 commit 417209f

File tree

7 files changed

+245
-169
lines changed

7 files changed

+245
-169
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 90d3da971148a471c5766b544dc4ba50a15e5b96
4+
refs/heads/snap-stage3: 3b1d3e5bf8e2f288147fd879b37bc5e6f8c5528f
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)