]> granicus.if.org Git - php/commitdiff
non readline fixes
authorkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 08:05:26 +0000 (08:05 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 08:05:26 +0000 (08:05 +0000)
phpdbg_help.c
phpdbg_print.c
phpdbg_prompt.c
phpdbg_utils.c
phpdbg_utils.h

index 78d12c82a8aff4e6110a7ac0fe3aa5946d6d1dce..c337ec92142a492ff0c9f6cf39f211d00317dc61 100644 (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);
index 1524ec5bf9da72b56ded91741de5710f01f1c6c6..600d8f2795c35d0483136277a7d99e6453791d3d 100644 (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);
index 60982a9d805b4eb81bbd009030ba9d227eee74dc..85c5345fcc8ba2897adc8611614ff669c90aef3b 100644 (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
index df37df088e1d3fc38d062ec4d38c661dc2a5f071..4fff4673e14c69c93f34fe143075266d7c92d9eb 100644 (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;
 } /* }}} */
index 7682201493f94bfc1bb6171e9a6fdf2953f70b3a..b45342d0e07b14c455e744d5e0fd98c2c2735e0c 100644 (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__)