diff options
author | joeyh <joeyh> | 2006-03-08 03:19:40 +0000 |
---|---|---|
committer | joeyh <joeyh> | 2006-03-08 03:19:40 +0000 |
commit | d8c8aa26cb9f1f4bd411056ad3049ed0357ae3e4 (patch) | |
tree | 18c4338e4ad989db263b3234cf1d42a992d654b7 /sponge.c | |
parent | c996e056d782796fba098b546f16d7ead1ea9d78 (diff) | |
download | moreutils-d8c8aa26cb9f1f4bd411056ad3049ed0357ae3e4.tar.gz |
* Indentation improvements.
Diffstat (limited to 'sponge.c')
-rw-r--r-- | sponge.c | 96 |
1 files changed, 48 insertions, 48 deletions
@@ -30,62 +30,62 @@ #include <string.h> void usage() { - printf("sponge <file>: suck in all input from stdin and write it to <file>"); - exit(0); + printf("sponge <file>: suck in all input from stdin and write it to <file>"); + exit(0); } int main(int argc, char **argv) { - char *buf, *bufstart; - size_t bufsize = 8192; - size_t bufused = 0; - ssize_t i = 0; - int outfd; - if (argc != 2) { - usage(); - } + char *buf, *bufstart; + size_t bufsize = 8192; + size_t bufused = 0; + ssize_t i = 0; + int outfd; + + if (argc != 2) { + usage(); + } - bufstart = buf = malloc(bufsize); - if (!buf) { - perror("malloc"); - exit(1); - } + bufstart = buf = malloc(bufsize); + if (!buf) { + perror("malloc"); + exit(1); + } - while ((i = read(0, buf, bufsize - bufused)) > 0) { - bufused = bufused+i; - if (bufused == bufsize) { - bufsize *= 2; - bufstart = realloc(bufstart, bufsize); - if (!bufstart) { - perror("realloc"); - exit(1); - } + while ((i = read(0, buf, bufsize - bufused)) > 0) { + bufused = bufused+i; + if (bufused == bufsize) { + bufsize *= 2; + bufstart = realloc(bufstart, bufsize); + if (!bufstart) { + perror("realloc"); + exit(1); + } - buf = bufstart + bufused; - } - } - if (i == -1) { - perror("read"); - exit(1); - } + buf = bufstart + bufused; + } + } + if (i == -1) { + perror("read"); + exit(1); + } - outfd = open(argv[1], O_CREAT | O_TRUNC | O_WRONLY, - 0666); - if (outfd == -1) { - fprintf(stderr, "Can't open %s: %s\n", argv[1], strerror(errno)); - exit(1); - } + outfd = open(argv[1], O_CREAT | O_TRUNC | O_WRONLY, 0666); + if (outfd == -1) { + fprintf(stderr, "Can't open %s: %s\n", argv[1], strerror(errno)); + exit(1); + } - i = write(outfd, bufstart, bufused); - if (i == -1) { - perror("write"); - exit(1); - } + i = write(outfd, bufstart, bufused); + if (i == -1) { + perror("write"); + exit(1); + } - i = close(outfd); - if (i == -1) { - perror("close"); - exit(1); - } + i = close(outfd); + if (i == -1) { + perror("close"); + exit(1); + } - return 0; + return 0; } |