sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

commit 2433bb78cb896bcaec61616830a3f71c2458a282
parent f08d798f777627c6e0bef413c6fb1e443b1b6476
Author: Truls Becken <truls.becken@gmail.com>
Date:   Wed, 17 Dec 2014 21:14:14 +0100

cut: clean up file loop

Diffstat:
Mcut.c | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/cut.c b/cut.c @@ -162,21 +162,19 @@ main(int argc, char *argv[]) if (!mode) usage(); - if (!argc) + + if (!argc) { cut(stdin); - else { - for (; argc--; argv++) { - if (strcmp(*argv, "-")) - fp = fopen(*argv, "r"); - else - fp = stdin; - if (!fp) { + } else for (; argc--; argv++) { + if (!strcmp(*argv, "-")) { + cut(stdin); + } else { + if (!(fp = fopen(*argv, "r"))) { weprintf("fopen %s:", *argv); continue; } cut(fp); - if (fp != stdin) - fclose(fp); + fclose(fp); } } return 0;