sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit bd67e7d92de6d768e726e268f927118fc5272c09
parent 72250324b1af5c8d7d9a036fe8860252487a533f
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue,  5 May 2015 13:42:56 +0200

libutil/getlines: use known line length

Diffstat:
Mlibutil/getlines.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libutil/getlines.c b/libutil/getlines.c @@ -22,7 +22,7 @@ getlines(FILE *fp, struct linebuf *b) b->lines[b->nlines - 1] = memcpy(emalloc(linelen), line, linelen); } free(line); - if (b->lines && b->nlines && !strchr(b->lines[b->nlines - 1], '\n')) { + if (b->lines && b->nlines && b->lines[b->nlines - 1][linelen - 1] != '\n') { b->lines[b->nlines - 1] = erealloc(b->lines[b->nlines - 1], linelen + 1); b->lines[b->nlines - 1][linelen - 1] = '\n'; b->lines[b->nlines - 1][linelen] = '\0';