summaryrefslogtreecommitdiff
path: root/findutils/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'findutils/grep.c')
-rw-r--r--findutils/grep.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 6872ac2..bb1a146 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -65,16 +65,13 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName,
{
char *cp;
long line = 0;
- char haystack[BUF_SIZE];
+ char *haystack;
int truth = !invertSearch;
- while (fgets(haystack, sizeof(haystack), fp)) {
+ while ((haystack = cstring_lineFromFile(fp))) {
line++;
cp = &haystack[strlen(haystack) - 1];
- if (*cp != '\n')
- fprintf(stderr, "%s: Line too long\n", fileName);
-
if (find_match(haystack, needle, ignoreCase) == truth) {
if (tellName == TRUE)
printf("%s:", fileName);
@@ -87,6 +84,7 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName,
match = TRUE;
}
+ free(haystack);
}
}