diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-01-14 11:41:08 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-01-14 11:41:08 +0100 |
commit | 02d7aa8915f9c3a3288dab01f321eb94ba219e3b (patch) | |
tree | f053238978479e408a2b83571443e132f30586ab /src/cmd/acme | |
parent | c0c9d8f883dfd3a7f5a74499d91bb95884b15873 (diff) | |
parent | 3d1382b98a502d0c34d5ba2c462396acc515016e (diff) | |
download | plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.gz plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.bz2 plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd/acme')
-rw-r--r-- | src/cmd/acme/acme.c | 129 | ||||
-rw-r--r-- | src/cmd/acme/cols.c | 12 | ||||
-rw-r--r-- | src/cmd/acme/ecmd.c | 37 | ||||
-rw-r--r-- | src/cmd/acme/edit.c | 4 | ||||
-rw-r--r-- | src/cmd/acme/elog.c | 4 | ||||
-rw-r--r-- | src/cmd/acme/exec.c | 8 | ||||
-rw-r--r-- | src/cmd/acme/fns.h | 1 | ||||
-rw-r--r-- | src/cmd/acme/fsys.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/logf.c | 16 | ||||
-rw-r--r-- | src/cmd/acme/look.c | 20 | ||||
-rw-r--r-- | src/cmd/acme/mail/dat.h | 1 | ||||
-rw-r--r-- | src/cmd/acme/mail/html.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/mail/mail.c | 15 | ||||
-rw-r--r-- | src/cmd/acme/mail/mesg.c | 16 | ||||
-rw-r--r-- | src/cmd/acme/mail/reply.c | 8 | ||||
-rw-r--r-- | src/cmd/acme/mail/util.c | 1 | ||||
-rw-r--r-- | src/cmd/acme/mail/win.c | 2 | ||||
-rw-r--r-- | src/cmd/acme/text.c | 20 | ||||
-rw-r--r-- | src/cmd/acme/util.c | 6 | ||||
-rw-r--r-- | src/cmd/acme/wind.c | 87 |
20 files changed, 214 insertions, 177 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 12701f23..e5658a4e 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -968,69 +968,69 @@ Cursor boxcursor = { Cursor2 boxcursor2 = { {-15, -15}, - {0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xC0, 0x03, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, + {0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xC0, 0x03, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0x00, 0x00, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x00, 0x00, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0x00, 0x00, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; @@ -1047,7 +1047,7 @@ iconinit(void) tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue); tagcols[TEXT] = display->black; tagcols[HTEXT] = display->black; - + /* Yellow */ textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite); textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow); @@ -1055,7 +1055,7 @@ iconinit(void) textcols[TEXT] = display->black; textcols[HTEXT] = display->black; } - + r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1); if(button && eqrect(r, button->r)) return; @@ -1169,4 +1169,3 @@ timefmt(Fmt *f) return fmtprint(f, "%04d/%02d/%02d %02d:%02d:%02d", tm->year+1900, tm->mon+1, tm->mday, tm->hour, tm->min, tm->sec); } - diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c index 6215e044..63c33ac1 100644 --- a/src/cmd/acme/cols.c +++ b/src/cmd/acme/cols.c @@ -89,19 +89,19 @@ coladd(Column *c, Window *w, Window *clone, int y) /* * figure out where to split v to make room for w */ - + /* new window stops where next window begins */ if(i < c->nw) ymax = c->w[i]->r.min.y-Border; else ymax = c->r.max.y; - + /* new window must start after v's tag ends */ y = max(y, v->tagtop.max.y+Border); - + /* new window must start early enough to end before ymax */ y = min(y, ymax - minht); - + /* if y is too small, too many windows in column */ if(y < v->tagtop.max.y+Border) buggered = 1; @@ -118,7 +118,7 @@ coladd(Column *c, Window *w, Window *clone, int y) r1.min.y = winresize(v, r1, FALSE, FALSE); r1.max.y = r1.min.y+Border; draw(screen, r1, display->black, nil, ZP); - + /* * leave r with w's coordinates */ @@ -142,7 +142,7 @@ coladd(Column *c, Window *w, Window *clone, int y) c->nw++; c->w[i] = w; c->safe = TRUE; - + /* if there were too many windows, redraw the whole column */ if(buggered) colresize(c, c->r); diff --git a/src/cmd/acme/ecmd.c b/src/cmd/acme/ecmd.c index ef92e339..f7613172 100644 --- a/src/cmd/acme/ecmd.c +++ b/src/cmd/acme/ecmd.c @@ -28,7 +28,7 @@ int append(File*, Cmd*, long); int pdisplay(File*); void pfilename(File*); void looper(File*, Cmd*, int); -void filelooper(Cmd*, int); +void filelooper(Text*, Cmd*, int); void linelooper(File*, Cmd*); Address lineaddr(long, Address, int); int filematch(File*, String*); @@ -584,7 +584,7 @@ X_cmd(Text *t, Cmd *cp) { USED(t); - filelooper(cp, cp->cmdc=='X'); + filelooper(t, cp, cp->cmdc=='X'); return TRUE; } @@ -633,8 +633,8 @@ runpipe(Text *t, int cmd, Rune *cr, int ncr, int state) /* * The editoutlk exists only so that we can tell when * the editout file has been closed. It can get closed *after* - * the process exits because, since the process cannot be - * connected directly to editout (no 9P kernel support), + * the process exits because, since the process cannot be + * connected directly to editout (no 9P kernel support), * the process is actually connected to a pipe to another * process (arranged via 9pserve) that reads from the pipe * and then writes the data in the pipe to editout using @@ -704,7 +704,7 @@ printposn(Text *t, int mode) if (t != nil && t->file != nil && t->file->name != nil) warning(nil, "%.*S:", t->file->nname, t->file->name); - + switch(mode) { case PosnChars: warning(nil, "#%d", addr.r.q0); @@ -712,7 +712,7 @@ printposn(Text *t, int mode) warning(nil, ",#%d", addr.r.q1); warning(nil, "\n"); return; - + default: case PosnLine: l1 = 1+nlcount(t, 0, addr.r.q0, nil); @@ -978,9 +978,10 @@ alllocker(Window *w, void *v) } void -filelooper(Cmd *cp, int XY) +filelooper(Text *t, Cmd *cp, int XY) { int i; + Text *targ; if(Glooping++) editerror("can't nest %c command", "YX"[XY]); @@ -1001,8 +1002,26 @@ filelooper(Cmd *cp, int XY) */ allwindows(alllocker, (void*)1); globalincref = 1; - for(i=0; i<loopstruct.nw; i++) - cmdexec(&loopstruct.w[i]->body, cp->u.cmd); + + /* + * Unlock the window running the X command. + * We'll need to lock and unlock each target window in turn. + */ + if(t && t->w) + winunlock(t->w); + + for(i=0; i<loopstruct.nw; i++) { + targ = &loopstruct.w[i]->body; + if(targ && targ->w) + winlock(targ->w, cp->cmdc); + cmdexec(targ, cp->u.cmd); + if(targ && targ->w) + winunlock(targ->w); + } + + if(t && t->w) + winlock(t->w, cp->cmdc); + allwindows(alllocker, (void*)0); globalincref = 0; free(loopstruct.w); diff --git a/src/cmd/acme/edit.c b/src/cmd/acme/edit.c index d3f82059..81f80300 100644 --- a/src/cmd/acme/edit.c +++ b/src/cmd/acme/edit.c @@ -515,7 +515,7 @@ parsecmd(int nest) if(nextc() == 'g') cmd.flag = getch(); } - + } } } @@ -613,7 +613,7 @@ simpleaddr(void) addr.num = getnum(1); break; case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': + case '5': case '6': case '7': case '8': case '9': addr.num = getnum(1); addr.type='l'; break; diff --git a/src/cmd/acme/elog.c b/src/cmd/acme/elog.c index c5650f03..8a8951fb 100644 --- a/src/cmd/acme/elog.c +++ b/src/cmd/acme/elog.c @@ -243,7 +243,7 @@ elogapply(File *f) * but using coordinates relative to the unmodified buffer. As we apply the log, * we have to update the coordinates to be relative to the modified buffer. * Textinsert and textdelete will do this for us; our only work is to apply the - * convention that an insertion at t->q0==t->q1 is intended to select the + * convention that an insertion at t->q0==t->q1 is intended to select the * inserted text. */ @@ -337,7 +337,7 @@ elogapply(File *f) } fbuffree(buf); elogterm(f); - + /* * Bad addresses will cause bufload to crash, so double check. * If changes were out of order, we expect problems so don't complain further. diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index bb2c93d6..3575c984 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -702,7 +702,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) Rune *r; Biobuf *b; char *s, *name; - int i, fd, q; + int i, fd, q, ret; Dir *d, *d1; Window *w; int isapp; @@ -765,9 +765,13 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) warning(nil, "can't write file %s: %r\n", name); goto Rescue2; } - Bterm(b); + ret = Bterm(b); free(b); b = nil; + if(ret < 0) { + warning(nil, "can't write file %s: %r\n", name); + goto Rescue2; // flush or close failed + } if(runeeq(namer, nname, f->name, f->nname)){ if(q0!=0 || q1!=f->b.nc){ f->mod = TRUE; diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h index 8dc02378..c0339c23 100644 --- a/src/cmd/acme/fns.h +++ b/src/cmd/acme/fns.h @@ -95,6 +95,7 @@ void flushwarnings(void); void startplumbing(void); long nlcount(Text*, long, long, long*); long nlcounttopos(Text*, long, long, long); +Rune* parsetag(Window*, int, int*); Runestr runestr(Rune*, uint); Range range(int, int); diff --git a/src/cmd/acme/fsys.c b/src/cmd/acme/fsys.c index 4c395eb2..d9d4b30d 100644 --- a/src/cmd/acme/fsys.c +++ b/src/cmd/acme/fsys.c @@ -463,7 +463,7 @@ fsyswalk(Xfid *x, Fid *f) qunlock(&row.lk); dir = dirtabw; goto Accept; - + Regular: if(strcmp(x->fcall.wname[i], "new") == 0){ if(w) diff --git a/src/cmd/acme/logf.c b/src/cmd/acme/logf.c index 567b8383..562026c9 100644 --- a/src/cmd/acme/logf.c +++ b/src/cmd/acme/logf.c @@ -20,7 +20,7 @@ struct Log Rendez r; vlong start; // msg[0] corresponds to 'start' in the global sequence of events - + // queued events (nev=entries in ev, mev=capacity of p) char **ev; int nev; @@ -30,7 +30,7 @@ struct Log Fid **f; int nf; int mf; - + // active (blocked) reads waiting for events Xfid **read; int nread; @@ -43,7 +43,7 @@ void xfidlogopen(Xfid *x) { qlock(&eventlog.lk); - if(eventlog.nf >= eventlog.mf) { + if(eventlog.nf >= eventlog.mf) { eventlog.mf = eventlog.mf*2; if(eventlog.mf == 0) eventlog.mf = 8; @@ -78,20 +78,20 @@ xfidlogread(Xfid *x) Fcall fc; qlock(&eventlog.lk); - if(eventlog.nread >= eventlog.mread) { + if(eventlog.nread >= eventlog.mread) { eventlog.mread = eventlog.mread*2; if(eventlog.mread == 0) eventlog.mread = 8; eventlog.read = erealloc(eventlog.read, eventlog.mread*sizeof eventlog.read[0]); } eventlog.read[eventlog.nread++] = x; - + if(eventlog.r.l == nil) eventlog.r.l = &eventlog.lk; x->flushed = FALSE; while(x->f->logoff >= eventlog.start+eventlog.nev && !x->flushed) rsleep(&eventlog.r); - + for(i=0; i<eventlog.nread; i++) { if(eventlog.read[i] == x) { eventlog.read[i] = eventlog.read[--eventlog.nread]; @@ -112,7 +112,7 @@ xfidlogread(Xfid *x) fc.data = p; fc.count = strlen(p); respond(x, &fc, nil); - free(p); + free(p); } void @@ -177,7 +177,7 @@ xfidlog(Window *w, char *op) eventlog.start += n; memmove(eventlog.ev, eventlog.ev+n, eventlog.nev*sizeof eventlog.ev[0]); } - + // Otherwise grow. if(eventlog.nev >= eventlog.mev) { eventlog.mev = eventlog.mev*2; diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 44e23cca..35667c6c 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -477,9 +477,9 @@ includename(Text *t, Rune *r, int n) Runestr dirname(Text *t, Rune *r, int n) { - Rune *b, c; - uint m, nt; - int slash; + Rune *b; + uint nt; + int slash, i; Runestr tmp; b = nil; @@ -490,15 +490,13 @@ dirname(Text *t, Rune *r, int n) goto Rescue; if(n>=1 && r[0]=='/') goto Rescue; - b = runemalloc(nt+n+1); - bufread(&t->w->tag.file->b, 0, b, nt); + b = parsetag(t->w, n, &i); slash = -1; - for(m=0; m<nt; m++){ - c = b[m]; - if(c == '/') - slash = m; - if(c==' ' || c=='\t') + for(i--; i >= 0; i--){ + if(b[i] == '/'){ + slash = i; break; + } } if(slash < 0) goto Rescue; @@ -612,7 +610,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) if(nname == -1) nname = n; for(i=0; i<nname; i++) - if(!isfilec(r[i])) + if(!isfilec(r[i]) && r[i] != ' ') goto Isntfile; /* * See if it's a file name in <>, and turn that into an include diff --git a/src/cmd/acme/mail/dat.h b/src/cmd/acme/mail/dat.h index a7ac6a0b..66bb3a5d 100644 --- a/src/cmd/acme/mail/dat.h +++ b/src/cmd/acme/mail/dat.h @@ -178,4 +178,3 @@ extern int shortmenu; extern CFsys *mailfs; extern CFsys *acmefs; - diff --git a/src/cmd/acme/mail/html.c b/src/cmd/acme/mail/html.c index e3a956b0..e193fc4d 100644 --- a/src/cmd/acme/mail/html.c +++ b/src/cmd/acme/mail/html.c @@ -67,7 +67,7 @@ char* readbody(char *type, char *dir, int *np) { char *body; - + body = readfile(dir, "body", np); if(body != nil && strcmp(type, "text/html") == 0) return formathtml(body, np); diff --git a/src/cmd/acme/mail/mail.c b/src/cmd/acme/mail/mail.c index d79721f8..e1047bb8 100644 --- a/src/cmd/acme/mail/mail.c +++ b/src/cmd/acme/mail/mail.c @@ -558,16 +558,16 @@ mainctl(void *v) Unknown: print("unknown message %c%c\n", e->c1, e->c2); break; - + case 'E': /* write to body; can't affect us */ break; - + case 'F': /* generated by our actions; ignore */ break; - + case 'K': /* type away; we don't care */ break; - + case 'M': switch(e->c2){ case 'x': @@ -597,7 +597,7 @@ mainctl(void *v) if(na) free(s); break; - + case 'l': case 'L': buf = nil; @@ -628,17 +628,16 @@ mainctl(void *v) winwriteevent(w, e); free(buf); break; - + case 'I': /* modify away; we don't care */ case 'D': case 'd': case 'i': break; - + default: goto Unknown; } } } } - diff --git a/src/cmd/acme/mail/mesg.c b/src/cmd/acme/mail/mesg.c index 9bfe10e1..739ce10a 100644 --- a/src/cmd/acme/mail/mesg.c +++ b/src/cmd/acme/mail/mesg.c @@ -85,7 +85,7 @@ mkaddrs(char *t, char **colon) int i, nf, inquote; char **f, *s; Fmt fmt; - + inquote = 0; nf = 2; for(s=t; *s; s++){ @@ -127,7 +127,7 @@ loadinfo(Message *m, char *dir) data = readfile(dir, "info", &n); if(data == nil) return 0; - + p = data; while((s = line(p, &p)) != nil && *s != 0){ t = strchr(s, ' '); @@ -282,7 +282,7 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest) if (m->level != 1){ m->recursed = 1; - readmbox(m, dir, m->name); + readmbox(m, dir, m->name); } return 1; } @@ -351,7 +351,7 @@ readfile(char *dir, char *name, int *np) fsseek(fid, 0, 0); free(d); d = fsdirfstat(fid); - } + } free(file); len = 0; if(d != nil) @@ -400,13 +400,13 @@ info(Message *m, int ind, int ogf) i = estrdup(s); return i; - } + } i = estrdup(""); i = eappend(i, "\t", p); i = egrow(i, "\t", stripdate(m->date)); if(ind == 0){ - if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 && + if(strcmp(m->type, "text")!=0 && strncmp(m->type, "text/", 5)!=0 && strncmp(m->type, "multipart/", 10)!=0) i = egrow(i, "\t(", estrstrdup(m->type, ")")); }else if(strncmp(m->type, "multipart/", 10) != 0) @@ -647,7 +647,7 @@ mesgsave(Message *m, char *s, int save) } return 1; } - + t = estrstrdup(mbox.name, m->name); raw = readfile(t, "raw", &n); unixheader = readfile(t, "unixheader", &k); @@ -1160,7 +1160,7 @@ tokenizec(char *str, char **args, int max, char *splitc) if(max <= 0) return 0; - + /* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */ /* splitc = ","; */ for(na=0; *str != '\0';str++){ diff --git a/src/cmd/acme/mail/reply.c b/src/cmd/acme/mail/reply.c index 5dda0edc..f28cbef1 100644 --- a/src/cmd/acme/mail/reply.c +++ b/src/cmd/acme/mail/reply.c @@ -78,7 +78,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext) Plumbattr *a; quotereply = (label[0] == 'Q'); - + if(quotereply && m && m->replywinid > 0){ snprint(buf, sizeof buf, "%d/body", m->replywinid); if((fd = fsopen(acmefs, buf, OWRITE)) != nil){ @@ -88,7 +88,7 @@ mkreply(Message *m, char *label, char *to, Plumbattr *attr, char *quotetext) return; } } - + r = emalloc(sizeof(Message)); r->isreply = 1; if(m != nil) @@ -212,7 +212,7 @@ execproc(void *v) q[0] = e->q[0]; q[1] = e->q[1]; prog = e->prog; /* known not to be malloc'ed */ - + fd[0] = dup(p[0], -1); if(q[0]) fd[1] = dup(q[1], -1); @@ -224,7 +224,7 @@ execproc(void *v) free(e->argv); chanfree(e->sync); free(e); - + threadexec(nil, fd, prog, argv); close(fd[0]); close(fd[1]); diff --git a/src/cmd/acme/mail/util.c b/src/cmd/acme/mail/util.c index 888e7e72..8ac9f946 100644 --- a/src/cmd/acme/mail/util.c +++ b/src/cmd/acme/mail/util.c @@ -104,4 +104,3 @@ ctlprint(CFid *fd, char *fmt, ...) if(n <= 0) error("control file write error: %r"); } - diff --git a/src/cmd/acme/mail/win.c b/src/cmd/acme/mail/win.c index 84c9cee0..1cf776dd 100644 --- a/src/cmd/acme/mail/win.c +++ b/src/cmd/acme/mail/win.c @@ -196,7 +196,7 @@ wingeter(Window *w, char *buf, int *nb) while(!fullrune(buf, n)) buf[n++] = wingetec(w); chartorune(&r, buf); - } + } *nb = n; return r; } diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c index 241665ff..00a3ed5b 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -391,7 +391,7 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile) textscrdraw(u); } } - + } if(q0 < t->iq1) t->iq1 += n; @@ -552,7 +552,7 @@ textbswidth(Text *t, Rune c) if(r == '\n'){ /* eat at most one more character */ if(q == t->q0) /* eat the newline */ --q; - break; + break; } if(c == 0x17){ eq = isalnum(r); @@ -842,7 +842,7 @@ texttype(Text *t, Rune r) winresize(t->w, t->w->r, FALSE, TRUE); } return; - + Tagup: /* shrink tag to single line */ if(t->w->tagexpand){ @@ -1254,7 +1254,7 @@ void textsetselect(Text *t, uint q0, uint q1) { int p0, p1, ticked; - + /* t->fr.p0 and t->fr.p1 are always right; t->q0 and t->q1 may be off */ t->q0 = q0; t->q1 = q1; @@ -1407,7 +1407,7 @@ textselect23(Text *t, uint *q0, uint *q1, Image *high, int mask) { uint p0, p1; int buts; - + p0 = xselect(&t->fr, mousectl, high, &p1); buts = mousectl->m.buttons; if((buts & mask) == 0){ @@ -1474,7 +1474,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1) if(textclickhtmlmatch(t, q0, q1)) return; - + for(i=0; left[i]!=nil; i++){ q = *q0; l = left[i]; @@ -1506,7 +1506,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1) return; } } - + /* try filling out word to right */ while(*q1<t->file->b.nc && isalnum(textreadc(t, *q1))) (*q1)++; @@ -1580,7 +1580,7 @@ static int ishtmlend(Text *t, uint q, uint *q0) { int c, c1, c2; - + if(q < 2) return 0; if(textreadc(t, --q) != '>') @@ -1608,7 +1608,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1) { int depth, n; uint q, nq; - + q = *q0; // after opening tag? scan forward for closing tag if(ishtmlend(t, q, nil) == 1) { @@ -1645,7 +1645,7 @@ textclickhtmlmatch(Text *t, uint *q0, uint *q1) q--; } } - + return 0; } diff --git a/src/cmd/acme/util.c b/src/cmd/acme/util.c index d694634f..c153f8c1 100644 --- a/src/cmd/acme/util.c +++ b/src/cmd/acme/util.c @@ -132,7 +132,7 @@ errorwin(Mntdir *md, int owner) } /* - * Incoming window should be locked. + * Incoming window should be locked. * It will be unlocked and returned window * will be locked in its place. */ @@ -189,7 +189,7 @@ void addwarningtext(Mntdir *md, Rune *r, int nr) { Warning *warn; - + for(warn = warnings; warn; warn=warn->next){ if(warn->md == md){ bufinsert(&warn->buf, warn->buf.nc, r, nr); @@ -276,6 +276,8 @@ runeeq(Rune *s1, uint n1, Rune *s2, uint n2) { if(n1 != n2) return FALSE; + if(n1 == 0) + return TRUE; return memcmp(s1, s2, n1*sizeof(Rune)) == 0; } diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 9010192a..cf261311 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -100,7 +100,7 @@ windrawbutton(Window *w) { Image *b; Rectangle br; - + b = button; if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache)) b = modbutton; @@ -113,25 +113,22 @@ windrawbutton(Window *w) int delrunepos(Window *w) { - int n; - Rune rune; - - for(n=0; n<w->tag.file->b.nc; n++) { - bufread(&w->tag.file->b, n, &rune, 1); - if(rune == ' ') - break; - } - n += 2; - if(n >= w->tag.file->b.nc) + Rune *r; + int i; + + r = parsetag(w, 0, &i); + free(r); + i += 2; + if(i >= w->tag.file->b.nc) return -1; - return n; + return i; } void movetodel(Window *w) { int n; - + n = delrunepos(w); if(n < 0) return; @@ -156,7 +153,7 @@ wintaglines(Window *w, Rectangle r) textresize(&w->tag, r, TRUE); w->tag.fr.noredraw = 0; w->tagsafe = FALSE; - + if(!w->tagexpand) { /* use just as many lines as needed to show the Del */ n = delrunepos(w); @@ -165,7 +162,7 @@ wintaglines(Window *w, Rectangle r) p = subpt(frptofchar(&w->tag.fr, n), w->tag.fr.r.min); return 1 + p.y / w->tag.fr.font->height; } - + /* can't use more than we have */ if(w->tag.fr.nlines >= w->tag.fr.maxlines) return w->tag.fr.maxlines; @@ -227,7 +224,7 @@ winresize(Window *w, Rectangle r, int safe, int keepextra) moveto(mousectl, p); } } - + /* If needed, resize & redraw body. */ r1 = r; r1.min.y = y; @@ -296,7 +293,7 @@ winunlock(Window *w) void winmousebut(Window *w) { - moveto(mousectl, addpt(w->tag.scrollr.min, + moveto(mousectl, addpt(w->tag.scrollr.min, divpt(Pt(Dx(w->tag.scrollr), font->height), 2))); } @@ -422,11 +419,7 @@ wincleartag(Window *w) /* w must be committed */ n = w->tag.file->b.nc; - r = runemalloc(n); - bufread(&w->tag.file->b, 0, r, n); - for(i=0; i<n; i++) - if(r[i]==' ' || r[i]=='\t') - break; + r = parsetag(w, 0, &i); for(; i<n; i++) if(r[i] == '|') break; @@ -443,6 +436,38 @@ wincleartag(Window *w) textsetselect(&w->tag, w->tag.q0, w->tag.q1); } +Rune* +parsetag(Window *w, int extra, int *len) +{ + static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0 }; + static Rune Lspacepipe[] = { ' ', '|', 0 }; + static Rune Ltabpipe[] = { '\t', '|', 0 }; + int i; + Rune *r, *p, *pipe; + + r = runemalloc(w->tag.file->b.nc+extra+1); + bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc); + r[w->tag.file->b.nc] = '\0'; + + /* + * " |" or "\t|" ends left half of tag + * If we find " Del Snarf" in the left half of the tag + * (before the pipe), that ends the file name. + */ + pipe = runestrstr(r, Lspacepipe); + if((p = runestrstr(r, Ltabpipe)) != nil && (pipe == nil || p < pipe)) + pipe = p; + if((p = runestrstr(r, Ldelsnarf)) != nil && (pipe == nil || p < pipe)) + i = p - r; + else { + for(i=0; i<w->tag.file->b.nc; i++) + if(r[i]==' ' || r[i]=='\t') + break; + } + *len = i; + return r; +} + void winsettag1(Window *w) { @@ -461,12 +486,7 @@ winsettag1(Window *w) /* there are races that get us here with stuff in the tag cache, so we take extra care to sync it */ if(w->tag.ncache!=0 || w->tag.file->mod) wincommit(w, &w->tag); /* check file name; also guarantees we can modify tag contents */ - old = runemalloc(w->tag.file->b.nc+1); - bufread(&w->tag.file->b, 0, old, w->tag.file->b.nc); - old[w->tag.file->b.nc] = '\0'; - for(i=0; i<w->tag.file->b.nc; i++) - if(old[i]==' ' || old[i]=='\t') - break; + old = parsetag(w, 0, &i); if(runeeq(old, i, w->body.file->name, w->body.file->nname) == FALSE){ textdelete(&w->tag, 0, i, TRUE); textinsert(&w->tag, 0, w->body.file->name, w->body.file->nname, TRUE); @@ -479,7 +499,8 @@ winsettag1(Window *w) /* compute the text for the whole tag, replacing current only if it differs */ new = runemalloc(w->body.file->nname+100); i = 0; - runemove(new+i, w->body.file->name, w->body.file->nname); + if(w->body.file->nname != 0) + runemove(new, w->body.file->name, w->body.file->nname); i += w->body.file->nname; runemove(new+i, Ldelsnarf, 10); i += 10; @@ -586,11 +607,7 @@ wincommit(Window *w, Text *t) textcommit(f->text[i], FALSE); /* no-op for t */ if(t->what == Body) return; - r = runemalloc(w->tag.file->b.nc); - bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc); - for(i=0; i<w->tag.file->b.nc; i++) - if(r[i]==' ' || r[i]=='\t') - break; + r = parsetag(w, 0, &i); if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){ seq++; filemark(w->body.file); @@ -675,7 +692,7 @@ winctlprint(Window *w, char *buf, int fonts) sprint(buf, "%11d %11d %11d %11d %11d ", w->id, w->tag.file->b.nc, w->body.file->b.nc, w->isdir, w->dirty); if(fonts) - return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r), + return smprint("%s%11d %q %11d ", buf, Dx(w->body.fr.r), w->body.reffont->f->name, w->body.fr.maxtab); return buf; } |