diff options
author | Elliott Hughes <enh@google.com> | 2019-01-12 09:30:29 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-01-12 13:37:30 -0600 |
commit | 411f7fc4781f6758a50ce206df62efd809c20186 (patch) | |
tree | ff7228d472085c09fd4c40808bdab1541ec11bf9 /lib | |
parent | 7d355098320a0cbc54001a07e44cf9f7e7a3636c (diff) | |
download | toybox-411f7fc4781f6758a50ce206df62efd809c20186.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 6 | ||||
-rw-r--r-- | lib/lib.h | 2 |
2 files changed, 4 insertions, 4 deletions
@@ -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; @@ -253,7 +253,7 @@ int regexec0(regex_t *preg, char *string, long len, int nmatch, regmatch_t pmatch[], int eflags); char *getusername(uid_t uid); char *getgroupname(gid_t gid); -void do_lines(int fd, void (*call)(char **pline, long len)); +void do_lines(int fd, char delim, void (*call)(char **pline, long len)); long environ_bytes(); long long millitime(void); char *format_iso_time(char *buf, size_t len, struct timespec *ts); |