Skip to content

Commit 7af270e

Browse files
committed
Fix #77805 phpdbg build fails when readline is shared
1 parent 6d3a2b4 commit 7af270e

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

NEWS

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

1819
- Reflection:
1920
. 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
@@ -11,6 +11,9 @@ PHP_ARG_ENABLE(phpdbg-webhelper, for phpdbg web SAPI support,
1111
PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
1212
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
1313

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

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

3143
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,16 +751,15 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
751751
}
752752

753753
if (buffered == NULL) {
754-
#define USE_LIB_STAR (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT))
754+
#ifdef HAVE_PHPDBG_READLINE
755755
/* note: EOF makes readline write prompt again in local console mode - and ignored if compiled without readline */
756-
#if USE_LIB_STAR
757756
if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE) || !isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd))
758757
#endif
759758
{
760759
phpdbg_write("prompt", "", "%s", phpdbg_get_prompt());
761760
phpdbg_consume_stdin_line(cmd = buf);
762761
}
763-
#if USE_LIB_STAR
762+
#ifdef HAVE_PHPDBG_READLINE
764763
else {
765764
cmd = readline(phpdbg_get_prompt());
766765
PHPDBG_G(last_was_newline) = 1;
@@ -779,7 +778,7 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
779778

780779
buffer = estrdup(cmd);
781780

782-
#if USE_LIB_STAR
781+
#ifdef HAVE_PHPDBG_READLINE
783782
if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
784783
free(cmd);
785784
}

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)