sbase/sponge.c

41 lines
574 B
C
Raw Normal View History

2013-07-02 13:26:24 -04:00
/* See LICENSE file for copyright and license details. */
#include <stdio.h>
2013-07-02 13:26:24 -04:00
#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)
2013-07-02 13:26:24 -04:00
usage();
if (!(tmpfp = tmpfile()))
2013-07-02 13:26:24 -04:00
eprintf("tmpfile:");
concat(stdin, "<stdin>", tmpfp, "<tmpfile>");
rewind(tmpfp);
if (!(fp = fopen(argv[0], "w")))
2014-11-16 08:20:20 -05:00
eprintf("fopen %s:", argv[0]);
2013-07-02 13:26:24 -04:00
concat(tmpfp, "<tmpfile>", fp, argv[0]);
fclose(fp);
fclose(tmpfp);
2014-10-02 18:46:04 -04:00
return 0;
2013-07-02 13:26:24 -04:00
}