aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/files.c b/files.c
index 26c6535..22eaed1 100644
--- a/files.c
+++ b/files.c
@@ -27,19 +27,14 @@ static void populate_lines(file_t *f)
f->lines = new(const char*[linecap]);
f->nlines = 0;
char *p = f->start;
- for (size_t n = 0; p && p < f->end; ++n) {
+ for (size_t n = 0; p && p <= f->end; ++n) {
++f->nlines;
if (n >= linecap)
f->lines = grow(f->lines, linecap *= 2);
f->lines[n] = p;
- do {
- char *nl = memchr(p, '\n', (size_t)(f->end - p));
- if (nl) {
- p = nl+1;
- break;
- } else if (p < f->end)
- p += strlen(p)+1;
- } while (p < f->end);
+ char *nl = memchr(p, '\n', (size_t)(f->end - p));
+ if (nl && nl < f->end) p = nl+1;
+ else break;
}
}