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:
tg 2009-04-07 19:08:25 +00:00
parent edeb22fb96
commit 31d2796169
1 changed files with 2 additions and 3 deletions

5
shf.c
View File

@ -2,7 +2,7 @@
#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() */
#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)
{
/* can't have a read+write string */
if (!(sflags & (SHF_RD | SHF_WR)) ||
(sflags & (SHF_RD | SHF_WR)) == (SHF_RD | SHF_WR))
if (!(sflags & SHF_RD) ^ !(sflags & SHF_WR))
internal_errorf("shf_sopen: flags 0x%x", sflags);
if (!shf) {