Commit 7a71303c authored by unknown's avatar unknown

Fix bug#23293 "readline detection broken on NetBSD":

Its root cause is a difference between the "readline" and "libedit" (header files)
definitions of "rl_completion_entry_function", where the "libedit" one is wrong anyway:
This variable is used as a pointer to a function returning "char *",
but "libedit" declares it as returning "int" and then adds casts on usage.

Change it to "CPFunction *" and get rid of the casts.


client/mysql.cc:
  Fix bug#23293 "readline detection broken on NetBSD":
  
  Now that the "libedit" header files declares "rl_completion_entry_function" correctly,
  it need not be cast on usage, and "no_completion()" can be declared to return "char *".
cmd-line-utils/libedit/readline.c:
  Fix bug#23293 "readline detection broken on NetBSD":
  
  Now that the "libedit" header files declares "rl_completion_entry_function" correctly,
  it need not be cast on usage, and "complet_func()" is a "CPFunction *" as well.
cmd-line-utils/libedit/readline/readline.h:
  Fix bug#23293 "readline detection broken on NetBSD":
  
  Declare "rl_completion_entry_function()" to be a "CPFunction *", this avoids casts
  and brings "libedit" in sync with "readline".
parent 0142be55
......@@ -1420,7 +1420,7 @@ static char **new_mysql_completion (const char *text, int start, int end);
#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_LIBEDIT_INTERFACE)
char *no_completion(const char*,int)
#else
int no_completion()
char *no_completion()
#endif
{
return 0; /* No filename completion */
......@@ -1508,10 +1508,10 @@ static void initialize_readline (char *name)
setlocale(LC_ALL,""); /* so as libedit use isprint */
#endif
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= (Function*)&no_completion;
rl_completion_entry_function= &no_completion;
#else
rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion;
rl_completion_entry_function= (Function*)&no_completion;
rl_completion_entry_function= &no_completion;
#endif
}
......
......@@ -112,7 +112,7 @@ int rl_attempted_completion_over = 0;
char *rl_basic_word_break_characters = break_chars;
char *rl_completer_word_break_characters = NULL;
char *rl_completer_quote_characters = NULL;
Function *rl_completion_entry_function = NULL;
CPFunction *rl_completion_entry_function = NULL;
CPPFunction *rl_attempted_completion_function = NULL;
Function *rl_pre_input_hook = NULL;
Function *rl_startup1_hook = NULL;
......@@ -1724,7 +1724,7 @@ rl_display_match_list (matches, len, max)
static int
_rl_complete_internal(int what_to_do)
{
Function *complet_func;
CPFunction *complet_func;
const LineInfo *li;
char *temp, **matches;
const char *ctemp;
......@@ -1737,7 +1737,7 @@ _rl_complete_internal(int what_to_do)
complet_func = rl_completion_entry_function;
if (!complet_func)
complet_func = (Function *)(void *)filename_completion_function;
complet_func = filename_completion_function;
/* We now look backwards for the start of a filename/variable word */
li = el_line(e);
......@@ -1764,7 +1764,7 @@ _rl_complete_internal(int what_to_do)
} else
matches = 0;
if (!rl_attempted_completion_function || !matches)
matches = completion_matches(temp, (CPFunction *)complet_func);
matches = completion_matches(temp, complet_func);
if (matches) {
int i, retval = CC_REFRESH;
......@@ -1789,8 +1789,7 @@ _rl_complete_internal(int what_to_do)
* object is a directory.
*/
size_t alen = strlen(matches[0]);
if ((complet_func !=
(Function *)filename_completion_function
if ((complet_func != filename_completion_function
|| (alen > 0 && (matches[0])[alen - 1] != '/'))
&& rl_completion_append_character) {
char buf[2];
......
......@@ -102,7 +102,7 @@ extern int max_input_history;
extern char *rl_basic_word_break_characters;
extern char *rl_completer_word_break_characters;
extern char *rl_completer_quote_characters;
extern Function *rl_completion_entry_function;
extern CPFunction *rl_completion_entry_function;
extern CPPFunction *rl_attempted_completion_function;
extern int rl_completion_type;
extern int rl_completion_query_items;
......
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