diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-09-18 18:18:45 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-09-23 18:23:23 -0700 |
| commit | 3b1d3e5bf8e2f288147fd879b37bc5e6f8c5528f (patch) | |
| tree | 691cc50bfb90eee27fcfa553d998a0fbddfc8115 /src/libextra | |
| parent | 90d3da971148a471c5766b544dc4ba50a15e5b96 (diff) | |
| download | rust-3b1d3e5bf8e2f288147fd879b37bc5e6f8c5528f.tar.gz rust-3b1d3e5bf8e2f288147fd879b37bc5e6f8c5528f.zip | |
librustc: Fix merge fallout.
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/rl.rs | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/libextra/rl.rs b/src/libextra/rl.rs index 7c7b6de9a3a..7662a159ba4 100644 --- a/src/libextra/rl.rs +++ b/src/libextra/rl.rs @@ -30,31 +30,40 @@ pub mod rustrt { macro_rules! locked { ($expr:expr) => { - // FIXME #9105: can't use a static mutex in pure Rust yet. - rustrt::rust_take_linenoise_lock(); - let x = $expr; - rustrt::rust_drop_linenoise_lock(); - x + { + // FIXME #9105: can't use a static mutex in pure Rust yet. + rustrt::rust_take_linenoise_lock(); + let x = $expr; + rustrt::rust_drop_linenoise_lock(); + x + } } } /// Add a line to history pub fn add_history(line: &str) -> bool { do line.with_c_str |buf| { - (locked!(rustrt::linenoiseHistoryAdd(buf))) == 1 as c_int + unsafe { + (locked!(rustrt::linenoiseHistoryAdd(buf))) == 1 as c_int + } } } /// Set the maximum amount of lines stored pub fn set_history_max_len(len: int) -> bool { - (locked!(rustrt::linenoiseHistorySetMaxLen(len as c_int))) == 1 as c_int + unsafe { + (locked!(rustrt::linenoiseHistorySetMaxLen(len as c_int))) == 1 + as c_int + } } /// Save line history to a file pub fn save_history(file: &str) -> bool { do file.with_c_str |buf| { // 0 on success, -1 on failure - (locked!(rustrt::linenoiseHistorySave(buf))) == 0 as c_int + unsafe { + (locked!(rustrt::linenoiseHistorySave(buf))) == 0 as c_int + } } } @@ -62,14 +71,18 @@ pub fn save_history(file: &str) -> bool { pub fn load_history(file: &str) -> bool { do file.with_c_str |buf| { // 0 on success, -1 on failure - (locked!(rustrt::linenoiseHistoryLoad(buf))) == 0 as c_int + unsafe { + (locked!(rustrt::linenoiseHistoryLoad(buf))) == 0 as c_int + } } } /// Print out a prompt and then wait for input and return it pub fn read(prompt: &str) -> Option<~str> { do prompt.with_c_str |buf| { - let line = locked!(rustrt::linenoise(buf)); + let line = unsafe { + locked!(rustrt::linenoise(buf)) + }; if line.is_null() { None } else { |
