OSDN Git Service

Pass through all the readfile() arguments from xreadfile().
authorRob Landley <rob@landley.net>
Sat, 28 Dec 2013 00:45:01 +0000 (18:45 -0600)
committerRob Landley <rob@landley.net>
Sat, 28 Dec 2013 00:45:01 +0000 (18:45 -0600)
lib/lib.h
lib/xwrap.c
toys/posix/grep.c

index c46aaca..d052880 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -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);
index 08a93dd..ae296cd 100644 (file)
@@ -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;
 }
 
index 8877f45..d78f755 100644 (file)
@@ -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 {