The REQUIRE macro is used to check for a condition, and set an error in
the parse struct if it is not satisfied.

This changes it from ((condition) || function call) to a, IMHO more
readable, if() test.

Index: regcomp.c
===================================================================
RCS file: /OpenBSD/src/lib/libc/regex/regcomp.c,v
retrieving revision 1.38
diff -u -p -r1.38 regcomp.c
--- regcomp.c   30 Dec 2020 08:59:17 -0000      1.38
+++ regcomp.c   31 Dec 2020 07:21:31 -0000
@@ -84,7 +84,7 @@ static void ordinary(struct parse *, int
 static void backslash(struct parse *, int);
 static void nonnewline(struct parse *);
 static void repeat(struct parse *, sopno, int, int);
-static int seterr(struct parse *, int);
+static void seterr(struct parse *, int);
 static cset *allocset(struct parse *);
 static void freeset(struct parse *, cset *);
 static int freezeset(struct parse *, cset *);
@@ -121,7 +120,7 @@ static char nuls[10];               /* place to point
 #define        NEXTn(n)        (p->next += (n))
 #define        GETNEXT()       (*p->next++)
 #define        SETERROR(e)     seterr(p, (e))
-#define        REQUIRE(co, e)  (void) ((co) || SETERROR(e))
+#define        REQUIRE(co, e)  do { if (!(co)) SETERROR(e); } while (0)
 #define        EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
 #define        INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
 #define        AHEAD(pos)              dofwd(p, pos, HERE()-(pos))
@@ -1010,14 +996,13 @@ repeat(struct parse *p,
 /*
  - seterr - set an error condition
  */
-static int                     /* useless but makes type checking happy */
+static void
 seterr(struct parse *p, int e)
 {
        if (p->error == 0)      /* keep earliest error condition */
                p->error = e;
        p->next = nuls;         /* try to bring things to a halt */
        p->end = nuls;
-       return(0);              /* make the return value well-defined */
 }
 
 /*

Reply via email to