diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2019-07-23 06:11:43 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2019-07-23 06:11:43 +0300 |
commit | 9a80874f7f13422d2e60cac2bfa87469dfa25152 (patch) | |
tree | aaa146d003677a643b8a3d66ed0a4af500bf1727 /builtin.c | |
parent | 3940fe507bc67794100e1f075597f451ef1f3c22 (diff) | |
download | egawk-9a80874f7f13422d2e60cac2bfa87469dfa25152.tar.gz egawk-9a80874f7f13422d2e60cac2bfa87469dfa25152.tar.bz2 egawk-9a80874f7f13422d2e60cac2bfa87469dfa25152.zip |
Further improvements to bitwise functions.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -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); } |