commit 154381a0c7604e20c4460516968339b28f0c9941
parent 6e3c035db8d35e9c5bc916af6d303775d2780830
Author: sin <sin@2f30.org>
Date: Mon, 17 Nov 2014 16:03:18 +0000
Sync up util/*.c from sbase
Diffstat:
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"