aboutsummaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorMark Whitley <markw@lineo.com>2000-06-28 22:15:26 +0000
committerMark Whitley <markw@lineo.com>2000-06-28 22:15:26 +0000
commit1ca41775bbdc07cf67be79aebc566754c9c02855 (patch)
tree0ac134f0a80036aec272b04c3a057ea2ae055b20 /findutils
parentd37218941c37795cc8e96ddb3312d83fb2269d5a (diff)
downloadbusybox-1ca41775bbdc07cf67be79aebc566754c9c02855.tar.gz
Yanked out the cstring_alloc() and cstring_lineFromFile() functions from
utility.c and replaced them with get_line_from_file() from the new grep.c. Also changed declaration in internal.h and replaced instances of cstring_lineFromFile() in dc.c and sort.c with get_line_from_file(). Tested them and they worked fine.
Diffstat (limited to 'findutils')
-rw-r--r--findutils/grep.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index aca469e2f..a374e114d 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -46,8 +46,6 @@ static const char grep_usage[] =
#endif
;
-static const int GROWBY = 80; /* how large we will grow strings by */
-
/* options */
static int ignore_case = 0;
static int print_filename = 0;
@@ -62,35 +60,6 @@ static int nmatches = 0; /* keeps track of the number of matches */
static char *cur_file = NULL; /* the current file we are reading */
-/* This returns a malloc'ed char * which must be stored and free'ed */
-/* XXX: This function should probably go in a 'common'/'util'/'misc' file
- * somewhere so it can be used by other folks. */
-static char *get_line_from_file(FILE *file)
-{
- int ch;
- int idx = 0;
- char *linebuf = NULL;
- int linebufsz = 0;
-
- while (1) {
- ch = fgetc(file);
- if (ch == EOF)
- break;
- /* grow the line buffer as necessary */
- if (idx > linebufsz-1)
- linebuf = realloc(linebuf, linebufsz += GROWBY);
- linebuf[idx++] = (char)ch;
- if ((char)ch == '\n')
- break;
- }
-
- if (idx == 0)
- return NULL;
-
- linebuf[idx] = 0;
- return linebuf;
-}
-
static void print_matched_line(char *line, int linenum)
{
if (print_filename)