aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>2000-06-12 23:39:04 +0000
committerJohn Beppu <beppu@lbox.org>2000-06-12 23:39:04 +0000
commitc7ccfc99fc3ce621cc3739896493670316184dec (patch)
treeb7b02e5968fb4db92de8b2cf2645d1a6e44ef463
parent9f16d614083a96b521cbbca6d5c0b33da91991c4 (diff)
downloadbusybox-w32-c7ccfc99fc3ce621cc3739896493670316184dec.tar.gz
busybox-w32-c7ccfc99fc3ce621cc3739896493670316184dec.tar.bz2
busybox-w32-c7ccfc99fc3ce621cc3739896493670316184dec.zip
+ 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.c8
-rw-r--r--grep.c8
-rw-r--r--utility.c2
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,
65{ 65{
66 char *cp; 66 char *cp;
67 long line = 0; 67 long line = 0;
68 char haystack[BUF_SIZE]; 68 char *haystack;
69 int truth = !invertSearch; 69 int truth = !invertSearch;
70 70
71 while (fgets(haystack, sizeof(haystack), fp)) { 71 while ((haystack = cstring_lineFromFile(fp))) {
72 line++; 72 line++;
73 cp = &haystack[strlen(haystack) - 1]; 73 cp = &haystack[strlen(haystack) - 1];
74 74
75 if (*cp != '\n')
76 fprintf(stderr, "%s: Line too long\n", fileName);
77
78 if (find_match(haystack, needle, ignoreCase) == truth) { 75 if (find_match(haystack, needle, ignoreCase) == truth) {
79 if (tellName == TRUE) 76 if (tellName == TRUE)
80 printf("%s:", fileName); 77 printf("%s:", fileName);
@@ -87,6 +84,7 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName,
87 84
88 match = TRUE; 85 match = TRUE;
89 } 86 }
87 free(haystack);
90 } 88 }
91} 89}
92 90
diff --git a/grep.c b/grep.c
index 6872ac271..bb1a14622 100644
--- a/grep.c
+++ b/grep.c
@@ -65,16 +65,13 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName,
65{ 65{
66 char *cp; 66 char *cp;
67 long line = 0; 67 long line = 0;
68 char haystack[BUF_SIZE]; 68 char *haystack;
69 int truth = !invertSearch; 69 int truth = !invertSearch;
70 70
71 while (fgets(haystack, sizeof(haystack), fp)) { 71 while ((haystack = cstring_lineFromFile(fp))) {
72 line++; 72 line++;
73 cp = &haystack[strlen(haystack) - 1]; 73 cp = &haystack[strlen(haystack) - 1];
74 74
75 if (*cp != '\n')
76 fprintf(stderr, "%s: Line too long\n", fileName);
77
78 if (find_match(haystack, needle, ignoreCase) == truth) { 75 if (find_match(haystack, needle, ignoreCase) == truth) {
79 if (tellName == TRUE) 76 if (tellName == TRUE)
80 printf("%s:", fileName); 77 printf("%s:", fileName);
@@ -87,6 +84,7 @@ static void do_grep(FILE * fp, char *needle, char *fileName, int tellName,
87 84
88 match = TRUE; 85 match = TRUE;
89 } 86 }
87 free(haystack);
90 } 88 }
91} 89}
92 90
diff --git a/utility.c b/utility.c
index 48aaeb85d..b9c7a76cd 100644
--- a/utility.c
+++ b/utility.c
@@ -1573,7 +1573,7 @@ extern int find_real_root_device_name(char* name)
1573} 1573}
1574#endif 1574#endif
1575 1575
1576const unsigned int CSTRING_BUFFER_LENGTH = 128; 1576const unsigned int CSTRING_BUFFER_LENGTH = 1024;
1577/* recursive parser that returns cstrings of arbitrary length 1577/* recursive parser that returns cstrings of arbitrary length
1578 * from a FILE* 1578 * from a FILE*
1579 */ 1579 */