1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 07:58:20 +02:00

non readline fixes

This commit is contained in:
krakjoe
2013-11-13 08:05:26 +00:00
parent b6c4fbee1b
commit 5e266f34fc
5 changed files with 30 additions and 22 deletions
+4
View File
@@ -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);
+2
View File
@@ -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);
+2 -3
View File
@@ -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
+21 -18
View File
@@ -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;
} /* }}} */
+1 -1
View File
@@ -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__)