set rl_startup_hook only once
This commit is contained in:
@@ -107,16 +107,6 @@ pub fn readline_initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_batch(prompt: &str) -> Result<&'static str, SessionError> {
|
pub fn read_batch(prompt: &str) -> Result<&'static str, SessionError> {
|
||||||
unsafe {
|
|
||||||
use std::ptr::null;
|
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
// deactivate the startup hook that emits a "?- " to the
|
|
||||||
// beginning of the readline buffer.
|
|
||||||
let p: *const i8 = null();
|
|
||||||
rl_startup_hook = mem::transmute(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
match readline_rl(prompt) {
|
match readline_rl(prompt) {
|
||||||
Some(input) => Ok(input),
|
Some(input) => Ok(input),
|
||||||
None => Err(SessionError::UserPrompt)
|
None => Err(SessionError::UserPrompt)
|
||||||
@@ -131,7 +121,10 @@ fn read_line(prompt: &str) -> Result<&'static str, SessionError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn insert_query_prompt() -> i32 {
|
unsafe extern "C" fn insert_query_prompt() -> i32 {
|
||||||
|
if let LineMode::Single = LINE_MODE {
|
||||||
insert_text_rl("?- ");
|
insert_text_rl("?- ");
|
||||||
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user