changeset 1170:8afe1fde9314 draft

Pass through all the readfile() arguments from xreadfile().
author Rob Landley <rob@landley.net>
date Fri, 27 Dec 2013 18:45:01 -0600
parents ab7f336bfe52
children a7df29f72bc6
files lib/lib.h lib/xwrap.c toys/posix/grep.c
diffstat 3 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.h	Fri Dec 27 08:36:03 2013 -0600
+++ b/lib/lib.h	Fri Dec 27 18:45:01 2013 -0600
@@ -102,7 +102,7 @@
 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);
--- a/lib/xwrap.c	Fri Dec 27 08:36:03 2013 -0600
+++ b/lib/xwrap.c	Fri Dec 27 18:45:01 2013 -0600
@@ -451,10 +451,10 @@
   }
 }
 
-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;
 }
 
--- a/toys/posix/grep.c	Fri Dec 27 08:36:03 2013 -0600
+++ b/toys/posix/grep.c	Fri Dec 27 18:45:01 2013 -0600
@@ -186,7 +186,7 @@
   // 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 {