[hackers] [sbase] cut: clean up file loop || Truls Becken
commit 2433bb78cb896bcaec61616830a3f71c2458a282
Author: Truls Becken <truls.becken_AT_gmail.com>
Date: Wed Dec 17 21:14:14 2014 +0100
cut: clean up file loop
diff --git a/cut.c b/cut.c
index aca0083..99ec4ce 100644
--- a/cut.c
+++ b/cut.c
_AT_@ -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;
Received on Thu Dec 18 2014 - 16:17:53 CET
This archive was generated by hypermail 2.3.0
: Thu Dec 18 2014 - 16:24:15 CET