Description: Add parentheses to disambiguate mixed boolean operators.
Origin: https://src.fedoraproject.org/rpms/qepcad-B/blob/60ceecd/f/qepcad-B-parens.patch
Forwarded: https://github.com/chriswestbrown/qepcad/pull/2
Last-Update: 2021-06-23

--- a/extensions/adj2d/truthbytop/BOUNDARY2D.c
+++ b/extensions/adj2d/truthbytop/BOUNDARY2D.c
@@ -38,9 +38,9 @@
       while(S_c != NIL && RED(S_c) != NIL)
       {
 	Word c1 = FIRST(S_c), c2 = SECOND(S_c), c3 = THIRD(S_c);
-	if (LELTI(c1,TRUTH) == TRUE && LELTI(c3,TRUTH) == FALSE
+	if ((LELTI(c1,TRUTH) == TRUE && LELTI(c3,TRUTH) == FALSE)
 	    ||
-	    LELTI(c1,TRUTH) == FALSE && LELTI(c3,TRUTH) == TRUE)
+	    (LELTI(c1,TRUTH) == FALSE && LELTI(c3,TRUTH) == TRUE))
 	{
 	  SLELTI(c2,TRUTH,TRUE);
 	  SLELTI(c2,HOWTV,TOPINF);
@@ -106,7 +106,7 @@
        tc++;
      else
        fc++; }
-   if (tc > 0 && fc > 0 || GVERTEXLABEL(v,G) == TRUE && tc == 0)
+   if ((tc > 0 && fc > 0) || (GVERTEXLABEL(v,G) == TRUE && tc == 0))
      GNEWLABEL(v,TRUE,G);
    else
      GNEWLABEL(v,FALSE,G); }
--- a/extensions/lift2D/IBPRRIOAP.c
+++ b/extensions/lift2D/IBPRRIOAP.c
@@ -95,7 +95,7 @@
 	  goto Return; }
 	
 	/* get trend of first root */
-	if (PDEG(B) % 2 == 0 && s == 1 || PDEG(B) % 2 == 1 && s == -1)
+	if ((PDEG(B) % 2 == 0 && s == 1) || (PDEG(B) % 2 == 1 && s == -1))
 	  t1 = -1;
 	else
 	  t1 = 1;
--- a/extensions/lift2D/modIBPRRIOAP.c
+++ b/extensions/lift2D/modIBPRRIOAP.c
@@ -97,7 +97,7 @@
 	  goto Return; }
 	
 	/* get trend of first root */
-	if (PDEG(B) % 2 == 0 && s == 1 || PDEG(B) % 2 == 1 && s == -1)
+	if ((PDEG(B) % 2 == 0 && s == 1) || (PDEG(B) % 2 == 1 && s == -1))
 	  t1 = -1;
 	else
 	  t1 = 1;
--- a/source/db/convenientstreams.h
+++ b/source/db/convenientstreams.h
@@ -31,7 +31,7 @@
     string s = "";
     char c = in.get(); 
     if (opt == skipleadingws) 
-      while(c != EOF && (isspace(c) || c == '\\' && isspace(in.peek()))) c = in.get();
+      while(c != EOF && (isspace(c) || (c == '\\' && isspace(in.peek())))) c = in.get();
     // States  : 0 = normal, 1 = in comment, 2 = just read a backslash
     int state = 0;
     do {
@@ -44,7 +44,7 @@
       if (state == 0 && c == '\\') { state = 2; continue; }
       s += c;
       state = 0;
-    }while(c = in.get());
+    }while((c = in.get()));
     str(s);
   }
 };
--- a/source/db/SINGULAR.c
+++ b/source/db/SINGULAR.c
@@ -58,7 +58,7 @@
 
 char peekNonWS(istream &in) 
 { 
-  char c; while((c = in.peek()) && c == ' ' || c == '\t' || c == '\n') in.get(); return c; 
+  char c; while((c = in.peek()) && (c == ' ' || c == '\t' || c == '\n')) in.get(); return c; 
 }
 
 
--- a/source/proj/GROUPSAMEPJ.c
+++ b/source/proj/GROUPSAMEPJ.c
@@ -46,7 +46,7 @@
     Word KR = LIST2(SECOND(aK),LIST2(1,1));
     Word sL = AFSIGN(aM,aI,AFPEMV(1,aM,G,KL));
     Word sR = AFSIGN(aM,aI,AFPEMV(1,aM,G,KR));
