summaryrefslogtreecommitdiffstats
path: root/lib/libc/regex/regex2.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/regex/regex2.h')
-rw-r--r--lib/libc/regex/regex2.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h
index 7f8f73ad842..5a609f4aea8 100644
--- a/lib/libc/regex/regex2.h
+++ b/lib/libc/regex/regex2.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: regex2.h,v 1.10 2020/12/31 17:20:19 millert Exp $ */
+/* $OpenBSD: regex2.h,v 1.11 2021/01/03 10:50:02 tb Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
@@ -107,10 +107,26 @@ typedef struct {
uch mask; /* bit within array */
uch hash; /* hash code */
} cset;
-/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
-#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
-#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
-#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
+
+static inline void
+CHadd(cset *cs, char c)
+{
+ cs->ptr[(uch)c] |= cs->mask;
+ cs->hash += c;
+}
+
+static inline void
+CHsub(cset *cs, char c)
+{
+ cs->ptr[(uch)c] &= ~cs->mask;
+ cs->hash -= c;
+}
+
+static inline uch
+CHIN(const cset *cs, char c)
+{
+ return cs->ptr[(uch)c] & cs->mask;
+}
/*
* main compiled-expression structure