diff options
author | Rob Landley <rob@landley.net> | 2016-09-03 15:41:55 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-09-03 15:41:55 -0500 |
commit | 7528a9628443b2d8e57b7bece698a5a6a0a3fe18 (patch) | |
tree | 88d17020076eaa496e5a4f6ce59d4420c30d4fe4 /toys/posix | |
parent | 7b7fec9cc6c67382ab4144d98e72c881858281f4 (diff) | |
download | toybox-7528a9628443b2d8e57b7bece698a5a6a0a3fe18.tar.gz |
Move genericish function to lib.
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/sed.c | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/toys/posix/sed.c b/toys/posix/sed.c index 71988248..c62d2d10 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -621,30 +621,6 @@ done: free(line); } -// Genericish function, can probably get moved to lib.c - -// Iterate over lines in file, calling function. Function can write 0 to -// the line pointer if they want to keep it, or 1 to terminate processing, -// otherwise line is freed. Passed file descriptor is closed at the end. -static void do_lines(int fd, void (*call)(char **pline, long len)) -{ - FILE *fp = fd ? xfdopen(fd, "r") : stdin; - - for (;;) { - char *line = 0; - ssize_t len; - - len = getline(&line, (void *)&len, fp); - if (len > 0) { - call(&line, len); - if (line == (void *)1) break; - free(line); - } else break; - } - - if (fd) fclose(fp); -} - // Callback called on each input file static void do_sed(int fd, char *name) { |