aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/acme/xfid.c18
-rw-r--r--src/cmd/devdraw/srv.c8
-rwxr-xr-xsrc/cmd/dformat108
-rw-r--r--src/cmd/fontsrv/mac.c22
-rw-r--r--src/cmd/sam/sam.h3
-rw-r--r--src/cmd/time.c6
-rw-r--r--src/cmd/touch.c2
-rw-r--r--src/libdiskfs/hfs.h33
-rw-r--r--src/libdraw/drawclient.c7
-rw-r--r--src/libthread/thread.c10
10 files changed, 95 insertions, 122 deletions
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;
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");
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") }
-' $*
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
@@ -76,6 +76,17 @@ mac2r(CGRect r, int size, int unit)
}
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)
{
int i, n;
@@ -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;
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.
*/
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<argc; i++){
add("%s", argv[i], 0);
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;
}
diff --git a/src/libdiskfs/hfs.h b/src/libdiskfs/hfs.h
index bf5ebc9f..dc30aeed 100644
--- a/src/libdiskfs/hfs.h
+++ b/src/libdiskfs/hfs.h
@@ -75,6 +75,39 @@ enum
/* catalog record types */
Folder = 1, File, FolderThread, FileThread,
+ /* some systems have these defined */
+ #undef IEXEC
+ #undef IWRITE
+ #undef IREAD
+ #undef ISVTX
+ #undef ISGID
+ #undef ISUID
+ #undef IFMT
+ #undef IFIFO
+ #undef IFCHR
+ #undef IFDIR
+ #undef IFBLK
+ #undef IFREG
+ #undef IFLNK
+ #undef IFSOCK
+ #undef IFWHT
+
+ #define IEXEC HFS_IEXEC
+ #define IWRITE HFS_IWRITE
+ #define IREAD HFS_IREAD
+ #define ISVTX HFS_ISVTX
+ #define ISGID HFS_ISGID
+ #define ISUID HFS_ISUID
+ #define IFMT HFS_IFMT
+ #define IFIFO HFS_IFIFO
+ #define IFCHR HFS_IFCHR
+ #define IFDIR HFS_IFDIR
+ #define IFBLK HFS_IFBLK
+ #define IFREG HFS_IFREG
+ #define IFLNK HFS_IFLNK
+ #define IFSOCK HFS_IFSOCK
+ #define IFWHT HFS_IFWHT
+
/* permissions in Inode.mode */
IEXEC = 00100,
IWRITE = 0200,
diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c
index c38f4801..2ac1b232 100644
--- a/src/libdraw/drawclient.c
+++ b/src/libdraw/drawclient.c
@@ -23,7 +23,7 @@ int
_displayconnect(Display *d)
{
int pid, p[2], fd, nbuf, n;
- char *wsysid, *addr, *id;
+ char *wsysid, *ns, *addr, *id;
uchar *buf;
Wsysmsg w;
@@ -40,7 +40,10 @@ _displayconnect(Display *d)
return -1;
}
*id++ = '\0';
- addr = smprint("unix!%s/%s", getns(), wsysid);
+ if((ns = getns()) == nil)
+ return -1;
+ addr = smprint("unix!%s/%s", ns, wsysid);
+ free(ns);
if(addr == nil)
return -1;
fd = dial(addr, 0, 0, 0);
diff --git a/src/libthread/thread.c b/src/libthread/thread.c
index 902942d9..65e65194 100644
--- a/src/libthread/thread.c
+++ b/src/libthread/thread.c
@@ -411,7 +411,14 @@ Top:
p->nthread--;
/*print("nthread %d\n", p->nthread); */
_threadstkfree(t->stk, t->stksize);
- free(t);
+ /*
+ * Cannot free p->thread0 yet: it is used for the
+ * context switches back to the scheduler.
+ * Instead, we will free it at the end of this function.
+ * But all the other threads can be freed now.
+ */
+ if(t != p->thread0)
+ free(t);
}
for(;;){
@@ -490,6 +497,7 @@ Out:
unlock(&threadnproclock);
unlock(&p->lock);
_threadsetproc(nil);
+ free(p->thread0);
free(p);
_threadpexit();
}