com php-src: added phpdbg_write to replace all the printf: phpdbg_prompt.c phpdbg_utils.c phpdb g_utils.h
| From: | Bob Weinand | Date: | Tue, 12 Nov 2013 23:10:53 +0000 |
| Subject: | com php-src: added phpdbg_write to replace all the printf: phpdbg_prompt.c phpdbg_utils.c phpdb g_utils.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75050@lists.php.net to get a copy of this message | ||
Commit: a712674964ffbabf93dae6eac6e4394079567a51
Author: krakjoe <joe.watkins@live.co.uk> Tue, 12 Nov 2013 23:10:53 +0000
Parents: ff54d20b583e41e996bdbf4c49b72919f3988f8b
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a712674964ffbabf93dae6eac6e4394079567a51
Log:
added phpdbg_write to replace all the printf
Changed paths:
M phpdbg_prompt.c
M phpdbg_utils.c
M phpdbg_utils.h
Diff:
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 444d3d4..a322373 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -357,19 +357,21 @@ static int clean_non_persistent_function_full(zend_function *function
TSRMLS_DC)
static PHPDBG_COMMAND(clean) /* {{{ */
{
if (!EG(in_execution)) {
- printf("[Cleaning Environment:]\n");
- printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
- printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
- printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
- printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
+ phpdbg_notice("Cleaning Execution Environment");
+
+ phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
+ phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
+ phpdbg_write("Constants\t%d", zend_hash_num_elements(EG(zend_constants)));
+ phpdbg_write("Includes\t%d", zend_hash_num_elements(&EG(included_files)));
phpdbg_clean(1 TSRMLS_CC);
- printf("[Clean Environment:]\n");
- printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
- printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
- printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
- printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
+ phpdbg_notice("Clean Execution Environment");
+
+ phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
+ phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
+ phpdbg_write("Constants\t%d", zend_hash_num_elements(EG(zend_constants)));
+ phpdbg_write("Includes\t%d", zend_hash_num_elements(&EG(included_files)));
} else {
phpdbg_error("Cannot clean environment while executing");
return FAILURE;
@@ -380,12 +382,13 @@ static PHPDBG_COMMAND(clean) /* {{{ */
static PHPDBG_COMMAND(clear) /* {{{ */
{
- printf("[Clearing Breakpoints:]\n");
- printf("[\tFile\t%d]\n",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
- printf("[\tSymbols\t%d]\n",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
- printf("[\tOplines\t%d]\n",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
- printf("[\tMethods\t%d]\n",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
-
+ phpdbg_notice("Clearing Breakpoints");
+
+ phpdbg_write("File\t%d",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
+ phpdbg_write("Functions\t%d",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
+ phpdbg_write("Methods\t%d",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
+ phpdbg_write("Oplines\t%d",
zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
+
phpdbg_clear_breakpoints(TSRMLS_C);
return SUCCESS;
diff --git a/phpdbg_utils.c b/phpdbg_utils.c
index f37135f..4607bf6 100644
--- a/phpdbg_utils.c
+++ b/phpdbg_utils.c
@@ -79,19 +79,28 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
vspprintf(&buffer, 0, format, args);
va_end(args);
+ /* TODO(anyone) colours */
+
switch (type) {
case ERROR:
printf("%s%s%s\n",
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
buffer,
- PHPDBG_END_LINE(TSRMLS_D));
+ ((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_END_LINE(TSRMLS_D));
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
+ break;
+
+ case WRITE:
+ printf("%s%s%s\n",
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m" : ""),
+ buffer,
+ ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
break;
}
diff --git a/phpdbg_utils.h b/phpdbg_utils.h
index 432d6a0..af659c0 100644
--- a/phpdbg_utils.h
+++ b/phpdbg_utils.h
@@ -31,16 +31,18 @@ int phpdbg_is_addr(const char*);
int phpdbg_is_class_method(const char*, size_t, char**, char**);
/**
- * Error/notice printing helper
+ * Error/notice/formatting helper
*/
enum {
ERROR = 1,
- NOTICE
+ NOTICE,
+ WRITE
};
void 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__)
+#define phpdbg_write(fmt, ...) phpdbg_print(WRITE TSRMLS_CC, fmt, ##__VA_ARGS__)
#endif /* PHPDBG_UTILS_H */