sbase

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

commit 6579919fec1230a363a49276fb0a7414752c5da6
parent f769c2402f4f15c3d721bce6d1cf38fd891cace1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 31 Jan 2015 15:19:42 +0100

grep: getline returns signed (ssize_t)

Diffstat:
Mgrep.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/grep.c b/grep.c @@ -205,10 +205,10 @@ addpatternfile(FILE *fp) { static char *buf = NULL; static size_t size = 0; - size_t len = 0; + ssize_t len = 0; while ((len = getline(&buf, &size, fp)) != -1) { - if (len && buf[len - 1] == '\n') + if (len > 0 && buf[len - 1] == '\n') buf[len - 1] = '\0'; addpattern(buf); } @@ -221,7 +221,7 @@ grep(FILE *fp, const char *str) { static char *buf = NULL; static size_t size = 0; - size_t len = 0; + ssize_t len = 0; long c = 0, n; struct pattern *pnode; int match = NoMatch;