From c7b51537a03734a3e0a8fbb9100840cd64a66d37 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Tue, 12 Nov 2013 02:29:56 +0000 Subject: [PATCH] fix --- phpdbg_list.c | 15 ++++++++------- phpdbg_list.h | 2 +- phpdbg_prompt.c | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/phpdbg_list.c b/phpdbg_list.c index d460315531..f4209e1219 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -23,25 +23,26 @@ #include #include #include +#include "phpdbg.h" #include "phpdbg_list.h" -void phpdbg_list_file(const char *filename, long count, long offset) /* {{{ */ +void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */ { unsigned char *mem, *pos, *last_pos, *end_pos; struct stat st; int fd, all_content = (count == 0); unsigned int line = 0, displayed = 0; - if ((fd = open(filename, O_RDONLY)) == -1) { - printf("[Failed to open file %s to list]\n", filename); - return; - } - - if (fstat(fd, &st) == -1) { + if (VCWD_STAT(filename, &st) == -1) { printf("[Failed to stat file %s]\n", filename); goto out; } + if ((fd = VCWD_OPEN(filename, O_RDONLY)) == -1) { + printf("[Failed to open file %s to list]\n", filename); + return; + } + last_pos = mem = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); end_pos = mem + st.st_size; diff --git a/phpdbg_list.h b/phpdbg_list.h index 4531a65d10..883f9917f1 100644 --- a/phpdbg_list.h +++ b/phpdbg_list.h @@ -20,6 +20,6 @@ #ifndef PHPDBG_LIST_H #define PHPDBG_LIST_H -void phpdbg_list_file(const char*, long, long); +void phpdbg_list_file(const char*, long, long TSRMLS_DC); #endif /* PHPDBG_LIST_H */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index fb6ba7cebc..c30d15589b 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -508,7 +508,7 @@ static PHPDBG_COMMAND(list) /* {{{ */ return SUCCESS; } - phpdbg_list_file(filename, count, offset); + phpdbg_list_file(filename, count, offset TSRMLS_CC); return SUCCESS; } /* }}} */ -- 2.50.1