$OpenBSD: patch-dpic_c,v 1.1 2017/09/09 22:56:49 nigel Exp $
Index: dpic.c
--- dpic.c.orig
+++ dpic.c
@@ -1241,11 +1241,11 @@ void wfloat(FILE **iou, double y)
 { char buf[25];
   int i;
   if (fabs(y)==distmax)
-     sprintf(buf,"%24.6e", y);
+     snprintf(buf,sizeof(buf), "%24.6e", y);
   else if (y >= 0.0)
-     sprintf(buf,"%24.6f", floor( 1000000*y+0.5)/1000000.0 );
+     snprintf(buf,sizeof(buf), "%24.6f", floor( 1000000*y+0.5)/1000000.0 );
   else
-     sprintf(buf,"%24.6f",-floor(-1000000*y+0.5)/1000000.0 );
+     snprintf(buf,sizeof(buf), "%24.6f",-floor(-1000000*y+0.5)/1000000.0 );
   for (i=23; buf[i]=='0'; ) i-- ;
   if (buf[i]=='.') buf[i] = (char)0;
   else buf[i+1] = (char)0;
@@ -1897,7 +1897,7 @@ boolean drawn(primitive *node, int linesp, double fill
       return true;
   }
   else if (linesp == XLdotted || linesp == XLdashed || linesp == XLsolid ||
-	   fill >= 0.0 && fill <= 1.0) {
+	   (fill >= 0.0 && fill <= 1.0)) {
       return true;
   }
   else {
@@ -4793,7 +4793,7 @@ void mfpdraw(primitive *node)
     initnesw();
     nesw(node);
     if (node->ptype == XLbox) {
-	if (node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0 ||
+	if ((node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0) ||
 	     node->shadedp != NULL) {
 	    mfpsetshade(node->Upr.Ubox.boxfill, node->shadedp);
 	    mfpbox(node->aat.xpos, node->aat.ypos, north, south, east, west,
@@ -4812,7 +4812,7 @@ void mfpdraw(primitive *node)
     break;
 
   case XLellipse:
-    if (node->Upr.Uellipse.efill >= 0.0 && node->Upr.Uellipse.efill <= 1.0 ||
+    if ((node->Upr.Uellipse.efill >= 0.0 && node->Upr.Uellipse.efill <= 1.0) ||
 	 node->shadedp != NULL) {
 	mfpsetshade(node->Upr.Uellipse.efill, node->shadedp);
 	mfpellipse(node->aat, node->Upr.Uellipse.elwidth, node->Upr.Uellipse.elheight);
@@ -4828,7 +4828,7 @@ void mfpdraw(primitive *node)
     break;
 
   case XLcircle:
-    if (node->Upr.Ucircle.cfill >= 0.0 && node->Upr.Ucircle.cfill <= 1.0 ||
+    if ((node->Upr.Ucircle.cfill >= 0.0 && node->Upr.Ucircle.cfill <= 1.0) ||
 	 node->shadedp != NULL) {
 	mfpsetshade(node->Upr.Ucircle.cfill, node->shadedp);
 	mfpcircle(node->aat, node->Upr.Ucircle.radius);
@@ -5423,7 +5423,7 @@ void mpodraw(primitive *node)
   case XBLOCK:
     if (node->ptype == XLbox) {
 	if (node->shadedp != NULL ||
-	     node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0) {
+	     (node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0)) {
 	    mpobox("fill ", node->aat, node->Upr.Ubox.boxwidth / 2,
 		   node->Upr.Ubox.boxheight / 2, node->Upr.Ubox.boxradius);
 	    addcolor(node->shadedp, node->Upr.Ubox.boxfill);
@@ -5442,7 +5442,7 @@ void mpodraw(primitive *node)
 
   case XLellipse:
     if (node->shadedp != NULL ||
-	 node->Upr.Uellipse.efill >= 0.0 && node->Upr.Uellipse.efill <= 1.0) {
+	 (node->Upr.Uellipse.efill >= 0.0 && node->Upr.Uellipse.efill <= 1.0)) {
 	mpoellipse("fill ", node->aat, node->Upr.Uellipse.elwidth / 2,
 		   node->Upr.Uellipse.elheight / 2);
 	addcolor(node->shadedp, node->Upr.Uellipse.efill);
@@ -5460,7 +5460,7 @@ void mpodraw(primitive *node)
 
   case XLcircle:
     if (node->shadedp != NULL ||
-	 node->Upr.Ucircle.cfill >= 0.0 && node->Upr.Ucircle.cfill <= 1.0) {
+	 (node->Upr.Ucircle.cfill >= 0.0 && node->Upr.Ucircle.cfill <= 1.0)) {
 	printf("fill fullcircle scaled ");
 	wfloat(&output, node->Upr.Ucircle.radius * 2 / fsc);
 	printf(" shifted ");
@@ -6974,7 +6974,7 @@ void psdraw(primitive *node)
   switch (node->ptype) {
 
   case XLbox:
-    if (node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0 ||
+    if ((node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0) ||
 	 node->shadedp != NULL) {
 	psbox(node->aat, node->Upr.Ubox.boxwidth / 2,
 	      node->Upr.Ubox.boxheight / 2, node->Upr.Ubox.boxradius);
@@ -7027,7 +7027,7 @@ void psdraw(primitive *node)
     else {
 	fill = node->Upr.Ucircle.cfill;
     }
-    if (fill >= 0.0 && fill <= 1.0 || node->shadedp != NULL) {
+    if ((fill >= 0.0 && fill <= 1.0) || node->shadedp != NULL) {
 	pssetthick(lth);
 	printf(" gsave ");
 	pswpos(node->aat);
@@ -7416,7 +7416,7 @@ void pdfwfloat(double y)
       ix = ixd;
   } while (ix != 0 || j <= 6);
   for (j = 1; j <= ln; j++) {
-      sprintf(STR1, "%c", ts[ln - j]);
+      snprintf(STR1, sizeof(STR1), "%c", ts[ln - j]);
       pdfstream(STR1, 1, &cx);
   }
 }
@@ -7580,10 +7580,10 @@ void pdfwstring(nametype *p)
       iswhite = (c == etxch || c == nlch || c == tabch || c == ' ');
       if (!iswhite || !waswhite) {
 	  if (c == bslch || c == ')' || c == '(') {
-	      sprintf(STR1, "%c", bslch);
+	      snprintf(STR1, sizeof(STR1), "%c", bslch);
 	      pdfstream(STR1, 1, &cx);
 	  }
-	  sprintf(STR1, "%c", c);
+	  snprintf(STR1, sizeof(STR1), "%c", c);
 	  pdfstream(STR1, 1, &cx);
       }
       waswhite = iswhite;
@@ -8020,7 +8020,7 @@ void pdfdraw(primitive *node)
 
   case XLbox:
     if (drawn(node, lsp, node->Upr.Ubox.boxfill)) {
-	fll = (node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0 ||
+	fll = ((node->Upr.Ubox.boxfill >= 0.0 && node->Upr.Ubox.boxfill <= 1.0) ||
 	       node->shadedp != NULL);
 	pdflinearfill(node->Upr.Ubox.boxfill, node->shadedp);
 	pdflineopts(lsp, node->lparam, lth, node->outlinep);
@@ -8052,7 +8052,7 @@ void pdfdraw(primitive *node)
 	fill = node->Upr.Ucircle.cfill;
     }
     if (drawn(node, lsp, fill)) {
-	fll = (fill >= 0.0 && fill <= 1.0 || node->shadedp != NULL);
+	fll = ((fill >= 0.0 && fill <= 1.0) || node->shadedp != NULL);
 	pdflinearfill(fill, node->shadedp);
 	pdflineopts(lsp, node->lparam, lth, node->outlinep);
 	pdfellipse(node->aat, x, y);
@@ -8160,7 +8160,7 @@ void pdfdraw(primitive *node)
 	pdfwpos(node->Upr.Uline.endpos);
 	pdfstream(" l", 2, &cx);
 	if (node->son != NULL) {
-	    sprintf(STR1, "%c", nlch);
+	    snprintf(STR1, sizeof(STR1), "%c", nlch);
 	    pdfstream(STR1, 1, &cx);
 	}
 	else {
@@ -8241,7 +8241,7 @@ void pdfdraw(primitive *node)
   case XLaTeX:
     if (node->textp != NULL) {
 	pdfwstring(node->textp);
-	sprintf(STR1, "%c", nlch);
+	snprintf(STR1, sizeof(STR1), "%c", nlch);
 	pdfstream(STR1, 1, &cx);
     }
     break;
@@ -8448,7 +8448,7 @@ void texdraw(primitive *node)
 	lgth = linlen(node->Upr.Uline.endpos.xpos - node->aat.xpos,
 		      node->Upr.Uline.endpos.ypos - node->aat.ypos);
 	if (drawmode == Pict2e ||
-	     lsp == XLsolid && (lgth > 0.18 || drawmode == tTeX)) {
+	     (lsp == XLsolid && (lgth > 0.18 || drawmode == tTeX))) {
 	    if (lgth > 0) {
 		printf("\\put");
 		wpos(node->aat);
@@ -8759,16 +8759,16 @@ void texdraw(primitive *node)
 		node->direction = p->direction;
 	    }
 	}
-	if (node->direction == XLleft && node->Upr.Uline.endpos.ypos < 0.0 ||
-	     node->direction == XLdown && node->Upr.Uline.endpos.ypos > 0.0) {
+	if ((node->direction == XLleft && node->Upr.Uline.endpos.ypos < 0.0) ||
+	     (node->direction == XLdown && node->Upr.Uline.endpos.ypos > 0.0)) {
 	    printf("[bl]}\n");
 	}
-	else if (node->direction == XLleft && node->Upr.Uline.endpos.ypos > 0.0 ||
-		 node->direction == XLup && node->Upr.Uline.endpos.ypos < 0.0) {
+	else if ((node->direction == XLleft && node->Upr.Uline.endpos.ypos > 0.0) ||
+		 (node->direction == XLup && node->Upr.Uline.endpos.ypos < 0.0)) {
 	    printf("[tl]}\n");
 	}
-	else if (node->direction == XLright && node->Upr.Uline.endpos.ypos < 0.0 ||
-		 node->direction == XLup && node->Upr.Uline.endpos.ypos > 0.0) {
+	else if ((node->direction == XLright && node->Upr.Uline.endpos.ypos < 0.0) ||
+		 (node->direction == XLup && node->Upr.Uline.endpos.ypos > 0.0)) {
 	    printf("[tr]}\n");
 	}
 	else {
@@ -12552,8 +12552,8 @@ void produce(stackinx newp, int p)
 	}
 	else {
 	    With1->xval += With1->yval;
-	    if (With1->yval > 0 && With1->xval > With1->endchop ||
-		 With1->yval < 0 && With1->xval < With1->endchop) {
+	    if ((With1->yval > 0 && With1->xval > With1->endchop) ||
+		 (With1->yval < 0 && With1->xval < With1->endchop)) {
 		bswitch = true;
 	    }
 	}
@@ -13464,16 +13464,16 @@ void produce(stackinx newp, int p)
 	      s = sin(With2->Upr.Uline.endpos.xpos);
 	      With2->aat.xpos += With2->Upr.Uline.aradius * r;
 	      With2->aat.ypos += With2->Upr.Uline.aradius * s;
-	      if (With2->direction == XLup && i == XLleft ||
-		   With2->direction == XLdown && i == XLright ||
-		   With2->direction == XLright && i == XLup ||
-		   With2->direction == XLleft && i == XLdown) {
+	      if ((With2->direction == XLup && i == XLleft) ||
+		   (With2->direction == XLdown && i == XLright) ||
+		   (With2->direction == XLright && i == XLup) ||
+		   (With2->direction == XLleft && i == XLdown)) {
 		  With2->Upr.Uline.endpos.ypos = pi * 0.5;
 	      }
-	      else if (With2->direction == XLup && i == XLright ||
-		       With2->direction == XLdown && i == XLleft ||
-		       With2->direction == XLright && i == XLdown ||
-		       With2->direction == XLleft && i == XLup) {
+	      else if ((With2->direction == XLup && i == XLright) ||
+		       (With2->direction == XLdown && i == XLleft) ||
+		       (With2->direction == XLright && i == XLdown) ||
+		       (With2->direction == XLleft && i == XLup)) {
 		  With2->Upr.Uline.endpos.ypos = -pi * 0.5;
 	      }
 	      if (attstack[newp+2].lexval != XEMPTY) {
@@ -17640,7 +17640,7 @@ void defineargbody(int *parenlevel, fbuffer **p2)
 	      }
 	  }
 	  /*D if debuglevel=2 then write(log,' instring=',instring,' '); D*/
-	  if (!instring && (*parenlevel < 0 || *parenlevel == 0 && ch == ',')) {
+	  if (!instring && (*parenlevel < 0 || (*parenlevel == 0 && ch == ','))) {
 	      j = With->savedlen;
 	      inarg = false;
 	  }
@@ -18743,7 +18743,7 @@ void getoptions(void)
 }  /* getoptions */
 
 
-void main(int argc, Char *argv[])
+int main(int argc, Char *argv[])
 { P_argc = argc; P_argv = argv; __top_jb = NULL;
   redirect = NULL;
   copyin = NULL;
