[hackers] [sbase] libutil/getlines: use known line length || Hiltjo Posthuma
commit bd67e7d92de6d768e726e268f927118fc5272c09
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Tue May 5 13:42:56 2015 +0200
libutil/getlines: use known line length
diff --git a/libutil/getlines.c b/libutil/getlines.c
index 820c781..89664cc 100644
--- a/libutil/getlines.c
+++ b/libutil/getlines.c
_AT_@ -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';
Received on Thu May 07 2015 - 19:18:55 CEST
This archive was generated by hypermail 2.3.0
: Thu May 07 2015 - 19:24:11 CEST