From 41480c0bacf8f354610825856b5c66b8516da607 Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 1 Jul 2016 09:00:16 +0200 Subject: [PATCH] Bug#23708332: -DWITH_EDITLINE=SYSTEM BREAKS WITH LIBEDIT-20160618-3.1 Add CMake check for the new editline completion API and based on the result, use already existing code for it in the mysql client. Change-Id: I8a9a721de24eef6359d3285cffd9745a8894ea4b --- client/mysql.cc | 8 ++++---- cmake/readline.cmake | 22 +++++++++++++++++++--- config.h.cmake | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 94c3227..46147e9 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2816,7 +2816,7 @@ C_MODE_END if not. */ -#if defined(USE_NEW_READLINE_INTERFACE) +#if defined(USE_NEW_EDITLINE_INTERFACE) static int fake_magic_space(int, int); extern "C" char *no_completion(const char*,int) #elif defined(USE_LIBEDIT_INTERFACE) @@ -2845,7 +2845,7 @@ static int not_in_history(const char *line) } -#if defined(USE_NEW_READLINE_INTERFACE) +#if defined(USE_NEW_EDITLINE_INTERFACE) static int fake_magic_space(int, int) #else static int fake_magic_space(const char *, int) @@ -2862,7 +2862,7 @@ static void initialize_readline (char *name) rl_readline_name = name; /* Tell the completer that we want a crack first. */ -#if defined(USE_NEW_READLINE_INTERFACE) +#if defined(USE_NEW_EDITLINE_INTERFACE) rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; rl_completion_entry_function= (rl_compentry_func_t*)&no_completion; @@ -2890,7 +2890,7 @@ static char **new_mysql_completion(const char *text, int end MY_ATTRIBUTE((unused))) { if (!status.batch && !quick) -#if defined(USE_NEW_READLINE_INTERFACE) +#if defined(USE_NEW_EDITLINE_INTERFACE) return rl_completion_matches(text, new_command_generator); #else return completion_matches((char *)text, (CPFunction *)new_command_generator); diff --git a/cmake/readline.cmake b/cmake/readline.cmake index 00ecc53..8aed8cb 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -158,12 +158,28 @@ MACRO (FIND_SYSTEM_EDITLINE) completion_matches(0,0); return res; }" - EDITLINE_HAVE_COMPLETION) + EDITLINE_HAVE_COMPLETION_INT) - IF(EDITLINE_HAVE_COMPLETION) + CHECK_CXX_SOURCE_COMPILES(" + #include + #include + int main(int argc, char **argv) + { + typedef char* MYFunction(const char*, int); + MYFunction* myf= rl_completion_entry_function; + char *res= (myf)(NULL, 0); + completion_matches(0,0); + return res != NULL; + }" + EDITLINE_HAVE_COMPLETION_CHAR) + + IF(EDITLINE_HAVE_COMPLETION_INT OR EDITLINE_HAVE_COMPLETION_CHAR) SET(HAVE_HIST_ENTRY ${EDITLINE_HAVE_HIST_ENTRY}) SET(USE_LIBEDIT_INTERFACE 1) SET(EDITLINE_FOUND 1) + IF(EDITLINE_HAVE_COMPLETION_CHAR) + SET(USE_NEW_EDITLINE_INTERFACE 1) + ENDIF() ENDIF() ENDIF() ENDMACRO() diff --git a/config.h.cmake b/config.h.cmake index f0a11c4..388442c 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -276,6 +276,7 @@ #cmakedefine HAVE_NCURSES_H 1 #cmakedefine USE_LIBEDIT_INTERFACE 1 #cmakedefine HAVE_HIST_ENTRY 1 +#cmakedefine USE_NEW_EDITLINE_INTERFACE 1 /* * Libedit -- 2.7.4