ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 420258990c7236a8aabfed7c1d4521288a5aaee2
parent 24a0741a7d18efc7d53b80384a185598392a7d5f
Author: sin <sin@2f30.org>
Date:   Mon Nov 17 16:03:18 +0000

Sync up util/*.c from sbase

Diffstat:
util/apathmax.c | 1-
util/concat.c | 11+++++------
util/putword.c | 6++----
util/recurse.c | 5++---
util/strlcat.c | 3+--
util/strlcpy.c | 3+--
6 files changed, 11 insertions(+), 18 deletions(-)
diff --git 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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"