]> granicus.if.org Git - php/commitdiff
Fix https://github.com/krakjoe/phpdbg/issues/91
authorRemi Collet <remi@php.net>
Mon, 23 Jun 2014 08:04:40 +0000 (10:04 +0200)
committerRemi Collet <remi@php.net>
Mon, 23 Jun 2014 08:21:19 +0000 (10:21 +0200)
Enable edit feature when build with libedit.

Notice: coloured prompt only enable with READLINE

sapi/phpdbg/config.m4
sapi/phpdbg/phpdbg.h
sapi/phpdbg/phpdbg_cmd.c
sapi/phpdbg/phpdbg_prompt.c
sapi/phpdbg/phpdbg_utils.c

index 1a6640eaca280d1aa91660f5355b310ef3f5e32d..d78a439af0248014965b26d6535968e61da5af0c 100644 (file)
@@ -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
   
index 12350d5425dc61a07d5465cf9a4f461a63796adf..b2e7a03c213e836731b5fc0dd77815519dc47905 100644 (file)
@@ -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
index d4ce8ebc55f36b4c28ab478a6b441eb2b1e54052..a45513bee6b39012493c5f474d6925567854bd60 100644 (file)
@@ -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);
index 5379e77586772eee12a9a65f605fabe72464bea2..d91ef3f3f5c89e4036fe0713baf47afac0827cab 100644 (file)
@@ -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");
index 98748b202a12dcbb8e8f8e086aa5e3aec2a878a2..3b4eac73279c6bb484af70ca984026b2fc12b1c6 100644 (file)
@@ -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]);