From f905c74d9ab24a51d036853a8c609d8da3e5c91f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 20 Jul 2001 07:46:39 +0000 Subject: ^$&%&*$&)% readline uses \n characters instead of letting the terminal wrap the screen. This mucks up expect something severe. )-: Don't use readline if the CLI_NO_READLINE environment variable is set. (This used to be commit f0b7593ef54f8f093018ee2a8325e6f4422a4bbd) --- source3/lib/readline.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'source3/lib/readline.c') diff --git a/source3/lib/readline.c b/source3/lib/readline.c index 75a38c6852..11d65a2b16 100644 --- a/source3/lib/readline.c +++ b/source3/lib/readline.c @@ -43,25 +43,17 @@ /**************************************************************************** display the prompt and wait for input. Call callback() regularly ****************************************************************************/ -char *smb_readline(char *prompt, void (*callback)(void), - char **(completion_fn)(char *text, int start, int end)) +static char *smb_readline_replacement(char *prompt, void (*callback)(void), + char **(completion_fn)(char *text, + int start, + int end)) { - char *ret; -#if HAVE_LIBREADLINE - if (completion_fn) { - rl_attempted_completion_function = completion_fn; - } - - if (callback) rl_event_hook = (Function *)callback; - ret = readline(prompt); - if (ret && *ret) add_history(ret); - return ret; -#else fd_set fds; extern FILE *dbf; static pstring line; struct timeval timeout; int fd = fileno(stdin); + char *ret; fprintf(dbf, "%s", prompt); fflush(dbf); @@ -79,6 +71,35 @@ char *smb_readline(char *prompt, void (*callback)(void), } if (callback) callback(); } +} + +/**************************************************************************** +display the prompt and wait for input. Call callback() regularly +****************************************************************************/ +char *smb_readline(char *prompt, void (*callback)(void), + char **(completion_fn)(char *text, int start, int end)) +{ +#if HAVE_LIBREADLINE + char *ret; + + /* Aargh! Readline does bizzare things with the terminal width + that mucks up expect(1). Set CLI_NO_READLINE in the environment + to force readline not to be used. */ + + if (getenv("CLI_NO_READLINE")) + return smb_readline_replacement(prompt, callback, + completion_fn); + + if (completion_fn) { + rl_attempted_completion_function = completion_fn; + } + + if (callback) rl_event_hook = (Function *)callback; + ret = readline(prompt); + if (ret && *ret) add_history(ret); + return ret; +#else + return smb_readline_replacement(prompt, callback, completion_fn); #endif } -- cgit