From 2be5a1e3da05caee88bc92f2abec223cc999c1f0 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 25 Nov 2013 20:33:52 +0100 Subject: [PATCH] Enable backwards reading in list command --- phpdbg_list.c | 5 +++-- phpdbg_prompt.c | 4 ++++ phpdbg_utils.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/phpdbg_list.c b/phpdbg_list.c index 14ca56c1c3..05231bcf97 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -42,8 +42,9 @@ PHPDBG_LIST(lines) /* {{{ */ case NUMERIC_PARAM: case EMPTY_PARAM: phpdbg_list_file(phpdbg_current_file(TSRMLS_C), - param->type == EMPTY_PARAM ? 0 : param->num, - zend_get_executed_lineno(TSRMLS_C), 0 TSRMLS_CC); + param->type == EMPTY_PARAM ? 0 : (param->num < 0 ? 1 - param->num : param->num), + (param->type != EMPTY_PARAM && param->num < 0 ? param->num : 0) + zend_get_executed_lineno(TSRMLS_C), + 0 TSRMLS_CC); break; case FILE_PARAM: phpdbg_list_file(param->file.name, param->file.line, 0, 0 TSRMLS_CC); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 679f52f95b..eff36f4253 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -668,6 +668,10 @@ PHPDBG_COMMAND(back) /* {{{ */ zval **file, **line, **funcname, **class, **type, **args; char is_class; + if (limit < 0) { + phpdbg_error("Invalid backtrace size %d", limit); + } + zend_fetch_debug_backtrace( &zbacktrace, 0, 0, limit TSRMLS_CC); diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 2c73f9b55b..5a922e8e53 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -69,7 +69,7 @@ PHPDBG_API int phpdbg_is_numeric(const char *str) /* {{{ */ return 0; for (; *str; str++) { - if (isspace(*str)) { + if (isspace(*str) || *str == '-') { continue; } return isdigit(*str); -- 2.50.1