summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsheldonh <sheldonh@FreeBSD.org>2000-07-24 21:50:38 +0000
committersheldonh <sheldonh@FreeBSD.org>2000-07-24 21:50:38 +0000
commitfa8e7cc20713f567566a54aafd4a6a41a800d4eb (patch)
tree4ae208374ebb24f4876457b3ca512d9d2b341535
parent1951291f8f92a47df03a630735e21c023e3ef3ea (diff)
downloadFreeBSD-src-fa8e7cc20713f567566a54aafd4a6a41a800d4eb.zip
FreeBSD-src-fa8e7cc20713f567566a54aafd4a6a41a800d4eb.tar.gz
Simplify some conditionals.
-rw-r--r--usr.bin/truncate/truncate.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/usr.bin/truncate/truncate.c b/usr.bin/truncate/truncate.c
index 8a1feff..ed4306a 100644
--- a/usr.bin/truncate/truncate.c
+++ b/usr.bin/truncate/truncate.c
@@ -58,15 +58,15 @@ main(int argc, char **argv)
char *fname, *rname;
rsize = tsize = 0;
- rname = NULL;
error = 0;
+ rname = NULL;
while ((ch = getopt(argc, argv, "cr:s:")) != -1)
switch (ch) {
case 'c':
- no_create++;
+ no_create = 1;
break;
case 'r':
- do_refer++;
+ do_refer = 1;
rname = optarg;
break;
case 's':
@@ -74,8 +74,8 @@ main(int argc, char **argv)
errx(EXIT_FAILURE,
"invalid size argument `%s'", optarg);
if (*optarg == '+' || *optarg == '-')
- do_relative++;
- got_size++;
+ do_relative = 1;
+ got_size = 1;
break;
default:
usage();
@@ -90,18 +90,16 @@ main(int argc, char **argv)
* do_relative implies got_size, do_relative and do_refer are
* also mutually exclusive. See usage() for allowed invocations.
*/
- if (!(do_refer || got_size) || (do_refer && got_size) || argc < 1)
+ if (do_refer + got_size != 1 || argc < 1)
usage();
if (do_refer) {
if (stat(rname, &sb) == -1)
err(EXIT_FAILURE, "%s", rname);
tsize = sb.st_size;
- } else if (got_size) {
- if (do_relative)
- rsize = sz;
- else
- tsize = sz;
- }
+ } else if (do_relative)
+ rsize = sz;
+ else
+ tsize = sz;
if (no_create)
oflags = O_WRONLY;
OpenPOWER on IntegriCloud