mirror of
git://git.suckless.org/sbase
synced 2024-12-26 08:52:36 +00:00
b5a511dacf
Fixed for consistency purposes.
41 lines
605 B
C
41 lines
605 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "text.h"
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: sponge file\n");
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
FILE *fp, *tmpfp;
|
|
|
|
ARGBEGIN {
|
|
default:
|
|
usage();
|
|
} ARGEND;
|
|
|
|
if(argc != 1)
|
|
usage();
|
|
|
|
if(!(tmpfp = tmpfile()))
|
|
eprintf("tmpfile:");
|
|
|
|
concat(stdin, "<stdin>", tmpfp, "<tmpfile>");
|
|
rewind(tmpfp);
|
|
|
|
if(!(fp = fopen(argv[0], "w")))
|
|
eprintf("sponge: '%s':", argv[0]);
|
|
concat(tmpfp, "<tmpfile>", fp, argv[0]);
|
|
|
|
fclose(fp);
|
|
fclose(tmpfp);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|