mirror of git://git.suckless.org/ubase
Sync up util/*.c from sbase
This commit is contained in:
parent
6e3c035db8
commit
154381a0c7
|
@ -18,6 +18,5 @@ apathmax(char **p, long *size)
|
||||||
eprintf("pathconf:");
|
eprintf("pathconf:");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = emalloc(*size);
|
*p = emalloc(*size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../text.h"
|
#include "../text.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
@ -8,14 +9,12 @@ void
|
||||||
concat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
|
concat(FILE *fp1, const char *s1, FILE *fp2, const char *s2)
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
size_t n;
|
ssize_t n;
|
||||||
|
|
||||||
while ((n = fread(buf, 1, sizeof buf, fp1)) > 0) {
|
while ((n = read(fileno(fp1), buf, sizeof buf)) > 0) {
|
||||||
if (fwrite(buf, 1, n, fp2) != n)
|
if (write(fileno(fp2), buf, n) != n)
|
||||||
eprintf("%s: write error:", s2);
|
eprintf("%s: write error:", s2);
|
||||||
if (feof(fp1))
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (ferror(fp1))
|
if (n < 0)
|
||||||
eprintf("%s: read error:", s1);
|
eprintf("%s: read error:", s1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
@ -7,12 +6,11 @@
|
||||||
void
|
void
|
||||||
putword(const char *s)
|
putword(const char *s)
|
||||||
{
|
{
|
||||||
static bool first = true;
|
static int first = 1;
|
||||||
|
|
||||||
if (!first)
|
if (!first)
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
|
|
||||||
fputs(s, stdout);
|
fputs(s, stdout);
|
||||||
first = false;
|
first = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,8 @@
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue