mirror of
git://git.suckless.org/sbase
synced 2024-12-23 15:34:38 +00:00
d23cc72490
Get rid of the !!()-constructs and use ret where available (or introduce it). In some cases, there would be an "abort" on the first fshut-error, but we want to close all files and report all warnings and then quit, not just the warning for the first file.
37 lines
609 B
C
37 lines
609 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdio.h>
|
|
|
|
#include "text.h"
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: %s file\n", argv0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
FILE *fp, *tmpfp;
|
|
int ret = 0;
|
|
|
|
argv0 = argv[0], argc--, argv++;
|
|
|
|
if (argc != 1)
|
|
usage();
|
|
|
|
if (!(tmpfp = tmpfile()))
|
|
eprintf("tmpfile:");
|
|
concat(stdin, "<stdin>", tmpfp, "<tmpfile>");
|
|
rewind(tmpfp);
|
|
|
|
if (!(fp = fopen(argv[0], "w")))
|
|
eprintf("fopen %s:", argv[0]);
|
|
concat(tmpfp, "<tmpfile>", fp, argv[0]);
|
|
|
|
ret |= fshut(fp, argv[0]) | fshut(tmpfp, "<tmpfile>");
|
|
|
|
return ret;
|
|
}
|