Commit e2808aa2 authored by Jim Winstead's avatar Jim Winstead

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)
parent 9796aec8
...@@ -2296,8 +2296,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end); ...@@ -2296,8 +2296,10 @@ extern "C" char **new_mysql_completion (const char *text, int start, int end);
*/ */
#if defined(USE_NEW_READLINE_INTERFACE) #if defined(USE_NEW_READLINE_INTERFACE)
static int fake_magic_space(int, int);
extern "C" char *no_completion(const char*,int) extern "C" char *no_completion(const char*,int)
#elif defined(USE_LIBEDIT_INTERFACE) #elif defined(USE_LIBEDIT_INTERFACE)
static int fake_magic_space(const char *, int);
extern "C" int no_completion(const char*,int) extern "C" int no_completion(const char*,int)
#else #else
extern "C" char *no_completion() extern "C" char *no_completion()
...@@ -2374,6 +2376,18 @@ static int not_in_history(const char *line) ...@@ -2374,6 +2376,18 @@ static int not_in_history(const char *line)
return 1; 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) static void initialize_readline (char *name)
{ {
/* Allow conditional parsing of the ~/.inputrc file. */ /* Allow conditional parsing of the ~/.inputrc file. */
...@@ -2383,12 +2397,15 @@ static void initialize_readline (char *name) ...@@ -2383,12 +2397,15 @@ static void initialize_readline (char *name)
#if defined(USE_NEW_READLINE_INTERFACE) #if defined(USE_NEW_READLINE_INTERFACE)
rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
rl_completion_entry_function= (rl_compentry_func_t*)&no_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) #elif defined(USE_LIBEDIT_INTERFACE)
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
setlocale(LC_ALL,""); /* so as libedit use isprint */ setlocale(LC_ALL,""); /* so as libedit use isprint */
#endif #endif
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= &no_completion; rl_completion_entry_function= &no_completion;
rl_add_defun("magic-space", (Function*)&fake_magic_space, -1);
#else #else
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= &no_completion; rl_completion_entry_function= &no_completion;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment