diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2021-01-03 17:07:59 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2021-01-03 17:07:59 +0000 |
commit | 35f2a9f2eafad7db7da441807265f80ec41edffd (patch) | |
tree | b82189c5ac646c0a0326450d05aebb227769b967 | |
parent | 2ef6f246599a03be5832dadd32eb5157575890f6 (diff) |
Make CHIN() Boolean-valued and use this to turn an expression with a
quintuple negation into one with a simple negation.
From miod, ok millert
-rw-r--r-- | lib/libc/regex/regcomp.c | 4 | ||||
-rw-r--r-- | lib/libc/regex/regex2.h | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index c41970223f1..cf6acbb7d86 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regcomp.c,v 1.42 2021/01/02 20:42:01 millert Exp $ */ +/* $OpenBSD: regcomp.c,v 1.43 2021/01/03 17:07:57 tb Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 @@ -1099,7 +1099,7 @@ freezeset(struct parse *p, cset *cs) if (cs2->hash == h && cs2 != cs) { /* maybe */ for (i = 0; i < css; i++) - if (!!CHIN(cs2, i) != !!CHIN(cs, i)) + if (CHIN(cs2, i) != CHIN(cs, i)) break; /* no */ if (i == css) break; /* yes */ diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h index 5a609f4aea8..6fb9dcca27c 100644 --- a/lib/libc/regex/regex2.h +++ b/lib/libc/regex/regex2.h @@ -1,4 +1,4 @@ -/* $OpenBSD: regex2.h,v 1.11 2021/01/03 10:50:02 tb Exp $ */ +/* $OpenBSD: regex2.h,v 1.12 2021/01/03 17:07:58 tb Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -122,10 +122,10 @@ CHsub(cset *cs, char c) cs->hash -= c; } -static inline uch +static inline int CHIN(const cset *cs, char c) { - return cs->ptr[(uch)c] & cs->mask; + return (cs->ptr[(uch)c] & cs->mask) != 0; } /* |