diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-03-01 19:23:13 -0800 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-03-01 19:23:13 -0800 |
commit | f234b29c7fc119fa148af2108f93e5eaf9ecbfb4 (patch) | |
tree | 06aeb86d3dea3a2ec60648cb5ca036ba943aea17 | |
parent | a0404ff58245f16d2117542d2dffd1fc6199943d (diff) | |
download | plan9front-f234b29c7fc119fa148af2108f93e5eaf9ecbfb4.tar.xz |
Mail: revert 096538d64724
-rw-r--r-- | sys/src/cmd/upas/Mail/mbox.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/sys/src/cmd/upas/Mail/mbox.c b/sys/src/cmd/upas/Mail/mbox.c index b32c9b6a4..5b05dc529 100644 --- a/sys/src/cmd/upas/Mail/mbox.c +++ b/sys/src/cmd/upas/Mail/mbox.c @@ -260,15 +260,13 @@ addmesg(Mesg *m, int ins) mbox.mesgsz *= 2; mbox.mesg = erealloc(mbox.mesg, mbox.mesgsz*sizeof(Mesg*)); } - if(ins >= 0){ - if(ins == 0) - idx = slotfor(m); - else - idx = mbox.nmesg; - memmove(&mbox.mesg[idx + 1], &mbox.mesg[idx], (mbox.nmesg - idx)*sizeof(Mesg*)); - mbox.mesg[idx] = m; - mbox.nmesg++; - } + if(ins) + idx = slotfor(m); + else + idx = mbox.nmesg; + memmove(&mbox.mesg[idx + 1], &mbox.mesg[idx], (mbox.nmesg - idx)*sizeof(Mesg*)); + mbox.mesg[idx] = m; + mbox.nmesg++; if(m->messageid == nil) return; @@ -298,7 +296,7 @@ addmesg(Mesg *m, int ins) } static Mesg * -placeholder(char *msgid, vlong time) +placeholder(char *msgid, vlong time, int ins) { Mesg *m; @@ -307,6 +305,7 @@ placeholder(char *msgid, vlong time) m->messageid = estrdup(msgid); m->hash = strhash(msgid); m->time = time; + addmesg(m, ins); return m; } @@ -382,10 +381,8 @@ load(char *name, char *digest, int ins) return m; } p = lookupid(m->inreplyto); - if(p == nil){ - p = placeholder(m->inreplyto, m->time); - addmesg(m, ins); - } + if(p == nil) + p = placeholder(m->inreplyto, m->time, ins); if(!addchild(p, m, d)) m->state |= Stoplev; return m; @@ -659,8 +656,6 @@ relinkmsg(Mesg *p, Mesg *m) /* remove child, preserving order */ j = 0; - if(p == nil || m == nil) - return; for(i = 0; p && i < p->nchild; i++){ if(p->child[i] != m) p->child[j++] = p->child[i]; @@ -680,7 +675,7 @@ relinkmsg(Mesg *p, Mesg *m) static void mbflush(char **, int) { - int i, j, ln, fd, dummy; + int i, j, ln, fd; char *path; Mesg *m, *p; @@ -692,7 +687,7 @@ mbflush(char **, int) sysfatal("open mbox: %r"); while(i < mbox.nmesg){ m = mbox.mesg[i]; - if((m->state & (Sopen|Sdummy)) || !(m->flags & (Fdel|Ftodel))){ + if((m->state & Sopen) || !(m->flags & (Fdel|Ftodel))){ i++; continue; } @@ -703,23 +698,18 @@ mbflush(char **, int) fprint(fd, "delete %s %d", mailbox, atoi(m->name)); p = m->parent; - dummy = 0; removeid(m); if(p == nil && m->nsub != 0){ - p = placeholder(m->messageid, m->time); + p = placeholder(m->messageid, m->time, 1); p->nsub = m->nsub + 1; - addmesg(p, -1); mbox.mesg[i] = p; - dummy = 1; } - relinkmsg(p, m); + if(p != nil) + relinkmsg(p, m); for(j = 0; j < m->nchild; j++) mbredraw(m->child[j], 1, 1); - if(!dummy){ - memmove(&mbox.mesg[i], &mbox.mesg[i+1], (mbox.nmesg - i)*sizeof(Mesg*)); - mbox.nmesg--; - } - mesgfree(m); + memmove(&mbox.mesg[i], &mbox.mesg[i+1], (mbox.nmesg - i)*sizeof(Mesg*)); + mbox.nmesg--; } close(fd); fprint(mbox.ctl, "clean\n"); |