Cleanup print_buff_lines

This commit is contained in:
twinaphex 2015-01-25 07:40:36 +01:00
parent 4e8020bf90
commit 8b086d0cc5

View File

@ -2163,12 +2163,17 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size,
for (i = 0; i < buf_size; i++)
{
if (*(buf + i) == '\n')
{
/* Found a line ending, print the line and compute new line_start */
size_t ln;
/* The end of the buffer, print the last bit */
if (*(buf + i) == '\0')
break;
if (*(buf + i) != '\n')
continue;
/* Found a line ending, print the line and compute new line_start */
/* Save the next char */
c = *(buf + i + 1);
/* replace with \0 */
@ -2186,12 +2191,6 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size,
*(buf + i + 1) = c;
line_start = buf + i + 1;
}
else if (*(buf + i) == '\0')
{
/* The end of the buffer, print the last bit */
break;
}
}
/* If the buffer was completely full, and didn't end with a newline, just
* ignore the partial last line.
*/