diff options
author | John Beppu <beppu@lbox.org> | 2000-06-12 23:39:04 +0000 |
---|---|---|
committer | John Beppu <beppu@lbox.org> | 2000-06-12 23:39:04 +0000 |
commit | c7ccfc99fc3ce621cc3739896493670316184dec (patch) | |
tree | b7b02e5968fb4db92de8b2cf2645d1a6e44ef463 | |
parent | 9f16d614083a96b521cbbca6d5c0b33da91991c4 (diff) | |
download | busybox-c7ccfc99fc3ce621cc3739896493670316184dec.tar.gz |
+ utility.c
CSTRING_BUFFER_LENGTH = 1024 /* so it recurses less often */
+ grep.c
uses cstring_lineFromFile(), and doesn't ever say
Line is too long, anymore
-rw-r--r-- | findutils/grep.c | 8 | ||||
-rw-r--r-- | grep.c | 8 | ||||
-rw-r--r-- | utility.c | 2 |
3 files changed, 7 insertions, 11 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 6872ac271..bb1a14622 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); } } @@ -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); } } @@ -1573,7 +1573,7 @@ extern int find_real_root_device_name(char* name) } #endif -const unsigned int CSTRING_BUFFER_LENGTH = 128; +const unsigned int CSTRING_BUFFER_LENGTH = 1024; /* recursive parser that returns cstrings of arbitrary length * from a FILE* */ |