On Sun, Jan 03, 2021 at 04:45:30PM +0000, Miod Vallat wrote:
> > Is there a reason not to do
> > 
> >     return (cs->ptr[(uch)c] & cs->mask) != 0;
> > 
> > This would allow us to get rid of the !! construct in regcomp.c
> 
> Why not. What about that?

Thanks. Here's the diff rebased on top of -current. This is

ok tb

Index: regcomp.c
===================================================================
RCS file: /cvs/src/lib/libc/regex/regcomp.c,v
retrieving revision 1.42
diff -u -p -r1.42 regcomp.c
--- regcomp.c   2 Jan 2021 20:42:01 -0000       1.42
+++ regcomp.c   3 Jan 2021 16:48:59 -0000
@@ -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 */
Index: regex2.h
===================================================================
RCS file: /cvs/src/lib/libc/regex/regex2.h,v
retrieving revision 1.11
diff -u -p -r1.11 regex2.h
--- regex2.h    3 Jan 2021 10:50:02 -0000       1.11
+++ regex2.h    3 Jan 2021 16:49:20 -0000
@@ -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;
 }
 
 /*


Reply via email to