diff --git a/.travis.yml b/.travis.yml index e256b58171026..1188c5a97f2db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ addons: - locales - language-pack-de - re2c + - libedit-dev - libgmp-dev - libicu-dev - libtidy-dev diff --git a/ext/readline/config.m4 b/ext/readline/config.m4 index 21f4f63b04e3d..ff2195d484296 100644 --- a/ext/readline/config.m4 +++ b/ext/readline/config.m4 @@ -3,79 +3,7 @@ dnl config.m4 for extension readline PHP_ARG_WITH(libedit,for libedit readline replacement, [ --with-libedit Include libedit readline replacement (CLI/CGI only)]) -if test "$PHP_LIBEDIT" = "no"; then - PHP_ARG_WITH(readline,for readline support, - [ --with-readline[=DIR] Include readline support (CLI/CGI only)]) -else - dnl "register" the --with-readline option to preven invalid "unknown configure option" warning - php_with_readline=no -fi - -if test "$PHP_READLINE" && test "$PHP_READLINE" != "no"; then - for i in $PHP_READLINE /usr/local /usr; do - test -f $i/include/readline/readline.h && READLINE_DIR=$i && break - done - - if test -z "$READLINE_DIR"; then - AC_MSG_ERROR(Please reinstall readline - I cannot find readline.h) - fi - - PHP_ADD_INCLUDE($READLINE_DIR/include) - - PHP_READLINE_LIBS="" - AC_CHECK_LIB(ncurses, tgetent, - [ - PHP_ADD_LIBRARY(ncurses,,READLINE_SHARED_LIBADD) - PHP_READLINE_LIBS="$PHP_READLINE_LIBS -lncurses" - ],[ - AC_CHECK_LIB(termcap, tgetent, - [ - PHP_ADD_LIBRARY(termcap,,READLINE_SHARED_LIBADD) - PHP_READLINE_LIBS="$PHP_READLINE_LIBS -ltermcap" - ]) - ]) - - PHP_CHECK_LIBRARY(readline, readline, - [ - PHP_ADD_LIBRARY_WITH_PATH(readline, $READLINE_DIR/$PHP_LIBDIR, READLINE_SHARED_LIBADD) - ], [ - AC_MSG_ERROR(readline library not found) - ], [ - -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS - ]) - - PHP_CHECK_LIBRARY(readline, rl_pending_input, - [], [ - AC_MSG_ERROR([invalid readline installation detected. Try --with-libedit instead.]) - ], [ - -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS - ]) - - PHP_CHECK_LIBRARY(readline, rl_callback_read_char, - [ - AC_DEFINE(HAVE_RL_CALLBACK_READ_CHAR, 1, [ ]) - ],[],[ - -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS - ]) - - PHP_CHECK_LIBRARY(readline, rl_on_new_line, - [ - AC_DEFINE(HAVE_RL_ON_NEW_LINE, 1, [ ]) - ],[],[ - -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS - ]) - - PHP_CHECK_LIBRARY(readline, rl_completion_matches, - [ - AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1, [ ]) - ],[],[ - -L$READLINE_DIR/$PHP_LIBDIR $PHP_READLINE_LIBS - ]) - - AC_DEFINE(HAVE_HISTORY_LIST, 1, [ ]) - AC_DEFINE(HAVE_LIBREADLINE, 1, [ ]) - -elif test "$PHP_LIBEDIT" != "no"; then +if test "$PHP_LIBEDIT" != "no"; then if test "$PHP_LIBEDIT" != "yes"; then AC_MSG_WARN([libedit directory ignored, rely on pkg-config]) fi @@ -131,9 +59,7 @@ elif test "$PHP_LIBEDIT" != "no"; then ]) AC_DEFINE(HAVE_LIBEDIT, 1, [ ]) -fi - -if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then PHP_NEW_EXTENSION(readline, readline.c readline_cli.c, $ext_shared, cli) PHP_SUBST(READLINE_SHARED_LIBADD) fi + diff --git a/ext/readline/php_readline.h b/ext/readline/php_readline.h index bcd61bcc88bf4..6bb3502d6ca4c 100644 --- a/ext/readline/php_readline.h +++ b/ext/readline/php_readline.h @@ -19,7 +19,7 @@ #ifndef PHP_READLINE_H #define PHP_READLINE_H -#if HAVE_LIBREADLINE || HAVE_LIBEDIT +#if HAVE_LIBEDIT #ifndef PHP_WIN32 #ifdef ZTS #warning Readline module will *NEVER* be thread-safe @@ -36,6 +36,6 @@ extern zend_module_entry readline_module_entry; #define phpext_readline_ptr NULL -#endif /* HAVE_LIBREADLINE */ +#endif /* HAVE_LIBEDIT */ #endif /* PHP_READLINE_H */ diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 89842b965552d..5a2e4a6ffd3be 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -26,18 +26,13 @@ #include "php_readline.h" #include "readline_cli.h" -#if HAVE_LIBREADLINE || HAVE_LIBEDIT +#if HAVE_LIBEDIT #ifndef HAVE_RL_COMPLETION_MATCHES #define rl_completion_matches completion_matches #endif -#ifdef HAVE_LIBEDIT #include -#else -#include -#include -#endif PHP_FUNCTION(readline); PHP_FUNCTION(readline_add_history); @@ -170,10 +165,6 @@ ZEND_GET_MODULE(readline) PHP_MINIT_FUNCTION(readline) { -#if HAVE_LIBREADLINE - /* libedit don't need this call which set the tty in cooked mode */ - using_history(); -#endif ZVAL_UNDEF(&_readline_completion); #if HAVE_RL_CALLBACK_READ_CHAR ZVAL_UNDEF(&_prepped_callback); @@ -254,21 +245,6 @@ PHP_FUNCTION(readline_info) #ifndef PHP_WIN32 add_assoc_long(return_value,"end",rl_end); #endif -#ifdef HAVE_LIBREADLINE - add_assoc_long(return_value,"mark",rl_mark); - add_assoc_long(return_value,"done",rl_done); - add_assoc_long(return_value,"pending_input",rl_pending_input); - add_assoc_string(return_value,"prompt",SAFE_STRING(rl_prompt)); - add_assoc_string(return_value,"terminal_name",(char *)SAFE_STRING(rl_terminal_name)); - add_assoc_str(return_value, "completion_append_character", - rl_completion_append_character == 0 - ? ZSTR_EMPTY_ALLOC() - : ZSTR_CHAR(rl_completion_append_character)); - add_assoc_bool(return_value,"completion_suppress_append",rl_completion_suppress_append); -#endif -#if HAVE_ERASE_EMPTY_LINE - add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line); -#endif #ifndef PHP_WIN32 add_assoc_string(return_value,"library_version",(char *)SAFE_STRING(rl_library_version)); #endif @@ -289,51 +265,6 @@ PHP_FUNCTION(readline_info) } else if (!strcasecmp(what, "end")) { RETVAL_LONG(rl_end); #endif -#ifdef HAVE_LIBREADLINE - } else if (!strcasecmp(what, "mark")) { - RETVAL_LONG(rl_mark); - } else if (!strcasecmp(what, "done")) { - oldval = rl_done; - if (value) { - convert_to_long_ex(value); - rl_done = Z_LVAL_P(value); - } - RETVAL_LONG(oldval); - } else if (!strcasecmp(what, "pending_input")) { - oldval = rl_pending_input; - if (value) { - convert_to_string_ex(value); - rl_pending_input = Z_STRVAL_P(value)[0]; - } - RETVAL_LONG(oldval); - } else if (!strcasecmp(what, "prompt")) { - RETVAL_STRING(SAFE_STRING(rl_prompt)); - } else if (!strcasecmp(what, "terminal_name")) { - RETVAL_STRING((char *)SAFE_STRING(rl_terminal_name)); - } else if (!strcasecmp(what, "completion_suppress_append")) { - oldval = rl_completion_suppress_append; - if (value) { - rl_completion_suppress_append = zend_is_true(value); - } - RETVAL_BOOL(oldval); - } else if (!strcasecmp(what, "completion_append_character")) { - oldval = rl_completion_append_character; - if (value) { - convert_to_string_ex(value) - rl_completion_append_character = (int)Z_STRVAL_P(value)[0]; - } - RETVAL_INTERNED_STR( - oldval == 0 ? ZSTR_EMPTY_ALLOC() : ZSTR_CHAR(oldval)); -#endif -#if HAVE_ERASE_EMPTY_LINE - } else if (!strcasecmp(what, "erase_empty_line")) { - oldval = rl_erase_empty_line; - if (value) { - convert_to_long_ex(value); - rl_erase_empty_line = Z_LVAL_P(value); - } - RETVAL_LONG(oldval); -#endif #ifndef PHP_WIN32 } else if (!strcasecmp(what,"library_version")) { RETVAL_STRING((char *)SAFE_STRING(rl_library_version)); @@ -383,11 +314,9 @@ PHP_FUNCTION(readline_clear_history) return; } -#if HAVE_LIBEDIT /* clear_history is the only function where rl_initialize is not call to ensure correct allocation */ using_history(); -#endif clear_history(); RETURN_TRUE; @@ -408,7 +337,7 @@ PHP_FUNCTION(readline_list_history) array_init(return_value); -#if defined(HAVE_LIBEDIT) && defined(PHP_WIN32) /* Winedit on Windows */ +#ifdef PHP_WIN32 /* Winedit on Windows */ history = history_list(); if (history) { @@ -418,7 +347,7 @@ PHP_FUNCTION(readline_list_history) } } -#elif defined(HAVE_LIBEDIT) /* libedit */ +#else /* libedit */ { HISTORY_STATE *hs; int i; @@ -434,16 +363,6 @@ PHP_FUNCTION(readline_list_history) } } } - -#else /* readline */ - history = history_list(); - - if (history) { - int i; - for (i = 0; history[i]; i++) { - add_next_index_string(return_value, history[i]->line); - } - } #endif } /* }}} */ @@ -669,11 +588,9 @@ PHP_FUNCTION(readline_callback_handler_remove) Ask readline to redraw the display */ PHP_FUNCTION(readline_redisplay) { -#if HAVE_LIBEDIT /* seems libedit doesn't take care of rl_initialize in rl_redisplay * see bug #72538 */ using_history(); -#endif rl_redisplay(); } /* }}} */ @@ -692,4 +609,4 @@ PHP_FUNCTION(readline_on_new_line) #endif -#endif /* HAVE_LIBREADLINE */ +#endif /* HAVE_LIBEDIT */ diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index f55de8e4f9627..5a5a27193b37c 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -50,12 +50,7 @@ #include #endif -#if HAVE_LIBEDIT #include -#else -#include -#include -#endif #include "zend_compile.h" #include "zend_execute.h" @@ -667,11 +662,7 @@ static int readline_shell_run(void) /* {{{ */ } if (history_lines_to_write) { -#if HAVE_LIBEDIT write_history(history_file); -#else - append_history(history_lines_to_write, history_file); -#endif history_lines_to_write = 0; } @@ -750,11 +741,7 @@ PHP_MINIT_FUNCTION(cli_readline) ZEND_INIT_MODULE_GLOBALS(cli_readline, cli_readline_init_globals, NULL); REGISTER_INI_ENTRIES(); -#if HAVE_LIBEDIT REGISTER_STRING_CONSTANT("READLINE_LIB", "libedit", CONST_CS|CONST_PERSISTENT); -#else - REGISTER_STRING_CONSTANT("READLINE_LIB", "readline", CONST_CS|CONST_PERSISTENT); -#endif GET_SHELL_CB(cb); if (cb) { diff --git a/travis/compile.sh b/travis/compile.sh index dd930b025407c..2c912373a4cc8 100755 --- a/travis/compile.sh +++ b/travis/compile.sh @@ -58,7 +58,7 @@ $TS \ --enable-sysvshm \ --enable-shmop \ --enable-pcntl \ ---with-readline \ +--with-libedit \ --enable-mbstring \ --with-curl \ --with-gettext \