-    return EQUAL(KL,KR) && sL == 0 || sL == 1 && sR == -1 || sL == -1 && sR == 1;
+    return (EQUAL(KL,KR) && sL == 0) || (sL == 1 && sR == -1) || (sL == -1 && sR == 1);
   }
 
   /* One primitive, the other not */
@@ -75,10 +75,10 @@
 	 {
            ADV(Jt,&J2,&Jt);
            Jt2 = LELTI(J2,PO_POLY);
-           if (LELTI(J1,PO_TYPE) == PO_POINT && LELTI(J2,PO_TYPE) == PO_POINT
-	       && PRJPNTEQUAL(Js1,Jt2) || 
-	       LELTI(J1,PO_TYPE) != PO_POINT && LELTI(J2,PO_TYPE) != PO_POINT
-	       && EQUAL(Js1,Jt2))
+           if ((LELTI(J1,PO_TYPE) == PO_POINT && LELTI(J2,PO_TYPE) == PO_POINT
+		&& PRJPNTEQUAL(Js1,Jt2)) || 
+	       (LELTI(J1,PO_TYPE) != PO_POINT && LELTI(J2,PO_TYPE) != PO_POINT
+		&& EQUAL(Js1,Jt2)))
 	   {
              SLELTI(J2,PO_PARENT,CONC(LELTI(J2,PO_PARENT),LELTI(J1,PO_PARENT)));
              t = 1;
--- a/source/proj/PROJMCECmod.c
+++ b/source/proj/PROJMCECmod.c
@@ -67,7 +67,7 @@
 	   t = 1; }
 	 
 	 /* If r = 2 OR r-1 is in free variable space, the leading coefficient is always enough! */
-	 if (t && (r == 2 || (PCMZERROR && r-1 <= GVNFV)) 
+	 if ((t && (r == 2 || (PCMZERROR && r-1 <= GVNFV)))
 	     || (experimentalExtensionFlag && qfrCheckNonNullified(r,Ap1,GVNA.W,GVNQFF.W,GVVL.W))
 	     )
 	   t = 0;
@@ -101,7 +101,7 @@
 	     tf = tf || (Q == FULLDE || Q == FULLDA);
 	     
 	     /* Test 3: in free variable space when the PCMZERROR option is used */
-	     tf = tf || PCMZERROR && rp <= GVNFV;
+	     tf = tf || (PCMZERROR && rp <= GVNFV);
 
 	     /* Test 4: has no common zero with the system of all other coefficients */
 	     if (!tf)
--- a/source/proj/PROJMCmod.c
+++ b/source/proj/PROJMCmod.c
@@ -57,7 +57,7 @@
 	   t = 1; }
 	 
 	 /* If r = 2 OR r-1 is in free variable space, the leading coefficient is always enough! */
-	 if (t && (r == 2 || (PCMZERROR && r-1 <= GVNFV))
+	 if ((t && (r == 2 || (PCMZERROR && r-1 <= GVNFV)))
 	     || (experimentalExtensionFlag && qfrCheckNonNullified(r,Ap1,GVNA.W,GVNQFF.W,GVVL.W))
 	     )
 	   t = 0;
@@ -91,7 +91,7 @@
 	     tf = tf || (Q == FULLDE || Q == FULLDA);
 	     
 	     /* Test 3: in free variable space when the PCMZERROR option is used */
-	     tf = tf || PCMZERROR && rp <= GVNFV;
+	     tf = tf || (PCMZERROR && rp <= GVNFV);
 
 	     /* Test 4: has no common zero with the system of all other coefficients */
 	     if (!tf)
--- a/source/ticad/INITPCAD.c
+++ b/source/ticad/INITPCAD.c
@@ -14,7 +14,7 @@
        Word D, tv;
 
 Step0: /* Determine truth value! */
-       if (GVNA == FALSE || GVNA != NIL && LELTI(GVNA,1) == NEOP && LELTI(GVNA,2) == 0) tv = NA;
+       if (GVNA == FALSE || (GVNA != NIL && LELTI(GVNA,1) == NEOP && LELTI(GVNA,2) == 0)) tv = NA;
        else if (LELTI(GVNQFF,1) == NEOP && LELTI(GVNQFF,2) == 0) tv = FALSE;
        else if (LELTI(GVNQFF,1) == EQOP && LELTI(GVNQFF,2) == 0) tv = TRUE;
        else tv = UNDET;
