You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

105 lines
3.7 KiB

commit 2220f7458ef90829eacc457167a28aeba75ca1bc
Author: Sebastian Kemper <sebastian_ml@gmx.net>
Date: Sun Dec 9 21:19:24 2018 +0100
cmake: support new libedit interface
libedit changed it's interface a while ago. MariaDB's cmake file doesn't
recognize the new interface, the compile test fails:
/mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx: In function 'int main(int, char**)':
/mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx:6:47: error: invalid conversion from 'char*' to 'int' [-fpermissive]
int res= (*rl_completion_entry_function)(0,0);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Fix this by adding a detection for the new interface as well.
In client/mysql.cc the ifdefs for the new readline interface are
extended to also check for the new libedit interface. They work the same
way.
Run-tested on a MIPS machine.
Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2577,7 +2577,7 @@ C_MODE_END
if not.
*/
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
static int fake_magic_space(int, int);
extern "C" char *no_completion(const char*,int)
#elif defined(USE_LIBEDIT_INTERFACE)
@@ -2659,7 +2659,7 @@ static int not_in_history(const char *li
}
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
static int fake_magic_space(int, int)
#else
static int fake_magic_space(const char *, int)
@@ -2676,7 +2676,7 @@ static void initialize_readline (char *n
rl_readline_name = name;
/* Tell the completer that we want a crack first. */
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
@@ -2706,7 +2706,7 @@ static char **new_mysql_completion(const
int end __attribute__((unused)))
{
if (!status.batch && !quick)
-#if defined(USE_NEW_READLINE_INTERFACE)
+#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
return rl_completion_matches(text, new_command_generator);
#else
return completion_matches((char *)text, (CPFunction *)new_command_generator);
--- a/cmake/readline.cmake
+++ b/cmake/readline.cmake
@@ -160,8 +160,20 @@ MACRO (MYSQL_FIND_SYSTEM_LIBEDIT)
int res= (*rl_completion_entry_function)(0,0);
completion_matches(0,0);
}"
- LIBEDIT_INTERFACE)
- SET(USE_LIBEDIT_INTERFACE ${LIBEDIT_INTERFACE})
+ LIBEDIT_HAVE_COMPLETION_INT)
+
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <stdio.h>
+ #include <readline.h>
+ int main(int argc, char **argv)
+ {
+ char res= *(*rl_completion_entry_function)(0,0);
+ completion_matches(0,0);
+ }"
+ LIBEDIT_HAVE_COMPLETION_CHAR)
+ IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR)
+ SET(USE_LIBEDIT_INTERFACE 1)
+ ENDIF()
ENDIF()
ENDMACRO()
@@ -187,6 +199,7 @@ MACRO (MYSQL_CHECK_READLINE)
IF(USE_LIBEDIT_INTERFACE)
SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR})
SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY})
+ SET(USE_NEW_LIBEDIT_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR})
ELSE()
MYSQL_USE_BUNDLED_READLINE()
ENDIF()
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -113,6 +113,7 @@
/* Readline */
#cmakedefine HAVE_HIST_ENTRY 1
#cmakedefine USE_LIBEDIT_INTERFACE 1
+#cmakedefine USE_NEW_LIBEDIT_INTERFACE 1
#cmakedefine USE_NEW_READLINE_INTERFACE 1
#cmakedefine FIONREAD_IN_SYS_IOCTL 1