Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix issue krakjoe/phpdbg#97 - list now appends a newline if there is …
…none

The prompt should always ensure it is on a newline
  • Loading branch information
bwoebi committed Jun 29, 2014
1 parent d298425 commit 4fde0c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions phpdbg_list.c
Expand Up @@ -130,7 +130,7 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
char *opened = NULL;
char buffer[8096] = {0,};
long line = 0;

php_stream *stream = NULL;

if (VCWD_STAT(filename, &st) == FAILURE) {
Expand All @@ -146,6 +146,8 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
}

while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) {
long linelen = strlen(buffer);

++line;

if (!offset || offset <= line) {
Expand All @@ -159,9 +161,13 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
phpdbg_write(">%05ld: %s", line, buffer);
}
}

if (buffer[linelen - 1] != '\n') {
phpdbg_write("\n");
}
}
if ((count + (offset-1)) == line)

if ((count + (offset - 1)) == line)
break;
}

Expand Down

0 comments on commit 4fde0c2

Please sign in to comment.