Skip to content

Commit 0febafc

Browse files
committed
Enable edit feature when build with libedit. Notice: coloured prompt only enable with READLINE
1 parent 53158f2 commit 0febafc

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

sapi/phpdbg/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then
2121
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
2222
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"
2323

24-
if test "$PHP_READLINE" != "no"; then
24+
if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
2525
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
2626
fi
2727

sapi/phpdbg/phpdbg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
# include "TSRM.h"
6565
#endif
6666

67-
#ifdef HAVE_LIBREADLINE
67+
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
6868
# include <readline/readline.h>
6969
# include <readline/history.h>
7070
#endif

sapi/phpdbg/phpdbg_cmd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC)
792792
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
793793
{
794794
char *cmd = NULL;
795-
#ifndef HAVE_LIBREADLINE
795+
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
796796
char buf[PHPDBG_MAX_CMD];
797797
#endif
798798
char *buffer = NULL;
@@ -811,7 +811,7 @@ PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
811811
return NULL;
812812
}
813813

814-
#ifndef HAVE_LIBREADLINE
814+
#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
815815
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
816816
if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) {
817817
goto disconnect;
@@ -850,7 +850,7 @@ PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
850850

851851
buffer = estrdup(cmd);
852852

853-
#ifdef HAVE_LIBREADLINE
853+
#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
854854
if (!buffered && cmd &&
855855
!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
856856
free(cmd);

sapi/phpdbg/phpdbg_prompt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,11 @@ PHPDBG_COMMAND(print) /* {{{ */
732732
#else
733733
phpdbg_writeln("Readline\tno");
734734
#endif
735+
#ifdef HAVE_LIBEDIT
736+
phpdbg_writeln("Libedit\t\tyes");
737+
#else
738+
phpdbg_writeln("Libedit\t\tno");
739+
#endif
735740

736741
phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");
737742
phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no");

sapi/phpdbg/phpdbg_utils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,16 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */
400400
}
401401

402402
/* create cached prompt */
403+
#ifdef HAVE_LIBREADLINE
404+
/* TODO: libedit doesn't seems to support coloured prompt */
403405
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
404406
asprintf(
405407
&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
406408
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
407409
PHPDBG_G(prompt)[0]);
408-
} else {
410+
} else
411+
#endif
412+
{
409413
asprintf(
410414
&PHPDBG_G(prompt)[1], "%s ",
411415
PHPDBG_G(prompt)[0]);

0 commit comments

Comments
 (0)