From 9a80874f7f13422d2e60cac2bfa87469dfa25152 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 23 Jul 2019 06:11:43 +0300 Subject: Further improvements to bitwise functions. --- builtin.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'builtin.c') diff --git a/builtin.c b/builtin.c index 2f379689..1c205aa4 100644 --- a/builtin.c +++ b/builtin.c @@ -3468,7 +3468,7 @@ do_and(int nargs) uintmax_t res, uval; AWKNUM val; - res = ~0; /* start off with all ones */ + res = ~(uintmax_t) 0; /* start off with all ones */ if (nargs < 2) fatal(_("and: called with less than two arguments")); @@ -3529,13 +3529,12 @@ do_xor(int nargs) NODE *s1; uintmax_t res, uval; AWKNUM val; - int i; if (nargs < 2) fatal(_("xor: called with less than two arguments")); - res = 0; /* silence compiler warning */ - for (i = 1; nargs > 0; nargs--, i++) { + res = 0; /* start with all zeroes */ + for (; nargs > 0; nargs--) { s1 = POP_SCALAR(); if (do_lint && (fixtype(s1)->flags & NUMBER) == 0) lintwarn(_("xor: argument %d is non-numeric"), nargs); @@ -3545,10 +3544,7 @@ do_xor(int nargs) fatal(_("xor: argument %d negative value %g is not allowed"), nargs, val); uval = (uintmax_t) val; - if (i == 1) - res = uval; - else - res ^= uval; + res ^= uval; DEREF(s1); } -- cgit v1.2.1