From 411f7fc4781f6758a50ce206df62efd809c20186 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 12 Jan 2019 09:30:29 -0800 Subject: sed: add -z. Used to construct SELinux policies in the AOSP build. I left loopfiles_lines with its hard-coded '\n' because although cut(1) also has a -z option, I can't find any case where it's used in any of the codebases searchable by me. (And fmt(1), the other user, doesn't even have the option.) YAGNI. Bug: http://b/122744241 --- lib/lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index 2ba009f9..b074a92b 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -656,7 +656,7 @@ void loopfiles(char **argv, void (*function)(int fd, char *name)) static void (*do_lines_bridge)(char **pline, long len); static void loopfile_lines_bridge(int fd, char *name) { - do_lines(fd, do_lines_bridge); + do_lines(fd, '\n', do_lines_bridge); } void loopfiles_lines(char **argv, void (*function)(char **pline, long len)) @@ -1356,7 +1356,7 @@ char *getgroupname(gid_t gid) // 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. // At EOF calls function(0, 0) -void do_lines(int fd, void (*call)(char **pline, long len)) +void do_lines(int fd, char delim, void (*call)(char **pline, long len)) { FILE *fp = fd ? xfdopen(fd, "r") : stdin; @@ -1364,7 +1364,7 @@ void do_lines(int fd, void (*call)(char **pline, long len)) char *line = 0; ssize_t len; - len = getline(&line, (void *)&len, fp); + len = getdelim(&line, (void *)&len, delim, fp); if (len > 0) { call(&line, len); if (line == (void *)1) break; -- cgit v1.2.3