@@ -30,46 +30,59 @@ pub mod rustrt {
3030
3131macro_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
4244pub 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
4953pub 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
5461pub 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
6271pub 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
7081pub 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