[hackers] [ubase] mount: use libutil/concat instead of custom catfile || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sun, 22 Feb 2015 12:34:44 +0100 (CET)

commit 9455f51dd8f7bebeb13074b34deeb41f491d5343
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun Feb 22 12:02:20 2015 +0100

    mount: use libutil/concat instead of custom catfile
    
    this trivializes the code some more

diff --git a/mount.c b/mount.c
index 11ac669..12d14b7 100644
--- a/mount.c
+++ b/mount.c
_AT_@ -10,6 +10,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "text.h"
 #include "util.h"
 
 struct {
_AT_@ -98,21 +99,6 @@ mounted(const char *dir)
         return 0;
 }
 
-static int
-catfile(FILE *in, FILE *out)
-{
- char buf[BUFSIZ];
- size_t bytesread;
-
- while (!feof(in)) {
- bytesread = fread(buf, 1, sizeof(buf), in);
- if (ferror(in))
- return -1;
- fwrite(buf, 1, bytesread, out);
- }
- return 0;
-}
-
 static void
 usage(void)
 {
_AT_@ -161,12 +147,9 @@ main(int argc, char *argv[])
         if (argc < 1 && aflag == 0) {
                 if (!(fp = fopen(files[0], "r")))
                         eprintf("fopen %s:", files[0]);
- if (catfile(fp, stdout) == -1) {
- weprintf("error while reading %s:", files[0]);
- status = 1;
- }
+ concat(fp, files[0], stdout, "<stdout>");
                 fclose(fp);
- return status;
+ return 0;
         }
 
         if (aflag == 1)
Received on Sun Feb 22 2015 - 12:34:44 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 22 2015 - 12:36:12 CET