shithub: Nail

Download patch

ref: 7b17c392d3d9a3616009d11681b6f6dfdbf2ed04
parent: 62741ed595f4ad79b7d7d18fdc4049a6b46baa8d
author: Ori Bernstein <[email protected]>
date: Thu Nov 12 18:19:15 EST 2020

Count tree height corectly: account for dummy at root.

--- a/mbox.c
+++ b/mbox.c
@@ -215,9 +215,7 @@
 		e = mbox.hash[i];
 		if(e == nil)
 			return;
-		if(e == &dead)
-			continue;
-		if(e->hash == m->hash && strcmp(e->messageid, m->messageid) == 0){
+		if(e != &dead && e->hash == m->hash && strcmp(e->messageid, m->messageid) == 0){
 			mbox.hash[i] = &dead;
 			mbox.ndead++;
 		}
@@ -660,7 +658,7 @@
 {
 	char *digest, *action;
 	Mesg *m, *r;
-	int ln;
+	int ln, nr;
 
 	digest = plumblookup(pm->attr, "digest");
 	action = plumblookup(pm->attr, "mailtype");
@@ -673,7 +671,9 @@
 		/* Bump whole thread up in list */
 		if(r->nsub > 0){
 			ln = mesglineno(r, nil);
-			fprint(mbox.addr, "%d,%d", ln, ln+r->nsub-1);
+			nr = r->nsub + (r->flags & Fdummy) ? 0 : 1;
+			assert(nr >= 0);
+			fprint(mbox.addr, "%d,%d", ln, ln+nr-1);
 			write(mbox.data, "", 0);
 			reinsert(r);
 		}