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

  1. commit 2220f7458ef90829eacc457167a28aeba75ca1bc
  2. Author: Sebastian Kemper <sebastian_ml@gmx.net>
  3. Date: Sun Dec 9 21:19:24 2018 +0100
  4. cmake: support new libedit interface
  5. libedit changed it's interface a while ago. MariaDB's cmake file doesn't
  6. recognize the new interface, the compile test fails:
  7. /mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx: In function 'int main(int, char**)':
  8. /mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx:6:47: error: invalid conversion from 'char*' to 'int' [-fpermissive]
  9. int res= (*rl_completion_entry_function)(0,0);
  10. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
  11. Fix this by adding a detection for the new interface as well.
  12. In client/mysql.cc the ifdefs for the new readline interface are
  13. extended to also check for the new libedit interface. They work the same
  14. way.
  15. Run-tested on a MIPS machine.
  16. Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
  17. --- a/client/mysql.cc
  18. +++ b/client/mysql.cc
  19. @@ -2577,7 +2577,7 @@ C_MODE_END
  20. if not.
  21. */
  22. -#if defined(USE_NEW_READLINE_INTERFACE)
  23. +#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
  24. static int fake_magic_space(int, int);
  25. extern "C" char *no_completion(const char*,int)
  26. #elif defined(USE_LIBEDIT_INTERFACE)
  27. @@ -2659,7 +2659,7 @@ static int not_in_history(const char *li
  28. }
  29. -#if defined(USE_NEW_READLINE_INTERFACE)
  30. +#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
  31. static int fake_magic_space(int, int)
  32. #else
  33. static int fake_magic_space(const char *, int)
  34. @@ -2676,7 +2676,7 @@ static void initialize_readline (char *n
  35. rl_readline_name = name;
  36. /* Tell the completer that we want a crack first. */
  37. -#if defined(USE_NEW_READLINE_INTERFACE)
  38. +#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
  39. rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
  40. rl_completion_entry_function= (rl_compentry_func_t*)&no_completion;
  41. @@ -2706,7 +2706,7 @@ static char **new_mysql_completion(const
  42. int end __attribute__((unused)))
  43. {
  44. if (!status.batch && !quick)
  45. -#if defined(USE_NEW_READLINE_INTERFACE)
  46. +#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE)
  47. return rl_completion_matches(text, new_command_generator);
  48. #else
  49. return completion_matches((char *)text, (CPFunction *)new_command_generator);
  50. --- a/cmake/readline.cmake
  51. +++ b/cmake/readline.cmake
  52. @@ -160,8 +160,20 @@ MACRO (MYSQL_FIND_SYSTEM_LIBEDIT)
  53. int res= (*rl_completion_entry_function)(0,0);
  54. completion_matches(0,0);
  55. }"
  56. - LIBEDIT_INTERFACE)
  57. - SET(USE_LIBEDIT_INTERFACE ${LIBEDIT_INTERFACE})
  58. + LIBEDIT_HAVE_COMPLETION_INT)
  59. +
  60. + CHECK_CXX_SOURCE_COMPILES("
  61. + #include <stdio.h>
  62. + #include <readline.h>
  63. + int main(int argc, char **argv)
  64. + {
  65. + char res= *(*rl_completion_entry_function)(0,0);
  66. + completion_matches(0,0);
  67. + }"
  68. + LIBEDIT_HAVE_COMPLETION_CHAR)
  69. + IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR)
  70. + SET(USE_LIBEDIT_INTERFACE 1)
  71. + ENDIF()
  72. ENDIF()
  73. ENDMACRO()
  74. @@ -187,6 +199,7 @@ MACRO (MYSQL_CHECK_READLINE)
  75. IF(USE_LIBEDIT_INTERFACE)
  76. SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR})
  77. SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY})
  78. + SET(USE_NEW_LIBEDIT_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR})
  79. ELSE()
  80. MYSQL_USE_BUNDLED_READLINE()
  81. ENDIF()
  82. --- a/config.h.cmake
  83. +++ b/config.h.cmake
  84. @@ -113,6 +113,7 @@
  85. /* Readline */
  86. #cmakedefine HAVE_HIST_ENTRY 1
  87. #cmakedefine USE_LIBEDIT_INTERFACE 1
  88. +#cmakedefine USE_NEW_LIBEDIT_INTERFACE 1
  89. #cmakedefine USE_NEW_READLINE_INTERFACE 1
  90. #cmakedefine FIONREAD_IN_SYS_IOCTL 1