From 00920ce29b42c7cf6c5e25cd17ec36b0c1a9f15b Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 19 May 2009 10:17:05 -0700 Subject: [PATCH] The mysql command-line client didn't implement the readline magic-space command, which bash does, which could result in a user accidentally disabling the use of the space key in the mysql command-line client. (Bug #27439) --- client/mysql.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/mysql.cc b/client/mysql.cc index 8de3cfee041..5752017bbff 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2296,8 +2296,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end); */ #if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int); extern "C" char *no_completion(const char*,int) #elif defined(USE_LIBEDIT_INTERFACE) +static int fake_magic_space(const char *, int); extern "C" int no_completion(const char*,int) #else extern "C" char *no_completion() @@ -2374,6 +2376,18 @@ static int not_in_history(const char *line) return 1; } + +#if defined(USE_NEW_READLINE_INTERFACE) +static int fake_magic_space(int, int) +#else +static int fake_magic_space(const char *, int) +#endif +{ + rl_insert(1, ' '); + return 0; +} + + static void initialize_readline (char *name) { /* Allow conditional parsing of the ~/.inputrc file. */ @@ -2383,12 +2397,15 @@ static void initialize_readline (char *name) #if defined(USE_NEW_READLINE_INTERFACE) rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; rl_completion_entry_function= (rl_compentry_func_t*)&no_completion; + + rl_add_defun("magic-space", (rl_command_func_t *)&fake_magic_space, -1); #elif defined(USE_LIBEDIT_INTERFACE) #ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); /* so as libedit use isprint */ #endif rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion; + rl_add_defun("magic-space", (Function*)&fake_magic_space, -1); #else rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= &no_completion;