[hackers] [sbase] grep: getline returns signed (ssize_t) || Hiltjo Posthuma
commit 3ffe33ae9ebd9f1b8ac6ba8b17efc3c11a57b6c5
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat Jan 31 15:19:42 2015 +0100
grep: getline returns signed (ssize_t)
diff --git a/grep.c b/grep.c
index 6f6927e..11937e9 100644
--- a/grep.c
+++ b/grep.c
_AT_@ -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);
}
_AT_@ -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;
Received on Sat Jan 31 2015 - 20:14:56 CET
This archive was generated by hypermail 2.3.0
: Sat Jan 31 2015 - 20:24:18 CET