From dcead8ea90537dea6b06306ebb4767b2ff57d5ba Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 17 Nov 2013 11:11:09 +0000 Subject: [PATCH] add highlight param to file listing --- phpdbg_list.c | 18 ++++++++++++------ phpdbg_list.h | 2 +- phpdbg_prompt.c | 9 +++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/phpdbg_list.c b/phpdbg_list.c index a778f640b1..ba1e31e43e 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -38,8 +38,8 @@ PHPDBG_LIST(lines) /* {{{ */ case EMPTY_PARAM: { if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) { if (param->type == EMPTY_PARAM) { - phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC); - } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC); + phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0, 0 TSRMLS_CC); + } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0, 0 TSRMLS_CC); } else phpdbg_error("Not executing, and execution context not set"); } break; @@ -106,7 +106,7 @@ PHPDBG_LIST(class) /* {{{ */ phpdbg_list_file( (*ce)->info.user.filename, (*ce)->info.user.line_end - (*ce)->info.user.line_start + 1, - (*ce)->info.user.line_start TSRMLS_CC + (*ce)->info.user.line_start, 0 TSRMLS_CC ); } else { phpdbg_error("The source of the requested class (%s) cannot be found", (*ce)->name); @@ -125,7 +125,7 @@ PHPDBG_LIST(class) /* {{{ */ return SUCCESS; } /* }}} */ -void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */ +void phpdbg_list_file(const char *filename, long count, long offset, int highlight TSRMLS_DC) /* {{{ */ { unsigned char *mem, *pos, *last_pos, *end_pos; struct stat st; @@ -185,7 +185,13 @@ void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) / if (!offset || offset <= line) { /* Without offset, or offset reached */ - phpdbg_writeln("%05u: %.*s", line, (int)(pos - last_pos), last_pos); + if (!highlight) { + phpdbg_writeln("%05u: %.*s", line, (int)(pos - last_pos), last_pos); + } else { + if (highlight != line) { + phpdbg_writeln(" %05u: %.*s", line, (int)(pos - last_pos), last_pos); + } else phpdbg_writeln(">%05u: %.*s", line, (int)(pos - last_pos), last_pos); + } ++displayed; } @@ -220,7 +226,7 @@ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */ ops = (zend_op_array*)fbc; phpdbg_list_file(ops->filename, - ops->line_end - ops->line_start + 1, ops->line_start TSRMLS_CC); + ops->line_end - ops->line_start + 1, ops->line_start, 0 TSRMLS_CC); } /* }}} */ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC) diff --git a/phpdbg_list.h b/phpdbg_list.h index 5c7e9885eb..0d869a94d7 100644 --- a/phpdbg_list.h +++ b/phpdbg_list.h @@ -41,7 +41,7 @@ PHPDBG_LIST(func); void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC); void phpdbg_list_function(const zend_function* TSRMLS_DC); -void phpdbg_list_file(const char*, long, long TSRMLS_DC); +void phpdbg_list_file(const char*, long, long, int TSRMLS_DC); static const phpdbg_command_t phpdbg_list_commands[] = { PHPDBG_LIST_EX_D(lines, "lists the specified lines", 'l'), diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 0281fd7ec6..d68933be3a 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -698,13 +698,13 @@ static PHPDBG_COMMAND(list) /* {{{ */ case EMPTY_PARAM: { if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) { if (param->type == EMPTY_PARAM) { - phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC); - } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC); + phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0, 0 TSRMLS_CC); + } else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0, 0 TSRMLS_CC); } else phpdbg_error("Not executing, and execution context not set"); } break; case FILE_PARAM: - phpdbg_list_file(param->file.name, param->file.line, 0 TSRMLS_CC); + phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC); break; case STR_PARAM: { @@ -1013,7 +1013,8 @@ zend_vm_enter: #define DO_INTERACTIVE() do {\ phpdbg_list_file(\ zend_get_executed_filename(TSRMLS_C), \ - 2, \ + 3, \ + zend_get_executed_lineno(TSRMLS_C)-1, \ zend_get_executed_lineno(TSRMLS_C) \ TSRMLS_CC\ );\ -- 2.50.1