Skip to content

Commit 4fde0c2

Browse files
committed
Fix issue krakjoe/phpdbg#97 - list now appends a newline if there is none
The prompt should always ensure it is on a newline
1 parent d298425 commit 4fde0c2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

phpdbg_list.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
130130
char *opened = NULL;
131131
char buffer[8096] = {0,};
132132
long line = 0;
133-
133+
134134
php_stream *stream = NULL;
135135

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

148148
while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) {
149+
long linelen = strlen(buffer);
150+
149151
++line;
150152

151153
if (!offset || offset <= line) {
@@ -159,9 +161,13 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
159161
phpdbg_write(">%05ld: %s", line, buffer);
160162
}
161163
}
164+
165+
if (buffer[linelen - 1] != '\n') {
166+
phpdbg_write("\n");
167+
}
162168
}
163-
164-
if ((count + (offset-1)) == line)
169+
170+
if ((count + (offset - 1)) == line)
165171
break;
166172
}
167173

0 commit comments

Comments
 (0)