diff options
author | Rob Landley <rob@landley.net> | 2013-12-27 18:45:01 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-12-27 18:45:01 -0600 |
commit | dc3731783ead154d5a0d8d318566468474b43013 (patch) | |
tree | 9d57677eaceacbe64459f6bfb35944c5daa5db34 | |
parent | fc33eb78115adf8a90875f822706bdf3d462524c (diff) | |
download | toybox-dc3731783ead154d5a0d8d318566468474b43013.tar.gz |
Pass through all the readfile() arguments from xreadfile().
-rw-r--r-- | lib/lib.h | 2 | ||||
-rw-r--r-- | lib/xwrap.c | 6 | ||||
-rw-r--r-- | toys/posix/grep.c | 2 |
3 files changed, 5 insertions, 5 deletions
@@ -102,7 +102,7 @@ size_t xread(int fd, void *buf, size_t len); void xreadall(int fd, void *buf, size_t len); void xwrite(int fd, void *buf, size_t len); off_t xlseek(int fd, off_t offset, int whence); -char *xreadfile(char *name); +char *xreadfile(char *name, char *buf, off_t len); int xioctl(int fd, int request, void *data); char *xgetcwd(void); void xstat(char *path, struct stat *st); diff --git a/lib/xwrap.c b/lib/xwrap.c index 08a93ddf..ae296cd6 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -451,10 +451,10 @@ char *xreadlink(char *name) } } -char *xreadfile(char *name) +char *xreadfile(char *name, char *buf, off_t len) { - char *buf = readfile(name, 0, 0); - if (!buf) perror_exit("xreadfile %s", name); + if (!(buf = readfile(name, buf, len))) perror_exit("Bad '%s'", name); + return buf; } diff --git a/toys/posix/grep.c b/toys/posix/grep.c index 8877f452..d78f7559 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -186,7 +186,7 @@ static void parse_regex(void) // exit to free. Not supporting nofork for this command any time soon.) al = TT.f ? TT.f : TT.e; while (al) { - if (TT.f) s = ss = xreadfile(al->arg); + if (TT.f) s = ss = xreadfile(al->arg, 0, 0); else s = ss = al->arg; do { |