]> granicus.if.org Git - php/commitdiff
Fix #77805 phpdbg build fails when readline is shared
authorJoe Watkins <krakjoe@php.net>
Wed, 27 Mar 2019 08:58:40 +0000 (09:58 +0100)
committerJoe Watkins <krakjoe@php.net>
Wed, 27 Mar 2019 09:02:42 +0000 (10:02 +0100)
NEWS
sapi/phpdbg/config.m4
sapi/phpdbg/phpdbg.h
sapi/phpdbg/phpdbg_cmd.c
sapi/phpdbg/phpdbg_prompt.c

diff --git a/NEWS b/NEWS
index 1711079d218115b4617e0c836048cc865446c7f9..81d172797beb644b2506b342898f9a313c407800 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP                                                                        NEWS
   . Fixed bug #76801 (too many open files). (alekitto)
   . Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
     (krakjoe)
+  . Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe)
     
 - Reflection:
   . Fixed bug #77772 (ReflectionClass::getMethods(null) doesn't work). (Nikita)
index 223c1827f187e4f7470843f6ed4e17e6529e2ad9..d6765e1b1980b9f4dc3df26abe167f839ce63c28 100644 (file)
@@ -11,6 +11,9 @@ PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support,
 PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
 [  --enable-phpdbg-debug      Build phpdbg in debug mode], no, no)
 
+PHP_ARG_ENABLE(phpdbg-readline, for phpdbg readline support,
+[  --enable-phpdbg-readline   Enable readline support in phpdbg (depends on static ext/readline)], yes, yes)
+
 if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
   AC_HEADER_TIOCGWINSZ
   AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@@ -24,8 +27,17 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
   PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
   PHP_PHPDBG_FILES="phpdbg.c phpdbg_parser.c phpdbg_lexer.c phpdbg_prompt.c phpdbg_help.c phpdbg_break.c phpdbg_print.c phpdbg_bp.c phpdbg_opcode.c phpdbg_list.c phpdbg_utils.c phpdbg_info.c phpdbg_cmd.c phpdbg_set.c phpdbg_frame.c phpdbg_watch.c phpdbg_btree.c phpdbg_sigsafe.c phpdbg_wait.c phpdbg_io.c phpdbg_eol.c phpdbg_out.c"
 
-  if test "$PHP_READLINE" != "no" -o  "$PHP_LIBEDIT" != "no"; then
-       PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
+  AC_MSG_CHECKING([for phpdbg and readline integration])
+  if test "$PHP_PHPDBG_READLINE" = "yes"; then
+    if test "$PHP_READLINE" != "no" -o  "$PHP_LIBEDIT" != "no"; then
+         AC_DEFINE(HAVE_PHPDBG_READLINE, 1, [ ])
+         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
 
   PHP_SUBST(PHP_PHPDBG_CFLAGS)
index 980db28be9777131eeec1ba8a5d348524fb28554..e22a968d96564f1a3561f510015220d470f6ed5a 100644 (file)
 #define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
 #endif
 
-#ifdef HAVE_LIBREADLINE
-#      include <readline/readline.h>
-#      include <readline/history.h>
-#endif
-#ifdef HAVE_LIBEDIT
-#      include <editline/readline.h>
+#ifdef HAVE_PHPDBG_READLINE
+# ifdef HAVE_LIBREADLINE
+#       include <readline/readline.h>
+#       include <readline/history.h>
+# endif
+# ifdef HAVE_LIBEDIT
+#       include <editline/readline.h>
+# endif
 #endif
 
 /* {{{ remote console headers */
index b4a878818bee637600262d5cc50c1d6c2368be76..e93e92190e0bce84f390504e4493b3abd82f25c0 100644 (file)
@@ -751,16 +751,15 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
                }
 
                if (buffered == NULL) {
-#define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT))
+#ifdef HAVE_PHPDBG_READLINE
                        /* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */
-#if USE_LIB_STAR
                        if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) || !isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd))
 #endif
                        {
                                phpdbg_write("prompt", "", "%s", phpdbg_get_prompt());
                                phpdbg_consume_stdin_line(cmd = buf);
                        }
-#if USE_LIB_STAR
+#ifdef HAVE_PHPDBG_READLINE
                        else {
                                cmd = readline(phpdbg_get_prompt());
                                PHPDBG_G(last_was_newline) = 1;
@@ -779,7 +778,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
 
                buffer = estrdup(cmd);
 
-#if USE_LIB_STAR
+#ifdef HAVE_PHPDBG_READLINE
                if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
                        free(cmd);
                }
index 70c02221aa8bf40288bbd56b097f17c1d9673da3..fd668fcfecd2a08a1419b98c8cc0ff1627893bd0 100644 (file)
@@ -1158,15 +1158,19 @@ PHPDBG_COMMAND(info) /* {{{ */
 {
        phpdbg_out("Execution Context Information\n\n");
        phpdbg_xml("<printinfo %r>");
-#ifdef HAVE_LIBREADLINE
-       phpdbg_writeln("info", "readline=\"yes\"", "Readline   yes");
+#ifdef HAVE_PHPDBG_READLINE
+# ifdef HAVE_LIBREADLINE
+        phpdbg_writeln("info", "readline=\"yes\"", "Readline   yes");
+# else
+        phpdbg_writeln("info", "readline=\"no\"", "Readline   no");
+# endif
+# ifdef HAVE_LIBEDIT
+        phpdbg_writeln("info", "libedit=\"yes\"", "Libedit    yes");
+# else
+        phpdbg_writeln("info", "libedit=\"no\"", "Libedit    no");
+# endif
 #else
-       phpdbg_writeln("info", "readline=\"no\"", "Readline   no");
-#endif
-#ifdef HAVE_LIBEDIT
-       phpdbg_writeln("info", "libedit=\"yes\"", "Libedit    yes");
-#else
-       phpdbg_writeln("info", "libedit=\"no\"", "Libedit    no");
+     phpdbg_writeln("info", "readline=\"unavailable\"", "Readline   unavailable");
 #endif
 
        phpdbg_writeln("info", "context=\"%s\"", "Exec       %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");