From 95ab1308b410ad8547e38e47ec4a36f560dcece5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 22 Jun 2020 11:20:42 -0400 Subject: src/cmd: rm dformat Unclear why it is here (wkj added it long ago). It has never been installed into $PLAN9/bin, so it's doubtful that anyone has ever used it. Arnold Robbins has an alternate version at https://github.com/arnoldrobbins/dformat. Fixes #421. --- src/cmd/dformat | 108 -------------------------------------------------------- 1 file changed, 108 deletions(-) delete mode 100755 src/cmd/dformat (limited to 'src/cmd') diff --git a/src/cmd/dformat b/src/cmd/dformat deleted file mode 100755 index f14b5841..00000000 --- a/src/cmd/dformat +++ /dev/null @@ -1,108 +0,0 @@ -awk ' -function error(s) { print "dformat error: " s " near input line " NR | "cat 1>&2" } - -BEGIN { s = "recht 0.3 addrht 0.055 recspread 0.15 " - s = s "charwid 0.07 textht 0.167 addrdelta 4 " - s = s "bitwid 0.125 linedisp 0.04 addr both " - s = s "fill off linethrutext 1" - n = split(s, x) - for (i = 1; i <= n-1; i += 2) oparm[x[i]] = parm[x[i]] = x[i+1] -} - -inlang == 0 { if ($0 !~ /^\.begin[ \t]/ || $2 != "dformat") print - else { - inlang = 1; print ".PS"; boxacnt = 0 - if (firstpic != 1) { firstpic = 1; print "fillval = 0.9" } - } - next - } -/^\.end/ { inlang = 0; print ".PE"; next } - -$1 == "style" { if (!($2 in parm)) error("unrecognized name: " $2) - else if ($3 == "reset") { - t = oparm[$2]; oparm[$2] = parm[$2]; parm[$2] = t - } else { - oparm[$2] = parm[$2]; parm[$2] = $3 - } - next - } - -$1 == "pic" { $1 = ""; print $0; next } - -/^[^ \t]/ { printf "BoxA: box invis ht %g wid 0", parm["recht"] - if (boxacnt++) printf " with .n at BoxA.s - (0,%g)", - parm["recspread"] + maxdy*parm["textht"] - printf "\n" - maxdy = sumboxlen = 0 - gsub(/[ \t]+$/, "") - if ($0 != "noname") { - printf " \"%s \" rjust at BoxA.w\n", $0 - printf " box invis with .e at BoxA.w ht 0 wid %g\n", - parm["charwid"] * (length($0) + 3) - } - printf " BoxB: box invis ht %g wid 0 at BoxA\n", parm["recht"] - next - } -/./ { boxname = "" - if ($1 ~ /:$/) { - boxname = substr($1, 1, length($1)-1) - $1 = ""; $0 = " " $0 - } - range = $1; $1 = "" - gsub(/^[ \t]+/, ""); gsub(/[ \t]+$/, ""); text = $0 - n = split(range, x, "-") - rlo = x[1] - rhi = (n >= 2) ? x[2] : rlo - cwid = (rhi >= rlo) ? rhi - rlo + 1 : rlo - rhi + 1 - rwid = (n >= 3) ? (0 + x[3]) : cwid - btype = x[4] - if (btype !~ /^(dot|dash|invis)/) btype = "solid" - textlen = parm["charwid"] * length(text) - boxlen = parm["bitwid"] * rwid - dy = 0 - if (textlen > boxlen) { # set dy, the channel for this text - chan[maxdy+1] = -999 - for (dy = 1; chan[dy]+textlen > sumboxlen; dy++) ; - if (dy > maxdy) maxdy = dy - if (parm["linethrutext"] == 0) - for (k = 1; k <= dy; k++) - chan[k] = sumboxlen+boxlen - else - chan[dy] = sumboxlen - } - sumboxlen += boxlen - fill = "" - if (parm["fill"] == "on") fill = " fill " - if (boxname != "") printf " %s:", boxname - printf " BoxB: box %s %s ht %g wid %g with .w at BoxB.e\n", - fill, btype, parm["recht"], boxlen - if (dy == 0) printf " \"%s\" at BoxB.c\n", text - else { if (rwid < 2) start = "BoxB.s" - else start = "BoxB.se - (" parm["linedisp"] ",0)" - printf " line from %s down %g\n", - start, dy*parm["textht"] - printf " \"%s\\|\" at last line .s rjust\n", text - printf " box invis with .e at last line .s ht 0 wid %g\n", - textlen - } - - if (parm["addr"] ~ /^(left|right|both)$/) { - dp = int(parm["addrdelta"]) # Delta Point size - if (dp < 0 || dp > 9) error("bad addrdelta value: " dp) - dah = parm["addrht"] # Delta Addr Height - pb = parm["addr"] # Parameter for Bits - if (rlo == rhi) { - printf " \"\\s-%d%s\\s+%d\" at BoxB.s + (0,%g)\n", - dp, rlo, dp, dah - } else { - if (pb == "left" || pb == "both") - printf "\t\"\\|\\s-%d%s\\s+%d\" ljust at BoxB.sw + (0,%g)\n", - dp, rlo, dp, dah - if (pb == "right" || pb == "both") - printf "\t\"\\s-%d%s\\s+%d\\|\" rjust at BoxB.se + (0,%g)\n", - dp, rhi, dp, dah - } - } - } -END { if (inlang) error("eof inside begin/end") } -' $* -- cgit v1.2.3 From 057d8a76a9d840994edf453f97245efb295d9582 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 18 Jul 2020 19:52:58 -0400 Subject: acme: add font control message --- src/cmd/acme/xfid.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 9c7be2c0..e7d9f4cb 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -701,6 +701,24 @@ out: winsetname(w, r, nr); m += (q+1) - pp; }else + if(strncmp(p, "font ", 5) == 0){ /* execute font command */ + pp = p+5; + m = 5; + q = memchr(pp, '\n', e-pp); + if(q==nil || q==pp){ + err = Ebadctl; + break; + } + *q = 0; + nulls = FALSE; + cvttorunes(pp, q-pp, r, &nb, &nr, &nulls); + if(nulls){ + err = "nulls in font string"; + break; + } + fontx(&w->body, nil, nil, FALSE, XXX, r, nr); + m += (q+1) - pp; + }else if(strncmp(p, "dump ", 5) == 0){ /* set dump string */ pp = p+5; m = 5; -- cgit v1.2.3 From afa34a73a91655f16d24abae491881ae45500d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20B=C3=B6hm?= Date: Wed, 22 Jul 2020 20:59:58 +0200 Subject: devdraw, libdraw: fix memory leaks by freeing getns() malloced string (#431) --- src/cmd/devdraw/srv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 05a08fda..479e41e0 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -88,7 +88,7 @@ threadmain(int argc, char **argv) void gfx_started(void) { - char *addr; + char *ns, *addr; if(srvname == nil) { // Legacy mode: serving single client on pipes. @@ -97,7 +97,11 @@ gfx_started(void) } // Server mode. - addr = smprint("unix!%s/%s", getns(), srvname); + if((ns = getns()) == nil) + sysfatal("out of memory"); + + addr = smprint("unix!%s/%s", ns, srvname); + free(ns); if(addr == nil) sysfatal("out of memory"); -- cgit v1.2.3 From a1c4307800c7f1ef9c5d71ba4c6c3642837e2877 Mon Sep 17 00:00:00 2001 From: James Cook Date: Sat, 8 Aug 2020 01:54:00 +0000 Subject: touch: fix for OpenBSD. This fixes https://github.com/9fans/plan9port/issues/436 This doesn't necessarily address the underlying issue: calling p9create with mode = OREAD should probably be allowed, but currently doesn't work on OpenBSD. --- src/cmd/touch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd') diff --git a/src/cmd/touch.c b/src/cmd/touch.c index 471e2b17..26141815 100644 --- a/src/cmd/touch.c +++ b/src/cmd/touch.c @@ -54,7 +54,7 @@ touch(int nocreate, char *name) fprint(2, "touch: %s: cannot wstat: %r\n", name); return 1; } - if((fd = create(name, OREAD, 0666)) < 0) { + if((fd = create(name, OWRITE, 0666)) < 0) { fprint(2, "touch: %s: cannot create: %r\n", name); return 1; } -- cgit v1.2.3 From 9843fc0d82c68c78059ccb167e8402def5a4ee1f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Aug 2020 09:10:54 -0400 Subject: fontsrv: fix handling of colored glyphs (emoji) Drawing as white on black to produce a mask only works if the white on black is the inversion of black on white. Emoji that force use of specific colors don't respect that. Draw black on white and invert to mask separately. --- src/cmd/fontsrv/mac.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/fontsrv/mac.c b/src/cmd/fontsrv/mac.c index 9829b5a8..c5a2e0f1 100644 --- a/src/cmd/fontsrv/mac.c +++ b/src/cmd/fontsrv/mac.c @@ -75,6 +75,17 @@ mac2r(CGRect r, int size, int unit) return rr; } +void +meminvert(Memimage *m) +{ + uchar *p, *ep; + + p = byteaddr(m, m->r.min); + ep = p + 4*m->width*Dy(m->r); + for(; p < ep; p++) + *p ^= 0xff; +} + void loadfonts(void) { @@ -223,8 +234,8 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) int i, height, ascent; Fontchar *fc, *fc0; Memsubfont *sf; - CGFloat whitef[] = { 1.0, 1.0 }; - CGColorRef white; + CGFloat blackf[] = { 0.0, 1.0 }; + CGColorRef black; s = c2mac(name); desc = CTFontDescriptorCreateWithNameAndSize(s, size); @@ -267,7 +278,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) color = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray); ctxt = CGBitmapContextCreate(byteaddr(mc, mc->r.min), Dx(mc->r), Dy(mc->r), 8, mc->width*sizeof(u32int), color, kCGImageAlphaNone); - white = CGColorCreate(color, whitef); + black = CGColorCreate(color, blackf); CGColorSpaceRelease(color); if(ctxt == nil) { freememimage(m); @@ -293,7 +304,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) CGRect r; CGPoint p1; CFStringRef keys[] = { kCTFontAttributeName, kCTForegroundColorAttributeName }; - CFTypeRef values[] = { font, white }; + CFTypeRef values[] = { font, black }; sprint(buf, "%C", (Rune)mapUnicode(name, i)); str = c2mac(buf); @@ -310,7 +321,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) line = CTLineCreateWithAttributedString(attrString); CGContextSetTextPosition(ctxt, 0, y0); r = CTLineGetImageBounds(line, ctxt); - memfillcolor(mc, DBlack); + memfillcolor(mc, DWhite); CTLineDraw(line, ctxt); CFRelease(line); @@ -330,6 +341,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) continue; } + meminvert(mc); memimagedraw(m, Rect(x, 0, x + p1.x, y), mc, ZP, memopaque, ZP, S); fc->width = p1.x; fc->left = 0; -- cgit v1.2.3 From 1f098efb7370a0b28306d10681e21883fb1c1507 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Aug 2020 20:46:23 -0400 Subject: all: a few more #define tricks for AIX This should make the AIX build finally work. Fixes #400. --- src/cmd/sam/sam.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index c11163ef..aae39b4a 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -9,6 +9,9 @@ #undef warn #define warn samwarn +#undef class +#define class samclass + /* * BLOCKSIZE is relatively small to keep memory consumption down. */ -- cgit v1.2.3 From a012d174336358f997ddcb0099c0b01499b053e4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 15 Dec 2020 00:01:26 -0500 Subject: time: print 1s of milliseconds --- src/cmd/time.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/time.c b/src/cmd/time.c index 3b52216b..16379a89 100644 --- a/src/cmd/time.c +++ b/src/cmd/time.c @@ -47,11 +47,11 @@ main(int argc, char *argv[]) error("wait"); } l = w->time[0]; - add("%ld.%.2ldu", l/1000, (l%1000)/10); + add("%ld.%.3ldu", l/1000, l%1000); l = w->time[1]; - add("%ld.%.2lds", l/1000, (l%1000)/10); + add("%ld.%.3lds", l/1000, l%1000); l = (t1-t0)/1000000; - add("%ld.%.2ldr", l/1000, (l%1000)/10); + add("%ld.%.3ldr", l/1000, l%1000); add("\t"); for(i=1; i