From: krakjoe Date: Wed, 13 Nov 2013 08:05:26 +0000 (+0000) Subject: non readline fixes X-Git-Tag: php-5.6.0alpha1~110^2~388 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e266f34fc4b45be6ee04749d62bb379bef2c692;p=php non readline fixes --- diff --git a/phpdbg_help.c b/phpdbg_help.c index 78d12c82a8..c337ec9214 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -67,8 +67,12 @@ PHPDBG_HELP(print) /* {{{ */ phpdbg_writeln("Examples:"); phpdbg_writeln("\t%sprint class \\my\\class", PROMPT); phpdbg_writeln("Will print information about \\my\\class, including the instructions for every method and their address"); + phpdbg_writeln("\t%sprint method \\my\\class::method", PROMPT); + phpdbg_writeln("Will print the instructions for \\my\\class::method"); phpdbg_writeln("\t%sprint func .getSomething", PROMPT); phpdbg_writeln("Will print the instructions for the method getSomething in the currently active scope"); + phpdbg_writeln("\t%sprint func my_function", PROMPT); + phpdbg_writeln("Will print the instructions for the global function my_function"); phpdbg_writeln("\t%sprint opline", PROMPT); phpdbg_writeln("Will print the instruction for the current opline"); phpdbg_writeln(EMPTY); diff --git a/phpdbg_print.c b/phpdbg_print.c index 1524ec5bf9..600d8f2795 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -146,6 +146,8 @@ PHPDBG_PRINT(method) /* {{{ */ } else { phpdbg_error("The method %s could not be found", func_name); } + } else { + phpdbg_error("Failed to find the requested class %s", class_name); } efree(class_name); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 60982a9d80..85c5345fcc 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -208,8 +208,7 @@ static PHPDBG_COMMAND(back) /* {{{ */ static PHPDBG_COMMAND(print) /* {{{ */ { if (expr && expr_len > 0L) { - if (phpdbg_print_commands && - phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) { + if (phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) { phpdbg_error("Failed to find print command %s", expr); } return SUCCESS; @@ -569,7 +568,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ /* ensure string is null terminated */ cmd[cmd_len] = '\0'; - if (cmd && cmd_len > 0L) { + if (*cmd && cmd_len > 0L) { #ifdef HAVE_LIBREADLINE add_history(cmd); #endif diff --git a/phpdbg_utils.c b/phpdbg_utils.c index df37df088e..4fff4673e1 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -71,8 +71,9 @@ int phpdbg_is_class_method(const char *str, size_t len, char **class, char **met return 1; } /* }}} */ -void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */ +int phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */ { + int rc = 0; char *buffer = NULL; va_list args; @@ -86,39 +87,41 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */ switch (type) { case ERROR: - printf("%s%s%s\n", - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["), - buffer, - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]")); + rc = printf("%s%s%s\n", + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["), + buffer, + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]")); break; case NOTICE: - printf("%s%s%s\n", - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["), - buffer, - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]")); + rc = printf("%s%s%s\n", + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["), + buffer, + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]")); break; case WRITELN: { if (buffer) { - printf("%s%s%s\n", - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""), - buffer, - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : "")); + rc = printf("%s%s%s\n", + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""), + buffer, + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : "")); } else { - printf("\n"); + rc = printf("\n"); } } break; case WRITE: if (buffer) { - printf("%s%s%s", - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""), - buffer, - ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : "")); + rc = printf("%s%s%s", + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""), + buffer, + ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : "")); } break; } if (buffer) { efree(buffer); } + + return rc; } /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 7682201493..b45342d0e0 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -38,7 +38,7 @@ enum { WRITE }; -void phpdbg_print(int TSRMLS_DC, const char*, ...); +int phpdbg_print(int TSRMLS_DC, const char*, ...); #define phpdbg_error(fmt, ...) phpdbg_print(ERROR TSRMLS_CC, fmt, ##__VA_ARGS__) #define phpdbg_notice(fmt, ...) phpdbg_print(NOTICE TSRMLS_CC, fmt, ##__VA_ARGS__)