Skip to content

Commit eb405a2

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #77805 phpdbg build fails when readline is shared
2 parents 1e4cff9 + 7af270e commit eb405a2

File tree

5 files changed

+38
-24
lines changed

5 files changed

+38
-24
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PHP NEWS
1818
. Fixed bug #76801 (too many open files). (alekitto)
1919
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
2020
(krakjoe)
21+
. Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe)
2122

2223
- Reflection:
2324
. Fixed bug #77772 (ReflectionClass::getMethods(null) doesn't work). (Nikita)

sapi/phpdbg/config.m4

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support,
1010
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
1111
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
1212

13+
PHP_ARG_ENABLE(phpdbg-readline, for phpdbg readline support,
14+
[ --enable-phpdbg-readline Enable readline support in phpdbg (depends on static ext/readline)], yes, yes)
15+
1316
if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
1417
AC_HEADER_TIOCGWINSZ
1518
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@@ -23,8 +26,17 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
2326
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
2427
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"
2528

26-
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
27-
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
29+
AC_MSG_CHECKING([for phpdbg and readline integration])
30+
if test "$PHP_PHPDBG_READLINE" = "yes"; then
31+
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
32+
AC_DEFINE(HAVE_PHPDBG_READLINE, 1, [ ])
33+
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
34+
AC_MSG_RESULT([ok])
35+
else
36+
AC_MSG_RESULT([readline is not available])
37+
fi
38+
else
39+
AC_MSG_RESULT([disabled])
2840
fi
2941

3042
PHP_SUBST(PHP_PHPDBG_CFLAGS)

sapi/phpdbg/phpdbg.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@
8383
#define zend_hash_str_add(...) zend_hash_str_add_tmp(__VA_ARGS__)
8484
#endif
8585

86-
#ifdef HAVE_LIBREADLINE
87-
# include <readline/readline.h>
88-
# include <readline/history.h>
89-
#endif
90-
#ifdef HAVE_LIBEDIT
91-
# include <editline/readline.h>
86+
#ifdef HAVE_PHPDBG_READLINE
87+
# ifdef HAVE_LIBREADLINE
88+
# include <readline/readline.h>
89+
# include <readline/history.h>
90+
# endif
91+
# ifdef HAVE_LIBEDIT
92+
# include <editline/readline.h>
93+
# endif
9294
#endif
9395

9496
/* {{{ remote console headers */

sapi/phpdbg/phpdbg_cmd.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,20 +751,15 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
751751
}
752752

753753
if (buffered == NULL) {
754-
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
755-
#define USE_LIB_STAR 1
756-
#else
757-
#define USE_LIB_STAR 0
758-
#endif
754+
#ifdef HAVE_PHPDBG_READLINE
759755
/* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */
760-
#if USE_LIB_STAR
761756
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) || !isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd))
762757
#endif
763758
{
764759
phpdbg_write("prompt", "", "%s", phpdbg_get_prompt());
765760
phpdbg_consume_stdin_line(cmd = buf);
766761
}
767-
#if USE_LIB_STAR
762+
#ifdef HAVE_PHPDBG_READLINE
768763
else {
769764
cmd = readline(phpdbg_get_prompt());
770765
PHPDBG_G(last_was_newline) = 1;
@@ -783,7 +778,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
783778

784779
buffer = estrdup(cmd);
785780

786-
#if USE_LIB_STAR
781+
#ifdef HAVE_PHPDBG_READLINE
787782
if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
788783
free(cmd);
789784
}

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,15 +1158,19 @@ PHPDBG_COMMAND(info) /* {{{ */
11581158
{
11591159
phpdbg_out("Execution Context Information\n\n");
11601160
phpdbg_xml("<printinfo %r>");
1161-
#ifdef HAVE_LIBREADLINE
1162-
phpdbg_writeln("info", "readline=\"yes\"", "Readline yes");
1161+
#ifdef HAVE_PHPDBG_READLINE
1162+
# ifdef HAVE_LIBREADLINE
1163+
phpdbg_writeln("info", "readline=\"yes\"", "Readline yes");
1164+
# else
1165+
phpdbg_writeln("info", "readline=\"no\"", "Readline no");
1166+
# endif
1167+
# ifdef HAVE_LIBEDIT
1168+
phpdbg_writeln("info", "libedit=\"yes\"", "Libedit yes");
1169+
# else
1170+
phpdbg_writeln("info", "libedit=\"no\"", "Libedit no");
1171+
# endif
11631172
#else
1164-
phpdbg_writeln("info", "readline=\"no\"", "Readline no");
1165-
#endif
1166-
#ifdef HAVE_LIBEDIT
1167-
phpdbg_writeln("info", "libedit=\"yes\"", "Libedit yes");
1168-
#else
1169-
phpdbg_writeln("info", "libedit=\"no\"", "Libedit no");
1173+
phpdbg_writeln("info", "readline=\"unavailable\"", "Readline unavailable");
11701174
#endif
11711175

11721176
phpdbg_writeln("info", "context=\"%s\"", "Exec %s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");

0 commit comments

Comments
 (0)