summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi Collet <remi@php.net>2014-06-23 10:04:40 +0200
committerRemi Collet <remi@php.net>2014-06-23 10:21:19 +0200
commit0febafcfbe3e35f4a230430368ba931f19f8e957 (patch)
tree745cc1c42877f144a24f643dc80c9a5b940175c8
parent53158f2c32c71bddbfaa390c0c4758bc98540946 (diff)
downloadphp-git-0febafcfbe3e35f4a230430368ba931f19f8e957.tar.gz
Fix https://github.com/krakjoe/phpdbg/issues/91
Enable edit feature when build with libedit. Notice: coloured prompt only enable with READLINE
-rw-r--r--sapi/phpdbg/config.m42
-rw-r--r--sapi/phpdbg/phpdbg.h2
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c6
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c5
-rw-r--r--sapi/phpdbg/phpdbg_utils.c6
5 files changed, 15 insertions, 6 deletions
diff --git a/sapi/phpdbg/config.m4 b/sapi/phpdbg/config.m4
index 1a6640eaca..d78a439af0 100644
--- a/sapi/phpdbg/config.m4
+++ b/sapi/phpdbg/config.m4
@@ -21,7 +21,7 @@ if test "$PHP_PHPDBG" != "no"; then
PHP_PHPDBG_CFLAGS="-D_GNU_SOURCE"
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"
- if test "$PHP_READLINE" != "no"; then
+ if test "$PHP_READLINE" != "no" -o "$PHP_LIBEDIT" != "no"; then
PHPDBG_EXTRA_LIBS="$PHP_READLINE_LIBS"
fi
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index 12350d5425..b2e7a03c21 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -64,7 +64,7 @@
# include "TSRM.h"
#endif
-#ifdef HAVE_LIBREADLINE
+#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
# include <readline/readline.h>
# include <readline/history.h>
#endif
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index d4ce8ebc55..a45513bee6 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -792,7 +792,7 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why TSRMLS_DC)
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
char *cmd = NULL;
-#ifndef HAVE_LIBREADLINE
+#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
char buf[PHPDBG_MAX_CMD];
#endif
char *buffer = NULL;
@@ -811,7 +811,7 @@ disconnect:
return NULL;
}
-#ifndef HAVE_LIBREADLINE
+#if !defined(HAVE_LIBREADLINE) && !defined(HAVE_LIBEDIT)
if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
if (!phpdbg_write("%s", phpdbg_get_prompt(TSRMLS_C))) {
goto disconnect;
@@ -850,7 +850,7 @@ readline:
buffer = estrdup(cmd);
-#ifdef HAVE_LIBREADLINE
+#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
if (!buffered && cmd &&
!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
free(cmd);
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index 5379e77586..d91ef3f3f5 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -732,6 +732,11 @@ PHPDBG_COMMAND(print) /* {{{ */
#else
phpdbg_writeln("Readline\tno");
#endif
+#ifdef HAVE_LIBEDIT
+ phpdbg_writeln("Libedit\t\tyes");
+#else
+ phpdbg_writeln("Libedit\t\tno");
+#endif
phpdbg_writeln("Exec\t\t%s", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none");
phpdbg_writeln("Compiled\t%s", PHPDBG_G(ops) ? "yes" : "no");
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index 98748b202a..3b4eac7327 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -400,12 +400,16 @@ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */
}
/* create cached prompt */
+#ifdef HAVE_LIBREADLINE
+ /* TODO: libedit doesn't seems to support coloured prompt */
if ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED)) {
asprintf(
&PHPDBG_G(prompt)[1], "\033[%sm%s\033[0m ",
PHPDBG_G(colors)[PHPDBG_COLOR_PROMPT]->code,
PHPDBG_G(prompt)[0]);
- } else {
+ } else
+#endif
+ {
asprintf(
&PHPDBG_G(prompt)[1], "%s ",
PHPDBG_G(prompt)[0]);