commit 154381a0c7604e20c4460516968339b28f0c9941
Author: sin <[email protected]>
Date:   Mon Nov 17 16:03:18 2014 +0000

    Sync up util/*.c from sbase

diff --git a/util/apathmax.c b/util/apathmax.c
index 63affa4..c570329 100644
--- a/util/apathmax.c
+++ b/util/apathmax.c
@@ -18,6 +18,5 @@ apathmax(char **p, long *size)
                        eprintf("pathconf:");
                }
        }
-
        *p = emalloc(*size);
 }
diff --git a/util/concat.c b/util/concat.c
index 939219d..a276fbb 100644
--- a/util/concat.c
+++ b/util/concat.c
@@ -1,5 +1,6 @@
 /* See LICENSE file for copyright and license details. */
 #include <stdio.h>
+#include <unistd.h>
 
 #include "../text.h"
 #include "../util.h"
@@ -8,14 +9,12 @@ void
 concat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
 {
        char buf[BUFSIZ];
-       size_t n;
+       ssize_t n;
 
-       while ((n = fread(buf, 1, sizeof buf, fp1)) > 0) {
-               if (fwrite(buf, 1, n, fp2) != n)
+       while ((n = read(fileno(fp1), buf, sizeof buf)) > 0) {
+               if (write(fileno(fp2), buf, n) != n)
                        eprintf("%s: write error:", s2);
-               if (feof(fp1))
-                       break;
        }
-       if (ferror(fp1))
+       if (n < 0)
                eprintf("%s: read error:", s1);
 }
diff --git a/util/putword.c b/util/putword.c
index 504d7a5..c460703 100644
--- a/util/putword.c
+++ b/util/putword.c
@@ -1,5 +1,4 @@
 /* See LICENSE file for copyright and license details. */
-#include <stdbool.h>
 #include <stdio.h>
 
 #include "../util.h"
@@ -7,12 +6,11 @@
 void
 putword(const char *s)
 {
-       static bool first = true;
+       static int first = 1;
 
        if (!first)
                putchar(' ');
 
        fputs(s, stdout);
-       first = false;
+       first = 0;
 }
-
diff --git a/util/recurse.c b/util/recurse.c
index 74ff918..318987d 100644
--- a/util/recurse.c
+++ b/util/recurse.c
@@ -1,12 +1,11 @@
 /* See LICENSE file for copyright and license details. */
-#include <sys/stat.h>
-#include <sys/types.h>
-
 #include <dirent.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include "../util.h"
diff --git a/util/strlcat.c b/util/strlcat.c
index 019458d..9e2d251 100644
--- a/util/strlcat.c
+++ b/util/strlcat.c
@@ -14,9 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
-
 #include <string.h>
+#include <sys/types.h>
 
 #include "../util.h"
 
diff --git a/util/strlcpy.c b/util/strlcpy.c
index 4dca94e..388b426 100644
--- a/util/strlcpy.c
+++ b/util/strlcpy.c
@@ -14,9 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
-
 #include <string.h>
+#include <sys/types.h>
 
 #include "../util.h"
 


Reply via email to