shithub: riscv

Download patch

ref: ee6ffe998bdef7b5780a373589ff90f123198821
parent: 6d2d7e0ea19a6a538a65e63000154198e6bb1493
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jan 6 15:11:34 EST 2023

libmemdraw: coding style (from drawterm)

--- a/sys/src/libmemdraw/draw.c
+++ b/sys/src/libmemdraw/draw.c
@@ -1296,7 +1296,7 @@
 	r = p->bytermin + y*p->bwidth;
 	bits = *r++;
 	nbits = 8;
-	if(i=x&(npack-1)){
+	if((i=x&(npack-1)) != 0){
 		bits <<= depth*i;
 		nbits -= depth*i;
 	}
@@ -1324,7 +1324,7 @@
 	r = p->bytey0s + y*p->bwidth;
 	bits = *r++;
 	nbits = 8;
-	if(i=x&(npack-1)){
+	if((i=x&(npack-1)) != 0){
 		bits <<= depth*i;
 		nbits -= depth*i;
 	}
--- a/sys/src/libmemdraw/ellipse.c
+++ b/sys/src/libmemdraw/ellipse.c
@@ -124,7 +124,7 @@
 	p.op = op;
 
 	u = (t<<1)*(a-b);
-	if(b<a && u>b*b || a<b && -u>a*a) {
+	if((b<a && u>b*b) || (a<b && -u>a*a)) {
 /*	if(b<a&&(t<<1)>b*b/a || a<b&&(t<<1)>a*a/b)	# very thick */
 		bellipse(b, newstate(&in, a, b), &p);
 		return;
@@ -207,7 +207,7 @@
 {
 	Rectangle r;
 
-/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); /**/
+/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); */
 	r = Rect(p->c.x+x0, p->c.y+y0, p->c.x+x1+1, p->c.y+y1+1);
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), memopaque, ZP, p->op);
 }
@@ -222,7 +222,7 @@
 	Point p0;
 	Rectangle r;
 
-/*	print("P%d %d,%d\n", p->t, x, y);	/**/
+/*	print("P%d %d,%d\n", p->t, x, y); */
 	p0 = Pt(p->c.x+x, p->c.y+y);
 	r = Rpt(addpt(p0, p->disc->r.min), addpt(p0, p->disc->r.max));
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op);
@@ -235,7 +235,7 @@
 void
 eline(int x0, int y0, int x1, int y1, Param *p)
 {
-/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); /**/
+/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); */
 	if(x1 > x0+1)
 		erect(x0+1, y0-p->t, x1-1, y1+p->t, p);
 	else if(y1 > y0+1)
--- a/sys/src/libmemdraw/line.c
+++ b/sys/src/libmemdraw/line.c
@@ -13,23 +13,24 @@
 
 static
 int
-lmin(int a, int b)
+lmax(int a, int b)
 {
-	if(a < b)
+	if(a > b)
 		return a;
 	return b;
 }
 
+#ifdef NOTUSED
+
 static
 int
-lmax(int a, int b)
+lmin(int a, int b)
 {
-	if(a > b)
+	if(a < b)
 		return a;
 	return b;
 }
 
-#ifdef NOTUSED
 /*
  * Rather than line clip, we run the Bresenham loop over the full line,
  * and clip on each pixel.  This is more expensive but means that
--- a/sys/src/libmemdraw/string.c
+++ b/sys/src/libmemdraw/string.c
@@ -13,7 +13,7 @@
 	Fontchar *i;
 
 	s = (uchar*)cs;
-	for(; c=*s; p.x+=width, cp.x+=width){
+	for(; (c=*s) != 0; p.x+=width, cp.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
@@ -46,7 +46,7 @@
 
 	p = Pt(0, f->height);
 	s = (uchar*)cs;
-	for(; c=*s; p.x+=width){
+	for(; (c=*s) != 0; p.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;