diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-09-23 17:31:21 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-09-23 17:31:21 -0700 |
| commit | 04eb92153f04930b348f85120255c5715ec55b6f (patch) | |
| tree | 4a9838fbd09488850358c7272b256bb8b2a6bbc9 /files.c | |
| parent | c81601729ea2d1f7ef6aab14fec0e19ee326b740 (diff) | |
WIP
Diffstat (limited to 'files.c')
| -rw-r--r-- | files.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -36,7 +36,7 @@ static void populate_lines(file_t *f) f->lines = grow(f->lines, linecap *= 2); f->lines[n] = p; do { - char *nl = strchr(p, '\n'); + char *nl = memchr(p, '\n', (size_t)(f->end - p)); if (nl) { p = nl+1; break; @@ -234,7 +234,7 @@ void fprint_line(FILE *dest, file_t *f, const char *start, const char *end, cons va_end(args); (void)fputc('\n', dest); - const char *eol = linenum == f->nlines ? strchr(line, '\0') : strchr(line, '\n'); + const char *eol = linenum == f->nlines ? f->end : strchr(line, '\n'); if (end == NULL || end > eol) end = eol; fprintf(dest, "\033[2m%5lu\033(0\x78\033(B\033[m%.*s\033[41;30m%.*s\033[m%.*s\n", linenum, |
