shithub: Nail

Download patch

ref: 45505983f4a552fbfb71dbdfad56b8792d04e2b6
parent: 45cd659ce651be49bb2f9cdfb8ad51435dc08e76
author: Ori Bernstein <[email protected]>
date: Thu Nov 5 19:46:58 EST 2020

make Upthread: link in message work

--- a/mbox.c
+++ b/mbox.c
@@ -839,7 +839,7 @@
 	mbox.show = chancreate(sizeof(Plumbmsg*), 0);
 
 	addrpat = regcomp("[^ \t]*@[^ \t]*\\.[^ \t]*");
-	mesgpat = regcomp("(\\(deleted\\)-)?[0-9]+/.*");
+	mesgpat = regcomp("[0-9]+(/.*)?");
 	cwait = threadwaitchan();
 
 	if(argc > 1)
--- a/mesg.c
+++ b/mesg.c
@@ -235,7 +235,7 @@
 
 	if((wfd = winopen(m, "body", OWRITE)) == -1)
 		return -1;
-	if(m->parent != nil)
+	if(m->parent != nil && m->parent->name != nil)
 		fprint(wfd, "Upthread: %s\n", m->parent->name);
 	fprint(wfd, "From: %s\n", m->fromcolon);
 	fprint(wfd, "To:   %s\n", m->to);
@@ -409,16 +409,18 @@
 void
 mesgpath2name(char *buf, int nbuf, char *name)
 {
-	char *e;
+	char *p, *e;
 	int n;
 
 	n = strlen(mbox.path);
-	if(strncmp(name, mbox.path, n) == 0){
-		e = strecpy(buf, buf + nbuf - 2, name + n);
-		e[0] = '/';
-		e[1] = 0;
-	}else
-		strecpy(buf, buf+nbuf, name);
+	if(strncmp(name, mbox.path, n) == 0)
+		e = strecpy(buf, buf+nbuf-2, name + n);
+	else
+		e = strecpy(buf, buf+nbuf-2, name);
+	if((p = strchr(buf, '/')) == nil)
+		p = e;
+	p[0] = '/';
+	p[1] = 0;
 }
 
 int
--- a/win.c
+++ b/win.c
@@ -317,8 +317,10 @@
 	if(strncmp(text, mbox.path, strlen(mbox.path)) == 0)
 		return 1;
 	else if(regexec(mesgpat, text, nil, 0)){
+		print("matchedx\n");
 		if((p = strchr(text, '/')) != nil)
 			p[1] = 0;
+		print("matched\n");
 		return 1;
 	}
 	return 0;