diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-02-11 13:40:11 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-02-11 13:40:11 +0100 |
commit | 9c79e48c93c0c4d14aabcb490fab048d68934cb2 (patch) | |
tree | 1d57d3fd193621a2357473bb65b92190914c5736 /src/cmd/acme | |
parent | 02d7aa8915f9c3a3288dab01f321eb94ba219e3b (diff) | |
parent | 0237dec768a4ee36ae9e18ce8566d2c999d78410 (diff) | |
download | plan9port-9c79e48c93c0c4d14aabcb490fab048d68934cb2.tar.gz plan9port-9c79e48c93c0c4d14aabcb490fab048d68934cb2.tar.bz2 plan9port-9c79e48c93c0c4d14aabcb490fab048d68934cb2.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd/acme')
-rw-r--r-- | src/cmd/acme/exec.c | 10 | ||||
-rw-r--r-- | src/cmd/acme/rows.c | 20 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 3575c984..f6dc32f4 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, ret; + int i, fd, q, ret, retc; Dir *d, *d1; Window *w; int isapp; @@ -766,9 +766,10 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) goto Rescue2; } ret = Bterm(b); + retc = close(fd); free(b); b = nil; - if(ret < 0) { + if(ret < 0 || retc < 0) { warning(nil, "can't write file %s: %r\n", name); goto Rescue2; // flush or close failed } @@ -788,10 +789,9 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) // in case we don't have read permission. // (The create above worked, so we probably // still have write permission.) - close(fd); fd = open(name, OWRITE); - d1 = dirfstat(fd); + close(fd); if(d1 != nil){ free(d); d = d1; @@ -824,11 +824,11 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) if(b != nil) { Bterm(b); free(b); + close(fd); } free(h); fbuffree(s); fbuffree(r); - close(fd); /* fall through */ Rescue1: diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 83c64594..7a64fabf 100644 --- a/src/cmd/acme/rows.c +++ b/src/cmd/acme/rows.c @@ -316,7 +316,7 @@ rowclean(Row *row) void rowdump(Row *row, char *file) { - int i, j, fd, m, n, dumped; + int i, j, fd, m, n, start, dumped; uint q0, q1; Biobuf *b; char *buf, *a, *fontname; @@ -434,9 +434,17 @@ rowdump(Row *row, char *file) m = min(RBUFSIZE, w->tag.file->b.nc); bufread(&w->tag.file->b, 0, r, m); n = 0; - while(n<m && r[n]!='\n') - n++; - Bprint(b, "%.*S\n", n, r); + while(n<m) { + start = n; + while(n<m && r[n]!='\n') + n++; + Bprint(b, "%.*S", n-start, r+start); + if(n<m) { + Bputc(b, 0xff); // \n in tag becomes 0xff byte (invalid UTF) + n++; + } + } + Bprint(b, "\n"); if(dumped){ q0 = 0; q1 = t->file->b.nc; @@ -719,6 +727,10 @@ rowload(Row *row, char *file, int initing) if(l == nil) goto Rescue2; l[Blinelen(b)-1] = 0; + /* convert 0xff in multiline tag back to \n */ + for(i = 0; l[i] != 0; i++) + if((uchar)l[i] == 0xff) + l[i] = '\n'; r = bytetorune(l+5*12, &nr); ns = -1; for(n=0; n<nr; n++){ |