shithub: fm

Download patch

ref: 021767d217ac1a04e51d8c03fcc5bfae881b6fd8
parent: fd11b89767dc2586e0a79cd5b276df5e1c2e9ae0
author: phil9 <[email protected]>
date: Sun Nov 14 17:59:24 EST 2021

more explicit struct field names

--- a/a.h
+++ b/a.h
@@ -2,8 +2,8 @@
 
 struct Match
 {
-	char *n;
-	int s;
+	char *name;
+	int score;
 };
 
 int fuzzymatch(char *pat, char *s);
--- a/main.c
+++ b/main.c
@@ -51,7 +51,7 @@
 
 	m = *(Match*)a;
 	n = *(Match*)b;
-	return n.s - m.s;
+	return n.score - m.score;
 }
 
 void
@@ -63,8 +63,8 @@
 	for(i = 0; i < nlines; i++){
 		s = fuzzymatch(pat, lines[i]);
 		if(s >= 0){
-			matches[nmatches].n = lines[i];
-			matches[nmatches].s = s;
+			matches[nmatches].name  = lines[i];
+			matches[nmatches].score = s;
 			nmatches++;
 		}
 	}
@@ -85,7 +85,7 @@
 		if(s == nil)
 			break;
 		lines[nlines++] = s;
-		matches[nmatches++].n = s;
+		matches[nmatches++].name = s;
 		if(nlines >= Maxlines)
 			break;
 	}
@@ -99,10 +99,10 @@
 
 	m = matches[lsel + loff];
 	if(pmode){
-		print("%s", m.n);
+		print("%s", m.name);
 		threadexitsall(nil);
 	}
-	plumbsendtext(plumbfd, argv0, nil, pwd, m.n);
+	plumbsendtext(plumbfd, argv0, nil, pwd, m.name);
 }
 
 int
@@ -132,7 +132,7 @@
 	if(loff + i >= nmatches)
 		return;
 	draw(screen, linerect(i), sel ? selbg : display->white, nil, ZP);
-	string(screen, addpt(lr.min, Pt(0, i * lh)), display->black, ZP, font, matches[loff + i].n);
+	string(screen, addpt(lr.min, Pt(0, i * lh)), display->black, ZP, font, matches[loff + i].name);
 }
 
 void
@@ -192,7 +192,7 @@
 	}else{
 		nmatches = 0;
 		for(i = 0; i < nlines; i++)
-			matches[nmatches++].n = lines[i];
+			matches[nmatches++].name = lines[i];
 	}
 	if(lsel >= (nmatches - 1))
 		lsel = 0;