simplify
if ((flags & (1 | 2) == 0) || (flags & (1 | 2) == (1 | 2))) to if (!(flags & 1) ^ !(flags & 2)) which works because ! returns 1 or 0, making the ^ an ^^, and because XOR survives NOTting its arguments
This commit is contained in:
parent
edeb22fb96
commit
31d2796169
5
shf.c
5
shf.c
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.25 2009/03/14 18:12:55 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.26 2009/04/07 19:08:25 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
|
@ -175,8 +175,7 @@ struct shf *
|
||||||
shf_sopen(char *buf, int bsize, int sflags, struct shf *shf)
|
shf_sopen(char *buf, int bsize, int sflags, struct shf *shf)
|
||||||
{
|
{
|
||||||
/* can't have a read+write string */
|
/* can't have a read+write string */
|
||||||
if (!(sflags & (SHF_RD | SHF_WR)) ||
|
if (!(sflags & SHF_RD) ^ !(sflags & SHF_WR))
|
||||||
(sflags & (SHF_RD | SHF_WR)) == (SHF_RD | SHF_WR))
|
|
||||||
internal_errorf("shf_sopen: flags 0x%x", sflags);
|
internal_errorf("shf_sopen: flags 0x%x", sflags);
|
||||||
|
|
||||||
if (!shf) {
|
if (!shf) {
|
||||||
|
|
Loading…
Reference in New Issue