summaryrefslogtreecommitdiff
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2019-07-23 06:11:43 +0300
committerArnold D. Robbins <arnold@skeeve.com>2019-07-23 06:11:43 +0300
commit9a80874f7f13422d2e60cac2bfa87469dfa25152 (patch)
treeaaa146d003677a643b8a3d66ed0a4af500bf1727 /builtin.c
parent3940fe507bc67794100e1f075597f451ef1f3c22 (diff)
downloadgawk-9a80874f7f13422d2e60cac2bfa87469dfa25152.tar.gz
Further improvements to bitwise functions.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c12
1 files changed, 4 insertions, 8 deletions
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);
}