Skip to content

Commit 56293d0

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #77805 phpdbg build fails when readline is shared
2 parents f177a2a + eb405a2 commit 56293d0

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
@@ -88,6 +88,7 @@ PHP NEWS
8888
. Fixed bug #76801 (too many open files). (alekitto)
8989
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
9090
(krakjoe)
91+
. Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe)
9192

9293
- Sockets:
9394
. Fixed bug #67619 (Validate length on socket_write). (thiagooak)

sapi/phpdbg/config.m4

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ PHP_ARG_ENABLE([phpdbg-debug],
2020
[no],
2121
[no])
2222

23+
PHP_ARG_ENABLE(phpdbg-readline, for phpdbg readline support,
24+
[ --enable-phpdbg-readline Enable readline support in phpdbg (depends on static ext/readline)], yes, yes)
25+
2326
if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
2427
AC_HEADER_TIOCGWINSZ
2528
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
@@ -33,8 +36,17 @@ if test "$BUILD_PHPDBG" = "" && test "$PHP_PHPDBG" != "no"; then
3336
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
3437
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"
3538

36-
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
37-
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
39+
AC_MSG_CHECKING([for phpdbg and readline integration])
40+
if test "$PHP_PHPDBG_READLINE" = "yes"; then
41+
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
42+
AC_DEFINE(HAVE_PHPDBG_READLINE, 1, [ ])
43+
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
44+
AC_MSG_RESULT([ok])
45+
else
46+
AC_MSG_RESULT([readline is not available])
47+
fi
48+
else
49+
AC_MSG_RESULT([disabled])
3850
fi
3951

4052
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)