From 308d4a1166d1452998b27546e787690a17f792bf Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 14 Sep 2024 11:34:05 +0200 Subject: [PATCH] Remove Readline library integration This removes the GNU Readline library integration and relies on the libedit library if present. Issue is that there are several ext/readline libraries and GNU Readline license (GNU GPL 3) is not compatible with the PHP license. There was a similar attempt to fix this (GH-3823) and now fix continues here. Changes: - `--with-libedit` configure option removed (only `--with-readline` stays) - readline extension tests fixed: those required by only readline library removed, added missing skip reasons, some functions are always available, etc. - New PHP_SETUP_EDIT Autoconf macro that finds libedit This also fixes the phpdbg readline integration on *nix systems (using libedit library) for history (up/down keys and similar nice features) to not produce compile errors: ./configure --enable-phpdbg-readline make undefined reference to 'readline' undefined reference to 'add_history' --- .circleci/config.yml | 2 +- .github/actions/apk/action.yml | 2 +- .github/actions/apt-x32/action.yml | 2 +- .github/actions/configure-macos/action.yml | 2 +- .github/actions/configure-x64/action.yml | 2 +- build/php.m4 | 19 +++ ext/readline/config.m4 | 129 +++--------------- ext/readline/php_readline.h | 6 +- ext/readline/readline.c | 92 +------------ ext/readline/readline_cli.c | 9 -- ext/readline/tests/bug69054.phpt | 2 - ext/readline/tests/bug72538.phpt | 2 +- ext/readline/tests/bug77812-libedit.phpt | 1 - ext/readline/tests/bug77812-readline.phpt | 56 -------- .../libedit_callback_handler_install_001.phpt | 4 +- .../libedit_callback_handler_remove_001.phpt | 4 +- .../tests/libedit_info_001-win32.phpt | 2 +- ext/readline/tests/libedit_info_001.phpt | 2 +- .../libedit_write_history_001-win32.phpt | 3 +- .../tests/libedit_write_history_001.phpt | 3 +- .../tests/readline_add_history_001.phpt | 2 +- ...readline_callback_handler_install_001.phpt | 26 ---- .../readline_callback_handler_remove_001.phpt | 24 ---- ext/readline/tests/readline_info_001.phpt | 67 --------- ext/readline/tests/readline_info_002.phpt | 31 ----- .../tests/readline_list_history_001.phpt | 2 +- .../tests/readline_read_history_001.phpt | 2 +- .../readline_read_history_error_001.phpt | 3 - ...eadline_read_history_open_basedir_001.phpt | 2 - .../tests/readline_without_input.phpt | 4 - .../tests/readline_write_history_001.phpt | 29 ---- ...adline_write_history_open_basedir_001.phpt | 2 - sapi/phpdbg/config.m4 | 20 +-- sapi/phpdbg/phpdbg.h | 8 +- sapi/phpdbg/phpdbg_prompt.c | 13 +- 35 files changed, 69 insertions(+), 510 deletions(-) delete mode 100644 ext/readline/tests/bug77812-readline.phpt delete mode 100644 ext/readline/tests/readline_callback_handler_install_001.phpt delete mode 100644 ext/readline/tests/readline_callback_handler_remove_001.phpt delete mode 100644 ext/readline/tests/readline_info_001.phpt delete mode 100644 ext/readline/tests/readline_info_002.phpt delete mode 100644 ext/readline/tests/readline_write_history_001.phpt diff --git a/.circleci/config.yml b/.circleci/config.yml index 78520332dfc7e..e5d6ddf67595a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,7 @@ jobs: libxml2-dev \ libxslt1-dev \ libpq-dev \ - libreadline-dev \ + libedit-dev \ libldap2-dev \ libsodium-dev \ libargon2-0-dev \ diff --git a/.github/actions/apk/action.yml b/.github/actions/apk/action.yml index 49e336aa0fecb..f3d5078f58f3f 100644 --- a/.github/actions/apk/action.yml +++ b/.github/actions/apk/action.yml @@ -41,7 +41,7 @@ runs: libzip-dev \ oniguruma-dev \ openssl-dev \ - readline-dev \ + libedit-dev \ sqlite-dev \ tidyhtml-dev \ krb5-dev \ diff --git a/.github/actions/apt-x32/action.yml b/.github/actions/apt-x32/action.yml index 0638881d1e4c2..d0d5f7b90acfe 100644 --- a/.github/actions/apt-x32/action.yml +++ b/.github/actions/apt-x32/action.yml @@ -28,7 +28,7 @@ runs: libonig-dev:i386 \ libpng-dev:i386 \ libpq-dev:i386 \ - libreadline-dev:i386 \ + libedit-dev:i386 \ libsasl2-dev:i386 \ libsodium-dev:i386 \ libsqlite3-dev:i386 \ diff --git a/.github/actions/configure-macos/action.yml b/.github/actions/configure-macos/action.yml index ab92dfb2d782f..6bbac9ff03dcc 100644 --- a/.github/actions/configure-macos/action.yml +++ b/.github/actions/configure-macos/action.yml @@ -45,7 +45,7 @@ runs: --enable-sysvshm \ --enable-shmop \ --enable-pcntl \ - --with-readline="$BREW_OPT"/readline \ + --with-readline \ --enable-mbstring \ --with-curl \ --with-gettext="$BREW_OPT"/gettext \ diff --git a/.github/actions/configure-x64/action.yml b/.github/actions/configure-x64/action.yml index 3de17a246d02f..38dce5ef8fad8 100644 --- a/.github/actions/configure-x64/action.yml +++ b/.github/actions/configure-x64/action.yml @@ -41,7 +41,7 @@ runs: --enable-sysvshm \ --enable-shmop \ --enable-pcntl \ - --without-readline --with-libedit \ + --with-readline \ --enable-mbstring \ --with-curl \ --with-gettext \ diff --git a/build/php.m4 b/build/php.m4 index e45b22b7665fc..f35d73ed754fc 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -2002,6 +2002,25 @@ $2], ]))])]) ]) +dnl +dnl +dnl PHP_SETUP_EDIT([shared-add], [action-if-found], [action-if-not-found], [not-extension]) +dnl +dnl Common setup macro for linking libedit library. If "not-extension" argument +dnl is passed, the found library is appended to the "shared-add" variable +dnl unconditionally (for SAPIs). +dnl +AC_DEFUN([PHP_SETUP_EDIT], [ +PKG_CHECK_MODULES([EDIT], [libedit], [ + PHP_EVAL_INCLINE([$EDIT_CFLAGS]) + PHP_EVAL_LIBLINE([$EDIT_LIBS], [$1], [$4]) + AC_DEFINE([HAVE_LIBEDIT], [1], + [Define to 1 if 'libedit' library is available.]) + $2 +], +[$3]) +]) + dnl ---------------------------------------------------------------------------- dnl Misc. macros dnl ---------------------------------------------------------------------------- diff --git a/ext/readline/config.m4 b/ext/readline/config.m4 index 856116436650c..cf3475183bf89 100644 --- a/ext/readline/config.m4 +++ b/ext/readline/config.m4 @@ -1,103 +1,17 @@ -PHP_ARG_WITH([libedit], - [for libedit readline replacement], - [AS_HELP_STRING([--with-libedit], - [Include libedit readline replacement (CLI/CGI only)])]) +PHP_ARG_WITH([readline], + [for readline support], + [AS_HELP_STRING([--with-readline], + [Include readline support using the libedit library (CLI/CGI only)])]) -if test "$PHP_LIBEDIT" = "no"; then - PHP_ARG_WITH([readline], - [for readline support], - [AS_HELP_STRING([[--with-readline[=DIR]]], - [Include readline support (CLI/CGI only)])]) -else - dnl "register" the --with-readline option to prevent invalid "unknown - dnl 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 - AS_IF([test -f $i/include/readline/readline.h], [READLINE_DIR=$i; break;]) - done - - AS_VAR_IF([READLINE_DIR],, - [AC_MSG_ERROR([Please reinstall readline - I cannot find readline.h])]) - - 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_FAILURE([The readline library not found.])], - [-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]) - - CFLAGS_SAVE=$CFLAGS - LDFLAGS_SAVE=$LDFLAGS - LIBS_SAVE=$LIBS - CFLAGS="$CFLAGS $INCLUDES" - LDFLAGS="$LDFLAGS -L$READLINE_DIR/$PHP_LIBDIR" - LIBS="$LIBS -lreadline" - - dnl Sanity and minimum version check if readline library has variable - dnl rl_pending_input. - AC_CHECK_DECL([rl_pending_input],, [AC_MSG_FAILURE([ - Invalid readline installation detected. Try --with-libedit instead. - ])], [ - #include - #include - ]) - - AC_CHECK_DECL([rl_erase_empty_line], - [AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1])],, [ - #include - #include - ]) - CFLAGS=$CFLAGS_SAVE - LDFLAGS=$LDFLAGS_SAVE - LIBS=$LIBS_SAVE +if test "$PHP_READLINE" != "no"; then + AS_VAR_IF([PHP_READLINE], [yes],, + [AC_MSG_WARN([m4_text_wrap([ + The directory argument is not supported anymore, rely on pkg-config. + Replace '--with-readline=$PHP_READLINE' with '--with-realine' and use + environment variables 'PKG_CONFIG_PATH', 'EDIT_LIBS', or 'EDIT_CFLAGS'. + ])])]) - AC_DEFINE([HAVE_HISTORY_LIST], [1]) - AC_DEFINE([HAVE_LIBREADLINE], [1], - [Define to 1 if readline extension uses the 'readline' library.]) - -elif test "$PHP_LIBEDIT" != "no"; then - AS_VAR_IF([PHP_LIBEDIT], [yes],, - [AC_MSG_WARN(m4_text_wrap([ - The libedit directory argument is not supported anymore, rely on - pkg-config. Replace '--with-libedit=$PHP_LIBEDIT' with '--with-libedit' - and use environment variables 'PKG_CONFIG_PATH', 'EDIT_LIBS', or - 'EDIT_CFLAGS'. - ]))]) - - PKG_CHECK_MODULES([EDIT], [libedit]) - PHP_EVAL_LIBLINE([$EDIT_LIBS], [READLINE_SHARED_LIBADD]) - PHP_EVAL_INCLINE([$EDIT_CFLAGS]) + PHP_SETUP_EDIT([READLINE_SHARED_LIBADD]) AC_CHECK_LIB([ncurses], [tgetent], [PHP_ADD_LIBRARY([ncurses],, [READLINE_SHARED_LIBADD])], @@ -111,28 +25,26 @@ elif test "$PHP_LIBEDIT" != "no"; then PHP_CHECK_LIBRARY([edit], [rl_callback_read_char], [AC_DEFINE([HAVE_RL_CALLBACK_READ_CHAR], [1], - [Define to 1 if edit/readline library has the 'rl_callback_read_char' - function.])], + [Define to 1 if edit library has the 'rl_callback_read_char' function.])], [], [$READLINE_SHARED_LIBADD]) PHP_CHECK_LIBRARY([edit], [rl_on_new_line], [AC_DEFINE([HAVE_RL_ON_NEW_LINE], [1], - [Define to 1 if edit/readline library has the 'rl_on_new_line' - function.])], + [Define to 1 if edit library has the 'rl_on_new_line' function.])], [], [$READLINE_SHARED_LIBADD]) PHP_CHECK_LIBRARY([edit], [rl_completion_matches], [AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], [1], - [Define to 1 if edit/readline library has the 'rl_completion_matches' + [Define to 1 if edit library has the 'rl_completion_matches' function.])], [], [$READLINE_SHARED_LIBADD]) PHP_CHECK_LIBRARY([edit], [history_list], [AC_DEFINE([HAVE_HISTORY_LIST], [1], - [Define to 1 if edit/readline library has the 'history_list' function.])], + [Define to 1 if edit library has the 'history_list' function.])], [], [$READLINE_SHARED_LIBADD]) @@ -142,17 +54,12 @@ elif test "$PHP_LIBEDIT" != "no"; then LIBS="$LIBS $EDIT_LIBS" AC_CHECK_DECL([rl_erase_empty_line], [AC_DEFINE([HAVE_ERASE_EMPTY_LINE], [1], - [Define to 1 if edit/readline library has the 'rl_erase_empty_line' - global variable.])],, + [Define to 1 if edit library has the 'rl_erase_empty_line' global + variable.])],, [#include ]) CFLAGS=$CFLAGS_SAVE LIBS=$LIBS_SAVE - AC_DEFINE([HAVE_LIBEDIT], [1], - [Define to 1 if readline extension uses the 'libedit' library.]) -fi - -if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then dnl Add -Wno-strict-prototypes as depends on user libs PHP_NEW_EXTENSION([readline], [readline.c readline_cli.c], diff --git a/ext/readline/php_readline.h b/ext/readline/php_readline.h index f67238db663ae..ce789a391787a 100644 --- a/ext/readline/php_readline.h +++ b/ext/readline/php_readline.h @@ -20,10 +20,10 @@ #ifdef HAVE_LIBEDIT #define READLINE_LIB "libedit" #else -#define READLINE_LIB "readline" +#define READLINE_LIB "" #endif -#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) +#ifdef HAVE_LIBEDIT extern zend_module_entry readline_module_entry; #define phpext_readline_ptr &readline_module_entry @@ -35,6 +35,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 d94e20db9c32d..3b4de3bee450b 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -25,18 +25,13 @@ #include "readline_cli.h" #include "readline_arginfo.h" -#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT) +#ifdef HAVE_LIBEDIT #ifndef HAVE_RL_COMPLETION_MATCHES #define rl_completion_matches completion_matches #endif -#ifdef HAVE_LIBEDIT #include -#else -#include -#include -#endif #ifdef HAVE_RL_CALLBACK_READ_CHAR @@ -74,10 +69,6 @@ ZEND_GET_MODULE(readline) PHP_MINIT_FUNCTION(readline) { -#ifdef HAVE_LIBREADLINE - /* libedit don't need this call which set the tty in cooked mode */ - using_history(); -#endif ZVAL_UNDEF(&_readline_completion); #ifdef HAVE_RL_CALLBACK_READ_CHAR ZVAL_UNDEF(&_prepped_callback); @@ -159,18 +150,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 #ifdef HAVE_ERASE_EMPTY_LINE add_assoc_long(return_value,"erase_empty_line",rl_erase_empty_line); #endif @@ -186,15 +165,6 @@ PHP_FUNCTION(readline_info) if (!try_convert_to_string(value)) { RETURN_THROWS(); } -#if !defined(PHP_WIN32) && !defined(HAVE_LIBEDIT) - if (!rl_line_buffer) { - rl_line_buffer = malloc(Z_STRLEN_P(value) + 1); - } else if (strlen(oldstr) < Z_STRLEN_P(value)) { - rl_extend_line_buffer(Z_STRLEN_P(value) + 1); - oldstr = rl_line_buffer; - } - memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1); -#else char *tmp = strdup(Z_STRVAL_P(value)); if (tmp) { if (rl_line_buffer) { @@ -202,7 +172,6 @@ PHP_FUNCTION(readline_info) } rl_line_buffer = tmp; } -#endif #if !defined(PHP_WIN32) rl_end = Z_STRLEN_P(value); #endif @@ -214,45 +183,6 @@ PHP_FUNCTION(readline_info) } else if (zend_string_equals_literal_ci(what, "end")) { RETVAL_LONG(rl_end); #endif -#ifdef HAVE_LIBREADLINE - } else if (zend_string_equals_literal_ci(what, "mark")) { - RETVAL_LONG(rl_mark); - } else if (zend_string_equals_literal_ci(what, "done")) { - oldval = rl_done; - if (value) { - rl_done = zval_get_long(value); - } - RETVAL_LONG(oldval); - } else if (zend_string_equals_literal_ci(what, "pending_input")) { - oldval = rl_pending_input; - if (value) { - if (!try_convert_to_string(value)) { - RETURN_THROWS(); - } - rl_pending_input = Z_STRVAL_P(value)[0]; - } - RETVAL_LONG(oldval); - } else if (zend_string_equals_literal_ci(what, "prompt")) { - RETVAL_STRING(SAFE_STRING(rl_prompt)); - } else if (zend_string_equals_literal_ci(what, "terminal_name")) { - RETVAL_STRING((char *)SAFE_STRING(rl_terminal_name)); - } else if (zend_string_equals_literal_ci(what, "completion_suppress_append")) { - oldval = rl_completion_suppress_append; - if (value) { - rl_completion_suppress_append = zend_is_true(value); - } - RETVAL_BOOL(oldval); - } else if (zend_string_equals_literal_ci(what, "completion_append_character")) { - oldval = rl_completion_append_character; - if (value) { - if (!try_convert_to_string(value)) { - RETURN_THROWS(); - } - rl_completion_append_character = (int)Z_STRVAL_P(value)[0]; - } - RETVAL_INTERNED_STR( - oldval == 0 ? ZSTR_EMPTY_ALLOC() : ZSTR_CHAR(oldval)); -#endif #ifdef HAVE_ERASE_EMPTY_LINE } else if (zend_string_equals_literal_ci(what, "erase_empty_line")) { oldval = rl_erase_empty_line; @@ -309,11 +239,9 @@ PHP_FUNCTION(readline_clear_history) RETURN_THROWS(); } -#ifdef 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; @@ -333,7 +261,7 @@ PHP_FUNCTION(readline_list_history) array_init(return_value); -#if defined(HAVE_LIBEDIT) && defined(PHP_WIN32) /* Winedit on Windows */ +#if defined(PHP_WIN32) /* Winedit on Windows */ history = history_list(); if (history) { @@ -343,7 +271,7 @@ PHP_FUNCTION(readline_list_history) } } -#elif defined(HAVE_LIBEDIT) /* libedit */ +#else /* libedit */ { HISTORY_STATE *hs; int i; @@ -360,16 +288,6 @@ PHP_FUNCTION(readline_list_history) } free(hs); } - -#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 } /* }}} */ @@ -585,11 +503,9 @@ PHP_FUNCTION(readline_redisplay) RETURN_THROWS(); } -#ifdef HAVE_LIBEDIT /* seems libedit doesn't take care of rl_initialize in rl_redisplay * see bug #72538 */ using_history(); -#endif rl_redisplay(); } /* }}} */ @@ -611,4 +527,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 312129991c708..321d829899e01 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -38,12 +38,7 @@ #include #endif -#ifdef HAVE_LIBEDIT #include -#else -#include -#include -#endif #include "zend_compile.h" #include "zend_execute.h" @@ -687,11 +682,7 @@ static int readline_shell_run(void) /* {{{ */ } if (history_lines_to_write) { -#ifdef HAVE_LIBEDIT write_history(history_file); -#else - append_history(history_lines_to_write, history_file); -#endif history_lines_to_write = 0; } diff --git a/ext/readline/tests/bug69054.phpt b/ext/readline/tests/bug69054.phpt index 99750bfd3d3c0..985b473604739 100644 --- a/ext/readline/tests/bug69054.phpt +++ b/ext/readline/tests/bug69054.phpt @@ -2,8 +2,6 @@ Bug #69054 (Null dereference in readline_(read|write)_history() without parameters) --EXTENSIONS-- readline ---SKIPIF-- - --INI-- open_basedir="{TMP}" --FILE-- diff --git a/ext/readline/tests/bug72538.phpt b/ext/readline/tests/bug72538.phpt index 45f64ffda0511..bfd92e16154bb 100644 --- a/ext/readline/tests/bug72538.phpt +++ b/ext/readline/tests/bug72538.phpt @@ -3,7 +3,7 @@ Bug #72538 (readline_redisplay crashes php) --EXTENSIONS-- readline --SKIPIF-- - --FILE-- diff --git a/ext/readline/tests/bug77812-libedit.phpt b/ext/readline/tests/bug77812-libedit.phpt index a522ac2751b73..c5941398ba9c7 100644 --- a/ext/readline/tests/bug77812-libedit.phpt +++ b/ext/readline/tests/bug77812-libedit.phpt @@ -4,7 +4,6 @@ Bug #77812 (Interactive mode does not support PHP 7.3-style heredoc) readline --SKIPIF-- --FILE-- diff --git a/ext/readline/tests/bug77812-readline.phpt b/ext/readline/tests/bug77812-readline.phpt deleted file mode 100644 index a2d6c212c536a..0000000000000 --- a/ext/readline/tests/bug77812-readline.phpt +++ /dev/null @@ -1,56 +0,0 @@ ---TEST-- -Bug #77812 (Interactive mode does not support PHP 7.3-style heredoc) ---EXTENSIONS-- -readline ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Interactive shell - -php > echo << bar -<<< > FOO; -bar -php > print(<< xx -<<< > FOO); -xx -php > echo << xxx -<<< > FOO; -xxx -php > FOO -php > ; - -Warning: Uncaught Error: Undefined constant "FOO" in php shell code:1 -Stack trace: -#0 {main} - thrown in php shell code on line 1 -php > echo << FOOL -<<< > FOO -php > ,1; -FOOL1 -php > echo << FOO4 -<<< > FOO -php > ,2; -FOO42 -php > diff --git a/ext/readline/tests/libedit_callback_handler_install_001.phpt b/ext/readline/tests/libedit_callback_handler_install_001.phpt index a98027fbb9ebc..8981da66b30e8 100644 --- a/ext/readline/tests/libedit_callback_handler_install_001.phpt +++ b/ext/readline/tests/libedit_callback_handler_install_001.phpt @@ -4,9 +4,7 @@ lsan disabled due to a leak on ubuntu focal only. --EXTENSIONS-- readline --SKIPIF-- - + --INI-- zend.signal_check=0 --ENV-- diff --git a/ext/readline/tests/libedit_callback_handler_remove_001.phpt b/ext/readline/tests/libedit_callback_handler_remove_001.phpt index 1c7185c1bba6c..9f24d4a98f184 100644 --- a/ext/readline/tests/libedit_callback_handler_remove_001.phpt +++ b/ext/readline/tests/libedit_callback_handler_remove_001.phpt @@ -4,8 +4,8 @@ lsan disabled due to a leak on ubuntu focal only. --EXTENSIONS-- readline --SKIPIF-- - --INI-- zend.signal_check=0 diff --git a/ext/readline/tests/libedit_info_001-win32.phpt b/ext/readline/tests/libedit_info_001-win32.phpt index 59202ee772384..e3783cd8b1c4b 100644 --- a/ext/readline/tests/libedit_info_001-win32.phpt +++ b/ext/readline/tests/libedit_info_001-win32.phpt @@ -3,7 +3,7 @@ readline_info(): Basic test --EXTENSIONS-- readline --SKIPIF-- - + --FILE-- ---FILE-- -getMessage() . \PHP_EOL; -} - -?> ---EXPECT-- -testing: bool(true) -readline_callback_handler_install(): Argument #2 ($callback) must be a valid callback, function "foobar!" not found or invalid function name diff --git a/ext/readline/tests/readline_callback_handler_remove_001.phpt b/ext/readline/tests/readline_callback_handler_remove_001.phpt deleted file mode 100644 index 78d44e90dd29b..0000000000000 --- a/ext/readline/tests/readline_callback_handler_remove_001.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -readline_callback_handler_remove(): Basic test ---EXTENSIONS-- -readline ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -bool(false) -%Atesting: bool(true) -testing: bool(true) -bool(true) diff --git a/ext/readline/tests/readline_info_001.phpt b/ext/readline/tests/readline_info_001.phpt deleted file mode 100644 index 0dcd24a05c19c..0000000000000 --- a/ext/readline/tests/readline_info_001.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -readline_info(): Basic test ---EXTENSIONS-- -readline ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -array(%d) { - ["line_buffer"]=> - string(0) "" - ["point"]=> - int(0) - ["end"]=> - int(0) - ["mark"]=> - int(0) - ["done"]=> - int(0) - ["pending_input"]=> - int(0) - ["prompt"]=> - string(0) "" - ["terminal_name"]=> - string(0) "" - ["completion_append_character"]=> - string(1) " " - ["completion_suppress_append"]=> - bool(false)%A - ["library_version"]=> - string(%d) "%s" - ["readline_name"]=> - string(5) "other" - ["attempted_completion_over"]=> - int(0) -} -NULL -NULL -string(0) "" -string(5) "other" -string(5) "other" -string(1) "1" -int(0) -int(1) -string(1) " " -string(0) "" -bool(false) -bool(true) diff --git a/ext/readline/tests/readline_info_002.phpt b/ext/readline/tests/readline_info_002.phpt deleted file mode 100644 index 35fb6cd7b1de7..0000000000000 --- a/ext/readline/tests/readline_info_002.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -readline_info(): using line_buffer before rl_line_buffer is initialised. ---EXTENSIONS-- -readline ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -string(0) "" -string(6) "abcdef" -string(12) "abcdefghijkl" -string(4) "123 -" diff --git a/ext/readline/tests/readline_list_history_001.phpt b/ext/readline/tests/readline_list_history_001.phpt index f5ae215750e67..d9bda158d98c9 100644 --- a/ext/readline/tests/readline_list_history_001.phpt +++ b/ext/readline/tests/readline_list_history_001.phpt @@ -3,7 +3,7 @@ readline_list_history(): Basic test --EXTENSIONS-- readline --SKIPIF-- - + --FILE-- --FILE-- diff --git a/ext/readline/tests/readline_read_history_error_001.phpt b/ext/readline/tests/readline_read_history_error_001.phpt index 500b509b865bd..faebec29c30d9 100644 --- a/ext/readline/tests/readline_read_history_error_001.phpt +++ b/ext/readline/tests/readline_read_history_error_001.phpt @@ -4,9 +4,6 @@ readline_read_history() function - Error cases Pedro Manoel Evangelista --EXTENSIONS-- readline ---SKIPIF-- - - --FILE-- --INI-- open_basedir=/tmp/some-sandbox --FILE-- diff --git a/ext/readline/tests/readline_without_input.phpt b/ext/readline/tests/readline_without_input.phpt index 0b727256403b3..4c855b6d756e0 100644 --- a/ext/readline/tests/readline_without_input.phpt +++ b/ext/readline/tests/readline_without_input.phpt @@ -5,10 +5,6 @@ Jonathan Stevens User Group: PHP-WVL & PHPGent #PHPTestFest --EXTENSIONS-- readline ---SKIPIF-- - --FILE-- ---FILE-- - ---EXPECT-- -string(7) "foo - -1 -" diff --git a/ext/readline/tests/readline_write_history_open_basedir_001.phpt b/ext/readline/tests/readline_write_history_open_basedir_001.phpt index 263522a0b6567..0b85f32168328 100644 --- a/ext/readline/tests/readline_write_history_open_basedir_001.phpt +++ b/ext/readline/tests/readline_write_history_open_basedir_001.phpt @@ -2,8 +2,6 @@ readline_write_history(): Test that open_basedir is respected --EXTENSIONS-- readline ---SKIPIF-- - --INI-- open_basedir=/tmp/some-sandbox --FILE-- diff --git a/sapi/phpdbg/config.m4 b/sapi/phpdbg/config.m4 index 55f8fa3a8aa02..528b927e67cfe 100644 --- a/sapi/phpdbg/config.m4 +++ b/sapi/phpdbg/config.m4 @@ -16,7 +16,7 @@ PHP_ARG_ENABLE([phpdbg-debug], PHP_ARG_ENABLE([phpdbg-readline], [for phpdbg readline support], [AS_HELP_STRING([--enable-phpdbg-readline], - [Enable readline support in phpdbg (depends on static ext/readline)])], + [Enable readline support in phpdbg (requires libedit)])], [no], [no]) @@ -27,19 +27,11 @@ if test "$PHP_PHPDBG" != "no"; then AS_VAR_IF([PHP_PHPDBG_DEBUG], [no],, [AS_VAR_APPEND([PHP_PHPDBG_CFLAGS], [" -DPHPDBG_DEBUG=1"])]) - AC_MSG_CHECKING([for phpdbg and readline integration]) - if test "$PHP_PHPDBG_READLINE" = "yes"; then - if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then - AC_DEFINE([HAVE_PHPDBG_READLINE], [1], - [Define to 1 if the phpdbg SAPI has libedit/readline integration.]) - PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS" - AC_MSG_RESULT([ok]) - else - AC_MSG_RESULT([readline is not available]) - fi - else - AC_MSG_RESULT([disabled]) - fi + AS_VAR_IF([PHP_PHPDBG_READLINE], [yes], [ + PHP_SETUP_EDIT([PHPDBG_EXTRA_LIBS],,, [yes]) + AC_DEFINE([HAVE_PHPDBG_READLINE], [1], + [Define to 1 if the phpdbg SAPI has libedit integration.]) + ]) AH_TEMPLATE([HAVE_USERFAULTFD_WRITEFAULT], [Define to 1 if faulting on write-protected memory support can be compiled diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 41fe8faecf99b..ebb4b3108e548 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -78,13 +78,7 @@ #endif #ifdef HAVE_PHPDBG_READLINE -# ifdef HAVE_LIBREADLINE -# include -# include -# endif -# ifdef HAVE_LIBEDIT -# include -# endif +# include #endif /* {{{ strings */ diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 2314068044fb8..70e1307080818 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1087,18 +1087,9 @@ PHPDBG_COMMAND(info) /* {{{ */ { phpdbg_out("Execution Context Information\n\n"); #ifdef HAVE_PHPDBG_READLINE -# ifdef HAVE_LIBREADLINE - phpdbg_writeln( "Readline yes"); -# else - phpdbg_writeln("Readline no"); -# endif -# ifdef HAVE_LIBEDIT - phpdbg_writeln("Libedit yes"); -# else - phpdbg_writeln("Libedit no"); -# endif + phpdbg_writeln("Libedit yes"); #else - phpdbg_writeln("Readline unavailable"); + phpdbg_writeln("Libedit no"); #endif phpdbg_writeln("Exec %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");