Skip to content

Commit 5e266f3

Browse files
committed
non readline fixes
1 parent b6c4fbe commit 5e266f3

File tree

5 files changed

+30
-22
lines changed

5 files changed

+30
-22
lines changed

phpdbg_help.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ PHPDBG_HELP(print) /* {{{ */
6767
phpdbg_writeln("Examples:");
6868
phpdbg_writeln("\t%sprint class \\my\\class", PROMPT);
6969
phpdbg_writeln("Will print information about \\my\\class, including the instructions for every method and their address");
70+
phpdbg_writeln("\t%sprint method \\my\\class::method", PROMPT);
71+
phpdbg_writeln("Will print the instructions for \\my\\class::method");
7072
phpdbg_writeln("\t%sprint func .getSomething", PROMPT);
7173
phpdbg_writeln("Will print the instructions for the method getSomething in the currently active scope");
74+
phpdbg_writeln("\t%sprint func my_function", PROMPT);
75+
phpdbg_writeln("Will print the instructions for the global function my_function");
7276
phpdbg_writeln("\t%sprint opline", PROMPT);
7377
phpdbg_writeln("Will print the instruction for the current opline");
7478
phpdbg_writeln(EMPTY);

phpdbg_print.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ PHPDBG_PRINT(method) /* {{{ */
146146
} else {
147147
phpdbg_error("The method %s could not be found", func_name);
148148
}
149+
} else {
150+
phpdbg_error("Failed to find the requested class %s", class_name);
149151
}
150152

151153
efree(class_name);

phpdbg_prompt.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ static PHPDBG_COMMAND(back) /* {{{ */
208208
static PHPDBG_COMMAND(print) /* {{{ */
209209
{
210210
if (expr && expr_len > 0L) {
211-
if (phpdbg_print_commands &&
212-
phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
211+
if (phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
213212
phpdbg_error("Failed to find print command %s", expr);
214213
}
215214
return SUCCESS;
@@ -569,7 +568,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
569568
/* ensure string is null terminated */
570569
cmd[cmd_len] = '\0';
571570

572-
if (cmd && cmd_len > 0L) {
571+
if (*cmd && cmd_len > 0L) {
573572
#ifdef HAVE_LIBREADLINE
574573
add_history(cmd);
575574
#endif

phpdbg_utils.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ int phpdbg_is_class_method(const char *str, size_t len, char **class, char **met
7171
return 1;
7272
} /* }}} */
7373

74-
void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
74+
int phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
7575
{
76+
int rc = 0;
7677
char *buffer = NULL;
7778
va_list args;
7879

@@ -86,39 +87,41 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
8687

8788
switch (type) {
8889
case ERROR:
89-
printf("%s%s%s\n",
90-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
91-
buffer,
92-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
90+
rc = printf("%s%s%s\n",
91+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
92+
buffer,
93+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
9394
break;
9495

9596
case NOTICE:
96-
printf("%s%s%s\n",
97-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
98-
buffer,
99-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
97+
rc = printf("%s%s%s\n",
98+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
99+
buffer,
100+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
100101
break;
101102

102103
case WRITELN: {
103104
if (buffer) {
104-
printf("%s%s%s\n",
105-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
106-
buffer,
107-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
105+
rc = printf("%s%s%s\n",
106+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
107+
buffer,
108+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
108109
} else {
109-
printf("\n");
110+
rc = printf("\n");
110111
}
111112
} break;
112113

113114
case WRITE: if (buffer) {
114-
printf("%s%s%s",
115-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
116-
buffer,
117-
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
115+
rc = printf("%s%s%s",
116+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[37m" : ""),
117+
buffer,
118+
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
118119
} break;
119120
}
120121

121122
if (buffer) {
122123
efree(buffer);
123124
}
125+
126+
return rc;
124127
} /* }}} */

phpdbg_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum {
3838
WRITE
3939
};
4040

41-
void phpdbg_print(int TSRMLS_DC, const char*, ...);
41+
int phpdbg_print(int TSRMLS_DC, const char*, ...);
4242

4343
#define phpdbg_error(fmt, ...) phpdbg_print(ERROR TSRMLS_CC, fmt, ##__VA_ARGS__)
4444
#define phpdbg_notice(fmt, ...) phpdbg_print(NOTICE TSRMLS_CC, fmt, ##__VA_ARGS__)

0 commit comments

Comments
 (0)