From 112744e54bfdab025bd2146457f41f1f8f4a903b Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Wed, 14 Mar 2018 20:27:46 -0500 Subject: [PATCH 001/323] 9pfuse: retries read(3) upon EINTR read(3) sometimes errors with EINTR on macOS over slow connections. 9pfuse(1) now retries read(3) instead of sysfatal(3)ing. --- src/cmd/9pfuse/fuse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c index 3f91ce787..b84663e99 100644 --- a/src/cmd/9pfuse/fuse.c +++ b/src/cmd/9pfuse/fuse.c @@ -48,7 +48,6 @@ readfusemsg(void) int n, nn; m = allocfusemsg(); - errno = 0; /* * The FUSE kernel device apparently guarantees * that this read will return exactly one message. @@ -57,7 +56,11 @@ readfusemsg(void) * FUSE returns an ENODEV error, not EOF, * when the connection is unmounted. */ - if((n = read(fusefd, m->buf, fusebufsize)) < 0){ + do{ + errno = 0; + n = read(fusefd, m->buf, fusebufsize); + }while(n < 0 && errno == EINTR); + if(n < 0){ if(errno != ENODEV) sysfatal("readfusemsg: %r"); } From cfa9a6dfa108cda8f830dac649c804161bbde618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Wed, 28 Feb 2018 11:10:46 +0100 Subject: [PATCH 002/323] 9term: Set TERM_PROGRAM to termprog TERM_PROGRAM is the customary way to identify which kind of terminal emulator program one uses on macOS. This change sets TERM_PROGRAM to termprog since both variables are used for the same purpose. --- src/cmd/9term/rcstart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c index 5e6e11194..141b9b005 100644 --- a/src/cmd/9term/rcstart.c +++ b/src/cmd/9term/rcstart.c @@ -87,6 +87,7 @@ rcstart(int argc, char **argv, int *pfd, int *tfd) // Set $termprog to 9term or win for those who care about what kind of // dumb terminal this is. putenv("termprog", (char*)termprog); + putenv("TERM_PROGRAM", (char*)termprog); pid = fork(); switch(pid){ From 3473f4e5fde931d4988c84aa46ca3dbcf9c1150d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ku=CC=88hl?= Date: Thu, 1 Feb 2018 14:29:47 +0100 Subject: [PATCH 003/323] .gitignore: ignore files created for astro(1) and scat(1) To use astro(1) and scat(1) one has to create sky/here and download various catalogue files as detailed in sky/README. This change marks those files as ignored by git so they don't clutter its status messages. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8957273c9..f590cf28d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,8 @@ bin/ log/ dict/ postscript/font/ +sky/here +sky/*.scat *.orig config install.log From d5791246822e27ef99a593d11518b457ce439a85 Mon Sep 17 00:00:00 2001 From: Ray Lai Date: Fri, 19 Jan 2018 00:39:41 +0800 Subject: [PATCH 004/323] 9pserve: fix memory leak in warning --- src/cmd/9pserve.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c index 077715d6c..24c807148 100644 --- a/src/cmd/9pserve.c +++ b/src/cmd/9pserve.c @@ -1248,6 +1248,8 @@ mread9p(Ioproc *io, int fd) nn = convM2S(pkt, n, &m->tx); if(nn != n){ fprint(2, "%T read bad packet from %d\n", fd); + free(m->tpkt); + free(m); return nil; } return m; From 72fc31acb3d91224d1ebf8769076cc3c4e2d2ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ku=CC=88hl?= Date: Wed, 31 Jan 2018 14:43:49 +0100 Subject: [PATCH 005/323] mount: check current osxfuse kext location Current versions of osxfuse ship with multiple versions of its kernel extension (kext) for differend versions of macOS. Running mount(1) on macOS with a current version of osxfuse fails with `don't know how to mount (no fuse)' since it fails to find the kext. Running 9pfuse(4) directly works fine. This change adds a check to mount(1) that determines: 1) which version of macOS we're running on 2) if there is an osxfuse kext available for this version of macOS --- bin/mount | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/mount b/bin/mount index 79b974f77..a343a5328 100755 --- a/bin/mount +++ b/bin/mount @@ -19,10 +19,12 @@ case FreeBSD exec 9pfuse $1 $2 echo 'don''t know how to mount (no fuse)' >[1=2] case Darwin + version=`{sw_vers -productVersion|cut -d. -f1,2} if(sysctl fuse.version >[2]/dev/null |9 grep -si 'fuse.version' || sysctl macfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' || sysctl osxfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' || test -d /System/Library/Extensions/fusefs.kext || + test -d /Library/Filesystems/osxfuse.fs/Contents/Extensions/$version/osxfuse.kext || test -d /Library/Filesystems/osxfusefs.fs/Support/osxfusefs.kext || test -d /Library/Filesystems/fusefs.fs/Support/fusefs.kext) exec 9pfuse $1 $2 From 4ebaf18e9234bf58aae7a5c47fc15ec4c80812b6 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sat, 6 Jan 2018 18:01:55 +0100 Subject: [PATCH 006/323] fontsrv: skip only the surrogate pairs fontsrv wasn't rendering fontawesome icons, which uses the private use area around 0xf000. --- src/cmd/fontsrv/osx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index f48f5b496..adb007c2e 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -30,7 +30,7 @@ mapUnicode(char *name, int i) { int j; - if(0xd800 <= i && i < 0xe0000) // surrogate pairs, will crash OS X libraries! + if(0xd800 <= i && i < 0xe000) // surrogate pairs, will crash OS X libraries! return 0xfffd; for(j=0; j Date: Wed, 14 Mar 2018 20:17:10 -0500 Subject: [PATCH 007/323] mount, 9pfuse: detect macports installed osxfuse MacPorts installs osxfuse under /opt/local. --- bin/mount | 1 + src/cmd/9pfuse/fuse.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/bin/mount b/bin/mount index a343a5328..0fbb1bfd5 100755 --- a/bin/mount +++ b/bin/mount @@ -26,6 +26,7 @@ case Darwin test -d /System/Library/Extensions/fusefs.kext || test -d /Library/Filesystems/osxfuse.fs/Contents/Extensions/$version/osxfuse.kext || test -d /Library/Filesystems/osxfusefs.fs/Support/osxfusefs.kext || + test -d /opt/local/Library/Filesystems/osxfuse.fs || test -d /Library/Filesystems/fusefs.fs/Support/fusefs.kext) exec 9pfuse $1 $2 echo 'don''t know how to mount (no fuse)' >[1=2] diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c index b84663e99..66f66065d 100644 --- a/src/cmd/9pfuse/fuse.c +++ b/src/cmd/9pfuse/fuse.c @@ -810,6 +810,8 @@ mountfuse(char *mtpt) "/Support/load_osxfusefs"), 0) < 0 && access((v="osxfuse", f="/Library/Filesystems/osxfuse.fs" "/Contents/Resources/load_osxfuse"), 0) < 0 && + access((v="osxfuse", f="/opt/local/Library/Filesystems/osxfuse.fs" + "/Contents/Resources/load_osxfuse"), 0) < 0 && access((v="fusefs", f="/System/Library/Extensions/fusefs.kext" "/Contents/Resources/load_fusefs"), 0) < 0 && access(f="/Library/Extensions/fusefs.kext" @@ -874,6 +876,12 @@ mountfuse(char *mtpt) execl("/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", "mount_osxfuse", buf, mtpt, nil); + /* OSXFUSE >=3.3 from macports */ + putenv("MOUNT_OSXFUSE_DAEMON_PATH", + "/opt/local/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse"); + execl("/opt/local/Library/Filesystems/osxfuse.fs/Contents/Resources/mount_osxfuse", + "mount_osxfuse", buf, mtpt, nil); + /* Lion OSXFUSE location */ putenv("MOUNT_FUSEFS_DAEMON_PATH", "/Library/Filesystems/osxfusefs.fs/Support/mount_osxfusefs"); From 96dc2330918909c925a5c3a6407116dad7f93c3a Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Wed, 14 Mar 2018 22:45:33 -0500 Subject: [PATCH 008/323] fontsrv: enlarge drawing buffer for subfonts on macOS Double the width returned by CTFontGetBoundingBox when drawing. Add box drawing characters for determining the line height. Call freememimage(1) for the character memimage. Fixes #18. Fixes #120. Fixes #146. --- src/cmd/fontsrv/osx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index adb007c2e..18197a23d 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -104,6 +104,7 @@ static char *lines[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "g", + "┌┬┐├┼┤└┴┘│─", "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει.", "私はガラスを食べられます。それは私を傷つけません。", "Aš galiu valgyti stiklą ir jis manęs nežeidžia", @@ -234,7 +235,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) bbox = CTFontGetBoundingBox(font); - x = (int)(bbox.size.width + 0.99999999); + x = (int)(bbox.size.width*2 + 0.99999999); fontheight(f, size, &height, &ascent); y = height; @@ -343,6 +344,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) m1 = allocmemimage(Rect(0, 0, x, y), antialias ? GREY8 : GREY1); memimagedraw(m1, m1->r, m, m->r.min, memopaque, ZP, S); freememimage(m); + freememimage(mc); sf->name = nil; sf->n = hi+1 - lo; From 7ca1c90109e17dced4b38fbaadea9d2cf39871b7 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 20 Mar 2018 22:15:12 -0500 Subject: [PATCH 009/323] acme: fix some memory leaks --- src/cmd/acme/acme.c | 7 +++++-- src/cmd/acme/exec.c | 1 + src/cmd/acme/rows.c | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 10dcdcc85..742aabdf8 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -383,7 +383,7 @@ int erroutfd; void acmeerrorproc(void *v) { - char *buf; + char *buf, *s; int n; USED(v); @@ -391,8 +391,11 @@ acmeerrorproc(void *v) buf = emalloc(8192+1); while((n=read(errorfd, buf, 8192)) >= 0){ buf[n] = '\0'; - sendp(cerr, estrdup(buf)); + s = estrdup(buf); + sendp(cerr, s); + free(s); } + free(buf); } void diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index deaef0cb1..68c5d9769 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -194,6 +194,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt) aa = getbytearg(argt, TRUE, TRUE, &a); if(a){ if(strlen(a) > EVENTSIZE){ /* too big; too bad */ + free(r); free(aa); free(a); warning(nil, "argument string too long\n"); diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 2d6cbccaa..8cff0855e 100644 --- a/src/cmd/acme/rows.c +++ b/src/cmd/acme/rows.c @@ -613,6 +613,7 @@ rowload(Row *row, char *file, int initing) } textdelete(&row->col[i]->tag, 0, row->col[i]->tag.file->b.nc, TRUE); textinsert(&row->col[i]->tag, 0, r+n+1, nr-(n+1), TRUE); + free(r); break; case 'w': l[Blinelen(b)-1] = 0; @@ -626,6 +627,7 @@ rowload(Row *row, char *file, int initing) } textdelete(&row->tag, 0, row->tag.file->b.nc, TRUE); textinsert(&row->tag, 0, r, nr, TRUE); + free(r); break; default: done = 1; From b2f67698309b0c573cd52e357be126171be0a93a Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 20 Mar 2018 22:16:17 -0500 Subject: [PATCH 010/323] devdraw: fix some memory leaks in x11 --- src/cmd/devdraw/x11-init.c | 2 ++ src/cmd/devdraw/x11-itrans.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index 04b13a038..5363fb74f 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -176,6 +176,7 @@ _xattach(char *label, char *winsize) } } } + XFree(pfmt); if(_x.chan == 0){ werrstr("could not determine screen pixel format"); goto err0; @@ -232,6 +233,7 @@ _xattach(char *label, char *winsize) geom = smprint("%s.geometry", label); if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres)) mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height); + XrmDestroyDatabase(database); free(geom); if((mask & WidthValue) && (mask & HeightValue)){ diff --git a/src/cmd/devdraw/x11-itrans.c b/src/cmd/devdraw/x11-itrans.c index d84cdc8f9..729f26473 100644 --- a/src/cmd/devdraw/x11-itrans.c +++ b/src/cmd/devdraw/x11-itrans.c @@ -431,8 +431,10 @@ _xgetsnarffrom(XWindow w, Atom clipboard, Atom target, int timeout0, int timeout usleep(10*1000); XGetWindowProperty(_x.display, _x.drawable, prop, 0, 0, 0, AnyPropertyType, &type, &fmt, &dummy, &len, &xdata); - if(lastlen == len && len > 0) + if(lastlen == len && len > 0){ + XFree(xdata); break; + } lastlen = len; XFree(xdata); } From a3ec102dc7fee3d4ecb32ade5ec9d7de4b9b4304 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 20 Mar 2018 22:17:05 -0500 Subject: [PATCH 011/323] fontsrv: fix some memory leaks --- src/cmd/fontsrv/osx.c | 4 +++- src/cmd/fontsrv/x11.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index 18197a23d..4d969290b 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -245,8 +245,10 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) if(m == nil) return nil; mc = allocmemimage(Rect(0, 0, x+1, y+1), GREY8); - if(mc == nil) + if(mc == nil){ + freememimage(m); return nil; + } memfillcolor(m, DBlack); memfillcolor(mc, DBlack); fc = malloc((hi+2 - lo) * sizeof fc[0]); diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index f106d2532..a097ca4d0 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -236,6 +236,7 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) m1 = allocmemimage(Rect(0, 0, x, y), antialias ? GREY8 : GREY1); memimagedraw(m1, m1->r, m, m->r.min, memopaque, ZP, S); freememimage(m); + freememimage(mc); sf->name = nil; sf->n = hi+1 - lo; From dc2a17b95cace1f220292cb6df97ee423d6be229 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 20 Mar 2018 22:17:57 -0500 Subject: [PATCH 012/323] libdraw: fix some memory leaks in font handling --- src/libdraw/buildfont.c | 1 + src/libdraw/freesubfont.c | 1 + src/libdraw/openfont.c | 20 ++++++++++++++------ src/libdraw/subfontcache.c | 1 + src/libdraw/subfontname.c | 1 + 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/libdraw/buildfont.c b/src/libdraw/buildfont.c index d3f2e69e5..ed533b142 100644 --- a/src/libdraw/buildfont.c +++ b/src/libdraw/buildfont.c @@ -36,6 +36,7 @@ buildfont(Display *d, char *buf, char *name) if(fnt->name==0 || fnt->cache==0 || fnt->subf==0){ Err2: free(fnt->name); + free(fnt->namespec); free(fnt->cache); free(fnt->subf); free(fnt->sub); diff --git a/src/libdraw/freesubfont.c b/src/libdraw/freesubfont.c index 6830b9dcd..16b2ef3e8 100644 --- a/src/libdraw/freesubfont.c +++ b/src/libdraw/freesubfont.c @@ -12,6 +12,7 @@ freesubfont(Subfont *f) return; uninstallsubfont(f); free(f->info); /* note: f->info must have been malloc'ed! */ + free(f->name); freeimage(f->bits); free(f); } diff --git a/src/libdraw/openfont.c b/src/libdraw/openfont.c index b97ea22d5..2b729d739 100644 --- a/src/libdraw/openfont.c +++ b/src/libdraw/openfont.c @@ -31,7 +31,7 @@ openfont1(Display *d, char *name) { Font *fnt; int fd, i, n, scale; - char *buf, *nambuf, *fname, *freename; + char *buf, *nambuf, *nambuf0, *fname, *freename; nambuf = 0; freename = nil; @@ -42,19 +42,21 @@ openfont1(Display *d, char *name) nambuf = smprint("#9/font/%s", fname+14); if(nambuf == nil) return 0; - nambuf = unsharp(nambuf); + *nambuf0 = unsharp(nambuf); + if(nambuf0 != nambuf) + free(nambuf); + nambuf = nambuf0; if(nambuf == nil) return 0; if((fd = open(nambuf, OREAD)) < 0){ free(nambuf); return 0; } - fname = nambuf; if(scale > 1) { - name = smprint("%d*%s", scale, fname); + name = smprint("%d*%s", scale, nambuf); freename = name; } else { - name = fname; + name = nambuf; } } if(fd >= 0) @@ -63,13 +65,17 @@ openfont1(Display *d, char *name) fd = _fontpipe(fname+10); n = 128*1024; } - if(fd < 0) + if(fd < 0){ + free(nambuf); + free(freename); return 0; + } buf = malloc(n+1); if(buf == 0){ close(fd); free(nambuf); + free(freename); return 0; } i = readn(fd, buf, n); @@ -77,6 +83,7 @@ openfont1(Display *d, char *name) if(i <= 0){ free(buf); free(nambuf); + free(freename); return 0; } buf[i] = 0; @@ -224,6 +231,7 @@ openfont(Display *d, char *name) if(!f) return nil; f->lodpi = f; + free(f->namespec); f->namespec = namespec; /* add to display list for when dpi changes */ diff --git a/src/libdraw/subfontcache.c b/src/libdraw/subfontcache.c index 2a7f489b4..91a6861a9 100644 --- a/src/libdraw/subfontcache.c +++ b/src/libdraw/subfontcache.c @@ -34,6 +34,7 @@ void uninstallsubfont(Subfont *subfont) { if(subfont == lastsubfont){ + free(lastname); lastname = 0; lastsubfont = 0; } diff --git a/src/libdraw/subfontname.c b/src/libdraw/subfontname.c index 9280244af..9d68570d3 100644 --- a/src/libdraw/subfontname.c +++ b/src/libdraw/subfontname.c @@ -47,6 +47,7 @@ subfontname(char *cfname, char *fname, int maxdepth) } return tmp2; } + free(tmp2); } /* try default */ From edfe3c016fe6ef10c55f7a17aab668214ec21efc Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Wed, 21 Mar 2018 22:24:12 -0500 Subject: [PATCH 013/323] sam: freetmpstr instead of free --- src/cmd/sam/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/sam/error.c b/src/cmd/sam/error.c index eb4e48f45..70554e195 100644 --- a/src/cmd/sam/error.c +++ b/src/cmd/sam/error.c @@ -138,7 +138,7 @@ termwrite(char *s) else Strinsert(&cmdstr, p, cmdstr.n); cmdptadv += p->n; - free(p); + freetmpstr(p); }else Write(2, s, strlen(s)); } From 75ea8515a5cd26817b4eb5de99eeb6934def9328 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Wed, 21 Mar 2018 22:24:50 -0500 Subject: [PATCH 014/323] samterm: free some getenv results --- src/cmd/samterm/plan9.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c index 469d566e0..1b9335785 100644 --- a/src/cmd/samterm/plan9.c +++ b/src/cmd/samterm/plan9.c @@ -53,8 +53,10 @@ getscreen(int argc, char **argv) threadexitsall("init"); } t = getenv("tabstop"); - if(t != nil) + if(t != nil){ maxtab = strtoul(t, nil, 0); + free(t); + } draw(screen, screen->clipr, display->white, nil, ZP); } @@ -149,10 +151,13 @@ extstart(void) if(user == nil) return; disp = getenv("DISPLAY"); - if(disp) + if(disp){ exname = smprint("/tmp/.sam.%s.%s", user, disp); + free(disp); + } else exname = smprint("/tmp/.sam.%s", user); + free(user); if(exname == nil){ fprint(2, "not posting for B: out of memory\n"); return; From 96025b1ec8916c986fb691db79ae96d4f690c8f1 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Thu, 22 Mar 2018 23:16:53 -0500 Subject: [PATCH 015/323] mc: fix crash in acme with hidpi display --- src/cmd/draw/mc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cmd/draw/mc.c b/src/cmd/draw/mc.c index c24d67b31..ea36e28df 100644 --- a/src/cmd/draw/mc.c +++ b/src/cmd/draw/mc.c @@ -268,8 +268,8 @@ void getwidth(void) { CFsys *fs; - char buf[500], *p, *q, *f[10]; - int fd, n, nf; + char buf[500], *p, *q, *f[10], *fname; + int fd, n, nf, scale; struct winsize ws; Font *f1; @@ -285,15 +285,19 @@ getwidth(void) buf[n] = 0; if((nf=tokenize(buf, f, nelem(f))) < 7) return; + // hidpi font in stringwidth(3) will call scalesubfont, + // which aborts in bytesperline, due to unknow depth, + // without initdraw. We scale by ourselves. + scale = parsefontscale(f[6], &fname); tabwid = 0; - if(nf >= 8 && (tabwid = atoi(f[7])) == 0) + if(nf >= 8 && (tabwid = atoi(f[7])/scale) == 0) return; - if((font = openfont(nil, f[6])) == nil) + if((font = openfont(nil, fname)) == nil) return; mintab = stringwidth(font, "0"); if(tabwid == 0) tabwid = mintab*4; - linewidth = atoi(f[5]); + linewidth = atoi(f[5]) / scale; tabflag = 1; return; } From 03a8ec739af17bc4ba0a2e18ea59b33671c34f2b Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Tue, 27 Mar 2018 10:52:45 -0500 Subject: [PATCH 016/323] libdraw: fix error in the previous commit --- src/libdraw/openfont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libdraw/openfont.c b/src/libdraw/openfont.c index 2b729d739..3fe9410a9 100644 --- a/src/libdraw/openfont.c +++ b/src/libdraw/openfont.c @@ -42,7 +42,7 @@ openfont1(Display *d, char *name) nambuf = smprint("#9/font/%s", fname+14); if(nambuf == nil) return 0; - *nambuf0 = unsharp(nambuf); + nambuf0 = unsharp(nambuf); if(nambuf0 != nambuf) free(nambuf); nambuf = nambuf0; From df2d9ec9d169626cdc2a23829bb2831738215722 Mon Sep 17 00:00:00 2001 From: Igor Burago Date: Thu, 17 May 2018 16:18:10 -0700 Subject: [PATCH 017/323] fontsrv: omit box-drawing characters from line struts on macOS For some fonts, using box-drawing characters in the representative text for computing the line height results in it being uncomfortably high. Replace them with accented capitals and tall lower-case letters which lead to a more conservative increase in the line height. Fixes #162. --- src/cmd/fontsrv/osx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index 4d969290b..b28ee2522 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -104,7 +104,7 @@ static char *lines[] = { "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "g", - "┌┬┐├┼┤└┴┘│─", + "ÁĂÇÂÄĊÀČĀĄÅÃĥľƒ", "ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει.", "私はガラスを食べられます。それは私を傷つけません。", "Aš galiu valgyti stiklą ir jis manęs nežeidžia", From a82a8b6368274d77d42f526e379b74e79c137e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Wed, 19 Sep 2018 15:19:36 +0200 Subject: [PATCH 018/323] acme: Apply each -/+ only once (#156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When plumbing an address like `3-`, Acme selects line 1, and similarly `3+` selects line 5. The same problem can be observed for character addresses (`#123+`) but _not_ for ones like `+`, `.+` or `/foo/+`: The problem only occurs when a number is followed by a direction (`-`/`+`). Following along with the example `3-` through `address` (in addr.c): We read `3` into `c` and match the `case` on line 239. The `while` loop on line 242ff reads additional digits into `c` and puts the first non-digit back by decrementing the index `q`. Then we find the range for line 3 on line 251 and continue. On the next iteration, we set `prevc` to the last `c`, but since that part read ahead _into `c`_, `c` is currently the _next_ character we will read, `-`, and now `prevc` is too. Then in the case block (line 210) the condition on line 211 holds and Acme believes that it has read two `-` in sequence and modifies the range to account for the “first” `-`. The “second” `-` gets applied after the loop is done, on line 292. So the general problem is: While reading numbers, Acme reads the next character after the number into `c`. It decrements the counter to ensure it will read it again on the next iteration, but it still uses it to update `prevc`. This change solves the problem by reading digits into `nc` instead. This variable is used to similar effect in the block for directions (line 212) and fills the role of “local `c` that we can safely use to read ahead” nicely. --- src/cmd/acme/addr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/acme/addr.c b/src/cmd/acme/addr.c index 2ccae960a..6aee8993c 100644 --- a/src/cmd/acme/addr.c +++ b/src/cmd/acme/addr.c @@ -240,12 +240,12 @@ address(uint showerr, Text *t, Range lim, Range ar, void *a, uint q0, uint q1, i case '5': case '6': case '7': case '8': case '9': n = c -'0'; while(q Date: Sat, 29 Sep 2018 15:59:31 +0200 Subject: [PATCH 019/323] libregexp: include stddef.h in lib9.std.h Commit 2d82ef9d98 added ptrdiff_t in regcomp.c. However, this change broke the build of the Unix package because ptrdiff_t is defined in stddef.h. --- src/libregexp/lib9.std.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libregexp/lib9.std.h b/src/libregexp/lib9.std.h index 0cefdde73..1d7aaa627 100644 --- a/src/libregexp/lib9.std.h +++ b/src/libregexp/lib9.std.h @@ -3,6 +3,7 @@ #include #include #include +#include #define exits(x) exit(x && *x ? 1 : 0) From 93c75d2bad341af383520409fd354dcff3f2c279 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 1 Oct 2018 17:20:35 +0200 Subject: [PATCH 020/323] grep: update from Plan 9 This change fixes a segfault in grep -e when no argument has been provided. Thanks to Sean Hinchee for reporting this issue. Fixes #186. --- src/cmd/grep/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/grep/main.c b/src/cmd/grep/main.c index d37aeb10f..a847d73f5 100644 --- a/src/cmd/grep/main.c +++ b/src/cmd/grep/main.c @@ -5,7 +5,7 @@ char *validflags = "bchiLlnsv"; void usage(void) { - fprint(2, "usage: grep [-%s] [-f file] [-e expr] [file ...]\n", validflags); + fprint(2, "usage: grep [-%s] [-e pattern] [-f patternfile] [file ...]\n", validflags); exits("usage"); } @@ -31,12 +31,12 @@ main(int argc, char *argv[]) case 'e': flags['e']++; lineno = 0; - str2top(ARGF()); + str2top(EARGF(usage())); break; case 'f': flags['f']++; - filename = ARGF(); + filename = EARGF(usage()); rein = Bopen(filename, OREAD); if(rein == 0) { fprint(2, "grep: can't open %s: %r\n", filename); From db27122d3942ebec4471c260403d87cdd6541add Mon Sep 17 00:00:00 2001 From: Charles Collicutt Date: Thu, 17 May 2018 22:56:12 +0100 Subject: [PATCH 021/323] upas/nfs: correctly quote IMAP LOGIN arguments According to RFC 3501 the arguments to the LOGIN command should be quoted strings (or length prefixed string literals). Without quoting, authentication to some IMAP servers (e.g. Dovecot) will fail. --- src/cmd/upas/nfs/imap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c index 2cbe99e1f..8d43fe799 100644 --- a/src/cmd/upas/nfs/imap.c +++ b/src/cmd/upas/nfs/imap.c @@ -214,7 +214,7 @@ imaplogin(Imap *z) return -1; } - sx = imapcmdsx(z, nil, "LOGIN %Z %Z", up->user, up->passwd); + sx = imapcmdsx(z, nil, "LOGIN %#Z %#Z", up->user, up->passwd); freeup(up); if(sx == nil) return -1; From 48da9bd71ddae0c51f8aff4c0d6806a8e32c4e23 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Fri, 22 Jun 2018 16:43:17 -0400 Subject: [PATCH 022/323] fontsrv: copy some fixes from OS X to X11 * Avoid allocating empty images by adding 1 to width/height. This was crashing fontsrv. The total width of the subfont image can be zero even if the characters are present in the font. For example, all the characters in x0300.bit (part of "Combining Diacritical Marks" Unicode block) have zero width. * Make sure U+0000 is always present in the font, otherwise libdraw complains with: "stringwidth: bad character set for rune 0x0000 in ..." * Use the same fallback glyph (pjw face) as OS X. This also fixes a bug where advance was set to the total width of subfont instead of the character. Update #125 (most likely fixes the crash if in X11) Change-Id: Icdc2b641b8b0c08644569006e91cf613b4d5477f --- src/cmd/fontsrv/x11.c | 81 +++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index a097ca4d0..455e81260 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -66,19 +66,16 @@ load(XFont *f) return; e = FT_New_Face(lib, f->fontfile, f->index, &face); - if(e){ fprint(2, "load failed for %s (%s) index:%d\n", f->name, f->fontfile, f->index); return; } - if(!FT_IS_SCALABLE(face)) { fprint(2, "%s is a non scalable font, skipping\n", f->name); FT_Done_Face(face); - f->loaded = 1; + f->loaded = 1; return; } - f->unit = face->units_per_EM; f->height = (int)((face->ascender - face->descender) * 1.2); f->originy = face->descender; // bbox.yMin (or descender) is negative, becase the baseline is y-coord 0 @@ -96,7 +93,11 @@ load(XFont *f) f->nrange++; } } - + // libdraw expects U+0000 to be present + if(!f->range[0]) { + f->range[0] = 1; + f->nrange++; + } FT_Done_Face(face); f->loaded = 1; } @@ -108,14 +109,13 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) FT_Error e; Memimage *m, *mc, *m1; double pixel_size; - int x, y, y0; + int w, x, y, y0; int i; Fontchar *fc, *fc0; Memsubfont *sf; //Point rect_points[4]; e = FT_New_Face(lib, xf->fontfile, xf->index, &face); - if(e){ fprint(2, "load failed for %s (%s) index:%d\n", xf->name, xf->fontfile, xf->index); return nil; @@ -129,16 +129,16 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) } pixel_size = (dpi*size)/72.0; - x = (int)((face->max_advance_width) * pixel_size/xf->unit + 0.99999999); + w = x = (int)((face->max_advance_width) * pixel_size/xf->unit + 0.99999999); y = (int)((face->ascender - face->descender) * pixel_size/xf->unit + 0.99999999); y0 = (int)(-face->descender * pixel_size/xf->unit + 0.99999999); - m = allocmemimage(Rect(0, 0, x*(hi+1-lo), y), antialias ? GREY8 : GREY1); + m = allocmemimage(Rect(0, 0, x*(hi+1-lo)+1, y+1), antialias ? GREY8 : GREY1); if(m == nil) { FT_Done_Face(face); return nil; } - mc = allocmemimage(Rect(0, 0, x, y), antialias ? GREY8 : GREY1); + mc = allocmemimage(Rect(0, 0, x+1, y+1), antialias ? GREY8 : GREY1); if(mc == nil) { freememimage(m); FT_Done_Face(face); @@ -165,41 +165,42 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) x = 0; for(i=lo; i<=hi; i++, fc++) { - int r; + int k, r; int advance; memfillcolor(mc, DBlack); - e = FT_Load_Char(face, i, FT_LOAD_RENDER|FT_LOAD_NO_HINTING|(antialias ? 0:FT_LOAD_TARGET_MONO)); - if(e){ - fprint(2, "FT_Load_Char failed for %d\n", i); - //mempoly(mc, rect_points, 4, Endsquare, Endsquare, 0, memopaque, ZP, S); - memimageline(mc, m->r.min, Pt(m->r.max.x, m->r.min.y), Endsquare, Endsquare, 0, memopaque, ZP, S); - memimageline(mc, m->r.min, Pt(m->r.min.x, m->r.max.y), Endsquare, Endsquare, 0, memopaque, ZP, S); - memimageline(mc, Pt(m->r.max.x, m->r.min.y), m->r.max, Endsquare, Endsquare, 0, memopaque, ZP, S); - memimageline(mc, Pt(m->r.min.x, m->r.max.y), m->r.max, Endsquare, Endsquare, 0, memopaque, ZP, S); - memimageline(mc, m->r.min, m->r.max, Endsquare, Endsquare, 0, memopaque, ZP, S); - advance = Dx(m->r); - - memimagedraw(m, Rect(x, 0, x + advance, y), mc, ZP, memopaque, ZP, S); - } else { - FT_Bitmap *bitmap = &face->glyph->bitmap; - uchar *base = byteaddr(mc, mc->r.min); - advance = (face->glyph->advance.x+32) >> 6; - - for(r=0; r < bitmap->rows; r++) - memmove(base + r*mc->width*sizeof(u32int), bitmap->buffer + r*bitmap->pitch, bitmap->pitch); - - memimagedraw(m, Rect(x, 0, x + advance, y), mc, - Pt(-face->glyph->bitmap_left, -(y - y0 - face->glyph->bitmap_top)), - memopaque, ZP, S); - } - fc->x = x; fc->top = 0; - fc->bottom = y; - fc->left = 0; + fc->bottom = Dy(m->r); + e = 1; + k = FT_Get_Char_Index(face, i); + if(k != 0) { + e = FT_Load_Glyph(face, k, FT_LOAD_RENDER|FT_LOAD_NO_HINTING|(antialias ? 0:FT_LOAD_TARGET_MONO)); + } + if(e || face->glyph->advance.x <= 0) { + fc->width = 0; + fc->left = 0; + if(i == 0) { + drawpjw(m, fc, x, w, y, y - y0); + x += fc->width; + } + continue; + } + + FT_Bitmap *bitmap = &face->glyph->bitmap; + uchar *base = byteaddr(mc, mc->r.min); + advance = (face->glyph->advance.x+32) >> 6; + + for(r=0; r < bitmap->rows; r++) + memmove(base + r*mc->width*sizeof(u32int), bitmap->buffer + r*bitmap->pitch, bitmap->pitch); + + memimagedraw(m, Rect(x, 0, x + advance, y), mc, + Pt(-face->glyph->bitmap_left, -(y - y0 - face->glyph->bitmap_top)), + memopaque, ZP, S); + fc->width = advance; + fc->left = 0; x += advance; #ifdef DEBUG_FT_BITMAP @@ -229,6 +230,10 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) // round up to 32-bit boundary // so that in-memory data is same // layout as in-file data. + if(x == 0) + x = 1; + if(y == 0) + y = 1; if(antialias) x += -x & 3; else From 82abcd6fd693549b225e53c6c161ea3909f2cf00 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 12 Nov 2018 11:07:41 -0500 Subject: [PATCH 023/323] plumb: allow @ in file names Helps Go module download cache, Upspin, maybe others. --- plumb/basic | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plumb/basic b/plumb/basic index f728132fd..438fc48fc 100644 --- a/plumb/basic +++ b/plumb/basic @@ -37,8 +37,8 @@ plumb start wdoc2txt $file # image files go to page type is text -data matches '[a-zA-Z¡-￿0-9_\-./]+' -data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)' +data matches '[a-zA-Z¡-￿0-9_\-./@]+' +data matches '([a-zA-Z¡-￿0-9_\-./@]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)' arg isfile $0 plumb to image plumb start 9 page $file @@ -46,22 +46,22 @@ plumb start 9 page $file # postscript/pdf/dvi go to page but not over the a plumb port # the port is here for reference but is unused type is text -data matches '[a-zA-Z¡-￿0-9_\-./]+' -data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)' +data matches '[a-zA-Z¡-￿0-9_\-./@]+' +data matches '([a-zA-Z¡-￿0-9_\-./@]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)' arg isfile $0 plumb to postscript plumb start 9 page $file # open office - s[xt][cdigmw], doc, xls, ppt -data matches '[a-zA-Z¡-￿0-9_\-./]+' -data matches '([a-zA-Z¡-￿0-9_\-./]+)\.([Ss][XxTt][CcDdIiGgMmWw]|[Dd][Oo][Cc]|[Xx][Ll][Ss]|[Pp][Pp][Tt])' +data matches '[a-zA-Z¡-￿0-9_\-./@]+' +data matches '([a-zA-Z¡-￿0-9_\-./@]+)\.([Ss][XxTt][CcDdIiGgMmWw]|[Dd][Oo][Cc]|[Xx][Ll][Ss]|[Pp][Pp][Tt])' arg isfile $0 plumb to openoffice plumb start openoffice $file # existing files tagged by line number:columnumber or linenumber.columnumber, twice, go to editor type is text -data matches '([.a-zA-Z¡-￿0-9_/\-]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr,$twocolonaddr +data matches '([.a-zA-Z¡-￿0-9_/\-@]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr,$twocolonaddr arg isfile $1 data set $file attr add addr=$2-#1+#$3,$4-#1+#$5 @@ -70,7 +70,7 @@ plumb client $editor # existing files tagged by line number:columnumber or linenumber.columnumber, twice, go to editor type is text -data matches '([.a-zA-Z¡-￿0-9_/\-]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr +data matches '([.a-zA-Z¡-￿0-9_/\-@]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr arg isfile $1 data set $file attr add addr=$2-#1+#$3 @@ -79,7 +79,7 @@ plumb client $editor # existing files, possibly tagged by line number, go to editor type is text -data matches '([.a-zA-Z¡-￿0-9_/\-]*[a-zA-Z¡-￿0-9_/\-])('$addr')?' +data matches '([.a-zA-Z¡-￿0-9_/\-@]*[a-zA-Z¡-￿0-9_/\-])('$addr')?' arg isfile $1 data set $file attr add addr=$3 From 13ed1c423ecbd45d2ca982f2a7a433b785873629 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 12 Nov 2018 11:08:23 -0500 Subject: [PATCH 024/323] 9l: drop xcode text-based stub warning --- bin/9l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/9l b/bin/9l index 2409e641e..6195815f7 100755 --- a/bin/9l +++ b/bin/9l @@ -349,7 +349,7 @@ fi xtmp=/tmp/9l.$$.$USER.out xxout() { sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | - egrep -v 'is (often|almost always) misused|is dangerous, better use' + egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' rm -f $xtmp } From 014fd65a5ca780823c0e75787f193d3c6597de8f Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Tue, 13 Nov 2018 22:09:10 -0600 Subject: [PATCH 025/323] 9term: fix getpts on FreeBSD 11.2 (#199) Opening /dev/ptyXX files fails on recent FreeBSD versions. Following the same fix being applied to Linux, OpenBSD, and Darwin, we use openpty to open a pseudoterminal in openpts. --- src/cmd/9term/FreeBSD.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmd/9term/FreeBSD.c b/src/cmd/9term/FreeBSD.c index eec79c286..e91f6ace5 100644 --- a/src/cmd/9term/FreeBSD.c +++ b/src/cmd/9term/FreeBSD.c @@ -1 +1,17 @@ +#define getpts not_using_this_getpts #include "bsdpty.c" +#undef getpts + +#include + +int +getpts(int fd[], char *slave) +{ + if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){ + fchmod(fd[1], 0620); + strcpy(slave, ttyname(fd[0])); + return 0; + } + sysfatal("no ptys"); + return 0; +} From 2419c9343827a679353a8c0a44fd6e0e3e631a3c Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Tue, 13 Nov 2018 22:09:59 -0600 Subject: [PATCH 026/323] fontsrv: disable font smoothing on osx (#196) macOS Mojave version 10.14 starts to disable font smoothing. We disable font smoothing for OSX_VERSION >= 101400 to match the system default font rendering. It also makes the font rendering on macOS similar to that on X11. --- src/cmd/fontsrv/mkfile | 1 + src/cmd/fontsrv/osx.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/cmd/fontsrv/mkfile b/src/cmd/fontsrv/mkfile index eed0355a7..8ad99dbc0 100644 --- a/src/cmd/fontsrv/mkfile +++ b/src/cmd/fontsrv/mkfile @@ -1,4 +1,5 @@ <$PLAN9/src/mkhdr +<|osxvers <|sh ../devdraw/mkwsysrules.sh <|sh freetyperules.sh $WSYSTYPE $X11H diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index b28ee2522..c01ae6ce5 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -277,6 +277,9 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) CGContextSetAllowsAntialiasing(ctxt, antialias); CGContextSetTextPosition(ctxt, 0, 0); // XXX +#if OSX_VERSION >= 101400 + CGContextSetAllowsFontSmoothing(ctxt, false); +#endif x = 0; for(i=lo; i<=hi; i++, fc++) { From 76b9347a5fa3a0970527c6ee1b97ef1c714f636b Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Tue, 13 Nov 2018 23:11:31 -0500 Subject: [PATCH 027/323] acme: avoid division by zero when resizing col (#189) To reproduce, create a column with at least two windows and resize acme to have almost zero height. --- src/cmd/acme/cols.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c index 10e014eea..b1fe23bab 100644 --- a/src/cmd/acme/cols.c +++ b/src/cmd/acme/cols.c @@ -250,8 +250,12 @@ colresize(Column *c, Rectangle r) w->maxlines = 0; if(i == c->nw-1) r1.max.y = r.max.y; - else - r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r); + else{ + r1.max.y = r1.min.y; + if(Dy(c->r) != 0){ + r1.max.y += (Dy(w->r)+Border)*Dy(r)/Dy(c->r); + } + } r1.max.y = max(r1.max.y, r1.min.y + Border+font->height); r2 = r1; r2.max.y = r2.min.y+Border; From c82e11b24e7a6aa03473111367cb792ce0537f61 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Tue, 13 Nov 2018 22:13:15 -0600 Subject: [PATCH 028/323] fontsrv: x11 uses FC_POSTSCRIPT_NAME (#174) This makes fontsrv use the PostScript font names on X11. The PostScript font names contains only alphanumeric and hyphens. This allows us to use the Font command in acme. It also matches the font names used by fontsrv on macOS, which has been using PostScript font names. --- src/cmd/fontsrv/x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 455e81260..f93c031eb 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -40,7 +40,7 @@ loadfonts(void) int index; FcPattern *pat = sysfonts->fonts[i]; - if(FcPatternGetString(pat, FC_FULLNAME, 0, &fullname) != FcResultMatch || + if(FcPatternGetString(pat, FC_POSTSCRIPT_NAME, 0, &fullname) != FcResultMatch || FcPatternGetString(pat, FC_FILE, 0, &fontfile) != FcResultMatch || FcPatternGetInteger(pat, FC_INDEX, 0, &index) != FcResultMatch) continue; From c38ae2afb5b000400d7e9979fd5bb043b9819d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Wed, 14 Nov 2018 05:13:39 +0100 Subject: [PATCH 029/323] keyboard: add tab/untab symbols (#160) --- lib/keyboard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/keyboard b/lib/keyboard index ec16fa302..ccc19adcf 100644 --- a/lib/keyboard +++ b/lib/keyboard @@ -475,6 +475,8 @@ 2194 ab ↔ left right arrow 21D0 V= ⇐ left double arrow 21D2 =V ⇒ right double arrow +21E4 |< ⇤ left arrow to bar +21E5 >| ⇥ right arrow to bar 2200 fa ∀ for all 2202 pd ∂ partial differential 2203 te ∃ there exists From 931c5906118e4db3419bfb4dced833902eb14139 Mon Sep 17 00:00:00 2001 From: thisrod Date: Wed, 14 Nov 2018 15:14:20 +1100 Subject: [PATCH 030/323] keyboard: add compose sequences lc and rc for ceiling brackets (#126) Change-Id: Ice1c8c9d15cc6febf32dc2b7c449d457acc319b6 --- lib/keyboard | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/keyboard b/lib/keyboard index ccc19adcf..a1574a365 100644 --- a/lib/keyboard +++ b/lib/keyboard @@ -553,6 +553,8 @@ 22E6 !~ ⋧ greater than but not equivalent to 22EF el ⋯ midline horizontal ellipsis +2308 lc ⌈ left ceiling +2309 rc ⌉ right ceiling 230A lf ⌊ left floor 230B rf ⌋ right floor 2329 Date: Tue, 13 Nov 2018 22:57:56 -0600 Subject: [PATCH 031/323] devdraw: make ctrl generate 1-click while mouse down (#119) This makes 2-1 chords possible with touchpad on a mac laptop. --- src/cmd/devdraw/cocoa-screen.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index e7296e44d..16053eaa2 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -927,6 +927,8 @@ - (void)insertText:(id)arg{} /* to avoid a latency after some time */ case NSFlagsChanged: if(in.mbuttons || in.kbuttons){ in.kbuttons = 0; + if(m & NSControlKeyMask) + in.kbuttons |= 1; if(m & NSAlternateKeyMask) in.kbuttons |= 2; if(m & NSCommandKeyMask) From 73ea36569e83560168cfd7e40d85d9d247bce593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Wed, 14 Nov 2018 05:59:04 +0100 Subject: [PATCH 032/323] plumb/basic: avoid wrap around in file:1:2 (#158) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #122, #140. As reported in #122, `file:1:1` moves to the end of the file, and `file:1:2` fails with “address out of range”. I’ll use file:2:3 as an example so we can tell the line and column number apart. What’s happening is this: plumb/basic matches `2:3` using twocolonaddr (from plumb/fileaddr), then sets addr to `2-#1+#3` (the 1 is constant and was introduced because column numbers are 1-based). Acme interprets this in three steps: 1. find the range (q0, q1) that contains line 2 2. create the range (q2, q2) where q2 = q0 - 1 3. create the range (q3, q3) where q3 = q2 + 3 The second step has a branch where if q0 == 0 and 1 > 0 (remember that 1 is constant and comes form plumb/basic), q0 is set to the end of the file. This makes addressing things at the end of the file easier. The problem then is that if we select line 1, which starts at the beginning of the file, q0 is always 0 and the branch in step 2) will always be used. `1:1` is interpreted as `1-#1+#1` which starts at 0, wraps around to the end of the file, then moves 1 character backwards and then forwards again, ending at the end of the file. `1:2` is interpretes as `1-#1+#2` which starts at 0, wraps around to the end od the file, then moves 1 character backwards and tries moving 2 characters forwards beyond the end of the file, resulting in the out of range error. In #140 @rsc proposed transforming `:X:Y` into `:X-#0+#Y-#1` instead since that avoids wrapping around by not moving backwards at first. This change modifies `plumb/basic` to do that. --- plumb/basic | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plumb/basic b/plumb/basic index 438fc48fc..b59b7948f 100644 --- a/plumb/basic +++ b/plumb/basic @@ -64,7 +64,7 @@ type is text data matches '([.a-zA-Z¡-￿0-9_/\-@]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr,$twocolonaddr arg isfile $1 data set $file -attr add addr=$2-#1+#$3,$4-#1+#$5 +attr add addr=$2-#0+#$3-#1,$4-#0+#$5-#1 plumb to edit plumb client $editor @@ -73,7 +73,7 @@ type is text data matches '([.a-zA-Z¡-￿0-9_/\-@]*[a-zA-Z¡-￿0-9_/\-])':$twocolonaddr arg isfile $1 data set $file -attr add addr=$2-#1+#$3 +attr add addr=$2-#0+#$3-#1 plumb to edit plumb client $editor From f3ed5754b1c4ccc616afb1fbb1ce65e1f8f29808 Mon Sep 17 00:00:00 2001 From: "KADOTA, Kyohei" Date: Wed, 14 Nov 2018 13:59:49 +0900 Subject: [PATCH 033/323] 9term.app: add $PLAN9/bin to $PATH if not already in $PATH (#144) 9term set $PLAN9 if PLAN9 is not set. But $PATH is not set. As a result, 9term exits with "exec devdraw: No such file or directory" --- mac/9term.app/Contents/MacOS/9term | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mac/9term.app/Contents/MacOS/9term b/mac/9term.app/Contents/MacOS/9term index ef6692c3a..d6487348e 100755 --- a/mac/9term.app/Contents/MacOS/9term +++ b/mac/9term.app/Contents/MacOS/9term @@ -2,4 +2,8 @@ cd $HOME . ~/.bashrc PLAN9=${PLAN9:-/usr/local/plan9} +if ! [[ :$PATH: =~ :$PLAN9/bin: ]] +then + PATH=$PATH:$PLAN9/bin +fi $PLAN9/bin/9term -W600x800 & From ed959cfba326356a5cdea1a12c8ac17b5365486c Mon Sep 17 00:00:00 2001 From: iru- Date: Tue, 13 Nov 2018 21:01:04 -0800 Subject: [PATCH 034/323] fontsrv: increase x11 font height scale (#111) --- src/cmd/fontsrv/x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index f93c031eb..4137f9ca4 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -77,7 +77,7 @@ load(XFont *f) return; } f->unit = face->units_per_EM; - f->height = (int)((face->ascender - face->descender) * 1.2); + f->height = (int)((face->ascender - face->descender) * 1.35); f->originy = face->descender; // bbox.yMin (or descender) is negative, becase the baseline is y-coord 0 for(charcode=FT_Get_First_Char(face, &glyph_index); glyph_index != 0; From 2ba6fa9a65c82088cde14aa56740d0eea9e38628 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 14 Nov 2018 00:03:17 -0500 Subject: [PATCH 035/323] web: allow any $BROWSER Fixes #118. --- bin/web | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/web b/bin/web index 7829229f8..5de673980 100755 --- a/bin/web +++ b/bin/web @@ -34,7 +34,7 @@ plumbunix() $BROWSER -remote 'openURL('"$@"',new-tab)' || $BROWSER "$@" ;; - *chrome*|*chromium*) + ?*) $BROWSER "$@" ;; esac From d3f21b709efc5e1ca4c4f0ef58bf9ac5db8e921c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 14 Nov 2018 00:11:48 -0500 Subject: [PATCH 036/323] 9term: make 9term -l invoke $SHELL with -l --- src/cmd/9term/rcstart.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c index 141b9b005..fddabc6de 100644 --- a/src/cmd/9term/rcstart.c +++ b/src/cmd/9term/rcstart.c @@ -34,7 +34,7 @@ int rcstart(int argc, char **argv, int *pfd, int *tfd) { int fd[2], i, pid; - char *cmd, *xargv[3]; + char *cmd, *xargv[4]; char slave[256]; int sfd; @@ -46,6 +46,11 @@ rcstart(int argc, char **argv, int *pfd, int *tfd) argv[0] = "rc"; argv[1] = "-i"; argv[2] = 0; + if(loginshell){ + argv[2] = "-l"; + argv[3] = 0; + argc = 3; + } } cmd = argv[0]; if(loginshell){ From a791787a384745b90fa0eb704cd9cbbe8c758684 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 14 Nov 2018 00:11:58 -0500 Subject: [PATCH 037/323] mac/9term.app: invoke 9term with -l This seems to match Terminal. Fixes #145. --- mac/9term.app/Contents/MacOS/9term | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac/9term.app/Contents/MacOS/9term b/mac/9term.app/Contents/MacOS/9term index d6487348e..e5ef2735c 100755 --- a/mac/9term.app/Contents/MacOS/9term +++ b/mac/9term.app/Contents/MacOS/9term @@ -6,4 +6,4 @@ if ! [[ :$PATH: =~ :$PLAN9/bin: ]] then PATH=$PATH:$PLAN9/bin fi -$PLAN9/bin/9term -W600x800 & +$PLAN9/bin/9term -l -W600x800 & From 000c1a3b19a8d3f8bbaefba84131995cb62c889f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20D=C3=ADaz?= Date: Wed, 14 Nov 2018 06:19:29 +0100 Subject: [PATCH 038/323] devdraw: set displaydpi on devdraw x11 attach (#178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://plan9port-review.googlesource.com/c/plan9/+/1470 for discussion of the approach, especially Michael Stapleberg's comment: Note that chromium, firefox and others have tried this and then switched to using the Xft.dpi X resource, see e.g. https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/ui/libgtk2ui/gtk2_ui.cc and especially http://sources.debian.net/src/gnome-settings-daemon/3.18.2-1/plugins/xsettings/gsd-xsettings-manager.c/?hl=824#L80 for some anecdata about why this approach doesn’t work out. The Xft.dpi resource is being set accurately by desktop environments (GNOME, KDE, …) and can easily be changed by users of niche window managers by editing ~/.Xresources. I suggest we check only Xft.dpi, without considering the DPI environment variable or the monitor width/height. --- src/cmd/devdraw/x11-init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index 5363fb74f..f09963dce 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -208,9 +208,9 @@ _xattach(char *label, char *winsize) * Parse the various X resources. Thanks to Peter Canning. */ char *screen_resources, *display_resources, *geom, - *geomrestype, *home, *file; + *geomrestype, *home, *file, *dpitype; XrmDatabase database; - XrmValue geomres; + XrmValue geomres, dpires; database = XrmGetDatabase(_x.display); screen_resources = XScreenResourceString(xscreen); @@ -230,6 +230,11 @@ _xattach(char *label, char *winsize) }else XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False); + if (XrmGetResource(database, "Xft.dpi", "String", &dpitype, &dpires) == True) { + if (dpires.addr) { + displaydpi=atoi(dpires.addr); + } + } geom = smprint("%s.geometry", label); if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres)) mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height); From 9c38253d1d8bae2f821d30fb8216783d2eb76f87 Mon Sep 17 00:00:00 2001 From: Francis Conti Date: Tue, 13 Nov 2018 21:23:40 -0800 Subject: [PATCH 039/323] INSTALL: fix compiler detection on FreeBSD+clang (#177) --- INSTALL | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/INSTALL b/INSTALL index 4673056b5..282f900c9 100755 --- a/INSTALL +++ b/INSTALL @@ -15,9 +15,9 @@ x-c) doinstall=true ;; x-r) - shift - PLAN9_TARGET=$1 export PLAN9_TARGET - ;; + shift + PLAN9_TARGET=$1 export PLAN9_TARGET + ;; *) echo 'usage: INSTALL [-b | -c] [-r path]' 1>&2 exit 1 @@ -42,23 +42,27 @@ echo "* Resetting $PLAN9/config" rm -f config ( -echo "* Compiler version:" -9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /' - if [ `uname` = FreeBSD ]; then - echo "* Running on FreeBSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config + case `cc -v 2>&1` in + *clang*) + echo "CC9=clang" >> $PLAN9/config + ;; + *) + ;; + esac + echo "* Running on FreeBSD, adjusting linker flags" + echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config fi if [ `uname` = DragonFly ]; then - echo "* Running on DragonFly BSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config - echo "CFLAGS='-pthread'" >> $PLAN9/config + echo "* Running on DragonFly BSD, adjusting linker flags" + echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config + echo "CFLAGS='-pthread'" >> $PLAN9/config fi if [ `uname` = OpenBSD ]; then - echo "* Running on OpenBSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config + echo "* Running on OpenBSD, adjusting linker flags" + echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config fi if [ `uname` = Linux ]; then @@ -80,8 +84,8 @@ fi if [ `uname` = SunOS ]; then # On Solaris x86, uname -p cannot be trusted. - echo "* Running on Solaris: checking architecture..." - case "$(isainfo -n)" in + echo "* Running on Solaris: checking architecture..." + case "$(isainfo -n)" in *amd64*) echo " x86-64 found." echo "OBJTYPE=x86_64" >>$PLAN9/config @@ -92,7 +96,7 @@ if [ `uname` = SunOS ]; then echo "OBJTYPE=386" >>$PLAN9/config echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386 ;; - *sparc*) + *sparc*) echo " Sparc found." echo "OBJTYPE=sparc" >>$PLAN9/config ;; @@ -118,7 +122,7 @@ if [ `uname` = Darwin ]; then echo "OBJTYPE=386" >>$PLAN9/config ;; *ppc*) - echo " power found." + echo " power found." echo "OBJTYPE=power" >>$PLAN9/config ;; esac @@ -147,6 +151,9 @@ if [ -f LOCAL.config ]; then cat LOCAL.config >>config fi +echo "* Compiler version:" +9c -v 2>&1 | grep -v 'Configured with:' | grep -i version | sed 's/^/ /' + cd src if $dobuild; then if [ ! -x ../bin/mk ]; then From de43b1629d008aa6cdf4f6beb2b06e3859616a3e Mon Sep 17 00:00:00 2001 From: Zach Scott Date: Wed, 14 Nov 2018 05:24:07 +0000 Subject: [PATCH 040/323] upas/smtp: fix TLS connections (#163) Both `upas/nfs` and `upas/smtp` call the currently broken `tlsClient()` from libsec. This commit copies a fix from upas/nfs into upas/smtp. In `imapdial()`, upas/nfs replaces a process call for tlsClient with `stunnel3` when not on Plan 9. upas/smtp calls tlsClient directly as a function, so imapdial was copied into mxdial.c as `smtpdial()`, and tlsClient+dial replaced with a call to smtpdial. --- src/cmd/upas/smtp/mxdial.c | 48 ++++++++++++++++++++++++++++++++++++++ src/cmd/upas/smtp/smtp.c | 1 + 2 files changed, 49 insertions(+) diff --git a/src/cmd/upas/smtp/mxdial.c b/src/cmd/upas/smtp/mxdial.c index f3a2a2090..56962dcd5 100644 --- a/src/cmd/upas/smtp/mxdial.c +++ b/src/cmd/upas/smtp/mxdial.c @@ -2,6 +2,7 @@ #include #include "smtp.h" /* to publish dial_string_parse */ #include +#include enum { @@ -27,6 +28,45 @@ static int callmx(DS*, char*, char*); static void expand_meta(DS *ds); extern int cistrcmp(char*, char*); +/* Taken from imapdial, replaces tlsclient call with stunnel */ +static int +smtpdial(char *server) +{ + int p[2]; + int fd[3]; + char *tmp; + char *fpath; + + if(pipe(p) < 0) + return -1; + fd[0] = dup(p[0], -1); + fd[1] = dup(p[0], -1); + fd[2] = dup(2, -1); +#ifdef PLAN9PORT + tmp = smprint("%s:587", server); + fpath = searchpath("stunnel3"); + if (!fpath) { + werrstr("stunnel not found. it is required for tls support."); + return -1; + } + if(threadspawnl(fd, fpath, "stunnel", "-n", "smtp" , "-c", "-r", tmp, nil) < 0) { +#else + tmp = smprint("tcp!%s!587", server); + if(threadspawnl(fd, "/bin/tlsclient", "tlsclient", tmp, nil) < 0){ +#endif + free(tmp); + close(p[0]); + close(p[1]); + close(fd[0]); + close(fd[1]); + close(fd[2]); + return -1; + } + free(tmp); + close(p[0]); + return p[1]; +} + int mxdial(char *addr, char *ddomain, char *gdomain) { @@ -100,13 +140,21 @@ callmx(DS *ds, char *dest, char *domain) } /* dial each one in turn */ for(i = 0; i < nmx; i++){ +#ifdef PLAN9PORT + snprint(addr, sizeof(addr), "%s", mx[i].host); +#else snprint(addr, sizeof(addr), "%s!%s!%s", ds->proto, mx[i].host, ds->service); +#endif if(debug) fprint(2, "mxdial trying %s (%d)\n", addr, i); atnotify(timeout, 1); alarm(10*1000); +#ifdef PLAN9PORT + fd = smtpdial(addr); +#else fd = dial(addr, 0, 0, 0); +#endif alarm(0); atnotify(timeout, 0); if(fd >= 0) diff --git a/src/cmd/upas/smtp/smtp.c b/src/cmd/upas/smtp/smtp.c index 9dd055962..92873723d 100644 --- a/src/cmd/upas/smtp/smtp.c +++ b/src/cmd/upas/smtp/smtp.c @@ -467,6 +467,7 @@ hello(char *me, int encrypted) } ehlo = 1; + encrypted = 1; Again: if(ehlo) dBprint("EHLO %s\r\n", me); From 9af9ceca26596d562a3ae89fda70bad9f8822ab0 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Sun, 21 Oct 2018 20:59:21 -0500 Subject: [PATCH 041/323] devdraw: rewrite the Cocoa screen using Metal Add a new macOS cocoa screen, cocoa-screen-metal.m. Rewrite the macOS cocoa drawing code to use the builtin runloop, and use Metal to push pixels with CAMetalLayer. Remove all of the deprecated code, and simplify some of the logic. Modify mkwsysrules.sh such that the new code is used only when the system version is equal or higher than 10.14. Allow touch events to simulate mouse clicks: three finger tap for the middle mouse button; four finger tap for the 2-1 chord. Support Tresize. Scale 16x16 Cursor up to 32x32 with an EPX algorithm. Support macOS input sources including the basic dead keys and the advanced CJK input methods. Increase the communication buffers in cocoa-srv.c to allow more input, especially for long sentences prepared by the macOS input souces. --- src/cmd/devdraw/bigarrow.h | 22 +- src/cmd/devdraw/cocoa-screen-metal.m | 1260 ++++++++++++++++++++++++++ src/cmd/devdraw/cocoa-screen.h | 6 +- src/cmd/devdraw/cocoa-srv.c | 22 +- src/cmd/devdraw/cocoa-thread.c | 7 + src/cmd/devdraw/cocoa-thread.h | 1 + src/cmd/devdraw/mkfile | 3 + src/cmd/devdraw/mkwsysrules.sh | 7 +- 8 files changed, 1307 insertions(+), 21 deletions(-) create mode 100644 src/cmd/devdraw/cocoa-screen-metal.m diff --git a/src/cmd/devdraw/bigarrow.h b/src/cmd/devdraw/bigarrow.h index a46f19a09..3b66c954e 100644 --- a/src/cmd/devdraw/bigarrow.h +++ b/src/cmd/devdraw/bigarrow.h @@ -1,11 +1,13 @@ -Cursor bigarrow = { - {0, 0}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, - 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, - 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, - 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40}, - {0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0, - 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8, - 0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8, - 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00}, +Cursor bigarrow = { + { -1, -1 }, + { 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0C, + 0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04, + 0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8C, 0x04, + 0x92, 0x08, 0x91, 0x10, 0xA0, 0xA0, 0xC0, 0x40, + }, + { 0x00, 0x00, 0x7F, 0xFE, 0x7F, 0xFC, 0x7F, 0xF0, + 0x7F, 0xE0, 0x7F, 0xE0, 0x7F, 0xF0, 0x7F, 0xF8, + 0x7F, 0xFC, 0x7F, 0xFE, 0x7F, 0xFC, 0x73, 0xF8, + 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00, + }, }; diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m new file mode 100644 index 000000000..c82ce0bc2 --- /dev/null +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -0,0 +1,1260 @@ +#define Cursor OSXCursor +#define Point OSXPoint +#define Rect OSXRect + +#import +#import +#import + +#undef Cursor +#undef Point +#undef Rect + +#include +#include +#include "cocoa-thread.h" +#include +#include +#include +#include +#include "cocoa-screen.h" +#include "osx-keycodes.h" +#include "devdraw.h" +#include "bigarrow.h" +#include "glendapng.h" + +AUTOFRAMEWORK(Cocoa) +AUTOFRAMEWORK(Metal) +AUTOFRAMEWORK(QuartzCore) + +#define LOG if(0)NSLog + +static void setprocname(const char*); +static uint keycvt(uint); +static uint msec(void); +static Memimage* initimg(void); + +void +usage(void) +{ + fprint(2, "usage: devdraw (don't run directly)\n"); + threadexitsall("usage"); +} + +@interface AppDelegate : NSObject ++ (void)callservep9p:(id)arg; ++ (void)makewin:(NSValue *)v; ++ (void)callkicklabel:(NSString *)v; ++ (void)callsetNeedsDisplayInRect:(NSValue *)v; ++ (void)callsetcursor:(NSValue *)v; +@end +@interface DevDrawView : NSView +- (void)clearInput; +- (void)getmouse:(NSEvent *)e; +- (void)sendmouse:(NSUInteger)b; +- (void)resetLastInputRect; +- (void)enlargeLastInputRect:(NSRect)r; +@end +@interface DrawLayer : CAMetalLayer +@end + +static AppDelegate *myApp = NULL; +static DevDrawView *myContent = NULL; +static NSWindow *win = NULL; +static NSCursor *currentCursor = NULL; + +static DrawLayer *layer; +static MTLRenderPassDescriptor *renderPass; +static id device; +static id pipelineState; +static id commandQueue; +static id texture; + +static Memimage *img = NULL; + +static QLock snarfl; + +static NSString *const metal = +@"#include\n" +"using namespace metal;\n" +"typedef struct {\n" +" float4 rCoord [[position]];\n" +" float2 tCoord;\n" +"} VertexOut;\n" +"vertex VertexOut\n" +"renderVertex(unsigned int vid [[ vertex_id ]])\n" +"{\n" +" const VertexOut fixedV[] = {\n" +" {{ -1.0f, -1.0f, 0.0f, 1.0f }, { 0.0f, 1.0f }},\n" +" {{ 1.0f, -1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f }},\n" +" {{ -1.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f }},\n" +" {{ 1.0f, 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f }},\n" +" };\n" +" return fixedV[vid];\n" +"}\n" +"fragment half4\n" +"renderFragment(VertexOut in [[ stage_in ]],\n" +" texture2d texture [[ texture(0) ]]) {\n" +" constexpr sampler s;\n" +" return texture.sample(s, in.tCoord);\n" +"}"; + + +void +threadmain(int argc, char **argv) +{ + /* + * Move the protocol off stdin/stdout so that + * any inadvertent prints don't screw things up. + */ + dup(0,3); + dup(1,4); + close(0); + close(1); + open("/dev/null", OREAD); + open("/dev/null", OWRITE); + + ARGBEGIN{ + case 'D': /* for good ps -a listings */ + break; + case 'f': /* fall through for backward compatibility */ + case 'g': + case 'b': + break; + default: + usage(); + }ARGEND + + setprocname(argv0); + + @autoreleasepool{ + [NSApplication sharedApplication]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + myApp = [AppDelegate new]; + [NSApp setDelegate:myApp]; + [NSApp run]; + } +} + +@implementation AppDelegate + ++ (void)callservep9p:(id)arg +{ + servep9p(); + [NSApp terminate:self]; +} + ++ (void)makewin:(NSValue *)v +{ + NSRect r, sr; + Rectangle wr; + int set; + char *s; + id library; + MTLRenderPipelineDescriptor *pipelineDesc; + NSError *error; + + const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled + | NSWindowStyleMaskClosable + | NSWindowStyleMaskMiniaturizable + | NSWindowStyleMaskResizable; + + sr = [[NSScreen mainScreen] frame]; + r = [[NSScreen mainScreen] visibleFrame]; + + s = [v pointerValue]; + LOG(@"makewin(%s)", s); + if(s && *s){ + if(parsewinsize(s, &wr, &set) < 0) + sysfatal("%r"); + }else{ + wr = Rect(0, 0, sr.size.width*2/3, sr.size.height*2/3); + set = 0; + } + + r.origin.x = wr.min.x; + r.origin.y = sr.size.height-wr.max.y; /* winsize is top-left-based */ + r.size.width = fmin(Dx(wr), r.size.width); + r.size.height = fmin(Dy(wr), r.size.height); + r = [NSWindow contentRectForFrameRect:r styleMask:Winstyle]; + + win = [[NSWindow alloc] + initWithContentRect:r + styleMask:Winstyle + backing:NSBackingStoreBuffered defer:NO]; + [win setTitle:@"devdraw"]; + + if(!set) + [win center]; + [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + [win setContentMinSize:NSMakeSize(64,64)]; + + [win setRestorable:NO]; + [win setAcceptsMouseMovedEvents:YES]; + [win setDelegate:myApp]; + + myContent = [DevDrawView new]; + [win setContentView:myContent]; + [myContent setWantsLayer:YES]; + [myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; + + device = MTLCreateSystemDefaultDevice(); + commandQueue = [device newCommandQueue]; + + layer = (DrawLayer *)[myContent layer]; + layer.device = device; + layer.pixelFormat = MTLPixelFormatBGRA8Unorm; + layer.framebufferOnly = YES; + layer.opaque = YES; + + renderPass = [MTLRenderPassDescriptor renderPassDescriptor]; + renderPass.colorAttachments[0].loadAction = MTLLoadActionDontCare; + renderPass.colorAttachments[0].storeAction = MTLStoreActionDontCare; + + library = [device newLibraryWithSource:metal options:nil error:&error]; + if(!library) + sysfatal((char *)[[error localizedDescription] UTF8String]); + + pipelineDesc = [MTLRenderPipelineDescriptor new]; + pipelineDesc.alphaToOneEnabled = YES; + pipelineDesc.inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle; + pipelineDesc.rasterSampleCount = 1; + pipelineDesc.colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm; + [pipelineDesc setVertexFunction: [library newFunctionWithName: @"renderVertex"]]; + [pipelineDesc setFragmentFunction: [library newFunctionWithName: @"renderFragment"]]; + + pipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDesc error:&error]; + if(!pipelineState) + sysfatal((char *)[[error localizedDescription] UTF8String]); + + [NSEvent setMouseCoalescingEnabled:NO]; + + topwin(); +} + ++ (void)callkicklabel:(NSString *)s +{ + LOG(@"callkicklabel(%@)", s); + [win setTitle:s]; + [[NSApp dockTile] setBadgeLabel:s]; +} + + ++ (void)callsetNeedsDisplayInRect:(NSValue *)v +{ + NSRect r; + + r = [v rectValue]; + LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); + r = [win convertRectFromBacking:r]; + LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); + [layer setNeedsDisplayInRect:r]; + [myContent enlargeLastInputRect:r]; +} + ++ (void)callsetcursor:(NSValue *)v +{ + Cursor *c; + NSBitmapImageRep *r, *r2; + NSImage *i; + NSPoint p; + uint b, x, y, a; + uchar *plane[5], *plane2[5]; + uchar pu, pb, pl, pr, pc; // upper, bottom, left, right, center + uchar pul, pur, pbl, pbr; + uchar ful, fur, fbl, fbr; + + c = [v pointerValue]; + if(!c) + c = &bigarrow; + + r = [[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:16 + pixelsHigh:16 + bitsPerSample:1 + samplesPerPixel:2 + hasAlpha:YES + isPlanar:YES + colorSpaceName:NSDeviceWhiteColorSpace + bytesPerRow:2 + bitsPerPixel:0]; + [r getBitmapDataPlanes:plane]; + for(b=0; b<2*16; b++){ + plane[0][b] = ~c->set[b] & c->clr[b]; + plane[1][b] = c->set[b] | c->clr[b]; + } + + r2 = [[NSBitmapImageRep alloc] + initWithBitmapDataPlanes:nil + pixelsWide:32 + pixelsHigh:32 + bitsPerSample:1 + samplesPerPixel:2 + hasAlpha:YES + isPlanar:YES + colorSpaceName:NSDeviceWhiteColorSpace + bytesPerRow:4 + bitsPerPixel:0]; + [r2 getBitmapDataPlanes:plane2]; + // https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms#EPX/Scale2×/AdvMAME2× + for(a=0; a<2; a++){ + for(y=0; y<16; y++){ + for(x=0; x<2; x++){ + pc = plane[a][x+2*y]; + pu = y==0 ? pc : plane[a][x+2*(y-1)]; + pb = y==15 ? pc : plane[a][x+2*(y+1)]; + pl = (pc>>1) | (x==0 ? pc&0x80 : (plane[a][x-1+2*y]&1)<<7); + pr = (pc<<1) | (x==1 ? pc&1 : (plane[a][x+1+2*y]&0x80)>>7); + ful = ~(pl^pu) & (pl^pb) & (pu^pr); + pul = (ful & pu) | (~ful & pc); + fur = ~(pu^pr) & (pu^pl) & (pr^pb); + pur = (fur & pr) | (~fur & pc); + fbl = ~(pb^pl) & (pb^pr) & (pl^pu); + pbl = (fbl & pl) | (~fbl & pc); + fbr = ~(pr^pb) & (pr^pu) & (pb^pl); + pbr = (fbr & pb) | (~fbr & pc); + plane2[a][2*x+4*2*y] = (pul&0x80) | ((pul&0x40)>>1) | ((pul&0x20)>>2) | ((pul&0x10)>>3) + | ((pur&0x80)>>1) | ((pur&0x40)>>2) | ((pur&0x20)>>3) | ((pur&0x10)>>4); + plane2[a][2*x+1+4*2*y] = ((pul&0x8)<<4) | ((pul&0x4)<<3) | ((pul&0x2)<<2) | ((pul&0x1)<<1) + | ((pur&0x8)<<3) | ((pur&0x4)<<2) | ((pur&0x2)<<1) | (pur&0x1); + plane2[a][2*x+4*(2*y+1)] = (pbl&0x80) | ((pbl&0x40)>>1) | ((pbl&0x20)>>2) | ((pbl&0x10)>>3) + | ((pbr&0x80)>>1) | ((pbr&0x40)>>2) | ((pbr&0x20)>>3) | ((pbr&0x10)>>4); + plane2[a][2*x+1+4*(2*y+1)] = ((pbl&0x8)<<4) | ((pbl&0x4)<<3) | ((pbl&0x2)<<2) | ((pbl&0x1)<<1) + | ((pbr&0x8)<<3) | ((pbr&0x4)<<2) | ((pbr&0x2)<<1) | (pbr&0x1); + } + } + } + + // For checking out the cursor bitmap image +/* + static BOOL saveimg = YES; + if(saveimg){ + NSData *data = [r representationUsingType: NSBitmapImageFileTypeBMP properties: @{}]; + [data writeToFile: @"/tmp/r.bmp" atomically: NO]; + data = [r2 representationUsingType: NSBitmapImageFileTypeBMP properties: @{}]; + [data writeToFile: @"/tmp/r2.bmp" atomically: NO]; + saveimg = NO; + } +*/ + + i = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)]; + [i addRepresentation:r2]; + [i addRepresentation:r]; + + p = NSMakePoint(-c->offset.x, -c->offset.y); + currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; + + [win invalidateCursorRectsForView:myContent]; +} + +- (void)applicationDidFinishLaunching:(id)arg +{ + NSMenu *m, *sm; + NSData *d; + NSImage *i; + + LOG(@"applicationDidFinishLaunching"); + + sm = [NSMenu new]; + [sm addItemWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"]; + [sm addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"]; + [sm addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; + m = [NSMenu new]; + [m addItemWithTitle:@"DEVDRAW" action:NULL keyEquivalent:@""]; + [m setSubmenu:sm forItem:[m itemWithTitle:@"DEVDRAW"]]; + [NSApp setMainMenu:m]; + + d = [[NSData alloc] initWithBytes:glenda_png length:(sizeof glenda_png)]; + i = [[NSImage alloc] initWithData:d]; + [NSApp setApplicationIconImage:i]; + [[NSApp dockTile] display]; + + [NSThread + detachNewThreadSelector:@selector(callservep9p:) + toTarget:[self class] withObject:nil]; +} + +- (NSApplicationPresentationOptions)window:(id)arg + willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + NSApplicationPresentationOptions o; + o = proposedOptions; + o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); + o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + return o; +} + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { + return YES; +} + +@end + +@implementation DevDrawView +{ + NSMutableString *_tmpText; + NSRange _markedRange; + NSRange _selectedRange; + NSRect _lastInputRect; // The view is flipped, this is not. + BOOL _tapping; + NSUInteger _tapFingers; + NSUInteger _tapTime; +} + +- (id)init +{ + LOG(@"View init"); + self = [super init]; + [self setAllowedTouchTypes:NSTouchTypeMaskDirect|NSTouchTypeMaskIndirect]; + _tmpText = [[NSMutableString alloc] initWithCapacity:2]; + _markedRange = NSMakeRange(NSNotFound, 0); + _selectedRange = NSMakeRange(0, 0); + return self; +} + +- (CALayer *)makeBackingLayer +{ + LOG(@"makeBackingLayer"); + return [DrawLayer layer]; +} + +- (BOOL)wantsUpdateLayer +{ + return YES; +} + +- (BOOL)isOpaque +{ + return YES; +} + +- (BOOL)isFlipped +{ + return YES; +} + +- (BOOL)acceptsFirstResponder +{ + return YES; +} + +- (void)mouseMoved:(NSEvent*)e{ [self getmouse:e];} +- (void)mouseDown:(NSEvent*)e{ [self getmouse:e];} +- (void)mouseDragged:(NSEvent*)e{ [self getmouse:e];} +- (void)mouseUp:(NSEvent*)e{ [self getmouse:e];} +- (void)otherMouseDown:(NSEvent*)e{ [self getmouse:e];} +- (void)otherMouseDragged:(NSEvent*)e{ [self getmouse:e];} +- (void)otherMouseUp:(NSEvent*)e{ [self getmouse:e];} +- (void)rightMouseDown:(NSEvent*)e{ [self getmouse:e];} +- (void)rightMouseDragged:(NSEvent*)e{ [self getmouse:e];} +- (void)rightMouseUp:(NSEvent*)e{ [self getmouse:e];} + +- (void)scrollWheel:(NSEvent*)e +{ + NSInteger s; + + s = [e scrollingDeltaY]; + if(s > 0) + [self sendmouse:8]; + else if (s < 0) + [self sendmouse:16]; +} + +- (void)keyDown:(NSEvent*)e +{ + LOG(@"keyDown to interpret"); + + [self interpretKeyEvents:[NSArray arrayWithObject:e]]; + + [self resetLastInputRect]; +} + +- (void)flagsChanged:(NSEvent*)e +{ + static NSEventModifierFlags omod; + NSEventModifierFlags m; + uint b; + + LOG(@"flagsChanged"); + m = [e modifierFlags]; + + b = [NSEvent pressedMouseButtons]; + b = (b&~6) | (b&4)>>1 | (b&2)<<1; + if(b){ + if(m & ~omod & NSEventModifierFlagControl) + b |= 1; + if(m & ~omod & NSEventModifierFlagOption) + b |= 2; + if(m & ~omod & NSEventModifierFlagCommand) + b |= 4; + [self sendmouse:b]; + }else if(m & ~omod & NSEventModifierFlagOption) + keystroke(Kalt); + + omod = m; +} + +- (void)magnifyWithEvent:(NSEvent*)e +{ + if(fabs([e magnification]) > 0.02) + [[self window] toggleFullScreen:nil]; +} + +- (void)touchesBeganWithEvent:(NSEvent*)e +{ + _tapping = YES; + _tapFingers = [e touchesMatchingPhase:NSTouchPhaseTouching inView:nil].count; + _tapTime = msec(); +} +- (void)touchesMovedWithEvent:(NSEvent*)e +{ + _tapping = NO; +} +- (void)touchesEndedWithEvent:(NSEvent*)e +{ + if(_tapping + && [e touchesMatchingPhase:NSTouchPhaseTouching inView:nil].count == 0 + && msec() - _tapTime < 250){ + switch(_tapFingers){ + case 3: + [self sendmouse:2]; + [self sendmouse:0]; + break; + case 4: + [self sendmouse:2]; + [self sendmouse:1]; + [self sendmouse:0]; + break; + } + _tapping = NO; + } +} +- (void)touchesCancelledWithEvent:(NSEvent*)e +{ + _tapping = NO; +} + +- (void)getmouse:(NSEvent *)e +{ + NSUInteger b; + NSEventModifierFlags m; + + b = [NSEvent pressedMouseButtons]; + b = b&~6 | (b&4)>>1 | (b&2)<<1; + b = mouseswap(b); + + if(b == 1){ + m = [e modifierFlags]; + if(m & NSEventModifierFlagOption){ + abortcompose(); + b = 2; + }else + if(m & NSEventModifierFlagCommand) + b = 4; + } + [self sendmouse:b]; +} + +- (void)sendmouse:(NSUInteger)b +{ + NSPoint p; + + p = [self.window convertPointToBacking: + [self.window mouseLocationOutsideOfEventStream]]; + p.y = Dy(mouserect) - p.y; + // LOG(@"(%g, %g) <- sendmouse(%d)", p.x, p.y, (uint)b); + mousetrack(p.x, p.y, b, msec()); + if(b && _lastInputRect.size.width && _lastInputRect.size.height) + [self resetLastInputRect]; +} + +- (void)resetCursorRects { + [super resetCursorRects]; + [self addCursorRect:self.bounds cursor:currentCursor]; +} + +- (void)viewDidEndLiveResize +{ + [super viewDidEndLiveResize]; + resizeimg(); +} + +- (void)viewDidChangeBackingProperties +{ + [super viewDidChangeBackingProperties]; + resizeimg(); +} + +// conforms to protocol NSTextInputClient +- (BOOL)hasMarkedText +{ + LOG(@"hasMarkedText"); + return _markedRange.location != NSNotFound; +} +- (NSRange)markedRange +{ + LOG(@"markedRange"); + return _markedRange; +} +- (NSRange)selectedRange +{ + LOG(@"selectedRange"); + return _selectedRange; +} +- (void)setMarkedText:(id)string + selectedRange:(NSRange)sRange + replacementRange:(NSRange)rRange +{ + NSString *str; + + LOG(@"setMarkedText: %@ (%ld, %ld) (%ld, %ld)", string, + sRange.location, sRange.length, + rRange.location, rRange.length); + + [self clearInput]; + + if([string isKindOfClass:[NSAttributedString class]]) + str = [string string]; + else + str = string; + + if(rRange.location == NSNotFound){ + if(_markedRange.location != NSNotFound){ + rRange = _markedRange; + }else{ + rRange = _selectedRange; + } + } + + if(str.length == 0){ + [_tmpText deleteCharactersInRange:rRange]; + [self unmarkText]; + }else{ + _markedRange = NSMakeRange(rRange.location, str.length); + [_tmpText replaceCharactersInRange:rRange withString:str]; + } + _selectedRange.location = rRange.location + sRange.location; + _selectedRange.length = sRange.length; + + if(_tmpText.length){ + uint i; + LOG(@"text length %ld", _tmpText.length); + for(i = 0; i <= _tmpText.length; ++i){ + if(i == _markedRange.location) + keystroke('['); + if(_selectedRange.length){ + if(i == _selectedRange.location) + keystroke('{'); + if(i == NSMaxRange(_selectedRange)) + keystroke('}'); + } + if(i == NSMaxRange(_markedRange)) + keystroke(']'); + if(i < _tmpText.length) + keystroke([_tmpText characterAtIndex:i]); + } + int l; + l = 1 + _tmpText.length - NSMaxRange(_selectedRange) + + (_selectedRange.length > 0); + LOG(@"move left %d", l); + for(i = 0; i < l; ++i) + keystroke(Kleft); + } + + LOG(@"text: \"%@\" (%ld,%ld) (%ld,%ld)", _tmpText, + _markedRange.location, _markedRange.length, + _selectedRange.location, _selectedRange.length); +} +- (void)unmarkText +{ + //NSUInteger i; + NSUInteger len; + + LOG(@"unmarkText"); + len = [_tmpText length]; + //for(i = 0; i < len; ++i) + // keystroke([_tmpText characterAtIndex:i]); + [_tmpText deleteCharactersInRange:NSMakeRange(0, len)]; + _markedRange = NSMakeRange(NSNotFound, 0); + _selectedRange = NSMakeRange(0, 0); +} +- (NSArray *)validAttributesForMarkedText +{ + LOG(@"validAttributesForMarkedText"); + return @[]; +} +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)r + actualRange:(NSRangePointer)actualRange +{ + NSRange sr; + NSAttributedString *s; + + LOG(@"attributedSubstringForProposedRange: (%ld, %ld) (%ld, %ld)", + r.location, r.length, actualRange->location, actualRange->length); + sr = NSMakeRange(0, [_tmpText length]); + sr = NSIntersectionRange(sr, r); + if(actualRange) + *actualRange = sr; + LOG(@"use range: %ld, %ld", sr.location, sr.length); + if(sr.length) + s = [[NSAttributedString alloc] + initWithString:[_tmpText substringWithRange:sr]]; + LOG(@" return %@", s); + return s; +} +- (void)insertText:(id)s + replacementRange:(NSRange)r +{ + NSUInteger i; + NSUInteger len; + + LOG(@"insertText: %@ replacementRange: %ld, %ld", s, r.location, r.length); + + [self clearInput]; + + len = [s length]; + for(i = 0; i < len; ++i) + keystroke([s characterAtIndex:i]); + [_tmpText deleteCharactersInRange:NSMakeRange(0, _tmpText.length)]; + _markedRange = NSMakeRange(NSNotFound, 0); + _selectedRange = NSMakeRange(0, 0); +} +- (NSUInteger)characterIndexForPoint:(NSPoint)point +{ + LOG(@"characterIndexForPoint: %g, %g", point.x, point.y); + return 0; +} +- (NSRect)firstRectForCharacterRange:(NSRange)r + actualRange:(NSRangePointer)actualRange +{ + LOG(@"firstRectForCharacterRange: (%ld, %ld) (%ld, %ld)", + r.location, r.length, actualRange->location, actualRange->length); + if(actualRange) + *actualRange = r; + return [[self window] convertRectToScreen:_lastInputRect]; +} +- (void)doCommandBySelector:(SEL)s +{ + NSEvent *e; + NSEventModifierFlags m; + uint c, k; + + LOG(@"doCommandBySelector (%@)", NSStringFromSelector(s)); + + e = [NSApp currentEvent]; + c = [[e characters] characterAtIndex:0]; + k = keycvt(c); + LOG(@"keyDown: character0: 0x%x -> 0x%x", c, k); + m = [e modifierFlags]; + + if(m & NSEventModifierFlagCommand){ + if((m & NSEventModifierFlagShift) && 'a' <= k && k <= 'z') + k += 'A' - 'a'; + if(' '<=k && k<='~') + k += Kcmd; + } + if(k>0) + keystroke(k); +} + +// Helper for managing input rect approximately +- (void)resetLastInputRect +{ + LOG(@"resetLastInputRect"); + _lastInputRect.origin.x = 0.0; + _lastInputRect.origin.y = 0.0; + _lastInputRect.size.width = 0.0; + _lastInputRect.size.height = 0.0; +} + +- (void)enlargeLastInputRect:(NSRect)r +{ + r.origin.y = [self bounds].size.height - r.origin.y - r.size.height; + _lastInputRect = NSUnionRect(_lastInputRect, r); + LOG(@"update last input rect (%g, %g, %g, %g)", + _lastInputRect.origin.x, _lastInputRect.origin.y, + _lastInputRect.size.width, _lastInputRect.size.height); +} + +- (void)clearInput +{ + if(_tmpText.length){ + uint i; + int l; + l = 1 + _tmpText.length - NSMaxRange(_selectedRange) + + (_selectedRange.length > 0); + LOG(@"move right %d", l); + for(i = 0; i < l; ++i) + keystroke(Kright); + l = _tmpText.length+2+2*(_selectedRange.length > 0); + LOG(@"backspace %d", l); + for(uint i = 0; i < l; ++i) + keystroke(Kbs); + } +} + +@end + +@implementation DrawLayer + +- (void)display +{ + id cbuf; + id cmd; + + LOG(@"display"); + + cbuf = [commandQueue commandBuffer]; + + LOG(@"display query drawable"); + +@autoreleasepool{ + id drawable; + + drawable = [layer nextDrawable]; + if(!drawable){ + LOG(@"display couldn't get drawable"); + [self setNeedsDisplay]; + return; + } + + LOG(@"display got drawable"); + + renderPass.colorAttachments[0].texture = drawable.texture; + + cmd = [cbuf renderCommandEncoderWithDescriptor:renderPass]; + [cmd setRenderPipelineState:pipelineState]; + [cmd setFragmentTexture:texture atIndex:0]; + [cmd drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; + [cmd endEncoding]; + + [cbuf presentDrawable:drawable]; + drawable = nil; +} + [cbuf addCompletedHandler:^(id cmdBuff){ + if(cmdBuff.error){ + NSLog(@"command buffer finished with error: %@", + cmdBuff.error.localizedDescription); + }else + LOG(@"command buffer finishes present drawable"); + }]; + [cbuf commit]; + + LOG(@"display commit"); +} + +@end + +static uint +msec(void) +{ + return nsec()/1000000; +} + +static uint +keycvt(uint code) +{ + switch(code){ + case '\r': return '\n'; + case '\b': return 127; + case 127: return '\b'; + case NSUpArrowFunctionKey: return Kup; + case NSDownArrowFunctionKey: return Kdown; + case NSLeftArrowFunctionKey: return Kleft; + case NSRightArrowFunctionKey: return Kright; + case NSInsertFunctionKey: return Kins; + case NSDeleteFunctionKey: return Kdel; + case NSHomeFunctionKey: return Khome; + case NSEndFunctionKey: return Kend; + case NSPageUpFunctionKey: return Kpgup; + case NSPageDownFunctionKey: return Kpgdown; + case NSF1FunctionKey: return KF|1; + case NSF2FunctionKey: return KF|2; + case NSF3FunctionKey: return KF|3; + case NSF4FunctionKey: return KF|4; + case NSF5FunctionKey: return KF|5; + case NSF6FunctionKey: return KF|6; + case NSF7FunctionKey: return KF|7; + case NSF8FunctionKey: return KF|8; + case NSF9FunctionKey: return KF|9; + case NSF10FunctionKey: return KF|10; + case NSF11FunctionKey: return KF|11; + case NSF12FunctionKey: return KF|12; + case NSBeginFunctionKey: + case NSPrintScreenFunctionKey: + case NSScrollLockFunctionKey: + case NSF13FunctionKey: + case NSF14FunctionKey: + case NSF15FunctionKey: + case NSF16FunctionKey: + case NSF17FunctionKey: + case NSF18FunctionKey: + case NSF19FunctionKey: + case NSF20FunctionKey: + case NSF21FunctionKey: + case NSF22FunctionKey: + case NSF23FunctionKey: + case NSF24FunctionKey: + case NSF25FunctionKey: + case NSF26FunctionKey: + case NSF27FunctionKey: + case NSF28FunctionKey: + case NSF29FunctionKey: + case NSF30FunctionKey: + case NSF31FunctionKey: + case NSF32FunctionKey: + case NSF33FunctionKey: + case NSF34FunctionKey: + case NSF35FunctionKey: + case NSPauseFunctionKey: + case NSSysReqFunctionKey: + case NSBreakFunctionKey: + case NSResetFunctionKey: + case NSStopFunctionKey: + case NSMenuFunctionKey: + case NSUserFunctionKey: + case NSSystemFunctionKey: + case NSPrintFunctionKey: + case NSClearLineFunctionKey: + case NSClearDisplayFunctionKey: + case NSInsertLineFunctionKey: + case NSDeleteLineFunctionKey: + case NSInsertCharFunctionKey: + case NSDeleteCharFunctionKey: + case NSPrevFunctionKey: + case NSNextFunctionKey: + case NSSelectFunctionKey: + case NSExecuteFunctionKey: + case NSUndoFunctionKey: + case NSRedoFunctionKey: + case NSFindFunctionKey: + case NSHelpFunctionKey: + case NSModeSwitchFunctionKey: return 0; + default: return code; + } +} + +Memimage* +attachscreen(char *label, char *winsize) +{ + LOG(@"attachscreen(%s, %s)", label, winsize); + [AppDelegate + performSelectorOnMainThread:@selector(makewin:) + withObject:[NSValue valueWithPointer:winsize] + waitUntilDone:YES]; + kicklabel(label); + setcursor(nil); + mouseresized = 0; + return initimg(); +} + +static Memimage* +initimg(void) +{ +@autoreleasepool{ + CGFloat scale; + NSSize size; + MTLTextureDescriptor *textureDesc; + + size = [myContent convertSizeToBacking:[myContent bounds].size]; + mouserect = Rect(0, 0, size.width, size.height); + + LOG(@"initimg %.0f %.0f", size.width, size.height); + + img = allocmemimage(mouserect, XRGB32); + if(img == nil) + panic("allocmemimage: %r"); + if(img->data == nil) + panic("img->data == nil"); + + textureDesc = [MTLTextureDescriptor + texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm + width:size.width + height:size.height + mipmapped:NO]; + textureDesc.allowGPUOptimizedContents = YES; + textureDesc.usage = MTLTextureUsageShaderRead; + textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; + texture = [device newTextureWithDescriptor:textureDesc]; + + scale = [win backingScaleFactor]; + [layer setDrawableSize:size]; + [layer setContentsScale:scale]; + + // NOTE: This is not really the display DPI. + // On retina, scale is 2; otherwise it is 1. + // This formula gives us 220 for retina, 110 otherwise. + // That's not quite right but it's close to correct. + // https://en.wikipedia.org/wiki/Retina_display#Models + displaydpi = scale * 110; +} + LOG(@"initimg return"); + + return img; +} + +void +_flushmemscreen(Rectangle r) +{ + LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); + + @autoreleasepool{ + [texture + replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) + mipmapLevel:0 + withBytes:byteaddr(img, Pt(r.min.x, r.min.y)) + bytesPerRow:img->width*sizeof(u32int)]; + [AppDelegate + performSelectorOnMainThread:@selector(callsetNeedsDisplayInRect:) + withObject:[NSValue valueWithRect:NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r))] + waitUntilDone:NO]; + } +} + +void +setmouse(Point p) +{ + @autoreleasepool{ + NSPoint q; + + LOG(@"setmouse(%d,%d)", p.x, p.y); + q = [win convertPointFromBacking:NSMakePoint(p.x, p.y)]; + LOG(@"(%g, %g) <- fromBacking", q.x, q.y); + q = [myContent convertPoint:q toView:nil]; + LOG(@"(%g, %g) <- toWindow", q.x, q.y); + q = [win convertPointToScreen:q]; + LOG(@"(%g, %g) <- toScreen", q.x, q.y); + // Quartz has the origin of the "global display + // coordinate space" at the top left of the primary + // screen with y increasing downward, while Cocoa has + // the origin at the bottom left of the primary screen + // with y increasing upward. We flip the coordinate + // with a negative sign and shift upward by the height + // of the primary screen. + q.y = NSScreen.screens[0].frame.size.height - q.y; + LOG(@"(%g, %g) <- setmouse", q.x, q.y); + CGWarpMouseCursorPosition(NSPointToCGPoint(q)); + CGAssociateMouseAndMouseCursorPosition(true); + } +} + +char* +getsnarf(void) +{ + NSPasteboard *pb; + NSString *s; + + @autoreleasepool{ + pb = [NSPasteboard generalPasteboard]; + + qlock(&snarfl); + s = [pb stringForType:NSPasteboardTypeString]; + qunlock(&snarfl); + + if(s) + return strdup((char *)[s UTF8String]); + else + return nil; + } +} + +void +putsnarf(char *s) +{ + NSArray *t; + NSPasteboard *pb; + NSString *str; + + if(strlen(s) >= SnarfSize) + return; + + @autoreleasepool{ + t = [NSArray arrayWithObject:NSPasteboardTypeString]; + pb = [NSPasteboard generalPasteboard]; + str = [[NSString alloc] initWithUTF8String:s]; + + qlock(&snarfl); + [pb declareTypes:t owner:nil]; + [pb setString:str forType:NSPasteboardTypeString]; + qunlock(&snarfl); + } +} + +void +kicklabel(char *label) +{ + NSString *s; + + LOG(@"kicklabel(%s)", label); + if(label == nil) + return; + + @autoreleasepool{ + s = [[NSString alloc] initWithUTF8String:label]; + [AppDelegate + performSelectorOnMainThread:@selector(callkicklabel:) + withObject:s + waitUntilDone:NO]; + } +} + +void +setcursor(Cursor *c) +{ + [AppDelegate + performSelectorOnMainThread:@selector(callsetcursor:) + withObject:[NSValue valueWithPointer:c] + waitUntilDone:YES]; +} + +void +topwin(void) +{ + [win + performSelectorOnMainThread: + @selector(makeKeyAndOrderFront:) + withObject:nil + waitUntilDone:YES]; + + [NSApp activateIgnoringOtherApps:YES]; +} + +void +resizeimg(void) +{ + zlock(); + _drawreplacescreenimage(initimg()); + + mouseresized = 1; + zunlock(); + [myContent sendmouse:0]; +} + +void +resizewindow(Rectangle r) +{ + LOG(@"resizewindow %d %d %d %d", r.min.x, r.min.y, Dx(r), Dy(r)); + dispatch_async(dispatch_get_main_queue(), ^(void){ + NSSize s; + + s = [myContent convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; + [win setContentSize:s]; + resizeimg(); + }); +} + +static void +setprocname(const char *s) +{ + CFStringRef process_name; + + process_name = CFStringCreateWithBytes(nil, (uchar*)s, strlen(s), kCFStringEncodingUTF8, false); + + // Adapted from Chrome's mac_util.mm. + // http://src.chromium.org/viewvc/chrome/trunk/src/base/mac/mac_util.mm + // + // Copyright (c) 2012 The Chromium Authors. All rights reserved. + // + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions are + // met: + // + // * Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // * Redistributions in binary form must reproduce the above + // copyright notice, this list of conditions and the following disclaimer + // in the documentation and/or other materials provided with the + // distribution. + // * Neither the name of Google Inc. nor the names of its + // contributors may be used to endorse or promote products derived from + // this software without specific prior written permission. + // + // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + // Warning: here be dragons! This is SPI reverse-engineered from WebKit's + // plugin host, and could break at any time (although realistically it's only + // likely to break in a new major release). + // When 10.7 is available, check that this still works, and update this + // comment for 10.8. + + // Private CFType used in these LaunchServices calls. + typedef CFTypeRef PrivateLSASN; + typedef PrivateLSASN (*LSGetCurrentApplicationASNType)(); + typedef OSStatus (*LSSetApplicationInformationItemType)(int, PrivateLSASN, + CFStringRef, + CFStringRef, + CFDictionaryRef*); + + static LSGetCurrentApplicationASNType ls_get_current_application_asn_func = + NULL; + static LSSetApplicationInformationItemType + ls_set_application_information_item_func = NULL; + static CFStringRef ls_display_name_key = NULL; + + static bool did_symbol_lookup = false; + if (!did_symbol_lookup) { + did_symbol_lookup = true; + CFBundleRef launch_services_bundle = + CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices")); + if (!launch_services_bundle) { + fprint(2, "Failed to look up LaunchServices bundle\n"); + return; + } + + ls_get_current_application_asn_func = + (LSGetCurrentApplicationASNType)( + CFBundleGetFunctionPointerForName( + launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN"))); + if (!ls_get_current_application_asn_func) + fprint(2, "Could not find _LSGetCurrentApplicationASN\n"); + + ls_set_application_information_item_func = + (LSSetApplicationInformationItemType)( + CFBundleGetFunctionPointerForName( + launch_services_bundle, + CFSTR("_LSSetApplicationInformationItem"))); + if (!ls_set_application_information_item_func) + fprint(2, "Could not find _LSSetApplicationInformationItem\n"); + + CFStringRef* key_pointer = (CFStringRef*)( + CFBundleGetDataPointerForName(launch_services_bundle, + CFSTR("_kLSDisplayNameKey"))); + ls_display_name_key = key_pointer ? *key_pointer : NULL; + if (!ls_display_name_key) + fprint(2, "Could not find _kLSDisplayNameKey\n"); + + // Internally, this call relies on the Mach ports that are started up by the + // Carbon Process Manager. In debug builds this usually happens due to how + // the logging layers are started up; but in release, it isn't started in as + // much of a defined order. So if the symbols had to be loaded, go ahead + // and force a call to make sure the manager has been initialized and hence + // the ports are opened. + ProcessSerialNumber psn; + GetCurrentProcess(&psn); + } + if (!ls_get_current_application_asn_func || + !ls_set_application_information_item_func || + !ls_display_name_key) { + return; + } + + PrivateLSASN asn = ls_get_current_application_asn_func(); + // Constant used by WebKit; what exactly it means is unknown. + const int magic_session_constant = -2; + OSErr err = + ls_set_application_information_item_func(magic_session_constant, asn, + ls_display_name_key, + process_name, + NULL /* optional out param */); + if(err != noErr) + fprint(2, "Call to set process name failed\n"); +} diff --git a/src/cmd/devdraw/cocoa-screen.h b/src/cmd/devdraw/cocoa-screen.h index 3c4c94c5c..7b41c34b4 100644 --- a/src/cmd/devdraw/cocoa-screen.h +++ b/src/cmd/devdraw/cocoa-screen.h @@ -16,5 +16,9 @@ void servep9p(void); void zlock(void); void zunlock(void); +void resizeimg(void); + Rectangle mouserect; -int mouseresized; + +int mouseresized; +void resizewindow(Rectangle); diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 197fd512a..6f9449adc 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -21,7 +21,7 @@ typedef struct Tagbuf Tagbuf; struct Kbdbuf { - Rune r[32]; + Rune r[256]; int ri; int wi; int stall; @@ -29,7 +29,7 @@ struct Kbdbuf struct Mousebuf { - Mouse m[32]; + Mouse m[256]; Mouse last; int ri; int wi; @@ -38,7 +38,7 @@ struct Mousebuf struct Tagbuf { - int t[32]; + int t[256]; int ri; int wi; }; @@ -97,7 +97,7 @@ servep9p(void) /* pick off messages one by one */ if(convM2W(mbuf, nn+4, &m) <= 0) sysfatal("cannot convert message"); - if(trace) fprint(2, "<- %W\n", &m); + if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m); runmsg(&m); } } @@ -191,6 +191,7 @@ runmsg(Wsysmsg *m) break; case Trddraw: + zlock(); n = m->count; if(n > sizeof buf) n = sizeof buf; @@ -202,13 +203,16 @@ runmsg(Wsysmsg *m) m->data = buf; replymsg(m); } + zunlock(); break; case Twrdraw: + zlock(); if(_drawmsgwrite(m->data, m->count) < 0) replyerror(m); else replymsg(m); + zunlock(); break; case Ttop: @@ -217,7 +221,9 @@ runmsg(Wsysmsg *m) break; case Tresize: - // _xresizewindow(m->rect); +#if OSX_VERSION >= 101400 + resizewindow(m->rect); +#endif replymsg(m); break; } @@ -238,7 +244,7 @@ replymsg(Wsysmsg *m) if(m->type%2 == 0) m->type++; - if(trace) fprint(2, "-> %W\n", m); + if(trace) fprint(2, "%ud [%d] -> %W\n", nsec()/1000000, threadid(), m); /* copy to output buffer */ n = sizeW2M(m); @@ -293,11 +299,11 @@ matchmouse(void) mousetags.ri = 0; m.mouse = mouse.m[mouse.ri]; m.resized = mouseresized; + mouseresized = 0; /* if(m.resized) fprint(2, "sending resize\n"); */ - mouseresized = 0; mouse.ri++; if(mouse.ri == nelem(mouse.m)) mouse.ri = 0; @@ -367,8 +373,6 @@ abortcompose(void) keystroke(Kalt); } -void resizeimg(void); - void keystroke(int c) { diff --git a/src/cmd/devdraw/cocoa-thread.c b/src/cmd/devdraw/cocoa-thread.c index c9b280f7c..92b92d2cf 100644 --- a/src/cmd/devdraw/cocoa-thread.c +++ b/src/cmd/devdraw/cocoa-thread.c @@ -25,4 +25,11 @@ qunlock(QLock *q) { pthread_mutex_unlock(&q->m); } + +int +threadid(void) +{ + return pthread_mach_thread_np(pthread_self()); +} + #endif diff --git a/src/cmd/devdraw/cocoa-thread.h b/src/cmd/devdraw/cocoa-thread.h index c2f3e9821..d5793f0a7 100644 --- a/src/cmd/devdraw/cocoa-thread.h +++ b/src/cmd/devdraw/cocoa-thread.h @@ -30,4 +30,5 @@ void qlock(QLock*); void qunlock(QLock*); + int threadid(void); #endif diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index cad244ac5..2e40087e0 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -35,6 +35,9 @@ latin1.h: $PLAN9/lib/keyboard $O.mklatinkbd $O.macargv: $MACARGV $LD -o $target $prereq +cocoa-screen-metal-objc.$O: cocoa-screen-metal.m + $CC $CFLAGS $OBJCFLAGS -o $target cocoa-screen-metal.m + %-objc.$O: %.m $CC $CFLAGS -o $target $stem.m diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index 9c422261a..98d6799d9 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -60,7 +60,12 @@ elif [ $WSYSTYPE = osx ]; then echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = osx-cocoa ]; then - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o' + if sw_vers|awk '/ProductVersion/{split($2,a,".");exit(a[2]<14)}' >/dev/null; then # 0 is true in sh. + echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-metal-objc.o cocoa-srv.o cocoa-thread.o' + else + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o' + fi echo 'MACARGV=macargv-objc.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' From 8581c2b56763d7787604c8c833d2bd78bdc6a466 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:22:59 -0500 Subject: [PATCH 042/323] libdraw: add Cursor2, a 32x32 high-res cursor Also add setcursor2, esetcursor2, and draw protocol encoding. Calls to the old setcursor, esetcursor create a 32x32 by pixel doubling when needed. --- include/cursor.h | 10 ++++++++++ include/draw.h | 3 ++- include/drawfcall.h | 6 ++++++ include/event.h | 2 ++ include/mouse.h | 2 ++ src/libdraw/cursor.c | 32 ++++++++++++++++++++++++++++++++ src/libdraw/drawclient.c | 7 ++++++- src/libdraw/drawfcall.c | 14 +++++++++++--- src/libdraw/event.c | 8 +++++++- src/libdraw/mkfile | 1 + src/libdraw/mouse.c | 8 +++++++- 11 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 src/libdraw/cursor.c diff --git a/include/cursor.h b/include/cursor.h index d53baf81d..e39d2ea58 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -12,6 +12,16 @@ struct Cursor uchar set[2*16]; }; +typedef struct Cursor2 Cursor2; +struct Cursor2 +{ + Point offset; + uchar clr[4*32]; + uchar set[4*32]; +}; + +void scalecursor(Cursor2*, Cursor*); + #if defined(__cplusplus) } #endif diff --git a/include/draw.h b/include/draw.h index 3a012959f..2f283bdf1 100644 --- a/include/draw.h +++ b/include/draw.h @@ -568,9 +568,10 @@ int mousescrollsize(int); */ struct Mouse; struct Cursor; +struct Cursor2; int _displaybouncemouse(Display *d, struct Mouse *m); int _displayconnect(Display *d); -int _displaycursor(Display *d, struct Cursor *c); +int _displaycursor(Display *d, struct Cursor *c, struct Cursor2 *c2); int _displayinit(Display *d, char *label, char *winsize); int _displaylabel(Display *d, char *label); int _displaymoveto(Display *d, Point p); diff --git a/include/drawfcall.h b/include/drawfcall.h index fb339919d..acab98c5e 100644 --- a/include/drawfcall.h +++ b/include/drawfcall.h @@ -13,6 +13,9 @@ tag[1] Rmoveto tag[1] Tcursor cursor[] tag[1] Rcursor +tag[1] Tcursor2 cursor[] +tag[1] Rcursor2 + tag[1] Tbouncemouse x[4] y[4] button[4] tag[1] Rbouncemouse @@ -89,6 +92,8 @@ enum { Rtop, Tresize = 26, Rresize, + Tcursor2 = 28, + Rcursor2, Tmax, }; @@ -104,6 +109,7 @@ struct Wsysmsg Mouse mouse; int resized; Cursor cursor; + Cursor2 cursor2; int arrowcursor; Rune rune; char *winsize; diff --git a/include/event.h b/include/event.h index 09cb5c78c..e66bf1173 100644 --- a/include/event.h +++ b/include/event.h @@ -61,7 +61,9 @@ extern int emenuhit(int, Mouse*, Menu*); extern int eatomouse(Mouse*, char*, int); extern Rectangle getrect(int, Mouse*); struct Cursor; +struct Cursor2; extern void esetcursor(struct Cursor*); +extern void esetcursor2(struct Cursor*, struct Cursor2*); extern void emoveto(Point); extern Rectangle egetrect(int, Mouse*); extern void edrawgetrect(Rectangle, int); diff --git a/include/mouse.h b/include/mouse.h index 3d5c975fe..c46d51e92 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -38,7 +38,9 @@ extern void moveto(Mousectl*, Point); extern int readmouse(Mousectl*); extern void closemouse(Mousectl*); struct Cursor; +struct Cursor2; extern void setcursor(Mousectl*, struct Cursor*); +extern void setcursor2(Mousectl*, struct Cursor*, struct Cursor2*); extern void drawgetrect(Rectangle, int); extern Rectangle getrect(int, Mousectl*); extern int menuhit(int, Mousectl*, Menu*, Screen*); diff --git a/src/libdraw/cursor.c b/src/libdraw/cursor.c new file mode 100644 index 000000000..58f447b13 --- /dev/null +++ b/src/libdraw/cursor.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +static uint8 expand[16] = { + 0x00, 0x03, 0x0c, 0x0f, + 0x30, 0x33, 0x3c, 0x3f, + 0xc0, 0xc3, 0xcc, 0xcf, + 0xf0, 0xf3, 0xfc, 0xff, +}; + +void +scalecursor(Cursor2 *c2, Cursor *c) +{ + int y; + + c2->offset.x = 2*c->offset.x; + c2->offset.y = 2*c->offset.y; + memset(c2->clr, 0, sizeof c2->clr); + memset(c2->set, 0, sizeof c2->set); + for(y = 0; y < 16; y++) { + c2->clr[8*y] = c2->clr[8*y+4] = expand[c->clr[2*y]>>4]; + c2->set[8*y] = c2->set[8*y+4] = expand[c->set[2*y]>>4]; + c2->clr[8*y+1] = c2->clr[8*y+5] = expand[c->clr[2*y]&15]; + c2->set[8*y+1] = c2->set[8*y+5] = expand[c->set[2*y]&15]; + c2->clr[8*y+2] = c2->clr[8*y+6] = expand[c->clr[2*y+1]>>4]; + c2->set[8*y+2] = c2->set[8*y+6] = expand[c->set[2*y+1]>>4]; + c2->clr[8*y+3] = c2->clr[8*y+7] = expand[c->clr[2*y+1]&15]; + c2->set[8*y+3] = c2->set[8*y+7] = expand[c->set[2*y+1]&15]; + } +} diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index f0c094300..de20d3a3b 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -292,17 +292,22 @@ _displaymoveto(Display *d, Point p) } int -_displaycursor(Display *d, Cursor *c) +_displaycursor(Display *d, Cursor *c, Cursor2 *c2) { Wsysmsg tx, rx; tx.type = Tcursor; if(c == nil){ memset(&tx.cursor, 0, sizeof tx.cursor); + memset(&tx.cursor2, 0, sizeof tx.cursor2); tx.arrowcursor = 1; }else{ tx.arrowcursor = 0; tx.cursor = *c; + if(c2 != nil) + tx.cursor2 = *c2; + else + scalecursor(&tx.cursor2, c); } return displayrpc(d, &tx, &rx, nil); } diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index e2d3c642f..e36413b65 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -64,7 +64,7 @@ sizeW2M(Wsysmsg *m) case Tmoveto: return 4+1+1+4+4; case Tcursor: - return 4+1+1+4+4+2*16+2*16+1; + return 4+1+1+4+4+2*16+2*16+4+4+4*32+4*32+1; case Rerror: return 4+1+1+_stringsize(m->error); case Rrdkbd: @@ -141,7 +141,11 @@ convW2M(Wsysmsg *m, uchar *p, uint n) PUT(p+10, m->cursor.offset.y); memmove(p+14, m->cursor.clr, sizeof m->cursor.clr); memmove(p+46, m->cursor.set, sizeof m->cursor.set); - p[78] = m->arrowcursor; + PUT(p+78, m->cursor2.offset.x); + PUT(p+82, m->cursor2.offset.y); + memmove(p+86, m->cursor2.clr, sizeof m->cursor2.clr); + memmove(p+214, m->cursor2.set, sizeof m->cursor2.set); + p[342] = m->arrowcursor; break; case Rrdkbd: PUT2(p+6, m->rune); @@ -229,7 +233,11 @@ convM2W(uchar *p, uint n, Wsysmsg *m) GET(p+10, m->cursor.offset.y); memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); memmove(m->cursor.set, p+46, sizeof m->cursor.set); - m->arrowcursor = p[78]; + GET(p+78, m->cursor2.offset.x); + GET(p+82, m->cursor2.offset.y); + memmove(m->cursor2.clr, p+86, sizeof m->cursor2.clr); + memmove(m->cursor2.set, p+214, sizeof m->cursor2.set); + m->arrowcursor = p[342]; break; case Rrdkbd: GET2(p+6, m->rune); diff --git a/src/libdraw/event.c b/src/libdraw/event.c index f113d1f09..b369c0200 100644 --- a/src/libdraw/event.c +++ b/src/libdraw/event.c @@ -416,7 +416,13 @@ emoveto(Point pt) void esetcursor(Cursor *c) { - _displaycursor(display, c); + _displaycursor(display, c, nil); +} + +void +esetcursor2(Cursor *c, Cursor2 *c2) +{ + _displaycursor(display, c, c2); } int diff --git a/src/libdraw/mkfile b/src/libdraw/mkfile index ddb0e8332..003bf3cec 100644 --- a/src/libdraw/mkfile +++ b/src/libdraw/mkfile @@ -14,6 +14,7 @@ OFILES=\ cloadimage.$O\ computil.$O\ creadimage.$O\ + cursor.$O\ debug.$O\ defont.$O\ draw.$O\ diff --git a/src/libdraw/mouse.c b/src/libdraw/mouse.c index ad1a069b1..fc486be43 100644 --- a/src/libdraw/mouse.c +++ b/src/libdraw/mouse.c @@ -85,6 +85,12 @@ initmouse(char *file, Image *i) void setcursor(Mousectl *mc, Cursor *c) { - _displaycursor(mc->display, c); + _displaycursor(mc->display, c, nil); +} + +void +setcursor2(Mousectl *mc, Cursor *c, Cursor2 *c2) +{ + _displaycursor(mc->display, c, c2); } From be0a15c47b75dc73a5c389cca125692f0cfdf726 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:24:38 -0500 Subject: [PATCH 043/323] tweak: add support for Cursor2 --- src/cmd/draw/tweak.c | 108 +++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 30 deletions(-) diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c index 9d7cd6019..89fdef32a 100644 --- a/src/cmd/draw/tweak.c +++ b/src/cmd/draw/tweak.c @@ -30,7 +30,7 @@ enum Up = 1, Down = 0, Mag = 4, - Maxmag = 10 + Maxmag = 20 }; enum @@ -161,7 +161,7 @@ Image *values[256]; Image *greyvalues[256]; uchar data[8192]; -Thing* tget(char*); +Thing* tget(char*, int); void mesg(char*, ...); void drawthing(Thing*, int); void xselect(void); @@ -184,6 +184,7 @@ main(volatile int argc, char **volatile argv) volatile int i; Event e; Thing *t; + Thing *nt; ARGBEGIN{ case 'W': @@ -209,9 +210,14 @@ main(volatile int argc, char **volatile argv) setjmp(err); for(; inext; + t->next = 0; drawthing(t, 1); + if(nt) + drawthing(nt, 1); + } flushimage(display, 1); } file = 0; @@ -382,6 +388,8 @@ stext(Thing *t, char *l0, char *l1) }else if(t->s) sprint(l1, "offset(hex): %ux n:%d height:%d ascent:%d", t->off, t->s->n, t->s->height, t->s->ascent); + else if(t->face == CURSOR) + sprint(l0+strlen(l0), " cursor:%d", Dx(t->b->r)); } void @@ -569,7 +577,7 @@ tohex(int c) } Thing* -tget(char *file) +tget(char *file, int extra) { int i, j, fd, face, x, y, c, chan; Image *b; @@ -577,8 +585,9 @@ tget(char *file) Thing *t; Dir *volatile d; jmp_buf oerr; - uchar buf[256]; + uchar buf[300]; char *data; + Rectangle r; buf[0] = '\0'; errstr((char*)buf, sizeof buf); /* flush pending error message */ @@ -628,17 +637,15 @@ tget(char *file) close(fd); goto Err; } - b = allocimage(display, Rect(0, 0, 16, 32), GREY1, 0, DNofill); - if(b == 0){ - mesg("image alloc failed file %s: %r", file); - free(data); - close(fd); - goto Err; - } i = 0; - for(x=0;x<64; ){ - if((c=data[i]) == '\0') - goto ill; + for(x=0;; ){ + if((c=data[i]) == '\0' || x > 256) { + if(x == 64 || x == 256) + goto HaveCursor; + mesg("ill-formed cursor file %s", file); + close(fd); + goto Err; + } if(c=='0' && data[i+1] == 'x'){ i += 2; continue; @@ -650,7 +657,19 @@ tget(char *file) } i++; } - loadimage(b, Rect(0, 0, 16, 32), buf, sizeof buf); + HaveCursor: + if(x == 64) + r = Rect(0, 0, 16, 32); + else + r = Rect(0, 0, 32, 64); + b = allocimage(display, r, GREY1, 0, DNofill); + if(b == 0){ + mesg("image alloc failed file %s: %r", file); + free(data); + close(fd); + goto Err; + } + loadimage(b, r, buf, sizeof buf); free(data); }else if(memcmp(buf, "0x", 2)==0){ /* @@ -752,7 +771,7 @@ tget(char *file) s = readsubfonti(display, file, fd, b, 0); } close(fd); - t = malloc(sizeof(Thing)); + t = mallocz(sizeof(Thing), 1); if(t == 0){ nomem: mesg("malloc failed: %r"); @@ -775,6 +794,40 @@ tget(char *file) t->c = -1; t->mag = 1; t->off = 0; + if(face == CURSOR && extra && Dx(t->b->r) == 16) { + // Make 32x32 cursor as second image. + Thing *nt; + Cursor c; + Cursor2 c2; + + nt = mallocz(sizeof(Thing), 1); + if(nt == 0) + goto nomem; + nt->name = strdup(""); + if(nt->name == 0) { + free(nt); + goto nomem; + } + b = allocimage(display, Rect(0, 0, 32, 64), GREY1, 0, DNofill); + if(b == nil) { + free(nt->name); + free(nt); + goto nomem; + } + memmove(c.clr, buf, 64); + scalecursor(&c2, &c); + memmove(buf, c2.clr, 256); + loadimage(b, b->r, buf, sizeof buf); + t->next = nt; + nt->b = b; + nt->s = 0; + nt->face = CURSOR; + nt->mod = 0; + nt->parent = 0; + nt->c = -1; + nt->mag = 1; + nt->off = 0; + } memmove(err, oerr, sizeof err); return t; } @@ -1637,18 +1690,13 @@ twrite(Thing *t) Bprint(&buf, "%.2x", data[i+j]); Bprint(&buf, ", "); } - if(t->face == CURSOR){ - switch(y){ - case 3: case 7: case 11: case 19: case 23: case 27: - Bprint(&buf, "\n "); - break; - case 15: + if(t->face == CURSOR) { + if(y == Dy(r)/2-1) Bprint(&buf, "},\n{"); - break; - case 31: + else if(y == Dy(r)-1) Bprint(&buf, "}\n"); - break; - } + else + Bprint(&buf, "\n\t"); }else Bprint(&buf, "\n"); } @@ -1759,7 +1807,7 @@ tread(Thing *t) if(t->parent) t = t->parent; - new = tget(t->name); + new = tget(t->name, 0); if(new == 0) return; nclosed = 0; @@ -2025,7 +2073,7 @@ menu(void) switch(sel){ case Mopen: if(type(buf, "file")){ - t = tget(buf); + t = tget(buf, 0); if(t) drawthing(t, 1); } From 7d43dde539378fb5730df6ce961f7916f495746e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:28:56 -0500 Subject: [PATCH 044/323] devdraw: add Cursor2 support on macOS 10.14 Mojave This replaces the pixel-art scaling algorithm used for upscaling before. The results were not crisp enough to serve as everyday cursors. --- src/cmd/devdraw/bigarrow.h | 70 ++++++++++++++++++++++++++++ src/cmd/devdraw/cocoa-screen-metal.m | 62 +++++++++++------------- src/cmd/devdraw/cocoa-screen.h | 2 +- src/cmd/devdraw/cocoa-screen.m | 10 +++- src/cmd/devdraw/cocoa-srv.c | 6 +-- src/cmd/devdraw/mkfile | 2 + src/cmd/devdraw/osx-screen.h | 2 +- src/cmd/devdraw/osx-srv.c | 4 +- 8 files changed, 113 insertions(+), 45 deletions(-) diff --git a/src/cmd/devdraw/bigarrow.h b/src/cmd/devdraw/bigarrow.h index 3b66c954e..1221ec8c1 100644 --- a/src/cmd/devdraw/bigarrow.h +++ b/src/cmd/devdraw/bigarrow.h @@ -11,3 +11,73 @@ Cursor bigarrow = { 0x61, 0xF0, 0x60, 0xE0, 0x40, 0x40, 0x00, 0x00, }, }; + +Cursor2 bigarrow2 = { + { -2, -2 }, + { 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x07, + 0xC0, 0x00, 0x00, 0x1E, + 0xC0, 0x00, 0x00, 0x3C, + 0xC0, 0x00, 0x00, 0xF0, + 0xC0, 0x00, 0x03, 0xE0, + 0xC0, 0x00, 0x0F, 0x80, + 0xC0, 0x00, 0x0E, 0x00, + 0xC0, 0x00, 0x07, 0x00, + 0xC0, 0x00, 0x03, 0x80, + 0xC0, 0x00, 0x01, 0xC0, + 0xC0, 0x00, 0x00, 0xE0, + 0xC0, 0x00, 0x00, 0x70, + 0xC0, 0x00, 0x00, 0x38, + 0xC0, 0x00, 0x00, 0x1C, + 0xC0, 0x00, 0x00, 0x0E, + 0xC0, 0x00, 0x00, 0x07, + 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0xC0, 0x00, 0x07, + 0xC0, 0xE0, 0x00, 0x0E, + 0xC1, 0xF0, 0x00, 0x1C, + 0xC1, 0xB8, 0x00, 0x38, + 0xC3, 0x9C, 0x00, 0x70, + 0xC3, 0x0E, 0x00, 0xE0, + 0xC7, 0x07, 0x01, 0xC0, + 0xCE, 0x03, 0x83, 0x80, + 0xCC, 0x01, 0xC7, 0x00, + 0xDC, 0x00, 0xEE, 0x00, + 0xF8, 0x00, 0x7C, 0x00, + 0xF0, 0x00, 0x38, 0x00, + }, + { 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xF8, + 0x3F, 0xFF, 0xFF, 0xE0, + 0x3F, 0xFF, 0xFF, 0xC0, + 0x3F, 0xFF, 0xFF, 0x00, + 0x3F, 0xFF, 0xFC, 0x00, + 0x3F, 0xFF, 0xF0, 0x00, + 0x3F, 0xFF, 0xF0, 0x00, + 0x3F, 0xFF, 0xF8, 0x00, + 0x3F, 0xFF, 0xFC, 0x00, + 0x3F, 0xFF, 0xFE, 0x00, + 0x3F, 0xFF, 0xFF, 0x00, + 0x3F, 0xFF, 0xFF, 0x80, + 0x3F, 0xFF, 0xFF, 0xC0, + 0x3F, 0xFF, 0xFF, 0xE0, + 0x3F, 0xFF, 0xFF, 0xF0, + 0x3F, 0xFF, 0xFF, 0xF8, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0x3F, 0xFF, 0xF8, + 0x3F, 0x1F, 0xFF, 0xF0, + 0x3E, 0x0F, 0xFF, 0xE0, + 0x3E, 0x07, 0xFF, 0xC0, + 0x3C, 0x03, 0xFF, 0x80, + 0x3C, 0x01, 0xFF, 0x00, + 0x38, 0x00, 0xFE, 0x00, + 0x30, 0x00, 0x7C, 0x00, + 0x30, 0x00, 0x38, 0x00, + 0x20, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + } +}; diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index c82ce0bc2..049d1c5cd 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -252,21 +252,30 @@ + (void)callsetNeedsDisplayInRect:(NSValue *)v [myContent enlargeLastInputRect:r]; } +typedef struct Cursors Cursors; +struct Cursors { + Cursor *c; + Cursor2 *c2; +}; + + (void)callsetcursor:(NSValue *)v { + Cursors *cs; Cursor *c; + Cursor2 *c2; NSBitmapImageRep *r, *r2; NSImage *i; NSPoint p; - uint b, x, y, a; uchar *plane[5], *plane2[5]; - uchar pu, pb, pl, pr, pc; // upper, bottom, left, right, center - uchar pul, pur, pbl, pbr; - uchar ful, fur, fbl, fbr; + int b; - c = [v pointerValue]; + cs = [v pointerValue]; + c = cs->c; if(!c) c = &bigarrow; + c2 = cs->c2; + if(!c2) + c2 = &bigarrow2; r = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil @@ -280,7 +289,7 @@ + (void)callsetcursor:(NSValue *)v bytesPerRow:2 bitsPerPixel:0]; [r getBitmapDataPlanes:plane]; - for(b=0; b<2*16; b++){ + for(b=0; bset); b++){ plane[0][b] = ~c->set[b] & c->clr[b]; plane[1][b] = c->set[b] | c->clr[b]; } @@ -297,33 +306,9 @@ + (void)callsetcursor:(NSValue *)v bytesPerRow:4 bitsPerPixel:0]; [r2 getBitmapDataPlanes:plane2]; - // https://en.wikipedia.org/wiki/Pixel-art_scaling_algorithms#EPX/Scale2×/AdvMAME2× - for(a=0; a<2; a++){ - for(y=0; y<16; y++){ - for(x=0; x<2; x++){ - pc = plane[a][x+2*y]; - pu = y==0 ? pc : plane[a][x+2*(y-1)]; - pb = y==15 ? pc : plane[a][x+2*(y+1)]; - pl = (pc>>1) | (x==0 ? pc&0x80 : (plane[a][x-1+2*y]&1)<<7); - pr = (pc<<1) | (x==1 ? pc&1 : (plane[a][x+1+2*y]&0x80)>>7); - ful = ~(pl^pu) & (pl^pb) & (pu^pr); - pul = (ful & pu) | (~ful & pc); - fur = ~(pu^pr) & (pu^pl) & (pr^pb); - pur = (fur & pr) | (~fur & pc); - fbl = ~(pb^pl) & (pb^pr) & (pl^pu); - pbl = (fbl & pl) | (~fbl & pc); - fbr = ~(pr^pb) & (pr^pu) & (pb^pl); - pbr = (fbr & pb) | (~fbr & pc); - plane2[a][2*x+4*2*y] = (pul&0x80) | ((pul&0x40)>>1) | ((pul&0x20)>>2) | ((pul&0x10)>>3) - | ((pur&0x80)>>1) | ((pur&0x40)>>2) | ((pur&0x20)>>3) | ((pur&0x10)>>4); - plane2[a][2*x+1+4*2*y] = ((pul&0x8)<<4) | ((pul&0x4)<<3) | ((pul&0x2)<<2) | ((pul&0x1)<<1) - | ((pur&0x8)<<3) | ((pur&0x4)<<2) | ((pur&0x2)<<1) | (pur&0x1); - plane2[a][2*x+4*(2*y+1)] = (pbl&0x80) | ((pbl&0x40)>>1) | ((pbl&0x20)>>2) | ((pbl&0x10)>>3) - | ((pbr&0x80)>>1) | ((pbr&0x40)>>2) | ((pbr&0x20)>>3) | ((pbr&0x10)>>4); - plane2[a][2*x+1+4*(2*y+1)] = ((pbl&0x8)<<4) | ((pbl&0x4)<<3) | ((pbl&0x2)<<2) | ((pbl&0x1)<<1) - | ((pbr&0x8)<<3) | ((pbr&0x4)<<2) | ((pbr&0x2)<<1) | (pbr&0x1); - } - } + for(b=0; bset); b++){ + plane2[0][b] = ~c2->set[b] & c2->clr[b]; + plane2[1][b] = c2->set[b] | c2->clr[b]; } // For checking out the cursor bitmap image @@ -943,7 +928,7 @@ - (void)display withObject:[NSValue valueWithPointer:winsize] waitUntilDone:YES]; kicklabel(label); - setcursor(nil); + setcursor(nil, nil); mouseresized = 0; return initimg(); } @@ -1099,11 +1084,16 @@ - (void)display } void -setcursor(Cursor *c) +setcursor(Cursor *c, Cursor2 *c2) { + Cursors cs; + + cs.c = c; + cs.c2 = c2; + [AppDelegate performSelectorOnMainThread:@selector(callsetcursor:) - withObject:[NSValue valueWithPointer:c] + withObject:[NSValue valueWithPointer:&cs] waitUntilDone:YES]; } diff --git a/src/cmd/devdraw/cocoa-screen.h b/src/cmd/devdraw/cocoa-screen.h index 7b41c34b4..b5e3c7010 100644 --- a/src/cmd/devdraw/cocoa-screen.h +++ b/src/cmd/devdraw/cocoa-screen.h @@ -2,7 +2,7 @@ Memimage *attachscreen(char*, char*); void setmouse(Point); -void setcursor(Cursor*); +void setcursor(Cursor*, Cursor2*); void setlabel(char*); char* getsnarf(void); void putsnarf(char*); diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index 16053eaa2..c2489a6c9 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -1410,8 +1410,10 @@ - (void)insertText:(id)arg{} /* to avoid a latency after some time */ } void -setcursor(Cursor *c) +setcursor(Cursor *c, Cursor2 *c2) { + USED(c2); + /* * No cursor change unless in main thread. */ @@ -1658,3 +1660,9 @@ typedef OSStatus (*LSSetApplicationInformationItemType)(int, PrivateLSASN, if(err != noErr) fprint(2, "Call to set process name failed\n"); } + +void +resizewindow(Rectangle r) +{ + USED(r); +} diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 6f9449adc..329dd71fa 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -163,9 +163,9 @@ runmsg(Wsysmsg *m) case Tcursor: if(m->arrowcursor) - setcursor(nil); + setcursor(nil, nil); else - setcursor(&m->cursor); + setcursor(&m->cursor, &m->cursor2); replymsg(m); break; @@ -221,9 +221,7 @@ runmsg(Wsysmsg *m) break; case Tresize: -#if OSX_VERSION >= 101400 resizewindow(m->rect); -#endif replymsg(m); break; } diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index 2e40087e0..7f0c2a203 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -3,6 +3,8 @@ TARG=devdraw +SHORTLIB=draw memdraw + WSYSOFILES=\ devdraw.$O\ latin1.$O\ diff --git a/src/cmd/devdraw/osx-screen.h b/src/cmd/devdraw/osx-screen.h index f50d8dfe7..d5ba3dd24 100644 --- a/src/cmd/devdraw/osx-screen.h +++ b/src/cmd/devdraw/osx-screen.h @@ -5,7 +5,7 @@ void zunlock(void); Memimage *attachscreen(char*, char*); void setmouse(Point); -void setcursor(Cursor*); +void setcursor(Cursor*, Cursor2*); void setlabel(char*); char* getsnarf(void); void putsnarf(char*); diff --git a/src/cmd/devdraw/osx-srv.c b/src/cmd/devdraw/osx-srv.c index 6cbb52359..d0a1c2d31 100644 --- a/src/cmd/devdraw/osx-srv.c +++ b/src/cmd/devdraw/osx-srv.c @@ -230,9 +230,9 @@ runmsg(Wsysmsg *m) case Tcursor: if(m->arrowcursor) - setcursor(nil); + setcursor(nil, nil); else - setcursor(&m->cursor); + setcursor(&m->cursor, &m->cursor2); replymsg(m); break; From fe92b4a0b1a8268238bce088cd081da9b802b465 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:34:32 -0500 Subject: [PATCH 045/323] INSTALL: set CC9 on macOS to use xcrun clang Using plain 'clang' does not work well for the new devdraw on macOS 10.14. But 'xcrun --sdk macosx clang' does work, for reasons no one understands. Hopefully this will be OK on all macOS systems. --- INSTALL | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL b/INSTALL index 282f900c9..bfb7f657c 100755 --- a/INSTALL +++ b/INSTALL @@ -116,6 +116,7 @@ if [ `uname` = Darwin ]; then *x86_64*) echo " x86-64 found." echo "OBJTYPE=x86_64" >>$PLAN9/config + echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config ;; *i386*) echo " i386 found." From 43b0d532bd3c1e4fbd4385c6470db12dbf7a5ad8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 20:52:18 -0500 Subject: [PATCH 046/323] acme: add 32x32 boxcursor The only difference from the upscaled 16x16 is a one-pixel adjustment in the offset position, but this at least exercises setcursor2. --- src/cmd/acme/acme.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ src/cmd/acme/cols.c | 2 +- src/cmd/acme/dat.h | 1 + src/cmd/acme/rows.c | 2 +- 4 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 742aabdf8..12701f23f 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -966,6 +966,74 @@ Cursor boxcursor = { 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x00, 0x00} }; +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}, + {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} +}; + void iconinit(void) { diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c index b1fe23bab..6215e0441 100644 --- a/src/cmd/acme/cols.c +++ b/src/cmd/acme/cols.c @@ -477,7 +477,7 @@ coldragwin(Column *c, Window *w, int but) Column *nc; clearmouse(); - setcursor(mousectl, &boxcursor); + setcursor2(mousectl, &boxcursor, &boxcursor2); b = mouse->buttons; op = mouse->xy; while(mouse->buttons == b) diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h index 8c4b14ee2..8a81c97d6 100644 --- a/src/cmd/acme/dat.h +++ b/src/cmd/acme/dat.h @@ -525,6 +525,7 @@ Image *button; Image *but2col; Image *but3col; Cursor boxcursor; +Cursor2 boxcursor2; Row row; int timerpid; Disk *disk; diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 8cff0855e..83c645942 100644 --- a/src/cmd/acme/rows.c +++ b/src/cmd/acme/rows.c @@ -148,7 +148,7 @@ rowdragcol(Row *row, Column *c, int _0) USED(_0); clearmouse(); - setcursor(mousectl, &boxcursor); + setcursor2(mousectl, &boxcursor, &boxcursor2); b = mouse->buttons; op = mouse->xy; while(mouse->buttons == b) From 4e2ac7657b2ac3173bd4b23ecb7a7e8c4b74c00f Mon Sep 17 00:00:00 2001 From: Mat Kovach Date: Thu, 15 Nov 2018 22:00:50 -0500 Subject: [PATCH 047/323] unix: fix tar use in mkfile to allow Plan 9 tar --- unix/mkfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unix/mkfile b/unix/mkfile index 245ea2ed8..ab1e66280 100644 --- a/unix/mkfile +++ b/unix/mkfile @@ -38,15 +38,15 @@ test-%:V: lib%.tgz:V: mk new-$stem - tar cf - lib$stem | gzip > $target + tar c lib$stem | gzip > $target libregexp9.tgz:V: mk new-regexp - tar cf - libregexp | gzip >$target + tar c libregexp | gzip >$target mk.tgz:V: mk new-mk - tar cf - mk | gzip > $target + tar c mk | gzip > $target mk-with-libs.tgz:V: mk new-utf @@ -59,7 +59,7 @@ mk-with-libs.tgz:V: mv libutf libfmt libbio libregexp mk zot mv zot mk cp make/Makefile.all mk/Makefile - tar cf - mk | gzip > $target + tar c mk | gzip > $target rm -r mk tgz:V: libutf.tgz libfmt.tgz libregexp9.tgz libbio.tgz mk.tgz mk-with-libs.tgz From 3d6fc088f028e0267ecbc64e21eadbe9ca1bcb83 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Sat, 6 Oct 2018 00:13:04 +0200 Subject: [PATCH 048/323] devdraw: remove os x 10.5 compatibility code --- src/cmd/devdraw/mkwsysrules.sh | 10 +- src/cmd/devdraw/osx-screen-carbon.m | 1302 --------------------------- src/cmd/devdraw/osx-screen.h | 18 - src/cmd/devdraw/osx-srv.c | 462 ---------- 4 files changed, 2 insertions(+), 1790 deletions(-) delete mode 100644 src/cmd/devdraw/osx-screen-carbon.m delete mode 100644 src/cmd/devdraw/osx-screen.h delete mode 100644 src/cmd/devdraw/osx-srv.c diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index 98d6799d9..e94afbd36 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -23,7 +23,8 @@ fi if [ "x$WSYSTYPE" = "x" ]; then if [ "x`uname`" = "xDarwin" ]; then if sw_vers | grep 'ProductVersion: 10\.[0-5]\.' >/dev/null; then - WSYSTYPE=osx + echo 1>&2 'OS X 10.5 and older are not supported' + exit 1 else #echo 1>&2 'WARNING: OS X Lion is not working. Copy binaries from a Snow Leopard system.' WSYSTYPE=osx-cocoa @@ -52,13 +53,6 @@ if [ $WSYSTYPE = x11 ]; then echo 'HFILES=$HFILES $XHFILES' XO=`ls x11-*.c 2>/dev/null | sed 's/\.c$/.o/'` echo 'WSYSOFILES=$WSYSOFILES '$XO -elif [ $WSYSTYPE = osx ]; then - if [ -d /System/Library/PrivateFrameworks/MultitouchSupport.framework ]; then - echo 'CFLAGS=$CFLAGS -DMULTITOUCH' - echo 'LDFLAGS=$LDFLAGS -F/System/Library/PrivateFrameworks' - fi - echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o' - echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = osx-cocoa ]; then if sw_vers|awk '/ProductVersion/{split($2,a,".");exit(a[2]<14)}' >/dev/null; then # 0 is true in sh. echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' diff --git a/src/cmd/devdraw/osx-screen-carbon.m b/src/cmd/devdraw/osx-screen-carbon.m deleted file mode 100644 index d41e9d10d..000000000 --- a/src/cmd/devdraw/osx-screen-carbon.m +++ /dev/null @@ -1,1302 +0,0 @@ -#define Point OSXPoint -#define Rect OSXRect -#define Cursor OSXCursor -#include -#import -#ifdef MULTITOUCH -#include -#include -#endif -#undef Rect -#undef Point -#undef Cursor -#undef offsetof -#undef nil - -#include "u.h" -#include "libc.h" -#include -#include -#include -#include -#include "mouse.h" -#include -#include "osx-screen.h" -#include "osx-keycodes.h" -#include "devdraw.h" -#include "glendapng.h" - -AUTOFRAMEWORK(Carbon) -AUTOFRAMEWORK(Cocoa) - -#ifdef MULTITOUCH -AUTOFRAMEWORK(MultitouchSupport) -AUTOFRAMEWORK(IOKit) -#endif - -#define panic sysfatal - -extern Rectangle mouserect; - -struct { - char *label; - char *winsize; - QLock labellock; - - Rectangle fullscreenr; - Rectangle screenr; - Memimage *screenimage; - int isfullscreen; - ulong fullscreentime; - - Point xy; - int buttons; - int kbuttons; - - CGDataProviderRef provider; - MenuRef wmenu; - MenuRef vmenu; - WindowRef window; - CGImageRef image; - CGContextRef windowctx; - PasteboardRef snarf; - int needflush; - QLock flushlock; - int active; - int infullscreen; - int kalting; // last keystroke was Kalt - int touched; // last mouse event was touchCallback - int collapsed; // parked in dock - int flushing; // flushproc has started - NSMutableArray* devicelist; -} osx; - -/* - These structs are required, in order to handle some parameters returned from the - Support.framework - */ -typedef struct { - float x; - float y; -}mtPoint; - -typedef struct { - mtPoint position; - mtPoint velocity; -}mtReadout; - -/* - Some reversed engineered informations from MultiTouchSupport.framework - */ -typedef struct -{ - int frame; //the current frame - double timestamp; //event timestamp - int identifier; //identifier guaranteed unique for life of touch per device - int state; //the current state (not sure what the values mean) - int unknown1; //no idea what this does - int unknown2; //no idea what this does either - mtReadout normalized; //the normalized position and vector of the touch (0,0 to 1,1) - float size; //the size of the touch (the area of your finger being tracked) - int unknown3; //no idea what this does - float angle; //the angle of the touch -| - float majorAxis; //the major axis of the touch -|-- an ellipsoid. you can track the angle of each finger! - float minorAxis; //the minor axis of the touch -| - mtReadout unknown4; //not sure what this is for - int unknown5[2]; //no clue - float unknown6; //no clue -}Touch; - -//a reference pointer for the multitouch device -typedef void *MTDeviceRef; - -//the prototype for the callback function -typedef int (*MTContactCallbackFunction)(int,Touch*,int,double,int); - -//returns a pointer to the default device (the trackpad?) -MTDeviceRef MTDeviceCreateDefault(void); - -//returns a CFMutableArrayRef array of all multitouch devices -CFMutableArrayRef MTDeviceCreateList(void); - -//registers a device's frame callback to your callback function -void MTRegisterContactFrameCallback(MTDeviceRef, MTContactCallbackFunction); -void MTUnregisterContactFrameCallback(MTDeviceRef, MTContactCallbackFunction); - -//start sending events -void MTDeviceStart(MTDeviceRef, int); -void MTDeviceStop(MTDeviceRef); - -MTDeviceRef MTDeviceCreateFromService(io_service_t); -io_service_t MTDeviceGetService(MTDeviceRef); - -#define kNTracks 10 -struct TouchTrack { - int id; - float firstThreshTime; - mtPoint pos; -} tracks[kNTracks]; - -#define kSizeSensitivity 1.25f -#define kTimeSensitivity 0.03f /* seconds */ -#define kButtonLimit 0.6f /* percentage from base of pad */ - -int -findTrack(int id) -{ - int i; - for(i = 0; i < kNTracks; ++i) - if(tracks[i].id == id) - return i; - return -1; -} - -#define kMoveSensitivity 0.05f - -int -moved(mtPoint a, mtPoint b) -{ - if(fabs(a.x - b.x) > kMoveSensitivity) - return 1; - if(fabs(a.y - b.y) > kMoveSensitivity) - return 1; - return 0; -} - -int -classifyTouch(Touch *t) -{ - mtPoint p; - int i; - - p = t->normalized.position; - - i = findTrack(t->identifier); - if(i == -1) { - i = findTrack(-1); - if(i == -1) - return 0; // No empty tracks. - tracks[i].id = t->identifier; - tracks[i].firstThreshTime = t->timestamp; - tracks[i].pos = p; - // we don't have a touch yet - we wait kTimeSensitivity before reporting it. - return 0; - } - - if(t->size == 0) { // lost touch - tracks[i].id = -1; - return 0; - } - if(t->size < kSizeSensitivity) { - tracks[i].firstThreshTime = t->timestamp; - } - if((t->timestamp - tracks[i].firstThreshTime) < kTimeSensitivity) { - return 0; - } - if(p.y > kButtonLimit && t->size > kSizeSensitivity) { - if(p.x < 0.35) - return 1; - if(p.x > 0.65) - return 4; - if(p.x > 0.35 && p.x < 0.65) - return 2; - } - return 0; -} - -static ulong msec(void); - -int -touchCallback(int device, Touch *data, int nFingers, double timestamp, int frame) -{ -#ifdef MULTITOUCH - int buttons, delta, i; - static int obuttons; - CGPoint p; - CGEventRef e; - - p.x = osx.xy.x+osx.screenr.min.x; - p.y = osx.xy.y+osx.screenr.min.y; - if(!ptinrect(Pt(p.x, p.y), osx.screenr)) - return 0; - osx.touched = 1; - buttons = 0; - for(i = 0; i < nFingers; ++i) - buttons |= classifyTouch(data+i); - delta = buttons ^ obuttons; - obuttons = buttons; - if(delta & 1) { - e = CGEventCreateMouseEvent(NULL, - (buttons & 1) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp, - p, - 29); - CGEventPost(kCGSessionEventTap, e); - CFRelease(e); - } - if(delta & 2) { - e = CGEventCreateMouseEvent(NULL, - (buttons & 2) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp, - p, - 30); - CGEventPost(kCGSessionEventTap, e); - CFRelease(e); - } - if(delta & 4){ - e = CGEventCreateMouseEvent(NULL, - (buttons & 4) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp, - p, - 31); - CGEventPost(kCGSessionEventTap, e); - CFRelease(e); - } - return delta != 0; -#else - return 0; -#endif -} - -extern int multitouch; - -enum -{ - WindowAttrs = - kWindowCloseBoxAttribute | - kWindowCollapseBoxAttribute | - kWindowResizableAttribute | - kWindowStandardHandlerAttribute | - kWindowFullZoomAttribute -}; - -enum -{ - P9PEventLabelUpdate = 1 -}; - -static void screenproc(void*); -static void eresized(int); -static void fullscreen(int); -static void seticon(void); -static void activated(int); - -static OSStatus quithandler(EventHandlerCallRef, EventRef, void*); -static OSStatus eventhandler(EventHandlerCallRef, EventRef, void*); -static OSStatus cmdhandler(EventHandlerCallRef, EventRef, void*); - -enum -{ - CmdFullScreen = 1, -}; - -void screeninit(void); -void _flushmemscreen(Rectangle r); - -#ifdef MULTITOUCH -static void -RegisterMultitouch(void *ctx, io_iterator_t iter) -{ - io_object_t io; - MTDeviceRef dev; - - while((io = IOIteratorNext(iter)) != 0){ - dev = MTDeviceCreateFromService(io); - if (dev != nil){ - MTRegisterContactFrameCallback(dev, touchCallback); - [osx.devicelist addObject:dev]; - if(osx.active) - MTDeviceStart(dev, 0); - } - - IOObjectRelease(io); - } -} - -static void -UnregisterMultitouch(void *ctx, io_iterator_t iter) -{ - io_object_t io; - MTDeviceRef dev; - int i; - - while((io = IOIteratorNext(iter)) != 0){ - for(i = 0; i < [osx.devicelist count]; i++){ - dev = [osx.devicelist objectAtIndex:i]; - if(IOObjectIsEqualTo(MTDeviceGetService(dev), io)){ - if(osx.active) - MTDeviceStop(dev); - MTUnregisterContactFrameCallback(dev, touchCallback); - [osx.devicelist removeObjectAtIndex:i]; - break; - } - } - - IOObjectRelease(io); - } -} - -#endif /*MULTITOUCH*/ - -static void -InitMultiTouch() -{ -#ifdef MULTITOUCH - IONotificationPortRef port; - CFRunLoopSourceRef source; - io_iterator_t iter; - kern_return_t kr; - io_object_t obj; - int i; - - if(!multitouch) - return; - - osx.devicelist = [[NSMutableArray alloc] init]; - - for(i = 0; i < kNTracks; ++i) - tracks[i].id = -1; - - port = IONotificationPortCreate(kIOMasterPortDefault); - if(port == nil){ - fprint(2, "failed to get an IO notification port\n"); - return; - } - - source = IONotificationPortGetRunLoopSource(port); - if(source == nil){ - fprint(2, "failed to get loop source for port"); - return; - } - - CFRunLoopAddSource( - (CFRunLoopRef)GetCFRunLoopFromEventLoop(GetMainEventLoop()), - source, - kCFRunLoopDefaultMode); - - kr = IOServiceAddMatchingNotification( - port, kIOTerminatedNotification, - IOServiceMatching("AppleMultitouchDevice"), - &UnregisterMultitouch, - nil, &iter); - - if(kr != KERN_SUCCESS){ - fprint(2, "failed to add termination notification\n"); - return; - } - - /* Arm the notification */ - while((obj = IOIteratorNext(iter)) != 0) - IOObjectRelease(obj); - - kr = IOServiceAddMatchingNotification( - port, kIOMatchedNotification, - IOServiceMatching("AppleMultitouchDevice"), - &RegisterMultitouch, - nil, &iter); - - if(kr != KERN_SUCCESS){ - fprint(2, "failed to add matching notification\n"); - return; - } - - RegisterMultitouch(nil, iter); -#endif -} - -Memimage* -attachscreen(char *label, char *winsize) -{ - if(label == nil) - label = "gnot a label"; - osx.label = strdup(label); - osx.winsize = winsize; - if(osx.screenimage == nil){ - screeninit(); - if(osx.screenimage == nil) - panic("cannot create OS X screen"); - } - return osx.screenimage; -} - -extern int multitouch; - -void -_screeninit(void) -{ - CGRect cgr; - OSXRect or; - Rectangle r; - int havemin; - - memimageinit(); - - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - SetFrontProcess(&psn); - - cgr = CGDisplayBounds(CGMainDisplayID()); - osx.fullscreenr = Rect(0, 0, cgr.size.width, cgr.size.height); - - InitCursor(); - - // Create minimal menu with full-screen option. - ClearMenuBar(); - CreateStandardWindowMenu(0, &osx.wmenu); - InsertMenu(osx.wmenu, 0); - MenuItemIndex ix; - CreateNewMenu(1004, 0, &osx.vmenu); // XXX 1004? - SetMenuTitleWithCFString(osx.vmenu, CFSTR("View")); - AppendMenuItemTextWithCFString(osx.vmenu, - CFSTR("Full Screen"), 0, CmdFullScreen, &ix); - SetMenuItemCommandKey(osx.vmenu, ix, 0, 'F'); - AppendMenuItemTextWithCFString(osx.vmenu, - CFSTR("Cmd-F exits full screen"), - kMenuItemAttrDisabled, CmdFullScreen, &ix); - InsertMenu(osx.vmenu, GetMenuID(osx.wmenu)); - DrawMenuBar(); - - // Create the window. - r = Rect(0, 0, Dx(osx.fullscreenr)*2/3, Dy(osx.fullscreenr)*2/3); - havemin = 0; - if(osx.winsize && osx.winsize[0]){ - if(parsewinsize(osx.winsize, &r, &havemin) < 0) - sysfatal("%r"); - } - if(!havemin) - r = rectaddpt(r, Pt((Dx(osx.fullscreenr)-Dx(r))/2, (Dy(osx.fullscreenr)-Dy(r))/2)); - or.left = r.min.x; - or.top = r.min.y; - or.right = r.max.x; - or.bottom = r.max.y; - CreateNewWindow(kDocumentWindowClass, WindowAttrs, &or, &osx.window); - setlabel(osx.label); - seticon(); - - // Set up the clip board. - if(PasteboardCreate(kPasteboardClipboard, &osx.snarf) != noErr) - panic("pasteboard create"); - - // Explain in great detail which events we want to handle. - // Why can't we just have one handler? - const EventTypeSpec quits[] = { - { kEventClassApplication, kEventAppQuit } - }; - const EventTypeSpec cmds[] = { - { kEventClassWindow, kEventWindowClosed }, - { kEventClassWindow, kEventWindowBoundsChanged }, - { kEventClassWindow, kEventWindowDrawContent }, - { kEventClassCommand, kEventCommandProcess }, - { kEventClassWindow, kEventWindowActivated }, - { kEventClassWindow, kEventWindowDeactivated }, - { kEventClassWindow, kEventWindowCollapsed }, - { kEventClassWindow, kEventWindowExpanded }, - }; - const EventTypeSpec events[] = { - { kEventClassApplication, kEventAppShown }, - { kEventClassKeyboard, kEventRawKeyDown }, - { kEventClassKeyboard, kEventRawKeyModifiersChanged }, - { kEventClassKeyboard, kEventRawKeyRepeat }, - { kEventClassMouse, kEventMouseDown }, - { kEventClassMouse, kEventMouseUp }, - { kEventClassMouse, kEventMouseMoved }, - { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseWheelMoved }, - { 'P9PE', P9PEventLabelUpdate} - }; - - InstallApplicationEventHandler( - NewEventHandlerUPP(quithandler), - nelem(quits), quits, nil, nil); - - InstallApplicationEventHandler( - NewEventHandlerUPP(eventhandler), - nelem(events), events, nil, nil); - - InstallWindowEventHandler(osx.window, - NewEventHandlerUPP(cmdhandler), - nelem(cmds), cmds, osx.window, nil); - - // Finally, put the window on the screen. - ShowWindow(osx.window); - ShowMenuBar(); - eresized(0); - SelectWindow(osx.window); - - if(multitouch) - InitMultiTouch(); - - // CoreGraphics pins mouse events to the destination point of a - // CGWarpMouseCursorPosition (see setmouse) for an interval of time - // following the move. Disable this by setting the interval to zero - // seconds. - CGSetLocalEventsSuppressionInterval(0.0); - - InitCursor(); -} - -static Rendez scr; -static QLock slock; - -void -screeninit(void) -{ - scr.l = &slock; - qlock(scr.l); - proccreate(screenproc, nil, 256*1024); - while(osx.window == nil) - rsleep(&scr); - qunlock(scr.l); -} - -static void -screenproc(void *v) -{ - qlock(scr.l); - _screeninit(); - rwakeup(&scr); - qunlock(scr.l); - RunApplicationEventLoop(); -} - -static OSStatus kbdevent(EventRef); -static OSStatus mouseevent(EventRef); - -static OSStatus -cmdhandler(EventHandlerCallRef next, EventRef event, void *arg) -{ - return eventhandler(next, event, arg); -} - -static OSStatus -quithandler(EventHandlerCallRef next, EventRef event, void *arg) -{ - exit(0); - return 0; -} - -static OSStatus -eventhandler(EventHandlerCallRef next, EventRef event, void *arg) -{ - OSStatus result; - - result = CallNextEventHandler(next, event); - - switch(GetEventClass(event)){ - - case 'P9PE': - if(GetEventKind(event) == P9PEventLabelUpdate) { - qlock(&osx.labellock); - setlabel(osx.label); - qunlock(&osx.labellock); - return noErr; - } else - return eventNotHandledErr; - - case kEventClassApplication:; - Rectangle r = Rect(0, 0, Dx(osx.screenr), Dy(osx.screenr)); - _flushmemscreen(r); - return eventNotHandledErr; - - case kEventClassKeyboard: - return kbdevent(event); - - case kEventClassMouse: - return mouseevent(event); - - case kEventClassCommand:; - HICommand cmd; - GetEventParameter(event, kEventParamDirectObject, - typeHICommand, nil, sizeof cmd, nil, &cmd); - switch(cmd.commandID){ - case kHICommandQuit: - exit(0); - - case CmdFullScreen: - fullscreen(1); - break; - - default: - return eventNotHandledErr; - } - break; - - case kEventClassWindow: - switch(GetEventKind(event)){ - case kEventWindowClosed: - exit(0); - - case kEventWindowBoundsChanged:; - // We see kEventWindowDrawContent - // if we grow a window but not if we shrink it. - UInt32 flags; - GetEventParameter(event, kEventParamAttributes, - typeUInt32, 0, sizeof flags, 0, &flags); - int new = (flags & kWindowBoundsChangeSizeChanged) != 0; - eresized(new); - break; - - case kEventWindowDrawContent: - // Tried using just flushmemimage here, but - // it causes an odd artifact in which making a window - // bigger in both width and height can then only draw - // on the new border: it's like the old window is stuck - // floating on top. Doing a full "get a new window" - // seems to solve the problem. - eresized(1); - break; - - case kEventWindowActivated: - if(!osx.collapsed) - activated(1); - return eventNotHandledErr; - - case kEventWindowDeactivated: - activated(0); - return eventNotHandledErr; - - case kEventWindowCollapsed: - osx.collapsed = 1; - activated(0); - return eventNotHandledErr; - - case kEventWindowExpanded: - osx.collapsed = 0; - activated(1); - return eventNotHandledErr; - - default: - return eventNotHandledErr; - } - break; - } - - return result; -} - -static ulong -msec(void) -{ - return nsec()/1000000; -} - -static OSStatus -mouseevent(EventRef event) -{ - int wheel; - OSXPoint op; - - GetEventParameter(event, kEventParamMouseLocation, - typeQDPoint, 0, sizeof op, 0, &op); - - osx.xy = subpt(Pt(op.h, op.v), osx.screenr.min); - wheel = 0; - - switch(GetEventKind(event)){ - case kEventMouseWheelMoved:; - SInt32 delta; - GetEventParameter(event, kEventParamMouseWheelDelta, - typeSInt32, 0, sizeof delta, 0, &delta); - - // if I have any active touches in my region, I need to ignore the wheel motion. - //int i; - //for(i = 0; i < kNTracks; ++i) { - // if(tracks[i].id != -1 && tracks[i].pos.y > kButtonLimit) break; - //} - //if(i == kNTracks) { // No active touches, go ahead and scroll. - if(delta > 0) - wheel = 8; - else - wheel = 16; - //} - break; - - case kEventMouseDown: - case kEventMouseUp:; - UInt32 but, mod; - GetEventParameter(event, kEventParamMouseChord, - typeUInt32, 0, sizeof but, 0, &but); - GetEventParameter(event, kEventParamKeyModifiers, - typeUInt32, 0, sizeof mod, 0, &mod); - - // OS X swaps button 2 and 3 - but = (but & ~6) | ((but & 4)>>1) | ((but&2)<<1); - but = (but & ~((1<<10)-1)) | mouseswap(but & ((1<<10)-1)); - if(osx.touched) { - // in multitouch we use the clicks down to enable our - // virtual buttons. - if(but & 0x7) { - if(but>>29) - but = but >> 29; - } else - but = 0; - osx.touched = 0; - } - - // Apply keyboard modifiers and pretend it was a real mouse button. - // (Modifiers typed while holding the button go into kbuttons, - // but this one does not.) - if(but == 1){ - if(mod & optionKey) { - // Take the ALT away from the keyboard handler. - if(osx.kalting) { - osx.kalting = 0; - keystroke(Kalt); - } - but = 2; - } - else if(mod & cmdKey) - but = 4; - } - osx.buttons = but; - break; - - case kEventMouseMoved: - case kEventMouseDragged: - break; - - default: - return eventNotHandledErr; - } - - mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons|wheel, msec()); - return noErr; -} - -static int keycvt[] = -{ - [QZ_IBOOK_ENTER] '\n', - [QZ_RETURN] '\n', - [QZ_ESCAPE] 27, - [QZ_BACKSPACE] '\b', - [QZ_LALT] Kalt, - [QZ_LCTRL] Kctl, - [QZ_LSHIFT] Kshift, - [QZ_F1] KF+1, - [QZ_F2] KF+2, - [QZ_F3] KF+3, - [QZ_F4] KF+4, - [QZ_F5] KF+5, - [QZ_F6] KF+6, - [QZ_F7] KF+7, - [QZ_F8] KF+8, - [QZ_F9] KF+9, - [QZ_F10] KF+10, - [QZ_F11] KF+11, - [QZ_F12] KF+12, - [QZ_INSERT] Kins, - [QZ_DELETE] 0x7F, - [QZ_HOME] Khome, - [QZ_END] Kend, - [QZ_KP_PLUS] '+', - [QZ_KP_MINUS] '-', - [QZ_TAB] '\t', - [QZ_PAGEUP] Kpgup, - [QZ_PAGEDOWN] Kpgdown, - [QZ_UP] Kup, - [QZ_DOWN] Kdown, - [QZ_LEFT] Kleft, - [QZ_RIGHT] Kright, - [QZ_KP_MULTIPLY] '*', - [QZ_KP_DIVIDE] '/', - [QZ_KP_ENTER] '\n', - [QZ_KP_PERIOD] '.', - [QZ_KP0] '0', - [QZ_KP1] '1', - [QZ_KP2] '2', - [QZ_KP3] '3', - [QZ_KP4] '4', - [QZ_KP5] '5', - [QZ_KP6] '6', - [QZ_KP7] '7', - [QZ_KP8] '8', - [QZ_KP9] '9', -}; - -static OSStatus -kbdevent(EventRef event) -{ - char ch; - UInt32 code; - UInt32 mod; - int k; - - GetEventParameter(event, kEventParamKeyMacCharCodes, - typeChar, nil, sizeof ch, nil, &ch); - GetEventParameter(event, kEventParamKeyCode, - typeUInt32, nil, sizeof code, nil, &code); - GetEventParameter(event, kEventParamKeyModifiers, - typeUInt32, nil, sizeof mod, nil, &mod); - - switch(GetEventKind(event)){ - case kEventRawKeyDown: - case kEventRawKeyRepeat: - osx.kalting = 0; - if(mod == cmdKey){ - if(ch == 'F' || ch == 'f'){ - if(osx.isfullscreen && msec() - osx.fullscreentime > 500) - fullscreen(0); - return noErr; - } - - // Pass most Cmd keys through as Kcmd + ch. - // OS X interprets a few no matter what we do, - // so it is useless to pass them through as keystrokes too. - switch(ch) { - case 'm': // minimize window - case 'h': // hide window - case 'H': // hide others - case 'q': // quit - return eventNotHandledErr; - } - if(' ' <= ch && ch <= '~') { - keystroke(Kcmd + ch); - return noErr; - } - return eventNotHandledErr; - } - k = ch; - if(code < nelem(keycvt) && keycvt[code]) - k = keycvt[code]; - if(k == 0) - return noErr; - if(k > 0) - keystroke(k); - else{ - UniChar uc; - OSStatus s; - - s = GetEventParameter(event, kEventParamKeyUnicodes, - typeUnicodeText, nil, sizeof uc, nil, &uc); - if(s == noErr) - keystroke(uc); - } - break; - - case kEventRawKeyModifiersChanged: - if(!osx.buttons && !osx.kbuttons){ - if(mod == optionKey) { - osx.kalting = 1; - keystroke(Kalt); - } - break; - } - - // If the mouse button is being held down, treat - // changes in the keyboard modifiers as changes - // in the mouse buttons. - osx.kbuttons = 0; - if(mod & optionKey) - osx.kbuttons |= 2; - if(mod & cmdKey) - osx.kbuttons |= 4; - mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec()); - break; - } - return noErr; -} - -static void -eresized(int new) -{ - Memimage *m; - OSXRect or; - ulong chan; - Rectangle r; - int bpl; - CGDataProviderRef provider; - CGImageRef image; - CGColorSpaceRef cspace; - - GetWindowBounds(osx.window, kWindowContentRgn, &or); - r = Rect(or.left, or.top, or.right, or.bottom); - if(Dx(r) == Dx(osx.screenr) && Dy(r) == Dy(osx.screenr) && !new){ - // No need to make new image. - osx.screenr = r; - return; - } - - chan = XBGR32; - m = allocmemimage(Rect(0, 0, Dx(r), Dy(r)), chan); - if(m == nil) - panic("allocmemimage: %r"); - if(m->data == nil) - panic("m->data == nil"); - bpl = bytesperline(r, 32); - provider = CGDataProviderCreateWithData(0, - m->data->bdata, Dy(r)*bpl, 0); - //cspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); - cspace = CGColorSpaceCreateDeviceRGB(); - image = CGImageCreate(Dx(r), Dy(r), 8, 32, bpl, - cspace, - kCGImageAlphaNoneSkipLast, - provider, 0, 0, kCGRenderingIntentDefault); - CGColorSpaceRelease(cspace); - CGDataProviderRelease(provider); // CGImageCreate did incref - - mouserect = m->r; - if(new){ - mouseresized = 1; - mousetrack(osx.xy.x, osx.xy.y, osx.buttons|osx.kbuttons, msec()); - } -// termreplacescreenimage(m); - _drawreplacescreenimage(m); // frees old osx.screenimage if any - if(osx.image) - CGImageRelease(osx.image); - osx.image = image; - osx.screenimage = m; - osx.screenr = r; - - if(new){ - qlock(&osx.flushlock); - QDEndCGContext(GetWindowPort(osx.window), &osx.windowctx); - osx.windowctx = nil; - qunlock(&osx.flushlock); - } -} - -void -flushproc(void *v) -{ - for(;;){ - if(osx.needflush && osx.windowctx && canqlock(&osx.flushlock)){ - if(osx.windowctx){ - CGContextFlush(osx.windowctx); - osx.needflush = 0; - } - qunlock(&osx.flushlock); - } - usleep(33333); - } -} - -void -_flushmemscreen(Rectangle r) -{ - CGRect cgr; - CGImageRef subimg; - - qlock(&osx.flushlock); - if(osx.windowctx == nil){ - QDBeginCGContext(GetWindowPort(osx.window), &osx.windowctx); - if(!osx.flushing) { - proccreate(flushproc, nil, 256*1024); - osx.flushing = 1; - } - } - - cgr.origin.x = r.min.x; - cgr.origin.y = r.min.y; - cgr.size.width = Dx(r); - cgr.size.height = Dy(r); - subimg = CGImageCreateWithImageInRect(osx.image, cgr); - cgr.origin.y = Dy(osx.screenr) - r.max.y; // XXX how does this make any sense? - CGContextDrawImage(osx.windowctx, cgr, subimg); - osx.needflush = 1; - qunlock(&osx.flushlock); - CGImageRelease(subimg); -} - -void -activated(int active) -{ -#ifdef MULTITOUCH - int i; - if(active) { - for(i = 0; i<[osx.devicelist count]; i++) { //iterate available devices - MTDeviceStart([osx.devicelist objectAtIndex:i], 0); //start sending events - } - } else { - osx.xy.x = -10000; - for(i = 0; i<[osx.devicelist count]; i++) { //iterate available devices - MTDeviceStop([osx.devicelist objectAtIndex:i]); //stop sending events - } - for(i = 0; igdRect; - if(dr.top == 0 && dr.left == 0) - HideMenuBar(); - GetWindowBounds(osx.window, kWindowContentRgn, &oldrect); - ChangeWindowAttributes(osx.window, - kWindowNoTitleBarAttribute, - kWindowResizableAttribute); - MoveWindow(osx.window, 0, 0, 1); - MoveWindow(osx.window, dr.left, dr.top, 0); - SizeWindow(osx.window, - dr.right - dr.left, - dr.bottom - dr.top, 0); - osx.isfullscreen = 1; - }else{ - ShowMenuBar(); - ChangeWindowAttributes(osx.window, - kWindowResizableAttribute, - kWindowNoTitleBarAttribute); - SizeWindow(osx.window, - oldrect.right - oldrect.left, - oldrect.bottom - oldrect.top, 0); - MoveWindow(osx.window, oldrect.left, oldrect.top, 0); - osx.isfullscreen = 0; - } - eresized(1); -} - -void -setmouse(Point p) -{ - CGPoint cgp; - - cgp.x = p.x + osx.screenr.min.x; - cgp.y = p.y + osx.screenr.min.y; - CGWarpMouseCursorPosition(cgp); - osx.xy = p; -} - -void -setcursor(Cursor *c) -{ - OSXCursor oc; - int i; - - if(c == nil){ - InitCursor(); - return; - } - - // SetCursor is deprecated, but what replaces it? - for(i=0; i<16; i++){ - oc.data[i] = ((ushort*)c->set)[i]; - oc.mask[i] = oc.data[i] | ((ushort*)c->clr)[i]; - } - oc.hotSpot.h = - c->offset.x; - oc.hotSpot.v = - c->offset.y; - SetCursor(&oc); -} - -void -getcolor(ulong i, ulong *r, ulong *g, ulong *b) -{ - ulong v; - - v = 0; - *r = (v>>16)&0xFF; - *g = (v>>8)&0xFF; - *b = v&0xFF; -} - -int -setcolor(ulong i, ulong r, ulong g, ulong b) -{ - /* no-op */ - return 0; -} - - -int -hwdraw(Memdrawparam *p) -{ - return 0; -} - -struct { - QLock lk; - char buf[SnarfSize]; - Rune rbuf[SnarfSize]; - PasteboardRef apple; -} clip; - -char* -getsnarf(void) -{ - char *s; - CFArrayRef flavors; - CFDataRef data; - CFIndex nflavor, ndata, j; - CFStringRef type; - ItemCount nitem; - PasteboardItemID id; - PasteboardSyncFlags flags; - UInt32 i; - u16int *u; - Fmt fmt; - Rune r; - -/* fprint(2, "applegetsnarf\n"); */ - qlock(&clip.lk); - clip.apple = osx.snarf; - if(clip.apple == nil){ - if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){ - fprint(2, "apple pasteboard create failed\n"); - qunlock(&clip.lk); - return nil; - } - } - flags = PasteboardSynchronize(clip.apple); - if(flags&kPasteboardClientIsOwner){ - s = strdup(clip.buf); - qunlock(&clip.lk); - return s; - } - if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){ - fprint(2, "apple pasteboard get item count failed\n"); - qunlock(&clip.lk); - return nil; - } - for(i=1; i<=nitem; i++){ - if(PasteboardGetItemIdentifier(clip.apple, i, &id) != noErr) - continue; - if(PasteboardCopyItemFlavors(clip.apple, id, &flavors) != noErr) - continue; - nflavor = CFArrayGetCount(flavors); - for(j=0; j= SnarfSize) - return; - qlock(&clip.lk); - strcpy(clip.buf, s); - runesnprint(clip.rbuf, nelem(clip.rbuf), "%s", s); - clip.apple = osx.snarf; - if(PasteboardClear(clip.apple) != noErr){ - fprint(2, "apple pasteboard clear failed\n"); - qunlock(&clip.lk); - return; - } - flags = PasteboardSynchronize(clip.apple); - if((flags&kPasteboardModified) || !(flags&kPasteboardClientIsOwner)){ - fprint(2, "apple pasteboard cannot assert ownership\n"); - qunlock(&clip.lk); - return; - } - u = malloc(runestrlen(clip.rbuf)*4); - p = u; - for(i=0; clip.rbuf[i]; i++) { - r = clip.rbuf[i]; - // convert to utf-16 - if(0xd800 <= r && r < 0xe000) - r = Runeerror; - if(r >= 0x10000) { - r -= 0x10000; - *p++ = 0xd800 + (r>>10); - *p++ = 0xdc00 + (r & ((1<<10)-1)); - } else - *p++ = r; - } - cfdata = CFDataCreate(kCFAllocatorDefault, - (uchar*)u, (p-u)*2); - free(u); - if(cfdata == nil){ - fprint(2, "apple pasteboard cfdatacreate failed\n"); - qunlock(&clip.lk); - return; - } - if(PasteboardPutItemFlavor(clip.apple, (PasteboardItemID)1, - CFSTR("public.utf16-plain-text"), cfdata, 0) != noErr){ - fprint(2, "apple pasteboard putitem failed\n"); - CFRelease(cfdata); - qunlock(&clip.lk); - return; - } - CFRelease(cfdata); - qunlock(&clip.lk); -} - -void -setlabel(char *label) -{ - CFStringRef cs; - - cs = CFStringCreateWithBytes(nil, (uchar*)label, strlen(label), kCFStringEncodingUTF8, false); - SetWindowTitleWithCFString(osx.window, cs); - CFRelease(cs); -} - -void -kicklabel(char *label) -{ - char *p; - EventRef e; - - p = strdup(label); - if(p == nil) - return; - qlock(&osx.labellock); - free(osx.label); - osx.label = p; - qunlock(&osx.labellock); - - CreateEvent(nil, 'P9PE', P9PEventLabelUpdate, 0, kEventAttributeUserEvent, &e); - PostEventToQueue(GetMainEventQueue(), e, kEventPriorityStandard); - -} - -static void -seticon(void) -{ - CGImageRef im; - CGDataProviderRef d; - - d = CGDataProviderCreateWithData(nil, glenda_png, sizeof glenda_png, nil); - im = CGImageCreateWithPNGDataProvider(d, nil, true, kCGRenderingIntentDefault); - if(im) - SetApplicationDockTileImage(im); - CGImageRelease(im); - CGDataProviderRelease(d); -} - diff --git a/src/cmd/devdraw/osx-screen.h b/src/cmd/devdraw/osx-screen.h deleted file mode 100644 index d5ba3dd24..000000000 --- a/src/cmd/devdraw/osx-screen.h +++ /dev/null @@ -1,18 +0,0 @@ -void zlock(void); -void zunlock(void); - -#define setcursor dsetcursor - -Memimage *attachscreen(char*, char*); -void setmouse(Point); -void setcursor(Cursor*, Cursor2*); -void setlabel(char*); -char* getsnarf(void); -void putsnarf(char*); - -void mousetrack(int, int, int, int); -void keystroke(int); -void kicklabel(char*); - -extern Rectangle mouserect; -extern int mouseresized; diff --git a/src/cmd/devdraw/osx-srv.c b/src/cmd/devdraw/osx-srv.c deleted file mode 100644 index d0a1c2d31..000000000 --- a/src/cmd/devdraw/osx-srv.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Window system protocol server. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "osx-screen.h" -#include "devdraw.h" - -#undef time - -#define MouseMask (\ - ButtonPressMask|\ - ButtonReleaseMask|\ - PointerMotionMask|\ - Button1MotionMask|\ - Button2MotionMask|\ - Button3MotionMask) - -#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|EnterWindowMask|LeaveWindowMask - -typedef struct Kbdbuf Kbdbuf; -typedef struct Mousebuf Mousebuf; -typedef struct Fdbuf Fdbuf; -typedef struct Tagbuf Tagbuf; - -struct Kbdbuf -{ - Rune r[32]; - int ri; - int wi; - int stall; -}; - -struct Mousebuf -{ - Mouse m[32]; - Mouse last; - int ri; - int wi; - int stall; -}; - -struct Tagbuf -{ - int t[32]; - int ri; - int wi; -}; - -Kbdbuf kbd; -Mousebuf mouse; -Tagbuf kbdtags; -Tagbuf mousetags; - -void fdslide(Fdbuf*); -void runmsg(Wsysmsg*); -void replymsg(Wsysmsg*); -void matchkbd(void); -void matchmouse(void); -int fdnoblock(int); -Rectangle mouserect; -int mouseresized; - - -QLock lk; -void -zlock(void) -{ - qlock(&lk); -} - -void -zunlock(void) -{ - qunlock(&lk); -} - -int chatty; -int drawsleep; -int trace; -int multitouch = 1; - -void -usage(void) -{ - fprint(2, "usage: devdraw (don't run directly)\n"); - threadexitsall("usage"); -} - -void -bell(void *v, char *msg) -{ - if(strcmp(msg, "alarm") == 0) - drawsleep = drawsleep ? 0 : 1000; - noted(NCONT); -} - -void -threadmain(int argc, char **argv) -{ - uchar buf[4], *mbuf; - int nmbuf, n, nn; - Wsysmsg m; - - /* - * Move the protocol off stdin/stdout so that - * any inadvertent prints don't screw things up. - */ - dup(0, 3); - dup(1, 4); - close(0); - close(1); - open("/dev/null", OREAD); - open("/dev/null", OWRITE); - -//trace = 1; - fmtinstall('W', drawfcallfmt); - - ARGBEGIN{ - case 'D': - chatty++; - break; - case 'M': - multitouch = 0; - break; - default: - usage(); - }ARGEND - - /* - * Ignore arguments. They're only for good ps -a listings. - */ - - notify(bell); - - mbuf = nil; - nmbuf = 0; - while((n = read(3, buf, 4)) == 4){ - GET(buf, n); - if(n > nmbuf){ - free(mbuf); - mbuf = malloc(4+n); - if(mbuf == nil) - sysfatal("malloc: %r"); - nmbuf = n; - } - memmove(mbuf, buf, 4); - nn = readn(3, mbuf+4, n-4); - if(nn != n-4) - sysfatal("eof during message"); - - /* pick off messages one by one */ - if(convM2W(mbuf, nn+4, &m) <= 0) - sysfatal("cannot convert message"); - if(trace) fprint(2, "<- %W\n", &m); - runmsg(&m); - } - threadexitsall(0); -} - -void -replyerror(Wsysmsg *m) -{ - char err[256]; - - rerrstr(err, sizeof err); - m->type = Rerror; - m->error = err; - replymsg(m); -} - -/* - * Handle a single wsysmsg. - * Might queue for later (kbd, mouse read) - */ -void -runmsg(Wsysmsg *m) -{ - static uchar buf[65536]; - int n; - Memimage *i; - - switch(m->type){ - case Tinit: - memimageinit(); - i = attachscreen(m->label, m->winsize); - _initdisplaymemimage(i); - replymsg(m); - break; - - case Trdmouse: - zlock(); - mousetags.t[mousetags.wi++] = m->tag; - if(mousetags.wi == nelem(mousetags.t)) - mousetags.wi = 0; - if(mousetags.wi == mousetags.ri) - sysfatal("too many queued mouse reads"); - mouse.stall = 0; - matchmouse(); - zunlock(); - break; - - case Trdkbd: - zlock(); - kbdtags.t[kbdtags.wi++] = m->tag; - if(kbdtags.wi == nelem(kbdtags.t)) - kbdtags.wi = 0; - if(kbdtags.wi == kbdtags.ri) - sysfatal("too many queued keyboard reads"); - kbd.stall = 0; - matchkbd(); - zunlock(); - break; - - case Tmoveto: - setmouse(m->mouse.xy); - replymsg(m); - break; - - case Tcursor: - if(m->arrowcursor) - setcursor(nil, nil); - else - setcursor(&m->cursor, &m->cursor2); - replymsg(m); - break; - - case Tbouncemouse: - // _xbouncemouse(&m->mouse); - replymsg(m); - break; - - case Tlabel: - kicklabel(m->label); - replymsg(m); - break; - - case Trdsnarf: - m->snarf = getsnarf(); - replymsg(m); - free(m->snarf); - break; - - case Twrsnarf: - putsnarf(m->snarf); - replymsg(m); - break; - - case Trddraw: - n = m->count; - if(n > sizeof buf) - n = sizeof buf; - n = _drawmsgread(buf, n); - if(n < 0) - replyerror(m); - else{ - m->count = n; - m->data = buf; - replymsg(m); - } - break; - - case Twrdraw: - if(_drawmsgwrite(m->data, m->count) < 0) - replyerror(m); - else - replymsg(m); - break; - - case Ttop: - // _xtopwindow(); - replymsg(m); - break; - - case Tresize: - // _xresizewindow(m->rect); - replymsg(m); - break; - } -} - -/* - * Reply to m. - */ -QLock replylock; -void -replymsg(Wsysmsg *m) -{ - int n; - static uchar *mbuf; - static int nmbuf; - - /* T -> R msg */ - if(m->type%2 == 0) - m->type++; - - if(trace) fprint(2, "-> %W\n", m); - /* copy to output buffer */ - n = sizeW2M(m); - - qlock(&replylock); - if(n > nmbuf){ - free(mbuf); - mbuf = malloc(n); - if(mbuf == nil) - sysfatal("out of memory"); - nmbuf = n; - } - convW2M(m, mbuf, n); - if(write(4, mbuf, n) != n) - sysfatal("write: %r"); - qunlock(&replylock); -} - -/* - * Match queued kbd reads with queued kbd characters. - */ -void -matchkbd(void) -{ - Wsysmsg m; - - if(kbd.stall) - return; - while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){ - m.type = Rrdkbd; - m.tag = kbdtags.t[kbdtags.ri++]; - if(kbdtags.ri == nelem(kbdtags.t)) - kbdtags.ri = 0; - m.rune = kbd.r[kbd.ri++]; - if(kbd.ri == nelem(kbd.r)) - kbd.ri = 0; - replymsg(&m); - } -} - -/* - * Match queued mouse reads with queued mouse events. - */ -void -matchmouse(void) -{ - Wsysmsg m; - - while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){ - m.type = Rrdmouse; - m.tag = mousetags.t[mousetags.ri++]; - if(mousetags.ri == nelem(mousetags.t)) - mousetags.ri = 0; - m.mouse = mouse.m[mouse.ri]; - m.resized = mouseresized; - /* - if(m.resized) - fprint(2, "sending resize\n"); - */ - mouseresized = 0; - mouse.ri++; - if(mouse.ri == nelem(mouse.m)) - mouse.ri = 0; - replymsg(&m); - } -} - -void -mousetrack(int x, int y, int b, int ms) -{ - Mouse *m; - - if(x < mouserect.min.x) - x = mouserect.min.x; - if(x > mouserect.max.x) - x = mouserect.max.x; - if(y < mouserect.min.y) - y = mouserect.min.y; - if(y > mouserect.max.y) - y = mouserect.max.y; - - zlock(); - // If reader has stopped reading, don't bother. - // If reader is completely caught up, definitely queue. - // Otherwise, queue only button change events. - if(!mouse.stall) - if(mouse.wi == mouse.ri || mouse.last.buttons != b){ - m = &mouse.last; - m->xy.x = x; - m->xy.y = y; - m->buttons = b; - m->msec = ms; - - mouse.m[mouse.wi] = *m; - if(++mouse.wi == nelem(mouse.m)) - mouse.wi = 0; - if(mouse.wi == mouse.ri){ - mouse.stall = 1; - mouse.ri = 0; - mouse.wi = 1; - mouse.m[0] = *m; - } - matchmouse(); - } - zunlock(); -} - -void -kputc(int c) -{ - zlock(); - kbd.r[kbd.wi++] = c; - if(kbd.wi == nelem(kbd.r)) - kbd.wi = 0; - if(kbd.ri == kbd.wi) - kbd.stall = 1; - matchkbd(); - zunlock(); -} - -void -keystroke(int c) -{ - static Rune k[10]; - static int alting, nk; - int i; - - if(c == Kalt){ - alting = !alting; - return; - } - if(!alting){ - kputc(c); - return; - } - if(nk >= nelem(k)) // should not happen - nk = 0; - k[nk++] = c; - c = _latin1(k, nk); - if(c > 0){ - alting = 0; - kputc(c); - nk = 0; - return; - } - if(c == -1){ - alting = 0; - for(i=0; i Date: Thu, 15 Nov 2018 22:05:39 -0500 Subject: [PATCH 049/323] rio: make 'mk all' explain why it does nothing on non-x11 systems Fixes #98. --- src/cmd/rio/mkriorules.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/rio/mkriorules.sh b/src/cmd/rio/mkriorules.sh index 76dda36b4..25cacc79b 100644 --- a/src/cmd/rio/mkriorules.sh +++ b/src/cmd/rio/mkriorules.sh @@ -1,6 +1,8 @@ if [ "x$WSYSTYPE" != xx11 ]; then - echo 'all install clean nuke:Q:' - echo ' #' + echo 'default:V: all' + echo + echo 'all install clean nuke:' + echo ' # WSYSTYPE is not x11, and rio is only for x11' exit 0 fi cat $PLAN9/src/mkmany From a309537fdc8d86131522d43f9a9b2a0f58d9bda9 Mon Sep 17 00:00:00 2001 From: Tobias Heinicke Date: Wed, 6 Sep 2017 14:30:17 +0200 Subject: [PATCH 050/323] paint: add drawing program from 9front (#112) Paint first appeared in 9front. The 9front license is reproduced in the related source files - the original repository is located at https://code.9front.org/hg/plan9front. --- man/man1/paint.1 | 85 ++++ src/cmd/paint/eenter.c | 258 +++++++++++++ src/cmd/paint/mkfile | 11 + src/cmd/paint/paint.c | 859 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1213 insertions(+) create mode 100644 man/man1/paint.1 create mode 100644 src/cmd/paint/eenter.c create mode 100644 src/cmd/paint/mkfile create mode 100644 src/cmd/paint/paint.c diff --git a/man/man1/paint.1 b/man/man1/paint.1 new file mode 100644 index 000000000..2bcbf245c --- /dev/null +++ b/man/man1/paint.1 @@ -0,0 +1,85 @@ +.TH PAINT 1 +.CT 1 graphics +.SH NAME +paint \- create image files by drawing with a mouse or other pointing device +.SH SYNOPSIS +.B paint +[ +.I file +] +.SH DESCRIPTION +.I Paint +displays a canvas upon which can be drawn lines using the mouse holding +down buttons 1 or 2 for foreground or background color. The canvas +may be moved with button 3. Colors and brush sizes may be selected by +clicking on the palette at the bottom of the screen with buttons 1 or 2. +.PP +If the optional +.I file +argument is specified, then it is read and used as the canvas. +.I Paint +only recognizes Plan 9 bitmap format (see +.IR image (6)). +.PP +A number of immediate keyboard commands are recognized: +.TP +.B u +Undos the previous action. +.TP +.B c +Clears the canvas with the background color. +.TP +.B 1-9 +Select brush size. +.TP +.B f +Select flood fill brush. +.TP +.B + +Doubles magnification. +.TP +.B - +Halves magnification. +.TP +.B esc +Centers the canvas and resets magnification. +.PP +Hitting any other key on the keyboard shows a command prompt +where the following commands may be entered: +.TP +.BI r file +Reads the canvas from +.I file. +.TP +.BI w file +Writes the canvas to +.I file. +.TP +.BI < command +Executes +.I command +and reads the canvas from its standard output. +.TP +.BI > command +Executes +.I command +and writes the canvas to its standard input. +.TP +.BI | command +Transforms the canvas by piping it thru +.I command. +.TP +.B q +Quits the program. +.SH SOURCE +.B /sys/src/cmd/paint.c +.SH "SEE ALSO" +.IR resample (1), +.IR rotate (1), +.IR crop (1), +.IR jpg (1), +.IR page (1), +.IR image (6) +.SH HISTORY +.I Paint +first appeared in 9front (October, 2011). diff --git a/src/cmd/paint/eenter.c b/src/cmd/paint/eenter.c new file mode 100644 index 000000000..6645820c6 --- /dev/null +++ b/src/cmd/paint/eenter.c @@ -0,0 +1,258 @@ +/* +This code was taken from 9front repository (https://code.9front.org/hg/plan9front). +It is subject to license from 9front, below is a reproduction of the license. + +Copyright (c) 20XX 9front + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +#include +#include +#include +#include +#include + +/* additional keyboard codes needed - defined here to avoid API change */ +enum { + Spec= 0xF800, + Knack= 0x15, + Ksoh= 0x01, + Kenq= 0x05, + Ketb= 0x17 +}; + +int +eenter(char *ask, char *buf, int len, Mouse *m) +{ + int done, down, tick, n, h, w, l, i; + Image *b, *save, *backcol, *bordcol; + Point p, o, t; + Rectangle r, sc; + Event ev; + Rune k; + + o = screen->r.min; + backcol = allocimagemix(display, DPurpleblue, DWhite); + bordcol = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue); + if(backcol == nil || bordcol == nil) + return -1; + + while(ecankbd()) + ekbd(); + + if(m) o = m->xy; + + if(buf && len > 0) + n = strlen(buf); + else { + buf = nil; + len = 0; + n = 0; + } + + k = -1; + tick = n; + save = nil; + done = down = 0; + + p = stringsize(font, " "); + h = p.y; + w = p.x; + + b = screen; + sc = b->clipr; + replclipr(b, 0, b->r); + + while(!done){ + p = stringsize(font, buf ? buf : ""); + if(ask && ask[0]){ + if(buf) p.x += w; + p.x += stringwidth(font, ask); + } + r = rectaddpt(insetrect(Rpt(ZP, p), -4), o); + p.x = 0; + r = rectsubpt(r, p); + + p = ZP; + if(r.min.x < screen->r.min.x) + p.x = screen->r.min.x - r.min.x; + if(r.min.y < screen->r.min.y) + p.y = screen->r.min.y - r.min.y; + r = rectaddpt(r, p); + p = ZP; + if(r.max.x > screen->r.max.x) + p.x = r.max.x - screen->r.max.x; + if(r.max.y > screen->r.max.y) + p.y = r.max.y - screen->r.max.y; + r = rectsubpt(r, p); + + r = insetrect(r, -2); + if(save == nil){ + save = allocimage(display, r, b->chan, 0, DNofill); + if(save == nil){ + n = -1; + break; + } + draw(save, r, b, nil, r.min); + } + draw(b, r, backcol, nil, ZP); + border(b, r, 2, bordcol, ZP); + p = addpt(r.min, Pt(6, 6)); + if(ask && ask[0]){ + p = string(b, p, bordcol, ZP, font, ask); + if(buf) p.x += w; + } + if(buf){ + t = p; + p = stringn(b, p, display->black, ZP, font, buf, utfnlen(buf, tick)); + draw(b, Rect(p.x-1, p.y, p.x+2, p.y+3), display->black, nil, ZP); + draw(b, Rect(p.x, p.y, p.x+1, p.y+h), display->black, nil, ZP); + draw(b, Rect(p.x-1, p.y+h-3, p.x+2, p.y+h), display->black, nil, ZP); + p = string(b, p, display->black, ZP, font, buf+tick); + } + flushimage(display, 1); + +nodraw: + i = Ekeyboard; + if(m != nil) + i |= Emouse; + + replclipr(b, 0, sc); + i = eread(i, &ev); + + /* screen might have been resized */ + if(b != screen || !eqrect(screen->clipr, sc)){ + freeimage(save); + save = nil; + } + b = screen; + sc = b->clipr; + replclipr(b, 0, b->r); + + switch(i){ + default: + done = 1; + n = -1; + break; + case Ekeyboard: + k = ev.kbdc; + if(buf == nil || k == Keof || k == '\n'){ + done = 1; + break; + } + if(k == Knack || k == Kesc){ + done = !n; + buf[n = tick = 0] = 0; + break; + } + if(k == Ksoh || k == Khome){ + tick = 0; + continue; + } + if(k == Kenq || k == Kend){ + tick = n; + continue; + } + if(k == Kright){ + if(tick < n) + tick += chartorune(&k, buf+tick); + continue; + } + if(k == Kleft){ + for(i = 0; i < n; i += l){ + l = chartorune(&k, buf+tick); + if(i+l >= tick){ + tick = i; + break; + } + } + continue; + } + if(k == Ketb){ + while(tick > 0){ + tick--; + if(tick == 0 || + strchr(" !\"#$%&'()*+,-./:;<=>?@`[\\]^{|}~", buf[tick-1])) + break; + } + buf[n = tick] = 0; + break; + } + if(k == Kbs){ + if(tick <= 0) + continue; + for(i = 0; i < n; i += l){ + l = chartorune(&k, buf+i); + if(i+l >= tick){ + memmove(buf+i, buf+i+l, n - (i+l)); + buf[n -= l] = 0; + tick -= l; + break; + } + } + break; + } + if(k < 0x20 || k == Kdel || (k & 0xFF00) == KF || (k & 0xFF00) == Spec) + continue; + if((len-n) <= (l = runelen(k))) + continue; + memmove(buf+tick+l, buf+tick, n - tick); + runetochar(buf+tick, &k); + buf[n += l] = 0; + tick += l; + break; + case Emouse: + *m = ev.mouse; + if(!ptinrect(m->xy, r)){ + down = 0; + goto nodraw; + } + if(m->buttons & 7){ + down = 1; + if(buf && m->xy.x >= (t.x - w)){ + down = 0; + for(i = 0; i < n; i += l){ + l = chartorune(&k, buf+i); + t.x += stringnwidth(font, buf+i, 1); + if(t.x > m->xy.x) + break; + } + tick = i; + } + continue; + } + done = down; + break; + } + if(save){ + draw(b, save->r, save, nil, save->r.min); + freeimage(save); + save = nil; + } + } + + replclipr(b, 0, sc); + + freeimage(backcol); + freeimage(bordcol); + flushimage(display, 1); + + return n; +} + diff --git a/src/cmd/paint/mkfile b/src/cmd/paint/mkfile new file mode 100644 index 000000000..272db4b4f --- /dev/null +++ b/src/cmd/paint/mkfile @@ -0,0 +1,11 @@ +<$PLAN9/src/mkhdr + +TARG=paint + +OFILES=\ + eenter.$O\ + paint.$O\ + +HFILES=paint.h\ + +<$PLAN9/src/mkone diff --git a/src/cmd/paint/paint.c b/src/cmd/paint/paint.c new file mode 100644 index 000000000..7dce3710c --- /dev/null +++ b/src/cmd/paint/paint.c @@ -0,0 +1,859 @@ +/* +This code was taken from 9front repository (https://code.9front.org/hg/plan9front). +It is subject to license from 9front, below is a reproduction of the license. + +Copyright (c) 20XX 9front + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ +#include +#include +#include +#include +#include + +/* additional libdraw function needed - defined here to avoid API change */ +extern int eenter(char*, char*, int, Mouse*); + +char *filename; +int zoom = 1; +int brush = 1; +Point spos; /* position on screen */ +Point cpos; /* position on canvas */ +Image *canvas; +Image *ink; +Image *back; +Image *pal[16]; /* palette */ +Rectangle palr; /* palette rect on screen */ +Rectangle penr; /* pen size rect on screen */ + +enum { + NBRUSH = 10+1, +}; + +int nundo = 0; +Image *undo[1024]; + +int c64[] = { /* c64 color palette */ + 0x000000, + 0xFFFFFF, + 0x68372B, + 0x70A4B2, + 0x6F3D86, + 0x588D43, + 0x352879, + 0xB8C76F, + 0x6F4F25, + 0x433900, + 0x9A6759, + 0x444444, + 0x6C6C6C, + 0x9AD284, + 0x6C5EB5, + 0x959595, +}; + +/* + * get bounding rectnagle for stroke from r.min to r.max with + * specified brush (size). + */ +static Rectangle +strokerect(Rectangle r, int brush) +{ + r = canonrect(r); + return Rect(r.min.x-brush, r.min.y-brush, r.max.x+brush+1, r.max.y+brush+1); +} + +/* + * draw stroke from r.min to r.max to dst with color ink and + * brush (size). + */ +static void +strokedraw(Image *dst, Rectangle r, Image *ink, int brush) +{ + if(!eqpt(r.min, r.max)) + line(dst, r.min, r.max, Enddisc, Enddisc, brush, ink, ZP); + fillellipse(dst, r.max, brush, brush, ink, ZP); +} + +/* + * A draw operation that touches only the area contained in bot but not in top. + * mp and sp get aligned with bot.min. + */ +static void +gendrawdiff(Image *dst, Rectangle bot, Rectangle top, + Image *src, Point sp, Image *mask, Point mp, int op) +{ + Rectangle r; + Point origin; + Point delta; + + if(Dx(bot)*Dy(bot) == 0) + return; + + /* no points in bot - top */ + if(rectinrect(bot, top)) + return; + + /* bot - top ≡ bot */ + if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){ + gendrawop(dst, bot, src, sp, mask, mp, op); + return; + } + + origin = bot.min; + /* split bot into rectangles that don't intersect top */ + /* left side */ + if(bot.min.x < top.min.x){ + r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y); + delta = subpt(r.min, origin); + gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); + bot.min.x = top.min.x; + } + + /* right side */ + if(bot.max.x > top.max.x){ + r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y); + delta = subpt(r.min, origin); + gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); + bot.max.x = top.max.x; + } + + /* top */ + if(bot.min.y < top.min.y){ + r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y); + delta = subpt(r.min, origin); + gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); + bot.min.y = top.min.y; + } + + /* bottom */ + if(bot.max.y > top.max.y){ + r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y); + delta = subpt(r.min, origin); + gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op); + bot.max.y = top.max.y; + } +} + +int +alphachan(ulong chan) +{ + for(; chan; chan >>= 8) + if(TYPE(chan) == CAlpha) + return 1; + return 0; +} + +void +zoomdraw(Image *d, Rectangle r, Rectangle top, Image *b, Image *s, Point sp, int f) +{ + Rectangle dr; + Image *t; + Point a; + int w; + + a = ZP; + if(r.min.x < d->r.min.x){ + sp.x += (d->r.min.x - r.min.x)/f; + a.x = (d->r.min.x - r.min.x)%f; + r.min.x = d->r.min.x; + } + if(r.min.y < d->r.min.y){ + sp.y += (d->r.min.y - r.min.y)/f; + a.y = (d->r.min.y - r.min.y)%f; + r.min.y = d->r.min.y; + } + rectclip(&r, d->r); + w = s->r.max.x - sp.x; + if(w > Dx(r)) + w = Dx(r); + dr = r; + dr.max.x = dr.min.x+w; + if(!alphachan(s->chan)) + b = nil; + if(f <= 1){ + if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD); + gendrawdiff(d, dr, top, s, sp, nil, ZP, SoverD); + return; + } + if((t = allocimage(display, dr, s->chan, 0, 0)) == nil) + return; + for(; dr.min.y < r.max.y; dr.min.y++){ + dr.max.y = dr.min.y+1; + draw(t, dr, s, nil, sp); + if(++a.y == f){ + a.y = 0; + sp.y++; + } + } + dr = r; + for(sp=dr.min; dr.min.x < r.max.x; sp.x++){ + dr.max.x = dr.min.x+1; + if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD); + gendrawdiff(d, dr, top, t, sp, nil, ZP, SoverD); + for(dr.min.x++; ++a.x < f && dr.min.x < r.max.x; dr.min.x++){ + dr.max.x = dr.min.x+1; + gendrawdiff(d, dr, top, d, Pt(dr.min.x-1, dr.min.y), nil, ZP, SoverD); + } + a.x = 0; + } + freeimage(t); +} + +Point +s2c(Point p){ + p = subpt(p, spos); + if(p.x < 0) p.x -= zoom-1; + if(p.y < 0) p.y -= zoom-1; + return addpt(divpt(p, zoom), cpos); +} + +Point +c2s(Point p){ + return addpt(mulpt(subpt(p, cpos), zoom), spos); +} + +Rectangle +c2sr(Rectangle r){ + return Rpt(c2s(r.min), c2s(r.max)); +} + +void +update(Rectangle *rp){ + if(canvas==nil) + draw(screen, screen->r, back, nil, ZP); + else { + if(rp == nil) + rp = &canvas->r; + gendrawdiff(screen, screen->r, c2sr(canvas->r), back, ZP, nil, ZP, SoverD); + zoomdraw(screen, c2sr(*rp), ZR, back, canvas, rp->min, zoom); + } + flushimage(display, 1); +} + +void +expand(Rectangle r) +{ + Rectangle nr; + Image *tmp; + + if(canvas==nil){ + if((canvas = allocimage(display, r, screen->chan, 0, DNofill)) == nil) + sysfatal("allocimage: %r"); + draw(canvas, canvas->r, back, nil, ZP); + return; + } + nr = canvas->r; + combinerect(&nr, r); + if(eqrect(nr, canvas->r)) + return; + if((tmp = allocimage(display, nr, canvas->chan, 0, DNofill)) == nil) + return; + draw(tmp, canvas->r, canvas, nil, canvas->r.min); + gendrawdiff(tmp, tmp->r, canvas->r, back, ZP, nil, ZP, SoverD); + freeimage(canvas); + canvas = tmp; +} + +void +save(Rectangle r, int mark) +{ + Image *tmp; + int x; + + if(mark){ + x = nundo++ % nelem(undo); + if(undo[x]) + freeimage(undo[x]); + undo[x] = nil; + } + if(canvas==nil || nundo<0) + return; + if(!rectclip(&r, canvas->r)) + return; + if((tmp = allocimage(display, r, canvas->chan, 0, DNofill)) == nil) + return; + draw(tmp, r, canvas, nil, r.min); + x = nundo++ % nelem(undo); + if(undo[x]) + freeimage(undo[x]); + undo[x] = tmp; +} + +void +restore(int n) +{ + Image *tmp; + int x; + + while(nundo > 0){ + if(n-- == 0) + return; + x = --nundo % nelem(undo); + if((tmp = undo[x]) == nil) + return; + undo[x] = nil; + if(canvas == nil || canvas->chan != tmp->chan){ + freeimage(canvas); + canvas = tmp; + update(nil); + } else { + expand(tmp->r); + draw(canvas, tmp->r, tmp, nil, tmp->r.min); + update(&tmp->r); + freeimage(tmp); + } + } +} + +typedef struct { + Rectangle r; + Rectangle r0; + Image* dst; + + int yscan; /* current scanline */ + int wscan; /* bscan width in bytes */ + Image* iscan; /* scanline image */ + uchar* bscan; /* scanline buffer */ + + int nmask; /* size of bmask in bytes */ + int wmask; /* width of bmask in bytes */ + Image* imask; /* mask image */ + uchar* bmask; /* mask buffer */ + + int ncmp; + uchar bcmp[4]; +} Filldata; + +void +fillscan(Filldata *f, Point p0) +{ + int x, y; + uchar *b; + + x = p0.x; + y = p0.y; + b = f->bmask + y*f->wmask; + if(b[x/8] & 0x80>>(x%8)) + return; + + if(f->yscan != y){ + draw(f->iscan, f->iscan->r, f->dst, nil, Pt(f->r.min.x, f->r.min.y+y)); + if(unloadimage(f->iscan, f->iscan->r, f->bscan, f->wscan) < 0) + return; + f->yscan = y; + } + + for(x = p0.x; x >= 0; x--){ + if(memcmp(f->bscan + x*f->ncmp, f->bcmp, f->ncmp)) + break; + b[x/8] |= 0x80>>(x%8); + } + for(x = p0.x+1; x < f->r0.max.x; x++){ + if(memcmp(f->bscan + x*f->ncmp, f->bcmp, f->ncmp)) + break; + b[x/8] |= 0x80>>(x%8); + } + + y = p0.y-1; + if(y >= 0){ + for(x = p0.x; x >= 0; x--){ + if((b[x/8] & 0x80>>(x%8)) == 0) + break; + fillscan(f, Pt(x, y)); + } + for(x = p0.x+1; x < f->r0.max.x; x++){ + if((b[x/8] & 0x80>>(x%8)) == 0) + break; + fillscan(f, Pt(x, y)); + } + } + + y = p0.y+1; + if(y < f->r0.max.y){ + for(x = p0.x; x >= 0; x--){ + if((b[x/8] & 0x80>>(x%8)) == 0) + break; + fillscan(f, Pt(x, y)); + } + for(x = p0.x+1; x < f->r0.max.x; x++){ + if((b[x/8] & 0x80>>(x%8)) == 0) + break; + fillscan(f, Pt(x, y)); + } + } +} + +void +floodfill(Image *dst, Rectangle r, Point p, Image *src) +{ + Filldata f; + + if(!rectclip(&r, dst->r)) + return; + if(!ptinrect(p, r)) + return; + memset(&f, 0, sizeof(f)); + f.dst = dst; + f.r = r; + f.r0 = rectsubpt(r, r.min); + f.wmask = bytesperline(f.r0, 1); + f.nmask = f.wmask*f.r0.max.y; + if((f.bmask = mallocz(f.nmask, 1)) == nil) + goto out; + if((f.imask = allocimage(display, f.r0, GREY1, 0, DNofill)) == nil) + goto out; + + r = f.r0; + r.max.y = 1; + if((f.iscan = allocimage(display, r, RGB24, 0, DNofill)) == nil) + goto out; + f.yscan = -1; + f.wscan = bytesperline(f.iscan->r, f.iscan->depth); + if((f.bscan = mallocz(f.wscan, 0)) == nil) + goto out; + + r = Rect(0,0,1,1); + f.ncmp = (f.iscan->depth+7) / 8; + draw(f.iscan, r, dst, nil, p); + if(unloadimage(f.iscan, r, f.bcmp, sizeof(f.bcmp)) < 0) + goto out; + + fillscan(&f, subpt(p, f.r.min)); + + loadimage(f.imask, f.imask->r, f.bmask, f.nmask); + draw(f.dst, f.r, src, f.imask, f.imask->r.min); +out: + free(f.bmask); + free(f.bscan); + if(f.iscan) + freeimage(f.iscan); + if(f.imask) + freeimage(f.imask); +} + +void +translate(Point d) +{ + Rectangle r, nr; + + if(canvas==nil || d.x==0 && d.y==0) + return; + r = c2sr(canvas->r); + nr = rectaddpt(r, d); + rectclip(&r, screen->clipr); + draw(screen, rectaddpt(r, d), screen, nil, r.min); + zoomdraw(screen, nr, rectaddpt(r, d), back, canvas, canvas->r.min, zoom); + gendrawdiff(screen, screen->r, nr, back, ZP, nil, ZP, SoverD); + spos = addpt(spos, d); + flushimage(display, 1); +} + +void +setzoom(Point o, int z) +{ + if(z < 1) + return; + cpos = s2c(o); + spos = o; + zoom = z; + update(nil); +} + +void +center(void) +{ + cpos = ZP; + if(canvas) + cpos = addpt(canvas->r.min, + divpt(subpt(canvas->r.max, canvas->r.min), 2)); + spos = addpt(screen->r.min, + divpt(subpt(screen->r.max, screen->r.min), 2)); + update(nil); +} + +void +drawpal(void) +{ + Rectangle r, rr; + int i; + + r = screen->r; + r.min.y = r.max.y - 20; + replclipr(screen, 0, r); + + penr = r; + penr.min.x = r.max.x - NBRUSH*Dy(r); + + palr = r; + palr.max.x = penr.min.x; + + r = penr; + draw(screen, r, back, nil, ZP); + for(i=0; ir; + r.max.y -= Dy(palr); + replclipr(screen, 0, r); +} + +int +hitpal(Mouse m) +{ + if(ptinrect(m.xy, penr)){ + if(m.buttons & 7){ + brush = ((m.xy.x - penr.min.x) * NBRUSH) / Dx(penr); + drawpal(); + } + return 1; + } + if(ptinrect(m.xy, palr)){ + Image *col; + + col = pal[(m.xy.x - palr.min.x) * nelem(pal) / Dx(palr)]; + switch(m.buttons & 7){ + case 1: + ink = col; + drawpal(); + break; + case 2: + back = col; + drawpal(); + update(nil); + break; + } + return 1; + } + return 0; +} + +void +catch(void * _, char *msg) +{ + USED(_); + if(strstr(msg, "closed pipe")) + noted(NCONT); + noted(NDFLT); +} + +int +pipeline(char *fmt, ...) +{ + char buf[1024]; + va_list a; + int p[2]; + + va_start(a, fmt); + vsnprint(buf, sizeof(buf), fmt, a); + va_end(a); + if(pipe(p) < 0) + return -1; + switch(rfork(RFPROC|RFMEM|RFFDG|RFNOTEG)){ // RFEND not available in libc port + case -1: + close(p[0]); + close(p[1]); + return -1; + case 0: + close(p[1]); + dup(p[0], 0); + dup(p[0], 1); + close(p[0]); + execl("/bin/rc", "rc", "-c", buf, nil); + exits("exec"); + } + close(p[0]); + return p[1]; +} + +void +usage(void) +{ + fprint(2, "usage: %s [ file ]\n", argv0); + exits("usage"); +} + +void +main(int argc, char *argv[]) +{ + char *s, buf[1024]; + Rectangle r; + Image *img; + int i, fd; + Event e; + Mouse m; + Point p, d; + + ARGBEGIN { + default: + usage(); + } ARGEND; + + if(argc == 1) + filename = strdup(argv[0]); + else if(argc != 0) + usage(); + + if(initdraw(0, 0, "paint") < 0) + sysfatal("initdraw: %r"); + + if(filename){ + if((fd = open(filename, OREAD)) < 0) + sysfatal("open: %r"); + if((canvas = readimage(display, fd, 0)) == nil) + sysfatal("readimage: %r"); + close(fd); + } + + /* palette initialization */ + for(i=0; ir)){ + back = img; + drawpal(); + update(nil); + break; + } + r = canvas->r; + save(r, 1); + floodfill(canvas, r, p, img); + update(&r); + + /* wait for mouse release */ + while(event(&e) == Emouse && (e.mouse.buttons & 7) != 0) + ; + break; + } + r = strokerect(Rpt(p, p), brush); + expand(r); + save(r, 1); + strokedraw(canvas, Rpt(p, p), img, brush); + update(&r); + for(;;){ + m = e.mouse; + if(event(&e) != Emouse) + break; + if((e.mouse.buttons ^ m.buttons) & 7) + break; + d = s2c(e.mouse.xy); + if(eqpt(d, p)) + continue; + r = strokerect(Rpt(p, d), brush); + expand(r); + save(r, 0); + strokedraw(canvas, Rpt(p, d), img, brush); + update(&r); + p = d; + } + break; + case 4: + for(;;){ + m = e.mouse; + if(event(&e) != Emouse) + break; + if((e.mouse.buttons & 7) != 4) + break; + translate(subpt(e.mouse.xy, m.xy)); + } + break; + } + break; + case Ekeyboard: + switch(e.kbdc){ + case Kesc: + zoom = 1; + center(); + break; + case '+': + if(zoom < 0x1000) + setzoom(e.mouse.xy, zoom*2); + break; + case '-': + if(zoom > 1) + setzoom(e.mouse.xy, zoom/2); + break; + case 'c': + if(canvas == nil) + break; + save(canvas->r, 1); + freeimage(canvas); + canvas = nil; + update(nil); + break; + case 'u': + restore(16); + break; + case 'f': + brush = NBRUSH-1; + drawpal(); + break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + brush = e.kbdc - '0'; + drawpal(); + break; + default: + if(e.kbdc == Kdel) + e.kbdc = 'q'; + buf[0] = 0; + if(filename && (e.kbdc == 'r' || e.kbdc == 'w')) + snprint(buf, sizeof(buf), "%C %s", e.kbdc, filename); + else if(e.kbdc > 0x20 && e.kbdc < 0x7f) + snprint(buf, sizeof(buf), "%C", e.kbdc); + if(eenter("Cmd", buf, sizeof(buf), &e.mouse) <= 0) + break; + if(strcmp(buf, "q") == 0) + exits(nil); + s = buf+1; + while(*s == ' ' || *s == '\t') + s++; + if(*s == 0) + break; + switch(buf[0]){ + case 'r': + if((fd = open(s, OREAD)) < 0){ + Error: + snprint(buf, sizeof(buf), "%r"); + eenter(buf, nil, 0, &e.mouse); + break; + } + free(filename); + filename = strdup(s); + Readimage: + unlockdisplay(display); + img = readimage(display, fd, 1); + close(fd); + lockdisplay(display); + if(img == nil){ + werrstr("readimage: %r"); + goto Error; + } + if(canvas){ + save(canvas->r, 1); + freeimage(canvas); + } + canvas = img; + center(); + break; + case 'w': + if((fd = create(s, OWRITE, 0660)) < 0) + goto Error; + free(filename); + filename = strdup(s); + Writeimage: + if(canvas) + if(writeimage(fd, canvas, 0) < 0){ + close(fd); + werrstr("writeimage: %r"); + goto Error; + } + close(fd); + break; + case '<': + if((fd = pipeline("%s", s)) < 0) + goto Error; + goto Readimage; + case '>': + if((fd = pipeline("%s", s)) < 0) + goto Error; + goto Writeimage; + case '|': + if(canvas == nil) + break; + if((fd = pipeline("%s", s)) < 0) + goto Error; + switch(rfork(RFMEM|RFPROC|RFFDG)){ + case -1: + close(fd); + werrstr("rfork: %r"); + goto Error; + case 0: + writeimage(fd, canvas, 1); + exits(nil); + } + goto Readimage; + } + break; + } + break; + } + } +} + +void +eresized(int _) +{ + USED(_); + if(getwindow(display, Refnone) < 0) + sysfatal("resize failed"); + drawpal(); + update(nil); +} From 3ae09bee86485f1aaa517f68ed2823ae9b960524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Thu, 8 Feb 2018 13:59:31 +0100 Subject: [PATCH 051/323] file: add missing newlines to file types --- src/cmd/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/file.c b/src/cmd/file.c index 0afb9ba3a..232c1b306 100644 --- a/src/cmd/file.c +++ b/src/cmd/file.c @@ -519,10 +519,10 @@ Filemagic long0tab[] = { 0x32636170, 0xFFFF00FF, "pac4 audio file\n", OCTET, 0xBA010000, 0xFFFFFFFF, "mpeg system stream\n", OCTET, 0x30800CC0, 0xFFFFFFFF, "inferno .dis executable\n", OCTET, - 0x04034B50, 0xFFFFFFFF, "zip archive\n", "application/zip", + 0x04034B50, 0xFFFFFFFF, "zip archive\n", "application/zip\n", 070707, 0xFFFF, "cpio archive\n", OCTET, - 0x2F7, 0xFFFF, "tex dvi\n", "application/dvi", - 0xfffa0000, 0xfffe0000, "mp3 audio", "audio/mpeg", + 0x2F7, 0xFFFF, "tex dvi\n", "application/dvi\n", + 0xfffa0000, 0xfffe0000, "mp3 audio\n", "audio/mpeg\n", }; int From 3ebbb99ce3b13357f4dfb0156877c6e5892de5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Thu, 8 Feb 2018 14:00:46 +0100 Subject: [PATCH 052/323] file: recognize Mach-O binaries and Java class files --- src/cmd/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/file.c b/src/cmd/file.c index 232c1b306..32d580cdf 100644 --- a/src/cmd/file.c +++ b/src/cmd/file.c @@ -523,6 +523,9 @@ Filemagic long0tab[] = { 070707, 0xFFFF, "cpio archive\n", OCTET, 0x2F7, 0xFFFF, "tex dvi\n", "application/dvi\n", 0xfffa0000, 0xfffe0000, "mp3 audio\n", "audio/mpeg\n", + 0xcafebabe, 0xFFFFFFFF, "Mach-O fat executable\n", "application/x-mach-binary\n", + 0xfeedface, 0xFFFFFFFE, "Mach-O executable\n", "application/x-mach-binary\n", + 0xbebafeca, 0xFFFFFFFF, "Java class\n", "application/x-java-applet\n", }; int From 16d00819899260085ee10949012b07bf1c203db6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 15 Nov 2018 23:52:05 -0500 Subject: [PATCH 053/323] libdraw: redo default font construction to be hidpi-safe If $font is not set, the default font is constructed from font data linked into every libdraw binary. That process was different from the usual openfont code, and so it was not hidpi-aware, resulting in very tiny fonts out of the box on hidpi systems, until users set $font. Fix this by using openfont to construct the default font, by recognizing the name *default* when looking for font and subfont file contents. Then all the hidpi scaling applies automatically. As a side effect, the concept of a 'default subfont' is gone, as are display->defaultsubfont, getdefont, and memgetdefont. --- include/draw.h | 4 - include/memdraw.h | 1 - man/man3/graphics.3 | 11 +- man/man3/memdraw.3 | 3 - src/cmd/fontsrv/a.h | 1 - src/cmd/fontsrv/main.c | 3 - src/libdraw/buildfont.c | 2 +- src/libdraw/defont.c | 402 ------------------------------------- src/libdraw/defont.h | 303 ++++++++++++++++++++++++++++ src/libdraw/font.c | 3 +- src/libdraw/getdefont.c | 60 ------ src/libdraw/getsubfont.c | 31 ++- src/libdraw/init.c | 32 +-- src/libdraw/mkfile | 4 +- src/libdraw/openfont.c | 7 + src/libdraw/readsubfont.c | 16 ++ src/libdraw/subfontcache.c | 2 - src/libdraw/subfontname.c | 7 +- src/libmemdraw/defont.c | 68 ------- src/libmemdraw/mkfile | 1 - 20 files changed, 374 insertions(+), 587 deletions(-) delete mode 100644 src/libdraw/defont.c create mode 100644 src/libdraw/defont.h delete mode 100644 src/libdraw/getdefont.c delete mode 100644 src/libmemdraw/defont.c diff --git a/include/draw.h b/include/draw.h index 2f283bdf1..926cc7486 100644 --- a/include/draw.h +++ b/include/draw.h @@ -199,7 +199,6 @@ struct Display int obufsize; uchar *obufp; Font *defaultfont; - Subfont *defaultsubfont; Image *windows; Image *screenimage; int _isnewdisplay; @@ -498,7 +497,6 @@ extern Point strsubfontwidth(Subfont*, char*); extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**); extern char* subfontname(char*, char*, int); extern Subfont* _getsubfont(Display*, char*); -extern Subfont* getdefont(Display*); extern void lockdisplay(Display*); extern void unlockdisplay(Display*); extern int drawlsetrefresh(u32int, int, void*, void*); @@ -508,8 +506,6 @@ extern void swapfont(Font*, Font**, Font**); /* * Predefined */ -extern uchar defontdata[]; -extern int sizeofdefont; extern Point ZP; extern Rectangle ZR; diff --git a/include/memdraw.h b/include/memdraw.h index b1495ed82..a22dbe2bb 100644 --- a/include/memdraw.h +++ b/include/memdraw.h @@ -178,7 +178,6 @@ extern Memsubfont* allocmemsubfont(char*, int, int, int, Fontchar*, Memimage*); extern Memsubfont* openmemsubfont(char*); extern void freememsubfont(Memsubfont*); extern Point memsubfontwidth(Memsubfont*, char*); -extern Memsubfont* getmemdefont(void); /* * Predefined diff --git a/man/man3/graphics.3 b/man/man3/graphics.3 index a2b2d8480..4f58451a0 100644 --- a/man/man3/graphics.3 +++ b/man/man3/graphics.3 @@ -1,6 +1,6 @@ .TH GRAPHICS 3 .SH NAME -Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, initdisplay, closedisplay, getdefont, getwindow, gengetwindow, flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, chantostr, chantodepth \- interactive graphics +Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, initdisplay, closedisplay, getwindow, gengetwindow, flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, chantostr, chantodepth \- interactive graphics .SH SYNOPSIS .nf .PP @@ -38,9 +38,6 @@ Display* initdisplay(char *devdir, char *win, void(*errfun)(Display*, char*)) void closedisplay(Display *d) .PP .B -Font* getdefont(Display *d) -.PP -.B int flushimage(Display *d, int vis) .PP .B @@ -398,11 +395,7 @@ names the directory, default in which the files associated with the window reside. .I Closedisplay disconnects the display and frees the associated data structures. -.I Getdefont -builds a -.B Font -structure from in-core data describing a default font. -None of these routines is needed by most programs, since +Neither of these routines is needed by most programs, since .I initdraw calls them as needed. .PP diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3 index 3f6c483ef..16a5cd796 100644 --- a/man/man3/memdraw.3 +++ b/man/man3/memdraw.3 @@ -152,7 +152,6 @@ Memsubfont* allocmemsubfont(char *name, int n, int height, Memsubfont* openmemsubfont(char *name) void freememsubfont(Memsubfont *f) Point memsubfontwidth(Memsubfont *f, char *s) -Memsubfont* getmemdefont(void) Point memimagestring(Memimage *dst, Point p, Memimage *color, Point cp, Memsubfont *f, char *cs, Drawop op) .PP @@ -354,7 +353,6 @@ Similarly, .IR openmemsubfont , .IR freememsubfont , .IR memsubfontwidth , -.IR getmemdefont , and .I memimagestring are the @@ -364,7 +362,6 @@ analogues of .IR openfont , .IR freesubfont , .IR strsubfontwidth , -.IR getdefont , and .B string (see diff --git a/src/cmd/fontsrv/a.h b/src/cmd/fontsrv/a.h index 3344d28e4..164b1bd6c 100644 --- a/src/cmd/fontsrv/a.h +++ b/src/cmd/fontsrv/a.h @@ -30,6 +30,5 @@ Memsubfont* mksubfont(XFont*, char*, int, int, int, int); extern XFont *xfont; extern int nxfont; void *emalloc9p(ulong); -extern Memsubfont *defont; void drawpjw(Memimage*, Fontchar*, int, int, int, int); diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index b00802d88..37f0da32d 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -13,8 +13,6 @@ #include "a.h" -Memsubfont *defont; - void usage(void) { @@ -526,7 +524,6 @@ main(int argc, char **argv) fmtinstall('R', Rfmt); fmtinstall('P', Pfmt); memimageinit(); - defont = getmemdefont(); loadfonts(); qsort(xfont, nxfont, sizeof xfont[0], fontcmp); diff --git a/src/libdraw/buildfont.c b/src/libdraw/buildfont.c index ed533b142..02d976e17 100644 --- a/src/libdraw/buildfont.c +++ b/src/libdraw/buildfont.c @@ -132,7 +132,7 @@ freefont(Font *f) } for(i=0; insubf; i++){ s = f->subf[i].f; - if(s && (!display || s!=display->defaultsubfont)) + if(s) freesubfont(s); } freeimage(f->cacheimage); diff --git a/src/libdraw/defont.c b/src/libdraw/defont.c deleted file mode 100644 index b0c85e1dc..000000000 --- a/src/libdraw/defont.c +++ /dev/null @@ -1,402 +0,0 @@ -#include -#include -#include - -/* - * lucm/latin1.9, in uncompressed form - */ -uchar -defontdata[] = -{ -0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20, -0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, -0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x33,0x30,0x34,0x20, -0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x35,0x20,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x30,0x06,0x06,0x03,0x42,0x40,0x00,0x00,0x00,0x18,0x03,0x03, -0x02,0x43,0x00,0x60,0x60,0x48,0x00,0x0d,0x0c,0x01,0x81,0x80,0xd0,0x90,0x00,0x00, -0x18,0x01,0x81,0x81,0x40,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x7f,0x9c,0x1c, -0x0e,0x07,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x70, -0x38,0x1c,0x0e,0x04,0x81,0xc1,0xc0,0x70,0x00,0x1c,0x1c,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaa,0x80,0xc0,0x63,0xe3, -0xf1,0xf8,0xfe,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x7f,0xff,0xff,0x1f,0x8f, -0xc7,0xe3,0xf1,0xfb,0x7e,0x3e,0x3f,0x8f,0xff,0xe3,0xe3,0xff,0xff,0xff,0xff,0xff, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x0c,0x18,0x09,0x05,0x82,0x40,0xc0,0x00,0x00,0x06,0x0c,0x04, -0x82,0x40,0xc1,0x80,0x90,0x48,0x00,0x16,0x03,0x06,0x02,0x41,0x60,0x90,0x00,0x00, -0x06,0x06,0x02,0x41,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x7f,0xa0,0x10, -0x08,0x04,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x48, -0x24,0x12,0x09,0x06,0x82,0x01,0x00,0x90,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x04,0x80,0x00,0x40,0x00,0x00,0x38,0x06,0x18,0x00,0x00,0x00,0x00,0x00, -0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x07,0xc6,0x01,0xf0,0x00,0x00,0x0c,0x00,0x18,0x00,0x00,0x30,0x00,0x3c, -0x00,0x60,0x06,0x01,0x8c,0x07,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0xc3,0xc0,0x01,0x54,0x9c,0xc0,0x5f,0xef, -0xf7,0xfb,0xfd,0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0x7f,0xff,0xff,0x6f,0xb7, -0xdb,0xed,0xf6,0xf9,0x7d,0xfe,0xff,0x6f,0xff,0xdf,0xef,0xff,0xff,0xff,0xff,0xff, -0xff,0x00,0x01,0x00,0x00,0x00,0x00,0x30,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x30,0x06,0x06,0x06,0x82,0x80,0xc0,0x00, -0x00,0x18,0x03,0x03,0x02,0x41,0x80,0x30,0x30,0x24,0x76,0x0d,0x0c,0x00,0xc0,0xc0, -0xd0,0x50,0x00,0x00,0x18,0x01,0x81,0x81,0x40,0x30,0x00,0x28,0x0f,0x7f,0xbc,0x1c, -0x0e,0x07,0x03,0xc0,0x10,0x70,0x24,0x10,0x09,0x07,0x03,0x80,0xe0,0x70,0x90,0x48, -0x24,0x12,0x09,0x05,0x81,0x81,0xc0,0x80,0x70,0x18,0x1c,0x07,0x01,0xc1,0xc0,0x90, -0x00,0x0c,0x04,0x84,0x83,0xe1,0xc0,0xe0,0x38,0x0c,0x0c,0x02,0x00,0x00,0x00,0x00, -0x00,0x06,0x1c,0x06,0x0f,0x87,0xc0,0x63,0xf8,0x78,0xfe,0x3e,0x0e,0x00,0x00,0x00, -0x00,0x00,0x00,0x7c,0x1c,0x0c,0x1f,0x03,0xc7,0xc3,0xf1,0xf8,0x3c,0x63,0x3f,0x0f, -0x8c,0x66,0x06,0x19,0x84,0x78,0x7e,0x1e,0x1f,0x07,0xcf,0xf3,0x1b,0x0d,0x86,0x63, -0x61,0x9f,0xc6,0x06,0x00,0x30,0x00,0x00,0x10,0x00,0x18,0x00,0x00,0x30,0x00,0x60, -0x00,0x60,0x06,0x01,0x8c,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80, -0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0xc0,0x60,0x00,0xaa,0xb6,0xc0,0x43,0xe3, -0xf1,0xf8,0xfc,0x3f,0xef,0x8f,0xdb,0xef,0xf6,0xf8,0xfb,0xff,0x1f,0x8f,0x6f,0xb7, -0xdb,0xed,0xf6,0xfa,0x7e,0x7e,0x3f,0x7f,0x8f,0xe7,0xe3,0xf8,0xfe,0x3e,0x3f,0x6f, -0x00,0x00,0x01,0x01,0xc8,0x0b,0x0c,0x30,0x7c,0x14,0x0f,0x0f,0x00,0x00,0x00,0x00, -0x78,0x00,0x1c,0x00,0x0f,0x07,0x81,0x80,0x00,0x7c,0x00,0x00,0x1c,0x0f,0x80,0x04, -0x42,0x23,0x90,0x00,0x18,0x0c,0x06,0x03,0x01,0x80,0xc0,0x3c,0x3c,0x3f,0x1f,0x8f, -0xc7,0xe7,0xe3,0xf1,0xf8,0xfc,0x7c,0x30,0x8f,0x07,0x83,0xc1,0xe0,0xf0,0x00,0x3d, -0x31,0x98,0xcc,0x66,0x36,0x19,0x80,0xcc,0x0c,0x18,0x09,0x0b,0x02,0x81,0x20,0x00, -0x00,0x06,0x0c,0x04,0x82,0x40,0x60,0xc0,0x48,0x24,0x18,0x16,0x03,0x03,0x01,0x21, -0x60,0x50,0x00,0x00,0x06,0x06,0x02,0x41,0x40,0xc1,0x80,0x28,0x87,0x7f,0x84,0x10, -0x08,0x04,0x02,0x40,0x38,0x48,0x24,0x10,0x09,0x04,0x04,0x81,0x00,0x80,0x90,0x48, -0x24,0x12,0x09,0x04,0x80,0x41,0x00,0x80,0x40,0x04,0x10,0x04,0x02,0x01,0x20,0x90, -0x00,0x0c,0x04,0x84,0x86,0x53,0x65,0xb0,0x08,0x18,0x06,0x0a,0x80,0x00,0x00,0x00, -0x00,0x0c,0x36,0x0e,0x19,0xcc,0xe0,0xe3,0xf8,0xcc,0xfe,0x63,0x1b,0x00,0x00,0x00, -0x00,0x00,0x00,0xc6,0x62,0x0c,0x19,0x86,0x66,0x63,0x01,0x80,0x66,0x63,0x0c,0x01, -0x8c,0xc6,0x06,0x19,0xc4,0xcc,0x63,0x33,0x19,0x8c,0x61,0x83,0x1b,0x0d,0x86,0x63, -0x61,0x80,0xc6,0x03,0x00,0x30,0x30,0x00,0x1c,0x00,0x18,0x00,0x00,0x30,0x00,0x60, -0x00,0x60,0x00,0x00,0x0c,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80, -0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0xc0,0x60,0x01,0x54,0x86,0xc0,0x7b,0xef, -0xf7,0xfb,0xfd,0xbf,0xc7,0xb7,0xdb,0xef,0xf6,0xfb,0xfb,0x7e,0xff,0x7f,0x6f,0xb7, -0xdb,0xed,0xf6,0xfb,0x7f,0xbe,0xff,0x7f,0xbf,0xfb,0xef,0xfb,0xfd,0xfe,0xdf,0x6f, -0xff,0x00,0x07,0x83,0x24,0x13,0x0c,0x30,0xc6,0x00,0x10,0x81,0x80,0x00,0x00,0x00, -0x84,0x00,0x22,0x00,0x01,0x80,0xc0,0x00,0x00,0xf4,0x00,0x00,0x2c,0x18,0xc0,0x0c, -0x46,0x20,0x90,0x00,0x18,0x0c,0x06,0x03,0x01,0x80,0xc0,0x70,0x66,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x66,0x38,0x99,0x8c,0xc6,0x63,0x31,0x98,0x00,0x66, -0x31,0x98,0xcc,0x66,0x36,0x19,0x80,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0xff,0x7f,0xb8,0x1c, -0x0e,0x07,0x02,0x40,0x7c,0x70,0x3c,0x10,0x09,0x07,0x04,0x00,0xc0,0x60,0xe0,0x70, -0x38,0x1c,0x0e,0x04,0x83,0x81,0xc0,0x70,0x70,0x38,0x1c,0x07,0x02,0xc1,0xc0,0x90, -0x00,0x0c,0x00,0x04,0x86,0x43,0x69,0xb0,0x30,0x18,0x06,0x07,0x01,0x00,0x00,0x00, -0x00,0x0c,0x63,0x16,0x00,0xc0,0x61,0x62,0x01,0x80,0x06,0x63,0x31,0x80,0x00,0x00, -0x60,0x00,0xc0,0x06,0x43,0x16,0x19,0x8c,0x06,0x33,0x01,0x80,0xc0,0x63,0x0c,0x01, -0x8c,0x86,0x07,0x39,0xc5,0x86,0x63,0x61,0x99,0x8c,0x01,0x83,0x1b,0x0d,0xb6,0x63, -0x31,0x01,0x86,0x03,0x00,0x30,0x30,0x00,0x1c,0x3e,0x1b,0x03,0xc1,0xf0,0xf0,0x60, -0x3e,0x6e,0x3e,0x0f,0x8c,0x60,0xc5,0xb1,0xb8,0x38,0x6c,0x0f,0x8c,0xc7,0xc1,0x83, -0x19,0x8d,0x82,0x63,0x31,0x9f,0xc1,0x80,0xc0,0xc0,0x00,0xaa,0x86,0xc0,0x47,0xe3, -0xf1,0xf8,0xfd,0xbf,0x83,0x8f,0xc3,0xef,0xf6,0xf8,0xfc,0xff,0x3f,0x9f,0x1f,0x8f, -0xc7,0xe3,0xf1,0xfb,0x7c,0x7e,0x3f,0x8f,0x8f,0xc7,0xe3,0xf8,0xfd,0x3e,0x3f,0x6f, -0x00,0x0c,0x0d,0x43,0x03,0xe1,0x88,0x30,0xc0,0x00,0x27,0x41,0x80,0x00,0x00,0x01, -0x72,0x00,0x22,0x04,0x01,0x80,0xc0,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xc0,0x04, -0x82,0x43,0x20,0x18,0x2c,0x16,0x0b,0x05,0x82,0xc1,0x60,0xb0,0xc0,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x38,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x00,0xc7, -0x31,0x98,0xcc,0x66,0x33,0x11,0xf8,0xc8,0x7c,0x3e,0x1f,0x0f,0x87,0xc3,0xe1,0xd8, -0x3c,0x1e,0x0f,0x07,0x83,0xc7,0xc3,0xe1,0xf0,0xf8,0x06,0x37,0x07,0x03,0x81,0xc0, -0xe0,0x70,0x10,0x1d,0x31,0x98,0xcc,0x66,0x33,0x19,0xb0,0xc6,0x8f,0x7f,0x87,0x03, -0x81,0x80,0x90,0x30,0x6c,0x48,0x24,0x10,0x06,0x04,0x04,0x80,0x20,0x10,0x10,0x0e, -0x07,0x03,0x81,0xc0,0x60,0x88,0x38,0x0c,0x40,0x09,0x03,0x84,0x02,0x41,0x40,0x90, -0x00,0x0c,0x00,0x1f,0xe7,0x41,0xd1,0xa0,0x00,0x30,0x03,0x0a,0x81,0x00,0x00,0x00, -0x00,0x18,0x63,0x06,0x00,0xc0,0xc2,0x62,0x01,0xb0,0x0c,0x72,0x31,0x86,0x03,0x00, -0xc0,0x00,0x60,0x06,0x8f,0x16,0x19,0x0c,0x06,0x33,0x01,0x80,0xc0,0x63,0x0c,0x01, -0x8d,0x06,0x07,0x39,0x65,0x86,0x63,0x61,0x99,0x0e,0x01,0x83,0x19,0x89,0xb6,0x32, -0x33,0x03,0x06,0x01,0x80,0x30,0x78,0x00,0x00,0x03,0x1d,0x86,0x23,0x31,0x99,0xfc, -0x66,0x77,0x06,0x01,0x8c,0x40,0xc6,0xd9,0xdc,0x6c,0x76,0x19,0x8d,0xcc,0x27,0xf3, -0x19,0x8d,0x82,0x63,0x31,0x80,0xc0,0x80,0xc0,0x80,0x01,0x54,0x8c,0xc0,0x78,0xfc, -0x7e,0x7f,0x6f,0xcf,0x93,0xb7,0xdb,0xef,0xf9,0xfb,0xff,0xff,0xdf,0xef,0xef,0xf1, -0xf8,0xfc,0x7e,0x3f,0x9f,0x77,0xc7,0xf3,0xbf,0xf6,0xfc,0x7b,0xfd,0xbe,0xbf,0x6f, -0xff,0x0c,0x19,0x03,0x03,0x61,0x98,0x30,0x78,0x00,0x28,0x4f,0x83,0x30,0x00,0x01, -0x4a,0x00,0x1c,0x04,0x03,0x03,0x80,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xd9,0x84, -0x82,0x40,0xa0,0x18,0x2c,0x16,0x0b,0x05,0x82,0xc1,0x60,0xb0,0xc0,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x2c,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x64,0xcb, -0x31,0x98,0xcc,0x66,0x33,0x31,0x8c,0xd8,0x06,0x03,0x01,0x80,0xc0,0x60,0x30,0x6c, -0x62,0x33,0x19,0x8c,0xc6,0x60,0xc0,0x60,0x30,0x18,0x1e,0x3b,0x8d,0x86,0xc3,0x61, -0xb0,0xd8,0x10,0x36,0x31,0x98,0xcc,0x66,0x33,0x19,0xd8,0xc6,0x0f,0x7f,0x82,0x01, -0x02,0x40,0xd0,0x40,0x6c,0x70,0x24,0x1c,0x06,0x04,0x03,0x01,0xc0,0xe0,0x10,0x12, -0x09,0x04,0x82,0x40,0x90,0x50,0x10,0x12,0x70,0x09,0x04,0x04,0x01,0xc1,0x20,0x60, -0x00,0x0c,0x00,0x04,0x83,0xc0,0x20,0xcc,0x00,0x30,0x03,0x02,0x01,0x00,0x00,0x00, -0x00,0x18,0x63,0x06,0x01,0x83,0x84,0x63,0xf1,0xd8,0x18,0x3c,0x31,0x86,0x03,0x01, -0x83,0xf8,0x30,0x1c,0x9b,0x33,0x1e,0x0c,0x06,0x33,0xe1,0x80,0xc0,0x7f,0x0c,0x01, -0x8f,0x06,0x07,0x79,0x65,0x86,0x66,0x61,0x9e,0x07,0x81,0x83,0x19,0x89,0xb6,0x1c, -0x1a,0x03,0x06,0x01,0x80,0x30,0x48,0x00,0x00,0x03,0x18,0xcc,0x06,0x33,0x18,0x60, -0xc6,0x63,0x06,0x01,0x8c,0x80,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8e,0x4c,0x01,0x83, -0x19,0x8d,0x92,0x32,0x31,0x81,0x87,0x00,0xc0,0x70,0xe4,0xaa,0x98,0xc0,0x7d,0xfe, -0xfd,0xbf,0x2f,0xbf,0x93,0x8f,0xdb,0xe3,0xf9,0xfb,0xff,0x1e,0x3f,0x1f,0xef,0xed, -0xf6,0xfb,0x7d,0xbf,0x6f,0xaf,0xef,0xed,0x8f,0xf6,0xfb,0xfb,0xfe,0x3e,0xdf,0x9f, -0x00,0x00,0x19,0x0f,0xc6,0x30,0xd0,0x00,0xcc,0x00,0x28,0x59,0x86,0x67,0xf0,0x01, -0x72,0x00,0x00,0x3f,0x86,0x00,0xc0,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xcc,0xc5, -0x32,0x83,0x4c,0x00,0x66,0x33,0x19,0x8c,0xc6,0x63,0x31,0xbc,0xc0,0x3e,0x1f,0x0f, -0x87,0xc1,0x80,0xc0,0x60,0x30,0xfb,0x2c,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x38,0xcb, -0x31,0x98,0xcc,0x66,0x31,0xa1,0x8c,0xcc,0x06,0x03,0x01,0x80,0xc0,0x60,0x30,0x6c, -0xc0,0x63,0x31,0x98,0xcc,0x60,0xc0,0x60,0x30,0x18,0x37,0x31,0x98,0xcc,0x66,0x33, -0x19,0x8c,0x00,0x67,0x31,0x98,0xcc,0x66,0x33,0x19,0x8c,0xc6,0x1f,0x7f,0x82,0x01, -0x02,0x40,0xb0,0x40,0x6c,0x07,0x03,0x83,0x80,0xe0,0xe0,0x00,0x18,0x0e,0x10,0x10, -0x08,0x04,0x02,0x00,0xf0,0x20,0x10,0x1e,0x08,0x89,0x03,0x00,0xe0,0x38,0x1c,0x0e, -0x00,0x0c,0x00,0x04,0x81,0xe0,0x41,0x6c,0x00,0x30,0x03,0x00,0x0f,0xe0,0x03,0xf8, -0x00,0x30,0x63,0x06,0x03,0x00,0xc7,0xf0,0x39,0x8c,0x30,0x3e,0x1b,0x80,0x00,0x03, -0x00,0x00,0x18,0x30,0x9b,0x23,0x19,0x0c,0x06,0x33,0x01,0xf8,0xc6,0x63,0x0c,0x01, -0x8d,0x86,0x05,0xd9,0x35,0x86,0x7c,0x61,0x9b,0x01,0xc1,0x83,0x19,0x99,0xb4,0x1c, -0x0c,0x06,0x06,0x00,0xc0,0x30,0xcc,0x00,0x00,0x3f,0x18,0xcc,0x06,0x33,0xf8,0x60, -0xc6,0x63,0x06,0x01,0x8f,0x00,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x0f,0x81,0x83, -0x18,0xd9,0xba,0x1c,0x1b,0x03,0x00,0x80,0xc0,0x81,0x75,0x54,0x98,0xc0,0x7d,0xfe, -0xfd,0xbf,0x4f,0xbf,0x93,0xf8,0xfc,0x7c,0x7f,0x1f,0x1f,0x6f,0xe7,0xf1,0xef,0xef, -0xf7,0xfb,0xfd,0xff,0x0f,0xdf,0xef,0xe1,0xf7,0x76,0xfc,0xff,0x1f,0xc7,0xe3,0xf1, -0xff,0x08,0x19,0x03,0x06,0x31,0xf8,0x00,0xc6,0x00,0x28,0x5b,0x8c,0xc0,0x11,0xf1, -0x4a,0x00,0x00,0x04,0x0c,0x00,0xc0,0x03,0x18,0x74,0x38,0x00,0x0c,0x18,0xc6,0x65, -0x52,0xb8,0x54,0x18,0x46,0x23,0x11,0x88,0xc4,0x62,0x31,0x30,0xc0,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x26,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x10,0xd3, -0x31,0x98,0xcc,0x66,0x30,0xc1,0x8c,0xc6,0x7e,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xfc, -0xc0,0x7f,0x3f,0x9f,0xcf,0xe0,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33, -0x19,0x8c,0xfe,0x6b,0x31,0x98,0xcc,0x66,0x31,0xb1,0x8c,0x6c,0x0e,0x7f,0x82,0x01, -0x01,0x80,0x90,0x30,0xc6,0x08,0x01,0x02,0x00,0x40,0x80,0xe0,0x24,0x04,0x1c,0x10, -0x08,0x04,0x02,0x00,0x90,0x20,0x10,0x12,0x0d,0x86,0x00,0x81,0x00,0x40,0x20,0x10, -0x00,0x04,0x00,0x1f,0xe1,0x70,0xbb,0x28,0x00,0x30,0x03,0x00,0x01,0x00,0x00,0x00, -0x00,0x30,0x63,0x06,0x06,0x00,0x67,0xf0,0x19,0x8c,0x30,0x67,0x0d,0x80,0x00,0x01, -0x83,0xf8,0x30,0x30,0x9b,0x7f,0x19,0x8c,0x06,0x33,0x01,0x80,0xc6,0x63,0x0c,0x01, -0x8c,0xc6,0x05,0xd9,0x35,0x86,0x60,0x61,0x99,0x80,0xe1,0x83,0x18,0xd0,0xdc,0x26, -0x0c,0x0c,0x06,0x00,0xc0,0x30,0x84,0x00,0x00,0x63,0x18,0xcc,0x06,0x33,0x00,0x60, -0xc6,0x63,0x06,0x01,0x8d,0x80,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x03,0xe1,0x83, -0x18,0xd9,0xba,0x1c,0x1b,0x06,0x01,0x80,0xc0,0xc1,0x38,0xaa,0x80,0xc0,0x7d,0xfe, -0xfe,0x7f,0x6f,0xcf,0x39,0xf7,0xfe,0xfd,0xff,0xbf,0x7f,0x0f,0xdb,0xfb,0xe3,0xef, -0xf7,0xfb,0xfd,0xff,0x6f,0xdf,0xef,0xed,0xf2,0x79,0xff,0x7e,0xff,0xbf,0xdf,0xef, -0x00,0x0c,0x19,0x03,0x03,0x60,0x60,0x30,0x66,0x00,0x28,0x4d,0xc6,0x60,0x10,0x00, -0x84,0x00,0x00,0x04,0x0f,0x87,0x80,0x03,0x18,0x14,0x38,0x00,0x3f,0x0f,0x8c,0xc2, -0x90,0x84,0xa4,0x18,0xfe,0x7f,0x3f,0x9f,0xcf,0xe7,0xf1,0xf0,0xc0,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x26,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x38,0xd3, -0x31,0x98,0xcc,0x66,0x30,0xc1,0x98,0xc6,0xc6,0x63,0x31,0x98,0xcc,0x66,0x33,0x60, -0xc0,0x60,0x30,0x18,0x0c,0x00,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33, -0x19,0x8c,0x00,0x6b,0x31,0x98,0xcc,0x66,0x31,0xb1,0x8c,0x6c,0x1c,0x7f,0x81,0x20, -0x90,0x38,0x18,0x0b,0x83,0x06,0x01,0x03,0x80,0x40,0xe0,0x90,0x24,0x04,0x03,0x8e, -0x86,0xc3,0x61,0x90,0x24,0x12,0x0e,0x04,0x8a,0x81,0xc7,0x70,0xc0,0x30,0x18,0x0c, -0x00,0x00,0x00,0x04,0x81,0x31,0x6f,0x30,0x00,0x18,0x06,0x00,0x01,0x00,0x00,0x00, -0x00,0x60,0x63,0x06,0x0c,0x00,0x60,0x60,0x19,0x8c,0x60,0x63,0x01,0x80,0x00,0x00, -0xc0,0x00,0x60,0x00,0x4d,0xe1,0x99,0x8c,0x06,0x33,0x01,0x80,0xc6,0x63,0x0c,0x01, -0x8c,0xc6,0x04,0x99,0x1d,0x86,0x60,0x61,0x99,0x80,0x61,0x83,0x18,0xd0,0xdc,0x63, -0x0c,0x0c,0x06,0x00,0x60,0x30,0x84,0x00,0x00,0x63,0x18,0xcc,0x06,0x33,0x00,0x60, -0x6e,0x63,0x06,0x01,0x8c,0xc0,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x00,0x61,0x83, -0x18,0xd0,0xcc,0x26,0x0e,0x0c,0x03,0x00,0xc0,0x60,0x01,0x54,0x98,0xc0,0x7e,0xdf, -0x6f,0xc7,0xe7,0xf4,0x7c,0xf9,0xfe,0xfc,0x7f,0xbf,0x1f,0x5f,0xdb,0xfb,0xfc,0x71, -0x79,0x3c,0x9e,0x6f,0xdb,0xed,0xf1,0xfb,0x75,0x7e,0x38,0x8f,0x3f,0xcf,0xe7,0xf3, -0xff,0x0c,0x0d,0x03,0x03,0xe1,0xf8,0x30,0x3c,0x00,0x27,0x40,0x03,0x30,0x00,0x00, -0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x14,0x00,0x00,0x00,0x00,0x19,0x82, -0xf8,0x98,0xbe,0x70,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x30,0xc0,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x23,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x4c,0xe3, -0x31,0x98,0xcc,0x66,0x30,0xc1,0xf0,0xc6,0xc6,0x63,0x31,0x98,0xcc,0x66,0x33,0x60, -0xc0,0x60,0x30,0x18,0x0c,0x00,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33, -0x19,0x8c,0x10,0x73,0x31,0x98,0xcc,0x66,0x30,0xe1,0x8c,0x38,0x1c,0x7f,0x80,0xa0, -0x50,0x10,0x24,0x0d,0xff,0x01,0x01,0x02,0x00,0x40,0x80,0xf0,0x24,0x04,0x02,0x01, -0x81,0x20,0x10,0x30,0x28,0x1a,0x09,0x06,0x8a,0x81,0x20,0x90,0x20,0x08,0x04,0x02, -0x00,0x0c,0x00,0x04,0x85,0x32,0x6f,0xb8,0x00,0x18,0x06,0x00,0x01,0x01,0xc0,0x00, -0x70,0x60,0x36,0x06,0x1f,0xcc,0xe0,0x63,0x30,0xd8,0x60,0x63,0x33,0x06,0x03,0x00, -0x60,0x00,0xc0,0x30,0x60,0x61,0x99,0x86,0x66,0x63,0x01,0x80,0x66,0x63,0x0c,0x03, -0x0c,0x66,0x04,0x19,0x1c,0xcc,0x60,0x33,0x18,0xcc,0x61,0x81,0xb0,0x60,0xcc,0x63, -0x0c,0x18,0x06,0x00,0x60,0x30,0x00,0x00,0x00,0x67,0x19,0x86,0x23,0x71,0x88,0x60, -0x36,0x63,0x06,0x01,0x8c,0x60,0xc6,0xd9,0x8c,0x6c,0x66,0x1b,0x8c,0x08,0x61,0x83, -0xb8,0x70,0xcc,0x63,0x0c,0x18,0x03,0x00,0xc0,0x60,0x00,0xaa,0x98,0xc0,0x7f,0x5f, -0xaf,0xef,0xdb,0xf2,0x00,0xfe,0xfe,0xfd,0xff,0xbf,0x7f,0x6f,0xdb,0xfb,0xfd,0xfe, -0x7e,0xdf,0xef,0xcf,0xd7,0xe5,0xf6,0xf9,0x75,0x7e,0xdf,0x6f,0xdf,0xf7,0xfb,0xfd, -0x00,0x0c,0x07,0xc6,0x04,0x10,0x60,0x30,0x06,0x00,0x10,0x80,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x3f,0x80,0x00,0x00,0x03,0xb8,0x14,0x00,0x00,0x00,0x00,0x00,0x04, -0x11,0x21,0x04,0xc0,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x30,0x66,0x30,0x18,0x0c, -0x06,0x01,0x80,0xc0,0x60,0x30,0x66,0x23,0x99,0x8c,0xc6,0x63,0x31,0x98,0x00,0x66, -0x1b,0x0d,0x86,0xc3,0x60,0xc1,0x80,0xc6,0xce,0x67,0x33,0x99,0xcc,0xe6,0x73,0x74, -0x62,0x31,0x18,0x8c,0x46,0x20,0xc0,0x60,0x30,0x18,0x36,0x31,0x8d,0x86,0xc3,0x61, -0xb0,0xd8,0x10,0x36,0x3b,0x9d,0xce,0xe7,0x70,0xc1,0x98,0x30,0x00,0x7f,0x80,0xc0, -0x60,0x10,0x24,0x0c,0x38,0x0e,0x01,0x02,0x00,0x40,0x80,0xa0,0x18,0x0e,0x03,0x00, -0x80,0x40,0x60,0x50,0x30,0x16,0x0e,0x05,0x88,0x81,0xc0,0x81,0xc0,0x70,0x38,0x1c, -0x00,0x0c,0x00,0x04,0x83,0xe0,0x39,0xcc,0x00,0x0c,0x0c,0x00,0x00,0x01,0xc0,0x00, -0x70,0xc0,0x1c,0x06,0x1f,0xc7,0xc0,0x61,0xe0,0x70,0x60,0x3e,0x1e,0x06,0x03,0x00, -0x00,0x00,0x00,0x30,0x1e,0x61,0x9f,0x03,0xc7,0xc3,0xf1,0x80,0x3e,0x63,0x3f,0x1e, -0x0c,0x67,0xe4,0x19,0x0c,0x78,0x60,0x1e,0x18,0xc7,0xc1,0x80,0xe0,0x60,0xcc,0x63, -0x0c,0x1f,0xc6,0x00,0x30,0x30,0x00,0x00,0x00,0x3b,0x9f,0x03,0xc1,0xb0,0xf0,0x60, -0x06,0x63,0x06,0x01,0x8c,0x70,0xc6,0xd9,0x8c,0x38,0x7c,0x0d,0x8c,0x07,0xc0,0xf1, -0xd8,0x60,0xcc,0x63,0x0c,0x1f,0xc3,0x00,0xc0,0x60,0x01,0x54,0x80,0xc0,0x7f,0x3f, -0x9f,0xef,0xdb,0xf3,0xc7,0xf1,0xfe,0xfd,0xff,0xbf,0x7f,0xff,0xe7,0xf1,0xfc,0xff, -0x7f,0xbf,0x9f,0xaf,0xcf,0xe9,0xf1,0xfa,0x77,0x7e,0x3f,0x7e,0x3f,0x8f,0xc7,0xe3, -0xff,0x0c,0x01,0x0f,0xe8,0x08,0x60,0x30,0xc6,0x00,0x0f,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xd8,0x14,0x00,0x00,0x00,0x00,0x00,0x04, -0x11,0x3d,0x04,0xc0,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x3c,0x3c,0x3f,0x1f,0x8f, -0xc7,0xe7,0xe3,0xf1,0xf8,0xfc,0x7c,0x21,0x8f,0x07,0x83,0xc1,0xe0,0xf0,0x00,0xbc, -0x0e,0x07,0x03,0x81,0xc0,0xc1,0x80,0xcc,0x77,0x3b,0x9d,0xce,0xe7,0x73,0xb9,0x98, -0x3c,0x1e,0x0f,0x07,0x83,0xc0,0xc0,0x60,0x30,0x18,0x1c,0x31,0x87,0x03,0x81,0xc0, -0xe0,0x70,0x00,0x5c,0x1d,0x8e,0xc7,0x63,0xb0,0xc1,0xf0,0x30,0x00,0x7f,0x81,0x40, -0xa0,0x10,0x28,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x00,0x02,0x00, -0x80,0x80,0x10,0xf8,0x28,0x12,0x09,0x04,0x80,0x01,0x20,0x80,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x06,0x18,0x00,0x00,0x00,0x40,0x00, -0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x07,0xc0,0x31,0xf0,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xcc,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x80,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x18,0x00,0x01,0xe0,0xc3,0xc0,0x00,0x00,0xff,0xc0,0x7e,0xbf, -0x5f,0xef,0xd7,0xf5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff, -0x7f,0x7f,0xef,0x07,0xd7,0xed,0xf6,0xfb,0x7f,0xfe,0xdf,0x7f,0xff,0xff,0xff,0xff, -0x00,0x0c,0x01,0x00,0x00,0x00,0x00,0x30,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x14,0x00,0x08,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81,0x80,0x60,0x00,0x7f,0x81,0x20, -0x90,0x10,0x1c,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80, -0x81,0xe0,0x60,0x10,0x24,0x12,0x0e,0x04,0x80,0x01,0xc0,0x70,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x78,0x00,0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x80,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xfe,0xdf, -0x6f,0xef,0xe3,0xf5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x7f, -0x7e,0x1f,0x9f,0xef,0xdb,0xed,0xf1,0xfb,0x7f,0xfe,0x3f,0x8f,0xff,0xff,0xff,0xff, -0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81,0x80,0x60,0x20,0x20,0x20,0x20, -0x20,0x20,0x20,0x20,0x32,0x35,0x36,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, -0x20,0x31,0x35,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x33,0x20, -0x00,0x00,0x01,0x0c,0x00,0x09,0x09,0x00,0x01,0x0f,0x00,0x09,0x12,0x00,0x01,0x0f, -0x00,0x09,0x1b,0x00,0x01,0x0f,0x00,0x09,0x24,0x00,0x01,0x0f,0x00,0x09,0x2d,0x00, -0x01,0x0f,0x00,0x09,0x36,0x00,0x01,0x0f,0x00,0x09,0x3f,0x00,0x03,0x0d,0x00,0x09, -0x48,0x00,0x03,0x0d,0x00,0x09,0x51,0x00,0x03,0x0d,0x00,0x09,0x5a,0x00,0x03,0x0d, -0x00,0x09,0x63,0x00,0x03,0x0d,0x00,0x09,0x6c,0x00,0x03,0x0d,0x00,0x09,0x75,0x00, -0x03,0x0e,0x00,0x09,0x7e,0x00,0x03,0x0d,0x00,0x09,0x87,0x00,0x03,0x0d,0x00,0x09, -0x90,0x00,0x01,0x0f,0x00,0x09,0x99,0x00,0x01,0x0f,0x00,0x09,0xa2,0x00,0x01,0x0f, -0x00,0x09,0xab,0x00,0x01,0x0f,0x00,0x09,0xb4,0x00,0x01,0x0f,0x00,0x09,0xbd,0x00, -0x01,0x0f,0x00,0x09,0xc6,0x00,0x01,0x0f,0x00,0x09,0xcf,0x00,0x01,0x0f,0x00,0x09, -0xd8,0x00,0x01,0x0f,0x00,0x09,0xe1,0x00,0x03,0x0d,0x00,0x09,0xea,0x00,0x01,0x0f, -0x00,0x09,0xf3,0x00,0x01,0x0f,0x00,0x09,0xfc,0x00,0x03,0x0d,0x00,0x09,0x05,0x01, -0x03,0x0d,0x00,0x09,0x0e,0x01,0x03,0x0d,0x00,0x09,0x17,0x01,0x03,0x0d,0x00,0x09, -0x20,0x01,0x00,0x00,0x00,0x09,0x29,0x01,0x03,0x0d,0x00,0x09,0x32,0x01,0x02,0x05, -0x00,0x09,0x3b,0x01,0x03,0x0d,0x00,0x09,0x44,0x01,0x02,0x0e,0x00,0x09,0x4d,0x01, -0x03,0x0d,0x00,0x09,0x56,0x01,0x03,0x0d,0x00,0x09,0x5f,0x01,0x02,0x06,0x00,0x09, -0x68,0x01,0x02,0x0e,0x00,0x09,0x71,0x01,0x02,0x0e,0x00,0x09,0x7a,0x01,0x03,0x08, -0x00,0x09,0x83,0x01,0x05,0x0c,0x00,0x09,0x8c,0x01,0x0b,0x0f,0x00,0x09,0x95,0x01, -0x08,0x09,0x00,0x09,0x9e,0x01,0x0b,0x0d,0x00,0x09,0xa7,0x01,0x02,0x0e,0x00,0x09, -0xb0,0x01,0x03,0x0d,0x00,0x09,0xb9,0x01,0x03,0x0d,0x00,0x09,0xc2,0x01,0x03,0x0d, -0x00,0x09,0xcb,0x01,0x03,0x0d,0x00,0x09,0xd4,0x01,0x03,0x0d,0x00,0x09,0xdd,0x01, -0x03,0x0d,0x00,0x09,0xe6,0x01,0x03,0x0d,0x00,0x09,0xef,0x01,0x03,0x0d,0x00,0x09, -0xf8,0x01,0x03,0x0d,0x00,0x09,0x01,0x02,0x03,0x0d,0x00,0x09,0x0a,0x02,0x06,0x0d, -0x00,0x09,0x13,0x02,0x06,0x0f,0x00,0x09,0x1c,0x02,0x05,0x0c,0x00,0x09,0x25,0x02, -0x07,0x0a,0x00,0x09,0x2e,0x02,0x05,0x0c,0x00,0x09,0x37,0x02,0x03,0x0d,0x00,0x09, -0x40,0x02,0x03,0x0d,0x00,0x09,0x49,0x02,0x03,0x0d,0x00,0x09,0x52,0x02,0x03,0x0d, -0x00,0x09,0x5b,0x02,0x03,0x0d,0x00,0x09,0x64,0x02,0x03,0x0d,0x00,0x09,0x6d,0x02, -0x03,0x0d,0x00,0x09,0x76,0x02,0x03,0x0d,0x00,0x09,0x7f,0x02,0x03,0x0d,0x00,0x09, -0x88,0x02,0x03,0x0d,0x00,0x09,0x91,0x02,0x03,0x0d,0x00,0x09,0x9a,0x02,0x03,0x0d, -0x00,0x09,0xa3,0x02,0x03,0x0d,0x00,0x09,0xac,0x02,0x03,0x0d,0x00,0x09,0xb5,0x02, -0x03,0x0d,0x00,0x09,0xbe,0x02,0x03,0x0d,0x00,0x09,0xc7,0x02,0x03,0x0d,0x00,0x09, -0xd0,0x02,0x03,0x0d,0x00,0x09,0xd9,0x02,0x03,0x0f,0x00,0x09,0xe2,0x02,0x03,0x0d, -0x00,0x09,0xeb,0x02,0x03,0x0d,0x00,0x09,0xf4,0x02,0x03,0x0d,0x00,0x09,0xfd,0x02, -0x03,0x0d,0x00,0x09,0x06,0x03,0x03,0x0d,0x00,0x09,0x0f,0x03,0x03,0x0d,0x00,0x09, -0x18,0x03,0x03,0x0d,0x00,0x09,0x21,0x03,0x03,0x0d,0x00,0x09,0x2a,0x03,0x03,0x0d, -0x00,0x09,0x33,0x03,0x02,0x0e,0x00,0x09,0x3c,0x03,0x02,0x0e,0x00,0x09,0x45,0x03, -0x02,0x0e,0x00,0x09,0x4e,0x03,0x04,0x0b,0x00,0x09,0x57,0x03,0x0d,0x0e,0x00,0x09, -0x60,0x03,0x02,0x06,0x00,0x09,0x69,0x03,0x05,0x0d,0x00,0x09,0x72,0x03,0x02,0x0d, -0x00,0x09,0x7b,0x03,0x05,0x0d,0x00,0x09,0x84,0x03,0x02,0x0d,0x00,0x09,0x8d,0x03, -0x05,0x0d,0x00,0x09,0x96,0x03,0x02,0x0d,0x00,0x09,0x9f,0x03,0x05,0x0f,0x00,0x09, -0xa8,0x03,0x02,0x0d,0x00,0x09,0xb1,0x03,0x02,0x0d,0x00,0x09,0xba,0x03,0x02,0x0f, -0x00,0x09,0xc3,0x03,0x02,0x0d,0x00,0x09,0xcc,0x03,0x02,0x0d,0x00,0x09,0xd5,0x03, -0x05,0x0d,0x00,0x09,0xde,0x03,0x05,0x0d,0x00,0x09,0xe7,0x03,0x05,0x0d,0x00,0x09, -0xf0,0x03,0x05,0x0f,0x00,0x09,0xf9,0x03,0x05,0x0f,0x00,0x09,0x02,0x04,0x05,0x0d, -0x00,0x09,0x0b,0x04,0x05,0x0d,0x00,0x09,0x14,0x04,0x03,0x0d,0x00,0x09,0x1d,0x04, -0x05,0x0d,0x00,0x09,0x26,0x04,0x05,0x0d,0x00,0x09,0x2f,0x04,0x05,0x0d,0x00,0x09, -0x38,0x04,0x05,0x0d,0x00,0x09,0x41,0x04,0x05,0x0f,0x00,0x09,0x4a,0x04,0x05,0x0d, -0x00,0x09,0x53,0x04,0x02,0x0e,0x00,0x09,0x5c,0x04,0x02,0x0e,0x00,0x09,0x65,0x04, -0x02,0x0e,0x00,0x09,0x6e,0x04,0x07,0x0a,0x00,0x09,0x77,0x04,0x01,0x0d,0x00,0x09, -0x80,0x04,0x00,0x0e,0x00,0x09,0x89,0x04,0x00,0x0f,0x00,0x09,0x92,0x04,0x00,0x0f, -0x00,0x09,0x9b,0x04,0x00,0x0f,0x00,0x09,0xa4,0x04,0x00,0x0f,0x00,0x09,0xad,0x04, -0x00,0x0f,0x00,0x09,0xb6,0x04,0x00,0x0f,0x00,0x09,0xbf,0x04,0x00,0x0f,0x00,0x09, -0xc8,0x04,0x00,0x0f,0x00,0x09,0xd1,0x04,0x00,0x0f,0x00,0x09,0xda,0x04,0x00,0x0f, -0x00,0x09,0xe3,0x04,0x00,0x0f,0x00,0x09,0xec,0x04,0x00,0x0f,0x00,0x09,0xf5,0x04, -0x00,0x0f,0x00,0x09,0xfe,0x04,0x00,0x0f,0x00,0x09,0x07,0x05,0x00,0x0f,0x00,0x09, -0x10,0x05,0x00,0x0f,0x00,0x09,0x19,0x05,0x00,0x0f,0x00,0x09,0x22,0x05,0x00,0x0f, -0x00,0x09,0x2b,0x05,0x00,0x0f,0x00,0x09,0x34,0x05,0x00,0x0f,0x00,0x09,0x3d,0x05, -0x00,0x0f,0x00,0x09,0x46,0x05,0x00,0x0f,0x00,0x09,0x4f,0x05,0x00,0x0f,0x00,0x09, -0x58,0x05,0x00,0x0f,0x00,0x09,0x61,0x05,0x00,0x0f,0x00,0x09,0x6a,0x05,0x00,0x0f, -0x00,0x09,0x73,0x05,0x00,0x0f,0x00,0x09,0x7c,0x05,0x00,0x0f,0x00,0x09,0x85,0x05, -0x00,0x0f,0x00,0x09,0x8e,0x05,0x00,0x0f,0x00,0x09,0x97,0x05,0x00,0x0f,0x00,0x09, -0xa0,0x05,0x00,0x0d,0x00,0x09,0xa9,0x05,0x05,0x0f,0x00,0x09,0xb2,0x05,0x02,0x0e, -0x00,0x09,0xbb,0x05,0x03,0x0d,0x00,0x09,0xc4,0x05,0x03,0x0d,0x00,0x09,0xcd,0x05, -0x03,0x0d,0x00,0x09,0xd6,0x05,0x02,0x0e,0x00,0x09,0xdf,0x05,0x03,0x0e,0x00,0x09, -0xe8,0x05,0x02,0x04,0x00,0x09,0xf1,0x05,0x03,0x0d,0x00,0x09,0xfa,0x05,0x03,0x0a, -0x00,0x09,0x03,0x06,0x06,0x0b,0x00,0x09,0x0c,0x06,0x07,0x0a,0x00,0x09,0x15,0x06, -0x08,0x09,0x00,0x09,0x1e,0x06,0x03,0x0b,0x00,0x09,0x27,0x06,0x02,0x03,0x00,0x09, -0x30,0x06,0x03,0x07,0x00,0x09,0x39,0x06,0x05,0x0c,0x00,0x09,0x42,0x06,0x03,0x0a, -0x00,0x09,0x4b,0x06,0x03,0x0a,0x00,0x09,0x54,0x06,0x02,0x04,0x00,0x09,0x5d,0x06, -0x05,0x0f,0x00,0x09,0x66,0x06,0x03,0x0e,0x00,0x09,0x6f,0x06,0x08,0x0a,0x00,0x09, -0x78,0x06,0x0d,0x0f,0x00,0x09,0x81,0x06,0x03,0x0a,0x00,0x09,0x8a,0x06,0x03,0x0a, -0x00,0x09,0x93,0x06,0x06,0x0b,0x00,0x09,0x9c,0x06,0x03,0x0d,0x00,0x09,0xa5,0x06, -0x03,0x0d,0x00,0x09,0xae,0x06,0x03,0x0d,0x00,0x09,0xb7,0x06,0x05,0x0f,0x00,0x09, -0xc0,0x06,0x00,0x0d,0x00,0x09,0xc9,0x06,0x00,0x0d,0x00,0x09,0xd2,0x06,0x00,0x0d, -0x00,0x09,0xdb,0x06,0x00,0x0d,0x00,0x09,0xe4,0x06,0x00,0x0d,0x00,0x09,0xed,0x06, -0x01,0x0d,0x00,0x09,0xf6,0x06,0x03,0x0d,0x00,0x09,0xff,0x06,0x03,0x0f,0x00,0x09, -0x08,0x07,0x00,0x0d,0x00,0x09,0x11,0x07,0x00,0x0d,0x00,0x09,0x1a,0x07,0x00,0x0d, -0x00,0x09,0x23,0x07,0x00,0x0d,0x00,0x09,0x2c,0x07,0x00,0x0d,0x00,0x09,0x35,0x07, -0x00,0x0d,0x00,0x09,0x3e,0x07,0x00,0x0d,0x00,0x09,0x47,0x07,0x00,0x0d,0x00,0x09, -0x50,0x07,0x03,0x0d,0x00,0x09,0x59,0x07,0x00,0x0d,0x00,0x09,0x62,0x07,0x00,0x0d, -0x00,0x09,0x6b,0x07,0x00,0x0d,0x00,0x09,0x74,0x07,0x00,0x0d,0x00,0x09,0x7d,0x07, -0x00,0x0d,0x00,0x09,0x86,0x07,0x00,0x0d,0x00,0x09,0x8f,0x07,0x06,0x0b,0x00,0x09, -0x98,0x07,0x03,0x0d,0x00,0x09,0xa1,0x07,0x00,0x0d,0x00,0x09,0xaa,0x07,0x00,0x0d, -0x00,0x09,0xb3,0x07,0x00,0x0d,0x00,0x09,0xbc,0x07,0x00,0x0d,0x00,0x09,0xc5,0x07, -0x00,0x0d,0x00,0x09,0xce,0x07,0x03,0x0d,0x00,0x09,0xd7,0x07,0x02,0x0d,0x00,0x09, -0xe0,0x07,0x02,0x0d,0x00,0x09,0xe9,0x07,0x02,0x0d,0x00,0x09,0xf2,0x07,0x02,0x0d, -0x00,0x09,0xfb,0x07,0x02,0x0d,0x00,0x09,0x04,0x08,0x02,0x0d,0x00,0x09,0x0d,0x08, -0x02,0x0d,0x00,0x09,0x16,0x08,0x05,0x0d,0x00,0x09,0x1f,0x08,0x05,0x0f,0x00,0x09, -0x28,0x08,0x02,0x0d,0x00,0x09,0x31,0x08,0x02,0x0d,0x00,0x09,0x3a,0x08,0x02,0x0d, -0x00,0x09,0x43,0x08,0x02,0x0d,0x00,0x09,0x4c,0x08,0x02,0x0d,0x00,0x09,0x55,0x08, -0x02,0x0d,0x00,0x09,0x5e,0x08,0x02,0x0d,0x00,0x09,0x67,0x08,0x02,0x0d,0x00,0x09, -0x70,0x08,0x02,0x0d,0x00,0x09,0x79,0x08,0x02,0x0d,0x00,0x09,0x82,0x08,0x02,0x0d, -0x00,0x09,0x8b,0x08,0x02,0x0d,0x00,0x09,0x94,0x08,0x02,0x0d,0x00,0x09,0x9d,0x08, -0x02,0x0d,0x00,0x09,0xa6,0x08,0x02,0x0d,0x00,0x09,0xaf,0x08,0x05,0x0c,0x00,0x09, -0xb8,0x08,0x05,0x0d,0x00,0x09,0xc1,0x08,0x02,0x0d,0x00,0x09,0xca,0x08,0x02,0x0d, -0x00,0x09,0xd3,0x08,0x02,0x0d,0x00,0x09,0xdc,0x08,0x02,0x0d,0x00,0x09,0xe5,0x08, -0x02,0x0f,0x00,0x09,0xee,0x08,0x03,0x0f,0x00,0x09,0xf7,0x08,0x02,0x0f,0x00,0x09, -0x00,0x09,0x00,0x00,0x00,0x00, -}; - -int sizeofdefont = sizeof defontdata; - -void -_unpackinfo(Fontchar *fc, uchar *p, int n) -{ - int j; - - for(j=0; j<=n; j++){ - fc->x = p[0]|(p[1]<<8); - fc->top = p[2]; - fc->bottom = p[3]; - fc->left = p[4]; - fc->width = p[5]; - fc++; - p += 6; - } -} diff --git a/src/libdraw/defont.h b/src/libdraw/defont.h new file mode 100644 index 000000000..3d108cfc2 --- /dev/null +++ b/src/libdraw/defont.h @@ -0,0 +1,303 @@ + +/* + * lucm/latin1.9 + */ + +char _defontfile[] = "15 13\n0 255\t*default*\n"; + +static uchar +defontdata[] = +{ +// xd -b ../../font/lucm/latin1.9 | awk '{$1=""; for(i=2; i<=NF;i++) $i="0x"$i","; print}' + 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x6b, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x33, 0x30, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x31, 0x35, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x39, 0x37, 0x36, 0x20, 0x80, + 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x10, 0x00, 0x80, 0xff, 0x7c, 0x00, 0x80, + 0xff, 0x7c, 0x45, 0x87, 0x00, 0x00, 0x30, 0x06, 0x06, 0x03, 0x42, 0x40, 0x00, 0x08, 0x90, 0x18, + 0x03, 0x03, 0x02, 0x43, 0x00, 0x60, 0x60, 0x48, 0x00, 0x0d, 0x0c, 0x01, 0x81, 0x80, 0xd0, 0x90, + 0x00, 0x12, 0x84, 0x01, 0x81, 0x81, 0x40, 0x60, 0x7c, 0x43, 0x04, 0x00, 0x87, 0x18, 0x7f, 0x9c, + 0x1c, 0x0e, 0x07, 0x01, 0x80, 0x1c, 0x11, 0x8c, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x04, 0x81, 0xc1, + 0xc0, 0x70, 0x00, 0x1c, 0x1c, 0x7c, 0x40, 0x7c, 0x00, 0x7c, 0x00, 0x1c, 0x00, 0x88, 0xaa, 0x80, + 0xc0, 0x63, 0xe3, 0xf1, 0xf8, 0xfe, 0x7f, 0x0d, 0x09, 0x80, 0xfc, 0x00, 0x07, 0x8c, 0x1f, 0x8f, + 0xc7, 0xe3, 0xf1, 0xfb, 0x7e, 0x3e, 0x3f, 0x8f, 0xff, 0xe3, 0xe3, 0x7d, 0x1f, 0x10, 0x00, 0x98, + 0x0c, 0x18, 0x09, 0x05, 0x82, 0x40, 0xc0, 0x00, 0x00, 0x06, 0x0c, 0x04, 0x82, 0x40, 0xc1, 0x80, + 0x90, 0x48, 0x00, 0x16, 0x03, 0x06, 0x02, 0x41, 0x60, 0x01, 0x1f, 0x80, 0x06, 0x00, 0x07, 0x80, + 0x41, 0x20, 0xf1, 0x64, 0x00, 0x86, 0x3e, 0x7f, 0xa0, 0x10, 0x08, 0x04, 0x02, 0x05, 0x69, 0x10, + 0x00, 0x8c, 0x90, 0x48, 0x24, 0x12, 0x09, 0x06, 0x82, 0x01, 0x00, 0x90, 0x00, 0x20, 0x10, 0x10, + 0x13, 0x82, 0x04, 0x80, 0x00, 0x00, 0x21, 0x82, 0x38, 0x06, 0x18, 0x0c, 0x0e, 0x80, 0x06, 0x7c, + 0x57, 0x2c, 0x00, 0x83, 0x07, 0xc6, 0x01, 0xf0, 0x00, 0xb3, 0x80, 0x00, 0x00, 0x3f, 0x88, 0x30, + 0x00, 0x3c, 0x00, 0x60, 0x06, 0x01, 0x8c, 0x07, 0x00, 0xbb, 0x28, 0x00, 0x8d, 0x01, 0xe0, 0xc3, + 0xc0, 0x01, 0x54, 0x9c, 0xc0, 0x5f, 0xef, 0xf7, 0xfb, 0xfd, 0xbf, 0x0d, 0x1f, 0x80, 0xfb, 0x01, + 0x1f, 0x8c, 0x6f, 0xb7, 0xdb, 0xed, 0xf6, 0xf9, 0x7d, 0xfe, 0xff, 0x6f, 0xff, 0xdf, 0xef, 0x11, + 0x1f, 0x80, 0x01, 0x0a, 0x22, 0x81, 0x00, 0x14, 0x10, 0x3a, 0x80, 0x38, 0x08, 0x05, 0x3e, 0x11, + 0x81, 0x01, 0x20, 0x64, 0x94, 0x80, 0x78, 0x02, 0x63, 0x82, 0x06, 0x82, 0x80, 0x00, 0x87, 0x06, + 0x63, 0x8c, 0x41, 0x80, 0x30, 0x30, 0x24, 0x76, 0x0d, 0x0c, 0x00, 0xc0, 0xc0, 0xd0, 0x50, 0x12, + 0x63, 0x82, 0x30, 0x00, 0x28, 0x82, 0x0f, 0x7f, 0xbc, 0x02, 0x3f, 0x8b, 0x03, 0xc0, 0x10, 0x70, + 0x24, 0x10, 0x09, 0x07, 0x03, 0x80, 0xe0, 0x70, 0x09, 0x1f, 0x98, 0x05, 0x81, 0x81, 0xc0, 0x80, + 0x70, 0x18, 0x1c, 0x07, 0x01, 0xc1, 0xc0, 0x90, 0x00, 0x0c, 0x04, 0x84, 0x83, 0xe1, 0xc0, 0xe0, + 0x38, 0x0c, 0x0c, 0x02, 0x0d, 0x1f, 0x8a, 0x1c, 0x06, 0x0f, 0x87, 0xc0, 0x63, 0xf8, 0x78, 0xfe, + 0x3e, 0x0e, 0x0c, 0x6b, 0xa0, 0x7c, 0x1c, 0x0c, 0x1f, 0x03, 0xc7, 0xc3, 0xf1, 0xf8, 0x3c, 0x63, + 0x3f, 0x0f, 0x8c, 0x66, 0x06, 0x19, 0x84, 0x78, 0x7e, 0x1e, 0x1f, 0x07, 0xcf, 0xf3, 0x1b, 0x0d, + 0x86, 0x63, 0x61, 0x9f, 0xc6, 0x06, 0x00, 0xcd, 0x81, 0x00, 0x10, 0x0d, 0x1f, 0x80, 0x60, 0x09, + 0x1f, 0x80, 0x00, 0x15, 0x1f, 0x16, 0xbb, 0x88, 0x03, 0x00, 0xc0, 0x60, 0x00, 0xaa, 0xb6, 0xc0, + 0x43, 0x02, 0x3f, 0x88, 0xfc, 0x3f, 0xef, 0x8f, 0xdb, 0xef, 0xf6, 0xf8, 0xfb, 0x02, 0x3d, 0x09, + 0x1f, 0x8c, 0xfa, 0x7e, 0x7e, 0x3f, 0x7f, 0x8f, 0xe7, 0xe3, 0xf8, 0xfe, 0x3e, 0x3f, 0x6f, 0x00, + 0x33, 0x88, 0x01, 0xc8, 0x0b, 0x0c, 0x30, 0x7c, 0x14, 0x0f, 0x0f, 0x08, 0xe8, 0x9c, 0x00, 0x1c, + 0x00, 0x0f, 0x07, 0x81, 0x80, 0x00, 0x7c, 0x00, 0x00, 0x1c, 0x0f, 0x80, 0x04, 0x42, 0x23, 0x90, + 0x00, 0x18, 0x0c, 0x06, 0x03, 0x01, 0x80, 0xc0, 0x3c, 0x3c, 0x3f, 0x02, 0x7f, 0x80, 0xe7, 0x04, + 0x52, 0x91, 0x7c, 0x30, 0x8f, 0x07, 0x83, 0xc1, 0xe0, 0xf0, 0x00, 0x3d, 0x31, 0x98, 0xcc, 0x66, + 0x36, 0x19, 0x80, 0xcc, 0x02, 0x63, 0x82, 0x0b, 0x02, 0x81, 0x01, 0x43, 0x0a, 0x63, 0x8a, 0x60, + 0xc0, 0x48, 0x24, 0x18, 0x16, 0x03, 0x03, 0x01, 0x21, 0x60, 0x01, 0x1f, 0x06, 0x63, 0x02, 0x76, + 0x80, 0x28, 0x82, 0x87, 0x7f, 0x84, 0x0a, 0x3f, 0x81, 0x38, 0x48, 0x01, 0x1f, 0x83, 0x04, 0x04, + 0x81, 0x00, 0x02, 0x89, 0x01, 0x1f, 0x8b, 0x04, 0x80, 0x41, 0x00, 0x80, 0x40, 0x04, 0x10, 0x04, + 0x02, 0x01, 0x20, 0x09, 0x1f, 0x87, 0x86, 0x53, 0x65, 0xb0, 0x08, 0x18, 0x06, 0x0a, 0x08, 0xcc, + 0x8b, 0x0c, 0x36, 0x0e, 0x19, 0xcc, 0xe0, 0xe3, 0xf8, 0xcc, 0xfe, 0x63, 0x1b, 0x0c, 0xdc, 0x98, + 0xc6, 0x62, 0x0c, 0x19, 0x86, 0x66, 0x63, 0x01, 0x80, 0x66, 0x63, 0x0c, 0x01, 0x8c, 0xc6, 0x06, + 0x19, 0xc4, 0xcc, 0x63, 0x33, 0x19, 0x8c, 0x61, 0x83, 0x09, 0x1f, 0x85, 0x80, 0xc6, 0x03, 0x00, + 0x30, 0x30, 0x00, 0xc5, 0x15, 0x1f, 0x06, 0x4b, 0x45, 0x1f, 0x84, 0x01, 0x54, 0x86, 0xc0, 0x7b, + 0x0a, 0x3f, 0x81, 0xc7, 0xb7, 0x01, 0x1f, 0x84, 0xfb, 0xfb, 0x7e, 0xff, 0x7f, 0x09, 0x1f, 0x8b, + 0xfb, 0x7f, 0xbe, 0xff, 0x7f, 0xbf, 0xfb, 0xef, 0xfb, 0xfd, 0xfe, 0xdf, 0x01, 0x1f, 0x88, 0x07, + 0x83, 0x24, 0x13, 0x0c, 0x30, 0xc6, 0x00, 0x10, 0x01, 0x14, 0x84, 0x00, 0x00, 0x84, 0x00, 0x22, + 0x00, 0x45, 0x00, 0x4f, 0x87, 0xf4, 0x00, 0x00, 0x2c, 0x18, 0xc0, 0x0c, 0x46, 0x00, 0xb2, 0x11, + 0x1f, 0x82, 0x70, 0x66, 0x30, 0x00, 0x09, 0x00, 0x08, 0x8b, 0x60, 0x30, 0x66, 0x38, 0x99, 0x8c, + 0xc6, 0x63, 0x31, 0x98, 0x00, 0x66, 0x15, 0x1f, 0x0c, 0x77, 0x26, 0xc7, 0x80, 0x6c, 0x32, 0x7f, + 0x81, 0x80, 0x00, 0x82, 0xff, 0x7f, 0xb8, 0x02, 0x3f, 0x84, 0x02, 0x40, 0x7c, 0x70, 0x3c, 0x02, + 0x3f, 0x80, 0x04, 0x00, 0xa3, 0x89, 0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x04, 0x83, 0x81, 0xc0, 0x70, + 0x00, 0x08, 0x81, 0x07, 0x02, 0x0a, 0x3f, 0x89, 0x00, 0x04, 0x86, 0x43, 0x69, 0xb0, 0x30, 0x18, + 0x06, 0x07, 0x0a, 0xd9, 0x8b, 0x0c, 0x63, 0x16, 0x00, 0xc0, 0x61, 0x62, 0x01, 0x80, 0x06, 0x63, + 0x31, 0x00, 0xa0, 0x89, 0x60, 0x00, 0xc0, 0x06, 0x43, 0x16, 0x19, 0x8c, 0x06, 0x33, 0x00, 0x88, + 0x05, 0x1f, 0x83, 0x86, 0x07, 0x39, 0xc5, 0x01, 0x16, 0x82, 0x99, 0x8c, 0x01, 0x01, 0x1f, 0x84, + 0xb6, 0x63, 0x31, 0x01, 0x86, 0x0d, 0x1f, 0xa5, 0x3e, 0x1b, 0x03, 0xc1, 0xf0, 0xf0, 0x60, 0x3e, + 0x6e, 0x3e, 0x0f, 0x8c, 0x60, 0xc5, 0xb1, 0xb8, 0x38, 0x6c, 0x0f, 0x8c, 0xc7, 0xc1, 0x83, 0x19, + 0x8d, 0x82, 0x63, 0x31, 0x9f, 0xc1, 0x80, 0xc0, 0xc0, 0x00, 0xaa, 0x86, 0xc0, 0x47, 0x01, 0xec, + 0x84, 0xfd, 0xbf, 0x83, 0x8f, 0xc3, 0x02, 0x3f, 0x83, 0xfc, 0xff, 0x3f, 0x9f, 0x01, 0xff, 0x86, + 0xe3, 0xf1, 0xfb, 0x7c, 0x7e, 0x3f, 0x8f, 0x00, 0x08, 0x81, 0xf8, 0xfd, 0x06, 0x3f, 0x8a, 0x0c, + 0x0d, 0x43, 0x03, 0xe1, 0x88, 0x30, 0xc0, 0x00, 0x27, 0x41, 0x00, 0x7e, 0x84, 0x01, 0x72, 0x00, + 0x22, 0x04, 0x00, 0x79, 0x81, 0x03, 0x18, 0x01, 0x1f, 0x90, 0x0c, 0x18, 0xc0, 0x04, 0x82, 0x43, + 0x20, 0x18, 0x2c, 0x16, 0x0b, 0x05, 0x82, 0xc1, 0x60, 0xb0, 0xc0, 0x19, 0x1f, 0x89, 0x63, 0x38, + 0xb0, 0xd8, 0x6c, 0x36, 0x1b, 0x0c, 0x00, 0xc7, 0x05, 0x1f, 0x9f, 0x33, 0x11, 0xf8, 0xc8, 0x7c, + 0x3e, 0x1f, 0x0f, 0x87, 0xc3, 0xe1, 0xd8, 0x3c, 0x1e, 0x0f, 0x07, 0x83, 0xc7, 0xc3, 0xe1, 0xf0, + 0xf8, 0x06, 0x37, 0x07, 0x03, 0x81, 0xc0, 0xe0, 0x70, 0x10, 0x1d, 0x08, 0x23, 0x82, 0x19, 0xb0, + 0xc6, 0x88, 0x8f, 0x7f, 0x87, 0x03, 0x81, 0x80, 0x90, 0x30, 0x6c, 0x02, 0x3f, 0x86, 0x06, 0x04, + 0x04, 0x80, 0x20, 0x10, 0x10, 0x03, 0x6e, 0x89, 0x81, 0xc0, 0x60, 0x88, 0x38, 0x0c, 0x40, 0x09, + 0x03, 0x84, 0x02, 0x65, 0x05, 0x1f, 0x89, 0x1f, 0xe7, 0x41, 0xd1, 0xa0, 0x00, 0x30, 0x03, 0x0a, + 0x81, 0x05, 0x1f, 0x8b, 0x18, 0x63, 0x06, 0x00, 0xc0, 0xc2, 0x62, 0x01, 0xb0, 0x0c, 0x72, 0x31, + 0x00, 0xfa, 0x80, 0xc0, 0x03, 0x30, 0x83, 0x8f, 0x16, 0x19, 0x0c, 0x15, 0x1f, 0x84, 0x8d, 0x06, + 0x07, 0x39, 0x65, 0x05, 0x1f, 0x88, 0x0e, 0x01, 0x83, 0x19, 0x89, 0xb6, 0x32, 0x33, 0x03, 0x00, + 0xa1, 0x81, 0x30, 0x78, 0x02, 0x22, 0x87, 0x1d, 0x86, 0x23, 0x31, 0x99, 0xfc, 0x66, 0x77, 0x03, + 0x5f, 0x8a, 0x40, 0xc6, 0xd9, 0xdc, 0x6c, 0x76, 0x19, 0x8d, 0xcc, 0x27, 0xf3, 0x09, 0x1f, 0x81, + 0x80, 0xc0, 0x00, 0x01, 0x8a, 0x01, 0x54, 0x8c, 0xc0, 0x78, 0xfc, 0x7e, 0x7f, 0x6f, 0xcf, 0x93, + 0x02, 0x3f, 0x86, 0xf9, 0xfb, 0xff, 0xff, 0xdf, 0xef, 0xef, 0x03, 0x1b, 0x8c, 0x7e, 0x3f, 0x9f, + 0x77, 0xc7, 0xf3, 0xbf, 0xf6, 0xfc, 0x7b, 0xfd, 0xbe, 0xbf, 0x01, 0x1f, 0x84, 0x19, 0x03, 0x03, + 0x61, 0x98, 0x00, 0x51, 0x8c, 0x28, 0x4f, 0x83, 0x30, 0x00, 0x01, 0x4a, 0x00, 0x1c, 0x04, 0x03, + 0x03, 0x80, 0x11, 0x1f, 0x84, 0xd9, 0x84, 0x82, 0x40, 0xa0, 0x45, 0x1f, 0x80, 0x2c, 0x0d, 0x1f, + 0x81, 0x64, 0xcb, 0x08, 0xfb, 0x82, 0x31, 0x8c, 0xd8, 0x0a, 0x61, 0x83, 0x60, 0x30, 0x6c, 0x62, + 0x02, 0xe9, 0x81, 0xc6, 0x60, 0x00, 0x09, 0x8a, 0x18, 0x1e, 0x3b, 0x8d, 0x86, 0xc3, 0x61, 0xb0, + 0xd8, 0x10, 0x36, 0x0d, 0x1f, 0x81, 0xd8, 0xc6, 0x92, 0x0f, 0x7f, 0x82, 0x01, 0x02, 0x40, 0xd0, + 0x40, 0x6c, 0x70, 0x24, 0x1c, 0x06, 0x04, 0x03, 0x01, 0xc0, 0xe0, 0x10, 0x03, 0x5d, 0x86, 0x82, + 0x40, 0x90, 0x50, 0x10, 0x12, 0x70, 0x03, 0x70, 0x83, 0x01, 0xc1, 0x20, 0x60, 0x06, 0x3f, 0x83, + 0x83, 0xc0, 0x20, 0xcc, 0x01, 0x1f, 0x80, 0x02, 0x0a, 0x3f, 0x01, 0x1f, 0x87, 0x01, 0x83, 0x84, + 0x63, 0xf1, 0xd8, 0x18, 0x3c, 0x01, 0x1f, 0x87, 0x01, 0x83, 0xf8, 0x30, 0x1c, 0x9b, 0x33, 0x1e, + 0x01, 0x1f, 0x90, 0xe1, 0x80, 0xc0, 0x7f, 0x0c, 0x01, 0x8f, 0x06, 0x07, 0x79, 0x65, 0x86, 0x66, + 0x61, 0x9e, 0x07, 0x81, 0x05, 0x1f, 0x81, 0x1c, 0x1a, 0x09, 0x1f, 0x80, 0x48, 0x01, 0x1f, 0x86, + 0x18, 0xcc, 0x06, 0x33, 0x18, 0x60, 0xc6, 0x00, 0x3e, 0x83, 0x8c, 0x80, 0xc6, 0xd9, 0x06, 0xee, + 0x81, 0x8e, 0x4c, 0x01, 0x43, 0x96, 0x8d, 0x92, 0x32, 0x31, 0x81, 0x87, 0x00, 0xc0, 0x70, 0xe4, + 0xaa, 0x98, 0xc0, 0x7d, 0xfe, 0xfd, 0xbf, 0x2f, 0xbf, 0x93, 0x8f, 0xdb, 0xe3, 0x01, 0x1f, 0x83, + 0x1e, 0x3f, 0x1f, 0xef, 0x03, 0x5d, 0x86, 0x7d, 0xbf, 0x6f, 0xaf, 0xef, 0xed, 0x8f, 0x03, 0x70, + 0x92, 0xfe, 0x3e, 0xdf, 0x9f, 0x00, 0x00, 0x19, 0x0f, 0xc6, 0x30, 0xd0, 0x00, 0xcc, 0x00, 0x28, + 0x59, 0x86, 0x67, 0xf0, 0x02, 0x3f, 0x83, 0x00, 0x3f, 0x86, 0x00, 0x16, 0x3f, 0x85, 0xcc, 0xc5, + 0x32, 0x83, 0x4c, 0x00, 0x00, 0xdc, 0x04, 0x5e, 0x81, 0xbc, 0xc0, 0x06, 0x23, 0x02, 0x9a, 0x82, + 0x60, 0x30, 0xfb, 0x11, 0x1f, 0x80, 0x38, 0x09, 0x1f, 0x83, 0x31, 0xa1, 0x8c, 0xcc, 0x15, 0x1f, + 0x80, 0xc0, 0x03, 0x75, 0x80, 0xcc, 0x09, 0x1f, 0x80, 0x37, 0x0d, 0x16, 0x82, 0x8c, 0x00, 0x67, + 0x10, 0x08, 0x80, 0xc6, 0x80, 0x1f, 0x09, 0x1f, 0x9a, 0xb0, 0x40, 0x6c, 0x07, 0x03, 0x83, 0x80, + 0xe0, 0xe0, 0x00, 0x18, 0x0e, 0x10, 0x10, 0x08, 0x04, 0x02, 0x00, 0xf0, 0x20, 0x10, 0x1e, 0x08, + 0x89, 0x03, 0x00, 0xe0, 0x03, 0x6c, 0x05, 0x1f, 0x83, 0x81, 0xe0, 0x41, 0x6c, 0x01, 0x1f, 0x94, + 0x00, 0x0f, 0xe0, 0x03, 0xf8, 0x00, 0x30, 0x63, 0x06, 0x03, 0x00, 0xc7, 0xf0, 0x39, 0x8c, 0x30, + 0x3e, 0x1b, 0x80, 0x00, 0x03, 0x01, 0x30, 0x82, 0x30, 0x9b, 0x23, 0x0a, 0x3f, 0x81, 0xf8, 0xc6, + 0x06, 0x3f, 0x88, 0x86, 0x05, 0xd9, 0x35, 0x86, 0x7c, 0x61, 0x9b, 0x01, 0x03, 0x3b, 0x84, 0x99, + 0xb4, 0x1c, 0x0c, 0x06, 0x02, 0x6e, 0x80, 0x30, 0x03, 0xee, 0x80, 0x3f, 0x05, 0x1f, 0x80, 0xf8, + 0x09, 0x1f, 0x81, 0x8f, 0x00, 0x0d, 0x1f, 0x8f, 0x8c, 0x0f, 0x81, 0x83, 0x18, 0xd9, 0xba, 0x1c, + 0x1b, 0x03, 0x00, 0x80, 0xc0, 0x81, 0x75, 0x54, 0x0d, 0x1f, 0x9a, 0x4f, 0xbf, 0x93, 0xf8, 0xfc, + 0x7c, 0x7f, 0x1f, 0x1f, 0x6f, 0xe7, 0xf1, 0xef, 0xef, 0xf7, 0xfb, 0xfd, 0xff, 0x0f, 0xdf, 0xef, + 0xe1, 0xf7, 0x76, 0xfc, 0xff, 0x1f, 0x03, 0x6c, 0x94, 0x00, 0x08, 0x19, 0x03, 0x06, 0x31, 0xf8, + 0x00, 0xc6, 0x00, 0x28, 0x5b, 0x8c, 0xc0, 0x11, 0xf1, 0x4a, 0x00, 0x00, 0x04, 0x0c, 0x05, 0x1f, + 0x81, 0x74, 0x38, 0x01, 0x1f, 0x8d, 0xc6, 0x65, 0x52, 0xb8, 0x54, 0x18, 0x46, 0x23, 0x11, 0x88, + 0xc4, 0x62, 0x31, 0x30, 0x22, 0x3f, 0x80, 0x26, 0x0d, 0x1f, 0x81, 0x10, 0xd3, 0x04, 0xfb, 0x85, + 0x30, 0xc1, 0x8c, 0xc6, 0x7e, 0x3f, 0x0b, 0xbb, 0x86, 0xfc, 0xc0, 0x7f, 0x3f, 0x9f, 0xcf, 0xe0, + 0x05, 0x1f, 0x05, 0x28, 0x05, 0x16, 0x81, 0xfe, 0x6b, 0x09, 0x43, 0x82, 0xb1, 0x8c, 0x6c, 0x80, + 0x0e, 0x01, 0x1f, 0x80, 0x01, 0x03, 0x5f, 0x8a, 0xc6, 0x08, 0x01, 0x02, 0x00, 0x40, 0x80, 0xe0, + 0x24, 0x04, 0x1c, 0x09, 0x1f, 0x93, 0x90, 0x20, 0x10, 0x12, 0x0d, 0x86, 0x00, 0x81, 0x00, 0x40, + 0x20, 0x10, 0x00, 0x04, 0x00, 0x1f, 0xe1, 0x70, 0xbb, 0x28, 0x05, 0x1f, 0x0a, 0x3f, 0x01, 0x1f, + 0x8a, 0x06, 0x00, 0x67, 0xf0, 0x19, 0x8c, 0x30, 0x67, 0x0d, 0x80, 0x00, 0x06, 0x3f, 0x84, 0x30, + 0x9b, 0x7f, 0x19, 0x8c, 0x07, 0x5f, 0x05, 0x1f, 0x81, 0x8c, 0xc6, 0x05, 0x1f, 0x8b, 0x60, 0x61, + 0x99, 0x80, 0xe1, 0x83, 0x18, 0xd0, 0xdc, 0x26, 0x0c, 0x0c, 0x05, 0x1f, 0x83, 0x84, 0x00, 0x00, + 0x63, 0x05, 0x1f, 0x80, 0x00, 0x09, 0x1f, 0x80, 0x8d, 0x12, 0x3f, 0x81, 0x8c, 0x03, 0x00, 0x23, + 0x05, 0x1f, 0x04, 0xc4, 0x83, 0xc1, 0x38, 0xaa, 0x80, 0x01, 0x1f, 0x80, 0xfe, 0x03, 0x5f, 0x8a, + 0x39, 0xf7, 0xfe, 0xfd, 0xff, 0xbf, 0x7f, 0x0f, 0xdb, 0xfb, 0xe3, 0x09, 0x1f, 0x8b, 0x6f, 0xdf, + 0xef, 0xed, 0xf2, 0x79, 0xff, 0x7e, 0xff, 0xbf, 0xdf, 0xef, 0x0b, 0x5f, 0x8a, 0x60, 0x60, 0x30, + 0x66, 0x00, 0x28, 0x4d, 0xc6, 0x60, 0x10, 0x00, 0x00, 0x59, 0x82, 0x04, 0x0f, 0x87, 0x03, 0x5f, + 0x8b, 0x14, 0x38, 0x00, 0x3f, 0x0f, 0x8c, 0xc2, 0x90, 0x84, 0xa4, 0x18, 0xfe, 0x04, 0xf3, 0x82, + 0xe7, 0xf1, 0xf0, 0x3d, 0x1f, 0x80, 0x38, 0x11, 0x1f, 0x81, 0x98, 0xc6, 0x00, 0x7e, 0x05, 0x0e, + 0x0a, 0x39, 0x01, 0x5f, 0x21, 0x1f, 0x80, 0x00, 0x19, 0x1f, 0x93, 0x1c, 0x7f, 0x81, 0x20, 0x90, + 0x38, 0x18, 0x0b, 0x83, 0x06, 0x01, 0x03, 0x80, 0x40, 0xe0, 0x90, 0x24, 0x04, 0x03, 0x8e, 0x03, + 0x82, 0x88, 0x90, 0x24, 0x12, 0x0e, 0x04, 0x8a, 0x81, 0xc7, 0x70, 0x04, 0x5f, 0x01, 0x11, 0x87, + 0x04, 0x81, 0x31, 0x6f, 0x30, 0x00, 0x18, 0x06, 0x0d, 0x1f, 0x95, 0x60, 0x63, 0x06, 0x0c, 0x00, + 0x60, 0x60, 0x19, 0x8c, 0x60, 0x63, 0x01, 0x80, 0x00, 0x00, 0xc0, 0x00, 0x60, 0x00, 0x4d, 0xe1, + 0x99, 0x21, 0x1f, 0x82, 0x04, 0x99, 0x1d, 0x09, 0x1f, 0x80, 0x61, 0x05, 0x1f, 0x80, 0x63, 0x05, + 0x1f, 0x80, 0x60, 0x21, 0x1f, 0x80, 0x6e, 0x07, 0x5f, 0x80, 0xc0, 0x11, 0x1f, 0x80, 0x00, 0x04, + 0x23, 0x84, 0xcc, 0x26, 0x0e, 0x0c, 0x03, 0x00, 0xa1, 0x80, 0x01, 0x02, 0x3f, 0xb2, 0x7e, 0xdf, + 0x6f, 0xc7, 0xe7, 0xf4, 0x7c, 0xf9, 0xfe, 0xfc, 0x7f, 0xbf, 0x1f, 0x5f, 0xdb, 0xfb, 0xfc, 0x71, + 0x79, 0x3c, 0x9e, 0x6f, 0xdb, 0xed, 0xf1, 0xfb, 0x75, 0x7e, 0x38, 0x8f, 0x3f, 0xcf, 0xe7, 0xf3, + 0x00, 0x0c, 0x0d, 0x03, 0x03, 0xe1, 0xf8, 0x30, 0x3c, 0x00, 0x27, 0x40, 0x03, 0x30, 0x00, 0x00, + 0x78, 0x04, 0x93, 0x07, 0xbd, 0x80, 0x14, 0x04, 0x06, 0x87, 0x19, 0x82, 0xf8, 0x98, 0xbe, 0x70, + 0xc3, 0x61, 0x09, 0x0d, 0x26, 0x3f, 0x80, 0x23, 0x0d, 0x1f, 0x81, 0x4c, 0xe3, 0x0d, 0x1f, 0x80, + 0xf0, 0x61, 0x1f, 0x81, 0x10, 0x73, 0x08, 0x23, 0x82, 0xe1, 0x8c, 0x38, 0x89, 0x1c, 0x7f, 0x80, + 0xa0, 0x50, 0x10, 0x24, 0x0d, 0xff, 0x01, 0x0a, 0x3f, 0x8d, 0xf0, 0x24, 0x04, 0x02, 0x01, 0x81, + 0x20, 0x10, 0x30, 0x28, 0x1a, 0x09, 0x06, 0x8a, 0x01, 0x3a, 0x80, 0x20, 0x06, 0x4c, 0x03, 0x5f, + 0x83, 0x85, 0x32, 0x6f, 0xb8, 0x09, 0x1f, 0x8f, 0x01, 0xc0, 0x00, 0x70, 0x60, 0x36, 0x06, 0x1f, + 0xcc, 0xe0, 0x63, 0x30, 0xd8, 0x60, 0x63, 0x33, 0x03, 0x69, 0x80, 0x60, 0x02, 0x1d, 0x01, 0x0d, + 0x81, 0x86, 0x66, 0x01, 0x2d, 0x94, 0x66, 0x63, 0x0c, 0x03, 0x0c, 0x66, 0x04, 0x19, 0x1c, 0xcc, + 0x60, 0x33, 0x18, 0xcc, 0x61, 0x81, 0xb0, 0x60, 0xcc, 0x63, 0x0c, 0x00, 0x37, 0x80, 0x60, 0x00, + 0xc7, 0x88, 0x00, 0x67, 0x19, 0x86, 0x23, 0x71, 0x88, 0x60, 0x36, 0x05, 0x1f, 0x80, 0x60, 0x01, + 0x1f, 0x88, 0x6c, 0x66, 0x1b, 0x8c, 0x08, 0x61, 0x83, 0xb8, 0x70, 0x04, 0x23, 0x05, 0x1f, 0x8b, + 0x00, 0xaa, 0x98, 0xc0, 0x7f, 0x5f, 0xaf, 0xef, 0xdb, 0xf2, 0x00, 0xfe, 0x0a, 0x3f, 0x8d, 0x6f, + 0xdb, 0xfb, 0xfd, 0xfe, 0x7e, 0xdf, 0xef, 0xcf, 0xd7, 0xe5, 0xf6, 0xf9, 0x75, 0x01, 0x3a, 0x80, + 0xdf, 0x02, 0x4c, 0x8a, 0x00, 0x0c, 0x07, 0xc6, 0x04, 0x10, 0x60, 0x30, 0x06, 0x00, 0x10, 0x01, + 0x9d, 0x08, 0x00, 0x80, 0x3f, 0x00, 0x08, 0x81, 0x03, 0xb8, 0x09, 0x1f, 0x85, 0x00, 0x04, 0x11, + 0x21, 0x04, 0xc0, 0x15, 0x1f, 0x80, 0x66, 0x19, 0x1f, 0x82, 0x66, 0x23, 0x99, 0x05, 0x90, 0x98, + 0x98, 0x00, 0x66, 0x1b, 0x0d, 0x86, 0xc3, 0x60, 0xc1, 0x80, 0xc6, 0xce, 0x67, 0x33, 0x99, 0xcc, + 0xe6, 0x73, 0x74, 0x62, 0x31, 0x18, 0x8c, 0x46, 0x20, 0x05, 0x1f, 0x82, 0x36, 0x31, 0x8d, 0x02, + 0x1c, 0x8b, 0xb0, 0xd8, 0x10, 0x36, 0x3b, 0x9d, 0xce, 0xe7, 0x70, 0xc1, 0x98, 0x30, 0x81, 0x00, + 0x7f, 0x00, 0x3b, 0x84, 0x10, 0x24, 0x0c, 0x38, 0x0e, 0x09, 0x1f, 0x94, 0xa0, 0x18, 0x0e, 0x03, + 0x00, 0x80, 0x40, 0x60, 0x50, 0x30, 0x16, 0x0e, 0x05, 0x88, 0x81, 0xc0, 0x81, 0xc0, 0x70, 0x38, + 0x1c, 0x05, 0x1f, 0x85, 0x83, 0xe0, 0x39, 0xcc, 0x00, 0x0c, 0x02, 0x4a, 0x05, 0x1f, 0x8b, 0xc0, + 0x1c, 0x06, 0x1f, 0xc7, 0xc0, 0x61, 0xe0, 0x70, 0x60, 0x3e, 0x1e, 0x01, 0x1f, 0x07, 0x71, 0x98, + 0x1e, 0x61, 0x9f, 0x03, 0xc7, 0xc3, 0xf1, 0x80, 0x3e, 0x63, 0x3f, 0x1e, 0x0c, 0x67, 0xe4, 0x19, + 0x0c, 0x78, 0x60, 0x1e, 0x18, 0xc7, 0xc1, 0x80, 0xe0, 0x05, 0x1f, 0x83, 0x1f, 0xc6, 0x00, 0x30, + 0x05, 0x1f, 0x87, 0x3b, 0x9f, 0x03, 0xc1, 0xb0, 0xf0, 0x60, 0x06, 0x05, 0x1f, 0x80, 0x70, 0x01, + 0x1f, 0x87, 0x38, 0x7c, 0x0d, 0x8c, 0x07, 0xc0, 0xf1, 0xd8, 0x08, 0x23, 0x80, 0xc3, 0x0a, 0x3f, + 0x81, 0x80, 0xc0, 0x03, 0x18, 0x84, 0xef, 0xdb, 0xf3, 0xc7, 0xf1, 0x09, 0x1f, 0x9f, 0xff, 0xe7, + 0xf1, 0xfc, 0xff, 0x7f, 0xbf, 0x9f, 0xaf, 0xcf, 0xe9, 0xf1, 0xfa, 0x77, 0x7e, 0x3f, 0x7e, 0x3f, + 0x8f, 0xc7, 0xe3, 0x00, 0x0c, 0x01, 0x0f, 0xe8, 0x08, 0x60, 0x30, 0xc6, 0x00, 0x0f, 0x11, 0x1e, + 0x0e, 0x3f, 0x80, 0xd8, 0x15, 0x1f, 0x80, 0x3d, 0x19, 0x1f, 0x9d, 0x3c, 0x3c, 0x3f, 0x1f, 0x8f, + 0xc7, 0xe7, 0xe3, 0xf1, 0xf8, 0xfc, 0x7c, 0x21, 0x8f, 0x07, 0x83, 0xc1, 0xe0, 0xf0, 0x00, 0xbc, + 0x0e, 0x07, 0x03, 0x81, 0xc0, 0xc1, 0x80, 0xcc, 0x77, 0x05, 0x04, 0x88, 0x73, 0xb9, 0x98, 0x3c, + 0x1e, 0x0f, 0x07, 0x83, 0xc0, 0x05, 0x1f, 0x82, 0x1c, 0x31, 0x87, 0x00, 0x1a, 0x8b, 0xe0, 0x70, + 0x00, 0x5c, 0x1d, 0x8e, 0xc7, 0x63, 0xb0, 0xc1, 0xf0, 0x30, 0x87, 0x00, 0x7f, 0x81, 0x40, 0xa0, + 0x10, 0x28, 0x0a, 0x10, 0x63, 0x8f, 0x90, 0x00, 0x00, 0x02, 0x00, 0x80, 0x80, 0x10, 0xf8, 0x28, + 0x12, 0x09, 0x04, 0x80, 0x01, 0x20, 0x15, 0x9f, 0x0f, 0x57, 0x81, 0x06, 0x18, 0x00, 0x04, 0x80, + 0x40, 0x07, 0x50, 0x20, 0x00, 0x08, 0x19, 0x44, 0x00, 0x09, 0x38, 0x0c, 0x00, 0x85, 0x07, 0xc0, + 0x31, 0xf0, 0x01, 0xff, 0x14, 0x0d, 0x80, 0xcc, 0x00, 0x34, 0x0c, 0x58, 0x80, 0x60, 0x10, 0x07, + 0x86, 0x00, 0x00, 0x18, 0x00, 0x01, 0xe0, 0xc3, 0x00, 0x57, 0x88, 0xff, 0xc0, 0x7e, 0xbf, 0x5f, + 0xef, 0xd7, 0xf5, 0xff, 0x18, 0x00, 0x8d, 0xfd, 0xff, 0x7f, 0x7f, 0xef, 0x07, 0xd7, 0xed, 0xf6, + 0xfb, 0x7f, 0xfe, 0xdf, 0x7f, 0x04, 0x11, 0x01, 0x1f, 0x09, 0x93, 0x80, 0x7c, 0x34, 0x6f, 0x82, + 0x14, 0x00, 0x08, 0x10, 0x0b, 0x80, 0xc6, 0x14, 0x14, 0x14, 0x10, 0x64, 0x00, 0x54, 0x23, 0x83, + 0x01, 0x81, 0x80, 0x60, 0x01, 0x1f, 0x83, 0x20, 0x90, 0x10, 0x1c, 0x15, 0x1f, 0x04, 0x66, 0x82, + 0x80, 0x81, 0xe0, 0x02, 0x51, 0x81, 0x12, 0x0e, 0x01, 0x1f, 0x81, 0xc0, 0x70, 0x3c, 0x34, 0x19, + 0x32, 0x10, 0x00, 0x80, 0x02, 0x54, 0x76, 0x38, 0x29, 0x14, 0x00, 0x83, 0x78, 0x00, 0x00, 0x1f, + 0x0c, 0x09, 0x25, 0x1f, 0x10, 0x00, 0x01, 0x04, 0x82, 0x6f, 0xef, 0xe3, 0x21, 0x1f, 0x83, 0xfc, + 0x7f, 0x7e, 0x1f, 0x02, 0x51, 0x81, 0xed, 0xf1, 0x01, 0x1f, 0x81, 0x3f, 0x8f, 0x0d, 0x1f, 0x59, + 0x8f, 0x06, 0xa5, 0x04, 0x00, 0x19, 0x3a, 0x14, 0x10, 0x64, 0x00, 0x54, 0x23, 0x05, 0x1f, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x35, 0x36, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x31, 0x33, 0x20, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x09, 0x09, 0x00, 0x01, 0x0f, 0x00, 0x09, 0x12, + 0x00, 0x01, 0x0f, 0x00, 0x09, 0x1b, 0x00, 0x01, 0x0f, 0x00, 0x09, 0x24, 0x00, 0x01, 0x0f, 0x00, + 0x09, 0x2d, 0x00, 0x01, 0x0f, 0x00, 0x09, 0x36, 0x00, 0x01, 0x0f, 0x00, 0x09, 0x3f, 0x00, 0x03, + 0x0d, 0x00, 0x09, 0x48, 0x00, 0x03, 0x0d, 0x00, 0x09, 0x51, 0x00, 0x03, 0x0d, 0x00, 0x09, 0x5a, + 0x00, 0x03, 0x0d, 0x00, 0x09, 0x63, 0x00, 0x03, 0x0d, 0x00, 0x09, 0x6c, 0x00, 0x03, 0x0d, 0x00, + 0x09, 0x75, 0x00, 0x03, 0x0e, 0x00, 0x09, 0x7e, 0x00, 0x03, 0x0d, 0x00, 0x09, 0x87, 0x00, 0x03, + 0x0d, 0x00, 0x09, 0x90, 0x00, 0x01, 0x0f, 0x00, 0x09, 0x99, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xa2, + 0x00, 0x01, 0x0f, 0x00, 0x09, 0xab, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xb4, 0x00, 0x01, 0x0f, 0x00, + 0x09, 0xbd, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xc6, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xcf, 0x00, 0x01, + 0x0f, 0x00, 0x09, 0xd8, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xe1, 0x00, 0x03, 0x0d, 0x00, 0x09, 0xea, + 0x00, 0x01, 0x0f, 0x00, 0x09, 0xf3, 0x00, 0x01, 0x0f, 0x00, 0x09, 0xfc, 0x00, 0x03, 0x0d, 0x00, + 0x09, 0x05, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x0e, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x17, 0x01, 0x03, + 0x0d, 0x00, 0x09, 0x20, 0x01, 0x00, 0x00, 0x00, 0x09, 0x29, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x32, + 0x01, 0x02, 0x05, 0x00, 0x09, 0x3b, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x44, 0x01, 0x02, 0x0e, 0x00, + 0x09, 0x4d, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x56, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x5f, 0x01, 0x02, + 0x06, 0x00, 0x09, 0x68, 0x01, 0x02, 0x0e, 0x00, 0x09, 0x71, 0x01, 0x02, 0x0e, 0x00, 0x09, 0x7a, + 0x01, 0x03, 0x08, 0x00, 0x09, 0x83, 0x01, 0x05, 0x0c, 0x00, 0x09, 0x8c, 0x01, 0x0b, 0x0f, 0x00, + 0x09, 0x95, 0x01, 0x08, 0x09, 0x00, 0x09, 0x9e, 0x01, 0x0b, 0x0d, 0x00, 0x09, 0xa7, 0x01, 0x02, + 0x0e, 0x00, 0x09, 0xb0, 0x01, 0x03, 0x0d, 0x00, 0x09, 0xb9, 0x01, 0x03, 0x0d, 0x00, 0x09, 0xc2, + 0x01, 0x03, 0x0d, 0x00, 0x09, 0xcb, 0x01, 0x03, 0x0d, 0x00, 0x09, 0xd4, 0x01, 0x03, 0x0d, 0x00, + 0x09, 0xdd, 0x01, 0x03, 0x0d, 0x00, 0x09, 0xe6, 0x01, 0x03, 0x0d, 0x00, 0x09, 0xef, 0x01, 0x03, + 0x0d, 0x00, 0x09, 0xf8, 0x01, 0x03, 0x0d, 0x00, 0x09, 0x01, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x0a, + 0x02, 0x06, 0x0d, 0x00, 0x09, 0x13, 0x02, 0x06, 0x0f, 0x00, 0x09, 0x1c, 0x02, 0x05, 0x0c, 0x00, + 0x09, 0x25, 0x02, 0x07, 0x0a, 0x00, 0x09, 0x2e, 0x02, 0x05, 0x0c, 0x00, 0x09, 0x37, 0x02, 0x03, + 0x0d, 0x00, 0x09, 0x40, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x49, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x52, + 0x02, 0x03, 0x0d, 0x00, 0x09, 0x5b, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x64, 0x02, 0x03, 0x0d, 0x00, + 0x09, 0x6d, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x76, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x7f, 0x02, 0x03, + 0x0d, 0x00, 0x09, 0x88, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x91, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x9a, + 0x02, 0x03, 0x0d, 0x00, 0x09, 0xa3, 0x02, 0x03, 0x0d, 0x00, 0x09, 0xac, 0x02, 0x03, 0x0d, 0x00, + 0x09, 0xb5, 0x02, 0x03, 0x0d, 0x00, 0x09, 0xbe, 0x02, 0x03, 0x0d, 0x00, 0x09, 0xc7, 0x02, 0x03, + 0x0d, 0x00, 0x09, 0xd0, 0x02, 0x03, 0x0d, 0x00, 0x09, 0xd9, 0x02, 0x03, 0x0f, 0x00, 0x09, 0xe2, + 0x02, 0x03, 0x0d, 0x00, 0x09, 0xeb, 0x02, 0x03, 0x0d, 0x00, 0x09, 0xf4, 0x02, 0x03, 0x0d, 0x00, + 0x09, 0xfd, 0x02, 0x03, 0x0d, 0x00, 0x09, 0x06, 0x03, 0x03, 0x0d, 0x00, 0x09, 0x0f, 0x03, 0x03, + 0x0d, 0x00, 0x09, 0x18, 0x03, 0x03, 0x0d, 0x00, 0x09, 0x21, 0x03, 0x03, 0x0d, 0x00, 0x09, 0x2a, + 0x03, 0x03, 0x0d, 0x00, 0x09, 0x33, 0x03, 0x02, 0x0e, 0x00, 0x09, 0x3c, 0x03, 0x02, 0x0e, 0x00, + 0x09, 0x45, 0x03, 0x02, 0x0e, 0x00, 0x09, 0x4e, 0x03, 0x04, 0x0b, 0x00, 0x09, 0x57, 0x03, 0x0d, + 0x0e, 0x00, 0x09, 0x60, 0x03, 0x02, 0x06, 0x00, 0x09, 0x69, 0x03, 0x05, 0x0d, 0x00, 0x09, 0x72, + 0x03, 0x02, 0x0d, 0x00, 0x09, 0x7b, 0x03, 0x05, 0x0d, 0x00, 0x09, 0x84, 0x03, 0x02, 0x0d, 0x00, + 0x09, 0x8d, 0x03, 0x05, 0x0d, 0x00, 0x09, 0x96, 0x03, 0x02, 0x0d, 0x00, 0x09, 0x9f, 0x03, 0x05, + 0x0f, 0x00, 0x09, 0xa8, 0x03, 0x02, 0x0d, 0x00, 0x09, 0xb1, 0x03, 0x02, 0x0d, 0x00, 0x09, 0xba, + 0x03, 0x02, 0x0f, 0x00, 0x09, 0xc3, 0x03, 0x02, 0x0d, 0x00, 0x09, 0xcc, 0x03, 0x02, 0x0d, 0x00, + 0x09, 0xd5, 0x03, 0x05, 0x0d, 0x00, 0x09, 0xde, 0x03, 0x05, 0x0d, 0x00, 0x09, 0xe7, 0x03, 0x05, + 0x0d, 0x00, 0x09, 0xf0, 0x03, 0x05, 0x0f, 0x00, 0x09, 0xf9, 0x03, 0x05, 0x0f, 0x00, 0x09, 0x02, + 0x04, 0x05, 0x0d, 0x00, 0x09, 0x0b, 0x04, 0x05, 0x0d, 0x00, 0x09, 0x14, 0x04, 0x03, 0x0d, 0x00, + 0x09, 0x1d, 0x04, 0x05, 0x0d, 0x00, 0x09, 0x26, 0x04, 0x05, 0x0d, 0x00, 0x09, 0x2f, 0x04, 0x05, + 0x0d, 0x00, 0x09, 0x38, 0x04, 0x05, 0x0d, 0x00, 0x09, 0x41, 0x04, 0x05, 0x0f, 0x00, 0x09, 0x4a, + 0x04, 0x05, 0x0d, 0x00, 0x09, 0x53, 0x04, 0x02, 0x0e, 0x00, 0x09, 0x5c, 0x04, 0x02, 0x0e, 0x00, + 0x09, 0x65, 0x04, 0x02, 0x0e, 0x00, 0x09, 0x6e, 0x04, 0x07, 0x0a, 0x00, 0x09, 0x77, 0x04, 0x01, + 0x0d, 0x00, 0x09, 0x80, 0x04, 0x00, 0x0e, 0x00, 0x09, 0x89, 0x04, 0x00, 0x0f, 0x00, 0x09, 0x92, + 0x04, 0x00, 0x0f, 0x00, 0x09, 0x9b, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xa4, 0x04, 0x00, 0x0f, 0x00, + 0x09, 0xad, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xb6, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xbf, 0x04, 0x00, + 0x0f, 0x00, 0x09, 0xc8, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xd1, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xda, + 0x04, 0x00, 0x0f, 0x00, 0x09, 0xe3, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xec, 0x04, 0x00, 0x0f, 0x00, + 0x09, 0xf5, 0x04, 0x00, 0x0f, 0x00, 0x09, 0xfe, 0x04, 0x00, 0x0f, 0x00, 0x09, 0x07, 0x05, 0x00, + 0x0f, 0x00, 0x09, 0x10, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x19, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x22, + 0x05, 0x00, 0x0f, 0x00, 0x09, 0x2b, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x34, 0x05, 0x00, 0x0f, 0x00, + 0x09, 0x3d, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x46, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x4f, 0x05, 0x00, + 0x0f, 0x00, 0x09, 0x58, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x61, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x6a, + 0x05, 0x00, 0x0f, 0x00, 0x09, 0x73, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x7c, 0x05, 0x00, 0x0f, 0x00, + 0x09, 0x85, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x8e, 0x05, 0x00, 0x0f, 0x00, 0x09, 0x97, 0x05, 0x00, + 0x0f, 0x00, 0x09, 0xa0, 0x05, 0x00, 0x00, 0x00, 0x09, 0xa9, 0x05, 0x05, 0x0f, 0x00, 0x09, 0xb2, + 0x05, 0x02, 0x0e, 0x00, 0x09, 0xbb, 0x05, 0x03, 0x0d, 0x00, 0x09, 0xc4, 0x05, 0x03, 0x0d, 0x00, + 0x09, 0xcd, 0x05, 0x03, 0x0d, 0x00, 0x09, 0xd6, 0x05, 0x02, 0x0e, 0x00, 0x09, 0xdf, 0x05, 0x03, + 0x0e, 0x00, 0x09, 0xe8, 0x05, 0x02, 0x04, 0x00, 0x09, 0xf1, 0x05, 0x03, 0x0d, 0x00, 0x09, 0xfa, + 0x05, 0x03, 0x0a, 0x00, 0x09, 0x03, 0x06, 0x06, 0x0b, 0x00, 0x09, 0x0c, 0x06, 0x07, 0x0a, 0x00, + 0x09, 0x15, 0x06, 0x08, 0x09, 0x00, 0x09, 0x1e, 0x06, 0x03, 0x0b, 0x00, 0x09, 0x27, 0x06, 0x02, + 0x03, 0x00, 0x09, 0x30, 0x06, 0x03, 0x07, 0x00, 0x09, 0x39, 0x06, 0x05, 0x0c, 0x00, 0x09, 0x42, + 0x06, 0x03, 0x0a, 0x00, 0x09, 0x4b, 0x06, 0x03, 0x0a, 0x00, 0x09, 0x54, 0x06, 0x02, 0x04, 0x00, + 0x09, 0x5d, 0x06, 0x05, 0x0f, 0x00, 0x09, 0x66, 0x06, 0x03, 0x0e, 0x00, 0x09, 0x6f, 0x06, 0x08, + 0x0a, 0x00, 0x09, 0x78, 0x06, 0x0d, 0x0f, 0x00, 0x09, 0x81, 0x06, 0x03, 0x0a, 0x00, 0x09, 0x8a, + 0x06, 0x03, 0x0a, 0x00, 0x09, 0x93, 0x06, 0x06, 0x0b, 0x00, 0x09, 0x9c, 0x06, 0x03, 0x0d, 0x00, + 0x09, 0xa5, 0x06, 0x03, 0x0d, 0x00, 0x09, 0xae, 0x06, 0x03, 0x0d, 0x00, 0x09, 0xb7, 0x06, 0x05, + 0x0f, 0x00, 0x09, 0xc0, 0x06, 0x00, 0x0d, 0x00, 0x09, 0xc9, 0x06, 0x00, 0x0d, 0x00, 0x09, 0xd2, + 0x06, 0x00, 0x0d, 0x00, 0x09, 0xdb, 0x06, 0x00, 0x0d, 0x00, 0x09, 0xe4, 0x06, 0x00, 0x0d, 0x00, + 0x09, 0xed, 0x06, 0x01, 0x0d, 0x00, 0x09, 0xf6, 0x06, 0x03, 0x0d, 0x00, 0x09, 0xff, 0x06, 0x03, + 0x0f, 0x00, 0x09, 0x08, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x11, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x1a, + 0x07, 0x00, 0x0d, 0x00, 0x09, 0x23, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x2c, 0x07, 0x00, 0x0d, 0x00, + 0x09, 0x35, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x3e, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x47, 0x07, 0x00, + 0x0d, 0x00, 0x09, 0x50, 0x07, 0x03, 0x0d, 0x00, 0x09, 0x59, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x62, + 0x07, 0x00, 0x0d, 0x00, 0x09, 0x6b, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x74, 0x07, 0x00, 0x0d, 0x00, + 0x09, 0x7d, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x86, 0x07, 0x00, 0x0d, 0x00, 0x09, 0x8f, 0x07, 0x06, + 0x0b, 0x00, 0x09, 0x98, 0x07, 0x03, 0x0d, 0x00, 0x09, 0xa1, 0x07, 0x00, 0x0d, 0x00, 0x09, 0xaa, + 0x07, 0x00, 0x0d, 0x00, 0x09, 0xb3, 0x07, 0x00, 0x0d, 0x00, 0x09, 0xbc, 0x07, 0x00, 0x0d, 0x00, + 0x09, 0xc5, 0x07, 0x00, 0x0d, 0x00, 0x09, 0xce, 0x07, 0x03, 0x0d, 0x00, 0x09, 0xd7, 0x07, 0x02, + 0x0d, 0x00, 0x09, 0xe0, 0x07, 0x02, 0x0d, 0x00, 0x09, 0xe9, 0x07, 0x02, 0x0d, 0x00, 0x09, 0xf2, + 0x07, 0x02, 0x0d, 0x00, 0x09, 0xfb, 0x07, 0x02, 0x0d, 0x00, 0x09, 0x04, 0x08, 0x02, 0x0d, 0x00, + 0x09, 0x0d, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x16, 0x08, 0x05, 0x0d, 0x00, 0x09, 0x1f, 0x08, 0x05, + 0x0f, 0x00, 0x09, 0x28, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x31, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x3a, + 0x08, 0x02, 0x0d, 0x00, 0x09, 0x43, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x4c, 0x08, 0x02, 0x0d, 0x00, + 0x09, 0x55, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x5e, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x67, 0x08, 0x02, + 0x0d, 0x00, 0x09, 0x70, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x79, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x82, + 0x08, 0x02, 0x0d, 0x00, 0x09, 0x8b, 0x08, 0x02, 0x0d, 0x00, 0x09, 0x94, 0x08, 0x02, 0x0d, 0x00, + 0x09, 0x9d, 0x08, 0x02, 0x0d, 0x00, 0x09, 0xa6, 0x08, 0x02, 0x0d, 0x00, 0x09, 0xaf, 0x08, 0x05, + 0x0c, 0x00, 0x09, 0xb8, 0x08, 0x05, 0x0d, 0x00, 0x09, 0xc1, 0x08, 0x02, 0x0d, 0x00, 0x09, 0xca, + 0x08, 0x02, 0x0d, 0x00, 0x09, 0xd3, 0x08, 0x02, 0x0d, 0x00, 0x09, 0xdc, 0x08, 0x02, 0x0d, 0x00, + 0x09, 0xe5, 0x08, 0x02, 0x0f, 0x00, 0x09, 0xee, 0x08, 0x03, 0x0f, 0x00, 0x09, 0xf7, 0x08, 0x02, + 0x0f, 0x00, 0x09, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, +}; diff --git a/src/libdraw/font.c b/src/libdraw/font.c index 13bcd267e..c0235c4b3 100644 --- a/src/libdraw/font.c +++ b/src/libdraw/font.c @@ -132,8 +132,7 @@ agefont(Font *f) if(s->age){ if(s->agecf->name != nil){ /* clean up */ - if(display==nil || s->f != display->defaultsubfont) - freesubfont(s->f); + freesubfont(s->f); s->cf = nil; s->f = nil; s->age = 0; diff --git a/src/libdraw/getdefont.c b/src/libdraw/getdefont.c deleted file mode 100644 index 9279eec46..000000000 --- a/src/libdraw/getdefont.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include - -Subfont* -getdefont(Display *d) -{ - char *hdr, *p; - int n; - Fontchar *fc; - Subfont *f; - int ld; - Rectangle r; - Image *i; - - /* - * make sure data is word-aligned. this is true with Plan 9 compilers - * but not in general. the byte order is right because the data is - * declared as char*, not ulong*. - */ - p = (char*)defontdata; - n = (ulong)p & 3; - if(n != 0){ - memmove(p+(4-n), p, sizeofdefont-n); - p += 4-n; - } - ld = atoi(p+0*12); - r.min.x = atoi(p+1*12); - r.min.y = atoi(p+2*12); - r.max.x = atoi(p+3*12); - r.max.y = atoi(p+4*12); - - i = allocimage(d, r, drawld2chan[ld], 0, 0); - if(i == 0) - return 0; - - p += 5*12; - n = loadimage(i, r, (uchar*)p, (defontdata+sizeofdefont)-(uchar*)p); - if(n < 0){ - freeimage(i); - return 0; - } - - hdr = p+n; - n = atoi(hdr); - p = hdr+3*12; - fc = malloc(sizeof(Fontchar)*(n+1)); - if(fc == 0){ - freeimage(i); - return 0; - } - _unpackinfo(fc, (uchar*)p, n); - f = allocsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i); - if(f == 0){ - freeimage(i); - free(fc); - return 0; - } - return f; -} diff --git a/src/libdraw/getsubfont.c b/src/libdraw/getsubfont.c index 1a5006b46..ba6753909 100644 --- a/src/libdraw/getsubfont.c +++ b/src/libdraw/getsubfont.c @@ -1,12 +1,14 @@ #include #include #include +#include "defont.h" /* * Default version: treat as file name */ int _fontpipe(char*); +static int defaultpipe(void); static void scalesubfont(Subfont*, int); @@ -17,12 +19,14 @@ _getsubfont(Display *d, char *name) Subfont *f; int scale; char *fname; - + scale = parsefontscale(name, &fname); - fd = open(fname, OREAD); + if(strcmp(fname, "*default*") == 0) + fd = defaultpipe(); + else + fd = open(fname, OREAD); if(fd < 0 && strncmp(fname, "/mnt/font/", 10) == 0) fd = _fontpipe(fname+10); - if(fd < 0){ fprint(2, "getsubfont: can't open %s: %r\n", fname); return 0; @@ -46,6 +50,21 @@ _getsubfont(Display *d, char *name) return f; } +static int +defaultpipe(void) +{ + int p[2]; + + // assuming defontdata (<5k) fits in pipe buffer. + // especially reasonable since p9pipe is actually + // a socket pair. + if(pipe(p) < 0) + return -1; + write(p[1], defontdata, sizeof defontdata); + close(p[1]); + return p[0]; +} + static void scalesubfont(Subfont *f, int scale) { @@ -69,8 +88,10 @@ scalesubfont(Subfont *f, int scale) i = allocimage(f->bits->display, r2, f->bits->chan, 0, DBlack); for(y=r.min.y; y < r.max.y; y++) { n = unloadimage(f->bits, Rect(r.min.x, y, r.max.x, y+1), src, srcn); - if(n != srcn) - sysfatal("scalesubfont: bad unload: %d < %d: %r", n, srcn); + if(n != srcn) { + abort(); + sysfatal("scalesubfont: bad unload %R %R: %d < %d: %r", f->bits->r, Rect(r.min.x, y, r.max.x, y+1), n, srcn); + } memset(dst, 0, dstn+1); pack = 8 / f->bits->depth; mask = (1<bits->depth) - 1; diff --git a/src/libdraw/init.c b/src/libdraw/init.c index e5a367f31..350365fe1 100644 --- a/src/libdraw/init.c +++ b/src/libdraw/init.c @@ -8,7 +8,6 @@ Font *font; Image *screen; int _drawdebug; -static char deffontname[] = "*default*"; Screen *_screen; int debuglockdisplay = 1; @@ -41,8 +40,7 @@ drawshutdown(void) int geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *label, char *windir, int ref) { - Subfont *df; - char buf[128], *p; + char *p; if(label == nil) label = argv0; @@ -53,9 +51,7 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l /* * Set up default font */ - df = getdefont(display); - display->defaultsubfont = df; - if(df == nil){ + if(openfont(display, "*default*") == 0) { fprint(2, "imageinit: can't open default subfont: %r\n"); Error: closedisplay(display); @@ -69,21 +65,13 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l * Build fonts with caches==depth of screen, for speed. * If conversion were faster, we'd use 0 and save memory. */ - if(fontname == nil){ - snprint(buf, sizeof buf, "%d %d\n0 %d\t%s\n", df->height, df->ascent, - df->n-1, deffontname); -//BUG: Need something better for this installsubfont("*default*", df); - font = buildfont(display, buf, deffontname); - if(font == nil){ - fprint(2, "imageinit: can't open default font: %r\n"); - goto Error; - } - }else{ - font = openfont(display, fontname); /* BUG: grey fonts */ - if(font == nil){ - fprint(2, "imageinit: can't open font %s: %r\n", fontname); - goto Error; - } + if(fontname == nil) + fontname = strdup("*default*"); + + font = openfont(display, fontname); + if(font == nil){ + fprint(2, "imageinit: can't open font %s: %r\n", fontname); + goto Error; } display->defaultfont = font; @@ -306,7 +294,7 @@ _initdisplay(void (*error)(Display*, char*), char *label) /* * Call with d unlocked. - * Note that disp->defaultfont and defaultsubfont are not freed here. + * Note that disp->defaultfont is not freed here. */ void closedisplay(Display *disp) diff --git a/src/libdraw/mkfile b/src/libdraw/mkfile index 003bf3cec..fab6295b8 100644 --- a/src/libdraw/mkfile +++ b/src/libdraw/mkfile @@ -16,7 +16,6 @@ OFILES=\ creadimage.$O\ cursor.$O\ debug.$O\ - defont.$O\ draw.$O\ drawclient.$O\ drawfcall.$O\ @@ -27,7 +26,6 @@ OFILES=\ event.$O\ font.$O\ freesubfont.$O\ - getdefont.$O\ getrect.$O\ getsubfont.$O\ icossin.$O\ @@ -72,5 +70,7 @@ HFILES=\ $PLAN9/include/mouse.h\ $PLAN9/include/keyboard.h\ +getsubfont.$O: defont.h + <$PLAN9/src/mksyslib diff --git a/src/libdraw/openfont.c b/src/libdraw/openfont.c index 3fe9410a9..366664ae9 100644 --- a/src/libdraw/openfont.c +++ b/src/libdraw/openfont.c @@ -26,6 +26,8 @@ parsefontscale(char *name, char **base) return scale; } +extern char _defontfile[]; + Font* openfont1(Display *d, char *name) { @@ -37,6 +39,10 @@ openfont1(Display *d, char *name) freename = nil; scale = parsefontscale(name, &fname); + if(strcmp(fname, "*default*") == 0) { + buf = strdup(_defontfile); + goto build; + } fd = open(fname, OREAD); if(fd < 0 && strncmp(fname, "/lib/font/bit/", 14) == 0){ nambuf = smprint("#9/font/%s", fname+14); @@ -87,6 +93,7 @@ openfont1(Display *d, char *name) return 0; } buf[i] = 0; +build: fnt = buildfont(d, buf, name); free(buf); free(nambuf); diff --git a/src/libdraw/readsubfont.c b/src/libdraw/readsubfont.c index 059626406..e1024326c 100644 --- a/src/libdraw/readsubfont.c +++ b/src/libdraw/readsubfont.c @@ -58,3 +58,19 @@ readsubfont(Display*d, char *name, int fd, int dolock) { return readsubfonti(d, name, fd, nil, dolock); } + +void +_unpackinfo(Fontchar *fc, uchar *p, int n) +{ + int j; + + for(j=0; j<=n; j++){ + fc->x = p[0]|(p[1]<<8); + fc->top = p[2]; + fc->bottom = p[3]; + fc->left = p[4]; + fc->width = p[5]; + fc++; + p += 6; + } +} diff --git a/src/libdraw/subfontcache.c b/src/libdraw/subfontcache.c index 91a6861a9..6a51f4354 100644 --- a/src/libdraw/subfontcache.c +++ b/src/libdraw/subfontcache.c @@ -12,8 +12,6 @@ Subfont *lastsubfont; Subfont* lookupsubfont(Display *d, char *name) { - if(d && strcmp(name, "*default*") == 0) - return d->defaultsubfont; if(lastname && strcmp(name, lastname)==0) if(d==lastsubfont->bits->display){ lastsubfont->ref++; diff --git a/src/libdraw/subfontname.c b/src/libdraw/subfontname.c index 9d68570d3..e6059d0e8 100644 --- a/src/libdraw/subfontname.c +++ b/src/libdraw/subfontname.c @@ -15,8 +15,13 @@ subfontname(char *cfname, char *fname, int maxdepth) scale = parsefontscale(fname, &base); t = strdup(cfname); /* t is the return string */ - if(strcmp(cfname, "*default*") == 0) + if(strcmp(cfname, "*default*") == 0) { + if(scale > 1) { + free(t); + return smprint("%d*%s", scale, cfname); + } return t; + } if(t[0] != '/'){ tmp2 = strdup(base); u = utfrrune(tmp2, '/'); diff --git a/src/libmemdraw/defont.c b/src/libmemdraw/defont.c deleted file mode 100644 index 21ea6cc01..000000000 --- a/src/libmemdraw/defont.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include - -Memsubfont* -getmemdefont(void) -{ - char *hdr, *p; - int n; - Fontchar *fc; - Memsubfont *f; - int ld; - Rectangle r; - Memdata *md; - Memimage *i; - - /* - * make sure data is word-aligned. this is true with Plan 9 compilers - * but not in general. the byte order is right because the data is - * declared as char*, not u32int*. - */ - p = (char*)defontdata; - n = (uintptr)p & 3; - if(n != 0){ - memmove(p+(4-n), p, sizeofdefont-n); - p += 4-n; - } - ld = atoi(p+0*12); - r.min.x = atoi(p+1*12); - r.min.y = atoi(p+2*12); - r.max.x = atoi(p+3*12); - r.max.y = atoi(p+4*12); - - md = mallocz(sizeof(Memdata), 1); - if(md == nil) - return nil; - - p += 5*12; - - md->base = nil; /* so freememimage doesn't free p */ - md->bdata = (uchar*)p; /* ick */ - md->ref = 1; - md->allocd = 1; /* so freememimage does free md */ - - i = allocmemimaged(r, drawld2chan[ld], md, nil); - if(i == nil){ - free(md); - return nil; - } - - hdr = p+Dy(r)*i->width*sizeof(u32int); - n = atoi(hdr); - p = hdr+3*12; - fc = malloc(sizeof(Fontchar)*(n+1)); - if(fc == 0){ - freememimage(i); - return 0; - } - _unpackinfo(fc, (uchar*)p, n); - f = allocmemsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i); - if(f == 0){ - freememimage(i); - free(fc); - return 0; - } - return f; -} diff --git a/src/libmemdraw/mkfile b/src/libmemdraw/mkfile index a8c32ff54..5668ea430 100644 --- a/src/libmemdraw/mkfile +++ b/src/libmemdraw/mkfile @@ -10,7 +10,6 @@ OFILES=\ cload-stub.$O\ cmap.$O\ cread.$O\ - defont.$O\ draw.$O\ draw-stub.$O\ ellipse.$O\ From ad2d49503b1242be501ab92832400ef344a6afae Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 16 Nov 2018 00:01:10 -0500 Subject: [PATCH 054/323] INSTALL: set $NPROC on macOS My MacBook Pro has hw.ncpu=12, so set NPROC=12. Speeds up INSTALL dramatically. Should probably add similar code to other OSes. Also silence rio warning from earlier commit. --- INSTALL | 1 + dist/isum.awk | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index bfb7f657c..bfb0d5d7d 100755 --- a/INSTALL +++ b/INSTALL @@ -104,6 +104,7 @@ if [ `uname` = SunOS ]; then fi if [ `uname` = Darwin ]; then + export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //') # On Darwin, uname -m -p cannot be trusted. echo "* Running on Darwin: checking architecture..." rm -f ./a.out diff --git a/dist/isum.awk b/dist/isum.awk index 0d2f8721c..081ba0ef3 100644 --- a/dist/isum.awk +++ b/dist/isum.awk @@ -132,7 +132,7 @@ errors != 0 { next } -/(up to date|nothing to see|assuming it will be|loop not entered)/ { +/(up to date|nothing to see|assuming it will be|loop not entered|# WSYSTYPE)/ { next } From 74223e0b4fe2edc1e8aa9665f916603a9f14323d Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 16 Nov 2018 09:14:02 -0600 Subject: [PATCH 055/323] unix: fix for tar on FreeBSD (#202) Use the widely accepted /dev/stdout. --- unix/mkfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unix/mkfile b/unix/mkfile index ab1e66280..1c4319c6b 100644 --- a/unix/mkfile +++ b/unix/mkfile @@ -38,15 +38,15 @@ test-%:V: lib%.tgz:V: mk new-$stem - tar c lib$stem | gzip > $target + tar cf /dev/stdout lib$stem | gzip > $target libregexp9.tgz:V: mk new-regexp - tar c libregexp | gzip >$target + tar cf /dev/stdout libregexp | gzip >$target mk.tgz:V: mk new-mk - tar c mk | gzip > $target + tar cf /dev/stdout mk | gzip > $target mk-with-libs.tgz:V: mk new-utf @@ -59,7 +59,7 @@ mk-with-libs.tgz:V: mv libutf libfmt libbio libregexp mk zot mv zot mk cp make/Makefile.all mk/Makefile - tar c mk | gzip > $target + tar cf /dev/stdout mk | gzip > $target rm -r mk tgz:V: libutf.tgz libfmt.tgz libregexp9.tgz libbio.tgz mk.tgz mk-with-libs.tgz From 2607cc565ee3d5facb8949e9acfed35c8ae300c9 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 16 Nov 2018 09:14:49 -0600 Subject: [PATCH 056/323] INSTALL: use cc to check for fontsrv on non-Darwin (#203) FreeBSD 11.2 by default does not have gcc. --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index bfb0d5d7d..cb0df570b 100755 --- a/INSTALL +++ b/INSTALL @@ -134,7 +134,7 @@ fi if [ `uname` != Darwin ]; then # Determine whether fontsrv X11 files are available. rm -f a.out - gcc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \ + cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \ -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1 if [ -f a.out ]; then echo " fontsrv dependencies found." From 43f1873709d39405b55f676ef21c42065cc1408d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 30 Jul 2018 21:37:37 -0400 Subject: [PATCH 057/323] acme: drop trailing spaces during Put of auto-indent window Auto-indent mode leaves trailing spaces on blank lines as you type past them, so silently elide them from the window content as it gets written back to disk. Another option would be to remove them from the window entirely during Put, but they're actually nice to have while editing, and to date Put has never modified the window content. --- src/cmd/acme/exec.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 68c5d9769..0fc6c16b4 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -690,12 +690,44 @@ checksha1(char *name, File *f, Dir *d) f->qidpath = d->qid.path; f->mtime = d->mtime; } -} +} + +static uint +trimspaces(Rune *r, uint *np, int eof) +{ + uint i, w, nonspace, n; + Rune c; + + nonspace = 0; + w = 0; + n = *np; + for(i=0; i 0 && nonspace < w) { + // Trailing spaces at end of buffer. + // Tell caller to reread them with what follows, + // so we can determine whether they need trimming. + // Unless the trailing spaces are the entire buffer, + // in which case let them through to avoid an infinite loop + // if an entire buffer fills with spaces. + // At EOF, just consume the spaces. + if(!eof) + *np = n - (w - nonspace); + w = nonspace; + } + return w; +} void putfile(File *f, int q0, int q1, Rune *namer, int nname) { - uint n, m; + uint n, nn, m; Rune *r; Biobuf *b; char *s, *name; @@ -750,7 +782,10 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) if(n > BUFSIZE/UTFmax) n = BUFSIZE/UTFmax; bufread(&f->b, q, r, n); - m = snprint(s, BUFSIZE+1, "%.*S", n, r); + nn = n; + if(w->autoindent) + nn = trimspaces(r, &n, q+n==q1); + m = snprint(s, BUFSIZE+1, "%.*S", nn, r); sha1((uchar*)s, m, nil, h); if(Bwrite(b, s, m) != m){ warning(nil, "can't write file %s: %r\n", name); From 3ad4afbe821687bd77f8dffb0e0bf4947faf0a83 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 1 Feb 2019 13:20:27 -0500 Subject: [PATCH 058/323] rio: delete ancient Imakefile (use mk instead) Fixes #235. --- src/cmd/rio/Imakefile | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/cmd/rio/Imakefile diff --git a/src/cmd/rio/Imakefile b/src/cmd/rio/Imakefile deleted file mode 100644 index 43a789318..000000000 --- a/src/cmd/rio/Imakefile +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = -I$(TOP) -DEPLIBS = $(DEPXLIB) -LOCAL_LIBRARIES = $(XLIB) -DEFINES = -DSHAPE # -g3 -DDEBUG -DDEBUG_EV -SRCS = main.c event.c manage.c menu.c client.c grab.c cursor.c error.c color.c -OBJS = main.o event.o manage.o menu.o client.o grab.o cursor.o error.o color.o -HFILES = dat.h fns.h patchlevel.h -MFILES = README 9wm.man Imakefile Makefile.no-imake - -ComplexProgramTarget(rio) - -bun: - bundle $(MFILES) $(SRCS) $(HFILES) >bun - -dist: - bundle $(MFILES) main.c event.c manage.c >bun1 - bundle menu.c client.c grab.c cursor.c error.c $(HFILES) >bun2 - -trout: 9wm.man - troff -man 9wm.man >trout - -vu: trout - xditview trout - -clean:: - $(RM) bun bun[12] trout core - From 047fd921744f39a82a86d9370e03f7af511e6e84 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 25 Feb 2019 09:45:53 -0500 Subject: [PATCH 059/323] page: handle EPS without showpage --- src/cmd/page/gs.c | 4 ++++ src/cmd/page/ps.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/page/gs.c b/src/cmd/page/gs.c index 7179429ac..5c493b355 100644 --- a/src/cmd/page/gs.c +++ b/src/cmd/page/gs.c @@ -186,6 +186,10 @@ spawngs(GSInfo *g, char *safer) Binit(&g->gsrd, stdoutp[0], OREAD); + gscmd(g, "/PAGEDIDSHOWPAGE false def\n"); + gscmd(g, "/showpage { /PAGEDIDSHOWPAGE true def showpage } bind def\n"); + gscmd(g, "/PAGEFLUSH { PAGEDIDSHOWPAGE not {showpage} if /PAGEDIDSHOWPAGE false def } def\n"); + gscmd(g, "/PAGEOUT (/dev/fd/4) (w) file def\n"); if(!strcmp(safer, "-dSAFER")) gscmd(g, ".setsafe\n"); diff --git a/src/cmd/page/ps.c b/src/cmd/page/ps.c index e75a1477c..7935f694c 100644 --- a/src/cmd/page/ps.c +++ b/src/cmd/page/ps.c @@ -353,7 +353,7 @@ initps(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf) } if(dumb) { - fprint(ps->gs.gsfd, "(%s) run\n", argv[0]); + fprint(ps->gs.gsfd, "(%s) run PAGEFLUSH\n", argv[0]); fprint(ps->gs.gsfd, "(/dev/fd/3) (w) file dup (THIS IS NOT A PLAN9 BITMAP 01234567890123456789012345678901234567890123456789\\n) writestring flushfile\n"); } @@ -420,6 +420,7 @@ psdrawpage(Document *d, int page) * so send one to avoid deadlock. */ write(ps->gs.gsfd, "\n", 1); + fprint(ps->gs.gsfd, "\nPAGEFLUSH\n"); im = convert(&ps->gs.g); if(im == nil) { fprint(2, "fatal: readimage error %r\n"); From 4d3c36cce4d70dfd88bd5e782e86141775577d30 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 5 Apr 2019 20:43:21 +0200 Subject: [PATCH 060/323] devdraw: respond to windowDidBecomeKey on darwin (#239) Fixes bug where devdraw does not "notice" mouse position after task switch. Fixes https://github.com/9fans/plan9port/issues/232. --- src/cmd/devdraw/cocoa-screen-metal.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 049d1c5cd..21123f163 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -373,6 +373,11 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl return YES; } +- (void)windowDidBecomeKey:(id)arg +{ + [myContent sendmouse:0]; +} + @end @implementation DevDrawView From 0308e1f010cd8650840fa0ceee3b342229982420 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 5 Apr 2019 12:44:47 -0600 Subject: [PATCH 061/323] devdraw: fix cocoa metal _flushmemscreen for invalid rectangles (#240) It is possible to receive multiple screen resize events, and resizeimg would be called for different sizes, before _flushmemscreen actually gets called with rectangle sizes different from the most recent resizeimg call. The size mismatch would trigger illegal memory access inside _flushmemscreen. This commit protects _flushmemscreen by returning early if the requested rectangle is outside of the current texture rectangle. --- src/cmd/devdraw/cocoa-screen-metal.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 21123f163..78110302b 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -987,6 +987,10 @@ - (void)display _flushmemscreen(Rectangle r) { LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); + if(!rectinrect(r, Rect(0, 0, texture.width, texture.height))){ + LOG(@"Rectangle is out of bounds, return."); + return; + } @autoreleasepool{ [texture From dfac95269ab7944810043fb9e78557b06ed3a767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Fri, 5 Apr 2019 18:45:56 +0000 Subject: [PATCH 062/323] acme: Update tag after receiving menu/nomenu control event (#251) --- src/cmd/acme/xfid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 5aa4a1804..9c7be2c04 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -790,10 +790,12 @@ xfidctlwrite(Xfid *x, Window *w) }else if(strncmp(p, "nomenu", 6) == 0){ /* turn off automatic menu */ w->filemenu = FALSE; + settag = TRUE; m = 6; }else if(strncmp(p, "menu", 4) == 0){ /* enable automatic menu */ w->filemenu = TRUE; + settag = TRUE; m = 4; }else if(strncmp(p, "cleartag", 8) == 0){ /* wipe tag right of bar */ From dc60de7b64948e89832f03181e6db799060036b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Travis=20sn=C9=AF=C7=9D=E1=97=A1=C9=94W?= Date: Fri, 5 Apr 2019 14:47:55 -0400 Subject: [PATCH 063/323] fortunes: correct a mispelling (#234) --- lib/fortunes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fortunes b/lib/fortunes index c1a4580c1..7ac3c1d73 100644 --- a/lib/fortunes +++ b/lib/fortunes @@ -1506,7 +1506,7 @@ This terminal is not for your use, please log off! This time for sure! This will be a memorable month -- no matter how hard you try to forget it. This will hurt me more than it hurts you. -Thos who do not remember the past are condemned to repeat it. +Those who do not remember the past are condemned to repeat it. Those who can't write, write manuals. Those who can, do; those who can't, simulate. Those who can, do; those who can't, write. From 26c6b2579543e928158fa7d3c00d8b0e04ac270c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 5 Apr 2019 15:04:10 -0400 Subject: [PATCH 064/323] devdraw: avoid deadlock on pre-Mojave macOS --- src/cmd/devdraw/cocoa-screen.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index c2489a6c9..97128da21 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -541,6 +541,11 @@ - (BOOL)performDragOperation:(id)arg return; rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); + + // This can get blocked behind responding to mouse events, + // which need to acquire the zlock, so let go of it during + // the flush. Perhaps the waitUntilDone:YES is wrong? + zunlock(); [appdelegate performSelectorOnMainThread:@selector(callflushimg:) withObject:[NSValue valueWithRect:rect] @@ -548,6 +553,7 @@ - (BOOL)performDragOperation:(id)arg modes:[NSArray arrayWithObjects: NSRunLoopCommonModes, @"waiting image", nil]]; + zlock(); } static void drawimg(NSRect, uint); From 61601587295f6d0ef1c4084530fe0318e0c72b16 Mon Sep 17 00:00:00 2001 From: Chris Schultz Date: Fri, 5 Apr 2019 14:08:20 -0500 Subject: [PATCH 065/323] devdraw: prefer low-power GPU for macOS metal rendering (#231) --- src/cmd/devdraw/cocoa-screen-metal.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 78110302b..21c041a55 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -153,6 +153,7 @@ + (void)makewin:(NSValue *)v id library; MTLRenderPipelineDescriptor *pipelineDesc; NSError *error; + NSArray *allDevices; const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable @@ -197,8 +198,18 @@ + (void)makewin:(NSValue *)v [win setContentView:myContent]; [myContent setWantsLayer:YES]; [myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; - - device = MTLCreateSystemDefaultDevice(); + + device = nil; + allDevices = MTLCopyAllDevices(); + for(id mtlDevice in allDevices) { + if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) { + device = mtlDevice; + break; + } + } + if(!device) + device = MTLCreateSystemDefaultDevice(); + commandQueue = [device newCommandQueue]; layer = (DrawLayer *)[myContent layer]; From 7bb69ba88b8083b3eb9b3afefd8cdeae6aea2149 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Fri, 5 Apr 2019 15:09:35 -0400 Subject: [PATCH 066/323] libdraw,devdraw: fix compatibility with old 16x16 cursor protocol (#217) Some libraries that depend on devdraw don't know about 32x32 cursor -- mainly 9fans.net/go/draw. --- src/cmd/devdraw/cocoa-srv.c | 8 ++++++++ src/cmd/devdraw/x11-srv.c | 1 + src/libdraw/drawclient.c | 2 +- src/libdraw/drawfcall.c | 23 +++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index 329dd71fa..c1cf59838 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -162,6 +162,14 @@ runmsg(Wsysmsg *m) break; case Tcursor: + if(m->arrowcursor) + setcursor(nil, nil); + else + setcursor(&m->cursor, nil); + replymsg(m); + break; + + case Tcursor2: if(m->arrowcursor) setcursor(nil, nil); else diff --git a/src/cmd/devdraw/x11-srv.c b/src/cmd/devdraw/x11-srv.c index 17563f411..814164827 100644 --- a/src/cmd/devdraw/x11-srv.c +++ b/src/cmd/devdraw/x11-srv.c @@ -332,6 +332,7 @@ runmsg(Wsysmsg *m) break; case Tcursor: + case Tcursor2: if(m->arrowcursor) _xsetcursor(nil); else diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index de20d3a3b..f0b1d388a 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -296,7 +296,7 @@ _displaycursor(Display *d, Cursor *c, Cursor2 *c2) { Wsysmsg tx, rx; - tx.type = Tcursor; + tx.type = Tcursor2; if(c == nil){ memset(&tx.cursor, 0, sizeof tx.cursor); memset(&tx.cursor2, 0, sizeof tx.cursor2); diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index e36413b65..09051bbc0 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -48,6 +48,7 @@ sizeW2M(Wsysmsg *m) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -64,6 +65,8 @@ sizeW2M(Wsysmsg *m) case Tmoveto: return 4+1+1+4+4; case Tcursor: + return 4+1+1+4+4+2*16+2*16+1; + case Tcursor2: return 4+1+1+4+4+2*16+2*16+4+4+4*32+4*32+1; case Rerror: return 4+1+1+_stringsize(m->error); @@ -108,6 +111,7 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -137,6 +141,13 @@ convW2M(Wsysmsg *m, uchar *p, uint n) PUT(p+10, m->mouse.xy.y); break; case Tcursor: + PUT(p+6, m->cursor.offset.x); + PUT(p+10, m->cursor.offset.y); + memmove(p+14, m->cursor.clr, sizeof m->cursor.clr); + memmove(p+46, m->cursor.set, sizeof m->cursor.set); + p[78] = m->arrowcursor; + break; + case Tcursor2: PUT(p+6, m->cursor.offset.x); PUT(p+10, m->cursor.offset.y); memmove(p+14, m->cursor.clr, sizeof m->cursor.clr); @@ -200,6 +211,7 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Rbouncemouse: case Rmoveto: case Rcursor: + case Rcursor2: case Trdkbd: case Rlabel: case Rinit: @@ -229,6 +241,13 @@ convM2W(uchar *p, uint n, Wsysmsg *m) GET(p+10, m->mouse.xy.y); break; case Tcursor: + GET(p+6, m->cursor.offset.x); + GET(p+10, m->cursor.offset.y); + memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); + memmove(m->cursor.set, p+46, sizeof m->cursor.set); + m->arrowcursor = p[78]; + break; + case Tcursor2: GET(p+6, m->cursor.offset.x); GET(p+10, m->cursor.offset.y); memmove(m->cursor.clr, p+14, sizeof m->cursor.clr); @@ -319,8 +338,12 @@ drawfcallfmt(Fmt *fmt) return fmtprint(fmt, "Rmoveto"); case Tcursor: return fmtprint(fmt, "Tcursor arrow=%d", m->arrowcursor); + case Tcursor2: + return fmtprint(fmt, "Tcursor2 arrow=%d", m->arrowcursor); case Rcursor: return fmtprint(fmt, "Rcursor"); + case Rcursor2: + return fmtprint(fmt, "Rcursor2"); case Trdkbd: return fmtprint(fmt, "Trdkbd"); case Rrdkbd: From 5517aa034025214e43fff6760140d3089d3baf80 Mon Sep 17 00:00:00 2001 From: Noah Evans Date: Sat, 6 Apr 2019 04:10:05 +0900 Subject: [PATCH 067/323] man/memdraw.3: fix typo --- man/man3/memdraw.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3 index 16a5cd796..243cfe161 100644 --- a/man/man3/memdraw.3 +++ b/man/man3/memdraw.3 @@ -267,7 +267,7 @@ returning pointers to the word and byte, respectively, that contain the beginning of the data for a given pixel. .PP .I Allocmemimage -allocages +allocates images with a given rectangle and channel descriptor (see .B strtochan From 317c3cdb76806629e8c2710b7fb9a69cc3e46867 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 5 Apr 2019 13:11:11 -0600 Subject: [PATCH 068/323] devdraw: stop redirecting ^H in cocoa-metal (#209) --- src/cmd/devdraw/cocoa-screen-metal.m | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 21c041a55..5fc031728 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -857,7 +857,6 @@ - (void)display { switch(code){ case '\r': return '\n'; - case '\b': return 127; case 127: return '\b'; case NSUpArrowFunctionKey: return Kup; case NSDownArrowFunctionKey: return Kdown; From 9179fdaaf4fb5748832b2162d35a515133bad0f5 Mon Sep 17 00:00:00 2001 From: Pocket7878 Date: Sat, 6 Apr 2019 04:12:41 +0900 Subject: [PATCH 069/323] samterm: stop ignoring all keys >= Kcmd --- src/cmd/samterm/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index 5b645e842..5fc42908e 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -512,10 +512,11 @@ nontypingkey(int c) case PAGEUP: case RIGHTARROW: case SCROLLKEY: + case CUT: + case COPY: + case PASTE: return 1; } - if(c >= Kcmd) - return 1; return 0; } From 3197719090b3fd0a038767f7e8e15e771b1515be Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 19 Apr 2019 22:24:53 -0400 Subject: [PATCH 070/323] acme: do not trim spaces during Put The commit that introduced this was pushed accidentally. It is not a good idea to do this. (It breaks programs that think that a clean window means the body matches the on-disk file.) --- src/cmd/acme/exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 0fc6c16b4..b3bb0ac37 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -192,7 +192,7 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt) f |= 2; } aa = getbytearg(argt, TRUE, TRUE, &a); - if(a){ + if(a){ if(strlen(a) > EVENTSIZE){ /* too big; too bad */ free(r); free(aa); @@ -674,7 +674,7 @@ checksha1(char *name, File *f, Dir *d) DigestState *h; uchar out[20]; uchar *buf; - + fd = open(name, OREAD); if(fd < 0) return; @@ -700,7 +700,7 @@ trimspaces(Rune *r, uint *np, int eof) nonspace = 0; w = 0; - n = *np; + n = *np; for(i=0; ib, q, r, n); nn = n; - if(w->autoindent) + // An attempt at automatically trimming trailing spaces. + // Breaks programs that inspect body file and think it will match on-disk file + // when window is clean. Should apply the changes to the actual window instead. + // Later. + if(0 && w->autoindent) nn = trimspaces(r, &n, q+n==q1); m = snprint(s, BUFSIZE+1, "%.*S", nn, r); sha1((uchar*)s, m, nil, h); From cc9ecfbee7b1c346bd6b35bf1b9501bdf7eb9c21 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Fri, 17 May 2019 22:17:45 -0500 Subject: [PATCH 071/323] devdraw: cocoa metal screen updates (#215) * devdraw: cocoa metal screen uses a dirty hack to make everything smooth * devdraw: cocoa metal screen uses a layer to make fullscreen applications behave * devdraw: macOS cocoa metal fix resizeimg without img * devdraw: macOS cocoa metal uses blit instead of render We directly use the blit command encoder to copy texture to the framebuffer. We no longer need to compile the metal shader every time the application starts just for rendering a flat 2D surface. * travis: add osx images covering 10.13 and 10.14 --- .travis.yml | 4 ++ src/cmd/devdraw/cocoa-screen-metal.m | 90 +++++++++------------------- 2 files changed, 31 insertions(+), 63 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94ae95e5a..091fd351f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: c matrix: include: + - os: osx + osx_image: xcode10.2 + - os: osx + osx_image: xcode9.4 - os: osx osx_image: xcode9 - os: osx diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 5fc031728..09b346352 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -64,9 +64,7 @@ @interface DrawLayer : CAMetalLayer static NSCursor *currentCursor = NULL; static DrawLayer *layer; -static MTLRenderPassDescriptor *renderPass; static id device; -static id pipelineState; static id commandQueue; static id texture; @@ -74,32 +72,6 @@ @interface DrawLayer : CAMetalLayer static QLock snarfl; -static NSString *const metal = -@"#include\n" -"using namespace metal;\n" -"typedef struct {\n" -" float4 rCoord [[position]];\n" -" float2 tCoord;\n" -"} VertexOut;\n" -"vertex VertexOut\n" -"renderVertex(unsigned int vid [[ vertex_id ]])\n" -"{\n" -" const VertexOut fixedV[] = {\n" -" {{ -1.0f, -1.0f, 0.0f, 1.0f }, { 0.0f, 1.0f }},\n" -" {{ 1.0f, -1.0f, 0.0f, 1.0f }, { 1.0f, 1.0f }},\n" -" {{ -1.0f, 1.0f, 0.0f, 1.0f }, { 0.0f, 0.0f }},\n" -" {{ 1.0f, 1.0f, 0.0f, 1.0f }, { 1.0f, 0.0f }},\n" -" };\n" -" return fixedV[vid];\n" -"}\n" -"fragment half4\n" -"renderFragment(VertexOut in [[ stage_in ]],\n" -" texture2d texture [[ texture(0) ]]) {\n" -" constexpr sampler s;\n" -" return texture.sample(s, in.tCoord);\n" -"}"; - - void threadmain(int argc, char **argv) { @@ -150,9 +122,6 @@ + (void)makewin:(NSValue *)v Rectangle wr; int set; char *s; - id library; - MTLRenderPipelineDescriptor *pipelineDesc; - NSError *error; NSArray *allDevices; const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled @@ -189,7 +158,7 @@ + (void)makewin:(NSValue *)v [win center]; [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; [win setContentMinSize:NSMakeSize(64,64)]; - + [win setOpaque:YES]; [win setRestorable:NO]; [win setAcceptsMouseMovedEvents:YES]; [win setDelegate:myApp]; @@ -209,7 +178,7 @@ + (void)makewin:(NSValue *)v } if(!device) device = MTLCreateSystemDefaultDevice(); - + commandQueue = [device newCommandQueue]; layer = (DrawLayer *)[myContent layer]; @@ -218,25 +187,14 @@ + (void)makewin:(NSValue *)v layer.framebufferOnly = YES; layer.opaque = YES; - renderPass = [MTLRenderPassDescriptor renderPassDescriptor]; - renderPass.colorAttachments[0].loadAction = MTLLoadActionDontCare; - renderPass.colorAttachments[0].storeAction = MTLStoreActionDontCare; - - library = [device newLibraryWithSource:metal options:nil error:&error]; - if(!library) - sysfatal((char *)[[error localizedDescription] UTF8String]); - - pipelineDesc = [MTLRenderPipelineDescriptor new]; - pipelineDesc.alphaToOneEnabled = YES; - pipelineDesc.inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle; - pipelineDesc.rasterSampleCount = 1; - pipelineDesc.colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm; - [pipelineDesc setVertexFunction: [library newFunctionWithName: @"renderVertex"]]; - [pipelineDesc setFragmentFunction: [library newFunctionWithName: @"renderFragment"]]; - - pipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDesc error:&error]; - if(!pipelineState) - sysfatal((char *)[[error localizedDescription] UTF8String]); + // We use a default transparent layer on top of the CAMetalLayer. + // This seems to make fullscreen applications behave. + { + CALayer *stub = [CALayer layer]; + stub.frame = CGRectMake(0, 0, 1, 1); + [stub setNeedsDisplay]; + [layer addSublayer:stub]; + } [NSEvent setMouseCoalescingEnabled:NO]; @@ -278,7 +236,7 @@ + (void)callsetcursor:(NSValue *)v NSImage *i; NSPoint p; uchar *plane[5], *plane2[5]; - int b; + uint b; cs = [v pointerValue]; c = cs->c; @@ -577,13 +535,15 @@ - (void)resetCursorRects { - (void)viewDidEndLiveResize { [super viewDidEndLiveResize]; - resizeimg(); + if(img) + resizeimg(); } - (void)viewDidChangeBackingProperties { [super viewDidChangeBackingProperties]; - resizeimg(); + if(img) + resizeimg(); } // conforms to protocol NSTextInputClient @@ -801,7 +761,7 @@ @implementation DrawLayer - (void)display { id cbuf; - id cmd; + id blit; LOG(@"display"); @@ -821,13 +781,17 @@ - (void)display LOG(@"display got drawable"); - renderPass.colorAttachments[0].texture = drawable.texture; - - cmd = [cbuf renderCommandEncoderWithDescriptor:renderPass]; - [cmd setRenderPipelineState:pipelineState]; - [cmd setFragmentTexture:texture atIndex:0]; - [cmd drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4]; - [cmd endEncoding]; + blit = [cbuf blitCommandEncoder]; + [blit copyFromTexture:texture + sourceSlice:0 + sourceLevel:0 + sourceOrigin:MTLOriginMake(0, 0, 0) + sourceSize:MTLSizeMake(texture.width, texture.height, texture.depth) + toTexture:drawable.texture + destinationSlice:0 + destinationLevel:0 + destinationOrigin:MTLOriginMake(0, 0, 0)]; + [blit endEncoding]; [cbuf presentDrawable:drawable]; drawable = nil; From 161742770e63fec914b0290def3ac063ad3d2cf9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 24 Apr 2019 11:02:34 -0400 Subject: [PATCH 072/323] acme: delete trailing spaces during Put in autoindent mode Autoident mode is the leading cause of trailing spaces on lines. Remove them during Put to make various picky tools happier. The changes during Put are added as a separate entry to the file history, so that the first Undo after Put restores the spaces. --- src/cmd/acme/exec.c | 105 +++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index b3bb0ac37..ff491601a 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -692,42 +692,10 @@ checksha1(char *name, File *f, Dir *d) } } -static uint -trimspaces(Rune *r, uint *np, int eof) -{ - uint i, w, nonspace, n; - Rune c; - - nonspace = 0; - w = 0; - n = *np; - for(i=0; i 0 && nonspace < w) { - // Trailing spaces at end of buffer. - // Tell caller to reread them with what follows, - // so we can determine whether they need trimming. - // Unless the trailing spaces are the entire buffer, - // in which case let them through to avoid an infinite loop - // if an entire buffer fills with spaces. - // At EOF, just consume the spaces. - if(!eof) - *np = n - (w - nonspace); - w = nonspace; - } - return w; -} - void putfile(File *f, int q0, int q1, Rune *namer, int nname) { - uint n, nn, m; + uint n, m; Rune *r; Biobuf *b; char *s, *name; @@ -754,6 +722,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) goto Rescue1; } } + fd = create(name, OWRITE, 0666); if(fd < 0){ warning(nil, "can't create file %s: %r\n", name); @@ -782,14 +751,7 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) if(n > BUFSIZE/UTFmax) n = BUFSIZE/UTFmax; bufread(&f->b, q, r, n); - nn = n; - // An attempt at automatically trimming trailing spaces. - // Breaks programs that inspect body file and think it will match on-disk file - // when window is clean. Should apply the changes to the actual window instead. - // Later. - if(0 && w->autoindent) - nn = trimspaces(r, &n, q+n==q1); - m = snprint(s, BUFSIZE+1, "%.*S", nn, r); + m = snprint(s, BUFSIZE+1, "%.*S", n, r); sha1((uchar*)s, m, nil, h); if(Bwrite(b, s, m) != m){ warning(nil, "can't write file %s: %r\n", name); @@ -868,6 +830,65 @@ putfile(File *f, int q0, int q1, Rune *namer, int nname) free(name); } +static void +trimspaces(Text *et) +{ + File *f; + Rune *r; + Text *t; + uint q0, n, delstart; + int c, i, marked; + + t = &et->w->body; + f = t->file; + marked = 0; + + if(t->w!=nil && et->w!=t->w){ + /* can this happen when t == &et->w->body? */ + c = 'M'; + if(et->w) + c = et->w->owner; + winlock(t->w, c); + } + + r = fbufalloc(); + q0 = f->b.nc; + delstart = q0; /* end of current space run, or 0 if no active run; = q0 to delete spaces before EOF */ + while(q0 > 0) { + n = RBUFSIZE; + if(n > q0) + n = q0; + q0 -= n; + bufread(&f->b, q0, r, n); + for(i=n; ; i--) { + if(i == 0 || (r[i-1] != ' ' && r[i-1] != '\t')) { + // Found non-space or start of buffer. Delete active space run. + if(q0+i < delstart) { + if(!marked) { + marked = 1; + seq++; + filemark(f); + } + textdelete(t, q0+i, delstart, TRUE); + } + if(i == 0) { + /* keep run active into tail of next buffer */ + if(delstart > 0) + delstart = q0; + break; + } + delstart = 0; + if(r[i-1] == '\n') + delstart = q0+i-1; /* delete spaces before this newline */ + } + } + } + fbuffree(r); + + if(t->w!=nil && et->w!=t->w) + winunlock(t->w); +} + void put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg) { @@ -890,6 +911,8 @@ put(Text *et, Text *_0, Text *argt, int _1, int _2, Rune *arg, int narg) warning(nil, "no file name\n"); return; } + if(w->autoindent) + trimspaces(et); namer = bytetorune(name, &nname); putfile(f, 0, f->b.nc, namer, nname); xfidlog(w, "put"); From 7a241631b2097b1acda431ff059b771c5d1c391c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 10 Jun 2019 16:01:10 -0400 Subject: [PATCH 073/323] acme: accept expanded URLs in look Just as look expands a click in /etc/passwd to the full name (provided that file exists), it now expands a click in https://9fans.net/ to the full URL (provided the prefix is http:// or https://). Probably more adjustment is needed. --- src/cmd/acme/look.c | 48 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index cbbc71bf5..44e23ccac 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -30,7 +30,7 @@ plumbthread(void *v) USED(v); threadsetname("plumbproc"); - + /* * Loop so that if plumber is restarted, acme need not be. */ @@ -46,7 +46,7 @@ plumbthread(void *v) } plumbeditfid = fid; plumbsendfid = plumbopenfid("send", OWRITE|OCEXEC); - + /* * Relay messages. */ @@ -432,9 +432,9 @@ includename(Text *t, Rune *r, int n) char buf[128]; Rune Lsysinclude[] = { '/', 's', 'y', 's', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 }; Rune Lusrinclude[] = { '/', 'u', 's', 'r', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 }; - Rune Lusrlocalinclude[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l', + Rune Lusrlocalinclude[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 }; - Rune Lusrlocalplan9include[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l', + Rune Lusrlocalplan9include[] = { '/', 'u', 's', 'r', '/', 'l', 'o', 'c', 'a', 'l', '/', 'p', 'l', 'a', 'n', '9', '/', 'i', 'n', 'c', 'l', 'u', 'd', 'e', 0 }; Runestr file; int i; @@ -443,7 +443,7 @@ includename(Text *t, Rune *r, int n) sprint(buf, "/%s/include", objtype); objdir = bytetorune(buf, &i); objdir = runerealloc(objdir, i+1); - objdir[i] = '\0'; + objdir[i] = '\0'; } w = t->w; @@ -514,6 +514,19 @@ dirname(Text *t, Rune *r, int n) return tmp; } +static int +texthas(Text *t, uint q0, Rune *r) +{ + int i; + + if((int)q0 < 0) + return FALSE; + for(i=0; r[i]; i++) + if(q0+i >= t->file->b.nc || textreadc(t, q0+i) != r[i]) + return FALSE; + return TRUE; +} + int expandfile(Text *t, uint q0, uint q1, Expand *e) { @@ -522,12 +535,14 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) Rune *r, c; Window *w; Runestr rs; + Rune Lhttpcss[] = {'h', 't', 't', 'p', ':', '/', '/', 0}; + Rune Lhttpscss[] = {'h', 't', 't', 'p', 's', ':', '/', '/', 0}; amax = q1; if(q1 == q0){ colon = -1; while(q1file->b.nc && isfilec(c=textreadc(t, q1))){ - if(c == ':'){ + if(c == ':' && !texthas(t, q1-4, Lhttpcss) && !texthas(t, q1-5, Lhttpscss)){ colon = q1; break; } @@ -535,7 +550,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) } while(q0>0 && (isfilec(c=textreadc(t, q0-1)) || isaddrc(c) || isregexc(c))){ q0--; - if(colon<0 && c==':') + if(colon<0 && c==':' && !texthas(t, q0-4, Lhttpcss) && !texthas(t, q0-5, Lhttpscss)) colon = q0; } /* @@ -565,8 +580,23 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) if(n == 0) return FALSE; /* see if it's a file name */ - r = runemalloc(n); + r = runemalloc(n+1); bufread(&t->file->b, q0, r, n); + r[n] = 0; + /* is it a URL? look for http:// and https:// prefix */ + if(runestrncmp(r, Lhttpcss, 7) == 0 || runestrncmp(r, Lhttpscss, 8) == 0){ + // Avoid capturing end-of-sentence punctuation. + if(r[n-1] == '.') { + e->q1--; + n--; + } + e->name = r; + e->nname = n; + e->u.at = t; + e->a0 = e->q1; + e->a1 = e->q1; + return TRUE; + } /* first, does it have bad chars? */ nname = -1; for(i=0; i Date: Sat, 17 Nov 2018 21:22:42 +0900 Subject: [PATCH 074/323] devdraw: handle windowDidResize on macOS (#212) This supports non-live window resize. --- src/cmd/devdraw/cocoa-screen-metal.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 09b346352..959df59bf 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -342,6 +342,13 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl return YES; } +- (void)windowDidResize:(NSNotification *)notification +{ + if(![myContent inLiveResize] && img) { + resizeimg(); + } +} + - (void)windowDidBecomeKey:(id)arg { [myContent sendmouse:0]; @@ -1112,7 +1119,6 @@ - (void)display s = [myContent convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; [win setContentSize:s]; - resizeimg(); }); } From e995a0c101863688d5f14649ae3de45a7c43789c Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Wed, 19 Jun 2019 13:32:57 -0500 Subject: [PATCH 075/323] devdraw: cocoa metal screen adds a delayed update (#270) The immediate display of the screen sometimes miss the update from the CPU side memory. No obvious synchronization mechanism is available. In order to make sure the screen updates properly, we set needsDisplay again after 16ms delay to ensure a second screen update. --- src/cmd/devdraw/cocoa-screen-metal.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen-metal.m index 959df59bf..984ede033 100644 --- a/src/cmd/devdraw/cocoa-screen-metal.m +++ b/src/cmd/devdraw/cocoa-screen-metal.m @@ -212,12 +212,19 @@ + (void)callkicklabel:(NSString *)s + (void)callsetNeedsDisplayInRect:(NSValue *)v { NSRect r; + dispatch_time_t time; r = [v rectValue]; LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); r = [win convertRectFromBacking:r]; LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); [layer setNeedsDisplayInRect:r]; + + time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); + dispatch_after(time, dispatch_get_main_queue(), ^(void){ + [layer setNeedsDisplayInRect:r]; + }); + [myContent enlargeLastInputRect:r]; } From 7d827b5cca185b411be3ac9b71834958f4737bdf Mon Sep 17 00:00:00 2001 From: Zach Scott Date: Thu, 19 Sep 2019 17:08:36 +0000 Subject: [PATCH 076/323] auxstats: replace /proc ACPI calls with /sys ones (#245) According to , use of `/proc/acpi` to get battery usage is deprecated. This commit replaces the two files from this API with the single file `/sys/class/power_supply/BAT0/capacity`, simultaneously removing the need to calculate battery percentage. --- src/cmd/auxstats/Linux.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index 09ca18f30..64c86a26c 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -26,36 +26,22 @@ void (*statfn[])(int) = void xapm(int first) { - static int fd = -1, fdb = -1; - int i, last = -1, curr = -1; + static int fd = -1; + int curr = -1; if(first){ - fd = open("/proc/acpi/battery/BAT0/info", OREAD); - fdb = open("/proc/acpi/battery/BAT0/state", OREAD); + fd = open("/sys/class/power_supply/BAT0/capacity", OREAD); return; } - if(fd == -1 || fdb == -1) + if(fd == -1) return; readfile(fd); - for(i=0; i Date: Thu, 19 Sep 2019 13:08:54 -0400 Subject: [PATCH 077/323] plumber: fix EOF detection on writes to rules file (#257) Instead of checking Fcall.data==nil, check Fcall.count==0. The former check always fails after `gcc -O2` optimizations (gcc version 8.3.0). Also fix an out-of-bound read detected by valgrind: ``` ==31162== Invalid read of size 1 ==31162== at 0x11005E: morerules (rules.c:739) ==31162== by 0x110254: writerules (rules.c:775) ==31162== by 0x10D2FE: fsyswrite (fsys.c:848) ==31162== by 0x10C304: fsysproc (fsys.c:248) ==31162== by 0x112E8C: threadstart (thread.c:96) ==31162== by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so) ==31162== Address 0x4ea984a is 0 bytes after a block of size 250 alloc'd ==31162== at 0x483AD7B: realloc (vg_replace_malloc.c:826) ==31162== by 0x1196F3: p9realloc (malloc.c:53) ==31162== by 0x10BDFD: erealloc (plumber.c:124) ==31162== by 0x10FCD9: concat (rules.c:642) ==31162== by 0x10FCD9: concat (rules.c:635) ==31162== by 0x110230: writerules (rules.c:773) ==31162== by 0x10D2FE: fsyswrite (fsys.c:848) ==31162== by 0x10C304: fsysproc (fsys.c:248) ==31162== by 0x112E8C: threadstart (thread.c:96) ==31162== by 0x4A682BF: ??? (in /usr/lib/libc-2.29.so) ``` Fixes #256 --- src/cmd/plumb/rules.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/plumb/rules.c b/src/cmd/plumb/rules.c index 4da4bb23c..6e9b2c632 100644 --- a/src/cmd/plumb/rules.c +++ b/src/cmd/plumb/rules.c @@ -736,8 +736,8 @@ morerules(uchar *text, int done) */ endofrule = nil; for(s=text; *s!='\0'; s++) - if(*s=='\n' && *++s=='\n') - endofrule = s+1; + if(*s=='\n' && *(s+1)=='\n') + endofrule = s+2; if(endofrule == nil) return text; input->end = endofrule; @@ -772,7 +772,7 @@ writerules(char *s, int n) tmp = stringof(s, n); text = (uchar*)concat((char*)text, tmp); free(tmp); - text = morerules(text, s==nil); + text = morerules(text, n==0); } if(s == nil){ free(text); From 9389de63d7b0dab99773511f48b2d303e3f957d7 Mon Sep 17 00:00:00 2001 From: telephil Date: Thu, 19 Sep 2019 19:10:09 +0200 Subject: [PATCH 078/323] upas/nfs: fix null date when message is sent to plumber (#263) When fetching, messages are sent to plumber as soon as the ENVELOPE part is read. The date field of the message is sent when the INTERNALDATE part is read and there is no guarantee that this will be read before the ENVELOPE. This bug can be observed when using faces(1) which will retrieve messages with a null date and then always display a 'Jan 1' date instead of the correct one. The fix is to simply send the message to plumber after having read all parts, thus ensuring the message is complete. --- src/cmd/upas/nfs/imap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c index 8d43fe799..ef76487b5 100644 --- a/src/cmd/upas/nfs/imap.c +++ b/src/cmd/upas/nfs/imap.c @@ -1468,6 +1468,7 @@ xfetch(Imap *z, Sx *sx) if(isatom(sx->sx[i], msgtab[j].name)) msgtab[j].fn(msg, sx->sx[i], sx->sx[i+1]); } + msgplumb(msg, 0); } static void @@ -1549,7 +1550,6 @@ xmsgenvelope(Msg *msg, Sx *k, Sx *v) USED(k); hdrfree(msg->part[0]->hdr); msg->part[0]->hdr = parseenvelope(v); - msgplumb(msg, 0); } static struct { From f1dd3f065a97f57bf59db2e3284868e181734159 Mon Sep 17 00:00:00 2001 From: deepcube Date: Thu, 19 Sep 2019 10:10:28 -0700 Subject: [PATCH 079/323] hoc: don't nest calls to follow() when lexing ++/+= and --/-= (#287) The code had a nested use of the follow() function that could cause +=+ and -=- to register as ++ and --. The first follow() to execute could consume a character and match and then the second follow() could consume another character and match. For example i-=-10 would result in a syntax error and i-=- would decrement i. --- src/cmd/hoc/hoc.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/hoc/hoc.y b/src/cmd/hoc/hoc.y index 9c5a02f1e..f634e82d9 100644 --- a/src/cmd/hoc/hoc.y +++ b/src/cmd/hoc/hoc.y @@ -215,8 +215,8 @@ yylex(void) /* hoc6 */ return STRING; } switch (c) { - case '+': return follow('+', INC, follow('=', ADDEQ, '+')); - case '-': return follow('-', DEC, follow('=', SUBEQ, '-')); + case '+': return follow('+', INC, '+') == INC ? INC : follow('=', ADDEQ, '+'); + case '-': return follow('-', DEC, '-') == DEC ? DEC : follow('=', SUBEQ, '-'); case '*': return follow('=', MULEQ, '*'); case '/': return follow('=', DIVEQ, '/'); case '%': return follow('=', MODEQ, '%'); From 13d40aa64c8c073c296ad2c8df0bae6d607aff07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Noack?= Date: Thu, 19 Sep 2019 22:49:08 +0200 Subject: [PATCH 080/323] 9l: support Linux version 5.0+ (#274) Update 9l to support Linux 5.x. --- bin/9l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/9l b/bin/9l index 6195815f7..4266b10ea 100755 --- a/bin/9l +++ b/bin/9l @@ -40,7 +40,7 @@ case "$tag" in userpath=true extralibs="$extralibs -lutil -lresolv" case "${SYSVERSION:-`uname -r`}" in - 2.6.* | 3.* | 4.*) + 2.6.* | [3-9].* | [1-9][0-9].*) extralibs="$extralibs -lpthread" ;; esac From 715807d706cd13bc583588477a84090fbf02e057 Mon Sep 17 00:00:00 2001 From: Francis Conti Date: Thu, 19 Sep 2019 13:50:44 -0700 Subject: [PATCH 081/323] =?UTF-8?q?Teach=209l=20about=20FreeBSD=20?= =?UTF-8?q?=E2=89=A5=2012;=20address=20issue=20#247.=20(#249)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/9l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/9l b/bin/9l index 4266b10ea..0e9395247 100755 --- a/bin/9l +++ b/bin/9l @@ -19,7 +19,7 @@ case "$tag" in 5.2.*) extralibs="$extralibs -lkse" ;; - [5-9].*|1[0-1].*) + [5-9].*|1[0-9].*) extralibs="$extralibs -lpthread" ;; esac From 1309450668aa571dee97f4373f9555b4fddcf1aa Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Tue, 29 Oct 2019 10:04:06 -0400 Subject: [PATCH 082/323] awk: split record into runes for empty FS (#292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit awk was splitting records into bytes instead of runes for empty FS. For example, this was printing only the first byte of the utf-8 encoding of é: echo é | awk 'BEGIN{FS=""}{print $1}' The change just copies how the `split` function handles runes. Originally reported by kris on twitter: https://twitter.com/p9luv/status/1180436083433201665 --- src/cmd/awk/lib.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cmd/awk/lib.c b/src/cmd/awk/lib.c index 6a6849c54..3eb30687c 100644 --- a/src/cmd/awk/lib.c +++ b/src/cmd/awk/lib.c @@ -29,6 +29,7 @@ THIS SOFTWARE. #include #include #include +#include #include "awk.h" #include "y.tab.h" @@ -293,15 +294,19 @@ void fldbld(void) /* create fields from current record */ } *fr = 0; } else if ((sep = *inputFS) == 0) { /* new: FS="" => 1 char/field */ - for (i = 0; *r != 0; r++) { - char buf[2]; + int nb; + for (i = 0; *r != 0; r += nb) { + Rune rr; + char buf[UTFmax+1]; + i++; if (i > nfields) growfldtab(i); if (freeable(fldtab[i])) xfree(fldtab[i]->sval); - buf[0] = *r; - buf[1] = 0; + nb = chartorune(&rr, r); + memmove(buf, r, nb); + buf[nb] = '\0'; fldtab[i]->sval = tostring(buf); fldtab[i]->tval = FLD | STR; } From b0aecb4ba5c3d7df6589c01f5a7c0427f5a75305 Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Tue, 29 Oct 2019 10:07:10 -0400 Subject: [PATCH 083/323] plumber: add -f (foreground) option (#288) In MacOS, services run by launchd must run in the foreground, since launchd manages forking and other resources. --- man/man4/plumber.4 | 9 ++++++++- src/cmd/plumb/fsys.c | 7 +++++-- src/cmd/plumb/plumber.c | 6 +++++- src/cmd/plumb/plumber.h | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/man/man4/plumber.4 b/man/man4/plumber.4 index 0dfe68bb8..88801eb4d 100644 --- a/man/man4/plumber.4 +++ b/man/man4/plumber.4 @@ -4,6 +4,9 @@ plumber \- file system for interprocess messaging .SH SYNOPSIS .B plumber [ +.B -f +] +[ .B -p .I plumbing ] @@ -23,7 +26,7 @@ in the format of Its services are posted via .IR 9pserve (4) as -.BR plumb . +.BR plumb , and consist of two pre-defined files, .B plumb/send @@ -95,6 +98,10 @@ Thus the rule set may be edited dynamically with a traditional text editor. However, ports are never deleted dynamically; if a new set of rules does not include a port that was defined in earlier rules, that port will still exist (although no new messages will be delivered there). +.PP +The +.B -f +option causes the process to run in the foreground. .SH FILES .TF $HOME/lib/plumbing .TP diff --git a/src/cmd/plumb/fsys.c b/src/cmd/plumb/fsys.c index 515426748..63106fcdb 100644 --- a/src/cmd/plumb/fsys.c +++ b/src/cmd/plumb/fsys.c @@ -186,7 +186,7 @@ getclock(void) } void -startfsys(void) +startfsys(int foreground) { int p[2]; @@ -199,7 +199,10 @@ startfsys(void) if(post9pservice(p[1], "plumb", nil) < 0) sysfatal("post9pservice plumb: %r"); close(p[1]); - proccreate(fsysproc, nil, Stack); + if(foreground) + fsysproc(nil); + else + proccreate(fsysproc, nil, Stack); } static void diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c index 2debf49ba..c99282f02 100644 --- a/src/cmd/plumb/plumber.c +++ b/src/cmd/plumb/plumber.c @@ -7,6 +7,7 @@ #include "plumber.h" int debug; +int foreground=0; char *plumbfile; char *user; char *home; @@ -37,6 +38,9 @@ threadmain(int argc, char *argv[]) case 'd': debug = 1; break; + case 'f': + foreground = 1; + break; case 'p': plumbfile = ARGF(); break; @@ -69,7 +73,7 @@ threadmain(int argc, char *argv[]) */ printerrors = 0; makeports(rules); - startfsys(); + startfsys(foreground); threadexits(nil); } diff --git a/src/cmd/plumb/plumber.h b/src/cmd/plumb/plumber.h index c8f308166..44700559b 100644 --- a/src/cmd/plumb/plumber.h +++ b/src/cmd/plumb/plumber.h @@ -72,7 +72,7 @@ void* emalloc(long); void* erealloc(void*, long); char* estrdup(char*); Ruleset** readrules(char*, int); -void startfsys(void); +void startfsys(int); Exec* matchruleset(Plumbmsg*, Ruleset*); void freeexec(Exec*); char* startup(Ruleset*, Exec*); From 436ff26c3688198de8e8e48121296eace0b5d119 Mon Sep 17 00:00:00 2001 From: Jason Felice Date: Mon, 11 Nov 2019 17:06:55 -0500 Subject: [PATCH 084/323] 9c, 9l: use $TMPDIR if available (#272) NixOS sandboxed builds (at least on Mac) don't have access to /tmp, and this should be better POSIX. --- bin/9c | 2 +- bin/9l | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/9c b/bin/9c index 3ffb716ca..88c47887d 100755 --- a/bin/9c +++ b/bin/9c @@ -133,7 +133,7 @@ case "$tag" in esac # N.B. Must use temp file to avoid pipe; pipe loses status. -xtmp=/tmp/9c.$$.$USER.out +xtmp=${TMPDIR-/tmp}/9c.$$.$USER.out $cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp status=$? quiet $xtmp diff --git a/bin/9l b/bin/9l index 0e9395247..032d38010 100755 --- a/bin/9l +++ b/bin/9l @@ -346,7 +346,7 @@ then echo $ld -L$PLAN9/lib "$@" $libsl $extralibs $frameworks fi -xtmp=/tmp/9l.$$.$USER.out +xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out" xxout() { sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' From 46606276c3fe20fa81597cf87378e18f7baf88a7 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Thu, 14 Nov 2019 00:47:58 -0500 Subject: [PATCH 085/323] page: fix hang for forward-only postscript files Page was hanging because ghostscript never closes the fd from which we're reading BMP data. We close our end of the pipe so that ghostscript will close its end. Tested with ghostscript version 9.50. Fixes #124 --- src/cmd/page/cache.c | 7 ++++++- src/cmd/page/ps.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd/page/cache.c b/src/cmd/page/cache.c index 0063a3396..5110840f7 100644 --- a/src/cmd/page/cache.c +++ b/src/cmd/page/cache.c @@ -168,7 +168,12 @@ raproc(void *a) c = a; lockdisplay(display); - _cachedpage(c->doc, c->angle, c->page, "-ra"); + /* + * If there is only one page in a fwdonly file, we may reach EOF + * while doing readahead and page will exit without showing anything. + */ + if(!c->doc->fwdonly) + _cachedpage(c->doc, c->angle, c->page, "-ra"); rabusy = 0; unlockdisplay(display); free(c); diff --git a/src/cmd/page/ps.c b/src/cmd/page/ps.c index 7935f694c..846895718 100644 --- a/src/cmd/page/ps.c +++ b/src/cmd/page/ps.c @@ -355,6 +355,7 @@ initps(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf) if(dumb) { fprint(ps->gs.gsfd, "(%s) run PAGEFLUSH\n", argv[0]); fprint(ps->gs.gsfd, "(/dev/fd/3) (w) file dup (THIS IS NOT A PLAN9 BITMAP 01234567890123456789012345678901234567890123456789\\n) writestring flushfile\n"); + close(ps->gs.gsfd); } ps->bbox = bbox; From 3d08a066b167b60691949fe89a7a67ef29df39cb Mon Sep 17 00:00:00 2001 From: Marc Simpson Date: Sun, 8 Dec 2019 17:19:17 -0800 Subject: [PATCH 086/323] ed: replace magic number (077776, i.e. 32766) with NBLK-1. (#300) Temp file size is now declared in an enum; changing it from the default introduces a subtle bug in putline(), which expects it to be 32767. Mask with NBLK-1 instead. --- src/cmd/ed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ed.c b/src/cmd/ed.c index 788b35be5..90bb63152 100644 --- a/src/cmd/ed.c +++ b/src/cmd/ed.c @@ -1050,7 +1050,7 @@ putline(void) } } nl = tline; - tline += ((lp-linebuf) + 03) & 077776; + tline += ((lp-linebuf) + 03) & (NBLK-1); return nl; } From 01a29ffe9dec8f11afa6db22a6ed0218bdbe5c5c Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Sun, 8 Dec 2019 20:20:22 -0500 Subject: [PATCH 087/323] page: fix pdf prolog for ghostscript >= 9.27 (#296) Ghostscript 9.27 removed GS_PDF_ProcSet and pdfdict due to a security issue (see https://security-tracker.debian.org/tracker/CVE-2019-3839). This fix was contributed by @onyxperidot (see #279). Fixes #279 --- src/cmd/page/pdfprolog.c | 3 +-- src/cmd/page/pdfprolog.ps | Bin 519 -> 496 bytes 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cmd/page/pdfprolog.c b/src/cmd/page/pdfprolog.c index de51c062a..3b6cbcd75 100644 --- a/src/cmd/page/pdfprolog.c +++ b/src/cmd/page/pdfprolog.c @@ -16,5 +16,4 @@ " } if\n" "} bind def\n" "\n" -"GS_PDF_ProcSet begin\n" -"pdfdict begin\n" +"runpdfbegin\n" diff --git a/src/cmd/page/pdfprolog.ps b/src/cmd/page/pdfprolog.ps index 681e0587a709e20412700a85bd7378e79d161536..a57e20b117eb5e708e1416ec80c98aba483fc7b4 100644 GIT binary patch delta 20 bcmZo?`M|v42_sKYX Date: Tue, 10 Dec 2019 08:36:05 -0800 Subject: [PATCH 088/323] ed: formatting tweak (remove redundant tab). (#301) --- src/cmd/ed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ed.c b/src/cmd/ed.c index 90bb63152..4084994cc 100644 --- a/src/cmd/ed.c +++ b/src/cmd/ed.c @@ -13,7 +13,7 @@ enum FNSIZE = 128, /* file name */ LBSIZE = 4096, /* max line size */ BLKSIZE = 4096, /* block size in temp file */ - NBLK = 32767, /* max size of temp file */ + NBLK = 32767, /* max size of temp file */ ESIZE = 256, /* max size of reg exp */ GBSIZE = 256, /* max size of global command */ MAXSUB = 9, /* max number of sub reg exp */ From 4af8158b5351cc0ed7fc0ebb5e7b31c64069363d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 19 Dec 2019 14:49:35 -0500 Subject: [PATCH 089/323] libbio: report Bflush/close error from Bterm --- src/libbio/binit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libbio/binit.c b/src/libbio/binit.c index 8ec375ce6..95a70a285 100644 --- a/src/libbio/binit.c +++ b/src/libbio/binit.c @@ -141,13 +141,15 @@ Bopen(char *name, int mode) int Bterm(Biobuf *bp) { + int ret; deinstall(bp); - Bflush(bp); + ret = Bflush(bp); if(bp->flag == Bmagic) { bp->flag = 0; - close(bp->fid); + if(close(bp->fid) < 0) + ret = -1; free(bp); } - return 0; + return ret; } From 0b349f6f34f1fff58ab9748277a093f70df2be33 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 19 Dec 2019 14:51:18 -0500 Subject: [PATCH 090/323] acme: report close failure during Put --- src/cmd/acme/exec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index ff491601a..1d50f92fe 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -699,7 +699,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; @@ -762,9 +762,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; From a1ead676e69d46df89dd0de12cf86380c5773353 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 19 Dec 2019 15:00:58 -0500 Subject: [PATCH 091/323] sam: report close error --- src/cmd/sam/io.c | 2 +- src/cmd/sam/sam.h | 1 + src/cmd/sam/sys.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cmd/sam/io.c b/src/cmd/sam/io.c index 8740c7ca8..c112c0a1a 100644 --- a/src/cmd/sam/io.c +++ b/src/cmd/sam/io.c @@ -166,7 +166,7 @@ writeio(File *f) void closeio(Posn p) { - close(io); + Close(io); io = 0; if(p >= 0) dprint("#%lud\n", p); diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index c2aaa0702..c11163ef0 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -237,6 +237,7 @@ int Read(int, void*, int); void Seek(int, long, int); int plan9(File*, int, String*, int); int Write(int, void*, int); +void Close(int); int bexecute(File*, Posn); void cd(String*); void closefiles(File*, String*); diff --git a/src/cmd/sam/sys.c b/src/cmd/sam/sys.c index db54d28d6..7eed4c9e0 100644 --- a/src/cmd/sam/sys.c +++ b/src/cmd/sam/sys.c @@ -58,3 +58,10 @@ Seek(int f, long n, int w) if(seek(f, n, w)==-1) syserror("seek"); } + +void +Close(int f) +{ + if(close(f) < 0) + syserror("close"); +} From ab6f1aeac761178fb70863681eab9e681aa3f379 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 31 May 2016 11:23:30 +0200 Subject: [PATCH 092/323] cb: fix a null pointer dereference Just added a pair of parentheses. I also ran cb on cb.c to beautify the code. This is actually on Gerrit from 2016: https://plan9port-review.googlesource.com/c/plan9/+/1574 Change-Id: I5e234adba0f95c13d6eecb121bf11bba4bf54566 --- src/cmd/cb/cb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/cb/cb.c b/src/cmd/cb/cb.c index 0b2458965..9e611f042 100644 --- a/src/cmd/cb/cb.c +++ b/src/cmd/cb/cb.c @@ -29,7 +29,7 @@ main(int argc, char *argv[]) maxleng -= (maxleng + 5)/10; continue; default: - fprint(2, "cb: illegal option %c\n", *argv[1]); + fprint(2, "cb: illegal option %c\n", (*argv)[1]); exits("boom"); } } @@ -354,7 +354,7 @@ work(void){ continue; } } - else if (lbegin == 0 || p > string) + else if (lbegin == 0 || p > string) if(strict) putch(c,NO); else putch(c,YES); @@ -969,7 +969,7 @@ getnext(int must){ if(nlct++ > 2)goto done; } puttmp(c,1); - star: +star: if(puttmp((c=Bgetc(input)),1) == '/'){ beg = tp; puttmp((c=Bgetc(input)),1); From f77d12f8d8a822aae41b835c0cca050928c58221 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Thu, 8 Aug 2019 21:24:58 +0000 Subject: [PATCH 093/323] cmd/rc: fix declarations of some externally linked variables Change-Id: If8fe1afecb9fe55f85e8e5af37521b83e787d718 --- src/cmd/rc/exec.h | 2 +- src/cmd/rc/rc.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/rc/exec.h b/src/cmd/rc/exec.h index 06d2991f5..06cfd64e4 100644 --- a/src/cmd/rc/exec.h +++ b/src/cmd/rc/exec.h @@ -67,7 +67,7 @@ struct builtin{ }; extern struct builtin Builtin[]; int eflagok; /* kludge flag so that -e doesn't exit in startup */ -int havefork; +extern int havefork; void execcd(void), execwhatis(void), execeval(void), execexec(void); int execforkexec(void); diff --git a/src/cmd/rc/rc.h b/src/cmd/rc/rc.h index 7778ff4c8..46ff95106 100644 --- a/src/cmd/rc/rc.h +++ b/src/cmd/rc/rc.h @@ -71,7 +71,6 @@ union code{ char *s; }; char *promptstr; -int doprompt; #define NTOK 8192 char tok[NTOK]; #define APPEND 1 @@ -126,7 +125,7 @@ int mypid; char **argp; char **args; int nerror; /* number of errors encountered during compilation */ -int doprompt; /* is it time for a prompt? */ +extern int doprompt; /* is it time for a prompt? */ /* * Which fds are the reading/writing end of a pipe? * Unfortunately, this can vary from system to system. From d6f8c236b8c601781cef6f8521fd47dffa1758b4 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sat, 28 May 2016 15:00:06 +0200 Subject: [PATCH 094/323] acme: do not pass null pointers where disallowed The C standards disallow passing null pointers to memmove and memcmp. Change-Id: I1c88c2adbc32a23ef742f206038b8f7c4e0540c7 --- src/cmd/acme/util.c | 2 ++ src/cmd/acme/wind.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/acme/util.c b/src/cmd/acme/util.c index d694634f2..dc9780954 100644 --- a/src/cmd/acme/util.c +++ b/src/cmd/acme/util.c @@ -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 19b52f5c1..b4f1a1cbc 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -476,7 +476,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; From 8cd46ae7bc031f311c833ad32445f5cde1916f99 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sat, 28 May 2016 03:13:35 +0200 Subject: [PATCH 095/323] ls: check that pointer is not nil before calling qsort Passing a null pointer to qsort is an error in C (GCC and Clang agree with the standards there, so this is no joke). Change-Id: Ia2b015793a75ea4e85ae8f47da6beead9c4290e6 --- src/cmd/ls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ls.c b/src/cmd/ls.c index 60615059b..fca3ee958 100644 --- a/src/cmd/ls.c +++ b/src/cmd/ls.c @@ -143,7 +143,7 @@ output(void) char buf[4096]; char *s; - if(!nflag) + if(!nflag && dirbuf!=0) qsort(dirbuf, ndir, sizeof dirbuf[0], (int (*)(const void*, const void*))compar); for(i=0; i Date: Sat, 28 Dec 2019 21:33:59 +0000 Subject: [PATCH 096/323] cmd/htmlroff: fix buffer overflow in t2.c getqarg This is actually from 2016: https://plan9port-review.googlesource.com/c/plan9/+/1590 Change-Id: I6f2a3d71a9dd589eff7ab15b3c1d3997254b3c35 --- src/cmd/htmlroff/t2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/htmlroff/t2.c b/src/cmd/htmlroff/t2.c index 54481d0a5..daac3ea12 100644 --- a/src/cmd/htmlroff/t2.c +++ b/src/cmd/htmlroff/t2.c @@ -26,7 +26,7 @@ getqarg(void) Rune *p, *e; p = buf; - e = p+sizeof buf-1; + e = p + nelem(buf) - 1; if(getrune() != '\'') return nil; From f264bbcdf6da8ea784cf1342b9583d34944fef0c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 6 Jan 2020 15:26:25 -0500 Subject: [PATCH 097/323] acme(1): update man page to note -a trimming trailing spaces on Put --- man/man1/acme.1 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/man/man1/acme.1 b/man/man1/acme.1 index b3266595b..182bcc7b6 100644 --- a/man/man1/acme.1 +++ b/man/man1/acme.1 @@ -129,7 +129,7 @@ hold button 3 down near the top of the scroll bar. Moving the mouse down the scroll bar speeds up the rate of scrolling. (The experimental option .B -r -reverses the scrolling behavior of buttons 1 and 3, to behave +reverses the scrolling behavior of buttons 1 and 3, to behave more like .IR xterm (1).) .SS Layout @@ -193,10 +193,15 @@ When a window is in autoindent mode (see the .B Indent command below) and a newline character is typed, -acme copies leading white space on the current line to the new line. +.I acme +copies leading white space on the current line to the new line, +and when a window is +.BR Put , +.I acme +removes all trailing end-of-line white space before writing the file. The option .B -a -causes each window to start in +causes each window to start in autoindent mode. .SS "Directory context Each window's tag names a directory: explicitly if the window @@ -406,7 +411,7 @@ command. .B Local In the Plan 9 .IR acme , -this prefix causes a command to be run in +this prefix causes a command to be run in .IR acme 's own file name space and environment variable group. On Unix this is impossible. @@ -540,7 +545,7 @@ The environment variable .B $acmeshell determines which shell is used to execute such commands; the .IR rc (1) -shell is used by default. +shell is used by default. .SS "Mouse button 3 Pointing at text with button 3 instructs .I acme @@ -658,7 +663,7 @@ button and then typing Option without letting go of the button will cause a 1-2 chord, cutting the selection. On Mac systems, the usual keyboard shortcuts Command-C, -V, -X, and -Z invoke -copy, paste, cut, and undo, +copy, paste, cut, and undo, and Command-Shift-Z invokes redo, as in other programs. Especially on Mac laptops, these keyboard shortcuts are From 6f5bd96ed836ad26b9c4ab6ad9ecc81e28622736 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 7 Jan 2020 20:49:26 +0100 Subject: [PATCH 098/323] all: sync and dedup the creation of the SYSNAME and OBJTYPE env vars (#321) This should prevent the issues of dist/buildmk and src/mkhdr getting out of synchronization yet again. I also add a rule for arm64 to the OBJTYPE sed command. Fixes #243 Fixes #320 Change-Id: I60f69a1f32b5ed5ae5ac8a1659c38e29debed005 --- buildEnvironmentVariables | 19 +++++++++++++++++++ dist/buildmk | 19 ++----------------- src/mkhdr | 20 +------------------- 3 files changed, 22 insertions(+), 36 deletions(-) create mode 100644 buildEnvironmentVariables diff --git a/buildEnvironmentVariables b/buildEnvironmentVariables new file mode 100644 index 000000000..f6de1e350 --- /dev/null +++ b/buildEnvironmentVariables @@ -0,0 +1,19 @@ +SYSNAME=`uname` +OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' + s;.*i[3-6]86.*;386;; + s;.*i86pc.*;386;; + s;.*amd64.*;x86_64;; + s;.*x86_64.*;x86_64;; + s;.*armv.*;arm;g; + s;.*powerpc.*;power;g; + s;.*PowerMacintosh.*;power;g; + s;.*Power.Macintosh.*;power;g; + s;.*macppc.*;power;g; + s;.*mips.*;mips;g; + s;.*ppc64.*;power;g; + s;.*ppc.*;power;g; + s;.*alpha.*;alpha;g; + s;.*sun4u.*;sun4u;g; + s;.*aarch64.*;arm64; + s;.*arm64.*;arm64; +'` diff --git a/dist/buildmk b/dist/buildmk index 07b223aca..6be4ba50f 100755 --- a/dist/buildmk +++ b/dist/buildmk @@ -1,21 +1,6 @@ #!/bin/sh # run this in the src directory -SYSNAME=`uname` export SYSNAME -OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' - s;.*i[3-6]86.*;386;; - s;.*i86pc.*;386;; - s;.*amd64.*;x86_64;; - s;.*x86_64.*;x86_64;; - s;.*armv.*;arm;g; - s;.*powerpc.*;power;g; - s;.*PowerMacintosh.*;power;g; - s;.*Power.Macintosh.*;power;g; - s;.*macppc.*;power;g; - s;.*mips.*;mips;g; - s;.*ppc64.*;power;g; - s;.*ppc.*;power;g; - s;.*alpha.*;alpha;g; - s;.*sun4u.*;sun4u;g; -'` export OBJTYPE +export SYSNAME OBJTYPE +. ../buildEnvironmentVariables sh -x mkmk.sh diff --git a/src/mkhdr b/src/mkhdr index 1c3f20af2..03447df93 100644 --- a/src/mkhdr +++ b/src/mkhdr @@ -1,22 +1,4 @@ -# if you change this, also edit ../dist/buildmk -SYSNAME=`uname` -OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' - s;.*i[3-6]86.*;386;; - s;.*i86pc.*;386;; - s;.*amd64.*;x86_64;; - s;.*x86_64.*;x86_64;; - s;.*armv.*;arm;g; - s;.*powerpc.*;power;g; - s;.*PowerMacintosh.*;power;g; - s;.*Power.Macintosh.*;power;g; - s;.*macppc.*;power;g; - s;.*mips.*;mips;g; - s;.*ppc64.*;power;g; - s;.*ppc.*;power;g; - s;.*alpha.*;alpha;g; - s;.*sun4u.*;sun4u;g; - s;.*aarch64.*;arm64; -'` +<$PLAN9/buildEnvironmentVariables BIN=$PLAN9/bin LIBDIR=$PLAN9/lib From cf6b778799edf4ebc2331d12707e66e7d38331ea Mon Sep 17 00:00:00 2001 From: Leonid Bobrov Date: Tue, 7 Jan 2020 21:51:42 +0200 Subject: [PATCH 099/323] INSTALL, 9c, 9l: improve handling of *BSD (#302) --- INSTALL | 48 +++++++++++++++++++++++++----------------------- bin/9c | 5 ++--- bin/9l | 13 ------------- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/INSTALL b/INSTALL index cb0df570b..502eff417 100755 --- a/INSTALL +++ b/INSTALL @@ -29,6 +29,30 @@ case `uname` in SunOS) awk=nawk ;; +DragonFly|*BSD) + case `cc -v 2>&1` in + *clang*) + echo "CC9=clang" >> $PLAN9/config + ;; + *gcc*) + echo "CC9=gcc" >> $PLAN9/config + ;; + esac + echo "* Running on" `uname`", adjusting linker flags" + case `uname` in + OpenBSD) + echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config + ;; + NetBSD) + echo "LDFLAGS='-L/usr/X11R7/lib -pthread'" >> $PLAN9/config + ;; + *) + echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config + ;; + esac + echo "CFLAGS='-pthread'" >> $PLAN9/config + awk=awk + ;; *) awk=awk ;; @@ -42,29 +66,6 @@ echo "* Resetting $PLAN9/config" rm -f config ( -if [ `uname` = FreeBSD ]; then - case `cc -v 2>&1` in - *clang*) - echo "CC9=clang" >> $PLAN9/config - ;; - *) - ;; - esac - echo "* Running on FreeBSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/local/lib'" >> $PLAN9/config -fi - -if [ `uname` = DragonFly ]; then - echo "* Running on DragonFly BSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/local/lib -pthread'" >> $PLAN9/config - echo "CFLAGS='-pthread'" >> $PLAN9/config -fi - -if [ `uname` = OpenBSD ]; then - echo "* Running on OpenBSD, adjusting linker flags" - echo "LDFLAGS='-L/usr/X11R6/lib -pthread'" >> $PLAN9/config -fi - if [ `uname` = Linux ]; then # On Linux, we use the kernel version to decide whether # to use pthreads or not. On 2.6 versions that aren't @@ -135,6 +136,7 @@ if [ `uname` != Darwin ]; then # Determine whether fontsrv X11 files are available. rm -f a.out cc -o a.out -c -Iinclude -I/usr/include -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 \ + -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 \ -I/usr/X11R6/include -I/usr/X11R6/include/freetype2 src/cmd/fontsrv/x11.c >/dev/null 2>&1 if [ -f a.out ]; then echo " fontsrv dependencies found." diff --git a/bin/9c b/bin/9c index 88c47887d..7e6e3ab81 100755 --- a/bin/9c +++ b/bin/9c @@ -79,9 +79,8 @@ useclang() tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" case "$tag" in -*FreeBSD*gcc*) usegcc ;; -*FreeBSD*clang*) useclang ;; -*DragonFly*|*BSD*) usegcc ;; +*(DragonFly|BSD)*gcc*) usegcc ;; +*(DragonFly|BSD)*clang*) useclang ;; *Darwin-x86_64*) useclang cflags="$ngflags -g3 -m64" diff --git a/bin/9l b/bin/9l index 032d38010..8af271543 100755 --- a/bin/9l +++ b/bin/9l @@ -11,19 +11,6 @@ nmflags="" extralibs="-lm" tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}" case "$tag" in -*FreeBSD*) - ld=${CC9:-gcc} - userpath=true - extralibs="$extralibs -lutil" - case "`uname -r`" in - 5.2.*) - extralibs="$extralibs -lkse" - ;; - [5-9].*|1[0-9].*) - extralibs="$extralibs -lpthread" - ;; - esac - ;; *DragonFly*|*BSD*) ld=${CC9:-gcc} userpath=true From a4e59b37021326e304c311825ba52a52b02bd9c0 Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Tue, 7 Jan 2020 15:02:01 -0500 Subject: [PATCH 100/323] 9term: add a "look" menu item (#299) Add a menu item which functions similar to acme's `Look` command. This is copied from 9front. See: https://code.9front.org/hg/plan9front/rev/1f1596dbca51 https://code.9front.org/hg/plan9front/rev/d2de1d2f7b48 --- man/man1/9term.1 | 7 +++++++ src/cmd/9term/9term.c | 6 ++++++ src/cmd/9term/dat.h | 1 + src/cmd/9term/wind.c | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+) diff --git a/man/man1/9term.1 b/man/man1/9term.1 index e0e5aad71..b07061398 100644 --- a/man/man1/9term.1 +++ b/man/man1/9term.1 @@ -285,6 +285,13 @@ containing the selection (typing cursor). A typical use of this feature is to tell the editor to find the source of an error by plumbing the file and line information in a compiler's diagnostic. .PP +The +.B look +menu item searches forward for the contents of the selection within +the window. If a match is found, it becomes the new selection and the +window scrolls to display it. The search wraps around to the beginning +of the windows if the end of the window is reached. +.PP For systems without a three-button mouse, the keyboard modifier keys can be used to modify the effect of the main mouse button. On Unix systems, the Control key changes the main button to button 2, diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index 107afed3f..81c39a635 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -288,6 +288,7 @@ enum Paste, Snarf, Plumb, + Look, Send, Scroll, Cook @@ -298,6 +299,7 @@ char *menu2str[] = { "paste", "snarf", "plumb", + "look", "send", "cook", "scroll", @@ -348,6 +350,10 @@ button2menu(Window *w) wplumb(w); break; + case Look: + wlook(w); + break; + case Send: riogetsnarf(); wsnarf(w); diff --git a/src/cmd/9term/dat.h b/src/cmd/9term/dat.h index c1af6592a..25270a0e3 100644 --- a/src/cmd/9term/dat.h +++ b/src/cmd/9term/dat.h @@ -177,6 +177,7 @@ void wmousectl(Window*); void wmovemouse(Window*, Point); void wpaste(Window*); void wplumb(Window*); +void wlook(Window*); void wrefresh(Window*, Rectangle); void wrepaint(Window*); void wresize(Window*, Image*, int); diff --git a/src/cmd/9term/wind.c b/src/cmd/9term/wind.c index 7dc204435..d47e84674 100644 --- a/src/cmd/9term/wind.c +++ b/src/cmd/9term/wind.c @@ -906,6 +906,31 @@ winborder(Window *w, Point xy) return ptinrect(xy, w->screenr) && !ptinrect(xy, insetrect(w->screenr, wscale(w, Selborder))); } +void +wlook(Window *w) +{ + int i, n, e; + + i = w->q1; + n = i - w->q0; + e = w->nr - n; + if(n <= 0 || e < n) + return; + + if(i > e) + i = 0; + + while(runestrncmp(w->r+w->q0, w->r+i, n) != 0){ + if(i < e) + i++; + else + i = 0; + } + + wsetselect(w, i, i+n); + wshow(w, i); +} + void wmousectl(Window *w) { From 2c97de1a26686adf2a6377bc4ef18d1aec6a1f3a Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 11 Aug 2019 00:54:13 +0000 Subject: [PATCH 101/323] libmach: plug memory leak Change-Id: I08cb7227c071c7fc2e30f43e07bcf599fc1d174a --- src/libmach/elf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libmach/elf.c b/src/libmach/elf.c index 2459a2917..5b7494d98 100644 --- a/src/libmach/elf.c +++ b/src/libmach/elf.c @@ -191,7 +191,7 @@ elfinit(int fd) ElfHdrBytes h32; ElfHdrBytes64 h64; } hdrb; - void *p; + void *p = nil; ElfSect *s; e = mallocz(sizeof(Elf), 1); @@ -234,6 +234,7 @@ elfinit(int fd) unpackprog(h, &e->prog[i], p); } free(p); + p = nil; e->nsect = h->shnum; if(e->nsect == 0) @@ -247,6 +248,7 @@ elfinit(int fd) unpacksect(h, &e->sect[i], p); } free(p); + p = nil; if(h->shstrndx >= e->nsect){ fprint(2, "warning: bad string section index %d >= %d", h->shstrndx, e->nsect); @@ -287,6 +289,7 @@ elfinit(int fd) return e; err: + free(p); free(e->sect); free(e->prog); free(e->shstrtab); From 2897735523dd05a4ef21d25d3d99fa7fa0b24b44 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 11 Aug 2019 02:11:02 +0000 Subject: [PATCH 102/323] libmach: plug another memory leak Change-Id: Ia5c888db1f0ded2aa92238d994239e46bf52667a --- src/libmach/crack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libmach/crack.c b/src/libmach/crack.c index 6d1674049..5695b7eb8 100644 --- a/src/libmach/crack.c +++ b/src/libmach/crack.c @@ -69,6 +69,7 @@ crackhdr(char *name, int mode) return hdr; } werrstr("unknown file type: %r"); + free(hdr->filename); free(hdr); close(fd); return nil; @@ -89,6 +90,7 @@ uncrackhdr(Fhdr *hdr) for(i=0; inthread; i++) free(hdr->thread[i].ureg); free(hdr->thread); + free(hdr->filename); free(hdr); } From 540caa5873bcc3bc2a0e1896119f5b53a0e8e630 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 7 Jan 2020 15:31:01 -0500 Subject: [PATCH 103/323] lib9: remove getcallerpc implementations These make no sense and are not really needed at all. Add a best-effort attempt to get at the gcc/clang macro in lib9.h, but if it fails, no big deal. Fixes #324. --- include/libc.h | 25 ++++++++++++++----------- src/lib9/getcallerpc-386.c | 7 ------- src/lib9/getcallerpc-arm.c | 8 -------- src/lib9/getcallerpc-arm64.c | 8 -------- src/lib9/getcallerpc-mips.c | 8 -------- src/lib9/getcallerpc-power.c | 11 ----------- src/lib9/getcallerpc-sun4u.s | 5 ----- src/lib9/getcallerpc-x86_64.c | 7 ------- src/lib9/mkfile | 2 +- 9 files changed, 15 insertions(+), 66 deletions(-) delete mode 100644 src/lib9/getcallerpc-386.c delete mode 100644 src/lib9/getcallerpc-arm.c delete mode 100644 src/lib9/getcallerpc-arm64.c delete mode 100644 src/lib9/getcallerpc-mips.c delete mode 100644 src/lib9/getcallerpc-power.c delete mode 100644 src/lib9/getcallerpc-sun4u.s delete mode 100644 src/lib9/getcallerpc-x86_64.c diff --git a/include/libc.h b/include/libc.h index 45b22b691..94d5b5ca5 100644 --- a/include/libc.h +++ b/include/libc.h @@ -11,13 +11,13 @@ #define _LIBC_H_ 1 #if defined(__cplusplus) extern "C" { -#endif +#endif #include #include /* - * Begin usual libc.h + * Begin usual libc.h */ #ifndef nil @@ -361,7 +361,7 @@ enum extern int p9atexit(void(*)(void)); extern void p9atexitdont(void(*)(void)); extern int atnotify(int(*)(void*, char*), int); -/* +/* * extern double atof(char*); */ @@ -385,6 +385,9 @@ extern int exitcode(char*); extern void exits(char*); extern double frexp(double, int*); extern ulong getcallerpc(void*); +#if defined(__GNUC__) || defined(__clang__) +#define getcallerpc(x) ((ulong)__builtin_return_address(0)) +#endif extern char* p9getenv(char*); extern int p9putenv(char*, char*); extern int getfields(char*, char**, int, int, char*); @@ -479,7 +482,7 @@ extern void lock(Lock*); extern void unlock(Lock*); extern int canlock(Lock*); extern int (*_lock)(Lock*, int, ulong); -extern void (*_unlock)(Lock*, ulong); +extern void (*_unlock)(Lock*, ulong); typedef struct QLock QLock; struct QLock @@ -670,15 +673,15 @@ extern void freenetconninfo(NetConnInfo*); enum { - RFNAMEG = (1<<0), - RFENVG = (1<<1), + RFNAMEG = (1<<0), + RFENVG = (1<<1), RFFDG = (1<<2), RFNOTEG = (1<<3), RFPROC = (1<<4), RFMEM = (1<<5), RFNOWAIT = (1<<6), - RFCNAMEG = (1<<10), - RFCENVG = (1<<11), + RFCNAMEG = (1<<10), + RFCENVG = (1<<11), RFCFDG = (1<<12) /* RFREND = (1<<13), */ /* RFNOMNT = (1<<14) */ @@ -707,7 +710,7 @@ struct Dir { char *uid; /* owner name */ char *gid; /* group name */ char *muid; /* last modifier name */ - + /* 9P2000.u extensions */ uint uidnum; /* numeric uid */ uint gidnum; /* numeric gid */ @@ -750,7 +753,7 @@ extern int p9exec(char*, char*[]); extern int p9execl(char*, ...); /* extern int p9fork(void); */ extern int p9rfork(int); -/* not implemented +/* not implemented extern int fauth(int, char*); extern int fstat(int, uchar*, int); extern int fwstat(int, uchar*, int); @@ -767,7 +770,7 @@ extern int notifyoff(char*); extern int p9open(char*, int); extern int fd2path(int, char*, int); extern int p9pipe(int*); -/* +/* * use defs from extern long pread(int, void*, long, vlong); extern long preadv(int, IOchunk*, int, vlong); diff --git a/src/lib9/getcallerpc-386.c b/src/lib9/getcallerpc-386.c deleted file mode 100644 index 1367370e9..000000000 --- a/src/lib9/getcallerpc-386.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - return (((ulong*)(x))[-1]); -} diff --git a/src/lib9/getcallerpc-arm.c b/src/lib9/getcallerpc-arm.c deleted file mode 100644 index 9bb4a9559..000000000 --- a/src/lib9/getcallerpc-arm.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - return ((ulong*)x)[-2]; -} - diff --git a/src/lib9/getcallerpc-arm64.c b/src/lib9/getcallerpc-arm64.c deleted file mode 100644 index 9bb4a9559..000000000 --- a/src/lib9/getcallerpc-arm64.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - return ((ulong*)x)[-2]; -} - diff --git a/src/lib9/getcallerpc-mips.c b/src/lib9/getcallerpc-mips.c deleted file mode 100644 index 9bb4a9559..000000000 --- a/src/lib9/getcallerpc-mips.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - return ((ulong*)x)[-2]; -} - diff --git a/src/lib9/getcallerpc-power.c b/src/lib9/getcallerpc-power.c deleted file mode 100644 index b4bf6980f..000000000 --- a/src/lib9/getcallerpc-power.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - ulong *lp; - - lp = x; - - return lp[-1]; -} diff --git a/src/lib9/getcallerpc-sun4u.s b/src/lib9/getcallerpc-sun4u.s deleted file mode 100644 index f28e57f18..000000000 --- a/src/lib9/getcallerpc-sun4u.s +++ /dev/null @@ -1,5 +0,0 @@ -.text -.globl getcallerpc -getcallerpc: - retl - or %o7, %r0, %o0 diff --git a/src/lib9/getcallerpc-x86_64.c b/src/lib9/getcallerpc-x86_64.c deleted file mode 100644 index 1367370e9..000000000 --- a/src/lib9/getcallerpc-x86_64.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -ulong -getcallerpc(void *x) -{ - return (((ulong*)(x))[-1]); -} diff --git a/src/lib9/mkfile b/src/lib9/mkfile index 8f7283ef8..943b597b9 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -104,7 +104,7 @@ LIB9OFILES=\ fcallfmt.$O\ frand.$O\ get9root.$O\ - getcallerpc-$OBJTYPE.$O\ + getcallerpc.$O\ getenv.$O\ getfields.$O\ getnetconn.$O\ From e6ed10f25e4b2ea791d8e52253f7d806316420e9 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Mon, 6 Jan 2020 22:57:05 +0000 Subject: [PATCH 104/323] lib9, libndb: exclude terminating null from strncpy bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM equals destination size [-Wstringop-truncation]" warnings. Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32 --- src/lib9/ctime.c | 2 +- src/libndb/sysdnsquery.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c index a9ce7b7a7..9fcd62008 100644 --- a/src/lib9/ctime.c +++ b/src/lib9/ctime.c @@ -58,7 +58,7 @@ localtime(long tim) if (zonelookuptinfo(&ti, tim)!=-1) { ct = gmtime(tim+ti.tzoff); - strncpy(ct->zone, ti.zone, sizeof ct->zone); + strncpy(ct->zone, ti.zone, sizeof ct->zone - 1); ct->zone[sizeof ct->zone-1] = 0; ct->tzoff = ti.tzoff; return ct; diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c index b9661be1c..0a771e2b9 100644 --- a/src/libndb/sysdnsquery.c +++ b/src/libndb/sysdnsquery.c @@ -84,7 +84,7 @@ mkptrname(char *ip, char *rip, int rlen) static void nstrcpy(char *to, char *from, int len) { - strncpy(to, from, len); + strncpy(to, from, len-1); to[len-1] = 0; } From 194178b5788a09379e01e8ff8bff391b8a8d5c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BChl?= Date: Tue, 7 Jan 2020 23:27:39 +0100 Subject: [PATCH 105/323] 9c: Fix case patterns for DragonFly and other BSDs POSIX does not support grouping in case item patterns. Installing with a strict POSIX shell fails with: /usr/local/plan9/bin/9c: line 82: syntax error near unexpected token `(' /usr/local/plan9/bin/9c: line 82: `*(DragonFly|BSD)*gcc*) usegcc ;;' This change expands the patterns to work around the limitation. See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10 (and search for case_clause) --- bin/9c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/9c b/bin/9c index 7e6e3ab81..f21ea7544 100755 --- a/bin/9c +++ b/bin/9c @@ -79,8 +79,8 @@ useclang() tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" case "$tag" in -*(DragonFly|BSD)*gcc*) usegcc ;; -*(DragonFly|BSD)*clang*) useclang ;; +*DragonFly*gcc*|*BSD*gcc*) usegcc ;; +*DragonFly*clang|*BSD*clang*) useclang ;; *Darwin-x86_64*) useclang cflags="$ngflags -g3 -m64" From c65d179354fd3fd6f9719531f3414cf1c9c5280a Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 31 Dec 2019 21:32:42 +0000 Subject: [PATCH 106/323] mk: fix out of bounds access A loop is added for each structure field instead of accessing the other fields through the first one in one loop. Updates #313 Change-Id: I0e27e15feacb77391bc1decee7cf720d64d14586 --- src/cmd/mk/archive.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c index 01288908f..6869bacf8 100644 --- a/src/cmd/mk/archive.c +++ b/src/cmd/mk/archive.c @@ -1,6 +1,6 @@ #include "mk.h" #define ARMAG "!\n" -#define SARMAG 8 +#define SARMAG (sizeof(ARMAG) - sizeof("")) #define ARFMAG "`\n" #define SARNAME 16 @@ -102,7 +102,7 @@ atouch(char *name) LSEEK(fd, SARMAG, 0); while(read(fd, (char *)&h, sizeof(h)) == sizeof(h)){ for(i = SARNAME-1; i > 0 && h.name[i] == ' '; i--) - ; + ; h.name[i+1]=0; if(strcmp(member, h.name) == 0){ t = SARNAME-sizeof(h); /* ughgghh */ @@ -118,6 +118,18 @@ atouch(char *name) close(fd); } +static int +allspaces(char *a, int n) +{ + int i; + for (i = 0; i < n; i++) { + if (a[i] != ' ') { + return 0; + } + } + return 1; +} + static void atimes(char *ar) { @@ -151,11 +163,13 @@ atimes(char *ar) if(readn(fd, name, namelen) != namelen) break; name[namelen] = 0; - }else if(memcmp(h.name, "// ", 2) == 0){ /* GNU */ + }else if(memcmp(h.name, "// ", 3) == 0){ /* GNU */ /* date, uid, gid, mode all ' ' */ - for(i=2; i<16+12+6+6+8; i++) - if(h.name[i] != ' ') - goto skip; + if(!allspaces(&h.name[3], sizeof(h.name) - 3) || + !allspaces(h.date, sizeof(h.date)) || !allspaces(h.uid, sizeof(h.uid)) || + !allspaces(h.gid, sizeof(h.gid)) || !allspaces(h.mode, sizeof(h.mode))){ + goto skip; + } t = atol(h.size); if(t&01) t++; @@ -189,7 +203,7 @@ atimes(char *ar) }else{ strncpy(name, h.name, sizeof(h.name)); for(i = sizeof(h.name)-1; i > 0 && name[i] == ' '; i--) - ; + ; if(name[i] == '/') /* system V bug */ i--; name[i+1]=0; From 2738cc3cfc053a5922aee655405c0ab620beae0f Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Wed, 8 Jan 2020 01:36:49 +0000 Subject: [PATCH 107/323] mk: plan9 style. In general, no space after `if` etc, and no braces for a single statement inside of a loop or conditional. Signed-off-by: Dan Cross --- src/cmd/mk/archive.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c index 6869bacf8..026641bdd 100644 --- a/src/cmd/mk/archive.c +++ b/src/cmd/mk/archive.c @@ -122,11 +122,11 @@ static int allspaces(char *a, int n) { int i; - for (i = 0; i < n; i++) { - if (a[i] != ' ') { + + for(i=0; i Date: Sun, 18 Aug 2019 13:46:43 +0000 Subject: [PATCH 108/323] libhtml: plug quite a few memory leaks Change-Id: I45bd62a590373669e90183cc2b2ee56570c007f5 --- src/libhtml/build.c | 3 +++ src/libhtml/lex.c | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libhtml/build.c b/src/libhtml/build.c index 7ce744497..06397086b 100644 --- a/src/libhtml/build.c +++ b/src/libhtml/build.c @@ -2127,6 +2127,7 @@ getitems(ItemSource* is, uchar* data, int datalen) outerps = lastps(ps); ans = outerps->items->next; /* note: ans may be nil and di->kids not nil, if there's a frameset! */ + freeitem(outerps->items); outerps->items = newispacer(ISPnull); outerps->lastit = outerps->items; is->psstk = ps; @@ -2134,6 +2135,7 @@ getitems(ItemSource* is, uchar* data, int datalen) /* TODO evalscript(nil); */ ; } + freeitems(outerps->items); return_ans: if(dbgbuild) { @@ -2143,6 +2145,7 @@ getitems(ItemSource* is, uchar* data, int datalen) else printitems(ans, "getitems returning:"); } + _freetokens(toks, tokslen); return ans; } diff --git a/src/libhtml/lex.c b/src/libhtml/lex.c index 12127b584..258807dd0 100644 --- a/src/libhtml/lex.c +++ b/src/libhtml/lex.c @@ -540,8 +540,11 @@ _gettoks(uchar* data, int datalen, int chset, int mtype, int* plen) if(dbglex) fprint(2, "lex: returning %d tokens\n", ai); *plen = ai; - if(ai == 0) + free(ts); + if(ai == 0) { + free(a); return nil; + } return a; } @@ -603,15 +606,18 @@ getplaindata(TokenSource* ts, Token* a, int* pai) } /* Return concatenation of s and buf[0:j] */ +/* Frees s. */ static Rune* buftostr(Rune* s, Rune* buf, int j) { + Rune *tmp; buf[j] = 0; if(s == nil) - s = _Strndup(buf, j); + tmp = _Strndup(buf, j); else - s = _Strdup2(s, buf); - return s; + tmp = _Strdup2(s, buf); + free(s); + return tmp; } /* Gather data up to next start-of-tag or end-of-buffer. */ From a18741729cc1460088d1ddaa365dfa6455a459ec Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 18 Aug 2019 20:10:09 +0000 Subject: [PATCH 109/323] libhtml: plug a memory leak in addtext Change-Id: I9b8a4430e7d26008ba9508095f8eb4b124a93b9b --- src/libhtml/build.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libhtml/build.c b/src/libhtml/build.c index 06397086b..78b6efff4 100644 --- a/src/libhtml/build.c +++ b/src/libhtml/build.c @@ -2445,6 +2445,9 @@ addtext(Pstate* ps, Rune* s) free(s); } } + else { + free(s); + } } else { /* not literal mode */ if((ps->curstate&IFbrk) || ps->lastit == ps->items) From 323e1a8fac276f008e6d5146a83cbc88edeabc87 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 22:27:29 -0500 Subject: [PATCH 110/323] lib9: add getcallerpc.c (fixes build) --- src/lib9/getcallerpc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib9/getcallerpc.c diff --git a/src/lib9/getcallerpc.c b/src/lib9/getcallerpc.c new file mode 100644 index 000000000..3067f053c --- /dev/null +++ b/src/lib9/getcallerpc.c @@ -0,0 +1,13 @@ +#include +#include + +/* + * On gcc and clang, getcallerpc is a macro invoking a compiler builtin. + * If the macro in libc.h did not trigger, there's no implementation. + */ +#undef getcallerpc +ulong +getcallerpc(void *v) +{ + return 1; +} From 5aad8f3d6d24ee109ea23514862fa579191cb5e4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 9 Jan 2020 19:57:56 -0500 Subject: [PATCH 111/323] mkfile, mkmk.sh: update for new asm-free getcallerpc --- src/mkfile | 1 - src/mkmk.sh | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mkfile b/src/mkfile index 8c1f74548..8ddaee207 100644 --- a/src/mkfile +++ b/src/mkfile @@ -38,7 +38,6 @@ mkmk.sh:VD: s/'$SYSNAME'/$SYSNAME/g s/'$OBJTYPE'/$OBJTYPE/g s;'$PLAN9';$PLAN9;g - s/9[ac] *getcallerpc-.*/9c getcallerpc-$OBJTYPE.c || 9a getcallerpc-$OBJTYPE.s/ s/^9[ac] *tas-.*/9a tas-$OBJTYPE.s || 9c tas-$OBJTYPE.c/ ' >$target diff --git a/src/mkmk.sh b/src/mkmk.sh index c17671000..dae87ddfb 100644 --- a/src/mkmk.sh +++ b/src/mkmk.sh @@ -37,8 +37,9 @@ echo cd `pwd` 9c execl.c 9c exitcode.c 9c fcallfmt.c +9c frand.c 9c get9root.c -9c getcallerpc-$OBJTYPE.c || 9a getcallerpc-$OBJTYPE.s +9c getcallerpc.c 9c getenv.c 9c getfields.c 9c getnetconn.c @@ -149,7 +150,7 @@ echo cd `pwd` 9c utf/utfrrune.c 9c utf/utfrune.c 9c utf/utfutf.c -9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o get9root.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o +9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o frand.o get9root.o getcallerpc.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o cd .. cd libbio echo cd `pwd` From 77a0a5b5194d4441c86de097f2aae297cb75e2c2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 9 Jan 2020 20:08:10 -0500 Subject: [PATCH 112/323] src: mv ../buildEnvironmentVariables mkhdr Also note that the file must be valid shell and mk input. For #321. --- dist/buildmk | 2 +- buildEnvironmentVariables => src/mkenv | 3 +++ src/mkhdr | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) rename buildEnvironmentVariables => src/mkenv (82%) diff --git a/dist/buildmk b/dist/buildmk index 6be4ba50f..c559570cd 100755 --- a/dist/buildmk +++ b/dist/buildmk @@ -1,6 +1,6 @@ #!/bin/sh # run this in the src directory +. ../src/mkenv export SYSNAME OBJTYPE -. ../buildEnvironmentVariables sh -x mkmk.sh diff --git a/buildEnvironmentVariables b/src/mkenv similarity index 82% rename from buildEnvironmentVariables rename to src/mkenv index f6de1e350..6ff746e08 100644 --- a/buildEnvironmentVariables +++ b/src/mkenv @@ -1,3 +1,6 @@ +# This file must be valid mk input for mkhdr +# and also valid shell input for ../dist/buildmk + SYSNAME=`uname` OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' s;.*i[3-6]86.*;386;; diff --git a/src/mkhdr b/src/mkhdr index 03447df93..24889cded 100644 --- a/src/mkhdr +++ b/src/mkhdr @@ -1,4 +1,4 @@ -<$PLAN9/buildEnvironmentVariables +<$PLAN9/src/mkenv BIN=$PLAN9/bin LIBDIR=$PLAN9/lib From fa325e9b42b0bdfb48857d1958d9fb7ceac55151 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Fri, 10 Jan 2020 14:44:21 +0000 Subject: [PATCH 113/323] Trivial changes: whitespace and modes. Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross --- src/cmd/9660/boot.c | 8 +- src/cmd/9660/cdrdwr.c | 7 +- src/cmd/9660/direc.c | 7 +- src/cmd/9660/dump.c | 6 +- src/cmd/9660/dump9660.c | 27 +- src/cmd/9660/ichar.c | 6 +- src/cmd/9660/iso9660.h | 6 +- src/cmd/9660/jchar.c | 9 +- src/cmd/9660/path.c | 2 +- src/cmd/9660/rune.c | 1 - src/cmd/9660/sysuse.c | 35 +- src/cmd/9660/util.c | 2 +- src/cmd/9660/write.c | 4 +- src/cmd/9660srv/iobuf.c | 2 +- src/cmd/9660srv/main.c | 4 +- src/cmd/9660srv/xfile.c | 1 - src/cmd/9p.c | 41 +- src/cmd/9pfuse/errstr.c | 3 +- src/cmd/9pfuse/fuse.c | 44 +- src/cmd/9pfuse/main.c | 74 +- src/cmd/9pserve.c | 24 +- src/cmd/9term/9term.c | 37 +- src/cmd/9term/SunOS.c | 1 - src/cmd/9term/bsdpty.c | 3 +- src/cmd/9term/dat.h | 4 +- src/cmd/9term/data.c | 120 +- src/cmd/9term/fns.h | 1 - src/cmd/9term/malloc.c | 7 +- src/cmd/9term/rcstart.c | 8 +- src/cmd/9term/util.c | 1 - src/cmd/9term/win.c | 24 +- src/cmd/9term/wind.c | 14 +- src/cmd/acid/builtin.c | 16 +- src/cmd/acid/dot.c | 12 +- src/cmd/acid/expr.c | 12 +- src/cmd/acid/lex.c | 6 +- src/cmd/acid/list.c | 2 +- src/cmd/acid/main.c | 4 +- src/cmd/acid/proc.c | 3 +- src/cmd/acid/util.c | 10 +- src/cmd/acidtypes/dat.h | 3 +- src/cmd/acidtypes/dwarf.c | 1 - src/cmd/acidtypes/main.c | 3 +- src/cmd/acidtypes/stabs.c | 16 +- src/cmd/acidtypes/type.c | 16 +- src/cmd/acidtypes/util.c | 2 +- src/cmd/acme/acme.c | 129 +- src/cmd/acme/cols.c | 12 +- src/cmd/acme/ecmd.c | 8 +- src/cmd/acme/edit.c | 4 +- src/cmd/acme/elog.c | 4 +- src/cmd/acme/fsys.c | 2 +- src/cmd/acme/logf.c | 16 +- src/cmd/acme/mail/dat.h | 1 - src/cmd/acme/mail/html.c | 2 +- src/cmd/acme/mail/mail.c | 15 +- src/cmd/acme/mail/mesg.c | 16 +- src/cmd/acme/mail/reply.c | 8 +- src/cmd/acme/mail/util.c | 1 - src/cmd/acme/mail/win.c | 2 +- src/cmd/acme/text.c | 22 +- src/cmd/acme/util.c | 4 +- src/cmd/acme/wind.c | 16 +- src/cmd/astro/cosadd.c | 2 +- src/cmd/auth/dsa2pub.c | 2 +- src/cmd/auth/dsa2ssh.c | 2 +- src/cmd/auth/dsagen.c | 2 +- src/cmd/auth/dsasign.c | 16 +- src/cmd/auth/factotum/apop.c | 7 +- src/cmd/auth/factotum/attr.c | 4 +- src/cmd/auth/factotum/chap.c | 10 +- src/cmd/auth/factotum/conv.c | 1 - src/cmd/auth/factotum/cpu.c | 8 +- src/cmd/auth/factotum/dat.h | 2 +- src/cmd/auth/factotum/dsa.c | 23 +- src/cmd/auth/factotum/fs.c | 9 +- src/cmd/auth/factotum/httpdigest.c | 10 +- src/cmd/auth/factotum/key.c | 4 +- src/cmd/auth/factotum/log.c | 1 - src/cmd/auth/factotum/main.c | 2 +- src/cmd/auth/factotum/p9any.c | 9 +- src/cmd/auth/factotum/p9cr.c | 6 +- src/cmd/auth/factotum/p9sk1.c | 7 +- src/cmd/auth/factotum/pass.c | 4 +- src/cmd/auth/factotum/pkcs1.c | 15 +- src/cmd/auth/factotum/rpc.c | 5 +- src/cmd/auth/factotum/rsa.c | 40 +- src/cmd/auth/factotum/secstore.c | 1 - src/cmd/auth/factotum/std.h | 1 - src/cmd/auth/factotum/util.c | 2 - src/cmd/auth/factotum/wep.c | 6 +- src/cmd/auth/factotum/xio.c | 3 +- src/cmd/auth/passwd.c | 2 +- src/cmd/auth/respond.c | 2 - src/cmd/auth/rsa2any.c | 12 +- src/cmd/auth/rsa2pub.c | 2 +- src/cmd/auth/rsa2ssh.c | 4 +- src/cmd/auth/rsafill.c | 2 +- src/cmd/auth/rsagen.c | 2 +- src/cmd/auth/secstore/SConn.c | 1 - src/cmd/auth/secstore/SConn.h | 1 - src/cmd/auth/secstore/dirls.c | 1 - src/cmd/auth/secstore/pak.c | 1 - src/cmd/auth/secstore/password.c | 1 - src/cmd/auth/secstore/secstore.c | 5 +- src/cmd/auth/secstore/secstore.h | 1 - src/cmd/auth/secstore/secstored.c | 3 +- src/cmd/auth/secstore/secureidcheck.c | 2 +- src/cmd/auth/secstore/secuser.c | 1 - src/cmd/auth/ssh-agent.c | 69 +- src/cmd/auxstats/Darwin.c | 46 +- src/cmd/auxstats/DragonFly.c | 3 +- src/cmd/auxstats/FreeBSD.c | 5 +- src/cmd/auxstats/Linux.c | 6 +- src/cmd/auxstats/NetBSD.c | 3 +- src/cmd/auxstats/SunOS.c | 3 +- src/cmd/auxstats/main.c | 1 - src/cmd/awk/awk.h | 3 +- src/cmd/awk/lex.c | 27 +- src/cmd/awk/lib.c | 3 +- src/cmd/awk/main.c | 1 - src/cmd/awk/maketab.c | 1 - src/cmd/awk/parse.c | 1 - src/cmd/awk/proto.h | 1 - src/cmd/awk/re.c | 3 +- src/cmd/awk/run.c | 3 +- src/cmd/awk/tran.c | 9 +- src/cmd/bzip2/bunzip2.c | 2 +- src/cmd/bzip2/bzip2.c | 2 +- src/cmd/bzip2/bzip2recover.c | 20 +- src/cmd/bzip2/lib/blocksort.c | 138 +- src/cmd/bzip2/lib/buffcompress.c | 29 +- src/cmd/bzip2/lib/buffdecompress.c | 26 +- src/cmd/bzip2/lib/bzassert.c | 12 +- src/cmd/bzip2/lib/bzbuffcompress.c | 29 +- src/cmd/bzip2/lib/bzcompress.c | 37 +- src/cmd/bzip2/lib/bzdecompress.c | 99 +- src/cmd/bzip2/lib/bzfeof.c | 11 +- src/cmd/bzip2/lib/bzlib.c | 10 +- src/cmd/bzip2/lib/bzlib.h | 70 +- src/cmd/bzip2/lib/bzlib_private.h | 30 +- src/cmd/bzip2/lib/bzlib_stdio.h | 113 +- src/cmd/bzip2/lib/bzlib_stdio_private.h | 3 +- src/cmd/bzip2/lib/bzread.c | 48 +- src/cmd/bzip2/lib/bzstdio.c | 11 +- src/cmd/bzip2/lib/bzversion.c | 11 +- src/cmd/bzip2/lib/bzwrite.c | 43 +- src/cmd/bzip2/lib/bzzlib.c | 18 +- src/cmd/bzip2/lib/compress.c | 92 +- src/cmd/bzip2/lib/crctable.c | 10 +- src/cmd/bzip2/lib/decompress.c | 56 +- src/cmd/bzip2/lib/huffman.c | 18 +- src/cmd/bzip2/lib/os.h | 3 +- src/cmd/bzip2/lib/randtable.c | 114 +- src/cmd/bzip2/lib/unix.h | 1 - src/cmd/calendar.c | 6 +- src/cmd/cat.c | 1 - src/cmd/cb/cb.c | 2 +- src/cmd/cmp.c | 2 +- src/cmd/date.c | 2 +- src/cmd/db/command.c | 32 +- src/cmd/db/expr.c | 8 +- src/cmd/db/input.c | 2 +- src/cmd/db/output.c | 2 +- src/cmd/db/pcs.c | 12 +- src/cmd/db/setup.c | 8 +- src/cmd/deroff.c | 48 +- src/cmd/devdraw/bigarrow.h | 124 +- src/cmd/devdraw/cocoa-srv.c | 24 +- src/cmd/devdraw/devdraw.c | 16 +- src/cmd/devdraw/drawclient.c | 9 +- src/cmd/devdraw/latin1.c | 2 +- src/cmd/devdraw/mklatinkbd.c | 6 +- src/cmd/devdraw/mouseswap.c | 2 +- src/cmd/devdraw/nowsys.c | 4 +- src/cmd/devdraw/osx-draw.c | 1 - src/cmd/devdraw/snarf.c | 3 +- src/cmd/devdraw/x11-alloc.c | 1 - src/cmd/devdraw/x11-cload.c | 1 - src/cmd/devdraw/x11-draw.c | 1 - src/cmd/devdraw/x11-fill.c | 4 +- src/cmd/devdraw/x11-get.c | 7 +- src/cmd/devdraw/x11-init.c | 14 +- src/cmd/devdraw/x11-itrans.c | 18 +- src/cmd/devdraw/x11-keysym2ucs.c | 2 +- src/cmd/devdraw/x11-load.c | 1 - src/cmd/devdraw/x11-pixelbits.c | 2 - src/cmd/devdraw/x11-srv.c | 35 +- src/cmd/devdraw/x11-unload.c | 1 - src/cmd/devdraw/x11-wsys.c | 1 - src/cmd/dict/dict.c | 6 +- src/cmd/dict/oed.c | 10 +- src/cmd/dict/pcollinsg.c | 4 +- src/cmd/dict/pgw.c | 10 +- src/cmd/dict/roget.c | 6 +- src/cmd/dict/world.c | 2 +- src/cmd/diff/diffio.c | 4 +- src/cmd/diff/diffreg.c | 18 +- src/cmd/diff/main.c | 8 +- src/cmd/disk/mkext.c | 2 +- src/cmd/disk/mkfs.c | 4 +- src/cmd/draw/cmapcube.c | 2 +- src/cmd/draw/crop.c | 2 +- src/cmd/draw/gview.c | 4 +- src/cmd/draw/mc.c | 1 - src/cmd/draw/stats.c | 7 +- src/cmd/draw/statusbar.c | 13 +- src/cmd/draw/tcolors.c | 1 - src/cmd/draw/tweak.c | 28 +- src/cmd/echo.c | 2 +- src/cmd/ed.c | 8 +- src/cmd/eqn/diacrit.c | 2 +- src/cmd/eqn/eqnbox.c | 2 +- src/cmd/eqn/font.c | 2 +- src/cmd/eqn/fromto.c | 10 +- src/cmd/eqn/funny.c | 2 +- src/cmd/eqn/main.c | 6 +- src/cmd/eqn/mbwc.c | 1 - src/cmd/eqn/move.c | 2 +- src/cmd/eqn/over.c | 8 +- src/cmd/eqn/paren.c | 2 +- src/cmd/eqn/pile.c | 14 +- src/cmd/eqn/shift.c | 8 +- src/cmd/eqn/size.c | 2 +- src/cmd/eqn/sqrt.c | 2 +- src/cmd/eqn/text.c | 4 +- src/cmd/faces/facedb.c | 20 +- src/cmd/faces/main.c | 6 +- src/cmd/faces/plumb.c | 2 +- src/cmd/faces/util.c | 1 - src/cmd/file.c | 18 +- src/cmd/fmt.c | 2 +- src/cmd/fontsrv/main.c | 23 +- src/cmd/fontsrv/osx.c | 28 +- src/cmd/fontsrv/pjw.c | 6 +- src/cmd/fossil/9fsys.c | 8 +- src/cmd/fossil/9lstn.c | 2 +- src/cmd/fossil/9p.c | 4 +- src/cmd/fossil/9ping.c | 6 +- src/cmd/fossil/archive.c | 4 +- src/cmd/fossil/bwatch.c | 3 +- src/cmd/fossil/cache.c | 24 +- src/cmd/fossil/flchk.c | 3 +- src/cmd/fossil/flfmt9660.c | 4 +- src/cmd/fossil/fs.c | 3 +- src/cmd/fossil/nobwatch.c | 1 - src/cmd/fossil/pack.c | 1 - src/cmd/fossil/periodic.c | 1 - src/cmd/fossil/srcload.c | 8 +- src/cmd/fossil/view.c | 8 +- src/cmd/fossil/walk.c | 1 - src/cmd/getflags.c | 12 +- src/cmd/grap/misc.c | 2 +- src/cmd/grap/print.c | 6 +- src/cmd/graph/graph.c | 10 +- src/cmd/grep/grep.h | 2 +- src/cmd/gzip/gunzip.c | 2 +- src/cmd/gzip/zip.c | 2 +- src/cmd/hget.c | 29 +- src/cmd/hist.c | 2 +- src/cmd/hoc/code.c | 8 +- src/cmd/hoc/symbol.c | 2 +- src/cmd/htmlroff/a.h | 4 +- src/cmd/htmlroff/char.c | 9 +- src/cmd/htmlroff/html.c | 13 +- src/cmd/htmlroff/input.c | 14 +- src/cmd/htmlroff/main.c | 7 +- src/cmd/htmlroff/roff.c | 26 +- src/cmd/htmlroff/t1.c | 11 +- src/cmd/htmlroff/t10.c | 9 +- src/cmd/htmlroff/t11.c | 1 - src/cmd/htmlroff/t13.c | 3 +- src/cmd/htmlroff/t14.c | 3 +- src/cmd/htmlroff/t15.c | 1 - src/cmd/htmlroff/t16.c | 14 +- src/cmd/htmlroff/t17.c | 4 +- src/cmd/htmlroff/t18.c | 6 +- src/cmd/htmlroff/t19.c | 11 +- src/cmd/htmlroff/t2.c | 23 +- src/cmd/htmlroff/t20.c | 9 +- src/cmd/htmlroff/t3.c | 3 +- src/cmd/htmlroff/t4.c | 7 +- src/cmd/htmlroff/t5.c | 5 +- src/cmd/htmlroff/t6.c | 3 +- src/cmd/htmlroff/t7.c | 27 +- src/cmd/htmlroff/t8.c | 27 +- src/cmd/htmlroff/t9.c | 1 - src/cmd/htmlroff/util.c | 13 +- src/cmd/import.c | 6 +- src/cmd/ip/dhcp.h | 4 +- src/cmd/ip/dhcpd/dat.h | 1 - src/cmd/ip/dhcpd/db.c | 4 +- src/cmd/ip/dhcpd/dhcpd.c | 8 +- src/cmd/ip/dhcpd/dhcpleases.c | 2 +- src/cmd/ip/dhcpd/ndb.c | 2 +- src/cmd/ip/dhcpd/ping.c | 0 src/cmd/ip/dhcpd/testlook.c | 2 +- src/cmd/ip/dhcpd/testlookup.c | 0 src/cmd/ip/dhcpd/testping.c | 0 src/cmd/ip/snoopy/arp.c | 2 +- src/cmd/ip/snoopy/bootp.c | 2 +- src/cmd/ip/snoopy/dat.h | 2 +- src/cmd/ip/snoopy/dhcp.c | 5 +- src/cmd/ip/snoopy/dns.c | 12 +- src/cmd/ip/snoopy/dump.c | 2 +- src/cmd/ip/snoopy/ether.c | 2 +- src/cmd/ip/snoopy/gre.c | 4 +- src/cmd/ip/snoopy/hdlc.c | 0 src/cmd/ip/snoopy/icmp.c | 2 +- src/cmd/ip/snoopy/icmp6.c | 20 +- src/cmd/ip/snoopy/il.c | 8 +- src/cmd/ip/snoopy/ip.c | 2 +- src/cmd/ip/snoopy/ip6.c | 8 +- src/cmd/ip/snoopy/llc.c | 10 +- src/cmd/ip/snoopy/main.c | 24 +- src/cmd/ip/snoopy/ninep.c | 0 src/cmd/ip/snoopy/ospf.c | 12 +- src/cmd/ip/snoopy/p80211.c | 22 +- src/cmd/ip/snoopy/ppp.c | 24 +- src/cmd/ip/snoopy/ppp_ccp.c | 0 src/cmd/ip/snoopy/ppp_chap.c | 0 src/cmd/ip/snoopy/ppp_comp.c | 0 src/cmd/ip/snoopy/ppp_ipcp.c | 0 src/cmd/ip/snoopy/ppp_lcp.c | 0 src/cmd/ip/snoopy/pppoe_disc.c | 3 +- src/cmd/ip/snoopy/pppoe_sess.c | 0 src/cmd/ip/snoopy/radiotap.c | 2 +- src/cmd/ip/snoopy/rarp.c | 0 src/cmd/ip/snoopy/rtcp.c | 4 +- src/cmd/ip/snoopy/rtp.c | 0 src/cmd/ip/snoopy/snap.c | 4 +- src/cmd/ip/snoopy/tcp.c | 2 +- src/cmd/ip/snoopy/udp.c | 2 +- src/cmd/jpg/jpegdump.c | 10 +- src/cmd/jpg/jpg.c | 2 +- src/cmd/jpg/onechan.c | 2 +- src/cmd/jpg/readbmp.c | 8 +- src/cmd/jpg/readgif.c | 2 +- src/cmd/jpg/readjpg.c | 4 +- src/cmd/jpg/readpng.c | 14 +- src/cmd/jpg/readppm.c | 4 +- src/cmd/jpg/readyuv.c | 4 +- src/cmd/jpg/writegif.c | 4 +- src/cmd/jpg/writepng.c | 10 +- src/cmd/jpg/writeppm.c | 2 +- src/cmd/lex/sub1.c | 4 +- src/cmd/lex/sub2.c | 8 +- src/cmd/look.c | 4 +- src/cmd/lp/ipcopen.c | 2 +- src/cmd/lp/lpdsend.c | 4 +- src/cmd/lp/lpsend.c | 2 +- src/cmd/ls.c | 3 +- src/cmd/map/libmap/bonne.c | 2 +- src/cmd/map/libmap/cubrt.c | 2 +- src/cmd/map/libmap/elco2.c | 2 +- src/cmd/map/libmap/gilbert.c | 2 - src/cmd/map/libmap/homing.c | 2 +- src/cmd/map/libmap/lambert.c | 2 +- src/cmd/map/libmap/lune.c | 2 +- src/cmd/map/libmap/tetra.c | 7 +- src/cmd/map/libmap/twocirc.c | 6 +- src/cmd/map/map.c | 22 +- src/cmd/map/route.c | 2 +- src/cmd/mk/env.c | 2 +- src/cmd/mk/rule.c | 2 +- src/cmd/mk/run.c | 2 +- src/cmd/mk/sh.c | 1 - src/cmd/mk/sys.h | 1 - src/cmd/mk/unix.c | 6 +- src/cmd/mk/varsub.c | 8 +- src/cmd/mk/word.c | 2 +- src/cmd/mpm/range.h | 2 +- src/cmd/mpm/slug.h | 2 +- src/cmd/namespace.c | 1 - src/cmd/ndb/convDNS2M.c | 0 src/cmd/ndb/convM2DNS.c | 0 src/cmd/ndb/dblookup.c | 16 +- src/cmd/ndb/dn.c | 8 +- src/cmd/ndb/dnarea.c | 3 +- src/cmd/ndb/dnnotify.c | 0 src/cmd/ndb/dnresolve.c | 18 +- src/cmd/ndb/dns.c | 2 +- src/cmd/ndb/dns.h | 2 +- src/cmd/ndb/dnsdebug.c | 2 +- src/cmd/ndb/dnserver.c | 4 +- src/cmd/ndb/dnsquery.c | 0 src/cmd/ndb/dnstcp.c | 0 src/cmd/ndb/dntcpserver.c | 2 +- src/cmd/ndb/dnudpserver.c | 1 - src/cmd/ndb/ndbmkhash.c | 2 +- src/cmd/ndb/ndbquery.c | 2 +- src/cmd/ndb/runproc.c | 1 - src/cmd/netfiles/acme.c | 13 +- src/cmd/netfiles/acme.h | 2 +- src/cmd/netfiles/main.c | 37 +- src/cmd/netfiles/wait.c | 7 +- src/cmd/page/cache.c | 6 +- src/cmd/page/gfx.c | 8 +- src/cmd/page/gs.c | 6 +- src/cmd/page/nrotate.c | 11 +- src/cmd/page/page.c | 12 +- src/cmd/page/pdf.c | 8 +- src/cmd/page/ps.c | 6 +- src/cmd/page/rotate.c | 14 +- src/cmd/page/util.c | 6 +- src/cmd/page/view.c | 80 +- src/cmd/paint/eenter.c | 1 - src/cmd/paint/paint.c | 6 +- src/cmd/pbd.c | 2 +- src/cmd/pic/arcgen.c | 1 - src/cmd/pic/linegen.c | 2 +- src/cmd/pic/misc.c | 2 +- src/cmd/plot/libplot/circ.c | 2 +- src/cmd/plot/libplot/disk.c | 2 +- src/cmd/plot/libplot/move.c | 2 +- src/cmd/plot/libplot/parabola.c | 10 +- src/cmd/plot/libplot/ppause.c | 10 +- src/cmd/plot/libplot/rarc.c | 28 +- src/cmd/plot/libplot/save.c | 6 +- src/cmd/plot/libplot/spline.c | 26 +- src/cmd/plot/libplot/subr.c | 40 +- src/cmd/plot/plot.c | 2 +- src/cmd/plumb/match.c | 4 +- src/cmd/postscript/common/bbox.c | 1 - src/cmd/postscript/common/comments.h | 1 - src/cmd/postscript/common/common.h | 1 - src/cmd/postscript/common/ext.h | 2 +- src/cmd/postscript/common/gen.h | 1 - src/cmd/postscript/common/glob.c | 1 - src/cmd/postscript/common/misc.c | 1 - src/cmd/postscript/common/path.h | 1 - src/cmd/postscript/common/request.c | 1 - src/cmd/postscript/common/request.h | 1 - src/cmd/postscript/download/download.c | 1 - src/cmd/postscript/download/download.h | 1 - src/cmd/postscript/misc/ibmfont.c | 9 +- src/cmd/postscript/misc/laserbar.c | 4 +- src/cmd/postscript/misc/macfont.c | 9 +- src/cmd/postscript/misc/pscrypt.c | 1 - src/cmd/postscript/postreverse/postreverse.c | 3 +- src/cmd/postscript/postreverse/postreverse.h | 1 - src/cmd/postscript/tr2post/Bgetfield.c | 10 +- src/cmd/postscript/tr2post/chartab.c | 6 +- src/cmd/postscript/tr2post/devcntl.c | 1 - src/cmd/postscript/tr2post/draw.c | 2 +- src/cmd/postscript/tr2post/readDESC.c | 4 +- src/cmd/postscript/tr2post/tr2post.c | 4 +- src/cmd/postscript/tr2post/utils.c | 6 +- src/cmd/proof/font.c | 12 +- src/cmd/proof/htroff.c | 8 +- src/cmd/proof/main.c | 4 +- src/cmd/ramfs.c | 1 - src/cmd/rc/exec.c | 4 +- src/cmd/rc/havefork.c | 4 +- src/cmd/rc/lex.c | 2 +- src/cmd/rc/plan9ish.c | 8 +- src/cmd/rc/tree.c | 2 +- src/cmd/readcons.c | 5 +- src/cmd/resample.c | 2 +- src/cmd/rio/client.c | 5 +- src/cmd/rio/color.c | 1 - src/cmd/rio/cursor.c | 138 +- src/cmd/rio/event.c | 4 +- src/cmd/rio/grab.c | 6 +- src/cmd/rio/key.c | 1 - src/cmd/rio/main.c | 6 +- src/cmd/rio/menu.c | 12 +- src/cmd/rio/printevent.c | 15 +- src/cmd/rio/showevent/sample.c | 1 - src/cmd/rio/xevents.c | 5 +- src/cmd/rio/xshove.c | 12 +- src/cmd/sam/cmd.c | 4 +- src/cmd/sam/mesg.c | 4 +- src/cmd/sam/mesg.h | 18 +- src/cmd/sam/moveto.c | 1 - src/cmd/sam/plumb.h | 1 - src/cmd/sam/rasp.c | 1 - src/cmd/sam/sam.c | 2 +- src/cmd/sam/unix.c | 18 +- src/cmd/samterm/icons.c | 8 +- src/cmd/samterm/io.c | 2 +- src/cmd/samterm/main.c | 4 +- src/cmd/samterm/mesg.c | 2 +- src/cmd/samterm/samterm.h | 1 - src/cmd/scat/display.c | 4 +- src/cmd/scat/header.c | 1 - src/cmd/scat/plot.c | 8 +- src/cmd/scat/scat.c | 4 +- src/cmd/scat/sky.h | 2 +- src/cmd/sed.c | 8 +- src/cmd/sftpcache.c | 19 +- src/cmd/smugfs/a.h | 1 - src/cmd/smugfs/cache.c | 14 +- src/cmd/smugfs/download.c | 6 +- src/cmd/smugfs/fs.c | 100 +- src/cmd/smugfs/http.c | 8 +- src/cmd/smugfs/icache.c | 9 +- src/cmd/smugfs/json.c | 20 +- src/cmd/smugfs/jsonrpc.c | 11 +- src/cmd/smugfs/log.c | 1 - src/cmd/smugfs/main.c | 6 +- src/cmd/smugfs/openssl.c | 8 +- src/cmd/smugfs/tcp.c | 1 - src/cmd/smugfs/util.c | 9 +- src/cmd/snarfer/osx-cocoa-snarfer.c | 1 - src/cmd/snarfer/osx-snarfer.c | 1 - src/cmd/snarfer/snarfer.c | 26 +- src/cmd/spell/code.h | 4 +- src/cmd/spell/sprog.c | 4 +- src/cmd/split.c | 6 +- src/cmd/srv.c | 15 +- src/cmd/strings.c | 2 +- src/cmd/svgpic/arcgen.c | 1 - src/cmd/svgpic/linegen.c | 2 +- src/cmd/svgpic/misc.c | 2 +- src/cmd/svgpic/plsvg.c | 2 +- src/cmd/tail.c | 4 +- src/cmd/tapefs/32vfs.c | 2 +- src/cmd/tapefs/util.c | 2 +- src/cmd/tapefs/v10fs.c | 2 +- src/cmd/tapefs/v6fs.c | 2 +- src/cmd/tapefs/zipfs.c | 3 +- src/cmd/tar.c | 2 +- src/cmd/tbl/t1.c | 6 +- src/cmd/tbl/t2.c | 2 - src/cmd/tbl/t3.c | 10 +- src/cmd/tbl/t4.c | 136 +- src/cmd/tbl/t5.c | 42 +- src/cmd/tbl/t6.c | 38 +- src/cmd/tbl/t7.c | 16 +- src/cmd/tbl/t8.c | 52 +- src/cmd/tbl/t9.c | 16 +- src/cmd/tbl/tb.c | 12 +- src/cmd/tbl/tc.c | 10 +- src/cmd/tbl/te.c | 2 - src/cmd/tbl/tf.c | 2 - src/cmd/tbl/tg.c | 16 +- src/cmd/tbl/ti.c | 22 +- src/cmd/tbl/tm.c | 8 +- src/cmd/tbl/tr.c | 2 - src/cmd/tbl/ts.c | 4 +- src/cmd/tbl/tt.c | 22 +- src/cmd/tbl/tu.c | 78 +- src/cmd/tbl/tv.c | 70 +- src/cmd/tcs/conv_ksc.c | 1 - src/cmd/tcs/font/bbits.c | 2 +- src/cmd/tcs/html.c | 19 +- src/cmd/tcs/jis.h | 1 - src/cmd/tcs/ksc.c | 1946 +++++++++--------- src/cmd/tcs/misc.h | 8 +- src/cmd/tcs/ms.h | 4 +- src/cmd/tcs/tcs.c | 6 +- src/cmd/tcs/tune.c | 6 +- src/cmd/touch.c | 2 +- src/cmd/tpic/arcgen.c | 1 - src/cmd/tpic/linegen.c | 2 +- src/cmd/tpic/pic.h | 1 - src/cmd/tpic/tex.c | 22 +- src/cmd/tr.c | 4 +- src/cmd/troff/dwbinit.c | 5 +- src/cmd/troff/ext.h | 1 - src/cmd/troff/mbwc.c | 1 - src/cmd/troff/n1.c | 10 +- src/cmd/troff/n10.c | 20 +- src/cmd/troff/n2.c | 12 +- src/cmd/troff/n3.c | 20 +- src/cmd/troff/n4.c | 4 +- src/cmd/troff/n5.c | 48 +- src/cmd/troff/n6.c | 6 +- src/cmd/troff/n7.c | 28 +- src/cmd/troff/n8.c | 16 +- src/cmd/troff/n9.c | 18 +- src/cmd/troff/ni.c | 1 - src/cmd/troff/t10.c | 10 +- src/cmd/troff/t11.c | 4 +- src/cmd/troff/t6.c | 28 +- src/cmd/troff/tdef.h | 8 +- src/cmd/troff2html/troff2html.c | 2 +- src/cmd/uniq.c | 4 +- src/cmd/unutf.c | 2 +- src/cmd/upas/bayes/addhash.c | 3 +- src/cmd/upas/bayes/dfa.c | 4 +- src/cmd/upas/bayes/dfa.h | 1 - src/cmd/upas/bayes/dump.c | 2 +- src/cmd/upas/bayes/msgclass.c | 1 - src/cmd/upas/bayes/msgtok.c | 7 +- src/cmd/upas/bayes/regcomp.c | 2 +- src/cmd/upas/bayes/regen.c | 6 +- src/cmd/upas/common/common.h | 4 +- src/cmd/upas/common/config.c | 2 +- src/cmd/upas/common/libsys.c | 8 +- src/cmd/upas/common/process.c | 2 +- src/cmd/upas/filterkit/list.c | 2 +- src/cmd/upas/filterkit/readaddrs.c | 2 +- src/cmd/upas/filterkit/token.c | 4 +- src/cmd/upas/fs/dat.h | 1 - src/cmd/upas/fs/fs.c | 8 +- src/cmd/upas/fs/imap4.c | 10 +- src/cmd/upas/fs/mbox.c | 5 +- src/cmd/upas/fs/pop3.c | 3 +- src/cmd/upas/fs/strtotm.c | 4 +- src/cmd/upas/fs/tester.c | 2 +- src/cmd/upas/marshal/marshal.c | 24 +- src/cmd/upas/misc/mail.c | 1 - src/cmd/upas/ml/common.c | 2 +- src/cmd/upas/ml/ml.c | 2 +- src/cmd/upas/ned/nedmail.c | 30 +- src/cmd/upas/nfs/box.c | 33 +- src/cmd/upas/nfs/box.h | 5 +- src/cmd/upas/nfs/decode.c | 14 +- src/cmd/upas/nfs/fs.c | 71 +- src/cmd/upas/nfs/imap.c | 115 +- src/cmd/upas/nfs/main.c | 5 +- src/cmd/upas/nfs/mbox.c | 8 +- src/cmd/upas/nfs/msg.c | 1 - src/cmd/upas/nfs/sx.c | 20 +- src/cmd/upas/nfs/sx.h | 1 - src/cmd/upas/nfs/thread.c | 5 +- src/cmd/upas/nfs/util.c | 2 +- src/cmd/upas/pop3/pop3.c | 9 +- src/cmd/upas/scanmail/common.c | 4 +- src/cmd/upas/scanmail/testscan.c | 2 +- src/cmd/upas/send/bind.c | 1 - src/cmd/upas/send/main.c | 2 +- src/cmd/upas/send/message.c | 4 +- src/cmd/upas/send/rewrite.c | 7 +- src/cmd/upas/send/skipequiv.c | 2 +- src/cmd/upas/smtp/mxdial.c | 8 +- src/cmd/upas/smtp/smtp.c | 14 +- src/cmd/upas/smtp/smtpd.c | 8 +- src/cmd/upas/smtp/smtpd.h | 2 +- src/cmd/upas/smtp/spam.c | 8 +- src/cmd/upas/vf/unvf.c | 7 +- src/cmd/upas/vf/vf.c | 22 +- src/cmd/usage.c | 4 +- src/cmd/vac/dat.h | 1 - src/cmd/vac/file.c | 89 +- src/cmd/vac/glob.c | 9 +- src/cmd/vac/pack.c | 26 +- src/cmd/vac/testinc.c | 4 +- src/cmd/vac/unvac.c | 12 +- src/cmd/vac/vac.c | 29 +- src/cmd/vac/vac.h | 5 +- src/cmd/vac/vacfs.c | 9 +- src/cmd/vbackup/config.c | 4 +- src/cmd/vbackup/disknfs.c | 1 - src/cmd/vbackup/mount-Linux.c | 1 - src/cmd/vbackup/mount-none.c | 1 - src/cmd/vbackup/nfs3srv.c | 5 +- src/cmd/vbackup/nfs3srv.h | 1 - src/cmd/vbackup/vbackup.c | 27 +- src/cmd/vbackup/vftp.c | 47 +- src/cmd/vbackup/vnfs.c | 109 +- src/cmd/venti/copy.c | 10 +- src/cmd/venti/devnull.c | 3 +- src/cmd/venti/dump.c | 8 +- src/cmd/venti/randtest.c | 1 - src/cmd/venti/readlist.c | 2 +- src/cmd/venti/ro.c | 7 +- src/cmd/venti/srv/arena.c | 24 +- src/cmd/venti/srv/bloom.c | 26 +- src/cmd/venti/srv/buildindex.c | 121 +- src/cmd/venti/srv/clumpstats.c | 2 +- src/cmd/venti/srv/cmparenas.c | 12 +- src/cmd/venti/srv/config.c | 3 +- src/cmd/venti/srv/conv.c | 12 +- src/cmd/venti/srv/dat.h | 21 +- src/cmd/venti/srv/dcache.c | 18 +- src/cmd/venti/srv/disksched.c | 15 +- src/cmd/venti/srv/fixarenas.c | 157 +- src/cmd/venti/srv/fmtbloom.c | 6 +- src/cmd/venti/srv/graph.c | 16 +- src/cmd/venti/srv/hdisk.c | 66 +- src/cmd/venti/srv/hproc.c | 3 +- src/cmd/venti/srv/httpd.c | 34 +- src/cmd/venti/srv/icache.c | 31 +- src/cmd/venti/srv/icachewrite.c | 7 +- src/cmd/venti/srv/index.c | 20 +- src/cmd/venti/srv/lump.c | 2 +- src/cmd/venti/srv/lumpcache.c | 3 +- src/cmd/venti/srv/lumpqueue.c | 2 +- src/cmd/venti/srv/mgr.c | 46 +- src/cmd/venti/srv/mirrorarenas.c | 42 +- src/cmd/venti/srv/part.c | 19 +- src/cmd/venti/srv/png.c | 8 +- src/cmd/venti/srv/rdarena.c | 2 +- src/cmd/venti/srv/readifile.c | 4 +- src/cmd/venti/srv/reseal.c | 16 +- src/cmd/venti/srv/round.c | 1 - src/cmd/venti/srv/sortientry.c | 2 +- src/cmd/venti/srv/stats.c | 12 +- src/cmd/venti/srv/syncindex0.c | 8 +- src/cmd/venti/srv/venti.c | 2 +- src/cmd/venti/srv/verifyarena.c | 10 +- src/cmd/venti/srv/wrarena.c | 2 +- src/cmd/venti/srv/xml.c | 1 - src/cmd/venti/srv/zblock.c | 1 - src/cmd/venti/sync.c | 2 +- src/cmd/venti/writefile.c | 7 +- src/cmd/zerotrunc.c | 1 - src/lib9/_p9dir.c | 7 +- src/lib9/_p9translate.c | 2 +- src/lib9/announce.c | 1 - src/lib9/atoi.c | 1 - src/lib9/atol.c | 1 - src/lib9/atoll.c | 1 - src/lib9/await.c | 3 +- src/lib9/convD2M.c | 8 +- src/lib9/convM2D.c | 4 +- src/lib9/crypt.c | 0 src/lib9/ctime.c | 1 - src/lib9/debugmalloc.c | 4 +- src/lib9/dial.c | 3 +- src/lib9/dirfstat.c | 1 - src/lib9/dirfwstat.c | 1 - src/lib9/dirread.c | 4 +- src/lib9/dirstat.c | 1 - src/lib9/errstr.c | 1 - src/lib9/execl.c | 1 - src/lib9/exitcode.c | 1 - src/lib9/fmt/dofmt.c | 2 +- src/lib9/fmt/fltfmt.c | 55 +- src/lib9/fmt/fmtdef.h | 1 - src/lib9/fmt/fmtlocale.c | 3 +- src/lib9/fmt/fmtnull.c | 1 - src/lib9/fmt/fmtprint.c | 1 - src/lib9/fmt/fmtvprint.c | 1 - src/lib9/fmt/nan64.c | 6 +- src/lib9/fmt/plan9.h | 1 - src/lib9/fmt/runesnprint.c | 1 - src/lib9/fmt/runevseprint.c | 1 - src/lib9/fmt/runevsmprint.c | 4 +- src/lib9/fmt/snprint.c | 1 - src/lib9/fmt/vseprint.c | 1 - src/lib9/fmt/vsmprint.c | 4 +- src/lib9/get9root.c | 1 - src/lib9/getnetconn.c | 3 +- src/lib9/getns.c | 2 +- src/lib9/jmp.c | 1 - src/lib9/malloc.c | 4 +- src/lib9/netmkaddr.c | 2 +- src/lib9/notify.c | 11 +- src/lib9/opentemp.c | 1 - src/lib9/pin.c | 1 - src/lib9/postnote.c | 2 - src/lib9/priv.c | 1 - src/lib9/quote.c | 4 +- src/lib9/rfork.c | 2 +- src/lib9/searchpath.c | 1 - src/lib9/sendfd.c | 2 +- src/lib9/strdup.c | 1 - src/lib9/sysfatal.c | 1 - src/lib9/testfltfmt.c | 12 +- src/lib9/testfmt.c | 6 +- src/lib9/testprint.c | 2 +- src/lib9/time.c | 1 - src/lib9/tm2sec.c | 2 +- src/lib9/u64.c | 2 +- src/lib9/udp.c | 1 - src/lib9/unsharp.c | 2 +- src/lib9/utf/lib9.h | 1 - src/lib9/utf/plan9.h | 1 - src/lib9/utf/rune.c | 2 +- src/lib9/utf/runestrdup.c | 4 +- src/lib9/utf/utfdef.h | 1 - src/lib9/wait.c | 1 - src/lib9/waitpid.c | 1 - src/lib9/zoneinfo.c | 2 +- src/lib9/zoneinfo.h | 1 - src/lib9p/_post.c | 1 - src/lib9p/file.c | 4 +- src/lib9p/intmap.c | 8 +- src/lib9p/mem.c | 1 - src/lib9p/parse.c | 2 +- src/lib9p/post.c | 1 - src/lib9p/req.c | 2 +- src/lib9p/srv.c | 29 +- src/lib9pclient/access.c | 0 src/lib9pclient/close.c | 2 +- src/lib9pclient/create.c | 2 +- src/lib9pclient/fs.c | 4 +- src/lib9pclient/ns.c | 1 - src/lib9pclient/print.c | 1 - src/lib9pclient/read.c | 4 +- src/lib9pclient/remove.c | 1 - src/lib9pclient/stat.c | 3 +- src/lib9pclient/wstat.c | 2 +- src/libString/s_getline.c | 2 +- src/libString/s_grow.c | 3 +- src/libString/s_memappend.c | 1 - src/libString/s_nappend.c | 1 - src/libString/s_parse.c | 4 +- src/libString/s_rdinstack.c | 2 +- src/libString/s_read.c | 2 +- src/libString/s_read_line.c | 2 +- src/libacme/acme.c | 10 +- src/libauth/attr.c | 1 - src/libauth/auth_proxy.c | 3 +- src/libauth/auth_respond.c | 2 +- src/libauth/fsamount.c | 3 +- src/libauth/nsamount.c | 3 +- src/libauthsrv/convM2T.c | 1 - src/libauthsrv/convPR2M.c | 1 - src/libauthsrv/convTR2M.c | 1 - src/libauthsrv/readnvram.c | 5 +- src/libbio/bcat.c | 2 +- src/libbio/brdstr.c | 2 +- src/libbio/bvprint.c | 2 +- src/libbio/lib9.std.h | 1 - src/libdisk/disk.c | 13 +- src/libdisk/proto.c | 4 +- src/libdisk/scsi.c | 10 +- src/libdiskfs/block.c | 2 +- src/libdiskfs/cache.c | 10 +- src/libdiskfs/ext2.c | 8 +- src/libdiskfs/ext2.h | 3 +- src/libdiskfs/fat.c | 1 - src/libdiskfs/ffs.c | 20 +- src/libdiskfs/ffs.h | 3 +- src/libdiskfs/hfs.c | 12 +- src/libdiskfs/hfs.h | 20 +- src/libdiskfs/kfs.c | 1 - src/libdiskfs/part.c | 10 +- src/libdiskfs/venti.c | 1 - src/libdiskfs/vfile.c | 2 - src/libdraw/allocimagemix.c | 2 +- src/libdraw/arith.c | 1 - src/libdraw/buildfont.c | 2 +- src/libdraw/chan.c | 2 +- src/libdraw/computil.c | 2 +- src/libdraw/draw.c | 2 +- src/libdraw/drawclient.c | 33 +- src/libdraw/drawfcall.c | 18 +- src/libdraw/drawrepl.c | 1 - src/libdraw/event.c | 15 +- src/libdraw/font.c | 4 +- src/libdraw/getsubfont.c | 6 +- src/libdraw/icossin2.c | 2 +- src/libdraw/init.c | 20 +- src/libdraw/iprint.c | 2 +- src/libdraw/keyboard.c | 3 +- src/libdraw/mouse.c | 1 - src/libdraw/newwindow.c | 1 - src/libdraw/openfont.c | 28 +- src/libdraw/rgb.c | 2 +- src/libdraw/scroll.c | 2 +- src/libdraw/string.c | 2 +- src/libdraw/stringwidth.c | 2 +- src/libdraw/subfont.c | 4 +- src/libdraw/subfontname.c | 2 +- src/libdraw/unix.c | 1 - src/libdraw/wsys.c | 1 - src/libframe/frdelete.c | 2 +- src/libframe/frdraw.c | 2 +- src/libgeometry/quaternion.c | 4 +- src/libgeometry/tstack.c | 2 +- src/libhtml/build.c | 8 +- src/libhtml/lex.c | 6 +- src/libhttpd/redirected.c | 2 +- src/libip/BSD.c | 6 +- src/libip/Linux.c | 23 +- src/libip/freeipifc.c | 1 - src/libip/myetheraddr.c | 3 +- src/libip/myipaddr.c | 1 - src/libip/none.c | 2 +- src/libip/parseip.c | 2 +- src/libip/udp.c | 1 - src/libmach/DragonFly.c | 2 +- src/libmach/FreeBSD.c | 2 +- src/libmach/Linux.c | 9 +- src/libmach/cmdline.c | 3 +- src/libmach/crack.c | 5 +- src/libmach/crackelf.c | 11 +- src/libmach/crackmacho.c | 4 +- src/libmach/demangler.c | 4 +- src/libmach/dwarf.h | 1 - src/libmach/dwarf386.c | 4 +- src/libmach/dwarfabbrev.c | 3 +- src/libmach/dwarfaranges.c | 1 - src/libmach/dwarfcfa.c | 21 +- src/libmach/dwarfeval.c | 1 - src/libmach/dwarfget.c | 1 - src/libmach/dwarfinfo.c | 8 +- src/libmach/dwarfopen.c | 2 +- src/libmach/dwarfpc.c | 2 +- src/libmach/elf.c | 11 +- src/libmach/elfcorefreebsd386.c | 1 - src/libmach/elfcorefreebsdamd64.c | 7 +- src/libmach/elfcorelinux386.c | 7 +- src/libmach/elfdl386.c | 1 - src/libmach/elfdynsym.c | 2 +- src/libmach/fpformat.c | 2 +- src/libmach/frame.c | 4 +- src/libmach/hexify.c | 1 - src/libmach/loc.c | 1 - src/libmach/mach386.c | 14 +- src/libmach/machamd64.c | 4 +- src/libmach/macho.c | 10 +- src/libmach/macho.h | 4 +- src/libmach/machocorepower.c | 1 - src/libmach/machpower.c | 9 +- src/libmach/mangle.c | 6 +- src/libmach/manglegcc2.c | 47 +- src/libmach/manglegcc3.c | 23 +- src/libmach/map.c | 2 +- src/libmach/regs.c | 1 - src/libmach/stabs.c | 1 - src/libmach/stabs.h | 1 - src/libmach/sym.c | 5 +- src/libmach/symdwarf.c | 7 +- src/libmach/symelf.c | 1 - src/libmach/symmacho.c | 1 - src/libmach/symstabs.c | 10 +- src/libmach/t.c | 8 +- src/libmach/ureg386.c | 1 - src/libmemdraw/alloc-stub.c | 1 - src/libmemdraw/alloc.c | 2 +- src/libmemdraw/arctest.c | 3 +- src/libmemdraw/draw-stub.c | 3 +- src/libmemdraw/draw.c | 67 +- src/libmemdraw/drawtest.c | 14 +- src/libmemdraw/ellipse.c | 20 +- src/libmemdraw/fill-stub.c | 1 - src/libmemdraw/hwdraw.c | 1 - src/libmemdraw/iprint.c | 1 - src/libmemdraw/load-stub.c | 1 - src/libmp/port/crt.c | 2 +- src/libmp/port/mpaux.c | 1 - src/libmp/port/mpextendedgcd.c | 4 +- src/libmp/port/mpfmt.c | 1 - src/libmp/port/mptobe.c | 2 +- src/libmp/port/mptole.c | 2 +- src/libmp/port/mptouv.c | 2 +- src/libmp/port/mptov.c | 2 +- src/libmp/port/os.h | 1 - src/libmux/io.c | 5 +- src/libmux/mux.c | 10 +- src/libndb/csipinfo.c | 2 +- src/libndb/dnsquery.c | 4 +- src/libndb/ndbaux.c | 2 +- src/libndb/ndbcache.c | 2 +- src/libndb/ndbfree.c | 2 +- src/libndb/ndbhash.c | 4 +- src/libndb/ndbopen.c | 2 +- src/libndb/ndbreorder.c | 2 +- src/libndb/sysdnsquery.c | 32 +- src/libndb/testdns.c | 9 +- src/libplumb/event.c | 0 src/libplumb/fid.c | 1 - src/libplumb/mesg.c | 1 - src/libregexp/lib9.std.h | 1 - src/libregexp/regcomp.c | 2 +- src/libsec/port/aes.c | 10 +- src/libsec/port/blowfish.c | 534 +++-- src/libsec/port/des.c | 36 +- src/libsec/port/des3ECB.c | 4 +- src/libsec/port/desECB.c | 4 +- src/libsec/port/egdecrypt.c | 2 +- src/libsec/port/fastrand.c | 4 +- src/libsec/port/md4.c | 96 +- src/libsec/port/md5block.c | 126 +- src/libsec/port/nfastrand.c | 2 +- src/libsec/port/readcert.c | 1 - src/libsec/port/rsadecrypt.c | 2 +- src/libsec/port/rsafill.c | 1 - src/libsec/port/rsatest.c | 4 +- src/libsec/port/sha1block.c | 2 +- src/libsec/port/thumb.c | 1 - src/libsec/port/tlshand.c | 4 +- src/libsec/port/x509.c | 2 +- src/libsunrpc/client.c | 4 +- src/libsunrpc/emalloc.c | 2 - src/libsunrpc/mount3.c | 2 +- src/libsunrpc/nfs3.c | 4 +- src/libsunrpc/portmap.c | 2 +- src/libsunrpc/rpc.c | 3 +- src/libsunrpc/server.c | 3 +- src/libthread/386-ucontext.h | 6 +- src/libthread/BSD.c | 3 +- src/libthread/Darwin-386.c | 1 - src/libthread/Darwin-power.c | 3 +- src/libthread/Darwin-x86_64-swapcontext.c | 2 - src/libthread/Linux-arm-swapcontext.c | 2 - src/libthread/Linux-sparc64-swapcontext.c | 1 - src/libthread/Linux.c | 13 +- src/libthread/NetBSD.c | 1 - src/libthread/OpenBSD-386.c | 1 - src/libthread/OpenBSD-power.c | 1 - src/libthread/OpenBSD-x86_64.c | 2 - src/libthread/channel.c | 5 +- src/libthread/daemonize.c | 6 +- src/libthread/exec.c | 1 - src/libthread/ioproc.h | 1 - src/libthread/power-ucontext.h | 1 - src/libthread/sparc-ucontext.h | 1 - src/libthread/test/thello.c | 1 - src/libthread/thread.c | 24 +- src/libthread/threadimpl.h | 2 +- src/libthread/wait.c | 4 +- src/libthread/x86_64-ucontext.h | 1 - src/libventi/cache.c | 15 +- src/libventi/client.c | 2 +- src/libventi/cvt.h | 1 - src/libventi/debug.c | 1 - src/libventi/debugpacket.c | 9 +- src/libventi/dtype.c | 1 - src/libventi/entry.c | 9 +- src/libventi/file.c | 18 +- src/libventi/hangup.c | 1 - src/libventi/log.c | 15 +- src/libventi/mem.c | 7 +- src/libventi/packet.c | 48 +- src/libventi/queue.c | 2 +- src/libventi/rpc.c | 7 +- src/libventi/send.c | 9 +- src/libventi/server.c | 3 +- src/libventi/strdup.c | 1 - src/libventi/string.c | 1 - src/libventi/time.c | 9 +- src/libventi/zero.c | 2 +- src/libventi/zeroscore.c | 1 - 1021 files changed, 5688 insertions(+), 6193 deletions(-) mode change 100755 => 100644 src/cmd/ip/dhcp.h mode change 100755 => 100644 src/cmd/ip/dhcpd/dat.h mode change 100755 => 100644 src/cmd/ip/dhcpd/db.c mode change 100755 => 100644 src/cmd/ip/dhcpd/dhcpd.c mode change 100755 => 100644 src/cmd/ip/dhcpd/dhcpleases.c mode change 100755 => 100644 src/cmd/ip/dhcpd/ndb.c mode change 100755 => 100644 src/cmd/ip/dhcpd/ping.c mode change 100755 => 100644 src/cmd/ip/dhcpd/testlook.c mode change 100755 => 100644 src/cmd/ip/dhcpd/testlookup.c mode change 100755 => 100644 src/cmd/ip/dhcpd/testping.c mode change 100755 => 100644 src/cmd/ip/snoopy/arp.c mode change 100755 => 100644 src/cmd/ip/snoopy/bootp.c mode change 100755 => 100644 src/cmd/ip/snoopy/dat.h mode change 100755 => 100644 src/cmd/ip/snoopy/dhcp.c mode change 100755 => 100644 src/cmd/ip/snoopy/dump.c mode change 100755 => 100644 src/cmd/ip/snoopy/ether.c mode change 100755 => 100644 src/cmd/ip/snoopy/gre.c mode change 100755 => 100644 src/cmd/ip/snoopy/hdlc.c mode change 100755 => 100644 src/cmd/ip/snoopy/icmp.c mode change 100755 => 100644 src/cmd/ip/snoopy/icmp6.c mode change 100755 => 100644 src/cmd/ip/snoopy/il.c mode change 100755 => 100644 src/cmd/ip/snoopy/ip.c mode change 100755 => 100644 src/cmd/ip/snoopy/ip6.c mode change 100755 => 100644 src/cmd/ip/snoopy/main.c mode change 100755 => 100644 src/cmd/ip/snoopy/ninep.c mode change 100755 => 100644 src/cmd/ip/snoopy/ospf.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp_ccp.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp_chap.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp_comp.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp_ipcp.c mode change 100755 => 100644 src/cmd/ip/snoopy/ppp_lcp.c mode change 100755 => 100644 src/cmd/ip/snoopy/pppoe_disc.c mode change 100755 => 100644 src/cmd/ip/snoopy/pppoe_sess.c mode change 100755 => 100644 src/cmd/ip/snoopy/rarp.c mode change 100755 => 100644 src/cmd/ip/snoopy/rtcp.c mode change 100755 => 100644 src/cmd/ip/snoopy/rtp.c mode change 100755 => 100644 src/cmd/ip/snoopy/tcp.c mode change 100755 => 100644 src/cmd/ip/snoopy/udp.c mode change 100755 => 100644 src/cmd/ndb/convDNS2M.c mode change 100755 => 100644 src/cmd/ndb/convM2DNS.c mode change 100755 => 100644 src/cmd/ndb/dblookup.c mode change 100755 => 100644 src/cmd/ndb/dn.c mode change 100755 => 100644 src/cmd/ndb/dnarea.c mode change 100755 => 100644 src/cmd/ndb/dnnotify.c mode change 100755 => 100644 src/cmd/ndb/dnresolve.c mode change 100755 => 100644 src/cmd/ndb/dns.c mode change 100755 => 100644 src/cmd/ndb/dns.h mode change 100755 => 100644 src/cmd/ndb/dnsdebug.c mode change 100755 => 100644 src/cmd/ndb/dnserver.c mode change 100755 => 100644 src/cmd/ndb/dnsquery.c mode change 100755 => 100644 src/cmd/ndb/dnstcp.c mode change 100755 => 100644 src/cmd/ndb/dnudpserver.c mode change 100755 => 100644 src/cmd/resample.c mode change 100755 => 100644 src/lib9/crypt.c mode change 100755 => 100644 src/lib9pclient/access.c mode change 100755 => 100644 src/libplumb/event.c mode change 100755 => 100644 src/libplumb/mesg.c diff --git a/src/cmd/9660/boot.c b/src/cmd/9660/boot.c index 9cae95829..c7d728484 100644 --- a/src/cmd/9660/boot.c +++ b/src/cmd/9660/boot.c @@ -42,7 +42,7 @@ g% cdsector 3149 | xd -b # 0x0c4d 55 aa - magic 0000020 88 - 88 = bootable - 03 - 3 = 2.88MB diskette + 03 - 3 = 2.88MB diskette 00 00 - load segment 0 means default 0x7C0 00 - system type (byte 5 of boot image) 00 - unused (0) @@ -58,13 +58,13 @@ g% cdsector `{h2d 0c4e} | xd -b 1+0 records out 0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00 0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00 -0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 +0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 31 c0 FREEBSD 0000000 eb 3c 00 00 00 00 00 00 00 00 00 00 02 00 00 00 0000010 00 00 00 00 00 00 00 00 12 00 02 00 00 00 00 00 -0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 +0000020 00 00 00 00 00 16 1f 66 6a 00 51 50 06 53 31 c0 DOS 5 @@ -171,7 +171,7 @@ Cupdatebootcat(Cdimg *cd) Cputc(cd, 0); /* unused */ Cputnl(cd, 1, 2); /* 512-byte sector count for load */ Cputnl(cd, cd->bootdirec->block, 4); /* ptr to disk image */ - Cwseek(cd, o); + Cwseek(cd, o); } void diff --git a/src/cmd/9660/cdrdwr.c b/src/cmd/9660/cdrdwr.c index 757bfcd93..786b798f2 100644 --- a/src/cmd/9660/cdrdwr.c +++ b/src/cmd/9660/cdrdwr.c @@ -125,7 +125,7 @@ opencd(char *file, Cdinfo info) } /* lowercase because of isostring */ - if(strstr(cd->iso.systemid, "iso9660") == nil + if(strstr(cd->iso.systemid, "iso9660") == nil && strstr(cd->iso.systemid, "utf8") == nil) { werrstr("unknown systemid %s", cd->iso.systemid); free(cd); @@ -133,7 +133,7 @@ opencd(char *file, Cdinfo info) close(xfd); return nil; } - + if(strstr(cd->iso.systemid, "plan 9")) cd->flags |= CDplan9; if(strstr(cd->iso.systemid, "iso9660")) @@ -307,7 +307,7 @@ parsedesc(Voldesc *v, Cvoldesc *cv, char *(*string)(uchar*, int)) v->biblio = string(cv->biblio, sizeof cv->biblio); v->notice = string(cv->notice, sizeof cv->notice); } - + static int readisodesc(Cdimg *cd, Voldesc *v) { @@ -629,4 +629,3 @@ Clinelen(Cdimg *cd) { return Blinelen(&cd->brd); } - diff --git a/src/cmd/9660/direc.c b/src/cmd/9660/direc.c index 8185f6806..e67f0cb76 100644 --- a/src/cmd/9660/direc.c +++ b/src/cmd/9660/direc.c @@ -86,9 +86,9 @@ walkdirec(Direc *d, char *name) * Add the file ``name'' with attributes d to the * directory ``root''. Name may contain multiple * elements; all but the last must exist already. - * + * * The child lists are kept sorted by utfname. - */ + */ Direc* adddirec(Direc *root, char *name, XDir *d) { @@ -130,7 +130,7 @@ adddirec(Direc *root, char *name, XDir *d) return nd; } -/* +/* * Copy the tree src into dst. */ void @@ -219,4 +219,3 @@ dsort(Direc *d, int (*cmp)(const void*, const void*)) for(i=0; ichild[i], cmp); } - diff --git a/src/cmd/9660/dump.c b/src/cmd/9660/dump.c index d3504ff94..ad762f217 100644 --- a/src/cmd/9660/dump.c +++ b/src/cmd/9660/dump.c @@ -348,7 +348,7 @@ adddumpdir(Direc *root, ulong now, XDir *dir) Tm tm; tm = *localtime(now); - + sprint(buf, "%d", tm.year+1900); if((dyear = walkdirec(root, buf)) == nil) { dyear = adddirec(root, buf, dir); @@ -406,7 +406,7 @@ hasdump(Cdimg *cd) } return 0; } - + Direc readdumpdirs(Cdimg *cd, XDir *dir, char *(*cvt)(uchar*, int)) { @@ -500,7 +500,7 @@ readdumpconform(Cdimg *cd) if(tokenize(p, f, 2) != 2 || (f[0][0] != 'D' && f[0][0] != 'F') || strlen(f[0]) != 7 || !isalldigit(f[0]+1)) break; - + addtx(atom(f[1]), atom(f[0])); } } diff --git a/src/cmd/9660/dump9660.c b/src/cmd/9660/dump9660.c index 4e66bd78a..59ee31c0e 100644 --- a/src/cmd/9660/dump9660.c +++ b/src/cmd/9660/dump9660.c @@ -168,7 +168,7 @@ main(int argc, char **argv) Cwseek(cd, cd->nextblock*Blocksize); goto Dofix; } - + dumpname = adddumpdir(&idumproot, now, &dir); /* note that we assume all names are conforming and thus sorted */ if(cd->flags & CDjoliet) { @@ -192,7 +192,7 @@ main(int argc, char **argv) findbootimage(cd, &iroot); Cupdatebootcat(cd); } - + /* create Joliet tree */ if(cd->flags & CDjoliet) copydirec(&jroot, &iroot); @@ -235,14 +235,14 @@ main(int argc, char **argv) * Write incremental _conform.map block. */ wrconform(cd, cd->nconform, &cblock, &clength); - + /* jump here if we're just fixing up the cd */ Dofix: /* - * Write null dump header block; everything after this will be + * Write null dump header block; everything after this will be * overwritten at the next dump. Because of this, it needs to be * reconstructable. We reconstruct the _conform.map and dump trees - * from the header blocks in dump.c, and we reconstruct the path + * from the header blocks in dump.c, and we reconstruct the path * tables by walking the cd. */ newnull = Cputdumpblock(cd); @@ -254,12 +254,12 @@ main(int argc, char **argv) dir.mode = 0444; if(cd->flags & (CDconform|CDjoliet)) { if(!mk9660 && cd->nconform == 0){ - block = cblock; + block = cblock; length = clength; }else wrconform(cd, 0, &block, &length); - if(mk9660) + if(mk9660) { idumproot = iroot; jdumproot = jroot; @@ -315,11 +315,11 @@ main(int argc, char **argv) copybutname(r, &jroot); } } - + writedumpdirs(cd, &idumproot, Cputisodir); if(cd->flags & CDjoliet) writedumpdirs(cd, &jdumproot, Cputjolietdir); - + /* * Patch in new root directory entry. */ @@ -330,7 +330,7 @@ main(int argc, char **argv) setvolsize(cd, cd->jolietsvd, cd->nextblock*Blocksize); } } - writepathtables(cd); + writepathtables(cd); if(!mk9660){ /* @@ -341,16 +341,16 @@ main(int argc, char **argv) if(cd->nulldump && maxsize && Cwoffset(cd) > maxsize){ fprint(2, "too big; writing old tree back\n"); status = "cd too big; aborted"; - + rmdumpdir(&idumproot, dumpname); rmdumpdir(&jdumproot, dumpname); - + cd->nextblock = cd->nulldump+1; cd->nulldump = 0; Cwseek(cd, cd->nextblock*Blocksize); goto Dofix; } - + /* * Write old null header block; this commits all our changes. */ @@ -399,4 +399,3 @@ addprotofile(char *new, char *old, Dir *d, void *a) free(name); } - diff --git a/src/cmd/9660/ichar.c b/src/cmd/9660/ichar.c index 3b2b5367f..ef2944ce6 100644 --- a/src/cmd/9660/ichar.c +++ b/src/cmd/9660/ichar.c @@ -31,7 +31,7 @@ isostring(uchar *buf, int len) return q; } -int +int isisofrog(char c) { if(c >= '0' && c <= '9') @@ -85,7 +85,7 @@ isbadiso9660(char *s) /* * ISO9660 name comparison - * + * * The standard algorithm is as follows: * Take the filenames without extensions, pad the shorter with 0x20s (spaces), * and do strcmp. If they are equal, go on. @@ -169,7 +169,7 @@ Cputisopvd(Cdimg *cd, Cdinfo info) strcat(buf, "iso9660"); else strcat(buf, "utf8"); - + struprcpy(buf, buf); Cputs(cd, buf, 32); diff --git a/src/cmd/9660/iso9660.h b/src/cmd/9660/iso9660.h index b5131a27c..c08b2caa7 100644 --- a/src/cmd/9660/iso9660.h +++ b/src/cmd/9660/iso9660.h @@ -89,7 +89,7 @@ struct Voldesc { ulong mpathloc; /* root of file tree */ - Direc root; + Direc root; }; /* @@ -116,7 +116,7 @@ struct Cdimg { ulong bootimageptr; Direc *bootdirec; char *bootimage; - + Biobuf brd; Biobuf bwr; @@ -406,7 +406,7 @@ int Cputisodir(Cdimg*, Direc*, int, int, int); int Cputjolietdir(Cdimg*, Direc*, int, int, int); void Cputendvd(Cdimg*); -enum { +enum { Blocksize = 2048, Ndirblock = 16, /* directory blocks allocated at once */ diff --git a/src/cmd/9660/jchar.c b/src/cmd/9660/jchar.c index ccd3b6db7..fbabf26d2 100644 --- a/src/cmd/9660/jchar.c +++ b/src/cmd/9660/jchar.c @@ -26,15 +26,15 @@ jolietstring(uchar *buf, int len) } /* - * Joliet name validity check - * + * Joliet name validity check + * * Joliet names have length at most 128 bytes (64 runes), * and cannot contain '*', '/', ':', ';', '?', or '\'. */ int isjolietfrog(Rune r) { - return r=='*' || r=='/' || r==':' + return r=='*' || r=='/' || r==':' || r==';' || r=='?' || r=='\\'; } @@ -58,7 +58,7 @@ isbadjoliet(char *s) * The standard algorithm is the ISO9660 algorithm but * on the encoded Runes. Runes are encoded in big endian * format, so we can just use runecmp. - * + * * Padding is with zeros, but that still doesn't affect us. */ @@ -135,4 +135,3 @@ Cputjolietsvd(Cdimg *cd, Cdinfo info) Cputc(cd, 1); /* file structure version */ Cpadblock(cd); } - diff --git a/src/cmd/9660/path.c b/src/cmd/9660/path.c index f2757dba9..effc44b18 100644 --- a/src/cmd/9660/path.c +++ b/src/cmd/9660/path.c @@ -9,7 +9,7 @@ * Add the requisite path tables to the CD image. * They get put on the end once everything else is done. * We use the path table itself as a queue in the breadth-first - * traversal of the tree. + * traversal of the tree. * * The only problem with this is that the path table does not * store the lengths of the directories. So we keep an explicit diff --git a/src/cmd/9660/rune.c b/src/cmd/9660/rune.c index 3a436f4a3..8b03f2823 100644 --- a/src/cmd/9660/rune.c +++ b/src/cmd/9660/rune.c @@ -36,4 +36,3 @@ runecmp(Rune *s, Rune *t) s++, t++; return *s - *t; } - diff --git a/src/cmd/9660/sysuse.c b/src/cmd/9660/sysuse.c index 787165243..3039b3607 100644 --- a/src/cmd/9660/sysuse.c +++ b/src/cmd/9660/sysuse.c @@ -43,11 +43,11 @@ setcelen(Cdimg *cd, ulong woffset, ulong len) * Rock Ridge data is put into little blockettes, which can be * at most 256 bytes including a one-byte length. Some number * of blockettes get packed together into a normal 2048-byte block. - * Blockettes cannot cross block boundaries. + * Blockettes cannot cross block boundaries. * - * A Cbuf is a blockette buffer. Len contains + * A Cbuf is a blockette buffer. Len contains * the length of the buffer written so far, and we can - * write up to 254-28. + * write up to 254-28. * * We only have one active Cbuf at a time; cdimg.rrcontin is the byte * offset of the beginning of that Cbuf. @@ -94,7 +94,7 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite) /* * the current blockette is full; update cd->rrcontin and then - * write a CE record to finish it. Unfortunately we need to + * write a CE record to finish it. Unfortunately we need to * figure out which block will be next before we write the CE. */ end = Cwoffset(cd)+28; @@ -134,13 +134,13 @@ ensurespace(Cdimg *cd, int n, Cbuf *co, Cbuf *cn, int dowrite) return cn; } - + /* * Put down the name, but we might need to break it * into chunks so that each chunk fits in 254-28-5 bytes. * What a crock. * - * The new Plan 9 format uses strings of this form too, + * The new Plan 9 format uses strings of this form too, * since they're already there. */ Cbuf* @@ -211,7 +211,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen) what |= RR_SL; m = CputsuspRR(cd, what, 0); - cp = ensurespace(cd, m, cp, &cn, dowrite); + cp = ensurespace(cd, m, cp, &cn, dowrite); CputsuspRR(cd, what, dowrite); if(what & RR_PX) { @@ -235,7 +235,7 @@ Cputsysuse(Cdimg *cd, Direc *d, int dot, int dowrite, int initlen) /* * Put down the symbolic link. This is even more of a crock. - * Not only are the individual elements potentially split, + * Not only are the individual elements potentially split, * but the whole path itself can be split across SL blocks. * To keep the code simple as possible (really), we write * only one element per SL block, wasting 6 bytes per element. @@ -382,7 +382,7 @@ CputsuspSP(Cdimg *cd, int dowrite) { assert(cd!=0); - if(dowrite) { + if(dowrite) { chat("writing SUSP SP record\n"); Cputc(cd, 'S'); /* SP field marker */ Cputc(cd, 'P'); @@ -406,7 +406,7 @@ CputsuspST(Cdimg *cd, int dowrite) Cputc(cd, 'S'); /* ST field marker */ Cputc(cd, 'T'); Cputc(cd, 4); /* Length */ - Cputc(cd, 1); /* Version */ + Cputc(cd, 1); /* Version */ } return 4; } @@ -484,7 +484,7 @@ CputrripPX(Cdimg *cd, Direc *d, int dot, int dowrite) Cputc(cd, 'X'); Cputc(cd, 36); /* Length */ Cputc(cd, 1); /* Version */ - + Cputn(cd, mode(d, dot), 4); /* POSIX File mode */ Cputn(cd, nlink(d), 4); /* POSIX st_nlink */ Cputn(cd, d?d->uidno:0, 4); /* POSIX st_uid */ @@ -514,7 +514,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite) Cputc(cd, 5+7*length); /* Length */ Cputc(cd, 1); /* Version */ Cputc(cd, type); /* Flags (types) */ - + if (type & TFcreation) Cputdate(cd, d?d->ctime:0); if (type & TFmodify) @@ -523,7 +523,7 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite) Cputdate(cd, d?d->atime:0); if (type & TFattributes) Cputdate(cd, d?d->ctime:0); - + /* if (type & TFbackup) */ /* Cputdate(cd, 0); */ /* if (type & TFexpiration) */ @@ -566,7 +566,7 @@ static long mode(Direc *d, int dot) { long mode; - + if (!d) return 0; @@ -582,13 +582,13 @@ mode(Direc *d, int dot) mode = S_IFDIR | (0755); mode &= POSIXMODEMASK; - + /* Botch: not all POSIX types supported yet */ assert(mode & (S_IFDIR|S_IFREG)); -chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name); +chat("writing PX record mode field %ulo with dot %d and name \"%s\"\n", mode, dot, d->name); - return mode; + return mode; } static long @@ -610,4 +610,3 @@ nlink(Direc *d) /* Trump up the nlink field for POSIX compliance */ return n; } - diff --git a/src/cmd/9660/util.c b/src/cmd/9660/util.c index ebf944e20..d3182775e 100644 --- a/src/cmd/9660/util.c +++ b/src/cmd/9660/util.c @@ -39,7 +39,7 @@ atom(char *str) { uint h; Stringtab *tab; - + h = hash(str) % nelem(stab); for(tab=stab[h]; tab; tab=tab->link) if(strcmp(str, tab->str) == 0) diff --git a/src/cmd/9660/write.c b/src/cmd/9660/write.c index 944053176..652927ca8 100644 --- a/src/cmd/9660/write.c +++ b/src/cmd/9660/write.c @@ -90,7 +90,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc) assert(start != 0); Cwseek(cd, start*Blocksize); - + s = md5(nil, 0, nil, nil); length = 0; while((n = Bread(b, buf, sizeof buf)) > 0) { @@ -123,7 +123,7 @@ writefiles(Dump *d, Cdimg *cd, Direc *direc) } /* - * Write a directory tree. We work from the leaves, + * Write a directory tree. We work from the leaves, * and patch the dotdot pointers afterward. */ static void diff --git a/src/cmd/9660srv/iobuf.c b/src/cmd/9660srv/iobuf.c index 01acd06aa..a0b934c09 100644 --- a/src/cmd/9660srv/iobuf.c +++ b/src/cmd/9660srv/iobuf.c @@ -14,7 +14,7 @@ * tarring up a Plan 9 distribution CD, we now use 16 128kb * buffers. This works for ISO9660 because data is required * to be laid out contiguously; effectively we're doing agressive - * readahead. Because the buffers are so big and the typical + * readahead. Because the buffers are so big and the typical * disk accesses so concentrated, it's okay that we have so few * of them. * diff --git a/src/cmd/9660srv/main.c b/src/cmd/9660srv/main.c index 44fdc5124..d4c32b8f3 100644 --- a/src/cmd/9660srv/main.c +++ b/src/cmd/9660srv/main.c @@ -138,13 +138,13 @@ main(int argc, char **argv) open("/dev/null", OWRITE); if(pipe(pipefd) < 0) panic(1, "pipe"); - + if(post9pservice(pipefd[0], srvname, mtpt) < 0) sysfatal("post9pservice: %r"); close(pipefd[0]); } srvfd = pipefd[1]; - + switch(rfork(RFNOWAIT|RFNOTEG|RFFDG|RFPROC)){ case -1: panic(1, "fork"); diff --git a/src/cmd/9660srv/xfile.c b/src/cmd/9660srv/xfile.c index c46adf21e..bebf0986d 100644 --- a/src/cmd/9660srv/xfile.c +++ b/src/cmd/9660srv/xfile.c @@ -167,4 +167,3 @@ clean(Xfile *f) f->qid = (Qid){0,0,0}; return f; } - diff --git a/src/cmd/9p.c b/src/cmd/9p.c index c8d4c4448..75511a194 100644 --- a/src/cmd/9p.c +++ b/src/cmd/9p.c @@ -94,7 +94,7 @@ threadmain(int argc, char **argv) threadexitsall(0); } } - usage(); + usage(); } CFsys* @@ -168,7 +168,7 @@ xread(int argc, char **argv) fsclose(fid); if(n < 0) sysfatal("read error: %r"); - threadexitsall(0); + threadexitsall(0); } void @@ -192,7 +192,7 @@ xreadfd(int argc, char **argv) sysfatal("write error: %r"); if(n < 0) sysfatal("read error: %r"); - threadexitsall(0); + threadexitsall(0); } void @@ -246,7 +246,7 @@ xwrite(int argc, char **argv) if(n < 0) sysfatal("read error: %r"); fsclose(fid); - threadexitsall(0); + threadexitsall(0); } void @@ -270,7 +270,7 @@ xwritefd(int argc, char **argv) sysfatal("write error: %r"); if(n < 0) sysfatal("read error: %r"); - threadexitsall(0); + threadexitsall(0); } void @@ -331,7 +331,7 @@ xrdwr(int argc, char **argv) fprint(2, "write: %r\n"); } fsclose(fid); - threadexitsall(0); + threadexitsall(0); } void @@ -346,10 +346,10 @@ xcreate(int argc, char **argv) default: usage(); }ARGEND - + if(argc == 0) usage(); - + for(i=0; iargs, ulong); @@ -470,7 +470,7 @@ static int dircmp(const void *va, const void *vb) { Dir *a, *b; - + a = (Dir*)va; b = (Dir*)vb; return strcmp(a->name, b->name); @@ -480,7 +480,7 @@ static int timecmp(const void *va, const void *vb) { Dir *a, *b; - + a = (Dir*)va; b = (Dir*)vb; if(a->mtime < b->mtime) @@ -520,12 +520,12 @@ xls(int argc, char **argv) tflag = 1; break; }ARGEND - + fmtinstall('D', dirfmt); fmtinstall('M', dirmodefmt); quotefmtinstall(); fmtinstall('T', timefmt); - + if(argc == 0){ argv = dot; argc = 1; @@ -600,4 +600,3 @@ xls(int argc, char **argv) } threadexitsall(err); } - diff --git a/src/cmd/9pfuse/errstr.c b/src/cmd/9pfuse/errstr.c index e03d9589a..e3a122e4c 100644 --- a/src/cmd/9pfuse/errstr.c +++ b/src/cmd/9pfuse/errstr.c @@ -55,7 +55,7 @@ errstr2errno(void) { char e[ERRMAX]; int i, len; - + if(errno != EPLAN9) return errno; @@ -70,4 +70,3 @@ errstr2errno(void) return errortab[i].err; return ERANGE; /* who knows - be blatantly wrong */ } - diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c index 66f66065d..4c9aac9bf 100644 --- a/src/cmd/9pfuse/fuse.c +++ b/src/cmd/9pfuse/fuse.c @@ -15,7 +15,7 @@ allocfusemsg(void) { FuseMsg *m; void *vbuf; - + lock(&fusemsglock); if((m = fusemsglist) != nil){ fusemsglist = m->next; @@ -46,7 +46,7 @@ readfusemsg(void) { FuseMsg *m; int n, nn; - + m = allocfusemsg(); /* * The FUSE kernel device apparently guarantees @@ -84,7 +84,7 @@ readfusemsg(void) sysfatal("readfusemsg: got %d wanted %d", n, m->hdr->len); m->hdr->len -= sizeof(*m->hdr); - + /* * Paranoia. * Make sure lengths are long enough. @@ -125,7 +125,7 @@ readfusemsg(void) if(((char*)m->tx)[m->hdr->len-1] != 0 || memchr(m->tx, 0, m->hdr->len-1) == 0) goto bad; - break; + break; case FUSE_MKNOD: if(m->hdr->len <= sizeof(struct fuse_mknod_in) || ((char*)m->tx)[m->hdr->len-1] != 0) @@ -219,7 +219,7 @@ readfusemsg(void) } /* - * Reply to FUSE request m using additonal + * Reply to FUSE request m using additonal * argument buffer arg of size narg bytes. * Perhaps should free the FuseMsg here? */ @@ -229,7 +229,7 @@ replyfuse(FuseMsg *m, void *arg, int narg) struct iovec vec[2]; struct fuse_out_header hdr; int nvec; - + hdr.len = sizeof hdr + narg; hdr.error = 0; hdr.unique = m->hdr->unique; @@ -255,7 +255,7 @@ void replyfuseerrno(FuseMsg *m, int e) { struct fuse_out_header hdr; - + hdr.len = sizeof hdr; hdr.error = -e; /* FUSE sends negative errnos. */ hdr.unique = m->hdr->unique; @@ -307,12 +307,12 @@ initfuse(char *mtpt) /* * Complain if the kernel is too new. * We could forge ahead, but at least the one time I tried, - * the kernel rejected the newer version by making the + * the kernel rejected the newer version by making the * writev fail in replyfuse, which is a much more confusing - * error message. In the future, might be nice to try to + * error message. In the future, might be nice to try to * support older versions that differ only slightly. */ - if(tx->major < FUSE_KERNEL_VERSION + if(tx->major < FUSE_KERNEL_VERSION || (tx->major == FUSE_KERNEL_VERSION && tx->minor < FUSE_KERNEL_MINOR_VERSION)) sysfatal("fuse: too kernel version %d.%d older than program version %d.%d", tx->major, tx->minor, FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); @@ -386,7 +386,7 @@ fusefmt(Fmt *fmt) } case FUSE_SYMLINK: { char *old, *new; - + old = a; new = a + strlen(a) + 1; fmtprint(fmt, "Symlink nodeid %#llux old %#q new %#q", @@ -455,7 +455,7 @@ fusefmt(Fmt *fmt) case FUSE_RELEASE: { struct fuse_release_in *tx = a; fmtprint(fmt, "Release nodeid %#llux fh %#llux flags %#ux", - hdr->nodeid, tx->fh, tx->flags); + hdr->nodeid, tx->fh, tx->flags); break; } case FUSE_FSYNC: { @@ -516,7 +516,7 @@ fusefmt(Fmt *fmt) case FUSE_RELEASEDIR: { struct fuse_release_in *tx = a; fmtprint(fmt, "Releasedir nodeid %#llux fh %#llux flags %#ux", - hdr->nodeid, tx->fh, tx->flags); + hdr->nodeid, tx->fh, tx->flags); break; } case FUSE_FSYNCDIR: { @@ -554,7 +554,7 @@ fusefmt(Fmt *fmt) case FUSE_LOOKUP: { /* * For a negative entry, can send back ENOENT - * or rx->ino == 0. + * or rx->ino == 0. * In protocol version 7.4 and before, can only use * the ENOENT method. * Presumably the benefit of sending rx->ino == 0 @@ -571,7 +571,7 @@ fusefmt(Fmt *fmt) rx->attr_valid+rx->attr_valid_nsec*1e-9); fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", rx->attr.ino, rx->attr.size, rx->attr.blocks, - rx->attr.atime+rx->attr.atimensec*1e-9, + rx->attr.atime+rx->attr.atimensec*1e-9, rx->attr.mtime+rx->attr.mtimensec*1e-9, rx->attr.ctime+rx->attr.ctimensec*1e-9, rx->attr.mode, rx->attr.nlink, rx->attr.uid, @@ -592,7 +592,7 @@ fusefmt(Fmt *fmt) rx->attr_valid+rx->attr_valid_nsec*1e-9); fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", rx->attr.ino, rx->attr.size, rx->attr.blocks, - rx->attr.atime+rx->attr.atimensec*1e-9, + rx->attr.atime+rx->attr.atimensec*1e-9, rx->attr.mtime+rx->attr.mtimensec*1e-9, rx->attr.ctime+rx->attr.ctimensec*1e-9, rx->attr.mode, rx->attr.nlink, rx->attr.uid, @@ -733,7 +733,7 @@ fusefmt(Fmt *fmt) rx->e.attr_valid+rx->e.attr_valid_nsec*1e-9); fmtprint(fmt, " ino %#llux size %lld blocks %lld atime %.20g mtime %.20g ctime %.20g mode %#uo nlink %d uid %d gid %d rdev %#ux", rx->e.attr.ino, rx->e.attr.size, rx->e.attr.blocks, - rx->e.attr.atime+rx->e.attr.atimensec*1e-9, + rx->e.attr.atime+rx->e.attr.atimensec*1e-9, rx->e.attr.mtime+rx->e.attr.mtimensec*1e-9, rx->e.attr.ctime+rx->e.attr.ctimensec*1e-9, rx->e.attr.mode, rx->e.attr.nlink, rx->e.attr.uid, @@ -753,7 +753,7 @@ fusefmt(Fmt *fmt) /* * Mounts a fuse file system on mtpt and returns - * a file descriptor for the corresponding fuse + * a file descriptor for the corresponding fuse * message conversation. */ int @@ -762,7 +762,7 @@ mountfuse(char *mtpt) #if defined(__linux__) int p[2], pid, fd; char buf[20]; - + if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0) return -1; pid = fork(); @@ -783,11 +783,11 @@ mountfuse(char *mtpt) #elif defined(__FreeBSD__) && !defined(__APPLE__) int pid, fd; char buf[20]; - + if((fd = open("/dev/fuse", ORDWR)) < 0) return -1; snprint(buf, sizeof buf, "%d", fd); - + pid = fork(); if(pid < 0) return -1; @@ -903,7 +903,7 @@ mountfuse(char *mtpt) _exit(1); } return fd; - + #else werrstr("cannot mount fuse on this system"); return -1; diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index a36628988..0d4adb08c 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -14,7 +14,7 @@ * writing the 9P connection. Thus the many threads in the * request proc can do 9P interactions without blocking. */ - + #define _GNU_SOURCE 1 /* for O_DIRECTORY on Linux */ #include "a.h" @@ -165,16 +165,16 @@ init9p(char *addr, char *spec) /* * FUSE uses nodeids to refer to active "struct inodes" * (9P's unopened fids). FUSE uses fhs to refer to active - * "struct fuse_files" (9P's opened fids). The choice of + * "struct fuse_files" (9P's opened fids). The choice of * numbers is up to us except that nodeid 1 is the root directory. - * We use the same number space for both and call the + * We use the same number space for both and call the * bookkeeping structure a FuseFid. * - * FUSE requires nodeids to have associated generation - * numbers. If we reuse a nodeid, we have to bump the + * FUSE requires nodeids to have associated generation + * numbers. If we reuse a nodeid, we have to bump the * generation number to guarantee that the nodeid,gen * combination is never reused. - * + * * There are also inode numbers returned in directory reads * and file attributes, but these do NOT need to match the nodeids. * We use a combination of qid.path and qid.type as the inode @@ -192,7 +192,7 @@ struct Fusefid int id; int gen; int isnodeid; - + /* directory read state */ Dir *d0; Dir *d; @@ -208,7 +208,7 @@ Fusefid* allocfusefid(void) { Fusefid *f; - + if((f = freefusefidlist) == nil){ f = emalloc(sizeof *f); fusefid = erealloc(fusefid, (nfusefid+1)*sizeof *fusefid); @@ -247,7 +247,7 @@ uvlong _alloc(CFid *fid, int isnodeid) { Fusefid *ff; - + ff = allocfusefid(); ff->fid = fid; ff->isnodeid = isnodeid; @@ -283,7 +283,7 @@ CFid* _lookupcfid(uvlong id, int isnodeid) { Fusefid *ff; - + if((ff = lookupfusefid(id, isnodeid)) == nil) return nil; return ff->fid; @@ -360,7 +360,7 @@ fuselookup(FuseMsg *m) CFid *fid, *newfid; Dir *d; struct fuse_entry_out out; - + name = m->tx; if((fid = nodeid2fid(m->hdr->nodeid)) == nil){ replyfuseerrno(m, ESTALE); @@ -392,7 +392,7 @@ fuselookup(FuseMsg *m) /* * Forget. Reference-counted clunk for nodeids. * Does not send a reply. - * Each lookup response gives the kernel an additional reference + * Each lookup response gives the kernel an additional reference * to the returned nodeid. Forget says "drop this many references * to this nodeid". Our fuselookup, when presented with the same query, * does not return the same results (it allocates a new nodeid for each @@ -423,7 +423,7 @@ fuseforget(FuseMsg *m) * Getattr. * Replies with a fuse_attr_out structure giving the * attr for the requested nodeid in out.attr. - * Out.attr_valid and out.attr_valid_nsec give + * Out.attr_valid and out.attr_valid_nsec give * the amount of time that the attributes can * be cached. * @@ -479,7 +479,7 @@ fusesetattr(FuseMsg *m) /* * Special case: Linux issues a size change to * truncate a file before opening it OTRUNC. - * Synthetic file servers (e.g., plumber) honor + * Synthetic file servers (e.g., plumber) honor * open(OTRUNC) but not wstat. */ if(in->valid == FATTR_SIZE && in->size == 0){ @@ -554,7 +554,7 @@ _fuseopenfid(uvlong nodeid, int isdir, int openmode, int *err) *err = errstr2errno(); return nil; } - + if(fsfopen(newfid, openmode) < 0){ *err = errstr2errno(); fsclose(newfid); @@ -617,7 +617,7 @@ _fuseopen(FuseMsg *m, int isdir) return; } out.fh = allocfh(fid); - out.open_flags = FOPEN_DIRECT_IO; /* no page cache */ + out.open_flags = FOPEN_DIRECT_IO; /* no page cache */ replyfuse(m, &out, sizeof out); } @@ -696,7 +696,7 @@ fusemkdir(FuseMsg *m) CFid *fid; int err; char *name; - + in = m->tx; name = (char*)(in+1); if((fid = _fusecreate(m->hdr->nodeid, name, in->mode, 1, OREAD, &out, &err)) == nil){ @@ -716,7 +716,7 @@ fusecreate(FuseMsg *m) CFid *fid; int err, openmode, flags; char *name; - + in = m->tx; flags = in->flags; openmode = in->flags&3; @@ -740,7 +740,7 @@ fusecreate(FuseMsg *m) } /* - * Access. + * Access. * Lib9pclient implements this just as Plan 9 does, * by opening the file (or not) and then closing it. */ @@ -760,7 +760,7 @@ fuseaccess(FuseMsg *m) ORDWR, ORDWR }; - + in = m->tx; if(in->mask >= nelem(a2o)){ replyfuseerrno(m, EINVAL); @@ -791,7 +791,7 @@ fuserelease(FuseMsg *m) { struct fuse_release_in *in; Fusefid *ff; - + in = m->tx; if((ff = lookupfusefid(in->fh, 0)) != nil) freefusefid(ff); @@ -864,7 +864,7 @@ fusereadlink(FuseMsg *m) return; } -/* +/* * Readdir. * Read from file handle in->fh at offset in->offset for size in->size. * We truncate size to maxwrite just to keep the buffer reasonable. @@ -884,12 +884,12 @@ fusereaddir(FuseMsg *m) uchar *buf, *p, *ep; int n; Fusefid *ff; - + in = m->tx; if((ff = lookupfusefid(in->fh, 0)) == nil){ replyfuseerrno(m, ESTALE); return; - } + } if(in->offset == 0){ fsseek(ff->fid, 0, 0); free(ff->d0); @@ -922,7 +922,7 @@ fusereaddir(FuseMsg *m) break; ff->d = ff->d0; } -out: +out: replyfuse(m, buf, p - buf); free(buf); } @@ -958,7 +958,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep) uchar *p; struct fuse_dirent *de; int pad, size; - + p = *pp; size = FUSE_NAME_OFFSET + strlen(d->name); pad = 0; @@ -981,7 +981,7 @@ canpack(Dir *d, uvlong off, uchar **pp, uchar *ep) * Write. * Write from file handle in->fh at offset in->offset for size in->size. * Don't know what in->write_flags means. - * + * * Apparently implementations are allowed to buffer these writes * and wait until Flush is sent, but FUSE docs say flush may be * called zero, one, or even more times per close. So better do the @@ -996,7 +996,7 @@ fusewrite(FuseMsg *m) void *a; CFid *fid; int n; - + in = m->tx; a = in+1; if((fid = fh2fid(in->fh)) == nil){ @@ -1018,7 +1018,7 @@ fusewrite(FuseMsg *m) /* * Flush. Supposed to flush any buffered writes. Don't use this. - * + * * Flush is a total crock. It gets called on close() of a file descriptor * associated with this open file. Some open files have multiple file * descriptors and thus multiple closes of those file descriptors. @@ -1027,7 +1027,7 @@ fusewrite(FuseMsg *m) * closed explicitly. For those files, Flush is never called. * Even more amusing, Flush gets called before close() of read-only * file descriptors too! - * + * * This is just a bad idea. */ void @@ -1044,7 +1044,7 @@ _fuseremove(FuseMsg *m, int isdir) { char *name; CFid *fid, *newfid; - + name = m->tx; if((fid = nodeid2fid(m->hdr->nodeid)) == nil){ replyfuseerrno(m, ESTALE); @@ -1105,7 +1105,7 @@ fuserename(FuseMsg *m) char *before, *after; CFid *fid, *newfid; Dir d; - + in = m->tx; if(in->newdir != m->hdr->nodeid){ replyfuseerrno(m, EXDEV); @@ -1146,7 +1146,7 @@ fusefsync(FuseMsg *m) struct fuse_fsync_in *in; CFid *fid; Dir d; - + in = m->tx; if((fid = fh2fid(in->fh)) == nil){ replyfuseerrno(m, ESTALE); @@ -1181,7 +1181,7 @@ void fusestatfs(FuseMsg *m) { struct fuse_statfs_out out; - + memset(&out, 0, sizeof out); replyfuse(m, &out, sizeof out); } @@ -1215,7 +1215,7 @@ struct { { FUSE_FSYNC, fusefsync }, /* * FUSE_SETXATTR, FUSE_GETXATTR, FUSE_LISTXATTR, and - * FUSE_REMOVEXATTR are unimplemented. + * FUSE_REMOVEXATTR are unimplemented. * FUSE will stop sending these requests after getting * an -ENOSYS reply (see dispatch below). */ @@ -1237,7 +1237,7 @@ fusethread(void *v) FuseMsg *m; m = v; - if((uint)m->hdr->opcode >= nelem(fusehandlers) + if((uint)m->hdr->opcode >= nelem(fusehandlers) || !fusehandlers[m->hdr->opcode]){ replyfuseerrno(m, ENOSYS); return; @@ -1267,7 +1267,7 @@ fusedispatch(void *v) case FUSE_FORGET: fusehandlers[m->hdr->opcode](m); break; - default: + default: threadcreate(fusethread, m, STACK); } } diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c index 24c807148..255bcbb25 100644 --- a/src/cmd/9pserve.c +++ b/src/cmd/9pserve.c @@ -185,7 +185,7 @@ threadmain(int argc, char **argv) logging++; break; }ARGEND - + if(attached && !versioned){ fprint(2, "-A must be used with -M\n"); usage(); @@ -258,7 +258,7 @@ mainproc(void *v) /* if(rootfid) */ /* dorootstat(); */ - + threadcreate(listenthread, nil, STACK); threadexits(0); } @@ -302,7 +302,7 @@ listenthread(void *arg) c->outqdead = chancreate(sizeof(void*), 0); if(verbose) fprint(2, "%T incoming call on %s\n", c->dir); threadcreate(connthread, c, STACK); - } + } } void @@ -348,7 +348,7 @@ char* estrdup(char *s) { char *t; - + t = emalloc(strlen(s)+1); strcpy(t, s); return t; @@ -713,7 +713,7 @@ openfdthread(void *v) chanfree(c->internal); c->internal = 0; free(c); -} +} int xopenfd(Msg *m) @@ -868,7 +868,7 @@ outputthread(void *arg) closeioproc(io); fprint(2, "%T output eof\n"); threadexitsall(0); -} +} void inputthread(void *arg) @@ -1041,7 +1041,7 @@ msgnew(int x) * Clear data associated with connections, so that * if all msgs have been msgcleared, the connection * can be freed. Note that this does *not* free the tpkt - * and rpkt; they are freed in msgput with the msg itself. + * and rpkt; they are freed in msgput with the msg itself. * The io write thread might still be holding a ref to msg * even once the connection has finished with it. */ @@ -1080,7 +1080,7 @@ msgput(Msg *m) if(m == nil) return; - if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n", + if(verbose > 1) fprint(2, "%T msgput 0x%lux %p tag %d/%d ref %d\n", getcallerpc(&m), m, m->tag, m->ctag, m->ref); assert(m->ref > 0); if(--m->ref > 0) @@ -1296,7 +1296,7 @@ repack(Fcall *f, uchar **ppkt) { uint n, nn; uchar *pkt; - + pkt = *ppkt; n = GBIT32(pkt); nn = sizeS2M(f); @@ -1305,7 +1305,7 @@ repack(Fcall *f, uchar **ppkt) pkt = emalloc(nn); *ppkt = pkt; } - n = convS2M(f, pkt, nn); + n = convS2M(f, pkt, nn); if(n <= BIT16SZ) sysfatal("convS2M conversion error"); if(n != nn) @@ -1401,13 +1401,13 @@ ioaccept(Ioproc *io, int fd, char *dir) int timefmt(Fmt *fmt) { - static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; vlong ns; Tm tm; ns = nsec(); tm = *localtime(time(0)); - return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", + return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, (int)(ns%1000000000)/1000000); } diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index 81c39a635..b28f44faf 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -51,13 +51,13 @@ void threadmain(int argc, char *argv[]) { char *p; - + rfork(RFNOTEG); font = nil; _wantfocuschanges = 1; mainpid = getpid(); messagesize = 8192; - + ARGBEGIN{ default: usage(); @@ -80,7 +80,7 @@ threadmain(int argc, char *argv[]) winsize = EARGF(usage()); break; }ARGEND - + if(fontname) putenv("font", fontname); @@ -92,7 +92,7 @@ threadmain(int argc, char *argv[]) if(maxtab <= 0) maxtab = 4; free(p); - + startdir = "."; if(initdraw(derror, fontname, "9term") < 0) @@ -100,7 +100,7 @@ threadmain(int argc, char *argv[]) notify(hangupnote); noteenable("sys: child"); - + mousectl = initmouse(nil, screen); if(mousectl == nil) error("cannot find mouse"); @@ -181,13 +181,13 @@ void resizethread(void *v) { Point p; - + USED(v); - + for(;;){ p = stringsize(display->defaultfont, "0"); if(p.x && p.y) - updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x, + updatewinsize(Dy(screen->r)/p.y, (Dx(screen->r)-Scrollwid-2)/p.x, Dx(screen->r), Dy(screen->r)); wresize(w, screen, 0); flushimage(display, 1); @@ -197,7 +197,7 @@ resizethread(void *v) sysfatal("can't reattach to window"); } } - + void mousethread(void *v) { @@ -229,7 +229,7 @@ mousethread(void *v) bouncemouse(mouse); } } - + void wborder(Window *w, int type) { @@ -405,7 +405,7 @@ rcoutputproc(void *arg) Conswritemesg cwm; Rune *r; Stringpair pair; - + i = 0; cnt = 0; for(;;){ @@ -432,11 +432,11 @@ rcoutputproc(void *arg) if(nb < cnt) memmove(data, data+nb, cnt-nb); cnt -= nb; - + nr = label(r, nr); if(nr == 0) continue; - + recv(w->conswrite, &cwm); pair.s = r; pair.ns = nr; @@ -448,7 +448,7 @@ void winterrupt(Window *w) { char rubout[1]; - + USED(w); rubout[0] = getintr(sfd); write(rcfd, rubout, 1); @@ -474,7 +474,7 @@ label(Rune *sr, int n) { Rune *sl, *el, *er, *r; char *p, *dir; - + er = sr+n; for(r=er-1; r>=sr; r--) if(*r == '\007') @@ -527,7 +527,7 @@ rcinputproc(void *arg) recv(w->consread, &crm); c1 = crm.c1; c2 = crm.c2; - + pair.s = data; pair.ns = sizeof data; send(c1, &pair); @@ -547,7 +547,7 @@ void rioputsnarf(void) { char *s; - + s = smprint("%.*S", nsnarf, snarf); if(s){ putsnarf(s); @@ -648,7 +648,7 @@ textproc(void *arg) for(x=0; x= end) break; p = buf; @@ -664,4 +664,3 @@ textproc(void *arg) break2: close(fd); } - diff --git a/src/cmd/9term/SunOS.c b/src/cmd/9term/SunOS.c index e0f866ab5..73914a674 100644 --- a/src/cmd/9term/SunOS.c +++ b/src/cmd/9term/SunOS.c @@ -84,4 +84,3 @@ getintr(int fd) return 0x7F; return ttmode.c_cc[VINTR]; } - diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c index 31281325a..d64e4c2fc 100644 --- a/src/cmd/9term/bsdpty.c +++ b/src/cmd/9term/bsdpty.c @@ -20,7 +20,7 @@ static char *abc = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789"; -static char *_123 = +static char *_123 = "0123456789" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -111,4 +111,3 @@ getintr(int fd) return 0x7F; return ttmode.c_cc[VINTR]; } - diff --git a/src/cmd/9term/dat.h b/src/cmd/9term/dat.h index 25270a0e3..a215253fb 100644 --- a/src/cmd/9term/dat.h +++ b/src/cmd/9term/dat.h @@ -91,8 +91,8 @@ struct Mouseinfo ulong counter; /* serial no. of last mouse event we received */ ulong lastcounter; /* serial no. of last mouse event sent to client */ int lastb; /* last button state we received */ - uchar qfull; /* filled the queue; no more recording until client comes back */ -}; + uchar qfull; /* filled the queue; no more recording until client comes back */ +}; struct Window { diff --git a/src/cmd/9term/data.c b/src/cmd/9term/data.c index e0f18e873..4c2a76020 100644 --- a/src/cmd/9term/data.c +++ b/src/cmd/9term/data.c @@ -48,121 +48,121 @@ Cursor sightcursor = { Cursor whitearrow = { {0, 0}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, - 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, - 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, + 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, }, - {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C, - 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C, - 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C, + {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C, + 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C, + 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C, 0xD3, 0xB8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, } }; Cursor query = { {-7,-7}, - {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, - 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, - 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, + {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, + 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, + 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, }, - {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, - 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, - 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, + {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, + 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, + 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } }; Cursor tl = { {-4, -4}, - {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff, - 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff, - 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff, + 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff, + 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x1f, 0x00, }, - {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00, - 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00, - 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00, + 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00, + 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, } }; Cursor t = { {-7, -8}, - {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, - 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, + {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, + 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, - 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, + 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } }; Cursor tr = { {-11, -4}, - {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1, - 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88, - 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88, + {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1, + 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88, + 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xf8, }, - {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e, - 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70, - 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e, + 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70, + 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, } }; Cursor r = { {-8, -7}, - {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58, - 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02, - 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58, + {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58, + 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02, + 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58, 0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x07, 0xc0, }, - {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, - 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc, - 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80, + {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, + 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc, + 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } }; Cursor br = { {-11, -11}, - {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, - 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, - 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05, + {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, + 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, + 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05, 0xff, 0xe1, 0x00, 0x31, 0x00, 0x41, 0x00, 0x7f, }, - {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, - 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, - 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa, + {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0x00, } }; Cursor b = { {-7, -7}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, - 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, + 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70, 0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, }, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, - 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, + 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } }; Cursor bl = { {-4, -11}, - {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, - 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, - 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01, + {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01, 0x87, 0xff, 0x8c, 0x00, 0x82, 0x00, 0xfe, 0x00, }, - {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, - 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, - 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe, + {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe, 0x78, 0x00, 0x70, 0x00, 0x7c, 0x00, 0x00, 0x0, } }; Cursor l = { {-7, -7}, - {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20, - 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20, - 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20, + {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20, + 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20, + 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x03, 0xe0, }, - {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, - 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0, + {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, + 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, + 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, } }; diff --git a/src/cmd/9term/fns.h b/src/cmd/9term/fns.h index 34cebf01e..fd0bd74a3 100644 --- a/src/cmd/9term/fns.h +++ b/src/cmd/9term/fns.h @@ -39,4 +39,3 @@ int intrc(void); void rioputsnarf(void); void riogetsnarf(void); - diff --git a/src/cmd/9term/malloc.c b/src/cmd/9term/malloc.c index 130942bdc..9132235b3 100644 --- a/src/cmd/9term/malloc.c +++ b/src/cmd/9term/malloc.c @@ -13,7 +13,7 @@ void* p9malloc(ulong n) { void *v; - + if(n == 0) n++; lock(&malloclock); @@ -38,7 +38,7 @@ void* p9calloc(ulong a, ulong b) { void *v; - + if(a*b == 0) a = b = 1; @@ -53,11 +53,10 @@ void* p9realloc(void *v, ulong n) { void *vv; - + lock(&malloclock); vv = realloc(v, n); unlock(&malloclock); print("p9realloc %p %lud => %p; pc %lux\n", v, n, vv, getcallerpc(&v)); return vv; } - diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c index fddabc6de..a447036d4 100644 --- a/src/cmd/9term/rcstart.c +++ b/src/cmd/9term/rcstart.c @@ -69,15 +69,15 @@ rcstart(int argc, char **argv, int *pfd, int *tfd) } /* * notedisable("sys: window size change"); - * + * * Can't disable because will be inherited by other programs * like if you run an xterm from the prompt, and then xterm's - * resizes won't get handled right. Sigh. + * resizes won't get handled right. Sigh. * * Can't not disable because when we stty below we'll get a * signal, which will drop us into the thread library note handler, * which will get all confused because we just forked and thus - * have an unknown pid. + * have an unknown pid. * * So disable it internally. ARGH! */ @@ -145,7 +145,7 @@ echoed(char *p, int n) if(echo.w+n > sizeof echo.buf) n = 0; memmove(echo.buf+echo.w, p, n); - echo.w += n; + echo.w += n; unlock(&echo.l); } diff --git a/src/cmd/9term/util.c b/src/cmd/9term/util.c index 8a35d1d75..32ea08b62 100644 --- a/src/cmd/9term/util.c +++ b/src/cmd/9term/util.c @@ -146,4 +146,3 @@ runetobyte(Rune *r, int n, int *ip) *ip = m; return s; } - diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c index 017d546b4..9c7a12eb6 100644 --- a/src/cmd/9term/win.c +++ b/src/cmd/9term/win.c @@ -134,7 +134,7 @@ threadmain(int argc, char **argv) char buf1[128]; CFsys *fs; char *dump; - + dump = onestring(argc, argv); ARGBEGIN{ @@ -215,7 +215,7 @@ threadmain(int argc, char **argv) fswrite(ctlfd, buf, strlen(buf)); sprint(buf, "scroll"); fswrite(ctlfd, buf, strlen(buf)); - + updatewinsize(25, 80, 0, 0); proccreate(stdoutproc, nil, STACK); stdinproc(nil); @@ -225,7 +225,7 @@ void error(char *s, ...) { va_list arg; - + if(s){ va_start(arg, s); s = vsmprint(s, arg); @@ -378,11 +378,11 @@ stdinproc(void *v) fprint(2, "shift typing %d... ", e.q1-e.q0); q.p += e.q1-e.q0; break; - + case 'i': case 'd': /* tag */ break; - + default: goto Unknown; } @@ -484,7 +484,7 @@ dropcr(char *p, int n) { int i; char *w, *r, *q; - + r = p; w = p; for(i=0; i 0 && buf[i-1] == ' ') i--; @@ -743,7 +743,7 @@ void sendtype(int fd0) { int i, n, nr, raw; - + raw = israw(fd0); while(ntypebreak || (raw && ntypeb > 0)){ for(i=0; iname, "window.%d.%d", w->id, w->namecount++); for(i='A'; i<='Z'; i++){ if(nameimage(w->i, w->name, 1) > 0) @@ -224,7 +224,7 @@ winctl(void *arg) crm.c2 = chancreate(sizeof(Stringpair), 0); cwrm.c1 = chancreate(sizeof(Stringpair), 0); cwrm.c2 = chancreate(sizeof(Stringpair), 0); - + alts[WKey].c = w->ck; alts[WKey].v = &kbdr; @@ -803,7 +803,7 @@ wbswidth(Window *w, Rune c) if(r == '\n'){ /* eat at most one more character */ if(q == w->q0 && c != '\r') /* eat the newline */ --q; - break; + break; } if(c == 0x17){ eq = isalnum(r); @@ -1382,15 +1382,15 @@ wsetpid(Window *w, int pid, int dolabel) } } -static Rune left1[] = { +static Rune left1[] = { '{', '[', '(', '<', 0xAB, - 0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea, - 0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b, + 0x207d, 0x2329, 0x27e6, 0x27e8, 0x27ea, + 0xfe59, 0xfe5b, 0xfe5d, 0xff08, 0xff3b, 0xff5b, 0 }; static Rune right1[] = { '}', ']', ')', '>', 0xBB, - 0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb, + 0x207e, 0x232a, 0x27e7, 0x27e9, 0x27eb, 0xfe5a, 0xfe5c, 0xfe5e, 0xff09, 0xff3d, 0xff5d, 0 }; diff --git a/src/cmd/acid/builtin.c b/src/cmd/acid/builtin.c index ddc326a48..be387abeb 100644 --- a/src/cmd/acid/builtin.c +++ b/src/cmd/acid/builtin.c @@ -635,7 +635,7 @@ includepipe(Node *r, Node *args) if(pipe(pip) < 0) error("pipe: %r"); - + pid = fork(); switch(pid) { case -1: @@ -657,7 +657,7 @@ includepipe(Node *r, Node *args) close(pip[1]); pushfd(pip[0]); - + isave = interactive; interactive = 0; r->store.u.ival = yyparse(); @@ -746,7 +746,7 @@ doaccess(Node *r, Node *args) r->op = OCONST; r->type = TINT; r->store.fmt = 'D'; - r->store.u.ival = 0; + r->store.u.ival = 0; if(access(res.store.u.string->string, 4) == 0) r->store.u.ival = 1; } @@ -974,7 +974,7 @@ map(Node *r, Node *args) i = findseg(m, nam, fil); } if(i < 0) - error("%s %s is not a map entry", nam, fil); + error("%s %s is not a map entry", nam, fil); l = l->next; if(l->type != TINT) error("map entry not int"); @@ -1008,7 +1008,7 @@ map(Node *r, Node *args) } } -void +void flatten(Node **av, Node *n) { if(n == 0) @@ -1086,7 +1086,7 @@ strace(Node *r, Node *args) l = l->next; } regs.rw = straceregrw; - + tracelist = 0; if(stacktrace(cormap, ®s, trlist) <= 0) error("no stack frame"); @@ -1482,7 +1482,7 @@ pcfile(Node *r, Node *args) if(p == 0) error("pcfile(addr): funny file %s", buf); *p = '\0'; - r->store.u.string = strnode(buf); + r->store.u.string = strnode(buf); } void @@ -1507,7 +1507,7 @@ pcline(Node *r, Node *args) p = strrchr(buf, ':'); if(p == 0) error("pcline(addr): funny file %s", buf); - r->store.u.ival = atoi(p+1); + r->store.u.ival = atoi(p+1); } void diff --git a/src/cmd/acid/dot.c b/src/cmd/acid/dot.c index fd4464925..80ec2d020 100644 --- a/src/cmd/acid/dot.c +++ b/src/cmd/acid/dot.c @@ -46,9 +46,9 @@ odot(Node *n, Node *r) error("no tag for (expr).%s", s); /* Propagate types */ - if(t->type) + if(t->type) r->store.comt = t->type->lt; - + addr = res.store.u.ival+t->offset; if(t->fmt == 'a') { r->op = OCONST; @@ -56,7 +56,7 @@ odot(Node *n, Node *r) r->type = TINT; r->store.u.ival = addr; } - else + else indir(cormap, addr, t->fmt, r); } @@ -74,7 +74,7 @@ buildtype(Node *m, int d) switch(m->op) { case OLIST: - buildtype(m->left, d); + buildtype(m->left, d); buildtype(m->right, d); break; @@ -90,7 +90,7 @@ buildtype(Node *m, int d) t->offset = m->store.u.ival; if(m->left) { t->type = m->left->sym; - t->fmt = 'a'; + t->fmt = 'a'; } else { t->type = 0; @@ -101,7 +101,7 @@ buildtype(Node *m, int d) *tail = t; tail = &t->next; - } + } } void diff --git a/src/cmd/acid/expr.c b/src/cmd/acid/expr.c index 088b98f84..dc2f59c76 100644 --- a/src/cmd/acid/expr.c +++ b/src/cmd/acid/expr.c @@ -74,7 +74,7 @@ chklval(Node *lp) if(lp->op == OCALL){ s = chklval(lp->left); - if(strcmp(s->name, "var") == 0 + if(strcmp(s->name, "var") == 0 && (lp->builtin || s->proc == 0)){ if(lp->right == 0) error("var(string): arg count"); @@ -85,7 +85,7 @@ chklval(Node *lp) } } error("need l-value"); - return nil; + return nil; } void @@ -177,7 +177,7 @@ oframe(Node *n, Node *res) lp = n->left; if(localaddr(cormap, acidregs, p, lp->sym->name, &ival) < 0) error("colon: %r"); - + res->store.u.ival = ival; res->op = OCONST; res->store.fmt = 'X'; @@ -397,7 +397,7 @@ oadd(Node *n, Node *res) if(r.type == TSTRING) { res->type = TSTRING; res->store.fmt = 's'; - res->store.u.string = stradd(l.store.u.string, r.store.u.string); + res->store.u.string = stradd(l.store.u.string, r.store.u.string); break; } error("bad rhs for +"); @@ -916,7 +916,7 @@ oeinc(Node *n, Node *res) v->store.u.ival -= fmtsize(v); else v->store.u.ival += fmtsize(v); - break; + break; case TFLOAT: if(n->op == OEDEC) v->store.u.fval--; @@ -944,7 +944,7 @@ opinc(Node *n, Node *res) v->store.u.ival -= fmtsize(v); else v->store.u.ival += fmtsize(v); - break; + break; case TFLOAT: if(n->op == OPDEC) v->store.u.fval--; diff --git a/src/cmd/acid/lex.c b/src/cmd/acid/lex.c index 19581eab3..90e23f787 100644 --- a/src/cmd/acid/lex.c +++ b/src/cmd/acid/lex.c @@ -61,7 +61,7 @@ kinit(void) initcmap(); - for(i = 0; keywds[i].name; i++) + for(i = 0; keywds[i].name; i++) enter(keywds[i].name, keywds[i].terminal); } @@ -415,7 +415,7 @@ yylex(void) return numsym('.'); return '.'; - + case '(': case ')': case '[': @@ -671,7 +671,7 @@ delsym(Lsym *s) for(q = s->name; *q; q++) h = h*3 + *q; h %= Hashsize; - + if(hash[h] == s) hash[h] = s->hash; else{ diff --git a/src/cmd/acid/list.c b/src/cmd/acid/list.c index 2c26426e2..af9f77ae6 100644 --- a/src/cmd/acid/list.c +++ b/src/cmd/acid/list.c @@ -54,7 +54,7 @@ build(Node *n) l = al(res.type); l->store = res.store; *tail = l; - tail = &l->next; + tail = &l->next; } } diff --git a/src/cmd/acid/main.c b/src/cmd/acid/main.c index 59ae90b1c..ba3ce46e5 100644 --- a/src/cmd/acid/main.c +++ b/src/cmd/acid/main.c @@ -92,7 +92,7 @@ main(int argc, char *argv[]) default: usage(); }ARGEND - + USED(pid); fmtinstall('Z', Zfmt); @@ -198,7 +198,7 @@ attachfiles(int argc, char **argv) pid = 0; interactive = 0; USED(pid); - + if(setjmp(err)) return -1; diff --git a/src/cmd/acid/proc.c b/src/cmd/acid/proc.c index e6efc95a0..ff37cd5f3 100644 --- a/src/cmd/acid/proc.c +++ b/src/cmd/acid/proc.c @@ -29,7 +29,7 @@ sproc(int xpid) free(correg); correg = regs; }else{ - /* XXX should only change register set here if cormap already mapped */ + /* XXX should only change register set here if cormap already mapped */ if(xpid <= 0) error("bad pid"); unmapproc(cormap); @@ -245,4 +245,3 @@ getstatus(int pid) { return "unknown"; } - diff --git a/src/cmd/acid/util.c b/src/cmd/acid/util.c index 29db6d8bc..e44cb5e2f 100644 --- a/src/cmd/acid/util.c +++ b/src/cmd/acid/util.c @@ -40,7 +40,7 @@ unique(char *buf, Symbol *s) if(l == 0) l = enter(buf, Tid); s->aux = l; - return l; + return l; } void @@ -122,22 +122,22 @@ addvarsym(Fhdr *fp) tl->store.u.l = list; list->store.u.string = strnode(buf); list->store.fmt = 's'; - + list->next = al(TINT); list = list->next; list->store.fmt = 'c'; list->store.u.ival = s.type; - + list->next = al(TINT); list = list->next; list->store.fmt = 'X'; list->store.u.ival = v; - + list->next = al(TSTRING); list = list->next; list->store.fmt = 's'; list->store.u.string = file; - + list->next = al(TSTRING); list = list->next; list->store.fmt = 's'; diff --git a/src/cmd/acidtypes/dat.h b/src/cmd/acidtypes/dat.h index 8a043787c..97b3a1665 100644 --- a/src/cmd/acidtypes/dat.h +++ b/src/cmd/acidtypes/dat.h @@ -9,7 +9,7 @@ enum Base, Enum, Aggr, - Function, + Function, Pointer, Array, Range, @@ -92,4 +92,3 @@ int Bfmt(Fmt*); #ifdef VARARGCK #pragma varargck type "B" char* #endif - diff --git a/src/cmd/acidtypes/dwarf.c b/src/cmd/acidtypes/dwarf.c index f92942865..cb39fcbf8 100644 --- a/src/cmd/acidtypes/dwarf.c +++ b/src/cmd/acidtypes/dwarf.c @@ -183,4 +183,3 @@ ds2acid(Dwarf *d, DwarfSym *s, Biobuf *b, char *fn) break; } } - diff --git a/src/cmd/acidtypes/main.c b/src/cmd/acidtypes/main.c index f272f67a9..eb1a94182 100644 --- a/src/cmd/acidtypes/main.c +++ b/src/cmd/acidtypes/main.c @@ -64,7 +64,7 @@ main(int argc, char **argv) } have = 1; } - + if(!have){ Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]); /* fprint(2, "no debugging symbols in %s\n", argv[i]); */ @@ -75,4 +75,3 @@ main(int argc, char **argv) Bterm(&b); exits(0); } - diff --git a/src/cmd/acidtypes/stabs.c b/src/cmd/acidtypes/stabs.c index 5ce0d4611..0ca3b73f0 100644 --- a/src/cmd/acidtypes/stabs.c +++ b/src/cmd/acidtypes/stabs.c @@ -192,7 +192,7 @@ parsenum(char *p, int *n1, int *n2, char **pp) /* attr ::= '@' text ';' - text is + text is 'a' integer (alignment) 'p' integer (pointer class) 'P' (packed type) @@ -237,7 +237,7 @@ static Basic baseints[] = /*13*/ 8, 'f', /* double */ /*14*/ 10, 'f', /* long double */ /*15*/ 4, 'd', /* int32 */ -/*16*/ 4, 'd', /* bool32 */ +/*16*/ 4, 'd', /* bool32 */ /*17*/ 2, 'f', /* short real */ /*18*/ 4, 'f', /* real */ /*19*/ 4, 'x', /* stringptr */ @@ -391,7 +391,7 @@ parsedefn(char *p, Type *t, char **pp) t->ty = Pointer; t->sub = parseinfo(p+1, &p); break; - case 'a': /* array */ + case 'a': /* array */ case 'P': /* packed array */ t->ty = Pointer; tt = newtype(); @@ -422,7 +422,7 @@ parsedefn(char *p, Type *t, char **pp) } semi(&p); break; - + case 's': /* struct */ case 'u': /* union */ p++; @@ -532,7 +532,7 @@ parsedefn(char *p, Type *t, char **pp) } /* - bound ::= + bound ::= 'A' offset (bound is on stack by ref at offset offset from arg list) | 'T' offset (bound is on stack by val at offset offset from arg list) | 'a' regnum (bound passed by reference in register) @@ -642,7 +642,7 @@ stabs2acid(Stab *stabs, Biobuf *b) fno++; if((f = findftypes(dir, sym.name)) == nil){ static int cannotprint; - + if(cannotprint++ == 0) fprint(2, "cannot find remembered %s\n", sym.name); continue; @@ -673,7 +673,7 @@ stabs2acid(Stab *stabs, Biobuf *b) } if(setjmp(kaboom)){ static int cannotparse; - + if(cannotparse++ == 0) fprint(2, "cannot parse %s\n", name); continue; @@ -683,7 +683,7 @@ stabs2acid(Stab *stabs, Biobuf *b) continue; if(*p != 0){ static int extradesc; - + if(extradesc++ == 0) fprint(2, "extra desc '%s' in '%s'\n", p, desc); } diff --git a/src/cmd/acidtypes/type.c b/src/cmd/acidtypes/type.c index 00897e346..0f1c2f309 100644 --- a/src/cmd/acidtypes/type.c +++ b/src/cmd/acidtypes/type.c @@ -95,7 +95,7 @@ typebynum(uint n1, uint n2) t->n2 = n2; addhash(t); return t; -} +} Type* newtype(void) @@ -251,10 +251,10 @@ cleanstl(char *name) { char *b, *p; static char buf[65536]; /* These can be huge. */ - + if(strchr(name, '<') == nil) return nonempty(name); - + b = buf; for(p = name; *p != 0; p++){ switch(*p){ @@ -443,7 +443,7 @@ char* mkname(char *prefix, char *name) { static char buf[65536]; - + snprint(buf, sizeof buf, "%s%s", prefix, name); return buf; } @@ -630,7 +630,7 @@ ttt=ttt->sub; if(nprint == 0) Bprint(b, "\t'X' 0 __dummy;\n"); Bprint(b, "};\n\n"); - + name = nameof(t, 1); /* might have smashed it */ Bprint(b, "defn %B(addr) { %B(addr, \"\"); }\n", name, mkname("indent_", name)); Bprint(b, "defn %B(addr, indent) {\n", mkname("indent_", name)); @@ -675,13 +675,13 @@ ttt=ttt->sub; } Bprint(b, "};\n\n"); break; - + case Enum: name = nameof(t, 1); Bprint(b, "// enum %s\n", name); for(j=0; jn; j++) Bprint(b, "%B = %ld;\n", fixname(t->tname[j]), t->val[j]); - + Bprint(b, "%B = {\n", mkname("vals_", name)); for(j=0; jn; j++) Bprint(b, "\t%lud,\n", t->val[j]); @@ -738,7 +738,7 @@ printtypes(Biobuf *b) * only take one type of a given name; acid is going to do this anyway, * and this will reduce the amount of code we output considerably. * we could run a DFA equivalence relaxation sort of algorithm - * to find the actual equivalence classes, and then rename types + * to find the actual equivalence classes, and then rename types * appropriately, but this will do for now. */ all = emalloc(n*sizeof(all[0])); diff --git a/src/cmd/acidtypes/util.c b/src/cmd/acidtypes/util.c index 47fe193d7..41883bbd6 100644 --- a/src/cmd/acidtypes/util.c +++ b/src/cmd/acidtypes/util.c @@ -68,7 +68,7 @@ Bfmt(Fmt *fmt) { int i; char *s, *t; - + if(!isBfrog['.']){ for(i=0; i<256; i++) if(i != '_' && i != '$' && i < Runeself && !isalnum(i)) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 12701f23f..e5658a4ef 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 6215e0441..63c33ac11 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 ef92e3395..75cf710f1 100644 --- a/src/cmd/acme/ecmd.c +++ b/src/cmd/acme/ecmd.c @@ -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); diff --git a/src/cmd/acme/edit.c b/src/cmd/acme/edit.c index d3f820593..81f80300d 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 c5650f03f..8a8951fb4 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/fsys.c b/src/cmd/acme/fsys.c index 4c395eb2b..d9d4b30d7 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 567b83839..562026c92 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.mev) { eventlog.mev = eventlog.mev*2; diff --git a/src/cmd/acme/mail/dat.h b/src/cmd/acme/mail/dat.h index a7ac6a0bb..66bb3a5d4 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 e3a956b06..e193fc4d4 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 d79721f80..e1047bb8b 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 9bfe10e15..739ce10a7 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 5dda0edc3..f28cbef10 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 888e7e72c..8ac9f9467 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 84c9cee0c..1cf776dda 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 8ff5884df..09422dda0 100644 --- a/src/cmd/acme/text.c +++ b/src/cmd/acme/text.c @@ -388,7 +388,7 @@ textinsert(Text *t, uint q0, Rune *r, uint n, int tofile) textscrdraw(u); } } - + } if(q0 < t->iq1) t->iq1 += n; @@ -549,7 +549,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); @@ -771,7 +771,7 @@ texttype(Text *t, Rune r) case Kcmd+'Z': /* %-shift-Z: redo */ typecommit(t); undo(t, nil, nil, FALSE, 0, nil, 0); - return; + return; Tagdown: /* expand tag to show all text */ @@ -780,7 +780,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){ @@ -1192,7 +1192,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; @@ -1345,7 +1345,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){ @@ -1412,7 +1412,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]; @@ -1444,7 +1444,7 @@ textdoubleclick(Text *t, uint *q0, uint *q1) return; } } - + /* try filling out word to right */ while(*q1file->b.nc && isalnum(textreadc(t, *q1))) (*q1)++; @@ -1518,7 +1518,7 @@ static int ishtmlend(Text *t, uint q, uint *q0) { int c, c1, c2; - + if(q < 2) return 0; if(textreadc(t, --q) != '>') @@ -1546,7 +1546,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) { @@ -1583,7 +1583,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 dc9780954..c153f8c18 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); diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index b4f1a1cbc..820955b0b 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -97,7 +97,7 @@ windrawbutton(Window *w) { Image *b; Rectangle br; - + b = button; if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache)) b = modbutton; @@ -112,7 +112,7 @@ delrunepos(Window *w) { int n; Rune rune; - + for(n=0; ntag.file->b.nc; n++) { bufread(&w->tag.file->b, n, &rune, 1); if(rune == ' ') @@ -128,7 +128,7 @@ void movetodel(Window *w) { int n; - + n = delrunepos(w); if(n < 0) return; @@ -153,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); @@ -162,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; @@ -224,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; @@ -293,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))); } @@ -673,7 +673,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; } diff --git a/src/cmd/astro/cosadd.c b/src/cmd/astro/cosadd.c index 637ad206b..8ce3748bd 100644 --- a/src/cmd/astro/cosadd.c +++ b/src/cmd/astro/cosadd.c @@ -17,7 +17,7 @@ cosadd(int n, ...) int i; double sum, a1, a2; va_list arg; - + sum = 0; cp = cacp; va_start(arg, n); diff --git a/src/cmd/auth/dsa2pub.c b/src/cmd/auth/dsa2pub.c index d5f26bfc7..684275277 100644 --- a/src/cmd/auth/dsa2pub.c +++ b/src/cmd/auth/dsa2pub.c @@ -35,7 +35,7 @@ main(int argc, char **argv) sysfatal("%r"); s = smprint("key %A p=%lB q=%lB alpha=%lB key=%lB\n", - a, + a, key->pub.p, key->pub.q, key->pub.alpha, key->pub.key); if(s == nil) sysfatal("smprint: %r"); diff --git a/src/cmd/auth/dsa2ssh.c b/src/cmd/auth/dsa2ssh.c index 489f2d211..26f9ff6d0 100644 --- a/src/cmd/auth/dsa2ssh.c +++ b/src/cmd/auth/dsa2ssh.c @@ -18,7 +18,7 @@ main(int argc, char **argv) DSApriv *k; char *comment; uchar buf[8192], *p; - + fmtinstall('B', mpfmt); fmtinstall('[', encodefmt); comment = ""; diff --git a/src/cmd/auth/dsagen.c b/src/cmd/auth/dsagen.c index cb618edee..d938cf5dd 100644 --- a/src/cmd/auth/dsagen.c +++ b/src/cmd/auth/dsagen.c @@ -43,6 +43,6 @@ main(int argc, char **argv) if(write(1, s, strlen(s)) != strlen(s)) sysfatal("write: %r"); - + exits(nil); } diff --git a/src/cmd/auth/dsasign.c b/src/cmd/auth/dsasign.c index 913385f9a..594e84e28 100644 --- a/src/cmd/auth/dsasign.c +++ b/src/cmd/auth/dsasign.c @@ -30,10 +30,10 @@ threadmain(int argc, char **argv) uchar digest[SHA1dlen]; AuthRpc *rpc; Fmt fmt; - + fmtinstall('[', encodefmt); fmtinstall('H', encodefmt); - + verify = 0; id = ""; ARGBEGIN{ @@ -46,7 +46,7 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1) usage(); key = argv[0]; @@ -68,7 +68,7 @@ threadmain(int argc, char **argv) auth_freerpc(rpc); threadexits("rpc"); } - + print("+%s\n", id); Binit(&b, 0, OREAD); @@ -96,7 +96,7 @@ keytomp(Attr *a, char *name) { char *p; mpint *m; - + p = _strfindattr(a, name); if(p == nil) sysfatal("missing key attribute %s", name); @@ -117,7 +117,7 @@ doVerify(void) Attr *a; DSAsig dsig; DSApub dkey; - + a = _parseattr(key); if(a == nil) sysfatal("invalid key"); @@ -159,7 +159,7 @@ doVerify(void) if(dsaverify(&dkey, &dsig, betomp(digest, sizeof digest, nil)) < 0) sysfatal("signature failed to verify: %r"); - + write(1, text, strlen(text)); threadexitsall(0); } @@ -169,7 +169,7 @@ getline(int *np) { char *p; int n; - + if((p = Brdline(&b, '\n')) == nil) return nil; n = Blinelen(&b); diff --git a/src/cmd/auth/factotum/apop.c b/src/cmd/auth/factotum/apop.c index 992cc0ad1..d3d8c95ac 100644 --- a/src/cmd/auth/factotum/apop.c +++ b/src/cmd/auth/factotum/apop.c @@ -10,7 +10,7 @@ * S -> C: ok * * Note that this is the protocol between factotum and the local - * program, not between the two factotums. The information + * program, not between the two factotums. The information * exchanged here is wrapped in the APOP protocol by the local * programs. * @@ -42,7 +42,7 @@ apopclient(Conv *c) Attr *attr; DigestState *ds; Key *k; - + chal = nil; k = nil; res = nil; @@ -328,7 +328,7 @@ apopresp(ServerState *s, char *user, char *resp) } static Role -apoproles[] = +apoproles[] = { "client", apopclient, "server", apopserver, @@ -350,4 +350,3 @@ Proto cram = { apopcheck, nil }; - diff --git a/src/cmd/auth/factotum/attr.c b/src/cmd/auth/factotum/attr.c index 1c037a536..25a461599 100644 --- a/src/cmd/auth/factotum/attr.c +++ b/src/cmd/auth/factotum/attr.c @@ -53,7 +53,7 @@ addattrs(Attr *a, Attr *b) break; } } - return a; + return a; } void @@ -201,7 +201,7 @@ matchattr(Attr *pat, Attr *a0, Attr *a1) break; } } - return 1; + return 1; } Attr* diff --git a/src/cmd/auth/factotum/chap.c b/src/cmd/auth/factotum/chap.c index fa44db96b..d4fee3c4c 100644 --- a/src/cmd/auth/factotum/chap.c +++ b/src/cmd/auth/factotum/chap.c @@ -1,6 +1,6 @@ /* * CHAP, MSCHAP - * + * * The client does not authenticate the server, hence no CAI * * Protocol: @@ -51,7 +51,7 @@ nthash(uchar hash[MShashlen], char *passwd) { uchar buf[512]; int i; - + for(i=0; *passwd && iattr, "p"))==nil + if((a=strfindattr(k->attr, "p"))==nil || (priv->pub.p=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->attr, "q"))==nil + if((a=strfindattr(k->attr, "q"))==nil || (priv->pub.q=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); @@ -90,15 +90,15 @@ readdsapriv(Key *k) werrstr("dsa: p or q not prime"); goto Error; } - if((a=strfindattr(k->attr, "alpha"))==nil + if((a=strfindattr(k->attr, "alpha"))==nil || (priv->pub.alpha=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->attr, "key"))==nil + if((a=strfindattr(k->attr, "key"))==nil || (priv->pub.key=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->privattr, "!secret"))==nil + if((a=strfindattr(k->privattr, "!secret"))==nil || (priv->secret=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); @@ -113,7 +113,7 @@ static int dsacheck(Key *k) { static int first = 1; - + if(first){ fmtinstall('B', mpfmt); first = 0; @@ -134,7 +134,7 @@ dsaclose(Key *k) } static Role -dsaroles[] = +dsaroles[] = { "sign", xdsasign, 0 @@ -147,4 +147,3 @@ Proto dsa = { dsacheck, dsaclose }; - diff --git a/src/cmd/auth/factotum/fs.c b/src/cmd/auth/factotum/fs.c index fd89b2c28..811bd5b04 100644 --- a/src/cmd/auth/factotum/fs.c +++ b/src/cmd/auth/factotum/fs.c @@ -65,7 +65,7 @@ rootdirgen(int n, Dir *dir, void *v) if(n > 0) return -1; - + fillstat(dir, factname, QTDIR, Qfactotum, DMDIR|0555); return 0; } @@ -224,7 +224,7 @@ convlist(int i, char *a, uint nn) memmove(a, buf, n); return n; } - + static void fskickreply(Conv *c) { @@ -250,7 +250,7 @@ fskickreply(Conv *c) respond(r, nil); c->nreply = 0; } - + /* * Some of the file system work happens in the fs proc, but * fsopen, fsread, fswrite, fsdestroyfid, and fsflush happen in @@ -305,7 +305,7 @@ fsopen(Req *r) c->kickreply = fskickreply; r->fid->aux = c; } - + respond(r, nil); } @@ -538,4 +538,3 @@ fsinit0(void) fs.destroyfid = fssendclunk; fs.start = fsstart; } - diff --git a/src/cmd/auth/factotum/httpdigest.c b/src/cmd/auth/factotum/httpdigest.c index 3e299bf5e..1e9d5793f 100644 --- a/src/cmd/auth/factotum/httpdigest.c +++ b/src/cmd/auth/factotum/httpdigest.c @@ -2,7 +2,7 @@ * HTTPDIGEST - MD5 challenge/response authentication (RFC 2617) * * Client protocol: - * write challenge: nonce method uri + * write challenge: nonce method uri * read response: 2*MD5dlen hex digits * * Server protocol: @@ -22,10 +22,10 @@ hdclient(Conv *c) char *realm, *passwd, *user, *f[4], *s, resp[MD5dlen*2+1]; int ret; Key *k; - + ret = -1; s = nil; - + c->state = "keylookup"; k = keyfetch(c, "%A", c->attr); if(k == nil) @@ -45,7 +45,7 @@ hdclient(Conv *c) digest(user, realm, passwd, f[0], f[1], f[2], resp); convwrite(c, resp, strlen(resp)); ret = 0; - + out: free(s); keyclose(k); @@ -103,7 +103,7 @@ digest(char *user, char *realm, char *passwd, strtolower(dig); } -static Role hdroles[] = +static Role hdroles[] = { "client", hdclient, 0 diff --git a/src/cmd/auth/factotum/key.c b/src/cmd/auth/factotum/key.c index 9df50eb31..817df97bb 100644 --- a/src/cmd/auth/factotum/key.c +++ b/src/cmd/auth/factotum/key.c @@ -161,7 +161,7 @@ keyreplace(Conv *c, Key *k, char *fmt, ...) sysfatal("out of memory"); va_end(arg); - /* replace prompted values with prompts */ + /* replace prompted values with prompts */ a = copyattr(k->attr); bp = parseattr(k->proto->keyprompt); for(b=bp; b; b=b->next){ @@ -204,7 +204,7 @@ keyevict(Conv *c, Key *k, char *fmt, ...) sysfatal("out of memory"); va_end(arg); - /* replace prompted values with prompts */ + /* replace prompted values with prompts */ a = copyattr(k->attr); bp = parseattr(k->proto->keyprompt); for(b=bp; b; b=b->next){ diff --git a/src/cmd/auth/factotum/log.c b/src/cmd/auth/factotum/log.c index 4d29536b0..e644028ad 100644 --- a/src/cmd/auth/factotum/log.c +++ b/src/cmd/auth/factotum/log.c @@ -118,4 +118,3 @@ flog(char *fmt, ...) lbvappend(&logbuf, fmt, arg); va_end(arg); } - diff --git a/src/cmd/auth/factotum/main.c b/src/cmd/auth/factotum/main.c index 1f603ac7a..b3ace12c4 100644 --- a/src/cmd/auth/factotum/main.c +++ b/src/cmd/auth/factotum/main.c @@ -142,7 +142,7 @@ sendkey(Attr *attr) int rv; char buf[8192]; CFid *fid; - + fid = nsopen("factotum", nil, "ctl", OWRITE); if(fid == nil) sysfatal("opening factotum/ctl: %r"); diff --git a/src/cmd/auth/factotum/p9any.c b/src/cmd/auth/factotum/p9any.c index 0267a6164..079eed942 100644 --- a/src/cmd/auth/factotum/p9any.c +++ b/src/cmd/auth/factotum/p9any.c @@ -9,7 +9,7 @@ * C->S: proto dom NUL * [negotiated proto continues] */ - + extern Proto p9sk1, p9sk2, p9cr; static Proto* okproto[] = @@ -111,7 +111,7 @@ p9anyserver(Conv *c) } ret = 0; - + out: free(s); freeattr(attr); @@ -222,7 +222,7 @@ p9anyclient(Conv *c) /* f[i] is the chosen protocol, q the chosen domain */ attr = addattr(attr, "proto=%q dom=%q", f[i], q); c->state = "write choice"; - + /* have a key: go for it */ choice = estrappend(nil, "%q %q", f[i], q); if(convwrite(c, choice, strlen(choice)+1) < 0){ @@ -258,7 +258,7 @@ p9anyclient(Conv *c) } static Role -p9anyroles[] = +p9anyroles[] = { "client", p9anyclient, "server", p9anyserver, @@ -269,4 +269,3 @@ Proto p9any = { "p9any", p9anyroles }; - diff --git a/src/cmd/auth/factotum/p9cr.c b/src/cmd/auth/factotum/p9cr.c index 1c3f21e19..4f181e981 100644 --- a/src/cmd/auth/factotum/p9cr.c +++ b/src/cmd/auth/factotum/p9cr.c @@ -9,7 +9,7 @@ * S -> C: ok or bad * * Note that this is the protocol between factotum and the local - * program, not between the two factotums. The information + * program, not between the two factotums. The information * exchanged here is wrapped in other protocols by the local * programs. */ @@ -317,7 +317,7 @@ p9crresp(ServerState *s, uchar *resp, int resplen) static int p9response(char *pw, uchar *chal, uchar *resp) -{ +{ char key[DESKEYLEN]; uchar buf[8]; ulong x; @@ -338,7 +338,7 @@ static int vncresponse(char *pw, uchar *chal, uchar *resp) { DESstate des; - + memmove(resp, chal, MAXCHAL); setupDESstate(&des, 0, nil); // XXX put key in for 0 desECBencrypt(resp, MAXCHAL, &des); diff --git a/src/cmd/auth/factotum/p9sk1.c b/src/cmd/auth/factotum/p9sk1.c index 0a79a361b..d2d7eb895 100644 --- a/src/cmd/auth/factotum/p9sk1.c +++ b/src/cmd/auth/factotum/p9sk1.c @@ -93,7 +93,7 @@ p9skclient(Conv *c) k = keyfetch(c, "%A", a); if(k == nil) goto out; - + /* relay ticket request to auth server, get tickets */ strcpy(tr.hostid, strfindattr(k->attr, "user")); if(speakfor) @@ -329,7 +329,7 @@ p9sk1close(Key *k) } static Role -p9sk1roles[] = +p9sk1roles[] = { "client", p9skclient, "server", p9skserver, @@ -337,7 +337,7 @@ p9sk1roles[] = }; static Role -p9sk2roles[] = +p9sk2roles[] = { "client", p9skclient, "server", p9skserver, @@ -356,4 +356,3 @@ Proto p9sk2 = { "p9sk2", p9sk2roles }; - diff --git a/src/cmd/auth/factotum/pass.c b/src/cmd/auth/factotum/pass.c index 453045ce8..ddda95964 100644 --- a/src/cmd/auth/factotum/pass.c +++ b/src/cmd/auth/factotum/pass.c @@ -15,12 +15,12 @@ static int passproto(Conv *c) { Key *k; - + k = keyfetch(c, "%A", c->attr); if(k == nil) return -1; c->state = "write"; - convprint(c, "%q %q", + convprint(c, "%q %q", strfindattr(k->attr, "user"), strfindattr(k->privattr, "!password")); return 0; diff --git a/src/cmd/auth/factotum/pkcs1.c b/src/cmd/auth/factotum/pkcs1.c index f3278454c..0e116f2de 100644 --- a/src/cmd/auth/factotum/pkcs1.c +++ b/src/cmd/auth/factotum/pkcs1.c @@ -12,7 +12,7 @@ * * We sign hashes of messages instead of the messages * themselves. - * + * * The hashes are encoded in ASN.1 DER to identify * the signature type, and then prefixed with 0x01 PAD 0x00 * where PAD is as many 0xFF bytes as desired. @@ -138,7 +138,7 @@ mptoberjust(mpint *b, uchar *buf, uint len) #define O3(x) \ (((x)>>14)&0x7F)|0x80, \ (((x)>>7)&0x7F)|0x80, \ - ((x)&0x7F) + ((x)&0x7F) uchar oidsha1[] = { O0(1, 3), 14, 3, 2, 26 }; uchar oidmd2[] = { O0(1, 2), O2(840), O3(113549), 2, 2 }; uchar oidmd5[] = { O0(1, 2), O2(840), O3(113549), 2, 5 }; @@ -174,11 +174,11 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen) sysfatal("bad alg in mkasn1"); return -1; } - + p = asn1; *p++ = 0x30; /* sequence */ p++; - + *p++ = 0x30; /* another sequence */ p++; @@ -186,12 +186,12 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen) *p++ = olen; memmove(p, obj, olen); p += olen; - + *p++ = 0x05; /* null */ *p++ = 0; - + asn1[3] = p - (asn1+4); /* end of inner sequence */ - + *p++ = 0x04; /* octet string */ *p++ = dlen; memmove(p, d, dlen); @@ -200,4 +200,3 @@ mkasn1(uchar *asn1, DigestAlg *alg, uchar *d, uint dlen) asn1[1] = p - (asn1+2); /* end of outer sequence */ return p-asn1; } - diff --git a/src/cmd/auth/factotum/rpc.c b/src/cmd/auth/factotum/rpc.c index ad8943307..26d5fd4b8 100644 --- a/src/cmd/auth/factotum/rpc.c +++ b/src/cmd/auth/factotum/rpc.c @@ -32,7 +32,7 @@ * done [haveai] - authentication is done [haveai: you can get an ai with authinfo] */ -char *rpcname[] = +char *rpcname[] = { "unknown", "authinfo", @@ -196,7 +196,7 @@ rpcexec(Conv *c) rpcrespond(c, "error conversation not successful"); else{ /* make up an auth info using the attr */ - p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3, + p = convAI2M((uchar*)c->reply+3, sizeof c->reply-3, strfindattr(c->attr, "cuid"), strfindattr(c->attr, "suid"), strfindattr(c->attr, "cap"), @@ -341,4 +341,3 @@ convAI2M(uchar *p, int n, char *cuid, char *suid, char *cap, char *hex) werrstr("authinfo too big"); return p; } - diff --git a/src/cmd/auth/factotum/rsa.c b/src/cmd/auth/factotum/rsa.c index 95545f931..e59feaab1 100644 --- a/src/cmd/auth/factotum/rsa.c +++ b/src/cmd/auth/factotum/rsa.c @@ -3,7 +3,7 @@ /* * RSA authentication. - * + * * Encrypt/Decrypt: * start n=xxx ek=xxx * write msg @@ -13,7 +13,7 @@ * start n=xxx ek=xxx * write hash(msg) * read signature(hash(msg)) - * + * * Verify: * start n=xxx ek=xxx * write hash(msg) @@ -44,14 +44,14 @@ xrsadecrypt(Conv *c) if(k == nil) goto out; key = k->priv; - + /* make sure have private half if needed */ role = strfindattr(c->attr, "role"); if(strcmp(role, "decrypt") == 0 && !key->c2){ werrstr("missing private half of key -- cannot decrypt"); goto out; } - + /* read text */ c->state = "read"; if((n=convreadm(c, &txt)) < 0) @@ -60,7 +60,7 @@ xrsadecrypt(Conv *c) convprint(c, "data too short"); goto out; } - + /* encrypt/decrypt */ m = betomp((uchar*)txt, n, nil); if(m == nil) @@ -72,7 +72,7 @@ xrsadecrypt(Conv *c) if(mm == nil) goto out; n = mptobe(mm, (uchar*)buf, sizeof buf, nil); - + /* send response */ c->state = "write"; convwrite(c, buf, n); @@ -98,7 +98,7 @@ xrsasign(Conv *c) char *sig2; ret = -1; - + /* fetch key */ c->state = "keylookup"; k = keylookup("%A", c->attr); @@ -112,7 +112,7 @@ xrsasign(Conv *c) werrstr("missing private half of key -- cannot sign"); goto out; } - + /* get hash type from key */ hash = strfindattr(k->attr, "hash"); if(hash == nil) @@ -144,7 +144,7 @@ xrsasign(Conv *c) /* read signature */ if((n = convreadm(c, &sig2)) < 0) goto out; - + /* verify */ if(rsaverify(&key->pub, hashfn, digest, dlen, (uchar*)sig2, n) == 0) convprint(c, "ok"); @@ -160,7 +160,7 @@ xrsasign(Conv *c) } /* - * convert to canonical form (lower case) + * convert to canonical form (lower case) * for use in attribute matches. */ static void @@ -180,22 +180,22 @@ readrsapriv(Key *k) priv = rsaprivalloc(); - if((a=strfindattr(k->attr, "ek"))==nil + if((a=strfindattr(k->attr, "ek"))==nil || (priv->pub.ek=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->attr, "n"))==nil + if((a=strfindattr(k->attr, "n"))==nil || (priv->pub.n=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); if(k->privattr == nil) /* only public half */ return priv; - if((a=strfindattr(k->privattr, "!p"))==nil + if((a=strfindattr(k->privattr, "!p"))==nil || (priv->p=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->privattr, "!q"))==nil + if((a=strfindattr(k->privattr, "!q"))==nil || (priv->q=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); @@ -203,19 +203,19 @@ readrsapriv(Key *k) werrstr("rsa: p or q not prime"); goto Error; } - if((a=strfindattr(k->privattr, "!kp"))==nil + if((a=strfindattr(k->privattr, "!kp"))==nil || (priv->kp=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->privattr, "!kq"))==nil + if((a=strfindattr(k->privattr, "!kq"))==nil || (priv->kq=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->privattr, "!c2"))==nil + if((a=strfindattr(k->privattr, "!c2"))==nil || (priv->c2=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); - if((a=strfindattr(k->privattr, "!dk"))==nil + if((a=strfindattr(k->privattr, "!dk"))==nil || (priv->dk=strtomp(a, nil, 16, nil))==nil) goto Error; strlwr(a); @@ -230,7 +230,7 @@ static int rsacheck(Key *k) { static int first = 1; - + if(first){ fmtinstall('B', mpfmt); first = 0; @@ -251,7 +251,7 @@ rsaclose(Key *k) } static Role -rsaroles[] = +rsaroles[] = { "sign", xrsasign, "verify", xrsasign, /* public operation */ diff --git a/src/cmd/auth/factotum/secstore.c b/src/cmd/auth/factotum/secstore.c index c17c3cf27..9928d3610 100644 --- a/src/cmd/auth/factotum/secstore.c +++ b/src/cmd/auth/factotum/secstore.c @@ -659,4 +659,3 @@ secstorefetch(void) free(sta); return rv; } - diff --git a/src/cmd/auth/factotum/std.h b/src/cmd/auth/factotum/std.h index 814664e0f..52c55b7c8 100644 --- a/src/cmd/auth/factotum/std.h +++ b/src/cmd/auth/factotum/std.h @@ -7,4 +7,3 @@ #include #include #include <9p.h> - diff --git a/src/cmd/auth/factotum/util.c b/src/cmd/auth/factotum/util.c index accddddde..dce37dca7 100644 --- a/src/cmd/auth/factotum/util.c +++ b/src/cmd/auth/factotum/util.c @@ -50,5 +50,3 @@ estrappend(char *s, char *fmt, ...) free(t); return s; } - - diff --git a/src/cmd/auth/factotum/wep.c b/src/cmd/auth/factotum/wep.c index 1d516db28..701018e77 100644 --- a/src/cmd/auth/factotum/wep.c +++ b/src/cmd/auth/factotum/wep.c @@ -11,11 +11,11 @@ wepclient(Conv *c) char *dev, buf[128], *p, *kp; Key *k; int ret, fd, cfd; - + fd = cfd = -1; ret = -1; dev = nil; - + if((k = keylookup("%A !key1?", c->attr)) == nil && (k = keylookup("%A !key2?", c->attr)) == nil && (k = keylookup("%A !key3?", c->attr)) == nil){ @@ -73,7 +73,7 @@ static Role weproles[] = { 0 }; -Proto wep = +Proto wep = { "wep", weproles, diff --git a/src/cmd/auth/factotum/xio.c b/src/cmd/auth/factotum/xio.c index 2e6b141b0..116fccaf5 100644 --- a/src/cmd/auth/factotum/xio.c +++ b/src/cmd/auth/factotum/xio.c @@ -9,7 +9,7 @@ xioproc(void) { Ioproc *c; int i; - + for(i=0; ikp = strtomp(p, &p, 16, nil)) == nil || *p != 0){ fprint(2, "warning: bad !kp\n"); - regen = 1; + regen = 1; goto regen; } if((p = _strfindattr(a, "!kq")) == nil){ fprint(2, "warning: no !kq\n"); - regen = 1; + regen = 1; goto regen; } if((key->kq = strtomp(p, &p, 16, nil)) == nil || *p != 0){ fprint(2, "warning: bad !kq\n"); - regen = 1; + regen = 1; goto regen; } if((p = _strfindattr(a, "!c2")) == nil){ fprint(2, "warning: no !c2\n"); - regen = 1; + regen = 1; goto regen; } if((key->c2 = strtomp(p, &p, 16, nil)) == nil || *p != 0){ fprint(2, "warning: bad !c2\n"); - regen = 1; + regen = 1; goto regen; } regen: @@ -285,7 +285,7 @@ uchar* putmp2(uchar *p, mpint *b) { int bits, n; - + if(mpcmp(b, mpzero) == 0) return put4(p, 0); bits = mpsignif(b); diff --git a/src/cmd/auth/rsa2pub.c b/src/cmd/auth/rsa2pub.c index c0a208a72..e45c04915 100644 --- a/src/cmd/auth/rsa2pub.c +++ b/src/cmd/auth/rsa2pub.c @@ -35,7 +35,7 @@ main(int argc, char **argv) sysfatal("%r"); s = smprint("key %A size=%d ek=%lB n=%lB\n", - a, + a, mpsignif(key->pub.n), key->pub.ek, key->pub.n); if(s == nil) sysfatal("smprint: %r"); diff --git a/src/cmd/auth/rsa2ssh.c b/src/cmd/auth/rsa2ssh.c index 3de2792e3..9951106b6 100644 --- a/src/cmd/auth/rsa2ssh.c +++ b/src/cmd/auth/rsa2ssh.c @@ -19,7 +19,7 @@ main(int argc, char **argv) { RSApriv *k; char *comment; - + fmtinstall('B', mpfmt); fmtinstall('[', encodefmt); comment = ""; @@ -42,7 +42,7 @@ main(int argc, char **argv) if(ssh2){ uchar buf[8192], *p; - + p = buf; p = put4(p, 7); p = putn(p, "ssh-rsa", 7); diff --git a/src/cmd/auth/rsafill.c b/src/cmd/auth/rsafill.c index 08cb85998..efab877e2 100644 --- a/src/cmd/auth/rsafill.c +++ b/src/cmd/auth/rsafill.c @@ -35,7 +35,7 @@ main(int argc, char **argv) sysfatal("%r"); s = smprint("key %A size=%d ek=%lB !dk=%lB n=%lB !p=%lB !q=%lB !kp=%lB !kq=%lB !c2=%lB\n", - a, + a, mpsignif(key->pub.n), key->pub.ek, key->dk, key->pub.n, key->p, key->q, key->kp, key->kq, key->c2); diff --git a/src/cmd/auth/rsagen.c b/src/cmd/auth/rsagen.c index d51560b63..2ca99d349 100644 --- a/src/cmd/auth/rsagen.c +++ b/src/cmd/auth/rsagen.c @@ -55,6 +55,6 @@ main(int argc, char **argv) if(write(1, s, strlen(s)) != strlen(s)) sysfatal("write: %r"); - + exits(nil); } diff --git a/src/cmd/auth/secstore/SConn.c b/src/cmd/auth/secstore/SConn.c index 07e92327b..9ffb3d935 100644 --- a/src/cmd/auth/secstore/SConn.c +++ b/src/cmd/auth/secstore/SConn.c @@ -211,4 +211,3 @@ readstr(SConn *conn, char *s) } return n; } - diff --git a/src/cmd/auth/secstore/SConn.h b/src/cmd/auth/secstore/SConn.h index 31765f3ec..09ddb637f 100644 --- a/src/cmd/auth/secstore/SConn.h +++ b/src/cmd/auth/secstore/SConn.h @@ -23,4 +23,3 @@ extern int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */ extern void *emalloc(ulong); /* dies on failure; clears memory */ extern void *erealloc(void *, ulong); extern char *estrdup(char *); - diff --git a/src/cmd/auth/secstore/dirls.c b/src/cmd/auth/secstore/dirls.c index eaae8cdc9..39542a52c 100644 --- a/src/cmd/auth/secstore/dirls.c +++ b/src/cmd/auth/secstore/dirls.c @@ -84,4 +84,3 @@ dirls(char *path) free(dirbuf); return list; } - diff --git a/src/cmd/auth/secstore/pak.c b/src/cmd/auth/secstore/pak.c index effc01d9f..1f1a09c5b 100644 --- a/src/cmd/auth/secstore/pak.c +++ b/src/cmd/auth/secstore/pak.c @@ -341,4 +341,3 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp) mpfree(H); return rc; } - diff --git a/src/cmd/auth/secstore/password.c b/src/cmd/auth/secstore/password.c index b2a00e724..c9e63d19a 100644 --- a/src/cmd/auth/secstore/password.c +++ b/src/cmd/auth/secstore/password.c @@ -133,4 +133,3 @@ freePW(PW *pw) mpfree(pw->Hi); free(pw); } - diff --git a/src/cmd/auth/secstore/secstore.c b/src/cmd/auth/secstore/secstore.c index 571c6fae4..2b33e5d4e 100644 --- a/src/cmd/auth/secstore/secstore.c +++ b/src/cmd/auth/secstore/secstore.c @@ -85,7 +85,7 @@ getfile(SConn *conn, char *gf, uchar **buf, ulong *buflen, uchar *key, int nkey) return 0; } - /* conn is already encrypted against wiretappers, + /* conn is already encrypted against wiretappers, but gf is also encrypted against server breakin. */ if(buf == nil && (fd =create(gf, OWRITE, 0600)) < 0){ fprint(2, "can't open %s: %r\n", gf); @@ -197,7 +197,7 @@ putfile(SConn *conn, char *pf, uchar *buf, ulong len, uchar *key, int nkey) return -1; } }else{ - if((n = len - bufi) > Maxmsg-ivo) + if((n = len - bufi) > Maxmsg-ivo) n = Maxmsg-ivo; memcpy(b+ivo, buf+bufi, n); bufi += n; @@ -578,4 +578,3 @@ main(int argc, char **argv) exits(""); return 0; } - diff --git a/src/cmd/auth/secstore/secstore.h b/src/cmd/auth/secstore/secstore.h index d9cb807dc..dfc07730b 100644 --- a/src/cmd/auth/secstore/secstore.h +++ b/src/cmd/auth/secstore/secstore.h @@ -28,4 +28,3 @@ char *PAK_Hi(char *, char *, mpint *, mpint *); #define LOG "secstore" extern char *SECSTORE_DIR; - diff --git a/src/cmd/auth/secstore/secstored.c b/src/cmd/auth/secstore/secstored.c index 9a3c4b66b..d32ec64c1 100644 --- a/src/cmd/auth/secstore/secstored.c +++ b/src/cmd/auth/secstore/secstored.c @@ -24,7 +24,7 @@ usage(void) static int getdir(SConn *conn, char *id) { - char *ls, *s; + char *ls, *s; uchar *msg; int n, len; @@ -417,4 +417,3 @@ main(int argc, char **argv) } } } - diff --git a/src/cmd/auth/secstore/secureidcheck.c b/src/cmd/auth/secstore/secureidcheck.c index 8ef6f6aaa..9d8e81ad6 100644 --- a/src/cmd/auth/secstore/secureidcheck.c +++ b/src/cmd/auth/secstore/secureidcheck.c @@ -417,7 +417,7 @@ secureidcheck(char *user, char *response) resp = nil; continue; } - + switch(resp->code){ case R_AccessAccept: syslog(0, AUTHLOG, "%s accepted ruser=%s", dest, ruser); diff --git a/src/cmd/auth/secstore/secuser.c b/src/cmd/auth/secstore/secuser.c index 31ba184bb..8e4eae605 100644 --- a/src/cmd/auth/secstore/secuser.c +++ b/src/cmd/auth/secstore/secuser.c @@ -241,4 +241,3 @@ userinput(char *buf, int blen) exits("input too large"); } } - diff --git a/src/cmd/auth/ssh-agent.c b/src/cmd/auth/ssh-agent.c index 40516a770..c3b0c7ef3 100644 --- a/src/cmd/auth/ssh-agent.c +++ b/src/cmd/auth/ssh-agent.c @@ -25,7 +25,7 @@ enum /* agent protocol packet types */ SSH_AGENTC_ADD_RSA_IDENTITY, SSH_AGENTC_REMOVE_RSA_IDENTITY, SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES, - + SSH2_AGENTC_REQUEST_IDENTITIES = 11, SSH2_AGENT_IDENTITIES_ANSWER, SSH2_AGENTC_SIGN_REQUEST, @@ -42,12 +42,12 @@ enum /* agent protocol packet types */ SSH_AGENTC_ADD_RSA_ID_CONSTRAINED, SSH2_AGENTC_ADD_ID_CONSTRAINED, SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED, - + SSH_AGENT_CONSTRAIN_LIFETIME = 1, SSH_AGENT_CONSTRAIN_CONFIRM = 2, SSH2_AGENT_FAILURE = 30, - + SSH_COM_AGENT2_FAILURE = 102, SSH_AGENT_OLD_SIGNATURE = 0x01 }; @@ -121,12 +121,12 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc > 1) usage(); if(argc == 1) factotum = argv[0]; - + if(dotextlist) listkeystext(); @@ -145,7 +145,7 @@ threadmain(int argc, char **argv) if((afd = announce(addr, adir)) < 0) sysfatal("announce %s: %r", addr); - + print("SSH_AUTH_SOCK=%s;\n", sock); if(export) print("export SSH_AUTH_SOCK;\n"); @@ -178,7 +178,7 @@ agentproc(void *v) { Aconn *a; int n; - + a = v; a->fd = accept(a->ctl, a->dir); close(a->ctl); @@ -209,7 +209,7 @@ int get2(Msg *m) { uint x; - + if(m->p+2 > m->ep) return 0; x = (m->p[0]<<8)|m->p[1]; @@ -232,7 +232,7 @@ uchar* getn(Msg *m, uint n) { uchar *p; - + if(m->p+n > m->ep) return nil; p = m->p; @@ -261,7 +261,7 @@ getmp(Msg *m) { int n; uchar *p; - + n = (get2(m)+7)/8; if((p=getn(m, n)) == nil) return nil; @@ -273,7 +273,7 @@ getmp2(Msg *m) { int n; uchar *p; - + n = get4(m); if((p = getn(m, n)) == nil) return nil; @@ -301,7 +301,7 @@ getm(Msg *m, Msg *mm) { uint n; uchar *p; - + n = get4(m); if((p = getn(m, n)) == nil) return nil; @@ -347,7 +347,7 @@ void put4(Msg *m, uint n) { uchar *p; - + p = ensure(m, 4); p[0] = (n>>24)&0xFF; p[1] = (n>>16)&0xFF; @@ -359,7 +359,7 @@ void put2(Msg *m, uint n) { uchar *p; - + p = ensure(m, 2); p[0] = (n>>8)&0xFF; p[1] = n&0xFF; @@ -369,7 +369,7 @@ void put1(Msg *m, uint n) { uchar *p; - + p = ensure(m, 1); p[0] = n&0xFF; } @@ -378,7 +378,7 @@ void putn(Msg *m, void *a, uint n) { uchar *p; - + p = ensure(m, n); memmove(p, a, n); } @@ -388,7 +388,7 @@ putmp(Msg *m, mpint *b) { int bits, n; uchar *p; - + bits = mpsignif(b); put2(m, bits); n = (bits+7)/8; @@ -401,7 +401,7 @@ putmp2(Msg *m, mpint *b) { int bits, n; uchar *p; - + if(mpcmp(b, mpzero) == 0){ put4(m, 0); return; @@ -421,7 +421,7 @@ void putstr(Msg *m, char *s) { int n; - + n = strlen(s); put4(m, n); putn(m, s, n); @@ -431,7 +431,7 @@ void putm(Msg *m, Msg *mm) { uint n; - + n = mm->p - mm->bp; put4(m, n); putn(m, mm->bp, n); @@ -450,7 +450,7 @@ reply(Aconn *a, Msg *m) { uint n; uchar *p; - + n = (m->p - m->bp) - 4; p = m->bp; p[0] = (n>>24)&0xFF; @@ -513,7 +513,7 @@ void printattr(char **f, int nf) { int i; - + print("#"); for(i=0; indata < 4) return 0; len = (a->data[0]<<24)|(a->data[1]<<16)|(a->data[2]<<8)|a->data[3]; @@ -993,7 +993,7 @@ runmsg(Aconn *a) goto Failchal; md5(sessid, 16, digest, s); print("md5 %.*H %.*H => %.*H\n", 32, chalbuf, 16, sessid, MD5dlen, digest); - + newreply(&m, SSH_AGENT_RSA_RESPONSE); putn(&m, digest, 16); reply(a, &m); @@ -1020,22 +1020,22 @@ runmsg(Aconn *a) mreset(&msig); reply(a, &m); break; - + case SSH_AGENTC_ADD_RSA_IDENTITY: /* msg: n[4] mod[mp] pubexp[exp] privexp[mp] p^-1 mod q[mp] p[mp] q[mp] comment[str] */ goto Failure; - + case SSH_AGENTC_REMOVE_RSA_IDENTITY: /* msg: n[4] mod[mp] pubexp[mp] */ goto Failure; - + } - + a->ndata -= 4+len; memmove(a->data, a->data+4+len, a->ndata); return 1; @@ -1064,4 +1064,3 @@ erealloc(void *v, int n) } return v; } - diff --git a/src/cmd/auxstats/Darwin.c b/src/cmd/auxstats/Darwin.c index b92f682ef..836de5205 100644 --- a/src/cmd/auxstats/Darwin.c +++ b/src/cmd/auxstats/Darwin.c @@ -79,7 +79,7 @@ void sampleinit(void) { mach_timebase_info_data_t info; - + if(stat_port) return; @@ -115,7 +115,7 @@ samplenet(void) sample.net_obytes = 0; sample.net_errors = 0; sample.net_ifaces = 0; - + for(ifa=ifa_list; ifa; ifa=ifa->ifa_next){ if(ifa->ifa_addr->sa_family != AF_LINK) continue; @@ -125,7 +125,7 @@ samplenet(void) continue; if(strncmp(ifa->ifa_name, "lo", 2) == 0) /* loopback */ continue; - + if_data = (struct if_data*)ifa->ifa_data; sample.net_ipackets += if_data->ifi_ipackets; sample.net_opackets += if_data->ifi_opackets; @@ -144,7 +144,7 @@ samplenet(void) * all the other stat monitoring apps get set: * * -rwsr-xr-x 1 root wheel 83088 Mar 20 2005 /usr/bin/top - * -rwsrwxr-x 1 root admin 54048 Mar 20 2005 + * -rwsrwxr-x 1 root admin 54048 Mar 20 2005 * /Applications/Utilities/Activity Monitor.app/Contents/Resources/pmTool * * If Darwin eventually encompases more into sysctl then this @@ -165,7 +165,7 @@ sampleevents(void) mach_error_string(error)); return; } - + sample.p_syscalls_mach = sample.syscalls_mach; sample.p_syscalls_unix = sample.syscalls_unix; sample.p_csw = sample.csw; @@ -173,7 +173,7 @@ sampleevents(void) sample.syscalls_mach = 0; sample.syscalls_unix = 0; sample.csw = 0; - + for(i=0; i #include "dat.h" -void (*statfn[])(int) = +void (*statfn[])(int) = { 0 }; - diff --git a/src/cmd/auxstats/FreeBSD.c b/src/cmd/auxstats/FreeBSD.c index 2497fe35e..2cc82879d 100644 --- a/src/cmd/auxstats/FreeBSD.c +++ b/src/cmd/auxstats/FreeBSD.c @@ -203,8 +203,8 @@ xsysctl(int first) pgsize = 4096; } - Bprint(&bout, "mem =%lld %lld\n", - isys("vm.stats.vm.v_active_count")*pgsize, + Bprint(&bout, "mem =%lld %lld\n", + isys("vm.stats.vm.v_active_count")*pgsize, isys("vm.stats.vm.v_page_count")*pgsize); Bprint(&bout, "context %lld 1000\n", isys("vm.stats.sys.v_swtch")); Bprint(&bout, "syscall %lld 1000\n", isys("vm.stats.sys.v_syscall")); @@ -284,4 +284,3 @@ xswap(int first) Bprint(&bout, "swap =%lld %lld\n", s.ksw_used*(vlong)pgsize, s.ksw_total*(vlong)pgsize); } - diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index 64c86a26c..7bc4b7206 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -39,12 +39,12 @@ xapm(int first) readfile(fd); tokens(0); curr = atoi(tok[0]); - + if(curr != -1) Bprint(&bout, "battery =%d 100\n", curr); } - + void xloadavg(int first) { @@ -236,7 +236,7 @@ xwireless(int first) { static int fd = -1; int i; - + if(first){ fd = open("/proc/net/wireless", OREAD); return; diff --git a/src/cmd/auxstats/NetBSD.c b/src/cmd/auxstats/NetBSD.c index ec9310447..33ebdedc1 100644 --- a/src/cmd/auxstats/NetBSD.c +++ b/src/cmd/auxstats/NetBSD.c @@ -3,8 +3,7 @@ #include #include "dat.h" -void (*statfn[])(int) = +void (*statfn[])(int) = { 0 }; - diff --git a/src/cmd/auxstats/SunOS.c b/src/cmd/auxstats/SunOS.c index ec9310447..33ebdedc1 100644 --- a/src/cmd/auxstats/SunOS.c +++ b/src/cmd/auxstats/SunOS.c @@ -3,8 +3,7 @@ #include #include "dat.h" -void (*statfn[])(int) = +void (*statfn[])(int) = { 0 }; - diff --git a/src/cmd/auxstats/main.c b/src/cmd/auxstats/main.c index d1c355619..3fd77ac4c 100644 --- a/src/cmd/auxstats/main.c +++ b/src/cmd/auxstats/main.c @@ -120,4 +120,3 @@ tokens(int i) } ntok = tokenize(line[i], tok, nelem(tok)); } - diff --git a/src/cmd/awk/awk.h b/src/cmd/awk/awk.h index 1853381d4..913f45092 100644 --- a/src/cmd/awk/awk.h +++ b/src/cmd/awk/awk.h @@ -134,7 +134,7 @@ extern Node *nullnode; #define CCOPY 6 #define CCON 5 #define CTEMP 4 -#define CNAME 3 +#define CNAME 3 #define CVAR 2 #define CFLD 1 #define CUNK 0 @@ -182,4 +182,3 @@ extern int pairstack[], paircnt; #define freeable(p) ( ((p)->tval & (STR|DONTFREE)) == STR ) #include "proto.h" - diff --git a/src/cmd/awk/lex.c b/src/cmd/awk/lex.c index 74a990305..0a051eded 100644 --- a/src/cmd/awk/lex.c +++ b/src/cmd/awk/lex.c @@ -140,7 +140,7 @@ int gettok(char **pbuf, int *psz) /* get next input token */ if (bp-buf >= sz) if (!adjbuf(&buf, &sz, bp-buf+2, 100, &bp, 0)) FATAL( "out of space for number %.10s...", buf ); - if (isdigit(c) || c == 'e' || c == 'E' + if (isdigit(c) || c == 'e' || c == 'E' || c == '.' || c == '+' || c == '-') *bp++ = c; else { @@ -191,7 +191,7 @@ int yylex(void) /* should this also have STR set? */ RET(NUMBER); } - + yylval.i = c; switch (c) { case '\n': /* {EOL} */ @@ -220,7 +220,7 @@ int yylex(void) case '&': if (peek() == '&') { input(); RET(AND); - } else + } else RET('&'); case '|': if (peek() == '|') { @@ -295,7 +295,7 @@ int yylex(void) input(); yylval.i = POWEQ; RET(ASGNOP); } else RET(POWER); - + case '$': /* BUG: awkward, if not wrong */ c = gettok(&buf, &bufsize); @@ -313,7 +313,7 @@ int yylex(void) unputstr(buf); RET(INDIRECT); } - + case '}': if (--bracecnt < 0) SYNTAX( "extra }" ); @@ -336,10 +336,10 @@ int yylex(void) case '(': parencnt++; RET('('); - + case '"': return string(); /* BUG: should be like tran.c ? */ - + default: RET(c); } @@ -369,7 +369,7 @@ int string(void) c = input(); switch (c) { case '"': *bp++ = '"'; break; - case 'n': *bp++ = '\n'; break; + case 'n': *bp++ = '\n'; break; case 't': *bp++ = '\t'; break; case 'f': *bp++ = '\f'; break; case 'r': *bp++ = '\r'; break; @@ -406,7 +406,7 @@ int string(void) break; } - default: + default: *bp++ = c; break; } @@ -416,7 +416,7 @@ int string(void) break; } } - *bp = 0; + *bp = 0; s = tostring(buf); *bp++ = ' '; *bp++ = 0; yylval.cp = setsymtab(buf, s, 0.0, CON|STR|DONTFREE, symtab); @@ -442,7 +442,7 @@ int binsearch(char *w, Keyword *kp, int n) return -1; } -int word(char *w) +int word(char *w) { Keyword *kp; int c, n; @@ -504,11 +504,11 @@ int regexpr(void) if (!adjbuf(&buf, &bufsz, bp-buf+3, 500, &bp, 0)) FATAL("out of space for reg expr %.10s...", buf); if (c == '\n') { - SYNTAX( "newline in regular expression %.10s...", buf ); + SYNTAX( "newline in regular expression %.10s...", buf ); unput('\n'); break; } else if (c == '\\') { - *bp++ = '\\'; + *bp++ = '\\'; *bp++ = input(); } else { *bp++ = c; @@ -567,4 +567,3 @@ void unputstr(char *s) /* put a string back on input */ for (i = strlen(s)-1; i >= 0; i--) unput(s[i]); } - diff --git a/src/cmd/awk/lib.c b/src/cmd/awk/lib.c index 3eb30687c..30c3ddd4b 100644 --- a/src/cmd/awk/lib.c +++ b/src/cmd/awk/lib.c @@ -435,7 +435,7 @@ int refldbld(char *rec, char *fs) /* build fields from reg expr in FS */ break; } } - return i; + return i; } void recbld(void) /* create $0 from $1..$NF if necessary */ @@ -715,4 +715,3 @@ int is_number(char *s) else return 0; } - diff --git a/src/cmd/awk/main.c b/src/cmd/awk/main.c index ea20f63e5..532cc1f64 100644 --- a/src/cmd/awk/main.c +++ b/src/cmd/awk/main.c @@ -195,4 +195,3 @@ char *cursource(void) /* current source file name */ else return NULL; } - diff --git a/src/cmd/awk/maketab.c b/src/cmd/awk/maketab.c index 50908ce97..13d34e96e 100644 --- a/src/cmd/awk/maketab.c +++ b/src/cmd/awk/maketab.c @@ -166,4 +166,3 @@ int main(int argc, char *argv[]) printf("}\n"); return 0; } - diff --git a/src/cmd/awk/parse.c b/src/cmd/awk/parse.c index d4c883243..2ee6eca62 100644 --- a/src/cmd/awk/parse.c +++ b/src/cmd/awk/parse.c @@ -269,4 +269,3 @@ Node *itonp(int i) /* and vice versa */ { return (Node *) (long) i; } - diff --git a/src/cmd/awk/proto.h b/src/cmd/awk/proto.h index f124f4e4c..d12a93221 100644 --- a/src/cmd/awk/proto.h +++ b/src/cmd/awk/proto.h @@ -177,4 +177,3 @@ extern Cell *gsub(Node **, int); extern FILE *popen(const char *, const char *); extern int pclose(FILE *); - diff --git a/src/cmd/awk/re.c b/src/cmd/awk/re.c index a15d2f4dd..2a226768b 100644 --- a/src/cmd/awk/re.c +++ b/src/cmd/awk/re.c @@ -215,7 +215,7 @@ nematch(void *p, char *s, char *start) if (pmatch(p, s, start) == 1 && patlen > 0) return 1; patlen = -1; - patbeg = start; + patbeg = start; return 0; } /* in the parsing of regular expressions, metacharacters like . have */ @@ -322,4 +322,3 @@ overflow(void) { FATAL("%s", "regular expression too big"); } - diff --git a/src/cmd/awk/run.c b/src/cmd/awk/run.c index b145758cc..9aa3e0e4c 100644 --- a/src/cmd/awk/run.c +++ b/src/cmd/awk/run.c @@ -506,7 +506,7 @@ Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts * s = getsval(y); if (!adjbuf(&buf, &bufsz, strlen(buf)+strlen(s)+nsub+1, recsize, 0, 0)) FATAL("out of memory deleting %s[%s...]", x->nval, buf); - strcat(buf, s); + strcat(buf, s); if (np->nnext) strcat(buf, *SUBSEP); tempfree(y); @@ -1914,4 +1914,3 @@ void backsub(char **pb_ptr, char **sptr_ptr) /* handle \\& variations */ *pb_ptr = pb; *sptr_ptr = sptr; } - diff --git a/src/cmd/awk/tran.c b/src/cmd/awk/tran.c index 272a7fdc0..387bc00bd 100644 --- a/src/cmd/awk/tran.c +++ b/src/cmd/awk/tran.c @@ -167,7 +167,7 @@ void freesymtab(Cell *ap) /* free a symbol table */ if (freeable(cp)) xfree(cp->sval); temp = cp->cnext; /* avoids freeing then using */ - free(cp); + free(cp); } tp->tab[i] = 0; } @@ -180,7 +180,7 @@ void freeelem(Cell *ap, char *s) /* free elem s from ap (i.e., ap["s"] */ Array *tp; Cell *p, *prev = NULL; int h; - + tp = (Array *) ap->sval; h = hash(s, tp->size); for (p = tp->tab[h]; p != NULL; prev = p, p = p->cnext) @@ -275,7 +275,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */ { int fldno; - if ((vp->tval & (NUM | STR)) == 0) + if ((vp->tval & (NUM | STR)) == 0) funnyvar(vp, "assign to"); if (isfld(vp)) { donerec = 0; /* mark $0 invalid */ @@ -405,7 +405,7 @@ char *qstring(char *s, int delim) /* collect string up to next delim */ if (c == 0) { /* \ at end */ *bp++ = '\\'; break; /* for loop */ - } + } switch (c) { case '\\': *bp++ = '\\'; break; case 'n': *bp++ = '\n'; break; @@ -432,4 +432,3 @@ char *qstring(char *s, int delim) /* collect string up to next delim */ *bp++ = 0; return buf; } - diff --git a/src/cmd/bzip2/bunzip2.c b/src/cmd/bzip2/bunzip2.c index 653ebc33e..38abb7ed3 100644 --- a/src/cmd/bzip2/bunzip2.c +++ b/src/cmd/bzip2/bunzip2.c @@ -151,7 +151,7 @@ bunzip(int ofd, char *ofile, Biobuf *bin) if(!done && strm.avail_in < sizeof buf) { if(strm.avail_in) memmove(buf, strm.next_in, strm.avail_in); - + n = Bread(bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in); if(n <= 0) done = 1; diff --git a/src/cmd/bzip2/bzip2.c b/src/cmd/bzip2/bzip2.c index cc21a57c2..6743acb8e 100644 --- a/src/cmd/bzip2/bzip2.c +++ b/src/cmd/bzip2/bzip2.c @@ -175,7 +175,7 @@ bzip(char *file, long mtime, int ifd, Biobuf *bout) if(!done && strm.avail_in < sizeof buf) { if(strm.avail_in) memmove(buf, strm.next_in, strm.avail_in); - + n = Bread(&bin, buf+strm.avail_in, sizeof(buf)-strm.avail_in); if(n <= 0) done = 1; diff --git a/src/cmd/bzip2/bzip2recover.c b/src/cmd/bzip2/bzip2recover.c index ba3d17563..c31c50abe 100644 --- a/src/cmd/bzip2/bzip2recover.c +++ b/src/cmd/bzip2/bzip2recover.c @@ -5,7 +5,7 @@ /*-----------------------------------------------------------*/ /*-- - This program is bzip2recover, a program to attempt data + This program is bzip2recover, a program to attempt data salvage from damaged files created by the accompanying bzip2-1.0 program. @@ -18,16 +18,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -324,10 +324,10 @@ Int32 main ( Int32 argc, Char** argv ) } buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); - if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI + if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI && buffLo == BLOCK_HEADER_LO) - || - ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI + || + ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI && buffLo == BLOCK_ENDMARK_LO) ) { if (bitsRead > 49) @@ -378,7 +378,7 @@ Int32 main ( Int32 argc, Char** argv ) if (b == 2) break; buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); - if (bitsRead == 47+rbStart[wrBlock]) + if (bitsRead == 47+rbStart[wrBlock]) blockCRC = (buffHi << 16) | (buffLo >> 16); if (outFile != NULL && bitsRead >= rbStart[wrBlock] diff --git a/src/cmd/bzip2/lib/blocksort.c b/src/cmd/bzip2/lib/blocksort.c index f43d569e6..e6d154b30 100644 --- a/src/cmd/bzip2/lib/blocksort.c +++ b/src/cmd/bzip2/lib/blocksort.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -57,8 +57,8 @@ For more information on these sources, see the manual. - To get some idea how the block sorting algorithms in this file - work, read my paper + To get some idea how the block sorting algorithms in this file + work, read my paper On the Performance of BWT Sorting Algorithms in Proceedings of the IEEE Data Compression Conference 2000, Snowbird, Utah, USA, 27-30 March 2000. The main sort in this @@ -75,11 +75,11 @@ /*---------------------------------------------*/ /*---------------------------------------------*/ -static +static __inline__ -void fallbackSimpleSort ( UInt32* fmap, - UInt32* eclass, - Int32 lo, +void fallbackSimpleSort ( UInt32* fmap, + UInt32* eclass, + Int32 lo, Int32 hi ) { Int32 i, j, tmp; @@ -138,9 +138,9 @@ void fallbackSimpleSort ( UInt32* fmap, static -void fallbackQSort3 ( UInt32* fmap, +void fallbackQSort3 ( UInt32* fmap, UInt32* eclass, - Int32 loSt, + Int32 loSt, Int32 hiSt ) { Int32 unLo, unHi, ltLo, gtHi, n, m; @@ -165,9 +165,9 @@ void fallbackQSort3 ( UInt32* fmap, } /* Random partitioning. Median of 3 sometimes fails to - avoid bad cases. Median of 9 seems to help but + avoid bad cases. Median of 9 seems to help but looks rather expensive. This too seems to work but - is cheaper. Guidance for the magic constants + is cheaper. Guidance for the magic constants 7621 and 32768 is taken from Sedgewick's algorithms book, chapter 35. */ @@ -184,10 +184,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unLo]] - (Int32)med; - if (n == 0) { - fswap(fmap[unLo], fmap[ltLo]); - ltLo++; unLo++; - continue; + if (n == 0) { + fswap(fmap[unLo], fmap[ltLo]); + ltLo++; unLo++; + continue; }; if (n > 0) break; unLo++; @@ -195,10 +195,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unHi]] - (Int32)med; - if (n == 0) { - fswap(fmap[unHi], fmap[gtHi]); - gtHi--; unHi--; - continue; + if (n == 0) { + fswap(fmap[unHi], fmap[gtHi]); + gtHi--; unHi--; + continue; }; if (n < 0) break; unHi--; @@ -257,8 +257,8 @@ void fallbackQSort3 ( UInt32* fmap, #define UNALIGNED_BH(zz) ((zz) & 0x01f) static -void fallbackSort ( UInt32* fmap, - UInt32* eclass, +void fallbackSort ( UInt32* fmap, + UInt32* eclass, UInt32* bhtab, Int32 nblock, Int32 verb ) @@ -299,7 +299,7 @@ void fallbackSort ( UInt32* fmap, --*/ /*-- set sentinel bits for block-end detection --*/ - for (i = 0; i < 32; i++) { + for (i = 0; i < 32; i++) { SET_BH(nblock + 2*i); CLEAR_BH(nblock + 2*i + 1); } @@ -308,7 +308,7 @@ void fallbackSort ( UInt32* fmap, H = 1; while (1) { - if (verb >= 4) + if (verb >= 4) VPrintf1 ( " depth %6d has ", H ); j = 0; @@ -353,14 +353,14 @@ void fallbackSort ( UInt32* fmap, } } - if (verb >= 4) + if (verb >= 4) VPrintf1 ( "%6d unresolved strings\n", nNotDone ); H *= 2; if (H > nblock || nNotDone == 0) break; } - /*-- + /*-- Reconstruct the original block in eclass8 [0 .. nblock-1], since the previous phase destroyed it. @@ -392,9 +392,9 @@ void fallbackSort ( UInt32* fmap, /*---------------------------------------------*/ static __inline__ -Bool mainGtU ( UInt32 i1, +Bool mainGtU ( UInt32 i1, UInt32 i2, - UChar* block, + UChar* block, UInt16* quadrant, UInt32 nblock, Int32* budget ) @@ -534,8 +534,8 @@ void mainSimpleSort ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 lo, - Int32 hi, + Int32 lo, + Int32 hi, Int32 d, Int32* budget ) { @@ -559,8 +559,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -573,8 +573,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -587,8 +587,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -626,13 +626,13 @@ void mainSimpleSort ( UInt32* ptr, } \ } -static +static __inline__ UChar mmed3 ( UChar a, UChar b, UChar c ) { UChar t; if (a > b) { t = a; a = b; b = t; }; - if (b > c) { + if (b > c) { b = c; if (a > b) b = a; } @@ -670,8 +670,8 @@ void mainQSort3 ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 loSt, - Int32 hiSt, + Int32 loSt, + Int32 hiSt, Int32 dSt, Int32* budget ) { @@ -694,14 +694,14 @@ void mainQSort3 ( UInt32* ptr, AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 ); mpop ( lo, hi, d ); - if (hi - lo < MAIN_QSORT_SMALL_THRESH || + if (hi - lo < MAIN_QSORT_SMALL_THRESH || d > MAIN_QSORT_DEPTH_THRESH) { mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); if (*budget < 0) return; continue; } - med = (Int32) + med = (Int32) mmed3 ( block[ptr[ lo ]+d], block[ptr[ hi ]+d], block[ptr[ (lo+hi)>>1 ]+d] ); @@ -713,9 +713,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unLo]+d]) - med; - if (n == 0) { - mswap(ptr[unLo], ptr[ltLo]); - ltLo++; unLo++; continue; + if (n == 0) { + mswap(ptr[unLo], ptr[ltLo]); + ltLo++; unLo++; continue; }; if (n > 0) break; unLo++; @@ -723,9 +723,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unHi]+d]) - med; - if (n == 0) { - mswap(ptr[unHi], ptr[gtHi]); - gtHi--; unHi--; continue; + if (n == 0) { + mswap(ptr[unHi], ptr[gtHi]); + gtHi--; unHi--; continue; }; if (n < 0) break; unHi--; @@ -796,9 +796,9 @@ void mainQSort3 ( UInt32* ptr, #define CLEARMASK (~(SETMASK)) static -void mainSort ( UInt32* ptr, +void mainSort ( UInt32* ptr, UChar* block, - UInt16* quadrant, + UInt16* quadrant, UInt32* ftab, Int32 nblock, Int32 verb, @@ -926,7 +926,7 @@ void mainSort ( UInt32* ptr, /*-- Step 1: Complete the big bucket [ss] by quicksorting - any unsorted small buckets [ss, j], for j != ss. + any unsorted small buckets [ss, j], for j != ss. Hopefully previous pointer-scanning phases have already completed many of the small buckets [ss, j], so we don't have to sort them at all. @@ -942,10 +942,10 @@ void mainSort ( UInt32* ptr, VPrintf4 ( " qsort [0x%x, 0x%x] " "done %d this %d\n", ss, j, numQSorted, hi - lo + 1 ); - mainQSort3 ( - ptr, block, quadrant, nblock, - lo, hi, BZ_N_RADIX, budget - ); + mainQSort3 ( + ptr, block, quadrant, nblock, + lo, hi, BZ_N_RADIX, budget + ); numQSorted += (hi - lo + 1); if (*budget < 0) return; } @@ -977,7 +977,7 @@ void mainSort ( UInt32* ptr, for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { k = ptr[j]-1; if (k < 0) k += nblock; c1 = block[k]; - if (!bigDone[c1]) + if (!bigDone[c1]) ptr[ copyEnd[c1]-- ] = k; } } @@ -996,7 +996,7 @@ void mainSort ( UInt32* ptr, updating for the last bucket is pointless. The quadrant array provides a way to incrementally - cache sort orderings, as they appear, so as to + cache sort orderings, as they appear, so as to make subsequent comparisons in fullGtU() complete faster. For repetitive blocks this makes a big difference (but not big enough to be able to avoid @@ -1006,9 +1006,9 @@ void mainSort ( UInt32* ptr, for 0 <= i < nblock and 0 <= j <= nblock - if block[i] != block[j], + if block[i] != block[j], - then the relative values of quadrant[i] and + then the relative values of quadrant[i] and quadrant[j] are meaningless. else { @@ -1071,7 +1071,7 @@ void mainSort ( UInt32* ptr, */ void BZ2_blockSort ( EState* s ) { - UInt32* ptr = s->ptr; + UInt32* ptr = s->ptr; UChar* block = s->block; UInt32* ftab = s->ftab; Int32 nblock = s->nblock; @@ -1095,8 +1095,8 @@ void BZ2_blockSort ( EState* s ) quadrant = (UInt16*)(&(block[i])); /* (wfact-1) / 3 puts the default-factor-30 - transition point at very roughly the same place as - with v0.1 and v0.9.0. + transition point at very roughly the same place as + with v0.1 and v0.9.0. Not that it particularly matters any more, since the resulting compressed stream is now the same regardless of whether or not we use the main sort or fallback sort. @@ -1107,14 +1107,14 @@ void BZ2_blockSort ( EState* s ) budget = budgetInit; mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); - if (verb >= 3) + if (verb >= 3) VPrintf3 ( " %d work, %d block, ratio %5.2f\n", budgetInit - budget, - nblock, + nblock, (float)(budgetInit - budget) / - (float)(nblock==0 ? 1 : nblock) ); + (float)(nblock==0 ? 1 : nblock) ); if (budget < 0) { - if (verb >= 2) + if (verb >= 2) VPrintf0 ( " too repetitive; using fallback" " sorting algorithm\n" ); fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); diff --git a/src/cmd/bzip2/lib/buffcompress.c b/src/cmd/bzip2/lib/buffcompress.c index 849c8ff00..cd3509342 100644 --- a/src/cmd/bzip2/lib/buffcompress.c +++ b/src/cmd/bzip2/lib/buffcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,30 +89,30 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress) BZ2_bzCompressEnd ( &strm ); return ret; } - diff --git a/src/cmd/bzip2/lib/buffdecompress.c b/src/cmd/bzip2/lib/buffdecompress.c index 944166f3f..474924709 100644 --- a/src/cmd/bzip2/lib/buffdecompress.c +++ b/src/cmd/bzip2/lib/buffdecompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,10 +89,10 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffDecompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, int small, int verbosity ) @@ -100,10 +100,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || (small != 0 && small != 1) || - verbosity < 0 || verbosity > 4) + verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; strm.bzalloc = NULL; @@ -133,11 +133,9 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) } else { BZ2_bzDecompressEnd ( &strm ); return BZ_OUTBUFF_FULL; - }; + }; errhandler: BZ2_bzDecompressEnd ( &strm ); - return ret; + return ret; } - - diff --git a/src/cmd/bzip2/lib/bzassert.c b/src/cmd/bzip2/lib/bzassert.c index 56d58fc24..8a578bd02 100644 --- a/src/cmd/bzip2/lib/bzassert.c +++ b/src/cmd/bzip2/lib/bzassert.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -93,7 +93,7 @@ void BZ2_bz__AssertH__fail ( int errcode ) { - fprintf(stderr, + fprintf(stderr, "\n\nbzip2/libbzip2: internal error number %d.\n" "This is a bug in bzip2/libbzip2, %s.\n" "Please report it to me at: jseward@acm.org. If this happened\n" diff --git a/src/cmd/bzip2/lib/bzbuffcompress.c b/src/cmd/bzip2/lib/bzbuffcompress.c index 849c8ff00..cd3509342 100644 --- a/src/cmd/bzip2/lib/bzbuffcompress.c +++ b/src/cmd/bzip2/lib/bzbuffcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,30 +89,30 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress) BZ2_bzCompressEnd ( &strm ); return ret; } - diff --git a/src/cmd/bzip2/lib/bzcompress.c b/src/cmd/bzip2/lib/bzcompress.c index d27e67573..7f3deec0e 100644 --- a/src/cmd/bzip2/lib/bzcompress.c +++ b/src/cmd/bzip2/lib/bzcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -125,8 +125,8 @@ Bool isempty_RL ( EState* s ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ) @@ -136,7 +136,7 @@ int BZ_API(BZ2_bzCompressInit) if (!bz_config_ok()) return BZ_CONFIG_ERROR; - if (strm == NULL || + if (strm == NULL || blockSize100k < 1 || blockSize100k > 9 || workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; @@ -279,7 +279,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- no input? --*/ if (s->strm->avail_in == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -297,7 +297,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- flush/finish end? --*/ if (s->avail_in_expect == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -343,18 +343,18 @@ Bool handle_compress ( bz_stream* strm ) Bool progress_in = False; Bool progress_out = False; EState* s = strm->state; - + while (True) { if (s->state == BZ_S_OUTPUT) { progress_out |= copy_output_until_stop ( s ); if (s->state_out_pos < s->numZ) break; - if (s->mode == BZ_M_FINISHING && + if (s->mode == BZ_M_FINISHING && s->avail_in_expect == 0 && isempty_RL(s)) break; prepare_new_block ( s ); s->state = BZ_S_INPUT; - if (s->mode == BZ_M_FLUSHING && + if (s->mode == BZ_M_FLUSHING && s->avail_in_expect == 0 && isempty_RL(s)) break; } @@ -402,7 +402,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) if (action == BZ_RUN) { progress = handle_compress ( strm ); return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; - } + } else if (action == BZ_FLUSH) { s->avail_in_expect = strm->avail_in; @@ -415,12 +415,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) s->mode = BZ_M_FINISHING; goto preswitch; } - else + else return BZ_PARAM_ERROR; case BZ_M_FLUSHING: if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; /*rsc added */ @@ -431,7 +431,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) case BZ_M_FINISHING: if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; @@ -458,8 +458,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) if (s->ftab != NULL) BZFREE(s->ftab); BZFREE(strm->state); - strm->state = NULL; + strm->state = NULL; return BZ_OK; } - diff --git a/src/cmd/bzip2/lib/bzdecompress.c b/src/cmd/bzip2/lib/bzdecompress.c index 25ed92536..da3251fbe 100644 --- a/src/cmd/bzip2/lib/bzdecompress.c +++ b/src/cmd/bzip2/lib/bzdecompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -93,8 +93,8 @@ /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, int verbosity, int small ) { @@ -153,34 +153,34 @@ void unRLE_obuf_to_output_FAST ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - - + + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -217,7 +217,7 @@ void unRLE_obuf_to_output_FAST ( DState* s ) } s_state_out_len_eq_one: { - if (cs_avail_out == 0) { + if (cs_avail_out == 0) { c_state_out_len = 1; goto return_notr; }; *( (UChar*)(cs_next_out) ) = c_state_out_ch; @@ -225,29 +225,29 @@ void unRLE_obuf_to_output_FAST ( DState* s ) cs_next_out++; cs_avail_out--; } - } + } /* can a new run be started? */ if (c_nblock_used == s_save_nblockPP) { c_state_out_len = 0; goto return_notr; - }; + }; c_state_out_ch = c_k0; BZ_GET_FAST_C(k1); c_nblock_used++; - if (k1 != c_k0) { - c_k0 = k1; goto s_state_out_len_eq_one; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; }; - if (c_nblock_used == s_save_nblockPP) + if (c_nblock_used == s_save_nblockPP) goto s_state_out_len_eq_one; - + c_state_out_len = 2; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + c_state_out_len = 3; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + BZ_GET_FAST_C(k1); c_nblock_used++; c_state_out_len = ((Int32)k1) + 4; BZ_GET_FAST_C(c_k0); c_nblock_used++; @@ -311,34 +311,34 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - - + + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -357,26 +357,26 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - + s->state_out_len = 1; s->state_out_ch = s->k0; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + BZ_GET_SMALL(k1); s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; BZ_GET_SMALL(s->k0); s->nblock_used++; @@ -403,14 +403,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) unRLE_obuf_to_output_FAST ( s ); if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); - if (s->verbosity >= 3) - VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, + if (s->verbosity >= 3) + VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, s->calculatedBlockCRC ); if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->calculatedBlockCRC != s->storedBlockCRC) return BZ_DATA_ERROR; - s->calculatedCombinedCRC - = (s->calculatedCombinedCRC << 1) | + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | (s->calculatedCombinedCRC >> 31); s->calculatedCombinedCRC ^= s->calculatedBlockCRC; s->state = BZ_X_BLKHDR_1; @@ -422,7 +422,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Int32 r = BZ2_decompress ( s ); if (r == BZ_STREAM_END) { if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", + VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", s->storedCombinedCRC, s->calculatedCombinedCRC ); if (s->calculatedCombinedCRC != s->storedCombinedCRC) return BZ_DATA_ERROR; @@ -435,7 +435,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) /* AssertH ( 0, 6001 ); - return 0; + return 0; */ } @@ -458,4 +458,3 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) return BZ_OK; } - diff --git a/src/cmd/bzip2/lib/bzfeof.c b/src/cmd/bzip2/lib/bzfeof.c index 74e1f88da..c96974dae 100644 --- a/src/cmd/bzip2/lib/bzfeof.c +++ b/src/cmd/bzip2/lib/bzfeof.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -97,4 +97,3 @@ Bool bz_feof ( FILE* f ) ungetc ( c, f ); return False; } - diff --git a/src/cmd/bzip2/lib/bzlib.c b/src/cmd/bzip2/lib/bzlib.c index 66b89a2e8..12a4bf90f 100644 --- a/src/cmd/bzip2/lib/bzlib.c +++ b/src/cmd/bzip2/lib/bzlib.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS diff --git a/src/cmd/bzip2/lib/bzlib.h b/src/cmd/bzip2/lib/bzlib.h index 0ece4e8a6..fae78bcbd 100644 --- a/src/cmd/bzip2/lib/bzlib.h +++ b/src/cmd/bzip2/lib/bzlib.h @@ -29,16 +29,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -96,7 +96,7 @@ extern "C" { #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) -typedef +typedef struct { char *next_in; unsigned int avail_in; @@ -113,7 +113,7 @@ typedef void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; - } + } bz_stream; @@ -144,57 +144,57 @@ typedef /*-- Core (low-level) library functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action ); -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, int small ); -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm ); /*-- Utility functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int small, - int verbosity + int small, + int verbosity ); diff --git a/src/cmd/bzip2/lib/bzlib_private.h b/src/cmd/bzip2/lib/bzlib_private.h index ad5787063..002d79b32 100644 --- a/src/cmd/bzip2/lib/bzlib_private.h +++ b/src/cmd/bzip2/lib/bzlib_private.h @@ -29,16 +29,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -80,7 +80,7 @@ #ifndef __GNUC__ #define __inline__ /* */ -#endif +#endif /* these #defines can be overridden by bzlib_stdio.h */ extern void bz_internal_error ( int errcode ); @@ -257,19 +257,19 @@ typedef /*-- externs for compression. --*/ -extern void +extern void BZ2_blockSort ( EState* ); -extern void +extern void BZ2_compressBlock ( EState*, Bool ); -extern void +extern void BZ2_bsInitWrite ( EState* ); -extern void +extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); -extern void +extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); @@ -413,7 +413,7 @@ typedef Int32 save_N; Int32 save_curr; Int32 save_zt; - Int32 save_zn; + Int32 save_zn; Int32 save_zvec; Int32 save_zj; Int32 save_gSel; @@ -463,13 +463,13 @@ typedef /*-- externs for decompression. --*/ -extern Int32 +extern Int32 BZ2_indexIntoF ( Int32, Int32* ); -extern Int32 +extern Int32 BZ2_decompress ( DState* ); -extern void +extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); diff --git a/src/cmd/bzip2/lib/bzlib_stdio.h b/src/cmd/bzip2/lib/bzlib_stdio.h index 30d41d998..18805f0ba 100644 --- a/src/cmd/bzip2/lib/bzlib_stdio.h +++ b/src/cmd/bzip2/lib/bzlib_stdio.h @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -99,17 +99,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); - + BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( @@ -121,70 +121,69 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) ( ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, + BZFILE *b, int *errnum ); /*-- High(er) level library functions --*/ -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, int small, - void* unused, - int nUnused + void* unused, + int nUnused ); -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b ); -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ); -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); - diff --git a/src/cmd/bzip2/lib/bzlib_stdio_private.h b/src/cmd/bzip2/lib/bzlib_stdio_private.h index 24b311443..caacf36a1 100644 --- a/src/cmd/bzip2/lib/bzlib_stdio_private.h +++ b/src/cmd/bzip2/lib/bzlib_stdio_private.h @@ -53,7 +53,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode ); if (bzf != NULL) bzf->lastErr = eee; \ } -typedef +typedef struct { FILE* handle; Char buf[BZ_MAX_UNUSED]; @@ -66,4 +66,3 @@ typedef bzFile; extern Bool bz_feof( FILE* ); - diff --git a/src/cmd/bzip2/lib/bzread.c b/src/cmd/bzip2/lib/bzread.c index 8bd03888d..e523d249c 100644 --- a/src/cmd/bzip2/lib/bzread.c +++ b/src/cmd/bzip2/lib/bzread.c @@ -19,16 +19,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -82,9 +82,9 @@ #include "bzlib_stdio_private.h" /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzReadOpen) - ( int* bzerror, - FILE* f, +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, int verbosity, int small, void* unused, @@ -95,7 +95,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) BZ_SETERR(BZ_OK); - if (f == NULL || + if (f == NULL || (small != 0 && small != 1) || (verbosity < 0 || verbosity > 4) || (unused == NULL && nUnused != 0) || @@ -106,7 +106,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) + if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; BZ_SETERR(BZ_OK); @@ -118,7 +118,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.bzalloc = NULL; bzf->strm.bzfree = NULL; bzf->strm.opaque = NULL; - + while (nUnused > 0) { bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; unused = ((void*)( 1 + ((UChar*)(unused)) )); @@ -133,7 +133,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.next_in = bzf->buf; bzf->initialisedOk = True; - return bzf; + return bzf; } @@ -156,10 +156,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzRead) - ( int* bzerror, - BZFILE* b, - void* buf, +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, ret; @@ -181,11 +181,11 @@ int BZ_API(BZ2_bzRead) while (True) { - if (ferror(bzf->handle)) + if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; if (bzf->strm.avail_in == 0 && !bz_feof(bzf->handle)) { - n = fread ( bzf->buf, sizeof(UChar), + n = fread ( bzf->buf, sizeof(UChar), BZ_MAX_UNUSED, bzf->handle ); if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; @@ -199,7 +199,7 @@ int BZ_API(BZ2_bzRead) if (ret != BZ_OK && ret != BZ_STREAM_END) { BZ_SETERR(ret); return 0; }; - if (ret == BZ_OK && bz_feof(bzf->handle) && + if (ret == BZ_OK && bz_feof(bzf->handle) && bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; @@ -208,7 +208,7 @@ int BZ_API(BZ2_bzRead) return len - bzf->strm.avail_out; }; if (bzf->strm.avail_out == 0) { BZ_SETERR(BZ_OK); return len; }; - + } /* return 0; not reached*/ @@ -216,10 +216,10 @@ int BZ_API(BZ2_bzRead) /*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadGetUnused) - ( int* bzerror, - BZFILE* b, - void** unused, +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, int* nUnused ) { bzFile* bzf = (bzFile*)b; diff --git a/src/cmd/bzip2/lib/bzstdio.c b/src/cmd/bzip2/lib/bzstdio.c index 3e1f2de50..31b0a7688 100644 --- a/src/cmd/bzip2/lib/bzstdio.c +++ b/src/cmd/bzip2/lib/bzstdio.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -95,4 +95,3 @@ Bool bz_feof ( FILE* f ) ungetc ( c, f ); return False; } - diff --git a/src/cmd/bzip2/lib/bzversion.c b/src/cmd/bzip2/lib/bzversion.c index 5320144b2..601d0c91e 100644 --- a/src/cmd/bzip2/lib/bzversion.c +++ b/src/cmd/bzip2/lib/bzversion.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -96,4 +96,3 @@ const char * BZ_API(BZ2_bzlibVersion)(void) { return BZ_VERSION; } - diff --git a/src/cmd/bzip2/lib/bzwrite.c b/src/cmd/bzip2/lib/bzwrite.c index a37a66bab..086b6e2d0 100644 --- a/src/cmd/bzip2/lib/bzwrite.c +++ b/src/cmd/bzip2/lib/bzwrite.c @@ -19,16 +19,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -82,10 +82,10 @@ #include "bzlib_stdio_private.h" /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzWriteOpen) - ( int* bzerror, - FILE* f, - int blockSize100k, +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, int verbosity, int workFactor ) { @@ -117,23 +117,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen) bzf->strm.opaque = NULL; if (workFactor == 0) workFactor = 30; - ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) { BZ_SETERR(ret); free(bzf); return NULL; }; bzf->strm.avail_in = 0; bzf->initialisedOk = True; - return bzf; + return bzf; } /*---------------------------------------------------*/ void BZ_API(BZ2_bzWrite) - ( int* bzerror, - BZFILE* b, - void* buf, + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, n2, ret; @@ -162,7 +162,7 @@ void BZ_API(BZ2_bzWrite) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -176,20 +176,20 @@ void BZ_API(BZ2_bzWrite) /*---------------------------------------------------*/ void BZ_API(BZ2_bzWriteClose) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ) { - BZ2_bzWriteClose64 ( bzerror, b, abandon, + BZ2_bzWriteClose64 ( bzerror, b, abandon, nbytes_in, NULL, nbytes_out, NULL ); } void BZ_API(BZ2_bzWriteClose64) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, @@ -221,7 +221,7 @@ void BZ_API(BZ2_bzWriteClose64) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -250,4 +250,3 @@ void BZ_API(BZ2_bzWriteClose64) BZ2_bzCompressEnd ( &(bzf->strm) ); free ( bzf ); } - diff --git a/src/cmd/bzip2/lib/bzzlib.c b/src/cmd/bzip2/lib/bzzlib.c index 87b691289..56b0b7dea 100644 --- a/src/cmd/bzip2/lib/bzzlib.c +++ b/src/cmd/bzip2/lib/bzzlib.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -128,7 +128,7 @@ BZFILE * bzopen_or_bzdopen int verbosity = 0; int workFactor = 30; int smallMode = 0; - int nUnused = 0; + int nUnused = 0; if (mode == NULL) return NULL; while (*mode) { @@ -168,7 +168,7 @@ BZFILE * bzopen_or_bzdopen if (writing) { /* Guard against total chaos and anarchy -- JRS */ if (blockSize100k < 1) blockSize100k = 1; - if (blockSize100k > 9) blockSize100k = 9; + if (blockSize100k > 9) blockSize100k = 9; bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, verbosity,workFactor); } else { @@ -247,7 +247,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) { int bzerr; FILE *fp = ((bzFile *)b)->handle; - + if (b==NULL) {return;} if(((bzFile*)b)->writing){ BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); @@ -265,7 +265,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) /*---------------------------------------------------*/ /*-- - return last error code + return last error code --*/ static char *bzerrorstrings[] = { "OK" diff --git a/src/cmd/bzip2/lib/compress.c b/src/cmd/bzip2/lib/compress.c index 96c559183..c7a1aa80b 100644 --- a/src/cmd/bzip2/lib/compress.c +++ b/src/cmd/bzip2/lib/compress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -66,7 +66,7 @@ 0.9.0a/b -- no changes in this file. 0.9.0c - * changed setting of nGroups in sendMTFValues() so as to + * changed setting of nGroups in sendMTFValues() so as to do a bit better on small files --*/ @@ -171,11 +171,11 @@ void generateMTFValues ( EState* s ) Int32 wr; Int32 EOB; - /* + /* After sorting (eg, here), s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, and - ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] + ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] holds the original block data. The first thing to do is generate the MTF values, @@ -190,7 +190,7 @@ void generateMTFValues ( EState* s ) (UChar*) (&((UChar*)s->arr2)[s->nblock]) These storage aliases are set up in bzCompressInit(), - except for the last one, which is arranged in + except for the last one, which is arranged in compressBlock(). */ UInt32* ptr = s->ptr; @@ -213,7 +213,7 @@ void generateMTFValues ( EState* s ) ll_i = s->unseqToSeq[block[j]]; AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); - if (yy[0] == ll_i) { + if (yy[0] == ll_i) { zPend++; } else { @@ -221,11 +221,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -259,11 +259,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -306,7 +306,7 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf3( " %d in block, %d after MTF & 1-2 coding, " - "%d+2 syms in use\n", + "%d+2 syms in use\n", s->nblock, s->nMTF, s->nInUse ); alphaSize = s->nInUse+2; @@ -323,7 +323,7 @@ void sendMTFValues ( EState* s ) nGroups = 6; /*--- Generate an initial set of coding tables ---*/ - { + { Int32 nPart, remF, tFreq, aFreq; nPart = nGroups; @@ -338,8 +338,8 @@ void sendMTFValues ( EState* s ) aFreq += s->mtfFreq[ge]; } - if (ge > gs - && nPart != nGroups && nPart != 1 + if (ge > gs + && nPart != nGroups && nPart != 1 && ((nGroups-nPart) % 2 == 1)) { aFreq -= s->mtfFreq[ge]; ge--; @@ -348,21 +348,21 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf5( " initial group %d, [%d .. %d], " "has %d syms (%4.1f%%)\n", - nPart, gs, ge, aFreq, + nPart, gs, ge, aFreq, (100.0 * (float)aFreq) / (float)(s->nMTF) ); - + for (v = 0; v < alphaSize; v++) - if (v >= gs && v <= ge) + if (v >= gs && v <= ge) s->len[nPart-1][v] = BZ_LESSER_ICOST; else s->len[nPart-1][v] = BZ_GREATER_ICOST; - + nPart--; gs = ge+1; remF -= aFreq; } } - /*--- + /*--- Iterate up to BZ_N_ITERS times to improve the tables. ---*/ nSelectors = 40000; /* shut up some compilers' warnings about used and not set */ @@ -377,7 +377,7 @@ void sendMTFValues ( EState* s ) /*--- Set up an auxiliary length table which is used to fast-track - the common case (nGroups == 6). + the common case (nGroups == 6). ---*/ if (nGroups == 6) { for (v = 0; v < alphaSize; v++) { @@ -394,10 +394,10 @@ void sendMTFValues ( EState* s ) /*--- Set group start & end marks. --*/ if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; - /*-- + /*-- Calculate the cost of this group as coded by each of the coding tables. --*/ @@ -434,13 +434,13 @@ void sendMTFValues ( EState* s ) } else { /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) { + for (i = gs; i <= ge; i++) { UInt16 icv = mtfv[i]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; } } - - /*-- + + /*-- Find the coding table which is best for this group, and record its identity in the selector table. --*/ @@ -452,7 +452,7 @@ void sendMTFValues ( EState* s ) s->selector[nSelectors] = bt; nSelectors++; - /*-- + /*-- Increment the symbol frequencies for the selected table. --*/ if (nGroups == 6 && 50 == ge-gs+1) { @@ -482,7 +482,7 @@ void sendMTFValues ( EState* s ) gs = ge+1; } if (s->verbosity >= 3) { - VPrintf2 ( " pass %d: size is %d, grp uses are ", + VPrintf2 ( " pass %d: size is %d, grp uses are ", iter+1, totc/8 ); for (t = 0; t < nGroups; t++) VPrintf1 ( "%d ", fave[t] ); @@ -493,7 +493,7 @@ void sendMTFValues ( EState* s ) Recompute the tables based on the accumulated frequencies. --*/ for (t = 0; t < nGroups; t++) - BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), + BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 20 ); } @@ -533,19 +533,19 @@ void sendMTFValues ( EState* s ) } AssertH ( !(maxLen > 20), 3004 ); AssertH ( !(minLen < 1), 3005 ); - BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), + BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); } /*--- Transmit the mapping table. ---*/ - { + { Bool inUse16[16]; for (i = 0; i < 16; i++) { inUse16[i] = False; for (j = 0; j < 16; j++) if (s->inUse[i * 16 + j]) inUse16[i] = True; } - + nBytes = s->numZ; for (i = 0; i < 16; i++) if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); @@ -556,7 +556,7 @@ void sendMTFValues ( EState* s ) if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); } - if (s->verbosity >= 3) + if (s->verbosity >= 3) VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); } @@ -564,7 +564,7 @@ void sendMTFValues ( EState* s ) nBytes = s->numZ; bsW ( s, 3, nGroups ); bsW ( s, 15, nSelectors ); - for (i = 0; i < nSelectors; i++) { + for (i = 0; i < nSelectors; i++) { for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); bsW(s,1,0); } @@ -593,14 +593,14 @@ void sendMTFValues ( EState* s ) gs = 0; while (True) { if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; AssertH ( s->selector[selCtr] < nGroups, 3006 ); if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ UInt16 mtfv_i; - UChar* s_len_sel_selCtr + UChar* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]); Int32* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]); @@ -627,7 +627,7 @@ void sendMTFValues ( EState* s ) } else { /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { - bsW ( s, + bsW ( s, s->len [s->selector[selCtr]] [mtfv[i]], s->code [s->selector[selCtr]] [mtfv[i]] ); } @@ -682,8 +682,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block ) /*-- Now the block's CRC, so it is in a known place. --*/ bsPutUInt32 ( s, s->blockCRC ); - /*-- - Now a single bit indicating (non-)randomisation. + /*-- + Now a single bit indicating (non-)randomisation. As of version 0.9.5, we use a better sorting algorithm which makes randomisation unnecessary. So always set the randomised bit to 'no'. Of course, the decoder diff --git a/src/cmd/bzip2/lib/crctable.c b/src/cmd/bzip2/lib/crctable.c index db1eb93f8..efd1f8fb2 100644 --- a/src/cmd/bzip2/lib/crctable.c +++ b/src/cmd/bzip2/lib/crctable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS diff --git a/src/cmd/bzip2/lib/decompress.c b/src/cmd/bzip2/lib/decompress.c index 734bfee7b..e9f8a59d5 100644 --- a/src/cmd/bzip2/lib/decompress.c +++ b/src/cmd/bzip2/lib/decompress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -169,7 +169,7 @@ Int32 BZ2_decompress ( DState* s ) Int32 N; Int32 curr; Int32 zt; - Int32 zn; + Int32 zn; Int32 zvec; Int32 zj; Int32 gSel; @@ -223,7 +223,7 @@ Int32 BZ2_decompress ( DState* s ) N = s->save_N; curr = s->save_curr; zt = s->save_zt; - zn = s->save_zn; + zn = s->save_zn; zvec = s->save_zvec; zj = s->save_zj; gSel = s->save_gSel; @@ -246,14 +246,14 @@ Int32 BZ2_decompress ( DState* s ) if (uc != 'h') RETURN(BZ_DATA_ERROR_MAGIC); GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) - if (s->blockSize100k < '1' || + if (s->blockSize100k < '1' || s->blockSize100k > '9') RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k -= '0'; if (s->smallDecompress) { s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( - ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { @@ -279,7 +279,7 @@ Int32 BZ2_decompress ( DState* s ) s->currBlockNo++; if (s->verbosity >= 2) VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); - + s->storedBlockCRC = 0; GET_UCHAR(BZ_X_BCRC_1, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); @@ -302,14 +302,14 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0) RETURN(BZ_DATA_ERROR); - if (s->origPtr > 10 + 100000*s->blockSize100k) + if (s->origPtr > 10 + 100000*s->blockSize100k) RETURN(BZ_DATA_ERROR); /*--- Receive the mapping table ---*/ for (i = 0; i < 16; i++) { GET_BIT(BZ_X_MAPPING_1, uc); - if (uc == 1) - s->inUse16[i] = True; else + if (uc == 1) + s->inUse16[i] = True; else s->inUse16[i] = False; } @@ -345,7 +345,7 @@ Int32 BZ2_decompress ( DState* s ) { UChar pos[BZ_N_GROUPS], tmp, v; for (v = 0; v < nGroups; v++) pos[v] = v; - + for (i = 0; i < nSelectors; i++) { v = s->selectorMtf[i]; tmp = pos[v]; @@ -378,10 +378,10 @@ Int32 BZ2_decompress ( DState* s ) if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } - BZ2_hbCreateDecodeTables ( - &(s->limit[t][0]), - &(s->base[t][0]), - &(s->perm[t][0]), + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); @@ -473,23 +473,23 @@ Int32 BZ2_decompress ( DState* s ) s->mtfa[(z)-3] = s->mtfa[(z)-4]; nn -= 4; } - while (nn > 0) { - s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; }; s->mtfa[pp] = uc; - } else { + } else { /* general case */ lno = nn / MTFL_SIZE; off = nn % MTFL_SIZE; pp = s->mtfbase[lno] + off; uc = s->mtfa[pp]; - while (pp > s->mtfbase[lno]) { - s->mtfa[pp] = s->mtfa[pp-1]; pp--; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; }; s->mtfbase[lno]++; while (lno > 0) { s->mtfbase[lno]--; - s->mtfa[s->mtfbase[lno]] + s->mtfa[s->mtfbase[lno]] = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; lno--; } @@ -565,7 +565,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_SMALL(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_SMALL(s->k0); s->nblock_used++; } @@ -584,7 +584,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_FAST(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_FAST(s->k0); s->nblock_used++; } @@ -653,7 +653,7 @@ Int32 BZ2_decompress ( DState* s ) s->save_gBase = gBase; s->save_gPerm = gPerm; - return retVal; + return retVal; } diff --git a/src/cmd/bzip2/lib/huffman.c b/src/cmd/bzip2/lib/huffman.c index 9cad09706..9388ef213 100644 --- a/src/cmd/bzip2/lib/huffman.c +++ b/src/cmd/bzip2/lib/huffman.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -102,7 +102,7 @@ /*---------------------------------------------------*/ -void BZ2_hbMakeCodeLengths ( UChar *len, +void BZ2_hbMakeCodeLengths ( UChar *len, Int32 *freq, Int32 alphaSize, Int32 maxLen ) @@ -116,7 +116,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; - Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; + Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; for (i = 0; i < alphaSize; i++) weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; @@ -138,7 +138,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, } AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); - + while (nHeap > 1) { n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); @@ -161,7 +161,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, len[i-1] = j; if (j > maxLen) tooLong = True; } - + if (! tooLong) break; for (i = 1; i < alphaSize; i++) { diff --git a/src/cmd/bzip2/lib/os.h b/src/cmd/bzip2/lib/os.h index aa196a878..1236e5d58 100644 --- a/src/cmd/bzip2/lib/os.h +++ b/src/cmd/bzip2/lib/os.h @@ -76,7 +76,7 @@ typedef int Int32; typedef unsigned int UInt32; typedef short Int16; typedef unsigned short UInt16; - + #define True ((Bool)1) #define False ((Bool)0) @@ -85,4 +85,3 @@ typedef unsigned short UInt16; Only here to avoid probs with 64-bit platforms. --*/ typedef int IntNative; - diff --git a/src/cmd/bzip2/lib/randtable.c b/src/cmd/bzip2/lib/randtable.c index 2ab1e952d..c6d70773a 100644 --- a/src/cmd/bzip2/lib/randtable.c +++ b/src/cmd/bzip2/lib/randtable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -64,58 +64,58 @@ /*---------------------------------------------*/ -Int32 BZ2_rNums[512] = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, +Int32 BZ2_rNums[512] = { + 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, + 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, + 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, + 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, + 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, + 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, + 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, + 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, + 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, + 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, + 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, + 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, + 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, + 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, + 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, + 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, + 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, + 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, + 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, + 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, + 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, + 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, + 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, + 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, + 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, + 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, + 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, + 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, + 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, + 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, + 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, + 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, + 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, + 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, + 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, + 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, + 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, + 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, + 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, + 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, + 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, + 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, + 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, + 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, + 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, + 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, + 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, + 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, + 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, + 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, + 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 936, 638 }; diff --git a/src/cmd/bzip2/lib/unix.h b/src/cmd/bzip2/lib/unix.h index e47197b82..797ba1187 100644 --- a/src/cmd/bzip2/lib/unix.h +++ b/src/cmd/bzip2/lib/unix.h @@ -5,4 +5,3 @@ #include #include #include - diff --git a/src/cmd/calendar.c b/src/cmd/calendar.c index 778c76082..c936a286a 100644 --- a/src/cmd/calendar.c +++ b/src/cmd/calendar.c @@ -99,7 +99,7 @@ main(int argc, char *argv[]) exits(""); } -char *months[] = +char *months[] = { "january", "february", @@ -146,7 +146,7 @@ dates(Date **last, Tm *tm) first = alloc(sizeof(Date)); if(*last) (*last)->next = first; - first->p = regcomp(buf); + first->p = regcomp(buf); if (matchyear) snprint(buf, sizeof buf, @@ -159,7 +159,7 @@ dates(Date **last, Tm *tm) if(debug) print("%s\n", buf); nd = alloc(sizeof(Date)); - nd->p = regcomp(buf); + nd->p = regcomp(buf); nd->next = 0; first->next = nd; *last = nd; diff --git a/src/cmd/cat.c b/src/cmd/cat.c index ac5888979..8fdcf4ec3 100644 --- a/src/cmd/cat.c +++ b/src/cmd/cat.c @@ -33,4 +33,3 @@ main(int argc, char *argv[]) } exits(0); } - diff --git a/src/cmd/cb/cb.c b/src/cmd/cb/cb.c index 9e611f042..ebca5cc5e 100644 --- a/src/cmd/cb/cb.c +++ b/src/cmd/cb/cb.c @@ -1007,7 +1007,7 @@ clearif(struct indent *cl) int i; for(i=0;iifc[i] = 0; } -char +char puttmp(char c, int keep) { if(tp < &temp[TEMP-120]) diff --git a/src/cmd/cmp.c b/src/cmd/cmp.c index 4f69e1815..f06f12a51 100644 --- a/src/cmd/cmp.c +++ b/src/cmd/cmp.c @@ -88,7 +88,7 @@ main(int argc, char *argv[]) print("%6lld 0x%.2x 0x%.2x\n", nc+i, *p, *q); } } - } + } if(Lflag) for(p = b1s; p < b1e;) if(*p++ == '\n') diff --git a/src/cmd/date.c b/src/cmd/date.c index fc2ec5af5..272f5ec8c 100644 --- a/src/cmd/date.c +++ b/src/cmd/date.c @@ -25,6 +25,6 @@ main(int argc, char *argv[]) print("%s", asctime(gmtime(now))); else print("%s", ctime(now)); - + exits(0); } diff --git a/src/cmd/db/command.c b/src/cmd/db/command.c index 55ed02a82..b89318e80 100644 --- a/src/cmd/db/command.c +++ b/src/cmd/db/command.c @@ -76,26 +76,26 @@ command(char *buf, int defcom) break; case '>': - lastcom = savecom; + lastcom = savecom; savc=rdc(); if (reg=regname(savc)) rput(correg, reg, dot); - else + else error("bad variable"); break; case '!': lastcom=savecom; - shell(); + shell(); break; case '$': lastcom=savecom; - printdollar(nextchar()); + printdollar(nextchar()); break; case ':': - if (!executing) { + if (!executing) { executing=TRUE; subpcs(nextchar()); executing=FALSE; @@ -107,7 +107,7 @@ command(char *buf, int defcom) prints(DBNAME); break; - default: + default: error("bad command"); } flushbuf(); @@ -159,21 +159,21 @@ acommand(int pc) { case 'm': if (eqcom) - error(BADEQ); + error(BADEQ); cmdmap(map); break; case 'L': case 'l': if (eqcom) - error(BADEQ); + error(BADEQ); cmdsrc(lastc, map); break; case 'W': case 'w': if (eqcom) - error(BADEQ); + error(BADEQ); cmdwrite(lastc, map); break; @@ -199,10 +199,10 @@ cmdsrc(int c, Map *map) else dotinc = 2; savdot=dot; - expr(1); + expr(1); locval=expv; if (expr(0)) - locmsk=expv; + locmsk=expv; else locmsk = ~0; if (c == 'L') @@ -211,8 +211,8 @@ cmdsrc(int c, Map *map) else while ((ret = get2(map, dot, &sh)) > 0 && (sh&locmsk) != locval) dot = inkdot(dotinc); - if (ret < 0) { - dot=savdot; + if (ret < 0) { + dot=savdot; error("%r"); } symoff(buf, 512, dot, CANY); @@ -235,7 +235,7 @@ cmdwrite(int wcom, Map *map) expr(1); pass = 0; do { - pass++; + pass++; savdot=dot; exform(1, 1, format, map, 0, pass); dot=savdot; @@ -247,7 +247,7 @@ cmdwrite(int wcom, Map *map) error(badwrite); } savdot=dot; - dprint("=%8t"); + dprint("=%8t"); exform(1, 0, format, map, 0, pass); newline(); } while (expr(0)); @@ -305,7 +305,7 @@ shell(void) } break; } - prints("!"); + prints("!"); reread(); } } diff --git a/src/cmd/db/expr.c b/src/cmd/db/expr.c index 74c9319a7..72b8c9067 100644 --- a/src/cmd/db/expr.c +++ b/src/cmd/db/expr.c @@ -186,7 +186,7 @@ item(int a) return 1; } error("bad file location"); - } else if (symchar(0)) { + } else if (symchar(0)) { readsym(gsym); if (lastc=='.') { readchar(); /* ugh */ @@ -212,7 +212,7 @@ item(int a) reread(); } else if (getnum(readchar)) { ; - } else if (lastc=='.') { + } else if (lastc=='.') { readchar(); if (!symchar(0) && lastc != '.') { expv = dot; @@ -228,7 +228,7 @@ item(int a) if (localaddr(cormap, correg, s.name, lsym, &u) < 0) error("%r"); expv = u; - } + } reread(); } else if (lastc=='"') { expv=ditto; @@ -245,7 +245,7 @@ item(int a) expv = ascval(); else if (a) error("address expected"); - else { + else { reread(); return(0); } diff --git a/src/cmd/db/input.c b/src/cmd/db/input.c index 8cd091b01..bd97cd707 100644 --- a/src/cmd/db/input.c +++ b/src/cmd/db/input.c @@ -144,7 +144,7 @@ getformat(char *deformat) * * we handle this case specially because we have to look ahead * at the token after the colon to decide if it is a file reference - * or a colon-command with a symbol name prefix. + * or a colon-command with a symbol name prefix. */ int diff --git a/src/cmd/db/output.c b/src/cmd/db/output.c index 176cec285..db4d0fa25 100644 --- a/src/cmd/db/output.c +++ b/src/cmd/db/output.c @@ -77,7 +77,7 @@ iclose(int stack, int err) infile = STDIN; } else { if (infile) { - close(infile); + close(infile); infile=STDIN; } if (ifiledepth > 0) { diff --git a/src/cmd/db/pcs.c b/src/cmd/db/pcs.c index b876f50ab..681819da6 100644 --- a/src/cmd/db/pcs.c +++ b/src/cmd/db/pcs.c @@ -29,7 +29,7 @@ subpcs(int modif) switch (modif) { /* delete breakpoint */ - case 'd': + case 'd': case 'D': if ((bk=scanbkpt(dot)) == 0) error("no breakpoint set"); @@ -37,7 +37,7 @@ subpcs(int modif) return; /* set breakpoint */ - case 'b': + case 'b': case 'B': if (bk=scanbkpt(dot)) bk->flag=BKPTCLR; @@ -80,7 +80,7 @@ subpcs(int modif) return; /* run program */ - case 'r': + case 'r': case 'R': endpcs(); setup(); @@ -88,7 +88,7 @@ subpcs(int modif) break; /* single step */ - case 's': + case 's': if (pid == 0) { setup(); loopcnt--; @@ -119,8 +119,8 @@ subpcs(int modif) loopcnt = 0; break; /* continue with optional note */ - case 'c': - case 'C': + case 'c': + case 'C': if (pid==0) error(NOPCS); runmode=CONTIN; diff --git a/src/cmd/db/setup.c b/src/cmd/db/setup.c index eaeb61f2b..15a196e11 100644 --- a/src/cmd/db/setup.c +++ b/src/cmd/db/setup.c @@ -100,15 +100,15 @@ cmdmap(Map *map) /* textseg(expv, &fhdr); */ map->seg[i].base = expv; } else - error("Invalid base address"); + error("Invalid base address"); if (expr(0)) map->seg[i].size = expv - map->seg[i].base; else - error("Invalid end address"); + error("Invalid end address"); if (expr(0)) - map->seg[i].offset = expv; + map->seg[i].offset = expv; else - error("Invalid file offset"); + error("Invalid file offset"); /* if (rdc()=='?' && map == cormap) { if (fcor) diff --git a/src/cmd/deroff.c b/src/cmd/deroff.c index 1b758efec..0ad083759 100644 --- a/src/cmd/deroff.c +++ b/src/cmd/deroff.c @@ -13,7 +13,7 @@ * Deroff follows .so and .nx commands, removes contents of macro * definitions, equations (both .EQ ... .EN and $...$), * Tbl command sequences, and Troff backslash vconstructions. - * + * * All input is through the C macro; the most recently read character is in c. */ @@ -37,7 +37,7 @@ #define C fC() #define C1 fC1() -#define SKIP while(C != '\n') +#define SKIP while(C != '\n') #define SKIP1 while(C1 != '\n') #define SKIP_TO_COM SKIP;\ SKIP;\ @@ -211,7 +211,7 @@ skeqn(void) c = C1; else if(c == '"') while(C1 != '"') - if(c == '\\') + if(c == '\\') C1; if (msflag) eqnflag = 1; @@ -257,9 +257,9 @@ getfname(void) Rune r; Dir *dir; struct chain - { - struct chain* nextp; - char* datap; + { + struct chain* nextp; + char* datap; } *q; static struct chain *namechain= 0; @@ -470,7 +470,7 @@ comline(void) else if(filesp==files && c1=='T' && (c2=='S' || c2=='C' || c2=='&')) { if(msflag) - stbl(); + stbl(); else tbl(); } @@ -512,11 +512,11 @@ comline(void) SKIP; else if(c1=='h' && c2=='w') - SKIP; + SKIP; else if(msflag && c1 == 'T' && c2 == 'L') { SKIP_TO_COM; - goto comx; + goto comx; } else if(msflag && c1=='N' && c2 == 'R') @@ -526,17 +526,17 @@ comline(void) if(mac==MM)SKIP; else { SKIP_TO_COM; - goto comx; + goto comx; } } else if(msflag && c1=='F' && c2=='S') { SKIP_TO_COM; - goto comx; + goto comx; } else if(msflag && (c1=='S' || c1=='N') && c2=='H') { SKIP_TO_COM; - goto comx; + goto comx; } else if(c1 == 'U' && c2 == 'X') { if(wordflag) @@ -546,7 +546,7 @@ comline(void) } else if(msflag && c1=='O' && c2=='K') { SKIP_TO_COM; - goto comx; + goto comx; } else if(msflag && c1=='N' && c2=='D') SKIP; @@ -565,11 +565,11 @@ comline(void) if(!msflag && c1=='P' && c2=='S') { inpic(); } else - if(msflag && (c1=='D' || c1=='N' || c1=='K'|| c1=='P') && c2=='S') { - sdis(c1, 'E'); + if(msflag && (c1=='D' || c1=='N' || c1=='K'|| c1=='P') && c2=='S') { + sdis(c1, 'E'); } else - if(msflag && (c1 == 'K' && c2 == 'F')) { - sdis(c1,'E'); + if(msflag && (c1 == 'K' && c2 == 'F')) { + sdis(c1,'E'); } else if(msflag && c1=='n' && c2=='f') sdis('f','i'); @@ -601,8 +601,8 @@ void macro(void) { if(msflag) { - do { - SKIP1; + do { + SKIP1; } while(C1 != '.' || C1 != '.' || C1 == '.'); if(c != '\n') SKIP; @@ -660,7 +660,7 @@ sdis(char a1, char a2) SKIP1; } else if(a1 == 'D' && c1 == 'E' && c2 == 'Q') { - eqn(); + eqn(); eqnf = 0; } else if(a1 == 'f') { @@ -720,8 +720,8 @@ eqn(void) Bputc(&bout, 'x'); Bputc(&bout, ' '); if(last) { - Bputc(&bout, last); - Bputc(&bout, '\n'); + Bputc(&bout, last); + Bputc(&bout, '\n'); } } return; @@ -744,7 +744,7 @@ eqn(void) dflg = 0; } if(c != '\n') - while(C1 != '\n') { + while(C1 != '\n') { if(chars[c] == PUNCT) last = c; else @@ -762,7 +762,7 @@ backsl(void) { int bdelim; -sw: +sw: switch(C1) { case '"': diff --git a/src/cmd/devdraw/bigarrow.h b/src/cmd/devdraw/bigarrow.h index 1221ec8c1..4bfe02450 100644 --- a/src/cmd/devdraw/bigarrow.h +++ b/src/cmd/devdraw/bigarrow.h @@ -14,70 +14,70 @@ Cursor bigarrow = { Cursor2 bigarrow2 = { { -2, -2 }, - { 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xC0, 0x00, 0x00, 0x03, - 0xC0, 0x00, 0x00, 0x07, - 0xC0, 0x00, 0x00, 0x1E, - 0xC0, 0x00, 0x00, 0x3C, - 0xC0, 0x00, 0x00, 0xF0, - 0xC0, 0x00, 0x03, 0xE0, - 0xC0, 0x00, 0x0F, 0x80, - 0xC0, 0x00, 0x0E, 0x00, - 0xC0, 0x00, 0x07, 0x00, - 0xC0, 0x00, 0x03, 0x80, - 0xC0, 0x00, 0x01, 0xC0, - 0xC0, 0x00, 0x00, 0xE0, - 0xC0, 0x00, 0x00, 0x70, - 0xC0, 0x00, 0x00, 0x38, - 0xC0, 0x00, 0x00, 0x1C, - 0xC0, 0x00, 0x00, 0x0E, - 0xC0, 0x00, 0x00, 0x07, - 0xC0, 0x00, 0x00, 0x03, - 0xC0, 0xC0, 0x00, 0x07, - 0xC0, 0xE0, 0x00, 0x0E, - 0xC1, 0xF0, 0x00, 0x1C, - 0xC1, 0xB8, 0x00, 0x38, - 0xC3, 0x9C, 0x00, 0x70, - 0xC3, 0x0E, 0x00, 0xE0, - 0xC7, 0x07, 0x01, 0xC0, - 0xCE, 0x03, 0x83, 0x80, - 0xCC, 0x01, 0xC7, 0x00, - 0xDC, 0x00, 0xEE, 0x00, - 0xF8, 0x00, 0x7C, 0x00, + { 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0x00, 0x00, 0x07, + 0xC0, 0x00, 0x00, 0x1E, + 0xC0, 0x00, 0x00, 0x3C, + 0xC0, 0x00, 0x00, 0xF0, + 0xC0, 0x00, 0x03, 0xE0, + 0xC0, 0x00, 0x0F, 0x80, + 0xC0, 0x00, 0x0E, 0x00, + 0xC0, 0x00, 0x07, 0x00, + 0xC0, 0x00, 0x03, 0x80, + 0xC0, 0x00, 0x01, 0xC0, + 0xC0, 0x00, 0x00, 0xE0, + 0xC0, 0x00, 0x00, 0x70, + 0xC0, 0x00, 0x00, 0x38, + 0xC0, 0x00, 0x00, 0x1C, + 0xC0, 0x00, 0x00, 0x0E, + 0xC0, 0x00, 0x00, 0x07, + 0xC0, 0x00, 0x00, 0x03, + 0xC0, 0xC0, 0x00, 0x07, + 0xC0, 0xE0, 0x00, 0x0E, + 0xC1, 0xF0, 0x00, 0x1C, + 0xC1, 0xB8, 0x00, 0x38, + 0xC3, 0x9C, 0x00, 0x70, + 0xC3, 0x0E, 0x00, 0xE0, + 0xC7, 0x07, 0x01, 0xC0, + 0xCE, 0x03, 0x83, 0x80, + 0xCC, 0x01, 0xC7, 0x00, + 0xDC, 0x00, 0xEE, 0x00, + 0xF8, 0x00, 0x7C, 0x00, 0xF0, 0x00, 0x38, 0x00, }, - { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0xFF, 0xFF, 0xF8, - 0x3F, 0xFF, 0xFF, 0xE0, - 0x3F, 0xFF, 0xFF, 0xC0, - 0x3F, 0xFF, 0xFF, 0x00, - 0x3F, 0xFF, 0xFC, 0x00, - 0x3F, 0xFF, 0xF0, 0x00, - 0x3F, 0xFF, 0xF0, 0x00, - 0x3F, 0xFF, 0xF8, 0x00, - 0x3F, 0xFF, 0xFC, 0x00, - 0x3F, 0xFF, 0xFE, 0x00, - 0x3F, 0xFF, 0xFF, 0x00, - 0x3F, 0xFF, 0xFF, 0x80, - 0x3F, 0xFF, 0xFF, 0xC0, - 0x3F, 0xFF, 0xFF, 0xE0, - 0x3F, 0xFF, 0xFF, 0xF0, - 0x3F, 0xFF, 0xFF, 0xF8, - 0x3F, 0xFF, 0xFF, 0xFC, - 0x3F, 0x3F, 0xFF, 0xF8, - 0x3F, 0x1F, 0xFF, 0xF0, - 0x3E, 0x0F, 0xFF, 0xE0, - 0x3E, 0x07, 0xFF, 0xC0, - 0x3C, 0x03, 0xFF, 0x80, - 0x3C, 0x01, 0xFF, 0x00, - 0x38, 0x00, 0xFE, 0x00, - 0x30, 0x00, 0x7C, 0x00, - 0x30, 0x00, 0x38, 0x00, - 0x20, 0x00, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, + { 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0xFF, 0xFF, 0xF8, + 0x3F, 0xFF, 0xFF, 0xE0, + 0x3F, 0xFF, 0xFF, 0xC0, + 0x3F, 0xFF, 0xFF, 0x00, + 0x3F, 0xFF, 0xFC, 0x00, + 0x3F, 0xFF, 0xF0, 0x00, + 0x3F, 0xFF, 0xF0, 0x00, + 0x3F, 0xFF, 0xF8, 0x00, + 0x3F, 0xFF, 0xFC, 0x00, + 0x3F, 0xFF, 0xFE, 0x00, + 0x3F, 0xFF, 0xFF, 0x00, + 0x3F, 0xFF, 0xFF, 0x80, + 0x3F, 0xFF, 0xFF, 0xC0, + 0x3F, 0xFF, 0xFF, 0xE0, + 0x3F, 0xFF, 0xFF, 0xF0, + 0x3F, 0xFF, 0xFF, 0xF8, + 0x3F, 0xFF, 0xFF, 0xFC, + 0x3F, 0x3F, 0xFF, 0xF8, + 0x3F, 0x1F, 0xFF, 0xF0, + 0x3E, 0x0F, 0xFF, 0xE0, + 0x3E, 0x07, 0xFF, 0xC0, + 0x3C, 0x03, 0xFF, 0x80, + 0x3C, 0x01, 0xFF, 0x00, + 0x38, 0x00, 0xFE, 0x00, + 0x30, 0x00, 0x7C, 0x00, + 0x30, 0x00, 0x38, 0x00, + 0x20, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } }; diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index c1cf59838..dcb1801ac 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -77,7 +77,7 @@ servep9p(void) Wsysmsg m; fmtinstall('W', drawfcallfmt); - + mbuf = nil; nmbuf = 0; while((n = read(3, buf, 4)) == 4){ @@ -106,15 +106,15 @@ void replyerror(Wsysmsg *m) { char err[256]; - + rerrstr(err, sizeof err); m->type = Rerror; m->error = err; replymsg(m); } -/* - * Handle a single wsysmsg. +/* + * Handle a single wsysmsg. * Might queue for later (kbd, mouse read) */ void @@ -123,7 +123,7 @@ runmsg(Wsysmsg *m) static uchar buf[65536]; int n; Memimage *i; - + switch(m->type){ case Tinit: memimageinit(); @@ -176,7 +176,7 @@ runmsg(Wsysmsg *m) setcursor(&m->cursor, &m->cursor2); replymsg(m); break; - + case Tbouncemouse: // _xbouncemouse(&m->mouse); replymsg(m); @@ -222,12 +222,12 @@ runmsg(Wsysmsg *m) replymsg(m); zunlock(); break; - + case Ttop: topwin(); replymsg(m); break; - + case Tresize: resizewindow(m->rect); replymsg(m); @@ -249,7 +249,7 @@ replymsg(Wsysmsg *m) /* T -> R msg */ if(m->type%2 == 0) m->type++; - + if(trace) fprint(2, "%ud [%d] -> %W\n", nsec()/1000000, threadid(), m); /* copy to output buffer */ n = sizeW2M(m); @@ -275,7 +275,7 @@ void matchkbd(void) { Wsysmsg m; - + if(kbd.stall) return; while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){ @@ -297,7 +297,7 @@ void matchmouse(void) { Wsysmsg m; - + while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){ m.type = Rrdmouse; m.tag = mousetags.t[mousetags.ri++]; @@ -321,7 +321,7 @@ void mousetrack(int x, int y, int b, uint ms) { Mouse *m; - + if(x < mouserect.min.x) x = mouserect.min.x; if(x > mouserect.max.x) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 7f0bff211..654ab4af6 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -160,11 +160,11 @@ _drawreplacescreenimage(Memimage *m) /* * Replace the screen image because the screen * was resized. - * + * * In theory there should only be one reference * to the current screen image, and that's through * client0's image 0, installed a few lines above. - * Once the client drops the image, the underlying backing + * Once the client drops the image, the underlying backing * store freed properly. The client is being notified * about the resize through external means, so all we * need to do is this assignment. @@ -769,7 +769,7 @@ _drawmsgwrite(void *v, int n) { char cbuf[40], *err, ibuf[12*12+1], *s; int c, ci, doflush, dstid, e0, e1, esize, j, m; - int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y; + int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y; uchar *a, refresh, *u; u32int chan, value; Client *client; @@ -969,7 +969,7 @@ _drawmsgwrite(void *v, int n) err = "negative ellipse thickness"; goto error; } - + drawpoint(&sp, a+29); c = j; if(*a == 'E') @@ -1073,11 +1073,11 @@ _drawmsgwrite(void *v, int n) ni = sprint(ibuf, "%11d %11d %11s %11d %11d %11d %11d %11d" " %11d %11d %11d %11d ", client->clientid, - client->infoid, + client->infoid, chantostr(cbuf, i->chan), (i->flags&Frepl)==Frepl, i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y, - i->clipr.min.x, i->clipr.min.y, + i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y); free(client->readdata); client->readdata = malloc(ni); @@ -1087,7 +1087,7 @@ _drawmsgwrite(void *v, int n) client->nreaddata = ni; client->infoid = -1; continue; - + /* query: 'Q' n[1] queryspec[n] */ case 'q': if(n < 2) @@ -1633,5 +1633,3 @@ _drawmsgwrite(void *v, int n) qunlock(&sdraw.lk); return -1; } - - diff --git a/src/cmd/devdraw/drawclient.c b/src/cmd/devdraw/drawclient.c index 87df3f18c..f61392894 100644 --- a/src/cmd/devdraw/drawclient.c +++ b/src/cmd/devdraw/drawclient.c @@ -20,7 +20,7 @@ void startsrv(void) { int pid, p[2]; - + if(pipe(p) < 0) sysfatal("pipe"); if((pid=fork()) < 0) @@ -56,7 +56,7 @@ void cmdinit(int argc, char **argv) { Wsysmsg m; - + memset(&m, 0, sizeof m); m.op = Tinit; m.winsize = "100x100"; @@ -70,7 +70,7 @@ void cmdmouse(int argc, char **argv) { Wsysmsg m; - + memset(&m, 0, sizeof m); m.op = Trdmouse; if(domsg(&m) < 0) @@ -86,7 +86,7 @@ void cmdkbd(int argc, char **argv) { Wsysmsg m; - + memset(&m, 0, sizeof m); m.op = Trdkbd; if(domsg(&m) < 0) @@ -125,4 +125,3 @@ fprint(2, "%s...\n", p); } exits(0); } - diff --git a/src/cmd/devdraw/latin1.c b/src/cmd/devdraw/latin1.c index 09c67523c..2fa9e29d2 100644 --- a/src/cmd/devdraw/latin1.c +++ b/src/cmd/devdraw/latin1.c @@ -58,7 +58,7 @@ _latin1(Rune *k, int n) else return -5; } - + for(l=latintab; l->ld!=0; l++) if(k[0] == l->ld[0]){ if(n == 1) diff --git a/src/cmd/devdraw/mklatinkbd.c b/src/cmd/devdraw/mklatinkbd.c index abd202fb7..db34b6ece 100644 --- a/src/cmd/devdraw/mklatinkbd.c +++ b/src/cmd/devdraw/mklatinkbd.c @@ -132,7 +132,7 @@ printtrie(Biobuf *b, Trie *t) printtrie(b, t->link[i]); if(t->n == 0) return; - + if(xflag) { for(i=0; i<256; i++) { if(t->r[i] == 0) @@ -142,7 +142,7 @@ printtrie(Biobuf *b, Trie *t) Bprint(b, " %k", *p); Bprint(b, " %k : \"%C\" U%04X\n", i, t->r[i], t->r[i]); } - return; + return; } Bprint(b, "\t\""); @@ -315,5 +315,3 @@ kfmt(Fmt *f) return fmtprint(f, "<%s>", xkey[i].s); return fmtprint(f, "<%c>", c); } - - diff --git a/src/cmd/devdraw/mouseswap.c b/src/cmd/devdraw/mouseswap.c index e6ece3339..29f33b7bf 100644 --- a/src/cmd/devdraw/mouseswap.c +++ b/src/cmd/devdraw/mouseswap.c @@ -51,7 +51,7 @@ mouseswap(int but) if(!map.init) initmap(); - + nbut = 0; for(i=0; i= 0) diff --git a/src/cmd/devdraw/nowsys.c b/src/cmd/devdraw/nowsys.c index fd8b7ee16..08e0521fd 100644 --- a/src/cmd/devdraw/nowsys.c +++ b/src/cmd/devdraw/nowsys.c @@ -18,14 +18,14 @@ main(int argc, char **argv) int n; uchar buf[1024*1024]; Wsysmsg m; - + ARGBEGIN{ case 'D': break; default: usage(); }ARGEND - + if(argc != 0) usage(); diff --git a/src/cmd/devdraw/osx-draw.c b/src/cmd/devdraw/osx-draw.c index d3f083316..fdf7acecd 100644 --- a/src/cmd/devdraw/osx-draw.c +++ b/src/cmd/devdraw/osx-draw.c @@ -56,4 +56,3 @@ unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata) { return _unloadmemimage(i, r, data, ndata); } - diff --git a/src/cmd/devdraw/snarf.c b/src/cmd/devdraw/snarf.c index 1e7a93a1c..4d350654d 100644 --- a/src/cmd/devdraw/snarf.c +++ b/src/cmd/devdraw/snarf.c @@ -96,7 +96,7 @@ runxevent(XEvent *xev) case Expose: _xexpose(xev); break; - + case DestroyNotify: if(_xdestroy(xev)) exits(0); @@ -107,4 +107,3 @@ runxevent(XEvent *xev) break; } } - diff --git a/src/cmd/devdraw/x11-alloc.c b/src/cmd/devdraw/x11-alloc.c index a465f998b..9d85b4514 100644 --- a/src/cmd/devdraw/x11-alloc.c +++ b/src/cmd/devdraw/x11-alloc.c @@ -121,4 +121,3 @@ freememimage(Memimage *m) } _freememimage(m); } - diff --git a/src/cmd/devdraw/x11-cload.c b/src/cmd/devdraw/x11-cload.c index 33e3170a5..1666ecede 100644 --- a/src/cmd/devdraw/x11-cload.c +++ b/src/cmd/devdraw/x11-cload.c @@ -15,4 +15,3 @@ cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata) _xputxdata(i, r); return n; } - diff --git a/src/cmd/devdraw/x11-draw.c b/src/cmd/devdraw/x11-draw.c index 685ad88a7..f3b6a6897 100644 --- a/src/cmd/devdraw/x11-draw.c +++ b/src/cmd/devdraw/x11-draw.c @@ -147,4 +147,3 @@ xdraw(Memdrawparam *par) */ return 0; } - diff --git a/src/cmd/devdraw/x11-fill.c b/src/cmd/devdraw/x11-fill.c index fc43a684f..adead1ead 100644 --- a/src/cmd/devdraw/x11-fill.c +++ b/src/cmd/devdraw/x11-fill.c @@ -23,7 +23,7 @@ _xfillcolor(Memimage *m, Rectangle r, u32int v) Point p; Xmem *xm; XGC gc; - + xm = m->X; assert(xm != nil); @@ -52,5 +52,3 @@ _xfillcolor(Memimage *m, Rectangle r, u32int v) p = subpt(r.min, m->r.min); XFillRectangle(_x.display, xm->pixmap, gc, p.x, p.y, Dx(r), Dy(r)); } - - diff --git a/src/cmd/devdraw/x11-get.c b/src/cmd/devdraw/x11-get.c index 1a47be01d..61913f184 100644 --- a/src/cmd/devdraw/x11-get.c +++ b/src/cmd/devdraw/x11-get.c @@ -21,7 +21,7 @@ _xgetxdata(Memimage *m, Rectangle r) uchar *p; Point tp, xdelta, delta; Xmem *xm; - + xm = m->X; if(xm == nil) return nil; @@ -83,7 +83,7 @@ _xputxdata(Memimage *m, Rectangle r) XPutImage(_x.display, xm->pixmap, gc, xi, xdelta.x, xdelta.y, delta.x, delta.y, Dx(r), Dy(r)); - + if(_x.usetable && m->chan==CMAP8){ for(y=r.min.y; ydirty = 1; addrect(&xm->dirtyr, r); } - - - diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index f09963dce..8935c9d15 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -95,7 +95,7 @@ _xattach(char *label, char *winsize) xrootid = DefaultScreen(_x.display); xrootwin = DefaultRootWindow(_x.display); - /* + /* * Figure out underlying screen format. */ if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi) @@ -207,7 +207,7 @@ _xattach(char *label, char *winsize) /* * Parse the various X resources. Thanks to Peter Canning. */ - char *screen_resources, *display_resources, *geom, + char *screen_resources, *display_resources, *geom, *geomrestype, *home, *file, *dpitype; XrmDatabase database; XrmValue geomres, dpires; @@ -548,7 +548,7 @@ plan9cmap(void) * be the default depth. On such "suboptimal" systems, we have to allocate an * empty color map anyway, according to Axel Belinfante. */ -static int +static int setupcmap(XWindow w) { char buf[30]; @@ -561,16 +561,16 @@ setupcmap(XWindow w) if(_x.depth >= 24) { if(_x.usetable == 0) - _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); /* * The pixel value returned from XGetPixel needs to * be converted to RGB so we can call rgb2cmap() * to translate between 24 bit X and our color. Unfortunately, - * the return value appears to be display server endian + * the return value appears to be display server endian * dependant. Therefore, we run some heuristics to later * determine how to mask the int value correctly. - * Yeah, I know we can look at _x.vis->byte_order but + * Yeah, I know we can look at _x.vis->byte_order but * some displays say MSB even though they run on LSB. * Besides, this is more anal. */ @@ -611,7 +611,7 @@ setupcmap(XWindow w) _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); }else if(_x.vis->class == PseudoColor){ if(_x.usetable == 0){ - _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll); + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll); XStoreColors(_x.display, _x.cmap, _x.map, 256); for(i = 0; i < 256; i++){ _x.tox11[i] = i; diff --git a/src/cmd/devdraw/x11-itrans.c b/src/cmd/devdraw/x11-itrans.c index 729f26473..bdf7d2b2e 100644 --- a/src/cmd/devdraw/x11-itrans.c +++ b/src/cmd/devdraw/x11-itrans.c @@ -97,7 +97,7 @@ __xtoplan9kbd(XEvent *e) case XK_KP_End: k = Kend; break; - case XK_Page_Up: + case XK_Page_Up: case XK_KP_Page_Up: k = Kpgup; break; @@ -243,7 +243,7 @@ _xtoplan9mouse(XEvent *e, Mouse *m) case ButtonPress: be = (XButtonEvent*)e; - /* + /* * Fake message, just sent to make us announce snarf. * Apparently state and button are 16 and 8 bits on * the wire, since they are truncated by the time they @@ -443,7 +443,7 @@ _xgetsnarffrom(XWindow w, Atom clipboard, Atom target, int timeout0, int timeout /* get the property */ xdata = nil; - XGetWindowProperty(_x.display, _x.drawable, prop, 0, SnarfSize/sizeof(ulong), 0, + XGetWindowProperty(_x.display, _x.drawable, prop, 0, SnarfSize/sizeof(ulong), 0, AnyPropertyType, &type, &fmt, &len, &dummy, &xdata); if((type != target && type != XA_STRING && type != _x.utf8string) || len == 0){ if(xdata) @@ -500,7 +500,7 @@ _xgetsnarf(void) data = nil; goto out; } - + if((data = _xgetsnarffrom(w, clipboard, _x.utf8string, 10, 100)) == nil) if((data = _xgetsnarffrom(w, clipboard, XA_STRING, 10, 100)) == nil){ /* nothing left to do */ @@ -554,9 +554,9 @@ if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d (sizeof a[3] = _x.compoundtext; XChangeProperty(_x.display, xe->requestor, xe->property, XA_ATOM, 32, PropModeReplace, (uchar*)a, nelem(a)); - }else if(xe->target == XA_STRING - || xe->target == _x.utf8string - || xe->target == _x.text + }else if(xe->target == XA_STRING + || xe->target == _x.utf8string + || xe->target == _x.text || xe->target == _x.compoundtext || ((name = XGetAtomName(_x.display, xe->target)) && strcmp(name, "text/plain;charset=UTF-8") == 0)){ /* text/plain;charset=UTF-8 seems nonstandard but is used by Synergy */ @@ -643,7 +643,7 @@ _applegetsnarf(void) CFRelease(flavors); } qunlock(&clip.lk); - return nil; + return nil; } void @@ -677,7 +677,7 @@ _appleputsnarf(char *s) qunlock(&clip.lk); return; } - cfdata = CFDataCreate(kCFAllocatorDefault, + cfdata = CFDataCreate(kCFAllocatorDefault, (uchar*)clip.rbuf, runestrlen(clip.rbuf)*2); if(cfdata == nil){ fprint(2, "apple pasteboard cfdatacreate failed\n"); diff --git a/src/cmd/devdraw/x11-keysym2ucs.c b/src/cmd/devdraw/x11-keysym2ucs.c index 108f153c7..853fa552d 100644 --- a/src/cmd/devdraw/x11-keysym2ucs.c +++ b/src/cmd/devdraw/x11-keysym2ucs.c @@ -34,7 +34,7 @@ */ #ifndef KEYSYM2UCS_INCLUDED - + #include "x11-keysym2ucs.h" #define VISIBLE /* */ diff --git a/src/cmd/devdraw/x11-load.c b/src/cmd/devdraw/x11-load.c index a7446f37d..895e11096 100644 --- a/src/cmd/devdraw/x11-load.c +++ b/src/cmd/devdraw/x11-load.c @@ -15,4 +15,3 @@ loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata) _xputxdata(i, r); return n; } - diff --git a/src/cmd/devdraw/x11-pixelbits.c b/src/cmd/devdraw/x11-pixelbits.c index 5cbdded84..5227f39b5 100644 --- a/src/cmd/devdraw/x11-pixelbits.c +++ b/src/cmd/devdraw/x11-pixelbits.c @@ -12,5 +12,3 @@ pixelbits(Memimage *m, Point p) _xgetxdata(m, Rect(p.x, p.y, p.x+1, p.y+1)); return _pixelbits(m, p); } - - diff --git a/src/cmd/devdraw/x11-srv.c b/src/cmd/devdraw/x11-srv.c index 814164827..4d72415b1 100644 --- a/src/cmd/devdraw/x11-srv.c +++ b/src/cmd/devdraw/x11-srv.c @@ -147,12 +147,12 @@ main(int argc, char **argv) /* * Ignore arguments. They're only for good ps -a listings. */ - + notify(bell); fdin.rp = fdin.wp = fdin.buf; fdin.ep = fdin.buf+sizeof fdin.buf; - + fdout.rp = fdout.wp = fdout.buf; fdout.ep = fdout.buf+sizeof fdout.buf; @@ -222,7 +222,7 @@ main(int argc, char **argv) runmsg(&m); fdin.rp += n; } - + /* slide data to beginning of buf */ fdslide(&fdin); } @@ -277,7 +277,7 @@ void replyerror(Wsysmsg *m) { char err[256]; - + rerrstr(err, sizeof err); m->type = Rerror; m->error = err; @@ -286,8 +286,8 @@ replyerror(Wsysmsg *m) -/* - * Handle a single wsysmsg. +/* + * Handle a single wsysmsg. * Might queue for later (kbd, mouse read) */ void @@ -296,7 +296,7 @@ runmsg(Wsysmsg *m) uchar buf[65536]; int n; Memimage *i; - + switch(m->type){ case Tinit: memimageinit(); @@ -339,7 +339,7 @@ runmsg(Wsysmsg *m) _xsetcursor(&m->cursor); replymsg(m); break; - + case Tbouncemouse: _xbouncemouse(&m->mouse); replymsg(m); @@ -381,12 +381,12 @@ runmsg(Wsysmsg *m) else replymsg(m); break; - + case Ttop: _xtopwindow(); replymsg(m); break; - + case Tresize: _xresizewindow(m->rect); replymsg(m); @@ -405,7 +405,7 @@ replymsg(Wsysmsg *m) /* T -> R msg */ if(m->type%2 == 0) m->type++; - + /* fprint(2, "-> %W\n", m); */ /* copy to output buffer */ n = sizeW2M(m); @@ -422,7 +422,7 @@ void matchkbd(void) { Wsysmsg m; - + if(kbd.stall) return; while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){ @@ -444,7 +444,7 @@ void matchmouse(void) { Wsysmsg m; - + while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){ m.type = Rrdmouse; m.tag = mousetags.t[mousetags.ri++]; @@ -519,7 +519,7 @@ runxevent(XEvent *xev) case Expose: _xexpose(xev); break; - + case DestroyNotify: if(_xdestroy(xev)) exits(0); @@ -552,7 +552,7 @@ runxevent(XEvent *xev) return; sendmouse(m); break; - + case KeyRelease: case KeyPress: ke = (XKeyEvent*)xev; @@ -618,7 +618,7 @@ runxevent(XEvent *xev) kbd.stall = 1; matchkbd(); break; - + case FocusOut: /* * Some key combinations (e.g. Alt-Tab) can cause us @@ -629,10 +629,9 @@ runxevent(XEvent *xev) altdown = 0; abortcompose(); break; - + case SelectionRequest: _xselect(xev); break; } } - diff --git a/src/cmd/devdraw/x11-unload.c b/src/cmd/devdraw/x11-unload.c index d01a232ff..2f6241ba9 100644 --- a/src/cmd/devdraw/x11-unload.c +++ b/src/cmd/devdraw/x11-unload.c @@ -12,4 +12,3 @@ unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata) _xgetxdata(i, r); return _unloadmemimage(i, r, data, ndata); } - diff --git a/src/cmd/devdraw/x11-wsys.c b/src/cmd/devdraw/x11-wsys.c index 9095c950d..82a7d32c1 100644 --- a/src/cmd/devdraw/x11-wsys.c +++ b/src/cmd/devdraw/x11-wsys.c @@ -43,4 +43,3 @@ _xmovewindow(Rectangle r) XConfigureWindow(_x.display, _x.drawable, value_mask, &e); XFlush(_x.display); } - diff --git a/src/cmd/dict/dict.c b/src/cmd/dict/dict.c index d9cdca624..3c8597c6f 100644 --- a/src/cmd/dict/dict.c +++ b/src/cmd/dict/dict.c @@ -678,7 +678,7 @@ setdotprev(void) /* * find the specified file and return a path. - * default location is #9/dict, but can be + * default location is #9/dict, but can be * in $dictdir instead. */ char* @@ -686,12 +686,12 @@ dictfile(char *f) { static char *dict; static int did; - + if(!did){ dict = getenv("dictpath"); did = 1; } - + if(dict) return smprint("%s/%s", dict, f); return unsharp(smprint("#9/dict/%s", f)); diff --git a/src/cmd/dict/oed.c b/src/cmd/dict/oed.c index 81efe829b..5161456f8 100644 --- a/src/cmd/dict/oed.c +++ b/src/cmd/dict/oed.c @@ -816,7 +816,7 @@ static Assoc spectab[] = { bbc1 single chem bond below bbc2 double chem bond below bbl1 chem bond like / - bbl2 chem bond like // + bbl2 chem bond like // bbr1 chem bond like \ bbr2 chem bond \\ bcop1 copper symbol. Cf copper @@ -1253,7 +1253,7 @@ static char *prkey1 = "tʃ ... chop (tʃɒp), ditch (dɪtʃ)\n" "ʒ ... vision (ˈvɪʒən), déjeuner (deʒøne)\n" ; -static char *prkey2 = +static char *prkey2 = "dʒ ... judge (dʒʌdʒ)\n" "ŋ ... singing (ˈsɪŋɪŋ), think (θiŋk)\n" "ŋg ... finger (ˈfiŋgə(r))\n" @@ -1268,7 +1268,7 @@ static char *prkey2 = "ɥ ... Fr. cuisine (kɥizin)\n" "\n" ; -static char *prkey3 = +static char *prkey3 = "II. VOWELS AND DIPTHONGS\n" "\n" "Short\n" @@ -1308,7 +1308,7 @@ static char *prkey4 = "yː ... Ger. grün (gryːn)\n" "\n" ; -static char *prkey5 = +static char *prkey5 = "Nasal\n" "ɛ˜, æ˜ as in Fr. fin (fɛ˜, fæ˜)\n" "ã ... Fr. franc (frã)\n" @@ -1327,7 +1327,7 @@ static char *prkey5 = "ɔə ... boar (bɔə(r))\n" "\n" ; -static char *prkey6 = +static char *prkey6 = "III. STRESS\n" "\n" "Main stress: ˈ preceding stressed syllable\n" diff --git a/src/cmd/dict/pcollinsg.c b/src/cmd/dict/pcollinsg.c index cbdff9e6a..16a8a9133 100644 --- a/src/cmd/dict/pcollinsg.c +++ b/src/cmd/dict/pcollinsg.c @@ -142,7 +142,7 @@ pcollgprintentry(Entry e, int cmd) case TAGE: /* an extra one */ break; - + case SPCS: p = reach(p, 0xba); r = looknassoc(numtab, asize(numtab), strtol(tag,0,0)); @@ -183,7 +183,7 @@ pcollgprintentry(Entry e, int cmd) rprev = r; } } - + } if(rprev != NONE) outrune(rprev); diff --git a/src/cmd/dict/pgw.c b/src/cmd/dict/pgw.c index 8cdaec35e..5c93382af 100644 --- a/src/cmd/dict/pgw.c +++ b/src/cmd/dict/pgw.c @@ -993,7 +993,7 @@ pgwnextoff(long fromoff) if(c == '<' && Bgetc(bdict) == 'p' && Bgetc(bdict) == '>') { c = Bgetc(bdict); if(c == '<') { - if (Bgetc(bdict) == 'h' && Bgetc(bdict) == 'w' + if (Bgetc(bdict) == 'h' && Bgetc(bdict) == 'w' && Bgetc(bdict) == '>') n = 7; }else if (c == '{') @@ -1025,7 +1025,7 @@ static char *prkey1 = "tʃ ... chop (tʃɒp), ditch (dɪtʃ)\n" "ʒ ... vision (ˈvɪʒən), déjeuner (deʒøne)\n" ; -static char *prkey2 = +static char *prkey2 = "dʒ ... judge (dʒʌdʒ)\n" "ŋ ... singing (ˈsɪŋɪŋ), think (θiŋk)\n" "ŋg ... finger (ˈfiŋgə(r))\n" @@ -1040,7 +1040,7 @@ static char *prkey2 = "ɥ ... Fr. cuisine (kɥizin)\n" "\n" ; -static char *prkey3 = +static char *prkey3 = "II. VOWELS AND DIPTHONGS\n" "\n" "Short\n" @@ -1080,7 +1080,7 @@ static char *prkey4 = "yː ... Ger. grün (gryːn)\n" "\n" ; -static char *prkey5 = +static char *prkey5 = "Nasal\n" "ɛ˜, æ˜ as in Fr. fin (fɛ˜, fæ˜)\n" "ã ... Fr. franc (frã)\n" @@ -1099,7 +1099,7 @@ static char *prkey5 = "ɔə ... boar (bɔə(r))\n" "\n" ; -static char *prkey6 = +static char *prkey6 = "III. STRESS\n" "\n" "Main stress: ˈ preceding stressed syllable\n" diff --git a/src/cmd/dict/roget.c b/src/cmd/dict/roget.c index d95363658..6562315f7 100644 --- a/src/cmd/dict/roget.c +++ b/src/cmd/dict/roget.c @@ -23,7 +23,7 @@ rogetprintentry(Entry e, int cmd) while(strncmp(p, " -- ", 4) != 0 && p < e.end){ while(isspace((uchar)*p) && p < e.end) p++; - if (*p == '[' || *p == '{'){ + if (*p == '[' || *p == '{'){ c = (*p == '[')? ']': '}'; while(*p != c && p < e.end) p++; @@ -49,7 +49,7 @@ rogetprintentry(Entry e, int cmd) outchar(*p++); } return; - } + } while(p < e.end && !isspace((uchar)*p)) p++; @@ -62,7 +62,7 @@ rogetprintentry(Entry e, int cmd) p += 4; spc = 0; } - + if (p < e.end -2 && strncmp(p, "[ ", 4) == 0){ /* twiddle layout */ outchars(" ["); continue; diff --git a/src/cmd/dict/world.c b/src/cmd/dict/world.c index 6ead3ed6d..c25a31c07 100644 --- a/src/cmd/dict/world.c +++ b/src/cmd/dict/world.c @@ -50,7 +50,7 @@ static Rune chartab[] = { 0x26a, 0xf0, 0x292, 0xe3, 0x153, 0x169, 0x28c, 0x265, /*c0*/ 0x280, 0xeb, 0x6c, 0x28c, 0xf5, 0xf1, 0x152, NONE, NONE, 0x53, 0x73, 0x5a, 0x7a, NONE, NONE, NONE, -/*d0*/ 0xdf, NONE, NONE, 0x101, 0x12b, 0x16b, 0x113, 0x14d, +/*d0*/ 0xdf, NONE, NONE, 0x101, 0x12b, 0x16b, 0x113, 0x14d, NONE, NONE, NONE, 0x20, NONE, NONE, NONE, NONE, /*e0*/ 0x3b1, 0x3b2, 0x3b3, 0x3c0, 0x3a3, 0x3c3, 0xb5, 0x3c4, diff --git a/src/cmd/diff/diffio.c b/src/cmd/diff/diffio.c index 93de4e378..75a725ffd 100644 --- a/src/cmd/diff/diffio.c +++ b/src/cmd/diff/diffio.c @@ -54,7 +54,7 @@ readline(Biobuf *bp, char *buf) /* * hashing has the effect of * arranging line in 7-bit bytes and then - * summing 1-s complement in 16-bit hunks + * summing 1-s complement in 16-bit hunks */ static int readhash(Biobuf *bp, char *buf) @@ -346,7 +346,7 @@ flushchanges(void) if(nchanges == 0) return; - + for(i=0; iold); }else sprint(oldfile, "%s%s", oldroot, f->new); - if(strlen(newfile) >= sizeof newfile + if(strlen(newfile) >= sizeof newfile || strlen(oldfile) >= sizeof oldfile) error("name overfile"); } diff --git a/src/cmd/draw/cmapcube.c b/src/cmd/draw/cmapcube.c index 3d0e14e8c..4d56322b6 100644 --- a/src/cmd/draw/cmapcube.c +++ b/src/cmd/draw/cmapcube.c @@ -109,7 +109,7 @@ redraw(void) line3(v[0x36], v[0x32]); line3(v[0x32], v[0x3F]); line3(v[0x3F], v[0]); - + line3(v[0xF0], v[0xF3]); line3(v[0xF3], v[0xFF]); line3(v[0xFF], v[0xFC]); diff --git a/src/cmd/draw/crop.c b/src/cmd/draw/crop.c index 10a08f77d..d6d89722f 100644 --- a/src/cmd/draw/crop.c +++ b/src/cmd/draw/crop.c @@ -76,7 +76,7 @@ crop(Memimage *m, uint32 c) bottom = y; } } - + if(n != nil) freememimage(n); return Rect(left, top, right+1, bottom+1); diff --git a/src/cmd/draw/gview.c b/src/cmd/draw/gview.c index 0794f1006..0f5e69055 100644 --- a/src/cmd/draw/gview.c +++ b/src/cmd/draw/gview.c @@ -1547,7 +1547,7 @@ void all_set_clr(fpolygons* fps, Image* clr) for (p=fps->p; p!=0; p=p->link) p->clr = clr; } - + void do_recolor(int but, Mouse* m, int alluniv) { @@ -1819,7 +1819,7 @@ e_action* do_undo(e_action* a0) /* pop off an e_action and (un)do it */ case Erecolor: a->fp->clr = a->clr; eresized(0); break; - case Edelete: + case Edelete: a->fp->link = univ.p; univ.p = a->fp; grow_bb(&univ.bb, &a->fp->bb); diff --git a/src/cmd/draw/mc.c b/src/cmd/draw/mc.c index ea36e28df..ee112194f 100644 --- a/src/cmd/draw/mc.c +++ b/src/cmd/draw/mc.c @@ -337,4 +337,3 @@ getwidth(void) }else linewidth = ws.ws_col; } - diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c index 74b8b76c7..3b6471b79 100644 --- a/src/cmd/draw/stats.c +++ b/src/cmd/draw/stats.c @@ -50,7 +50,7 @@ enum }; char* -labels[Nvalue] = +labels[Nvalue] = { "802.11", "battery", @@ -70,7 +70,7 @@ labels[Nvalue] = "sys", "syscall", "user" -}; +}; struct Graph { @@ -435,7 +435,7 @@ newvalue(Machine *m, int i, ulong *v, ulong *vmax) if(m->last[i] == 0) m->last[i] = m->val[i][0]; - + if(i == Vload){ /* * Invert the ewma to obtain the 5s load statistics. @@ -928,4 +928,3 @@ initmach(Machine *m, char *name) *q = 0; return 1; } - diff --git a/src/cmd/draw/statusbar.c b/src/cmd/draw/statusbar.c index fef6d2dd1..f67b10417 100644 --- a/src/cmd/draw/statusbar.c +++ b/src/cmd/draw/statusbar.c @@ -108,7 +108,7 @@ resize() p.x = r.min.x+4; p.y += display->defaultfont->height+4; - + q = subpt(r.max, Pt(4,4)); rbar = Rpt(p, q); border(screen, rbar, -2, dark, ZP); @@ -116,12 +116,12 @@ resize() lastp = -1; flushimage(display, 1); - drawbar(); + drawbar(); } void keyboardthread(void *v) -{ +{ Rune r; while(recv(kc->c , &r) == 1){ @@ -132,9 +132,9 @@ keyboardthread(void *v) void mousethread(void *v) -{ +{ USED(v); - + while(recv(mc->c, 0) == 1); /* to unblock mc->c */ } @@ -188,7 +188,7 @@ threadmain(int argc, char **argv) int lfd; p = "300x40@100,100"; - + ARGBEGIN{ case 'W': p = ARGF(); @@ -231,4 +231,3 @@ threadmain(int argc, char **argv) } proccreate(updateproc, nil, STACK); } - diff --git a/src/cmd/draw/tcolors.c b/src/cmd/draw/tcolors.c index caac0be66..9aa4de798 100644 --- a/src/cmd/draw/tcolors.c +++ b/src/cmd/draw/tcolors.c @@ -232,4 +232,3 @@ resizethread(void *v) while(recv(mousectl->resizec, &x) >= 0) eresized(1); } - diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c index 89fdef32a..0a71e2dd8 100644 --- a/src/cmd/draw/tweak.c +++ b/src/cmd/draw/tweak.c @@ -112,32 +112,32 @@ Cursor sight = { Cursor pixel = { {-7, -7}, {0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xf8, 0x1f, - 0xf0, 0x0f, 0xe0, 0x07, 0xe0, 0x07, 0xfe, 0x7f, - 0xfe, 0x7f, 0xe0, 0x07, 0xe0, 0x07, 0xf0, 0x0f, + 0xf0, 0x0f, 0xe0, 0x07, 0xe0, 0x07, 0xfe, 0x7f, + 0xfe, 0x7f, 0xe0, 0x07, 0xe0, 0x07, 0xf0, 0x0f, 0x78, 0x1f, 0x7f, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, }, - {0x00, 0x00, 0x0f, 0xf0, 0x31, 0x8c, 0x21, 0x84, - 0x41, 0x82, 0x41, 0x82, 0x41, 0x82, 0x40, 0x02, - 0x40, 0x02, 0x41, 0x82, 0x41, 0x82, 0x41, 0x82, + {0x00, 0x00, 0x0f, 0xf0, 0x31, 0x8c, 0x21, 0x84, + 0x41, 0x82, 0x41, 0x82, 0x41, 0x82, 0x40, 0x02, + 0x40, 0x02, 0x41, 0x82, 0x41, 0x82, 0x41, 0x82, 0x21, 0x84, 0x31, 0x8c, 0x0f, 0xf0, 0x00, 0x00, } }; Cursor busy = { {-7, -7}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x8e, 0x1d, 0xc7, - 0xff, 0xe3, 0xff, 0xf3, 0xff, 0xff, 0x7f, 0xfe, + 0xff, 0xe3, 0xff, 0xf3, 0xff, 0xff, 0x7f, 0xfe, 0x3f, 0xf8, 0x17, 0xf0, 0x03, 0xe0, 0x00, 0x00,}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x82, - 0x04, 0x41, 0xff, 0xe1, 0x5f, 0xf1, 0x3f, 0xfe, + 0x04, 0x41, 0xff, 0xe1, 0x5f, 0xf1, 0x3f, 0xfe, 0x17, 0xf0, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,} }; Cursor skull = { {-7,-7}, - {0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe7, 0xe7, - 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x1f, 0xf8, - 0x0f, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, + {0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0xe7, 0xe7, + 0xff, 0xff, 0xff, 0xff, 0x3f, 0xfc, 0x1f, 0xf8, + 0x0f, 0xf0, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xef, 0xf7, 0xc7, 0xe3, 0x00, 0x00, 0x00, 0x00,}, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0xE7, 0xE7, 0x3F, 0xFC, 0x0F, 0xF0, 0x0D, 0xB0, @@ -372,7 +372,7 @@ stext(Thing *t, char *l0, char *l1) char buf[256]; l1[0] = 0; - sprint(buf, "depth:%d r:%d %d %d %d ", + sprint(buf, "depth:%d r:%d %d %d %d ", t->b->depth, t->b->r.min.x, t->b->r.min.y, t->b->r.max.x, t->b->r.max.y); if(t->parent) @@ -1397,7 +1397,7 @@ openedit(Thing *t, Point pt, int c) } br = t->b->r; if(t->s == 0){ - c = -1; + c = -1; /* if big enough to bother, sweep box */ if(Dx(br)<=16 && Dy(br)<=16) r = br; diff --git a/src/cmd/echo.c b/src/cmd/echo.c index 25b69692a..aa620b04a 100644 --- a/src/cmd/echo.c +++ b/src/cmd/echo.c @@ -27,7 +27,7 @@ main(int argc, char *argv[]) if(i < argc-1) *p++ = ' '; } - + if(!nflag) *p++ = '\n'; diff --git a/src/cmd/ed.c b/src/cmd/ed.c index 4084994cc..8b0f36e54 100644 --- a/src/cmd/ed.c +++ b/src/cmd/ed.c @@ -203,7 +203,7 @@ commands(void) a1 = dol; if((addr2=a1) == 0) { given = 0; - addr2 = dot; + addr2 = dot; } else given = 1; if(addr1 == 0) @@ -726,7 +726,7 @@ getchr(void) i++; if(fullrune(s, i)) break; - + } chartorune(&r, s); lastc = r; @@ -1072,7 +1072,7 @@ Rune* getblock(int atl, int iof) { int bno, off; - + static uchar ibuff[BLKSIZE]; static uchar obuff[BLKSIZE]; @@ -1488,7 +1488,7 @@ match(int *addr) } loc1 = loc2 = 0; return 0; - + } void diff --git a/src/cmd/eqn/diacrit.c b/src/cmd/eqn/diacrit.c index 10dc8c75c..54f48f798 100644 --- a/src/cmd/eqn/diacrit.c +++ b/src/cmd/eqn/diacrit.c @@ -64,7 +64,7 @@ void diacrit(int p1, int type) nrwid(c, ps, c); if (lfont[p1] != ITAL) printf(".nr %d 0\n", t); - printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", + printf(".as %d \\h'-\\n(%du-\\n(%du/2u+\\n(%du'\\v'0-\\n(10u'\\*(%d", p1, p1, c, t, c); printf("\\v'\\n(10u'\\h'-\\n(%du+\\n(%du/2u-\\n(%du'\n", c, p1, t); if (type != UNDER && type != UTILDE) diff --git a/src/cmd/eqn/eqnbox.c b/src/cmd/eqn/eqnbox.c index 6ec013bbc..98006aa9a 100644 --- a/src/cmd/eqn/eqnbox.c +++ b/src/cmd/eqn/eqnbox.c @@ -8,7 +8,7 @@ void eqnbox(int p1, int p2, int lu) yyval = p1; b = max(ebase[p1], ebase[p2]); - eht[yyval] = h = b + max(eht[p1]-ebase[p1], + eht[yyval] = h = b + max(eht[p1]-ebase[p1], eht[p2]-ebase[p2]); ebase[yyval] = b; dprintf(".\tS%d <- %d %d; b=%g, h=%g\n", (int)yyval, p1, p2, b, h); diff --git a/src/cmd/eqn/font.c b/src/cmd/eqn/font.c index 3fb01119c..961c7bb21 100644 --- a/src/cmd/eqn/font.c +++ b/src/cmd/eqn/font.c @@ -51,7 +51,7 @@ void globfont(void) } else if (strcmp(temp, "R") == 0 || strncmp(temp, "ro", 2) == 0) { ft = ROM; strcpy(temp, "1"); - } else { + } else { ft = ROM; /* assume it's a roman style */ } ftstack[0].ft = ft; diff --git a/src/cmd/eqn/fromto.c b/src/cmd/eqn/fromto.c index cf9c96e50..5dda828c9 100644 --- a/src/cmd/eqn/fromto.c +++ b/src/cmd/eqn/fromto.c @@ -28,21 +28,21 @@ void fromto(int p1, int p2, int p3) printf(".ds %d ", (int)yyval); /* bottom of middle box */ if (p2 > 0) { t = eht[p2]-ebase[p2]+b1; - printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'%s\\*(%d%s", + printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'%s\\*(%d%s", REL(t,ps), (int)yyval, p2, DPS(ps,subps), p2, DPS(subps,ps)); - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", (int)yyval, p2, REL(-t,ps)); } - printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", + printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n", (int)yyval, p1, p1, (int)yyval, p1); if (p3 >0) { t = h1-b1+ebase[p3]; - printf("\\v'%gm'\\h'-\\n(%du-\\n(%du/2u'%s\\*(%d%s\\h'\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", + printf("\\v'%gm'\\h'-\\n(%du-\\n(%du/2u'%s\\*(%d%s\\h'\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", REL(-t,ps), (int)yyval, p3, DPS(ps,subps), p3, DPS(subps,ps), (int)yyval, p3, REL(t,ps)); } printf("\n"); ebase[yyval] = b + b1; - dprintf(".\tS%d <- %d from %d to %d; h=%g b=%g\n", + dprintf(".\tS%d <- %d from %d to %d; h=%g b=%g\n", (int)yyval, p1, p2, p3, eht[yyval], ebase[yyval]); sfree(p1); if (p2 > 0) diff --git a/src/cmd/eqn/funny.c b/src/cmd/eqn/funny.c index 3d0cef747..f5e42758f 100644 --- a/src/cmd/eqn/funny.c +++ b/src/cmd/eqn/funny.c @@ -24,7 +24,7 @@ void funny(int n) printf(".ds %d %s\n", (int)yyval, f); eht[yyval] = EM(1.0, ps+Funnyps) - EM(Funnyht, ps); ebase[yyval] = EM(Funnybase, ps); - dprintf(".\tS%d <- %s; h=%g b=%g\n", + dprintf(".\tS%d <- %s; h=%g b=%g\n", (int)yyval, f, eht[yyval], ebase[yyval]); lfont[yyval] = rfont[yyval] = ROM; } diff --git a/src/cmd/eqn/main.c b/src/cmd/eqn/main.c index 25f7eee32..816218c02 100644 --- a/src/cmd/eqn/main.c +++ b/src/cmd/eqn/main.c @@ -188,7 +188,7 @@ void inline(void) printf(".lf %d\n", curfile->lineno+1); if (curfile->lineno > n+3) fprintf(stderr, "eqn warning: multi-line %c...%c, file %s:%d,%d\n", - lefteq, righteq, curfile->fname, n, curfile->lineno); + lefteq, righteq, curfile->fname, n, curfile->lineno); sfree(ds); if (sz1) sfree(sz1); } @@ -276,7 +276,7 @@ char *ABSPS(int dn) /* absolute size dn in printable form \sd or \s(dd (dd >= 40 } else { *lb++ = dn + '0'; } - *lb++ = '\0'; + *lb++ = '\0'; return p; } @@ -307,7 +307,7 @@ char *DPS(int f, int t) /* delta ps (t-f) in printable form \s+d or \s-d or \s+- } else { *lb++ = dn + '0'; } - *lb++ = '\0'; + *lb++ = '\0'; return p; } diff --git a/src/cmd/eqn/mbwc.c b/src/cmd/eqn/mbwc.c index c97b036ca..397635088 100644 --- a/src/cmd/eqn/mbwc.c +++ b/src/cmd/eqn/mbwc.c @@ -162,4 +162,3 @@ wcstombs(char *s, const wchar_t *pwcs, size_t n) } return p-s; } - diff --git a/src/cmd/eqn/move.c b/src/cmd/eqn/move.c index 06448adda..b6462c78b 100644 --- a/src/cmd/eqn/move.c +++ b/src/cmd/eqn/move.c @@ -14,6 +14,6 @@ void move(int dir, int amt, int p) printf("\\v'-%gm'\\*(%d\\v'%gm'\n", a, p, a); else if (dir == DOWN) printf("\\v'%gm'\\*(%d\\v'-%gm'\n", a, p, a); - dprintf(".\tmove %d dir %d amt %g; h=%g b=%g\n", + dprintf(".\tmove %d dir %d amt %g; h=%g b=%g\n", p, dir, a, eht[yyval], ebase[yyval]); } diff --git a/src/cmd/eqn/over.c b/src/cmd/eqn/over.c index 575d1c8e6..0d519dd50 100644 --- a/src/cmd/eqn/over.c +++ b/src/cmd/eqn/over.c @@ -11,7 +11,7 @@ void boverb(int p1, int p2) d = EM(Overgap, ps); h = eht[p1] + eht[p2] + d; b = eht[p2] - d; - dprintf(".\tS%d <- %d over %d; b=%g, h=%g\n", + dprintf(".\tS%d <- %d over %d; b=%g, h=%g\n", (int)yyval, p1, p2, b, h); nrwid(p1, ps, p1); nrwid(p2, ps, p2); @@ -19,12 +19,12 @@ void boverb(int p1, int p2) printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); printf(".nr %d \\n(%d+%gm\n", treg, treg, Overwid); d2 = eht[p2]-ebase[p2]-d; /* denom */ - printf(".ds %d \\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\v'%gm'\\\n", + printf(".ds %d \\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\v'%gm'\\\n", (int)yyval, REL(d2,ps), treg, p2, p2, REL(-d2,ps)); d1 = 2 * d + ebase[p1]; /* num */ - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\*(%d\\v'%gm'\\\n", + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\*(%d\\v'%gm'\\\n", p2, p1, REL(-d1,ps), p1, REL(d1,ps)); - printf("\\h'-\\n(%du-\\n(%du/2u+%gm'\\v'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", + printf("\\h'-\\n(%du-\\n(%du/2u+%gm'\\v'%gm'\\l'\\n(%du-%gm'\\h'%gm'\\v'%gm'\n", treg, p1, Overline, REL(-d,ps), treg, 2*Overline, Overline, REL(d,ps)); ebase[yyval] = b; diff --git a/src/cmd/eqn/paren.c b/src/cmd/eqn/paren.c index 4a9fea0bb..e7d7d7ce3 100644 --- a/src/cmd/eqn/paren.c +++ b/src/cmd/eqn/paren.c @@ -121,7 +121,7 @@ void paren(int leftc, int p1, int rightc) printf("\\v'%gm'", -bv); } printf("\n"); - dprintf(".\tcurly: h=%g b=%g n=%d v=%g l=%c, r=%c\n", + dprintf(".\tcurly: h=%g b=%g n=%d v=%g l=%c, r=%c\n", eht[yyval], ebase[yyval], n, v, leftc, rightc); } diff --git a/src/cmd/eqn/pile.c b/src/cmd/eqn/pile.c index a89017217..8052e5c41 100644 --- a/src/cmd/eqn/pile.c +++ b/src/cmd/eqn/pile.c @@ -41,34 +41,34 @@ void pile(int oct) printf(".nr %d \\n(%d\n", (int)yyval, lp[p1]); for (i = p1+1; i < p2; i++) { nrwid(lp[i], ps, lp[i]); - printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", + printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", lp[i], (int)yyval, (int)yyval, lp[i]); } - printf(".ds %d \\v'%gm'\\h'%du*\\n(%du'\\\n", (int)yyval, REL(ebase[yyval],ps), + printf(".ds %d \\v'%gm'\\h'%du*\\n(%du'\\\n", (int)yyval, REL(ebase[yyval],ps), type==RCOL ? 1 : 0, (int)yyval); sb = 0; /* sum of box hts */ for (i = p2-1; i >= p1; i--) { bi = sb + ebase[lp[i]]; switch (type) { case LCOL: - printf("\\v'%gm'\\*(%d\\h'-\\n(%du'\\v'%gm'\\\n", + printf("\\v'%gm'\\*(%d\\h'-\\n(%du'\\v'%gm'\\\n", REL(-bi,ps), lp[i], lp[i], REL(bi,ps)); break; case RCOL: - printf("\\v'%gm'\\h'-\\n(%du'\\*(%d\\v'%gm'\\\n", + printf("\\v'%gm'\\h'-\\n(%du'\\*(%d\\v'%gm'\\\n", REL(-bi,ps), lp[i], lp[i], REL(bi,ps)); break; case CCOL: case COL: - printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d", + printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'\\*(%d", REL(-bi,ps), (int)yyval, lp[i], lp[i]); - printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", + printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n", (int)yyval, lp[i], REL(bi,ps)); break; } sb += eht[lp[i]] + gap; } - printf("\\v'%gm'\\h'%du*\\n(%du'\n", REL(-ebase[yyval],ps), + printf("\\v'%gm'\\h'%du*\\n(%du'\n", REL(-ebase[yyval],ps), type!=RCOL ? 1 : 0, (int)yyval); for (i = p1; i < p2; i++) sfree(lp[i]); diff --git a/src/cmd/eqn/shift.c b/src/cmd/eqn/shift.c index 970c13e7c..34f040808 100644 --- a/src/cmd/eqn/shift.c +++ b/src/cmd/eqn/shift.c @@ -56,10 +56,10 @@ void bshiftb(int p1, int dir, int p2) sh1 = pad(n); rclass[p1] = rclass[p2]; /* OTHER leaves too much after sup */ } - dprintf(".\tS%d <- %d shift %g %d; b=%g, h=%g, ps=%d, subps=%d\n", + dprintf(".\tS%d <- %d shift %g %d; b=%g, h=%g, ps=%d, subps=%d\n", (int)yyval, p1, shval, p2, ebase[yyval], eht[yyval], ps, subps); sh2 = Sub2space; /* was Sub2space; */ - printf(".as %d \\v'%gm'%s%s\\*(%d%s%s\\v'%gm'\n", + printf(".as %d \\v'%gm'%s%s\\*(%d%s%s\\v'%gm'\n", (int)yyval, REL(shval,ps), DPS(ps,subps), sh1, p2, DPS(subps,ps), sh2, REL(-shval,ps)); rfont[p1] = 0; @@ -105,9 +105,9 @@ void shift2(int p1, int p2, int p3) nrwid(p3, subps, p3); printf(".nr %d \\n(%d\n", treg, p3); printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2); - printf(".as %d %s\\v'%gm'\\*(%d\\v'%gm'\\h'-\\n(%du'\\\n", + printf(".as %d %s\\v'%gm'\\*(%d\\v'%gm'\\h'-\\n(%du'\\\n", p1, DPS(ps,subps), REL(subsh,subps), p2, REL(-subsh,subps), p2); - printf("\\v'%gm'\\*(%d\\v'%gm'\\h'-\\n(%du+\\n(%du'%s%s\n", + printf("\\v'%gm'\\*(%d\\v'%gm'\\h'-\\n(%du+\\n(%du'%s%s\n", REL(supsh,subps), p3, REL(-supsh,subps), p3, treg, DPS(subps,ps), Sub2space); if (rfont[p2] == ITAL) rfont[yyval] = 0; /* lie */ diff --git a/src/cmd/eqn/size.c b/src/cmd/eqn/size.c index 01837e144..3e57b4ded 100644 --- a/src/cmd/eqn/size.c +++ b/src/cmd/eqn/size.c @@ -29,7 +29,7 @@ void size(int p1, int p2) { /* old size in p1, new in ps */ yyval = p2; - dprintf(".\tS%d <- \\s%d %d \\s%d; b=%g, h=%g\n", + dprintf(".\tS%d <- \\s%d %d \\s%d; b=%g, h=%g\n", (int)yyval, ps, p2, p1, ebase[yyval], eht[yyval]); if (szstack[nszstack] != 0) { printf(".ds %d %s\\*(%d\\s\\n(%d\n", (int)yyval, ABSPS(ps), p2, 99-nszstack); diff --git a/src/cmd/eqn/sqrt.c b/src/cmd/eqn/sqrt.c index 69359b673..0963fe45f 100644 --- a/src/cmd/eqn/sqrt.c +++ b/src/cmd/eqn/sqrt.c @@ -17,7 +17,7 @@ void sqrt(int p2) eht[yyval] = EM(1.15, nps); else /* DEV202, DEVPOST */ eht[yyval] = EM(1.15, nps); - dprintf(".\tS%d <- sqrt S%d;b=%g, h=%g, nps=%d\n", + dprintf(".\tS%d <- sqrt S%d;b=%g, h=%g, nps=%d\n", (int)yyval, p2, ebase[yyval], eht[yyval], nps); printf(".as %d \\|\n", (int)yyval); nrwid(p2, ps, p2); diff --git a/src/cmd/eqn/text.c b/src/cmd/eqn/text.c index c016cca08..4ca0bbd9d 100644 --- a/src/cmd/eqn/text.c +++ b/src/cmd/eqn/text.c @@ -193,7 +193,7 @@ trans(int c, char *p1) cadd(c); psp++; } else { - cadd(c); + cadd(c); } return f; case '-': @@ -263,7 +263,7 @@ char *pad(int n) /* return the padding as a string */ if (n < 0) { sprintf(buf, "\\h'-%du*\\w'\\^'u'", -n); return buf; - } + } for ( ; n > 1; n -= 2) strcat(buf, "\\|"); if (n > 0) diff --git a/src/cmd/faces/facedb.c b/src/cmd/faces/facedb.c index a24a391ad..5043aa782 100644 --- a/src/cmd/faces/facedb.c +++ b/src/cmd/faces/facedb.c @@ -112,7 +112,7 @@ readfile(char *s) continue; /* - * if it's less than 30 seconds since we read it, or it + * if it's less than 30 seconds since we read it, or it * hasn't changed, send back our copy */ if(time(0) - r->rdtime < 30) @@ -215,7 +215,7 @@ tryfindpicture(char *dom, char *user, char *dir, char *dict) { static char buf[1024]; char *file, *p, *nextp, *q; - + if((file = readfile(dict)) == nil) return nil; @@ -247,7 +247,7 @@ static char* estrstrdup(char *a, char *b) { char *t; - + t = emalloc(strlen(a)+strlen(b)+1); strcpy(t, a); strcat(t, b); @@ -261,7 +261,7 @@ tryfindfiledir(char *dom, char *user, char *dir) int fd; int i, n; Dir *d; - + /* * If this directory has a .machinelist, use it. */ @@ -279,7 +279,7 @@ tryfindfiledir(char *dom, char *user, char *dir) return x; } free(dict); - + /* * If not, recurse into subdirectories. * Ignore 48x48xN directories for now. @@ -305,7 +305,7 @@ tryfindfiledir(char *dom, char *user, char *dir) free(d); } close(fd); - + /* * Handle 48x48xN directories in the right order. */ @@ -398,7 +398,7 @@ freefacefile(Facefile *f) return; if(++nsaved > Nsave) clearsaved(); -} +} static Image* myallocimage(ulong chan) @@ -413,7 +413,7 @@ myallocimage(ulong chan) } return img; } - + static Image* readbit(int fd, ulong chan) @@ -527,14 +527,14 @@ readface(char *fn) mask = myallocimage(GREY1); if(mask == nil) goto Done; - if(unloadimage(face, face->r, data, Facesize*Facesize) != Facesize*Facesize){ + if(unloadimage(face, face->r, data, Facesize*Facesize) != Facesize*Facesize){ freeimage(mask); goto Done; } bits = 0; p = mdata; for(y=0; ytime) <= HhmmTime) != f->recent) drawface(f, i); - } + } } void @@ -610,7 +610,7 @@ click(int button, Mouse *m) return; }else{ for(i=first; istr[Sshow], "/XXXvwhois")){ lockdisplay(display); delface(i); diff --git a/src/cmd/faces/plumb.c b/src/cmd/faces/plumb.c index 6d82c779f..b2fcfa85f 100644 --- a/src/cmd/faces/plumb.c +++ b/src/cmd/faces/plumb.c @@ -113,7 +113,7 @@ setname(Face *f, char *sender) static char* months[] = { "jan", "feb", "mar", "apr", - "may", "jun", "jul", "aug", + "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; diff --git a/src/cmd/faces/util.c b/src/cmd/faces/util.c index 22f57549c..5f3e7fde9 100644 --- a/src/cmd/faces/util.c +++ b/src/cmd/faces/util.c @@ -39,4 +39,3 @@ estrdup(char *s) } return t; } - diff --git a/src/cmd/file.c b/src/cmd/file.c index 32d580cdf..0ee1d1cfc 100644 --- a/src/cmd/file.c +++ b/src/cmd/file.c @@ -52,7 +52,7 @@ struct "common", Fword, "con", Lword, "data", Fword, - "dimension", Fword, + "dimension", Fword, "double", Cword, "extern", Cword, "bio", I2, @@ -86,7 +86,7 @@ struct enum { Normal = 0, First, /* first entry for language spanning several ranges */ - Multi, /* later entries " " " ... */ + Multi, /* later entries " " " ... */ Shared, /* codes used in several languages */ }; @@ -97,7 +97,7 @@ struct int low; int high; char *name; - + } language[] = { Normal, 0, 0x0080, 0x0080, "Extended Latin", @@ -127,8 +127,8 @@ struct Shared, 0, 0x4e00, 0x9fff, "CJK", Normal, 0, 0, 0, 0, /* terminal entry */ }; - - + + enum { Fascii, /* printable ascii */ @@ -342,7 +342,7 @@ filetype(int fd) * lookup dictionary words */ memset(wfreq, 0, sizeof(wfreq)); - if(guess == Fascii || guess == Flatin || guess == Futf) + if(guess == Fascii || guess == Flatin || guess == Futf) wordfreq(); /* * call individual classify routines @@ -540,7 +540,7 @@ filemagic(Filemagic *tab, int ntab, ulong x) } return 0; } - + int long0(void) { @@ -876,7 +876,7 @@ isc(void) } if(wfreq[Alword] > 0) print("alef program\n"); - else + else print("c program\n"); return 1; } @@ -1042,7 +1042,7 @@ depthof(char *s, int *newp) s++; /* skip letter */ d += strtoul(s, &s, 10); } - + switch(d){ case 32: case 24: diff --git a/src/cmd/fmt.c b/src/cmd/fmt.c index 1c4de8714..047da847d 100644 --- a/src/cmd/fmt.c +++ b/src/cmd/fmt.c @@ -104,7 +104,7 @@ indentof(char **linep) ind -= ind%maxtab; break; } - + /* plain white space doesn't change the indent */ *linep = ""; return indent; diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index 37f0da32d..ebab62497 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -70,7 +70,7 @@ dostat(vlong path, Qid *qid, Dir *dir) vlong length; XFont *f; char buf[100]; - + q.type = 0; q.vers = 0; q.path = path; @@ -98,7 +98,7 @@ dostat(vlong path, Qid *qid, Dir *dir) snprint(buf, sizeof buf, "%lld%s", QSIZE(path), QANTIALIAS(path) ? "a" : ""); name = buf; break; - + case Qfontfile: f = &xfont[QFONT(path)]; load(f); @@ -111,7 +111,7 @@ dostat(vlong path, Qid *qid, Dir *dir) name = buf; break; } - + if(qid) *qid = q; if(dir) { @@ -214,7 +214,7 @@ fontgen(int i, Dir *d, void *v) { vlong path; Fid *f; - + f = v; path = f->qid.path; if(i >= 2*nelem(sizes)) @@ -280,7 +280,7 @@ void responderrstr(Req *r) { char err[ERRMAX]; - + rerrstr(err, sizeof err); respond(r, err); } @@ -295,7 +295,7 @@ xread(Req *r) char *data; Memsubfont *sf; Memimage *m; - + path = r->fid->qid.path; switch(QTYPE(path)) { case Qroot: @@ -377,7 +377,7 @@ static void xdestroyfid(Fid *fid) { Memsubfont *sf; - + sf = fid->aux; if(sf == nil) return; @@ -420,7 +420,7 @@ dump(char *path) // root memset(&fid, 0, sizeof fid); - dostat(0, &fid.qid, nil); + dostat(0, &fid.qid, nil); qid = fid.qid; path0 = path; @@ -440,7 +440,7 @@ dump(char *path) *p++ = '/'; path = p; } - + memset(&r, 0, sizeof r); xsrv.fake = 1; @@ -513,7 +513,7 @@ main(int argc, char **argv) default: usage(); }ARGEND - + xsrv.attach = xattach; xsrv.open = xopen; xsrv.read = xread; @@ -526,7 +526,7 @@ main(int argc, char **argv) memimageinit(); loadfonts(); qsort(xfont, nxfont, sizeof xfont[0], fontcmp); - + if(pflag) { if(argc != 1 || chatty9p || chattyfuse) usage(); @@ -600,4 +600,3 @@ dirpackage(uchar *buf, long ts, Dir **d) return nn; } - diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/osx.c index c01ae6ce5..b4dadd90a 100644 --- a/src/cmd/fontsrv/osx.c +++ b/src/cmd/fontsrv/osx.c @@ -51,7 +51,7 @@ mac2c(CFStringRef s) char *p; int n; - n = CFStringGetLength(s)*8; + n = CFStringGetLength(s)*8; p = malloc(n); CFStringGetCString(s, p, n, kCFStringEncodingUTF8); return p; @@ -93,7 +93,7 @@ loadfonts(void) if(f == nil) continue; s = CTFontDescriptorCopyAttribute(f, kCTFontNameAttribute); - xfont[nxfont].name = mac2c(s); + xfont[nxfont].name = mac2c(s); CFRelease(s); nxfont++; } @@ -147,7 +147,7 @@ fontheight(XFont *f, int size, int *height, int *ascent) CTLineRef line; str = c2mac(lines[i]); - + // See https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html#//apple_ref/doc/uid/TP40005533-CH12-SW2 attrs = CFDictionaryCreate(kCFAllocatorDefault, (const void**)&keys, (const void**)&values, sizeof(keys) / sizeof(keys[0]), @@ -162,15 +162,15 @@ fontheight(XFont *f, int size, int *height, int *ascent) r.size.width += r.origin.x; r.size.height += r.origin.y; CFRelease(line); - + // fprint(2, "%s: %g %g %g %g\n", lines[i], r.origin.x, r.origin.y, r.size.width, r.size.height); - + if(i == 0) bbox = r; if(bbox.origin.x > r.origin.x) - bbox.origin.x = r.origin.x; + bbox.origin.x = r.origin.x; if(bbox.origin.y > r.origin.y) - bbox.origin.y = r.origin.y; + bbox.origin.y = r.origin.y; if(bbox.size.width < r.size.width) bbox.size.width = r.size.width; if(bbox.size.height < r.size.height) @@ -182,7 +182,7 @@ fontheight(XFont *f, int size, int *height, int *ascent) *height = bbox.size.height + 0.999999; *ascent = *height - (-bbox.origin.y + 0.999999); - + CGContextRelease(ctxt); CFRelease(font); } @@ -232,8 +232,8 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) CFRelease(desc); if(font == nil) return nil; - - + + bbox = CTFontGetBoundingBox(font); x = (int)(bbox.size.width*2 + 0.99999999); @@ -295,7 +295,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) sprint(buf, "%C", (Rune)mapUnicode(name, i)); str = c2mac(buf); - + // See https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html#//apple_ref/doc/uid/TP40005533-CH12-SW2 attrs = CFDictionaryCreate(kCFAllocatorDefault, (const void**)&keys, (const void**)&values, sizeof(keys) / sizeof(keys[0]), @@ -309,7 +309,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) CGContextSetTextPosition(ctxt, 0, y0); r = CTLineGetImageBounds(line, ctxt); memfillcolor(mc, DBlack); - CTLineDraw(line, ctxt); + CTLineDraw(line, ctxt); CFRelease(line); fc->x = x; @@ -324,7 +324,7 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) if(i == 0) { drawpjw(m, fc, x, (int)(bbox.size.width + 0.99999999), y, y - y0); x += fc->width; - } + } continue; } @@ -357,6 +357,6 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) sf->ascent = Dy(m1->r) - y0; sf->info = fc0; sf->bits = m1; - + return sf; } diff --git a/src/cmd/fontsrv/pjw.c b/src/cmd/fontsrv/pjw.c index 30ebbed2c..82e8cfa1d 100644 --- a/src/cmd/fontsrv/pjw.c +++ b/src/cmd/fontsrv/pjw.c @@ -96,7 +96,7 @@ drawpjw(Memimage *m, Fontchar *fc, int x, int width, int height, int ascent) Memimage *pm, *pm1, *pm2; Rectangle r; int margin; - + w = width; // assume margin below baseline is @@ -116,7 +116,7 @@ drawpjw(Memimage *m, Fontchar *fc, int x, int width, int height, int ascent) close(p[0]); if(pm == nil) goto Error; - + pm1 = allocmemimage(pm->r, GREY8); memimagedraw(pm1, pm1->r, pm, pm->r.min, nil, ZP, S); pm2 = resample(w, w, pm1); @@ -216,7 +216,7 @@ fac(int L) return f; } -/* +/* * i0(x) is the modified Bessel function, Σ (x/2)^2L / (L!)² * There are faster ways to calculate this, but we precompute * into a table so let's keep it simple. diff --git a/src/cmd/fossil/9fsys.c b/src/cmd/fossil/9fsys.c index ac7242513..121e5b66c 100644 --- a/src/cmd/fossil/9fsys.c +++ b/src/cmd/fossil/9fsys.c @@ -503,7 +503,7 @@ fsysSync(Fsys* fsys, int argc, char* argv[]) { char *usage = "usage: [fsys name] sync"; int n; - + ARGBEGIN{ default: return cliError(usage); @@ -1307,7 +1307,7 @@ fsckClri(Fsck *fsck, char *name, MetaBlock *mb, int i, Block *b) mbDelete(mb, i); mbPack(mb); - blockDirty(b); + blockDirty(b); } static void @@ -1322,12 +1322,12 @@ fsckClose(Fsck *fsck, Block *b, u32int epoch) consPrint("%#ux is already closed\n", b->addr); return; } - if(epoch){ + if(epoch){ l.state |= BsClosed; l.epochClose = epoch; }else l.state = BsFree; - + if(!blockSetLabel(b, &l, 0)) consPrint("%#ux setlabel: %r\n", b->addr); } diff --git a/src/cmd/fossil/9lstn.c b/src/cmd/fossil/9lstn.c index b4023e8be..4f9607294 100644 --- a/src/cmd/fossil/9lstn.c +++ b/src/cmd/fossil/9lstn.c @@ -46,7 +46,7 @@ lstnListen(void* a) Lstn *lstn; int dfd, lfd; char newdir[NETPATHLEN]; - + threadsetname("listen"); lstn = a; diff --git a/src/cmd/fossil/9p.c b/src/cmd/fossil/9p.c index 6738670e0..e15622afa 100644 --- a/src/cmd/fossil/9p.c +++ b/src/cmd/fossil/9p.c @@ -939,7 +939,7 @@ parseAname(char *aname, char **fsname, char **path) /* * Check remote IP address against /mnt/ipok. * Sources.cs.bell-labs.com uses this to disallow - * network connections from Sudan, Libya, etc., + * network connections from Sudan, Libya, etc., * following U.S. cryptography export regulations. */ static int @@ -955,7 +955,7 @@ conIPCheck(Con* con) } if(access("/mnt/ipok/ok", AEXIST) < 0){ /* mount closes the fd on success */ - if((fd = open("/srv/ipok", ORDWR)) >= 0 + if((fd = open("/srv/ipok", ORDWR)) >= 0 && mount(fd, -1, "/mnt/ipok", MREPL, "") < 0) close(fd); if(access("/mnt/ipok/ok", AEXIST) < 0){ diff --git a/src/cmd/fossil/9ping.c b/src/cmd/fossil/9ping.c index dbf628c5b..d820f2081 100644 --- a/src/cmd/fossil/9ping.c +++ b/src/cmd/fossil/9ping.c @@ -37,7 +37,7 @@ main(int argc, char *argv[]) int n = 1000, m; int s = 1; double *t, t0, t1; - uchar *buf; + uchar *buf; double a, d, max, min; m = OREAD; @@ -67,7 +67,7 @@ main(int argc, char *argv[]) buf = malloc(s); t = malloc(n*sizeof(double)); - + t0 = nsec(); for(i=0; ib[i] = w->b[--w->nb]; } - diff --git a/src/cmd/fossil/cache.c b/src/cmd/fossil/cache.c index 23f89461e..6707d50ae 100644 --- a/src/cmd/fossil/cache.c +++ b/src/cmd/fossil/cache.c @@ -1062,10 +1062,10 @@ if(0)fprint(2, "%s: %d:%x:%d depends on %d:%x:%d\n", argv0, b->part, b->addr, b- /* * Mark an in-memory block as dirty. If there are too many - * dirty blocks, start writing some out to disk. - * + * dirty blocks, start writing some out to disk. + * * If there were way too many dirty blocks, we used to - * try to do some flushing ourselves, but it's just too dangerous -- + * try to do some flushing ourselves, but it's just too dangerous -- * it implies that the callers cannot have any of our priors locked, * but this is hard to avoid in some cases. */ @@ -1332,16 +1332,16 @@ if(0) fprint(2, "%s: iostate part=%d addr=%x %s->%s\n", argv0, b->part, b->addr, } /* - * The active file system is a tree of blocks. + * The active file system is a tree of blocks. * When we add snapshots to the mix, the entire file system * becomes a dag and thus requires a bit more care. - * + * * The life of the file system is divided into epochs. A snapshot * ends one epoch and begins the next. Each file system block * is marked with the epoch in which it was created (b.epoch). * When the block is unlinked from the file system (closed), it is marked - * with the epoch in which it was removed (b.epochClose). - * Once we have discarded or archived all snapshots up to + * with the epoch in which it was removed (b.epochClose). + * Once we have discarded or archived all snapshots up to * b.epochClose, we can reclaim the block. * * If a block was created in a past epoch but is not yet closed, @@ -1359,7 +1359,7 @@ if(0) fprint(2, "%s: iostate part=%d addr=%x %s->%s\n", argv0, b->part, b->addr, * lbb (bb's label block). * * (2) We have to mark b as closed, but only after we switch - * the pointer, so lb must be written out after p. In fact, we + * the pointer, so lb must be written out after p. In fact, we * can't even update the in-memory copy, or the cache might * mistakenly give out b for reuse before p gets written. * @@ -1369,7 +1369,7 @@ if(0) fprint(2, "%s: iostate part=%d addr=%x %s->%s\n", argv0, b->part, b->addr, * to arrange for (2) to happen once p is written. * * Until (2) happens, some pieces of the code (e.g., the archiver) - * still need to know whether a block has been copied, so we + * still need to know whether a block has been copied, so we * set the BsCopied bit in the label and force that to disk *before* * the copy gets written out. */ @@ -1436,7 +1436,7 @@ void blockRemoveLink(Block *b, u32int addr, int type, u32int tag, int recurse) { BList *p, **pp, bl; - + /* remove bb from prior list */ for(pp=&b->prior; (p=*pp)!=nil; ){ if(p->part == PartData && p->addr == addr){ @@ -1479,7 +1479,7 @@ blockRemoveLink(Block *b, u32int addr, int type, u32int tag, int recurse) b->utail = p; } -/* +/* * Process removal of a single block and perhaps its children. */ static void @@ -1592,7 +1592,7 @@ blistAlloc(Block *b) /* * No free BLists. What are our options? */ - + /* Block has no priors? Just write it. */ if(b->prior == nil){ qunlock(&c->lk); diff --git a/src/cmd/fossil/flchk.c b/src/cmd/fossil/flchk.c index c003f7069..2068a6176 100644 --- a/src/cmd/fossil/flchk.c +++ b/src/cmd/fossil/flchk.c @@ -64,7 +64,7 @@ threadmain(int argc, char *argv[]) int csize = 1000; VtConn *z; char *host = nil; - + fsck.useventi = 1; Binit(&bout, 1, OWRITE); ARGBEGIN{ @@ -119,4 +119,3 @@ threadmain(int argc, char *argv[]) threadexitsall(0); } - diff --git a/src/cmd/fossil/flfmt9660.c b/src/cmd/fossil/flfmt9660.c index ac466bdd5..128227d8a 100644 --- a/src/cmd/fossil/flfmt9660.c +++ b/src/cmd/fossil/flfmt9660.c @@ -1,7 +1,7 @@ /* * Initialize a fossil file system from an ISO9660 image already in the * file system. This is a fairly bizarre thing to do, but it lets us generate - * installation CDs that double as valid Plan 9 disk partitions. + * installation CDs that double as valid Plan 9 disk partitions. * People having trouble booting the CD can just copy it into a disk * partition and you've got a working Plan 9 system. * @@ -329,7 +329,7 @@ iso9660start(Cdir *c) c = (Cdir*)((uchar*)c+c->len); /* skip dotdot */ /* oops: might happen if leftmost directory is empty or leftmost file is zero length! */ if(little(c->dloc, 4) == 0) - sysfatal("error parsing cd image or unfortunate cd image"); + sysfatal("error parsing cd image or unfortunate cd image"); } return little(c->dloc, 4); } diff --git a/src/cmd/fossil/fs.c b/src/cmd/fossil/fs.c index 5f8a1cfd0..d1baf736b 100644 --- a/src/cmd/fossil/fs.c +++ b/src/cmd/fossil/fs.c @@ -529,7 +529,7 @@ fsSnapshot(Fs *fs, char *srcpath, char *dstpath, int doarchive) * It is important that we maintain the invariant that: * if both b and bb are marked as Active with start epoch e * and b points at bb, then no other pointers to bb exist. - * + * * When bb is unlinked from b, its close epoch is set to b's epoch. * A block with epoch == close epoch is * treated as free by cacheAllocBlock; this aggressively @@ -1095,4 +1095,3 @@ snapClose(Snap *s) periodicKill(s->tick); vtfree(s); } - diff --git a/src/cmd/fossil/nobwatch.c b/src/cmd/fossil/nobwatch.c index 9f98c03fe..e0e7b17eb 100644 --- a/src/cmd/fossil/nobwatch.c +++ b/src/cmd/fossil/nobwatch.c @@ -37,4 +37,3 @@ bwatchUnlock(Block *b) { USED(b); } - diff --git a/src/cmd/fossil/pack.c b/src/cmd/fossil/pack.c index b27f90b86..75077a05d 100644 --- a/src/cmd/fossil/pack.c +++ b/src/cmd/fossil/pack.c @@ -222,4 +222,3 @@ superUnpack(Super *s, uchar *p) werrstr(EBadSuper); return 0; } - diff --git a/src/cmd/fossil/periodic.c b/src/cmd/fossil/periodic.c index 634f975d8..6164eca22 100644 --- a/src/cmd/fossil/periodic.c +++ b/src/cmd/fossil/periodic.c @@ -79,4 +79,3 @@ periodicThread(void *a) } periodicFree(p); } - diff --git a/src/cmd/fossil/srcload.c b/src/cmd/fossil/srcload.c index 8cf63b4f6..97e455411 100644 --- a/src/cmd/fossil/srcload.c +++ b/src/cmd/fossil/srcload.c @@ -39,7 +39,7 @@ main(int argc, char *argv[]) case 'l': length = atoi(ARGF()); break; - case 'b': + case 'b': block = atoi(ARGF()); break; case 'u': @@ -92,7 +92,7 @@ main(int argc, char *argv[]) fprint(2, "count = %d\n", count(r, 1)); fprint(2, "total time = %ld\n", time(0)-t); - + fsClose(fs); vtDetach(); exits(0); @@ -119,7 +119,7 @@ new(Source *s, int trace, int depth) int i, n; Source *ss; Entry e; - + if(depth > maxdepth) maxdepth = depth; @@ -174,7 +174,7 @@ delete(Source *s) } if(i == n) return 0; - + for(;;){ ss = sourceOpen(s, nrand(n), OReadWrite); if(ss == nil) diff --git a/src/cmd/fossil/view.c b/src/cmd/fossil/view.c index ed18febc4..659e53809 100644 --- a/src/cmd/fossil/view.c +++ b/src/cmd/fossil/view.c @@ -298,7 +298,7 @@ copyMetaBlock(MetaBlock mb) } /* - * visualizer + * visualizer */ #pragma varargck argpos stringnode 1 @@ -555,7 +555,7 @@ initxentryblock(Block *b, Entry *ed) } typedef struct Xentry Xentry; -struct Xentry +struct Xentry { Tnode t; Entry e; @@ -813,7 +813,7 @@ parseScore(uchar *score, char *buf, int n) if((i & 1) == 0) c <<= 4; - + score[i>>1] |= c; } return 1; @@ -912,7 +912,7 @@ drawnub(Image *m, Image *clipr, Point o, Tnode *t) o.y += (display->defaultfont->height-Nubheight)/2; draw(m, rectaddpt(Rect(0,0,1,Nubheight), o), display->black, clipr, ZP); draw(m, rectaddpt(Rect(0,0,Nubwidth,1), o), display->black, clipr, o); - draw(m, rectaddpt(Rect(Nubwidth-1,0,Nubwidth,Nubheight), o), + draw(m, rectaddpt(Rect(Nubwidth-1,0,Nubwidth,Nubheight), o), display->black, clipr, addpt(o, Pt(Nubwidth-1, 0))); draw(m, rectaddpt(Rect(0, Nubheight-1, Nubwidth, Nubheight), o), display->black, clipr, addpt(o, Pt(0, Nubheight-1))); diff --git a/src/cmd/fossil/walk.c b/src/cmd/fossil/walk.c index 632e3e5e5..8fb1ceb71 100644 --- a/src/cmd/fossil/walk.c +++ b/src/cmd/fossil/walk.c @@ -62,4 +62,3 @@ nextWalk(WalkPtr *w, uchar score[VtScoreSize], uchar *type, u32int *tag, Entry * w->n++; return 1; } - diff --git a/src/cmd/getflags.c b/src/cmd/getflags.c index 7c7d17875..e97398a27 100644 --- a/src/cmd/getflags.c +++ b/src/cmd/getflags.c @@ -13,13 +13,13 @@ findarg(char *flags, Rune r) { char *p; Rune rr; - + for(p=flags; p!=(char*)1; p=strchr(p, ',')+1){ chartorune(&rr, p); if(rr == r) return p; } - return nil; + return nil; } int @@ -42,11 +42,11 @@ main(int argc, char *argv[]) char *flags, *p, buf[512]; int i, n; Fmt fmt; - - doquote = needsrcquote; + + doquote = needsrcquote; quotefmtinstall(); argv0 = argv[0]; /* for sysfatal */ - + flags = getenv("flagfmt"); if(flags == nil){ fprint(2, "$flagfmt not set\n"); @@ -72,7 +72,7 @@ main(int argc, char *argv[]) fmtprint(&fmt, "%s%q", i ? " " : "", EARGF(usage())); fmtprint(&fmt, ")\n"); }ARGEND - + fmtprint(&fmt, "*=("); for(i=0; iname, x, y); p.obj = s; p.x = x; diff --git a/src/cmd/grap/print.c b/src/cmd/grap/print.c index a7497e44d..0d4d4ab76 100644 --- a/src/cmd/grap/print.c +++ b/src/cmd/grap/print.c @@ -39,7 +39,7 @@ void print(void) /* arrange final output */ for (p = objlist; p; p = p->next) { dprintf("print: name = <%s>, type = %d\n", p->name, p->type); if (p->type == NAME) { - Point pt, pt1; + Point pt, pt1; pt = p->pt; pt1 = p->pt1; fprintf(tfd, "\t# %s %g .. %g, %g .. %g\n", @@ -78,7 +78,7 @@ void print(void) /* arrange final output */ p->pt1.y = pow(10.0, pt1.y); } dfp = setauto(); - } + } dx = pt1.x - pt.x; dy = pt1.y - pt.y; xfac = dx > 0 ? frame_wid/dx : frame_wid/2; @@ -184,7 +184,7 @@ void do_first(void) /* done at first .G1: definitions, etc. */ FILE *fp; snprintf(buf, sizeof buf, "define pid /%d/\n", getpid()); - pbstr(buf); + pbstr(buf); if (lib != 0) { if ((fp = fopen(lib_defines, "r")) != NULL) { snprintf(buf1, sizeof buf, "copy \"%s\"\n", lib_defines); diff --git a/src/cmd/graph/graph.c b/src/cmd/graph/graph.c index 7da0b81b3..1dba7dfcc 100644 --- a/src/cmd/graph/graph.c +++ b/src/cmd/graph/graph.c @@ -15,7 +15,7 @@ struct xy { float xquant; /*quantum*/ float xoff; /*screen offset fraction*/ float xsize; /*screen fraction*/ - int xbot,xtop; /*screen coords of border*/ + int xbot,xtop; /*screen coords of border*/ float xmult; /*scaling constant*/ } xd,yd; struct val { @@ -83,7 +83,7 @@ static void initpalette(void) { int i; - + for(i=0; i 0) { ub = 2*ub; lb = 0; - } + } else if(lb < 0) { lb = 2*lb; ub = 0; - } + } else { ub = 1; lb = -1; @@ -729,7 +729,7 @@ symbol(int ix, int iy, int k){ if(mode==0) point(ix,iy); return(1); - } + } else { move(ix,iy); text(k>=0?labels+k:plotsymb); diff --git a/src/cmd/grep/grep.h b/src/cmd/grep/grep.h index 777bd1e8b..ac86b86d4 100644 --- a/src/cmd/grep/grep.h +++ b/src/cmd/grep/grep.h @@ -36,7 +36,7 @@ struct Re { Rune lo; Rune hi; - } x; + } x; Rune val; /* char */ } u; Re* next; diff --git a/src/cmd/gzip/gunzip.c b/src/cmd/gzip/gunzip.c index bb348bc88..d9ef2e224 100644 --- a/src/cmd/gzip/gunzip.c +++ b/src/cmd/gzip/gunzip.c @@ -348,7 +348,7 @@ error(char *fmt, ...) vfprint(2, fmt, arg); va_end(arg); fprint(2, "\n"); - + if(delfile != nil){ fprint(2, "gunzip: removing output file %s\n", delfile); remove(delfile); diff --git a/src/cmd/gzip/zip.c b/src/cmd/gzip/zip.c index 5480ba845..d25fa3699 100644 --- a/src/cmd/gzip/zip.c +++ b/src/cmd/gzip/zip.c @@ -136,7 +136,7 @@ zip(Biobuf *bout, char *file, int stdout) zh->madevers = (2 * 10) + 0; zh->extos = ZDos; zh->extvers = (2 * 10) + 0; - + t = localtime(dir->mtime); zh->modtime = (t->hour<<11) | (t->min<<5) | (t->sec>>1); zh->moddate = ((t->year-80)<<9) | ((t->mon+1)<<5) | t->mday; diff --git a/src/cmd/hget.c b/src/cmd/hget.c index c30bb0b34..f99b9647c 100644 --- a/src/cmd/hget.c +++ b/src/cmd/hget.c @@ -146,7 +146,7 @@ threadmain(int argc, char **argv) else p = seprint(p, e, "%s", t); u.postbody = postbody; - + break; default: usage(); @@ -162,7 +162,7 @@ threadmain(int argc, char **argv) if(argc != 1) usage(); - + out.fd = 1; out.written = 0; out.offset = 0; @@ -278,7 +278,7 @@ crackurl(URL *u, char *s) if(p = strchr(u->host, ':')) { *p++ = 0; u->port = p; - } else + } else u->port = method[u->method].name; if(*(u->host) == 0){ @@ -429,7 +429,7 @@ dohttp(URL *u, URL *px, Range *r, Out *out, long mtime) cfd = -1; } } - + dfprint(fd, "\r\n", u->host); auth = 0; @@ -498,7 +498,7 @@ dohttp(URL *u, URL *px, Range *r, Out *out, long mtime) case 503: /* Service unavailable */ sysfatal("Service unavailable"); - + default: sysfatal("Unknown response code %d", code); } @@ -681,7 +681,7 @@ void hhetag(char *p, URL *u, Range *r) { USED(r); - + if(u->etag != nil){ if(strcmp(u->etag, p) != 0) sysfatal("file changed underfoot"); @@ -700,7 +700,7 @@ hhmtime(char *p, URL *u, Range *r) int i; USED(r); - + i = getfields(p, fields, 6, 1, " \t"); if(i < 5) return; @@ -764,7 +764,7 @@ void hhclen(char *p, URL *u, Range *r) { USED(u); - + r->end = atoi(p); } @@ -791,7 +791,7 @@ void hhuri(char *p, URL *u, Range *r) { USED(r); - + if(*p != '<') return; u->redirect = strdup(p+1); @@ -804,7 +804,7 @@ void hhlocation(char *p, URL *u, Range *r) { USED(r); - + u->redirect = strdup(p); } @@ -814,7 +814,7 @@ hhauth(char *p, URL *u, Range *r) char *f[4]; UserPasswd *up; char *s, cred[64]; - + USED(r); if (cistrncmp(p, "basic ", 6) != 0) @@ -898,7 +898,7 @@ doftp(URL *u, URL *px, Range *r, Out *out, long mtime) close(ctl); return Eof; } - + /* first try passive mode, then active */ data = passive(ctl, u); if(data < 0){ @@ -1215,7 +1215,7 @@ active(int ctl, URL *u) } close(afd); close(lcfd); - + return dfd; } @@ -1420,7 +1420,7 @@ DigestState* md5dup(DigestState *state) { DigestState *s2; - + s2 = malloc(sizeof(DigestState)); if(s2 == nil) sysfatal("malloc: %r"); @@ -1486,4 +1486,3 @@ output(Out *out, char *buf, int nb) } return n + d; } - diff --git a/src/cmd/hist.c b/src/cmd/hist.c index 46fd3f8a1..f6b81ed8b 100644 --- a/src/cmd/hist.c +++ b/src/cmd/hist.c @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { int i; - + sys = sysname(); if(strncmp(sys, "amsterdam", 9) == 0) /* BUG */ sys = "am"; diff --git a/src/cmd/hoc/code.c b/src/cmd/hoc/code.c index e2d4c5ea3..af60c194c 100644 --- a/src/cmd/hoc/code.c +++ b/src/cmd/hoc/code.c @@ -125,7 +125,7 @@ forcode(void) } void -ifcode(void) +ifcode(void) { Datum d; Inst *savepc = pc; /* then part */ @@ -133,7 +133,7 @@ ifcode(void) execute(savepc+3); /* condition */ d = pop(); if (d.val) - execute(*((Inst **)(savepc))); + execute(*((Inst **)(savepc))); else if (*((Inst **)(savepc+1))) /* else part? */ execute(*((Inst **)(savepc+1))); if (!returning) @@ -255,7 +255,7 @@ procret(void) /* return from a procedure */ } void -bltin(void) +bltin(void) { Datum d; @@ -611,7 +611,7 @@ prexpr(void) /* print numeric value */ } void -prstr(void) /* print string value */ +prstr(void) /* print string value */ { print("%s", (char *) *pc++); } diff --git a/src/cmd/hoc/symbol.c b/src/cmd/hoc/symbol.c index 0a777b0d5..d0e01ab18 100644 --- a/src/cmd/hoc/symbol.c +++ b/src/cmd/hoc/symbol.c @@ -13,7 +13,7 @@ lookup(char* s) /* find s in symbol table */ for (sp = symlist; sp != (Symbol *) 0; sp = sp->next) if (strcmp(sp->name, s) == 0) return sp; - return 0; /* 0 ==> not found */ + return 0; /* 0 ==> not found */ } Symbol* diff --git a/src/cmd/htmlroff/a.h b/src/cmd/htmlroff/a.h index 173fdc961..a42091789 100644 --- a/src/cmd/htmlroff/a.h +++ b/src/cmd/htmlroff/a.h @@ -23,13 +23,13 @@ enum UPI = 720, /* units per inch */ UPX = 10, /* units per pixel */ - + /* special input modes */ CopyMode = 1<<1, ExpandMode = 1<<2, ArgMode = 1<<3, HtmlMode = 1<<4, - + MaxLine = 1024 }; diff --git a/src/cmd/htmlroff/char.c b/src/cmd/htmlroff/char.c index 151c9339f..9e213e139 100644 --- a/src/cmd/htmlroff/char.c +++ b/src/cmd/htmlroff/char.c @@ -12,7 +12,7 @@ rune2html(Rune r) static Rune **tcscache[256]; int p[2]; char *q; - + if(r == '\n') return L("\n"); @@ -79,7 +79,7 @@ troff2rune(Rune *rs) char *file, *f[10], *p, s[3]; int i, nf; Biobuf *b; - + if(rs[0] >= Runeself || rs[1] >= Runeself) return Runeerror; s[0] = rs[0]; @@ -103,14 +103,13 @@ troff2rune(Rune *rs) } } Bterm(b); - + if(ntrtab >= nelem(trtab)) fprint(2, "%s: trtab too small\n", argv0); } - + for(i=0; is && *(p-1) == '/'){ close: for(p0=t+1; *p0 && *p0 != Ult; p0++) @@ -52,7 +52,7 @@ closingtag(Rune *s) runemove(t, p0, runestrlen(p0)+1); } } - return t; + return t; } void @@ -108,7 +108,7 @@ void closehtml(void) { Tag *t, *next; - + br(); hideihtml(); for(t=tagstack; t; t=next){ @@ -230,7 +230,7 @@ void r_html(Rune *name) { Rune *id, *line, *p; - + id = copyarg(); line = readline(HtmlMode); for(p=line; *p; p++){ @@ -281,7 +281,6 @@ htmlinit(void) addesc('`', e_btick, CopyMode); addesc('-', e_minus, CopyMode); addesc('@', e_at, CopyMode); - + ds(L("font"), L(defaultfont)); } - diff --git a/src/cmd/htmlroff/input.c b/src/cmd/htmlroff/input.c index 99e0d56e9..a4c4bc3a3 100644 --- a/src/cmd/htmlroff/input.c +++ b/src/cmd/htmlroff/input.c @@ -65,7 +65,7 @@ _inputfile(Rune *s, void (*push)(Istack*)) Istack *is; Biobuf *b; char *t; - + t = esmprint("%S", s); if((b = Bopen(t, OREAD)) == nil){ free(t); @@ -95,7 +95,7 @@ queueinputfile(Rune *s) int _inputstdin(void (*push)(Istack*)) -{ +{ Biobuf *b; Istack *is; @@ -128,7 +128,7 @@ void _inputstring(Rune *s, void (*push)(Istack*)) { Istack *is; - + is = emalloc(sizeof *is); is->s = erunestrdup(s); is->p = is->s; @@ -176,7 +176,7 @@ getrune(void) { Rune r; int c; - + top: if(istack == nil) return -1; @@ -199,7 +199,7 @@ getrune(void) sysfatal("getrune - can't happen"); } if(r == '\n') - istack->lineno++; + istack->lineno++; return r; } @@ -215,7 +215,7 @@ int linefmt(Fmt *f) { Istack *is; - + for(is=istack; is && !is->b; is=is->next) ; if(is) @@ -228,7 +228,7 @@ void setlinenumber(Rune *s, int n) { Istack *is; - + for(is=istack; is && !is->name; is=is->next) ; if(is){ diff --git a/src/cmd/htmlroff/main.c b/src/cmd/htmlroff/main.c index b6af1e7b4..bd77a225a 100644 --- a/src/cmd/htmlroff/main.c +++ b/src/cmd/htmlroff/main.c @@ -23,11 +23,11 @@ main(int argc, char **argv) char *p; Rune *r; Rune buf[2]; - + Binit(&bout, 1, OWRITE); fmtinstall('L', linefmt); quotefmtinstall(); - + tmacdir = unsharp("#9/tmac"); dostdin = 0; ARGBEGIN{ @@ -63,10 +63,9 @@ main(int argc, char **argv) } if(argc == 0 || dostdin) queuestdin(); - + run(); Bprint(&bout, "\n"); Bterm(&bout); exits(nil); } - diff --git a/src/cmd/htmlroff/roff.c b/src/cmd/htmlroff/roff.c index bdc51a3e1..34b794be7 100644 --- a/src/cmd/htmlroff/roff.c +++ b/src/cmd/htmlroff/roff.c @@ -59,7 +59,7 @@ void addraw(Rune *name, void (*f)(Rune*)) { Raw *r; - + if(nraw >= nelem(raw)){ fprint(2, "too many raw requets\n"); return; @@ -73,7 +73,7 @@ void delraw(Rune *name) { int i; - + for(i=0; i= nelem(esc)){ fprint(2, "too many escapes\n"); return; @@ -256,7 +256,7 @@ copyarg(void) static Rune buf[MaxLine]; int c; Rune *r; - + if(_readx(buf, sizeof buf, ArgMode, 0) < 0) return nil; r = runestrstr(buf, L("\\\"")); @@ -266,7 +266,7 @@ copyarg(void) ; ungetrune('\n'); } - r = erunestrdup(buf); + r = erunestrdup(buf); return r; } @@ -322,7 +322,7 @@ parseargs(Rune *p, Rune **argv) *w++ = *p; } *w = 0; - } + } }else{ /* unquoted argument - need to watch out for \" comment */ for(; *p; p++){ @@ -369,7 +369,7 @@ dotline(int dot) raw[i].f(raw[i].name); free(a); return; - } + } } /* @@ -515,7 +515,7 @@ void runinput(void) { int c; - + bol = 1; for(;;){ c = getnext(); @@ -573,7 +573,7 @@ run(void) t20init(); htmlinit(); hideihtml(); - + addreq(L("margin"), r_margin, 1); nr(L(".margin"), 1); nr(L(".paragraph"), 1); @@ -603,7 +603,7 @@ void inroman(Rune r) { int f; - + f = getnr(L(".f")); nr(L(".f"), 1); runmacro1(L("font")); @@ -631,7 +631,7 @@ void outhtml(Rune *s) { Rune r; - + for(; *s; s++){ switch(r = *s){ case '<': diff --git a/src/cmd/htmlroff/t1.c b/src/cmd/htmlroff/t1.c index 8236694de..c68ada77b 100644 --- a/src/cmd/htmlroff/t1.c +++ b/src/cmd/htmlroff/t1.c @@ -1,5 +1,5 @@ #include "a.h" - + /* * Section 1 - General Explanation. */ @@ -10,7 +10,7 @@ int scale2units(char c) { int x; - + switch(c){ case 'i': /* inch */ return UPI; @@ -49,7 +49,7 @@ long runestrtol(Rune *a, Rune **p) { long n; - + n = 0; while('0' <= *a && *a <= '9'){ n = n*10 + *a-'0'; @@ -111,7 +111,7 @@ eval0(Rune **pline, int scale, int recur) *pline = p; return x; } - + while(*p){ switch(*p++) { case '+': @@ -176,11 +176,10 @@ void t1init(void) { Tm tm; - + tm = *localtime(time(0)); nr(L("dw"), tm.wday+1); nr(L("dy"), tm.mday); nr(L("mo"), tm.mon); nr(L("yr"), tm.year%100); } - diff --git a/src/cmd/htmlroff/t10.c b/src/cmd/htmlroff/t10.c index 4aa745324..64d63f414 100644 --- a/src/cmd/htmlroff/t10.c +++ b/src/cmd/htmlroff/t10.c @@ -58,7 +58,7 @@ int e_bang(void) { Rune *line; - + line = readline(CopyMode); out(line); outrune('\n'); @@ -70,7 +70,7 @@ int e_X(void) { int c, c1; - + c1 = getrune(); if(c1 < 0 || c1 == '\n') { c = c1; @@ -119,7 +119,7 @@ void r_comment(Rune *name) { int c; - + USED(name); while((c = getrune()) >= 0 && c != '\n') ; @@ -136,11 +136,10 @@ t10init(void) addreq(L("tr"), r_warn, -1); addreq(L("ul"), r_nop, -1); addraw(L("\\\""), r_comment); - + addesc('!', e_bang, 0); addesc('X', e_X, 0); addesc('\"', e_quote, CopyMode|ArgMode); addesc('\n', e_newline, CopyMode|ArgMode|HtmlMode); addesc('e', e_e, 0); } - diff --git a/src/cmd/htmlroff/t11.c b/src/cmd/htmlroff/t11.c index dd1dd75b7..2e273ac4d 100644 --- a/src/cmd/htmlroff/t11.c +++ b/src/cmd/htmlroff/t11.c @@ -109,4 +109,3 @@ t11init(void) addesc('r', e_r, 0); addesc('k', e_k, 0); } - diff --git a/src/cmd/htmlroff/t13.c b/src/cmd/htmlroff/t13.c index 0fadab3ad..b2922f6a6 100644 --- a/src/cmd/htmlroff/t13.c +++ b/src/cmd/htmlroff/t13.c @@ -11,7 +11,6 @@ t13init(void) addreq(L("hy"), r_nop, -1); addreq(L("hc"), r_nop, -1); addreq(L("hw"), r_nop, -1); - + addesc('%', e_nop, 0); } - diff --git a/src/cmd/htmlroff/t14.c b/src/cmd/htmlroff/t14.c index 1dab35167..4242dd706 100644 --- a/src/cmd/htmlroff/t14.c +++ b/src/cmd/htmlroff/t14.c @@ -7,7 +7,7 @@ void r_lt(int argc, Rune **argv) { Rune *p; - + if(argc < 2) nr(L(".lt"), evalscale(L("6.5i"), 'm')); else{ @@ -30,4 +30,3 @@ t14init(void) addreq(L("pc"), r_nop, -1); /* page number char */ addreq(L("lt"), r_lt, -1); } - diff --git a/src/cmd/htmlroff/t15.c b/src/cmd/htmlroff/t15.c index fbfd5128f..221f642e6 100644 --- a/src/cmd/htmlroff/t15.c +++ b/src/cmd/htmlroff/t15.c @@ -10,4 +10,3 @@ t15init(void) addreq(L("nm"), r_warn, -1); addreq(L("nn"), r_warn, -1); } - diff --git a/src/cmd/htmlroff/t16.c b/src/cmd/htmlroff/t16.c index 3a9c427e8..9389a59af 100644 --- a/src/cmd/htmlroff/t16.c +++ b/src/cmd/htmlroff/t16.c @@ -24,7 +24,7 @@ void startbody(void) { int c; - + while((c = getrune()) == ' ' || c == '\t') ; ungetrune(c); @@ -52,7 +52,7 @@ ifeval(void) int c, cc, neg, nc; Rune line[MaxLine], *p, *e, *q; Rune *a; - + while((c = getnext()) == ' ' || c == '\t') ; neg = 0; @@ -68,7 +68,7 @@ ifeval(void) free(a); return c; } - + switch(c){ case ' ': case '\n': @@ -111,12 +111,12 @@ ifeval(void) return (q-line == p-(q+1) && memcmp(line, q+1, (q-line)*sizeof(Rune))==0) ^ neg; } - + void r_if(Rune *name) { int n; - + n = ifeval(); if(runestrcmp(name, L("ie")) == 0){ if(niftrue >= nelem(iftrue)) @@ -133,7 +133,7 @@ void r_el(Rune *name) { USED(name); - + if(niftrue <= 0){ warn("%Cel underflow", dot); return; @@ -150,7 +150,7 @@ t16init(void) addraw(L("if"), r_if); addraw(L("ie"), r_if); addraw(L("el"), r_el); - + addesc('{', e_nop, HtmlMode|ArgMode); addesc('}', e_nop, HtmlMode|ArgMode); } diff --git a/src/cmd/htmlroff/t17.c b/src/cmd/htmlroff/t17.c index bbd095d54..74096c5ce 100644 --- a/src/cmd/htmlroff/t17.c +++ b/src/cmd/htmlroff/t17.c @@ -97,7 +97,7 @@ r_ev(int argc, Rune **argv) { int i; Env *e; - + if(argc == 1){ if(nevstack <= 0){ if(verbose) warn(".ev stack underflow"); @@ -123,7 +123,7 @@ void t17init(void) { int i; - + for(i=0; i 5) @@ -93,7 +93,7 @@ r_rs(int argc, Rune **argv) void t5init(void) -{ +{ addreq(L("vs"), r_vs, -1); addreq(L("ls"), r_ls, -1); addreq(L("sp"), r_sp, -1); @@ -107,4 +107,3 @@ t5init(void) nr(L(".ls"), 1); nr(L(".ls0"), 1); } - diff --git a/src/cmd/htmlroff/t6.c b/src/cmd/htmlroff/t6.c index 130f535fe..3090cd262 100644 --- a/src/cmd/htmlroff/t6.c +++ b/src/cmd/htmlroff/t6.c @@ -71,7 +71,6 @@ t6init(void) addreq(L("ll"), r_ll, -1); addreq(L("in"), r_in, -1); addreq(L("ti"), r_ti, 1); - + nr(L(".l"), eval(L("6.5i"))); } - diff --git a/src/cmd/htmlroff/t7.c b/src/cmd/htmlroff/t7.c index 9936a44c8..cee439277 100644 --- a/src/cmd/htmlroff/t7.c +++ b/src/cmd/htmlroff/t7.c @@ -36,7 +36,7 @@ runmacro(int dot, int argc, Rune **argv) Rune *p; int i; Mac *m; - + if(verbose && isupperrune(argv[0][0])) fprint(2, "run: %S\n", argv[0]); p = getds(argv[0]); if(p == nil){ @@ -71,7 +71,7 @@ popmacro(void) { int i; Mac *m; - + if(--nmstack < 0){ fprint(2, "%L: macro stack underflow\n"); return; @@ -94,7 +94,7 @@ runmacro1(Rune *name) { Rune *argv[2]; int obol; - + if(verbose) fprint(2, "outcb %p\n", outcb); obol = bol; argv[0] = name; @@ -134,7 +134,7 @@ popmacro1(void) /* * diversions * - * processed output diverted + * processed output diverted * dn dl registers vertical and horizontal size of last diversion * .z - current diversion name */ @@ -195,7 +195,7 @@ void r_ch(int argc, Rune **argv) { int i; - + if(argc == 2){ if(trap0 && runestrcmp(argv[1], trap0) == 0){ free(trap0); @@ -244,7 +244,7 @@ r_de(int argc, Rune **argv) fmtrunestrcpy(&fmt, p); len = runestrlen(end); while((p = readline(CopyMode)) != nil){ - if(runestrncmp(p, end, len) == 0 + if(runestrncmp(p, end, len) == 0 && (p[len]==' ' || p[len]==0 || p[len]=='\t' || (p[len]=='\\' && p[len+1]=='}'))){ free(p); @@ -270,7 +270,7 @@ void r_ds(Rune *cmd) { Rune *name, *line, *p; - + name = copyarg(); line = readline(CopyMode); if(name == nil || line == nil){ @@ -335,7 +335,7 @@ flushdi(void) { int n; Rune *p; - + if(ndi == 0 || difmtinit == 0) return; fmtrune(&difmt, Uunformatted); @@ -448,7 +448,7 @@ void r_em(int argc, Rune **argv) { Rune buf[20]; - + USED(argc); runesnprint(buf, nelem(buf), ".%S\n", argv[1]); as(L("eof"), buf); @@ -458,7 +458,7 @@ int e_star(void) { Rune *p; - + p = getds(getname()); if(p) pushinputstring(p); @@ -514,7 +514,7 @@ e_dollar(void) void t7init(void) -{ +{ addreq(L("de"), r_de, -1); addreq(L("am"), r_de, -1); addreq(L("ig"), r_de, -1); @@ -529,15 +529,14 @@ t7init(void) addreq(L("wh"), r_wh, -1); addreq(L("ch"), r_ch, -1); addreq(L("dt"), r_dt, -1); - + addesc('$', e_dollar, CopyMode|ArgMode|HtmlMode); addesc('*', e_star, CopyMode|ArgMode|HtmlMode); addesc('t', e_t, CopyMode|ArgMode); addesc('a', e_a, CopyMode|ArgMode); addesc('\\', e_backslash, ArgMode|CopyMode); addesc('.', e_dot, CopyMode|ArgMode); - + ds(L("eof"), L(".sp 0.5i\n")); ds(L(".."), L("")); } - diff --git a/src/cmd/htmlroff/t8.c b/src/cmd/htmlroff/t8.c index ead5a0200..511737ced 100644 --- a/src/cmd/htmlroff/t8.c +++ b/src/cmd/htmlroff/t8.c @@ -74,7 +74,7 @@ Rune* getdsnr(Rune *name, Reg *list) { Reg *s; - + for(s=list; s; s=s->next) if(runestrcmp(name, s->name) == 0) return s->val; @@ -91,7 +91,7 @@ void as(Rune *name, Rune *val) { Rune *p, *q; - + p = getds(name); if(p == nil) p = L(""); @@ -113,7 +113,7 @@ printds(int t) { int n, total; Reg *s; - + total = 0; for(s=dslist; s; s=s->next){ if(s->val) @@ -131,7 +131,7 @@ void nr(Rune *name, int val) { Rune buf[20]; - + runesnprint(buf, nelem(buf), "%d", val); _nr(name, buf); } @@ -152,7 +152,7 @@ Rune* getaf(Rune *name) { Reg *s; - + for(s=nrlist; s; s=s->next) if(runestrcmp(s->name, name) == 0) return s->fmt; @@ -163,7 +163,7 @@ void printnr(void) { Reg *r; - + for(r=nrlist; r; r=r->next) fprint(2, "%S %S %d\n", r->name, r->val, r->inc); } @@ -225,7 +225,7 @@ void r_af(int argc, Rune **argv) { USED(argc); - + af(argv[1], argv[2]); } @@ -234,7 +234,7 @@ void r_rr(int argc, Rune **argv) { int i; - + for(i=1; i0; v/=26) i++; @@ -284,7 +284,7 @@ roman(Rune *buf, int n, int upper) Rune *p; char *q; struct romanv *r; - + if(upper) upper = 'A' - 'a'; if(n >= 5000 || n <= 0){ @@ -309,7 +309,7 @@ getname(void) { int i, c, cc; static Rune buf[100]; - + /* XXX add [name] syntax as in groff */ c = getnext(); if(c < 0) @@ -359,7 +359,7 @@ e_n(void) int inc, v, l; Rune *name, *fmt, buf[100]; Reg *s; - + inc = getnext(); if(inc < 0) return -1; @@ -442,8 +442,7 @@ t8init(void) addreq(L("af"), r_af, 2); addreq(L("rr"), r_rr, -1); addreq(L("pnr"), r_pnr, 0); - + addesc('n', e_n, CopyMode|ArgMode|HtmlMode); addesc('g', e_g, 0); } - diff --git a/src/cmd/htmlroff/t9.c b/src/cmd/htmlroff/t9.c index c9e045642..6f4c4d6c5 100644 --- a/src/cmd/htmlroff/t9.c +++ b/src/cmd/htmlroff/t9.c @@ -3,4 +3,3 @@ */ XXX - diff --git a/src/cmd/htmlroff/util.c b/src/cmd/htmlroff/util.c index 99e99543f..15dd4c74d 100644 --- a/src/cmd/htmlroff/util.c +++ b/src/cmd/htmlroff/util.c @@ -4,7 +4,7 @@ void* emalloc(uint n) { void *v; - + v = mallocz(n, 1); if(v == nil) sysfatal("out of memory"); @@ -15,7 +15,7 @@ char* estrdup(char *s) { char *t; - + t = strdup(s); if(t == nil) sysfatal("out of memory"); @@ -38,7 +38,7 @@ void* erealloc(void *ov, uint n) { void *v; - + v = realloc(ov, n); if(v == nil) sysfatal("out of memory"); @@ -50,7 +50,7 @@ erunesmprint(char *fmt, ...) { Rune *s; va_list arg; - + va_start(arg, fmt); s = runevsmprint(fmt, arg); va_end(arg); @@ -64,7 +64,7 @@ esmprint(char *fmt, ...) { char *s; va_list arg; - + va_start(arg, fmt); s = vsmprint(fmt, arg); va_end(arg); @@ -77,7 +77,7 @@ void warn(char *fmt, ...) { va_list arg; - + fprint(2, "htmlroff: %L: "); va_start(arg, fmt); vfprint(2, fmt, arg); @@ -120,4 +120,3 @@ L(char *s) hash[h] = l; return l->r; } - diff --git a/src/cmd/import.c b/src/cmd/import.c index 6b7152bab..0be2f5b6f 100644 --- a/src/cmd/import.c +++ b/src/cmd/import.c @@ -99,10 +99,10 @@ threadmain(int argc, char *argv[]) fmtinstall('F', fcallfmt); } - + if(rem){ netfd[0] = 0; - netfd[1] = 1; + netfd[1] = 1; write(1, "OK", 2); }else{ if(argc != 1) @@ -115,7 +115,7 @@ threadmain(int argc, char *argv[]) fn = localside; if(rem+export == 1) fn = remoteside; - + if(rem || !dofork) fn(nil); else diff --git a/src/cmd/ip/dhcp.h b/src/cmd/ip/dhcp.h old mode 100755 new mode 100644 index 0ca5084fe..d07a2e8ac --- a/src/cmd/ip/dhcp.h +++ b/src/cmd/ip/dhcp.h @@ -74,7 +74,7 @@ enum OBtcpka= 38, OBtcpkag= 39, OBnisdomain= 40, - OBniserver= 41, + OBniserver= 41, OBntpserver= 42, OBvendorinfo= 43, /* 0x2b */ OBnetbiosns= 44, @@ -127,7 +127,7 @@ enum { Sbound, Srenewing, Srebinding -}; +}; typedef struct Bootp Bootp; struct Bootp diff --git a/src/cmd/ip/dhcpd/dat.h b/src/cmd/ip/dhcpd/dat.h old mode 100755 new mode 100644 index aa64deebd..c69f9f383 --- a/src/cmd/ip/dhcpd/dat.h +++ b/src/cmd/ip/dhcpd/dat.h @@ -82,4 +82,3 @@ extern char *blog; extern Ipifc *ipifcs; extern long now; extern char *ndbfile; - diff --git a/src/cmd/ip/dhcpd/db.c b/src/cmd/ip/dhcpd/db.c old mode 100755 new mode 100644 index f4b48552e..cf245efed --- a/src/cmd/ip/dhcpd/db.c +++ b/src/cmd/ip/dhcpd/db.c @@ -405,7 +405,7 @@ commitbinding(Binding *b) } setbinding(b, b->offeredto, now + b->offer); b->lasttouched = now; - + if(writebinding(fd, b) < 0){ close(fd); return -1; @@ -434,7 +434,7 @@ releasebinding(Binding *b, char *id) } b->lease = 0; b->expoffer = 0; - + if(writebinding(fd, b) < 0){ close(fd); return -1; diff --git a/src/cmd/ip/dhcpd/dhcpd.c b/src/cmd/ip/dhcpd/dhcpd.c old mode 100755 new mode 100644 index e28bf3cb6..c5fb06bf1 --- a/src/cmd/ip/dhcpd/dhcpd.c +++ b/src/cmd/ip/dhcpd/dhcpd.c @@ -67,7 +67,7 @@ int pptponly; /* only answer request that came from the pptp server */ int mute; int minlease = MinLease; -ulong start; +ulong start; /* option magic */ char plan9opt[4] = { 'p', '9', ' ', ' ' }; @@ -502,7 +502,7 @@ rcvrequest(Req *rp) sendnak(rp, "no offer for you"); return; } - + /* if not for me, retract offer */ if(!forme(rp->server)){ b->expoffer = 0; @@ -1040,7 +1040,7 @@ parseoptions(Req *rp) p += n; if(p > rp->e) return; - + switch(code){ case ODipaddr: /* requested ip address */ if(n == IPv4addrlen) @@ -1506,7 +1506,7 @@ arpenter(uchar *ip, uchar *ether) { int pid; char xip[100], xether[100]; - + switch(pid=fork()){ case -1: break; diff --git a/src/cmd/ip/dhcpd/dhcpleases.c b/src/cmd/ip/dhcpd/dhcpleases.c old mode 100755 new mode 100644 index 71719649f..a99b92182 --- a/src/cmd/ip/dhcpd/dhcpleases.c +++ b/src/cmd/ip/dhcpd/dhcpleases.c @@ -39,5 +39,5 @@ main(void) continue; if(b.lease > now) print("%I leased by %s until %s", b.ip, b.boundto, ctime(b.lease)); - } + } } diff --git a/src/cmd/ip/dhcpd/ndb.c b/src/cmd/ip/dhcpd/ndb.c old mode 100755 new mode 100644 index 53ffb58fb..97b2284f3 --- a/src/cmd/ip/dhcpd/ndb.c +++ b/src/cmd/ip/dhcpd/ndb.c @@ -108,7 +108,7 @@ lookupip(uchar *ipaddr, Info *iip, int gate) t = ndbipinfo(db, "ip", ip, attrs, p - attrs); if(t == nil) return -1; - + for(nt = t; nt != nil; nt = nt->entry){ if(strcmp(nt->attr, "ip") == 0) setipaddr(iip->ipaddr, nt->val); diff --git a/src/cmd/ip/dhcpd/ping.c b/src/cmd/ip/dhcpd/ping.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/dhcpd/testlook.c b/src/cmd/ip/dhcpd/testlook.c old mode 100755 new mode 100644 index 4937e55b6..ac3f44f8b --- a/src/cmd/ip/dhcpd/testlook.c +++ b/src/cmd/ip/dhcpd/testlook.c @@ -188,7 +188,7 @@ ipinfo(Ndb *db, char *etherin, char *ipin, char *name, Ipinfo *iip) recursesubnet(db, classmask[CLASS(iip->ipaddr)], iip, fsname, gwname, auname); /* lookup fs's and gw's ip addresses */ - + if(fsname[0]) lookupip(db, fsname, iip->fsip, iip); if(gwname[0]) diff --git a/src/cmd/ip/dhcpd/testlookup.c b/src/cmd/ip/dhcpd/testlookup.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/dhcpd/testping.c b/src/cmd/ip/dhcpd/testping.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/arp.c b/src/cmd/ip/snoopy/arp.c old mode 100755 new mode 100644 index d317c1bbb..7b7fa3181 --- a/src/cmd/ip/snoopy/arp.c +++ b/src/cmd/ip/snoopy/arp.c @@ -34,7 +34,7 @@ enum Opa }; -static Field p_fields[] = +static Field p_fields[] = { {"spa", Fv4ip, Ospa, "protocol source", } , {"tpa", Fv4ip, Otpa, "protocol target", } , diff --git a/src/cmd/ip/snoopy/bootp.c b/src/cmd/ip/snoopy/bootp.c old mode 100755 new mode 100644 index e7ead8637..18350081b --- a/src/cmd/ip/snoopy/bootp.c +++ b/src/cmd/ip/snoopy/bootp.c @@ -55,7 +55,7 @@ enum Ot }; -static Field p_fields[] = +static Field p_fields[] = { {"ca", Fv4ip, Oca, "client IP addr", } , {"sa", Fv4ip, Osa, "server IP addr", } , diff --git a/src/cmd/ip/snoopy/dat.h b/src/cmd/ip/snoopy/dat.h old mode 100755 new mode 100644 index ba3e446da..0ac054c7b --- a/src/cmd/ip/snoopy/dat.h +++ b/src/cmd/ip/snoopy/dat.h @@ -60,7 +60,7 @@ struct Msg char *e; /* buffer end */ int needroot; /* pr is root, need to see in expression */ - Proto *pr; /* current/next protocol */ + Proto *pr; /* current/next protocol */ }; enum diff --git a/src/cmd/ip/snoopy/dhcp.c b/src/cmd/ip/snoopy/dhcp.c old mode 100755 new mode 100644 index cd976ec0b..bab0cf827 --- a/src/cmd/ip/snoopy/dhcp.c +++ b/src/cmd/ip/snoopy/dhcp.c @@ -61,7 +61,7 @@ enum OBtcpka= 38, OBtcpkag= 39, OBnisdomain= 40, - OBniserver= 41, + OBniserver= 41, OBntpserver= 42, OBvendorinfo= 43, /* 0x2b */ OBnetbiosns= 44, @@ -232,7 +232,7 @@ p_seprint(Msg *m) ps += n; if(ps > m->pe) break; - + switch(code){ case ODipaddr: /* requested ip address */ p = pserver(p, e, "ipaddr", o, n); @@ -473,4 +473,3 @@ Proto dhcp = nil, defaultframer }; - diff --git a/src/cmd/ip/snoopy/dns.c b/src/cmd/ip/snoopy/dns.c index 144a49497..c115df17b 100644 --- a/src/cmd/ip/snoopy/dns.c +++ b/src/cmd/ip/snoopy/dns.c @@ -32,7 +32,7 @@ enum /* query types (all RR types are also queries) */ Tixfr= 251, /* incremental zone transfer */ Taxfr= 252, /* zone transfer */ - Tmailb= 253, /* { Tmb, Tmg, Tmr } */ + Tmailb= 253, /* { Tmb, Tmg, Tmr } */ Tall= 255, /* all records */ /* classes */ @@ -87,7 +87,7 @@ getstr(uchar **pp, int *len, uchar *ep) { uchar *p; int n; - + p = *pp; n = *p++; if(p+n > ep) @@ -215,7 +215,7 @@ cname(int class) if(class == Cin) return ""; - + snprint(buf, sizeof buf, "class=%d", class); return buf; } @@ -236,7 +236,7 @@ p_seprint(Msg *m) char *sym1, *sym2, *sep; int type; static int first = 1; - + if(first){ first = 0; quotefmtinstall(); @@ -388,7 +388,7 @@ p_seprint(Msg *m) NetS(p), p[3], p[4], rlen-4, p+4); p += rlen; break; - + case Tsig: if(rlen < 18) goto error; @@ -408,7 +408,7 @@ p_seprint(Msg *m) } if(p != ep) goto error; - } + } return 0; error: diff --git a/src/cmd/ip/snoopy/dump.c b/src/cmd/ip/snoopy/dump.c old mode 100755 new mode 100644 index ec2a3ce7c..3d9451dac --- a/src/cmd/ip/snoopy/dump.c +++ b/src/cmd/ip/snoopy/dump.c @@ -55,7 +55,7 @@ p_seprint(Msg *m) for(i = 0; i < n && p+1>4]; - *p++ = tohex[c&0xf]; + *p++ = tohex[c&0xf]; } } diff --git a/src/cmd/ip/snoopy/ether.c b/src/cmd/ip/snoopy/ether.c old mode 100755 new mode 100644 index 9e16579ad..2b33106e4 --- a/src/cmd/ip/snoopy/ether.c +++ b/src/cmd/ip/snoopy/ether.c @@ -35,7 +35,7 @@ enum Ot, /* type */ }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fether, Os, "source address", } , {"d", Fether, Od, "destination address", } , diff --git a/src/cmd/ip/snoopy/gre.c b/src/cmd/ip/snoopy/gre.c old mode 100755 new mode 100644 index 6808293b7..2e7449408 --- a/src/cmd/ip/snoopy/gre.c +++ b/src/cmd/ip/snoopy/gre.c @@ -36,7 +36,7 @@ sprintgre(void *a, char *buf, int len) uchar *p = a; chksum = offset = key = seq = ack = 0; - + flag = NetS(p); prot = NetS(p+2); p += 4; len -= 4; @@ -78,6 +78,6 @@ sprintgre(void *a, char *buf, int len) n += sprintppp(p, buf+n, len); else n += sprintx(p, buf+n, len); - + return n; } diff --git a/src/cmd/ip/snoopy/hdlc.c b/src/cmd/ip/snoopy/hdlc.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/icmp.c b/src/cmd/ip/snoopy/icmp.c old mode 100755 new mode 100644 index 8e528dc96..f798e42a3 --- a/src/cmd/ip/snoopy/icmp.c +++ b/src/cmd/ip/snoopy/icmp.c @@ -23,7 +23,7 @@ enum Op, /* next protocol */ }; -static Field p_fields[] = +static Field p_fields[] = { {"t", Fnum, Ot, "type", } , {0} diff --git a/src/cmd/ip/snoopy/icmp6.c b/src/cmd/ip/snoopy/icmp6.c old mode 100755 new mode 100644 index 9ba749398..9ede92a57 --- a/src/cmd/ip/snoopy/icmp6.c +++ b/src/cmd/ip/snoopy/icmp6.c @@ -22,14 +22,14 @@ enum Ot, /* type */ Op, /* next protocol */}; -static Field p_fields[] = +static Field p_fields[] = { {"t", Fnum, Ot, "type", } , {0} }; enum -{ +{ /* ICMPv6 types */ EchoReply = 0, UnreachableV6 = 1, @@ -114,7 +114,7 @@ static char *parpcode[] = [2] "unrecognized IPv6 option encountered", [3] "icmp par prob: unknown code" }; -enum +enum { sll = 1, tll = 2, @@ -123,7 +123,7 @@ enum mtu = 5 }; -static char *icmp6opts[256] = +static char *icmp6opts[256] = { [0] "unknown opt", [1] "sll_addr", @@ -206,7 +206,7 @@ opt_seprint(Msg *m) case sll: case tll: - if ((pktsz < osz) || (osz != 8)) { + if ((pktsz < osz) || (osz != 8)) { p = seprint(p, e, "\n option=%s bad size=%d", opt, osz); m->pr = &dump; return p; @@ -217,7 +217,7 @@ opt_seprint(Msg *m) break; case pref: - if ((pktsz < osz) || (osz != 32)) { + if ((pktsz < osz) || (osz != 32)) { p = seprint(p, e, "\n option=%s: bad size=%d", opt, osz); m->pr = &dump; return p; @@ -235,11 +235,11 @@ opt_seprint(Msg *m) NetL(a+12)!=0); pktsz -= osz; - a += osz; + a += osz; break; case redir: - if (pktsz < osz) { + if (pktsz < osz) { p = seprint(p, e, "\n option=%s: bad size=%d", opt, osz); m->pr = &dump; return p; @@ -248,11 +248,11 @@ opt_seprint(Msg *m) p = seprint(p, e, "\n option=%s len %d", opt, osz); a += osz; m->ps = a; - return p; + return p; break; case mtu: - if ((pktsz < osz) || (osz != 8)) { + if ((pktsz < osz) || (osz != 8)) { p = seprint(p, e, "\n option=%s: bad size=%d", opt, osz); m->pr = &dump; return p; diff --git a/src/cmd/ip/snoopy/il.c b/src/cmd/ip/snoopy/il.c old mode 100755 new mode 100644 index a4ff60eb7..35c43a241 --- a/src/cmd/ip/snoopy/il.c +++ b/src/cmd/ip/snoopy/il.c @@ -29,7 +29,7 @@ enum Osd }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fnum, Os, "source port", } , {"d", Fnum, Od, "dest port", } , @@ -88,9 +88,9 @@ p_filter(Filter *f, Msg *m) return 0; } -char *pktnames[] = +char *pktnames[] = { - "Sync", + "Sync", "Data", "Dataquery", "Ack", @@ -103,7 +103,7 @@ static char* pkttype(int t) { static char b[10]; - + if(t > 6){ sprint(b, "%d", t); return b; diff --git a/src/cmd/ip/snoopy/ip.c b/src/cmd/ip/snoopy/ip.c old mode 100755 new mode 100644 index 234ca85ff..045897781 --- a/src/cmd/ip/snoopy/ip.c +++ b/src/cmd/ip/snoopy/ip.c @@ -135,7 +135,7 @@ enum Ot, /* type */ }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fv4ip, Os, "source address", } , {"d", Fv4ip, Od, "destination address", } , diff --git a/src/cmd/ip/snoopy/ip6.c b/src/cmd/ip/snoopy/ip6.c old mode 100755 new mode 100644 index 7187cda77..ba9be993c --- a/src/cmd/ip/snoopy/ip6.c +++ b/src/cmd/ip/snoopy/ip6.c @@ -132,7 +132,7 @@ enum Ot, /* type */ }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fv6ip, Os, "source address", } , {"d", Fv6ip, Od, "destination address", } , @@ -167,7 +167,7 @@ v6hdrlen(Hdr *h) int pktlen = IP6HDR + NetS(h->length); uchar nexthdr = h->proto; uchar *pkt = (uchar*) h; - + pkt += len; plen = len; @@ -176,7 +176,7 @@ v6hdrlen(Hdr *h) if (nexthdr == FRAG_HDR) len = FRAG_HSZ; - else + else len = ( ((int) *(pkt+1)) + 1) * 8; if (plen + len > pktlen) @@ -226,7 +226,7 @@ v6hdr_seprint(Msg *m) int pktlen = IP6HDR + NetS(h->length); uchar nexthdr = h->proto; int plen; - + pkt += len; plen = len; diff --git a/src/cmd/ip/snoopy/llc.c b/src/cmd/ip/snoopy/llc.c index bbc21986f..09cf022dc 100644 --- a/src/cmd/ip/snoopy/llc.c +++ b/src/cmd/ip/snoopy/llc.c @@ -1,4 +1,4 @@ -/* +/* * LLC. Only enough to dispatch to SNAP and IP. */ @@ -17,7 +17,7 @@ enum UPoll = 0x10, IsPoll = 0x100, XidFi = 0x81, - + SapNull = 0, SapGlobal = 0xff, Sap8021BI = 0x02, @@ -40,7 +40,7 @@ static Mux p_mux[] = // Linux gives llc -> snap not llc -> ip. // If we don't tell snoopy about llc -> ip, then the default patterns // like snoopy -h radiotap -f dns work better. -// { "ip", SapIP }, +// { "ip", SapIP }, { "snap", SapSnap }, { 0 } }; @@ -138,7 +138,7 @@ static int p_seprint(Msg *m) { Hdr h; - + memset(&h, 0, sizeof h); if(unpackhdr(m->ps, m->pe, &h) < 0) return -1; @@ -156,7 +156,7 @@ p_seprint(Msg *m) m->pr = &snap; break; } - } + } return 0; } diff --git a/src/cmd/ip/snoopy/main.c b/src/cmd/ip/snoopy/main.c old mode 100755 new mode 100644 index 9c2dad2e8..6902797e8 --- a/src/cmd/ip/snoopy/main.c +++ b/src/cmd/ip/snoopy/main.c @@ -290,14 +290,14 @@ struct pcap_file_header { }; /* - * pcap trace header + * pcap trace header */ void pcaphdr(int fd) { if(tiflag){ struct pcap_file_header hdr; - + if(readn(fd, &hdr, sizeof hdr) != sizeof hdr) sysfatal("short header"); if(hdr.magic != TCPDUMP_MAGIC) @@ -309,16 +309,16 @@ pcaphdr(int fd) } if(toflag){ struct pcap_file_header hdr; - + hdr.magic = TCPDUMP_MAGIC; hdr.version_major = PCAP_VERSION_MAJOR; hdr.version_minor = PCAP_VERSION_MINOR; - + hdr.thiszone = 0; hdr.snaplen = 1500; hdr.sigfigs = 0; hdr.linktype = 1; - + write(1, &hdr, sizeof(hdr)); } } @@ -682,7 +682,7 @@ _compile(Filter *f, Proto *last) case '=': if(last == nil) sysfatal("internal error: compilewalk: badly formed tree"); - + if(last->compile == nil) sysfatal("unknown %s field: %s", f->pr->name, f->s); (*last->compile)(f); @@ -840,7 +840,7 @@ cat(void) { char buf[1024]; int n; - + while((n = read(0, buf, sizeof buf)) > 0) write(1, buf, n); } @@ -850,10 +850,10 @@ void startmc(void) { int p[2]; - + if(fd1 == -1) fd1 = dup(1, -1); - + if(pipe(p) < 0) return; switch(fork()){ @@ -892,7 +892,7 @@ printhelp(char *name) Mux *m; Field *f; char fmt[40]; - + if(name == nil){ print("protocols:\n"); startmc(); @@ -901,13 +901,13 @@ printhelp(char *name) stopmc(); return; } - + pr = findproto(name); if(pr == nil){ print("unknown protocol %s\n", name); return; } - + if(pr->field){ print("%s's filter attributes:\n", pr->name); len = 0; diff --git a/src/cmd/ip/snoopy/ninep.c b/src/cmd/ip/snoopy/ninep.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/ospf.c b/src/cmd/ip/snoopy/ospf.c old mode 100755 new mode 100644 index bb4cd893b..d5871dd9b --- a/src/cmd/ip/snoopy/ospf.c +++ b/src/cmd/ip/snoopy/ospf.c @@ -22,7 +22,7 @@ struct Ospfpkt uchar auth[8]; uchar data[1]; }; -#define OSPF_HDRSIZE 24 +#define OSPF_HDRSIZE 24 enum { @@ -62,15 +62,15 @@ ospfauth(Ospfpkt *ospf) case 0: return "no authentication"; case 1: - sprint(auth, "password(%8.8ux %8.8ux)", NetL(ospf->auth), + sprint(auth, "password(%8.8ux %8.8ux)", NetL(ospf->auth), NetL(ospf->auth+4)); break; case 2: - sprint(auth, "crypto(plen %d id %d dlen %d)", NetS(ospf->auth), + sprint(auth, "crypto(plen %d id %d dlen %d)", NetS(ospf->auth), ospf->auth[2], ospf->auth[3]); break; default: - sprint(auth, "auth%d(%8.8ux %8.8ux)", NetS(ospf->autype), NetL(ospf->auth), + sprint(auth, "auth%d(%8.8ux %8.8ux)", NetS(ospf->autype), NetL(ospf->auth), NetL(ospf->auth+4)); } return auth; @@ -156,7 +156,7 @@ struct Ospfrt { uchar typ; uchar numtos; uchar metric[2]; - + }; struct OspfrtLSA { @@ -348,7 +348,7 @@ p_seprint(Msg *m) x -= OSPF_HDRSIZE; p = seprint(p, e, "ver=%d type=%d len=%d r=%V a=%V c=%4.4ux %s ", - ospf->version, ospf->type, x, + ospf->version, ospf->type, x, ospf->router, ospf->area, NetS(ospf->sum), ospfauth(ospf)); diff --git a/src/cmd/ip/snoopy/p80211.c b/src/cmd/ip/snoopy/p80211.c index 92ed8aba2..49fe0245c 100644 --- a/src/cmd/ip/snoopy/p80211.c +++ b/src/cmd/ip/snoopy/p80211.c @@ -1,4 +1,4 @@ -/* +/* * IEEE 802.11. */ @@ -29,7 +29,7 @@ enum NodataCfAck, NodataCfPoll, NodataCfAckPoll, - + FlagTods = 0x1, FlagFromds = 0x2, FlagMoreflag = 0x4, @@ -38,7 +38,7 @@ enum FlagMoreData = 0x20, FlagWep = 0x40, FlagOrder = 0x80, - + ProtoNone = 0, ProtoLlc, }; @@ -85,7 +85,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) if(h->vers != 0) return 0; - + switch(h->type){ case Tmgmt: // fc dur da sa bssid seq @@ -98,7 +98,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) memmove(h->bssid, p+16, 6); h->seq = LittleS(p+22); break; - + case Tctl: switch(h->subtype){ case CtlPoll: @@ -110,7 +110,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) memmove(h->bssid, p+4, 6); memmove(h->ta, p+10, 6); break; - + case CtlRts: // fc dur ra ta if(p+2+2+6+6 > ep) @@ -120,7 +120,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) memmove(h->ra, p+4, 6); memmove(h->ta, p+10, 6); break; - + case CtlCts: case CtlAck: // fc dur ra @@ -130,7 +130,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) h->dur = LittleS(p+2); memmove(h->ra, p+4, 6); break; - + case CtlCfEnd: case CtlCfEndAck: // fc dur ra bssid @@ -143,7 +143,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) break; } break; - + case Tdata: if(p+24 > ep) return -1; @@ -183,7 +183,7 @@ unpackhdr(uchar *p, uchar *ep, Hdr *h) h->proto = ProtoLlc; break; } - return 0; + return 0; } enum @@ -284,7 +284,7 @@ static int p_seprint(Msg *m) { Hdr h; - + memset(&h, 0, sizeof h); if(unpackhdr(m->ps, m->pe, &h) < 0) return -1; diff --git a/src/cmd/ip/snoopy/ppp.c b/src/cmd/ip/snoopy/ppp.c old mode 100755 new mode 100644 index 9319cdaec..453f711d7 --- a/src/cmd/ip/snoopy/ppp.c +++ b/src/cmd/ip/snoopy/ppp.c @@ -192,7 +192,7 @@ p_seprint(Msg *m) proto = *m->ps++; if((proto&1) == 0) proto = (proto<<8) | *m->ps++; - + m->p = seprint(m->p, m->e, "pr=%ud len=%d", proto, len); demux(p_mux, proto, proto, m, &dump); @@ -384,25 +384,25 @@ seprintipcpopt(char *p, char *e, void *a, int len) default: p = seprint(p, e, " (type=%d len=%d)", o->type, o->len); break; - case Oipaddrs: + case Oipaddrs: p = seprint(p, e, " ipaddrs(deprecated)"); break; case Oipcompress: p = seprint(p, e, " ipcompress"); break; - case Oipaddr: + case Oipaddr: p = seprint(p, e, " ipaddr=%V", o->data); break; - case Oipdns: + case Oipdns: p = seprint(p, e, " dnsaddr=%V", o->data); break; - case Oipwins: + case Oipwins: p = seprint(p, e, " winsaddr=%V", o->data); break; - case Oipdns2: + case Oipdns2: p = seprint(p, e, " dns2addr=%V", o->data); break; - case Oipwins2: + case Oipwins2: p = seprint(p, e, " wins2addr=%V", o->data); break; } @@ -430,7 +430,7 @@ p_seprintipcp(Msg *m) m->pe = m->ps+len; else if(m->ps+len > m->pe) return -1; - + p = seprint(p, e, "id=%d code=%d", lcp->id, lcp->code); switch(lcp->code) { default: @@ -467,13 +467,13 @@ seprintccpopt(char *p, char *e, void *a, int len) p = seprint(p, e, " bad opt len %ux", o->type); return p; } - + switch(o->type){ default: p = seprint(p, e, " type=%d ", o->type); break; case 0: - p = seprint(p, e, " OUI=(%d %.2ux%.2ux%.2ux) ", o->type, + p = seprint(p, e, " OUI=(%d %.2ux%.2ux%.2ux) ", o->type, o->data[0], o->data[1], o->data[2]); break; case 17: @@ -507,7 +507,7 @@ p_seprintccp(Msg *m) m->pe = m->ps+len; else if(m->ps+len > m->pe) return -1; - + p = seprint(p, e, "id=%d code=%d", lcp->id, lcp->code); switch(lcp->code) { default: @@ -528,7 +528,7 @@ p_seprintccp(Msg *m) break; } m->p = seprint(p, e, " len=%d", len); - + return 0; } diff --git a/src/cmd/ip/snoopy/ppp_ccp.c b/src/cmd/ip/snoopy/ppp_ccp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/ppp_chap.c b/src/cmd/ip/snoopy/ppp_chap.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/ppp_comp.c b/src/cmd/ip/snoopy/ppp_comp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/ppp_ipcp.c b/src/cmd/ip/snoopy/ppp_ipcp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/ppp_lcp.c b/src/cmd/ip/snoopy/ppp_lcp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/pppoe_disc.c b/src/cmd/ip/snoopy/pppoe_disc.c old mode 100755 new mode 100644 index 058f059df..ceb84d57e --- a/src/cmd/ip/snoopy/pppoe_disc.c +++ b/src/cmd/ip/snoopy/pppoe_disc.c @@ -30,7 +30,7 @@ enum Osess }; -static Field p_fields[] = +static Field p_fields[] = { {"v", Fnum, Overs, "version", } , {"t", Fnum, Otype, "type", } , @@ -171,4 +171,3 @@ Proto pppoe_sess = p_fields, defaultframer }; - diff --git a/src/cmd/ip/snoopy/pppoe_sess.c b/src/cmd/ip/snoopy/pppoe_sess.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/radiotap.c b/src/cmd/ip/snoopy/radiotap.c index 889dc8ab4..7fa7cc414 100644 --- a/src/cmd/ip/snoopy/radiotap.c +++ b/src/cmd/ip/snoopy/radiotap.c @@ -93,7 +93,7 @@ static int p_seprint(Msg *m) { Hdr h; - + memset(&h, 0, sizeof h); if(unpackhdr(m->ps, m->pe, &h) < 0) return -1; diff --git a/src/cmd/ip/snoopy/rarp.c b/src/cmd/ip/snoopy/rarp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/rtcp.c b/src/cmd/ip/snoopy/rtcp.c old mode 100755 new mode 100644 index 29745d658..e764063da --- a/src/cmd/ip/snoopy/rtcp.c +++ b/src/cmd/ip/snoopy/rtcp.c @@ -55,7 +55,7 @@ p_seprint(Msg *m) (NetS(h->len) + 1) * 4); for(i = 0; i < rc; i++){ - r = (Report*)m->ps; + r = (Report*)m->ps; m->ps += REPORTLEN; frac = (int)(((float)r->lost[0] * 100.) / 256.); @@ -64,7 +64,7 @@ p_seprint(Msg *m) m->p = seprint(m->p, m->e, "\n\trr(csrc=%8ux frac=%3d%% cumu=%10d seqhi=%10ud jitter=%10d lsr=%8ux dlsr=%f)", NetL(r->ssrc), frac, NetL(r->lost), NetL(r->seqhi), - NetL(r->jitter), NetL(r->lsr), + NetL(r->jitter), NetL(r->lsr), dlsr); } m->pr = nil; diff --git a/src/cmd/ip/snoopy/rtp.c b/src/cmd/ip/snoopy/rtp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ip/snoopy/snap.c b/src/cmd/ip/snoopy/snap.c index 1854d1d64..78a3be09c 100644 --- a/src/cmd/ip/snoopy/snap.c +++ b/src/cmd/ip/snoopy/snap.c @@ -1,4 +1,4 @@ -/* +/* * SNAP. */ @@ -12,7 +12,7 @@ enum { Oorg, Oet, - + OuiEther = 0, OuiCisco = 0xc, OuiCisco90 = 0xf8, diff --git a/src/cmd/ip/snoopy/tcp.c b/src/cmd/ip/snoopy/tcp.c old mode 100755 new mode 100644 index b8ea7e40e..0afbd5450 --- a/src/cmd/ip/snoopy/tcp.c +++ b/src/cmd/ip/snoopy/tcp.c @@ -39,7 +39,7 @@ enum Osd }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fnum, Os, "source port", } , {"d", Fnum, Od, "dest port", } , diff --git a/src/cmd/ip/snoopy/udp.c b/src/cmd/ip/snoopy/udp.c old mode 100755 new mode 100644 index 3d81f33d3..da9510f60 --- a/src/cmd/ip/snoopy/udp.c +++ b/src/cmd/ip/snoopy/udp.c @@ -26,7 +26,7 @@ enum Osetport }; -static Field p_fields[] = +static Field p_fields[] = { {"s", Fnum, Os, "source port", } , {"d", Fnum, Od, "dest port", } , diff --git a/src/cmd/jpg/jpegdump.c b/src/cmd/jpg/jpegdump.c index 6a0a7a007..5ecfc20ad 100644 --- a/src/cmd/jpg/jpegdump.c +++ b/src/cmd/jpg/jpegdump.c @@ -134,7 +134,7 @@ void get_sof (int kind) { tab = get1(); printf ("\tcomponent %d: %d hsample, %d vsample, quantization table %d\n", id, sf >> 4, sf & 0xf, tab); - } + } } void get_com (int kind) { @@ -301,10 +301,10 @@ int main (int argc, char *argv[]) { case 0xd8: printf ("SOI\n"); break; - case 0xe0: case 0xe1: case 0xe2: case 0xe3: - case 0xe4: case 0xe5: case 0xe6: case 0xe7: - case 0xe8: case 0xe9: case 0xea: case 0xeb: - case 0xec: case 0xed: case 0xee: case 0xef: + case 0xe0: case 0xe1: case 0xe2: case 0xe3: + case 0xe4: case 0xe5: case 0xe6: case 0xe7: + case 0xe8: case 0xe9: case 0xea: case 0xeb: + case 0xec: case 0xed: case 0xee: case 0xef: get_app(c); break; case 0xda: diff --git a/src/cmd/jpg/jpg.c b/src/cmd/jpg/jpg.c index f74da4c54..7618c6055 100644 --- a/src/cmd/jpg/jpg.c +++ b/src/cmd/jpg/jpg.c @@ -225,7 +225,7 @@ vidmerge(Rawimage **aa1, Rawimage **aa2) free(a2->cmap); free(a1); free(a2); - } + } if (aa2[i] != nil) fprint(2, "jpg: vidmerge: unequal lengths\n"); free(aa1); diff --git a/src/cmd/jpg/onechan.c b/src/cmd/jpg/onechan.c index ea1c489be..9baf366c9 100644 --- a/src/cmd/jpg/onechan.c +++ b/src/cmd/jpg/onechan.c @@ -63,7 +63,7 @@ load(Image *image, Memimage *memimage) dx = Dx(r); dy = Dy(r); - /* + /* * Read image data into memory * potentially one extra byte on each end of each scan line. */ diff --git a/src/cmd/jpg/readbmp.c b/src/cmd/jpg/readbmp.c index 154cb48d0..586f63cda 100644 --- a/src/cmd/jpg/readbmp.c +++ b/src/cmd/jpg/readbmp.c @@ -185,7 +185,7 @@ load_4C(Biobuf *b, long width, long height, Rgb* buf, Rgb* clut) p = &buf[ix + iy * width]; if((1 == (val & 3)) || (2 == (val & 3))) skip = 1; - else + else skip = 0; while(val--) { @@ -273,7 +273,7 @@ load_8C(Biobuf *b, long width, long height, Rgb* buf, Rgb* clut) p = &buf[ix + iy * width]; if(val & 1) skip = 1; - else + else skip = 0; while(val--) { @@ -488,7 +488,7 @@ ReadBMP(Biobuf *b, int *width, int *height) num_coltab = 3; if(num_coltab) { - int i; + int i; Bseek(b, bmih.size + sizeof(Infohdr), 0); for(i = 0; i < num_coltab; i++) { @@ -622,5 +622,3 @@ readbmp(int fd, int colorspace) Bterm(&b); return a; } - - diff --git a/src/cmd/jpg/readgif.c b/src/cmd/jpg/readgif.c index 22365669a..092faf071 100644 --- a/src/cmd/jpg/readgif.c +++ b/src/cmd/jpg/readgif.c @@ -166,7 +166,7 @@ readarray(Header *h) nimages = 0; array[0] = nil; h->array = array; - + for(;;){ switch(c = Bgetc(h->fd)){ case Beof: diff --git a/src/cmd/jpg/readjpg.c b/src/cmd/jpg/readjpg.c index f3ad802e6..c69d04385 100644 --- a/src/cmd/jpg/readjpg.c +++ b/src/cmd/jpg/readjpg.c @@ -78,7 +78,7 @@ struct Header Huffman acht[4]; int **data[3]; int ndata[3]; - + uchar *sf; /* start of frame; do better later */ uchar *ss; /* start of scan; do better later */ int ri; /* restart interval */ @@ -1484,7 +1484,7 @@ receiveEOB(Header *h, int s) return v; } -/* +/* * return next bit of input */ static diff --git a/src/cmd/jpg/readpng.c b/src/cmd/jpg/readpng.c index 5fdbc1dbb..e327a5729 100644 --- a/src/cmd/jpg/readpng.c +++ b/src/cmd/jpg/readpng.c @@ -11,9 +11,9 @@ int debug; enum{ IDATSIZE=1000000, /* filtering algorithms, supposedly increase compression */ FilterNone = 0, /* new[x][y] = buf[x][y] */ - FilterSub = 1, /* new[x][y] = buf[x][y] + new[x-1][y] */ - FilterUp = 2, /* new[x][y] = buf[x][y] + new[x][y-1] */ - FilterAvg = 3, /* new[x][y] = buf[x][y] + (new[x-1][y]+new[x][y-1])/2 */ + FilterSub = 1, /* new[x][y] = buf[x][y] + new[x-1][y] */ + FilterUp = 2, /* new[x][y] = buf[x][y] + new[x][y-1] */ + FilterAvg = 3, /* new[x][y] = buf[x][y] + (new[x-1][y]+new[x][y-1])/2 */ FilterPaeth= 4, /* new[x][y] = buf[x][y] + paeth(new[x-1][y],new[x][y-1],new[x-1][y-1]) */ FilterLast = 5, PropertyBit = 1<<5 @@ -141,11 +141,11 @@ zread(void *va) return *z->b++; } -static uchar +static uchar paeth(uchar a, uchar b, uchar c) { int p, pa, pb, pc; - + p = (int)a + (int)b - (int)c; pa = abs(p - (int)a); pb = abs(p - (int)b); @@ -218,7 +218,7 @@ convertpix(ZlibW *z, uchar *pixel, uchar *r, uchar *g, uchar *b) break; default: sysfatal("bad number of channels: %d", z->nchan); - } + } } static void @@ -234,7 +234,7 @@ scan(ZlibW *z) unfilter(p[0], p+1, z->pscan+1, z->scanl-1, (nch*z->bpp+7)/8); /* - * Adam7 interlace order. + * Adam7 interlace order. * 1 6 4 6 2 6 4 6 * 7 7 7 7 7 7 7 7 * 5 6 5 6 5 6 5 6 diff --git a/src/cmd/jpg/readppm.c b/src/cmd/jpg/readppm.c index 073f4436b..7067fc15f 100644 --- a/src/cmd/jpg/readppm.c +++ b/src/cmd/jpg/readppm.c @@ -21,7 +21,7 @@ Bgetch(Biobuf *b) while((c = Bgetc(b)) != Beof && c != '\n') ; } - return c; + return c; } /* @@ -40,7 +40,7 @@ Bgetint(Biobuf *b) return -1; i = 0; - do { + do { i = i*10 + (c-'0'); } while((c = Bgetch(b)) != Beof && isdigit(c)); diff --git a/src/cmd/jpg/readyuv.c b/src/cmd/jpg/readyuv.c index f90bc2373..5194d5448 100644 --- a/src/cmd/jpg/readyuv.c +++ b/src/cmd/jpg/readyuv.c @@ -29,7 +29,7 @@ enum { static int lsbtab[] = { 6, 4, 2, 0}; -static int +static int clip(int x) { x >>= 18; @@ -186,5 +186,3 @@ readyuv(int fd, int colorspace) Bterm(&b); return a; } - - diff --git a/src/cmd/jpg/writegif.c b/src/cmd/jpg/writegif.c index 08fc4801e..780bf7a50 100644 --- a/src/cmd/jpg/writegif.c +++ b/src/cmd/jpg/writegif.c @@ -281,7 +281,7 @@ writegraphiccontrol(Biobuf *fd, int dt, int trans) Bputc(fd, 0x01); else Bputc(fd, 0x00); - + /* Delay time, in centisec (argument is millisec for sanity) */ if(dt < 0) dt = 0; @@ -345,7 +345,7 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) else Bputc(fd, depth); - /* + /* * Read image data into memory * potentially one extra byte on each end of each scan line */ diff --git a/src/cmd/jpg/writepng.c b/src/cmd/jpg/writepng.c index 24a61a366..d0baf1223 100644 --- a/src/cmd/jpg/writepng.c +++ b/src/cmd/jpg/writepng.c @@ -70,7 +70,7 @@ zread(void *va, void *buf, int n) uchar *b = buf, *e = b+n, *img; int pixels; /* number of pixels in row that can be sent now */ int i, a, pixwid; - + pixwid = z->pixwid; while(b+pixwid <= e){ /* loop over image rows */ if(z->row >= nrow) @@ -103,7 +103,7 @@ zread(void *va, void *buf, int n) b[2] = (b[2]*255)/a; } } - }else + }else b += pixwid*pixels; z->col += pixels; @@ -148,7 +148,7 @@ memRGBA(Memimage *i) Memimage *ni; char buf[32]; ulong dst; - + /* * [A]BGR because we want R,G,B,[A] in big-endian order. Sigh. */ @@ -157,7 +157,7 @@ memRGBA(Memimage *i) dst = ABGR32; else dst = BGR24; - + if(i->chan == dst) return i; @@ -211,7 +211,7 @@ memwritepng(Biobuf *bo, Memimage *r, ImageInfo *II) *h++ = tm->min; *h++ = tm->sec; chunk(bo, "tIME", buf, h-buf); - + if(II->fields_set & II_GAMMA){ vgamma = II->gamma*100000; put4(buf, vgamma); diff --git a/src/cmd/jpg/writeppm.c b/src/cmd/jpg/writeppm.c index c83786524..da528a448 100644 --- a/src/cmd/jpg/writeppm.c +++ b/src/cmd/jpg/writeppm.c @@ -30,7 +30,7 @@ writedata(Biobuf *fd, Image *image, Memimage *memimage) chan = image->chan; } - /* + /* * Read image data into memory * potentially one extra byte on each end of each scan line */ diff --git a/src/cmd/lex/sub1.c b/src/cmd/lex/sub1.c index dcbbb581a..b2e6d359c 100644 --- a/src/cmd/lex/sub1.c +++ b/src/cmd/lex/sub1.c @@ -488,7 +488,7 @@ allprint(int c) if(!isprint(c)){ print("\\%-3o",c); charc += 3; - } else + } else print("%c", c); break; } @@ -588,7 +588,7 @@ treedump(void) print("final %d",left[t]); break; case S1FINAL: - print("s1final %d",left[t]); + print("s1final %d",left[t]); break; case S2FINAL: print("s2final %d",left[t]); diff --git a/src/cmd/lex/sub2.c b/src/cmd/lex/sub2.c index 9221aea71..d619abad7 100644 --- a/src/cmd/lex/sub2.c +++ b/src/cmd/lex/sub2.c @@ -51,7 +51,7 @@ cfoll(int v) case CARAT: cfoll(left[v]); break; - case STAR: case PLUS: case QUEST: case RSCON: + case STAR: case PLUS: case QUEST: case RSCON: cfoll(left[v]); break; case BAR: case RCAT: case DIV: case RNEWE: @@ -131,7 +131,7 @@ follow(int v) case BAR: case QUEST: case RNEWE: follow(p); break; - case RCAT: case DIV: + case RCAT: case DIV: if(v == left[p]){ if(nullstr[right[p]]) follow(p); @@ -139,7 +139,7 @@ follow(int v) } else follow(p); break; - case RSCON: case CARAT: + case RSCON: case CARAT: follow(p); break; # ifdef DEBUG @@ -803,7 +803,7 @@ layout(void) Bprint(&fout,"0,\t0,\t0};\n"); /* put out yymatch */ - + Bprint(&fout,"struct yywork *yytop = yycrank+%d;\n",yytop); Bprint(&fout,"struct yysvf *yybgin = yysvec+1;\n"); Bprint(&fout,"Uchar yymatch[] = {\n"); diff --git a/src/cmd/look.c b/src/cmd/look.c index 369afe1b3..af40cfcc6 100644 --- a/src/cmd/look.c +++ b/src/cmd/look.c @@ -90,7 +90,7 @@ main(int argc, char *argv[]) case 'f': fold++; break; - case 'i': + case 'i': iflag++; break; case 'n': @@ -118,7 +118,7 @@ main(int argc, char *argv[]) if(argc < 1) { direc++; fold++; - } else + } else filename = argv[0]; if (!iflag) rcanon(orig, key); diff --git a/src/cmd/lp/ipcopen.c b/src/cmd/lp/ipcopen.c index 666f64c4f..a07858a8d 100644 --- a/src/cmd/lp/ipcopen.c +++ b/src/cmd/lp/ipcopen.c @@ -78,7 +78,7 @@ pass(int from, int to) { char buf[1024]; int ppid, cpid; - int n, tot = 0; + int n, tot = 0; while ((n=read(from, buf, sizeof(buf))) > 0) { if (n==1 && tot==0 && *buf=='\0') diff --git a/src/cmd/lp/lpdsend.c b/src/cmd/lp/lpdsend.c index 0dc702590..363d9501e 100644 --- a/src/cmd/lp/lpdsend.c +++ b/src/cmd/lp/lpdsend.c @@ -289,7 +289,7 @@ main(int argc, char *argv[]) { if (statflag) { fprintf(stderr, "cannot have both -k and -q flags\n"); exit(1); - } + } killflag = 1; killarg = optarg; break; @@ -297,7 +297,7 @@ main(int argc, char *argv[]) { if (killflag) { fprintf(stderr, "cannot have both -q and -k flags\n"); exit(1); - } + } statflag = 1; break; case 's': diff --git a/src/cmd/lp/lpsend.c b/src/cmd/lp/lpsend.c index 4893f4521..bcdcfdbb5 100644 --- a/src/cmd/lp/lpsend.c +++ b/src/cmd/lp/lpsend.c @@ -154,7 +154,7 @@ pass(int inpfd, int outfd, int bsize) alarm(0); return(bcnt); } - + /* get whatever stdin has and put it into the temporary file. * return the file size. */ diff --git a/src/cmd/ls.c b/src/cmd/ls.c index fca3ee958..845532be6 100644 --- a/src/cmd/ls.c +++ b/src/cmd/ls.c @@ -249,7 +249,7 @@ growto(long n) if(dirbuf == 0){ fprint(2, "ls: malloc fail\n"); exits("malloc fail"); - } + } } int @@ -305,4 +305,3 @@ asciitime(long l) buf[12] = 0; return buf; } - diff --git a/src/cmd/map/libmap/bonne.c b/src/cmd/map/libmap/bonne.c index 858f0d69c..1c9db8688 100644 --- a/src/cmd/map/libmap/bonne.c +++ b/src/cmd/map/libmap/bonne.c @@ -15,7 +15,7 @@ Xbonne(struct place *place, double *x, double *y) alpha = place->wlon.l; else if(fabs(place->nlat.c)==0) alpha = 0; - else + else alpha = place->wlon.l/(1+ stdpar.c*stdpar.c*stdpar.c/place->nlat.c/3); else diff --git a/src/cmd/map/libmap/cubrt.c b/src/cmd/map/libmap/cubrt.c index fd508d2ba..abfd6ea09 100644 --- a/src/cmd/map/libmap/cubrt.c +++ b/src/cmd/map/libmap/cubrt.c @@ -6,7 +6,7 @@ double cubrt(double a) { double x,y,x1; - if(a==0) + if(a==0) return(0.); y = 1; if(a<0) { diff --git a/src/cmd/map/libmap/elco2.c b/src/cmd/map/libmap/elco2.c index b4c9bbf69..6f7d56044 100644 --- a/src/cmd/map/libmap/elco2.c +++ b/src/cmd/map/libmap/elco2.c @@ -76,7 +76,7 @@ elco2(double x, double y, double kc, double a, double b, double *u, double *v) cmul(c,dn2,1+e1*m2,e2*m2,&f1,&f2); cdiv(d*x,d*y,f1,f2,&d1[i],&d2[i]); - if(k<=CC) + if(k<=CC) break; kc = sqrt(m*kc); f = m2; diff --git a/src/cmd/map/libmap/gilbert.c b/src/cmd/map/libmap/gilbert.c index 173ffcd34..f7ee7b6f8 100644 --- a/src/cmd/map/libmap/gilbert.c +++ b/src/cmd/map/libmap/gilbert.c @@ -47,5 +47,3 @@ gilbert(void) use standard formula: tan x/2 = (1-cos x)/sin x = sin x/(1+cos x) to show that the right side of the last equation is tan(n/2) */ - - diff --git a/src/cmd/map/libmap/homing.c b/src/cmd/map/libmap/homing.c index 366f69fe4..9678c6810 100644 --- a/src/cmd/map/libmap/homing.c +++ b/src/cmd/map/libmap/homing.c @@ -94,7 +94,7 @@ hlimb(double *lat, double *lon, double res) return 0; } *lat += res; - if(*lat <= 90) + if(*lat <= 90) return 1; if(*lon == 90) return -1; diff --git a/src/cmd/map/libmap/lambert.c b/src/cmd/map/libmap/lambert.c index 6b688aa3d..e8037a6c4 100644 --- a/src/cmd/map/libmap/lambert.c +++ b/src/cmd/map/libmap/lambert.c @@ -34,7 +34,7 @@ lambert(double par0, double par1) } deg2rad(par0, &stdp0); deg2rad(par1, &stdp1); - if(fabs(par1+par0)<.1) + if(fabs(par1+par0)<.1) return(mercator()); if(fabs(par1-par0)<.1) return(perspective(-1.)); diff --git a/src/cmd/map/libmap/lune.c b/src/cmd/map/libmap/lune.c index dc58c6f05..a3d06d817 100644 --- a/src/cmd/map/libmap/lune.c +++ b/src/cmd/map/libmap/lune.c @@ -42,7 +42,7 @@ static int Xlune(struct place *place, double *x, double *y) deny = w1y + w2y; cdiv(numx, numy, denx, deny, x, y); return 1; -} +} proj lune(double lat, double theta) diff --git a/src/cmd/map/libmap/tetra.c b/src/cmd/map/libmap/tetra.c index 6bdef49b9..31837de28 100644 --- a/src/cmd/map/libmap/tetra.c +++ b/src/cmd/map/libmap/tetra.c @@ -66,7 +66,7 @@ static struct tproj { {/*30*/ {0., -45., 45., -150.}, /*31*/ {0., -135., 135., -30.}, /*32*/ {-90., 0., 0., 90.}, - /*33*/ {0.} + /*33*/ {0.} }}; static double tx[4] = { /*where to move facet after final rotation*/ 0., 0., -1., 1. /*-1,1 to be sqrt(3)*/ @@ -136,7 +136,7 @@ Xtetra(struct place *place, double *x, double *y) return 0; vr = fpir - vr; vi = fpii - vi; - } else + } else if(!elco2(br,bi,tk,1.,1.,&vr,&vi)) return 0; if(si>=0) { @@ -158,7 +158,7 @@ int tetracut(struct place *g, struct place *og, double *cutlon) { int i,j,k; - if((g->nlat.s<=-rt3inv&&og->nlat.s<=-rt3inv) && + if((g->nlat.s<=-rt3inv&&og->nlat.s<=-rt3inv) && (ckcut(g,og,*cutlon=0.)==2||ckcut(g,og,*cutlon=PI)==2)) return(2); twhichp(g,&i,&k); @@ -203,4 +203,3 @@ tetra(void) } return(Xtetra); } - diff --git a/src/cmd/map/libmap/twocirc.c b/src/cmd/map/libmap/twocirc.c index 0d0e48a4e..9c7b7ec4f 100644 --- a/src/cmd/map/libmap/twocirc.c +++ b/src/cmd/map/libmap/twocirc.c @@ -44,7 +44,7 @@ twocircles(double m, double p, double p1, double p2, double *x, double *y) *y = (*x*a+t/2)/b; } return 1; -} +} static int Xglobular(struct place *place, double *x, double *y) @@ -52,7 +52,7 @@ Xglobular(struct place *place, double *x, double *y) twocircles(-2*place->wlon.l/PI, 2*place->nlat.l/PI, place->nlat.c, place->nlat.s, x, y); return 1; -} +} proj globular(void) @@ -68,7 +68,7 @@ Xvandergrinten(struct place *place, double *x, double *y) double pval = abst>=1? 1: abst/(1+sqrt(1-t*t)); double p2 = 2*pval/(1+pval); twocircles(-place->wlon.l/PI, pval, sqrt(1-p2*p2), p2, x, y); - if(t < 0) + if(t < 0) *y = -*y; return 1; } diff --git a/src/cmd/map/map.c b/src/cmd/map/map.c index 74ae79ac3..5ca1a65c0 100644 --- a/src/cmd/map/map.c +++ b/src/cmd/map/map.c @@ -123,7 +123,7 @@ void windlim(void); void realcut(void); int -option(char *s) +option(char *s) { if(s[0]=='-' && (s[1]<'0'||s[1]>'9')) @@ -157,7 +157,7 @@ main(int argc, char *argv[]) s = getenv("MAPDIR"); if(s) mapdir = s; - if(argc<=1) + if(argc<=1) error("usage: map projection params options"); for(k=0;index[k].name;k++) { s = index[k].name; @@ -305,7 +305,7 @@ main(int argc, char *argv[]) argc -= i; break; case 'c': - for(i=0;i<3&&argc>i&&!option(argv[i]);i++) + for(i=0;i<3&&argc>i&&!option(argv[i]);i++) center[i] = atof(argv[i]); argc -= i; argv += i; @@ -315,7 +315,7 @@ main(int argc, char *argv[]) position[i] = atof(argv[i]); argc -= i; argv += i; - if(i!=3||position[2]<=0) + if(i!=3||position[2]<=0) error("incomplete positioning"); break; case 'y': @@ -445,7 +445,7 @@ main(int argc, char *argv[]) crot.l = center[2]*RAD; sincos(&crot); scaling *= HALFWIDTH*0.9; - if(symbolfile) + if(symbolfile) getsyms(symbolfile); if(!s2flag) { openpl(); @@ -457,11 +457,11 @@ main(int argc, char *argv[]) pen(DOTTED); if(grid[0]>0.) for(lat=ceil(lolat/grid[0])*grid[0]; - lat<=hilat;lat+=grid[0]) + lat<=hilat;lat+=grid[0]) dogrid(lat,lat,lolon,hilon); if(grid[1]>0.) for(lon=ceil(lolon/grid[1])*grid[1]; - lon<=hilon;lon+=grid[1]) + lon<=hilon;lon+=grid[1]) dogrid(lolat,hilat,lon,lon); comment("border",""); colorx(bordcolor); @@ -520,7 +520,7 @@ normproj(double lat, double lon, double *x, double *y) if(!inwindow(&geog)) return(-1); i = fixproj(&geog,x,y); - if(rflag) + if(rflag) *x = -*x; /* printp(&geog); @@ -537,7 +537,7 @@ posproj(double lat, double lon, double *x, double *y) latlon(lat,lon,&geog); normalize(&geog); i = fixproj(&geog,x,y); - if(rflag) + if(rflag) *x = -*x; return(i); } @@ -1167,7 +1167,7 @@ clipinit(void) nvert = 4; v[2] = v[1]; v[1].x=v[0].x, v[1].y=v[2].y, v[3].x=v[2].x, v[3].y=v[0].y; - } + } v[nvert] = v[0]; v[nvert+1] = v[1]; s = 0; @@ -1208,7 +1208,7 @@ realcut(void) { struct place g; double lat; - + if(cut != picut) /* punt on unusual cuts */ return; for(lat=window[0]; lat<=window[1]; lat+=grid[2]) { diff --git a/src/cmd/map/route.c b/src/cmd/map/route.c index c4c67134d..8a6cfccc3 100644 --- a/src/cmd/map/route.c +++ b/src/cmd/map/route.c @@ -117,7 +117,7 @@ doroute(double dir, double an, double aw, double bn, double bw) dlat = fabs(an-bn); printf("-o %.4f %.4f %.4f -w %.2f %.2f %.2f %.2f \n", pn,pw,theta, -0.3*cw1, .3*cw1, -.6*cw1, .6*cw1); - + } else { cn1 = 0; n = 1 + fabs(bw1-aw1)/.2; diff --git a/src/cmd/mk/env.c b/src/cmd/mk/env.c index 11df34e31..d7c6481d7 100644 --- a/src/cmd/mk/env.c +++ b/src/cmd/mk/env.c @@ -142,7 +142,7 @@ buildenv(Job *j, int slot) for(i = 0; *p; i++, p++){ if((j->r->attr®EXP) && j->match[i]) envupd(*p, newword(j->match[i])); - else + else envupd(*p, newword("")); } return envy; diff --git a/src/cmd/mk/rule.c b/src/cmd/mk/rule.c index 30728197e..537d2d75a 100644 --- a/src/cmd/mk/rule.c +++ b/src/cmd/mk/rule.c @@ -76,7 +76,7 @@ dumpr(char *s, Rule *r) { if(r == nil) return; - Bprint(&bout, "%s: start=%ld shelltype=%s shellcmd=%s\n", + Bprint(&bout, "%s: start=%ld shelltype=%s shellcmd=%s\n", s, r, r->shellt->name, wtos(r->shellcmd, ' ')); for(; r; r = r->next){ Bprint(&bout, "\tRule %ld: %s[%d] attr=%x next=%ld chain=%ld alltarget='%s'", diff --git a/src/cmd/mk/run.c b/src/cmd/mk/run.c index dd225c0d0..6f60cede0 100644 --- a/src/cmd/mk/run.c +++ b/src/cmd/mk/run.c @@ -29,7 +29,7 @@ run(Job *j) for(jj = jobs; jj->next; jj = jj->next) ; jj->next = j; - } else + } else jobs = j; j->next = 0; /* this code also in waitup after parse redirect */ diff --git a/src/cmd/mk/sh.c b/src/cmd/mk/sh.c index e25665141..d8f205c8c 100644 --- a/src/cmd/mk/sh.c +++ b/src/cmd/mk/sh.c @@ -203,4 +203,3 @@ Shell shshell = { shcopyq, shmatchname }; - diff --git a/src/cmd/mk/sys.h b/src/cmd/mk/sys.h index 03a9d058d..f520b066c 100644 --- a/src/cmd/mk/sys.h +++ b/src/cmd/mk/sys.h @@ -2,4 +2,3 @@ #include #include #include - diff --git a/src/cmd/mk/unix.c b/src/cmd/mk/unix.c index c63d3cefd..37f05b717 100644 --- a/src/cmd/mk/unix.c +++ b/src/cmd/mk/unix.c @@ -23,7 +23,7 @@ readenv(void) Word *w; for(p = environ; *p; p++){ -/* rsc 5/5/2004 -- This misparses fn#cd={whatever} +/* rsc 5/5/2004 -- This misparses fn#cd={whatever} s = shname(*p); if(*s == '=') { *s = 0; @@ -111,7 +111,7 @@ shargv(Word *cmd, int extra, char ***pargv) n = 0; for(w=cmd; w; w=w->next) n++; - + argv = Malloc((n+extra+1)*sizeof(argv[0])); i = 0; for(w=cmd; w; w=w->next) @@ -119,7 +119,7 @@ shargv(Word *cmd, int extra, char ***pargv) argv[n] = 0; *pargv = argv; return n; -} +} int execsh(char *args, char *cmd, Bufblock *buf, Envy *e, Shell *sh, Word *shellcmd) diff --git a/src/cmd/mk/varsub.c b/src/cmd/mk/varsub.c index f858a92af..b6c0ab0f7 100644 --- a/src/cmd/mk/varsub.c +++ b/src/cmd/mk/varsub.c @@ -61,7 +61,7 @@ varmatch(char *name) { Word *w; Symtab *sym; - + sym = symlook(name, S_VAR, 0); if(sym){ /* check for at least one non-NULL value */ @@ -107,7 +107,7 @@ expandvar(char **s) } *end = 0; *s = end+1; - + sym = symlook(buf->start, S_VAR, 0); if(sym == 0 || sym->u.ptr == 0) w = newword(buf->start); @@ -173,7 +173,7 @@ subsub(Word *v, char *s, char *end) while(w->next) w = w->next; } - if(PERCENT(*cp) && nmid > 0){ + if(PERCENT(*cp) && nmid > 0){ if(w){ bufcpy(buf, w->s, strlen(w->s)); bufcpy(buf, enda, nmid); @@ -205,7 +205,7 @@ subsub(Word *v, char *s, char *end) } if(w == 0) h = w = newword(v->s); - + if(head == 0) head = h; else diff --git a/src/cmd/mk/word.c b/src/cmd/mk/word.c index f94c4fd79..e1e52a1c3 100644 --- a/src/cmd/mk/word.c +++ b/src/cmd/mk/word.c @@ -29,7 +29,7 @@ stow(char *s) head = w = new; while(w->next) w = w->next; - + } if (!head) head = newword(""); diff --git a/src/cmd/mpm/range.h b/src/cmd/mpm/range.h index 54994cdd1..a1d00dfba 100644 --- a/src/cmd/mpm/range.h +++ b/src/cmd/mpm/range.h @@ -67,7 +67,7 @@ class range { class vboxrange : public range { int dv; // inherited from slug int base; // inherited from slug - int brk; // 0 => ok to break after, 1 => no break + int brk; // 0 => ok to break after, 1 => no break public: vboxrange(slug *p) : range(p) { dv = p->dv; base = p->base; brk = p->parm; } void dump() { diff --git a/src/cmd/mpm/slug.h b/src/cmd/mpm/slug.h index 9dfd3b2a1..0f72b931d 100644 --- a/src/cmd/mpm/slug.h +++ b/src/cmd/mpm/slug.h @@ -32,7 +32,7 @@ enum parmtypes { PL, // distance of physical page bottom from page top (Page Length) MF, // minimum fullness required for padding CT, // tolerance for division into two columns - WARN, // warnings to stderr? + WARN, // warnings to stderr? DBG // debugging flag }; diff --git a/src/cmd/namespace.c b/src/cmd/namespace.c index 823e204a6..ff01450ce 100644 --- a/src/cmd/namespace.c +++ b/src/cmd/namespace.c @@ -30,4 +30,3 @@ main(int argc, char **argv) print("%s\n", ns); exits(0); } - diff --git a/src/cmd/ndb/convDNS2M.c b/src/cmd/ndb/convDNS2M.c old mode 100755 new mode 100644 diff --git a/src/cmd/ndb/convM2DNS.c b/src/cmd/ndb/convM2DNS.c old mode 100755 new mode 100644 diff --git a/src/cmd/ndb/dblookup.c b/src/cmd/ndb/dblookup.c old mode 100755 new mode 100644 index ca73184aa..067ba4447 --- a/src/cmd/ndb/dblookup.c +++ b/src/cmd/ndb/dblookup.c @@ -463,13 +463,13 @@ soarr(Ndbtuple *entry, Ndbtuple *pair) rp->rmb = dnlookup(mailbox, Cin, 1); } - /* hang dns slaves off of the soa. this is + /* hang dns slaves off of the soa. this is * for managing the area. */ for(t = entry; t != nil; t = t->entry) if(strcmp(t->attr, "dnsslave") == 0) addserver(&rp->soa->slaves, t->val); - + return rp; } @@ -647,11 +647,11 @@ db2cache(int doit) unlock(&dblock); return; } - + /* forget our area definition */ freearea(&owned); freearea(&delegated); - + /* reopen all the files (to get oldest for time stamp) */ for(ndb = db; ndb; ndb = ndb->next) ndbreopen(ndb); @@ -659,14 +659,14 @@ db2cache(int doit) if(cachedb){ /* mark all db records as timed out */ dnagedb(); - + /* read in new entries */ for(ndb = db; ndb; ndb = ndb->next) dbfile2cache(ndb); - + /* mark as authentic anything in our domain */ dnauthdb(); - + /* remove old entries */ dnageall(1); } else { @@ -697,7 +697,7 @@ lookupinfo(char *attr) snprint(buf, sizeof buf, "%I", ipaddr); a[0] = attr; - + lock(&dblock); if(opendatabase() < 0){ unlock(&dblock); diff --git a/src/cmd/ndb/dn.c b/src/cmd/ndb/dn.c old mode 100755 new mode 100644 index 8b874030d..5a37eefa9 --- a/src/cmd/ndb/dn.c +++ b/src/cmd/ndb/dn.c @@ -67,7 +67,7 @@ char *rrtname[Tall+2] = "cert", nil, nil, - + /* 40 */ nil, nil, nil, nil, nil, nil, nil, nil, /* 48 */ nil, nil, nil, nil, nil, nil, nil, nil, /* 56 */ nil, nil, nil, nil, nil, nil, nil, nil, @@ -94,7 +94,7 @@ char *rrtname[Tall+2] = /* 224 */ nil, nil, nil, nil, nil, nil, nil, nil, /* 232 */ nil, nil, nil, nil, nil, nil, nil, nil, /* 240 */ nil, nil, nil, nil, nil, nil, nil, nil, -/* 248 */ nil, nil, nil, +/* 248 */ nil, nil, nil, "ixfr", "axfr", @@ -1318,7 +1318,7 @@ randomize(RR *rp) if(x->type != Ta && x->type != Tmx && x->type != Tns) return rp; - base = rp; + base = rp; n = rand(); last = first = nil; @@ -1564,7 +1564,7 @@ copyserverlist(Server *s) { Server *ns; - + for(ns = nil; s != nil; s = s->next) addserver(&ns, s->name); return ns; diff --git a/src/cmd/ndb/dnarea.c b/src/cmd/ndb/dnarea.c old mode 100755 new mode 100644 index 05c9d0043..bb4d050cb --- a/src/cmd/ndb/dnarea.c +++ b/src/cmd/ndb/dnarea.c @@ -96,7 +96,7 @@ refresh_areas(Area *s) { Waitmsg *w; char *argv[3]; - + argv[0] = zonerefreshprogram; argv[1] = "XXX"; argv[2] = nil; @@ -115,4 +115,3 @@ refresh_areas(Area *s) free(w); } } - diff --git a/src/cmd/ndb/dnnotify.c b/src/cmd/ndb/dnnotify.c old mode 100755 new mode 100644 diff --git a/src/cmd/ndb/dnresolve.c b/src/cmd/ndb/dnresolve.c old mode 100755 new mode 100644 index 979abe4eb..366521b68 --- a/src/cmd/ndb/dnresolve.c +++ b/src/cmd/ndb/dnresolve.c @@ -71,13 +71,13 @@ dnresolve(char *name, int class, int type, Request *req, RR **cn, int depth, int rp = nil; break; } - + name = rp->host->name; if(cn) rrcat(cn, rp); else rrfreelist(rp); - + rp = dnresolve1(name, class, type, req, depth, recurse); } } @@ -126,7 +126,7 @@ dnresolve1(char *name, int class, int type, Request *req, int depth, int recurse rrfreelist(rp); /* - * try the cache for a canonical name. if found punt + * try the cache for a canonical name. if found punt * since we'll find it during the canonical name search * in dnresolve(). */ @@ -242,7 +242,7 @@ walkup(char *name) } /* - * Get a udpport for requests and replies. + * Get a udpport for requests and replies. */ int udpport(void) @@ -310,7 +310,7 @@ readreply(int fd, DN *dp, int type, ushort req, len = udpreadtimeout(fd, (Udphdr*)ibuf, ibuf+Udphdrsize, Maxudpin, (endtime-now)*1000); if(len < 0) return -1; /* timed out */ - + /* convert into internal format */ memset(mp, 0, sizeof(*mp)); err = convM2DNS(&ibuf[Udphdrsize], len, mp); @@ -357,13 +357,13 @@ udpreadtimeout(int fd, Udphdr *h, void *data, int n, int ms) { fd_set rd; struct timeval tv; - + FD_ZERO(&rd); FD_SET(fd, &rd); - + tv.tv_sec = ms/1000; tv.tv_usec = (ms%1000)*1000; - + if(select(fd+1, &rd, 0, 0, &tv) != 1) return -1; return udpread(fd, h, data, n); @@ -512,7 +512,7 @@ cacheneg(DN *dp, int type, int rcode, RR *soarr) soarr->next = nil; } soaowner = soarr->owner; - } else + } else soaowner = nil; /* the attach can cause soarr to be freed so mine it now */ diff --git a/src/cmd/ndb/dns.c b/src/cmd/ndb/dns.c old mode 100755 new mode 100644 index 05a5dd456..cb3170529 --- a/src/cmd/ndb/dns.c +++ b/src/cmd/ndb/dns.c @@ -170,7 +170,7 @@ threadmain(int argc, char *argv[]) default: usage(); }ARGEND - + if(argc) usage(); if(serveudp && servetcp) diff --git a/src/cmd/ndb/dns.h b/src/cmd/ndb/dns.h old mode 100755 new mode 100644 index 9825f0bd1..fbd114f3a --- a/src/cmd/ndb/dns.h +++ b/src/cmd/ndb/dns.h @@ -26,7 +26,7 @@ enum /* query types (all RR types are also queries) */ Tixfr= 251, /* incremental zone transfer */ Taxfr= 252, /* zone transfer */ - Tmailb= 253, /* { Tmb, Tmg, Tmr } */ + Tmailb= 253, /* { Tmb, Tmg, Tmr } */ Tall= 255, /* all records */ /* classes */ diff --git a/src/cmd/ndb/dnsdebug.c b/src/cmd/ndb/dnsdebug.c old mode 100755 new mode 100644 index 0818b85ff..c3ad3e13c --- a/src/cmd/ndb/dnsdebug.c +++ b/src/cmd/ndb/dnsdebug.c @@ -331,7 +331,7 @@ void preloadserveraddrs(void) { RR *rp, **l, *first; - + l = &first; for(rp = serveraddrs; rp != nil; rp = rp->next){ rrcopy(rp, l); diff --git a/src/cmd/ndb/dnserver.c b/src/cmd/ndb/dnserver.c old mode 100755 new mode 100644 index 509734b03..660006bd7 --- a/src/cmd/ndb/dnserver.c +++ b/src/cmd/ndb/dnserver.c @@ -81,7 +81,7 @@ dnserver(DNSmsg *reqp, DNSmsg *repp, Request *req) nsdp = dnlookup(cp, repp->qd->owner->class, 0); if(nsdp == 0) continue; - + repp->ns = rrlookup(nsdp, Tns, OKneg); if(repp->ns){ /* don't pass on anything we know is wrong */ @@ -91,7 +91,7 @@ dnserver(DNSmsg *reqp, DNSmsg *repp, Request *req) } break; } - + repp->ns = dblookup(cp, repp->qd->owner->class, Tns, 0, 0); if(repp->ns) break; diff --git a/src/cmd/ndb/dnsquery.c b/src/cmd/ndb/dnsquery.c old mode 100755 new mode 100644 diff --git a/src/cmd/ndb/dnstcp.c b/src/cmd/ndb/dnstcp.c old mode 100755 new mode 100644 diff --git a/src/cmd/ndb/dntcpserver.c b/src/cmd/ndb/dntcpserver.c index 131615481..713331f46 100644 --- a/src/cmd/ndb/dntcpserver.c +++ b/src/cmd/ndb/dntcpserver.c @@ -269,7 +269,7 @@ static int tcpannounce(char *mntpt) { int fd; - + USED(mntpt); if((fd=announce(tcpaddr, adir)) < 0) warning("announce %s: %r", tcpaddr); diff --git a/src/cmd/ndb/dnudpserver.c b/src/cmd/ndb/dnudpserver.c old mode 100755 new mode 100644 index 9f84125cd..a84cd0505 --- a/src/cmd/ndb/dnudpserver.c +++ b/src/cmd/ndb/dnudpserver.c @@ -206,4 +206,3 @@ dnudpserver(void *v) for(i=0; iid, name); return fsopenfd(acmefs, buf, mode); } @@ -230,7 +230,7 @@ winreadaddr(Win *w, uint *q1) char buf[40], *p; uint q0; int n; - + n = fspread(wfid(w, "addr"), buf, sizeof buf-1, 0); if(n <= 0) return -1; @@ -258,7 +258,7 @@ fsreadm(CFid *fid) { char *buf; int n, tot, m; - + m = 128; buf = emalloc(m+1); tot = 0; @@ -288,7 +288,7 @@ winindex(void) { CFid *fid; char *s; - + mountacme(); if((fid = fsopen(acmefs, "index", OREAD)) == nil) return nil; @@ -595,7 +595,7 @@ eventreader(void *v) Event e[2]; Win *w; int i; - + w = v; i = 0; for(;;){ @@ -623,7 +623,7 @@ wingetname(Win *w) { int n; char *p; - + n = winread(w, "tag", w->name, sizeof w->name-1); if(n <= 0) return nil; @@ -633,4 +633,3 @@ wingetname(Win *w) *p = 0; return w->name; } - diff --git a/src/cmd/netfiles/acme.h b/src/cmd/netfiles/acme.h index 50997e97a..c792a9c1e 100644 --- a/src/cmd/netfiles/acme.h +++ b/src/cmd/netfiles/acme.h @@ -31,7 +31,7 @@ struct Win Channel *c; /* chan(Event) */ Win *next; Win *prev; - + /* events */ int nbuf; char name[1024]; diff --git a/src/cmd/netfiles/main.c b/src/cmd/netfiles/main.c index 45e194163..baacb984f 100644 --- a/src/cmd/netfiles/main.c +++ b/src/cmd/netfiles/main.c @@ -1,7 +1,7 @@ /* * Remote file system editing client. * Only talks to acme - external programs do all the hard work. - * + * * If you add a plumbing rule: # /n/ paths go to simulator in acme @@ -80,7 +80,7 @@ Arg* arg(char *file, char *addr, Channel *c) { Arg *a; - + a = emalloc(sizeof *a); a->file = estrdup(file); a->addr = estrdup(addr); @@ -92,7 +92,7 @@ Win* winbyid(int id) { Win *w; - + for(w=windows; w; w=w->next) if(w->id == id) return w; @@ -139,7 +139,7 @@ int lookup(char *s, char **list) { int i; - + for(i=0; list[i]; i++) if(strcmp(list[i], s) == 0) return i; @@ -174,7 +174,7 @@ char* expandarg(Win *w, Event *e) { uint q0, q1; - + if(e->c2 == 'l') /* in tag - no choice but to accept acme's expansion */ return estrdup(e->text); winaddr(w, ","); @@ -187,7 +187,7 @@ expandarg(Win *w, Event *e) if(e->oq0 == e->oq1 && e->q0 != e->q1 && !isdot(w, e->q0, e->q1)){ winaddr(w, "#%ud+#1-/[^ \t\\n]*/,#%ud-#1+/[^ \t\\n]*/", e->q0, e->q1); q0 = winreadaddr(w, &q1); - cprint("\tre-expand to %d-%d\n", q0, q1); + cprint("\tre-expand to %d-%d\n", q0, q1); }else winaddr(w, "#%ud,#%ud", e->q0, e->q1); return winmread(w, "xdata"); @@ -202,7 +202,7 @@ doplumb(void *vm) char *addr; Plumbmsg *m; Win *w; - + m = vm; if(m->ndata >= 1024){ fprint(2, "insanely long file name (%d bytes) in plumb message (%.32s...)\n", @@ -210,7 +210,7 @@ doplumb(void *vm) plumbfree(m); return; } - + addr = plumblookup(m->attr, "addr"); w = nametowin(m->data); if(w == nil) @@ -230,7 +230,7 @@ plumbthread(void *v) { CFid *fid; Plumbmsg *m; - + threadsetname("plumbthread"); fid = plumbopenfid("netfileedit", OREAD); if(fid == nil){ @@ -249,7 +249,7 @@ int parsename(char *name, char **server, char **path) { char *p, *nul; - + cleanname(name); if(strncmp(name, "/n/", 3) != 0 && name[3] == 0) return -1; @@ -326,9 +326,9 @@ filethread(void *v) winname(w, a->file); winprint(w, "tag", "Get Put Look "); c = wineventchan(w); - + goto caseGet; - + while((e=recvp(c)) != nil){ if(e->c1!='K') dprint("acme %E\n", e); @@ -352,7 +352,7 @@ filethread(void *v) winaddr(w, ","); winprint(w, "data", "[reading...]"); winaddr(w, ","); - cprint("9 netfileget %s%q %q\n", + cprint("9 netfileget %s%q %q\n", strcmp(type, "file") == 0 ? "" : "-d", server, path); if(strcmp(type, "file")==0) twait(pipetowin(w, "data", 2, "9 netfileget %q %q", server, path)); @@ -508,7 +508,7 @@ mkwin(char *name) Arg *a; Channel *c; Win *w; - + c = chancreate(sizeof(void*), 0); a = arg(name, nil, c); threadcreate(filethread, a, STACK); @@ -521,12 +521,12 @@ void loopthread(void *v) { QLock lk; - + threadsetname("loopthread"); qlock(&lk); qlock(&lk); } - + void threadmain(int argc, char **argv) { @@ -540,7 +540,7 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc) usage(); @@ -551,10 +551,9 @@ threadmain(int argc, char **argv) fmtinstall('E', eventfmt); doquote = needsrcquote; quotefmtinstall(); - + twaitinit(); threadcreate(plumbthread, nil, STACK); threadcreate(loopthread, nil, STACK); threadexits(nil); } - diff --git a/src/cmd/netfiles/wait.c b/src/cmd/netfiles/wait.c index 3434ebc84..0d6032978 100644 --- a/src/cmd/netfiles/wait.c +++ b/src/cmd/netfiles/wait.c @@ -61,7 +61,7 @@ waitthread(void *v) wq[nwq++] = w; } break; - + case 1: dprint("wait: req for pid %d chan %p\n", r.pid, r.c); for(i=0; imsg[0] != 0 ? -1 : 0; free(w); @@ -117,4 +117,3 @@ twaitinit(void) twaitchan = chancreate(sizeof(Waitreq), 10); threadcreate(waitthread, nil, 128*1024); } - diff --git a/src/cmd/page/cache.c b/src/cmd/page/cache.c index 5110840f7..a1083fc77 100644 --- a/src/cmd/page/cache.c +++ b/src/cmd/page/cache.c @@ -29,7 +29,7 @@ questionmark(void) static Image *im; if(im) - return im; + return im; im = xallocimage(display, Rect(0,0,50,50), GREY1, 1, DBlack); if(im == nil) return nil; @@ -165,7 +165,7 @@ static void raproc(void *a) { Cached *c; - + c = a; lockdisplay(display); /* @@ -187,7 +187,7 @@ cachedpage(Document *doc, int angle, int page) Cached *c; Image *im; int ra; - + if(doc->npage < 1) return display->white; diff --git a/src/cmd/page/gfx.c b/src/cmd/page/gfx.c index 22e08665f..793d75a41 100644 --- a/src/cmd/page/gfx.c +++ b/src/cmd/page/gfx.c @@ -77,7 +77,7 @@ initgfx(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf) doc = emalloc(sizeof(*doc)); gfx = emalloc(sizeof(*gfx)); gfx->g = nil; - + doc->npage = 0; doc->drawpage = gfxdrawpage; doc->pagename = gfxpagename; @@ -141,7 +141,7 @@ genaddpage(Document *doc, char *name, uchar *buf, int nbuf) memset(g, 0, sizeof *g); if(memcmp(buf, "GIF", 3) == 0) g->type = Igif; - else if(memcmp(buf, "\111\111\052\000", 4) == 0) + else if(memcmp(buf, "\111\111\052\000", 4) == 0) g->type = Itiff; else if(memcmp(buf, "\115\115\000\052", 4) == 0) g->type = Itiff; @@ -186,7 +186,7 @@ genaddpage(Document *doc, char *name, uchar *buf, int nbuf) return doc->npage++; } -static int +static int addpage(Document *doc, char *name) { return genaddpage(doc, name, nil, 0); @@ -257,7 +257,7 @@ convert(Graphic *g) if(fd < 0) { fprint(2, "cannot spawn converter: %r\n"); wexits("convert"); - } + } } im = readimage(display, fd, 0); diff --git a/src/cmd/page/gs.c b/src/cmd/page/gs.c index 5c493b355..1d60212a2 100644 --- a/src/cmd/page/gs.c +++ b/src/cmd/page/gs.c @@ -1,8 +1,8 @@ /* * gs interface for page. * ps.c and pdf.c both use these routines. - * a caveat: if you run more than one gs, only the last - * one gets killed by killgs + * a caveat: if you run more than one gs, only the last + * one gets killed by killgs */ #include #include @@ -88,7 +88,7 @@ spawnmonitor(void *cp) threadexits(0); } -int +int spawngs(GSInfo *g, char *safer) { Channel *cp; diff --git a/src/cmd/page/nrotate.c b/src/cmd/page/nrotate.c index 96563c3d1..00d065ad8 100644 --- a/src/cmd/page/nrotate.c +++ b/src/cmd/page/nrotate.c @@ -6,7 +6,7 @@ * The basic concept is that you can invert an array by * inverting the top half, inverting the bottom half, and * then swapping them. - * + * * This is usually overkill, but it speeds up slow remote * connections quite a bit. */ @@ -132,7 +132,7 @@ shuffle(Image *img, Image *tmp, int axis, int imgdim, Image *mask, int maskdim) /* * Halve the grating period in the mask. - * The grating currently looks like + * The grating currently looks like * ####____####____####____####____ * where #### is opacity. * @@ -140,7 +140,7 @@ shuffle(Image *img, Image *tmp, int axis, int imgdim, Image *mask, int maskdim) * ##__##__##__##__##__##__##__##__ * which is achieved by shifting the mask * and drawing on itself through itself. - * Draw doesn't actually allow this, so + * Draw doesn't actually allow this, so * we have to copy it first. * * ####____####____####____####____ (dst) @@ -229,7 +229,7 @@ swapadjacent(Image *img, Image *tmp, int axis, int imgdim, Image *mask, int mask /* * r0 is the lower rectangle, while r1 is the upper one. */ - draw(tmp, tmp->r, img, nil, + draw(tmp, tmp->r, img, nil, } void @@ -271,8 +271,7 @@ writefile(char *name, Image *im, int gran) snprint(buf, sizeof buf, "%d%s%d", c++, name, gran); fd = create(buf, OWRITE, 0666); if(fd < 0) - return; + return; writeimage(fd, im, 0); close(fd); } - diff --git a/src/cmd/page/page.c b/src/cmd/page/page.c index 041df26bb..01ad17ff9 100644 --- a/src/cmd/page/page.c +++ b/src/cmd/page/page.c @@ -41,7 +41,7 @@ watcherproc(void *v) for(;;) sleep(1000); } - + int bell(void *u, char *x) { @@ -81,7 +81,7 @@ afmt(Fmt *fmt) void usage(void) { - fprint(2, "usage: page [-biRrwf] [-p ppi] file...\n"); + fprint(2, "usage: page [-biRrwf] [-p ppi] file...\n"); wexits("usage"); } @@ -145,7 +145,7 @@ threadmain(int argc, char **argv) break; case 'f': fitwin = 1; - break; + break; default: usage(); }ARGEND; @@ -184,13 +184,13 @@ threadmain(int argc, char **argv) fprint(2, "page: short read reading %s\n", argv[0]); wexits("read"); } - + atexit(cleanup); }else if(argc != 0){ if(!(b = Bopen(argv[0], OREAD))) { fprint(2, "page: cannot open \"%s\"\n", argv[0]); wexits("open"); - } + } if(Bread(b, buf, Ninput) != Ninput) { fprint(2, "page: short read reading %s\n", argv[0]); @@ -242,7 +242,7 @@ threadmain(int argc, char **argv) wexits("initdraw"); } display->locking = 1; - + truecolor = screen->depth > 8; viewer(doc); wexits(0); diff --git a/src/cmd/page/pdf.c b/src/cmd/page/pdf.c index 2de67bc7a..89df6c5ef 100644 --- a/src/cmd/page/pdf.c +++ b/src/cmd/page/pdf.c @@ -1,6 +1,6 @@ /* * pdf.c - * + * * pdf file support for page */ @@ -15,7 +15,7 @@ static Image* pdfdrawpage(Document *d, int page); static char* pdfpagename(Document*, int); -char *pdfprolog = +char *pdfprolog = #include "pdfprolog.c" ; @@ -25,7 +25,7 @@ pdfbbox(GSInfo *gs) char *p; char *f[4]; Rectangle r; - + r = Rect(0,0,0,0); waitgs(gs); gscmd(gs, "/CropBox knownoget {} {[0 0 0 0]} ifelse PAGE==\n"); @@ -152,7 +152,7 @@ static char* pdfpagename(Document *d, int page) { static char str[15]; - + USED(d); sprint(str, "p %d", page+1); return str; diff --git a/src/cmd/page/ps.c b/src/cmd/page/ps.c index 846895718..eb09cc8f8 100644 --- a/src/cmd/page/ps.c +++ b/src/cmd/page/ps.c @@ -1,6 +1,6 @@ /* * ps.c - * + * * provide postscript file reading support for page */ @@ -245,10 +245,10 @@ initps(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf) if(!prefix(p, "%%Page:")) continue; - /* + /* * figure out of the %%Page: line contains a page number * or some other page description to use in the menu bar. - * + * * lines look like %%Page: x y or %%Page: x * we prefer just x, and will generate our * own if necessary. diff --git a/src/cmd/page/rotate.c b/src/cmd/page/rotate.c index 3ac83a1fb..2c6ea520f 100644 --- a/src/cmd/page/rotate.c +++ b/src/cmd/page/rotate.c @@ -1,12 +1,12 @@ /* * rotate an image 180° in O(log Dx + log Dy) /dev/draw writes, * using an extra buffer same size as the image. - * + * * the basic concept is that you can invert an array by inverting * the top half, inverting the bottom half, and then swapping them. * the code does this slightly backwards to ensure O(log n) runtime. * (If you do it wrong, you can get O(log² n) runtime.) - * + * * This is usually overkill, but it speeds up slow remote * connections quite a bit. */ @@ -37,7 +37,7 @@ writefile(char *name, Image *im, int gran) snprint(buf, sizeof buf, "%d%s%d", c++, name, gran); fd = create(buf, OWRITE, 0666); if(fd < 0) - return; + return; writeimage(fd, im, 0); close(fd); } @@ -109,7 +109,7 @@ interlace(Image *im, Image *tmp, int axis, int n, Image *mask, int gran) /* * Halve the grating period in the mask. - * The grating currently looks like + * The grating currently looks like * ####____####____####____####____ * where #### is opacity. * @@ -117,7 +117,7 @@ interlace(Image *im, Image *tmp, int axis, int n, Image *mask, int gran) * ##__##__##__##__##__##__##__##__ * which is achieved by shifting the mask * and drawing on itself through itself. - * Draw doesn't actually allow this, so + * Draw doesn't actually allow this, so * we have to copy it first. * * ####____####____####____####____ (dst) @@ -151,7 +151,7 @@ shuffle(Image *im, Image *tmp, int axis, int n, Image *mask, int gran, interlace(im, tmp, axis, nn, mask, gran); // writefile("interlace", im, gran); - + gran = nextmask(mask, axis, gran); shuffle(im, tmp, axis, n, mask, gran, nn); // writefile("shuffle", im, gran); @@ -288,7 +288,7 @@ fac(int L) return f; } -/* +/* * i0(x) is the modified Bessel function, Σ (x/2)^2L / (L!)² * There are faster ways to calculate this, but we precompute * into a table so let's keep it simple. diff --git a/src/cmd/page/util.c b/src/cmd/page/util.c index f10ef6db3..3b4655d1f 100644 --- a/src/cmd/page/util.c +++ b/src/cmd/page/util.c @@ -50,7 +50,7 @@ spooltodisk(uchar *ibuf, int in, char **name) { uchar buf[8192]; int fd, n; - + strcpy(tempfile, "/tmp/pagespoolXXXXXXXXX"); fd = opentemp(tempfile, ORDWR); if(name) @@ -94,7 +94,7 @@ _stdinpipe(void *a) arg = a; if(pipe(p) < 0){ - fprint(2, "pipe fails: %r\n"); + fprint(2, "pipe fails: %r\n"); wexits("pipe"); } @@ -103,7 +103,7 @@ _stdinpipe(void *a) write(p[1], arg->ibuf, arg->in); while((n = read(stdinfd, buf, sizeof buf)) > 0) write(p[1], buf, n); - + close(p[1]); threadexits(0); } diff --git a/src/cmd/page/view.c b/src/cmd/page/view.c index 315a22a80..2696f01fb 100644 --- a/src/cmd/page/view.c +++ b/src/cmd/page/view.c @@ -33,25 +33,25 @@ void plumbproc(void*); Cursor reading={ {-1, -1}, - {0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, - 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xef, 0xe0, - 0xc7, 0xf0, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0xc0, + {0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, + 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xef, 0xe0, + 0xc7, 0xf0, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0xc0, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, }, - {0x00, 0x00, 0x7f, 0x00, 0x7e, 0x00, 0x7c, 0x00, - 0x7e, 0x00, 0x7f, 0x00, 0x6f, 0x80, 0x47, 0xc0, - 0x03, 0xe0, 0x01, 0xf0, 0x00, 0xe0, 0x00, 0x40, + {0x00, 0x00, 0x7f, 0x00, 0x7e, 0x00, 0x7c, 0x00, + 0x7e, 0x00, 0x7f, 0x00, 0x6f, 0x80, 0x47, 0xc0, + 0x03, 0xe0, 0x01, 0xf0, 0x00, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x01, 0xb6, 0x01, 0xb6, 0x00, 0x00, } }; Cursor query = { {-7,-7}, - {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, - 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, - 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, + {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, + 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, + 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, }, - {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, - 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, - 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, + {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, + 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, + 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } }; @@ -79,13 +79,13 @@ unhide(void) USED(nil); } -int +int max(int a, int b) { return a > b ? a : b; } -int +int min(int a, int b) { return a < b ? a : b; @@ -130,7 +130,7 @@ showpage(int page, Menu *m) m->lasthit = 0; /* this page */ else m->lasthit = reverse ? doc->npage-1-page : page; - + setcursor(mc, &reading); delayfreeimage(nil); im = cachedpage(doc, angle, page); @@ -178,7 +178,7 @@ writebitmap(void) q = basename; if(p = strchr(q, '.')) *p = 0; - + memset(name, 0, sizeof name); snprint(name, sizeof(name)-1, "%s.%d.bit", q, page+1); if(access(name, 0) >= 0) { @@ -241,7 +241,7 @@ enum{ Empty3, Exit, }; - + void viewer(Document *dd) { @@ -269,13 +269,13 @@ viewer(Document *dd) "next", "prev", "zerox", - "", + "", "reverse", "discard", "write", - "", - "quit", - 0 + "", + "quit", + 0 }; char *s; enum { @@ -287,7 +287,7 @@ viewer(Document *dd) }; Alt alts[CN+1]; Plumbmsg *pm; - + cp = chancreate(sizeof pm, 0); assert(cp); @@ -483,7 +483,7 @@ viewer(Document *dd) setcursor(mc, &query); sleep(1000); setcursor(mc, nil); - break; + break; } break; @@ -494,7 +494,7 @@ viewer(Document *dd) xy0 = oxy; do { dxy = subpt(m.xy, oxy); - oxy = m.xy; + oxy = m.xy; translate(dxy); recv(mc->c, &m); } while(m.buttons == Left); @@ -503,7 +503,7 @@ viewer(Document *dd) translate(dxy); } break; - + case Middle: if(doc->npage == 0) break; @@ -524,7 +524,7 @@ viewer(Document *dd) if((page >= doc->npage) && !doc->fwdonly) return; - + showpage(page, &menu); nxt = 0; break; @@ -540,7 +540,7 @@ viewer(Document *dd) if((page >= doc->npage) && !doc->fwdonly && !reverse) return; - + showpage(page, &menu); nxt = 0; break; @@ -565,7 +565,7 @@ viewer(Document *dd) showpage(page, &menu); } break; - } + } else{ /* image */ double delta; Rectangle r; @@ -581,8 +581,8 @@ viewer(Document *dd) delta = (double)Dy(im->r)/(double)Dy(r); setcursor(mc, &reading); - tmp = xallocimage(display, - Rect(0, 0, (int)((double)Dx(im->r)*delta), (int)((double)Dy(im->r)*delta)), + tmp = xallocimage(display, + Rect(0, 0, (int)((double)Dx(im->r)*delta), (int)((double)Dy(im->r)*delta)), im->chan, 0, DBlack); if(tmp == nil) { fprint(2, "out of memory during zoom: %r\n"); @@ -639,7 +639,7 @@ viewer(Document *dd) break; reverse = !reverse; menu.lasthit = doc->npage-1-menu.lasthit; - + if(page == 0 || page == doc->npage-1) { page = doc->npage-1-page; showpage(page, &menu); @@ -672,10 +672,10 @@ viewer(Document *dd) case Empty3: break; - }; + }; + + - - case Right: if(doc->npage == 0) break; @@ -684,7 +684,7 @@ viewer(Document *dd) n = menuhit(RMenu, mc, &menu, nil); if(n == -1) break; - + if(doc->fwdonly) { switch(n){ case 0: /* this page */ @@ -697,12 +697,12 @@ viewer(Document *dd) } break; } - + if(n == doc->npage) return; else page = reverse ? doc->npage-1-n : n; - + if(oldpage != page) showpage(page, &menu); nxt = 0; @@ -753,7 +753,7 @@ Image *gray; * mp and sp get aligned with bot.min. */ static void -gendrawdiff(Image *dst, Rectangle bot, Rectangle top, +gendrawdiff(Image *dst, Rectangle bot, Rectangle top, Image *src, Point sp, Image *mask, Point mp, int op) { Rectangle r; @@ -890,7 +890,7 @@ redraw(Image *screen) } } border(screen, r, -4000, gray, ZP); -// flushimage(display, 0); +// flushimage(display, 0); } /* clip p to be in r */ @@ -911,7 +911,7 @@ pclip(Point p, Rectangle r) } /* - * resize is perhaps a misnomer. + * resize is perhaps a misnomer. * this really just grows the window to be at least dx across * and dy high. if the window hits the bottom or right edge, * it is backed up until it hits the top or left edge. diff --git a/src/cmd/paint/eenter.c b/src/cmd/paint/eenter.c index 6645820c6..6c84f2fb8 100644 --- a/src/cmd/paint/eenter.c +++ b/src/cmd/paint/eenter.c @@ -255,4 +255,3 @@ eenter(char *ask, char *buf, int len, Mouse *m) return n; } - diff --git a/src/cmd/paint/paint.c b/src/cmd/paint/paint.c index 7dce3710c..e7f502cf7 100644 --- a/src/cmd/paint/paint.c +++ b/src/cmd/paint/paint.c @@ -97,7 +97,7 @@ strokedraw(Image *dst, Rectangle r, Image *ink, int brush) * mp and sp get aligned with bot.min. */ static void -gendrawdiff(Image *dst, Rectangle bot, Rectangle top, +gendrawdiff(Image *dst, Rectangle bot, Rectangle top, Image *src, Point sp, Image *mask, Point mp, int op) { Rectangle r; @@ -482,7 +482,7 @@ center(void) { cpos = ZP; if(canvas) - cpos = addpt(canvas->r.min, + cpos = addpt(canvas->r.min, divpt(subpt(canvas->r.max, canvas->r.min), 2)); spos = addpt(screen->r.min, divpt(subpt(screen->r.max, screen->r.min), 2)); @@ -633,7 +633,7 @@ main(int argc, char *argv[]) if(argc == 1) filename = strdup(argv[0]); else if(argc != 0) - usage(); + usage(); if(initdraw(0, 0, "paint") < 0) sysfatal("initdraw: %r"); diff --git a/src/cmd/pbd.c b/src/cmd/pbd.c index 2e859f848..f4105bf34 100644 --- a/src/cmd/pbd.c +++ b/src/cmd/pbd.c @@ -16,4 +16,4 @@ main(void) } write(1, p, strlen(p)); exits(0); -} +} diff --git a/src/cmd/pic/arcgen.c b/src/cmd/pic/arcgen.c index bec41e47a..4cb16957b 100644 --- a/src/cmd/pic/arcgen.c +++ b/src/cmd/pic/arcgen.c @@ -221,4 +221,3 @@ quadrant(double x, double y) else if( x> 0.0 && y<=0.0) return(4); else return 0; /* shut up lint */ } - diff --git a/src/cmd/pic/linegen.c b/src/cmd/pic/linegen.c index e0db5fc6c..bc7e93351 100644 --- a/src/cmd/pic/linegen.c +++ b/src/cmd/pic/linegen.c @@ -225,7 +225,7 @@ obj *linegen(int type) extreme(ex, ey); nx = xi; ny = yi; } - + } p->o_ddval = ddval; if (dbg) { diff --git a/src/cmd/pic/misc.c b/src/cmd/pic/misc.c index e888fafc8..1e2db1b52 100644 --- a/src/cmd/pic/misc.c +++ b/src/cmd/pic/misc.c @@ -34,7 +34,7 @@ curdir(void) /* convert current dir (hvmode) to RIGHT, LEFT, etc. */ return 0; } -double +double getcomp(obj *p, int t) /* return component of a position */ { switch (t) { diff --git a/src/cmd/plot/libplot/circ.c b/src/cmd/plot/libplot/circ.c index 53337117c..d4b6699fe 100644 --- a/src/cmd/plot/libplot/circ.c +++ b/src/cmd/plot/libplot/circ.c @@ -4,7 +4,7 @@ void circ(double xc, double yc, double r){ int rad; p.x=SCX(xc); p.y=SCY(yc); - if (r < 0) + if (r < 0) rad=SCR(-r); else rad=SCR(r); diff --git a/src/cmd/plot/libplot/disk.c b/src/cmd/plot/libplot/disk.c index 47b39012b..6255efa5f 100644 --- a/src/cmd/plot/libplot/disk.c +++ b/src/cmd/plot/libplot/disk.c @@ -4,7 +4,7 @@ void plotdisc(double xc, double yc, double r){ int rad; p.x=SCX(xc); p.y=SCY(yc); - if (r < 0) + if (r < 0) rad=SCR(-r); else rad=SCR(r); diff --git a/src/cmd/plot/libplot/move.c b/src/cmd/plot/libplot/move.c index 4e60260b6..11cdcfcb6 100644 --- a/src/cmd/plot/libplot/move.c +++ b/src/cmd/plot/libplot/move.c @@ -1,5 +1,5 @@ #include "mplot.h" void move(double xx, double yy){ - e1->copyx = xx; + e1->copyx = xx; e1->copyy = yy; } diff --git a/src/cmd/plot/libplot/parabola.c b/src/cmd/plot/libplot/parabola.c index 212b9c973..d8b5ffb20 100644 --- a/src/cmd/plot/libplot/parabola.c +++ b/src/cmd/plot/libplot/parabola.c @@ -5,13 +5,13 @@ void parabola(double x0, double y0, double x1, double y1, double xb, double yb){ double dt, d2, d1; d1 = sqrt((xb - x0) * (xb - x0) + (yb - y0) * (yb - y0)); d2 = sqrt((xb - x1) * (xb - x1) + (yb - y1) * (yb - y1)); - if (d1 <= e1->quantum || d2 <= e1->quantum) { - plotline(x0, y0, x1, y1); - return; + if (d1 <= e1->quantum || d2 <= e1->quantum) { + plotline(x0, y0, x1, y1); + return; } - c0x = x0 + x1 - 2. * xb; + c0x = x0 + x1 - 2. * xb; c1x = 2. * (xb - x0); - c0y = y0 + y1 - 2. * yb; + c0y = y0 + y1 - 2. * yb; c1y = 2. * (yb - y0); move(x0, y0); dt = e1->quantum / d1; diff --git a/src/cmd/plot/libplot/ppause.c b/src/cmd/plot/libplot/ppause.c index 9fb8863d2..993a7b204 100644 --- a/src/cmd/plot/libplot/ppause.c +++ b/src/cmd/plot/libplot/ppause.c @@ -1,7 +1,7 @@ #include "mplot.h" -void ppause(void){ - char aa[4]; - fflush(stdout); - read(0, aa, 4); - erase(); +void ppause(void){ + char aa[4]; + fflush(stdout); + read(0, aa, 4); + erase(); } diff --git a/src/cmd/plot/libplot/rarc.c b/src/cmd/plot/libplot/rarc.c index 9c8ccf158..c0c8c6b3a 100644 --- a/src/cmd/plot/libplot/rarc.c +++ b/src/cmd/plot/libplot/rarc.c @@ -12,31 +12,31 @@ void rarc(double x1, double y1, double x2, double y2, double xc, double yc, doub dx = x1 - xc; dy = y1 - yc; rd = sqrt(dx * dx + dy * dy); - if (rd / e1->quantum < 1.0) { - move(xc, yc); - vec(xc, yc); + if (rd / e1->quantum < 1.0) { + move(xc, yc); + vec(xc, yc); return; } dph = acos(1.0 - (e1->quantum / rd)); - if (dph > PI4) + if (dph > PI4) dph = PI4; ph=atan2((y2-yc),(x2 - xc)) - atan2(dy, dx); - if (ph < 0) - ph += 6.2832; - if (rr < 0) + if (ph < 0) + ph += 6.2832; + if (rr < 0) ph = 6.2832 - ph; - if (ph < dph) + if (ph < dph) plotline(x1, y1, x2, y2); else { - n = ph / dph; - a = cos(dph); - b = sin(dph); - if (rr < 0) + n = ph / dph; + a = cos(dph); + b = sin(dph); + if (rr < 0) b = -b; move(x1, y1); while ((n--) >= 0) { - xnext = dx * a - dy * b; - dy = dx * b + dy * a; + xnext = dx * a - dy * b; + dy = dx * b + dy * a; dx = xnext; vec(dx + xc, dy + yc); } diff --git a/src/cmd/plot/libplot/save.c b/src/cmd/plot/libplot/save.c index e3dc4058f..0f12b6361 100644 --- a/src/cmd/plot/libplot/save.c +++ b/src/cmd/plot/libplot/save.c @@ -1,5 +1,5 @@ #include "mplot.h" -void save(void){ - sscpy(e1, e1 + 1); - e1++; +void save(void){ + sscpy(e1, e1 + 1); + e1++; } diff --git a/src/cmd/plot/libplot/spline.c b/src/cmd/plot/libplot/spline.c index 8cfa83d7a..6001bd726 100644 --- a/src/cmd/plot/libplot/spline.c +++ b/src/cmd/plot/libplot/spline.c @@ -10,25 +10,25 @@ void splin(int mode, int num[], double *ff[]){ np = num; fp = ff; while((n = *np++)){ - xp = *fp++; - yp = xp + 1; - xp0 = xp; + xp = *fp++; + yp = xp + 1; + xp0 = xp; yp0 = yp; - xpe = xp0 + 2 * (n - 1); + xpe = xp0 + 2 * (n - 1); ype = yp0 + 2 * (n - 1); - if (n < 3) { - plotline(*xp, *yp, *(xp + 2), *(yp + 2)); + if (n < 3) { + plotline(*xp, *yp, *(xp + 2), *(yp + 2)); continue; } if (mode == 4) { /*closed curve*/ - xa = 0.5 * (*xpe + *(xpe - 2)); + xa = 0.5 * (*xpe + *(xpe - 2)); xc = 0.5 * (*xpe + *xp0); - ya = 0.5 * (*ype + *(ype - 2)); + ya = 0.5 * (*ype + *(ype - 2)); yc = 0.5 * (*ype + *yp0); parabola(xa, ya, xc, yc, *xpe, *ype); - xa = 0.5 * (*xpe + *xp0); + xa = 0.5 * (*xpe + *xp0); xc = 0.5 * (*(xp0 + 2) + *xp0); - ya = 0.5 * (*ype + *yp0); + ya = 0.5 * (*ype + *yp0); yc = 0.5 * (*(yp0 + 2) + *yp0); parabola(xa, ya, xc, yc, *xp0, *yp0); } @@ -36,12 +36,12 @@ void splin(int mode, int num[], double *ff[]){ if (mode % 2) /*odd mode makes first point double*/ plotline(*xp0,*yp0,0.5*(*xp0+*(xp0+2)),0.5*(*yp0+*(yp0+2))); } - xp += 2; + xp += 2; yp += 2; for (i = 1; i < (n - 1); i++, xp += 2, yp += 2) { - xa = 0.5 * (*(xp - 2) + *xp); + xa = 0.5 * (*(xp - 2) + *xp); xc = 0.5 * ( *xp + *(xp + 2)); - ya = 0.5 * (*(yp - 2) + *yp); + ya = 0.5 * (*(yp - 2) + *yp); yc = 0.5 * ( *yp + *(yp + 2)); parabola(xa, ya, xc, yc, *xp, *yp); } diff --git a/src/cmd/plot/libplot/subr.c b/src/cmd/plot/libplot/subr.c index 2b41990d4..62333edfd 100644 --- a/src/cmd/plot/libplot/subr.c +++ b/src/cmd/plot/libplot/subr.c @@ -22,28 +22,28 @@ bcolor(char *s){ return(DBlack); case 'r': return(DRed); - case 'g': + case 'g': return(DGreen); - case 'b': + case 'b': return(DBlue); - case 'm': + case 'm': return(DMagenta); - case 'y': + case 'y': return(DYellow); - case 'c': + case 'c': return(DCyan); - case 'w': + case 'w': return(DWhite); - case 'R': + case 'R': return(atoi(s + 1)); - case 'G': - e1->pgap = atof(s + 1); + case 'G': + e1->pgap = atof(s + 1); return(-1); - case 'A': - e1->pslant = (180. - atof(s + 1)) / RADIAN; + case 'A': + e1->pslant = (180. - atof(s + 1)) / RADIAN; return(-1); } - while (*++s != 0) + while (*++s != 0) if (*s == '/') { s++; break; @@ -52,20 +52,20 @@ bcolor(char *s){ return DBlack; } void sscpy(struct penvir *a, struct penvir *b){ /* copy 'a' onto 'b' */ - b->left = a->left; - b->bottom = a->bottom; - b->xmin = a->xmin; + b->left = a->left; + b->bottom = a->bottom; + b->xmin = a->xmin; b->ymin = a->ymin; - b->scalex = a->scalex; + b->scalex = a->scalex; b->scaley = a->scaley; - b->sidex = a->sidex; + b->sidex = a->sidex; b->sidey = a->sidey; - b->copyx = a->copyx; + b->copyx = a->copyx; b->copyy = a->copyy; b->quantum = a->quantum; b->grade = a->grade; - b->pmode = a->pmode; - b->foregr = a->foregr; + b->pmode = a->pmode; + b->foregr = a->foregr; b->backgr = a->backgr; } void idle(void){} diff --git a/src/cmd/plot/plot.c b/src/cmd/plot/plot.c index 8b62387bb..f87e228bd 100644 --- a/src/cmd/plot/plot.c +++ b/src/cmd/plot/plot.c @@ -559,7 +559,7 @@ void call(char *a){ exits("undefined"); } *ap = sav; - while (isspace((uchar)*ap) || *ap == ',') + while (isspace((uchar)*ap) || *ap == ',') ap++; if (*ap != '\0') SC = atof(ap); diff --git a/src/cmd/plumb/match.c b/src/cmd/plumb/match.c index 5a4cd88ce..13ebe768f 100644 --- a/src/cmd/plumb/match.c +++ b/src/cmd/plumb/match.c @@ -309,7 +309,7 @@ Exec* newexec(Plumbmsg *m) { Exec *exec; - + exec = emalloc(sizeof(Exec)); exec->msg = m; exec->p0 = -1; @@ -331,7 +331,7 @@ rewrite(Plumbmsg *m, Exec *e) else prev->next = a->next; free(a->name); - free(a->value); + free(a->value); free(a); break; } diff --git a/src/cmd/postscript/common/bbox.c b/src/cmd/postscript/common/bbox.c index b6807a4d1..2dc55cbb4 100644 --- a/src/cmd/postscript/common/bbox.c +++ b/src/cmd/postscript/common/bbox.c @@ -259,4 +259,3 @@ concat(m1) } /* End of concat */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/common/comments.h b/src/cmd/postscript/common/comments.h index 6b409cad1..0bbf59020 100644 --- a/src/cmd/postscript/common/comments.h +++ b/src/cmd/postscript/common/comments.h @@ -124,4 +124,3 @@ #define ENDPAGE "%%EndPage:" #define FORMSPERPAGE "%%FormsPerPage:" #define VERSION "%%Version:" - diff --git a/src/cmd/postscript/common/common.h b/src/cmd/postscript/common/common.h index f49f6f1fd..7b2676688 100644 --- a/src/cmd/postscript/common/common.h +++ b/src/cmd/postscript/common/common.h @@ -45,4 +45,3 @@ void *galloc(void *, int, char *); void pagelist(char *); int safe_tmpnam(char*); - diff --git a/src/cmd/postscript/common/ext.h b/src/cmd/postscript/common/ext.h index 77635b6b5..75bea5b55 100644 --- a/src/cmd/postscript/common/ext.h +++ b/src/cmd/postscript/common/ext.h @@ -33,7 +33,7 @@ extern void interrupt(int); extern int cat(char*); extern void concat(double*); -/* +/* * extern char *tempnam(char*,char*); * extern char *malloc(); * extern char *calloc(); diff --git a/src/cmd/postscript/common/gen.h b/src/cmd/postscript/common/gen.h index dffeb9578..1553c2c46 100644 --- a/src/cmd/postscript/common/gen.h +++ b/src/cmd/postscript/common/gen.h @@ -66,4 +66,3 @@ extern char* safe_tempnam(char*, char*); #define ABS(A) ((A) >= 0 ? (A) : -(A)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) #define MAX(A, B) ((A) > (B) ? (A) : (B)) - diff --git a/src/cmd/postscript/common/glob.c b/src/cmd/postscript/common/glob.c index 2826f4e5f..31de6b4d4 100644 --- a/src/cmd/postscript/common/glob.c +++ b/src/cmd/postscript/common/glob.c @@ -26,4 +26,3 @@ double pagewidth = PAGEWIDTH; int reading = UTFENCODING; /* input */ int writing = WRITING; /* and output encoding */ - diff --git a/src/cmd/postscript/common/misc.c b/src/cmd/postscript/common/misc.c index 28120ea5d..81444465a 100644 --- a/src/cmd/postscript/common/misc.c +++ b/src/cmd/postscript/common/misc.c @@ -238,4 +238,3 @@ void interrupt(sig) } /* End of interrupt */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/common/path.h b/src/cmd/postscript/common/path.h index f2019c1e4..6e456bb26 100644 --- a/src/cmd/postscript/common/path.h +++ b/src/cmd/postscript/common/path.h @@ -29,4 +29,3 @@ #define FONTDIR "#9/troff/font" #define POSTLIBDIR "#9/postscript/prologues" #define TEMPDIR "/var/tmp" - diff --git a/src/cmd/postscript/common/request.c b/src/cmd/postscript/common/request.c index ba956d574..2e96093ba 100644 --- a/src/cmd/postscript/common/request.c +++ b/src/cmd/postscript/common/request.c @@ -127,4 +127,3 @@ dumprequest(want, file, fp_out) } /* End of dumprequest */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/common/request.h b/src/cmd/postscript/common/request.h index 25d94d01a..6898ffd04 100644 --- a/src/cmd/postscript/common/request.h +++ b/src/cmd/postscript/common/request.h @@ -19,4 +19,3 @@ typedef struct { int page; char *file; } Request; - diff --git a/src/cmd/postscript/download/download.c b/src/cmd/postscript/download/download.c index 31aa1b3bf..4c8f6ffb7 100644 --- a/src/cmd/postscript/download/download.c +++ b/src/cmd/postscript/download/download.c @@ -565,4 +565,3 @@ Map *allocate(ptr, num) } /* End of allocate */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/download/download.h b/src/cmd/postscript/download/download.h index f88cc57ad..3e8ac6ff0 100644 --- a/src/cmd/postscript/download/download.h +++ b/src/cmd/postscript/download/download.h @@ -11,4 +11,3 @@ typedef struct map { } Map; Map *allocate(); - diff --git a/src/cmd/postscript/misc/ibmfont.c b/src/cmd/postscript/misc/ibmfont.c index 49736d6f0..99d2f64c1 100644 --- a/src/cmd/postscript/misc/ibmfont.c +++ b/src/cmd/postscript/misc/ibmfont.c @@ -8,7 +8,7 @@ * * where font.ibm is the font file, exactly as it came over from an IBM PC, * and font.unix is equivalent host resident font file usable on Unix systems. - * + * */ #include @@ -212,7 +212,7 @@ asciitext(count) ch = '\n'; putc(ch, fp_out); } /* End for */ - + } /* End of asciitext */ /*****************************************************************************/ @@ -238,7 +238,7 @@ hexdata(count) if ( (++n % 40) == 0 ) putc('\n', fp_out); } /* End for */ - + } /* End of hexdata */ /*****************************************************************************/ @@ -263,7 +263,7 @@ getint() return(val); -} /* End of getint */ +} /* End of getint */ /*****************************************************************************/ @@ -293,4 +293,3 @@ error(kind, mesg, a1, a2, a3) } /* End of error */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/misc/laserbar.c b/src/cmd/postscript/misc/laserbar.c index 7b45e667a..7818fc1d4 100644 --- a/src/cmd/postscript/misc/laserbar.c +++ b/src/cmd/postscript/misc/laserbar.c @@ -13,13 +13,13 @@ static int code39[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* sp ! " # $ % & ' */ - 0304, 0, 0, 0, 0250, 0052, 0, 0, + 0304, 0, 0, 0, 0250, 0052, 0, 0, /* ( ) * + , - - / */ 0, 0, 0224, 0212, 0, 0205, 0604, 0242, /* 0 1 2 3 4 5 6 7 */ 0064, 0441, 0141, 0540, 0061, 0460, 0160, 0045, /* 8 9 : ; < = > ? */ - 0444, 0144, 0, 0, 0, 0, 0, 0, + 0444, 0144, 0, 0, 0, 0, 0, 0, /* @ A B C D E F G */ 0, 0411, 0111, 0510, 0031, 0430, 0130, 0015, /* H I J K L M N O */ diff --git a/src/cmd/postscript/misc/macfont.c b/src/cmd/postscript/misc/macfont.c index 59244a192..d0c9cb781 100644 --- a/src/cmd/postscript/misc/macfont.c +++ b/src/cmd/postscript/misc/macfont.c @@ -8,7 +8,7 @@ * * where font.mac is the font file, exactly as it came over from a Macintosh, * and font.unix is equivalent host resident font file usable on Unix systems. - * + * */ #include @@ -215,7 +215,7 @@ asciitext(count) ch = '\n'; putc(ch, fp_out); } /* End for */ - + } /* End of asciitext */ /*****************************************************************************/ @@ -241,7 +241,7 @@ hexdata(count) if ( (++n % 40) == 0 ) putc('\n', fp_out); } /* End for */ - + } /* End of hexdata */ /*****************************************************************************/ @@ -265,7 +265,7 @@ getint() return(val); -} /* End of getint */ +} /* End of getint */ /*****************************************************************************/ @@ -296,4 +296,3 @@ error(kind, mesg, a1, a2, a3) } /* End of error */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/misc/pscrypt.c b/src/cmd/postscript/misc/pscrypt.c index 1715288ba..520daf331 100644 --- a/src/cmd/postscript/misc/pscrypt.c +++ b/src/cmd/postscript/misc/pscrypt.c @@ -332,4 +332,3 @@ Getc(fp) } /* End of Getc */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/postreverse/postreverse.c b/src/cmd/postscript/postreverse/postreverse.c index d99124d58..563105209 100644 --- a/src/cmd/postscript/postreverse/postreverse.c +++ b/src/cmd/postscript/postreverse/postreverse.c @@ -364,7 +364,7 @@ moreprolog(str) * up being copied to the output file and FALSE will be returned to the caller. * The first call (made from reverse()) looks for ENDPROLOG. Any other call comes * from readpages() and will be looking for the ENDSETUP comment. - * + * */ len = strlen(FORMSPERPAGE); @@ -541,4 +541,3 @@ trailer() } /* End of trailer */ /*****************************************************************************/ - diff --git a/src/cmd/postscript/postreverse/postreverse.h b/src/cmd/postscript/postreverse/postreverse.h index edae7a277..a78ff4e8b 100644 --- a/src/cmd/postscript/postreverse/postreverse.h +++ b/src/cmd/postscript/postreverse/postreverse.h @@ -18,4 +18,3 @@ typedef struct { */ char *copystdin(); - diff --git a/src/cmd/postscript/tr2post/Bgetfield.c b/src/cmd/postscript/tr2post/Bgetfield.c index 5e49e55ef..f9fbfd769 100644 --- a/src/cmd/postscript/tr2post/Bgetfield.c +++ b/src/cmd/postscript/tr2post/Bgetfield.c @@ -22,7 +22,7 @@ Bskipws(Biobuf *bp) { do { r = Bgetrune(bp); if (r == '\n') inputlineno++; - sindex++; + sindex++; } while (r>=0 && isspace(r)); if (r<0) { return(-1); @@ -49,7 +49,7 @@ asc2dig(char c, int base) { } /* get a string of type: "d" for decimal integer, "u" for unsigned, - * "s" for string", "c" for char, + * "s" for string", "c" for char, * return the number of characters gotten for the field. If nothing * was gotten and the end of file was reached, a negative value * from the Bgetrune is returned. @@ -86,7 +86,7 @@ Bgetfield(Biobuf *bp, int type, void *thing, int size) { case '0': base = 8; continue; - default: + default: break; } break; @@ -96,7 +96,7 @@ Bgetfield(Biobuf *bp, int type, void *thing, int size) { continue; } } - if ((dig = asc2dig(r, base)) == -1) bailout = TRUE; + if ((dig = asc2dig(r, base)) == -1) bailout = TRUE; else n = dig + (n * base); } if (r < 0) return(-1); @@ -118,7 +118,7 @@ Bgetfield(Biobuf *bp, int type, void *thing, int size) { continue; } } - if ((dig = asc2dig(r, base)) == -1) bailout = TRUE; + if ((dig = asc2dig(r, base)) == -1) bailout = TRUE; else u = dig + (n * base); } *(int *)thing = u; diff --git a/src/cmd/postscript/tr2post/chartab.c b/src/cmd/postscript/tr2post/chartab.c index 11d1ae85b..4b4f4ef00 100644 --- a/src/cmd/postscript/tr2post/chartab.c +++ b/src/cmd/postscript/tr2post/chartab.c @@ -272,7 +272,7 @@ readtroffmetric(char *fontname, int trindex) { if (*cp == 0) *cp = galloc(0, sizeof(struct charent), "readtroffmetric:charent"); (*cp)->postfontid = thisfont; - (*cp)->postcharid = thischar; + (*cp)->postcharid = thischar; (*cp)->troffcharwidth = ntoken; (*cp)->name = galloc(0, 2, "readtroffmetric: char name"); (*cp)->next = 0; @@ -283,7 +283,7 @@ readtroffmetric(char *fontname, int trindex) { line++; break; } - if (!errorflg) { + if (!errorflg) { line++; } } while(!errorflg && rv>=0); @@ -351,7 +351,7 @@ readtroffmetric(char *fontname, int trindex) { } if (*cp == 0) *cp = galloc(0, sizeof(struct charent), "readtroffmetric:charent"); (*cp)->postfontid = RUNEGETGROUP(charnum); - (*cp)->postcharid = RUNEGETCHAR(charnum); + (*cp)->postcharid = RUNEGETCHAR(charnum); (*cp)->troffcharwidth = width; (*cp)->name = galloc(0, strlen(stoken)+1, "readtroffmetric: char name"); (*cp)->next = 0; diff --git a/src/cmd/postscript/tr2post/devcntl.c b/src/cmd/postscript/tr2post/devcntl.c index f0a9800a0..ad3abbaf9 100644 --- a/src/cmd/postscript/tr2post/devcntl.c +++ b/src/cmd/postscript/tr2post/devcntl.c @@ -175,4 +175,3 @@ devcntl(Biobuf *inp) { while ((c = Bgetc(inp)) != '\n' && c != Beof); inputlineno++; } - diff --git a/src/cmd/postscript/tr2post/draw.c b/src/cmd/postscript/tr2post/draw.c index a7f6b2236..b8bda78d3 100644 --- a/src/cmd/postscript/tr2post/draw.c +++ b/src/cmd/postscript/tr2post/draw.c @@ -220,7 +220,7 @@ drawpath(char *buf, int copy) { * was expected to be legitimate PostScript that manipulated the current path. * The old escape sequence will be supported for a while (for Ravi), and always * call this routine with copy set to TRUE. - * + * * */ diff --git a/src/cmd/postscript/tr2post/readDESC.c b/src/cmd/postscript/tr2post/readDESC.c index 366bae70a..90b7b8825 100644 --- a/src/cmd/postscript/tr2post/readDESC.c +++ b/src/cmd/postscript/tr2post/readDESC.c @@ -71,7 +71,7 @@ readDESC(void) { printdesclang=galloc(printdesclang, strlen(token)+1, "readdesc:"); strcpy(printdesclang, token); if (debug) Bprint(Bstderr, "PDL %s\n", token); - break; + break; case 1: encoding=galloc(encoding, strlen(token)+1, "readdesc:"); strcpy(encoding, token); @@ -85,7 +85,7 @@ readDESC(void) { } fontmnt = atoi(token) + 1; fontmtab = galloc(fontmtab, fontmnt*sizeof(char *), "readdesc:"); - + for (i=0; iBiobufhdr; */ - + ARGBEGIN{ case 'a': /* aspect ratio */ aspectratio = atof(ARGF()); @@ -239,7 +239,7 @@ main(int argc, char *argv[]) { exits("read"); } finish(); - + exits(""); return 0; } diff --git a/src/cmd/postscript/tr2post/utils.c b/src/cmd/postscript/tr2post/utils.c index f914a1c87..7f00dbd4d 100644 --- a/src/cmd/postscript/tr2post/utils.c +++ b/src/cmd/postscript/tr2post/utils.c @@ -47,7 +47,7 @@ hmot(int x) { if (delta == troffontab[curtrofffontid].spacewidth*fontsize/10 && isinstring()) { if (pageon()) runeout(' '); } else { - if (pageon()) { + if (pageon()) { endstring(); /* Bprint(Bstdout, " %d 0 rmoveto ", delta); */ /* Bprint(Bstdout, " %d %d m ", hpos+x, vpos); */ @@ -160,7 +160,7 @@ if (debug) fprint(2, " looking through special fonts: trying %s\n", troffontab[f if (*cp != 0) goto foundit; } } - + if (*cp == 0) { error(WARNING, "cannot find glyph, rune=0x%x stoken=<%s> troff font %s\n", rune, stoken, troffontab[curtrofffontid].trfontid); @@ -174,7 +174,7 @@ if (debug) fprint(2, " looking through special fonts: trying %s\n", troffontab[f Bprint(Bstderr, "runeout(0x%x)<%C> postfontid=0x%x postcharid=0x%x troffcharwidth=%d\n", rune, rune, (*cp)->postfontid, (*cp)->postcharid, (*cp)->troffcharwidth); } - + tfp = &(troffontab[fontid]); for (i=0; ipsfmapsize; i++) { psfp = &(tfp->psfmap[i]); diff --git a/src/cmd/proof/font.c b/src/cmd/proof/font.c index d930f34c5..5cd686237 100644 --- a/src/cmd/proof/font.c +++ b/src/cmd/proof/font.c @@ -108,12 +108,12 @@ dochar(Rune r[]) string(screen, p, display->black, ZP, f, s); } -static int drawlog2[] = { - 0, 0, - 1, 1, - 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +static int drawlog2[] = { + 0, 0, + 1, 1, + 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5 }; diff --git a/src/cmd/proof/htroff.c b/src/cmd/proof/htroff.c index d591d3846..c12fe91ed 100644 --- a/src/cmd/proof/htroff.c +++ b/src/cmd/proof/htroff.c @@ -302,8 +302,8 @@ readpage(void) static void spline(Image *b, int n, Point *pp) { - long w, t1, t2, t3, fac=1000; - int i, j, steps=10; + long w, t1, t2, t3, fac=1000; + int i, j, steps=10; Point p, q; for (i = n; i > 0; i--) @@ -321,9 +321,9 @@ spline(Image *b, int n, Point *pp) t2 = 3*fac/4 - w * w / fac; w = w - fac/2; t3 = w * w / (2*fac); - q.x = (t1*pp[i+2].x + t2*pp[i+1].x + + q.x = (t1*pp[i+2].x + t2*pp[i+1].x + t3*pp[i].x + fac/2) / fac; - q.y = (t1*pp[i+2].y + t2*pp[i+1].y + + q.y = (t1*pp[i+2].y + t2*pp[i+1].y + t3*pp[i].y + fac/2) / fac; line(b, p, q, 0, 0, 0, display->black, ZP); p = q; diff --git a/src/cmd/proof/main.c b/src/cmd/proof/main.c index 5e0c804c2..e8c18f873 100644 --- a/src/cmd/proof/main.c +++ b/src/cmd/proof/main.c @@ -43,7 +43,7 @@ main(int argc, char *argv[]) { char c; int dotrack = 0; - + libfont = unsharp(libfont); ARGBEGIN{ case 'm': /* magnification */ @@ -96,7 +96,7 @@ main(int argc, char *argv[]) loadfontname(c, "??"); mapscreen(); clearscreen(); - readpage(); + readpage(); } /* diff --git a/src/cmd/ramfs.c b/src/cmd/ramfs.c index 6e00c894b..42a38e811 100644 --- a/src/cmd/ramfs.c +++ b/src/cmd/ramfs.c @@ -900,4 +900,3 @@ usage(void) fprint(2, "usage: %s [-is] [-m mountpoint]\n", argv0); exits("usage"); } - diff --git a/src/cmd/rc/exec.c b/src/cmd/rc/exec.c index 03c96d490..172acfa3e 100644 --- a/src/cmd/rc/exec.c +++ b/src/cmd/rc/exec.c @@ -135,7 +135,7 @@ main(int argc, char *argv[]) code bootstrap[32]; char num[12], *rcmain; int i; - + /* needed for rcmain later */ putenv("PLAN9", unsharp("#9")); @@ -690,7 +690,7 @@ word* copynwords(word *a, word *tail, int n) { word *v, **end; - + v = 0; end = &v; while(n-- > 0){ diff --git a/src/cmd/rc/havefork.c b/src/cmd/rc/havefork.c index dc0ca2e88..63f83354d 100644 --- a/src/cmd/rc/havefork.c +++ b/src/cmd/rc/havefork.c @@ -37,11 +37,11 @@ Xasync(void) * ssh foo & will reopen /dev/tty, try to read a password, * get a signal, and repeat, in a tight loop, forever. * Arguably this is a bug in ssh (it behaves the same - * way under bash as under rc) but I'm fixing it here + * way under bash as under rc) but I'm fixing it here * anyway. If we dissociate the process from the tty, * then it won't be able to open /dev/tty ever again. * The SIG_IGN on SIGTTOU makes writing the tty - * (via fd 1 or 2, for example) succeed even though + * (via fd 1 or 2, for example) succeed even though * our pgrp is not the terminal's controlling pgrp. */ if((tty = open("/dev/tty", OREAD)) >= 0){ diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index d9369e5c4..973ddee8d 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -50,7 +50,7 @@ advance(void) } /* * read a character from the input stream - */ + */ int getnext(void) diff --git a/src/cmd/rc/plan9ish.c b/src/cmd/rc/plan9ish.c index da9d8679e..d52def7d0 100644 --- a/src/cmd/rc/plan9ish.c +++ b/src/cmd/rc/plan9ish.c @@ -343,7 +343,7 @@ char **mkenv(){ } *ep=0; qsort((char *)env, nvar, sizeof ep[0], cmpenv); - return env; + return env; } void Updenv(void){} void Execute(word *args, word *path) @@ -556,7 +556,7 @@ int exitcode(char *msg) { int n; - + n = atoi(msg); if(n == 0) n = 1; @@ -579,7 +579,7 @@ void delwaitpid(int pid) { int r, w; - + for(r=w=0; rchild[0]); freetree(p->child[1]); freetree(p->child[2]); diff --git a/src/cmd/readcons.c b/src/cmd/readcons.c index f0f8397f0..d9c4a182d 100644 --- a/src/cmd/readcons.c +++ b/src/cmd/readcons.c @@ -13,7 +13,7 @@ main(int argc, char **argv) { char *def, *p; int secret; - + def = nil; secret = 0; ARGBEGIN{ @@ -26,7 +26,7 @@ main(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1) usage(); @@ -36,4 +36,3 @@ main(int argc, char **argv) print("%s\n", p); exits(0); } - diff --git a/src/cmd/resample.c b/src/cmd/resample.c old mode 100755 new mode 100644 index d32084195..b882b826a --- a/src/cmd/resample.c +++ b/src/cmd/resample.c @@ -18,7 +18,7 @@ fac(int L) return f; } -/* +/* * i0(x) is the modified Bessel function, Σ (x/2)^2L / (L!)² * There are faster ways to calculate this, but we precompute * into a table so let's keep it simple. diff --git a/src/cmd/rio/client.c b/src/cmd/rio/client.c index c3b36df1a..256261cad 100644 --- a/src/cmd/rio/client.c +++ b/src/cmd/rio/client.c @@ -19,7 +19,7 @@ setactive(Client *c, int on) if(c->parent == c->screen->root) return; - + if(on){ XUngrabButton(dpy, AnyButton, AnyModifier, c->parent); XSetInputFocus(dpy, c->window, RevertToPointerRoot, timestamp()); @@ -254,7 +254,7 @@ void shuffle(int up) { Client **l, *c; - + if(clients == 0 || clients->next == 0) return; if(!up){ @@ -282,4 +282,3 @@ shuffle(int up) /* top(clients); */ /* active(clients); */ } - diff --git a/src/cmd/rio/color.c b/src/cmd/rio/color.c index f1fff54c1..489c68e85 100644 --- a/src/cmd/rio/color.c +++ b/src/cmd/rio/color.c @@ -42,4 +42,3 @@ colorpixel(Display *dpy, ScreenInfo *s, int depth, unsigned long rgb, unsigned l return rgb; } } - diff --git a/src/cmd/rio/cursor.c b/src/cmd/rio/cursor.c index 33f635224..3aff91bbc 100644 --- a/src/cmd/rio/cursor.c +++ b/src/cmd/rio/cursor.c @@ -16,15 +16,15 @@ typedef struct { Cursordata bigarrow = { 16, {0, 0}, - { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, - 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x3F, - 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, - 0xCF, 0x1F, 0x8F, 0x0F, 0x07, 0x07, 0x03, 0x02, + { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, + 0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x3F, + 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F, + 0xCF, 0x1F, 0x8F, 0x0F, 0x07, 0x07, 0x03, 0x02, }, - { 0x00, 0x00, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x0F, - 0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F, - 0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0x3F, 0xCE, 0x1F, - 0x86, 0x0F, 0x06, 0x07, 0x02, 0x02, 0x00, 0x00, + { 0x00, 0x00, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x0F, + 0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F, + 0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0x3F, 0xCE, 0x1F, + 0x86, 0x0F, 0x06, 0x07, 0x02, 0x02, 0x00, 0x00, } }; @@ -198,7 +198,7 @@ ScreenInfo *s; s->root_pixmap = XCreatePixmapFromBitmapData(dpy, s->root, grey_bits, grey_width, grey_height, s->black, s->white, s->depth); - + s->bordcurs[BorderN] = XCreateFontCursor(dpy, 138); s->bordcurs[BorderNNE] = XCreateFontCursor(dpy, 136); s->bordcurs[BorderENE] = s->bordcurs[BorderNNE] ; @@ -254,121 +254,121 @@ Cursor sightcursor = { Cursor whitearrow = { {0, 0}, - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, - 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, - 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, + 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF8, 0xFF, 0xFC, + 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFC, 0xF3, 0xF8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, }, - {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C, - 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C, - 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C, + {0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x06, 0xC0, 0x1C, + 0xC0, 0x30, 0xC0, 0x30, 0xC0, 0x38, 0xC0, 0x1C, + 0xC0, 0x0E, 0xC0, 0x07, 0xCE, 0x0E, 0xDF, 0x1C, 0xD3, 0xB8, 0xF1, 0xF0, 0xE0, 0xE0, 0xC0, 0x40, } }; Cursor query = { {-7,-7}, - {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, - 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, - 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, + {0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, + 0x7c, 0x7e, 0x78, 0x7e, 0x00, 0xfc, 0x01, 0xf8, + 0x03, 0xf0, 0x07, 0xe0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xc0, }, - {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, - 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, - 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, + {0x00, 0x00, 0x0f, 0xf0, 0x1f, 0xf8, 0x3c, 0x3c, + 0x38, 0x1c, 0x00, 0x3c, 0x00, 0x78, 0x00, 0xf0, + 0x01, 0xe0, 0x03, 0xc0, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } }; Cursor tl = { {-4, -4}, - {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff, - 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff, - 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + {0xfe, 0x00, 0x82, 0x00, 0x8c, 0x00, 0x87, 0xff, + 0xa0, 0x01, 0xb0, 0x01, 0xd0, 0x01, 0x11, 0xff, + 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x1f, 0x00, }, - {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00, - 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00, - 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + {0x00, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x78, 0x00, + 0x5f, 0xfe, 0x4f, 0xfe, 0x0f, 0xfe, 0x0e, 0x00, + 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x00, 0x00, } }; Cursor t = { {-7, -8}, - {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, - 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f, - 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, + {0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x06, 0xc0, + 0x1c, 0x70, 0x10, 0x10, 0x0c, 0x60, 0xfc, 0x7f, + 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, - 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x03, 0x80, + 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } }; Cursor tr = { {-11, -4}, - {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1, - 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88, - 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88, + {0x00, 0x7f, 0x00, 0x41, 0x00, 0x31, 0xff, 0xe1, + 0x80, 0x05, 0x80, 0x0d, 0x80, 0x0b, 0xff, 0x88, + 0x00, 0x88, 0x0, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0xf8, }, - {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e, - 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70, - 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + {0x00, 0x00, 0x00, 0x3e, 0x00, 0x0e, 0x00, 0x1e, + 0x7f, 0xfa, 0x7f, 0xf2, 0x7f, 0xf0, 0x00, 0x70, + 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, } }; Cursor r = { {-8, -7}, - {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58, - 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02, - 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58, + {0x07, 0xc0, 0x04, 0x40, 0x04, 0x40, 0x04, 0x58, + 0x04, 0x68, 0x04, 0x6c, 0x04, 0x06, 0x04, 0x02, + 0x04, 0x06, 0x04, 0x6c, 0x04, 0x68, 0x04, 0x58, 0x04, 0x40, 0x04, 0x40, 0x04, 0x40, 0x07, 0xc0, }, - {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, - 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc, - 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80, + {0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, + 0x03, 0x90, 0x03, 0x90, 0x03, 0xf8, 0x03, 0xfc, + 0x03, 0xf8, 0x03, 0x90, 0x03, 0x90, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, } }; Cursor br = { {-11, -11}, - {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, - 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, - 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05, + {0x00, 0xf8, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, + 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x88, + 0xff, 0x88, 0x80, 0x0b, 0x80, 0x0d, 0x80, 0x05, 0xff, 0xe1, 0x00, 0x31, 0x00, 0x41, 0x00, 0x7f, }, - {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, - 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, - 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa, + {0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + 0x0, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, + 0x00, 0x70, 0x7f, 0xf0, 0x7f, 0xf2, 0x7f, 0xfa, 0x00, 0x1e, 0x00, 0x0e, 0x00, 0x3e, 0x00, 0x00, } }; Cursor b = { {-7, -7}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, - 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, + 0xfc, 0x7f, 0x0c, 0x60, 0x10, 0x10, 0x1c, 0x70, 0x06, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, }, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, - 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, + 0x03, 0x80, 0x03, 0x80, 0x0f, 0xe0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } }; Cursor bl = { {-4, -11}, - {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, - 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, - 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01, + {0x1f, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, + 0x11, 0xff, 0xd0, 0x01, 0xb0, 0x01, 0xa0, 0x01, 0x87, 0xff, 0x8c, 0x00, 0x82, 0x00, 0xfe, 0x00, }, - {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, - 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, - 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe, + {0x00, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, 0x0e, 0x00, + 0x0e, 0x00, 0x0f, 0xfe, 0x4f, 0xfe, 0x5f, 0xfe, 0x78, 0x00, 0x70, 0x00, 0x7c, 0x00, 0x00, 0x0, } }; Cursor l = { {-7, -7}, - {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20, - 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20, - 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20, + {0x03, 0xe0, 0x02, 0x20, 0x02, 0x20, 0x1a, 0x20, + 0x16, 0x20, 0x36, 0x20, 0x60, 0x20, 0x40, 0x20, + 0x60, 0x20, 0x36, 0x20, 0x16, 0x20, 0x1a, 0x20, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x03, 0xe0, }, - {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, - 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, - 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0, + {0x00, 0x00, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, + 0x09, 0xc0, 0x09, 0xc0, 0x1f, 0xc0, 0x3f, 0xc0, + 0x1f, 0xc0, 0x09, 0xc0, 0x09, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x00, } }; diff --git a/src/cmd/rio/event.c b/src/cmd/rio/event.c index 0420c2bdc..0035cf34d 100644 --- a/src/cmd/rio/event.c +++ b/src/cmd/rio/event.c @@ -15,7 +15,7 @@ void mainloop(int shape_event) { XEvent ev; - + for(;;){ getevent(&ev); @@ -134,7 +134,7 @@ configurereq(XConfigureRequestEvent *e) c->dy = e->height; if(e->value_mask & CWBorderWidth) c->border = e->border_width; - + if(c->dx >= c->screen->width && c->dy >= c->screen->height) c->border = 0; else diff --git a/src/cmd/rio/grab.c b/src/cmd/rio/grab.c index 5aff69c81..85aa570c8 100644 --- a/src/cmd/rio/grab.c +++ b/src/cmd/rio/grab.c @@ -418,7 +418,7 @@ pullcalc(Client *c, int x, int y, BorderOrient bl, int init) c->dy = sy*(dy + 2*BORDER ); c->x = px; c->y = py; - + /* compensate position for size changed due to size hints */ if(spx) c->x -= c->dx - rdx; @@ -444,7 +444,7 @@ drawbound(Client *c, int drawing) ScreenInfo *s; if(debug) fprintf(stderr, "drawbound %d %dx%d+%d+%d\n", drawing, c->dx, c->dy, c->x, c->y); - + s = c->screen; x = c->x; y = c->y; @@ -466,7 +466,7 @@ drawbound(Client *c, int drawing) XUnmapWindow(dpy, s->sweepwin); return; } - + x += BORDER; y += BORDER; dx -= 2*BORDER; diff --git a/src/cmd/rio/key.c b/src/cmd/rio/key.c index 5bac17357..40740b054 100644 --- a/src/cmd/rio/key.c +++ b/src/cmd/rio/key.c @@ -64,4 +64,3 @@ alttab(int shift) shuffle(shift); /* fprintf(stderr, "%sTab\n", shift ? "Back" : ""); */ } - diff --git a/src/cmd/rio/main.c b/src/cmd/rio/main.c index 4bf87852e..1e0b37971 100644 --- a/src/cmd/rio/main.c +++ b/src/cmd/rio/main.c @@ -253,7 +253,7 @@ initscreen(ScreenInfo *s, int i, int background) s->min_cmaps = MinCmapsOfScreen(ScreenOfDisplay(dpy, i)); s->depth = DefaultDepth(dpy, i); - /* + /* * Figure out underlying screen format. */ if(XMatchVisualInfo(dpy, i, 16, TrueColor, &xvi) @@ -288,7 +288,7 @@ initscreen(ScreenInfo *s, int i, int background) s->vis = DefaultVisual(dpy, i); } if(DefaultDepth(dpy, i) != s->depth){ - s->def_cmap = XCreateColormap(dpy, s->root, s->vis, AllocNone); + s->def_cmap = XCreateColormap(dpy, s->root, s->vis, AllocNone); } ds = DisplayString(dpy); @@ -344,7 +344,7 @@ initscreen(ScreenInfo *s, int i, int background) attr.cursor = s->arrow; attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | ColormapChangeMask - | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask + | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask | KeyPressMask | EnterWindowMask; mask = CWCursor|CWEventMask; XChangeWindowAttributes(dpy, s->root, mask, &attr); diff --git a/src/cmd/rio/menu.c b/src/cmd/rio/menu.c index dc23f1c3b..e7a37c686 100644 --- a/src/cmd/rio/menu.c +++ b/src/cmd/rio/menu.c @@ -46,7 +46,7 @@ char *b2items[NUMVIRTUALS+1] = 0 }; -Menu b2menu = +Menu b2menu = { b2items }; @@ -116,7 +116,7 @@ button(XButtonEvent *e) e->x, e->y); XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw); - } + } switch (e->button){ case Button1: if(c){ @@ -132,7 +132,7 @@ button(XButtonEvent *e) XAllowEvents (dpy, ReplayPointer, curtime); } else if((e->state&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)){ menuhit(e, &egg); - } else if(numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1) + } else if(numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1) button2(n); return; case Button3: @@ -389,7 +389,7 @@ switch_to_c(int n, Client *c) int i; for(i = 0; i < numhidden; i++) - if(c == hiddenc[i]) + if(c == hiddenc[i]) break; if(i == numhidden){ @@ -397,7 +397,7 @@ switch_to_c(int n, Client *c) XMapWindow(dpy, c->parent); setstate(c, NormalState); if(currents[virt] == c) - active(c); + active(c); } } } @@ -421,6 +421,6 @@ switch_to(int n) void initb2menu(int n) -{ +{ b2items[n] = 0; } diff --git a/src/cmd/rio/printevent.c b/src/cmd/rio/printevent.c index 05cc5ad7b..927ea85f8 100644 --- a/src/cmd/rio/printevent.c +++ b/src/cmd/rio/printevent.c @@ -20,9 +20,9 @@ Archive-name: showevent/part01 There are times during debugging when it would be real useful to be able to -print the fields of an event in a human readable form. Too many times I found -myself scrounging around in section 8 of the Xlib manual looking for the valid -fields for the events I wanted to see, then adding printf's to display the +print the fields of an event in a human readable form. Too many times I found +myself scrounging around in section 8 of the Xlib manual looking for the valid +fields for the events I wanted to see, then adding printf's to display the numeric values of the fields, and then scanning through X.h trying to decode the cryptic detail and state fields. After playing with xev, I decided to write a couple of standard functions that I could keep in a library and call @@ -35,9 +35,9 @@ spend the time writing functions like this, they just want to have them when they need them. A simple, sample program is included which does little else but to demonstrate -the use of these two functions. These functions have saved me many an hour +the use of these two functions. These functions have saved me many an hour during debugging and I hope you find some benefit to these. If you have any -comments, suggestions, improvements, or if you find any blithering errors you +comments, suggestions, improvements, or if you find any blithering errors you can get it touch with me at the following location: ken@richsun.UUCP @@ -129,7 +129,7 @@ ServerTime(Time time) if(0) sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu", day, day == 1 ? "" : "(s)", hr, min, sec, msec); - + sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec); return (buffer); } @@ -770,7 +770,7 @@ VerbVisibility(XVisibilityEvent *ev) char *eventtype(XEvent *ev) { static char buffer[20]; - + switch (ev->type) { case KeyPress: return ("KeyPress"); @@ -983,4 +983,3 @@ void printevent(XEvent *e) break; } } - diff --git a/src/cmd/rio/showevent/sample.c b/src/cmd/rio/showevent/sample.c index 7b22e970e..9ad8c6390 100644 --- a/src/cmd/rio/showevent/sample.c +++ b/src/cmd/rio/showevent/sample.c @@ -45,4 +45,3 @@ char **argv; printf("\n\n"); } } - diff --git a/src/cmd/rio/xevents.c b/src/cmd/rio/xevents.c index d42ddbabf..c4d368d80 100644 --- a/src/cmd/rio/xevents.c +++ b/src/cmd/rio/xevents.c @@ -15,12 +15,12 @@ main(int argc, char **argv) Display *dpy; Window window; XEvent event; - + if (!(dpy = XOpenDisplay(""))) { printf("Failed to open display...\n"); exit(1); } - + screen = DefaultScreen(dpy); window = XCreateSimpleWindow(dpy, RootWindow(dpy, screen), 100, 100, @@ -42,4 +42,3 @@ main(int argc, char **argv) printevent(&event); } } - diff --git a/src/cmd/rio/xshove.c b/src/cmd/rio/xshove.c index 180eada41..e235874eb 100644 --- a/src/cmd/rio/xshove.c +++ b/src/cmd/rio/xshove.c @@ -55,7 +55,7 @@ void main(int argc, char **argv) { int screen; - + screen = 0; ARGBEGIN{ case 's': @@ -65,7 +65,7 @@ main(int argc, char **argv) usage(); break; }ARGEND - + dpy = XOpenDisplay(""); if(dpy == nil) sysfatal("open display: %r"); @@ -93,7 +93,7 @@ getproperty(Window w, Atom a) n = 100; p = nil; - XGetWindowProperty(dpy, w, a, 0, 100L, 0, + XGetWindowProperty(dpy, w, a, 0, 100L, 0, AnyPropertyType, &type, &fmt, &n, &dummy, &p); if(p == nil || *p == 0) @@ -132,7 +132,7 @@ getinfo(void) w = mallocz(nxwin*sizeof w[0], 1); if(w == 0) sysfatal("malloc: %r"); - + Win *ww = w; for(i=0; ix, ww->y, ww->x+ww->dx, ww->y+ww->dy); print("%08x %-20s %-10s %s\n", - (uint)ww->xw, + (uint)ww->xw, rect, ww->instance, ww->class); diff --git a/src/cmd/sam/cmd.c b/src/cmd/sam/cmd.c index 12510689d..386fe8d47 100644 --- a/src/cmd/sam/cmd.c +++ b/src/cmd/sam/cmd.c @@ -446,7 +446,7 @@ parsecmd(int nest) if(nextc() == 'g') cmd.flag = getch(); } - + } } } @@ -537,7 +537,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/sam/mesg.c b/src/cmd/sam/mesg.c index d9dd42ac5..2899f28ea 100644 --- a/src/cmd/sam/mesg.c +++ b/src/cmd/sam/mesg.c @@ -615,7 +615,7 @@ vlong invlong(void) { vlong v; - + v = (inp[7]<<24) | (inp[6]<<16) | (inp[5]<<8) | inp[4]; v = (v<<16) | (inp[3]<<8) | inp[2]; v = (v<<16) | (inp[1]<<8) | inp[0]; @@ -778,7 +778,7 @@ void outshort(int s) { *outp++ = s; - *outp++ = s>>8; + *outp++ = s>>8; } void diff --git a/src/cmd/sam/mesg.h b/src/cmd/sam/mesg.h index 234414998..0acf861c8 100644 --- a/src/cmd/sam/mesg.h +++ b/src/cmd/sam/mesg.h @@ -79,27 +79,27 @@ typedef struct Header{ /* * File transfer protocol schematic, a la Holzmann * #define N 6 - * + * * chan h = [4] of { mtype }; * chan t = [4] of { mtype }; - * + * * mtype = { Hgrow, Hdata, * Hcheck, Hcheck0, * Trequest, Tcheck, * }; - * + * * active proctype host() * { byte n; - * + * * do * :: n < N -> n++; t!Hgrow * :: n == N -> n++; t!Hcheck0 - * + * * :: h?Trequest -> t!Hdata * :: h?Tcheck -> t!Hcheck * od * } - * + * * active proctype term() * { * do @@ -118,14 +118,14 @@ typedef struct Header{ * From: gerard@research.bell-labs.com * Date: Tue Jul 17 13:47:23 EDT 2001 * To: rob@research.bell-labs.com - * + * * spin -c (or -a) spec * pcc -DNP -o pan pan.c * pan -l - * + * * proves that there are no non-progress cycles * (infinite executions *not* passing through * the statement marked with a label starting * with the prefix "progress") - * + * */ diff --git a/src/cmd/sam/moveto.c b/src/cmd/sam/moveto.c index 94fad3e7e..68207cd6f 100644 --- a/src/cmd/sam/moveto.c +++ b/src/cmd/sam/moveto.c @@ -170,4 +170,3 @@ doubleclick(File *f, Posn p1) while(--p >= 0 && alnum(filereadc(f, p))) f->dot.r.p1--; } - diff --git a/src/cmd/sam/plumb.h b/src/cmd/sam/plumb.h index d376acd0a..f11586217 100644 --- a/src/cmd/sam/plumb.h +++ b/src/cmd/sam/plumb.h @@ -14,4 +14,3 @@ char *plumbunpackattr(char*); char *plumbpack(Plumbmsg *, int *); int plumbfree(Plumbmsg *); char *cleanname(char*); - diff --git a/src/cmd/sam/rasp.c b/src/cmd/sam/rasp.c index 0bce4141d..c96101df6 100644 --- a/src/cmd/sam/rasp.c +++ b/src/cmd/sam/rasp.c @@ -337,4 +337,3 @@ rdata(List *r, Posn p1, Posn n) } return rg; } - diff --git a/src/cmd/sam/sam.c b/src/cmd/sam/sam.c index f180290bb..84e015f51 100644 --- a/src/cmd/sam/sam.c +++ b/src/cmd/sam/sam.c @@ -44,7 +44,7 @@ main(int _argc, char **_argv) char **volatile argv; String *t; char *termargs[10], **ap; - + argc = _argc; argv = _argv; ap = termargs; diff --git a/src/cmd/sam/unix.c b/src/cmd/sam/unix.c index a745a5bc3..97f2fce81 100644 --- a/src/cmd/sam/unix.c +++ b/src/cmd/sam/unix.c @@ -10,7 +10,7 @@ #include "sam.h" Rune samname[] = { '~', '~', 's', 'a', 'm', '~', '~', 0 }; - + static Rune l1[] = { '{', '[', '(', '<', 0253, 0}; static Rune l2[] = { '\n', 0}; static Rune l3[] = { '\'', '"', '`', 0}; @@ -85,15 +85,15 @@ getuser(void) return user; } -int -statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly) +int +statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly) { struct stat dirb; if (stat(name, &dirb) == -1) return -1; if (dev) - *dev = dirb.st_dev; + *dev = dirb.st_dev; if (id) *id = dirb.st_ino; if (time) @@ -110,11 +110,11 @@ statfd(int fd, ulong *dev, uvlong *id, long *time, long *length, long *appendonl { struct stat dirb; - if (fstat(fd, &dirb) == -1) + if (fstat(fd, &dirb) == -1) return -1; if (dev) *dev = dirb.st_dev; - if (id) + if (id) *id = dirb.st_ino; if (time) *time = dirb.st_mtime; @@ -174,11 +174,11 @@ tempdisk(void) int fd = temp_file(buf, sizeof buf); if (fd >= 0) remove(buf); - return fd; + return fd; } #undef waitfor -int +int samwaitfor(int pid) { int r; @@ -218,5 +218,3 @@ erealloc(void *p, ulong n) panic("realloc fails"); return p; } - - diff --git a/src/cmd/samterm/icons.c b/src/cmd/samterm/icons.c index 5ccd999ae..0b04d0b06 100644 --- a/src/cmd/samterm/icons.c +++ b/src/cmd/samterm/icons.c @@ -22,13 +22,13 @@ Cursor bullseye={ }; Cursor deadmouse={ {-7, -7}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x8E, 0x1D, 0xC7, - 0xFF, 0xE3, 0xFF, 0xF3, 0xFF, 0xFF, 0x7F, 0xFE, + 0xFF, 0xE3, 0xFF, 0xF3, 0xFF, 0xFF, 0x7F, 0xFE, 0x3F, 0xF8, 0x17, 0xF0, 0x03, 0xE0, 0x00, 0x00,}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x82, - 0x04, 0x41, 0xFF, 0xE1, 0x5F, 0xF1, 0x3F, 0xFE, + 0x04, 0x41, 0xFF, 0xE1, 0x5F, 0xF1, 0x3F, 0xFE, 0x17, 0xF0, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00,} }; Cursor lockarrow={ diff --git a/src/cmd/samterm/io.c b/src/cmd/samterm/io.c index 7c653aa48..e1dd148ad 100644 --- a/src/cmd/samterm/io.c +++ b/src/cmd/samterm/io.c @@ -170,7 +170,7 @@ waitforio(void) goto again; } got |= 1<name, "saturn") == 0){ drawdisc(scr, p->semidiam, 1, saturncolor, pt, "S"); - + return; } if(strcmp(p->name, "uranus") == 0){ drawdisc(scr, p->semidiam, 0, uranuscolor, pt, "U"); - + return; } if(strcmp(p->name, "neptune") == 0){ drawdisc(scr, p->semidiam, 0, neptunecolor, pt, "N"); - + return; } if(strcmp(p->name, "pluto") == 0){ drawdisc(scr, p->semidiam, 0, plutocolor, pt, "P"); - + return; } if(strcmp(p->name, "comet") == 0){ diff --git a/src/cmd/scat/scat.c b/src/cmd/scat/scat.c index 35b7e7aa0..dff596b17 100644 --- a/src/cmd/scat/scat.c +++ b/src/cmd/scat/scat.c @@ -531,7 +531,7 @@ alpha(char *s, char *t) if(strncmp(s, t, n)==0 && (s[n]<'a' || 'z' 0) { loc1 = subexp[0].s.rsp; diff --git a/src/cmd/sftpcache.c b/src/cmd/sftpcache.c index 3f8ea1655..b21e8a7e5 100644 --- a/src/cmd/sftpcache.c +++ b/src/cmd/sftpcache.c @@ -5,9 +5,9 @@ * * Stupid sftp bug: sftp invokes ssh, which always set O_NONBLOCK * on 0, 1, and 2. Ssh inherits sftp's 2, so we can't use the output pipe - * on fd 2, since it will get set O_NONBLOCK, sftp won't notice, and + * on fd 2, since it will get set O_NONBLOCK, sftp won't notice, and * writes will be lost. So instead we use a separate pipe for errors - * and consult it after each command. Assume the pipe buffer is + * and consult it after each command. Assume the pipe buffer is * big enough to hold the error output. */ #include @@ -35,7 +35,7 @@ Brd(Biobuf *bin) { static char buf[1000]; int c, tot; - + tot = 0; while((c = Bgetc(bin)) >= 0 && tot 0){ if(debug){ @@ -106,7 +106,7 @@ main(int argc, char **argv) char buf[200], cmd[1000], *q, *s; char dir[100], ndir[100]; int p[2], px[2], pe[2], pid, ctl, nctl, fd, n; - + notify(bell); fmtinstall('H', encodefmt); @@ -117,10 +117,10 @@ main(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1) usage(); - + if(pipe(p) < 0 || pipe(px) < 0 || pipe(pe) < 0) sysfatal("pipe: %r"); pid = fork(); @@ -169,7 +169,7 @@ main(int argc, char **argv) sysfatal("fork"); if(pid != 0) exits(nil); - + for(;;){ nctl = listen(dir, ndir); if(nctl < 0) @@ -215,4 +215,3 @@ main(int argc, char **argv) close(fd); } } - diff --git a/src/cmd/smugfs/a.h b/src/cmd/smugfs/a.h index fa65002d7..4b42f140a 100644 --- a/src/cmd/smugfs/a.h +++ b/src/cmd/smugfs/a.h @@ -187,4 +187,3 @@ enum }; extern int printerrors; - diff --git a/src/cmd/smugfs/cache.c b/src/cmd/smugfs/cache.c index 2adf8b9b6..afce6ba71 100644 --- a/src/cmd/smugfs/cache.c +++ b/src/cmd/smugfs/cache.c @@ -78,14 +78,14 @@ static void movetofront(Cache *c, CEntry *e) { popout(c, e); - insertfront(c, e); + insertfront(c, e); } static CEntry* evict(Cache *c) { CEntry *e; - + e = c->tail; popout(c, e); c->cefree(e); @@ -101,7 +101,7 @@ cachelookup(Cache *c, char *name, int create) { int h; CEntry *e; - + h = hash(name) % c->nhash; for(e=c->hash[h]; e; e=e->hash.next){ if(strcmp(name, e->name) == 0){ @@ -109,10 +109,10 @@ cachelookup(Cache *c, char *name, int create) return e; } } - + if(!create) return nil; - + if(c->nentry >= c->maxentry) e = evict(c); else{ @@ -124,7 +124,7 @@ cachelookup(Cache *c, char *name, int create) h = hash(name) % c->nhash; e->hash.next = c->hash[h]; c->hash[h] = e; - return e; + return e; } void @@ -132,7 +132,7 @@ cacheflush(Cache *c, char *substr) { CEntry **l, *e; int i; - + for(i=0; inhash; i++){ for(l=&c->hash[i]; (e=*l); ){ if(substr == nil || strstr(e->name, substr)){ diff --git a/src/cmd/smugfs/download.c b/src/cmd/smugfs/download.c index e23d49e14..82a2c753b 100644 --- a/src/cmd/smugfs/download.c +++ b/src/cmd/smugfs/download.c @@ -13,7 +13,7 @@ static void dfree(CEntry *ce) { DEntry *d; - + d = (DEntry*)ce; if(d->tmpfile){ remove(d->tmpfile); @@ -61,7 +61,7 @@ download(char *url, HTTPHeader *hdr) host = parseurl(url, &path); if(host == nil) return -1; - + d = (DEntry*)cachelookup(downloadcache, url, 1); if(d->tmpfile){ free(host); @@ -81,7 +81,7 @@ download(char *url, HTTPHeader *hdr) fmtprint(&fmt, "User-Agent: " USER_AGENT "\r\n"); fmtprint(&fmt, "\r\n"); req = fmtstrflush(&fmt); - + fprint(2, "Get %s\n", url); if(httptofile(&http, host, req, hdr, fd) < 0){ diff --git a/src/cmd/smugfs/fs.c b/src/cmd/smugfs/fs.c index a57b96d11..47e0a47b4 100644 --- a/src/cmd/smugfs/fs.c +++ b/src/cmd/smugfs/fs.c @@ -94,7 +94,7 @@ newupload(SmugFid *sf, char *name) Upload *u; int fd, i; char tmp[] = "/var/tmp/smugfs.XXXXXX"; - + if((fd = opentemp(tmp, ORDWR)) < 0) return nil; qlock(&uploadlock); @@ -192,7 +192,7 @@ getuploadname(SmugFid *sf, char *name) { int i; Upload *u; - + qlock(&uploadlock); for(i=0; ilength; free(d); - + memset(&ds, 0, sizeof ds); seek(u->fd, 0, 0); total = 0; @@ -306,7 +306,7 @@ doupload(Upload *u) fmtprint(&fmt, "X-Smug-FileName: %s\r\n", u->name); fmtprint(&fmt, "\r\n"); req = fmtstrflush(&fmt); - + seek(u->fd, 0, 0); jv = jsonupload(&http, UPLOAD_HOST, req, u->fd, datalen); free(req); @@ -330,7 +330,7 @@ nickindex(char *name) { int i; Json *v; - + for(i=0; iaux == nil) return nil; @@ -402,7 +402,7 @@ static Json* getcategories(SmugFid *sf) { Json *v, *w; - + v = smug("smugmug.categories.get", "NickName", nickname(sf->nickid), nil); w = jincref(jwalk(v, "Categories")); jclose(v); @@ -413,7 +413,7 @@ static Json* getcategorytree(SmugFid *sf) { Json *v, *w; - + v = smug("smugmug.users.getTree", "NickName", nickname(sf->nickid), nil); w = jincref(jwalk(v, "Categories")); jclose(v); @@ -425,7 +425,7 @@ getcategory(SmugFid *sf, vlong id) { int i; Json *v, *w; - + v = getcategorytree(sf); if(v == nil) return nil; @@ -446,7 +446,7 @@ getcategoryid(SmugFid *sf, char *name) int i; vlong id; Json *v; - + v = getcategories(sf); if(v == nil) return -1; @@ -470,7 +470,7 @@ getcategoryindex(SmugFid *sf, int i) { Json *v; vlong id; - + v = getcategories(sf); if(v == nil) return -1; @@ -510,7 +510,7 @@ getalbums(SmugFid *sf) "NickName", nickname(sf->nickid), nil); w = jincref(jwalk(v, "Albums")); jclose(v); - return w; + return w; } static vlong @@ -520,7 +520,7 @@ getalbumid(SmugFid *sf, char *name, char **keyp) vlong id; Json *v; char *key; - + v = getalbums(sf); if(v == nil) return -1; @@ -548,7 +548,7 @@ getalbumindex(SmugFid *sf, int i, char **keyp) vlong id; Json *v; char *key; - + v = getalbums(sf); if(v == nil) return -1; @@ -591,7 +591,7 @@ getimageid(SmugFid *sf, char *name, char **keyp) Json *v; char *p; char *key; - + id = strtol(name, &p, 10); if(*p != 0 || *name == 0) return -1; @@ -652,7 +652,7 @@ getimageindex(SmugFid *sf, int i, char **keyp) vlong id; Json *v; char *key; - + v = getimages(sf, sf->album, sf->albumkey); if(v == nil) return -1; @@ -677,7 +677,7 @@ categoryname(SmugFid *sf) { Json *v; char *s; - + v = getcategory(sf, sf->category); s = jstring(jwalk(v, "Name")); if(s) @@ -691,7 +691,7 @@ albumname(SmugFid *sf) { Json *v; char *s; - + v = getalbum(sf, sf->album, sf->albumkey); s = jstring(jwalk(v, "Title")); if(s) @@ -705,7 +705,7 @@ imagename(SmugFid *sf) { char *s; Json *v; - + v = getimageinfo(sf, sf->image, sf->imagekey); s = jstring(jwalk(v, "FileName")); if(s && s[0]) @@ -721,7 +721,7 @@ imagelength(SmugFid *sf) { vlong length; Json *v; - + v = getimageinfo(sf, sf->image, sf->imagekey); length = jint(jwalk(v, "Size")); jclose(v); @@ -763,7 +763,7 @@ imageurl(SmugFid *sf) return nil; } -static char* imagestrings[] = +static char* imagestrings[] = { "Caption", "LastUpdated", @@ -786,7 +786,7 @@ static char* imagestrings[] = "Album", }; -static char* albumbools[] = +static char* albumbools[] = { "Public", "Printable", @@ -810,7 +810,7 @@ static char* albumbools[] = "X3Larges", }; -static char* albumstrings[] = +static char* albumstrings[] = { "Description" "Keywords", @@ -866,7 +866,7 @@ readctl(SmugFid *sf) case Qimagectl: v = getimageinfo(sf, sf->image, sf->imagekey); break; - + case Qimageurl: v = getimageinfo(sf, sf->image, sf->imagekey); fmtstrinit(&fmt); @@ -875,11 +875,11 @@ readctl(SmugFid *sf) fmtprint(&fmt, "%s %s\n", urls[i].name, s); jclose(v); return fmtstrflush(&fmt); - + case Qimageexif: v = getimageexif(sf, sf->image, sf->imagekey); break; - + case Qalbumsettings: v = getalbum(sf, sf->album, sf->albumkey); fmtstrinit(&fmt); @@ -946,7 +946,7 @@ dostat(SmugFid *sf, Qid *qid, Dir *dir) char *uid; char *s; vlong length; - + memset(&q, 0, sizeof q); name = nil; freename = 0; @@ -1106,7 +1106,7 @@ xwalk1(Fid *fid, char *name, Qid *qid) SmugFid *sf; char *x; Upload *u; - + dotdot = strcmp(name, "..") == 0; sf = fid->aux; switch(sf->type){ @@ -1157,7 +1157,7 @@ xwalk1(Fid *fid, char *name, Qid *qid) break; } goto NotFound; - + case Qalbums: case Qcategory: if(dotdot){ @@ -1208,7 +1208,7 @@ xwalk1(Fid *fid, char *name, Qid *qid) break; } goto NotFound; - + case Qimage: if(dotdot){ free(sf->imagekey); @@ -1279,7 +1279,7 @@ dodirgen(int i, Dir *d, void *v) xsf.nickid = i; dostat(&xsf, nil, d); return 0; - + case Qnick: if(i-- == 0){ xsf.type = Qalbums; @@ -1292,7 +1292,7 @@ dodirgen(int i, Dir *d, void *v) xsf.category = id; dostat(&xsf, nil, d); return 0; - + case Qalbums: case Qcategory: if((id = getalbumindex(sf, i, &key)) < 0) @@ -1303,7 +1303,7 @@ dodirgen(int i, Dir *d, void *v) dostat(&xsf, nil, d); free(key); return 0; - + case Qalbum: if(i-- == 0){ xsf.type = Qalbumsettings; @@ -1325,7 +1325,7 @@ dodirgen(int i, Dir *d, void *v) dostat(&xsf, nil, d); free(key); return 0; - + case Qimage: if(i-- == 0){ xsf.type = Qimagefile; @@ -1394,13 +1394,13 @@ xwstat(Req *r) } } respond(r, "invalid wstat"); -} +} static void xattach(Req *r) { SmugFid *sf; - + sf = emalloc(sizeof *sf); r->fid->aux = sf; sf->type = Qroot; @@ -1430,7 +1430,7 @@ xopen(Req *r) case Qalbumsettings: case Qimagesettings: break; - + case Quploadfile: if(r->ifcall.mode != OREAD){ lock(&sf->upload->lk); @@ -1444,7 +1444,7 @@ xopen(Req *r) unlock(&sf->upload->lk); } break; - + default: if(r->ifcall.mode != OREAD){ respond(r, "permission denied"); @@ -1492,7 +1492,7 @@ xcreate(Req *r) dostat(sf, &r->ofcall.qid, nil); respond(r, nil); return; - + case Qcategory: // Create new album. if(!(r->ifcall.perm&DMDIR)) @@ -1500,7 +1500,7 @@ xcreate(Req *r) snprint(strid, sizeof strid, "%lld", sf->category); // Start with most restrictive settings. v = ncsmug("smugmug.albums.create", - "Title", r->ifcall.name, + "Title", r->ifcall.name, "CategoryID", strid, "Public", "0", "WorldSearchable", "0", @@ -1526,7 +1526,7 @@ xcreate(Req *r) dostat(sf, &r->ofcall.qid, nil); respond(r, nil); return; - + case Qalbum: // Upload image to album. if(r->ifcall.perm&DMDIR) @@ -1543,14 +1543,14 @@ xcreate(Req *r) respond(r, nil); return; } - respond(r, "permission denied"); + respond(r, "permission denied"); } static int writetofd(Req *r, int fd) { int total, n; - + total = 0; while(total < r->ifcall.count){ n = pwrite(fd, (char*)r->ifcall.data+total, r->ifcall.count-total, r->ifcall.offset+total); @@ -1580,7 +1580,7 @@ xread(Req *r) int fd; HTTPHeader hdr; char *url; - + sf = r->fid->aux; r->ofcall.count = 0; switch(sf->type){ @@ -1640,7 +1640,7 @@ xwrite(Req *r) Json *v; char strid[50]; SmugFid *sf; - + sf = r->fid->aux; r->ofcall.count = r->ifcall.count; sync = (r->ifcall.count==4 && memcmp(r->ifcall.data, "sync", 4) == 0); @@ -1660,7 +1660,7 @@ xwrite(Req *r) respond(r, nil); return; } - break; + break; case Qalbumsctl: case Qcategoryctl: jcacheflush("smugmug.categories.get"); @@ -1740,7 +1740,7 @@ xwrite(Req *r) } respond(r, "invalid control message"); return; -} +} void xremove(Req *r) @@ -1803,7 +1803,7 @@ xremove(Req *r) respond(r, nil); } return; - + case Qimage: snprint(id, sizeof id, "%lld", sf->image); v = ncsmug("smugmug.images.delete", @@ -1832,7 +1832,7 @@ Srv xsrv; void xinit(void) -{ +{ xsrv.attach = xattach; xsrv.open = xopen; xsrv.create = xcreate; diff --git a/src/cmd/smugfs/http.c b/src/cmd/smugfs/http.c index 9cf7f1d07..c6c117fca 100644 --- a/src/cmd/smugfs/http.c +++ b/src/cmd/smugfs/http.c @@ -21,7 +21,7 @@ parseheader(char *buf, int n, HTTPHeader *hdr) { int nline; char *data, *ebuf, *p, *q, *next; - + memset(hdr, 0, sizeof *hdr); ebuf = buf+n; data = haveheader(buf, n); @@ -78,7 +78,7 @@ parseheader(char *buf, int n, HTTPHeader *hdr) q++; strncpy(hdr->codedesc, q, sizeof hdr->codedesc); hdr->codedesc[sizeof hdr->codedesc-1] = 0; - continue; + continue; } q = strchr(p, ':'); if(q == nil) @@ -103,7 +103,7 @@ parseheader(char *buf, int n, HTTPHeader *hdr) memmove(buf, data, ebuf - data); return ebuf - data; -} +} static char* genhttp(Protocol *proto, char *host, char *req, HTTPHeader *hdr, int wfd, int rfd, vlong rtotal) @@ -131,7 +131,7 @@ genhttp(Protocol *proto, char *host, char *req, HTTPHeader *hdr, int wfd, int rf proto->close(fd); return nil; } - + if(rfd >= 0){ while(rtotal > 0){ m = sizeof buf; diff --git a/src/cmd/smugfs/icache.c b/src/cmd/smugfs/icache.c index 750f232c0..026aa59e8 100644 --- a/src/cmd/smugfs/icache.c +++ b/src/cmd/smugfs/icache.c @@ -30,7 +30,7 @@ icachefind(char *url) { int h; Icache *ic; - + h = hash(url) % NHASH; for(ic=icache.hash[h]; ic; ic=ic->hash){ if(strcmp(ic->url, url) == 0){ @@ -82,7 +82,7 @@ icacheinsert(char *url, HTTPHeader *hdr, char *file, int fd) ic = emalloc(sizeof *ic); icache.n++; } - + ic->url = estrdup(url); ic->fd = dup(fd, -1); ic->file = estrdup(file); @@ -103,7 +103,7 @@ void icacheflush(char *substr) { Icache **l, *ic; - + for(l=&icache.head; (ic=*l); ) { if(substr == nil || strstr(ic->url, substr)) { icache.n--; @@ -116,7 +116,7 @@ icacheflush(char *substr) }else l = &ic->next; } - + if(icache.head) { icache.head->prev = nil; for(ic=icache.head; ic; ic=ic->next){ @@ -168,4 +168,3 @@ urlfetch(char *url, HTTPHeader hdr) icacheinsert(url, &hdr, buf, fd); return fd; } - diff --git a/src/cmd/smugfs/json.c b/src/cmd/smugfs/json.c index d6472b4db..c79c189c7 100644 --- a/src/cmd/smugfs/json.c +++ b/src/cmd/smugfs/json.c @@ -22,7 +22,7 @@ static Json* newjval(int type) { Json *v; - + v = emalloc(sizeof *v); v->ref = 1; v->type = type; @@ -142,7 +142,7 @@ parsenumber(char **pp) double d; Json *v; - /* -?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?([Ee][-+]?[0-9]+) */ + /* -?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))?([Ee][-+]?[0-9]+) */ p = wskip(*pp); q = p; if(*q == '-') @@ -171,7 +171,7 @@ parsenumber(char **pp) while('0' <= *q && *q <= '9') q++; } - + t = emalloc(q-p+1); memmove(t, p, q-p); t[q-p] = 0; @@ -185,7 +185,7 @@ parsenumber(char **pp) v = newjval(Jnumber); v->number = d; *pp = q; - return v; + return v; } static Json* @@ -335,7 +335,7 @@ Json* parsejson(char *text) { Json *v; - + v = parsevalue(&text); if(v && text && *wskip(text) != 0){ jclose(v); @@ -417,7 +417,7 @@ printjval(Json *v) { Fmt fmt; char buf[256]; - + fmtfdinit(&fmt, 1, buf, sizeof buf); _printjval(&fmt, v, 0); fmtprint(&fmt, "\n"); @@ -429,7 +429,7 @@ int jsonfmt(Fmt *fmt) { Json *v; - + v = va_arg(fmt->args, Json*); if(fmt->flags&FmtSharp) _printjval(fmt, v, 0); @@ -484,7 +484,7 @@ Json* jlookup(Json *v, char *name) { int i; - + if(v->type != Jobject) return nil; for(i=0; ilen; i++) @@ -498,7 +498,7 @@ jwalk(Json *v, char *path) { char elem[128], *p, *next; int n; - + for(p=path; *p && v; p=next){ next = strchr(p, '/'); if(next == nil) @@ -547,7 +547,7 @@ int jstrcmp(Json *jv, char *s) { char *t; - + t = jstring(jv); if(t == nil) return -2; diff --git a/src/cmd/smugfs/jsonrpc.c b/src/cmd/smugfs/jsonrpc.c index 92490e775..f0043bb39 100644 --- a/src/cmd/smugfs/jsonrpc.c +++ b/src/cmd/smugfs/jsonrpc.c @@ -17,7 +17,7 @@ static void jfree(CEntry *ce) { JEntry *j; - + j = (JEntry*)ce; jclose(j->reply); } @@ -45,7 +45,7 @@ static char* makehttprequest(char *host, char *path, char *postdata) { Fmt fmt; - + fmtstrinit(&fmt); fmtprint(&fmt, "POST %s HTTP/1.0\r\n", path); fmtprint(&fmt, "Host: %s\r\n", host); @@ -87,7 +87,7 @@ dojsonhttp(Protocol *proto, char *host, char *request, int rfd, vlong rlength) { char *data; HTTPHeader hdr; - + data = httpreq(proto, host, request, &hdr, rfd, rlength); if(data == nil){ fprint(2, "httpreq: %r\n"); @@ -184,7 +184,7 @@ ncsmug(char *method, char *name1, ...) { Json *jv; va_list arg; - + va_start(arg, name1); // TODO: Could use https only for login. jv = jsonrpc(&https, HOST, PATH, method, name1, arg, 0); @@ -198,7 +198,7 @@ smug(char *method, char *name1, ...) { Json *jv; va_list arg; - + va_start(arg, name1); jv = jsonrpc(&http, HOST, PATH, method, name1, arg, 1); va_end(arg); @@ -241,4 +241,3 @@ jsonupload(Protocol *proto, char *host, char *req, int rfd, vlong rlength) jclose(jv); return nil; } - diff --git a/src/cmd/smugfs/log.c b/src/cmd/smugfs/log.c index 5603211e3..5e2f015a2 100644 --- a/src/cmd/smugfs/log.c +++ b/src/cmd/smugfs/log.c @@ -117,4 +117,3 @@ rpclog(char *fmt, ...) lbvappend(&rpclogbuf, fmt, arg); va_end(arg); } - diff --git a/src/cmd/smugfs/main.c b/src/cmd/smugfs/main.c index 6be0ca42d..e1c2745f6 100644 --- a/src/cmd/smugfs/main.c +++ b/src/cmd/smugfs/main.c @@ -32,7 +32,7 @@ smuglogin(void) nil); if(v == nil) sysfatal("login failed: %r"); - + memset(up->user, 'X', strlen(up->user)); memset(up->passwd, 'X', strlen(up->passwd)); free(up); @@ -80,13 +80,13 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 0) usage(); if(name == nil && mtpt == nil) mtpt = "/n/smug"; - + /* * Check twice -- if there is an exited smugfs instance * mounted there, the first access will fail but unmount it. diff --git a/src/cmd/smugfs/openssl.c b/src/cmd/smugfs/openssl.c index baccd3acd..01b169c8e 100644 --- a/src/cmd/smugfs/openssl.c +++ b/src/cmd/smugfs/openssl.c @@ -39,10 +39,10 @@ opensslconnect(char *host) sbio = BIO_new_ssl_connect(ctx); BIO_get_ssl(sbio, &ssl); SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); - + snprint(buf, sizeof buf, "%s:https", host); BIO_set_conn_hostname(sbio, buf); - + if(BIO_do_connect(sbio) <= 0 || BIO_do_handshake(sbio) <= 0){ ERR_error_string_n(ERR_get_error(), buf, sizeof buf); BIO_free_all(sbio); @@ -69,7 +69,7 @@ opensslwrite(Pfd *pfd, void *v, int n) { int m, total; char *p; - + p = v; total = 0; while(total < n){ @@ -80,7 +80,7 @@ opensslwrite(Pfd *pfd, void *v, int n) } total += m; } - return total; + return total; } static int diff --git a/src/cmd/smugfs/tcp.c b/src/cmd/smugfs/tcp.c index a203ece93..b8b951127 100644 --- a/src/cmd/smugfs/tcp.c +++ b/src/cmd/smugfs/tcp.c @@ -47,4 +47,3 @@ Protocol http = { httpwrite, httpclose, }; - diff --git a/src/cmd/smugfs/util.c b/src/cmd/smugfs/util.c index b4a649d83..90a12cb9a 100644 --- a/src/cmd/smugfs/util.c +++ b/src/cmd/smugfs/util.c @@ -4,7 +4,7 @@ void* emalloc(int n) { void *v; - + v = mallocz(n, 1); if(v == nil) sysfatal("out of memory"); @@ -34,9 +34,9 @@ timefmt(Fmt *f) { Tm tm; vlong ms; - + ms = nsec()/1000000; - + tm = *localtime(ms/1000); fmtprint(f, "%02d:%02d:%02d.%03d", tm.hour, tm.min, tm.sec, @@ -64,7 +64,7 @@ urlencodefmt(Fmt *fmt) { int x; char *s; - + s = va_arg(fmt->args, char*); for(; *s; s++){ x = (uchar)*s; @@ -78,4 +78,3 @@ urlencodefmt(Fmt *fmt) } return 0; } - diff --git a/src/cmd/snarfer/osx-cocoa-snarfer.c b/src/cmd/snarfer/osx-cocoa-snarfer.c index 20f5b6ad1..613a8cc51 100644 --- a/src/cmd/snarfer/osx-cocoa-snarfer.c +++ b/src/cmd/snarfer/osx-cocoa-snarfer.c @@ -1,2 +1 @@ #include "snarfer.c" - diff --git a/src/cmd/snarfer/osx-snarfer.c b/src/cmd/snarfer/osx-snarfer.c index 20f5b6ad1..613a8cc51 100644 --- a/src/cmd/snarfer/osx-snarfer.c +++ b/src/cmd/snarfer/osx-snarfer.c @@ -1,2 +1 @@ #include "snarfer.c" - diff --git a/src/cmd/snarfer/snarfer.c b/src/cmd/snarfer/snarfer.c index 9477f0420..d09b2f44b 100644 --- a/src/cmd/snarfer/snarfer.c +++ b/src/cmd/snarfer/snarfer.c @@ -89,7 +89,7 @@ void main(int argc, char **argv) { XEvent xevent; - + ARGBEGIN{ default: usage(); @@ -100,14 +100,14 @@ main(int argc, char **argv) if((xdisplay = XOpenDisplay(nil)) == nil) sysfatal("XOpenDisplay: %r"); - drawable = XCreateWindow(xdisplay, DefaultRootWindow(xdisplay), - 0, 0, 1, 1, 0, 0, - InputOutput, DefaultVisual(xdisplay, DefaultScreen(xdisplay)), + drawable = XCreateWindow(xdisplay, DefaultRootWindow(xdisplay), + 0, 0, 1, 1, 0, 0, + InputOutput, DefaultVisual(xdisplay, DefaultScreen(xdisplay)), 0, 0); if(drawable == None) sysfatal("XCreateWindow: %r"); XFlush(xdisplay); - + xclipboard = XInternAtom(xdisplay, "CLIPBOARD", False); xutf8string = XInternAtom(xdisplay, "UTF8_STRING", False); xtargets = XInternAtom(xdisplay, "TARGETS", False); @@ -122,7 +122,7 @@ main(int argc, char **argv) xgetsnarf(); appleputsnarf(); xputsnarf(); - + for(;;){ XNextEvent(xdisplay, &xevent); switch(xevent.type){ @@ -150,9 +150,9 @@ xselectionrequest(XEvent *e) XEvent r; XSelectionRequestEvent *xe; XDisplay *xd; - + xd = xdisplay; - + memset(&r, 0, sizeof r); xe = (XSelectionRequestEvent*)e; if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d\n", @@ -198,7 +198,7 @@ xgetsnarf(void) int fmt, i; XWindow w; XDisplay *xd; - + xd = xdisplay; w = None; @@ -229,7 +229,7 @@ xgetsnarf(void) */ if(w == None) return nil; - + /* * We should be waiting for SelectionNotify here, but it might never * come, and we have no way to time out. Instead, we will clear @@ -256,7 +256,7 @@ xgetsnarf(void) return nil; /* get the property */ data = nil; - XGetWindowProperty(xd, drawable, prop, 0, SnarfSize/sizeof(ulong), 0, + XGetWindowProperty(xd, drawable, prop, 0, SnarfSize/sizeof(ulong), 0, AnyPropertyType, &type, &fmt, &len, &dummy, &xdata); if(xdata == nil || (type != XA_STRING && type != xutf8string) || len == 0){ if(xdata) @@ -297,7 +297,7 @@ appleputsnarf(void) fprint(2, "apple pasteboard cannot assert ownership\n"); return; } - cfdata = CFDataCreate(kCFAllocatorDefault, + cfdata = CFDataCreate(kCFAllocatorDefault, (uchar*)rsnarf, runestrlen(rsnarf)*2); if(cfdata == nil){ fprint(2, "apple pasteboard cfdatacreate failed\n"); @@ -312,5 +312,3 @@ appleputsnarf(void) CFRelease(cfdata); #endif } - - diff --git a/src/cmd/spell/code.h b/src/cmd/spell/code.h index 73fff2e2b..35b59804e 100644 --- a/src/cmd/spell/code.h +++ b/src/cmd/spell/code.h @@ -4,7 +4,7 @@ */ #define ED (1<<0) /* +ed, +ing */ -#define ADJ (1<<1) /* (nce)-t_ce, +ize,+al, +ness, -t+cy, +ity, +ly */ +#define ADJ (1<<1) /* (nce)-t_ce, +ize,+al, +ness, -t+cy, +ity, +ly */ #define NOUN (1<<2) /* +s (+es), +make, +hood, +ship +less */ #define PROP_COLLECT (1<<3) /* +'s, +an, +ship(for -manship) +less */ #define ACTOR (1<<4) /* +er */ @@ -15,7 +15,7 @@ #define N_AFFIX (1<<8) /* +ic, +ive, +ize, +like, +al, +ful, +ism, +ist, -t+cy, +c (maniac) */ #define V_AFFIX (1<<9) /* +able, +ive, +ity((bility), +ment */ #define V_IRREG (1<<10) /* +ing +es +s*/ -#define VERB (V_IRREG|ED) +#define VERB (V_IRREG|ED) #define MAN (1<<11) /* +man, +men, +women, +woman */ #define ADV (1<<12) /* +hood, +ness */ #define STOP (1<<14) /* stop list */ diff --git a/src/cmd/spell/sprog.c b/src/cmd/spell/sprog.c index 6eaa026f8..1627829c0 100644 --- a/src/cmd/spell/sprog.c +++ b/src/cmd/spell/sprog.c @@ -580,7 +580,7 @@ main(int argc, char *argv[]) print("-"); else if(!vflag) print("+"); - else + else print("%c",'0' + (suffcount>0) + (prefcount>4? 8: 2*prefcount)); } else if(!h || Set(h,STOP)) { @@ -1122,7 +1122,7 @@ dict(char* bp, char* ep) loop: if(bp >= ep) { - if(xflag) + if(xflag) fprint(2, "=%.*s\n", utfnlen(w, n), w); return 0; } diff --git a/src/cmd/split.c b/src/cmd/split.c index e758786ce..14d55ef74 100644 --- a/src/cmd/split.c +++ b/src/cmd/split.c @@ -97,7 +97,7 @@ main(int argc, char *argv[]) } /* - * in case we didn't end with a newline, tack whatever's + * in case we didn't end with a newline, tack whatever's * left onto the last file */ while((n = Bread(b, buf, sizeof(buf))) > 0) @@ -119,7 +119,7 @@ nextfile(void) } else { strcpy(name, stem); strcat(name, suff); - if(++suff[1] > 'z') + if(++suff[1] > 'z') suff[1] = 'a', ++suff[0]; openf(); } @@ -135,7 +135,7 @@ matchfile(Resub *match) strcpy(name+len, suffix); openf(); return 1; - } + } return nextfile(); } diff --git a/src/cmd/srv.c b/src/cmd/srv.c index e53c99c88..c4e79cc44 100644 --- a/src/cmd/srv.c +++ b/src/cmd/srv.c @@ -30,7 +30,7 @@ threadmain(int argc, char **argv) fmtinstall('F', fcallfmt); fmtinstall('M', dirmodefmt); - + ARGBEGIN{ case 'D': debug = 1; @@ -51,7 +51,7 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1 && argc != 2) usage(); @@ -80,7 +80,7 @@ do9p(Fcall *tx, Fcall *rx) static uchar buf[9000]; static char ebuf[200]; int n; - + n = convS2M(tx, buf, sizeof buf); if(n == BIT16SZ){ werrstr("convS2M failed"); @@ -133,7 +133,7 @@ xauth(void) if(rx.type == Rerror) sysfatal("Tversion: %s", rx.ename); msize = rx.msize; - + tx.type = Tauth; tx.tag = 1; tx.afid = afid; @@ -154,7 +154,7 @@ int xread(void *buf, int n) { Fcall tx, rx; - + tx.type = Tread; tx.tag = 1; tx.fid = 0; /* afid above */ @@ -165,7 +165,7 @@ xread(void *buf, int n) werrstr("%s", rx.ename); return -1; } - + if(rx.count > n){ werrstr("too much data returned"); return -1; @@ -178,7 +178,7 @@ int xwrite(void *buf, int n) { Fcall tx, rx; - + tx.type = Twrite; tx.tag = 1; tx.fid = 0; /* afid above */ @@ -354,4 +354,3 @@ xauth_proxy(AuthGetkey *getkey, char *fmt, ...) auth_freerpc(rpc); return ai; } - diff --git a/src/cmd/strings.c b/src/cmd/strings.c index 6e7748baa..1fdbec1d3 100644 --- a/src/cmd/strings.c +++ b/src/cmd/strings.c @@ -69,7 +69,7 @@ stringit(char *str) } start = 0; cnt = 0; - } + } posn = Boffset(fin); } diff --git a/src/cmd/svgpic/arcgen.c b/src/cmd/svgpic/arcgen.c index bec41e47a..4cb16957b 100644 --- a/src/cmd/svgpic/arcgen.c +++ b/src/cmd/svgpic/arcgen.c @@ -221,4 +221,3 @@ quadrant(double x, double y) else if( x> 0.0 && y<=0.0) return(4); else return 0; /* shut up lint */ } - diff --git a/src/cmd/svgpic/linegen.c b/src/cmd/svgpic/linegen.c index e0db5fc6c..bc7e93351 100644 --- a/src/cmd/svgpic/linegen.c +++ b/src/cmd/svgpic/linegen.c @@ -225,7 +225,7 @@ obj *linegen(int type) extreme(ex, ey); nx = xi; ny = yi; } - + } p->o_ddval = ddval; if (dbg) { diff --git a/src/cmd/svgpic/misc.c b/src/cmd/svgpic/misc.c index e888fafc8..1e2db1b52 100644 --- a/src/cmd/svgpic/misc.c +++ b/src/cmd/svgpic/misc.c @@ -34,7 +34,7 @@ curdir(void) /* convert current dir (hvmode) to RIGHT, LEFT, etc. */ return 0; } -double +double getcomp(obj *p, int t) /* return component of a position */ { switch (t) { diff --git a/src/cmd/svgpic/plsvg.c b/src/cmd/svgpic/plsvg.c index 7f6db9d49..575dc356f 100644 --- a/src/cmd/svgpic/plsvg.c +++ b/src/cmd/svgpic/plsvg.c @@ -232,7 +232,7 @@ void arrow(double x0, double y0, double x1, double y1, double w, double h, if(i == 1) printf("M %.3f %.3f L %.3f %.3f", xconv(x1+dx), yconv(y1+dy), xconv(x1), yconv(y1)); else - printf(" L %.3f %.3f", xconv(x1+dx), yconv(y1+dy)); + printf(" L %.3f %.3f", xconv(x1+dx), yconv(y1+dy)); } if (nhead > 2) printf(" Z"); diff --git a/src/cmd/tail.c b/src/cmd/tail.c index b40552bfd..68f7c5eb8 100644 --- a/src/cmd/tail.c +++ b/src/cmd/tail.c @@ -343,9 +343,9 @@ getnumber(char *s) if(count < 0 || (int)count != count) fatal("too big"); return 1; -} +} -void +void fatal(char *s) { char buf[ERRMAX]; diff --git a/src/cmd/tapefs/32vfs.c b/src/cmd/tapefs/32vfs.c index 1d917f82c..af5f52003 100644 --- a/src/cmd/tapefs/32vfs.c +++ b/src/cmd/tapefs/32vfs.c @@ -177,7 +177,7 @@ iget(int ino) if ((flags&VFMT)==VIFDIR) f.mode |= DMDIR; f.uid = g2byte(dp->uid); - f.gid = g2byte(dp->gid); + f.gid = g2byte(dp->gid); f.mdate = g4byte(dp->mtime); return f; } diff --git a/src/cmd/tapefs/util.c b/src/cmd/tapefs/util.c index 199235f38..a166dcd0f 100644 --- a/src/cmd/tapefs/util.c +++ b/src/cmd/tapefs/util.c @@ -34,7 +34,7 @@ getpass(char *file) up[nid].id = atoi(line[2]); up[nid].name = strdup(line[0]); nid++; - } + } Bterm(bp); up[nid].name = 0; return up; diff --git a/src/cmd/tapefs/v10fs.c b/src/cmd/tapefs/v10fs.c index c2875b845..0b695dba1 100644 --- a/src/cmd/tapefs/v10fs.c +++ b/src/cmd/tapefs/v10fs.c @@ -168,7 +168,7 @@ iget(int ino) if ((flags&VFMT)==VIFDIR) f.mode |= DMDIR; f.uid = g2byte(dp->uid); - f.gid = g2byte(dp->gid); + f.gid = g2byte(dp->gid); f.mdate = g4byte(dp->mtime); return f; } diff --git a/src/cmd/tapefs/v6fs.c b/src/cmd/tapefs/v6fs.c index 74c6737c7..43de410c1 100644 --- a/src/cmd/tapefs/v6fs.c +++ b/src/cmd/tapefs/v6fs.c @@ -169,7 +169,7 @@ iget(int ino) if ((flags&V6FMT)==V6IFDIR) f.mode |= DMDIR; f.uid = dp->uid; - f.gid = dp->gid; + f.gid = dp->gid; f.mdate = (dp->mtime[2]<<0) + (dp->mtime[3]<<8) +(dp->mtime[0]<<16) + (dp->mtime[1]<<24); return f; diff --git a/src/cmd/tapefs/zipfs.c b/src/cmd/tapefs/zipfs.c index e9354f7b4..8725e0c94 100644 --- a/src/cmd/tapefs/zipfs.c +++ b/src/cmd/tapefs/zipfs.c @@ -154,7 +154,7 @@ doread(Ram *r, vlong off, long cnt) sysfatal("%d - unsupported compression method", zh.meth); break; } - + return buf; } @@ -382,4 +382,3 @@ msdos2time(int time, int date) return tm2sec(&tm); } - diff --git a/src/cmd/tar.c b/src/cmd/tar.c index 934fba9d9..61e9c4a63 100644 --- a/src/cmd/tar.c +++ b/src/cmd/tar.c @@ -98,7 +98,7 @@ typedef struct Hdr { char devmajor[8]; char devminor[8]; char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */ - + char pad[12]; } Hdr; diff --git a/src/cmd/tbl/t1.c b/src/cmd/tbl/t1.c index 1e6cbf114..6cb7ada10 100644 --- a/src/cmd/tbl/t1.c +++ b/src/cmd/tbl/t1.c @@ -41,7 +41,7 @@ setinp(int argc, char **argv) { sargc = argc; sargv = argv; - sargc--; + sargc--; sargv++; if (sargc > 0) swapin(); @@ -69,10 +69,10 @@ swapin(void) pr1403 = 1; if (match("-", *sargv)) break; - sargc--; + sargc--; sargv++; } - if (sargc <= 0) + if (sargc <= 0) return(0); /* file closing is done by GCOS troff preprocessor */ if(tabin) diff --git a/src/cmd/tbl/t2.c b/src/cmd/tbl/t2.c index 6d2d7414a..c3ecce7d9 100644 --- a/src/cmd/tbl/t2.c +++ b/src/cmd/tbl/t2.c @@ -21,5 +21,3 @@ tableput(void) freearr(); restline(); } - - diff --git a/src/cmd/tbl/t3.c b/src/cmd/tbl/t3.c index a4dc9f9f5..f2f81309e 100644 --- a/src/cmd/tbl/t3.c +++ b/src/cmd/tbl/t3.c @@ -1,7 +1,7 @@ /* t3.c: interpret commands affecting whole table */ # include "t.h" struct optstr { - char *optnam; + char *optnam; int *optadd; } options [] = { "expand", &expflg, @@ -46,7 +46,7 @@ getcomm(void) return; } for (cp = line; (c = *cp) != ';'; cp++) { - if (!letter(c)) + if (!letter(c)) continue; found = 0; for (lp = options; lp->optadd; lp++) { @@ -61,9 +61,9 @@ getcomm(void) if ( *cp == '(') while ((ci = *++cp) != ')') *t++ = ci; - else + else cp--; - *t++ = 0; + *t++ = 0; *t = 0; if (lp->optadd == &tab) { if (nb[0]) @@ -100,5 +100,3 @@ backrest(char *cp) un1getc(*--s); return; } - - diff --git a/src/cmd/tbl/t4.c b/src/cmd/tbl/t4.c index 558d3ba3a..21fd82c67 100644 --- a/src/cmd/tbl/t4.c +++ b/src/cmd/tbl/t4.c @@ -53,13 +53,13 @@ readspec(void) case ' ': /* note this is also case tab */ continue; case '\n': - if (sawchar == 0) + if (sawchar == 0) continue; case ',': case '.': /* end of table specification */ ncol = max(ncol, icol); if (lefline[ncol][nclin] > 0) { - ncol++; + ncol++; rightl++; }; if (sawchar) @@ -85,24 +85,24 @@ readspec(void) } sawchar = 0; continue; - case 'C': - case 'S': - case 'R': - case 'N': - case 'L': + case 'C': + case 'S': + case 'R': + case 'N': + case 'L': case 'A': c += ('a' - 'A'); - case '_': - if (c == '_') + case '_': + if (c == '_') c = '-'; - case '=': + case '=': case '-': case '^': - case 'c': - case 's': - case 'n': - case 'r': - case 'l': + case 'c': + case 's': + case 'n': + case 'r': + case 'l': case 'a': style[icol][nclin] = c; if (c == 's' && icol <= 0) @@ -122,30 +122,30 @@ readspec(void) error("too many columns in table"); sawchar = 1; continue; - case 'b': + case 'b': case 'i': c += 'A' - 'a'; - case 'B': + case 'B': case 'I': - if (icol == 0) + if (icol == 0) continue; snp = font[icol-1][nclin]; snp[0] = (c == 'I' ? '2' : '3'); snp[1] = 0; continue; - case 't': + case 't': case 'T': if (icol > 0) flags[icol-1][nclin] |= CTOP; continue; - case 'd': + case 'd': case 'D': if (icol > 0) flags[icol-1][nclin] |= CDOWN; continue; - case 'f': + case 'f': case 'F': - if (icol == 0) + if (icol == 0) continue; snp = font[icol-1][nclin]; snp[0] = snp[1] = stopc = 0; @@ -155,34 +155,34 @@ readspec(void) stopc = ')'; c = get1char(); } - if (c == 0) + if (c == 0) break; if (c == stopc) { - stopc = 0; + stopc = 0; break; } - if (stopc == 0) - if (c == ' ' || c == tab ) + if (stopc == 0) + if (c == ' ' || c == tab ) break; if (c == '\n' || c == '|') { - un1getc(c); + un1getc(c); break; } snp[i] = c; - if (c >= '0' && c <= '9') + if (c >= '0' && c <= '9') break; } - if (stopc) + if (stopc) if (get1char() != stopc) error("Nonterminated font name"); continue; - case 'P': + case 'P': case 'p': - if (icol <= 0) + if (icol <= 0) continue; temp = snp = csize[icol-1][nclin]; while (c = get1char()) { - if (c == ' ' || c == tab || c == '\n') + if (c == ' ' || c == tab || c == '\n') break; if (c == '-' || c == '+') if (snp > temp) @@ -191,7 +191,7 @@ readspec(void) *snp++ = c; else if (digit(c)) *snp++ = c; - else + else break; if (snp - temp > 4) error("point size too large"); @@ -201,13 +201,13 @@ readspec(void) error("point size unreasonable"); un1getc (c); continue; - case 'V': + case 'V': case 'v': - if (icol <= 0) + if (icol <= 0) continue; temp = snp = vsize[icol-1][nclin]; while (c = get1char()) { - if (c == ' ' || c == tab || c == '\n') + if (c == ' ' || c == tab || c == '\n') break; if (c == '-' || c == '+') if (snp > temp) @@ -216,7 +216,7 @@ readspec(void) *snp++ = c; else if (digit(c)) *snp++ = c; - else + else break; if (snp - temp > 4) error("vertical spacing value too large"); @@ -224,7 +224,7 @@ readspec(void) *snp = 0; un1getc(c); continue; - case 'w': + case 'w': case 'W': snp = cll [icol-1]; /* Dale Smith didn't like this check - possible to have two text blocks @@ -253,34 +253,34 @@ readspec(void) if (!stopc) un1getc(c); continue; - case 'e': + case 'e': case 'E': - if (icol < 1) + if (icol < 1) continue; evenup[icol-1] = 1; evenflg = 1; continue; - case 'z': + case 'z': case 'Z': /* zero width-ignre width this item */ - if (icol < 1) + if (icol < 1) continue; flags[icol-1][nclin] |= ZEROW; continue; - case 'u': + case 'u': case 'U': /* half line up */ - if (icol < 1) + if (icol < 1) continue; flags[icol-1][nclin] |= HALFUP; continue; - case '0': - case '1': - case '2': - case '3': + case '0': + case '1': + case '2': + case '3': case '4': - case '5': - case '6': - case '7': - case '8': + case '5': + case '6': + case '7': + case '8': case '9': sn[0] = c; snp = sn + 1; @@ -291,7 +291,7 @@ readspec(void) continue; case '|': lefline[icol][nclin]++; - if (icol == 0) + if (icol == 0) left1flg = 1; continue; } @@ -313,9 +313,9 @@ findcol(void) if (c != '\n') un1getc(c); for (s = line; *s = c = get1char(); s++) { - if (c == ')') + if (c == ')') inpar = 0; - if (inpar) + if (inpar) continue; if (c == '\n' || c == 0 || c == '.' || c == ',') break; @@ -326,20 +326,20 @@ findcol(void) } for (p = line; p < s; p++) switch (*p) { - case 'l': - case 'r': - case 'c': - case 'n': - case 'a': + case 'l': + case 'r': + case 'c': + case 'n': + case 'a': case 's': - case 'L': - case 'R': - case 'C': - case 'N': - case 'A': + case 'L': + case 'R': + case 'C': + case 'N': + case 'A': case 'S': - case '-': - case '=': + case '-': + case '=': case '_': n++; } @@ -401,5 +401,3 @@ freearr(void) free(acase); free(topat); } - - diff --git a/src/cmd/tbl/t5.c b/src/cmd/tbl/t5.c index e23784be2..c50077e7c 100644 --- a/src/cmd/tbl/t5.c +++ b/src/cmd/tbl/t5.c @@ -28,7 +28,7 @@ gettbl(void) while (*cstore++) ; continue; - } else + } else instead[nlin] = 0; if (nodata(nlin)) { if (ch = oneh(nlin)) @@ -46,11 +46,11 @@ gettbl(void) table[nlin] = (struct colstr *) alocv((ncol + 2) * sizeof(table[0][0])); if (cstore[1] == 0) switch (cstore[0]) { - case '_': - fullbot[nlin] = '-'; + case '_': + fullbot[nlin] = '-'; continue; - case '=': - fullbot[nlin] = '='; + case '=': + fullbot[nlin] = '='; continue; } stynum[nlin] = nslin; @@ -60,7 +60,7 @@ gettbl(void) table[nlin][icol].rcol = 0; ch = 1; if (match(cstore, "T{")) { /* text follows */ - table[nlin][icol].col = + table[nlin][icol].col = (char *)(uintptr)gettext(cstore, nlin, icol, font[icol][stynum[nlin]], csize[icol][stynum[nlin]]); @@ -81,7 +81,7 @@ gettbl(void) } while (ctype(nlin, icol + 1) == 's') /* spanning */ table[nlin][++icol].col = ""; - if (ch == '\0') + if (ch == '\0') break; } while (++icol < ncol + 2) { @@ -95,7 +95,7 @@ gettbl(void) } last = cstore; permute(); - if (textflg) + if (textflg) untext(); return; } @@ -108,11 +108,11 @@ nodata(int il) for (c = 0; c < ncol; c++) { switch (ctype(il, c)) { - case 'c': - case 'n': - case 'r': - case 'l': - case 's': + case 'c': + case 'n': + case 'r': + case 'l': + case 's': case 'a': return(0); } @@ -169,17 +169,17 @@ permute(void) int vspand(int ir, int ij, int ifform) { - if (ir < 0) + if (ir < 0) return(0); if (ir >= nlin) return(0); - if (instead[ir]) + if (instead[ir]) return(0); - if (ifform == 0 && ctype(ir, ij) == '^') + if (ifform == 0 && ctype(ir, ij) == '^') return(1); - if (table[ir][ij].rcol != 0) + if (table[ir][ij].rcol != 0) return(0); - if (fullbot[ir]) + if (fullbot[ir]) return(0); return(vspen(table[ir][ij].col)); } @@ -188,11 +188,9 @@ vspand(int ir, int ij, int ifform) int vspen(char *s) { - if (s == 0) + if (s == 0) return(0); - if (!point(s)) + if (!point(s)) return(0); return(match(s, SPAN)); } - - diff --git a/src/cmd/tbl/t6.c b/src/cmd/tbl/t6.c index 463bfa107..aed42a071 100644 --- a/src/cmd/tbl/t6.c +++ b/src/cmd/tbl/t6.c @@ -20,16 +20,16 @@ maktab(void) /* define the tab stops of the table */ Bprint(&tabout, ".%2s\n.rm %2s\n", reg(icol, CRIGHT), reg(icol, CRIGHT)); for (ilin = 0; ilin < nlin; ilin++) { - if (instead[ilin] || fullbot[ilin]) + if (instead[ilin] || fullbot[ilin]) continue; vforml = ilin; for (il = prev(ilin); il >= 0 && vspen(table[il][icol].col); il = prev(il)) vforml = il; - if (fspan(vforml, icol)) + if (fspan(vforml, icol)) continue; - if (filler(table[ilin][icol].col)) + if (filler(table[ilin][icol].col)) continue; - if ((flags[icol][stynum[ilin]] & ZEROW) != 0) + if ((flags[icol][stynum[ilin]] & ZEROW) != 0) continue; switch (ctype(vforml, icol)) { case 'a': @@ -52,10 +52,10 @@ maktab(void) /* define the tab stops of the table */ doubled[icol] = 1; if (real(ss = table[ilin][icol].col) && !vspen(ss)) { s = (int)(uintptr)ss; - if (tx(s) != text) + if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); - wide(ss, FN(vforml, icol), SZ(vforml, icol)); + wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); @@ -73,10 +73,10 @@ maktab(void) /* define the tab stops of the table */ case 'l': if (real(ss = table[ilin][icol].col) && !vspen(ss)) { s = (int)(uintptr)ss; - if (tx(s) != text) + if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); - wide(ss, FN(vforml, icol), SZ(vforml, icol)); + wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); @@ -85,7 +85,7 @@ maktab(void) /* define the tab stops of the table */ } } if (acase[icol]) { - Bprint(&tabout, ".if \\n(%d>=\\n(%2s .nr %2s \\n(%du+2n\n", + Bprint(&tabout, ".if \\n(%d>=\\n(%2s .nr %2s \\n(%du+2n\n", S2, reg(icol, CRIGHT), reg(icol, CRIGHT), S2); } if (doubled[icol]) { @@ -104,13 +104,13 @@ maktab(void) /* define the tab stops of the table */ for (ilin = 0; ilin < nlin; ilin++) if (k = lspan(ilin, icol)) { ss = table[ilin][icol-k].col; - if (!real(ss) || barent(ss) || vspen(ss) ) + if (!real(ss) || barent(ss) || vspen(ss) ) continue; Bprint(&tabout, ".nr %d ", TMP); wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k)); for (ik = k; ik >= 0; ik--) { Bprint(&tabout, "-\\n(%2s", reg(icol - ik, CRIGHT)); - if (!expflg && ik > 0) + if (!expflg && ik > 0) Bprint(&tabout, "-%dn", sep[icol-ik]); } Bprint(&tabout, "\n"); @@ -126,13 +126,13 @@ maktab(void) /* define the tab stops of the table */ } } } - if (textflg) + if (textflg) untext(); /* if even requested, make all columns widest width */ if (evenflg) { Bprint(&tabout, ".nr %d 0\n", TMP); for (icol = 0; icol < ncol; icol++) { - if (evenup[icol] == 0) + if (evenup[icol] == 0) continue; Bprint(&tabout, ".if \\n(%2s>\\n(%d .nr %d \\n(%2s\n", reg(icol, CRIGHT), TMP, TMP, reg(icol, CRIGHT)); @@ -169,7 +169,7 @@ maktab(void) /* define the tab stops of the table */ Bprint(&tabout, ".nr %d 1n\n", TMP); Bprint(&tabout, ".nr %2s 0\n", reg(-1, CRIGHT)); tsep = (boxflg || allflg || dboxflg || left1flg) ? 2 : 0; - if (sep[-1] >= 0) + if (sep[-1] >= 0) tsep = sep[-1]; for (icol = 0; icol < ncol; icol++) { Bprint(&tabout, ".nr %2s \\n(%2s+((%d*\\n(%d)/2)\n", reg(icol, CLEFT), @@ -202,14 +202,14 @@ wide(char *s, char *fn, char *size) { if (point(s)) { Bprint(&tabout, "\\w%c", F1); - if (*fn > 0) + if (*fn > 0) putfont(fn); - if (*size) + if (*size) putsize(size); Bprint(&tabout, "%s", s); - if (*fn > 0) + if (*fn > 0) putfont("P"); - if (*size) + if (*size) putsize("0"); Bprint(&tabout, "%c", F1); } else @@ -222,5 +222,3 @@ filler(char *s) { return (point(s) && s[0] == '\\' && s[1] == 'R'); } - - diff --git a/src/cmd/tbl/t7.c b/src/cmd/tbl/t7.c index 2fa9de53b..6a873d617 100644 --- a/src/cmd/tbl/t7.c +++ b/src/cmd/tbl/t7.c @@ -7,7 +7,7 @@ runout(void) { int i; - if (boxflg || allflg || dboxflg) + if (boxflg || allflg || dboxflg) need(); if (ctrflg) { Bprint(&tabout, ".nr #I \\n(.i\n"); @@ -65,15 +65,15 @@ runtabs(int lform, int ldata) int ifline(char *s) { - if (!point(s)) + if (!point(s)) return(0); - if (s[0] == '\\') + if (s[0] == '\\') s++; - if (s[1] ) + if (s[1] ) return(0); - if (s[0] == '_') + if (s[0] == '_') return('-'); - if (s[0] == '=') + if (s[0] == '=') return('='); return(0); } @@ -124,7 +124,7 @@ deftail(void) Bprint(&tabout, ".if \\n(T. "); drawline(nlin, 0, ncol, dboxflg ? '=' : '-', 1, 0); Bprint(&tabout, "\n.if \\n(T. .vs\n"); - /* T. is really an argument to a macro but because of + /* T. is really an argument to a macro but because of eqn we don't dare pass it as an argument and reference by $1 */ } for (c = 0; c < ncol; c++) { @@ -146,5 +146,3 @@ deftail(void) Bprint(&tabout, "..\n"); Bprint(&tabout, ".ec\n"); } - - diff --git a/src/cmd/tbl/t8.c b/src/cmd/tbl/t8.c index bfa21ecff..26375df5a 100644 --- a/src/cmd/tbl/t8.c +++ b/src/cmd/tbl/t8.c @@ -14,25 +14,25 @@ putline(int i, int nl) char *ss, *size, *fn, *rct; cmidx = watchout = vspf = exvspen = 0; - if (i == 0) + if (i == 0) once = 0; if (i == 0 && ( allflg || boxflg || dboxflg)) fullwide(0, dboxflg ? '=' : '-'); if (instead[nl] == 0 && fullbot[nl] == 0) for (c = 0; c < ncol; c++) { ss = table[nl][c].col; - if (ss == 0) + if (ss == 0) continue; if (vspen(ss)) { for (ip = nl; ip < nlin; ip = next(ip)) - if (!vspen(ss = table[ip][c].col)) + if (!vspen(ss = table[ip][c].col)) break; s = (int)(uintptr)ss; if (s > 0 && s < 128) Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s); continue; } - if (point(ss)) + if (point(ss)) continue; s = (int)(uintptr)ss; Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s); @@ -55,10 +55,10 @@ putline(int i, int nl) } for (c = 0; c < ncol; c++) { if (instead[nl] == 0 && fullbot[nl] == 0) - if (vspen(table[nl][c].col)) + if (vspen(table[nl][c].col)) vspf = 1; if (lf >= 0) - if (vspen(table[lf][c].col)) + if (vspen(table[lf][c].col)) vspf = 1; } if (vspf) { @@ -69,7 +69,7 @@ putline(int i, int nl) chfont = 0; for (c = 0; c < ncol; c++) { ss = table[nl][c].col; - if (ss == 0) + if (ss == 0) continue; if(font[c][stynum[nl]]) chfont = 1; @@ -107,7 +107,7 @@ putline(int i, int nl) drawvert(lf, i, c, lwid); vct += 2; } - if (rightl && c + 1 == ncol) + if (rightl && c + 1 == ncol) continue; vforml = i; for (lf = prev(nl); lf >= 0 && vspen(table[lf][c].col); lf = prev(lf)) @@ -115,9 +115,9 @@ putline(int i, int nl) form = ctype(vforml, c); if (form != 's') { rct = reg(c, CLEFT); - if (form == 'a') + if (form == 'a') rct = reg(c, CMID); - if (form == 'n' && table[nl][c].rcol && lused[c] == 0) + if (form == 'n' && table[nl][c].rcol && lused[c] == 0) rct = reg(c, CMID); Bprint(&tabout, "\\h'|\\n(%2su'", rct); } @@ -152,10 +152,10 @@ putline(int i, int nl) } } Bprint(&tabout, "%c%c", F1, F2); - if (uphalf) + if (uphalf) Bprint(&tabout, "\\u"); puttext(ss, fn, size); - if (uphalf) + if (uphalf) Bprint(&tabout, "\\d"); Bprint(&tabout, "%c", F1); } @@ -164,13 +164,13 @@ putline(int i, int nl) break; } case 'c': - form = 3; + form = 3; break; case 'r': - form = 2; + form = 2; break; case 'l': - form = 1; + form = 1; break; case '-': case '=': @@ -212,10 +212,10 @@ putline(int i, int nl) vspf = 1; else { - if (uphalf) + if (uphalf) Bprint(&tabout, "\\u"); puttext(ss, fn, size); - if (uphalf) + if (uphalf) Bprint(&tabout, "\\d"); } if (form != 2) @@ -225,8 +225,8 @@ putline(int i, int nl) ip = prev(nl); if (ip >= 0) if (vspen(table[ip][c].col)) { - exvspen = (c + 1 < ncol) && vspen(table[ip][c+1].col) && - (topat[c] == topat[c+1]) && + exvspen = (c + 1 < ncol) && vspen(table[ip][c+1].col) && + (topat[c] == topat[c+1]) && (cmidx == (flags[c+1] [stynum[nl]] & (CTOP | CDOWN) == 0)) && (left(i, c + 1, &lwid) < 0); if (exvspen == 0) { @@ -248,7 +248,7 @@ putline(int i, int nl) } } Bprint(&tabout, "\n"); - if (allh(i) && !pr1403) + if (allh(i) && !pr1403) Bprint(&tabout, ".vs \\n(%du\n", SVS); if (watchout) funnies(i, nl); @@ -270,9 +270,9 @@ puttext(char *s, char *fn, char *size) putfont(fn); putsize(size); Bprint(&tabout, "%s", s); - if (*fn > 0) + if (*fn > 0) Bprint(&tabout, "\\f\\n(%2d", S1); - if (size != 0) + if (size != 0) putsize("0"); } } @@ -289,9 +289,9 @@ funnies(int stl, int lin) Bprint(&tabout, ".nr %d \\n(##\n", S1); /* bottom position */ for (c = 0; c < ncol; c++) { ss = table[lin][c].col; - if (point(ss)) + if (point(ss)) continue; - if (ss == 0) + if (ss == 0) continue; s = (int)(uintptr)ss; Bprint(&tabout, ".sp |\\n(##u-1v\n"); @@ -333,7 +333,7 @@ funnies(int stl, int lin) } Bprint(&tabout, ".%c+\n", s); Bprint(&tabout, ".in -\\n(%du\n", SIND); - if (*fn > 0) + if (*fn > 0) putfont("P"); Bprint(&tabout, ".mk %d\n", S2); Bprint(&tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2); @@ -367,5 +367,3 @@ putsize(char *s) if (s && *s) Bprint(&tabout, "\\s%s", s); } - - diff --git a/src/cmd/tbl/t9.c b/src/cmd/tbl/t9.c index 69e9d6c77..db3a4d116 100644 --- a/src/cmd/tbl/t9.c +++ b/src/cmd/tbl/t9.c @@ -37,13 +37,13 @@ domore(char *dataln) instead[0] = (char *)0; if (dataln[1] == 0) switch (dataln[0]) { - case '_': - fullbot[0] = '-'; - putline(useln, 0); + case '_': + fullbot[0] = '-'; + putline(useln, 0); return(1); - case '=': - fullbot[0] = '='; - putline(useln, 0); + case '=': + fullbot[0] = '='; + putline(useln, 0); return(1); } for (icol = 0; icol < ncol; icol++) { @@ -63,7 +63,7 @@ domore(char *dataln) } while (ctype(useln, icol + 1) == 's') /* spanning */ table[0][++icol].col = ""; - if (ch == '\0') + if (ch == '\0') break; } while (++icol < ncol) @@ -72,5 +72,3 @@ domore(char *dataln) exstore = exspace; /* reuse space for numerical items */ return(1); } - - diff --git a/src/cmd/tbl/tb.c b/src/cmd/tbl/tb.c index 5cc598801..213d371c2 100644 --- a/src/cmd/tbl/tb.c +++ b/src/cmd/tbl/tb.c @@ -9,10 +9,10 @@ checkuse(void) for (c = 0; c < ncol; c++) { used[c] = lused[c] = rused[c] = 0; for (i = 0; i < nlin; i++) { - if (instead[i] || fullbot[i]) + if (instead[i] || fullbot[i]) continue; k = ctype(i, c); - if (k == '-' || k == '=') + if (k == '-' || k == '=') continue; if ((k == 'n' || k == 'a')) { rused[c] |= real(table[i][c].rcol); @@ -30,11 +30,11 @@ checkuse(void) int real(char *s) { - if (s == 0) + if (s == 0) return(0); - if (!point(s)) + if (!point(s)) return(1); - if (*s == 0) + if (*s == 0) return(0); return(1); } @@ -97,5 +97,3 @@ release(void) tpcount = -1; exstore = 0; } - - diff --git a/src/cmd/tbl/tc.c b/src/cmd/tbl/tc.c index a89fc0f04..0b9d19610 100644 --- a/src/cmd/tbl/tc.c +++ b/src/cmd/tbl/tc.c @@ -12,9 +12,9 @@ choochar(void) had[icol] = 0; F1 = F2 = 0; for (ilin = 0; ilin < nlin; ilin++) { - if (instead[ilin]) + if (instead[ilin]) continue; - if (fullbot[ilin]) + if (fullbot[ilin]) continue; for (icol = 0; icol < ncol; icol++) { k = ctype(ilin, icol); @@ -32,7 +32,7 @@ choochar(void) } /* choose first funny character */ for ( - s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz"; + s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz"; *s; s++) { if (had[(unsigned char)*s] == 0) { F1 = (unsigned char)*s; @@ -42,7 +42,7 @@ choochar(void) } /* choose second funny character */ for ( - s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz"; + s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz"; *s; s++) { if (had[(unsigned char)*s] == 0) { F2 = (unsigned char)*s; @@ -61,5 +61,3 @@ point(char *ss) int s = (int)(uintptr)ss; return(s >= 128 || s < 0); } - - diff --git a/src/cmd/tbl/te.c b/src/cmd/tbl/te.c index 3df8d445d..54df7e82e 100644 --- a/src/cmd/tbl/te.c +++ b/src/cmd/tbl/te.c @@ -71,5 +71,3 @@ get1char(void) iline++; return(c); } - - diff --git a/src/cmd/tbl/tf.c b/src/cmd/tbl/tf.c index 3791c32fe..097dfe36a 100644 --- a/src/cmd/tbl/tf.c +++ b/src/cmd/tbl/tf.c @@ -70,5 +70,3 @@ cleanfc(void) { Bprint(&tabout, ".fc\n"); } - - diff --git a/src/cmd/tbl/tg.c b/src/cmd/tbl/tg.c index 3afc88c68..7b5374bde 100644 --- a/src/cmd/tbl/tg.c +++ b/src/cmd/tbl/tg.c @@ -10,7 +10,7 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz) char *vs; startline = iline; - if (texname == 0) + if (texname == 0) error("Too many text block diversions"); if (textflg == 0) { Bprint(&tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */ @@ -21,13 +21,13 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz) Bprint(&tabout, ".br\n"); Bprint(&tabout, ".di %c+\n", texname); rstofill(); - if (fn && *fn) + if (fn && *fn) Bprint(&tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn); Bprint(&tabout, ".ft \\n(.f\n"); /* protect font */ vs = vsize[icol][stynum[ilin]]; if ((sz && *sz) || (vs && *vs)) { Bprint(&tabout, ".nr %d \\n(.v\n", S9); - if (vs == 0 || *vs == 0) + if (vs == 0 || *vs == 0) vs = "\\n(.s+2"; if (sz && *sz) Bprint(&tabout, ".ps %s\n", sz); @@ -48,15 +48,15 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz) iline = startline; error("missing closing T}"); } - if (line[0] == 'T' && line[1] == '}' && line[2] == tab) + if (line[0] == 'T' && line[1] == '}' && line[2] == tab) break; - if (match("T}", line)) + if (match("T}", line)) break; Bprint(&tabout, "%s\n", line); } - if (fn && *fn) + if (fn && *fn) Bprint(&tabout, ".ft \\n(%d\n", S1); - if (sz && *sz) + if (sz && *sz) Bprint(&tabout, ".br\n.ps\n.vs\n"); Bprint(&tabout, ".br\n"); Bprint(&tabout, ".di\n"); @@ -82,5 +82,3 @@ untext(void) Bprint(&tabout, ".nf\n"); Bprint(&tabout, ".ll \\n(%du\n", SL); } - - diff --git a/src/cmd/tbl/ti.c b/src/cmd/tbl/ti.c index ef995bbb3..d4a2ab4db 100644 --- a/src/cmd/tbl/ti.c +++ b/src/cmd/tbl/ti.c @@ -9,9 +9,9 @@ interv(int i, int c) if (c >= ncol || c == 0) { if (dboxflg) { - if (i == 0) + if (i == 0) return(BOT); - if (i >= nlin) + if (i >= nlin) return(TOP); return(THRU); } @@ -23,11 +23,11 @@ interv(int i, int c) kl = 0; else kl = lefdata(allh(i) ? i + 1 : i, c); - if (ku == 2 && kl == 2) + if (ku == 2 && kl == 2) return(THRU); - if (ku == 2) + if (ku == 2) return(TOP); - if (kl == BOT) + if (kl == BOT) return(2); return(0); } @@ -45,7 +45,7 @@ interh(int i, int c) return(RIGHT); return(THRU); } - if (i >= nlin) + if (i >= nlin) return(0); kl = c > 0 ? thish (i, c - 1) : 0; if (kl <= 1 && i > 0 && allh(up1(i))) @@ -53,11 +53,11 @@ interh(int i, int c) kr = thish(i, c); if (kr <= 1 && i > 0 && allh(up1(i))) kr = c > 0 ? thish(up1(i), c) : 0; - if (kl == '=' && kr == '=') + if (kl == '=' && kr == '=') return(THRU); - if (kl == '=') + if (kl == '=') return(LEFT); - if (kr == '=') + if (kr == '=') return(RIGHT); return(0); } @@ -67,9 +67,7 @@ int up1(int i) { i--; - while (instead[i] && i > 0) + while (instead[i] && i > 0) i--; return(i); } - - diff --git a/src/cmd/tbl/tm.c b/src/cmd/tbl/tm.c index 5b58f0d1b..cee294c4f 100644 --- a/src/cmd/tbl/tm.c +++ b/src/cmd/tbl/tm.c @@ -15,8 +15,8 @@ maknew(char *str) str = p; if (ba == 0) { for (dpoint = 0; *str; str++) { - if (*str == '.' && !ineqn(str, p) && - (str > p && digit(*(str - 1)) || + if (*str == '.' && !ineqn(str, p) && + (str > p && digit(*(str - 1)) || digit(*(str + 1)))) dpoint = str; } @@ -27,7 +27,7 @@ maknew(char *str) } if (!dpoint && p == str) /* not numerical, don't split */ return(0); - if (dpoint) + if (dpoint) str = dpoint; } else str = ba; @@ -61,5 +61,3 @@ ineqn (char *s, char *p) } return(0); } - - diff --git a/src/cmd/tbl/tr.c b/src/cmd/tbl/tr.c index 7d586e8b8..6a6261153 100644 --- a/src/cmd/tbl/tr.c +++ b/src/cmd/tbl/tr.c @@ -24,5 +24,3 @@ reg(int col, int place) error("Too many columns for registers"); return (nregs[qcol*place+col]); } - - diff --git a/src/cmd/tbl/ts.c b/src/cmd/tbl/ts.c index 43cc84ecd..2a98b5d63 100644 --- a/src/cmd/tbl/ts.c +++ b/src/cmd/tbl/ts.c @@ -19,7 +19,7 @@ prefix(char *small, char *big) int c; while ((c = *small++) == *big++) - if (c == 0) + if (c == 0) return(1); return(c == 0); } @@ -67,5 +67,3 @@ tcopy (char *s, char *t) while (*s++ = *t++) ; } - - diff --git a/src/cmd/tbl/tt.c b/src/cmd/tbl/tt.c index 96270b758..54c6180e8 100644 --- a/src/cmd/tbl/tt.c +++ b/src/cmd/tbl/tt.c @@ -33,7 +33,7 @@ lspan(int i, int c) { int k; - if (ctype(i, c) != 's') + if (ctype(i, c) != 's') return(0); c++; if (c < ncol && ctype(i, c) == 's') @@ -73,15 +73,15 @@ allh(int i) /* also at least one must be horizontl */ int c, one, k; - if (fullbot[i]) + if (fullbot[i]) return(1); - if (i >= nlin) + if (i >= nlin) return(dboxflg || boxflg); for (one = c = 0; c < ncol; c++) { k = thish(i, c); - if (k == 0) + if (k == 0) return(0); - if (k == 1) + if (k == 1) continue; one = 1; } @@ -98,30 +98,28 @@ thish(int i, int c) if (c < 0) return(0); - if (i < 0) + if (i < 0) return(0); t = ctype(i, c); if (t == '_' || t == '-') return('-'); if (t == '=') return('='); - if (t == '^') + if (t == '^') return(1); if (fullbot[i] ) return(fullbot[i]); - if (t == 's') + if (t == 's') return(thish(i, c - 1)); - if (t == 0) + if (t == 0) return(1); pc = &table[i][c]; s = (t == 'a' ? pc->rcol : pc->col); if (s == 0 || (point(s) && *s == 0)) return(1); - if (vspen(s)) + if (vspen(s)) return(1); if (t = barent( s)) return(t); return(0); } - - diff --git a/src/cmd/tbl/tu.c b/src/cmd/tbl/tu.c index 217869e1a..940895775 100644 --- a/src/cmd/tbl/tu.c +++ b/src/cmd/tbl/tu.c @@ -7,7 +7,7 @@ makeline(int i, int c, int lintype) int cr, type, shortl; type = thish(i, c); - if (type == 0) + if (type == 0) return; shortl = (table[i][c].col[0] == '\\'); if (c > 0 && !shortl && thish(i, c - 1) == type) @@ -55,17 +55,17 @@ drawline(int i, int cl, int cr, int lintype, int noheight, int shortl) lcount = 0; exhr = exhl = ""; switch (lintype) { - case '-': + case '-': lcount = 1; break; - case '=': - lcount = pr1403 ? 1 : 2; + case '=': + lcount = pr1403 ? 1 : 2; break; - case SHORTLINE: - lcount = 1; + case SHORTLINE: + lcount = 1; break; } - if (lcount <= 0) + if (lcount <= 0) return; nodata = cr - cl >= ncol || noheight || allh(i); if (!nodata) @@ -79,26 +79,26 @@ drawline(int i, int cl, int cr, int lintype, int noheight, int shortl) tohcol(cl); if (lcount > 1) { switch (interv(i, cl)) { - case TOP: - exhl = ln == 0 ? "1p" : "-1p"; + case TOP: + exhl = ln == 0 ? "1p" : "-1p"; break; - case BOT: - exhl = ln == 1 ? "1p" : "-1p"; + case BOT: + exhl = ln == 1 ? "1p" : "-1p"; break; - case THRU: - exhl = "1p"; + case THRU: + exhl = "1p"; break; } if (exhl[0]) Bprint(&tabout, "\\h'%s'", exhl); } else if (lcount == 1) { switch (interv(i, cl)) { - case TOP: - case BOT: - exhl = "-1p"; + case TOP: + case BOT: + exhl = "-1p"; break; - case THRU: - exhl = "1p"; + case THRU: + exhl = "1p"; break; } if (exhl[0]) @@ -106,24 +106,24 @@ drawline(int i, int cl, int cr, int lintype, int noheight, int shortl) } if (lcount > 1) { switch (interv(i, cr + 1)) { - case TOP: - exhr = ln == 0 ? "-1p" : "+1p"; + case TOP: + exhr = ln == 0 ? "-1p" : "+1p"; break; - case BOT: - exhr = ln == 1 ? "-1p" : "+1p"; + case BOT: + exhr = ln == 1 ? "-1p" : "+1p"; break; - case THRU: - exhr = "-1p"; + case THRU: + exhr = "-1p"; break; } } else if (lcount == 1) { switch (interv(i, cr + 1)) { - case TOP: - case BOT: - exhr = "+1p"; + case TOP: + case BOT: + exhr = "+1p"; break; - case THRU: - exhr = "-1p"; + case THRU: + exhr = "-1p"; break; } } @@ -183,18 +183,18 @@ left(int i, int c, int *lwidp) /* returns number of line where it starts */ /* stores into lwid the kind of line */ *lwidp = 0; - if (i < 0) + if (i < 0) return(-1); kind = lefdata(i, c); - if (kind == 0) + if (kind == 0) return(-1); if (i + 1 < nlin) - if (lefdata(next(i), c) == kind) + if (lefdata(next(i), c) == kind) return(-1); li = i; while (i >= 0 && lefdata(i, c) == kind) i = prev(li = i); - if (prev(li) == -1) + if (prev(li) == -1) li = 0; *lwidp = kind; for (lj = i + 1; lj < li; lj++) @@ -212,7 +212,7 @@ lefdata(int i, int c) { int ck; - if (i >= nlin) + if (i >= nlin) i = nlin - 1; if (ctype(i, c) == 's') { for (ck = c; ctype(i, ck) == 's'; ck--) @@ -222,13 +222,13 @@ lefdata(int i, int c) } i = stynum[i]; i = lefline[c][i]; - if (i > 0) + if (i > 0) return(i); - if (dboxflg && c == 0) + if (dboxflg && c == 0) return(2); if (allflg) return(1); - if (boxflg && c == 0) + if (boxflg && c == 0) return(1); return(0); } @@ -239,7 +239,7 @@ next(int i) { while (i + 1 < nlin) { i++; - if (!fullbot[i] && !instead[i]) + if (!fullbot[i] && !instead[i]) break; } return(i); @@ -253,5 +253,3 @@ prev(int i) ; return(i); } - - diff --git a/src/cmd/tbl/tv.c b/src/cmd/tbl/tv.c index 19a4b03fd..0fb330cc3 100644 --- a/src/cmd/tbl/tv.c +++ b/src/cmd/tbl/tv.c @@ -10,12 +10,12 @@ drawvert(int start, int end, int c, int lwid) end++; vm = 'v'; /* note: nr 35 has value of 1m outside of linesize */ - while (instead[end]) + while (instead[end]) end++; for (ln = 0; ln < lwid; ln++) { epb = ept = 0; pos = 2 * ln - lwid + 1; - if (pos != tp) + if (pos != tp) Bprint(&tabout, "\\h'%dp'", pos - tp); tp = pos; if (end < nlin) { @@ -24,53 +24,53 @@ drawvert(int start, int end, int c, int lwid) else switch (midbar(end, c)) { case '-': - exb = "1v-.5m"; + exb = "1v-.5m"; break; case '=': exb = "1v-.5m"; - epb = 1; + epb = 1; break; } } if (lwid > 1) switch (interh(end, c)) { - case THRU: - epb -= 1; + case THRU: + epb -= 1; break; - case RIGHT: - epb += (ln == 0 ? 1 : -1); + case RIGHT: + epb += (ln == 0 ? 1 : -1); break; - case LEFT: - epb += (ln == 1 ? 1 : -1); + case LEFT: + epb += (ln == 1 ? 1 : -1); break; } if (lwid == 1) switch (interh(end, c)) { - case THRU: - epb -= 1; + case THRU: + epb -= 1; break; - case RIGHT: - case LEFT: - epb += 1; + case RIGHT: + case LEFT: + epb += 1; break; } if (start > 0) { sl = start - 1; - while (sl >= 0 && instead[sl]) + while (sl >= 0 && instead[sl]) sl--; if (sl >= 0 && (fullbot[sl] || allh(sl))) ept = 0; else if (sl >= 0) switch (midbar(sl, c)) { case '-': - ext = ".5m"; + ext = ".5m"; break; case '=': - ext = ".5m"; - ept = -1; + ext = ".5m"; + ept = -1; break; default: - vm = 'm'; + vm = 'm'; break; } else @@ -81,24 +81,24 @@ drawvert(int start, int end, int c, int lwid) } if (lwid > 1) switch (interh(start, c)) { - case THRU: - ept += 1; + case THRU: + ept += 1; break; - case LEFT: - ept += (ln == 0 ? 1 : -1); + case LEFT: + ept += (ln == 0 ? 1 : -1); break; - case RIGHT: - ept += (ln == 1 ? 1 : -1); + case RIGHT: + ept += (ln == 1 ? 1 : -1); break; } else if (lwid == 1) switch (interh(start, c)) { - case THRU: - ept += 1; + case THRU: + ept += 1; break; - case LEFT: - case RIGHT: - ept -= 1; + case LEFT: + case RIGHT: + ept -= 1; break; } if (exb) @@ -163,11 +163,11 @@ midbcol(int i, int c) int barent(char *s) { - if (s == 0) + if (s == 0) return (1); - if (!point(s)) + if (!point(s)) return(0); - if (s[0] == '\\') + if (s[0] == '\\') s++; if (s[1] != 0) return(0); @@ -179,5 +179,3 @@ barent(char *s) } return(0); } - - diff --git a/src/cmd/tcs/conv_ksc.c b/src/cmd/tcs/conv_ksc.c index 293ffad1a..da1ebe0a3 100644 --- a/src/cmd/tcs/conv_ksc.c +++ b/src/cmd/tcs/conv_ksc.c @@ -158,4 +158,3 @@ uksc_out(Rune *base, int n, long *notused) if(p > obuf) write(1, obuf, p-obuf); } - diff --git a/src/cmd/tcs/font/bbits.c b/src/cmd/tcs/font/bbits.c index e48803369..feb2d755f 100644 --- a/src/cmd/tcs/font/bbits.c +++ b/src/cmd/tcs/font/bbits.c @@ -7,7 +7,7 @@ enum { Charsperfont = 157, Void1b = (0xC6-0xA2)*Charsperfont+0x3f, - Void1e = (0xC9-0xA2)*Charsperfont - 1 + Void1e = (0xC9-0xA2)*Charsperfont - 1 }; Bitmap * diff --git a/src/cmd/tcs/html.c b/src/cmd/tcs/html.c index 93bd9e5ad..be71c0800 100644 --- a/src/cmd/tcs/html.c +++ b/src/cmd/tcs/html.c @@ -294,7 +294,7 @@ static int hnamecmp(const void *va, const void *vb) { Hchar *a, *b; - + a = (Hchar*)va; b = (Hchar*)vb; return strcmp(a->s, b->s); @@ -304,7 +304,7 @@ static int hrunecmp(const void *va, const void *vb) { Hchar *a, *b; - + a = (Hchar*)va; b = (Hchar*)vb; return a->r - b->r; @@ -315,12 +315,12 @@ html_init(void) { static int init; int i; - + if(init) return; init = 1; memmove(byrune, byname, sizeof byrune); - + /* Eliminate names we aren't allowed to generate. */ for(i=0; i 0){ @@ -386,9 +386,9 @@ html_in(int fd, long *x, struct convert *out) Rune rbuf[N]; Rune *r, *er; int c, i; - + USED(x); - + html_init(); r = rbuf; er = rbuf+N; @@ -453,7 +453,7 @@ html_out(Rune *r, int n, long *x) char *s; Biobuf b; Rune *er; - + USED(x); html_init(); Binit(&b, 1, OWRITE); @@ -468,4 +468,3 @@ html_out(Rune *r, int n, long *x) } Bflush(&b); } - diff --git a/src/cmd/tcs/jis.h b/src/cmd/tcs/jis.h index 9b6d1dcc6..9c726ee26 100644 --- a/src/cmd/tcs/jis.h +++ b/src/cmd/tcs/jis.h @@ -104,4 +104,3 @@ * Returns 1 if they are, or 0 otherwise. */ #define CANJ2S(_h, _l) (CANJ2SB(_h) && CANJ2SB(_l)) - diff --git a/src/cmd/tcs/ksc.c b/src/cmd/tcs/ksc.c index 90d6793bb..05b0ecafa 100644 --- a/src/cmd/tcs/ksc.c +++ b/src/cmd/tcs/ksc.c @@ -1,7 +1,7 @@ #include "ksc.h" /* KSC5601 -> Unicode mapping table, compressed for the 94*94 codeset. */ -/* +/* * Unlike kuten-table, needed offset is 33 (0x21) instead of * 32 for 7-bit portion of each byte. i.e., a Unicode * codepoint for KSC's codepoint (n, m) would be found at @@ -9,978 +9,978 @@ */ long tabksc5601[] = { /* KSC 5601 -> Unicode mapping table; max codepoint = 0x7d7e */ - 0x3000, 0x3001, 0x3002, 0x00b7, 0x2025, 0x2026, 0x00a8, 0x3003, 0x00ad, - 0x2015, 0x2225, 0xff3c, 0x223c, 0x2018, 0x2019, 0x201c, 0x201d, 0x3014, - 0x3015, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, - 0x3010, 0x3011, 0x00b1, 0x00d7, 0x00f7, 0x2260, 0x2264, 0x2265, 0x221e, - 0x2234, 0x00b0, 0x2032, 0x2033, 0x2103, 0x212b, 0xffe0, 0xffe1, 0xffe5, - 0x2642, 0x2640, 0x2220, 0x22a5, 0x2312, 0x2202, 0x2207, 0x2261, 0x2252, - 0x00a7, 0x203b, 0x2606, 0x2605, 0x25cb, 0x25cf, 0x25ce, 0x25c7, 0x25c6, - 0x25a1, 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x2192, 0x2190, 0x2191, - 0x2193, 0x2194, 0x3013, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d, 0x2235, - 0x222b, 0x222c, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282, 0x2283, 0x222a, - 0x2229, 0x2227, 0x2228, 0xffe2, 0x21d2, 0x21d4, 0x2200, 0x2203, 0x00b4, - 0xff5e, 0x02c7, 0x02d8, 0x02dd, 0x02da, 0x02d9, 0x00b8, 0x02db, 0x00a1, - 0x00bf, 0x02d0, 0x222e, 0x2211, 0x220f, 0x00a4, 0x2109, 0x2030, 0x25c1, - 0x25c0, 0x25b7, 0x25b6, 0x2664, 0x2660, 0x2661, 0x2665, 0x2667, 0x2663, - 0x25c9, 0x25c8, 0x25a3, 0x25d0, 0x25d1, 0x2592, 0x25a4, 0x25a5, 0x25a8, - 0x25a7, 0x25a6, 0x25a9, 0x2668, 0x260f, 0x260e, 0x261c, 0x261e, 0x00b6, - 0x2020, 0x2021, 0x2195, 0x2197, 0x2199, 0x2196, 0x2198, 0x266d, 0x2669, - 0x266a, 0x266c, 0x327f, 0x321c, 0x2116, 0x33c7, 0x2122, 0x33c2, 0x33d8, - 0x2121, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0xff01, - 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, - 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff10, 0xff11, 0xff12, 0xff13, - 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0xff1a, 0xff1b, 0xff1c, - 0xff1d, 0xff1e, 0xff1f, 0xff20, 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, - 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, - 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, - 0xff38, 0xff39, 0xff3a, 0xff3b, 0xffe6, 0xff3d, 0xff3e, 0xff3f, 0xff40, - 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, - 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52, - 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58, 0xff59, 0xff5a, 0xff5b, - 0xff5c, 0xff5d, 0xffe3, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, - 0x3137, 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, - 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148, - 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, 0x3150, 0x3151, - 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a, - 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163, - 0x3164, 0x3165, 0x3166, 0x3167, 0x3168, 0x3169, 0x316a, 0x316b, 0x316c, - 0x316d, 0x316e, 0x316f, 0x3170, 0x3171, 0x3172, 0x3173, 0x3174, 0x3175, - 0x3176, 0x3177, 0x3178, 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e, - 0x317f, 0x3180, 0x3181, 0x3182, 0x3183, 0x3184, 0x3185, 0x3186, 0x3187, - 0x3188, 0x3189, 0x318a, 0x318b, 0x318c, 0x318d, 0x318e, 0x2170, 0x2171, - 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, -1, - -1, -1, -1, -1, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, - 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, -1, -1, -1, -1, - -1, -1, -1, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, - 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, - 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, - -1, -1, -1, -1, -1, -1, -1, -1, 0x03b1, - 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, - 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, - 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, -1, -1, -1, -1, - -1, -1, 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, - 0x252c, 0x2524, 0x2534, 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b, - 0x2517, 0x2523, 0x2533, 0x252b, 0x253b, 0x254b, 0x2520, 0x252f, 0x2528, - 0x2537, 0x253f, 0x251d, 0x2530, 0x2525, 0x2538, 0x2542, 0x2512, 0x2511, - 0x251a, 0x2519, 0x2516, 0x2515, 0x250e, 0x250d, 0x251e, 0x251f, 0x2521, - 0x2522, 0x2526, 0x2527, 0x2529, 0x252a, 0x252d, 0x252e, 0x2531, 0x2532, - 0x2535, 0x2536, 0x2539, 0x253a, 0x253d, 0x253e, 0x2540, 0x2541, 0x2543, - 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0x3395, 0x3396, 0x3397, - 0x2113, 0x3398, 0x33c4, 0x33a3, 0x33a4, 0x33a5, 0x33a6, 0x3399, 0x339a, - 0x339b, 0x339c, 0x339d, 0x339e, 0x339f, 0x33a0, 0x33a1, 0x33a2, 0x33ca, - 0x338d, 0x338e, 0x338f, 0x33cf, 0x3388, 0x3389, 0x33c8, 0x33a7, 0x33a8, - 0x33b0, 0x33b1, 0x33b2, 0x33b3, 0x33b4, 0x33b5, 0x33b6, 0x33b7, 0x33b8, - 0x33b9, 0x3380, 0x3381, 0x3382, 0x3383, 0x3384, 0x33ba, 0x33bb, 0x33bc, - 0x33bd, 0x33be, 0x33bf, 0x3390, 0x3391, 0x3392, 0x3393, 0x3394, 0x2126, - 0x33c0, 0x33c1, 0x338a, 0x338b, 0x338c, 0x33d6, 0x33c5, 0x33ad, 0x33ae, - 0x33af, 0x33db, 0x33a9, 0x33aa, 0x33ab, 0x33ac, 0x33dd, 0x33d0, 0x33d3, - 0x33c3, 0x33c9, 0x33dc, 0x33c6, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 0x00c6, 0x00d0, 0x00aa, 0x0126, -1, 0x0132, -1, 0x013f, - 0x0141, 0x00d8, 0x0152, 0x00ba, 0x00de, 0x0166, 0x014a, -1, 0x3260, - 0x3261, 0x3262, 0x3263, 0x3264, 0x3265, 0x3266, 0x3267, 0x3268, 0x3269, - 0x326a, 0x326b, 0x326c, 0x326d, 0x326e, 0x326f, 0x3270, 0x3271, 0x3272, - 0x3273, 0x3274, 0x3275, 0x3276, 0x3277, 0x3278, 0x3279, 0x327a, 0x327b, - 0x24d0, 0x24d1, 0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, - 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd, 0x24de, 0x24df, 0x24e0, 0x24e1, - 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x2460, - 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, - 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x00bd, 0x2153, 0x2154, 0x00bc, - 0x00be, 0x215b, 0x215c, 0x215d, 0x215e, 0x00e6, 0x0111, 0x00f0, 0x0127, - 0x0131, 0x0133, 0x0138, 0x0140, 0x0142, 0x00f8, 0x0153, 0x00df, 0x00fe, - 0x0167, 0x014b, 0x0149, 0x3200, 0x3201, 0x3202, 0x3203, 0x3204, 0x3205, - 0x3206, 0x3207, 0x3208, 0x3209, 0x320a, 0x320b, 0x320c, 0x320d, 0x320e, - 0x320f, 0x3210, 0x3211, 0x3212, 0x3213, 0x3214, 0x3215, 0x3216, 0x3217, - 0x3218, 0x3219, 0x321a, 0x321b, 0x249c, 0x249d, 0x249e, 0x249f, 0x24a0, - 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5, 0x24a6, 0x24a7, 0x24a8, 0x24a9, - 0x24aa, 0x24ab, 0x24ac, 0x24ad, 0x24ae, 0x24af, 0x24b0, 0x24b1, 0x24b2, - 0x24b3, 0x24b4, 0x24b5, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, - 0x247a, 0x247b, 0x247c, 0x247d, 0x247e, 0x247f, 0x2480, 0x2481, 0x2482, - 0x00b9, 0x00b2, 0x00b3, 0x2074, 0x207f, 0x2081, 0x2082, 0x2083, 0x2084, - 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, - 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050, 0x3051, 0x3052, - 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, - 0x305c, 0x305d, 0x305e, 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, - 0x3065, 0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, - 0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, - 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, - 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088, - 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090, 0x3091, - 0x3092, 0x3093, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, - 0x30a6, 0x30a7, 0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, - 0x30af, 0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, - 0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0, - 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8, 0x30c9, - 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0, 0x30d1, 0x30d2, - 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8, 0x30d9, 0x30da, 0x30db, - 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, - 0x30e5, 0x30e6, 0x30e7, 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, - 0x30ee, 0x30ef, 0x30f0, 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, - -1, -1, -1, -1, -1, -1, -1, -1, 0x0410, - 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416, 0x0417, 0x0418, - 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, 0x0420, 0x0421, - 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, - 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, - 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, - 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, - 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 0x3400, 0x3401, 0x3402, - 0x3403, 0x3404, 0x3405, 0x3406, 0x3407, 0x3408, 0x3409, 0x340a, 0x340b, - 0x340c, 0x340d, 0x340e, 0x340f, 0x3410, 0x3411, 0x3412, 0x3413, 0x3414, - 0x3415, 0x3416, 0x3417, 0x3418, 0x3419, 0x341a, 0x341b, 0x341c, 0x341d, - 0x341e, 0x341f, 0x3420, 0x3421, 0x3422, 0x3423, 0x3424, 0x3425, 0x3426, - 0x3427, 0x3428, 0x3429, 0x342a, 0x342b, 0x342c, 0x342d, 0x342e, 0x342f, - 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, - 0x3439, 0x343a, 0x343b, 0x343c, 0x343d, 0x343e, 0x343f, 0x3440, 0x3441, - 0x3442, 0x3443, 0x3444, 0x3445, 0x3446, 0x3447, 0x3448, 0x3449, 0x344a, - 0x344b, 0x344c, 0x344d, 0x344e, 0x344f, 0x3450, 0x3451, 0x3452, 0x3453, - 0x3454, 0x3455, 0x3456, 0x3457, 0x3458, 0x3459, 0x345a, 0x345b, 0x345c, - 0x345d, 0x345e, 0x345f, 0x3460, 0x3461, 0x3462, 0x3463, 0x3464, 0x3465, - 0x3466, 0x3467, 0x3468, 0x3469, 0x346a, 0x346b, 0x346c, 0x346d, 0x346e, - 0x346f, 0x3470, 0x3471, 0x3472, 0x3473, 0x3474, 0x3475, 0x3476, 0x3477, - 0x3478, 0x3479, 0x347a, 0x347b, 0x347c, 0x347d, 0x347e, 0x347f, 0x3480, - 0x3481, 0x3482, 0x3483, 0x3484, 0x3485, 0x3486, 0x3487, 0x3488, 0x3489, - 0x348a, 0x348b, 0x348c, 0x348d, 0x348e, 0x348f, 0x3490, 0x3491, 0x3492, - 0x3493, 0x3494, 0x3495, 0x3496, 0x3497, 0x3498, 0x3499, 0x349a, 0x349b, - 0x349c, 0x349d, 0x349e, 0x349f, 0x34a0, 0x34a1, 0x34a2, 0x34a3, 0x34a4, - 0x34a5, 0x34a6, 0x34a7, 0x34a8, 0x34a9, 0x34aa, 0x34ab, 0x34ac, 0x34ad, - 0x34ae, 0x34af, 0x34b0, 0x34b1, 0x34b2, 0x34b3, 0x34b4, 0x34b5, 0x34b6, - 0x34b7, 0x34b8, 0x34b9, 0x34ba, 0x34bb, 0x34bc, 0x34bd, 0x34be, 0x34bf, - 0x34c0, 0x34c1, 0x34c2, 0x34c3, 0x34c4, 0x34c5, 0x34c6, 0x34c7, 0x34c8, - 0x34c9, 0x34ca, 0x34cb, 0x34cc, 0x34cd, 0x34ce, 0x34cf, 0x34d0, 0x34d1, - 0x34d2, 0x34d3, 0x34d4, 0x34d5, 0x34d6, 0x34d7, 0x34d8, 0x34d9, 0x34da, - 0x34db, 0x34dc, 0x34dd, 0x34de, 0x34df, 0x34e0, 0x34e1, 0x34e2, 0x34e3, - 0x34e4, 0x34e5, 0x34e6, 0x34e7, 0x34e8, 0x34e9, 0x34ea, 0x34eb, 0x34ec, - 0x34ed, 0x34ee, 0x34ef, 0x34f0, 0x34f1, 0x34f2, 0x34f3, 0x34f4, 0x34f5, - 0x34f6, 0x34f7, 0x34f8, 0x34f9, 0x34fa, 0x34fb, 0x34fc, 0x34fd, 0x34fe, - 0x34ff, 0x3500, 0x3501, 0x3502, 0x3503, 0x3504, 0x3505, 0x3506, 0x3507, - 0x3508, 0x3509, 0x350a, 0x350b, 0x350c, 0x350d, 0x350e, 0x350f, 0x3510, - 0x3511, 0x3512, 0x3513, 0x3514, 0x3515, 0x3516, 0x3517, 0x3518, 0x3519, - 0x351a, 0x351b, 0x351c, 0x351d, 0x351e, 0x351f, 0x3520, 0x3521, 0x3522, - 0x3523, 0x3524, 0x3525, 0x3526, 0x3527, 0x3528, 0x3529, 0x352a, 0x352b, - 0x352c, 0x352d, 0x352e, 0x352f, 0x3530, 0x3531, 0x3532, 0x3533, 0x3534, - 0x3535, 0x3536, 0x3537, 0x3538, 0x3539, 0x353a, 0x353b, 0x353c, 0x353d, - 0x353e, 0x353f, 0x3540, 0x3541, 0x3542, 0x3543, 0x3544, 0x3545, 0x3546, - 0x3547, 0x3548, 0x3549, 0x354a, 0x354b, 0x354c, 0x354d, 0x354e, 0x354f, - 0x3550, 0x3551, 0x3552, 0x3553, 0x3554, 0x3555, 0x3556, 0x3557, 0x3558, - 0x3559, 0x355a, 0x355b, 0x355c, 0x355d, 0x355e, 0x355f, 0x3560, 0x3561, - 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568, 0x3569, 0x356a, - 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570, 0x3571, 0x3572, 0x3573, - 0x3574, 0x3575, 0x3576, 0x3577, 0x3578, 0x3579, 0x357a, 0x357b, 0x357c, - 0x357d, 0x357e, 0x357f, 0x3580, 0x3581, 0x3582, 0x3583, 0x3584, 0x3585, - 0x3586, 0x3587, 0x3588, 0x3589, 0x358a, 0x358b, 0x358c, 0x358d, 0x358e, - 0x358f, 0x3590, 0x3591, 0x3592, 0x3593, 0x3594, 0x3595, 0x3596, 0x3597, - 0x3598, 0x3599, 0x359a, 0x359b, 0x359c, 0x359d, 0x359e, 0x359f, 0x35a0, - 0x35a1, 0x35a2, 0x35a3, 0x35a4, 0x35a5, 0x35a6, 0x35a7, 0x35a8, 0x35a9, - 0x35aa, 0x35ab, 0x35ac, 0x35ad, 0x35ae, 0x35af, 0x35b0, 0x35b1, 0x35b2, - 0x35b3, 0x35b4, 0x35b5, 0x35b6, 0x35b7, 0x35b8, 0x35b9, 0x35ba, 0x35bb, - 0x35bc, 0x35bd, 0x35be, 0x35bf, 0x35c0, 0x35c1, 0x35c2, 0x35c3, 0x35c4, - 0x35c5, 0x35c6, 0x35c7, 0x35c8, 0x35c9, 0x35ca, 0x35cb, 0x35cc, 0x35cd, - 0x35ce, 0x35cf, 0x35d0, 0x35d1, 0x35d2, 0x35d3, 0x35d4, 0x35d5, 0x35d6, - 0x35d7, 0x35d8, 0x35d9, 0x35da, 0x35db, 0x35dc, 0x35dd, 0x35de, 0x35df, - 0x35e0, 0x35e1, 0x35e2, 0x35e3, 0x35e4, 0x35e5, 0x35e6, 0x35e7, 0x35e8, - 0x35e9, 0x35ea, 0x35eb, 0x35ec, 0x35ed, 0x35ee, 0x35ef, 0x35f0, 0x35f1, - 0x35f2, 0x35f3, 0x35f4, 0x35f5, 0x35f6, 0x35f7, 0x35f8, 0x35f9, 0x35fa, - 0x35fb, 0x35fc, 0x35fd, 0x35fe, 0x35ff, 0x3600, 0x3601, 0x3602, 0x3603, - 0x3604, 0x3605, 0x3606, 0x3607, 0x3608, 0x3609, 0x360a, 0x360b, 0x360c, - 0x360d, 0x360e, 0x360f, 0x3610, 0x3611, 0x3612, 0x3613, 0x3614, 0x3615, - 0x3616, 0x3617, 0x3618, 0x3619, 0x361a, 0x361b, 0x361c, 0x361d, 0x361e, - 0x361f, 0x3620, 0x3621, 0x3622, 0x3623, 0x3624, 0x3625, 0x3626, 0x3627, - 0x3628, 0x3629, 0x362a, 0x362b, 0x362c, 0x362d, 0x362e, 0x362f, 0x3630, - 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, - 0x363a, 0x363b, 0x363c, 0x363d, 0x363e, 0x363f, 0x3640, 0x3641, 0x3642, - 0x3643, 0x3644, 0x3645, 0x3646, 0x3647, 0x3648, 0x3649, 0x364a, 0x364b, - 0x364c, 0x364d, 0x364e, 0x364f, 0x3650, 0x3651, 0x3652, 0x3653, 0x3654, - 0x3655, 0x3656, 0x3657, 0x3658, 0x3659, 0x365a, 0x365b, 0x365c, 0x365d, - 0x365e, 0x365f, 0x3660, 0x3661, 0x3662, 0x3663, 0x3664, 0x3665, 0x3666, - 0x3667, 0x3668, 0x3669, 0x366a, 0x366b, 0x366c, 0x366d, 0x366e, 0x366f, - 0x3670, 0x3671, 0x3672, 0x3673, 0x3674, 0x3675, 0x3676, 0x3677, 0x3678, - 0x3679, 0x367a, 0x367b, 0x367c, 0x367d, 0x367e, 0x367f, 0x3680, 0x3681, - 0x3682, 0x3683, 0x3684, 0x3685, 0x3686, 0x3687, 0x3688, 0x3689, 0x368a, - 0x368b, 0x368c, 0x368d, 0x368e, 0x368f, 0x3690, 0x3691, 0x3692, 0x3693, - 0x3694, 0x3695, 0x3696, 0x3697, 0x3698, 0x3699, 0x369a, 0x369b, 0x369c, - 0x369d, 0x369e, 0x369f, 0x36a0, 0x36a1, 0x36a2, 0x36a3, 0x36a4, 0x36a5, - 0x36a6, 0x36a7, 0x36a8, 0x36a9, 0x36aa, 0x36ab, 0x36ac, 0x36ad, 0x36ae, - 0x36af, 0x36b0, 0x36b1, 0x36b2, 0x36b3, 0x36b4, 0x36b5, 0x36b6, 0x36b7, - 0x36b8, 0x36b9, 0x36ba, 0x36bb, 0x36bc, 0x36bd, 0x36be, 0x36bf, 0x36c0, - 0x36c1, 0x36c2, 0x36c3, 0x36c4, 0x36c5, 0x36c6, 0x36c7, 0x36c8, 0x36c9, - 0x36ca, 0x36cb, 0x36cc, 0x36cd, 0x36ce, 0x36cf, 0x36d0, 0x36d1, 0x36d2, - 0x36d3, 0x36d4, 0x36d5, 0x36d6, 0x36d7, 0x36d8, 0x36d9, 0x36da, 0x36db, - 0x36dc, 0x36dd, 0x36de, 0x36df, 0x36e0, 0x36e1, 0x36e2, 0x36e3, 0x36e4, - 0x36e5, 0x36e6, 0x36e7, 0x36e8, 0x36e9, 0x36ea, 0x36eb, 0x36ec, 0x36ed, - 0x36ee, 0x36ef, 0x36f0, 0x36f1, 0x36f2, 0x36f3, 0x36f4, 0x36f5, 0x36f6, - 0x36f7, 0x36f8, 0x36f9, 0x36fa, 0x36fb, 0x36fc, 0x36fd, 0x36fe, 0x36ff, - 0x3700, 0x3701, 0x3702, 0x3703, 0x3704, 0x3705, 0x3706, 0x3707, 0x3708, - 0x3709, 0x370a, 0x370b, 0x370c, 0x370d, 0x370e, 0x370f, 0x3710, 0x3711, - 0x3712, 0x3713, 0x3714, 0x3715, 0x3716, 0x3717, 0x3718, 0x3719, 0x371a, - 0x371b, 0x371c, 0x371d, 0x371e, 0x371f, 0x3720, 0x3721, 0x3722, 0x3723, - 0x3724, 0x3725, 0x3726, 0x3727, 0x3728, 0x3729, 0x372a, 0x372b, 0x372c, - 0x372d, 0x372e, 0x372f, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, - 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c, 0x373d, 0x373e, - 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744, 0x3745, 0x3746, 0x3747, - 0x3748, 0x3749, 0x374a, 0x374b, 0x374c, 0x374d, 0x374e, 0x374f, 0x3750, - 0x3751, 0x3752, 0x3753, 0x3754, 0x3755, 0x3756, 0x3757, 0x3758, 0x3759, - 0x375a, 0x375b, 0x375c, 0x375d, 0x375e, 0x375f, 0x3760, 0x3761, 0x3762, - 0x3763, 0x3764, 0x3765, 0x3766, 0x3767, 0x3768, 0x3769, 0x376a, 0x376b, - 0x376c, 0x376d, 0x376e, 0x376f, 0x3770, 0x3771, 0x3772, 0x3773, 0x3774, - 0x3775, 0x3776, 0x3777, 0x3778, 0x3779, 0x377a, 0x377b, 0x377c, 0x377d, - 0x377e, 0x377f, 0x3780, 0x3781, 0x3782, 0x3783, 0x3784, 0x3785, 0x3786, - 0x3787, 0x3788, 0x3789, 0x378a, 0x378b, 0x378c, 0x378d, 0x378e, 0x378f, - 0x3790, 0x3791, 0x3792, 0x3793, 0x3794, 0x3795, 0x3796, 0x3797, 0x3798, - 0x3799, 0x379a, 0x379b, 0x379c, 0x379d, 0x379e, 0x379f, 0x37a0, 0x37a1, - 0x37a2, 0x37a3, 0x37a4, 0x37a5, 0x37a6, 0x37a7, 0x37a8, 0x37a9, 0x37aa, - 0x37ab, 0x37ac, 0x37ad, 0x37ae, 0x37af, 0x37b0, 0x37b1, 0x37b2, 0x37b3, - 0x37b4, 0x37b5, 0x37b6, 0x37b7, 0x37b8, 0x37b9, 0x37ba, 0x37bb, 0x37bc, - 0x37bd, 0x37be, 0x37bf, 0x37c0, 0x37c1, 0x37c2, 0x37c3, 0x37c4, 0x37c5, - 0x37c6, 0x37c7, 0x37c8, 0x37c9, 0x37ca, 0x37cb, 0x37cc, 0x37cd, 0x37ce, - 0x37cf, 0x37d0, 0x37d1, 0x37d2, 0x37d3, 0x37d4, 0x37d5, 0x37d6, 0x37d7, - 0x37d8, 0x37d9, 0x37da, 0x37db, 0x37dc, 0x37dd, 0x37de, 0x37df, 0x37e0, - 0x37e1, 0x37e2, 0x37e3, 0x37e4, 0x37e5, 0x37e6, 0x37e7, 0x37e8, 0x37e9, - 0x37ea, 0x37eb, 0x37ec, 0x37ed, 0x37ee, 0x37ef, 0x37f0, 0x37f1, 0x37f2, - 0x37f3, 0x37f4, 0x37f5, 0x37f6, 0x37f7, 0x37f8, 0x37f9, 0x37fa, 0x37fb, - 0x37fc, 0x37fd, 0x37fe, 0x37ff, 0x3800, 0x3801, 0x3802, 0x3803, 0x3804, - 0x3805, 0x3806, 0x3807, 0x3808, 0x3809, 0x380a, 0x380b, 0x380c, 0x380d, - 0x380e, 0x380f, 0x3810, 0x3811, 0x3812, 0x3813, 0x3814, 0x3815, 0x3816, - 0x3817, 0x3818, 0x3819, 0x381a, 0x381b, 0x381c, 0x381d, 0x381e, 0x381f, - 0x3820, 0x3821, 0x3822, 0x3823, 0x3824, 0x3825, 0x3826, 0x3827, 0x3828, - 0x3829, 0x382a, 0x382b, 0x382c, 0x382d, 0x382e, 0x382f, 0x3830, 0x3831, - 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839, 0x383a, - 0x383b, 0x383c, 0x383d, 0x383e, 0x383f, 0x3840, 0x3841, 0x3842, 0x3843, - 0x3844, 0x3845, 0x3846, 0x3847, 0x3848, 0x3849, 0x384a, 0x384b, 0x384c, - 0x384d, 0x384e, 0x384f, 0x3850, 0x3851, 0x3852, 0x3853, 0x3854, 0x3855, - 0x3856, 0x3857, 0x3858, 0x3859, 0x385a, 0x385b, 0x385c, 0x385d, 0x385e, - 0x385f, 0x3860, 0x3861, 0x3862, 0x3863, 0x3864, 0x3865, 0x3866, 0x3867, - 0x3868, 0x3869, 0x386a, 0x386b, 0x386c, 0x386d, 0x386e, 0x386f, 0x3870, - 0x3871, 0x3872, 0x3873, 0x3874, 0x3875, 0x3876, 0x3877, 0x3878, 0x3879, - 0x387a, 0x387b, 0x387c, 0x387d, 0x387e, 0x387f, 0x3880, 0x3881, 0x3882, - 0x3883, 0x3884, 0x3885, 0x3886, 0x3887, 0x3888, 0x3889, 0x388a, 0x388b, - 0x388c, 0x388d, 0x388e, 0x388f, 0x3890, 0x3891, 0x3892, 0x3893, 0x3894, - 0x3895, 0x3896, 0x3897, 0x3898, 0x3899, 0x389a, 0x389b, 0x389c, 0x389d, - 0x389e, 0x389f, 0x38a0, 0x38a1, 0x38a2, 0x38a3, 0x38a4, 0x38a5, 0x38a6, - 0x38a7, 0x38a8, 0x38a9, 0x38aa, 0x38ab, 0x38ac, 0x38ad, 0x38ae, 0x38af, - 0x38b0, 0x38b1, 0x38b2, 0x38b3, 0x38b4, 0x38b5, 0x38b6, 0x38b7, 0x38b8, - 0x38b9, 0x38ba, 0x38bb, 0x38bc, 0x38bd, 0x38be, 0x38bf, 0x38c0, 0x38c1, - 0x38c2, 0x38c3, 0x38c4, 0x38c5, 0x38c6, 0x38c7, 0x38c8, 0x38c9, 0x38ca, - 0x38cb, 0x38cc, 0x38cd, 0x38ce, 0x38cf, 0x38d0, 0x38d1, 0x38d2, 0x38d3, - 0x38d4, 0x38d5, 0x38d6, 0x38d7, 0x38d8, 0x38d9, 0x38da, 0x38db, 0x38dc, - 0x38dd, 0x38de, 0x38df, 0x38e0, 0x38e1, 0x38e2, 0x38e3, 0x38e4, 0x38e5, - 0x38e6, 0x38e7, 0x38e8, 0x38e9, 0x38ea, 0x38eb, 0x38ec, 0x38ed, 0x38ee, - 0x38ef, 0x38f0, 0x38f1, 0x38f2, 0x38f3, 0x38f4, 0x38f5, 0x38f6, 0x38f7, - 0x38f8, 0x38f9, 0x38fa, 0x38fb, 0x38fc, 0x38fd, 0x38fe, 0x38ff, 0x3900, - 0x3901, 0x3902, 0x3903, 0x3904, 0x3905, 0x3906, 0x3907, 0x3908, 0x3909, - 0x390a, 0x390b, 0x390c, 0x390d, 0x390e, 0x390f, 0x3910, 0x3911, 0x3912, - 0x3913, 0x3914, 0x3915, 0x3916, 0x3917, 0x3918, 0x3919, 0x391a, 0x391b, - 0x391c, 0x391d, 0x391e, 0x391f, 0x3920, 0x3921, 0x3922, 0x3923, 0x3924, - 0x3925, 0x3926, 0x3927, 0x3928, 0x3929, 0x392a, 0x392b, 0x392c, 0x392d, - 0x392e, 0x392f, 0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, - 0x3937, 0x3938, 0x3939, 0x393a, 0x393b, 0x393c, 0x393d, 0x393e, 0x393f, - 0x3940, 0x3941, 0x3942, 0x3943, 0x3944, 0x3945, 0x3946, 0x3947, 0x3948, - 0x3949, 0x394a, 0x394b, 0x394c, 0x394d, 0x394e, 0x394f, 0x3950, 0x3951, - 0x3952, 0x3953, 0x3954, 0x3955, 0x3956, 0x3957, 0x3958, 0x3959, 0x395a, - 0x395b, 0x395c, 0x395d, 0x395e, 0x395f, 0x3960, 0x3961, 0x3962, 0x3963, - 0x3964, 0x3965, 0x3966, 0x3967, 0x3968, 0x3969, 0x396a, 0x396b, 0x396c, - 0x396d, 0x396e, 0x396f, 0x3970, 0x3971, 0x3972, 0x3973, 0x3974, 0x3975, - 0x3976, 0x3977, 0x3978, 0x3979, 0x397a, 0x397b, 0x397c, 0x397d, 0x397e, - 0x397f, 0x3980, 0x3981, 0x3982, 0x3983, 0x3984, 0x3985, 0x3986, 0x3987, - 0x3988, 0x3989, 0x398a, 0x398b, 0x398c, 0x398d, 0x398e, 0x398f, 0x3990, - 0x3991, 0x3992, 0x3993, 0x3994, 0x3995, 0x3996, 0x3997, 0x3998, 0x3999, - 0x399a, 0x399b, 0x399c, 0x399d, 0x399e, 0x399f, 0x39a0, 0x39a1, 0x39a2, - 0x39a3, 0x39a4, 0x39a5, 0x39a6, 0x39a7, 0x39a8, 0x39a9, 0x39aa, 0x39ab, - 0x39ac, 0x39ad, 0x39ae, 0x39af, 0x39b0, 0x39b1, 0x39b2, 0x39b3, 0x39b4, - 0x39b5, 0x39b6, 0x39b7, 0x39b8, 0x39b9, 0x39ba, 0x39bb, 0x39bc, 0x39bd, - 0x39be, 0x39bf, 0x39c0, 0x39c1, 0x39c2, 0x39c3, 0x39c4, 0x39c5, 0x39c6, - 0x39c7, 0x39c8, 0x39c9, 0x39ca, 0x39cb, 0x39cc, 0x39cd, 0x39ce, 0x39cf, - 0x39d0, 0x39d1, 0x39d2, 0x39d3, 0x39d4, 0x39d5, 0x39d6, 0x39d7, 0x39d8, - 0x39d9, 0x39da, 0x39db, 0x39dc, 0x39dd, 0x39de, 0x39df, 0x39e0, 0x39e1, - 0x39e2, 0x39e3, 0x39e4, 0x39e5, 0x39e6, 0x39e7, 0x39e8, 0x39e9, 0x39ea, - 0x39eb, 0x39ec, 0x39ed, 0x39ee, 0x39ef, 0x39f0, 0x39f1, 0x39f2, 0x39f3, - 0x39f4, 0x39f5, 0x39f6, 0x39f7, 0x39f8, 0x39f9, 0x39fa, 0x39fb, 0x39fc, - 0x39fd, 0x39fe, 0x39ff, 0x3a00, 0x3a01, 0x3a02, 0x3a03, 0x3a04, 0x3a05, - 0x3a06, 0x3a07, 0x3a08, 0x3a09, 0x3a0a, 0x3a0b, 0x3a0c, 0x3a0d, 0x3a0e, - 0x3a0f, 0x3a10, 0x3a11, 0x3a12, 0x3a13, 0x3a14, 0x3a15, 0x3a16, 0x3a17, - 0x3a18, 0x3a19, 0x3a1a, 0x3a1b, 0x3a1c, 0x3a1d, 0x3a1e, 0x3a1f, 0x3a20, - 0x3a21, 0x3a22, 0x3a23, 0x3a24, 0x3a25, 0x3a26, 0x3a27, 0x3a28, 0x3a29, - 0x3a2a, 0x3a2b, 0x3a2c, 0x3a2d, 0x3a2e, 0x3a2f, 0x3a30, 0x3a31, 0x3a32, - 0x3a33, 0x3a34, 0x3a35, 0x3a36, 0x3a37, 0x3a38, 0x3a39, 0x3a3a, 0x3a3b, - 0x3a3c, 0x3a3d, 0x3a3e, 0x3a3f, 0x3a40, 0x3a41, 0x3a42, 0x3a43, 0x3a44, - 0x3a45, 0x3a46, 0x3a47, 0x3a48, 0x3a49, 0x3a4a, 0x3a4b, 0x3a4c, 0x3a4d, - 0x3a4e, 0x3a4f, 0x3a50, 0x3a51, 0x3a52, 0x3a53, 0x3a54, 0x3a55, 0x3a56, - 0x3a57, 0x3a58, 0x3a59, 0x3a5a, 0x3a5b, 0x3a5c, 0x3a5d, 0x3a5e, 0x3a5f, - 0x3a60, 0x3a61, 0x3a62, 0x3a63, 0x3a64, 0x3a65, 0x3a66, 0x3a67, 0x3a68, - 0x3a69, 0x3a6a, 0x3a6b, 0x3a6c, 0x3a6d, 0x3a6e, 0x3a6f, 0x3a70, 0x3a71, - 0x3a72, 0x3a73, 0x3a74, 0x3a75, 0x3a76, 0x3a77, 0x3a78, 0x3a79, 0x3a7a, - 0x3a7b, 0x3a7c, 0x3a7d, 0x3a7e, 0x3a7f, 0x3a80, 0x3a81, 0x3a82, 0x3a83, - 0x3a84, 0x3a85, 0x3a86, 0x3a87, 0x3a88, 0x3a89, 0x3a8a, 0x3a8b, 0x3a8c, - 0x3a8d, 0x3a8e, 0x3a8f, 0x3a90, 0x3a91, 0x3a92, 0x3a93, 0x3a94, 0x3a95, - 0x3a96, 0x3a97, 0x3a98, 0x3a99, 0x3a9a, 0x3a9b, 0x3a9c, 0x3a9d, 0x3a9e, - 0x3a9f, 0x3aa0, 0x3aa1, 0x3aa2, 0x3aa3, 0x3aa4, 0x3aa5, 0x3aa6, 0x3aa7, - 0x3aa8, 0x3aa9, 0x3aaa, 0x3aab, 0x3aac, 0x3aad, 0x3aae, 0x3aaf, 0x3ab0, - 0x3ab1, 0x3ab2, 0x3ab3, 0x3ab4, 0x3ab5, 0x3ab6, 0x3ab7, 0x3ab8, 0x3ab9, - 0x3aba, 0x3abb, 0x3abc, 0x3abd, 0x3abe, 0x3abf, 0x3ac0, 0x3ac1, 0x3ac2, - 0x3ac3, 0x3ac4, 0x3ac5, 0x3ac6, 0x3ac7, 0x3ac8, 0x3ac9, 0x3aca, 0x3acb, - 0x3acc, 0x3acd, 0x3ace, 0x3acf, 0x3ad0, 0x3ad1, 0x3ad2, 0x3ad3, 0x3ad4, - 0x3ad5, 0x3ad6, 0x3ad7, 0x3ad8, 0x3ad9, 0x3ada, 0x3adb, 0x3adc, 0x3add, - 0x3ade, 0x3adf, 0x3ae0, 0x3ae1, 0x3ae2, 0x3ae3, 0x3ae4, 0x3ae5, 0x3ae6, - 0x3ae7, 0x3ae8, 0x3ae9, 0x3aea, 0x3aeb, 0x3aec, 0x3aed, 0x3aee, 0x3aef, - 0x3af0, 0x3af1, 0x3af2, 0x3af3, 0x3af4, 0x3af5, 0x3af6, 0x3af7, 0x3af8, - 0x3af9, 0x3afa, 0x3afb, 0x3afc, 0x3afd, 0x3afe, 0x3aff, 0x3b00, 0x3b01, - 0x3b02, 0x3b03, 0x3b04, 0x3b05, 0x3b06, 0x3b07, 0x3b08, 0x3b09, 0x3b0a, - 0x3b0b, 0x3b0c, 0x3b0d, 0x3b0e, 0x3b0f, 0x3b10, 0x3b11, 0x3b12, 0x3b13, - 0x3b14, 0x3b15, 0x3b16, 0x3b17, 0x3b18, 0x3b19, 0x3b1a, 0x3b1b, 0x3b1c, - 0x3b1d, 0x3b1e, 0x3b1f, 0x3b20, 0x3b21, 0x3b22, 0x3b23, 0x3b24, 0x3b25, - 0x3b26, 0x3b27, 0x3b28, 0x3b29, 0x3b2a, 0x3b2b, 0x3b2c, 0x3b2d, 0x3b2e, - 0x3b2f, 0x3b30, 0x3b31, 0x3b32, 0x3b33, 0x3b34, 0x3b35, 0x3b36, 0x3b37, - 0x3b38, 0x3b39, 0x3b3a, 0x3b3b, 0x3b3c, 0x3b3d, 0x3b3e, 0x3b3f, 0x3b40, - 0x3b41, 0x3b42, 0x3b43, 0x3b44, 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49, - 0x3b4a, 0x3b4b, 0x3b4c, 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, 0x3b52, - 0x3b53, 0x3b54, 0x3b55, 0x3b56, 0x3b57, 0x3b58, 0x3b59, 0x3b5a, 0x3b5b, - 0x3b5c, 0x3b5d, 0x3b5e, 0x3b5f, 0x3b60, 0x3b61, 0x3b62, 0x3b63, 0x3b64, - 0x3b65, 0x3b66, 0x3b67, 0x3b68, 0x3b69, 0x3b6a, 0x3b6b, 0x3b6c, 0x3b6d, - 0x3b6e, 0x3b6f, 0x3b70, 0x3b71, 0x3b72, 0x3b73, 0x3b74, 0x3b75, 0x3b76, - 0x3b77, 0x3b78, 0x3b79, 0x3b7a, 0x3b7b, 0x3b7c, 0x3b7d, 0x3b7e, 0x3b7f, - 0x3b80, 0x3b81, 0x3b82, 0x3b83, 0x3b84, 0x3b85, 0x3b86, 0x3b87, 0x3b88, - 0x3b89, 0x3b8a, 0x3b8b, 0x3b8c, 0x3b8d, 0x3b8e, 0x3b8f, 0x3b90, 0x3b91, - 0x3b92, 0x3b93, 0x3b94, 0x3b95, 0x3b96, 0x3b97, 0x3b98, 0x3b99, 0x3b9a, - 0x3b9b, 0x3b9c, 0x3b9d, 0x3b9e, 0x3b9f, 0x3ba0, 0x3ba1, 0x3ba2, 0x3ba3, - 0x3ba4, 0x3ba5, 0x3ba6, 0x3ba7, 0x3ba8, 0x3ba9, 0x3baa, 0x3bab, 0x3bac, - 0x3bad, 0x3bae, 0x3baf, 0x3bb0, 0x3bb1, 0x3bb2, 0x3bb3, 0x3bb4, 0x3bb5, - 0x3bb6, 0x3bb7, 0x3bb8, 0x3bb9, 0x3bba, 0x3bbb, 0x3bbc, 0x3bbd, 0x3bbe, - 0x3bbf, 0x3bc0, 0x3bc1, 0x3bc2, 0x3bc3, 0x3bc4, 0x3bc5, 0x3bc6, 0x3bc7, - 0x3bc8, 0x3bc9, 0x3bca, 0x3bcb, 0x3bcc, 0x3bcd, 0x3bce, 0x3bcf, 0x3bd0, - 0x3bd1, 0x3bd2, 0x3bd3, 0x3bd4, 0x3bd5, 0x3bd6, 0x3bd7, 0x3bd8, 0x3bd9, - 0x3bda, 0x3bdb, 0x3bdc, 0x3bdd, 0x3bde, 0x3bdf, 0x3be0, 0x3be1, 0x3be2, - 0x3be3, 0x3be4, 0x3be5, 0x3be6, 0x3be7, 0x3be8, 0x3be9, 0x3bea, 0x3beb, - 0x3bec, 0x3bed, 0x3bee, 0x3bef, 0x3bf0, 0x3bf1, 0x3bf2, 0x3bf3, 0x3bf4, - 0x3bf5, 0x3bf6, 0x3bf7, 0x3bf8, 0x3bf9, 0x3bfa, 0x3bfb, 0x3bfc, 0x3bfd, - 0x3bfe, 0x3bff, 0x3c00, 0x3c01, 0x3c02, 0x3c03, 0x3c04, 0x3c05, 0x3c06, - 0x3c07, 0x3c08, 0x3c09, 0x3c0a, 0x3c0b, 0x3c0c, 0x3c0d, 0x3c0e, 0x3c0f, - 0x3c10, 0x3c11, 0x3c12, 0x3c13, 0x3c14, 0x3c15, 0x3c16, 0x3c17, 0x3c18, - 0x3c19, 0x3c1a, 0x3c1b, 0x3c1c, 0x3c1d, 0x3c1e, 0x3c1f, 0x3c20, 0x3c21, - 0x3c22, 0x3c23, 0x3c24, 0x3c25, 0x3c26, 0x3c27, 0x3c28, 0x3c29, 0x3c2a, - 0x3c2b, 0x3c2c, 0x3c2d, 0x3c2e, 0x3c2f, 0x3c30, 0x3c31, 0x3c32, 0x3c33, - 0x3c34, 0x3c35, 0x3c36, 0x3c37, 0x3c38, 0x3c39, 0x3c3a, 0x3c3b, 0x3c3c, - 0x3c3d, 0x3c3e, 0x3c3f, 0x3c40, 0x3c41, 0x3c42, 0x3c43, 0x3c44, 0x3c45, - 0x3c46, 0x3c47, 0x3c48, 0x3c49, 0x3c4a, 0x3c4b, 0x3c4c, 0x3c4d, 0x3c4e, - 0x3c4f, 0x3c50, 0x3c51, 0x3c52, 0x3c53, 0x3c54, 0x3c55, 0x3c56, 0x3c57, - 0x3c58, 0x3c59, 0x3c5a, 0x3c5b, 0x3c5c, 0x3c5d, 0x3c5e, 0x3c5f, 0x3c60, - 0x3c61, 0x3c62, 0x3c63, 0x3c64, 0x3c65, 0x3c66, 0x3c67, 0x3c68, 0x3c69, - 0x3c6a, 0x3c6b, 0x3c6c, 0x3c6d, 0x3c6e, 0x3c6f, 0x3c70, 0x3c71, 0x3c72, - 0x3c73, 0x3c74, 0x3c75, 0x3c76, 0x3c77, 0x3c78, 0x3c79, 0x3c7a, 0x3c7b, - 0x3c7c, 0x3c7d, 0x3c7e, 0x3c7f, 0x3c80, 0x3c81, 0x3c82, 0x3c83, 0x3c84, - 0x3c85, 0x3c86, 0x3c87, 0x3c88, 0x3c89, 0x3c8a, 0x3c8b, 0x3c8c, 0x3c8d, - 0x3c8e, 0x3c8f, 0x3c90, 0x3c91, 0x3c92, 0x3c93, 0x3c94, 0x3c95, 0x3c96, - 0x3c97, 0x3c98, 0x3c99, 0x3c9a, 0x3c9b, 0x3c9c, 0x3c9d, 0x3c9e, 0x3c9f, - 0x3ca0, 0x3ca1, 0x3ca2, 0x3ca3, 0x3ca4, 0x3ca5, 0x3ca6, 0x3ca7, 0x3ca8, - 0x3ca9, 0x3caa, 0x3cab, 0x3cac, 0x3cad, 0x3cae, 0x3caf, 0x3cb0, 0x3cb1, - 0x3cb2, 0x3cb3, 0x3cb4, 0x3cb5, 0x3cb6, 0x3cb7, 0x3cb8, 0x3cb9, 0x3cba, - 0x3cbb, 0x3cbc, 0x3cbd, 0x3cbe, 0x3cbf, 0x3cc0, 0x3cc1, 0x3cc2, 0x3cc3, - 0x3cc4, 0x3cc5, 0x3cc6, 0x3cc7, 0x3cc8, 0x3cc9, 0x3cca, 0x3ccb, 0x3ccc, - 0x3ccd, 0x3cce, 0x3ccf, 0x3cd0, 0x3cd1, 0x3cd2, 0x3cd3, 0x3cd4, 0x3cd5, - 0x3cd6, 0x3cd7, 0x3cd8, 0x3cd9, 0x3cda, 0x3cdb, 0x3cdc, 0x3cdd, 0x3cde, - 0x3cdf, 0x3ce0, 0x3ce1, 0x3ce2, 0x3ce3, 0x3ce4, 0x3ce5, 0x3ce6, 0x3ce7, - 0x3ce8, 0x3ce9, 0x3cea, 0x3ceb, 0x3cec, 0x3ced, 0x3cee, 0x3cef, 0x3cf0, - 0x3cf1, 0x3cf2, 0x3cf3, 0x3cf4, 0x3cf5, 0x3cf6, 0x3cf7, 0x3cf8, 0x3cf9, - 0x3cfa, 0x3cfb, 0x3cfc, 0x3cfd, 0x3cfe, 0x3cff, 0x3d00, 0x3d01, 0x3d02, - 0x3d03, 0x3d04, 0x3d05, 0x3d06, 0x3d07, 0x3d08, 0x3d09, 0x3d0a, 0x3d0b, - 0x3d0c, 0x3d0d, 0x3d0e, 0x3d0f, 0x3d10, 0x3d11, 0x3d12, 0x3d13, 0x3d14, - 0x3d15, 0x3d16, 0x3d17, 0x3d18, 0x3d19, 0x3d1a, 0x3d1b, 0x3d1c, 0x3d1d, - 0x3d1e, 0x3d1f, 0x3d20, 0x3d21, 0x3d22, 0x3d23, 0x3d24, 0x3d25, 0x3d26, - 0x3d27, 0x3d28, 0x3d29, 0x3d2a, 0x3d2b, 0x3d2c, 0x3d2d, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0x4f3d, 0x4f73, 0x5047, 0x50f9, 0x52a0, 0x53ef, 0x5475, - 0x54e5, 0x5609, 0x5ac1, 0x5bb6, 0x6687, 0x67b6, 0x67b7, 0x67ef, 0x6b4c, - 0x73c2, 0x75c2, 0x7a3c, 0x82db, 0x8304, 0x8857, 0x8888, 0x8a36, 0x8cc8, - 0x8dcf, 0x8efb, 0x8fe6, 0x99d5, 0x523b, 0x5374, 0x5404, 0x606a, 0x6164, - 0x6bbc, 0x73cf, 0x811a, 0x89ba, 0x89d2, 0x95a3, 0x4f83, 0x520a, 0x58be, - 0x5978, 0x59e6, 0x5e72, 0x5e79, 0x61c7, 0x63c0, 0x6746, 0x67ec, 0x687f, - 0x6f97, 0x764e, 0x770b, 0x78f5, 0x7a08, 0x7aff, 0x7c21, 0x809d, 0x826e, - 0x8271, 0x8aeb, 0x9593, 0x4e6b, 0x559d, 0x66f7, 0x6e34, 0x78a3, 0x7aed, - 0x845b, 0x8910, 0x874e, 0x97a8, 0x52d8, 0x574e, 0x582a, 0x5d4c, 0x611f, - 0x61be, 0x6221, 0x6562, 0x67d1, 0x6a44, 0x6e1b, 0x7518, 0x75b3, 0x76e3, - 0x77b0, 0x7d3a, 0x90af, 0x9451, 0x9452, 0x9f95, 0x5323, 0x5cac, 0x7532, - 0x80db, 0x9240, 0x9598, 0x525b, 0x5808, 0x59dc, 0x5ca1, 0x5d17, 0x5eb7, - 0x5f3a, 0x5f4a, 0x6177, 0x6c5f, 0x757a, 0x7586, 0x7ce0, 0x7d73, 0x7db1, - 0x7f8c, 0x8154, 0x8221, 0x8591, 0x8941, 0x8b1b, 0x92fc, 0x964d, 0x9c47, - 0x4ecb, 0x4ef7, 0x500b, 0x51f1, 0x584f, 0x6137, 0x613e, 0x6168, 0x6539, - 0x69ea, 0x6f11, 0x75a5, 0x7686, 0x76d6, 0x7b87, 0x82a5, 0x84cb, 0xf900, - 0x93a7, 0x958b, 0x5580, 0x5ba2, 0x5751, 0xf901, 0x7cb3, 0x7fb9, 0x91b5, - 0x5028, 0x53bb, 0x5c45, 0x5de8, 0x62d2, 0x636e, 0x64da, 0x64e7, 0x6e20, - 0x70ac, 0x795b, 0x8ddd, 0x8e1e, 0xf902, 0x907d, 0x9245, 0x92f8, 0x4e7e, - 0x4ef6, 0x5065, 0x5dfe, 0x5efa, 0x6106, 0x6957, 0x8171, 0x8654, 0x8e47, - 0x9375, 0x9a2b, 0x4e5e, 0x5091, 0x6770, 0x6840, 0x5109, 0x528d, 0x5292, - 0x6aa2, 0x77bc, 0x9210, 0x9ed4, 0x52ab, 0x602f, 0x8ff2, 0x5048, 0x61a9, - 0x63ed, 0x64ca, 0x683c, 0x6a84, 0x6fc0, 0x8188, 0x89a1, 0x9694, 0x5805, - 0x727d, 0x72ac, 0x7504, 0x7d79, 0x7e6d, 0x80a9, 0x898b, 0x8b74, 0x9063, - 0x9d51, 0x6289, 0x6c7a, 0x6f54, 0x7d50, 0x7f3a, 0x8a23, 0x517c, 0x614a, - 0x7b9d, 0x8b19, 0x9257, 0x938c, 0x4eac, 0x4fd3, 0x501e, 0x50be, 0x5106, - 0x52c1, 0x52cd, 0x537f, 0x5770, 0x5883, 0x5e9a, 0x5f91, 0x6176, 0x61ac, - 0x64ce, 0x656c, 0x666f, 0x66bb, 0x66f4, 0x6897, 0x6d87, 0x7085, 0x70f1, - 0x749f, 0x74a5, 0x74ca, 0x75d9, 0x786c, 0x78ec, 0x7adf, 0x7af6, 0x7d45, - 0x7d93, 0x8015, 0x803f, 0x811b, 0x8396, 0x8b66, 0x8f15, 0x9015, 0x93e1, - 0x9803, 0x9838, 0x9a5a, 0x9be8, 0x4fc2, 0x5553, 0x583a, 0x5951, 0x5b63, - 0x5c46, 0x60b8, 0x6212, 0x6842, 0x68b0, 0x68e8, 0x6eaa, 0x754c, 0x7678, - 0x78ce, 0x7a3d, 0x7cfb, 0x7e6b, 0x7e7c, 0x8a08, 0x8aa1, 0x8c3f, 0x968e, - 0x9dc4, 0x53e4, 0x53e9, 0x544a, 0x5471, 0x56fa, 0x59d1, 0x5b64, 0x5c3b, - 0x5eab, 0x62f7, 0x6537, 0x6545, 0x6572, 0x66a0, 0x67af, 0x69c1, 0x6cbd, - 0x75fc, 0x7690, 0x777e, 0x7a3f, 0x7f94, 0x8003, 0x80a1, 0x818f, 0x82e6, - 0x82fd, 0x83f0, 0x85c1, 0x8831, 0x88b4, 0x8aa5, 0xf903, 0x8f9c, 0x932e, - 0x96c7, 0x9867, 0x9ad8, 0x9f13, 0x54ed, 0x659b, 0x66f2, 0x688f, 0x7a40, - 0x8c37, 0x9d60, 0x56f0, 0x5764, 0x5d11, 0x6606, 0x68b1, 0x68cd, 0x6efe, - 0x7428, 0x889e, 0x9be4, 0x6c68, 0xf904, 0x9aa8, 0x4f9b, 0x516c, 0x5171, - 0x529f, 0x5b54, 0x5de5, 0x6050, 0x606d, 0x62f1, 0x63a7, 0x653b, 0x73d9, - 0x7a7a, 0x86a3, 0x8ca2, 0x978f, 0x4e32, 0x5be1, 0x6208, 0x679c, 0x74dc, - 0x79d1, 0x83d3, 0x8a87, 0x8ab2, 0x8de8, 0x904e, 0x934b, 0x9846, 0x5ed3, - 0x69e8, 0x85ff, 0x90ed, 0xf905, 0x51a0, 0x5b98, 0x5bec, 0x6163, 0x68fa, - 0x6b3e, 0x704c, 0x742f, 0x74d8, 0x7ba1, 0x7f50, 0x83c5, 0x89c0, 0x8cab, - 0x95dc, 0x9928, 0x522e, 0x605d, 0x62ec, 0x9002, 0x4f8a, 0x5149, 0x5321, - 0x58d9, 0x5ee3, 0x66e0, 0x6d38, 0x709a, 0x72c2, 0x73d6, 0x7b50, 0x80f1, - 0x945b, 0x5366, 0x639b, 0x7f6b, 0x4e56, 0x5080, 0x584a, 0x58de, 0x602a, - 0x6127, 0x62d0, 0x69d0, 0x9b41, 0x5b8f, 0x7d18, 0x80b1, 0x8f5f, 0x4ea4, - 0x50d1, 0x54ac, 0x55ac, 0x5b0c, 0x5da0, 0x5de7, 0x652a, 0x654e, 0x6821, - 0x6a4b, 0x72e1, 0x768e, 0x77ef, 0x7d5e, 0x7ff9, 0x81a0, 0x854e, 0x86df, - 0x8f03, 0x8f4e, 0x90ca, 0x9903, 0x9a55, 0x9bab, 0x4e18, 0x4e45, 0x4e5d, - 0x4ec7, 0x4ff1, 0x5177, 0x52fe, 0x5340, 0x53e3, 0x53e5, 0x548e, 0x5614, - 0x5775, 0x57a2, 0x5bc7, 0x5d87, 0x5ed0, 0x61fc, 0x62d8, 0x6551, 0x67b8, - 0x67e9, 0x69cb, 0x6b50, 0x6bc6, 0x6bec, 0x6c42, 0x6e9d, 0x7078, 0x72d7, - 0x7396, 0x7403, 0x77bf, 0x77e9, 0x7a76, 0x7d7f, 0x8009, 0x81fc, 0x8205, - 0x820a, 0x82df, 0x8862, 0x8b33, 0x8cfc, 0x8ec0, 0x9011, 0x90b1, 0x9264, - 0x92b6, 0x99d2, 0x9a45, 0x9ce9, 0x9dd7, 0x9f9c, 0x570b, 0x5c40, 0x83ca, - 0x97a0, 0x97ab, 0x9eb4, 0x541b, 0x7a98, 0x7fa4, 0x88d9, 0x8ecd, 0x90e1, - 0x5800, 0x5c48, 0x6398, 0x7a9f, 0x5bae, 0x5f13, 0x7a79, 0x7aae, 0x828e, - 0x8eac, 0x5026, 0x5238, 0x52f8, 0x5377, 0x5708, 0x62f3, 0x6372, 0x6b0a, - 0x6dc3, 0x7737, 0x53a5, 0x7357, 0x8568, 0x8e76, 0x95d5, 0x673a, 0x6ac3, - 0x6f70, 0x8a6d, 0x8ecc, 0x994b, 0xf906, 0x6677, 0x6b78, 0x8cb4, 0x9b3c, - 0xf907, 0x53eb, 0x572d, 0x594e, 0x63c6, 0x69fb, 0x73ea, 0x7845, 0x7aba, - 0x7ac5, 0x7cfe, 0x8475, 0x898f, 0x8d73, 0x9035, 0x95a8, 0x52fb, 0x5747, - 0x7547, 0x7b60, 0x83cc, 0x921e, 0xf908, 0x6a58, 0x514b, 0x524b, 0x5287, - 0x621f, 0x68d8, 0x6975, 0x9699, 0x50c5, 0x52a4, 0x52e4, 0x61c3, 0x65a4, - 0x6839, 0x69ff, 0x747e, 0x7b4b, 0x82b9, 0x83eb, 0x89b2, 0x8b39, 0x8fd1, - 0x9949, 0xf909, 0x4eca, 0x5997, 0x64d2, 0x6611, 0x6a8e, 0x7434, 0x7981, - 0x79bd, 0x82a9, 0x887e, 0x887f, 0x895f, 0xf90a, 0x9326, 0x4f0b, 0x53ca, - 0x6025, 0x6271, 0x6c72, 0x7d1a, 0x7d66, 0x4e98, 0x5162, 0x77dc, 0x80af, - 0x4f01, 0x4f0e, 0x5176, 0x5180, 0x55dc, 0x5668, 0x573b, 0x57fa, 0x57fc, - 0x5914, 0x5947, 0x5993, 0x5bc4, 0x5c90, 0x5d0e, 0x5df1, 0x5e7e, 0x5fcc, - 0x6280, 0x65d7, 0x65e3, 0x671e, 0x671f, 0x675e, 0x68cb, 0x68c4, 0x6a5f, - 0x6b3a, 0x6c23, 0x6c7d, 0x6c82, 0x6dc7, 0x7398, 0x7426, 0x742a, 0x7482, - 0x74a3, 0x7578, 0x757f, 0x7881, 0x78ef, 0x7941, 0x7947, 0x7948, 0x797a, - 0x7b95, 0x7d00, 0x7dba, 0x7f88, 0x8006, 0x802d, 0x808c, 0x8a18, 0x8b4f, - 0x8c48, 0x8d77, 0x9321, 0x9324, 0x98e2, 0x9951, 0x9a0e, 0x9a0f, 0x9a65, - 0x9e92, 0x7dca, 0x4f76, 0x5409, 0x62ee, 0x6854, 0x91d1, 0x55ab, 0x513a, - 0xf90b, 0xf90c, 0x5a1c, 0x61e6, 0xf90d, 0x62cf, 0x62ff, 0xf90e, 0xf90f, - 0xf910, 0xf911, 0xf912, 0xf913, 0x90a3, 0xf914, 0xf915, 0xf916, 0xf917, - 0xf918, 0x8afe, 0xf919, 0xf91a, 0xf91b, 0xf91c, 0x6696, 0xf91d, 0x7156, - 0xf91e, 0xf91f, 0x96e3, 0xf920, 0x634f, 0x637a, 0x5357, 0xf921, 0x678f, - 0x6960, 0x6e73, 0xf922, 0x7537, 0xf923, 0xf924, 0xf925, 0x7d0d, 0xf926, - 0xf927, 0x8872, 0x56ca, 0x5a18, 0xf928, 0xf929, 0xf92a, 0xf92b, 0xf92c, - 0x4e43, 0xf92d, 0x5167, 0x5948, 0x67f0, 0x8010, 0xf92e, 0x5973, 0x5e74, - 0x649a, 0x79ca, 0x5ff5, 0x606c, 0x62c8, 0x637b, 0x5be7, 0x5bd7, 0x52aa, - 0xf92f, 0x5974, 0x5f29, 0x6012, 0xf930, 0xf931, 0xf932, 0x7459, 0xf933, - 0xf934, 0xf935, 0xf936, 0xf937, 0xf938, 0x99d1, 0xf939, 0xf93a, 0xf93b, - 0xf93c, 0xf93d, 0xf93e, 0xf93f, 0xf940, 0xf941, 0xf942, 0xf943, 0x6fc3, - 0xf944, 0xf945, 0x81bf, 0x8fb2, 0x60f1, 0xf946, 0xf947, 0x8166, 0xf948, - 0xf949, 0x5c3f, 0xf94a, 0xf94b, 0xf94c, 0xf94d, 0xf94e, 0xf94f, 0xf950, - 0xf951, 0x5ae9, 0x8a25, 0x677b, 0x7d10, 0xf952, 0xf953, 0xf954, 0xf955, - 0xf956, 0xf957, 0x80fd, 0xf958, 0xf959, 0x5c3c, 0x6ce5, 0x533f, 0x6eba, - 0x591a, 0x8336, 0x4e39, 0x4eb6, 0x4f46, 0x55ae, 0x5718, 0x58c7, 0x5f56, - 0x65b7, 0x65e6, 0x6a80, 0x6bb5, 0x6e4d, 0x77ed, 0x7aef, 0x7c1e, 0x7dde, - 0x86cb, 0x8892, 0x9132, 0x935b, 0x64bb, 0x6fbe, 0x737a, 0x75b8, 0x9054, - 0x5556, 0x574d, 0x61ba, 0x64d4, 0x66c7, 0x6de1, 0x6e5b, 0x6f6d, 0x6fb9, - 0x75f0, 0x8043, 0x81bd, 0x8541, 0x8983, 0x8ac7, 0x8b5a, 0x931f, 0x6c93, - 0x7553, 0x7b54, 0x8e0f, 0x905d, 0x5510, 0x5802, 0x5858, 0x5e62, 0x6207, - 0x649e, 0x68e0, 0x7576, 0x7cd6, 0x87b3, 0x9ee8, 0x4ee3, 0x5788, 0x576e, - 0x5927, 0x5c0d, 0x5cb1, 0x5e36, 0x5f85, 0x6234, 0x64e1, 0x73b3, 0x81fa, - 0x888b, 0x8cb8, 0x968a, 0x9edb, 0x5b85, 0x5fb7, 0x60b3, 0x5012, 0x5200, - 0x5230, 0x5716, 0x5835, 0x5857, 0x5c0e, 0x5c60, 0x5cf6, 0x5d8b, 0x5ea6, - 0x5f92, 0x60bc, 0x6311, 0x6389, 0x6417, 0x6843, 0x68f9, 0x6ac2, 0x6dd8, - 0x6e21, 0x6ed4, 0x6fe4, 0x71fe, 0x76dc, 0x7779, 0x79b1, 0x7a3b, 0x8404, - 0x89a9, 0x8ced, 0x8df3, 0x8e48, 0x9003, 0x9014, 0x9053, 0x90fd, 0x934d, - 0x9676, 0x97dc, 0x6bd2, 0x7006, 0x7258, 0x72a2, 0x7368, 0x7763, 0x79bf, - 0x7be4, 0x7e9b, 0x8b80, 0x58a9, 0x60c7, 0x6566, 0x65fd, 0x66be, 0x6c8c, - 0x711e, 0x71c9, 0x8c5a, 0x9813, 0x4e6d, 0x7a81, 0x4edd, 0x51ac, 0x51cd, - 0x52d5, 0x540c, 0x61a7, 0x6771, 0x6850, 0x68df, 0x6d1e, 0x6f7c, 0x75bc, - 0x77b3, 0x7ae5, 0x80f4, 0x8463, 0x9285, 0x515c, 0x6597, 0x675c, 0x6793, - 0x75d8, 0x7ac7, 0x8373, 0xf95a, 0x8c46, 0x9017, 0x982d, 0x5c6f, 0x81c0, - 0x829a, 0x9041, 0x906f, 0x920d, 0x5f97, 0x5d9d, 0x6a59, 0x71c8, 0x767b, - 0x7b49, 0x85e4, 0x8b04, 0x9127, 0x9a30, 0x5587, 0x61f6, 0xf95b, 0x7669, - 0x7f85, 0x863f, 0x87ba, 0x88f8, 0x908f, 0xf95c, 0x6d1b, 0x70d9, 0x73de, - 0x7d61, 0x843d, 0xf95d, 0x916a, 0x99f1, 0xf95e, 0x4e82, 0x5375, 0x6b04, - 0x6b12, 0x703e, 0x721b, 0x862d, 0x9e1e, 0x524c, 0x8fa3, 0x5d50, 0x64e5, - 0x652c, 0x6b16, 0x6feb, 0x7c43, 0x7e9c, 0x85cd, 0x8964, 0x89bd, 0x62c9, - 0x81d8, 0x881f, 0x5eca, 0x6717, 0x6d6a, 0x72fc, 0x7405, 0x746f, 0x8782, - 0x90de, 0x4f86, 0x5d0d, 0x5fa0, 0x840a, 0x51b7, 0x63a0, 0x7565, 0x4eae, - 0x5006, 0x5169, 0x51c9, 0x6881, 0x6a11, 0x7cae, 0x7cb1, 0x7ce7, 0x826f, - 0x8ad2, 0x8f1b, 0x91cf, 0x4fb6, 0x5137, 0x52f5, 0x5442, 0x5eec, 0x616e, - 0x623e, 0x65c5, 0x6ada, 0x6ffe, 0x792a, 0x85dc, 0x8823, 0x95ad, 0x9a62, - 0x9a6a, 0x9e97, 0x9ece, 0x529b, 0x66c6, 0x6b77, 0x701d, 0x792b, 0x8f62, - 0x9742, 0x6190, 0x6200, 0x6523, 0x6f23, 0x7149, 0x7489, 0x7df4, 0x806f, - 0x84ee, 0x8f26, 0x9023, 0x934a, 0x51bd, 0x5217, 0x52a3, 0x6d0c, 0x70c8, - 0x88c2, 0x5ec9, 0x6582, 0x6bae, 0x6fc2, 0x7c3e, 0x7375, 0x4ee4, 0x4f36, - 0x56f9, 0xf95f, 0x5cba, 0x5dba, 0x601c, 0x73b2, 0x7b2d, 0x7f9a, 0x7fce, - 0x8046, 0x901e, 0x9234, 0x96f6, 0x9748, 0x9818, 0x9f61, 0x4f8b, 0x6fa7, - 0x79ae, 0x91b4, 0x96b7, 0x52de, 0xf960, 0x6488, 0x64c4, 0x6ad3, 0x6f5e, - 0x7018, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def, 0x8f05, 0x9732, - 0x9b6f, 0x9dfa, 0x9e75, 0x788c, 0x797f, 0x7da0, 0x83c9, 0x9304, 0x9e7f, - 0x9e93, 0x8ad6, 0x58df, 0x5f04, 0x6727, 0x7027, 0x74cf, 0x7c60, 0x807e, - 0x5121, 0x7028, 0x7262, 0x78ca, 0x8cc2, 0x8cda, 0x8cf4, 0x96f7, 0x4e86, - 0x50da, 0x5bee, 0x5ed6, 0x6599, 0x71ce, 0x7642, 0x77ad, 0x804a, 0x84fc, - 0x907c, 0x9b27, 0x9f8d, 0x58d8, 0x5a41, 0x5c62, 0x6a13, 0x6dda, 0x6f0f, - 0x763b, 0x7d2f, 0x7e37, 0x851e, 0x8938, 0x93e4, 0x964b, 0x5289, 0x65d2, - 0x67f3, 0x69b4, 0x6d41, 0x6e9c, 0x700f, 0x7409, 0x7460, 0x7559, 0x7624, - 0x786b, 0x8b2c, 0x985e, 0x516d, 0x622e, 0x9678, 0x4f96, 0x502b, 0x5d19, - 0x6dea, 0x7db8, 0x8f2a, 0x5f8b, 0x6144, 0x6817, 0xf961, 0x9686, 0x52d2, - 0x808b, 0x51dc, 0x51cc, 0x695e, 0x7a1c, 0x7dbe, 0x83f1, 0x9675, 0x4fda, - 0x5229, 0x5398, 0x540f, 0x550e, 0x5c65, 0x60a7, 0x674e, 0x68a8, 0x6d6c, - 0x7281, 0x72f8, 0x7406, 0x7483, 0xf962, 0x75e2, 0x7c6c, 0x7f79, 0x7fb8, - 0x8389, 0x88cf, 0x88e1, 0x91cc, 0x91d0, 0x96e2, 0x9bc9, 0x541d, 0x6f7e, - 0x71d0, 0x7498, 0x85fa, 0x8eaa, 0x96a3, 0x9c57, 0x9e9f, 0x6797, 0x6dcb, - 0x7433, 0x81e8, 0x9716, 0x782c, 0x7acb, 0x7b20, 0x7c92, 0x6469, 0x746a, - 0x75f2, 0x78bc, 0x78e8, 0x99ac, 0x9b54, 0x9ebb, 0x5bde, 0x5e55, 0x6f20, - 0x819c, 0x83ab, 0x9088, 0x4e07, 0x534d, 0x5a29, 0x5dd2, 0x5f4e, 0x6162, - 0x633d, 0x6669, 0x66fc, 0x6eff, 0x6f2b, 0x7063, 0x779e, 0x842c, 0x8513, - 0x883b, 0x8f13, 0x9945, 0x9c3b, 0x551c, 0x62b9, 0x672b, 0x6cab, 0x8309, - 0x896a, 0x977a, 0x4ea1, 0x5984, 0x5fd8, 0x5fd9, 0x671b, 0x7db2, 0x7f54, - 0x8292, 0x832b, 0x83bd, 0x8f1e, 0x9099, 0x57cb, 0x59b9, 0x5a92, 0x5bd0, - 0x6627, 0x679a, 0x6885, 0x6bcf, 0x7164, 0x7f75, 0x8cb7, 0x8ce3, 0x9081, - 0x9b45, 0x8108, 0x8c8a, 0x964c, 0x9a40, 0x9ea5, 0x5b5f, 0x6c13, 0x731b, - 0x76f2, 0x76df, 0x840c, 0x51aa, 0x8993, 0x514d, 0x5195, 0x52c9, 0x68c9, - 0x6c94, 0x7704, 0x7720, 0x7dbf, 0x7dec, 0x9762, 0x9eb5, 0x6ec5, 0x8511, - 0x51a5, 0x540d, 0x547d, 0x660e, 0x669d, 0x6927, 0x6e9f, 0x76bf, 0x7791, - 0x8317, 0x84c2, 0x879f, 0x9169, 0x9298, 0x9cf4, 0x8882, 0x4fae, 0x5192, - 0x52df, 0x59c6, 0x5e3d, 0x6155, 0x6478, 0x6479, 0x66ae, 0x67d0, 0x6a21, - 0x6bcd, 0x6bdb, 0x725f, 0x7261, 0x7441, 0x7738, 0x77db, 0x8017, 0x82bc, - 0x8305, 0x8b00, 0x8b28, 0x8c8c, 0x6728, 0x6c90, 0x7267, 0x76ee, 0x7766, - 0x7a46, 0x9da9, 0x6b7f, 0x6c92, 0x5922, 0x6726, 0x8499, 0x536f, 0x5893, - 0x5999, 0x5edf, 0x63cf, 0x6634, 0x6773, 0x6e3a, 0x732b, 0x7ad7, 0x82d7, - 0x9328, 0x52d9, 0x5deb, 0x61ae, 0x61cb, 0x620a, 0x62c7, 0x64ab, 0x65e0, - 0x6959, 0x6b66, 0x6bcb, 0x7121, 0x73f7, 0x755d, 0x7e46, 0x821e, 0x8302, - 0x856a, 0x8aa3, 0x8cbf, 0x9727, 0x9d61, 0x58a8, 0x9ed8, 0x5011, 0x520e, - 0x543b, 0x554f, 0x6587, 0x6c76, 0x7d0a, 0x7d0b, 0x805e, 0x868a, 0x9580, - 0x96ef, 0x52ff, 0x6c95, 0x7269, 0x5473, 0x5a9a, 0x5c3e, 0x5d4b, 0x5f4c, - 0x5fae, 0x672a, 0x68b6, 0x6963, 0x6e3c, 0x6e44, 0x7709, 0x7c73, 0x7f8e, - 0x8587, 0x8b0e, 0x8ff7, 0x9761, 0x9ef4, 0x5cb7, 0x60b6, 0x610d, 0x61ab, - 0x654f, 0x65fb, 0x65fc, 0x6c11, 0x6cef, 0x739f, 0x73c9, 0x7de1, 0x9594, - 0x5bc6, 0x871c, 0x8b10, 0x525d, 0x535a, 0x62cd, 0x640f, 0x64b2, 0x6734, - 0x6a38, 0x6cca, 0x73c0, 0x749e, 0x7b94, 0x7c95, 0x7e1b, 0x818a, 0x8236, - 0x8584, 0x8feb, 0x96f9, 0x99c1, 0x4f34, 0x534a, 0x53cd, 0x53db, 0x62cc, - 0x642c, 0x6500, 0x6591, 0x69c3, 0x6cee, 0x6f58, 0x73ed, 0x7554, 0x7622, - 0x76e4, 0x76fc, 0x78d0, 0x78fb, 0x792c, 0x7d46, 0x822c, 0x87e0, 0x8fd4, - 0x9812, 0x98ef, 0x52c3, 0x62d4, 0x64a5, 0x6e24, 0x6f51, 0x767c, 0x8dcb, - 0x91b1, 0x9262, 0x9aee, 0x9b43, 0x5023, 0x508d, 0x574a, 0x59a8, 0x5c28, - 0x5e47, 0x5f77, 0x623f, 0x653e, 0x65b9, 0x65c1, 0x6609, 0x678b, 0x699c, - 0x6ec2, 0x78c5, 0x7d21, 0x80aa, 0x8180, 0x822b, 0x82b3, 0x84a1, 0x868c, - 0x8a2a, 0x8b17, 0x90a6, 0x9632, 0x9f90, 0x500d, 0x4ff3, 0xf963, 0x57f9, - 0x5f98, 0x62dc, 0x6392, 0x676f, 0x6e43, 0x7119, 0x76c3, 0x80cc, 0x80da, - 0x88f4, 0x88f5, 0x8919, 0x8ce0, 0x8f29, 0x914d, 0x966a, 0x4f2f, 0x4f70, - 0x5e1b, 0x67cf, 0x6822, 0x767d, 0x767e, 0x9b44, 0x5e61, 0x6a0a, 0x7169, - 0x71d4, 0x756a, 0xf964, 0x7e41, 0x8543, 0x85e9, 0x98dc, 0x4f10, 0x7b4f, - 0x7f70, 0x95a5, 0x51e1, 0x5e06, 0x68b5, 0x6c3e, 0x6c4e, 0x6cdb, 0x72af, - 0x7bc4, 0x8303, 0x6cd5, 0x743a, 0x50fb, 0x5288, 0x58c1, 0x64d8, 0x6a97, - 0x74a7, 0x7656, 0x78a7, 0x8617, 0x95e2, 0x9739, 0xf965, 0x535e, 0x5f01, - 0x8b8a, 0x8fa8, 0x8faf, 0x908a, 0x5225, 0x77a5, 0x9c49, 0x9f08, 0x4e19, - 0x5002, 0x5175, 0x5c5b, 0x5e77, 0x661e, 0x663a, 0x67c4, 0x68c5, 0x70b3, - 0x7501, 0x75c5, 0x79c9, 0x7add, 0x8f27, 0x9920, 0x9a08, 0x4fdd, 0x5821, - 0x5831, 0x5bf6, 0x666e, 0x6b65, 0x6d11, 0x6e7a, 0x6f7d, 0x73e4, 0x752b, - 0x83e9, 0x88dc, 0x8913, 0x8b5c, 0x8f14, 0x4f0f, 0x50d5, 0x5310, 0x535c, - 0x5b93, 0x5fa9, 0x670d, 0x798f, 0x8179, 0x832f, 0x8514, 0x8907, 0x8986, - 0x8f39, 0x8f3b, 0x99a5, 0x9c12, 0x672c, 0x4e76, 0x4ff8, 0x5949, 0x5c01, - 0x5cef, 0x5cf0, 0x6367, 0x68d2, 0x70fd, 0x71a2, 0x742b, 0x7e2b, 0x84ec, - 0x8702, 0x9022, 0x92d2, 0x9cf3, 0x4e0d, 0x4ed8, 0x4fef, 0x5085, 0x5256, - 0x526f, 0x5426, 0x5490, 0x57e0, 0x592b, 0x5a66, 0x5b5a, 0x5b75, 0x5bcc, - 0x5e9c, 0xf966, 0x6276, 0x6577, 0x65a7, 0x6d6e, 0x6ea5, 0x7236, 0x7b26, - 0x7c3f, 0x7f36, 0x8150, 0x8151, 0x819a, 0x8240, 0x8299, 0x83a9, 0x8a03, - 0x8ca0, 0x8ce6, 0x8cfb, 0x8d74, 0x8dba, 0x90e8, 0x91dc, 0x961c, 0x9644, - 0x99d9, 0x9ce7, 0x5317, 0x5206, 0x5429, 0x5674, 0x58b3, 0x5954, 0x596e, - 0x5fff, 0x61a4, 0x626e, 0x6610, 0x6c7e, 0x711a, 0x76c6, 0x7c89, 0x7cde, - 0x7d1b, 0x82ac, 0x8cc1, 0x96f0, 0xf967, 0x4f5b, 0x5f17, 0x5f7f, 0x62c2, - 0x5d29, 0x670b, 0x68da, 0x787c, 0x7e43, 0x9d6c, 0x4e15, 0x5099, 0x5315, - 0x532a, 0x5351, 0x5983, 0x5a62, 0x5e87, 0x60b2, 0x618a, 0x6249, 0x6279, - 0x6590, 0x6787, 0x69a7, 0x6bd4, 0x6bd6, 0x6bd7, 0x6bd8, 0x6cb8, 0xf968, - 0x7435, 0x75fa, 0x7812, 0x7891, 0x79d5, 0x79d8, 0x7c83, 0x7dcb, 0x7fe1, - 0x80a5, 0x813e, 0x81c2, 0x83f2, 0x871a, 0x88e8, 0x8ab9, 0x8b6c, 0x8cbb, - 0x9119, 0x975e, 0x98db, 0x9f3b, 0x56ac, 0x5b2a, 0x5f6c, 0x658c, 0x6ab3, - 0x6baf, 0x6d5c, 0x6ff1, 0x7015, 0x725d, 0x73ad, 0x8ca7, 0x8cd3, 0x983b, - 0x6191, 0x6c37, 0x8058, 0x9a01, 0x4e4d, 0x4e8b, 0x4e9b, 0x4ed5, 0x4f3a, - 0x4f3c, 0x4f7f, 0x4fdf, 0x50ff, 0x53f2, 0x53f8, 0x5506, 0x55e3, 0x56db, - 0x58eb, 0x5962, 0x5a11, 0x5beb, 0x5bfa, 0x5c04, 0x5df3, 0x5e2b, 0x5f99, - 0x601d, 0x6368, 0x659c, 0x65af, 0x67f6, 0x67fb, 0x68ad, 0x6b7b, 0x6c99, - 0x6cd7, 0x6e23, 0x7009, 0x7345, 0x7802, 0x793e, 0x7940, 0x7960, 0x79c1, - 0x7be9, 0x7d17, 0x7d72, 0x8086, 0x820d, 0x838e, 0x84d1, 0x86c7, 0x88df, - 0x8a50, 0x8a5e, 0x8b1d, 0x8cdc, 0x8d66, 0x8fad, 0x90aa, 0x98fc, 0x99df, - 0x9e9d, 0x524a, 0xf969, 0x6714, 0xf96a, 0x5098, 0x522a, 0x5c71, 0x6563, - 0x6c55, 0x73ca, 0x7523, 0x759d, 0x7b97, 0x849c, 0x9178, 0x9730, 0x4e77, - 0x6492, 0x6bba, 0x715e, 0x85a9, 0x4e09, 0xf96b, 0x6749, 0x68ee, 0x6e17, - 0x829f, 0x8518, 0x886b, 0x63f7, 0x6f81, 0x9212, 0x98af, 0x4e0a, 0x50b7, - 0x50cf, 0x511f, 0x5546, 0x55aa, 0x5617, 0x5b40, 0x5c19, 0x5ce0, 0x5e38, - 0x5e8a, 0x5ea0, 0x5ec2, 0x60f3, 0x6851, 0x6a61, 0x6e58, 0x723d, 0x7240, - 0x72c0, 0x76f8, 0x7965, 0x7bb1, 0x7fd4, 0x88f3, 0x89f4, 0x8a73, 0x8c61, - 0x8cde, 0x971c, 0x585e, 0x74bd, 0x8cfd, 0x55c7, 0xf96c, 0x7a61, 0x7d22, - 0x8272, 0x7272, 0x751f, 0x7525, 0xf96d, 0x7b19, 0x5885, 0x58fb, 0x5dbc, - 0x5e8f, 0x5eb6, 0x5f90, 0x6055, 0x6292, 0x637f, 0x654d, 0x6691, 0x66d9, - 0x66f8, 0x6816, 0x68f2, 0x7280, 0x745e, 0x7b6e, 0x7d6e, 0x7dd6, 0x7f72, - 0x80e5, 0x8212, 0x85af, 0x897f, 0x8a93, 0x901d, 0x92e4, 0x9ecd, 0x9f20, - 0x5915, 0x596d, 0x5e2d, 0x60dc, 0x6614, 0x6673, 0x6790, 0x6c50, 0x6dc5, - 0x6f5f, 0x77f3, 0x78a9, 0x84c6, 0x91cb, 0x932b, 0x4ed9, 0x50ca, 0x5148, - 0x5584, 0x5b0b, 0x5ba3, 0x6247, 0x657e, 0x65cb, 0x6e32, 0x717d, 0x7401, - 0x7444, 0x7487, 0x74bf, 0x766c, 0x79aa, 0x7dda, 0x7e55, 0x7fa8, 0x817a, - 0x81b3, 0x8239, 0x861a, 0x87ec, 0x8a75, 0x8de3, 0x9078, 0x9291, 0x9425, - 0x994d, 0x9bae, 0x5368, 0x5c51, 0x6954, 0x6cc4, 0x6d29, 0x6e2b, 0x820c, - 0x859b, 0x893b, 0x8a2d, 0x8aaa, 0x96ea, 0x9f67, 0x5261, 0x66b9, 0x6bb2, - 0x7e96, 0x87fe, 0x8d0d, 0x9583, 0x965d, 0x651d, 0x6d89, 0x71ee, 0xf96e, - 0x57ce, 0x59d3, 0x5bac, 0x6027, 0x60fa, 0x6210, 0x661f, 0x665f, 0x7329, - 0x73f9, 0x76db, 0x7701, 0x7b6c, 0x8056, 0x8072, 0x8165, 0x8aa0, 0x9192, - 0x4e16, 0x52e2, 0x6b72, 0x6d17, 0x7a05, 0x7b39, 0x7d30, 0xf96f, 0x8cb0, - 0x53ec, 0x562f, 0x5851, 0x5bb5, 0x5c0f, 0x5c11, 0x5de2, 0x6240, 0x6383, - 0x6414, 0x662d, 0x68b3, 0x6cbc, 0x6d88, 0x6eaf, 0x701f, 0x70a4, 0x71d2, - 0x7526, 0x758f, 0x758e, 0x7619, 0x7b11, 0x7be0, 0x7c2b, 0x7d20, 0x7d39, - 0x852c, 0x856d, 0x8607, 0x8a34, 0x900d, 0x9061, 0x90b5, 0x92b7, 0x97f6, - 0x9a37, 0x4fd7, 0x5c6c, 0x675f, 0x6d91, 0x7c9f, 0x7e8c, 0x8b16, 0x8d16, - 0x901f, 0x5b6b, 0x5dfd, 0x640d, 0x84c0, 0x905c, 0x98e1, 0x7387, 0x5b8b, - 0x609a, 0x677e, 0x6dde, 0x8a1f, 0x8aa6, 0x9001, 0x980c, 0x5237, 0xf970, - 0x7051, 0x788e, 0x9396, 0x8870, 0x91d7, 0x4fee, 0x53d7, 0x55fd, 0x56da, - 0x5782, 0x58fd, 0x5ac2, 0x5b88, 0x5cab, 0x5cc0, 0x5e25, 0x6101, 0x620d, - 0x624b, 0x6388, 0x641c, 0x6536, 0x6578, 0x6a39, 0x6b8a, 0x6c34, 0x6d19, - 0x6f31, 0x71e7, 0x72e9, 0x7378, 0x7407, 0x74b2, 0x7626, 0x7761, 0x79c0, - 0x7a57, 0x7aea, 0x7cb9, 0x7d8f, 0x7dac, 0x7e61, 0x7f9e, 0x8129, 0x8331, - 0x8490, 0x84da, 0x85ea, 0x8896, 0x8ab0, 0x8b90, 0x8f38, 0x9042, 0x9083, - 0x916c, 0x9296, 0x92b9, 0x968b, 0x96a7, 0x96a8, 0x96d6, 0x9700, 0x9808, - 0x9996, 0x9ad3, 0x9b1a, 0x53d4, 0x587e, 0x5919, 0x5b70, 0x5bbf, 0x6dd1, - 0x6f5a, 0x719f, 0x7421, 0x74b9, 0x8085, 0x83fd, 0x5de1, 0x5f87, 0x5faa, - 0x6042, 0x65ec, 0x6812, 0x696f, 0x6a53, 0x6b89, 0x6d35, 0x6df3, 0x73e3, - 0x76fe, 0x77ac, 0x7b4d, 0x7d14, 0x8123, 0x821c, 0x8340, 0x84f4, 0x8563, - 0x8a62, 0x8ac4, 0x9187, 0x931e, 0x9806, 0x99b4, 0x620c, 0x8853, 0x8ff0, - 0x9265, 0x5d07, 0x5d27, 0x5d69, 0x745f, 0x819d, 0x8768, 0x6fd5, 0x62fe, - 0x7fd2, 0x8936, 0x8972, 0x4e1e, 0x4e58, 0x50e7, 0x52dd, 0x5347, 0x627f, - 0x6607, 0x7e69, 0x8805, 0x965e, 0x4f8d, 0x5319, 0x5636, 0x59cb, 0x5aa4, - 0x5c38, 0x5c4e, 0x5c4d, 0x5e02, 0x5f11, 0x6043, 0x65bd, 0x662f, 0x6642, - 0x67be, 0x67f4, 0x731c, 0x77e2, 0x793a, 0x7fc5, 0x8494, 0x84cd, 0x8996, - 0x8a66, 0x8a69, 0x8ae1, 0x8c55, 0x8c7a, 0x57f4, 0x5bd4, 0x5f0f, 0x606f, - 0x62ed, 0x690d, 0x6b96, 0x6e5c, 0x7184, 0x7bd2, 0x8755, 0x8b58, 0x8efe, - 0x98df, 0x98fe, 0x4f38, 0x4f81, 0x4fe1, 0x547b, 0x5a20, 0x5bb8, 0x613c, - 0x65b0, 0x6668, 0x71fc, 0x7533, 0x795e, 0x7d33, 0x814e, 0x81e3, 0x8398, - 0x85aa, 0x85ce, 0x8703, 0x8a0a, 0x8eab, 0x8f9b, 0xf971, 0x8fc5, 0x5931, - 0x5ba4, 0x5be6, 0x6089, 0x5be9, 0x5c0b, 0x5fc3, 0x6c81, 0xf972, 0x6df1, - 0x700b, 0x751a, 0x82af, 0x8af6, 0x4ec0, 0x5341, 0xf973, 0x96d9, 0x6c0f, - 0x4e9e, 0x4fc4, 0x5152, 0x555e, 0x5a25, 0x5ce8, 0x6211, 0x7259, 0x82bd, - 0x83aa, 0x86fe, 0x8859, 0x8a1d, 0x963f, 0x96c5, 0x9913, 0x9d09, 0x9d5d, - 0x580a, 0x5cb3, 0x5dbd, 0x5e44, 0x60e1, 0x6115, 0x63e1, 0x6a02, 0x6e25, - 0x9102, 0x9354, 0x984e, 0x9c10, 0x9f77, 0x5b89, 0x5cb8, 0x6309, 0x664f, - 0x6848, 0x773c, 0x96c1, 0x978d, 0x9854, 0x9b9f, 0x65a1, 0x8b01, 0x8ecb, - 0x95bc, 0x5535, 0x5ca9, 0x5dd6, 0x5eb5, 0x6697, 0x764c, 0x83f4, 0x95c7, - 0x58d3, 0x62bc, 0x72ce, 0x9d28, 0x4ef0, 0x592e, 0x600f, 0x663b, 0x6b83, - 0x79e7, 0x9d26, 0x5393, 0x54c0, 0x57c3, 0x5d16, 0x611b, 0x66d6, 0x6daf, - 0x788d, 0x827e, 0x9698, 0x9744, 0x5384, 0x627c, 0x6396, 0x6db2, 0x7e0a, - 0x814b, 0x984d, 0x6afb, 0x7f4c, 0x9daf, 0x9e1a, 0x4e5f, 0x503b, 0x51b6, - 0x591c, 0x60f9, 0x63f6, 0x6930, 0x723a, 0x8036, 0xf974, 0x91ce, 0x5f31, - 0xf975, 0xf976, 0x7d04, 0x82e5, 0x846f, 0x84bb, 0x85e5, 0x8e8d, 0xf977, - 0x4f6f, 0xf978, 0xf979, 0x58e4, 0x5b43, 0x6059, 0x63da, 0x6518, 0x656d, - 0x6698, 0xf97a, 0x694a, 0x6a23, 0x6d0b, 0x7001, 0x716c, 0x75d2, 0x760d, - 0x79b3, 0x7a70, 0xf97b, 0x7f8a, 0xf97c, 0x8944, 0xf97d, 0x8b93, 0x91c0, - 0x967d, 0xf97e, 0x990a, 0x5704, 0x5fa1, 0x65bc, 0x6f01, 0x7600, 0x79a6, - 0x8a9e, 0x99ad, 0x9b5a, 0x9f6c, 0x5104, 0x61b6, 0x6291, 0x6a8d, 0x81c6, - 0x5043, 0x5830, 0x5f66, 0x7109, 0x8a00, 0x8afa, 0x5b7c, 0x8616, 0x4ffa, - 0x513c, 0x56b4, 0x5944, 0x63a9, 0x6df9, 0x5daa, 0x696d, 0x5186, 0x4e88, - 0x4f59, 0xf97f, 0xf980, 0xf981, 0x5982, 0xf982, 0xf983, 0x6b5f, 0x6c5d, - 0xf984, 0x74b5, 0x7916, 0xf985, 0x8207, 0x8245, 0x8339, 0x8f3f, 0x8f5d, - 0xf986, 0x9918, 0xf987, 0xf988, 0xf989, 0x4ea6, 0xf98a, 0x57df, 0x5f79, - 0x6613, 0xf98b, 0xf98c, 0x75ab, 0x7e79, 0x8b6f, 0xf98d, 0x9006, 0x9a5b, - 0x56a5, 0x5827, 0x59f8, 0x5a1f, 0x5bb4, 0xf98e, 0x5ef6, 0xf98f, 0xf990, - 0x6350, 0x633b, 0xf991, 0x693d, 0x6c87, 0x6cbf, 0x6d8e, 0x6d93, 0x6df5, - 0x6f14, 0xf992, 0x70df, 0x7136, 0x7159, 0xf993, 0x71c3, 0x71d5, 0xf994, - 0x784f, 0x786f, 0xf995, 0x7b75, 0x7de3, 0xf996, 0x7e2f, 0xf997, 0x884d, - 0x8edf, 0xf998, 0xf999, 0xf99a, 0x925b, 0xf99b, 0x9cf6, 0xf99c, 0xf99d, - 0xf99e, 0x6085, 0x6d85, 0xf99f, 0x71b1, 0xf9a0, 0xf9a1, 0x95b1, 0x53ad, - 0xf9a2, 0xf9a3, 0xf9a4, 0x67d3, 0xf9a5, 0x708e, 0x7130, 0x7430, 0x8276, - 0x82d2, 0xf9a6, 0x95bb, 0x9ae5, 0x9e7d, 0x66c4, 0xf9a7, 0x71c1, 0x8449, - 0xf9a8, 0xf9a9, 0x584b, 0xf9aa, 0xf9ab, 0x5db8, 0x5f71, 0xf9ac, 0x6620, - 0x668e, 0x6979, 0x69ae, 0x6c38, 0x6cf3, 0x6e36, 0x6f41, 0x6fda, 0x701b, - 0x702f, 0x7150, 0x71df, 0x7370, 0xf9ad, 0x745b, 0xf9ae, 0x74d4, 0x76c8, - 0x7a4e, 0x7e93, 0xf9af, 0xf9b0, 0x82f1, 0x8a60, 0x8fce, 0xf9b1, 0x9348, - 0xf9b2, 0x9719, 0xf9b3, 0xf9b4, 0x4e42, 0x502a, 0xf9b5, 0x5208, 0x53e1, - 0x66f3, 0x6c6d, 0x6fca, 0x730a, 0x777f, 0x7a62, 0x82ae, 0x85dd, 0x8602, - 0xf9b6, 0x88d4, 0x8a63, 0x8b7d, 0x8c6b, 0xf9b7, 0x92b3, 0xf9b8, 0x9713, - 0x9810, 0x4e94, 0x4f0d, 0x4fc9, 0x50b2, 0x5348, 0x543e, 0x5433, 0x55da, - 0x5862, 0x58ba, 0x5967, 0x5a1b, 0x5be4, 0x609f, 0xf9b9, 0x61ca, 0x6556, - 0x65ff, 0x6664, 0x68a7, 0x6c5a, 0x6fb3, 0x70cf, 0x71ac, 0x7352, 0x7b7d, - 0x8708, 0x8aa4, 0x9c32, 0x9f07, 0x5c4b, 0x6c83, 0x7344, 0x7389, 0x923a, - 0x6eab, 0x7465, 0x761f, 0x7a69, 0x7e15, 0x860a, 0x5140, 0x58c5, 0x64c1, - 0x74ee, 0x7515, 0x7670, 0x7fc1, 0x9095, 0x96cd, 0x9954, 0x6e26, 0x74e6, - 0x7aa9, 0x7aaa, 0x81e5, 0x86d9, 0x8778, 0x8a1b, 0x5a49, 0x5b8c, 0x5b9b, - 0x68a1, 0x6900, 0x6d63, 0x73a9, 0x7413, 0x742c, 0x7897, 0x7de9, 0x7feb, - 0x8118, 0x8155, 0x839e, 0x8c4c, 0x962e, 0x9811, 0x66f0, 0x5f80, 0x65fa, - 0x6789, 0x6c6a, 0x738b, 0x502d, 0x5a03, 0x6b6a, 0x77ee, 0x5916, 0x5d6c, - 0x5dcd, 0x7325, 0x754f, 0xf9ba, 0xf9bb, 0x50e5, 0x51f9, 0x582f, 0x592d, - 0x5996, 0x59da, 0x5be5, 0xf9bc, 0xf9bd, 0x5da2, 0x62d7, 0x6416, 0x6493, - 0x64fe, 0xf9be, 0x66dc, 0xf9bf, 0x6a48, 0xf9c0, 0x71ff, 0x7464, 0xf9c1, - 0x7a88, 0x7aaf, 0x7e47, 0x7e5e, 0x8000, 0x8170, 0xf9c2, 0x87ef, 0x8981, - 0x8b20, 0x9059, 0xf9c3, 0x9080, 0x9952, 0x617e, 0x6b32, 0x6d74, 0x7e1f, - 0x8925, 0x8fb1, 0x4fd1, 0x50ad, 0x5197, 0x52c7, 0x57c7, 0x5889, 0x5bb9, - 0x5eb8, 0x6142, 0x6995, 0x6d8c, 0x6e67, 0x6eb6, 0x7194, 0x7462, 0x7528, - 0x752c, 0x8073, 0x8338, 0x84c9, 0x8e0a, 0x9394, 0x93de, 0xf9c4, 0x4e8e, - 0x4f51, 0x5076, 0x512a, 0x53c8, 0x53cb, 0x53f3, 0x5b87, 0x5bd3, 0x5c24, - 0x611a, 0x6182, 0x65f4, 0x725b, 0x7397, 0x7440, 0x76c2, 0x7950, 0x7991, - 0x79b9, 0x7d06, 0x7fbd, 0x828b, 0x85d5, 0x865e, 0x8fc2, 0x9047, 0x90f5, - 0x91ea, 0x9685, 0x96e8, 0x96e9, 0x52d6, 0x5f67, 0x65ed, 0x6631, 0x682f, - 0x715c, 0x7a36, 0x90c1, 0x980a, 0x4e91, 0xf9c5, 0x6a52, 0x6b9e, 0x6f90, - 0x7189, 0x8018, 0x82b8, 0x8553, 0x904b, 0x9695, 0x96f2, 0x97fb, 0x851a, - 0x9b31, 0x4e90, 0x718a, 0x96c4, 0x5143, 0x539f, 0x54e1, 0x5713, 0x5712, - 0x57a3, 0x5a9b, 0x5ac4, 0x5bc3, 0x6028, 0x613f, 0x63f4, 0x6c85, 0x6d39, - 0x6e72, 0x6e90, 0x7230, 0x733f, 0x7457, 0x82d1, 0x8881, 0x8f45, 0x9060, - 0xf9c6, 0x9662, 0x9858, 0x9d1b, 0x6708, 0x8d8a, 0x925e, 0x4f4d, 0x5049, - 0x50de, 0x5371, 0x570d, 0x59d4, 0x5a01, 0x5c09, 0x6170, 0x6690, 0x6e2d, - 0x7232, 0x744b, 0x7def, 0x80c3, 0x840e, 0x8466, 0x853f, 0x875f, 0x885b, - 0x8918, 0x8b02, 0x9055, 0x97cb, 0x9b4f, 0x4e73, 0x4f91, 0x5112, 0x516a, - 0xf9c7, 0x552f, 0x55a9, 0x5b7a, 0x5ba5, 0x5e7c, 0x5e7d, 0x5ebe, 0x60a0, - 0x60df, 0x6108, 0x6109, 0x63c4, 0x6538, 0x6709, 0xf9c8, 0x67d4, 0x67da, - 0xf9c9, 0x6961, 0x6962, 0x6cb9, 0x6d27, 0xf9ca, 0x6e38, 0xf9cb, 0x6fe1, - 0x7336, 0x7337, 0xf9cc, 0x745c, 0x7531, 0xf9cd, 0x7652, 0xf9ce, 0xf9cf, - 0x7dad, 0x81fe, 0x8438, 0x88d5, 0x8a98, 0x8adb, 0x8aed, 0x8e30, 0x8e42, - 0x904a, 0x903e, 0x907a, 0x9149, 0x91c9, 0x936e, 0xf9d0, 0xf9d1, 0x5809, - 0xf9d2, 0x6bd3, 0x8089, 0x80b2, 0xf9d3, 0xf9d4, 0x5141, 0x596b, 0x5c39, - 0xf9d5, 0xf9d6, 0x6f64, 0x73a7, 0x80e4, 0x8d07, 0xf9d7, 0x9217, 0x958f, - 0xf9d8, 0xf9d9, 0xf9da, 0xf9db, 0x807f, 0x620e, 0x701c, 0x7d68, 0x878d, - 0xf9dc, 0x57a0, 0x6069, 0x6147, 0x6bb7, 0x8abe, 0x9280, 0x96b1, 0x4e59, - 0x541f, 0x6deb, 0x852d, 0x9670, 0x97f3, 0x98ee, 0x63d6, 0x6ce3, 0x9091, - 0x51dd, 0x61c9, 0x81ba, 0x9df9, 0x4f9d, 0x501a, 0x5100, 0x5b9c, 0x610f, - 0x61ff, 0x64ec, 0x6905, 0x6bc5, 0x7591, 0x77e3, 0x7fa9, 0x8264, 0x858f, - 0x87fb, 0x8863, 0x8abc, 0x8b70, 0x91ab, 0x4e8c, 0x4ee5, 0x4f0a, 0xf9dd, - 0xf9de, 0x5937, 0x59e8, 0xf9df, 0x5df2, 0x5f1b, 0x5f5b, 0x6021, 0xf9e0, - 0xf9e1, 0xf9e2, 0xf9e3, 0x723e, 0x73e5, 0xf9e4, 0x7570, 0x75cd, 0xf9e5, - 0x79fb, 0xf9e6, 0x800c, 0x8033, 0x8084, 0x82e1, 0x8351, 0xf9e7, 0xf9e8, - 0x8cbd, 0x8cb3, 0x9087, 0xf9e9, 0xf9ea, 0x98f4, 0x990c, 0xf9eb, 0xf9ec, - 0x7037, 0x76ca, 0x7fca, 0x7fcc, 0x7ffc, 0x8b1a, 0x4eba, 0x4ec1, 0x5203, - 0x5370, 0xf9ed, 0x54bd, 0x56e0, 0x59fb, 0x5bc5, 0x5f15, 0x5fcd, 0x6e6e, - 0xf9ee, 0xf9ef, 0x7d6a, 0x8335, 0xf9f0, 0x8693, 0x8a8d, 0xf9f1, 0x976d, - 0x9777, 0xf9f2, 0xf9f3, 0x4e00, 0x4f5a, 0x4f7e, 0x58f9, 0x65e5, 0x6ea2, - 0x9038, 0x93b0, 0x99b9, 0x4efb, 0x58ec, 0x598a, 0x59d9, 0x6041, 0xf9f4, - 0xf9f5, 0x7a14, 0xf9f6, 0x834f, 0x8cc3, 0x5165, 0x5344, 0xf9f7, 0xf9f8, - 0xf9f9, 0x4ecd, 0x5269, 0x5b55, 0x82bf, 0x4ed4, 0x523a, 0x54a8, 0x59c9, - 0x59ff, 0x5b50, 0x5b57, 0x5b5c, 0x6063, 0x6148, 0x6ecb, 0x7099, 0x716e, - 0x7386, 0x74f7, 0x75b5, 0x78c1, 0x7d2b, 0x8005, 0x81ea, 0x8328, 0x8517, - 0x85c9, 0x8aee, 0x8cc7, 0x96cc, 0x4f5c, 0x52fa, 0x56bc, 0x65ab, 0x6628, - 0x707c, 0x70b8, 0x7235, 0x7dbd, 0x828d, 0x914c, 0x96c0, 0x9d72, 0x5b71, - 0x68e7, 0x6b98, 0x6f7a, 0x76de, 0x5c91, 0x66ab, 0x6f5b, 0x7bb4, 0x7c2a, - 0x8836, 0x96dc, 0x4e08, 0x4ed7, 0x5320, 0x5834, 0x58bb, 0x58ef, 0x596c, - 0x5c07, 0x5e33, 0x5e84, 0x5f35, 0x638c, 0x66b2, 0x6756, 0x6a1f, 0x6aa3, - 0x6b0c, 0x6f3f, 0x7246, 0xf9fa, 0x7350, 0x748b, 0x7ae0, 0x7ca7, 0x8178, - 0x81df, 0x81e7, 0x838a, 0x846c, 0x8523, 0x8594, 0x85cf, 0x88dd, 0x8d13, - 0x91ac, 0x9577, 0x969c, 0x518d, 0x54c9, 0x5728, 0x5bb0, 0x624d, 0x6750, - 0x683d, 0x6893, 0x6e3d, 0x6ed3, 0x707d, 0x7e21, 0x88c1, 0x8ca1, 0x8f09, - 0x9f4b, 0x9f4e, 0x722d, 0x7b8f, 0x8acd, 0x931a, 0x4f47, 0x4f4e, 0x5132, - 0x5480, 0x59d0, 0x5e95, 0x62b5, 0x6775, 0x696e, 0x6a17, 0x6cae, 0x6e1a, - 0x72d9, 0x732a, 0x75bd, 0x7bb8, 0x7d35, 0x82e7, 0x83f9, 0x8457, 0x85f7, - 0x8a5b, 0x8caf, 0x8e87, 0x9019, 0x90b8, 0x96ce, 0x9f5f, 0x52e3, 0x540a, - 0x5ae1, 0x5bc2, 0x6458, 0x6575, 0x6ef4, 0x72c4, 0xf9fb, 0x7684, 0x7a4d, - 0x7b1b, 0x7c4d, 0x7e3e, 0x7fdf, 0x837b, 0x8b2b, 0x8cca, 0x8d64, 0x8de1, - 0x8e5f, 0x8fea, 0x8ff9, 0x9069, 0x93d1, 0x4f43, 0x4f7a, 0x50b3, 0x5168, - 0x5178, 0x524d, 0x526a, 0x5861, 0x587c, 0x5960, 0x5c08, 0x5c55, 0x5edb, - 0x609b, 0x6230, 0x6813, 0x6bbf, 0x6c08, 0x6fb1, 0x714e, 0x7420, 0x7530, - 0x7538, 0x7551, 0x7672, 0x7b4c, 0x7b8b, 0x7bad, 0x7bc6, 0x7e8f, 0x8a6e, - 0x8f3e, 0x8f49, 0x923f, 0x9293, 0x9322, 0x942b, 0x96fb, 0x985a, 0x986b, - 0x991e, 0x5207, 0x622a, 0x6298, 0x6d59, 0x7664, 0x7aca, 0x7bc0, 0x7d76, - 0x5360, 0x5cbe, 0x5e97, 0x6f38, 0x70b9, 0x7c98, 0x9711, 0x9b8e, 0x9ede, - 0x63a5, 0x647a, 0x8776, 0x4e01, 0x4e95, 0x4ead, 0x505c, 0x5075, 0x5448, - 0x59c3, 0x5b9a, 0x5e40, 0x5ead, 0x5ef7, 0x5f81, 0x60c5, 0x633a, 0x653f, - 0x6574, 0x65cc, 0x6676, 0x6678, 0x67fe, 0x6968, 0x6a89, 0x6b63, 0x6c40, - 0x6dc0, 0x6de8, 0x6e1f, 0x6e5e, 0x701e, 0x70a1, 0x738e, 0x73fd, 0x753a, - 0x775b, 0x7887, 0x798e, 0x7a0b, 0x7a7d, 0x7cbe, 0x7d8e, 0x8247, 0x8a02, - 0x8aea, 0x8c9e, 0x912d, 0x914a, 0x91d8, 0x9266, 0x92cc, 0x9320, 0x9706, - 0x9756, 0x975c, 0x9802, 0x9f0e, 0x5236, 0x5291, 0x557c, 0x5824, 0x5e1d, - 0x5f1f, 0x608c, 0x63d0, 0x68af, 0x6fdf, 0x796d, 0x7b2c, 0x81cd, 0x85ba, - 0x88fd, 0x8af8, 0x8e44, 0x918d, 0x9664, 0x969b, 0x973d, 0x984c, 0x9f4a, - 0x4fce, 0x5146, 0x51cb, 0x52a9, 0x5632, 0x5f14, 0x5f6b, 0x63aa, 0x64cd, - 0x65e9, 0x6641, 0x66fa, 0x66f9, 0x671d, 0x689d, 0x68d7, 0x69fd, 0x6f15, - 0x6f6e, 0x7167, 0x71e5, 0x722a, 0x74aa, 0x773a, 0x7956, 0x795a, 0x79df, - 0x7a20, 0x7a95, 0x7c97, 0x7cdf, 0x7d44, 0x7e70, 0x8087, 0x85fb, 0x86a4, - 0x8a54, 0x8abf, 0x8d99, 0x8e81, 0x9020, 0x906d, 0x91e3, 0x963b, 0x96d5, - 0x9ce5, 0x65cf, 0x7c07, 0x8db3, 0x93c3, 0x5b58, 0x5c0a, 0x5352, 0x62d9, - 0x731d, 0x5027, 0x5b97, 0x5f9e, 0x60b0, 0x616b, 0x68d5, 0x6dd9, 0x742e, - 0x7a2e, 0x7d42, 0x7d9c, 0x7e31, 0x816b, 0x8e2a, 0x8e35, 0x937e, 0x9418, - 0x4f50, 0x5750, 0x5de6, 0x5ea7, 0x632b, 0x7f6a, 0x4e3b, 0x4f4f, 0x4f8f, - 0x505a, 0x59dd, 0x80c4, 0x546a, 0x5468, 0x55fe, 0x594f, 0x5b99, 0x5dde, - 0x5eda, 0x665d, 0x6731, 0x67f1, 0x682a, 0x6ce8, 0x6d32, 0x6e4a, 0x6f8d, - 0x70b7, 0x73e0, 0x7587, 0x7c4c, 0x7d02, 0x7d2c, 0x7da2, 0x821f, 0x86db, - 0x8a3b, 0x8a85, 0x8d70, 0x8e8a, 0x8f33, 0x9031, 0x914e, 0x9152, 0x9444, - 0x99d0, 0x7af9, 0x7ca5, 0x4fca, 0x5101, 0x51c6, 0x57c8, 0x5bef, 0x5cfb, - 0x6659, 0x6a3d, 0x6d5a, 0x6e96, 0x6fec, 0x710c, 0x756f, 0x7ae3, 0x8822, - 0x9021, 0x9075, 0x96cb, 0x99ff, 0x8301, 0x4e2d, 0x4ef2, 0x8846, 0x91cd, - 0x537d, 0x6adb, 0x696b, 0x6c41, 0x847a, 0x589e, 0x618e, 0x66fe, 0x62ef, - 0x70dd, 0x7511, 0x75c7, 0x7e52, 0x84b8, 0x8b49, 0x8d08, 0x4e4b, 0x53ea, - 0x54ab, 0x5730, 0x5740, 0x5fd7, 0x6301, 0x6307, 0x646f, 0x652f, 0x65e8, - 0x667a, 0x679d, 0x67b3, 0x6b62, 0x6c60, 0x6c9a, 0x6f2c, 0x77e5, 0x7825, - 0x7949, 0x7957, 0x7d19, 0x80a2, 0x8102, 0x81f3, 0x829d, 0x82b7, 0x8718, - 0x8a8c, 0xf9fc, 0x8d04, 0x8dbe, 0x9072, 0x76f4, 0x7a19, 0x7a37, 0x7e54, - 0x8077, 0x5507, 0x55d4, 0x5875, 0x632f, 0x6422, 0x6649, 0x664b, 0x686d, - 0x699b, 0x6b84, 0x6d25, 0x6eb1, 0x73cd, 0x7468, 0x74a1, 0x755b, 0x75b9, - 0x76e1, 0x771e, 0x778b, 0x79e6, 0x7e09, 0x7e1d, 0x81fb, 0x852f, 0x8897, - 0x8a3a, 0x8cd1, 0x8eeb, 0x8fb0, 0x9032, 0x93ad, 0x9663, 0x9673, 0x9707, - 0x4f84, 0x53f1, 0x59ea, 0x5ac9, 0x5e19, 0x684e, 0x74c6, 0x75be, 0x79e9, - 0x7a92, 0x81a3, 0x86ed, 0x8cea, 0x8dcc, 0x8fed, 0x659f, 0x6715, 0xf9fd, - 0x57f7, 0x6f57, 0x7ddd, 0x8f2f, 0x93f6, 0x96c6, 0x5fb5, 0x61f2, 0x6f84, - 0x4e14, 0x4f98, 0x501f, 0x53c9, 0x55df, 0x5d6f, 0x5dee, 0x6b21, 0x6b64, - 0x78cb, 0x7b9a, 0xf9fe, 0x8e49, 0x8eca, 0x906e, 0x6349, 0x643e, 0x7740, - 0x7a84, 0x932f, 0x947f, 0x9f6a, 0x64b0, 0x6faf, 0x71e6, 0x74a8, 0x74da, - 0x7ac4, 0x7c12, 0x7e82, 0x7cb2, 0x7e98, 0x8b9a, 0x8d0a, 0x947d, 0x9910, - 0x994c, 0x5239, 0x5bdf, 0x64e6, 0x672d, 0x7d2e, 0x50ed, 0x53c3, 0x5879, - 0x6158, 0x6159, 0x61fa, 0x65ac, 0x7ad9, 0x8b92, 0x8b96, 0x5009, 0x5021, - 0x5275, 0x5531, 0x5a3c, 0x5ee0, 0x5f70, 0x6134, 0x655e, 0x660c, 0x6636, - 0x66a2, 0x69cd, 0x6ec4, 0x6f32, 0x7316, 0x7621, 0x7a93, 0x8139, 0x8259, - 0x83d6, 0x84bc, 0x50b5, 0x57f0, 0x5bc0, 0x5be8, 0x5f69, 0x63a1, 0x7826, - 0x7db5, 0x83dc, 0x8521, 0x91c7, 0x91f5, 0x518a, 0x67f5, 0x7b56, 0x8cac, - 0x51c4, 0x59bb, 0x60bd, 0x8655, 0x501c, 0xf9ff, 0x5254, 0x5c3a, 0x617d, - 0x621a, 0x62d3, 0x64f2, 0x65a5, 0x6ecc, 0x7620, 0x810a, 0x8e60, 0x965f, - 0x96bb, 0x4edf, 0x5343, 0x5598, 0x5929, 0x5ddd, 0x64c5, 0x6cc9, 0x6dfa, - 0x7394, 0x7a7f, 0x821b, 0x85a6, 0x8ce4, 0x8e10, 0x9077, 0x91e7, 0x95e1, - 0x9621, 0x97c6, 0x51f8, 0x54f2, 0x5586, 0x5fb9, 0x64a4, 0x6f88, 0x7db4, - 0x8f1f, 0x8f4d, 0x9435, 0x50c9, 0x5c16, 0x6cbe, 0x6dfb, 0x751b, 0x77bb, - 0x7c3d, 0x7c64, 0x8a79, 0x8ac2, 0x581e, 0x59be, 0x5e16, 0x6377, 0x7252, - 0x758a, 0x776b, 0x8adc, 0x8cbc, 0x8f12, 0x5ef3, 0x6674, 0x6df8, 0x807d, - 0x83c1, 0x8acb, 0x9751, 0x9bd6, 0xfa00, 0x5243, 0x66ff, 0x6d95, 0x6eef, - 0x7de0, 0x8ae6, 0x902e, 0x905e, 0x9ad4, 0x521d, 0x527f, 0x54e8, 0x6194, - 0x6284, 0x62db, 0x68a2, 0x6912, 0x695a, 0x6a35, 0x7092, 0x7126, 0x785d, - 0x7901, 0x790e, 0x79d2, 0x7a0d, 0x8096, 0x8278, 0x82d5, 0x8349, 0x8549, - 0x8c82, 0x8d85, 0x9162, 0x918b, 0x91ae, 0x4fc3, 0x56d1, 0x71ed, 0x77d7, - 0x8700, 0x89f8, 0x5bf8, 0x5fd6, 0x6751, 0x90a8, 0x53e2, 0x585a, 0x5bf5, - 0x60a4, 0x6181, 0x6460, 0x7e3d, 0x8070, 0x8525, 0x9283, 0x64ae, 0x50ac, - 0x5d14, 0x6700, 0x589c, 0x62bd, 0x63a8, 0x690e, 0x6978, 0x6a1e, 0x6e6b, - 0x76ba, 0x79cb, 0x82bb, 0x8429, 0x8acf, 0x8da8, 0x8ffd, 0x9112, 0x914b, - 0x919c, 0x9310, 0x9318, 0x939a, 0x96db, 0x9a36, 0x9c0d, 0x4e11, 0x755c, - 0x795d, 0x7afa, 0x7b51, 0x7bc9, 0x7e2e, 0x84c4, 0x8e59, 0x8e74, 0x8ef8, - 0x9010, 0x6625, 0x693f, 0x7443, 0x51fa, 0x672e, 0x9edc, 0x5145, 0x5fe0, - 0x6c96, 0x87f2, 0x885d, 0x8877, 0x60b4, 0x81b5, 0x8403, 0x8d05, 0x53d6, - 0x5439, 0x5634, 0x5a36, 0x5c31, 0x708a, 0x7fe0, 0x805a, 0x8106, 0x81ed, - 0x8da3, 0x9189, 0x9a5f, 0x9df2, 0x5074, 0x4ec4, 0x53a0, 0x60fb, 0x6e2c, - 0x5c64, 0x4f88, 0x5024, 0x55e4, 0x5cd9, 0x5e5f, 0x6065, 0x6894, 0x6cbb, - 0x6dc4, 0x71be, 0x75d4, 0x75f4, 0x7661, 0x7a1a, 0x7a49, 0x7dc7, 0x7dfb, - 0x7f6e, 0x81f4, 0x86a9, 0x8f1c, 0x96c9, 0x99b3, 0x9f52, 0x5247, 0x52c5, - 0x98ed, 0x89aa, 0x4e03, 0x67d2, 0x6f06, 0x4fb5, 0x5be2, 0x6795, 0x6c88, - 0x6d78, 0x741b, 0x7827, 0x91dd, 0x937c, 0x87c4, 0x79e4, 0x7a31, 0x5feb, - 0x4ed6, 0x54a4, 0x553e, 0x58ae, 0x59a5, 0x60f0, 0x6253, 0x62d6, 0x6736, - 0x6955, 0x8235, 0x9640, 0x99b1, 0x99dd, 0x502c, 0x5353, 0x5544, 0x577c, - 0xfa01, 0x6258, 0xfa02, 0x64e2, 0x666b, 0x67dd, 0x6fc1, 0x6fef, 0x7422, - 0x7438, 0x8a17, 0x9438, 0x5451, 0x5606, 0x5766, 0x5f48, 0x619a, 0x6b4e, - 0x7058, 0x70ad, 0x7dbb, 0x8a95, 0x596a, 0x812b, 0x63a2, 0x7708, 0x803d, - 0x8caa, 0x5854, 0x642d, 0x69bb, 0x5b95, 0x5e11, 0x6e6f, 0xfa03, 0x8569, - 0x514c, 0x53f0, 0x592a, 0x6020, 0x614b, 0x6b86, 0x6c70, 0x6cf0, 0x7b1e, - 0x80ce, 0x82d4, 0x8dc6, 0x90b0, 0x98b1, 0xfa04, 0x64c7, 0x6fa4, 0x6491, - 0x6504, 0x514e, 0x5410, 0x571f, 0x8a0e, 0x615f, 0x6876, 0xfa05, 0x75db, - 0x7b52, 0x7d71, 0x901a, 0x5806, 0x69cc, 0x817f, 0x892a, 0x9000, 0x9839, - 0x5078, 0x5957, 0x59ac, 0x6295, 0x900f, 0x9b2a, 0x615d, 0x7279, 0x95d6, - 0x5761, 0x5a46, 0x5df4, 0x628a, 0x64ad, 0x64fa, 0x6777, 0x6ce2, 0x6d3e, - 0x722c, 0x7436, 0x7834, 0x7f77, 0x82ad, 0x8ddb, 0x9817, 0x5224, 0x5742, - 0x677f, 0x7248, 0x74e3, 0x8ca9, 0x8fa6, 0x9211, 0x962a, 0x516b, 0x53ed, - 0x634c, 0x4f69, 0x5504, 0x6096, 0x6557, 0x6c9b, 0x6d7f, 0x724c, 0x72fd, - 0x7a17, 0x8987, 0x8c9d, 0x5f6d, 0x6f8e, 0x70f9, 0x81a8, 0x610e, 0x4fbf, - 0x504f, 0x6241, 0x7247, 0x7bc7, 0x7de8, 0x7fe9, 0x904d, 0x97ad, 0x9a19, - 0x8cb6, 0x576a, 0x5e73, 0x67b0, 0x840d, 0x8a55, 0x5420, 0x5b16, 0x5e63, - 0x5ee2, 0x5f0a, 0x6583, 0x80ba, 0x853d, 0x9589, 0x965b, 0x4f48, 0x5305, - 0x530d, 0x530f, 0x5486, 0x54fa, 0x5703, 0x5e03, 0x6016, 0x629b, 0x62b1, - 0x6355, 0xfa06, 0x6ce1, 0x6d66, 0x75b1, 0x7832, 0x80de, 0x812f, 0x82de, - 0x8461, 0x84b2, 0x888d, 0x8912, 0x900b, 0x92ea, 0x98fd, 0x9b91, 0x5e45, - 0x66b4, 0x66dd, 0x7011, 0x7206, 0xfa07, 0x4ff5, 0x527d, 0x5f6a, 0x6153, - 0x6753, 0x6a19, 0x6f02, 0x74e2, 0x7968, 0x8868, 0x8c79, 0x98c7, 0x98c4, - 0x9a43, 0x54c1, 0x7a1f, 0x6953, 0x8af7, 0x8c4a, 0x98a8, 0x99ae, 0x5f7c, - 0x62ab, 0x75b2, 0x76ae, 0x88ab, 0x907f, 0x9642, 0x5339, 0x5f3c, 0x5fc5, - 0x6ccc, 0x73cc, 0x7562, 0x758b, 0x7b46, 0x82fe, 0x999d, 0x4e4f, 0x903c, - 0x4e0b, 0x4f55, 0x53a6, 0x590f, 0x5ec8, 0x6630, 0x6cb3, 0x7455, 0x8377, - 0x8766, 0x8cc0, 0x9050, 0x971e, 0x9c15, 0x58d1, 0x5b78, 0x8650, 0x8b14, - 0x9db4, 0x5bd2, 0x6068, 0x608d, 0x65f1, 0x6c57, 0x6f22, 0x6fa3, 0x701a, - 0x7f55, 0x7ff0, 0x9591, 0x9592, 0x9650, 0x97d3, 0x5272, 0x8f44, 0x51fd, - 0x542b, 0x54b8, 0x5563, 0x558a, 0x6abb, 0x6db5, 0x7dd8, 0x8266, 0x929c, - 0x9677, 0x9e79, 0x5408, 0x54c8, 0x76d2, 0x86e4, 0x95a4, 0x95d4, 0x965c, - 0x4ea2, 0x4f09, 0x59ee, 0x5ae6, 0x5df7, 0x6052, 0x6297, 0x676d, 0x6841, - 0x6c86, 0x6e2f, 0x7f38, 0x809b, 0x822a, 0xfa08, 0xfa09, 0x9805, 0x4ea5, - 0x5055, 0x54b3, 0x5793, 0x595a, 0x5b69, 0x5bb3, 0x61c8, 0x6977, 0x6d77, - 0x7023, 0x87f9, 0x89e3, 0x8a72, 0x8ae7, 0x9082, 0x99ed, 0x9ab8, 0x52be, - 0x6838, 0x5016, 0x5e78, 0x674f, 0x8347, 0x884c, 0x4eab, 0x5411, 0x56ae, - 0x73e6, 0x9115, 0x97ff, 0x9909, 0x9957, 0x9999, 0x5653, 0x589f, 0x865b, - 0x8a31, 0x61b2, 0x6af6, 0x737b, 0x8ed2, 0x6b47, 0x96aa, 0x9a57, 0x5955, - 0x7200, 0x8d6b, 0x9769, 0x4fd4, 0x5cf4, 0x5f26, 0x61f8, 0x665b, 0x6ceb, - 0x70ab, 0x7384, 0x73b9, 0x73fe, 0x7729, 0x774d, 0x7d43, 0x7d62, 0x7e23, - 0x8237, 0x8852, 0xfa0a, 0x8ce2, 0x9249, 0x986f, 0x5b51, 0x7a74, 0x8840, - 0x9801, 0x5acc, 0x4fe0, 0x5354, 0x593e, 0x5cfd, 0x633e, 0x6d79, 0x72f9, - 0x8105, 0x8107, 0x83a2, 0x92cf, 0x9830, 0x4ea8, 0x5144, 0x5211, 0x578b, - 0x5f62, 0x6cc2, 0x6ece, 0x7005, 0x7050, 0x70af, 0x7192, 0x73e9, 0x7469, - 0x834a, 0x87a2, 0x8861, 0x9008, 0x90a2, 0x93a3, 0x99a8, 0x516e, 0x5f57, - 0x60e0, 0x6167, 0x66b3, 0x8559, 0x8e4a, 0x91af, 0x978b, 0x4e4e, 0x4e92, - 0x547c, 0x58d5, 0x58fa, 0x597d, 0x5cb5, 0x5f27, 0x6236, 0x6248, 0x660a, - 0x6667, 0x6beb, 0x6d69, 0x6dcf, 0x6e56, 0x6ef8, 0x6f94, 0x6fe0, 0x6fe9, - 0x705d, 0x72d0, 0x7425, 0x745a, 0x74e0, 0x7693, 0x795c, 0x7cca, 0x7e1e, - 0x80e1, 0x82a6, 0x846b, 0x84bf, 0x864e, 0x865f, 0x8774, 0x8b77, 0x8c6a, - 0x93ac, 0x9800, 0x9865, 0x60d1, 0x6216, 0x9177, 0x5a5a, 0x660f, 0x6df7, - 0x6e3e, 0x743f, 0x9b42, 0x5ffd, 0x60da, 0x7b0f, 0x54c4, 0x5f18, 0x6c5e, - 0x6cd3, 0x6d2a, 0x70d8, 0x7d05, 0x8679, 0x8a0c, 0x9d3b, 0x5316, 0x548c, - 0x5b05, 0x6a3a, 0x706b, 0x7575, 0x798d, 0x79be, 0x82b1, 0x83ef, 0x8a71, - 0x8b41, 0x8ca8, 0x9774, 0xfa0b, 0x64f4, 0x652b, 0x78ba, 0x78bb, 0x7a6b, - 0x4e38, 0x559a, 0x5950, 0x5ba6, 0x5e7b, 0x60a3, 0x63db, 0x6b61, 0x6665, - 0x6853, 0x6e19, 0x7165, 0x74b0, 0x7d08, 0x9084, 0x9a69, 0x9c25, 0x6d3b, - 0x6ed1, 0x733e, 0x8c41, 0x95ca, 0x51f0, 0x5e4c, 0x5fa8, 0x604d, 0x60f6, - 0x6130, 0x614c, 0x6643, 0x6644, 0x69a5, 0x6cc1, 0x6e5f, 0x6ec9, 0x6f62, - 0x714c, 0x749c, 0x7687, 0x7bc1, 0x7c27, 0x8352, 0x8757, 0x9051, 0x968d, - 0x9ec3, 0x532f, 0x56de, 0x5efb, 0x5f8a, 0x6062, 0x6094, 0x61f7, 0x6666, - 0x6703, 0x6a9c, 0x6dee, 0x6fae, 0x7070, 0x736a, 0x7e6a, 0x81be, 0x8334, - 0x86d4, 0x8aa8, 0x8cc4, 0x5283, 0x7372, 0x5b96, 0x6a6b, 0x9404, 0x54ee, - 0x5686, 0x5b5d, 0x6548, 0x6585, 0x66c9, 0x689f, 0x6d8d, 0x6dc6, 0x723b, - 0x80b4, 0x9175, 0x9a4d, 0x4faf, 0x5019, 0x539a, 0x540e, 0x543c, 0x5589, - 0x55c5, 0x5e3f, 0x5f8c, 0x673d, 0x7166, 0x73dd, 0x9005, 0x52db, 0x52f3, - 0x5864, 0x58ce, 0x7104, 0x718f, 0x71fb, 0x85b0, 0x8a13, 0x6688, 0x85a8, - 0x55a7, 0x6684, 0x714a, 0x8431, 0x5349, 0x5599, 0x6bc1, 0x5f59, 0x5fbd, - 0x63ee, 0x6689, 0x7147, 0x8af1, 0x8f1d, 0x9ebe, 0x4f11, 0x643a, 0x70cb, - 0x7566, 0x8667, 0x6064, 0x8b4e, 0x9df8, 0x5147, 0x51f6, 0x5308, 0x6d36, - 0x80f8, 0x9ed1, 0x6615, 0x6b23, 0x7098, 0x75d5, 0x5403, 0x5c79, 0x7d07, - 0x8a16, 0x6b20, 0x6b3d, 0x6b46, 0x5438, 0x6070, 0x6d3d, 0x7fd5, 0x8208, - 0x50d6, 0x51de, 0x559c, 0x566b, 0x56cd, 0x59ec, 0x5b09, 0x5e0c, 0x6199, - 0x6198, 0x6231, 0x665e, 0x66e6, 0x7199, 0x71b9, 0x71ba, 0x72a7, 0x79a7, - 0x7a00, 0x7fb2, 0x8a70, + 0x3000, 0x3001, 0x3002, 0x00b7, 0x2025, 0x2026, 0x00a8, 0x3003, 0x00ad, + 0x2015, 0x2225, 0xff3c, 0x223c, 0x2018, 0x2019, 0x201c, 0x201d, 0x3014, + 0x3015, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, + 0x3010, 0x3011, 0x00b1, 0x00d7, 0x00f7, 0x2260, 0x2264, 0x2265, 0x221e, + 0x2234, 0x00b0, 0x2032, 0x2033, 0x2103, 0x212b, 0xffe0, 0xffe1, 0xffe5, + 0x2642, 0x2640, 0x2220, 0x22a5, 0x2312, 0x2202, 0x2207, 0x2261, 0x2252, + 0x00a7, 0x203b, 0x2606, 0x2605, 0x25cb, 0x25cf, 0x25ce, 0x25c7, 0x25c6, + 0x25a1, 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x2192, 0x2190, 0x2191, + 0x2193, 0x2194, 0x3013, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d, 0x2235, + 0x222b, 0x222c, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282, 0x2283, 0x222a, + 0x2229, 0x2227, 0x2228, 0xffe2, 0x21d2, 0x21d4, 0x2200, 0x2203, 0x00b4, + 0xff5e, 0x02c7, 0x02d8, 0x02dd, 0x02da, 0x02d9, 0x00b8, 0x02db, 0x00a1, + 0x00bf, 0x02d0, 0x222e, 0x2211, 0x220f, 0x00a4, 0x2109, 0x2030, 0x25c1, + 0x25c0, 0x25b7, 0x25b6, 0x2664, 0x2660, 0x2661, 0x2665, 0x2667, 0x2663, + 0x25c9, 0x25c8, 0x25a3, 0x25d0, 0x25d1, 0x2592, 0x25a4, 0x25a5, 0x25a8, + 0x25a7, 0x25a6, 0x25a9, 0x2668, 0x260f, 0x260e, 0x261c, 0x261e, 0x00b6, + 0x2020, 0x2021, 0x2195, 0x2197, 0x2199, 0x2196, 0x2198, 0x266d, 0x2669, + 0x266a, 0x266c, 0x327f, 0x321c, 0x2116, 0x33c7, 0x2122, 0x33c2, 0x33d8, + 0x2121, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0xff01, + 0xff02, 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, + 0xff0b, 0xff0c, 0xff0d, 0xff0e, 0xff0f, 0xff10, 0xff11, 0xff12, 0xff13, + 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0xff1a, 0xff1b, 0xff1c, + 0xff1d, 0xff1e, 0xff1f, 0xff20, 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, + 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, + 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, + 0xff38, 0xff39, 0xff3a, 0xff3b, 0xffe6, 0xff3d, 0xff3e, 0xff3f, 0xff40, + 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, + 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52, + 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58, 0xff59, 0xff5a, 0xff5b, + 0xff5c, 0xff5d, 0xffe3, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, + 0x3137, 0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, + 0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148, + 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x314f, 0x3150, 0x3151, + 0x3152, 0x3153, 0x3154, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a, + 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163, + 0x3164, 0x3165, 0x3166, 0x3167, 0x3168, 0x3169, 0x316a, 0x316b, 0x316c, + 0x316d, 0x316e, 0x316f, 0x3170, 0x3171, 0x3172, 0x3173, 0x3174, 0x3175, + 0x3176, 0x3177, 0x3178, 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e, + 0x317f, 0x3180, 0x3181, 0x3182, 0x3183, 0x3184, 0x3185, 0x3186, 0x3187, + 0x3188, 0x3189, 0x318a, 0x318b, 0x318c, 0x318d, 0x318e, 0x2170, 0x2171, + 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, -1, + -1, -1, -1, -1, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, + 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, -1, -1, -1, -1, + -1, -1, -1, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, + 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, + 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, + -1, -1, -1, -1, -1, -1, -1, -1, 0x03b1, + 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, + 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, + 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, -1, -1, -1, -1, + -1, -1, 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, + 0x252c, 0x2524, 0x2534, 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b, + 0x2517, 0x2523, 0x2533, 0x252b, 0x253b, 0x254b, 0x2520, 0x252f, 0x2528, + 0x2537, 0x253f, 0x251d, 0x2530, 0x2525, 0x2538, 0x2542, 0x2512, 0x2511, + 0x251a, 0x2519, 0x2516, 0x2515, 0x250e, 0x250d, 0x251e, 0x251f, 0x2521, + 0x2522, 0x2526, 0x2527, 0x2529, 0x252a, 0x252d, 0x252e, 0x2531, 0x2532, + 0x2535, 0x2536, 0x2539, 0x253a, 0x253d, 0x253e, 0x2540, 0x2541, 0x2543, + 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0x3395, 0x3396, 0x3397, + 0x2113, 0x3398, 0x33c4, 0x33a3, 0x33a4, 0x33a5, 0x33a6, 0x3399, 0x339a, + 0x339b, 0x339c, 0x339d, 0x339e, 0x339f, 0x33a0, 0x33a1, 0x33a2, 0x33ca, + 0x338d, 0x338e, 0x338f, 0x33cf, 0x3388, 0x3389, 0x33c8, 0x33a7, 0x33a8, + 0x33b0, 0x33b1, 0x33b2, 0x33b3, 0x33b4, 0x33b5, 0x33b6, 0x33b7, 0x33b8, + 0x33b9, 0x3380, 0x3381, 0x3382, 0x3383, 0x3384, 0x33ba, 0x33bb, 0x33bc, + 0x33bd, 0x33be, 0x33bf, 0x3390, 0x3391, 0x3392, 0x3393, 0x3394, 0x2126, + 0x33c0, 0x33c1, 0x338a, 0x338b, 0x338c, 0x33d6, 0x33c5, 0x33ad, 0x33ae, + 0x33af, 0x33db, 0x33a9, 0x33aa, 0x33ab, 0x33ac, 0x33dd, 0x33d0, 0x33d3, + 0x33c3, 0x33c9, 0x33dc, 0x33c6, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 0x00c6, 0x00d0, 0x00aa, 0x0126, -1, 0x0132, -1, 0x013f, + 0x0141, 0x00d8, 0x0152, 0x00ba, 0x00de, 0x0166, 0x014a, -1, 0x3260, + 0x3261, 0x3262, 0x3263, 0x3264, 0x3265, 0x3266, 0x3267, 0x3268, 0x3269, + 0x326a, 0x326b, 0x326c, 0x326d, 0x326e, 0x326f, 0x3270, 0x3271, 0x3272, + 0x3273, 0x3274, 0x3275, 0x3276, 0x3277, 0x3278, 0x3279, 0x327a, 0x327b, + 0x24d0, 0x24d1, 0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7, 0x24d8, + 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd, 0x24de, 0x24df, 0x24e0, 0x24e1, + 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x2460, + 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, + 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x00bd, 0x2153, 0x2154, 0x00bc, + 0x00be, 0x215b, 0x215c, 0x215d, 0x215e, 0x00e6, 0x0111, 0x00f0, 0x0127, + 0x0131, 0x0133, 0x0138, 0x0140, 0x0142, 0x00f8, 0x0153, 0x00df, 0x00fe, + 0x0167, 0x014b, 0x0149, 0x3200, 0x3201, 0x3202, 0x3203, 0x3204, 0x3205, + 0x3206, 0x3207, 0x3208, 0x3209, 0x320a, 0x320b, 0x320c, 0x320d, 0x320e, + 0x320f, 0x3210, 0x3211, 0x3212, 0x3213, 0x3214, 0x3215, 0x3216, 0x3217, + 0x3218, 0x3219, 0x321a, 0x321b, 0x249c, 0x249d, 0x249e, 0x249f, 0x24a0, + 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5, 0x24a6, 0x24a7, 0x24a8, 0x24a9, + 0x24aa, 0x24ab, 0x24ac, 0x24ad, 0x24ae, 0x24af, 0x24b0, 0x24b1, 0x24b2, + 0x24b3, 0x24b4, 0x24b5, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, + 0x247a, 0x247b, 0x247c, 0x247d, 0x247e, 0x247f, 0x2480, 0x2481, 0x2482, + 0x00b9, 0x00b2, 0x00b3, 0x2074, 0x207f, 0x2081, 0x2082, 0x2083, 0x2084, + 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, + 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050, 0x3051, 0x3052, + 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, + 0x305c, 0x305d, 0x305e, 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, + 0x3065, 0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, + 0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, + 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, + 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088, + 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090, 0x3091, + 0x3092, 0x3093, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, + 0x30a6, 0x30a7, 0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, + 0x30af, 0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, + 0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0, + 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8, 0x30c9, + 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0, 0x30d1, 0x30d2, + 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8, 0x30d9, 0x30da, 0x30db, + 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, + 0x30e5, 0x30e6, 0x30e7, 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, + 0x30ee, 0x30ef, 0x30f0, 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, + -1, -1, -1, -1, -1, -1, -1, -1, 0x0410, + 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416, 0x0417, 0x0418, + 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, 0x0420, 0x0421, + 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, + 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, + 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, + 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, + 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 0x3400, 0x3401, 0x3402, + 0x3403, 0x3404, 0x3405, 0x3406, 0x3407, 0x3408, 0x3409, 0x340a, 0x340b, + 0x340c, 0x340d, 0x340e, 0x340f, 0x3410, 0x3411, 0x3412, 0x3413, 0x3414, + 0x3415, 0x3416, 0x3417, 0x3418, 0x3419, 0x341a, 0x341b, 0x341c, 0x341d, + 0x341e, 0x341f, 0x3420, 0x3421, 0x3422, 0x3423, 0x3424, 0x3425, 0x3426, + 0x3427, 0x3428, 0x3429, 0x342a, 0x342b, 0x342c, 0x342d, 0x342e, 0x342f, + 0x3430, 0x3431, 0x3432, 0x3433, 0x3434, 0x3435, 0x3436, 0x3437, 0x3438, + 0x3439, 0x343a, 0x343b, 0x343c, 0x343d, 0x343e, 0x343f, 0x3440, 0x3441, + 0x3442, 0x3443, 0x3444, 0x3445, 0x3446, 0x3447, 0x3448, 0x3449, 0x344a, + 0x344b, 0x344c, 0x344d, 0x344e, 0x344f, 0x3450, 0x3451, 0x3452, 0x3453, + 0x3454, 0x3455, 0x3456, 0x3457, 0x3458, 0x3459, 0x345a, 0x345b, 0x345c, + 0x345d, 0x345e, 0x345f, 0x3460, 0x3461, 0x3462, 0x3463, 0x3464, 0x3465, + 0x3466, 0x3467, 0x3468, 0x3469, 0x346a, 0x346b, 0x346c, 0x346d, 0x346e, + 0x346f, 0x3470, 0x3471, 0x3472, 0x3473, 0x3474, 0x3475, 0x3476, 0x3477, + 0x3478, 0x3479, 0x347a, 0x347b, 0x347c, 0x347d, 0x347e, 0x347f, 0x3480, + 0x3481, 0x3482, 0x3483, 0x3484, 0x3485, 0x3486, 0x3487, 0x3488, 0x3489, + 0x348a, 0x348b, 0x348c, 0x348d, 0x348e, 0x348f, 0x3490, 0x3491, 0x3492, + 0x3493, 0x3494, 0x3495, 0x3496, 0x3497, 0x3498, 0x3499, 0x349a, 0x349b, + 0x349c, 0x349d, 0x349e, 0x349f, 0x34a0, 0x34a1, 0x34a2, 0x34a3, 0x34a4, + 0x34a5, 0x34a6, 0x34a7, 0x34a8, 0x34a9, 0x34aa, 0x34ab, 0x34ac, 0x34ad, + 0x34ae, 0x34af, 0x34b0, 0x34b1, 0x34b2, 0x34b3, 0x34b4, 0x34b5, 0x34b6, + 0x34b7, 0x34b8, 0x34b9, 0x34ba, 0x34bb, 0x34bc, 0x34bd, 0x34be, 0x34bf, + 0x34c0, 0x34c1, 0x34c2, 0x34c3, 0x34c4, 0x34c5, 0x34c6, 0x34c7, 0x34c8, + 0x34c9, 0x34ca, 0x34cb, 0x34cc, 0x34cd, 0x34ce, 0x34cf, 0x34d0, 0x34d1, + 0x34d2, 0x34d3, 0x34d4, 0x34d5, 0x34d6, 0x34d7, 0x34d8, 0x34d9, 0x34da, + 0x34db, 0x34dc, 0x34dd, 0x34de, 0x34df, 0x34e0, 0x34e1, 0x34e2, 0x34e3, + 0x34e4, 0x34e5, 0x34e6, 0x34e7, 0x34e8, 0x34e9, 0x34ea, 0x34eb, 0x34ec, + 0x34ed, 0x34ee, 0x34ef, 0x34f0, 0x34f1, 0x34f2, 0x34f3, 0x34f4, 0x34f5, + 0x34f6, 0x34f7, 0x34f8, 0x34f9, 0x34fa, 0x34fb, 0x34fc, 0x34fd, 0x34fe, + 0x34ff, 0x3500, 0x3501, 0x3502, 0x3503, 0x3504, 0x3505, 0x3506, 0x3507, + 0x3508, 0x3509, 0x350a, 0x350b, 0x350c, 0x350d, 0x350e, 0x350f, 0x3510, + 0x3511, 0x3512, 0x3513, 0x3514, 0x3515, 0x3516, 0x3517, 0x3518, 0x3519, + 0x351a, 0x351b, 0x351c, 0x351d, 0x351e, 0x351f, 0x3520, 0x3521, 0x3522, + 0x3523, 0x3524, 0x3525, 0x3526, 0x3527, 0x3528, 0x3529, 0x352a, 0x352b, + 0x352c, 0x352d, 0x352e, 0x352f, 0x3530, 0x3531, 0x3532, 0x3533, 0x3534, + 0x3535, 0x3536, 0x3537, 0x3538, 0x3539, 0x353a, 0x353b, 0x353c, 0x353d, + 0x353e, 0x353f, 0x3540, 0x3541, 0x3542, 0x3543, 0x3544, 0x3545, 0x3546, + 0x3547, 0x3548, 0x3549, 0x354a, 0x354b, 0x354c, 0x354d, 0x354e, 0x354f, + 0x3550, 0x3551, 0x3552, 0x3553, 0x3554, 0x3555, 0x3556, 0x3557, 0x3558, + 0x3559, 0x355a, 0x355b, 0x355c, 0x355d, 0x355e, 0x355f, 0x3560, 0x3561, + 0x3562, 0x3563, 0x3564, 0x3565, 0x3566, 0x3567, 0x3568, 0x3569, 0x356a, + 0x356b, 0x356c, 0x356d, 0x356e, 0x356f, 0x3570, 0x3571, 0x3572, 0x3573, + 0x3574, 0x3575, 0x3576, 0x3577, 0x3578, 0x3579, 0x357a, 0x357b, 0x357c, + 0x357d, 0x357e, 0x357f, 0x3580, 0x3581, 0x3582, 0x3583, 0x3584, 0x3585, + 0x3586, 0x3587, 0x3588, 0x3589, 0x358a, 0x358b, 0x358c, 0x358d, 0x358e, + 0x358f, 0x3590, 0x3591, 0x3592, 0x3593, 0x3594, 0x3595, 0x3596, 0x3597, + 0x3598, 0x3599, 0x359a, 0x359b, 0x359c, 0x359d, 0x359e, 0x359f, 0x35a0, + 0x35a1, 0x35a2, 0x35a3, 0x35a4, 0x35a5, 0x35a6, 0x35a7, 0x35a8, 0x35a9, + 0x35aa, 0x35ab, 0x35ac, 0x35ad, 0x35ae, 0x35af, 0x35b0, 0x35b1, 0x35b2, + 0x35b3, 0x35b4, 0x35b5, 0x35b6, 0x35b7, 0x35b8, 0x35b9, 0x35ba, 0x35bb, + 0x35bc, 0x35bd, 0x35be, 0x35bf, 0x35c0, 0x35c1, 0x35c2, 0x35c3, 0x35c4, + 0x35c5, 0x35c6, 0x35c7, 0x35c8, 0x35c9, 0x35ca, 0x35cb, 0x35cc, 0x35cd, + 0x35ce, 0x35cf, 0x35d0, 0x35d1, 0x35d2, 0x35d3, 0x35d4, 0x35d5, 0x35d6, + 0x35d7, 0x35d8, 0x35d9, 0x35da, 0x35db, 0x35dc, 0x35dd, 0x35de, 0x35df, + 0x35e0, 0x35e1, 0x35e2, 0x35e3, 0x35e4, 0x35e5, 0x35e6, 0x35e7, 0x35e8, + 0x35e9, 0x35ea, 0x35eb, 0x35ec, 0x35ed, 0x35ee, 0x35ef, 0x35f0, 0x35f1, + 0x35f2, 0x35f3, 0x35f4, 0x35f5, 0x35f6, 0x35f7, 0x35f8, 0x35f9, 0x35fa, + 0x35fb, 0x35fc, 0x35fd, 0x35fe, 0x35ff, 0x3600, 0x3601, 0x3602, 0x3603, + 0x3604, 0x3605, 0x3606, 0x3607, 0x3608, 0x3609, 0x360a, 0x360b, 0x360c, + 0x360d, 0x360e, 0x360f, 0x3610, 0x3611, 0x3612, 0x3613, 0x3614, 0x3615, + 0x3616, 0x3617, 0x3618, 0x3619, 0x361a, 0x361b, 0x361c, 0x361d, 0x361e, + 0x361f, 0x3620, 0x3621, 0x3622, 0x3623, 0x3624, 0x3625, 0x3626, 0x3627, + 0x3628, 0x3629, 0x362a, 0x362b, 0x362c, 0x362d, 0x362e, 0x362f, 0x3630, + 0x3631, 0x3632, 0x3633, 0x3634, 0x3635, 0x3636, 0x3637, 0x3638, 0x3639, + 0x363a, 0x363b, 0x363c, 0x363d, 0x363e, 0x363f, 0x3640, 0x3641, 0x3642, + 0x3643, 0x3644, 0x3645, 0x3646, 0x3647, 0x3648, 0x3649, 0x364a, 0x364b, + 0x364c, 0x364d, 0x364e, 0x364f, 0x3650, 0x3651, 0x3652, 0x3653, 0x3654, + 0x3655, 0x3656, 0x3657, 0x3658, 0x3659, 0x365a, 0x365b, 0x365c, 0x365d, + 0x365e, 0x365f, 0x3660, 0x3661, 0x3662, 0x3663, 0x3664, 0x3665, 0x3666, + 0x3667, 0x3668, 0x3669, 0x366a, 0x366b, 0x366c, 0x366d, 0x366e, 0x366f, + 0x3670, 0x3671, 0x3672, 0x3673, 0x3674, 0x3675, 0x3676, 0x3677, 0x3678, + 0x3679, 0x367a, 0x367b, 0x367c, 0x367d, 0x367e, 0x367f, 0x3680, 0x3681, + 0x3682, 0x3683, 0x3684, 0x3685, 0x3686, 0x3687, 0x3688, 0x3689, 0x368a, + 0x368b, 0x368c, 0x368d, 0x368e, 0x368f, 0x3690, 0x3691, 0x3692, 0x3693, + 0x3694, 0x3695, 0x3696, 0x3697, 0x3698, 0x3699, 0x369a, 0x369b, 0x369c, + 0x369d, 0x369e, 0x369f, 0x36a0, 0x36a1, 0x36a2, 0x36a3, 0x36a4, 0x36a5, + 0x36a6, 0x36a7, 0x36a8, 0x36a9, 0x36aa, 0x36ab, 0x36ac, 0x36ad, 0x36ae, + 0x36af, 0x36b0, 0x36b1, 0x36b2, 0x36b3, 0x36b4, 0x36b5, 0x36b6, 0x36b7, + 0x36b8, 0x36b9, 0x36ba, 0x36bb, 0x36bc, 0x36bd, 0x36be, 0x36bf, 0x36c0, + 0x36c1, 0x36c2, 0x36c3, 0x36c4, 0x36c5, 0x36c6, 0x36c7, 0x36c8, 0x36c9, + 0x36ca, 0x36cb, 0x36cc, 0x36cd, 0x36ce, 0x36cf, 0x36d0, 0x36d1, 0x36d2, + 0x36d3, 0x36d4, 0x36d5, 0x36d6, 0x36d7, 0x36d8, 0x36d9, 0x36da, 0x36db, + 0x36dc, 0x36dd, 0x36de, 0x36df, 0x36e0, 0x36e1, 0x36e2, 0x36e3, 0x36e4, + 0x36e5, 0x36e6, 0x36e7, 0x36e8, 0x36e9, 0x36ea, 0x36eb, 0x36ec, 0x36ed, + 0x36ee, 0x36ef, 0x36f0, 0x36f1, 0x36f2, 0x36f3, 0x36f4, 0x36f5, 0x36f6, + 0x36f7, 0x36f8, 0x36f9, 0x36fa, 0x36fb, 0x36fc, 0x36fd, 0x36fe, 0x36ff, + 0x3700, 0x3701, 0x3702, 0x3703, 0x3704, 0x3705, 0x3706, 0x3707, 0x3708, + 0x3709, 0x370a, 0x370b, 0x370c, 0x370d, 0x370e, 0x370f, 0x3710, 0x3711, + 0x3712, 0x3713, 0x3714, 0x3715, 0x3716, 0x3717, 0x3718, 0x3719, 0x371a, + 0x371b, 0x371c, 0x371d, 0x371e, 0x371f, 0x3720, 0x3721, 0x3722, 0x3723, + 0x3724, 0x3725, 0x3726, 0x3727, 0x3728, 0x3729, 0x372a, 0x372b, 0x372c, + 0x372d, 0x372e, 0x372f, 0x3730, 0x3731, 0x3732, 0x3733, 0x3734, 0x3735, + 0x3736, 0x3737, 0x3738, 0x3739, 0x373a, 0x373b, 0x373c, 0x373d, 0x373e, + 0x373f, 0x3740, 0x3741, 0x3742, 0x3743, 0x3744, 0x3745, 0x3746, 0x3747, + 0x3748, 0x3749, 0x374a, 0x374b, 0x374c, 0x374d, 0x374e, 0x374f, 0x3750, + 0x3751, 0x3752, 0x3753, 0x3754, 0x3755, 0x3756, 0x3757, 0x3758, 0x3759, + 0x375a, 0x375b, 0x375c, 0x375d, 0x375e, 0x375f, 0x3760, 0x3761, 0x3762, + 0x3763, 0x3764, 0x3765, 0x3766, 0x3767, 0x3768, 0x3769, 0x376a, 0x376b, + 0x376c, 0x376d, 0x376e, 0x376f, 0x3770, 0x3771, 0x3772, 0x3773, 0x3774, + 0x3775, 0x3776, 0x3777, 0x3778, 0x3779, 0x377a, 0x377b, 0x377c, 0x377d, + 0x377e, 0x377f, 0x3780, 0x3781, 0x3782, 0x3783, 0x3784, 0x3785, 0x3786, + 0x3787, 0x3788, 0x3789, 0x378a, 0x378b, 0x378c, 0x378d, 0x378e, 0x378f, + 0x3790, 0x3791, 0x3792, 0x3793, 0x3794, 0x3795, 0x3796, 0x3797, 0x3798, + 0x3799, 0x379a, 0x379b, 0x379c, 0x379d, 0x379e, 0x379f, 0x37a0, 0x37a1, + 0x37a2, 0x37a3, 0x37a4, 0x37a5, 0x37a6, 0x37a7, 0x37a8, 0x37a9, 0x37aa, + 0x37ab, 0x37ac, 0x37ad, 0x37ae, 0x37af, 0x37b0, 0x37b1, 0x37b2, 0x37b3, + 0x37b4, 0x37b5, 0x37b6, 0x37b7, 0x37b8, 0x37b9, 0x37ba, 0x37bb, 0x37bc, + 0x37bd, 0x37be, 0x37bf, 0x37c0, 0x37c1, 0x37c2, 0x37c3, 0x37c4, 0x37c5, + 0x37c6, 0x37c7, 0x37c8, 0x37c9, 0x37ca, 0x37cb, 0x37cc, 0x37cd, 0x37ce, + 0x37cf, 0x37d0, 0x37d1, 0x37d2, 0x37d3, 0x37d4, 0x37d5, 0x37d6, 0x37d7, + 0x37d8, 0x37d9, 0x37da, 0x37db, 0x37dc, 0x37dd, 0x37de, 0x37df, 0x37e0, + 0x37e1, 0x37e2, 0x37e3, 0x37e4, 0x37e5, 0x37e6, 0x37e7, 0x37e8, 0x37e9, + 0x37ea, 0x37eb, 0x37ec, 0x37ed, 0x37ee, 0x37ef, 0x37f0, 0x37f1, 0x37f2, + 0x37f3, 0x37f4, 0x37f5, 0x37f6, 0x37f7, 0x37f8, 0x37f9, 0x37fa, 0x37fb, + 0x37fc, 0x37fd, 0x37fe, 0x37ff, 0x3800, 0x3801, 0x3802, 0x3803, 0x3804, + 0x3805, 0x3806, 0x3807, 0x3808, 0x3809, 0x380a, 0x380b, 0x380c, 0x380d, + 0x380e, 0x380f, 0x3810, 0x3811, 0x3812, 0x3813, 0x3814, 0x3815, 0x3816, + 0x3817, 0x3818, 0x3819, 0x381a, 0x381b, 0x381c, 0x381d, 0x381e, 0x381f, + 0x3820, 0x3821, 0x3822, 0x3823, 0x3824, 0x3825, 0x3826, 0x3827, 0x3828, + 0x3829, 0x382a, 0x382b, 0x382c, 0x382d, 0x382e, 0x382f, 0x3830, 0x3831, + 0x3832, 0x3833, 0x3834, 0x3835, 0x3836, 0x3837, 0x3838, 0x3839, 0x383a, + 0x383b, 0x383c, 0x383d, 0x383e, 0x383f, 0x3840, 0x3841, 0x3842, 0x3843, + 0x3844, 0x3845, 0x3846, 0x3847, 0x3848, 0x3849, 0x384a, 0x384b, 0x384c, + 0x384d, 0x384e, 0x384f, 0x3850, 0x3851, 0x3852, 0x3853, 0x3854, 0x3855, + 0x3856, 0x3857, 0x3858, 0x3859, 0x385a, 0x385b, 0x385c, 0x385d, 0x385e, + 0x385f, 0x3860, 0x3861, 0x3862, 0x3863, 0x3864, 0x3865, 0x3866, 0x3867, + 0x3868, 0x3869, 0x386a, 0x386b, 0x386c, 0x386d, 0x386e, 0x386f, 0x3870, + 0x3871, 0x3872, 0x3873, 0x3874, 0x3875, 0x3876, 0x3877, 0x3878, 0x3879, + 0x387a, 0x387b, 0x387c, 0x387d, 0x387e, 0x387f, 0x3880, 0x3881, 0x3882, + 0x3883, 0x3884, 0x3885, 0x3886, 0x3887, 0x3888, 0x3889, 0x388a, 0x388b, + 0x388c, 0x388d, 0x388e, 0x388f, 0x3890, 0x3891, 0x3892, 0x3893, 0x3894, + 0x3895, 0x3896, 0x3897, 0x3898, 0x3899, 0x389a, 0x389b, 0x389c, 0x389d, + 0x389e, 0x389f, 0x38a0, 0x38a1, 0x38a2, 0x38a3, 0x38a4, 0x38a5, 0x38a6, + 0x38a7, 0x38a8, 0x38a9, 0x38aa, 0x38ab, 0x38ac, 0x38ad, 0x38ae, 0x38af, + 0x38b0, 0x38b1, 0x38b2, 0x38b3, 0x38b4, 0x38b5, 0x38b6, 0x38b7, 0x38b8, + 0x38b9, 0x38ba, 0x38bb, 0x38bc, 0x38bd, 0x38be, 0x38bf, 0x38c0, 0x38c1, + 0x38c2, 0x38c3, 0x38c4, 0x38c5, 0x38c6, 0x38c7, 0x38c8, 0x38c9, 0x38ca, + 0x38cb, 0x38cc, 0x38cd, 0x38ce, 0x38cf, 0x38d0, 0x38d1, 0x38d2, 0x38d3, + 0x38d4, 0x38d5, 0x38d6, 0x38d7, 0x38d8, 0x38d9, 0x38da, 0x38db, 0x38dc, + 0x38dd, 0x38de, 0x38df, 0x38e0, 0x38e1, 0x38e2, 0x38e3, 0x38e4, 0x38e5, + 0x38e6, 0x38e7, 0x38e8, 0x38e9, 0x38ea, 0x38eb, 0x38ec, 0x38ed, 0x38ee, + 0x38ef, 0x38f0, 0x38f1, 0x38f2, 0x38f3, 0x38f4, 0x38f5, 0x38f6, 0x38f7, + 0x38f8, 0x38f9, 0x38fa, 0x38fb, 0x38fc, 0x38fd, 0x38fe, 0x38ff, 0x3900, + 0x3901, 0x3902, 0x3903, 0x3904, 0x3905, 0x3906, 0x3907, 0x3908, 0x3909, + 0x390a, 0x390b, 0x390c, 0x390d, 0x390e, 0x390f, 0x3910, 0x3911, 0x3912, + 0x3913, 0x3914, 0x3915, 0x3916, 0x3917, 0x3918, 0x3919, 0x391a, 0x391b, + 0x391c, 0x391d, 0x391e, 0x391f, 0x3920, 0x3921, 0x3922, 0x3923, 0x3924, + 0x3925, 0x3926, 0x3927, 0x3928, 0x3929, 0x392a, 0x392b, 0x392c, 0x392d, + 0x392e, 0x392f, 0x3930, 0x3931, 0x3932, 0x3933, 0x3934, 0x3935, 0x3936, + 0x3937, 0x3938, 0x3939, 0x393a, 0x393b, 0x393c, 0x393d, 0x393e, 0x393f, + 0x3940, 0x3941, 0x3942, 0x3943, 0x3944, 0x3945, 0x3946, 0x3947, 0x3948, + 0x3949, 0x394a, 0x394b, 0x394c, 0x394d, 0x394e, 0x394f, 0x3950, 0x3951, + 0x3952, 0x3953, 0x3954, 0x3955, 0x3956, 0x3957, 0x3958, 0x3959, 0x395a, + 0x395b, 0x395c, 0x395d, 0x395e, 0x395f, 0x3960, 0x3961, 0x3962, 0x3963, + 0x3964, 0x3965, 0x3966, 0x3967, 0x3968, 0x3969, 0x396a, 0x396b, 0x396c, + 0x396d, 0x396e, 0x396f, 0x3970, 0x3971, 0x3972, 0x3973, 0x3974, 0x3975, + 0x3976, 0x3977, 0x3978, 0x3979, 0x397a, 0x397b, 0x397c, 0x397d, 0x397e, + 0x397f, 0x3980, 0x3981, 0x3982, 0x3983, 0x3984, 0x3985, 0x3986, 0x3987, + 0x3988, 0x3989, 0x398a, 0x398b, 0x398c, 0x398d, 0x398e, 0x398f, 0x3990, + 0x3991, 0x3992, 0x3993, 0x3994, 0x3995, 0x3996, 0x3997, 0x3998, 0x3999, + 0x399a, 0x399b, 0x399c, 0x399d, 0x399e, 0x399f, 0x39a0, 0x39a1, 0x39a2, + 0x39a3, 0x39a4, 0x39a5, 0x39a6, 0x39a7, 0x39a8, 0x39a9, 0x39aa, 0x39ab, + 0x39ac, 0x39ad, 0x39ae, 0x39af, 0x39b0, 0x39b1, 0x39b2, 0x39b3, 0x39b4, + 0x39b5, 0x39b6, 0x39b7, 0x39b8, 0x39b9, 0x39ba, 0x39bb, 0x39bc, 0x39bd, + 0x39be, 0x39bf, 0x39c0, 0x39c1, 0x39c2, 0x39c3, 0x39c4, 0x39c5, 0x39c6, + 0x39c7, 0x39c8, 0x39c9, 0x39ca, 0x39cb, 0x39cc, 0x39cd, 0x39ce, 0x39cf, + 0x39d0, 0x39d1, 0x39d2, 0x39d3, 0x39d4, 0x39d5, 0x39d6, 0x39d7, 0x39d8, + 0x39d9, 0x39da, 0x39db, 0x39dc, 0x39dd, 0x39de, 0x39df, 0x39e0, 0x39e1, + 0x39e2, 0x39e3, 0x39e4, 0x39e5, 0x39e6, 0x39e7, 0x39e8, 0x39e9, 0x39ea, + 0x39eb, 0x39ec, 0x39ed, 0x39ee, 0x39ef, 0x39f0, 0x39f1, 0x39f2, 0x39f3, + 0x39f4, 0x39f5, 0x39f6, 0x39f7, 0x39f8, 0x39f9, 0x39fa, 0x39fb, 0x39fc, + 0x39fd, 0x39fe, 0x39ff, 0x3a00, 0x3a01, 0x3a02, 0x3a03, 0x3a04, 0x3a05, + 0x3a06, 0x3a07, 0x3a08, 0x3a09, 0x3a0a, 0x3a0b, 0x3a0c, 0x3a0d, 0x3a0e, + 0x3a0f, 0x3a10, 0x3a11, 0x3a12, 0x3a13, 0x3a14, 0x3a15, 0x3a16, 0x3a17, + 0x3a18, 0x3a19, 0x3a1a, 0x3a1b, 0x3a1c, 0x3a1d, 0x3a1e, 0x3a1f, 0x3a20, + 0x3a21, 0x3a22, 0x3a23, 0x3a24, 0x3a25, 0x3a26, 0x3a27, 0x3a28, 0x3a29, + 0x3a2a, 0x3a2b, 0x3a2c, 0x3a2d, 0x3a2e, 0x3a2f, 0x3a30, 0x3a31, 0x3a32, + 0x3a33, 0x3a34, 0x3a35, 0x3a36, 0x3a37, 0x3a38, 0x3a39, 0x3a3a, 0x3a3b, + 0x3a3c, 0x3a3d, 0x3a3e, 0x3a3f, 0x3a40, 0x3a41, 0x3a42, 0x3a43, 0x3a44, + 0x3a45, 0x3a46, 0x3a47, 0x3a48, 0x3a49, 0x3a4a, 0x3a4b, 0x3a4c, 0x3a4d, + 0x3a4e, 0x3a4f, 0x3a50, 0x3a51, 0x3a52, 0x3a53, 0x3a54, 0x3a55, 0x3a56, + 0x3a57, 0x3a58, 0x3a59, 0x3a5a, 0x3a5b, 0x3a5c, 0x3a5d, 0x3a5e, 0x3a5f, + 0x3a60, 0x3a61, 0x3a62, 0x3a63, 0x3a64, 0x3a65, 0x3a66, 0x3a67, 0x3a68, + 0x3a69, 0x3a6a, 0x3a6b, 0x3a6c, 0x3a6d, 0x3a6e, 0x3a6f, 0x3a70, 0x3a71, + 0x3a72, 0x3a73, 0x3a74, 0x3a75, 0x3a76, 0x3a77, 0x3a78, 0x3a79, 0x3a7a, + 0x3a7b, 0x3a7c, 0x3a7d, 0x3a7e, 0x3a7f, 0x3a80, 0x3a81, 0x3a82, 0x3a83, + 0x3a84, 0x3a85, 0x3a86, 0x3a87, 0x3a88, 0x3a89, 0x3a8a, 0x3a8b, 0x3a8c, + 0x3a8d, 0x3a8e, 0x3a8f, 0x3a90, 0x3a91, 0x3a92, 0x3a93, 0x3a94, 0x3a95, + 0x3a96, 0x3a97, 0x3a98, 0x3a99, 0x3a9a, 0x3a9b, 0x3a9c, 0x3a9d, 0x3a9e, + 0x3a9f, 0x3aa0, 0x3aa1, 0x3aa2, 0x3aa3, 0x3aa4, 0x3aa5, 0x3aa6, 0x3aa7, + 0x3aa8, 0x3aa9, 0x3aaa, 0x3aab, 0x3aac, 0x3aad, 0x3aae, 0x3aaf, 0x3ab0, + 0x3ab1, 0x3ab2, 0x3ab3, 0x3ab4, 0x3ab5, 0x3ab6, 0x3ab7, 0x3ab8, 0x3ab9, + 0x3aba, 0x3abb, 0x3abc, 0x3abd, 0x3abe, 0x3abf, 0x3ac0, 0x3ac1, 0x3ac2, + 0x3ac3, 0x3ac4, 0x3ac5, 0x3ac6, 0x3ac7, 0x3ac8, 0x3ac9, 0x3aca, 0x3acb, + 0x3acc, 0x3acd, 0x3ace, 0x3acf, 0x3ad0, 0x3ad1, 0x3ad2, 0x3ad3, 0x3ad4, + 0x3ad5, 0x3ad6, 0x3ad7, 0x3ad8, 0x3ad9, 0x3ada, 0x3adb, 0x3adc, 0x3add, + 0x3ade, 0x3adf, 0x3ae0, 0x3ae1, 0x3ae2, 0x3ae3, 0x3ae4, 0x3ae5, 0x3ae6, + 0x3ae7, 0x3ae8, 0x3ae9, 0x3aea, 0x3aeb, 0x3aec, 0x3aed, 0x3aee, 0x3aef, + 0x3af0, 0x3af1, 0x3af2, 0x3af3, 0x3af4, 0x3af5, 0x3af6, 0x3af7, 0x3af8, + 0x3af9, 0x3afa, 0x3afb, 0x3afc, 0x3afd, 0x3afe, 0x3aff, 0x3b00, 0x3b01, + 0x3b02, 0x3b03, 0x3b04, 0x3b05, 0x3b06, 0x3b07, 0x3b08, 0x3b09, 0x3b0a, + 0x3b0b, 0x3b0c, 0x3b0d, 0x3b0e, 0x3b0f, 0x3b10, 0x3b11, 0x3b12, 0x3b13, + 0x3b14, 0x3b15, 0x3b16, 0x3b17, 0x3b18, 0x3b19, 0x3b1a, 0x3b1b, 0x3b1c, + 0x3b1d, 0x3b1e, 0x3b1f, 0x3b20, 0x3b21, 0x3b22, 0x3b23, 0x3b24, 0x3b25, + 0x3b26, 0x3b27, 0x3b28, 0x3b29, 0x3b2a, 0x3b2b, 0x3b2c, 0x3b2d, 0x3b2e, + 0x3b2f, 0x3b30, 0x3b31, 0x3b32, 0x3b33, 0x3b34, 0x3b35, 0x3b36, 0x3b37, + 0x3b38, 0x3b39, 0x3b3a, 0x3b3b, 0x3b3c, 0x3b3d, 0x3b3e, 0x3b3f, 0x3b40, + 0x3b41, 0x3b42, 0x3b43, 0x3b44, 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49, + 0x3b4a, 0x3b4b, 0x3b4c, 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, 0x3b52, + 0x3b53, 0x3b54, 0x3b55, 0x3b56, 0x3b57, 0x3b58, 0x3b59, 0x3b5a, 0x3b5b, + 0x3b5c, 0x3b5d, 0x3b5e, 0x3b5f, 0x3b60, 0x3b61, 0x3b62, 0x3b63, 0x3b64, + 0x3b65, 0x3b66, 0x3b67, 0x3b68, 0x3b69, 0x3b6a, 0x3b6b, 0x3b6c, 0x3b6d, + 0x3b6e, 0x3b6f, 0x3b70, 0x3b71, 0x3b72, 0x3b73, 0x3b74, 0x3b75, 0x3b76, + 0x3b77, 0x3b78, 0x3b79, 0x3b7a, 0x3b7b, 0x3b7c, 0x3b7d, 0x3b7e, 0x3b7f, + 0x3b80, 0x3b81, 0x3b82, 0x3b83, 0x3b84, 0x3b85, 0x3b86, 0x3b87, 0x3b88, + 0x3b89, 0x3b8a, 0x3b8b, 0x3b8c, 0x3b8d, 0x3b8e, 0x3b8f, 0x3b90, 0x3b91, + 0x3b92, 0x3b93, 0x3b94, 0x3b95, 0x3b96, 0x3b97, 0x3b98, 0x3b99, 0x3b9a, + 0x3b9b, 0x3b9c, 0x3b9d, 0x3b9e, 0x3b9f, 0x3ba0, 0x3ba1, 0x3ba2, 0x3ba3, + 0x3ba4, 0x3ba5, 0x3ba6, 0x3ba7, 0x3ba8, 0x3ba9, 0x3baa, 0x3bab, 0x3bac, + 0x3bad, 0x3bae, 0x3baf, 0x3bb0, 0x3bb1, 0x3bb2, 0x3bb3, 0x3bb4, 0x3bb5, + 0x3bb6, 0x3bb7, 0x3bb8, 0x3bb9, 0x3bba, 0x3bbb, 0x3bbc, 0x3bbd, 0x3bbe, + 0x3bbf, 0x3bc0, 0x3bc1, 0x3bc2, 0x3bc3, 0x3bc4, 0x3bc5, 0x3bc6, 0x3bc7, + 0x3bc8, 0x3bc9, 0x3bca, 0x3bcb, 0x3bcc, 0x3bcd, 0x3bce, 0x3bcf, 0x3bd0, + 0x3bd1, 0x3bd2, 0x3bd3, 0x3bd4, 0x3bd5, 0x3bd6, 0x3bd7, 0x3bd8, 0x3bd9, + 0x3bda, 0x3bdb, 0x3bdc, 0x3bdd, 0x3bde, 0x3bdf, 0x3be0, 0x3be1, 0x3be2, + 0x3be3, 0x3be4, 0x3be5, 0x3be6, 0x3be7, 0x3be8, 0x3be9, 0x3bea, 0x3beb, + 0x3bec, 0x3bed, 0x3bee, 0x3bef, 0x3bf0, 0x3bf1, 0x3bf2, 0x3bf3, 0x3bf4, + 0x3bf5, 0x3bf6, 0x3bf7, 0x3bf8, 0x3bf9, 0x3bfa, 0x3bfb, 0x3bfc, 0x3bfd, + 0x3bfe, 0x3bff, 0x3c00, 0x3c01, 0x3c02, 0x3c03, 0x3c04, 0x3c05, 0x3c06, + 0x3c07, 0x3c08, 0x3c09, 0x3c0a, 0x3c0b, 0x3c0c, 0x3c0d, 0x3c0e, 0x3c0f, + 0x3c10, 0x3c11, 0x3c12, 0x3c13, 0x3c14, 0x3c15, 0x3c16, 0x3c17, 0x3c18, + 0x3c19, 0x3c1a, 0x3c1b, 0x3c1c, 0x3c1d, 0x3c1e, 0x3c1f, 0x3c20, 0x3c21, + 0x3c22, 0x3c23, 0x3c24, 0x3c25, 0x3c26, 0x3c27, 0x3c28, 0x3c29, 0x3c2a, + 0x3c2b, 0x3c2c, 0x3c2d, 0x3c2e, 0x3c2f, 0x3c30, 0x3c31, 0x3c32, 0x3c33, + 0x3c34, 0x3c35, 0x3c36, 0x3c37, 0x3c38, 0x3c39, 0x3c3a, 0x3c3b, 0x3c3c, + 0x3c3d, 0x3c3e, 0x3c3f, 0x3c40, 0x3c41, 0x3c42, 0x3c43, 0x3c44, 0x3c45, + 0x3c46, 0x3c47, 0x3c48, 0x3c49, 0x3c4a, 0x3c4b, 0x3c4c, 0x3c4d, 0x3c4e, + 0x3c4f, 0x3c50, 0x3c51, 0x3c52, 0x3c53, 0x3c54, 0x3c55, 0x3c56, 0x3c57, + 0x3c58, 0x3c59, 0x3c5a, 0x3c5b, 0x3c5c, 0x3c5d, 0x3c5e, 0x3c5f, 0x3c60, + 0x3c61, 0x3c62, 0x3c63, 0x3c64, 0x3c65, 0x3c66, 0x3c67, 0x3c68, 0x3c69, + 0x3c6a, 0x3c6b, 0x3c6c, 0x3c6d, 0x3c6e, 0x3c6f, 0x3c70, 0x3c71, 0x3c72, + 0x3c73, 0x3c74, 0x3c75, 0x3c76, 0x3c77, 0x3c78, 0x3c79, 0x3c7a, 0x3c7b, + 0x3c7c, 0x3c7d, 0x3c7e, 0x3c7f, 0x3c80, 0x3c81, 0x3c82, 0x3c83, 0x3c84, + 0x3c85, 0x3c86, 0x3c87, 0x3c88, 0x3c89, 0x3c8a, 0x3c8b, 0x3c8c, 0x3c8d, + 0x3c8e, 0x3c8f, 0x3c90, 0x3c91, 0x3c92, 0x3c93, 0x3c94, 0x3c95, 0x3c96, + 0x3c97, 0x3c98, 0x3c99, 0x3c9a, 0x3c9b, 0x3c9c, 0x3c9d, 0x3c9e, 0x3c9f, + 0x3ca0, 0x3ca1, 0x3ca2, 0x3ca3, 0x3ca4, 0x3ca5, 0x3ca6, 0x3ca7, 0x3ca8, + 0x3ca9, 0x3caa, 0x3cab, 0x3cac, 0x3cad, 0x3cae, 0x3caf, 0x3cb0, 0x3cb1, + 0x3cb2, 0x3cb3, 0x3cb4, 0x3cb5, 0x3cb6, 0x3cb7, 0x3cb8, 0x3cb9, 0x3cba, + 0x3cbb, 0x3cbc, 0x3cbd, 0x3cbe, 0x3cbf, 0x3cc0, 0x3cc1, 0x3cc2, 0x3cc3, + 0x3cc4, 0x3cc5, 0x3cc6, 0x3cc7, 0x3cc8, 0x3cc9, 0x3cca, 0x3ccb, 0x3ccc, + 0x3ccd, 0x3cce, 0x3ccf, 0x3cd0, 0x3cd1, 0x3cd2, 0x3cd3, 0x3cd4, 0x3cd5, + 0x3cd6, 0x3cd7, 0x3cd8, 0x3cd9, 0x3cda, 0x3cdb, 0x3cdc, 0x3cdd, 0x3cde, + 0x3cdf, 0x3ce0, 0x3ce1, 0x3ce2, 0x3ce3, 0x3ce4, 0x3ce5, 0x3ce6, 0x3ce7, + 0x3ce8, 0x3ce9, 0x3cea, 0x3ceb, 0x3cec, 0x3ced, 0x3cee, 0x3cef, 0x3cf0, + 0x3cf1, 0x3cf2, 0x3cf3, 0x3cf4, 0x3cf5, 0x3cf6, 0x3cf7, 0x3cf8, 0x3cf9, + 0x3cfa, 0x3cfb, 0x3cfc, 0x3cfd, 0x3cfe, 0x3cff, 0x3d00, 0x3d01, 0x3d02, + 0x3d03, 0x3d04, 0x3d05, 0x3d06, 0x3d07, 0x3d08, 0x3d09, 0x3d0a, 0x3d0b, + 0x3d0c, 0x3d0d, 0x3d0e, 0x3d0f, 0x3d10, 0x3d11, 0x3d12, 0x3d13, 0x3d14, + 0x3d15, 0x3d16, 0x3d17, 0x3d18, 0x3d19, 0x3d1a, 0x3d1b, 0x3d1c, 0x3d1d, + 0x3d1e, 0x3d1f, 0x3d20, 0x3d21, 0x3d22, 0x3d23, 0x3d24, 0x3d25, 0x3d26, + 0x3d27, 0x3d28, 0x3d29, 0x3d2a, 0x3d2b, 0x3d2c, 0x3d2d, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 0x4f3d, 0x4f73, 0x5047, 0x50f9, 0x52a0, 0x53ef, 0x5475, + 0x54e5, 0x5609, 0x5ac1, 0x5bb6, 0x6687, 0x67b6, 0x67b7, 0x67ef, 0x6b4c, + 0x73c2, 0x75c2, 0x7a3c, 0x82db, 0x8304, 0x8857, 0x8888, 0x8a36, 0x8cc8, + 0x8dcf, 0x8efb, 0x8fe6, 0x99d5, 0x523b, 0x5374, 0x5404, 0x606a, 0x6164, + 0x6bbc, 0x73cf, 0x811a, 0x89ba, 0x89d2, 0x95a3, 0x4f83, 0x520a, 0x58be, + 0x5978, 0x59e6, 0x5e72, 0x5e79, 0x61c7, 0x63c0, 0x6746, 0x67ec, 0x687f, + 0x6f97, 0x764e, 0x770b, 0x78f5, 0x7a08, 0x7aff, 0x7c21, 0x809d, 0x826e, + 0x8271, 0x8aeb, 0x9593, 0x4e6b, 0x559d, 0x66f7, 0x6e34, 0x78a3, 0x7aed, + 0x845b, 0x8910, 0x874e, 0x97a8, 0x52d8, 0x574e, 0x582a, 0x5d4c, 0x611f, + 0x61be, 0x6221, 0x6562, 0x67d1, 0x6a44, 0x6e1b, 0x7518, 0x75b3, 0x76e3, + 0x77b0, 0x7d3a, 0x90af, 0x9451, 0x9452, 0x9f95, 0x5323, 0x5cac, 0x7532, + 0x80db, 0x9240, 0x9598, 0x525b, 0x5808, 0x59dc, 0x5ca1, 0x5d17, 0x5eb7, + 0x5f3a, 0x5f4a, 0x6177, 0x6c5f, 0x757a, 0x7586, 0x7ce0, 0x7d73, 0x7db1, + 0x7f8c, 0x8154, 0x8221, 0x8591, 0x8941, 0x8b1b, 0x92fc, 0x964d, 0x9c47, + 0x4ecb, 0x4ef7, 0x500b, 0x51f1, 0x584f, 0x6137, 0x613e, 0x6168, 0x6539, + 0x69ea, 0x6f11, 0x75a5, 0x7686, 0x76d6, 0x7b87, 0x82a5, 0x84cb, 0xf900, + 0x93a7, 0x958b, 0x5580, 0x5ba2, 0x5751, 0xf901, 0x7cb3, 0x7fb9, 0x91b5, + 0x5028, 0x53bb, 0x5c45, 0x5de8, 0x62d2, 0x636e, 0x64da, 0x64e7, 0x6e20, + 0x70ac, 0x795b, 0x8ddd, 0x8e1e, 0xf902, 0x907d, 0x9245, 0x92f8, 0x4e7e, + 0x4ef6, 0x5065, 0x5dfe, 0x5efa, 0x6106, 0x6957, 0x8171, 0x8654, 0x8e47, + 0x9375, 0x9a2b, 0x4e5e, 0x5091, 0x6770, 0x6840, 0x5109, 0x528d, 0x5292, + 0x6aa2, 0x77bc, 0x9210, 0x9ed4, 0x52ab, 0x602f, 0x8ff2, 0x5048, 0x61a9, + 0x63ed, 0x64ca, 0x683c, 0x6a84, 0x6fc0, 0x8188, 0x89a1, 0x9694, 0x5805, + 0x727d, 0x72ac, 0x7504, 0x7d79, 0x7e6d, 0x80a9, 0x898b, 0x8b74, 0x9063, + 0x9d51, 0x6289, 0x6c7a, 0x6f54, 0x7d50, 0x7f3a, 0x8a23, 0x517c, 0x614a, + 0x7b9d, 0x8b19, 0x9257, 0x938c, 0x4eac, 0x4fd3, 0x501e, 0x50be, 0x5106, + 0x52c1, 0x52cd, 0x537f, 0x5770, 0x5883, 0x5e9a, 0x5f91, 0x6176, 0x61ac, + 0x64ce, 0x656c, 0x666f, 0x66bb, 0x66f4, 0x6897, 0x6d87, 0x7085, 0x70f1, + 0x749f, 0x74a5, 0x74ca, 0x75d9, 0x786c, 0x78ec, 0x7adf, 0x7af6, 0x7d45, + 0x7d93, 0x8015, 0x803f, 0x811b, 0x8396, 0x8b66, 0x8f15, 0x9015, 0x93e1, + 0x9803, 0x9838, 0x9a5a, 0x9be8, 0x4fc2, 0x5553, 0x583a, 0x5951, 0x5b63, + 0x5c46, 0x60b8, 0x6212, 0x6842, 0x68b0, 0x68e8, 0x6eaa, 0x754c, 0x7678, + 0x78ce, 0x7a3d, 0x7cfb, 0x7e6b, 0x7e7c, 0x8a08, 0x8aa1, 0x8c3f, 0x968e, + 0x9dc4, 0x53e4, 0x53e9, 0x544a, 0x5471, 0x56fa, 0x59d1, 0x5b64, 0x5c3b, + 0x5eab, 0x62f7, 0x6537, 0x6545, 0x6572, 0x66a0, 0x67af, 0x69c1, 0x6cbd, + 0x75fc, 0x7690, 0x777e, 0x7a3f, 0x7f94, 0x8003, 0x80a1, 0x818f, 0x82e6, + 0x82fd, 0x83f0, 0x85c1, 0x8831, 0x88b4, 0x8aa5, 0xf903, 0x8f9c, 0x932e, + 0x96c7, 0x9867, 0x9ad8, 0x9f13, 0x54ed, 0x659b, 0x66f2, 0x688f, 0x7a40, + 0x8c37, 0x9d60, 0x56f0, 0x5764, 0x5d11, 0x6606, 0x68b1, 0x68cd, 0x6efe, + 0x7428, 0x889e, 0x9be4, 0x6c68, 0xf904, 0x9aa8, 0x4f9b, 0x516c, 0x5171, + 0x529f, 0x5b54, 0x5de5, 0x6050, 0x606d, 0x62f1, 0x63a7, 0x653b, 0x73d9, + 0x7a7a, 0x86a3, 0x8ca2, 0x978f, 0x4e32, 0x5be1, 0x6208, 0x679c, 0x74dc, + 0x79d1, 0x83d3, 0x8a87, 0x8ab2, 0x8de8, 0x904e, 0x934b, 0x9846, 0x5ed3, + 0x69e8, 0x85ff, 0x90ed, 0xf905, 0x51a0, 0x5b98, 0x5bec, 0x6163, 0x68fa, + 0x6b3e, 0x704c, 0x742f, 0x74d8, 0x7ba1, 0x7f50, 0x83c5, 0x89c0, 0x8cab, + 0x95dc, 0x9928, 0x522e, 0x605d, 0x62ec, 0x9002, 0x4f8a, 0x5149, 0x5321, + 0x58d9, 0x5ee3, 0x66e0, 0x6d38, 0x709a, 0x72c2, 0x73d6, 0x7b50, 0x80f1, + 0x945b, 0x5366, 0x639b, 0x7f6b, 0x4e56, 0x5080, 0x584a, 0x58de, 0x602a, + 0x6127, 0x62d0, 0x69d0, 0x9b41, 0x5b8f, 0x7d18, 0x80b1, 0x8f5f, 0x4ea4, + 0x50d1, 0x54ac, 0x55ac, 0x5b0c, 0x5da0, 0x5de7, 0x652a, 0x654e, 0x6821, + 0x6a4b, 0x72e1, 0x768e, 0x77ef, 0x7d5e, 0x7ff9, 0x81a0, 0x854e, 0x86df, + 0x8f03, 0x8f4e, 0x90ca, 0x9903, 0x9a55, 0x9bab, 0x4e18, 0x4e45, 0x4e5d, + 0x4ec7, 0x4ff1, 0x5177, 0x52fe, 0x5340, 0x53e3, 0x53e5, 0x548e, 0x5614, + 0x5775, 0x57a2, 0x5bc7, 0x5d87, 0x5ed0, 0x61fc, 0x62d8, 0x6551, 0x67b8, + 0x67e9, 0x69cb, 0x6b50, 0x6bc6, 0x6bec, 0x6c42, 0x6e9d, 0x7078, 0x72d7, + 0x7396, 0x7403, 0x77bf, 0x77e9, 0x7a76, 0x7d7f, 0x8009, 0x81fc, 0x8205, + 0x820a, 0x82df, 0x8862, 0x8b33, 0x8cfc, 0x8ec0, 0x9011, 0x90b1, 0x9264, + 0x92b6, 0x99d2, 0x9a45, 0x9ce9, 0x9dd7, 0x9f9c, 0x570b, 0x5c40, 0x83ca, + 0x97a0, 0x97ab, 0x9eb4, 0x541b, 0x7a98, 0x7fa4, 0x88d9, 0x8ecd, 0x90e1, + 0x5800, 0x5c48, 0x6398, 0x7a9f, 0x5bae, 0x5f13, 0x7a79, 0x7aae, 0x828e, + 0x8eac, 0x5026, 0x5238, 0x52f8, 0x5377, 0x5708, 0x62f3, 0x6372, 0x6b0a, + 0x6dc3, 0x7737, 0x53a5, 0x7357, 0x8568, 0x8e76, 0x95d5, 0x673a, 0x6ac3, + 0x6f70, 0x8a6d, 0x8ecc, 0x994b, 0xf906, 0x6677, 0x6b78, 0x8cb4, 0x9b3c, + 0xf907, 0x53eb, 0x572d, 0x594e, 0x63c6, 0x69fb, 0x73ea, 0x7845, 0x7aba, + 0x7ac5, 0x7cfe, 0x8475, 0x898f, 0x8d73, 0x9035, 0x95a8, 0x52fb, 0x5747, + 0x7547, 0x7b60, 0x83cc, 0x921e, 0xf908, 0x6a58, 0x514b, 0x524b, 0x5287, + 0x621f, 0x68d8, 0x6975, 0x9699, 0x50c5, 0x52a4, 0x52e4, 0x61c3, 0x65a4, + 0x6839, 0x69ff, 0x747e, 0x7b4b, 0x82b9, 0x83eb, 0x89b2, 0x8b39, 0x8fd1, + 0x9949, 0xf909, 0x4eca, 0x5997, 0x64d2, 0x6611, 0x6a8e, 0x7434, 0x7981, + 0x79bd, 0x82a9, 0x887e, 0x887f, 0x895f, 0xf90a, 0x9326, 0x4f0b, 0x53ca, + 0x6025, 0x6271, 0x6c72, 0x7d1a, 0x7d66, 0x4e98, 0x5162, 0x77dc, 0x80af, + 0x4f01, 0x4f0e, 0x5176, 0x5180, 0x55dc, 0x5668, 0x573b, 0x57fa, 0x57fc, + 0x5914, 0x5947, 0x5993, 0x5bc4, 0x5c90, 0x5d0e, 0x5df1, 0x5e7e, 0x5fcc, + 0x6280, 0x65d7, 0x65e3, 0x671e, 0x671f, 0x675e, 0x68cb, 0x68c4, 0x6a5f, + 0x6b3a, 0x6c23, 0x6c7d, 0x6c82, 0x6dc7, 0x7398, 0x7426, 0x742a, 0x7482, + 0x74a3, 0x7578, 0x757f, 0x7881, 0x78ef, 0x7941, 0x7947, 0x7948, 0x797a, + 0x7b95, 0x7d00, 0x7dba, 0x7f88, 0x8006, 0x802d, 0x808c, 0x8a18, 0x8b4f, + 0x8c48, 0x8d77, 0x9321, 0x9324, 0x98e2, 0x9951, 0x9a0e, 0x9a0f, 0x9a65, + 0x9e92, 0x7dca, 0x4f76, 0x5409, 0x62ee, 0x6854, 0x91d1, 0x55ab, 0x513a, + 0xf90b, 0xf90c, 0x5a1c, 0x61e6, 0xf90d, 0x62cf, 0x62ff, 0xf90e, 0xf90f, + 0xf910, 0xf911, 0xf912, 0xf913, 0x90a3, 0xf914, 0xf915, 0xf916, 0xf917, + 0xf918, 0x8afe, 0xf919, 0xf91a, 0xf91b, 0xf91c, 0x6696, 0xf91d, 0x7156, + 0xf91e, 0xf91f, 0x96e3, 0xf920, 0x634f, 0x637a, 0x5357, 0xf921, 0x678f, + 0x6960, 0x6e73, 0xf922, 0x7537, 0xf923, 0xf924, 0xf925, 0x7d0d, 0xf926, + 0xf927, 0x8872, 0x56ca, 0x5a18, 0xf928, 0xf929, 0xf92a, 0xf92b, 0xf92c, + 0x4e43, 0xf92d, 0x5167, 0x5948, 0x67f0, 0x8010, 0xf92e, 0x5973, 0x5e74, + 0x649a, 0x79ca, 0x5ff5, 0x606c, 0x62c8, 0x637b, 0x5be7, 0x5bd7, 0x52aa, + 0xf92f, 0x5974, 0x5f29, 0x6012, 0xf930, 0xf931, 0xf932, 0x7459, 0xf933, + 0xf934, 0xf935, 0xf936, 0xf937, 0xf938, 0x99d1, 0xf939, 0xf93a, 0xf93b, + 0xf93c, 0xf93d, 0xf93e, 0xf93f, 0xf940, 0xf941, 0xf942, 0xf943, 0x6fc3, + 0xf944, 0xf945, 0x81bf, 0x8fb2, 0x60f1, 0xf946, 0xf947, 0x8166, 0xf948, + 0xf949, 0x5c3f, 0xf94a, 0xf94b, 0xf94c, 0xf94d, 0xf94e, 0xf94f, 0xf950, + 0xf951, 0x5ae9, 0x8a25, 0x677b, 0x7d10, 0xf952, 0xf953, 0xf954, 0xf955, + 0xf956, 0xf957, 0x80fd, 0xf958, 0xf959, 0x5c3c, 0x6ce5, 0x533f, 0x6eba, + 0x591a, 0x8336, 0x4e39, 0x4eb6, 0x4f46, 0x55ae, 0x5718, 0x58c7, 0x5f56, + 0x65b7, 0x65e6, 0x6a80, 0x6bb5, 0x6e4d, 0x77ed, 0x7aef, 0x7c1e, 0x7dde, + 0x86cb, 0x8892, 0x9132, 0x935b, 0x64bb, 0x6fbe, 0x737a, 0x75b8, 0x9054, + 0x5556, 0x574d, 0x61ba, 0x64d4, 0x66c7, 0x6de1, 0x6e5b, 0x6f6d, 0x6fb9, + 0x75f0, 0x8043, 0x81bd, 0x8541, 0x8983, 0x8ac7, 0x8b5a, 0x931f, 0x6c93, + 0x7553, 0x7b54, 0x8e0f, 0x905d, 0x5510, 0x5802, 0x5858, 0x5e62, 0x6207, + 0x649e, 0x68e0, 0x7576, 0x7cd6, 0x87b3, 0x9ee8, 0x4ee3, 0x5788, 0x576e, + 0x5927, 0x5c0d, 0x5cb1, 0x5e36, 0x5f85, 0x6234, 0x64e1, 0x73b3, 0x81fa, + 0x888b, 0x8cb8, 0x968a, 0x9edb, 0x5b85, 0x5fb7, 0x60b3, 0x5012, 0x5200, + 0x5230, 0x5716, 0x5835, 0x5857, 0x5c0e, 0x5c60, 0x5cf6, 0x5d8b, 0x5ea6, + 0x5f92, 0x60bc, 0x6311, 0x6389, 0x6417, 0x6843, 0x68f9, 0x6ac2, 0x6dd8, + 0x6e21, 0x6ed4, 0x6fe4, 0x71fe, 0x76dc, 0x7779, 0x79b1, 0x7a3b, 0x8404, + 0x89a9, 0x8ced, 0x8df3, 0x8e48, 0x9003, 0x9014, 0x9053, 0x90fd, 0x934d, + 0x9676, 0x97dc, 0x6bd2, 0x7006, 0x7258, 0x72a2, 0x7368, 0x7763, 0x79bf, + 0x7be4, 0x7e9b, 0x8b80, 0x58a9, 0x60c7, 0x6566, 0x65fd, 0x66be, 0x6c8c, + 0x711e, 0x71c9, 0x8c5a, 0x9813, 0x4e6d, 0x7a81, 0x4edd, 0x51ac, 0x51cd, + 0x52d5, 0x540c, 0x61a7, 0x6771, 0x6850, 0x68df, 0x6d1e, 0x6f7c, 0x75bc, + 0x77b3, 0x7ae5, 0x80f4, 0x8463, 0x9285, 0x515c, 0x6597, 0x675c, 0x6793, + 0x75d8, 0x7ac7, 0x8373, 0xf95a, 0x8c46, 0x9017, 0x982d, 0x5c6f, 0x81c0, + 0x829a, 0x9041, 0x906f, 0x920d, 0x5f97, 0x5d9d, 0x6a59, 0x71c8, 0x767b, + 0x7b49, 0x85e4, 0x8b04, 0x9127, 0x9a30, 0x5587, 0x61f6, 0xf95b, 0x7669, + 0x7f85, 0x863f, 0x87ba, 0x88f8, 0x908f, 0xf95c, 0x6d1b, 0x70d9, 0x73de, + 0x7d61, 0x843d, 0xf95d, 0x916a, 0x99f1, 0xf95e, 0x4e82, 0x5375, 0x6b04, + 0x6b12, 0x703e, 0x721b, 0x862d, 0x9e1e, 0x524c, 0x8fa3, 0x5d50, 0x64e5, + 0x652c, 0x6b16, 0x6feb, 0x7c43, 0x7e9c, 0x85cd, 0x8964, 0x89bd, 0x62c9, + 0x81d8, 0x881f, 0x5eca, 0x6717, 0x6d6a, 0x72fc, 0x7405, 0x746f, 0x8782, + 0x90de, 0x4f86, 0x5d0d, 0x5fa0, 0x840a, 0x51b7, 0x63a0, 0x7565, 0x4eae, + 0x5006, 0x5169, 0x51c9, 0x6881, 0x6a11, 0x7cae, 0x7cb1, 0x7ce7, 0x826f, + 0x8ad2, 0x8f1b, 0x91cf, 0x4fb6, 0x5137, 0x52f5, 0x5442, 0x5eec, 0x616e, + 0x623e, 0x65c5, 0x6ada, 0x6ffe, 0x792a, 0x85dc, 0x8823, 0x95ad, 0x9a62, + 0x9a6a, 0x9e97, 0x9ece, 0x529b, 0x66c6, 0x6b77, 0x701d, 0x792b, 0x8f62, + 0x9742, 0x6190, 0x6200, 0x6523, 0x6f23, 0x7149, 0x7489, 0x7df4, 0x806f, + 0x84ee, 0x8f26, 0x9023, 0x934a, 0x51bd, 0x5217, 0x52a3, 0x6d0c, 0x70c8, + 0x88c2, 0x5ec9, 0x6582, 0x6bae, 0x6fc2, 0x7c3e, 0x7375, 0x4ee4, 0x4f36, + 0x56f9, 0xf95f, 0x5cba, 0x5dba, 0x601c, 0x73b2, 0x7b2d, 0x7f9a, 0x7fce, + 0x8046, 0x901e, 0x9234, 0x96f6, 0x9748, 0x9818, 0x9f61, 0x4f8b, 0x6fa7, + 0x79ae, 0x91b4, 0x96b7, 0x52de, 0xf960, 0x6488, 0x64c4, 0x6ad3, 0x6f5e, + 0x7018, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def, 0x8f05, 0x9732, + 0x9b6f, 0x9dfa, 0x9e75, 0x788c, 0x797f, 0x7da0, 0x83c9, 0x9304, 0x9e7f, + 0x9e93, 0x8ad6, 0x58df, 0x5f04, 0x6727, 0x7027, 0x74cf, 0x7c60, 0x807e, + 0x5121, 0x7028, 0x7262, 0x78ca, 0x8cc2, 0x8cda, 0x8cf4, 0x96f7, 0x4e86, + 0x50da, 0x5bee, 0x5ed6, 0x6599, 0x71ce, 0x7642, 0x77ad, 0x804a, 0x84fc, + 0x907c, 0x9b27, 0x9f8d, 0x58d8, 0x5a41, 0x5c62, 0x6a13, 0x6dda, 0x6f0f, + 0x763b, 0x7d2f, 0x7e37, 0x851e, 0x8938, 0x93e4, 0x964b, 0x5289, 0x65d2, + 0x67f3, 0x69b4, 0x6d41, 0x6e9c, 0x700f, 0x7409, 0x7460, 0x7559, 0x7624, + 0x786b, 0x8b2c, 0x985e, 0x516d, 0x622e, 0x9678, 0x4f96, 0x502b, 0x5d19, + 0x6dea, 0x7db8, 0x8f2a, 0x5f8b, 0x6144, 0x6817, 0xf961, 0x9686, 0x52d2, + 0x808b, 0x51dc, 0x51cc, 0x695e, 0x7a1c, 0x7dbe, 0x83f1, 0x9675, 0x4fda, + 0x5229, 0x5398, 0x540f, 0x550e, 0x5c65, 0x60a7, 0x674e, 0x68a8, 0x6d6c, + 0x7281, 0x72f8, 0x7406, 0x7483, 0xf962, 0x75e2, 0x7c6c, 0x7f79, 0x7fb8, + 0x8389, 0x88cf, 0x88e1, 0x91cc, 0x91d0, 0x96e2, 0x9bc9, 0x541d, 0x6f7e, + 0x71d0, 0x7498, 0x85fa, 0x8eaa, 0x96a3, 0x9c57, 0x9e9f, 0x6797, 0x6dcb, + 0x7433, 0x81e8, 0x9716, 0x782c, 0x7acb, 0x7b20, 0x7c92, 0x6469, 0x746a, + 0x75f2, 0x78bc, 0x78e8, 0x99ac, 0x9b54, 0x9ebb, 0x5bde, 0x5e55, 0x6f20, + 0x819c, 0x83ab, 0x9088, 0x4e07, 0x534d, 0x5a29, 0x5dd2, 0x5f4e, 0x6162, + 0x633d, 0x6669, 0x66fc, 0x6eff, 0x6f2b, 0x7063, 0x779e, 0x842c, 0x8513, + 0x883b, 0x8f13, 0x9945, 0x9c3b, 0x551c, 0x62b9, 0x672b, 0x6cab, 0x8309, + 0x896a, 0x977a, 0x4ea1, 0x5984, 0x5fd8, 0x5fd9, 0x671b, 0x7db2, 0x7f54, + 0x8292, 0x832b, 0x83bd, 0x8f1e, 0x9099, 0x57cb, 0x59b9, 0x5a92, 0x5bd0, + 0x6627, 0x679a, 0x6885, 0x6bcf, 0x7164, 0x7f75, 0x8cb7, 0x8ce3, 0x9081, + 0x9b45, 0x8108, 0x8c8a, 0x964c, 0x9a40, 0x9ea5, 0x5b5f, 0x6c13, 0x731b, + 0x76f2, 0x76df, 0x840c, 0x51aa, 0x8993, 0x514d, 0x5195, 0x52c9, 0x68c9, + 0x6c94, 0x7704, 0x7720, 0x7dbf, 0x7dec, 0x9762, 0x9eb5, 0x6ec5, 0x8511, + 0x51a5, 0x540d, 0x547d, 0x660e, 0x669d, 0x6927, 0x6e9f, 0x76bf, 0x7791, + 0x8317, 0x84c2, 0x879f, 0x9169, 0x9298, 0x9cf4, 0x8882, 0x4fae, 0x5192, + 0x52df, 0x59c6, 0x5e3d, 0x6155, 0x6478, 0x6479, 0x66ae, 0x67d0, 0x6a21, + 0x6bcd, 0x6bdb, 0x725f, 0x7261, 0x7441, 0x7738, 0x77db, 0x8017, 0x82bc, + 0x8305, 0x8b00, 0x8b28, 0x8c8c, 0x6728, 0x6c90, 0x7267, 0x76ee, 0x7766, + 0x7a46, 0x9da9, 0x6b7f, 0x6c92, 0x5922, 0x6726, 0x8499, 0x536f, 0x5893, + 0x5999, 0x5edf, 0x63cf, 0x6634, 0x6773, 0x6e3a, 0x732b, 0x7ad7, 0x82d7, + 0x9328, 0x52d9, 0x5deb, 0x61ae, 0x61cb, 0x620a, 0x62c7, 0x64ab, 0x65e0, + 0x6959, 0x6b66, 0x6bcb, 0x7121, 0x73f7, 0x755d, 0x7e46, 0x821e, 0x8302, + 0x856a, 0x8aa3, 0x8cbf, 0x9727, 0x9d61, 0x58a8, 0x9ed8, 0x5011, 0x520e, + 0x543b, 0x554f, 0x6587, 0x6c76, 0x7d0a, 0x7d0b, 0x805e, 0x868a, 0x9580, + 0x96ef, 0x52ff, 0x6c95, 0x7269, 0x5473, 0x5a9a, 0x5c3e, 0x5d4b, 0x5f4c, + 0x5fae, 0x672a, 0x68b6, 0x6963, 0x6e3c, 0x6e44, 0x7709, 0x7c73, 0x7f8e, + 0x8587, 0x8b0e, 0x8ff7, 0x9761, 0x9ef4, 0x5cb7, 0x60b6, 0x610d, 0x61ab, + 0x654f, 0x65fb, 0x65fc, 0x6c11, 0x6cef, 0x739f, 0x73c9, 0x7de1, 0x9594, + 0x5bc6, 0x871c, 0x8b10, 0x525d, 0x535a, 0x62cd, 0x640f, 0x64b2, 0x6734, + 0x6a38, 0x6cca, 0x73c0, 0x749e, 0x7b94, 0x7c95, 0x7e1b, 0x818a, 0x8236, + 0x8584, 0x8feb, 0x96f9, 0x99c1, 0x4f34, 0x534a, 0x53cd, 0x53db, 0x62cc, + 0x642c, 0x6500, 0x6591, 0x69c3, 0x6cee, 0x6f58, 0x73ed, 0x7554, 0x7622, + 0x76e4, 0x76fc, 0x78d0, 0x78fb, 0x792c, 0x7d46, 0x822c, 0x87e0, 0x8fd4, + 0x9812, 0x98ef, 0x52c3, 0x62d4, 0x64a5, 0x6e24, 0x6f51, 0x767c, 0x8dcb, + 0x91b1, 0x9262, 0x9aee, 0x9b43, 0x5023, 0x508d, 0x574a, 0x59a8, 0x5c28, + 0x5e47, 0x5f77, 0x623f, 0x653e, 0x65b9, 0x65c1, 0x6609, 0x678b, 0x699c, + 0x6ec2, 0x78c5, 0x7d21, 0x80aa, 0x8180, 0x822b, 0x82b3, 0x84a1, 0x868c, + 0x8a2a, 0x8b17, 0x90a6, 0x9632, 0x9f90, 0x500d, 0x4ff3, 0xf963, 0x57f9, + 0x5f98, 0x62dc, 0x6392, 0x676f, 0x6e43, 0x7119, 0x76c3, 0x80cc, 0x80da, + 0x88f4, 0x88f5, 0x8919, 0x8ce0, 0x8f29, 0x914d, 0x966a, 0x4f2f, 0x4f70, + 0x5e1b, 0x67cf, 0x6822, 0x767d, 0x767e, 0x9b44, 0x5e61, 0x6a0a, 0x7169, + 0x71d4, 0x756a, 0xf964, 0x7e41, 0x8543, 0x85e9, 0x98dc, 0x4f10, 0x7b4f, + 0x7f70, 0x95a5, 0x51e1, 0x5e06, 0x68b5, 0x6c3e, 0x6c4e, 0x6cdb, 0x72af, + 0x7bc4, 0x8303, 0x6cd5, 0x743a, 0x50fb, 0x5288, 0x58c1, 0x64d8, 0x6a97, + 0x74a7, 0x7656, 0x78a7, 0x8617, 0x95e2, 0x9739, 0xf965, 0x535e, 0x5f01, + 0x8b8a, 0x8fa8, 0x8faf, 0x908a, 0x5225, 0x77a5, 0x9c49, 0x9f08, 0x4e19, + 0x5002, 0x5175, 0x5c5b, 0x5e77, 0x661e, 0x663a, 0x67c4, 0x68c5, 0x70b3, + 0x7501, 0x75c5, 0x79c9, 0x7add, 0x8f27, 0x9920, 0x9a08, 0x4fdd, 0x5821, + 0x5831, 0x5bf6, 0x666e, 0x6b65, 0x6d11, 0x6e7a, 0x6f7d, 0x73e4, 0x752b, + 0x83e9, 0x88dc, 0x8913, 0x8b5c, 0x8f14, 0x4f0f, 0x50d5, 0x5310, 0x535c, + 0x5b93, 0x5fa9, 0x670d, 0x798f, 0x8179, 0x832f, 0x8514, 0x8907, 0x8986, + 0x8f39, 0x8f3b, 0x99a5, 0x9c12, 0x672c, 0x4e76, 0x4ff8, 0x5949, 0x5c01, + 0x5cef, 0x5cf0, 0x6367, 0x68d2, 0x70fd, 0x71a2, 0x742b, 0x7e2b, 0x84ec, + 0x8702, 0x9022, 0x92d2, 0x9cf3, 0x4e0d, 0x4ed8, 0x4fef, 0x5085, 0x5256, + 0x526f, 0x5426, 0x5490, 0x57e0, 0x592b, 0x5a66, 0x5b5a, 0x5b75, 0x5bcc, + 0x5e9c, 0xf966, 0x6276, 0x6577, 0x65a7, 0x6d6e, 0x6ea5, 0x7236, 0x7b26, + 0x7c3f, 0x7f36, 0x8150, 0x8151, 0x819a, 0x8240, 0x8299, 0x83a9, 0x8a03, + 0x8ca0, 0x8ce6, 0x8cfb, 0x8d74, 0x8dba, 0x90e8, 0x91dc, 0x961c, 0x9644, + 0x99d9, 0x9ce7, 0x5317, 0x5206, 0x5429, 0x5674, 0x58b3, 0x5954, 0x596e, + 0x5fff, 0x61a4, 0x626e, 0x6610, 0x6c7e, 0x711a, 0x76c6, 0x7c89, 0x7cde, + 0x7d1b, 0x82ac, 0x8cc1, 0x96f0, 0xf967, 0x4f5b, 0x5f17, 0x5f7f, 0x62c2, + 0x5d29, 0x670b, 0x68da, 0x787c, 0x7e43, 0x9d6c, 0x4e15, 0x5099, 0x5315, + 0x532a, 0x5351, 0x5983, 0x5a62, 0x5e87, 0x60b2, 0x618a, 0x6249, 0x6279, + 0x6590, 0x6787, 0x69a7, 0x6bd4, 0x6bd6, 0x6bd7, 0x6bd8, 0x6cb8, 0xf968, + 0x7435, 0x75fa, 0x7812, 0x7891, 0x79d5, 0x79d8, 0x7c83, 0x7dcb, 0x7fe1, + 0x80a5, 0x813e, 0x81c2, 0x83f2, 0x871a, 0x88e8, 0x8ab9, 0x8b6c, 0x8cbb, + 0x9119, 0x975e, 0x98db, 0x9f3b, 0x56ac, 0x5b2a, 0x5f6c, 0x658c, 0x6ab3, + 0x6baf, 0x6d5c, 0x6ff1, 0x7015, 0x725d, 0x73ad, 0x8ca7, 0x8cd3, 0x983b, + 0x6191, 0x6c37, 0x8058, 0x9a01, 0x4e4d, 0x4e8b, 0x4e9b, 0x4ed5, 0x4f3a, + 0x4f3c, 0x4f7f, 0x4fdf, 0x50ff, 0x53f2, 0x53f8, 0x5506, 0x55e3, 0x56db, + 0x58eb, 0x5962, 0x5a11, 0x5beb, 0x5bfa, 0x5c04, 0x5df3, 0x5e2b, 0x5f99, + 0x601d, 0x6368, 0x659c, 0x65af, 0x67f6, 0x67fb, 0x68ad, 0x6b7b, 0x6c99, + 0x6cd7, 0x6e23, 0x7009, 0x7345, 0x7802, 0x793e, 0x7940, 0x7960, 0x79c1, + 0x7be9, 0x7d17, 0x7d72, 0x8086, 0x820d, 0x838e, 0x84d1, 0x86c7, 0x88df, + 0x8a50, 0x8a5e, 0x8b1d, 0x8cdc, 0x8d66, 0x8fad, 0x90aa, 0x98fc, 0x99df, + 0x9e9d, 0x524a, 0xf969, 0x6714, 0xf96a, 0x5098, 0x522a, 0x5c71, 0x6563, + 0x6c55, 0x73ca, 0x7523, 0x759d, 0x7b97, 0x849c, 0x9178, 0x9730, 0x4e77, + 0x6492, 0x6bba, 0x715e, 0x85a9, 0x4e09, 0xf96b, 0x6749, 0x68ee, 0x6e17, + 0x829f, 0x8518, 0x886b, 0x63f7, 0x6f81, 0x9212, 0x98af, 0x4e0a, 0x50b7, + 0x50cf, 0x511f, 0x5546, 0x55aa, 0x5617, 0x5b40, 0x5c19, 0x5ce0, 0x5e38, + 0x5e8a, 0x5ea0, 0x5ec2, 0x60f3, 0x6851, 0x6a61, 0x6e58, 0x723d, 0x7240, + 0x72c0, 0x76f8, 0x7965, 0x7bb1, 0x7fd4, 0x88f3, 0x89f4, 0x8a73, 0x8c61, + 0x8cde, 0x971c, 0x585e, 0x74bd, 0x8cfd, 0x55c7, 0xf96c, 0x7a61, 0x7d22, + 0x8272, 0x7272, 0x751f, 0x7525, 0xf96d, 0x7b19, 0x5885, 0x58fb, 0x5dbc, + 0x5e8f, 0x5eb6, 0x5f90, 0x6055, 0x6292, 0x637f, 0x654d, 0x6691, 0x66d9, + 0x66f8, 0x6816, 0x68f2, 0x7280, 0x745e, 0x7b6e, 0x7d6e, 0x7dd6, 0x7f72, + 0x80e5, 0x8212, 0x85af, 0x897f, 0x8a93, 0x901d, 0x92e4, 0x9ecd, 0x9f20, + 0x5915, 0x596d, 0x5e2d, 0x60dc, 0x6614, 0x6673, 0x6790, 0x6c50, 0x6dc5, + 0x6f5f, 0x77f3, 0x78a9, 0x84c6, 0x91cb, 0x932b, 0x4ed9, 0x50ca, 0x5148, + 0x5584, 0x5b0b, 0x5ba3, 0x6247, 0x657e, 0x65cb, 0x6e32, 0x717d, 0x7401, + 0x7444, 0x7487, 0x74bf, 0x766c, 0x79aa, 0x7dda, 0x7e55, 0x7fa8, 0x817a, + 0x81b3, 0x8239, 0x861a, 0x87ec, 0x8a75, 0x8de3, 0x9078, 0x9291, 0x9425, + 0x994d, 0x9bae, 0x5368, 0x5c51, 0x6954, 0x6cc4, 0x6d29, 0x6e2b, 0x820c, + 0x859b, 0x893b, 0x8a2d, 0x8aaa, 0x96ea, 0x9f67, 0x5261, 0x66b9, 0x6bb2, + 0x7e96, 0x87fe, 0x8d0d, 0x9583, 0x965d, 0x651d, 0x6d89, 0x71ee, 0xf96e, + 0x57ce, 0x59d3, 0x5bac, 0x6027, 0x60fa, 0x6210, 0x661f, 0x665f, 0x7329, + 0x73f9, 0x76db, 0x7701, 0x7b6c, 0x8056, 0x8072, 0x8165, 0x8aa0, 0x9192, + 0x4e16, 0x52e2, 0x6b72, 0x6d17, 0x7a05, 0x7b39, 0x7d30, 0xf96f, 0x8cb0, + 0x53ec, 0x562f, 0x5851, 0x5bb5, 0x5c0f, 0x5c11, 0x5de2, 0x6240, 0x6383, + 0x6414, 0x662d, 0x68b3, 0x6cbc, 0x6d88, 0x6eaf, 0x701f, 0x70a4, 0x71d2, + 0x7526, 0x758f, 0x758e, 0x7619, 0x7b11, 0x7be0, 0x7c2b, 0x7d20, 0x7d39, + 0x852c, 0x856d, 0x8607, 0x8a34, 0x900d, 0x9061, 0x90b5, 0x92b7, 0x97f6, + 0x9a37, 0x4fd7, 0x5c6c, 0x675f, 0x6d91, 0x7c9f, 0x7e8c, 0x8b16, 0x8d16, + 0x901f, 0x5b6b, 0x5dfd, 0x640d, 0x84c0, 0x905c, 0x98e1, 0x7387, 0x5b8b, + 0x609a, 0x677e, 0x6dde, 0x8a1f, 0x8aa6, 0x9001, 0x980c, 0x5237, 0xf970, + 0x7051, 0x788e, 0x9396, 0x8870, 0x91d7, 0x4fee, 0x53d7, 0x55fd, 0x56da, + 0x5782, 0x58fd, 0x5ac2, 0x5b88, 0x5cab, 0x5cc0, 0x5e25, 0x6101, 0x620d, + 0x624b, 0x6388, 0x641c, 0x6536, 0x6578, 0x6a39, 0x6b8a, 0x6c34, 0x6d19, + 0x6f31, 0x71e7, 0x72e9, 0x7378, 0x7407, 0x74b2, 0x7626, 0x7761, 0x79c0, + 0x7a57, 0x7aea, 0x7cb9, 0x7d8f, 0x7dac, 0x7e61, 0x7f9e, 0x8129, 0x8331, + 0x8490, 0x84da, 0x85ea, 0x8896, 0x8ab0, 0x8b90, 0x8f38, 0x9042, 0x9083, + 0x916c, 0x9296, 0x92b9, 0x968b, 0x96a7, 0x96a8, 0x96d6, 0x9700, 0x9808, + 0x9996, 0x9ad3, 0x9b1a, 0x53d4, 0x587e, 0x5919, 0x5b70, 0x5bbf, 0x6dd1, + 0x6f5a, 0x719f, 0x7421, 0x74b9, 0x8085, 0x83fd, 0x5de1, 0x5f87, 0x5faa, + 0x6042, 0x65ec, 0x6812, 0x696f, 0x6a53, 0x6b89, 0x6d35, 0x6df3, 0x73e3, + 0x76fe, 0x77ac, 0x7b4d, 0x7d14, 0x8123, 0x821c, 0x8340, 0x84f4, 0x8563, + 0x8a62, 0x8ac4, 0x9187, 0x931e, 0x9806, 0x99b4, 0x620c, 0x8853, 0x8ff0, + 0x9265, 0x5d07, 0x5d27, 0x5d69, 0x745f, 0x819d, 0x8768, 0x6fd5, 0x62fe, + 0x7fd2, 0x8936, 0x8972, 0x4e1e, 0x4e58, 0x50e7, 0x52dd, 0x5347, 0x627f, + 0x6607, 0x7e69, 0x8805, 0x965e, 0x4f8d, 0x5319, 0x5636, 0x59cb, 0x5aa4, + 0x5c38, 0x5c4e, 0x5c4d, 0x5e02, 0x5f11, 0x6043, 0x65bd, 0x662f, 0x6642, + 0x67be, 0x67f4, 0x731c, 0x77e2, 0x793a, 0x7fc5, 0x8494, 0x84cd, 0x8996, + 0x8a66, 0x8a69, 0x8ae1, 0x8c55, 0x8c7a, 0x57f4, 0x5bd4, 0x5f0f, 0x606f, + 0x62ed, 0x690d, 0x6b96, 0x6e5c, 0x7184, 0x7bd2, 0x8755, 0x8b58, 0x8efe, + 0x98df, 0x98fe, 0x4f38, 0x4f81, 0x4fe1, 0x547b, 0x5a20, 0x5bb8, 0x613c, + 0x65b0, 0x6668, 0x71fc, 0x7533, 0x795e, 0x7d33, 0x814e, 0x81e3, 0x8398, + 0x85aa, 0x85ce, 0x8703, 0x8a0a, 0x8eab, 0x8f9b, 0xf971, 0x8fc5, 0x5931, + 0x5ba4, 0x5be6, 0x6089, 0x5be9, 0x5c0b, 0x5fc3, 0x6c81, 0xf972, 0x6df1, + 0x700b, 0x751a, 0x82af, 0x8af6, 0x4ec0, 0x5341, 0xf973, 0x96d9, 0x6c0f, + 0x4e9e, 0x4fc4, 0x5152, 0x555e, 0x5a25, 0x5ce8, 0x6211, 0x7259, 0x82bd, + 0x83aa, 0x86fe, 0x8859, 0x8a1d, 0x963f, 0x96c5, 0x9913, 0x9d09, 0x9d5d, + 0x580a, 0x5cb3, 0x5dbd, 0x5e44, 0x60e1, 0x6115, 0x63e1, 0x6a02, 0x6e25, + 0x9102, 0x9354, 0x984e, 0x9c10, 0x9f77, 0x5b89, 0x5cb8, 0x6309, 0x664f, + 0x6848, 0x773c, 0x96c1, 0x978d, 0x9854, 0x9b9f, 0x65a1, 0x8b01, 0x8ecb, + 0x95bc, 0x5535, 0x5ca9, 0x5dd6, 0x5eb5, 0x6697, 0x764c, 0x83f4, 0x95c7, + 0x58d3, 0x62bc, 0x72ce, 0x9d28, 0x4ef0, 0x592e, 0x600f, 0x663b, 0x6b83, + 0x79e7, 0x9d26, 0x5393, 0x54c0, 0x57c3, 0x5d16, 0x611b, 0x66d6, 0x6daf, + 0x788d, 0x827e, 0x9698, 0x9744, 0x5384, 0x627c, 0x6396, 0x6db2, 0x7e0a, + 0x814b, 0x984d, 0x6afb, 0x7f4c, 0x9daf, 0x9e1a, 0x4e5f, 0x503b, 0x51b6, + 0x591c, 0x60f9, 0x63f6, 0x6930, 0x723a, 0x8036, 0xf974, 0x91ce, 0x5f31, + 0xf975, 0xf976, 0x7d04, 0x82e5, 0x846f, 0x84bb, 0x85e5, 0x8e8d, 0xf977, + 0x4f6f, 0xf978, 0xf979, 0x58e4, 0x5b43, 0x6059, 0x63da, 0x6518, 0x656d, + 0x6698, 0xf97a, 0x694a, 0x6a23, 0x6d0b, 0x7001, 0x716c, 0x75d2, 0x760d, + 0x79b3, 0x7a70, 0xf97b, 0x7f8a, 0xf97c, 0x8944, 0xf97d, 0x8b93, 0x91c0, + 0x967d, 0xf97e, 0x990a, 0x5704, 0x5fa1, 0x65bc, 0x6f01, 0x7600, 0x79a6, + 0x8a9e, 0x99ad, 0x9b5a, 0x9f6c, 0x5104, 0x61b6, 0x6291, 0x6a8d, 0x81c6, + 0x5043, 0x5830, 0x5f66, 0x7109, 0x8a00, 0x8afa, 0x5b7c, 0x8616, 0x4ffa, + 0x513c, 0x56b4, 0x5944, 0x63a9, 0x6df9, 0x5daa, 0x696d, 0x5186, 0x4e88, + 0x4f59, 0xf97f, 0xf980, 0xf981, 0x5982, 0xf982, 0xf983, 0x6b5f, 0x6c5d, + 0xf984, 0x74b5, 0x7916, 0xf985, 0x8207, 0x8245, 0x8339, 0x8f3f, 0x8f5d, + 0xf986, 0x9918, 0xf987, 0xf988, 0xf989, 0x4ea6, 0xf98a, 0x57df, 0x5f79, + 0x6613, 0xf98b, 0xf98c, 0x75ab, 0x7e79, 0x8b6f, 0xf98d, 0x9006, 0x9a5b, + 0x56a5, 0x5827, 0x59f8, 0x5a1f, 0x5bb4, 0xf98e, 0x5ef6, 0xf98f, 0xf990, + 0x6350, 0x633b, 0xf991, 0x693d, 0x6c87, 0x6cbf, 0x6d8e, 0x6d93, 0x6df5, + 0x6f14, 0xf992, 0x70df, 0x7136, 0x7159, 0xf993, 0x71c3, 0x71d5, 0xf994, + 0x784f, 0x786f, 0xf995, 0x7b75, 0x7de3, 0xf996, 0x7e2f, 0xf997, 0x884d, + 0x8edf, 0xf998, 0xf999, 0xf99a, 0x925b, 0xf99b, 0x9cf6, 0xf99c, 0xf99d, + 0xf99e, 0x6085, 0x6d85, 0xf99f, 0x71b1, 0xf9a0, 0xf9a1, 0x95b1, 0x53ad, + 0xf9a2, 0xf9a3, 0xf9a4, 0x67d3, 0xf9a5, 0x708e, 0x7130, 0x7430, 0x8276, + 0x82d2, 0xf9a6, 0x95bb, 0x9ae5, 0x9e7d, 0x66c4, 0xf9a7, 0x71c1, 0x8449, + 0xf9a8, 0xf9a9, 0x584b, 0xf9aa, 0xf9ab, 0x5db8, 0x5f71, 0xf9ac, 0x6620, + 0x668e, 0x6979, 0x69ae, 0x6c38, 0x6cf3, 0x6e36, 0x6f41, 0x6fda, 0x701b, + 0x702f, 0x7150, 0x71df, 0x7370, 0xf9ad, 0x745b, 0xf9ae, 0x74d4, 0x76c8, + 0x7a4e, 0x7e93, 0xf9af, 0xf9b0, 0x82f1, 0x8a60, 0x8fce, 0xf9b1, 0x9348, + 0xf9b2, 0x9719, 0xf9b3, 0xf9b4, 0x4e42, 0x502a, 0xf9b5, 0x5208, 0x53e1, + 0x66f3, 0x6c6d, 0x6fca, 0x730a, 0x777f, 0x7a62, 0x82ae, 0x85dd, 0x8602, + 0xf9b6, 0x88d4, 0x8a63, 0x8b7d, 0x8c6b, 0xf9b7, 0x92b3, 0xf9b8, 0x9713, + 0x9810, 0x4e94, 0x4f0d, 0x4fc9, 0x50b2, 0x5348, 0x543e, 0x5433, 0x55da, + 0x5862, 0x58ba, 0x5967, 0x5a1b, 0x5be4, 0x609f, 0xf9b9, 0x61ca, 0x6556, + 0x65ff, 0x6664, 0x68a7, 0x6c5a, 0x6fb3, 0x70cf, 0x71ac, 0x7352, 0x7b7d, + 0x8708, 0x8aa4, 0x9c32, 0x9f07, 0x5c4b, 0x6c83, 0x7344, 0x7389, 0x923a, + 0x6eab, 0x7465, 0x761f, 0x7a69, 0x7e15, 0x860a, 0x5140, 0x58c5, 0x64c1, + 0x74ee, 0x7515, 0x7670, 0x7fc1, 0x9095, 0x96cd, 0x9954, 0x6e26, 0x74e6, + 0x7aa9, 0x7aaa, 0x81e5, 0x86d9, 0x8778, 0x8a1b, 0x5a49, 0x5b8c, 0x5b9b, + 0x68a1, 0x6900, 0x6d63, 0x73a9, 0x7413, 0x742c, 0x7897, 0x7de9, 0x7feb, + 0x8118, 0x8155, 0x839e, 0x8c4c, 0x962e, 0x9811, 0x66f0, 0x5f80, 0x65fa, + 0x6789, 0x6c6a, 0x738b, 0x502d, 0x5a03, 0x6b6a, 0x77ee, 0x5916, 0x5d6c, + 0x5dcd, 0x7325, 0x754f, 0xf9ba, 0xf9bb, 0x50e5, 0x51f9, 0x582f, 0x592d, + 0x5996, 0x59da, 0x5be5, 0xf9bc, 0xf9bd, 0x5da2, 0x62d7, 0x6416, 0x6493, + 0x64fe, 0xf9be, 0x66dc, 0xf9bf, 0x6a48, 0xf9c0, 0x71ff, 0x7464, 0xf9c1, + 0x7a88, 0x7aaf, 0x7e47, 0x7e5e, 0x8000, 0x8170, 0xf9c2, 0x87ef, 0x8981, + 0x8b20, 0x9059, 0xf9c3, 0x9080, 0x9952, 0x617e, 0x6b32, 0x6d74, 0x7e1f, + 0x8925, 0x8fb1, 0x4fd1, 0x50ad, 0x5197, 0x52c7, 0x57c7, 0x5889, 0x5bb9, + 0x5eb8, 0x6142, 0x6995, 0x6d8c, 0x6e67, 0x6eb6, 0x7194, 0x7462, 0x7528, + 0x752c, 0x8073, 0x8338, 0x84c9, 0x8e0a, 0x9394, 0x93de, 0xf9c4, 0x4e8e, + 0x4f51, 0x5076, 0x512a, 0x53c8, 0x53cb, 0x53f3, 0x5b87, 0x5bd3, 0x5c24, + 0x611a, 0x6182, 0x65f4, 0x725b, 0x7397, 0x7440, 0x76c2, 0x7950, 0x7991, + 0x79b9, 0x7d06, 0x7fbd, 0x828b, 0x85d5, 0x865e, 0x8fc2, 0x9047, 0x90f5, + 0x91ea, 0x9685, 0x96e8, 0x96e9, 0x52d6, 0x5f67, 0x65ed, 0x6631, 0x682f, + 0x715c, 0x7a36, 0x90c1, 0x980a, 0x4e91, 0xf9c5, 0x6a52, 0x6b9e, 0x6f90, + 0x7189, 0x8018, 0x82b8, 0x8553, 0x904b, 0x9695, 0x96f2, 0x97fb, 0x851a, + 0x9b31, 0x4e90, 0x718a, 0x96c4, 0x5143, 0x539f, 0x54e1, 0x5713, 0x5712, + 0x57a3, 0x5a9b, 0x5ac4, 0x5bc3, 0x6028, 0x613f, 0x63f4, 0x6c85, 0x6d39, + 0x6e72, 0x6e90, 0x7230, 0x733f, 0x7457, 0x82d1, 0x8881, 0x8f45, 0x9060, + 0xf9c6, 0x9662, 0x9858, 0x9d1b, 0x6708, 0x8d8a, 0x925e, 0x4f4d, 0x5049, + 0x50de, 0x5371, 0x570d, 0x59d4, 0x5a01, 0x5c09, 0x6170, 0x6690, 0x6e2d, + 0x7232, 0x744b, 0x7def, 0x80c3, 0x840e, 0x8466, 0x853f, 0x875f, 0x885b, + 0x8918, 0x8b02, 0x9055, 0x97cb, 0x9b4f, 0x4e73, 0x4f91, 0x5112, 0x516a, + 0xf9c7, 0x552f, 0x55a9, 0x5b7a, 0x5ba5, 0x5e7c, 0x5e7d, 0x5ebe, 0x60a0, + 0x60df, 0x6108, 0x6109, 0x63c4, 0x6538, 0x6709, 0xf9c8, 0x67d4, 0x67da, + 0xf9c9, 0x6961, 0x6962, 0x6cb9, 0x6d27, 0xf9ca, 0x6e38, 0xf9cb, 0x6fe1, + 0x7336, 0x7337, 0xf9cc, 0x745c, 0x7531, 0xf9cd, 0x7652, 0xf9ce, 0xf9cf, + 0x7dad, 0x81fe, 0x8438, 0x88d5, 0x8a98, 0x8adb, 0x8aed, 0x8e30, 0x8e42, + 0x904a, 0x903e, 0x907a, 0x9149, 0x91c9, 0x936e, 0xf9d0, 0xf9d1, 0x5809, + 0xf9d2, 0x6bd3, 0x8089, 0x80b2, 0xf9d3, 0xf9d4, 0x5141, 0x596b, 0x5c39, + 0xf9d5, 0xf9d6, 0x6f64, 0x73a7, 0x80e4, 0x8d07, 0xf9d7, 0x9217, 0x958f, + 0xf9d8, 0xf9d9, 0xf9da, 0xf9db, 0x807f, 0x620e, 0x701c, 0x7d68, 0x878d, + 0xf9dc, 0x57a0, 0x6069, 0x6147, 0x6bb7, 0x8abe, 0x9280, 0x96b1, 0x4e59, + 0x541f, 0x6deb, 0x852d, 0x9670, 0x97f3, 0x98ee, 0x63d6, 0x6ce3, 0x9091, + 0x51dd, 0x61c9, 0x81ba, 0x9df9, 0x4f9d, 0x501a, 0x5100, 0x5b9c, 0x610f, + 0x61ff, 0x64ec, 0x6905, 0x6bc5, 0x7591, 0x77e3, 0x7fa9, 0x8264, 0x858f, + 0x87fb, 0x8863, 0x8abc, 0x8b70, 0x91ab, 0x4e8c, 0x4ee5, 0x4f0a, 0xf9dd, + 0xf9de, 0x5937, 0x59e8, 0xf9df, 0x5df2, 0x5f1b, 0x5f5b, 0x6021, 0xf9e0, + 0xf9e1, 0xf9e2, 0xf9e3, 0x723e, 0x73e5, 0xf9e4, 0x7570, 0x75cd, 0xf9e5, + 0x79fb, 0xf9e6, 0x800c, 0x8033, 0x8084, 0x82e1, 0x8351, 0xf9e7, 0xf9e8, + 0x8cbd, 0x8cb3, 0x9087, 0xf9e9, 0xf9ea, 0x98f4, 0x990c, 0xf9eb, 0xf9ec, + 0x7037, 0x76ca, 0x7fca, 0x7fcc, 0x7ffc, 0x8b1a, 0x4eba, 0x4ec1, 0x5203, + 0x5370, 0xf9ed, 0x54bd, 0x56e0, 0x59fb, 0x5bc5, 0x5f15, 0x5fcd, 0x6e6e, + 0xf9ee, 0xf9ef, 0x7d6a, 0x8335, 0xf9f0, 0x8693, 0x8a8d, 0xf9f1, 0x976d, + 0x9777, 0xf9f2, 0xf9f3, 0x4e00, 0x4f5a, 0x4f7e, 0x58f9, 0x65e5, 0x6ea2, + 0x9038, 0x93b0, 0x99b9, 0x4efb, 0x58ec, 0x598a, 0x59d9, 0x6041, 0xf9f4, + 0xf9f5, 0x7a14, 0xf9f6, 0x834f, 0x8cc3, 0x5165, 0x5344, 0xf9f7, 0xf9f8, + 0xf9f9, 0x4ecd, 0x5269, 0x5b55, 0x82bf, 0x4ed4, 0x523a, 0x54a8, 0x59c9, + 0x59ff, 0x5b50, 0x5b57, 0x5b5c, 0x6063, 0x6148, 0x6ecb, 0x7099, 0x716e, + 0x7386, 0x74f7, 0x75b5, 0x78c1, 0x7d2b, 0x8005, 0x81ea, 0x8328, 0x8517, + 0x85c9, 0x8aee, 0x8cc7, 0x96cc, 0x4f5c, 0x52fa, 0x56bc, 0x65ab, 0x6628, + 0x707c, 0x70b8, 0x7235, 0x7dbd, 0x828d, 0x914c, 0x96c0, 0x9d72, 0x5b71, + 0x68e7, 0x6b98, 0x6f7a, 0x76de, 0x5c91, 0x66ab, 0x6f5b, 0x7bb4, 0x7c2a, + 0x8836, 0x96dc, 0x4e08, 0x4ed7, 0x5320, 0x5834, 0x58bb, 0x58ef, 0x596c, + 0x5c07, 0x5e33, 0x5e84, 0x5f35, 0x638c, 0x66b2, 0x6756, 0x6a1f, 0x6aa3, + 0x6b0c, 0x6f3f, 0x7246, 0xf9fa, 0x7350, 0x748b, 0x7ae0, 0x7ca7, 0x8178, + 0x81df, 0x81e7, 0x838a, 0x846c, 0x8523, 0x8594, 0x85cf, 0x88dd, 0x8d13, + 0x91ac, 0x9577, 0x969c, 0x518d, 0x54c9, 0x5728, 0x5bb0, 0x624d, 0x6750, + 0x683d, 0x6893, 0x6e3d, 0x6ed3, 0x707d, 0x7e21, 0x88c1, 0x8ca1, 0x8f09, + 0x9f4b, 0x9f4e, 0x722d, 0x7b8f, 0x8acd, 0x931a, 0x4f47, 0x4f4e, 0x5132, + 0x5480, 0x59d0, 0x5e95, 0x62b5, 0x6775, 0x696e, 0x6a17, 0x6cae, 0x6e1a, + 0x72d9, 0x732a, 0x75bd, 0x7bb8, 0x7d35, 0x82e7, 0x83f9, 0x8457, 0x85f7, + 0x8a5b, 0x8caf, 0x8e87, 0x9019, 0x90b8, 0x96ce, 0x9f5f, 0x52e3, 0x540a, + 0x5ae1, 0x5bc2, 0x6458, 0x6575, 0x6ef4, 0x72c4, 0xf9fb, 0x7684, 0x7a4d, + 0x7b1b, 0x7c4d, 0x7e3e, 0x7fdf, 0x837b, 0x8b2b, 0x8cca, 0x8d64, 0x8de1, + 0x8e5f, 0x8fea, 0x8ff9, 0x9069, 0x93d1, 0x4f43, 0x4f7a, 0x50b3, 0x5168, + 0x5178, 0x524d, 0x526a, 0x5861, 0x587c, 0x5960, 0x5c08, 0x5c55, 0x5edb, + 0x609b, 0x6230, 0x6813, 0x6bbf, 0x6c08, 0x6fb1, 0x714e, 0x7420, 0x7530, + 0x7538, 0x7551, 0x7672, 0x7b4c, 0x7b8b, 0x7bad, 0x7bc6, 0x7e8f, 0x8a6e, + 0x8f3e, 0x8f49, 0x923f, 0x9293, 0x9322, 0x942b, 0x96fb, 0x985a, 0x986b, + 0x991e, 0x5207, 0x622a, 0x6298, 0x6d59, 0x7664, 0x7aca, 0x7bc0, 0x7d76, + 0x5360, 0x5cbe, 0x5e97, 0x6f38, 0x70b9, 0x7c98, 0x9711, 0x9b8e, 0x9ede, + 0x63a5, 0x647a, 0x8776, 0x4e01, 0x4e95, 0x4ead, 0x505c, 0x5075, 0x5448, + 0x59c3, 0x5b9a, 0x5e40, 0x5ead, 0x5ef7, 0x5f81, 0x60c5, 0x633a, 0x653f, + 0x6574, 0x65cc, 0x6676, 0x6678, 0x67fe, 0x6968, 0x6a89, 0x6b63, 0x6c40, + 0x6dc0, 0x6de8, 0x6e1f, 0x6e5e, 0x701e, 0x70a1, 0x738e, 0x73fd, 0x753a, + 0x775b, 0x7887, 0x798e, 0x7a0b, 0x7a7d, 0x7cbe, 0x7d8e, 0x8247, 0x8a02, + 0x8aea, 0x8c9e, 0x912d, 0x914a, 0x91d8, 0x9266, 0x92cc, 0x9320, 0x9706, + 0x9756, 0x975c, 0x9802, 0x9f0e, 0x5236, 0x5291, 0x557c, 0x5824, 0x5e1d, + 0x5f1f, 0x608c, 0x63d0, 0x68af, 0x6fdf, 0x796d, 0x7b2c, 0x81cd, 0x85ba, + 0x88fd, 0x8af8, 0x8e44, 0x918d, 0x9664, 0x969b, 0x973d, 0x984c, 0x9f4a, + 0x4fce, 0x5146, 0x51cb, 0x52a9, 0x5632, 0x5f14, 0x5f6b, 0x63aa, 0x64cd, + 0x65e9, 0x6641, 0x66fa, 0x66f9, 0x671d, 0x689d, 0x68d7, 0x69fd, 0x6f15, + 0x6f6e, 0x7167, 0x71e5, 0x722a, 0x74aa, 0x773a, 0x7956, 0x795a, 0x79df, + 0x7a20, 0x7a95, 0x7c97, 0x7cdf, 0x7d44, 0x7e70, 0x8087, 0x85fb, 0x86a4, + 0x8a54, 0x8abf, 0x8d99, 0x8e81, 0x9020, 0x906d, 0x91e3, 0x963b, 0x96d5, + 0x9ce5, 0x65cf, 0x7c07, 0x8db3, 0x93c3, 0x5b58, 0x5c0a, 0x5352, 0x62d9, + 0x731d, 0x5027, 0x5b97, 0x5f9e, 0x60b0, 0x616b, 0x68d5, 0x6dd9, 0x742e, + 0x7a2e, 0x7d42, 0x7d9c, 0x7e31, 0x816b, 0x8e2a, 0x8e35, 0x937e, 0x9418, + 0x4f50, 0x5750, 0x5de6, 0x5ea7, 0x632b, 0x7f6a, 0x4e3b, 0x4f4f, 0x4f8f, + 0x505a, 0x59dd, 0x80c4, 0x546a, 0x5468, 0x55fe, 0x594f, 0x5b99, 0x5dde, + 0x5eda, 0x665d, 0x6731, 0x67f1, 0x682a, 0x6ce8, 0x6d32, 0x6e4a, 0x6f8d, + 0x70b7, 0x73e0, 0x7587, 0x7c4c, 0x7d02, 0x7d2c, 0x7da2, 0x821f, 0x86db, + 0x8a3b, 0x8a85, 0x8d70, 0x8e8a, 0x8f33, 0x9031, 0x914e, 0x9152, 0x9444, + 0x99d0, 0x7af9, 0x7ca5, 0x4fca, 0x5101, 0x51c6, 0x57c8, 0x5bef, 0x5cfb, + 0x6659, 0x6a3d, 0x6d5a, 0x6e96, 0x6fec, 0x710c, 0x756f, 0x7ae3, 0x8822, + 0x9021, 0x9075, 0x96cb, 0x99ff, 0x8301, 0x4e2d, 0x4ef2, 0x8846, 0x91cd, + 0x537d, 0x6adb, 0x696b, 0x6c41, 0x847a, 0x589e, 0x618e, 0x66fe, 0x62ef, + 0x70dd, 0x7511, 0x75c7, 0x7e52, 0x84b8, 0x8b49, 0x8d08, 0x4e4b, 0x53ea, + 0x54ab, 0x5730, 0x5740, 0x5fd7, 0x6301, 0x6307, 0x646f, 0x652f, 0x65e8, + 0x667a, 0x679d, 0x67b3, 0x6b62, 0x6c60, 0x6c9a, 0x6f2c, 0x77e5, 0x7825, + 0x7949, 0x7957, 0x7d19, 0x80a2, 0x8102, 0x81f3, 0x829d, 0x82b7, 0x8718, + 0x8a8c, 0xf9fc, 0x8d04, 0x8dbe, 0x9072, 0x76f4, 0x7a19, 0x7a37, 0x7e54, + 0x8077, 0x5507, 0x55d4, 0x5875, 0x632f, 0x6422, 0x6649, 0x664b, 0x686d, + 0x699b, 0x6b84, 0x6d25, 0x6eb1, 0x73cd, 0x7468, 0x74a1, 0x755b, 0x75b9, + 0x76e1, 0x771e, 0x778b, 0x79e6, 0x7e09, 0x7e1d, 0x81fb, 0x852f, 0x8897, + 0x8a3a, 0x8cd1, 0x8eeb, 0x8fb0, 0x9032, 0x93ad, 0x9663, 0x9673, 0x9707, + 0x4f84, 0x53f1, 0x59ea, 0x5ac9, 0x5e19, 0x684e, 0x74c6, 0x75be, 0x79e9, + 0x7a92, 0x81a3, 0x86ed, 0x8cea, 0x8dcc, 0x8fed, 0x659f, 0x6715, 0xf9fd, + 0x57f7, 0x6f57, 0x7ddd, 0x8f2f, 0x93f6, 0x96c6, 0x5fb5, 0x61f2, 0x6f84, + 0x4e14, 0x4f98, 0x501f, 0x53c9, 0x55df, 0x5d6f, 0x5dee, 0x6b21, 0x6b64, + 0x78cb, 0x7b9a, 0xf9fe, 0x8e49, 0x8eca, 0x906e, 0x6349, 0x643e, 0x7740, + 0x7a84, 0x932f, 0x947f, 0x9f6a, 0x64b0, 0x6faf, 0x71e6, 0x74a8, 0x74da, + 0x7ac4, 0x7c12, 0x7e82, 0x7cb2, 0x7e98, 0x8b9a, 0x8d0a, 0x947d, 0x9910, + 0x994c, 0x5239, 0x5bdf, 0x64e6, 0x672d, 0x7d2e, 0x50ed, 0x53c3, 0x5879, + 0x6158, 0x6159, 0x61fa, 0x65ac, 0x7ad9, 0x8b92, 0x8b96, 0x5009, 0x5021, + 0x5275, 0x5531, 0x5a3c, 0x5ee0, 0x5f70, 0x6134, 0x655e, 0x660c, 0x6636, + 0x66a2, 0x69cd, 0x6ec4, 0x6f32, 0x7316, 0x7621, 0x7a93, 0x8139, 0x8259, + 0x83d6, 0x84bc, 0x50b5, 0x57f0, 0x5bc0, 0x5be8, 0x5f69, 0x63a1, 0x7826, + 0x7db5, 0x83dc, 0x8521, 0x91c7, 0x91f5, 0x518a, 0x67f5, 0x7b56, 0x8cac, + 0x51c4, 0x59bb, 0x60bd, 0x8655, 0x501c, 0xf9ff, 0x5254, 0x5c3a, 0x617d, + 0x621a, 0x62d3, 0x64f2, 0x65a5, 0x6ecc, 0x7620, 0x810a, 0x8e60, 0x965f, + 0x96bb, 0x4edf, 0x5343, 0x5598, 0x5929, 0x5ddd, 0x64c5, 0x6cc9, 0x6dfa, + 0x7394, 0x7a7f, 0x821b, 0x85a6, 0x8ce4, 0x8e10, 0x9077, 0x91e7, 0x95e1, + 0x9621, 0x97c6, 0x51f8, 0x54f2, 0x5586, 0x5fb9, 0x64a4, 0x6f88, 0x7db4, + 0x8f1f, 0x8f4d, 0x9435, 0x50c9, 0x5c16, 0x6cbe, 0x6dfb, 0x751b, 0x77bb, + 0x7c3d, 0x7c64, 0x8a79, 0x8ac2, 0x581e, 0x59be, 0x5e16, 0x6377, 0x7252, + 0x758a, 0x776b, 0x8adc, 0x8cbc, 0x8f12, 0x5ef3, 0x6674, 0x6df8, 0x807d, + 0x83c1, 0x8acb, 0x9751, 0x9bd6, 0xfa00, 0x5243, 0x66ff, 0x6d95, 0x6eef, + 0x7de0, 0x8ae6, 0x902e, 0x905e, 0x9ad4, 0x521d, 0x527f, 0x54e8, 0x6194, + 0x6284, 0x62db, 0x68a2, 0x6912, 0x695a, 0x6a35, 0x7092, 0x7126, 0x785d, + 0x7901, 0x790e, 0x79d2, 0x7a0d, 0x8096, 0x8278, 0x82d5, 0x8349, 0x8549, + 0x8c82, 0x8d85, 0x9162, 0x918b, 0x91ae, 0x4fc3, 0x56d1, 0x71ed, 0x77d7, + 0x8700, 0x89f8, 0x5bf8, 0x5fd6, 0x6751, 0x90a8, 0x53e2, 0x585a, 0x5bf5, + 0x60a4, 0x6181, 0x6460, 0x7e3d, 0x8070, 0x8525, 0x9283, 0x64ae, 0x50ac, + 0x5d14, 0x6700, 0x589c, 0x62bd, 0x63a8, 0x690e, 0x6978, 0x6a1e, 0x6e6b, + 0x76ba, 0x79cb, 0x82bb, 0x8429, 0x8acf, 0x8da8, 0x8ffd, 0x9112, 0x914b, + 0x919c, 0x9310, 0x9318, 0x939a, 0x96db, 0x9a36, 0x9c0d, 0x4e11, 0x755c, + 0x795d, 0x7afa, 0x7b51, 0x7bc9, 0x7e2e, 0x84c4, 0x8e59, 0x8e74, 0x8ef8, + 0x9010, 0x6625, 0x693f, 0x7443, 0x51fa, 0x672e, 0x9edc, 0x5145, 0x5fe0, + 0x6c96, 0x87f2, 0x885d, 0x8877, 0x60b4, 0x81b5, 0x8403, 0x8d05, 0x53d6, + 0x5439, 0x5634, 0x5a36, 0x5c31, 0x708a, 0x7fe0, 0x805a, 0x8106, 0x81ed, + 0x8da3, 0x9189, 0x9a5f, 0x9df2, 0x5074, 0x4ec4, 0x53a0, 0x60fb, 0x6e2c, + 0x5c64, 0x4f88, 0x5024, 0x55e4, 0x5cd9, 0x5e5f, 0x6065, 0x6894, 0x6cbb, + 0x6dc4, 0x71be, 0x75d4, 0x75f4, 0x7661, 0x7a1a, 0x7a49, 0x7dc7, 0x7dfb, + 0x7f6e, 0x81f4, 0x86a9, 0x8f1c, 0x96c9, 0x99b3, 0x9f52, 0x5247, 0x52c5, + 0x98ed, 0x89aa, 0x4e03, 0x67d2, 0x6f06, 0x4fb5, 0x5be2, 0x6795, 0x6c88, + 0x6d78, 0x741b, 0x7827, 0x91dd, 0x937c, 0x87c4, 0x79e4, 0x7a31, 0x5feb, + 0x4ed6, 0x54a4, 0x553e, 0x58ae, 0x59a5, 0x60f0, 0x6253, 0x62d6, 0x6736, + 0x6955, 0x8235, 0x9640, 0x99b1, 0x99dd, 0x502c, 0x5353, 0x5544, 0x577c, + 0xfa01, 0x6258, 0xfa02, 0x64e2, 0x666b, 0x67dd, 0x6fc1, 0x6fef, 0x7422, + 0x7438, 0x8a17, 0x9438, 0x5451, 0x5606, 0x5766, 0x5f48, 0x619a, 0x6b4e, + 0x7058, 0x70ad, 0x7dbb, 0x8a95, 0x596a, 0x812b, 0x63a2, 0x7708, 0x803d, + 0x8caa, 0x5854, 0x642d, 0x69bb, 0x5b95, 0x5e11, 0x6e6f, 0xfa03, 0x8569, + 0x514c, 0x53f0, 0x592a, 0x6020, 0x614b, 0x6b86, 0x6c70, 0x6cf0, 0x7b1e, + 0x80ce, 0x82d4, 0x8dc6, 0x90b0, 0x98b1, 0xfa04, 0x64c7, 0x6fa4, 0x6491, + 0x6504, 0x514e, 0x5410, 0x571f, 0x8a0e, 0x615f, 0x6876, 0xfa05, 0x75db, + 0x7b52, 0x7d71, 0x901a, 0x5806, 0x69cc, 0x817f, 0x892a, 0x9000, 0x9839, + 0x5078, 0x5957, 0x59ac, 0x6295, 0x900f, 0x9b2a, 0x615d, 0x7279, 0x95d6, + 0x5761, 0x5a46, 0x5df4, 0x628a, 0x64ad, 0x64fa, 0x6777, 0x6ce2, 0x6d3e, + 0x722c, 0x7436, 0x7834, 0x7f77, 0x82ad, 0x8ddb, 0x9817, 0x5224, 0x5742, + 0x677f, 0x7248, 0x74e3, 0x8ca9, 0x8fa6, 0x9211, 0x962a, 0x516b, 0x53ed, + 0x634c, 0x4f69, 0x5504, 0x6096, 0x6557, 0x6c9b, 0x6d7f, 0x724c, 0x72fd, + 0x7a17, 0x8987, 0x8c9d, 0x5f6d, 0x6f8e, 0x70f9, 0x81a8, 0x610e, 0x4fbf, + 0x504f, 0x6241, 0x7247, 0x7bc7, 0x7de8, 0x7fe9, 0x904d, 0x97ad, 0x9a19, + 0x8cb6, 0x576a, 0x5e73, 0x67b0, 0x840d, 0x8a55, 0x5420, 0x5b16, 0x5e63, + 0x5ee2, 0x5f0a, 0x6583, 0x80ba, 0x853d, 0x9589, 0x965b, 0x4f48, 0x5305, + 0x530d, 0x530f, 0x5486, 0x54fa, 0x5703, 0x5e03, 0x6016, 0x629b, 0x62b1, + 0x6355, 0xfa06, 0x6ce1, 0x6d66, 0x75b1, 0x7832, 0x80de, 0x812f, 0x82de, + 0x8461, 0x84b2, 0x888d, 0x8912, 0x900b, 0x92ea, 0x98fd, 0x9b91, 0x5e45, + 0x66b4, 0x66dd, 0x7011, 0x7206, 0xfa07, 0x4ff5, 0x527d, 0x5f6a, 0x6153, + 0x6753, 0x6a19, 0x6f02, 0x74e2, 0x7968, 0x8868, 0x8c79, 0x98c7, 0x98c4, + 0x9a43, 0x54c1, 0x7a1f, 0x6953, 0x8af7, 0x8c4a, 0x98a8, 0x99ae, 0x5f7c, + 0x62ab, 0x75b2, 0x76ae, 0x88ab, 0x907f, 0x9642, 0x5339, 0x5f3c, 0x5fc5, + 0x6ccc, 0x73cc, 0x7562, 0x758b, 0x7b46, 0x82fe, 0x999d, 0x4e4f, 0x903c, + 0x4e0b, 0x4f55, 0x53a6, 0x590f, 0x5ec8, 0x6630, 0x6cb3, 0x7455, 0x8377, + 0x8766, 0x8cc0, 0x9050, 0x971e, 0x9c15, 0x58d1, 0x5b78, 0x8650, 0x8b14, + 0x9db4, 0x5bd2, 0x6068, 0x608d, 0x65f1, 0x6c57, 0x6f22, 0x6fa3, 0x701a, + 0x7f55, 0x7ff0, 0x9591, 0x9592, 0x9650, 0x97d3, 0x5272, 0x8f44, 0x51fd, + 0x542b, 0x54b8, 0x5563, 0x558a, 0x6abb, 0x6db5, 0x7dd8, 0x8266, 0x929c, + 0x9677, 0x9e79, 0x5408, 0x54c8, 0x76d2, 0x86e4, 0x95a4, 0x95d4, 0x965c, + 0x4ea2, 0x4f09, 0x59ee, 0x5ae6, 0x5df7, 0x6052, 0x6297, 0x676d, 0x6841, + 0x6c86, 0x6e2f, 0x7f38, 0x809b, 0x822a, 0xfa08, 0xfa09, 0x9805, 0x4ea5, + 0x5055, 0x54b3, 0x5793, 0x595a, 0x5b69, 0x5bb3, 0x61c8, 0x6977, 0x6d77, + 0x7023, 0x87f9, 0x89e3, 0x8a72, 0x8ae7, 0x9082, 0x99ed, 0x9ab8, 0x52be, + 0x6838, 0x5016, 0x5e78, 0x674f, 0x8347, 0x884c, 0x4eab, 0x5411, 0x56ae, + 0x73e6, 0x9115, 0x97ff, 0x9909, 0x9957, 0x9999, 0x5653, 0x589f, 0x865b, + 0x8a31, 0x61b2, 0x6af6, 0x737b, 0x8ed2, 0x6b47, 0x96aa, 0x9a57, 0x5955, + 0x7200, 0x8d6b, 0x9769, 0x4fd4, 0x5cf4, 0x5f26, 0x61f8, 0x665b, 0x6ceb, + 0x70ab, 0x7384, 0x73b9, 0x73fe, 0x7729, 0x774d, 0x7d43, 0x7d62, 0x7e23, + 0x8237, 0x8852, 0xfa0a, 0x8ce2, 0x9249, 0x986f, 0x5b51, 0x7a74, 0x8840, + 0x9801, 0x5acc, 0x4fe0, 0x5354, 0x593e, 0x5cfd, 0x633e, 0x6d79, 0x72f9, + 0x8105, 0x8107, 0x83a2, 0x92cf, 0x9830, 0x4ea8, 0x5144, 0x5211, 0x578b, + 0x5f62, 0x6cc2, 0x6ece, 0x7005, 0x7050, 0x70af, 0x7192, 0x73e9, 0x7469, + 0x834a, 0x87a2, 0x8861, 0x9008, 0x90a2, 0x93a3, 0x99a8, 0x516e, 0x5f57, + 0x60e0, 0x6167, 0x66b3, 0x8559, 0x8e4a, 0x91af, 0x978b, 0x4e4e, 0x4e92, + 0x547c, 0x58d5, 0x58fa, 0x597d, 0x5cb5, 0x5f27, 0x6236, 0x6248, 0x660a, + 0x6667, 0x6beb, 0x6d69, 0x6dcf, 0x6e56, 0x6ef8, 0x6f94, 0x6fe0, 0x6fe9, + 0x705d, 0x72d0, 0x7425, 0x745a, 0x74e0, 0x7693, 0x795c, 0x7cca, 0x7e1e, + 0x80e1, 0x82a6, 0x846b, 0x84bf, 0x864e, 0x865f, 0x8774, 0x8b77, 0x8c6a, + 0x93ac, 0x9800, 0x9865, 0x60d1, 0x6216, 0x9177, 0x5a5a, 0x660f, 0x6df7, + 0x6e3e, 0x743f, 0x9b42, 0x5ffd, 0x60da, 0x7b0f, 0x54c4, 0x5f18, 0x6c5e, + 0x6cd3, 0x6d2a, 0x70d8, 0x7d05, 0x8679, 0x8a0c, 0x9d3b, 0x5316, 0x548c, + 0x5b05, 0x6a3a, 0x706b, 0x7575, 0x798d, 0x79be, 0x82b1, 0x83ef, 0x8a71, + 0x8b41, 0x8ca8, 0x9774, 0xfa0b, 0x64f4, 0x652b, 0x78ba, 0x78bb, 0x7a6b, + 0x4e38, 0x559a, 0x5950, 0x5ba6, 0x5e7b, 0x60a3, 0x63db, 0x6b61, 0x6665, + 0x6853, 0x6e19, 0x7165, 0x74b0, 0x7d08, 0x9084, 0x9a69, 0x9c25, 0x6d3b, + 0x6ed1, 0x733e, 0x8c41, 0x95ca, 0x51f0, 0x5e4c, 0x5fa8, 0x604d, 0x60f6, + 0x6130, 0x614c, 0x6643, 0x6644, 0x69a5, 0x6cc1, 0x6e5f, 0x6ec9, 0x6f62, + 0x714c, 0x749c, 0x7687, 0x7bc1, 0x7c27, 0x8352, 0x8757, 0x9051, 0x968d, + 0x9ec3, 0x532f, 0x56de, 0x5efb, 0x5f8a, 0x6062, 0x6094, 0x61f7, 0x6666, + 0x6703, 0x6a9c, 0x6dee, 0x6fae, 0x7070, 0x736a, 0x7e6a, 0x81be, 0x8334, + 0x86d4, 0x8aa8, 0x8cc4, 0x5283, 0x7372, 0x5b96, 0x6a6b, 0x9404, 0x54ee, + 0x5686, 0x5b5d, 0x6548, 0x6585, 0x66c9, 0x689f, 0x6d8d, 0x6dc6, 0x723b, + 0x80b4, 0x9175, 0x9a4d, 0x4faf, 0x5019, 0x539a, 0x540e, 0x543c, 0x5589, + 0x55c5, 0x5e3f, 0x5f8c, 0x673d, 0x7166, 0x73dd, 0x9005, 0x52db, 0x52f3, + 0x5864, 0x58ce, 0x7104, 0x718f, 0x71fb, 0x85b0, 0x8a13, 0x6688, 0x85a8, + 0x55a7, 0x6684, 0x714a, 0x8431, 0x5349, 0x5599, 0x6bc1, 0x5f59, 0x5fbd, + 0x63ee, 0x6689, 0x7147, 0x8af1, 0x8f1d, 0x9ebe, 0x4f11, 0x643a, 0x70cb, + 0x7566, 0x8667, 0x6064, 0x8b4e, 0x9df8, 0x5147, 0x51f6, 0x5308, 0x6d36, + 0x80f8, 0x9ed1, 0x6615, 0x6b23, 0x7098, 0x75d5, 0x5403, 0x5c79, 0x7d07, + 0x8a16, 0x6b20, 0x6b3d, 0x6b46, 0x5438, 0x6070, 0x6d3d, 0x7fd5, 0x8208, + 0x50d6, 0x51de, 0x559c, 0x566b, 0x56cd, 0x59ec, 0x5b09, 0x5e0c, 0x6199, + 0x6198, 0x6231, 0x665e, 0x66e6, 0x7199, 0x71b9, 0x71ba, 0x72a7, 0x79a7, + 0x7a00, 0x7fb2, 0x8a70, 0/* End of table; # of entries=8741(0x2225)+1 */ }; diff --git a/src/cmd/tcs/misc.h b/src/cmd/tcs/misc.h index cb223dae2..5afa316a9 100644 --- a/src/cmd/tcs/misc.h +++ b/src/cmd/tcs/misc.h @@ -16,14 +16,14 @@ long tabatari[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */ 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb, 0x00e3, 0x00f5, 0x00d8, 0x00f8, 0x0153, 0x0152, 0x00c0, 0x00c3, 0x00d5, 0x00a8, 0x00b4, 0x2020, 0x00b6, 0x00a9, 0x00ae, 0x2122, -0x0133, 0x0132, +0x0133, 0x0132, 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, /* hebrew */ 0x05d6, 0x05d7, 0x05d8, 0x05d9, 0x05db, 0x05dc, 0x05de, 0x05e0, 0x05e1, 0x05e2, 0x05e4, 0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea, -0x05df, 0x05da, 0x05dd, 0x05e3, 0x05e5, +0x05df, 0x05da, 0x05dd, 0x05e3, 0x05e5, 0x00a7, 0x2038, 0x221e, /* math */ 0x03b1, 0x03b2, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */ -0x03a6, 0x03b8, 0x2126, 0x03b4, +0x03a6, 0x03b8, 0x2126, 0x03b4, 0x222e, 0x03c6, 0x2208, 0x220f, /* math */ 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248, 0x00b0, 0x2022, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x00b3, 0x00af @@ -141,7 +141,7 @@ long tabps2[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */ 0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4, -0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce, +0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce, 0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580, 0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe, 0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4, diff --git a/src/cmd/tcs/ms.h b/src/cmd/tcs/ms.h index 617dd198a..90ecfec5b 100644 --- a/src/cmd/tcs/ms.h +++ b/src/cmd/tcs/ms.h @@ -5,10 +5,10 @@ for(i in $*){ j=`{echo $i | sed 's;.*./;cp;'} echo long tab$j'[256] = {' - hget http://www.microsoft.com/globaldev/reference/$i.mspx | htmlfmt | + hget http://www.microsoft.com/globaldev/reference/$i.mspx | htmlfmt | 9 grep '^.. = U\+....:' | 9 sed 's/= U\+/ 0x/; s/:.*.//' | awk ' { t[$1] = $2 } - END { + END { for(i=0; i<256; i++) { s = sprintf("%.2X", i); if(s in t) diff --git a/src/cmd/tcs/tcs.c b/src/cmd/tcs/tcs.c index 6722bb6be..d796ba63e 100644 --- a/src/cmd/tcs/tcs.c +++ b/src/cmd/tcs/tcs.c @@ -55,7 +55,7 @@ main(int argc, char **argv) break; case 'f': from = EARGF(usage()); - break; + break; case 'l': listem = 1; break; @@ -454,7 +454,7 @@ long tabmsdos[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567, -0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, +0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */ 0x03a6, 0x0398, 0x2126, 0x03b4, 0x221e, 0x2205, 0x2208, 0x2229, @@ -483,7 +483,7 @@ long tabmsdos2[256] = /* from jhelling@cs.ruu.nl (Jeroen Hellingman) */ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567, -0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, +0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4, /* greek */ 0x03a6, 0x0398, 0x2126, 0x03b4, 0x221e, 0x2205, 0x2208, 0x2229, diff --git a/src/cmd/tcs/tune.c b/src/cmd/tcs/tune.c index 1046b7796..5542008d4 100644 --- a/src/cmd/tcs/tune.c +++ b/src/cmd/tcs/tune.c @@ -30,7 +30,7 @@ static Tmap t1[] = static Rune t2[] = { - 0x0bcd/*்*/, + 0x0bcd/*்*/, 0x0bcd/*்*/, // filler 0x0bbe/*ா*/, 0x0bbf/*ி*/, @@ -112,7 +112,7 @@ tune_in(int fd, long *x, struct convert *out) Rune rbuf[N]; Rune *r, *er, tr; int c, i; - + USED(x); r = rbuf; er = rbuf+N-3; @@ -159,7 +159,7 @@ tune_in(int fd, long *x, struct convert *out) case 0xe38d/**/: *r++ = 0x0bb6/*ஶ*/; *r++ = 0x0bcd/*்*/; *r++ = 0x0bb0/*ர*/; *r++ = 0x0bc0/*ீ*/; break; - default: + default: if(c >= 0xe200 && c <= 0xe3ff){ if(squawk) EPR "%s: rune 0x%x not in output cs\n", argv0, c); diff --git a/src/cmd/touch.c b/src/cmd/touch.c index 6688293e3..471e2b17d 100644 --- a/src/cmd/touch.c +++ b/src/cmd/touch.c @@ -27,7 +27,7 @@ main(int argc, char **argv) case 'c': nocreate = 1; break; - default: + default: usage(); }ARGEND diff --git a/src/cmd/tpic/arcgen.c b/src/cmd/tpic/arcgen.c index 9c98d1977..de43dcd23 100644 --- a/src/cmd/tpic/arcgen.c +++ b/src/cmd/tpic/arcgen.c @@ -211,4 +211,3 @@ quadrant(double x, double y) else if( x> 0.0 && y<=0.0) return(4); else return 0; /* shut up lint */ } - diff --git a/src/cmd/tpic/linegen.c b/src/cmd/tpic/linegen.c index 8a7e08be5..639cdb474 100644 --- a/src/cmd/tpic/linegen.c +++ b/src/cmd/tpic/linegen.c @@ -197,7 +197,7 @@ linegen(int type) extreme(ex, ey); nx = xi; ny = yi; } - + } p->o_ddval = ddval; if (dbg) { diff --git a/src/cmd/tpic/pic.h b/src/cmd/tpic/pic.h index 438e71a6e..a11c74782 100644 --- a/src/cmd/tpic/pic.h +++ b/src/cmd/tpic/pic.h @@ -285,4 +285,3 @@ void yyerror(char *s); int yyparse(void); #include "tex.h" - diff --git a/src/cmd/tpic/tex.c b/src/cmd/tpic/tex.c index ade5df6b5..678dba607 100644 --- a/src/cmd/tpic/tex.c +++ b/src/cmd/tpic/tex.c @@ -20,7 +20,7 @@ devarc(double x1, double y1, double x2, double y2, double xc, double yc, int r) } void -box(double x0, double y0, double x1, double y1) +box(double x0, double y0, double x1, double y1) { fprintf(TEXFILE," \\special{pa %d %d}",TRX(x0),TRY(y0)); fprintf(TEXFILE,"\\special{pa %d %d}",TRX(x1),TRY(y0)); @@ -104,16 +104,16 @@ frame(double xs, double ys, double xf, double yf) } void -line(double x0, double y0, double x1, double y1) +line(double x0, double y0, double x1, double y1) { move(x0, y0); vec(x1, y1); } void -move(double xx, double yy) +move(double xx, double yy) { - e1->copyx = xx; + e1->copyx = xx; e1->copyy = yy; } @@ -136,7 +136,7 @@ FILE *TEXFILE; void openpl(void) -{ +{ TEXFILE = stdout; space(xmin, ymin, xmax, ymax); @@ -152,7 +152,7 @@ openpl(void) } void -range(double x0, double y0, double x1, double y1) +range(double x0, double y0, double x1, double y1) { e1->xmin = x0; e1->ymin = y0; @@ -165,30 +165,30 @@ range(double x0, double y0, double x1, double y1) } void -rmove(double xx, double yy) +rmove(double xx, double yy) { e1->copyx += xx; e1->copyy += yy; } void -rvec(double xx, double yy) +rvec(double xx, double yy) { vec(xx+e1->copyx, yy+e1->copyy); } void -sbox(double x0, double y0, double x1, double y1) +sbox(double x0, double y0, double x1, double y1) { fprintf(TEXFILE," \\special{bk}%%\n"); box(x0, y0, x1, y1); } void -vec(double xx, double yy) +vec(double xx, double yy) { fprintf(TEXFILE," \\special{pa %d %d}",TRX(e1->copyx),TRY(e1->copyy)); - e1->copyx = xx; + e1->copyx = xx; e1->copyy = yy; fprintf(TEXFILE,"\\special{pa %d %d}",TRX(xx),TRY(yy)); switch(e1->pen){ diff --git a/src/cmd/tr.c b/src/cmd/tr.c index 036967d6d..3b20c49bf 100644 --- a/src/cmd/tr.c +++ b/src/cmd/tr.c @@ -139,7 +139,7 @@ complement(void) writerune(1, (Rune) from); } } - + } else { while (readrune(0, &from) > 0){ if (from > high) @@ -191,7 +191,7 @@ translit(void) writerune(1, (Rune) from); } } - + } else { while (readrune(0, &from) > 0) { if (from <= high) diff --git a/src/cmd/troff/dwbinit.c b/src/cmd/troff/dwbinit.c index 064a0b027..5ecad0412 100644 --- a/src/cmd/troff/dwbinit.c +++ b/src/cmd/troff/dwbinit.c @@ -55,7 +55,7 @@ * NULL, xyzzy, sizeof(xyzzy), * NULL, NULL, 0 * }; - * + * * The last element must have NULL entries for the address and * value fields. The main() routine would then do, * @@ -300,7 +300,7 @@ void DWBprefix( char *prog, char *path, int length) * not great, but should be good enough for now. Also probably should * have DWBhome() only do the lookup once, and remember the value if * called again. - * + * */ if ( strncmp(path, DWBPREFIX, len) == 0 ) { @@ -315,4 +315,3 @@ void DWBprefix( char *prog, char *path, int length) } /* End of DWBprefix */ /*****************************************************************************/ - diff --git a/src/cmd/troff/ext.h b/src/cmd/troff/ext.h index 8df12f2c6..4c2fcf9d8 100644 --- a/src/cmd/troff/ext.h +++ b/src/cmd/troff/ext.h @@ -184,4 +184,3 @@ extern int c_isalnum; extern char *DWBfontdir; extern char *DWBntermdir; extern char *DWBalthyphens; - diff --git a/src/cmd/troff/mbwc.c b/src/cmd/troff/mbwc.c index c97b036ca..397635088 100644 --- a/src/cmd/troff/mbwc.c +++ b/src/cmd/troff/mbwc.c @@ -162,4 +162,3 @@ wcstombs(char *s, const wchar_t *pwcs, size_t n) } return p-s; } - diff --git a/src/cmd/troff/n1.c b/src/cmd/troff/n1.c index c65898cec..adda8c4b4 100644 --- a/src/cmd/troff/n1.c +++ b/src/cmd/troff/n1.c @@ -148,7 +148,7 @@ main(int argc, char *argv[]) save_tty(); break; case 'V': - fprintf(stdout, "%croff: DWB %s\n", + fprintf(stdout, "%croff: DWB %s\n", TROFF ? 't' : 'n', DWBVERSION); exit(0); case 't': @@ -436,12 +436,12 @@ Tchar getch(void) return(k); } if (k == FLSS) { - copyf++; + copyf++; raw++; i = getch0(); if (!fi) flss = i; - copyf--; + copyf--; raw--; goto g0; } @@ -456,8 +456,8 @@ Tchar getch(void) } if (k == fc || k == tabch || k == ldrch) { if ((i = setfield(k)) == 0) - goto g0; - else + goto g0; + else return(i); } if (k == '\b') { diff --git a/src/cmd/troff/n10.c b/src/cmd/troff/n10.c index b6be4c512..6f41dae23 100644 --- a/src/cmd/troff/n10.c +++ b/src/cmd/troff/n10.c @@ -319,7 +319,7 @@ void ptout1(void) j = -j; if (isvmot(i)) lead += j; - else + else esc += j; continue; } @@ -432,13 +432,13 @@ char *plot(char *x) } else if (*k & 0200) { if (*k & 0100) { if (*k & 040) - j = t.up; - else + j = t.up; + else j = t.down; } else { if (*k & 040) - j = t.left; - else + j = t.left; + else j = t.right; } if ((i = *k & 037) == 0) { /* 2nd 0200 turns it off */ @@ -447,7 +447,7 @@ char *plot(char *x) } while (i--) oputs(j); - } else + } else oput(*k); } oputs(t.plotoff); @@ -464,8 +464,8 @@ void move(void) iesct = esct; if (esct += esc) - i = "\0"; - else + i = "\0"; + else i = "\n\0"; j = t.hlf; p = t.right; @@ -492,10 +492,10 @@ void move(void) } else { /* no half-line forward, not at line begining */ k = lead / t.Newline; lead = lead % t.Newline; - if (k > 0) + if (k > 0) esc = esct; i = "\n"; - while (k--) + while (k--) oputs(i); } } diff --git a/src/cmd/troff/n2.c b/src/cmd/troff/n2.c index 2943e5530..41b2ec1e2 100644 --- a/src/cmd/troff/n2.c +++ b/src/cmd/troff/n2.c @@ -53,7 +53,7 @@ int pchar(Tchar i) return 0; } if (ismot(i)) { - pchar1(i); + pchar1(i); return 0; } switch (j = cbits(i)) { @@ -213,7 +213,7 @@ void caseex(void) } -void done(int x) +void done(int x) { int i; @@ -249,7 +249,7 @@ void done(int x) } -void done1(int x) +void done1(int x) { error |= x; if (numtabp[NL].val) { @@ -263,7 +263,7 @@ void done1(int x) } -void done2(int x) +void done2(int x) { ptlead(); if (TROFF && !ascii) @@ -272,7 +272,7 @@ void done2(int x) done3(x); } -void done3(int x) +void done3(int x) { error |= x; flusho(); @@ -284,7 +284,7 @@ void done3(int x) } -void edone(int x) +void edone(int x) { frame = stk; nxf = frame + 1; diff --git a/src/cmd/troff/n3.c b/src/cmd/troff/n3.c index 8279d7489..1c7c574f6 100644 --- a/src/cmd/troff/n3.c +++ b/src/cmd/troff/n3.c @@ -1,6 +1,6 @@ /* * troff3.c - * + * * macro and string routines, storage allocation */ @@ -137,7 +137,7 @@ void maddhash(Contab *rp) } void munhash(Contab *mp) -{ +{ Contab *p; Contab **lp; @@ -326,7 +326,7 @@ Offset finds(int mn) if (contabp[i].rq == 0) break; } - if (i == nm) + if (i == nm) growcontab(); freeslot = i + 1; if ((nextb = alloc()) == -1) { @@ -531,7 +531,7 @@ Tchar rbf(void) /* return next char from blist[] block */ else return(popi()); } - + i = rbf0(ip); if (i == 0) { if (!app) @@ -596,9 +596,9 @@ Offset pushi(Offset newip, int mname) lastpbp = pbp; pendt = ch = 0; frame = nxf; - if (nxf->nargs == 0) + if (nxf->nargs == 0) nxf += 1; - else + else nxf = (Stack *)argtop; return(ip = newip); } @@ -624,7 +624,7 @@ int getsn(void) return(0); if (i == '(') return(getrq()); - else + else return(i); } @@ -698,7 +698,7 @@ void collect(void) quote = 0; if (cbits(i = getch()) == '"') quote++; - else + else ch = i; while (1) { i = getch(); @@ -850,7 +850,7 @@ void casetl(void) if (ismot(delim = getch())) { ch = delim; delim = '\''; - } else + } else delim = cbits(delim); tp = buf; numtabp[HP].val = 0; @@ -932,7 +932,7 @@ void casepm(void) tcnt++; j = contabp[i].mx; for (k = 1; (j = blist[bindex(j)].nextoff) != -1; ) - k++; + k++; cnt++; kk += k; if (!tot) diff --git a/src/cmd/troff/n4.c b/src/cmd/troff/n4.c index a1abe943d..08e06ad36 100644 --- a/src/cmd/troff/n4.c +++ b/src/cmd/troff/n4.c @@ -123,7 +123,7 @@ void setn(void) i = ls; break; case 'R': /* maximal # of regs that can be addressed */ - i = 255*256 - regcnt; + i = 255*256 - regcnt; break; case 'z': p = unpair(dip->curd); @@ -137,7 +137,7 @@ void setn(void) cpushback(cfname[ifi]); return; case 'S': - buf[0] = j = 0; + buf[0] = j = 0; for( i = 0; tabtab[i] != 0 && i < NTAB; i++) { if (i > 0) buf[j++] = ' '; diff --git a/src/cmd/troff/n5.c b/src/cmd/troff/n5.c index 726643279..eab395fef 100644 --- a/src/cmd/troff/n5.c +++ b/src/cmd/troff/n5.c @@ -1,6 +1,6 @@ /* * troff5.c - * + * * misc processing requests */ @@ -30,16 +30,16 @@ void casead(void) case 'c': /*centered adj*/ admod = 1; break; - case 'b': + case 'b': case 'n': admod = 0; break; - case '0': - case '2': + case '0': + case '2': case '4': ad = 0; - case '1': - case '3': + case '1': + case '3': case '5': admod = (i - '0') / 2; } @@ -87,7 +87,7 @@ chget(int c) if (skip() || ismot(i = getch()) || cbits(i) == ' ' || cbits(i) == '\n') { ch = i; return(c); - } else + } else return cbits(i); /* was (i & BYTEMASK) */ } @@ -148,7 +148,7 @@ max(int aa, int bb) { if (aa > bb) return(aa); - else + else return(bb); } @@ -278,7 +278,7 @@ void casepl(void) skip(); if ((i = vnumb(&pl)) == 0) pl = 11 * INCH; /*11in*/ - else + else pl = i; if (numtabp[NL].val > pl) numtabp[NL].val = pl; @@ -321,7 +321,7 @@ void casech(void) skip(); if (!(j = getrq())) return; - else + else for (k = 0; k < NTRAP; k++) if (mlist[k] == j) break; @@ -399,7 +399,7 @@ void casefm(void) ERROR "fm: missing filename" WARN; return; } - + for (i = 0; i < 15 && fcache[i].fp != NULL; i++) { if (strcmp(nextf, fcache[i].name) == 0) break; @@ -418,7 +418,7 @@ void casefm(void) casetm1(0, fcache[i].fp); } -void casetm1(int ab, FILE *out) +void casetm1(int ab, FILE *out) { int i, j, c; char *p; @@ -444,7 +444,7 @@ void casetm1(int ab, FILE *out) trace = savtrac; } } else - skip(); + skip(); for (i = 0; i < NTM - 2; ) { if ((c = cbits(getch())) == '\n' || c == RIGHT) break; @@ -517,7 +517,7 @@ void casesp1(int a) j = vnumb((int *)0); if (nonumb) j = lss; - } else + } else j = a; if (j == 0) return; @@ -525,8 +525,8 @@ void casesp1(int a) j = i; savlss = lss; if (dip != d) - i = dip->dnl; - else + i = dip->dnl; + else i = numtabp[NL].val; if ((i + j) < 0) j = -i; @@ -542,8 +542,8 @@ void casert(void) skip(); if (dip != d) - p = &dip->dnl; - else + p = &dip->dnl; + else p = &numtabp[NL].val; a = vnumb(p); if (nonumb) @@ -594,7 +594,7 @@ void caseev(void) ERROR "cannot do .ev %d", nxev WARN; if (error) done2(040); - else + else edone(040); return; } @@ -840,7 +840,7 @@ rdtty(void) if (read(0, &onechar, 1) == 1) { if (onechar == '\n') tty++; - else + else tty = 1; if (tty != 3) return(onechar); @@ -878,7 +878,7 @@ void caseta(void) j = TABMASK; } tabtab[i] = j & TABMASK; - if (!nonumb) + if (!nonumb) switch (cbits(ch)) { case 'C': tabtab[i] |= CTAB; @@ -976,7 +976,7 @@ void caseuf(void) if (skip() || !(i = getrq()) || i == 'S' || (j = findft(i)) == -1) ulfont = ULFONT; /*default underline position*/ - else + else ulfont = j; if (NROFF && ulfont == FT) ulfont = ULFONT; @@ -1022,8 +1022,8 @@ void casemk(void) int i, j; if (dip != d) - j = dip->dnl; - else + j = dip->dnl; + else j = numtabp[NL].val; if (skip()) { dip->mkline = j; diff --git a/src/cmd/troff/n6.c b/src/cmd/troff/n6.c index 69d48f2e6..d44e67dac 100644 --- a/src/cmd/troff/n6.c +++ b/src/cmd/troff/n6.c @@ -139,7 +139,7 @@ void n_setfont(int a) if (a) i = getrq(); - else + else i = getsn(); if (!i || i == 'P') { j = font1; @@ -188,7 +188,7 @@ void n_setwd(void) k = -k; base -= k; emsz = 0; - } else + } else continue; if (base < numtabp[SB].val) numtabp[SB].val = base; @@ -300,7 +300,7 @@ void n_casebd(void) if (skip() || !(i = getrq()) || (j = findft(i)) == -1) { if (k) goto bd1; - else + else return; } if (j == smnt) { diff --git a/src/cmd/troff/n7.c b/src/cmd/troff/n7.c index 15bcfd5b0..414563c09 100644 --- a/src/cmd/troff/n7.c +++ b/src/cmd/troff/n7.c @@ -15,7 +15,7 @@ Tchar gettch(void); /* * troff7.c - * + * * text */ @@ -73,8 +73,8 @@ void tbreak(void) horiz(un); if (NROFF) { if (adrem % t.Adj) - resol = t.Hor; - else + resol = t.Hor; + else resol = t.Adj; } else resol = HOR; @@ -113,7 +113,7 @@ void tbreak(void) } if (icf) icf++; - else + else ic = 0; ne = nwd = 0; un = in; @@ -168,7 +168,7 @@ void text(void) nflush++; numtabp[HP].val = 0; if ((dip == d) && (numtabp[NL].val == -1)) { - newline(1); + newline(1); return; } setnel(); @@ -180,8 +180,8 @@ void text(void) goto t4; if (pendt) if (spcnt) - goto t2; - else + goto t2; + else goto t3; pendt++; if (spcnt) @@ -226,8 +226,8 @@ void text(void) adsp = adrem = 0; if (ad) { if (nwd == 1) - adsp = nel; - else + adsp = nel; + else adsp = nel / (nwd - 1); adsp = (adsp / HOR) * HOR; adrem = nel - adsp*(nwd-1); @@ -300,8 +300,8 @@ void callsp(void) int i; if (flss) - i = flss; - else + i = flss; + else i = lss; flss = 0; casesp1(i); @@ -379,7 +379,7 @@ void newline(int a) } if (dip->ditrap && !dip->ditf && dip->dnl >= dip->ditrap && dip->dimac) if (control(dip->dimac, 0)) { - trap++; + trap++; dip->ditf++; } return; @@ -514,7 +514,7 @@ findt1(void) if (dip != d) i = dip->dnl; - else + else i = numtabp[NL].val; return(findt(i)); } @@ -529,7 +529,7 @@ void eject(Stack *a) ejf++; if (a) ejl = a; - else + else ejl = frame; if (trap) return; diff --git a/src/cmd/troff/n8.c b/src/cmd/troff/n8.c index 9ff2ebce8..92c42724f 100644 --- a/src/cmd/troff/n8.c +++ b/src/cmd/troff/n8.c @@ -11,7 +11,7 @@ /* * troff8.c - * + * * hyphenation */ @@ -59,7 +59,7 @@ void hyphen(Tchar *wp) /* this appears to sort hyphenation points into increasing order */ *hyp++ = 0; - if (*hyptr) + if (*hyptr) for (j = 1; j; ) { j = 0; for (hyp = hyptr + 1; *hyp != 0; hyp++) { @@ -194,7 +194,7 @@ int exword(void) return(0); w = wdstart; while (*e && w <= hyend && (*e & 0177) == maplow(cbits(*w))) { - e++; + e++; w++; } if (!*e) { @@ -209,10 +209,10 @@ int exword(void) } return(1); } else { - e++; + e++; continue; } - } else + } else while (*e++) ; } @@ -249,7 +249,7 @@ suffix(void) } s = s0 + i - 1; w = hyend; - if (*s0 & HY_BIT) + if (*s0 & HY_BIT) goto mark; while (s > s0) { w--; @@ -273,7 +273,7 @@ suffix(void) int maplow(int i) { - if (isupper(i)) + if (isupper(i)) i = tolower(i); return(i); } @@ -327,7 +327,7 @@ void digram(void) val *= dilook('a', cbits(*w), bxh); else if (w == wdstart + 1) val *= dilook(cbits(*(w-1)), cbits(*w), bxxh); - else + else val *= dilook(cbits(*(w-1)), cbits(*w), xxh); val *= dilook(cbits(*w), cbits(*(w+1)), xhx); val *= dilook(cbits(*(w+1)), cbits(*(w+2)), hxx); diff --git a/src/cmd/troff/n9.c b/src/cmd/troff/n9.c index 3e3ad97f2..7c09de024 100644 --- a/src/cmd/troff/n9.c +++ b/src/cmd/troff/n9.c @@ -4,7 +4,7 @@ /* * troff9.c - * + * * misc functions */ @@ -115,7 +115,7 @@ void setov(void) } } } - else + else return; *pbp++ = makem(w[0] / 2); for (k = 0; o[k]; k++) @@ -187,7 +187,7 @@ void setvline(void) } if ((cbits(c = getch())) == delim) { c = BOXRULE | chbits; /*default box rule*/ - } else + } else getch(); c |= ZBIT; neg = 0; @@ -342,9 +342,9 @@ Tchar setfield(int x) static Tchar wbuf[] = { WORDSP, 0}; rchar = 0; - if (x == tabch) + if (x == tabch) rchar = tabc | chbits; - else if (x == ldrch) + else if (x == ldrch) rchar = dotc | chbits; temp = npad = ws = 0; savfc = fc; @@ -381,7 +381,7 @@ Tchar setfield(int x) if (pp > padptr + NPP - 1) break; goto s1; - } else if (j == savfc) + } else if (j == savfc) break; else if (j == '\n') { temp = j; @@ -435,7 +435,7 @@ Tchar setfield(int x) } if (length) jj = length | MOT; - else + else jj = getch0(); if (savepos > 0) pushback(wbuf); @@ -448,14 +448,14 @@ Tchar setfield(int x) numtabp[HP].val += jj; widthp = jj; *fp++ = ii; - if (fp > fbuf + FBUFSZ - 3) + if (fp > fbuf + FBUFSZ - 3) break; } *fp++ = ii; *fp = 0; if (type == RTAB) length -= ws; - else + else length -= ws / 2; /*CTAB*/ pushback(fbuf); if ((j = width(rchar)) != 0 && length > 0) { diff --git a/src/cmd/troff/ni.c b/src/cmd/troff/ni.c index ee09ed4a0..e12a3a08c 100644 --- a/src/cmd/troff/ni.c +++ b/src/cmd/troff/ni.c @@ -387,4 +387,3 @@ void (*ptpause)(void); void (*setfont)(int a); void (*setps)(void); void (*setwd)(void); - diff --git a/src/cmd/troff/t10.c b/src/cmd/troff/t10.c index b037bdda3..0c7725247 100644 --- a/src/cmd/troff/t10.c +++ b/src/cmd/troff/t10.c @@ -4,7 +4,7 @@ /* * troff10.c - * + * * typesetter interface */ @@ -169,7 +169,7 @@ int ptout0(Tchar *pi) j = -j; if (isvmot(i)) lead += j; - else + else esc += j; return(outsize); } @@ -191,7 +191,7 @@ int ptout0(Tchar *pi) if (sfbits(i) == oldbits) { xfont = pfont; xpts = ppts; - } else + } else xbits(i, 2); if (k == XON) { extern int xon; @@ -232,8 +232,8 @@ int ptout0(Tchar *pi) } if (iszbit(i)) { if (cs) - w = -j; - else + w = -j; + else w = 0; z = 1; } diff --git a/src/cmd/troff/t11.c b/src/cmd/troff/t11.c index f930d8b1b..9cd831c9d 100644 --- a/src/cmd/troff/t11.c +++ b/src/cmd/troff/t11.c @@ -50,7 +50,7 @@ getdesc(char *name) chadd(s, Troffchar, Install); break; } - /* else + /* else just skip anything else */ skipline(fin); } @@ -83,7 +83,7 @@ static int checkfont(char *name) } fclose(fp); return status; - + } int diff --git a/src/cmd/troff/t6.c b/src/cmd/troff/t6.c index 4a2bd0248..1e0dc9683 100644 --- a/src/cmd/troff/t6.c +++ b/src/cmd/troff/t6.c @@ -1,6 +1,6 @@ /* * t6.c - * + * * width functions, sizes and fonts */ @@ -46,7 +46,7 @@ t_width(Tchar j) if (sfbits(j) == oldbits) { xfont = pfont; xpts = ppts; - } else + } else xbits(j, 0); if (i < nchnames + ALPHABET && widcache[i].fontpts == (xfont<<8) + xpts && !setwdf) k = widcache[i].width; @@ -129,7 +129,7 @@ getcw(int i) if (setwdf) numtabp[CT].val |= fp->wp[n].kern; } else if (n == -2) { /* \N with default width */ - + k = fp->defaultwidth; } else { /* not on current font */ nocache = 1; @@ -153,8 +153,8 @@ getcw(int i) if (cs = cstab[xfont]) { nocache = 1; if (ccs = ccstab[xfont]) - x = ccs; - else + x = ccs; + else x = xpts; cs = (cs * EMPTS(x)) / 36; } @@ -247,7 +247,7 @@ Tchar t_setch(int c) return j | chbits; } else return chadd(temp, Troffchar, Install) | chbits; /* add name even if haven't seen it */ - + #endif /*UNICODE*/ } @@ -488,7 +488,7 @@ void t_setfont(int a) if (a) i = getrq(); - else + else i = getsn(); if (!i || i == 'P') { j = font1; @@ -538,7 +538,7 @@ void t_setwd(void) k = -k; base -= k; emsz = 0; - } else + } else continue; if (base < numtabp[SB].val) numtabp[SB].val = base; @@ -654,7 +654,7 @@ Tchar getlg(Tchar i) *pbp++ = k; j = LIG_FF; } - } else + } else j = LIG_FF; } else { *pbp++ = j; @@ -694,7 +694,7 @@ void casefp(void) if (i <= 0 || i > nfonts) ERROR "fp: bad font position %d", i WARN; else if (skip() || !(j = getrq())) - ERROR "fp: no font name" WARN; + ERROR "fp: no font name" WARN; else if (skip() || !getname()) setfp(i, j, (char*) 0, 1); else /* 3rd argument = filename */ @@ -745,8 +745,8 @@ setfp(int pos, int f, char *truename, int print) /* mount font f at position pos ptfont(); } if (pos == smnt) { - smnt = 0; - sbold = 0; + smnt = 0; + sbold = 0; } fontlab[pos] = f; if (smnt == 0 && fonts[pos].specfont) @@ -801,7 +801,7 @@ void casebd(void) if (skip() || !(i = getrq()) || (j = findft(i)) == -1) { if (k) goto bd1; - else + else return; } if (j == smnt) { @@ -836,7 +836,7 @@ void casevs(void) i = inumb(&lss); if (nonumb) i = lss1; - if (i < VERT) + if (i < VERT) i = VERT; lss1 = lss; lss = i; diff --git a/src/cmd/troff/tdef.h b/src/cmd/troff/tdef.h index 25c9270cc..4e6a4976f 100644 --- a/src/cmd/troff/tdef.h +++ b/src/cmd/troff/tdef.h @@ -102,7 +102,7 @@ extern char errbuf[]; /* 0 and 040 don't have any graphic or other function. /* The few that do have a purpose (e.g., \n, \b, \t, ... /* are avoided by the ad hoc choices here. -/* See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012 +/* See ifilt[] in n1.c for others -- 1, 2, 3, 5, 6, 7, 010, 011, 012 */ #define LEADER 001 @@ -189,7 +189,7 @@ extern char errbuf[]; /* 128 for parochial USA 7-bit ascii, */ /* 256 for "European" mode with e.g., Latin-1 */ - /* NCHARS must be greater than + /* NCHARS must be greater than ALPHABET (ascii stuff) + total number of distinct char names from all fonts that will be run in this job (including unnamed ones and \N's) @@ -303,13 +303,13 @@ extern Spnames spnames[]; error. In this version, the array is represented by a list of blocks, pointed to by blist[].bp. Each block is of size BLK Tchars, and BLK MUST be a power of 2 for the macros below to work. - + The blocks associated with a particular string or macro are chained together in the array blist[]. Each blist[i].nextoff contains the Offset associated with the next block in the giant array, or -1 if this is the last block in the chain. If .nextoff is 0, the block is free. - + To find the right index in blist for an Offset, divide by BLK. */ diff --git a/src/cmd/troff2html/troff2html.c b/src/cmd/troff2html/troff2html.c index 9f43946c1..d3e30db52 100644 --- a/src/cmd/troff2html/troff2html.c +++ b/src/cmd/troff2html/troff2html.c @@ -299,7 +299,7 @@ emit(Rune r) { emitul(r | attr, 0); /* - * Close man page references early, so that + * Close man page references early, so that * .IR proof (1), * doesn't make the comma part of the link. */ diff --git a/src/cmd/uniq.c b/src/cmd/uniq.c index 88fb92864..152975e02 100644 --- a/src/cmd/uniq.c +++ b/src/cmd/uniq.c @@ -160,10 +160,10 @@ skip(char *s) while(nf++ < fields) { while(*s == ' ' || *s == '\t') s++; - while(!(*s == ' ' || *s == '\t' || *s == 0) ) + while(!(*s == ' ' || *s == '\t' || *s == 0) ) s++; } - while(nl++ < letters && *s != 0) + while(nl++ < letters && *s != 0) s++; return s; } diff --git a/src/cmd/unutf.c b/src/cmd/unutf.c index 0be7aa8ea..001a5aa3b 100644 --- a/src/cmd/unutf.c +++ b/src/cmd/unutf.c @@ -1,5 +1,5 @@ /* - * stupid little program to pipe unicode chars through + * stupid little program to pipe unicode chars through * when converting to non-utf compilers. */ #include diff --git a/src/cmd/upas/bayes/addhash.c b/src/cmd/upas/bayes/addhash.c index 6be960ff6..3679b3184 100644 --- a/src/cmd/upas/bayes/addhash.c +++ b/src/cmd/upas/bayes/addhash.c @@ -57,10 +57,9 @@ main(int argc, char **argv) if(fd < 0) sysfatal("could not open %s: %r\n", out); } - + Binit(&bout, fd, OWRITE); Bwritehash(&bout, &hash); Bterm(&bout); exits(0); } - diff --git a/src/cmd/upas/bayes/dfa.c b/src/cmd/upas/bayes/dfa.c index ce4dc58a6..b038343b2 100644 --- a/src/cmd/upas/bayes/dfa.c +++ b/src/cmd/upas/bayes/dfa.c @@ -268,7 +268,7 @@ set(Deter *d, u32int **tab, Rune r) } /* - * Compute the list of important characters. + * Compute the list of important characters. * Other characters behave like the ones that surround them. */ static void @@ -672,7 +672,7 @@ main(int argc, char **argv) dp = dregcvt(p); print("=== dfa\n"); dump(dp); - + for(i=2; i */ @@ -122,7 +122,7 @@ buildre(Dreprog *re[3]) static char buf[16384], *s; re[0] = dregcomp("^From "); - + s = buf; for(i=0; ipid = rfork(RFPROC)){ default: @@ -470,7 +470,7 @@ sysnames_read(void) for(p=h->h_aliases; *p; p++) ; - + namev = malloc((2+p-h->h_aliases)*sizeof namev[0]); if(namev == 0) return 0; @@ -709,7 +709,7 @@ mboxpath(char *path, char *user, String *to, int dot) { char *dir; String *s; - + if (dot || *path=='/' || strncmp(path, "./", 2) == 0 || strncmp(path, "../", 3) == 0) { to = s_append(to, path); @@ -801,7 +801,7 @@ remoteaddr(int fd, char *dir) { char *raddr; NetConnInfo *nci; - + if((nci = getnetconninfo(dir, fd)) == nil) return nil; raddr = strdup(nci->raddr); diff --git a/src/cmd/upas/common/process.c b/src/cmd/upas/common/process.c index 56725a887..f593d551f 100644 --- a/src/cmd/upas/common/process.c +++ b/src/cmd/upas/common/process.c @@ -18,7 +18,7 @@ instream(void) return 0; } rv->fp = &rv->bb; - rv->fd = pfd[0]; + rv->fd = pfd[0]; return rv; } diff --git a/src/cmd/upas/filterkit/list.c b/src/cmd/upas/filterkit/list.c index 1913c6ded..51a50e986 100644 --- a/src/cmd/upas/filterkit/list.c +++ b/src/cmd/upas/filterkit/list.c @@ -286,7 +286,7 @@ add(char *pp, int argc, char **argv) s_free(s); } close(fd); - return nil; + return nil; } void diff --git a/src/cmd/upas/filterkit/readaddrs.c b/src/cmd/upas/filterkit/readaddrs.c index 9aadc1ab1..6ab9ed958 100644 --- a/src/cmd/upas/filterkit/readaddrs.c +++ b/src/cmd/upas/filterkit/readaddrs.c @@ -32,7 +32,7 @@ tokenize822(char *str, char **args, int max) int intok = 0, inquote = 0; if(max <= 0) - return 0; + return 0; for(na=0; ;str++) switch(*str) { case ' ': diff --git a/src/cmd/upas/filterkit/token.c b/src/cmd/upas/filterkit/token.c index 4e91e261a..86564c2b6 100644 --- a/src/cmd/upas/filterkit/token.c +++ b/src/cmd/upas/filterkit/token.c @@ -18,7 +18,7 @@ mktoken(char *key, long thetime) uchar digest[SHA1dlen]; char token[64]; String *s; - + now = ctime(thetime); memset(now+11, ':', 8); hmac_sha1((uchar*)now, strlen(now), (uchar*)key, strlen(key), digest, nil); @@ -45,7 +45,7 @@ check_token(char *key, char *file) if(i < 0) return "no match"; buf[i] = 0; - + now = time(0); for(i = 0; i < 14; i++){ diff --git a/src/cmd/upas/fs/dat.h b/src/cmd/upas/fs/dat.h index 14208ed6a..6264822dc 100644 --- a/src/cmd/upas/fs/dat.h +++ b/src/cmd/upas/fs/dat.h @@ -218,4 +218,3 @@ void henter(ulong, char*, Qid, Message*, Mailbox*); void hfree(ulong, char*); ulong msgallocd, msgfreed; - diff --git a/src/cmd/upas/fs/fs.c b/src/cmd/upas/fs/fs.c index 9fa433d8c..dc6ff3ba6 100644 --- a/src/cmd/upas/fs/fs.c +++ b/src/cmd/upas/fs/fs.c @@ -760,7 +760,7 @@ rwalk(Fid *f) for(i = 0; i < thdr.nwname; i++){ rv = dowalk(f, thdr.wname[i]); if(rv != nil){ - if(nf != nil) + if(nf != nil) rclunk(nf); break; } @@ -827,7 +827,7 @@ readtopdir(Fid* dummy, uchar *buf, long off, int cnt, int blen) cnt -= m; } pos += m; - + for(mb = mbl; mb != nil; mb = mb->next){ mkstat(&d, mb, nil, Qmbox); m = convD2M(&d, &buf[n], blen-n); @@ -872,7 +872,7 @@ readmboxdir(Fid *f, uchar *buf, long off, int cnt, int blen) } else { msg = f->mb->root->part; pos = 0; - } + } for(; cnt > 0 && msg != nil; msg = msg->next){ /* act like deleted files aren't there */ @@ -1301,7 +1301,7 @@ struct Ignorance Ignorance *ignorance; /* - * read the file of headers to ignore + * read the file of headers to ignore */ void readignore(void) diff --git a/src/cmd/upas/fs/imap4.c b/src/cmd/upas/fs/imap4.c index 48119fa77..7fcc51b5b 100644 --- a/src/cmd/upas/fs/imap4.c +++ b/src/cmd/upas/fs/imap4.c @@ -136,7 +136,7 @@ imapgrow(Imap *imap, int n) int i; if(imap->data == nil){ - imap->base = emalloc(n+1); + imap->base = emalloc(n+1); imap->data = imap->base; imap->size = n+1; } @@ -165,7 +165,7 @@ imap4resp(Imap *imap) ep = p+Blinelen(&imap->bin); while(ep > p && (ep[-1]=='\n' || ep[-1]=='\r')) *--ep = '\0'; - + if(imap->debug) fprint(2, "<- %s\n", p); strupr(p); @@ -186,7 +186,7 @@ imap4resp(Imap *imap) if(*p==' ') p++; verb = p; - + if(p = strchr(verb, ' ')) p++; else @@ -221,7 +221,7 @@ imap4resp(Imap *imap) /* <3031 bytes of data> */ /* ) */ if(strstr(p, "RFC822.SIZE") && strstr(p, "BODY[]")){ - if((q = strchr(p, '{')) + if((q = strchr(p, '{')) && (n=strtol(q+1, &en, 0), *en=='}')){ if(imap->data == nil || n >= imap->size) imapgrow(imap, n); @@ -268,7 +268,7 @@ imap4resp(Imap *imap) /* ) */ /* * 1 FETCH (UID 1 RFC822.HEADER "data") */ if(strstr(p, "RFC822.HEADER") || strstr(p, "RFC822.TEXT")){ - if((q = strchr(p, '{')) + if((q = strchr(p, '{')) && (n=strtol(q+1, &en, 0), *en=='}')){ if(imap->data == nil || n >= imap->size) imapgrow(imap, n); diff --git a/src/cmd/upas/fs/mbox.c b/src/cmd/upas/fs/mbox.c index 2f4837473..b77306d6c 100644 --- a/src/cmd/upas/fs/mbox.c +++ b/src/cmd/upas/fs/mbox.c @@ -721,7 +721,7 @@ ctype(Message *m, Header *h, char *p) p = skipwhite(p); p = getstring(p, m->type, 1); - + while(*p){ if(isattribute(&p, "boundary")){ s = s_new(); @@ -741,7 +741,7 @@ ctype(Message *m, Header *h, char *p) } else if(isattribute(&p, "charset")){ p = getstring(p, s_reset(m->charset), 0); } - + p = skiptosemi(p); } } @@ -1598,4 +1598,3 @@ date822tounix(char *s) *q = '\0'; return s_copy(p); } - diff --git a/src/cmd/upas/fs/pop3.c b/src/cmd/upas/fs/pop3.c index da8021dd2..d41d2b482 100644 --- a/src/cmd/upas/fs/pop3.c +++ b/src/cmd/upas/fs/pop3.c @@ -506,7 +506,7 @@ pop3read(Pop *pop, Mailbox *mb, int doplumb) (Qid){PATH(mb->id, Qmbox), mb->vers, QTDIR}, nil, mb); } - return nil; + return nil; } /* */ @@ -695,4 +695,3 @@ pop3mbox(Mailbox *mb, char *path) return nil; } - diff --git a/src/cmd/upas/fs/strtotm.c b/src/cmd/upas/fs/strtotm.c index bcf0bcee0..09a7914d4 100644 --- a/src/cmd/upas/fs/strtotm.c +++ b/src/cmd/upas/fs/strtotm.c @@ -20,7 +20,7 @@ skipwhite(char *q) static char* months[] = { "jan", "feb", "mar", "apr", - "may", "jun", "jul", "aug", + "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; @@ -81,7 +81,7 @@ strtotm(char *p, Tm *tmp) continue; /* look for time zone [A-Z][A-Z]T */ - if(q-p==3 && 'A' <= p[0] && p[0] <= 'Z' + if(q-p==3 && 'A' <= p[0] && p[0] <= 'Z' && 'A' <= p[1] && p[1] <= 'Z' && p[2] == 'T'){ strecpy(tm.zone, tm.zone+4, p); continue; diff --git a/src/cmd/upas/fs/tester.c b/src/cmd/upas/fs/tester.c index 3d24012ef..30c15b312 100644 --- a/src/cmd/upas/fs/tester.c +++ b/src/cmd/upas/fs/tester.c @@ -51,7 +51,7 @@ info(int indent, int mno, Message *m) info(indent+1, i++, nm); } } - + void main(int argc, char **argv) diff --git a/src/cmd/upas/marshal/marshal.c b/src/cmd/upas/marshal/marshal.c index 8ebd3957a..e83328e94 100644 --- a/src/cmd/upas/marshal/marshal.c +++ b/src/cmd/upas/marshal/marshal.c @@ -334,7 +334,7 @@ threadmain(int argc, char **argv) close(fd); threadexitsall(waitforsubprocs()); } - + if(Binit(&out, fd, OWRITE) < 0) fatal("can't Binit 1: %r"); @@ -689,7 +689,7 @@ attachment(Attach *a, Biobuf *out) free(f); return; } - + /* if it's not already mime encoded ... */ if(strcmp(a->type, "text/plain") != 0) Bprint(out, "Content-Type: %s\n", a->type); @@ -822,7 +822,7 @@ int mopen(char *file, int mode) { int fd; - + if((fd = open(file, mode)) >= 0) return fd; if(strncmp(file, "Mail/", 5) == 0 && mountmail() >= 0 && (fd = fsopenfd(mailfs, file+5, mode)) >= 0) @@ -890,7 +890,7 @@ mkattach(char *file, char *type, int inline) a->type = "application/octet-stream"; /* safest default */ if(pipe(pfd) < 0) return a; - + xfd[0] = mopen(file, OREAD); xfd[1] = pfd[0]; xfd[2] = dup(2, -1); @@ -955,7 +955,7 @@ static void teeproc(void *v) { int *a; - + a = v; tee(a[0], a[1], a[2]); write(a[2], "\n", 1); @@ -1094,7 +1094,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) if(pipe(pfd) < 0) fatal("pipe: %r"); - + xfd[0] = pfd[0]; xfd[1] = dup(1, -1); xfd[2] = dup(2, -1); @@ -1122,7 +1122,7 @@ sendmail(Addr *to, Addr *cc, int *pid, char *rcvr) proccreate(teeproc, targ, STACK); sfd = pfd[1]; } - + return sfd; } @@ -1348,7 +1348,7 @@ readaliases(void) addr->next = 0; *al = addr; al = &addr->next; - } + } if(a->addr == nil || a->addr->next == nil){ freealias(a); continue; @@ -1592,7 +1592,7 @@ get822token(String **tok, char *p, char **pp) type = Twords; quoting = 0; for(; *p && (quoting || (!ISWHITE(*p) && *p != '>' && *p != '<' && *p != ',')); p++) { - if(*p == '"') + if(*p == '"') quoting = !quoting; if(*p == '\\') { if(*(p+1) == '\0') { @@ -1609,7 +1609,7 @@ get822token(String **tok, char *p, char **pp) *pp = p; *tok = s_copyn(op, p-op); return type; -} +} /* expand local aliases in an RFC822 mail line */ /* add list of expanded addresses to to. */ @@ -1717,7 +1717,7 @@ expandline(String **s, Addr *to) nto = nil; werrstr("rfc822 syntax error"); rfc822syntaxerror = 1; - goto Break2; + goto Break2; } } Break2: @@ -1893,7 +1893,7 @@ rfc2047fmt(Fmt *fmt) fmtprint(fmt, "=%.2uX", (uchar)*p); else fmtrune(fmt, (uchar)*p); - } + } fmtprint(fmt, "?="); return 0; } diff --git a/src/cmd/upas/misc/mail.c b/src/cmd/upas/misc/mail.c index 20cf23970..bf2cff561 100644 --- a/src/cmd/upas/misc/mail.c +++ b/src/cmd/upas/misc/mail.c @@ -48,4 +48,3 @@ main (argc, argv) perror (realprog); exit (1); } - diff --git a/src/cmd/upas/ml/common.c b/src/cmd/upas/ml/common.c index 307a49255..c389d6396 100644 --- a/src/cmd/upas/ml/common.c +++ b/src/cmd/upas/ml/common.c @@ -185,7 +185,7 @@ sendnotification(char *addr, char *listname, int rem) fprint(pfd[1], "the word 'remove' in the subject or body.\n"); } close(pfd[1]); - + /* wait for mailer to end */ while(w = wait()){ if(w->msg != nil && w->msg[0]) diff --git a/src/cmd/upas/ml/ml.c b/src/cmd/upas/ml/ml.c index 8dad05179..a135b0511 100644 --- a/src/cmd/upas/ml/ml.c +++ b/src/cmd/upas/ml/ml.c @@ -56,7 +56,7 @@ main(int argc, char **argv) if(s_read_line(&in, firstline) == nil) sysfatal("reading input: %r"); - /* read up to the first 128k of the message. more is redculous. + /* read up to the first 128k of the message. more is redculous. Not if word documents are distributed. Upped it to 2MB (pb) */ if(s_read(&in, msg, 2*1024*1024) <= 0) sysfatal("reading input: %r"); diff --git a/src/cmd/upas/ned/nedmail.c b/src/cmd/upas/ned/nedmail.c index ef0f731c8..6acd73e4e 100644 --- a/src/cmd/upas/ned/nedmail.c +++ b/src/cmd/upas/ned/nedmail.c @@ -212,7 +212,7 @@ plural(int n) if (n == 1) return ""; - return "s"; + return "s"; } void @@ -366,7 +366,7 @@ mkaddrs(char *t) int i, nf, inquote; char **f, *s; Fmt fmt; - + inquote = 0; nf = 2; for(s=t; *s; s++){ @@ -402,7 +402,7 @@ file2message(Message *parent, char *name) String *path; char *f[30], *s, *t; int i, nf; - + m = mallocz(sizeof(Message), 1); if(m == nil) return nil; @@ -425,7 +425,7 @@ file2message(Message *parent, char *name) if(t == nil) continue; *t++ = 0; - + if(strcmp(s, "from") == 0) m->from = mkaddrs(t); else if(strcmp(s, "to") == 0) @@ -475,7 +475,7 @@ dir2message(Message *parent, int reverse) { int i, n, highest, newmsgs; CFid *fd; - + Dir *d; Message *first, *last, *m; @@ -972,7 +972,7 @@ parseaddr(char **pp, Message *first, Message *cur, Message *unspec, Message **mp goto number; } *mp = unspec; - break; + break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = strtoul(p, pp, 10); @@ -1191,7 +1191,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) free(prog); } } else { - + /* parse an address */ s = e = nil; err = parseaddr(&p, first, cur, cur, &s); @@ -1207,7 +1207,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) err = parseaddr(&p, first, cur, last, &e); if(err != nil) return err; - + /* select all messages in the range */ for(; s != nil; s = s->next){ *l = s; @@ -1258,7 +1258,7 @@ parsecmd(char *p, Cmd *cmd, Message *first, Message *cur) } cmd->f = cmdtab[i].f; } - return nil; + return nil; } /* inefficient read from standard input */ @@ -1511,7 +1511,7 @@ pcmd(Cmd *x, Message *m) Bprint(&out, "\n!--- using plumber to display message of type %s\n", m->type); else Bprint(&out, "\n!--- cannot display messages of type %s\n", m->type); - + return m; } @@ -1684,7 +1684,7 @@ Message* ycmd(Cmd *x, Message *m) { USED(x); - + doflush = 1; return icmd(nil, m); @@ -1839,7 +1839,7 @@ tokenize822(char *str, char **args, int max) int intok = 0, inquote = 0; if(max <= 0) - return 0; + return 0; for(na=0; ;str++) switch(*str) { case ' ': @@ -2452,9 +2452,9 @@ switchmb(char *file, char *singleton) fd = open("/mail/fs/ctl", ORDWR); if(fd < 0) sysfatal("can't open /mail/fs/ctl: %r"); - + path = s_new(); - + /* get an absolute path to the mail box */ if(strncmp(file, "./", 2) == 0){ /* resolve path here since upas/fs doesn't know */ @@ -2468,7 +2468,7 @@ switchmb(char *file, char *singleton) } else { mboxpath(file, user, path, 0); } - + /* make up a handle to use when talking to fs */ p = strrchr(file, '/'); if(p == nil){ diff --git a/src/cmd/upas/nfs/box.c b/src/cmd/upas/nfs/box.c index 202111f8e..a3525f0f3 100644 --- a/src/cmd/upas/nfs/box.c +++ b/src/cmd/upas/nfs/box.c @@ -30,7 +30,7 @@ Box* subbox(Box *b, char *elem) { int i; - + for(i=0; insub; i++) if(b->sub[i] && strcmp(b->sub[i]->elem, elem) == 0) return b->sub[i]; @@ -41,7 +41,7 @@ Box* boxbyid(uint id) { int i; - + /* LATER: replace with binary search */ for(i=0; iid == id) @@ -54,10 +54,10 @@ boxcreate(char *name) { char *p; Box *b, *bb; - + if((b = boxbyname(name)) != nil) return b; - + b = emalloc(sizeof *b); b->id = ++boxid; b->time = time(0); @@ -87,7 +87,7 @@ void boxfree(Box *b) { int i; - + if(b == nil) return; for(i=0; inmsg; i++) @@ -100,12 +100,12 @@ Part* partcreate(Msg *m, Part *pp) { Part *p; - + if(m->npart%PartChunk == 0) m->part = erealloc(m->part, (m->npart+PartChunk)*sizeof m->part[0]); p = emalloc(sizeof *p); p->msg = m; - p->ix = m->npart; + p->ix = m->npart; m->part[m->npart++] = p; if(pp){ if(pp->nsub%PartSubChunk == 0) @@ -121,7 +121,7 @@ void partfree(Part *p) { int i; - + if(p == nil) return; for(i=0; insub; i++) @@ -145,7 +145,7 @@ void msgfree(Msg *m) { int i; - + if(m == nil) return; for(i=0; inpart; i++) @@ -162,7 +162,7 @@ msgplumb(Msg *m, int delete) Plumbattr a[10]; char buf[256], date[40]; int ai; - + if(m == nil || m->npart < 1 || m->part[0]->hdr == nil) return; if(m->box && strcmp(m->box->name, "mbox") != 0) @@ -176,7 +176,7 @@ msgplumb(Msg *m, int delete) ai = 0; a[ai].name = "filetype"; a[ai].value = "mail"; - + a[++ai].name = "mailtype"; a[ai].value = delete?"delete":"new"; a[ai-1].next = &a[ai]; @@ -198,15 +198,15 @@ msgplumb(Msg *m, int delete) a[ai].value = m->part[0]->hdr->digest; a[ai-1].next = &a[ai]; } - + strcpy(date, ctime(m->date)); date[strlen(date)-1] = 0; /* newline */ a[++ai].name = "date"; a[ai].value = date; a[ai-1].next = &a[ai]; - + a[ai].next = nil; - + p.attr = a; #ifdef PLAN9PORT snprint(buf, sizeof buf, "Mail/%s/%ud", m->box->name, m->id); @@ -215,7 +215,7 @@ msgplumb(Msg *m, int delete) #endif p.ndata = strlen(buf); p.data = buf; - + if(fd < 0) fd = plumbopen("send", OWRITE); if(fd < 0) @@ -229,7 +229,7 @@ Msg* msgcreate(Box *box) { Msg *m; - + m = emalloc(sizeof *m); m->box = box; partcreate(m, nil); @@ -319,4 +319,3 @@ boxinit(void) rootbox->name = estrdup(""); rootbox->time = time(0); } - diff --git a/src/cmd/upas/nfs/box.h b/src/cmd/upas/nfs/box.h index 9ca3b8f9e..bbb3851e2 100644 --- a/src/cmd/upas/nfs/box.h +++ b/src/cmd/upas/nfs/box.h @@ -31,7 +31,7 @@ struct Box Msg** msg; /* array of messages (can have nils) */ uint nmsg; - + char* imapname; /* name on IMAP server */ u32int validity; /* IMAP validity number */ uint uidnext; /* IMAP expected next uid */ @@ -73,7 +73,7 @@ struct Msg uint flags; /* FlagDeleted etc. */ uint date; /* smtp envelope date */ uint size; - + Part** part; /* message subparts - part[0] is root */ uint npart; }; @@ -132,4 +132,3 @@ extern Box** boxes; extern uint nboxes; extern Box* rootbox; - diff --git a/src/cmd/upas/nfs/decode.c b/src/cmd/upas/nfs/decode.c index 3f8c4c681..0ad78ec4b 100644 --- a/src/cmd/upas/nfs/decode.c +++ b/src/cmd/upas/nfs/decode.c @@ -25,7 +25,7 @@ _decqp(uchar *out, int lim, char *in, int n, int underscores) { char *p, *ep; uchar *eout, *out0; - + out0 = out; eout = out+lim; for(p=in, ep=in+n; pfd, w->s, strlen(w->s)); close(w->fd); @@ -216,13 +216,13 @@ unrfc2047(char *s) int len; Rune r; Fmt fmt; - + if(s == nil) return nil; if(strstr(s, "=?") == nil) return s; - + fmtstrinit(&fmt); for(p=s; *p; ){ /* =?charset?e?text?= */ @@ -270,7 +270,7 @@ unrfc2047(char *s) } #ifdef TEST -char *test[] = +char *test[] = { "hello world", "hello =?iso-8859-1?q?this is some text?=", @@ -288,7 +288,7 @@ void threadmain(int argc, char **argv) { int i; - + for(i=0; iqid, &box, &msg, &part)){ case Qroot: if(strcmp(name, "..") == 0) @@ -347,7 +347,7 @@ addaddrs(Fmt *fmt, char *prefix, char *addrs) char **f; int i, nf, inquote; char *p, *sep; - + if(addrs == nil) return; addrs = estrdup(addrs); @@ -409,7 +409,7 @@ mkbody(Part *p, Qid q) } static Qid ZQ; - + static int filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *freeme, int force, Qid q) { @@ -444,7 +444,7 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre } *pp = ((char**)&part->hdr->date)[type-Qdate]; return 0; - + case Qunixdate: strcpy(buf, ctime(msg->date)); *pp = buf; @@ -630,7 +630,7 @@ filedata(int type, Box *box, Msg *msg, Part *part, char **pp, int *len, int *fre if(part->hdr->from==nil || (part->hdr->sender && strcmp(part->hdr->sender, part->hdr->from) != 0)) addaddrs(&fmt, "Sender", part->hdr->sender); - if(part->hdr->from==nil + if(part->hdr->from==nil || (part->hdr->replyto && strcmp(part->hdr->replyto, part->hdr->from) != 0)) addaddrs(&fmt, "Reply-To", part->hdr->replyto); fmtprint(&fmt, "Subject: %s\n", part->hdr->subject); @@ -681,7 +681,7 @@ filldir(Dir *d, int type, Box *box, Msg *msg, Part *part) case Qsearch: d->mode = 0666; break; - + case Qflags: d->mode = 0666; goto msgfile; @@ -736,7 +736,7 @@ filldir(Dir *d, int type, Box *box, Msg *msg, Part *part) } return 0; } - + static void fsstat(Req *r) { @@ -744,7 +744,7 @@ fsstat(Req *r) Box *box; Msg *msg; Part *part; - + type = parseqid(r->fid->qid, &box, &msg, &part); if(filldir(&r->d, type, box, msg, part) < 0) responderror(r); @@ -756,7 +756,7 @@ int rootgen(int i, Dir *d, void *aux) { USED(aux); - + if(i == 0) return filldir(d, Qctl, nil, nil, nil); i--; @@ -786,17 +786,17 @@ boxgen(int i, Dir *d, void *aux) } static int msgdir[] = { - Qtype, - Qbody, Qbcc, Qcc, Qdate, Qflags, Qfrom, Qheader, Qinfo, - Qinreplyto, Qlines, Qmimeheader, Qmessageid, + Qtype, + Qbody, Qbcc, Qcc, Qdate, Qflags, Qfrom, Qheader, Qinfo, + Qinreplyto, Qlines, Qmimeheader, Qmessageid, Qraw, Qrawunix, Qrawbody, Qrawheader, Qreplyto, Qsender, Qsubject, Qto, Qunixdate, Qunixheader }; static int mimemsgdir[] = { - Qtype, - Qbody, Qbcc, Qcc, Qdate, Qfrom, Qheader, Qinfo, - Qinreplyto, Qlines, Qmimeheader, Qmessageid, + Qtype, + Qbody, Qbcc, Qcc, Qdate, Qfrom, Qheader, Qinfo, + Qinreplyto, Qlines, Qmimeheader, Qmessageid, Qraw, Qrawunix, Qrawbody, Qrawheader, Qreplyto, Qsender, Qsubject, Qto }; @@ -808,14 +808,14 @@ static int mimedir[] = { Qmimeheader, Qraw }; - + int msggen(int i, Dir *d, void *aux) { Box *box; Msg *msg; Part *part; - + part = aux; msg = part->msg; box = msg->box; @@ -875,7 +875,7 @@ fsread(Req *r) Box *box; Msg *msg; Part *part; - + switch(type = parseqid(r->fid->qid, &box, &msg, &part)){ case Qroot: dirread9p(r, rootgen, nil); @@ -906,7 +906,7 @@ fsread(Req *r) dirread9p(r, msggen, part); respond(r, nil); return; - + case Qctl: case Qboxctl: respond(r, Egreg); @@ -937,7 +937,7 @@ mkmsglist(Box *box, char **f, int nf, Msg ***mm) { int i, nm; Msg **m; - + m = emalloc(nf*sizeof m[0]); nm = 0; for(i=0; iifcall.type){ case Tread: @@ -1255,10 +1255,9 @@ fsinit0(void) /* bad planning - clash with lib9pclient */ fs.write = fssend; fs.stat = fssend; fs.destroyfid = fsdestroyfid; - + rootqid = qid(Qroot, nil, nil, nil); - + fsreqchan = chancreate(sizeof(void*), 0); mailthread(fsrecv, nil); } - diff --git a/src/cmd/upas/nfs/imap.c b/src/cmd/upas/nfs/imap.c index ef76487b5..5249e2e78 100644 --- a/src/cmd/upas/nfs/imap.c +++ b/src/cmd/upas/nfs/imap.c @@ -41,7 +41,7 @@ struct Imap static struct { char *name; int flag; -} flagstab[] = +} flagstab[] = { "Junk", FlagJunk, "NonJunk", FlagNonJunk, @@ -116,20 +116,20 @@ imapconnect(char *server, int mode, char *root, char *user) z->fd = -1; z->autoreconnect = 0; z->io = ioproc(); - + qlock(&z->lk); if(imapreconnect(z) < 0){ free(z); return nil; } - + z->r.l = &z->rlk; z->autoreconnect = 1; qunlock(&z->lk); - + proccreate(imaptimerproc, z, STACK); mailthread(imaprefreshthread, z); - + return z; } @@ -231,7 +231,7 @@ getboxes(Imap *z) { int i; Box **r, **w, **e; - + for(i=0; imark = 1; boxes[i]->exists = 0; @@ -260,10 +260,10 @@ getbox(Imap *z, Box *b) { int i; Msg **r, **w, **e; - + if(b == nil) return 0; - + for(i=0; inmsg; i++) b->msg[i]->imapid = 0; if(imapcmd(z, b, "UID FETCH 1:* FLAGS") < 0) @@ -294,7 +294,7 @@ static void imaptimerproc(void *v) { Imap *z; - + z = v; for(;;){ sleep(60*1000); @@ -323,13 +323,13 @@ static void imaprefreshthread(void *v) { Imap *z; - + z = v; for(;;){ qlock(z->r.l); rsleep(&z->r); qunlock(z->r.l); - + qlock(&z->lk); if(z->inbox) checkbox(z, z->inbox); @@ -347,7 +347,7 @@ imapvcmdsx0(Imap *z, char *fmt, va_list arg, int dotag) Fmt f; int len; Sx *sx; - + if(canqlock(&z->lk)) abort(); @@ -380,7 +380,7 @@ imapcmdsx0(Imap *z, char *fmt, ...) { va_list arg; Sx *sx; - + va_start(arg, fmt); sx = imapvcmdsx0(z, fmt, arg, 1); va_end(arg); @@ -395,7 +395,7 @@ imapvcmdsx(Imap *z, Box *b, char *fmt, va_list arg, int dotag) { int tries; Sx *sx; - + tries = 0; z->nextbox = b; @@ -478,7 +478,7 @@ static Sx* imapwaitsx(Imap *z) { Sx *sx; - + while((sx = zBrdsx(z)) != nil){ if(chattyimap) fprint(2, "<| %#$\n", sx); @@ -534,7 +534,7 @@ static void fetch1(Imap *z, Part *p, char *s) { qlock(&z->lk); - imapcmd(z, p->msg->box, "UID FETCH %d BODY[%s]", + imapcmd(z, p->msg->box, "UID FETCH %d BODY[%s]", p->msg->imapuid, bodyname(p, s)); qunlock(&z->lk); } @@ -569,7 +569,7 @@ imaplistcmd(Imap *z, Box *box, char *before, Msg **m, uint nm, char *after) int i, r; char *cmd; Fmt fmt; - + if(nm == 0) return 0; @@ -582,7 +582,7 @@ imaplistcmd(Imap *z, Box *box, char *before, Msg **m, uint nm, char *after) } fmtprint(&fmt, " %s", after); cmd = fmtstrflush(&fmt); - + r = 0; if(imapcmd(z, box, "%s", cmd) < 0) r = -1; @@ -595,7 +595,7 @@ imapcopylist(Imap *z, char *nbox, Msg **m, uint nm) { int rv; char *name, *p; - + if(nm == 0) return 0; @@ -617,7 +617,7 @@ int imapremovelist(Imap *z, Msg **m, uint nm) { int rv; - + if(nm == 0) return 0; @@ -636,7 +636,7 @@ imapflaglist(Imap *z, int op, int flag, Msg **m, uint nm) char *mod, *s, *sep; int i, rv; Fmt fmt; - + if(op > 0) mod = "+"; else if(op == 0) @@ -655,7 +655,7 @@ imapflaglist(Imap *z, int op, int flag, Msg **m, uint nm) } fmtprint(&fmt, ")"); s = fmtstrflush(&fmt); - + qlock(&z->lk); rv = imaplistcmd(z, m[0]->box, "UID STORE", m, nm, s); qunlock(&z->lk); @@ -726,7 +726,7 @@ _ioimapdial(va_list *arg) { char *server; int mode; - + server = va_arg(*arg, char*); mode = va_arg(*arg, int); return imapdial(server, mode); @@ -742,7 +742,7 @@ _ioBrdsx(va_list *arg) { Biobuf *b; Sx **sx; - + b = va_arg(*arg, Biobuf*); sx = va_arg(*arg, Sx**); *sx = Brdsx(b); @@ -779,12 +779,12 @@ imapdial(char *server, int mode) int fd[3]; char *tmp; char *fpath; - + switch(mode){ default: case Unencrypted: return dial(netmkaddr(server, "tcp", "143"), nil, nil, nil); - + case Starttls: werrstr("starttls not supported"); return -1; @@ -818,7 +818,7 @@ imapdial(char *server, int mode) free(tmp); close(p[0]); return p[1]; - + case Cmd: if(pipe(p) < 0) return -1; @@ -912,7 +912,7 @@ static int sxmatch(Sx *sx, char *fmt) { int i; - + for(i=0; fmt[i]; i++){ if(fmt[i] == '*') fmt--; /* like i-- but better */ @@ -994,7 +994,7 @@ static int isatom(Sx *v, char *name) { int n; - + if(v == nil || v->type != SxAtom) return 0; n = strlen(name); @@ -1021,7 +1021,7 @@ isnumber(Sx *sx) static int isnil(Sx *v) { - return v == nil || + return v == nil || (v->type==SxList && v->nsx == 0) || (v->type==SxAtom && strcmp(v->data, "NIL") == 0); } @@ -1036,7 +1036,7 @@ static uint parseflags(Sx *v) { int f, i, j; - + if(v->type != SxList){ warn("malformed flags: %$", v); return 0; @@ -1051,13 +1051,13 @@ parseflags(Sx *v) } return f; } - + static char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; static int parsemon(char *s) { int i; - + for(i=0; months[i]; i+=3) if(memcmp(s, months+i, 3) == 0) return i/3; @@ -1071,13 +1071,13 @@ parsedate(Sx *v) uint t; int delta; char *p; - + if(v->type != SxString || !stringmatch("01-Aaa-1111 01:11:11 +1111", v->data)){ bad: warn("bad date: %$", v); return 0; } - + /* cannot use atoi because 09 is malformed octal! */ memset(&tm, 0, sizeof tm); p = v->data; @@ -1095,7 +1095,7 @@ parsedate(Sx *v) delta = ((p[22]-'0')*10+p[23]-'0')*3600 + ((p[24]-'0')*10+p[25]-'0')*60; if(p[21] == '-') delta = -delta; - + t -= delta; return t; } @@ -1123,7 +1123,7 @@ parseenvelope(Sx *v) Hdr *hdr; uchar digest[16]; DigestState ds; - + if(v->type != SxList || !sxmatch(v, "SSLLLLLLSS")){ warn("bad envelope: %$", v); return nil; @@ -1140,7 +1140,7 @@ parseenvelope(Sx *v) hdr->bcc = copyaddrs(v->sx[7]); hdr->inreplyto = unrfc2047(nstring(v->sx[8])); hdr->messageid = unrfc2047(nstring(v->sx[9])); - + memset(&ds, 0, sizeof ds); hash(&ds, "date", hdr->date); hash(&ds, "subject", hdr->subject); @@ -1162,7 +1162,7 @@ static void strlwr(char *s) { char *t; - + if(s == nil) return; for(t=s; *t; t++) @@ -1174,7 +1174,7 @@ static void nocr(char *s) { char *r, *w; - + if(s == nil) return; for(r=w=s; *r; r++) @@ -1191,7 +1191,7 @@ gsub(char *s, char *a, char *b) { char *p, *t, *w, *last; int n; - + n = 0; for(p=s; (p=strstr(p, a)) != nil; p+=strlen(a)) n++; @@ -1256,7 +1256,7 @@ unexpected(Imap *z, Sx *sx) name = sx->sx[1]->data; }else return; - + for(i=0; isx[2] the list of flags * that can be validly attached to messages in z->box. - * We don't have any use for this list, since we + * We don't have any use for this list, since we * use only the standard flags. */ } @@ -1396,7 +1396,7 @@ static void xsearch(Imap *z, Sx *sx) { int i; - + free(z->uid); z->uid = emalloc((sx->nsx-2)*sizeof z->uid[0]); z->nuid = sx->nsx-2; @@ -1404,7 +1404,7 @@ xsearch(Imap *z, Sx *sx) z->uid[i] = sx->sx[i+2]->number; } -/* +/* * Table-driven FETCH message info parser. */ static void xmsgflags(Msg*, Sx*, Sx*); @@ -1496,7 +1496,7 @@ static char* nstring(Sx *v) { char *p; - + if(isnil(v)) return estrdup(""); p = v->data; @@ -1511,7 +1511,7 @@ copyaddrs(Sx *v) char *name, *email, *host, *mbox; int i; Fmt fmt; - + if(v->nsx == 0) return nil; @@ -1565,7 +1565,7 @@ parseparams(Part *part, Sx *v) { int i, j; char *s, *t, **p; - + if(isnil(v)) return; if(v->nsx%2){ @@ -1586,7 +1586,7 @@ parseparams(Part *part, Sx *v) } free(s); free(t); - } + } } static void @@ -1594,7 +1594,7 @@ parsestructure(Part *part, Sx *v) { int i; char *s, *t; - + if(isnil(v)) return; if(v->type != SxList){ @@ -1627,7 +1627,7 @@ parsestructure(Part *part, Sx *v) strlwr(t); free(part->type); part->type = esmprint("%s/%s", s, t); - if(v->nsx < 7 || !islist(v->sx[2]) || !isstring(v->sx[3]) + if(v->nsx < 7 || !islist(v->sx[2]) || !isstring(v->sx[3]) || !isstring(v->sx[4]) || !isstring(v->sx[5]) || !isnumber(v->sx[6])) goto bad; parseparams(part, v->sx[2]); @@ -1676,13 +1676,13 @@ xmsgbodydata(Msg *msg, Sx *k, Sx *v) int i; char *name, *p; Part *part; - + name = k->data; name += 5; /* body[ */ p = strchr(name, ']'); if(p) *p = 0; - + /* now name is something like 1 or 3.2.MIME - walk down parts from root */ part = msg->part[0]; @@ -1777,7 +1777,7 @@ xokuidvalidity(Imap *z, Sx *sx) { int i; Box *b; - + if((b=z->box) == nil) return; if(b->validity != sx->number){ @@ -1822,4 +1822,3 @@ xokreadonly(Imap *z, Sx *sx) USED(sx); /* z->boxmode = OREAD; */ } - diff --git a/src/cmd/upas/nfs/main.c b/src/cmd/upas/nfs/main.c index ebcf701ca..c72a48494 100644 --- a/src/cmd/upas/nfs/main.c +++ b/src/cmd/upas/nfs/main.c @@ -67,13 +67,13 @@ threadmain(int argc, char **argv) break; }ARGEND - quotefmtinstall(); + quotefmtinstall(); fmtinstall('$', sxfmt); if(argc != 1) usage(); server = argv[0]; - + mailthreadinit(); boxinit(); fsinit0(); @@ -82,4 +82,3 @@ threadmain(int argc, char **argv) sysfatal("imapconnect: %r"); threadpostmountsrv(&fs, srvname, mtpt, 0); } - diff --git a/src/cmd/upas/nfs/mbox.c b/src/cmd/upas/nfs/mbox.c index 5f90f0a21..1b60ffa61 100644 --- a/src/cmd/upas/nfs/mbox.c +++ b/src/cmd/upas/nfs/mbox.c @@ -8,7 +8,7 @@ static void markboxes(int mark) { Mailbox *b; - + for(i=0; imark = mark; @@ -18,7 +18,7 @@ static void sweepboxes(void) { Mailbox *b; - + for(i=0; imark){ freembox(box[i]); @@ -30,7 +30,7 @@ static Mailbox* mboxbyname(char *name) { int i; - + for(i=0; iname, name) == 0) return box[i]; @@ -49,7 +49,7 @@ static Mailbox* mboxcreate(char *name) { Mailbox *b; - + b = emalloc(sizeof *b); b->name = estrdup(name); if(nbox%64 == 0) diff --git a/src/cmd/upas/nfs/msg.c b/src/cmd/upas/nfs/msg.c index f4a268629..622841a6c 100644 --- a/src/cmd/upas/nfs/msg.c +++ b/src/cmd/upas/nfs/msg.c @@ -6,4 +6,3 @@ cache flushes optionally to disk before being tossed out reload from disk, then from server - diff --git a/src/cmd/upas/nfs/sx.c b/src/cmd/upas/nfs/sx.c index 65d338c21..55e2934e7 100644 --- a/src/cmd/upas/nfs/sx.c +++ b/src/cmd/upas/nfs/sx.c @@ -7,7 +7,7 @@ Brdsx(Biobuf *b) { Sx **sx, *x; int nsx; - + nsx = 0; sx = nil; while((x = Brdsx1(b)) != nil){ @@ -21,11 +21,11 @@ Brdsx(Biobuf *b) return x; } -int +int sxwalk(Sx *sx) { int i, n; - + if(sx == nil) return 1; switch(sx->type){ @@ -46,7 +46,7 @@ void freesx(Sx *sx) { int i; - + if(sx == nil) return; switch(sx->type){ @@ -70,7 +70,7 @@ Brdsx1(Biobuf *b) char *s; vlong n; Sx *x; - + c = Bgetc(b); if(c == ' ') c = Bgetc(b); @@ -144,7 +144,7 @@ Brdsx1(Biobuf *b) s = emalloc(1); s[0] = c; nbr = 0; - while((c = Bgetc(b)) >= 0 && c > ' ' && !strchr("(){}", c)){ + while((c = Bgetc(b)) >= 0 && c > ' ' && !strchr("(){}", c)){ /* allow embedded brackets as in BODY[] */ if(c == '['){ if(s[0] == '[') @@ -169,7 +169,7 @@ Brdsx1(Biobuf *b) x->type = SxAtom; x->data = s; x->ndata = len; - return x; + return x; } int @@ -177,7 +177,7 @@ sxfmt(Fmt *fmt) { int i, paren; Sx *sx; - + sx = va_arg(fmt->args, Sx*); if(sx == nil) return 0; @@ -211,7 +211,7 @@ sxfmt(Fmt *fmt) int oksx(Sx *sx) { - return sx->nsx >= 2 - && sx->sx[1]->type == SxAtom + return sx->nsx >= 2 + && sx->sx[1]->type == SxAtom && cistrcmp(sx->sx[1]->data, "OK") == 0; } diff --git a/src/cmd/upas/nfs/sx.h b/src/cmd/upas/nfs/sx.h index 38a801d45..696b5a704 100644 --- a/src/cmd/upas/nfs/sx.h +++ b/src/cmd/upas/nfs/sx.h @@ -28,4 +28,3 @@ void freesx(Sx*); int oksx(Sx*); int sxfmt(Fmt*); int sxwalk(Sx*); - diff --git a/src/cmd/upas/nfs/thread.c b/src/cmd/upas/nfs/thread.c index bb40def13..b4c893ee0 100644 --- a/src/cmd/upas/nfs/thread.c +++ b/src/cmd/upas/nfs/thread.c @@ -13,7 +13,7 @@ void mailthread(void (*fn)(void*), void *arg) { New n; - + n.fn = fn; n.arg = arg; send(mailthreadchan, &n); @@ -23,7 +23,7 @@ void mailproc(void *v) { New n; - + USED(v); while(recv(mailthreadchan, &n) == 1) threadcreate(n.fn, n.arg, STACK); @@ -35,4 +35,3 @@ mailthreadinit(void) mailthreadchan = chancreate(sizeof(New), 0); proccreate(mailproc, nil, STACK); } - diff --git a/src/cmd/upas/nfs/util.c b/src/cmd/upas/nfs/util.c index ac9deba8a..048eef052 100644 --- a/src/cmd/upas/nfs/util.c +++ b/src/cmd/upas/nfs/util.c @@ -4,7 +4,7 @@ void warn(char *fmt, ...) { va_list arg; - + va_start(arg, fmt); fprint(2, "warning: "); vfprint(2, fmt, arg); diff --git a/src/cmd/upas/pop3/pop3.c b/src/cmd/upas/pop3/pop3.c index af6743685..4974a8b52 100644 --- a/src/cmd/upas/pop3/pop3.c +++ b/src/cmd/upas/pop3/pop3.c @@ -63,7 +63,7 @@ static int passwordinclear; static int didtls; typedef struct Msg Msg; -struct Msg +struct Msg { int upasnum; char digest[64]; @@ -575,7 +575,7 @@ stlscmd(char*) Binit(&out, 1, OWRITE); didtls = 1; return 0; -} +} static int topcmd(char *arg) @@ -643,7 +643,7 @@ uidlcmd(char *arg) return senderr("no such message"); sendok("%d %s", n+1, msg[n].digest); } - return 0; + return 0; } static char* @@ -746,7 +746,7 @@ dologin(char *response) if(tries++ >= 5){ senderr("authentication failed: %r; server exiting"); exits(nil); - } + } return senderr("authentication failed"); } @@ -801,4 +801,3 @@ apopcmd(char *arg) return -1; return dologin(resp); } - diff --git a/src/cmd/upas/scanmail/common.c b/src/cmd/upas/scanmail/common.c index 2e3685040..303014240 100644 --- a/src/cmd/upas/scanmail/common.c +++ b/src/cmd/upas/scanmail/common.c @@ -277,7 +277,7 @@ htmlchk(char **msg, char *end) p = *msg; if(ishtml == 0){ ishtml = htmlmatch(htmlcmds, p, end, &n); - + /* If not an HTML keyword, check if it's * an HTML comment (). if so, * skip over it; otherwise copy it in. @@ -287,7 +287,7 @@ htmlchk(char **msg, char *end) } else if(htmlmatch(hrefs, p, end, &n)) /* if special HTML string */ return '<'; /* copy it */ - + /* * this is an uninteresting HTML command; skip over it. */ diff --git a/src/cmd/upas/scanmail/testscan.c b/src/cmd/upas/scanmail/testscan.c index 48cd4bbfe..79399c8bf 100644 --- a/src/cmd/upas/scanmail/testscan.c +++ b/src/cmd/upas/scanmail/testscan.c @@ -110,7 +110,7 @@ main(int argc, char *argv[]) exits("open"); } Binit(&bin, fd, OREAD); - } else + } else Binit(&bin, 0, OREAD); *body = 0; diff --git a/src/cmd/upas/send/bind.c b/src/cmd/upas/send/bind.c index 8a8fc8eac..05327975a 100644 --- a/src/cmd/upas/send/bind.c +++ b/src/cmd/upas/send/bind.c @@ -130,4 +130,3 @@ forward_loop(char *addr, char *system) return 1; return 0; } - diff --git a/src/cmd/upas/send/main.c b/src/cmd/upas/send/main.c index 6c455833a..15a2026e0 100644 --- a/src/cmd/upas/send/main.c +++ b/src/cmd/upas/send/main.c @@ -122,7 +122,7 @@ main(int argc, char *argv[]) /* * If this is a gateway, translate the sender address into a local - * address. This only happens if mail to the local address is + * address. This only happens if mail to the local address is * forwarded to the sender. */ gateway(mp); diff --git a/src/cmd/upas/send/message.c b/src/cmd/upas/send/message.c index 3ec8d706e..60dd050b3 100644 --- a/src/cmd/upas/send/message.c +++ b/src/cmd/upas/send/message.c @@ -224,7 +224,7 @@ rfc822cruft(message *mp) if(p->addr){ cp = skipequiv(s_to_c(p->s)); s_append(body, cp); - } else + } else s_append(body, s_to_c(p->s)); }else{ s_putc(body, p->c); @@ -494,7 +494,7 @@ int isutf8(String *s) { char *p; - + for(p = s_to_c(s); *p; p++) if(*p&0x80) return 1; diff --git a/src/cmd/upas/send/rewrite.c b/src/cmd/upas/send/rewrite.c index 3f30d4f3a..3b19da27b 100644 --- a/src/cmd/upas/send/rewrite.c +++ b/src/cmd/upas/send/rewrite.c @@ -3,7 +3,7 @@ extern int debug; -/* +/* * Routines for dealing with the rewrite rules. */ @@ -249,7 +249,7 @@ substitute(String *source, Resub *subexp, message *mp) char *s; char *sp; String *stp; - + if(source == 0) return 0; sp = s_to_c(source); @@ -292,7 +292,7 @@ substitute(String *source, Resub *subexp, message *mp) s_putc(stp, *sp); break; } - } else if(*sp == '&') { + } else if(*sp == '&') { if(subexp[0].s.sp != 0) for (s = subexp[0].s.sp; s < subexp[0].e.ep; s++) @@ -345,4 +345,3 @@ dumprules(void) fprint(2, " '%s'\n", rp->repl2 ? rp->repl2->base:"..."); } } - diff --git a/src/cmd/upas/send/skipequiv.c b/src/cmd/upas/send/skipequiv.c index f40181ad5..d5bf0bb17 100644 --- a/src/cmd/upas/send/skipequiv.c +++ b/src/cmd/upas/send/skipequiv.c @@ -41,7 +41,7 @@ okfile(char *cp, Biobuf *fp) len = strlen(cp); Bseek(fp, 0, 0); - + /* one iteration per system name in the file */ while(buf = Brdline(fp, '\n')) { ep = &buf[Blinelen(fp)]; diff --git a/src/cmd/upas/smtp/mxdial.c b/src/cmd/upas/smtp/mxdial.c index 56962dcd5..f7a009afd 100644 --- a/src/cmd/upas/smtp/mxdial.c +++ b/src/cmd/upas/smtp/mxdial.c @@ -171,7 +171,7 @@ mxlookup(DS *ds, char *domain) { int i, n, nmx; Ndbtuple *t, *tmx, *tpref, *tip; - + strcpy(domain, ds->host); ds->netdir = "/net"; nmx = 0; @@ -184,7 +184,7 @@ mxlookup(DS *ds, char *domain) nmx++; break; } - } + } } ndbfree(t); } @@ -216,14 +216,14 @@ mxlookup(DS *ds, char *domain) strncpy(mx[i].ip, tip->val, sizeof(mx[i].ip)-1); ndbfree(t); continue; - + no: /* remove mx[i] and go around again */ nmx--; mx[i] = mx[nmx]; i--; } - return nmx; + return nmx; } static int diff --git a/src/cmd/upas/smtp/smtp.c b/src/cmd/upas/smtp/smtp.c index 92873723d..88d7f7a4d 100644 --- a/src/cmd/upas/smtp/smtp.c +++ b/src/cmd/upas/smtp/smtp.c @@ -60,7 +60,7 @@ void usage(void) { fprint(2, "usage: smtp [-adips] [-uuser] [-hhost] [.domain] net!host[!service] sender rcpt-list\n"); - threadexitsall(Giveup); + threadexitsall(Giveup); } int @@ -656,7 +656,7 @@ data(String *from, Biobuf *b) nbytes += Bprint(&bout, "Message-ID: <%s@%s>\r\n", id, hostdomain); if(debug) Bprint(&berr, "Message-ID: <%s@%s>\r\n", id, hostdomain); - } + } if(originator==0){ nbytes += Bprint(&bout, "From: %s\r\n", s_to_c(fromline)); @@ -687,7 +687,7 @@ data(String *from, Biobuf *b) /* * send body */ - + putcrnl(uneaten, buf+n - uneaten); nbytes += buf+n - uneaten; if(eof == 0){ @@ -1109,14 +1109,14 @@ dBputc(int x) return Bputc(&bout, x); } -char* +char* expand_addr(char *addr) { static char buf[256]; char *p, *q, *name, *sys; Ndbtuple *t; Ndb *db; - + p = strchr(addr, '!'); if(p){ q = strchr(p+1, '!'); @@ -1131,7 +1131,7 @@ expand_addr(char *addr) name++; if(q) *q = 0; - + sys = sysname(); db = ndbopen(0); t = ndbipinfo(db, "sys", sys, &name, 1); @@ -1141,7 +1141,7 @@ expand_addr(char *addr) *q = '!'; return addr; } - + *(name-1) = 0; if(q) *q = '!'; diff --git a/src/cmd/upas/smtp/smtpd.c b/src/cmd/upas/smtp/smtpd.c index e59dbddd2..df722c108 100644 --- a/src/cmd/upas/smtp/smtpd.c +++ b/src/cmd/upas/smtp/smtpd.c @@ -304,7 +304,7 @@ hello(String *himp, int extended) if (extended) { if(tlscert != nil) reply("250-STARTTLS\r\n"); - if (passwordinclear) + if (passwordinclear) reply("250 AUTH CRAM-MD5 PLAIN LOGIN\r\n"); else reply("250 AUTH CRAM-MD5\r\n"); @@ -1101,7 +1101,7 @@ sendermxcheck(void) * Could add an option with the remote IP address * to allow validatesender to implement SPF eventually. */ - execl(validate, "validatesender", + execl(validate, "validatesender", "-n", nci->root, senddom, user, nil); threadexitsall("exec validatesender: %r"); default: @@ -1165,7 +1165,7 @@ data(void) reply("450 %s\r\n", errx); for(l=rcvers.first; l; l=l->next) syslog(0, "smtpd", "[%s/%s] %s -> %s sendercheck: %s", - him, nci->rsys, s_to_c(senders.first->p), + him, nci->rsys, s_to_c(senders.first->p), s_to_c(l->p), errx); rejectcount++; return; @@ -1214,7 +1214,7 @@ data(void) code = 554; } else { syslog(0, "smtpd", "++[%s/%s] %s %s %s%s%sreturned %#q %s", him, nci->rsys, - s_to_c(senders.first->p), s_to_c(cmd), + s_to_c(senders.first->p), s_to_c(cmd), piperror ? "error during pipemsg: " : "", piperror ? piperror : "", piperror ? "; " : "", diff --git a/src/cmd/upas/smtp/smtpd.h b/src/cmd/upas/smtp/smtpd.h index bb982a2f3..9f8cdffaf 100644 --- a/src/cmd/upas/smtp/smtpd.h +++ b/src/cmd/upas/smtp/smtpd.h @@ -11,7 +11,7 @@ enum { MAXREJECTS = 100 }; - + typedef struct Link Link; typedef struct List List; diff --git a/src/cmd/upas/smtp/spam.c b/src/cmd/upas/smtp/spam.c index 723e341d5..2422dfe9b 100644 --- a/src/cmd/upas/smtp/spam.c +++ b/src/cmd/upas/smtp/spam.c @@ -26,7 +26,7 @@ static Keyword options[] = { "norelay", NORELAY, "verifysenderdom", DNSVERIFY, "saveblockedmsg", SAVEBLOCK, - "defaultdomain", DOMNAME, + "defaultdomain", DOMNAME, "ournets", OURNETS, "ourdomains", OURDOMS, 0, NONE @@ -84,7 +84,7 @@ getaction(char *s, char *type) return ACCEPT; for(k = actions; k->name != 0; k++){ - snprint(buf, sizeof buf, "%s/mail/ratify/%s/%s/%s", + snprint(buf, sizeof buf, "%s/mail/ratify/%s/%s/%s", get9root(), k->name, type, s); if(access(buf,0) >= 0) return k->code; @@ -435,7 +435,7 @@ cidrcheck(char *cp) if((v4peerip&m) == a) return 1; cp += strlen(cp)+1; - } + } return 0; } @@ -508,7 +508,7 @@ recipok(char *user) int pid; Waitmsg *w; static int beenhere; - + if(!beenhere){ beenhere++; validator = unsharp(validator); diff --git a/src/cmd/upas/vf/unvf.c b/src/cmd/upas/vf/unvf.c index aecbca62d..7269da900 100644 --- a/src/cmd/upas/vf/unvf.c +++ b/src/cmd/upas/vf/unvf.c @@ -15,10 +15,10 @@ main(void) Biobuf b, b1; char *p, *encoding; int e, len; - + Binit(&b, 0, OREAD); Binit(&b1, 1, OWRITE); - + /* header */ encoding = nil; while((p = Brdstr(&b, '\n', 1)) != nil){ @@ -58,7 +58,7 @@ main(void) } /* - * decode quoted + * decode quoted */ enum { @@ -153,4 +153,3 @@ decquoted(char *out, char *in, char *e) return p - out; } - diff --git a/src/cmd/upas/vf/vf.c b/src/cmd/upas/vf/vf.c index fb54d4a19..5aab37fef 100644 --- a/src/cmd/upas/vf/vf.c +++ b/src/cmd/upas/vf/vf.c @@ -213,7 +213,7 @@ part(Part *pp) passnotheader(); return part(p); } else { - /* + /* * This is the meat. This may be an executable. * if so, wrap it and change its type */ @@ -390,7 +390,7 @@ save(Part *p, char *file) Bprint(&out, "\n"); Bterm(&out); close(fd); - + memset(&out, 0, sizeof out); Binit(&out, 1, OWRITE); return 0; @@ -404,7 +404,7 @@ savetmp(Part *p) { char buf[40], *name; int fd; - + strcpy(buf, "/var/tmp/vf.XXXXXXXXXXX"); if((fd = mkstemp(buf)) < 0){ fprint(2, "error creating temporary file: %r\n"); @@ -439,7 +439,7 @@ runchecker(Part *p) char *name; Waitmsg *w; static char *val; - + if(val == nil) val = unsharp("#9/mail/lib/validateattachment"); if(val == nil || access(val, AEXEC) < 0) @@ -503,7 +503,7 @@ problemchild(Part *p) if(justreject) return p; - + syslog(0, "mail", "vf wrapped %s %s", p->type?s_to_c(p->type):"?", p->filename?s_to_c(p->filename):"?"); @@ -591,7 +591,7 @@ isattribute(char **pp, char *attr) } /* - * parse content type header + * parse content type header */ static void ctype(Part *p, Hdef *h, char *cp) @@ -605,7 +605,7 @@ ctype(Part *p, Hdef *h, char *cp) cp = getstring(cp, p->type, 1); if(badtype(s_to_c(p->type))) p->badtype = 1; - + while(*cp){ if(isattribute(&cp, "boundary")){ s = s_new(); @@ -627,13 +627,13 @@ ctype(Part *p, Hdef *h, char *cp) p->charset = s_new(); cp = getstring(cp, s_reset(p->charset), 0); } - + cp = skiptosemi(cp); } } /* - * parse content encoding header + * parse content encoding header */ static void cencoding(Part *m, Hdef *h, char *p) @@ -647,7 +647,7 @@ cencoding(Part *m, Hdef *h, char *p) } /* - * parse content disposition header + * parse content disposition header */ static void cdisposition(Part *p, Hdef *h, char *cp) @@ -1006,7 +1006,7 @@ tokenconvert(String *t) } /* - * decode quoted + * decode quoted */ enum { diff --git a/src/cmd/usage.c b/src/cmd/usage.c index b064feaf1..8d4a71e6a 100644 --- a/src/cmd/usage.c +++ b/src/cmd/usage.c @@ -9,7 +9,7 @@ main(int argc, char **argv) char *argv0, *args, *flags, *p, *p0; int single; Rune r; - + argv0 = getenv("0"); if(argv0 == nil) { if(argc > 1) @@ -21,7 +21,7 @@ main(int argc, char **argv) argv0 = p+1; flags = getenv("flagfmt"); args = getenv("args"); - + if(argv0 == nil){ fprint(2, "aux/usage: $0 not set\n"); exits("$0"); diff --git a/src/cmd/vac/dat.h b/src/cmd/vac/dat.h index 000a762a8..7182d52b8 100644 --- a/src/cmd/vac/dat.h +++ b/src/cmd/vac/dat.h @@ -35,4 +35,3 @@ struct VacDirEnum int i, n; VacDir *buf; }; - diff --git a/src/cmd/vac/file.c b/src/cmd/vac/file.c index d96502892..e25f6cfc6 100644 --- a/src/cmd/vac/file.c +++ b/src/cmd/vac/file.c @@ -8,21 +8,21 @@ /* * Vac file system. This is a simplified version of the same code in Fossil. - * + * * The locking order in the tree is upward: a thread can hold the lock * for a VacFile and then acquire the lock of f->up (the parent), * but not vice-versa. - * + * * A vac file is one or two venti files. Plain data files are one venti file, * while directores are two: a venti data file containing traditional - * directory entries, and a venti directory file containing venti + * directory entries, and a venti directory file containing venti * directory entries. The traditional directory entries in the data file * contain integers indexing into the venti directory entry file. * It's a little complicated, but it makes the data usable by standard * tools like venti/copy. * */ - + static int filemetaflush(VacFile*, char*); struct VacFile @@ -45,7 +45,7 @@ struct VacFile VtFile *msource; /* metadata for children in a directory */ VacFile *down; /* children */ int mode; - + uvlong qidoffset; /* qid offset */ }; @@ -215,7 +215,7 @@ vacfiledecref(VacFile *f) filefree(f); return 0; } - + filemetalock(f); f->ref--; if(f->ref > 0){ @@ -256,12 +256,12 @@ vacfiledecref(VacFile *f) } -/* - * Construct a vacfile for the root of a vac tree, given the - * venti file for the root information. That venti file is a +/* + * Construct a vacfile for the root of a vac tree, given the + * venti file for the root information. That venti file is a * directory file containing VtEntries for three more venti files: - * the two venti files making up the root directory, and a - * third venti file that would be the metadata half of the + * the two venti files making up the root directory, and a + * third venti file that would be the metadata half of the * "root's parent". * * Fossil generates slightly different vac files, due to a now @@ -273,7 +273,7 @@ VacFile* _vacfileroot(VacFs *fs, VtFile *r) { int redirected; - char err[ERRMAX]; + char err[ERRMAX]; VtBlock *b; VtFile *r0, *r1, *r2; MetaBlock mb; @@ -374,7 +374,7 @@ _vacfileroot(VacFs *fs, VtFile *r) * to look at every block to find a given name. * Dirlookup looks in f for an element name elem. * It returns a new VacFile with the dir, boff, and mode - * filled in, but the sources (venti files) are not, and f is + * filled in, but the sources (venti files) are not, and f is * not yet linked into the tree. These details must be taken * care of by the caller. * @@ -535,8 +535,8 @@ vacfilewalk(VacFile *f, char *elem) return nil; } -/* - * Open a path in the vac file system: +/* + * Open a path in the vac file system: * just walk each element one at a time. */ VacFile* @@ -696,12 +696,12 @@ vacfilegetsize(VacFile *f, uvlong *size) * Directory reading. * * A VacDirEnum is a buffer containing directory entries. - * Directory entries contain malloced strings and need to - * be cleaned up with vdcleanup. The invariant in the + * Directory entries contain malloced strings and need to + * be cleaned up with vdcleanup. The invariant in the * VacDirEnum is that the directory entries between * vde->i and vde->n are owned by the vde and need to * be cleaned up if it is closed. Those from 0 up to vde->i - * have been handed to the reader, and the reader must + * have been handed to the reader, and the reader must * take care of calling vdcleanup as appropriate. */ VacDirEnum* @@ -718,7 +718,7 @@ vdeopen(VacFile *f) /* * There might be changes to this directory's children * that have not been flushed out into the cache yet. - * Those changes are only available if we look at the + * Those changes are only available if we look at the * VacFile structures directory. But the directory reader * is going to read the cache blocks directly, so update them. */ @@ -912,19 +912,19 @@ vdeclose(VacDirEnum *vde) * On to mutation. If the vac file system has been opened * read-write, then the files and directories can all be edited. * Changes are kept in the in-memory cache until flushed out - * to venti, so we must be careful to explicitly flush data + * to venti, so we must be careful to explicitly flush data * that we're not likely to modify again. * * Each VacFile has its own copy of its VacDir directory entry * in f->dir, but otherwise the cache is the authoratative source - * for data. Thus, for the most part, it suffices if we just + * for data. Thus, for the most part, it suffices if we just * call vtfileflushbefore and vtfileflush when we modify things. * There are a few places where we have to remember to write * changed VacDirs back into the cache. If f->dir *is* out of sync, * then f->dirty should be set. * * The metadata in a directory is, to venti, a plain data file, - * but as mentioned above it is actually a sequence of + * but as mentioned above it is actually a sequence of * MetaBlocks that contain sorted lists of VacDir entries. * The filemetaxxx routines manipulate that stream. */ @@ -949,10 +949,10 @@ filemetaalloc(VacFile *fp, VacDir *dir, u32int start) int i, n; MetaEntry me; VtFile *ms; - + ms = fp->msource; n = vdsize(dir, VacDirVersion); - + /* Look for a block with room for a new entry of size n. */ nb = (vtfilegetsize(ms)+ms->dsize-1)/ms->dsize; if(start == NilBlock){ @@ -961,7 +961,7 @@ filemetaalloc(VacFile *fp, VacDir *dir, u32int start) else start = 0; } - + if(start > nb) start = nb; for(bo=start; bodir, VacDirVersion); @@ -1076,20 +1076,20 @@ filemetaflush(VacFile *f, char *oelem) vdunpack(&f->dir, &me); mbinsert(&mb, i, &me); mbpack(&mb); - + /* Done */ vtblockput(b); vtfileunlock(fp->msource); f->dirty = 0; return 0; } - + /* * The entry must be moved to another block. * This can only really happen on renames that * make the name very long. */ - + /* Allocate a spot in a new block. */ if((bo = filemetaalloc(fp, &f->dir, f->boff+1)) == NilBlock){ /* mbresize above might have modified block */ @@ -1175,7 +1175,7 @@ vacfileflush(VacFile *f, int recursive) int ret; VacFile **kids, *p; int i, nkids; - + if(f->mode == VtOREAD) return 0; @@ -1218,7 +1218,7 @@ vacfileflush(VacFile *f, int recursive) /* * Now we can flush our own data. - */ + */ vtfilelock(f->source, -1); if(vtfileflush(f->source) < 0) ret = -1; @@ -1233,7 +1233,7 @@ vacfileflush(VacFile *f, int recursive) return ret; } - + /* * Create a new file named elem in fp with the given mode. * The mode can be changed later except for the ModeDir bit. @@ -1339,7 +1339,7 @@ vacfilecreate(VacFile *fp, char *elem, ulong mode) vacfileincref(fp); fileunlock(fp); - + filelock(ff); vtfilelock(ff->source, -1); vtfileunlock(ff->source); @@ -1375,7 +1375,7 @@ vacfilesetsize(VacFile *f, uvlong size) werrstr(ENotFile); return -1; } - + if(filelock(f) < 0) return -1; @@ -1534,7 +1534,7 @@ vacfilesetdir(VacFile *f, VacDir *dir) if(filelock(f) < 0) return -1; filemetalock(f); - + if(f->source->mode != VtORDWR){ werrstr(EReadOnly); goto Err; @@ -1777,7 +1777,7 @@ vacfsopen(VtConn *z, char *file, int mode, ulong cachemem) int fd; uchar score[VtScoreSize]; char *prefix; - + if(vtparsescore(file, &prefix, score) >= 0){ if(prefix == nil || strcmp(prefix, "vac") != 0){ werrstr("not a vac file"); @@ -1836,7 +1836,7 @@ if(debug) fprint(2, "bad type %s\n", rt.type); memmove(e.score, rt.score, VtScoreSize); e.gen = 0; - + // Don't waste cache memory on pointer blocks // when rt.blocksize is large. e.psize = (rt.blocksize/VtEntrySize)*VtEntrySize; @@ -1918,7 +1918,7 @@ int vacfsgetmaxqid(VacFs *fs, uvlong *maxqid) { VacDir vd; - + if(vacfilegetdir(fs->root, &vd) < 0) return -1; if(vd.qidspace) @@ -1955,7 +1955,7 @@ vacfscreate(VtConn *z, int bsize, ulong cachemem) VacDir vd; MetaEntry me; int psize; - + if((fs = vacfsalloc(z, bsize, cachemem, VtORDWR)) == nil) return nil; @@ -1989,7 +1989,7 @@ if(debug) fprint(2, "create bsize %d psize %d\n", bsize, psize); vtblockwrite(b); memmove(metascore, b->score, VtScoreSize); vtblockput(b); - + /* First entry: empty venti directory stream. */ memset(&e, 0, sizeof e); e.flags = VtEntryActive; @@ -1999,7 +1999,7 @@ if(debug) fprint(2, "create bsize %d psize %d\n", bsize, psize); memmove(e.score, vtzeroscore, VtScoreSize); vtentrypack(&e, buf, 0); vtfilewrite(f, buf, VtEntrySize, 0); - + /* Second entry: empty metadata stream. */ e.type = VtDataType; vtentrypack(&e, buf, 0); @@ -2013,7 +2013,7 @@ if(debug) fprint(2, "create bsize %d psize %d\n", bsize, psize); vtfileflush(f); vtfileunlock(f); - + /* Now open it as a vac fs. */ fs->root = _vacfileroot(fs, f); if(fs->root == nil){ @@ -2105,7 +2105,7 @@ sha1matches(VacFile *f, ulong b, uchar *buf, int n) { uchar fscore[VtScoreSize]; uchar bufscore[VtScoreSize]; - + if(vacfileblockscore(f, b, fscore) < 0) return 0; n = vtzerotruncate(VtDataType, buf, n); @@ -2114,4 +2114,3 @@ sha1matches(VacFile *f, ulong b, uchar *buf, int n) return 1; return 0; } - diff --git a/src/cmd/vac/glob.c b/src/cmd/vac/glob.c index 863eb8486..69602ad75 100644 --- a/src/cmd/vac/glob.c +++ b/src/cmd/vac/glob.c @@ -89,7 +89,7 @@ glob2regexp(char *glob) *w++ = ')'; *w++ = '$'; *w = 0; - + re = regcomp(s); if(re == nil){ syntax: @@ -130,7 +130,7 @@ loadexcludefile(char *file) case '#': continue; } - + inc = 0; if(strncmp(p, "include ", 8) == 0){ inc = 1; @@ -157,7 +157,7 @@ void excludepattern(char *p) { Reprog *re; - + if((re = glob2regexp(p)) == nil) sysfatal("bad glob pattern %s", p); @@ -171,10 +171,9 @@ int includefile(char *file) { Pattern *p, *ep; - + for(p=pattern, ep=p+npattern; pre, file, nil, 0)) return p->include; return 1; } - diff --git a/src/cmd/vac/pack.c b/src/cmd/vac/pack.c index 5555cc0eb..1eca665db 100644 --- a/src/cmd/vac/pack.c +++ b/src/cmd/vac/pack.c @@ -36,7 +36,7 @@ stringunpack(char **s, uchar **p, int *n) if(*n < 2) return -1; - + nn = U16GET(*p); *p += 2; *n -= 2; @@ -187,7 +187,7 @@ if(0)print("eo = %d en = %d\n", eo, en); } p = mb->buf + eo; - + /* make sure entry looks ok and includes an elem name */ if(en < 8 || U32GET(p) != DirMagic || en < 8 + U16GET(p+6)) { werrstr("corrupted meta block entry"); @@ -317,7 +317,7 @@ mbcompact(MetaBlock *mb, MetaChunk *mc) int oo, o, n, i; oo = MetaHeaderSize + mb->maxindex*MetaIndexSize; - + for(i=0; inindex; i++) { o = mc[i].offset; n = mc[i].size; @@ -375,7 +375,7 @@ int vdsize(VacDir *dir, int version) { int n; - + if(version < 8 || version > 9) sysfatal("bad version %d in vdpack", version); @@ -433,7 +433,7 @@ vdpack(VacDir *dir, MetaEntry *me, int version) sysfatal("bad version %d in vdpack", version); p = me->p; - + U32PUT(p, DirMagic); U16PUT(p+4, version); /* version */ p += 6; @@ -442,7 +442,7 @@ vdpack(VacDir *dir, MetaEntry *me, int version) U32PUT(p, dir->entry); p += 4; - + if(version == 9){ U32PUT(p, dir->gen); U32PUT(p+4, dir->mentry); @@ -456,7 +456,7 @@ vdpack(VacDir *dir, MetaEntry *me, int version) p += stringpack(dir->uid, p); p += stringpack(dir->gid, p); p += stringpack(dir->mid, p); - + U32PUT(p, dir->mtime); U32PUT(p+4, dir->mcount); U32PUT(p+8, dir->ctime); @@ -481,7 +481,7 @@ vdpack(VacDir *dir, MetaEntry *me, int version) U64PUT(p+8, dir->qidmax, t32); p += 16; } - + if(dir->gen && version < 9) { U8PUT(p, DirGenEntry); U16PUT(p+1, 4); @@ -498,7 +498,7 @@ vdunpack(VacDir *dir, MetaEntry *me) { int t, nn, n, version; uchar *p; - + p = me->p; n = me->size; @@ -517,7 +517,7 @@ vdunpack(VacDir *dir, MetaEntry *me) if(version < 7 || version > 9) goto Err; p += 2; - n -= 2; + n -= 2; /* elem */ if(stringunpack(&dir->elem, &p, &n) < 0) @@ -560,7 +560,7 @@ vdunpack(VacDir *dir, MetaEntry *me) p += VtScoreSize; n -= VtScoreSize; } - + /* uid */ if(stringunpack(&dir->uid, &p, &n) < 0) goto Err; @@ -678,7 +678,7 @@ mbsearch(MetaBlock *mb, char *elem, int *ri, MetaEntry *me) *ri = i; return 1; } - + if(x < 0) b = i+1; else /* x > 0 */ @@ -686,7 +686,7 @@ mbsearch(MetaBlock *mb, char *elem, int *ri, MetaEntry *me) } assert(b == t); - + *ri = b; /* b is the index to insert this entry */ memset(me, 0, sizeof(*me)); diff --git a/src/cmd/vac/testinc.c b/src/cmd/vac/testinc.c index 0cd431434..3049e34b2 100644 --- a/src/cmd/vac/testinc.c +++ b/src/cmd/vac/testinc.c @@ -14,13 +14,13 @@ threadmain(int argc, char **argv) default: goto usage; }ARGEND - + if(argc != 1){ usage: fprint(2, "usage: testinc includefile\n"); threadexitsall("usage"); } - + loadexcludefile(argv[0]); Binit(&b, 0, OREAD); while((p = Brdline(&b, '\n')) != nil){ diff --git a/src/cmd/vac/unvac.c b/src/cmd/vac/unvac.c index 594a6a2e8..a265893fc 100644 --- a/src/cmd/vac/unvac.c +++ b/src/cmd/vac/unvac.c @@ -46,7 +46,7 @@ threadmain(int argc, char *argv[]) fmtinstall('F', vtfcallfmt); fmtinstall('t', mtimefmt); fmtinstall('M', dirmodefmt); - + host = nil; printstats = 0; @@ -104,7 +104,7 @@ threadmain(int argc, char *argv[]) if((f = vacfsgetroot(fs)) == nil) sysfatal("vacfsgetroot: %r"); - + unvac(f, nil, nil); for(i=0; i 0){ m = write(fd, buf, n); @@ -141,7 +141,7 @@ int wantfile(char *name) { int i, namelen, n; - + if(nwant == 0) return 1; @@ -229,7 +229,7 @@ unvac(VacFile *f, char *name, VacDir *vdir) fprint(2, "warning: ignoring %s %s\n", what, name); return; } - + if(mode&ModeDir){ if((vde = vdeopen(f)) == nil){ fprint(2, "vdeopen %s: %r", name); @@ -342,7 +342,7 @@ int mtimefmt(Fmt *f) { Tm *tm; - + tm = localtime(va_arg(f->args, ulong)); fmtprint(f, "%04d-%02d-%02d %02d:%02d", tm->year+1900, tm->mon+1, tm->mday, diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c index b54503e4e..7e4414825 100644 --- a/src/cmd/vac/vac.c +++ b/src/cmd/vac/vac.c @@ -48,7 +48,7 @@ static void removevacfile(void); #ifdef PLAN9PORT /* * We're between a rock and a hard place here. - * The pw library (getpwnam, etc.) reads the + * The pw library (getpwnam, etc.) reads the * password and group files into an on-stack buffer, * so if you have some huge groups, you overflow * the stack. Because of this, the thread library turns @@ -136,10 +136,10 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc == 0 && !stdinname) usage(); - + if(archivefile && (vacfile || diffvac)){ fprint(2, "cannot use -a with -f, -d\n"); usage(); @@ -266,7 +266,7 @@ threadmain(int argc, char **argv) } if(fdiff) vacfiledecref(fdiff); - + /* * Record the maximum qid so that vacs can be merged * without introducing overlapping qids. Older versions @@ -313,7 +313,7 @@ recentarchive(VacFs *fs, char *path) char buf[10]; int year, mmdd, nn, n, n1; char *p; - + fp = vacfsgetroot(fs); de = vdeopen(fp); year = 0; @@ -339,7 +339,7 @@ recentarchive(VacFs *fs, char *path) return nil; } fp = f; - + de = vdeopen(fp); mmdd = 0; nn = 0; @@ -440,7 +440,7 @@ enum { /* * Archive the file named name, which has stat info d, - * into the vac directory fp (p = parent). + * into the vac directory fp (p = parent). * * If we're doing a vac -d against another archive, the * equivalent directory to fp in that archive is diffp. @@ -469,7 +469,7 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d) if(merge && vacmerge(fp, name) >= 0) return; - + if(verbose) fprint(2, "%s%s\n", name, (d->mode&DMDIR) ? "/" : ""); @@ -551,7 +551,7 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d) if(vacfilegetentries(fdiff, &e, nil) >= 0) if(vacfilesetentries(f, &e, nil) >= 0){ bsize = e.dsize; - + /* * Or if -q is set, and the metadata looks the same, * don't even bother reading the file. @@ -565,7 +565,7 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d) vdcleanup(&vddiff); goto Out; } - + /* * Skip over presumably-unchanged prefix * of an append-only file. @@ -631,7 +631,7 @@ vacstdin(VacFile *fp, char *name) warn("vacfilecreate %s: %r", name); return; } - + off = 0; while((n = read(0, buf, sizeof buf)) > 0){ if(vacfilewrite(f, buf, n, off) < 0){ @@ -660,7 +660,7 @@ vacmergefile(VacFile *fp, VacFile *mp, VacDir *d, char *vacfile, VtEntry ed, em; VacFile *mf; VacFile *f; - + mf = vacfilewalk(mp, d->elem); if(mf == nil){ warn("could not walk %s in %s", d->elem, vacfile); @@ -671,7 +671,7 @@ vacmergefile(VacFile *fp, VacFile *mp, VacDir *d, char *vacfile, vacfiledecref(mf); return -1; } - + if((f = vacfilecreate(fp, d->elem, d->mode)) == nil){ warn("vacfilecreate %s: %r", d->elem); vacfiledecref(mf); @@ -693,7 +693,7 @@ vacmergefile(VacFile *fp, VacFile *mp, VacDir *d, char *vacfile, vacfiledecref(f); return -1; } - + vacfiledecref(mf); vacfiledecref(f); return 0; @@ -778,4 +778,3 @@ warn(char *fmt, ...) fprint(2, "\n"); va_end(arg); } - diff --git a/src/cmd/vac/vac.h b/src/cmd/vac/vac.h index 0edd41e40..bbed4931c 100644 --- a/src/cmd/vac/vac.h +++ b/src/cmd/vac/vac.h @@ -13,7 +13,7 @@ typedef struct VacDirEnum VacDirEnum; */ enum { - ModeOtherExec = (1<<0), + ModeOtherExec = (1<<0), ModeOtherWrite = (1<<1), ModeOtherRead = (1<<2), ModeGroupExec = (1<<3), @@ -64,7 +64,7 @@ struct VacDir ulong mgen; /* generation of meta entry */ uvlong size; /* size of file */ uvlong qid; /* unique file id */ - + char *uid; /* owner id */ char *gid; /* group id */ char *mid; /* last modified by */ @@ -144,4 +144,3 @@ int vdeunread(VacDirEnum*); int vacfiledsize(VacFile *f); int sha1matches(VacFile *f, ulong b, uchar *buf, int n); - diff --git a/src/cmd/vac/vacfs.c b/src/cmd/vac/vacfs.c index b45257294..05baf66ea 100644 --- a/src/cmd/vac/vacfs.c +++ b/src/cmd/vac/vacfs.c @@ -149,7 +149,7 @@ threadmain(int argc, char *argv[]) fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); - + defmnt = nil; defsrv = nil; ARGBEGIN{ @@ -620,7 +620,7 @@ rstat(Fid *f) VacDir dir; static uchar statbuf[1024]; VacFile *parent; - + if(!f->busy) return vtstrdup(Enotexist); parent = vacfilegetparent(f->file); @@ -671,7 +671,7 @@ vacstat(VacFile *parent, VacDir *vd, uchar *p, int np) dir.qid.type |= QTDIR; dir.mode |= DMDIR; } - + #ifdef PLAN9PORT if(vd->mode & (ModeLink|ModeDevice|ModeNamedPipe)){ vf = vacfilewalk(parent, vd->elem); @@ -695,7 +695,7 @@ vacstat(VacFile *parent, VacDir *vd, uchar *p, int np) dir.mode |= DMNAMEDPIPE; } #endif - + dir.atime = vd->atime; dir.mtime = vd->mtime; dir.length = vd->size; @@ -862,4 +862,3 @@ vacshutdown(void) vacfsclose(fs); vthangup(conn); } - diff --git a/src/cmd/vbackup/config.c b/src/cmd/vbackup/config.c index 1b5b404a5..288e34340 100644 --- a/src/cmd/vbackup/config.c +++ b/src/cmd/vbackup/config.c @@ -91,7 +91,7 @@ readconfigfile(char *name, VtCache *vcache) if((dir = dirstat(name)) == nil) return nil; - + if((b = Bopen(name, OREAD)) == nil){ free(dir); return nil; @@ -142,7 +142,7 @@ readconfigfile(char *name, VtCache *vcache) freeconfig(c); return nil; } - + return c; } diff --git a/src/cmd/vbackup/disknfs.c b/src/cmd/vbackup/disknfs.c index b51d0a3b8..b7798db8d 100644 --- a/src/cmd/vbackup/disknfs.c +++ b/src/cmd/vbackup/disknfs.c @@ -132,4 +132,3 @@ fsreaddir(SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int cookie, uchar **d { return fsysreaddir(fsys, au, h, count, cookie, data, pcount, peof); } - diff --git a/src/cmd/vbackup/mount-Linux.c b/src/cmd/vbackup/mount-Linux.c index b343aa627..bfc0e0fdd 100644 --- a/src/cmd/vbackup/mount-Linux.c +++ b/src/cmd/vbackup/mount-Linux.c @@ -56,4 +56,3 @@ mountnfs(int proto, struct sockaddr_in *sa, uchar *handle, int nhandle, char *mt if(mount("backup:/", mtpt, "nfs", mflag, &nfs) < 0) sysfatal("mount: %r"); } - diff --git a/src/cmd/vbackup/mount-none.c b/src/cmd/vbackup/mount-none.c index db8e1e5bc..28380e13b 100644 --- a/src/cmd/vbackup/mount-none.c +++ b/src/cmd/vbackup/mount-none.c @@ -9,4 +9,3 @@ mountnfs(int proto, struct sockaddr_in *addr, uchar *handle, int hlen, char *mtp { sysfatal("mountnfs not implemented"); } - diff --git a/src/cmd/vbackup/nfs3srv.c b/src/cmd/vbackup/nfs3srv.c index c3fc780ba..532f7e6c7 100644 --- a/src/cmd/vbackup/nfs3srv.c +++ b/src/cmd/vbackup/nfs3srv.c @@ -74,7 +74,7 @@ rumnt(SunMsg *m) NfsMount3RUmnt rx; /* ignore */ - + memset(&rx, 0, sizeof rx); return sunmsgreply(m, &rx.call); } @@ -359,7 +359,7 @@ rrofs(SunMsg *m) memset(buf, 0, sizeof buf); return senderror(m, (SunCall*)buf, Nfs3ErrRoFs); } - + static void rnfs3(void *v) @@ -429,4 +429,3 @@ nfs3proc(void *v) while((m = recvp(c)) != nil) threadcreate(rnfs3, m, SunStackSize); } - diff --git a/src/cmd/vbackup/nfs3srv.h b/src/cmd/vbackup/nfs3srv.h index f96be9850..6d72c1e60 100644 --- a/src/cmd/vbackup/nfs3srv.h +++ b/src/cmd/vbackup/nfs3srv.h @@ -15,4 +15,3 @@ enum { MaxDataSize = 8192 }; - diff --git a/src/cmd/vbackup/vbackup.c b/src/cmd/vbackup/vbackup.c index 353ff6106..df68abe23 100644 --- a/src/cmd/vbackup/vbackup.c +++ b/src/cmd/vbackup/vbackup.c @@ -13,7 +13,7 @@ * -s print status updates * -v print debugging trace * -w write parallelism - * + * * If score is given on the command line, it should be the * score from a previous vbackup on this fspartition. * In this mode, only the new blocks are stored to Venti. @@ -24,12 +24,12 @@ * by buffered queues: * * fsysproc | cmpproc | ventiproc - * + * * Fsysproc reads the disk and queues the blocks. * Cmpproc compares the blocks against the SHA1 hashes * in the old image, if any. It discards the unchanged blocks * and queues the changed ones. Ventiproc writes blocks to Venti. - * + * * There is a fourth proc, statusproc, which prints status * updates about how the various procs are progressing. */ @@ -259,14 +259,14 @@ threadmain(int argc, char **argv) tmpnam = smprint("%s/vbackup.XXXXXX", tmp); if(tmpnam == nil) sysfatal("smprint: %r"); - + if((fd = opentemp(tmpnam, ORDWR|ORCLOSE)) < 0) sysfatal("opentemp %s: %r", tmpnam); if(statustime) print("# %T reading scores into %s\n", tmpnam); if(verbose) fprint(2, "read scores into %s...\n", tmpnam); - + Binit(&bscores, fd, OWRITE); for(i=0; inblock; i++){ if(vtfileblockscore(vfile, i, score) < 0) @@ -276,7 +276,7 @@ threadmain(int argc, char **argv) } Bterm(&bscores); vtfileunlock(vfile); - + /* * prep scores for rereading */ @@ -285,7 +285,7 @@ threadmain(int argc, char **argv) } /* - * start the main processes + * start the main processes */ if(statustime) print("# %T starting procs\n"); @@ -307,7 +307,7 @@ threadmain(int argc, char **argv) * wait for processes to finish */ wlock(&endlk); - + qfree(qcmp); qfree(qventi); @@ -358,7 +358,7 @@ threadmain(int argc, char **argv) if(mountplace == nil) mountplace = guessmountplace(argv[0]); print("mount /%s/%d/%02d%02d%s %s:%V %d/%02d%02d/%02d%02d\n", - mountname, tm.year, tm.mon, tm.mday, + mountname, tm.year, tm.mon, tm.mday, mountplace, root.type, b->score, tm.year, tm.mon, tm.mday, tm.hour, tm.min); @@ -370,7 +370,7 @@ threadmain(int argc, char **argv) sysfatal("vtsync: %r"); if(statustime) print("# %T synced\n"); - + fsysclose(fsys); diskclose(disk); vtcachefree(zcache); @@ -468,7 +468,7 @@ writethread(void *v) nrecv++; if(wr.p == nil) break; - + if(fastwrites && vtread(z, wr.score, wr.type, nil, 0) < 0){ rerrstr(err, sizeof err); if(strstr(err, "read too small")){ /* already exists */ @@ -581,7 +581,7 @@ timefmt(Fmt *fmt) Tm tm; ns = nsec(); tm = *localtime(time(0)); - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", + return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", tm.year+1900, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec, (int)(ns%1000000000)/1000000); } @@ -592,7 +592,7 @@ guessmountplace(char *dev) char *cmd, *q; int p[2], fd[3], n; char buf[100]; - + if(pipe(p) < 0) sysfatal("pipe: %r"); @@ -617,4 +617,3 @@ guessmountplace(char *dev) *--q = 0; return strdup(buf); } - diff --git a/src/cmd/vbackup/vftp.c b/src/cmd/vbackup/vftp.c index c413af42d..84ac3df87 100644 --- a/src/cmd/vbackup/vftp.c +++ b/src/cmd/vbackup/vftp.c @@ -34,7 +34,7 @@ struct Cmd char *help; }; -Cmd cmdtab[] = +Cmd cmdtab[] = { "cd", cmdcd, "cd dir - change directory", "ls", cmdls, "ls [-d] path... - list file", @@ -49,7 +49,7 @@ char* ebuf(void) { static char buf[ERRMAX]; - + rerrstr(buf, sizeof buf); return buf; } @@ -58,7 +58,7 @@ static char* estrdup(char *s) { char *t; - + t = emalloc(strlen(s)+1); strcpy(t, s); return t; @@ -70,7 +70,7 @@ walk(char *path, Nfs3Handle *ph) char *p, *q; Nfs3Handle h; Nfs3Status ok; - + path = estrdup(path); /* writable */ if(path[0] == '/') h = root; @@ -99,7 +99,7 @@ char* cmdhelp(int argc, char **argv) { int i; - + for(i=0; itype */ Bprint(&bout, "%s%s%s", dir ? dir : "", dir && elem ? "/" : "", elem ? elem : ""); Bprint(&bout, " %c%luo %1d %4d %4d", c, attr->mode, attr->nlink, attr->uid, attr->gid); @@ -172,7 +172,7 @@ lsdir(char *dir, Nfs3Handle *h) u1int eof; Nfs3Status ok; u64int cookie; - + cookie = 0; for(;;){ ok = fsysreaddir(fsys, auth, h, 8192, cookie, &data, &count, &eof); @@ -201,7 +201,7 @@ fprint(2, "got %d\n", count); continue; } ls(dir, e.name, &attr); - } + } free(data); if(eof) break; @@ -217,7 +217,7 @@ cmdls(int argc, char **argv) Nfs3Handle h; Nfs3Attr attr; Nfs3Status ok; - + dflag = 0; ARGBEGIN{ case 'd': @@ -232,7 +232,7 @@ cmdls(int argc, char **argv) Bflush(&bout); return nil; } - + for(i=0; iblocksize; - + b = diskread(disk, fsys->blocksize, offset-delta); if(b == nil){ fprint(2, "diskread: %r\n"); @@ -396,7 +396,7 @@ threadmain(int argc, char **argv) int i, nf; uchar score[VtScoreSize]; Nfs3Status ok; - + allowall = 1; ARGBEGIN{ case 'V': @@ -405,14 +405,14 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1) usage(); fmtinstall('F', vtfcallfmt); fmtinstall('H', encodefmt); fmtinstall('V', vtscorefmt); - + if(access(argv[0], AEXIST) >= 0 || strchr(argv[0], '/')){ if((disk = diskopenfile(argv[0])) == nil) sysfatal("diskopen: %r"); @@ -442,7 +442,7 @@ threadmain(int argc, char **argv) cwd = root; Binit(&bin, 0, OREAD); Binit(&bout, 1, OWRITE); - + while(fprint(2, "vftp> "), (p = Brdstr(&bin, '\n', 1)) != nil){ if(p[0] == '#') continue; @@ -461,4 +461,3 @@ threadmain(int argc, char **argv) } threadexitsall(nil); } - diff --git a/src/cmd/vbackup/vnfs.c b/src/cmd/vbackup/vnfs.c index d4319c865..f78d4886c 100644 --- a/src/cmd/vbackup/vnfs.c +++ b/src/cmd/vbackup/vnfs.c @@ -154,7 +154,7 @@ threadmain(int argc, char **argv) nfschan = chancreate(sizeof(SunMsg*), 0); mountchan = chancreate(sizeof(SunMsg*), 0); timerchan = chancreate(sizeof(void*), 0); - + if(sunsrvudp(srv, addr) < 0) sysfatal("starting server: %r"); @@ -162,7 +162,7 @@ threadmain(int argc, char **argv) sunsrvthreadcreate(srv, mount3proc, mountchan); sunsrvthreadcreate(srv, timerthread, nil); proccreate(timerproc, nil, 32768); - + sunsrvprog(srv, &nfs3prog, nfschan); sunsrvprog(srv, &nfsmount3prog, mountchan); @@ -200,13 +200,13 @@ unittoull(char *s) /* * Handles. - * + * * We store all the state about which file a client is accessing in * the handle, so that we don't have to maintain any per-client state - * ourselves. In order to avoid leaking handles or letting clients + * ourselves. In order to avoid leaking handles or letting clients * create arbitrary handles, we sign and encrypt each handle with * AES using a key selected randomly when the server starts. - * Thus, handles cannot be used across sessions. + * Thus, handles cannot be used across sessions. * * The decrypted handles begin with the following header: * @@ -215,7 +215,7 @@ unittoull(char *s) * * If we're pressed for space in the rest of the handle, we could * probably reduce the amount of sessid bytes. Note that the sessid - * bytes must be consistent during a run of vnfs, or else some + * bytes must be consistent during a run of vnfs, or else some * clients (e.g., Linux 2.4) eventually notice that successive TLookups * return different handles, and they return "Stale NFS file handle" * errors to system calls in response (even though we never sent @@ -231,9 +231,9 @@ unittoull(char *s) * and the handles need to be stable across changes in the config file * (though not across server restarts since encryption screws * that up nicely). - * - * We encode each of the first two as a 10-byte hash that is - * the first half of a SHA1 hash. + * + * We encode each of the first two as a 10-byte hash that is + * the first half of a SHA1 hash. */ enum @@ -291,7 +291,7 @@ static Nfs3Status hdecrypt(Nfs3Handle *h) { AESstate aes; - + if(h->len == 1 && h->h[0] == 0){ /* single 0 byte is root */ *h = root; return Nfs3Ok; @@ -323,7 +323,7 @@ cryptinit(void) uchar key[32], ivec[AESbsize]; int i; u32int u32; - + u32 = truerand(); memmove(sessid, &u32, 4); for(i=0; iname = (char*)(n+1); memmove(n->name, elem, elen); @@ -424,7 +424,7 @@ mkcnode(Ctree *t, Cnode *parent, char *elem, uint elen, char *path, uint plen) h = dumbhash(n->handle); n->nexthash = t->hash[h]; t->hash[h] = n; - + return n; } @@ -446,7 +446,7 @@ refreshdisk(void) int i; Cnode *n; Ctree *t; - + t = config.ctree; for(i=0; ihash); i++) for(n=t->hash[i]; n; n=n->nexthash){ @@ -485,7 +485,7 @@ static Cnode* cnodewalk(Cnode *n, char *name, uint len, int markokay) { Cnode *nn; - + for(nn=n->kidlist; nn; nn=nn->nextsib) if(strncmp(nn->name, name, len) == 0 && nn->name[len] == 0) if(!nn->mark || markokay) @@ -498,7 +498,7 @@ ctreewalkpath(Ctree *t, char *name, ulong createmtime) { Cnode *n, *nn; char *p, *nextp; - + n = t->root; p = name; for(; *p; p=nextp){ @@ -526,10 +526,10 @@ Ctree* mkctree(void) { Ctree *t; - + t = emalloc(sizeof *t); t->root = mkcnode(t, nil, "", 0, "", 0); - + ctreewalkpath(t, "/+log", time(0))->read = logread; ctreewalkpath(t, "/+refreshdisk", time(0))->read = refreshdiskread; ctreewalkpath(t, "/+refreshconfig", time(0))->read = refreshconfigread; @@ -541,7 +541,7 @@ Cnode* ctreemountfsys(Ctree *t, char *path, ulong time, uchar *score, char *file) { Cnode *n; - + if(time == 0) time = 1; n = ctreewalkpath(t, path, time); @@ -570,7 +570,7 @@ cnodebyhandle(Ctree *t, uchar *p) { int h; Cnode *n; - + h = dumbhash(p); for(n=t->hash[h]; n; n=n->nexthash) if(memcmp(n->handle, p, CnodeHandleSize) == 0) @@ -582,7 +582,7 @@ static int parseipandmask(char *s, uchar *ip, uchar *mask) { char *p, *q; - + p = strchr(s, '/'); if(p) *p++ = 0; @@ -609,14 +609,14 @@ parsetime(char *s, ulong *time) char *p; int i; Tm tm; - + /* decimal integer is seconds since 1970 */ x = strtoul(s, &p, 10); if(x > 0 && *p == 0){ *time = x; return 0; } - + /* otherwise expect yyyy/mmdd/hhmm */ if(strlen(s) != 14 || s[4] != '/' || s[9] != '/') return -1; @@ -629,7 +629,7 @@ parsetime(char *s, ulong *time) return -1; tm.mon = (s[5]-'0')*10+s[6]-'0' - 1; if(tm.mon < 0 || tm.mon > 11) - return -1; + return -1; tm.mday = (s[7]-'0')*10+s[8]-'0'; if(tm.mday < 0 || tm.mday > 31) return -1; @@ -673,7 +673,7 @@ readconfigfile(Config *cp) free(dir); if((b = Bopen(name, OREAD)) == nil) return -1; - + /* * Reuse old tree, garbage collecting entries that * are not mentioned in the new config file. @@ -684,7 +684,7 @@ readconfigfile(Config *cp) markctree(c.ctree); c.ok = nil; c.nok = 0; - + line = 0; for(; (p=Brdstr(b, '\n', 1)) != nil; free(p)){ line++; @@ -726,7 +726,7 @@ readconfigfile(Config *cp) } if(strcmp(f[0], "allow") == 0 || strcmp(f[0], "deny") == 0){ if(nf != 2){ - werrstr("syntax error: allow|deny ip[/mask]"); + werrstr("syntax error: allow|deny ip[/mask]"); goto badline; } c.ok = erealloc(c.ok, (c.nok+1)*sizeof(c.ok[0])); @@ -755,8 +755,8 @@ ipokay(uchar *ip, ushort port) { int i; uchar ipx[IPaddrlen]; - Ipokay *ok; - + Ipokay *ok; + for(i=0; imask, ipx); @@ -775,7 +775,7 @@ Nfs3Status cnodelookup(Ctree *t, Cnode **np, char *name) { Cnode *n, *nn; - + n = *np; if(n->isblackhole) return Nfs3Ok; @@ -826,7 +826,7 @@ cnodereaddir(Cnode *n, u32int count, u64int cookie, uchar **pdata, u32int *pcoun u64int c; u64int u64; Nfs3Entry ne; - + n = n->kidlist; c = cookie; for(; c && n; c--) @@ -837,7 +837,7 @@ cnodereaddir(Cnode *n, u32int count, u64int cookie, uchar **pdata, u32int *pcoun *peof = 1; return Nfs3Ok; } - + data = emalloc(count); p = data; ep = data+count; @@ -882,7 +882,7 @@ timerthread(void *v) } /* - * Actually serve the NFS requests. Called from nfs3srv.c. + * Actually serve the NFS requests. Called from nfs3srv.c. * Each request runs in its own thread (coroutine). * * Decrypted handles have the form: @@ -891,7 +891,7 @@ timerthread(void *v) * glob[10] - SHA1 hash prefix identifying a glob state * fsyshandle[<=10] - disk file system handle (usually 4 bytes) */ - + /* * A fid represents a point in the file tree. * There are three components, all derived from the handle: @@ -933,7 +933,7 @@ handletofid(Nfs3Handle *eh, Fid *fid, int mode) Fsys *fsys; Nfs3Status ok; Nfs3Handle h2, *h, *fh; - + memset(fid, 0, sizeof *fid); domount = 1; @@ -999,7 +999,7 @@ handletofid(Nfs3Handle *eh, Fid *fid, int mode) n->mfsys = fsys; fsysroot(fsys, &n->mfsyshandle); } - + /* * Use inner handle. */ @@ -1010,7 +1010,7 @@ handletofid(Nfs3Handle *eh, Fid *fid, int mode) * Use fsys handle from tree or from handle. * This assumes that fsyshandle was set by fidtohandle * earlier, so it's not okay to reuse handles (except the root) - * across sessions. The encryption above makes and + * across sessions. The encryption above makes and * enforces the same restriction, so this is okay. */ fid->fsys = n->fsys; @@ -1035,7 +1035,7 @@ void _fidtohandle(Fid *fid, Nfs3Handle *h) { Cnode *n; - + n = fid->cnode; /* * Record fsys handle in n, don't bother sending it to client @@ -1062,7 +1062,7 @@ void setrootfid(void) { Fid fid; - + memset(&fid, 0, sizeof fid); fid.cnode = config.ctree->root; _fidtohandle(&fid, &root); @@ -1101,7 +1101,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) Nfs3Status ok; Nfs3Handle xh; int mode; - + trace("lookup %.*lH %s\n", h->len, h->h, name); mode = HWalk; @@ -1112,7 +1112,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) trace("lookup: handletofid %r\n"); return ok; } - + if(strcmp(name, ".") == 0){ fidtohandle(&fid, nh); return Nfs3Ok; @@ -1122,7 +1122,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) * Walk down file system and cnode simultaneously. * If dotdot and file system doesn't move, need to walk * up cnode. Save the corresponding fsys handles in - * the cnode as we walk down so that we'll have them + * the cnode as we walk down so that we'll have them * for dotdotting back up. */ n = fid.cnode; @@ -1143,7 +1143,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) return ok; } fid.fsyshandle = xh; - } + } }else{ /* * Walking dotdot. Ick. @@ -1162,7 +1162,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) /* * Usually just go to n->parent. - * + * * If we're in a subtree of the mounted file system that * isn't represented explicitly by the config tree (instead * the black hole node represents the entire file tree), @@ -1176,7 +1176,7 @@ fslookup(SunAuthUnix *au, Nfs3Handle *h, char *name, Nfs3Handle *nh) n->parent->fsyshandle.len, n->parent->fsyshandle.h, xh.len, xh.h); } - + if(n->isblackhole){ if(handlecmp(&n->parent->mfsyshandle, &xh) == 0) n = n->parent; @@ -1205,7 +1205,7 @@ fsaccess(SunAuthUnix *au, Nfs3Handle *h, u32int want, u32int *got, Nfs3Attr *att { Fid fid; Nfs3Status ok; - + trace("access %.*lH 0x%ux\n", h->len, h->h, want); if((ok = handletofid(h, &fid, HAccess)) != Nfs3Ok) return ok; @@ -1220,7 +1220,7 @@ fsreadlink(SunAuthUnix *au, Nfs3Handle *h, char **link) { Fid fid; Nfs3Status ok; - + trace("readlink %.*lH\n", h->len, h->h); if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok) return ok; @@ -1235,7 +1235,7 @@ fsreadfile(SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int offset, uchar ** { Fid fid; Nfs3Status ok; - + trace("readfile %.*lH\n", h->len, h->h); if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok) return ok; @@ -1252,7 +1252,7 @@ fsreaddir(SunAuthUnix *au, Nfs3Handle *h, u32int len, u64int cookie, uchar **pda Fid fid; Nfs3Status ok; - trace("readdir %.*lH\n", h->len, h->h); + trace("readdir %.*lH\n", h->len, h->h); if((ok = handletofid(h, &fid, HRead)) != Nfs3Ok) return ok; if(fid.fsys) @@ -1272,7 +1272,7 @@ Nfs3Status refreshdiskread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof) { char buf[128]; - + if(offset != 0){ *pcount = 0; *peof = 1; @@ -1293,7 +1293,7 @@ Nfs3Status refreshconfigread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *pcount, u1int *peof) { char buf[128]; - + if(offset != 0){ *pcount = 0; *peof = 1; @@ -1309,4 +1309,3 @@ refreshconfigread(Cnode *n, u32int count, u64int offset, uchar **data, u32int *p *peof = 1; return Nfs3Ok; } - diff --git a/src/cmd/venti/copy.c b/src/cmd/venti/copy.c index d6d770bcf..50d9bb202 100644 --- a/src/cmd/venti/copy.c +++ b/src/cmd/venti/copy.c @@ -53,7 +53,7 @@ static int havevisited(uchar score[VtScoreSize], int type) { ScoreTree a; - + if(scoretree == nil) return 0; memmove(a.score, score, VtScoreSize); @@ -99,7 +99,7 @@ walk(uchar score[VtScoreSize], uint type, int base, int depth) if(memcmp(score, vtzeroscore, VtScoreSize) == 0 || memcmp(score, zeroscore, VtScoreSize) == 0) return; - + if(havevisited(score, type)){ nskip++; return; @@ -145,7 +145,7 @@ walk(uchar score[VtScoreSize], uint type, int base, int depth) continue; walk(e.score, e.type, e.type&VtTypeBaseMask, depth+1); /* - * Don't repack unless we're rewriting -- some old + * Don't repack unless we're rewriting -- some old * vac files have psize==0 and dsize==0, and these * get rewritten by vtentryunpack to have less strange * block sizes. So vtentryunpack; vtentrypack does not @@ -175,7 +175,7 @@ walk(uchar score[VtScoreSize], uint type, int base, int depth) sysfatal("writing block %V (type %d): %r", score, type); } if(!rewrite && memcmp(score, nscore, VtScoreSize) != 0) - sysfatal("not rewriting: wrote %V got %V", score, nscore); + sysfatal("not rewriting: wrote %V got %V", score, nscore); if((type !=0 || base !=0) && verbose){ n = vtzerotruncate(type, buf, n); @@ -185,7 +185,7 @@ walk(uchar score[VtScoreSize], uint type, int base, int depth) fprint(2, " "); fprint(2, "<- %V\n", score); } - + markvisited(score, type); free(buf); } diff --git a/src/cmd/venti/devnull.c b/src/cmd/venti/devnull.c index fdad553e6..3bf6cee4e 100644 --- a/src/cmd/venti/devnull.c +++ b/src/cmd/venti/devnull.c @@ -33,7 +33,7 @@ threadmain(int argc, char **argv) fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); - + address = "tcp!*!venti"; ARGBEGIN{ @@ -76,4 +76,3 @@ threadmain(int argc, char **argv) } threadexitsall(nil); } - diff --git a/src/cmd/venti/dump.c b/src/cmd/venti/dump.c index 352b3cacc..53ec4bad1 100644 --- a/src/cmd/venti/dump.c +++ b/src/cmd/venti/dump.c @@ -31,7 +31,7 @@ dump(int indent, uchar *score, int type) uchar *buf; VtEntry e; VtRoot root; - + if(spaces[0] == 0) memset(spaces, ' ', sizeof spaces-1); @@ -54,7 +54,7 @@ dump(int indent, uchar *score, int type) indent*4, spaces, score, root.name, root.type, root.prev, root.blocksize); dump(indent+1, root.score, VtDirType); break; - + case VtDirType: Bprint(&bout, "%.*s%V dir n=%d\n", indent*4, spaces, score, n); for(i=0; i*VtEntrySize>1] |= c; } return 0; diff --git a/src/cmd/venti/ro.c b/src/cmd/venti/ro.c index ee954a32b..a499aa1e9 100644 --- a/src/cmd/venti/ro.c +++ b/src/cmd/venti/ro.c @@ -32,7 +32,7 @@ readthread(void *v) VtReq *r; uchar *buf; int n; - + r = v; buf = vtmalloc(r->tx.count); if((n=vtread(z, r->tx.score, r->tx.blocktype, buf, r->tx.count)) < 0){ @@ -57,10 +57,10 @@ threadmain(int argc, char **argv) fmtinstall('F', vtfcallfmt); fmtinstall('V', vtscorefmt); - + address = "tcp!*!venti"; ventiaddress = nil; - + ARGBEGIN{ case 'v': verbose++; @@ -109,4 +109,3 @@ threadmain(int argc, char **argv) } threadexitsall(nil); } - diff --git a/src/cmd/venti/srv/arena.c b/src/cmd/venti/srv/arena.c index ddeb3b4c0..7df1fc4b4 100644 --- a/src/cmd/venti/srv/arena.c +++ b/src/cmd/venti/srv/arena.c @@ -401,7 +401,7 @@ atailcmp(ATailStats *a, ATailStats *b) return -1; if(a->used > b->used) return 1; - + /* suspect tests - why order this way? (no one cares) */ if(a->clumps < b->clumps) return -1; @@ -419,7 +419,7 @@ atailcmp(ATailStats *a, ATailStats *b) return -1; if(a->sealed > b->sealed) return 1; - + /* everything matches */ return 0; } @@ -574,7 +574,7 @@ sumarena(Arena *arena) sha1(b->data, bs-VtScoreSize, nil, &s); sha1(zeroscore, VtScoreSize, nil, &s); sha1(nil, 0, score, &s); - + /* * check for no checksum or the same */ @@ -683,7 +683,7 @@ loadarena(Arena *arena) || arena->blocksize != head.blocksize || arena->size + 2 * arena->blocksize != head.size){ if(namecmp(arena->name, head.name)!=0) - logerr(ECorrupt, "arena tail name %s head %s", + logerr(ECorrupt, "arena tail name %s head %s", arena->name, head.name); else if(arena->clumpmagic != head.clumpmagic) logerr(ECorrupt, "arena tail clumpmagic 0x%lux head 0x%lux", @@ -780,22 +780,22 @@ putcib(Arena *arena, CIBlock *cib) /* - * For index entry readahead purposes, the arenas are + * For index entry readahead purposes, the arenas are * broken into smaller subpieces, called clump info groups * or cigs. Each cig has ArenaCIGSize clumps (ArenaCIGSize * is chosen to make the index entries take up about half * a megabyte). The index entries do not contain enough * information to determine what the clump index is for * a given address in an arena. That info is needed both for - * figuring out which clump group an address belongs to + * figuring out which clump group an address belongs to * and for prefetching a clump group's index entries from * the arena table of contents. The first time clump groups * are accessed, we scan the entire arena table of contents - * (which might be 10s of megabytes), recording the data + * (which might be 10s of megabytes), recording the data * offset of each clump group. */ -/* +/* * load clump info group information by scanning entire toc. */ static void @@ -811,7 +811,7 @@ loadcig(Arena *arena) return; // fprint(2, "loadcig %s\n", arena->name); - + ncig = (arena->memstats.clumps+ArenaCIGSize-1) / ArenaCIGSize; if(ncig == 0){ arena->cig = vtmalloc(1); @@ -839,7 +839,7 @@ loadcig(Arena *arena) } } vtfree(ci); - + arena->ncig = ncig; arena->cig = cig; @@ -900,7 +900,7 @@ asumload(Arena *arena, int g, IEntry *entries, int nentries) fprint(2, "asking for too few entries\n"); return -1; } - + qlock(&arena->lock); if(arena->cig == nil) loadcig(arena); @@ -908,7 +908,7 @@ asumload(Arena *arena, int g, IEntry *entries, int nentries) qunlock(&arena->lock); return -1; } - + addr = 0; base = g*ArenaCIGSize; limit = base + ArenaCIGSize; diff --git a/src/cmd/venti/srv/bloom.c b/src/cmd/venti/srv/bloom.c index 42418d1c9..d50b17778 100644 --- a/src/cmd/venti/srv/bloom.c +++ b/src/cmd/venti/srv/bloom.c @@ -1,6 +1,6 @@ /* * Bloom filter tracking which scores are present in our arenas - * and (more importantly) which are not. + * and (more importantly) which are not. */ #include "stdinc.h" @@ -13,19 +13,19 @@ int bloominit(Bloom *b, vlong vsize, u8int *data) { ulong size; - + size = vsize; if(size != vsize){ /* truncation */ werrstr("bloom data too big"); return -1; } - + b->size = size; b->nhash = 32; /* will be fixed by caller on initialization */ if(data != nil) if(unpackbloomhead(b, data) < 0) return -1; - + b->bitmask = (b->size<<3) - 1; b->data = data; return 0; @@ -42,7 +42,7 @@ readbloom(Part *p) { uchar buf[512]; Bloom *b; - + b = vtmallocz(sizeof *b); if(readpart(p, 0, buf, sizeof buf) < 0) return nil; @@ -75,7 +75,7 @@ int resetbloom(Bloom *b) { uchar *data; - + data = vtmallocz(b->size); b->data = data; if(b->size == MaxBloomSize) /* 2^32 overflows ulong */ @@ -92,7 +92,7 @@ loadbloom(Bloom *b) uint ones; uchar *data; u32int *a; - + data = vtmallocz(b->size); if(readpart(b->part, 0, data, b->size) < 0){ vtfree(b); @@ -105,14 +105,14 @@ loadbloom(Bloom *b) n = b->size/4; ones = 0; for(i=0; isize == MaxBloomSize) /* 2^32 overflows ulong */ addstat(StatBloomBits, b->size*8-1); else addstat(StatBloomBits, b->size*8); - + return 0; } @@ -204,7 +204,7 @@ inbloomfilter(Bloom *b, u8int *score) if(ignorebloom) return 1; - + rlock(&b->lk); r = _inbloomfilter(b, score); runlock(&b->lk); @@ -236,7 +236,7 @@ markbloomfiltern(Bloom *b, u8int score[][20], int n) if(b == nil || b->data == nil) return; - + rlock(&b->lk); qlock(&b->mod); for(i=0; iwritechan, 0); @@ -268,5 +268,5 @@ startbloomproc(Bloom *b) { b->writechan = chancreate(sizeof(void*), 0); b->writedonechan = chancreate(sizeof(ulong), 0); - vtproc(bloomwriteproc, b); + vtproc(bloomwriteproc, b); } diff --git a/src/cmd/venti/srv/buildindex.c b/src/cmd/venti/srv/buildindex.c index 95fb74b72..faf4b4144 100644 --- a/src/cmd/venti/srv/buildindex.c +++ b/src/cmd/venti/srv/buildindex.c @@ -12,7 +12,7 @@ enum }; typedef struct IEntryBuf IEntryBuf; -struct IEntryBuf +struct IEntryBuf { IEntry ie[100]; int nie; @@ -61,7 +61,7 @@ threadmain(int argc, char *argv[]) u32int bcmem, imem; Config conf; Part *p; - + maxdisks = 100000; ventifmtinstall(); imem = 256*1024*1024; @@ -116,18 +116,18 @@ threadmain(int argc, char *argv[]) close(fd); } } - + /* * need a block for every arena */ bcmem = maxblocksize * (mainindex->narenas + 16); if(0) fprint(2, "initialize %d bytes of disk block cache\n", bcmem); initdcache(bcmem); - + totalclumps = 0; for(i=0; inarenas; i++) totalclumps += ix->arenas[i]->diskstats.clumps; - + totalbuckets = 0; for(i=0; insects; i++) totalbuckets += ix->sects[i]->blocks; @@ -142,7 +142,7 @@ threadmain(int argc, char *argv[]) vtproc(isectproc, ix->sects[i]); } } - + for(i=0; ibloom && writebloom(ix->bloom) < 0) fprint(2, "writing bloom filter: %r\n"); - fprint(2, "%T done arenaentries=%,lld indexed=%,lld (nskip=%,lld)\n", + fprint(2, "%T done arenaentries=%,lld indexed=%,lld (nskip=%,lld)\n", arenaentries, indexentries, skipentries); threadexitsall(nil); } @@ -189,7 +189,7 @@ static int shouldprocess(ISect *is) { int i; - + if(nisect == 0) return 1; @@ -205,7 +205,7 @@ static void add(u64int *a, u64int n) { static Lock l; - + lock(&l); *a += n; unlock(&l); @@ -233,7 +233,7 @@ arenapartproc(void *v) IEntryBuf *buf, *b; uchar *score; ScoreBuf sb; - + p = v; threadsetname("arenaproc %s", p->name); buf = MKNZ(IEntryBuf, ix->nsects); @@ -247,10 +247,10 @@ arenapartproc(void *v) if(a->part != p) continue; if(a->memstats.clumps) - fprint(2, "%T arena %s: %d entries\n", + fprint(2, "%T arena %s: %d entries\n", a->name, a->memstats.clumps); /* - * Running the loop backwards accesses the + * Running the loop backwards accesses the * clump info blocks forwards, since they are * stored in reverse order at the end of the arena. * This speeds things slightly. @@ -304,7 +304,7 @@ arenapartproc(void *v) } add(&arenaentries, tot); add(&skipentries, nskip); - + for(i=0; insects; i++) if(ix->sects[i]->writechan && buf[i].nie > 0) send(ix->sects[i]->writechan, &buf[i]); @@ -323,7 +323,7 @@ static u32int score2bucket(ISect *is, uchar *score) { u32int b; - + b = hashbits(score, 32)/ix->div; if(b < is->start || b >= is->stop){ fprint(2, "score2bucket: score=%V div=%d b=%ud start=%ud stop=%ud\n", @@ -340,7 +340,7 @@ static u32int offset2bucket(ISect *is, u64int offset) { u32int b; - + assert(is->blockbase <= offset); offset -= is->blockbase; b = offset/is->blocksize; @@ -358,7 +358,7 @@ bucket2offset(ISect *is, u32int b) return is->blockbase + (u64int)b*is->blocksize; } -/* +/* * IEntry buffers to hold initial round of spraying. */ typedef struct Buf Buf; @@ -378,7 +378,7 @@ static void bflush(Buf *buf) { u32int bufsize; - + if(buf->woffset >= buf->eoffset) sysfatal("buf index chunk overflow - need bigger index"); bufsize = buf->ep - buf->bp; @@ -420,11 +420,11 @@ struct Minibuf }; /* - * Index entry pool. Used when trying to shuffle around + * Index entry pool. Used when trying to shuffle around * the entries in a big buffer into the corresponding M minibuffers. * Sized to hold M*EntriesPerBlock entries, so that there will always * either be room in the pool for another block worth of entries - * or there will be an entire block worth of sorted entries to + * or there will be an entire block worth of sorted entries to * write out. */ typedef struct IEntryLink IEntryLink; @@ -461,7 +461,7 @@ countsokay(IPool *p) { int i; u64int n; - + n = 0; for(i=0; inmbuf; i++) n += p->mcount[i]; @@ -477,21 +477,21 @@ countsokay(IPool *p) */ static IPool* -mkipool(ISect *isect, Minibuf *mbuf, u32int nmbuf, +mkipool(ISect *isect, Minibuf *mbuf, u32int nmbuf, u32int mbufbuckets, u32int bufsize) { u32int i, nentry; uchar *data; IPool *p; IEntryLink *l; - + nentry = (nmbuf+1)*bufsize / IEntrySize; p = ezmalloc(sizeof(IPool) +nentry*sizeof(IEntry) +nmbuf*sizeof(IEntryLink*) +nmbuf*sizeof(u32int) +3*bufsize); - + p->isect = isect; p->mbufbuckets = mbufbuckets; p->bufsize = bufsize; @@ -516,7 +516,7 @@ mkipool(ISect *isect, Minibuf *mbuf, u32int nmbuf, return p; } -/* +/* * Add the index entry ie to the pool p. * Caller must know there is room. */ @@ -543,7 +543,7 @@ ipoolinsert(IPool *p, uchar *ie) l->next = p->mlist[x]; p->mlist[x] = l; p->mcount[x]++; -} +} /* * Pull out a block containing as many @@ -555,7 +555,7 @@ ipoolgetbuf(IPool *p, u32int x) uchar *bp, *ep, *wp; IEntryLink *l; u32int n; - + bp = p->wbuf; ep = p->wbuf + p->bufsize; n = 0; @@ -582,7 +582,7 @@ static void ipoolloadblock(IPool *p, Minibuf *mb) { u32int i, n; - + assert(mb->nentry > 0); assert(mb->roffset >= mb->woffset); assert(mb->roffset < mb->eoffset); @@ -609,14 +609,14 @@ ipoolflush0(IPool *pool, u32int x) { u32int bufsize; Minibuf *mb; - + mb = pool->mbuf+x; bufsize = pool->bufsize; mb->nwentry += ipoolgetbuf(pool, x); if(mb->nentry > 0 && mb->roffset == mb->woffset){ assert(pool->nfree >= pool->bufsize/IEntrySize); /* - * There will be room in the pool -- we just + * There will be room in the pool -- we just * removed a block worth. */ ipoolloadblock(pool, mb); @@ -655,7 +655,7 @@ static void ipoolflush(IPool *pool) { u32int i; - + for(i=0; inmbuf; i++) while(pool->mlist[i]) ipoolflush0(pool, i); @@ -668,7 +668,7 @@ ipoolflush(IPool *pool) */ /* - * Compare two packed index entries. + * Compare two packed index entries. * Usual ordering except break ties by putting higher * index addresses first (assumes have duplicates * due to corruption in the lower addresses). @@ -678,7 +678,7 @@ ientrycmpaddr(const void *va, const void *vb) { int i; uchar *a, *b; - + a = (uchar*)va; b = (uchar*)vb; i = ientrycmp(a, b); @@ -692,7 +692,7 @@ zerorange(Part *p, u64int o, u64int e) { static uchar zero[MaxIoSize]; u32int n; - + for(; o e) @@ -703,7 +703,7 @@ zerorange(Part *p, u64int o, u64int e) } /* - * Load a minibuffer into memory and write out the + * Load a minibuffer into memory and write out the * corresponding buckets. */ static void @@ -714,10 +714,10 @@ sortminibuffer(ISect *is, Minibuf *mb, uchar *buf, u32int nbuf, u32int bufsize) u64int o; IBucket ib; Part *part; - + part = is->part; buckdata = emalloc(is->blocksize); - + if(mb->nwentry == 0) return; @@ -732,7 +732,7 @@ sortminibuffer(ISect *is, Minibuf *mb, uchar *buf, u32int nbuf, u32int bufsize) return; } assert(*(uint*)buf != 0xa5a5a5a5); - + /* * remove fragmentation due to IEntrySize * not evenly dividing Bufsize @@ -746,7 +746,7 @@ sortminibuffer(ISect *is, Minibuf *mb, uchar *buf, u32int nbuf, u32int bufsize) ep = buf + mb->nwentry*IEntrySize; assert(ep <= buf+nbuf); - /* + /* * sort entries */ qsort(buf, mb->nwentry, IEntrySize, ientrycmpaddr); @@ -795,14 +795,14 @@ isectproc(void *v) IPool *ipool; ISect *is; Minibuf *mbuf, *mb; - + is = v; blocksize = is->blocksize; nbucket = is->stop - is->start; /* * Three passes: - * pass 1 - write index entries from arenas into + * pass 1 - write index entries from arenas into * large sequential sections on index disk. * requires nbuf * bufsize memory. * @@ -810,36 +810,36 @@ isectproc(void *v) * requires nminibuf * bufsize memory. * * pass 3 - read each minibuf into memory and - * write buckets out. + * write buckets out. * requires entries/minibuf * IEntrySize memory. - * + * * The larger we set bufsize the less seeking hurts us. - * + * * The fewer sections and minibufs we have, the less * seeking hurts us. - * - * The fewer sections and minibufs we have, the + * + * The fewer sections and minibufs we have, the * more entries we end up with in each minibuf - * at the end. + * at the end. * * Shoot for using half our memory to hold each - * minibuf. The chance of a random distribution - * getting off by 2x is quite low. + * minibuf. The chance of a random distribution + * getting off by 2x is quite low. * - * Once that is decided, figure out the smallest + * Once that is decided, figure out the smallest * nminibuf and nsection/biggest bufsize we can use * and still fit in the memory constraints. */ - + /* expected number of clump index entries we'll see */ xclump = nbucket * (double)totalclumps/totalbuckets; - + /* number of clumps we want to see in a minibuf */ xminiclump = isectmem/2/IEntrySize; - + /* total number of minibufs we need */ prod = (xclump+xminiclump-1) / xminiclump; - + /* if possible, skip second pass */ if(!dumb && prod*MinBufSize < isectmem){ nbuf = prod; @@ -904,7 +904,7 @@ isectproc(void *v) } } add(&indexentries, n); - + nn = 0; for(i=0; ipart->name); - + /* * Rearrange entries into minibuffers and then * split each minibuffer into buckets. - * The minibuffer must be sized so that it is + * The minibuffer must be sized so that it is * a multiple of blocksize -- ipoolloadblock assumes * that each minibuf starts aligned on a blocksize * boundary. @@ -971,7 +971,7 @@ isectproc(void *v) while(mb->nentry > 0){ if(ipool->nfree < epbuf){ ipoolflush1(ipool); - /* ipoolflush1 might change mb->nentry */ + /* ipoolflush1 might change mb->nentry */ continue; } assert(ipool->nfree >= epbuf); @@ -1002,9 +1002,6 @@ isectproc(void *v) } free(data); } - + sendp(isectdonechan, is); } - - - diff --git a/src/cmd/venti/srv/clumpstats.c b/src/cmd/venti/srv/clumpstats.c index d2cfe251c..1a7e016c2 100644 --- a/src/cmd/venti/srv/clumpstats.c +++ b/src/cmd/venti/srv/clumpstats.c @@ -122,6 +122,6 @@ threadmain(int argc, char *argv[]) initdcache(bcmem); clumpstats(mainindex); - + threadexitsall(0); } diff --git a/src/cmd/venti/srv/cmparenas.c b/src/cmd/venti/srv/cmparenas.c index 322f16ee1..5abf8575f 100644 --- a/src/cmd/venti/srv/cmparenas.c +++ b/src/cmd/venti/srv/cmparenas.c @@ -57,7 +57,7 @@ printheader(char *name, ArenaHead *head, int fd) Arena arena; vlong baseoff, lo, hi, off; int clumpmax; - + off = seek(fd, 0, 1); seek(fd, off + head->size - head->blocksize, 0); if(readblock(fd, data, head->blocksize) < 0){ @@ -91,7 +91,7 @@ printheader(char *name, ArenaHead *head, int fd) lo = hi; fprint(2, "\t%llx-%llx: clumps (%llx)\n", lo, hi, hi - lo); fprint(2, "\t%llx-%llx: tail\n", hi, hi + head->blocksize); - + fprint(2, "arena:\n"); printarena(2, &arena); return 0; @@ -149,7 +149,7 @@ cmparena(char *name, vlong len) if(printheader(name, &head, fd) < 0) return; - + /* * now we know how much to read * read everything but the last block, which is special @@ -196,7 +196,7 @@ static int shouldcheck(char *name, char **s, int n) { int i; - + if(n == 0) return 1; @@ -213,7 +213,7 @@ char * readap(int fd, ArenaPart *ap) { char *table; - + if(preadblock(fd, data, 8192, PartBlank) < 0) sysfatal("read arena part header: %r"); if(unpackarenapart(ap, data) < 0) @@ -237,7 +237,7 @@ threadmain(int argc, char *argv[]) vlong start, stop; ArenaPart ap; ArenaPart ap1; - + ventifmtinstall(); blocksize = MaxIoSize; ARGBEGIN{ diff --git a/src/cmd/venti/srv/config.c b/src/cmd/venti/srv/config.c index 8c29fe95f..e7dde3e4d 100644 --- a/src/cmd/venti/srv/config.c +++ b/src/cmd/venti/srv/config.c @@ -201,7 +201,7 @@ configisect(char *file) { Part *part; ISect *is; - + if(0) fprint(2, "configure index section in %s\n", file); part = initpart(file, ORDWR|ODIRECT); @@ -252,4 +252,3 @@ void needmainindex(void) { } - diff --git a/src/cmd/venti/srv/conv.c b/src/cmd/venti/srv/conv.c index e6a6cbfe1..90aefbecd 100644 --- a/src/cmd/venti/srv/conv.c +++ b/src/cmd/venti/srv/conv.c @@ -162,7 +162,7 @@ unpackarena(Arena *arena, u8int *buf) * all the existing version 4 arenas too. * * To maintain backwards compatibility with existing venti - * installations using the older format, we define that if + * installations using the older format, we define that if * memstats == diskstats, then the extension fields are not * included (see packarena below). That is, only partially * indexed arenas have these fields. Fully indexed arenas @@ -181,7 +181,7 @@ unpackarena(Arena *arena, u8int *buf) p += U64Size; arena->memstats.sealed = U8GET(p); p += U8Size; - + /* * 2008/4/2 * Packarena (below) used to have a bug in which it would @@ -264,7 +264,7 @@ _packarena(Arena *arena, u8int *buf, int forceext) p += U64Size; U8PUT(p, arena->diskstats.sealed); p += U8Size; - + /* * Extension fields; see above. */ @@ -281,7 +281,7 @@ _packarena(Arena *arena, u8int *buf, int forceext) p += U32Size; U32PUT(p, arena->memstats.cclumps); p += U32Size; - U64PUT(p, arena->memstats.used, t32); + U64PUT(p, arena->memstats.used, t32); p += U64Size; U64PUT(p, arena->memstats.uncsize, t32); p += U64Size; @@ -669,7 +669,7 @@ unpackibucket(IBucket *b, u8int *buf, u32int magic) b->data = buf + IBucketSize; if(magic && magic != U32GET(buf+U16Size)) b->n = 0; -} +} void packibucket(IBucket *b, u8int *buf, u32int magic) @@ -705,7 +705,7 @@ unpackbloomhead(Bloom *b, u8int *buf) return -1; } p += U32Size; - + m = U32GET(p); if(m != BloomVersion){ seterr(ECorrupt, "bloom filter has wrong version %ud expected %ud", (uint)m, (uint)BloomVersion); diff --git a/src/cmd/venti/srv/dat.h b/src/cmd/venti/srv/dat.h index f47d01a12..68e6c8f5a 100644 --- a/src/cmd/venti/srv/dat.h +++ b/src/cmd/venti/srv/dat.h @@ -90,7 +90,7 @@ enum ArenaPartMagic = 0xa9e4a5e7U, /* arena partition header */ ArenaMagic = 0xf2a14eadU, /* arena trailer */ ArenaHeadMagic = 0xd15c4eadU, /* arena header */ - + BloomMagic = 0xb1004eadU, /* bloom filter header */ BloomMaxHash = 32, @@ -145,7 +145,7 @@ enum IEntryAddrOff = VtScoreSize + U32Size + U16Size, MaxClumpBlocks = (VtMaxLumpSize + ClumpSize + (1 << ABlockLog) - 1) >> ABlockLog, - + IcacheFrac = 1000000, /* denominator */ SleepForever = 1000000000, /* magic value for sleep time */ @@ -156,7 +156,7 @@ enum DirtyArenaCib, DirtyArenaTrailer, DirtyMax, - + ArenaCIGSize = 10*1024, // about 0.5 MB worth of IEntry. VentiZZZZZZZZ @@ -231,7 +231,7 @@ struct DBlock u32int used2; u32int ref; /* reference count */ RWLock lock; /* for access to data only */ - Channel *writedonechan; + Channel *writedonechan; void* chanbuf[1]; /* buffer for the chan! */ }; @@ -315,7 +315,7 @@ struct CIBlock }; /* - * Statistics kept in the tail. + * Statistics kept in the tail. */ struct ATailStats { @@ -382,7 +382,7 @@ struct Arena u32int ctime; /* first time a block was written */ u32int wtime; /* last time a block was written */ u32int clumpmagic; - + ArenaCIG *cig; int ncig; }; @@ -465,7 +465,7 @@ struct Index Bloom *bloom; /* bloom filter */ /* - * fields stored in config file + * fields stored in config file */ u32int version; char name[ANameSize]; /* text label */ @@ -473,7 +473,7 @@ struct Index AMap *smap; /* mapping of buckets to index sections */ int narenas; AMap *amap; /* mapping from index addesses to arenas */ - + QLock writing; }; @@ -529,7 +529,7 @@ struct IEntry /* on disk data - 32 bytes*/ u8int score[VtScoreSize]; IAddr ia; - + IEntry *nexthash; IEntry *nextdirty; IEntry *next; @@ -657,7 +657,7 @@ enum StatSumRead, StatSumReadBytes, - + StatCigLoad, StatCigLoadTime, @@ -762,4 +762,3 @@ extern ulong stattime; #pragma varargck type "V" uchar* #define ODIRECT 0 #endif - diff --git a/src/cmd/venti/srv/dcache.c b/src/cmd/venti/srv/dcache.c index a50ef0c5c..f4f008988 100644 --- a/src/cmd/venti/srv/dcache.c +++ b/src/cmd/venti/srv/dcache.c @@ -1,23 +1,23 @@ /* * Disk cache. - * + * * Caches raw disk blocks. Getdblock() gets a block, putdblock puts it back. * Getdblock has a mode parameter that determines i/o and access to a block: * if mode is OREAD or ORDWR, it is read from disk if not already in memory. * If mode is ORDWR or OWRITE, it is locked for exclusive use before being returned. * It is *not* marked dirty -- once changes have been made, they should be noted - * by using dirtydblock() before putdblock(). + * by using dirtydblock() before putdblock(). * - * There is a global cache lock as well as a lock on each block. + * There is a global cache lock as well as a lock on each block. * Within a thread, the cache lock can be acquired while holding a block lock, * but not vice versa; and a block cannot be locked if you already hold the lock * on another block. - * + * * The flush proc writes out dirty blocks in batches, one batch per dirty tag. * For example, the DirtyArena blocks are all written to disk before any of the * DirtyArenaCib blocks. * - * This code used to be in charge of flushing the dirty index blocks out to + * This code used to be in charge of flushing the dirty index blocks out to * disk, but updating the index turned out to benefit from extra care. * Now cached index blocks are never marked dirty. The index.c code takes * care of updating them behind our back, and uses _getdblock to update any @@ -134,7 +134,7 @@ DBlock* getdblock(Part *part, u64int addr, int mode) { DBlock *b; - + b = _getdblock(part, addr, mode, 1); if(mode == OREAD || mode == ORDWR) addstat(StatDcacheRead, 1); @@ -335,7 +335,7 @@ static void unchain(DBlock *b) { ulong h; - + /* * unchain the block */ @@ -395,7 +395,7 @@ void emptydcache(void) { DBlock *b; - + qlock(&dcache.lock); while(dcache.nheap > 0){ b = dcache.heap[0]; @@ -575,7 +575,7 @@ parallelwrites(DBlock **b, DBlock **eb, int dirty) assert(b<=p && pwritedonechan); } - + /* * Flush the partitions that have been written to. */ diff --git a/src/cmd/venti/srv/disksched.c b/src/cmd/venti/srv/disksched.c index d43b64c7f..0315425c4 100644 --- a/src/cmd/venti/srv/disksched.c +++ b/src/cmd/venti/srv/disksched.c @@ -15,7 +15,7 @@ disksched(void) ulong t; vlong cflush; Stats *prev; - + /* * no locks because all the data accesses are atomic. */ @@ -40,22 +40,22 @@ disksched(void) /* # entries written to index cache */ nwrite = stats.n[StatIcacheWrite] - prev->n[StatIcacheWrite]; - + /* # dirty entries in index cache */ ndirty = stats.n[StatIcacheDirty] - prev->n[StatIcacheDirty]; - + /* # entries flushed to disk */ nflush = nwrite - ndirty; - + /* want to stay around 70% dirty */ tdirty = (vlong)stats.n[StatIcacheSize]*700/1000; - + /* assume nflush*icachesleeptime is a constant */ cflush = (vlong)nflush*(icachesleeptime+1); - + /* computer number entries to write in next minute */ toflush = nwrite + (stats.n[StatIcacheDirty] - tdirty); - + /* schedule for that many */ if(toflush <= 0 || cflush/toflush > 100000) icachesleeptime = SleepForever; @@ -86,4 +86,3 @@ diskaccess(int level) } lasttime[level] = time(0); } - diff --git a/src/cmd/venti/srv/fixarenas.c b/src/cmd/venti/srv/fixarenas.c index d7ae41d39..8fc4f55db 100644 --- a/src/cmd/venti/srv/fixarenas.c +++ b/src/cmd/venti/srv/fixarenas.c @@ -6,7 +6,7 @@ * * The rule here (hopefully followed!) is that block corruption * only ever has a local effect -- there are no blocks that you - * can wipe out that will cause large portions of + * can wipe out that will cause large portions of * uncorrupted data blocks to be useless. */ @@ -26,7 +26,7 @@ enum K = 1024, M = 1024*1024, G = 1024*1024*1024, - + Block = 4096, }; @@ -64,7 +64,7 @@ static int zfmt(Fmt *fmt) { vlong x; - + x = va_arg(fmt->args, vlong); if(x == 0) return fmtstrcpy(fmt, "0"); @@ -85,7 +85,7 @@ tfmt(Fmt *fmt) { uint t; char buf[30]; - + t = va_arg(fmt->args, uint); strcpy(buf, ctime(t)); buf[28] = 0; @@ -133,7 +133,7 @@ readdisk(uchar *buf, vlong offset, int len) memset(buf, 0xFB, len); return buf; } - + if(offset+len > partend){ memset(buf, 0xFB, len); len = partend - offset; @@ -141,7 +141,7 @@ readdisk(uchar *buf, vlong offset, int len) if(readpart(part, offset, buf, len) >= 0) return buf; - + /* * The read failed. Clear the buffer to nonsense, and * then try reading in smaller pieces. If that fails, @@ -191,7 +191,7 @@ void sbdebug(Shabuf *sb, char *file) { int fd; - + if(sb->fd > 0){ close(sb->fd); sb->fd = 0; @@ -234,7 +234,7 @@ sbupdate(Shabuf *sb, uchar *p, vlong offset, int len) len -= x; } assert(sb->offset == offset); - + if(sb->fd > 0) pwrite(sb->fd, p, len, offset - sb->r0); @@ -243,7 +243,7 @@ sbupdate(Shabuf *sb, uchar *p, vlong offset, int len) sb->offset += len; return; } - + /* save state every 4M so we can roll back quickly */ o = offset - sb->r0; while(len > 0){ @@ -265,7 +265,7 @@ sbupdate(Shabuf *sb, uchar *p, vlong offset, int len) } sb->hist[x] = sb->state; } - } + } } void @@ -273,7 +273,7 @@ sbdiskhash(Shabuf *sb, vlong eoffset) { static uchar dbuf[4*M]; int n; - + while(sb->offset < eoffset){ n = sizeof dbuf; if(sb->offset+n > eoffset) @@ -289,7 +289,7 @@ sbrollback(Shabuf *sb, vlong offset) int x; vlong o; Dir d; - + if(!sb->rollback || !sb->r0){ print("cannot rollback sha\n"); return; @@ -305,7 +305,7 @@ sbrollback(Shabuf *sb, vlong offset) sb->state = sb->hist[x]; sb->offset = sb->r0 + x*4*M; assert(sb->offset <= offset); - + if(sb->fd > 0){ nulldir(&d); d.length = sb->offset - sb->r0; @@ -325,7 +325,7 @@ sbscore(Shabuf *sb, uchar *score) /* * If we're fixing arenas, then editing this memory edits the disk! - * It will be written back out as new data is paged in. + * It will be written back out as new data is paged in. */ uchar buf[4*M]; uchar sbuf[4*M]; @@ -341,7 +341,7 @@ pagein(vlong offset, int len) memset(buf, 0xFB, sizeof buf); return buf; } - + if(offset+len > partend){ memset(buf, 0xFB, sizeof buf); len = partend - offset; @@ -373,16 +373,16 @@ zerorange(vlong offset, int len) vlong ooff; int olen; enum { MinBlock = 4*K, MaxBlock = 8*K }; - + if(0) if(bufoffset <= offset && offset+len <= bufoffset+buflen){ memset(buf+(offset-bufoffset), 0, len); return; } - + ooff = bufoffset; olen = buflen; - + i = offset%MinBlock; if(i+len < MaxBlock){ pagein(offset-i, (len+MinBlock-1)&~(MinBlock-1)); @@ -455,7 +455,7 @@ static int vlongcmp(const void *va, const void *vb) { vlong a, b; - + a = *(vlong*)va; b = *(vlong*)vb; if(a < b) @@ -524,7 +524,7 @@ Info tailinfo4[] = { 1, "sealed", 0 }; - + Info tailinfo4a[] = { /* tailinfo 4 */ 4, "magic", @@ -547,7 +547,7 @@ Info tailinfo4a[] = { 1, "mem.sealed", 0 }; - + Info tailinfo5[] = { 4, "magic", D|4, "version", @@ -586,12 +586,12 @@ Info tailinfo5a[] = { 1, "mem.sealed", 0 }; - + void showdiffs(uchar *want, uchar *have, int len, Info *info) { int n; - + while(len > 0 && (n=info->len&N) > 0){ if(memcmp(have, want, n) != 0){ switch(info->len){ @@ -625,7 +625,7 @@ showdiffs(uchar *want, uchar *have, int len, Info *info) break; case S|ANameSize: print("\t%s: correct=%s disk=%.*s\n", - info->name, (char*)want, + info->name, (char*)want, utfnlen((char*)have, ANameSize-1), (char*)have); break; @@ -672,7 +672,7 @@ guessgeometry(void) uchar *p, *ep, *sp; u64int diff[100], head[20], tail[20]; u64int offset, bestdiff; - + ap.version = ArenaPartVersion; if(arenasize == 0 || ap.blocksize == 0){ @@ -705,8 +705,8 @@ guessgeometry(void) } if(nhead < 3 && ntail < 3) sysfatal("too few intact arenas: %d heads, %d tails", nhead, ntail); - - /* + + /* * Arena size is likely the most common * inter-head or inter-tail spacing. */ @@ -816,7 +816,7 @@ guessgeometry(void) } } p = pagein(ap.arenabase, Block); - print("arena base likely %z%s\n", (vlong)ap.arenabase, + print("arena base likely %z%s\n", (vlong)ap.arenabase, u32(p)!=ArenaHeadMagic ? " (but no arena head there)" : ""); ap.tabsize = ap.arenabase - ap.tabbase; @@ -893,7 +893,7 @@ isclump(uchar *p, Clump *cl, u32int *pmagic) uchar score[VtScoreSize], *bp; Unwhack uw; uchar ubuf[70*1024]; - + bp = p; magic = u32(p); if(magic == 0) @@ -942,7 +942,7 @@ isclump(uchar *p, Clump *cl, u32int *pmagic) return 0; } p += cl->info.size; - + /* it all worked out in the end */ *pmagic = magic; return p - bp; @@ -975,7 +975,7 @@ int* ltreewalk(int *p, uchar *score) { int i; - + for(;;){ if(*p == -1) return p; @@ -993,7 +993,7 @@ void addcibuf(ClumpInfo *ci, vlong corrupt) { Cit *cit; - + if(ncibuf == mcibuf){ mcibuf += 131072; cibuf = vtrealloc(cibuf, mcibuf*sizeof cibuf[0]); @@ -1012,7 +1012,7 @@ void addcicorrupt(vlong len) { static ClumpInfo zci; - + addcibuf(&zci, len); } @@ -1021,7 +1021,7 @@ haveclump(uchar *score) { int i; int p; - + p = ciroot; for(;;){ if(p == -1) @@ -1054,7 +1054,7 @@ int sealedarena(uchar *p, int blocksize) { int v, n; - + v = u32(p+4); switch(v){ default: @@ -1085,13 +1085,13 @@ int okayname(char *name, int n) { char buf[20]; - + if(nameok(name) < 0) return 0; sprint(buf, "%d", n); if(n == 0) buf[0] = 0; - if(strlen(name) < strlen(buf) + if(strlen(name) < strlen(buf) || strcmp(name+strlen(name)-strlen(buf), buf) != 0) return 0; return 1; @@ -1115,7 +1115,7 @@ loadci(vlong offset, Arena *arena, int nci) int i, j, per; uchar *p, *sp; ClumpInfo *bci, *ci; - + per = arena->blocksize/ClumpInfoSize; bci = vtmalloc(nci*sizeof bci[0]); ci = bci; @@ -1139,7 +1139,7 @@ writeci(vlong offset, Arena *arena, ClumpInfo *ci, int nci) { int i, j, per; uchar *p, *sp; - + per = arena->blocksize/ClumpInfoSize; offset += arena->size - arena->blocksize; p = sp = nil; @@ -1177,11 +1177,11 @@ loadarenabasics(vlong offset0, int anum, ArenaHead *head, Arena *arena) if(offset0+arena->size > partend) arena->size = partend - offset0; head->size = arena->size; - + arena->blocksize = ap.blocksize; head->blocksize = arena->blocksize; - - /* + + /* * Look for clump magic and name in head/tail blocks. * All the other info we will reconstruct just in case. */ @@ -1194,7 +1194,7 @@ loadarenabasics(vlong offset0, int anum, ArenaHead *head, Arena *arena) strcpy(head->name, ohead.name); } - p = pagein(offset0+arena->size-arena->blocksize, + p = pagein(offset0+arena->size-arena->blocksize, arena->blocksize); memset(&oarena, 0, sizeof oarena); if(unpackarena(&oarena, p) >= 0){ @@ -1228,7 +1228,7 @@ print("old arena: sealed=%d\n", oarena.diskstats.sealed); strcpy(lastbase, arena->name); sprint(dname, "%d", anum); lastbase[strlen(lastbase)-strlen(dname)] = 0; - + /* Was working in arena, now copy to head. */ head->version = arena->version; memmove(head->name, arena->name, sizeof head->name); @@ -1240,7 +1240,7 @@ void shahead(Shabuf *sb, vlong offset0, ArenaHead *head) { uchar headbuf[MaxDiskBlock]; - + sb->offset = offset0; memset(headbuf, 0, sizeof headbuf); packarenahead(head, headbuf); @@ -1251,7 +1251,7 @@ u32int newclumpmagic(int version) { u32int m; - + if(version == ArenaVersion4) return _ClumpMagic; do{ @@ -1279,7 +1279,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, ClumpInfo *bci, *ci, *eci, *xci; Cit *bcit, *cit, *ecit; Shabuf oldsha, newsha; - + /* * We expect to find an arena, with data, between offset * and offset+arenasize. With any luck, the data starts at @@ -1314,7 +1314,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, loadarenabasics(offset0, anum, head, arena); /* start the clump hunt */ - + clumps = 0; totalcorrupt = 0; sealing = 1; @@ -1424,7 +1424,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, * grow clump info blocks if needed. */ if(verbose > 1) - print("\tclump %d: %d %V at %#llux+%#ux (%d)\n", + print("\tclump %d: %d %V at %#llux+%#ux (%d)\n", clumps, cl.info.type, cl.info.score, offset, n, n); addcibuf(&cl.info, 0); if(minclumps%ncib == 0) @@ -1435,7 +1435,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, arena->diskstats.cclumps++; arena->diskstats.uncsize += cl.info.uncsize; arena->wtime = cl.time; - + /* * Move to next clump. */ @@ -1470,7 +1470,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, pageout(); if(verbose) - print("readable clumps: %d; min. directory entries: %d\n", + print("readable clumps: %d; min. directory entries: %d\n", clumps, minclumps); arena->diskstats.used = lastclumpend - boffset; leaked = eoffset - lastclumpend; @@ -1488,10 +1488,10 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, sbupdate(&oldsha, dbuf, toffset, arena->blocksize); sbscore(&oldsha, oldscore); } - + /* * If we still don't know the clump magic, the arena - * must be empty. It still needs a value, so make + * must be empty. It still needs a value, so make * something up. */ if(arena->version == 0) @@ -1537,7 +1537,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, v = offset0 + arena->size - arena->blocksize; clumps = (v-lastclumpend)/arena->blocksize * ncib; } - + if(clumps < minclumps) print("cannot happen?\n"); @@ -1546,7 +1546,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, * The tricky part is handling the corrupt sections of arena. * If possible, we remark just the affected directory entries * rather than slide everything down. - * + * * Allocate clumps+1 blocks and check that we don't need * the last one at the end. */ @@ -1554,7 +1554,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, eci = bci+clumps+1; bcit = cibuf; ecit = cibuf+ncibuf; - + smart = 0; /* Somehow the smart code doesn't do corrupt clumps right. */ Again: nbad = 0; @@ -1614,11 +1614,11 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, if(clumpinfocmp(&cit->ci, ci) != 0){ if(verbose && (smart || verbose>1)){ print("clumpinfo %d\n", (int)(ci-bci)); - print("\twant: %d %d %d %V\n", + print("\twant: %d %d %d %V\n", cit->ci.type, cit->ci.size, cit->ci.uncsize, cit->ci.score); - print("\thave: %d %d %d %V\n", - ci->type, ci->size, + print("\thave: %d %d %d %V\n", + ci->type, ci->size, ci->uncsize, ci->score); } *ci = cit->ci; @@ -1633,7 +1633,7 @@ guessarena(vlong offset0, int anum, ArenaHead *head, Arena *arena, smart = 0; goto Again; } - + assert(ci <= eci); arena->diskstats.clumps = ci-bci; eoffset = writeci(offset0, arena, bci, ci-bci); @@ -1661,7 +1661,7 @@ print("eoffset=%lld lastclumpend=%lld diff=%lld unseal=%d\n", eoffset, lastclump arena->memstats = arena->diskstats; if(sealing && fix){ uchar tbuf[MaxDiskBlock]; - + sbdiskhash(&newsha, toffset); memset(tbuf, 0, sizeof tbuf); packarena(arena, tbuf); @@ -1676,7 +1676,7 @@ dumparena(vlong offset, int anum, Arena *arena) char buf[1000]; vlong o, e; int fd, n; - + snprint(buf, sizeof buf, "%s.%d", dumpbase, anum); if((fd = create(buf, OWRITE, 0666)) < 0){ fprint(2, "create %s: %r\n", buf); @@ -1703,7 +1703,7 @@ checkarena(vlong offset, int anum) ArenaHead head; Info *fmt, *fmta; int sz; - + print("# arena %d: offset %#llux\n", anum, offset); if(offset >= partend){ @@ -1737,11 +1737,11 @@ checkarena(vlong offset, int anum) p = pagein(offset, arena.blocksize); if(memcmp(dbuf, p, arena.blocksize) != 0){ print("on-disk arena header incorrect\n"); - showdiffs(dbuf, p, arena.blocksize, + showdiffs(dbuf, p, arena.blocksize, arena.version==ArenaVersion4 ? headinfo4 : headinfo5); } memmove(p, dbuf, arena.blocksize); - + memset(dbuf, 0, sizeof dbuf); packarena(&arena, dbuf); if(arena.diskstats.sealed) @@ -1781,14 +1781,14 @@ checkarena(vlong offset, int anum) print("\t disk=%V\n", p+arena.blocksize-VtScoreSize); } if(fix && scorecmp(p+arena.blocksize-VtScoreSize, score) != 0){ - print("%ssealing arena%s: %V\n", + print("%ssealing arena%s: %V\n", oarena.diskstats.sealed ? "re" : "", - scorecmp(oldscore, score) == 0 ? + scorecmp(oldscore, score) == 0 ? "" : " after changes", score); } } memmove(p, dbuf, arena.blocksize); - + pageout(); } @@ -1800,7 +1800,7 @@ buildamap(void) ArenaHead h; AMapN *an; AMap *m; - + an = vtmallocz(sizeof *an); for(o=ap.arenabase; oname, h.name); } } - return an; + return an; } void @@ -1823,7 +1823,7 @@ checkmap(void) int i, len; AMapN *an; Fmt fmt; - + an = buildamap(); fmtstrinit(&fmt); fmtprint(&fmt, "%ud\n", an->n); @@ -1837,7 +1837,7 @@ checkmap(void) (vlong)len, (vlong)ap.tabsize); len = ap.tabsize; } - + if(ap.tabsize >= 4*M){ /* can't happen - max arenas is 2000 */ print("arena partition map *way* too long\n"); return; @@ -1857,9 +1857,9 @@ void threadmain(int argc, char **argv) { int mode; - + mode = OREAD; - readonly = 1; + readonly = 1; ARGBEGIN{ case 'U': unseal = 1; @@ -1887,22 +1887,22 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 1 && argc != 2) usage(); file = argv[0]; - + ventifmtinstall(); fmtinstall('z', zfmt); fmtinstall('t', tfmt); quotefmtinstall(); - + part = initpart(file, mode|ODIRECT); if(part == nil) sysfatal("can't open %s: %r", file); partend = part->size; - + if(isonearena()){ checkarena(0, -1); threadexitsall(nil); @@ -1911,4 +1911,3 @@ threadmain(int argc, char **argv) checkmap(); threadexitsall(nil); } - diff --git a/src/cmd/venti/srv/fmtbloom.c b/src/cmd/venti/srv/fmtbloom.c index 76677871f..db08b91a1 100644 --- a/src/cmd/venti/srv/fmtbloom.c +++ b/src/cmd/venti/srv/fmtbloom.c @@ -19,7 +19,7 @@ threadmain(int argc, char *argv[]) vlong bits, size, size2; int nhash; vlong nblocks; - + ventifmtinstall(); statsinit(); @@ -62,7 +62,7 @@ threadmain(int argc, char *argv[]) if(size == 0) size = part->size; - + if(size < 1024*1024) sysfatal("bloom filter too small"); @@ -93,7 +93,7 @@ threadmain(int argc, char *argv[]) } /* - * optimal is to use ln 2 times as many hash functions as we have bits per blocks. + * optimal is to use ln 2 times as many hash functions as we have bits per blocks. */ bits = (8*size)/nblocks; nhash = bits*7/10; diff --git a/src/cmd/venti/srv/graph.c b/src/cmd/venti/srv/graph.c index db12c3d9a..f43363693 100644 --- a/src/cmd/venti/srv/graph.c +++ b/src/cmd/venti/srv/graph.c @@ -36,7 +36,7 @@ Memimage* allocrepl(ulong color) { Memimage *m; - + m = allocmemimage(Rect(0,0,1,1), RGB24); memfillcolor(m, color); m->flags |= Frepl; @@ -49,10 +49,10 @@ ginit(void) { static int first = 1; int i; - + if(!first) return; - + first = 0; memimageinit(); #ifdef PLAN9PORT @@ -90,7 +90,7 @@ drawlabel(Memimage *m, Point p, int n) { char buf[30]; Point w; - + mklabel(buf, n); w = memsubfontwidth(smallfont, buf); memimagestring(m, Pt(p.x-5-w.x, p.y), memblack, ZP, smallfont, buf); @@ -117,7 +117,7 @@ statgraph(Graph *g) Statbin *b, bin[2000]; /* 32 kB, but whack is worse */ needstack(8192); /* double check that bin didn't kill us */ - + if(g->wid <= MinWidth) g->wid = DefaultWidth; if(g->ht <= MinHeight) @@ -128,7 +128,7 @@ statgraph(Graph *g) g->fill = ((uint)(uintptr)g->arg>>8)%nelem(lofill); if(g->fill > nelem(lofill)) g->fill %= nelem(lofill); - + nbin = g->wid - (Left+Right); binstats(g->fn, g->arg, g->t0, g->t1, bin, nbin); @@ -168,7 +168,7 @@ statgraph(Graph *g) } r = Rect(Left, Top, g->wid-Right, g->ht-Bottom); memfillcolor(m, DTransparent); - + /* x axis */ memimagedraw(m, Rect(r.min.x, r.max.y, r.max.x, r.max.y+1), black, ZP, memopaque, ZP, S); @@ -176,7 +176,7 @@ statgraph(Graph *g) drawlabel(m, r.min, max); if(min != 0) drawlabel(m, Pt(r.min.x, r.max.y-smallfont->height), min); - + /* actual data */ for(i=0; ihout, "

venti disks

\n"); hprint(&c->hout, "
\n");
 	ix = mainindex;
@@ -83,7 +83,7 @@ readap(Part *p, ArenaPart *ap)
 {
 	uchar *blk;
 	char *table;
-	
+
 	blk = vtmalloc(8192);
 	if(readpart(p, PartBlank, blk, 8192) != 8192)
 		return nil;
@@ -108,7 +108,7 @@ xfindarena(char *table, char *name, vlong *start, vlong *end)
 {
 	int i, nline;
 	char *p, *q, *f[4], line[256];
-	
+
 	nline = atoi(table);
 	p = strchr(table, '\n');
 	if(p)
@@ -212,7 +212,7 @@ diskarenapart(HConnect *c, char *disk, Part *p)
 		hprint(&c->hout, "%r\n");
 		goto out;
 	}
-	
+
 	hprint(&c->hout, "
\n");
 	hprint(&c->hout, "version=%d blocksize=%d base=%d\n",
 		ap.version, ap.blocksize, ap.arenabase);
@@ -223,12 +223,12 @@ diskarenapart(HConnect *c, char *disk, Part *p)
 		diskarenatable(c, disk, table);
 		goto out;
 	}
-	
+
 	if(xfindarena(table, arenaname, &start, &end) < 0){
 		hprint(&c->hout, "no such arena %s\n", arenaname);
 		goto out;
 	}
-	
+
 	hprint(&c->hout, "

arena %s

\n", arenaname); hprint(&c->hout, "
start=%#llx end=%#llx
\n", start, end);
 	if(end < start || end - start < HeadSize){
@@ -253,7 +253,7 @@ diskarenapart(HConnect *c, char *disk, Part *p)
 
 	hprint(&c->hout, "head:\n
\n");
 	hprint(&c->hout, "version=%d name=%s blocksize=%d size=%#llx clumpmagic=%#ux\n",
-		head.version, head.name, head.blocksize, head.size, 
+		head.version, head.name, head.blocksize, head.size,
 		head.clumpmagic);
 	hprint(&c->hout, "


\n"); @@ -281,7 +281,7 @@ diskarenapart(HConnect *c, char *disk, Part *p) scorecp(arena.score, blk+head.blocksize - VtScoreSize); vtfree(blk); - + hprint(&c->hout, "tail:\n
\n");
 	hprint(&c->hout, "version=%d name=%s\n", arena.version, arena.name);
 	hprint(&c->hout, "ctime=%d %s\n", arena.ctime, fmttime(tbuf, arena.ctime));
@@ -389,10 +389,10 @@ diskarenatoc(HConnect *c, Arena *arena)
 		}
 		unpackclumpinfo(&ci, blk+(i%arena->clumpmax)*ClumpInfoSize);
 		if(i/arena->clumpmax == cib || i%arena->clumpmax == 0){
-			hprint(&c->hout, "%5d %6d %7d %V", 
+			hprint(&c->hout, "%5d %6d %7d %V",
 				ci.type, ci.size, ci.uncsize, ci.score);
 			if(coff >= 0)
-				hprint(&c->hout, " at %#llx", 
+				hprint(&c->hout, " at %#llx",
 					base, coff, ci.score, coff);
 			if(i/arena->clumpmax != cib)
 				hprint(&c->hout, "  more", base, i/arena->clumpmax);
@@ -415,7 +415,7 @@ diskarenaclump(HConnect *c, Arena *arena, vlong off, char *scorestr)
 	uchar xscore[VtScoreSize], score[VtScoreSize];
 	Unwhack uw;
 	int n;
-	
+
 	if(scorestr){
 		if(vtparsescore(scorestr, nil, score) < 0){
 			hprint(&c->hout, "bad score %s: %r\n", scorestr);
@@ -436,7 +436,7 @@ diskarenaclump(HConnect *c, Arena *arena, vlong off, char *scorestr)
 		hprint(&c->hout, "bad offset %#llx\n", off);
 		return -1;
 	}
-	
+
 	off += arena->base;
 
 	blk = vtmalloc(ClumpSize + VtMaxLumpSize);
@@ -461,15 +461,15 @@ diskarenaclump(HConnect *c, Arena *arena, vlong off, char *scorestr)
 
 	hprint(&c->hout, "
type=%d size=%d uncsize=%d score=%V\n", cl.info.type, cl.info.size, cl.info.uncsize, cl.info.score);
 	hprint(&c->hout, "encoding=%d creator=%d time=%d %s
\n", cl.encoding, cl.creator, cl.time, fmttime(err, cl.time)); - + if(cl.info.type == VtCorruptType) hprint(&c->hout, "clump is marked corrupt
\n"); - + if(cl.info.size >= VtMaxLumpSize){ hprint(&c->hout, "clump too big\n"); goto error; } - + switch(cl.encoding){ case ClumpECompress: blk2 = vtmalloc(VtMaxLumpSize); @@ -493,7 +493,7 @@ diskarenaclump(HConnect *c, Arena *arena, vlong off, char *scorestr) scoremem(xscore, blk+ClumpSize, cl.info.size); break; } - + hprint(&c->hout, "score=%V
\n", xscore); if(scorestr && scorecmp(score, xscore) != 0) hprint(&c->hout, "score does NOT match expected %V\n", score); @@ -536,7 +536,7 @@ debugamap(HConnect *c) amap = mainindex->amap; for(i=0; inarenas; i++) - hprint(&c->hout, "%s %#llx %#llx\n", + hprint(&c->hout, "%s %#llx %#llx\n", amap[i].name, amap[i].start, amap[i].stop); } @@ -559,23 +559,23 @@ debugread(HConnect *c, u8int *score) hprint(&c->hout, "zero score\n"); return; } - + hprint(&c->hout, "

index search %V

\n", score);
 	if(icachelookup(score, -1, &ia) < 0)
 		hprint(&c->hout, "  icache: not found\n");
 	else
 		hprint(&c->hout, "  icache: addr=%#llx size=%d type=%d blocks=%d\n",
 			ia.addr, ia.size, ia.type, ia.blocks);
-	
+
 	if(loadientry(mainindex, score, -1, &ie) < 0)
 		hprint(&c->hout, "  idisk: not found\n");
 	else
 		hprint(&c->hout, "  idisk: addr=%#llx size=%d type=%d blocks=%d\n",
 			ie.ia.addr, ie.ia.size, ie.ia.type, ie.ia.blocks);
-	
+
 	hprint(&c->hout, "

lookup %V

\n", score); hprint(&c->hout, "
\n");
-	
+
 	for(type=0; type < VtMaxType; type++){
 		hprint(&c->hout, "%V type %d:", score, type);
 		u = lookuplump(score, type);
@@ -584,14 +584,14 @@ debugread(HConnect *c, u8int *score)
 		else
 			hprint(&c->hout, " -cache");
 		putlump(u);
-		
+
 		if(lookupscore(score, type, &ia) < 0){
 			hprint(&c->hout, " -lookup\n");
 			continue;
 		}
 		hprint(&c->hout, "\n  lookupscore: addr=%#llx size=%d blocks=%d\n",
 			ia.addr, ia.size, ia.blocks);
-		
+
 		arena = amapitoa(mainindex, ia.addr, &aa);
 		if(arena == nil){
 			hprint(&c->hout, "  amapitoa failed: %r\n");
@@ -606,7 +606,7 @@ debugread(HConnect *c, u8int *score)
 			hprint(&c->hout, "  loadclump failed: %r\n");
 			continue;
 		}
-		
+
 		hprint(&c->hout, "  loadclump: uncsize=%d type=%d score=%V\n",
 			cl.info.uncsize, cl.info.type, sc);
 		if(ia.size != cl.info.uncsize || ia.type != cl.info.type || scorecmp(score, sc) != 0){
@@ -614,12 +614,12 @@ debugread(HConnect *c, u8int *score)
 			continue;
 		}
 	}
-	
+
 	if(hargstr(c, "brute", "")[0] == 'y'){
 		hprint(&c->hout, "
\n"); hprint(&c->hout, "

brute force arena search %V

\n", score); hprint(&c->hout, "
\n");
-		
+
 		for(i=0; inarenas; i++){
 			arena = mainindex->arenas[i];
 			hprint(&c->hout, "%s...\n", arena->name);
@@ -637,10 +637,10 @@ static void
 debugmem(HConnect *c)
 {
 	Index *ix;
-	
+
 	ix = mainindex;
 	hprint(&c->hout, "

memory

\n"); - + hprint(&c->hout, "
\n");
 	hprint(&c->hout, "ix=%p\n", ix);
 	hprint(&c->hout, "\tarenas=%p\n", ix->arenas);
@@ -660,7 +660,7 @@ hdebug(HConnect *c)
 {
 	char *scorestr, *op;
 	u8int score[VtScoreSize];
-	
+
 	if(hsethtml(c) < 0)
 		return -1;
 	hprint(&c->hout, "

venti debug

\n"); @@ -670,7 +670,7 @@ hdebug(HConnect *c) hprint(&c->hout, "no op\n"); return 0; } - + if(strcmp(op, "amap") == 0){ debugamap(c); return 0; @@ -690,7 +690,7 @@ hdebug(HConnect *c) debugread(c, score); return 0; } - + hprint(&c->hout, "unknown op %s", op); return 0; } diff --git a/src/cmd/venti/srv/hproc.c b/src/cmd/venti/srv/hproc.c index 42933920a..3da217cec 100644 --- a/src/cmd/venti/srv/hproc.c +++ b/src/cmd/venti/srv/hproc.c @@ -7,11 +7,10 @@ int hproc(HConnect *c) { int r; - + if((r = hsettext(c)) < 0) return r; hprint(&c->hout, "/proc only implemented on Plan 9\n"); hflush(&c->hout); return 0; } - diff --git a/src/cmd/venti/srv/httpd.c b/src/cmd/venti/srv/httpd.c index 83d80ca77..05896ff4e 100644 --- a/src/cmd/venti/srv/httpd.c +++ b/src/cmd/venti/srv/httpd.c @@ -51,7 +51,7 @@ httpdinit(char *address, char *dir) if(address == nil) address = "tcp!*!http"; webroot = dir; - + httpdobj("/stats", estats); httpdobj("/index", dindex); httpdobj("/storage", sindex); @@ -168,7 +168,7 @@ httpproc(void *v) */ if(hparsereq(c, 0) < 0) break; - + for(i = 0; i < MaxObjs && objs[i].name[0]; i++){ n = strlen(objs[i].name); if((objs[i].name[n-1] == '/' && strncmp(c->req.uri, objs[i].name, n) == 0) @@ -196,7 +196,7 @@ char* hargstr(HConnect *c, char *name, char *def) { HSPairs *p; - + for(p=c->req.searchpairs; p; p=p->next) if(strcmp(p->s, name) == 0) return p->t; @@ -207,7 +207,7 @@ vlong hargint(HConnect *c, char *name, vlong def) { char *a; - + if((a = hargstr(c, name, nil)) == nil) return def; return atoll(a); @@ -282,7 +282,7 @@ herror(HConnect *c) { int n; Hio *hout; - + hout = &c->hout; n = snprint(c->xferbuf, HBufSize, "Error\n

Error

\n
%r
\n"); hprint(hout, "%s %s\r\n", hversion, "400 Bad Request"); @@ -301,7 +301,7 @@ herror(HConnect *c) return hflush(hout); } - + int hnotfound(HConnect *c) { @@ -331,7 +331,7 @@ fromwebdir(HConnect *c) char buf[4096], *p, *ext, *type; int i, fd, n, defaulted; Dir *d; - + if(webroot == nil || strstr(c->req.uri, "..")) return hnotfound(c); snprint(buf, sizeof buf-20, "%s/%s", webroot, c->req.uri+1); @@ -430,7 +430,7 @@ xset(HConnect *c) hflush(&c->hout); return 0; } - + old = *namedints[i].p; *namedints[i].p = atoll(value); hprint(&c->hout, "%s = %d (was %d)\n", name, *namedints[i].p, old); @@ -496,7 +496,7 @@ estats(HConnect *c) percent(stats.absorbedwrites, stats.dirtydblocks)); hprint(hout, "disk cache flushes=%,ld\n", stats.dcacheflushes); - hprint(hout, "disk cache flush writes=%,ld (%,ld per flush)\n", + hprint(hout, "disk cache flush writes=%,ld (%,ld per flush)\n", stats.dcacheflushwrites, stats.dcacheflushwrites/(stats.dcacheflushes ? stats.dcacheflushes : 1)); @@ -821,7 +821,7 @@ diskbw(Stats *s) ulong *n; n = s->n; - return n[StatApartReadBytes]+n[StatApartWriteBytes] + return n[StatApartReadBytes]+n[StatApartWriteBytes] + n[StatIsectReadBytes]+n[StatIsectWriteBytes] + n[StatSumReadBytes]; } @@ -882,7 +882,7 @@ static char* graphname[] = "lcachesize", "lcachestall", "lcachelookuptime", - + "dcachehit", "dcachemiss", "dcachelookup", @@ -931,7 +931,7 @@ static char* graphname[] = "sumread", "sumreadbyte", - + "cigload", "cigloadtime", }; @@ -996,7 +996,7 @@ xgraph(HConnect *c) g.ht = hargint(c, "ht", -1); dotext = hargstr(c, "text", "")[0] != 0; g.fill = hargint(c, "fill", -1); - + graph = hargstr(c, "graph", "raw"); if(strcmp(graph, "raw") == 0) g.fn = rawgraph; @@ -1135,14 +1135,14 @@ vtloghdump(Hio *h, VtLog *l) int i; VtLogChunk *c; char *name; - + name = l ? l->name : "<nil>"; hprint(h, "\n"); hprint(h, "Venti Server Log: %s\n", name); hprint(h, "\n"); hprint(h, "Venti Server Log: %s\n

\n", name); - + if(l){ c = l->w; for(i=0; inchunk; i++){ @@ -1165,12 +1165,12 @@ vtloghlist(Hio *h) { char **p; int i, n; - + hprint(h, "\n"); hprint(h, "Venti Server Logs\n"); hprint(h, "\n"); hprint(h, "Venti Server Logs\n

\n"); - + p = vtlognames(&n); qsort(p, n, sizeof(p[0]), strpcmp); for(i=0; itable[0])); ih->table = (IEntry**)(ih+1); ih->bits = bits; @@ -80,7 +80,7 @@ ihashlookup(IHash *ih, u8int score[VtScoreSize], int type) { u32int h; IEntry *ie; - + h = hashbits(score, ih->bits); for(ie=ih->table[h]; ie; ie=ie->nexthash) if((type == -1 || type == ie->ia.type) && scorecmp(score, ie->score) == 0) @@ -93,7 +93,7 @@ ihashdelete(IHash *ih, IEntry *ie, char *what) { u32int h; IEntry **l; - + h = hashbits(ie->score, ih->bits); for(l=&ih->table[h]; *l; l=&(*l)->nexthash) if(*l == ie){ @@ -107,7 +107,7 @@ static void ihashinsert(IHash *ih, IEntry *ie) { u32int h; - + h = hashbits(ie->score, ih->bits); ie->nexthash = ih->table[h]; ih->table[h] = ie; @@ -203,7 +203,7 @@ scacheevict(void) { ISum *s; int i; - + for(i=icache.nsum-1; i>=0; i--){ s = icache.sum[i]; if(canqlock(&s->lock)){ @@ -281,7 +281,7 @@ scachemiss(u64int addr) qunlock(&s->lock); return nil; } - + return s; /* locked */ } @@ -294,7 +294,7 @@ initicache(u32int mem0) { u32int mem; int i, entries, scache; - + icache.full.l = &icache.lock; mem = mem0; @@ -312,7 +312,7 @@ fprint(2, "icache %,d bytes = %,d entries; %d scache\n", mem0, entries, scache); icache.clean.prev = icache.clean.next = &icache.clean; icache.dirty.prev = icache.dirty.next = &icache.dirty; icache.free.prev = icache.free.next = (IEntry*)&icache.free; - + icache.hash = mkihash(entries); icache.nentries = entries; setstat(StatIcacheSize, entries); @@ -338,7 +338,7 @@ static IEntry* evictlru(void) { IEntry *ie; - + ie = poplast(&icache.clean); if(ie == nil) return nil; @@ -356,7 +356,7 @@ icacheinsert(u8int score[VtScoreSize], IAddr *ia, int state) while((ie = poplast(&icache.free)) == nil && (ie = evictlru()) == nil){ // Could safely return here if state == IEClean. // But if state == IEDirty, have to wait to make - // sure we don't lose an index write. + // sure we don't lose an index write. // Let's wait all the time. flushdcache(); kickicache(); @@ -444,7 +444,7 @@ insertscore(u8int score[VtScoreSize], IAddr *ia, int state, AState *as) scacheload(toload); qunlock(&toload->lock); } - + if(icache.ndirty >= icache.maxdirty) kickicache(); @@ -483,7 +483,7 @@ lookupscore(u8int score[VtScoreSize], int type, IAddr *ia) addstat2(StatIcacheRead, 1, StatIcacheReadTime, msec() - ms); return ret; } - + u32int hashbits(u8int *sc, int bits) { @@ -550,7 +550,7 @@ void icacheclean(IEntry *ie) { IEntry *next; - + trace(TraceProc, "icacheclean enter"); qlock(&icache.lock); for(; ie; ie=next){ @@ -574,7 +574,7 @@ emptyicache(void) int i; IEntry *ie; ISum *s; - + qlock(&icache.lock); while((ie = evictlru()) != nil) pushfirst(&icache.free, ie); @@ -586,4 +586,3 @@ emptyicache(void) } qunlock(&icache.lock); } - diff --git a/src/cmd/venti/srv/icachewrite.c b/src/cmd/venti/srv/icachewrite.c index e1406ef15..d2e5a8158 100644 --- a/src/cmd/venti/srv/icachewrite.c +++ b/src/cmd/venti/srv/icachewrite.c @@ -81,7 +81,7 @@ nextchunk(Index *ix, ISect *is, IEntry **pie, u64int *paddr, uint *pnbuf) *pnbuf = nbuf; return iefirst; } - + static int icachewritesect(Index *ix, ISect *is, u8int *buf) { @@ -192,7 +192,7 @@ icachewritesect(Index *ix, ISect *is, u8int *buf) err = -1; continue; } - + addstat(StatIsectWriteBytes, nbuf); addstat(StatIsectWrite, 1); icacheclean(chunk); @@ -264,7 +264,7 @@ icachewritecoord(void *v) send(ix->sects[i]->writechan, 0); if(ix->bloom) send(ix->bloom->writechan, 0); - + err = 0; for(i=0; insects; i++) err |= recvul(ix->sects[i]->writedonechan); @@ -355,4 +355,3 @@ iesort(IEntry *ie) *l = nil; return sorted; } - diff --git a/src/cmd/venti/srv/index.c b/src/cmd/venti/srv/index.c index 07bf81c86..c3baa9059 100644 --- a/src/cmd/venti/srv/index.c +++ b/src/cmd/venti/srv/index.c @@ -1,21 +1,21 @@ /* - * Index, mapping scores to log positions. + * Index, mapping scores to log positions. * * The index is made up of some number of index sections, each of - * which is typically stored on a different disk. The blocks in all the - * index sections are logically numbered, with each index section + * which is typically stored on a different disk. The blocks in all the + * index sections are logically numbered, with each index section * responsible for a range of blocks. Blocks are typically 8kB. * * The N index blocks are treated as a giant hash table. The top 32 bits * of score are used as the key for a lookup. Each index block holds * one hash bucket, which is responsible for ceil(2^32 / N) of the key space. - * - * The index is sized so that a particular bucket is extraordinarily - * unlikely to overflow: assuming compressed data blocks are 4kB + * + * The index is sized so that a particular bucket is extraordinarily + * unlikely to overflow: assuming compressed data blocks are 4kB * on disk, and assuming each block has a 40 byte index entry, * the index data will be 1% of the total data. Since scores are essentially * random, all buckets should be about the same fullness. - * A factor of 5 gives us a wide comfort boundary to account for + * A factor of 5 gives us a wide comfort boundary to account for * random variation. So the index disk space should be 5% of the arena disk space. */ @@ -500,7 +500,7 @@ initisect1(ISect *is) v = is->part->size & ~(u64int)(is->blocksize - 1); if(is->blockbase + (u64int)is->blocks * is->blocksize != v){ seterr(ECorrupt, "invalid blocks in index section %s", is->name); - /* ZZZ what to do? + /* ZZZ what to do? freeisect(is); return nil; */ @@ -654,7 +654,7 @@ amapitoag(Index *ix, u64int a, u64int *gstart, u64int *glimit, int *g) { u64int aa; Arena *arena; - + arena = amapitoa(ix, a, &aa); if(arena == nil) return nil; @@ -895,5 +895,3 @@ loadibucket(Index *ix, u8int *score, ISect **pis, u32int *pbuck, IBucket *ib) { return loadibucket1(ix, score, pis, pbuck, ib); } - - diff --git a/src/cmd/venti/srv/lump.c b/src/cmd/venti/srv/lump.c index cc0a26dc6..3e66068a8 100644 --- a/src/cmd/venti/srv/lump.c +++ b/src/cmd/venti/srv/lump.c @@ -178,7 +178,7 @@ writeqlump(Lump *u, Packet *p, int creator, uint ms) insertlump(u, p); else packetfree(p); - + if(syncwrites){ flushdcache(); flushicache(); diff --git a/src/cmd/venti/srv/lumpcache.c b/src/cmd/venti/srv/lumpcache.c index 93fed6d1a..0fdc0102c 100644 --- a/src/cmd/venti/srv/lumpcache.c +++ b/src/cmd/venti/srv/lumpcache.c @@ -73,7 +73,7 @@ lookuplump(u8int *score, int type) ms = 0; trace(TraceLump, "lookuplump enter"); - + h = hashbits(score, HashLog); /* @@ -426,4 +426,3 @@ checklumpcache(void) if(lumpcache.nheap + nfree + refed != lumpcache.nblocks) sysfatal("lc: missing blocks: %d %d %d %d", lumpcache.nheap, refed, nfree, lumpcache.nblocks); } - diff --git a/src/cmd/venti/srv/lumpqueue.c b/src/cmd/venti/srv/lumpqueue.c index 869eaeae0..a312ad178 100644 --- a/src/cmd/venti/srv/lumpqueue.c +++ b/src/cmd/venti/srv/lumpqueue.c @@ -127,7 +127,7 @@ flushqueue(void) qunlock(&q->lock); } } - + static void queueproc(void *vq) { diff --git a/src/cmd/venti/srv/mgr.c b/src/cmd/venti/srv/mgr.c index 9a615b2c0..93e87a393 100644 --- a/src/cmd/venti/srv/mgr.c +++ b/src/cmd/venti/srv/mgr.c @@ -105,7 +105,7 @@ rdconf(char *file, Conf *conf) char *s, *line, *flds[10]; int i, ok; IFile f; - + if(readifile(&f, file) < 0) return -1; memset(conf, 0, sizeof *conf); @@ -132,7 +132,7 @@ rdconf(char *file, Conf *conf) }else if(i == 3 && strcmp(flds[1], "verify") == 0) { if(conf->nverify%64 == 0) conf->verify = vtrealloc(conf->verify, (conf->nverify+64)*sizeof(conf->verify[0])); - conf->verify[conf->nverify++] = vtstrdup(flds[2]); + conf->verify[conf->nverify++] = vtstrdup(flds[2]); }else if(i == 3 && strcmp(flds[1], "verifyfreq") == 0) { conf->verifyfreq = atoi(flds[2]); }else if(i == 3 && strcmp(flds[1], "httpaddr") == 0){ @@ -186,7 +186,7 @@ logtext(VtLog *l) int i; char *p; VtLogChunk *c; - + p = logbuf; c = l->w; for(i=0; inchunk; i++) { @@ -283,7 +283,7 @@ hsettext(HConnect *c) { return hsettype(c, "text/plain; charset=utf-8"); } - + int hnotfound(HConnect *c) { @@ -316,12 +316,12 @@ vtloghlist(Hio *h) { char **p; int i, n; - + hprint(h, "\n"); hprint(h, "Venti Server Logs\n"); hprint(h, "\n"); hprint(h, "Venti Server Logs\n

\n"); - + p = vtlognames(&n); qsort(p, n, sizeof(p[0]), strpcmp); for(i=0; iname : "<nil>"; hprint(h, "\n"); hprint(h, "Venti Server Log: %s\n", name); hprint(h, "\n"); hprint(h, "Venti Server Log: %s\n

\n", name); - + if(l){ c = l->w; for(i=0; inchunk; i++){ @@ -360,7 +360,7 @@ char* hargstr(HConnect *c, char *name, char *def) { HSPairs *p; - + for(p=c->req.searchpairs; p; p=p->next) if(strcmp(p->s, name) == 0) return p->t; @@ -446,7 +446,7 @@ httpproc(void *v) */ if(hparsereq(c, 0) < 0) break; - + for(i = 0; i < MaxObjs && objs[i].name[0]; i++){ n = strlen(objs[i].name); if((objs[i].name[n-1] == '/' && strncmp(c->req.uri, objs[i].name, n) == 0) @@ -508,7 +508,7 @@ fromwebdir(HConnect *c) char buf[4096], *p, *ext, *type; int i, fd, n, defaulted; Dir *d; - + if(conf.webroot == nil || strstr(c->req.uri, "..")) return hnotfound(c); snprint(buf, sizeof buf-20, "%s/%s", conf.webroot, c->req.uri+1); @@ -614,7 +614,7 @@ piper(void *v) int fd; char *p; int ok; - + j = v; fd = j->pipe; l = j->newlog; @@ -625,7 +625,7 @@ piper(void *v) } qlock(&loglk); p = logtext(l); - ok = j->ok(p); + ok = j->ok(p); qunlock(&loglk); j->newok = ok; close(fd); @@ -808,7 +808,7 @@ threadmain(int argc, char **argv) int nofork; char *prog; Job *j; - + ventilogging = 1; ventifmtinstall(); #ifdef PLAN9PORT @@ -893,8 +893,8 @@ void qp(Biobuf *b, char *p) { int n, nspace; - - nspace = 0; + + nspace = 0; n = 0; for(; *p; p++) { if(*p == '\n') { @@ -934,7 +934,7 @@ smtpread(Biobuf *b, int code) { char *p, *q; int n; - + while((p = Brdstr(b, '\n', 1)) != nil) { n = strtol(p, &q, 10); if(n == 0 || q != p+3) { @@ -957,13 +957,13 @@ smtpread(Biobuf *b, int code) return -1; } - + void sendmail(char *content, char *subject, char *msg) { int fd; Biobuf *bin, *bout; - + if((fd = dial(conf.smtp, 0, 0, 0)) < 0) { vtlogprint(errlog, "dial %s: %r\n", conf.smtp); return; @@ -979,7 +979,7 @@ sendmail(char *content, char *subject, char *msg) Bterm(bout); return; } - + Bprint(bout, "HELO venti-mgr\n"); Bflush(bout); if(smtpread(bin, 250) < 0) @@ -994,12 +994,12 @@ sendmail(char *content, char *subject, char *msg) Bflush(bout); if(smtpread(bin, 250) < 0) goto error; - + Bprint(bout, "DATA\n"); Bflush(bout); if(smtpread(bin, 354) < 0) goto error; - + Bprint(bout, "From: \"venti mgr\" <%s>\n", conf.mailfrom); Bprint(bout, "To: <%s>\n", conf.mailto); Bprint(bout, "Subject: %s\n", subject); @@ -1013,7 +1013,7 @@ sendmail(char *content, char *subject, char *msg) Bflush(bout); if(smtpread(bin, 250) < 0) goto error; - + Bprint(bout, "QUIT\n"); Bflush(bout); Bterm(bin); diff --git a/src/cmd/venti/srv/mirrorarenas.c b/src/cmd/venti/srv/mirrorarenas.c index c0d02e65d..adca4a784 100644 --- a/src/cmd/venti/srv/mirrorarenas.c +++ b/src/cmd/venti/srv/mirrorarenas.c @@ -1,5 +1,5 @@ /* - * Mirror one arena partition onto another. + * Mirror one arena partition onto another. * Be careful to copy only new data. */ @@ -41,7 +41,7 @@ void tag(int indx, char *name, char *fmt, ...) { va_list arg; - + if(tagged){ free(tagged); tagged = nil; @@ -53,7 +53,7 @@ tag(int indx, char *name, char *fmt, ...) va_end(arg); } -enum +enum { Sealed = 1, Mirrored = 2, @@ -99,7 +99,7 @@ setstatus(int bits) if(bits < 0) { startindx = -1; return; - } + } } void @@ -132,7 +132,7 @@ ereadpart(Part *p, u64int offset, u8int *buf, u32int count) } return 0; } - + int ewritepart(Part *p, u64int offset, u8int *buf, u32int count) { @@ -153,7 +153,7 @@ static void writeproc(void *v) { Write *w; - + USED(v); while((w = recvp(writechan)) != nil){ if(w == &wsync) @@ -175,7 +175,7 @@ copy(uvlong start, uvlong end, char *what, DigestState *ds) static uchar *tmp[2]; uchar *p; Write w[2]; - + assert(start <= end); assert(astart <= start && start < aend); assert(astart <= end && end <= aend); @@ -240,7 +240,7 @@ copy1(uvlong start, uvlong end, char *what, DigestState *ds) int n; uvlong o; static uchar tmp[1024*1024]; - + assert(start <= end); assert(astart <= start && start < aend); assert(astart <= end && end <= aend); @@ -310,16 +310,16 @@ mirror(int indx, Arena *sa, Arena *da) ArenaHead h; DigestState xds, *ds; vlong shaoff, base; - + base = sa->base; blocksize = sa->blocksize; end = sa->base + sa->size; - + astart = base - blocksize; aend = end + blocksize; tag(indx, sa->name, "%T %s (%,llud-%,llud)\n", sa->name, astart, aend); - + if(force){ copy(astart, aend, "all", nil); return; @@ -357,7 +357,7 @@ mirror(int indx, Arena *sa, Arena *da) if(ewritepart(dst, end, buf, blocksize) < 0) return; } - + memset(&h, 0, sizeof h); h.version = da->version; strcpy(h.name, da->name); @@ -379,7 +379,7 @@ mirror(int indx, Arena *sa, Arena *da) sha1(buf, blocksize, nil, ds); shaoff = base; } - + if(sa->diskstats.used != da->diskstats.used){ di = base+rdown(da->diskstats.used, blocksize); si = base+rup(sa->diskstats.used, blocksize); @@ -389,14 +389,14 @@ mirror(int indx, Arena *sa, Arena *da) return; shaoff = si; } - + clumpmax = sa->clumpmax; di = end - da->diskstats.clumps/clumpmax * blocksize; si = end - (sa->diskstats.clumps+clumpmax-1)/clumpmax * blocksize; if(sa->diskstats.sealed){ /* - * might be a small hole between the end of the + * might be a small hole between the end of the * data and the beginning of the directory. */ v = base+rup(sa->diskstats.used, blocksize); @@ -419,7 +419,7 @@ mirror(int indx, Arena *sa, Arena *da) da->wtime = sa->wtime; da->diskstats = sa->diskstats; da->diskstats.sealed = 0; - + /* * Repack the arena tail information * and save it for next time... @@ -525,7 +525,7 @@ mirrormany(ArenaPart *sp, ArenaPart *dp, char *range) mirror(i, sa, da); } setstatus(-1); - } + } } @@ -536,7 +536,7 @@ threadmain(int argc, char **argv) Arena *sa, *da; ArenaPart *s, *d; char *ranges; - + ventifmtinstall(); ARGBEGIN{ @@ -552,7 +552,7 @@ threadmain(int argc, char **argv) default: usage(); }ARGEND - + if(argc != 2 && argc != 3) usage(); ranges = nil; @@ -571,7 +571,7 @@ threadmain(int argc, char **argv) sysfatal("loadarenapart %s: %r", argv[1]); for(i=0; inarenas; i++) delarena(d->arenas[i]); - + /* * The arena geometries must match or all bets are off. */ @@ -589,7 +589,7 @@ threadmain(int argc, char **argv) if(strcmp(sa->name, da->name) != 0) sysfatal("arena %d: name mismatch: %s vs %s", i, sa->name, da->name); } - + /* * Mirror one arena at a time. */ diff --git a/src/cmd/venti/srv/part.c b/src/cmd/venti/srv/part.c index ae0448149..c1fb929fd 100644 --- a/src/cmd/venti/srv/part.c +++ b/src/cmd/venti/srv/part.c @@ -56,7 +56,7 @@ strtoullsuf(char *p, char **pp, int rad, u64int *u) *u = v; return 0; } - + static int parsepart(char *name, char **file, char **subpart, u64int *lo, u64int *hi) { @@ -221,11 +221,11 @@ partblocksize(Part *part, u32int blocksize) * Most Unix systems require that when accessing a block device directly, * the buffer, offset, and count are all multiples of the device block size, * making this a lot more complicated than it otherwise would be. - * + * * Most of our callers will make things easy on us, but for some callers it's best * if we just do the work here, with only one place to get it right (hopefully). - * - * If everything is aligned properly, prwb will try to do big transfers in the main + * + * If everything is aligned properly, prwb will try to do big transfers in the main * body of the loop: up to MaxIo bytes at a time. If everything isn't aligned properly, * we work one block at a time. */ @@ -412,7 +412,7 @@ rwpart(Part *part, int isread, u64int offset, u8int *buf, u32int count) int n, try; u32int blocksize; - trace(TraceDisk, "%s %s %ud at 0x%llx", + trace(TraceDisk, "%s %s %ud at 0x%llx", isread ? "read" : "write", part->name, count, offset); if(offset >= part->size || offset+count > part->size){ seterr(EStrange, "out of bounds %s offset 0x%llux count %ud to partition %s size 0x%llux", @@ -491,7 +491,7 @@ readfile(char *name) /* * Search for the Plan 9 partition with the given name. - * This lets you write things like /dev/ad4:arenas + * This lets you write things like /dev/ad4:arenas * if you move a disk from a Plan 9 system to a FreeBSD system. * * God I hope I never write this code again. @@ -566,7 +566,7 @@ findsubpart(Part *part, char *name) /* See if this is a Plan 9 partition. */ if(tryplan9part(part, name) >= 0) return 0; - + /* Otherwise try for an MBR and then narrow to Plan 9 partition. */ if(readpart(part, 0, buf, 512) != 512) return -1; @@ -587,8 +587,3 @@ findsubpart(Part *part, char *name) } return -1; } - - - - - diff --git a/src/cmd/venti/srv/png.c b/src/cmd/venti/srv/png.c index 8805ada42..85901a92a 100644 --- a/src/cmd/venti/srv/png.c +++ b/src/cmd/venti/srv/png.c @@ -99,7 +99,7 @@ zread(void *va, void *buf, int n) b[2] = (b[2]*255)/a; } } - }else + }else b += pixwid*pixels; z->x += pixels; @@ -148,7 +148,7 @@ memRGBA(Memimage *i) Memimage *ni; char buf[32]; ulong dst; - + /* * [A]BGR because we want R,G,B,[A] in big-endian order. Sigh. */ @@ -157,7 +157,7 @@ memRGBA(Memimage *i) dst = ABGR32; else dst = BGR24; - + if(i->chan == dst) return i; @@ -194,7 +194,7 @@ writepng(Hio *io, Memimage *m) return -1; hwrite(io, PNGmagic, sizeof PNGmagic); - + /* IHDR chunk */ h = buf; put4(h, Dx(m->r)); h += 4; diff --git a/src/cmd/venti/srv/rdarena.c b/src/cmd/venti/srv/rdarena.c index 9d7cd20e4..42be56632 100644 --- a/src/cmd/venti/srv/rdarena.c +++ b/src/cmd/venti/srv/rdarena.c @@ -33,7 +33,7 @@ rdarena(Arena *arena) if(a + bs > e) bs = arena->blocksize; if(readpart(arena->part, a, b->data, bs) < 0) - fprint(2, "can't copy %s, read at %lld failed: %r\n", arena->name, a); + fprint(2, "can't copy %s, read at %lld failed: %r\n", arena->name, a); if(write(1, b->data, bs) != bs) sysfatal("can't copy %s, write at %lld failed: %r", arena->name, a); } diff --git a/src/cmd/venti/srv/readifile.c b/src/cmd/venti/srv/readifile.c index a822a9878..ddfef1410 100644 --- a/src/cmd/venti/srv/readifile.c +++ b/src/cmd/venti/srv/readifile.c @@ -18,10 +18,10 @@ threadmain(int argc, char *argv[]) default: usage(); }ARGEND - + if(argc != 1) usage(); - + if(readifile(&ifile, argv[0]) < 0) sysfatal("readifile %s: %r", argv[0]); write(1, ifile.b->data, ifile.b->len); diff --git a/src/cmd/venti/srv/reseal.c b/src/cmd/venti/srv/reseal.c index f7353122e..41a53ce10 100644 --- a/src/cmd/venti/srv/reseal.c +++ b/src/cmd/venti/srv/reseal.c @@ -97,7 +97,7 @@ verify(Arena *arena, void *data, uchar *newscore) bs = e - n; sha1(data, bs, nil, &ds); } - + /* last block */ if(preadblock(data, arena->blocksize, o + e) < 0){ werrstr("read: %r"); @@ -113,7 +113,7 @@ verify(Arena *arena, void *data, uchar *newscore) } fprint(2, "warning: score mismatch %V != %V\n", score, arena->score); } - + /* prepare new last block */ memset(data, 0, arena->blocksize); packarena(arena, data); @@ -158,17 +158,17 @@ resealarena(char *name, vlong len) if(loadheader(name, &head, &arena, off) < 0) return; - + if(!arena.diskstats.sealed){ fprint(2, "%s: not sealed\n", name); return; } - + if(verify(&arena, data, newscore) < 0){ fprint(2, "%s: failed to verify before reseal: %r\n", name); return; } - + if(pwriteblock(data, arena.blocksize, arena.base + arena.size) < 0){ fprint(2, "%s: writing new tail: %r\n", name); return; @@ -188,7 +188,7 @@ static int shouldcheck(char *name, char **s, int n) { int i; - + if(n == 0) return 1; @@ -205,7 +205,7 @@ char * readap(ArenaPart *ap) { char *table; - + if(preadblock(data, 8192, PartBlank) < 0) sysfatal("read arena part header: %r"); if(unpackarenapart(ap, data) < 0) @@ -229,7 +229,7 @@ threadmain(int argc, char *argv[]) vlong start, stop; ArenaPart ap; Part *part; - + ventifmtinstall(); blocksize = MaxIoSize; ARGBEGIN{ diff --git a/src/cmd/venti/srv/round.c b/src/cmd/venti/srv/round.c index bbf4a478a..5e01b0baf 100644 --- a/src/cmd/venti/srv/round.c +++ b/src/cmd/venti/srv/round.c @@ -99,4 +99,3 @@ delaykickroundproc(void *v) trace(TraceProc, "finishround 0x%ux", (uint)n); } } - diff --git a/src/cmd/venti/srv/sortientry.c b/src/cmd/venti/srv/sortientry.c index b8b8e876c..e65b99883 100644 --- a/src/cmd/venti/srv/sortientry.c +++ b/src/cmd/venti/srv/sortientry.c @@ -262,7 +262,7 @@ sortiebucks(IEBucks *ib) if(n == TWID32) return TWID64; if(n != ib->bucks[i].total/IEntrySize) - fprint(2, "bucket %d changed count %d => %d\n", + fprint(2, "bucket %d changed count %d => %d\n", i, (int)(ib->bucks[i].total/IEntrySize), n); tot += n; } diff --git a/src/cmd/venti/srv/stats.c b/src/cmd/venti/srv/stats.c index bb944760b..e2f077be5 100644 --- a/src/cmd/venti/srv/stats.c +++ b/src/cmd/venti/srv/stats.c @@ -17,7 +17,7 @@ Statdesc statdesc[NStat] = { "rpc read cached time", }, { "rpc read uncached", }, { "rpc read uncached time "}, - + { "rpc writes", }, { "rpc writes new", }, { "rpc writes old", }, @@ -83,7 +83,7 @@ Statdesc statdesc[NStat] = { "sum reads", }, { "sum read bytes", }, - + { "cig loads" }, { "cig load time" }, }; @@ -158,9 +158,9 @@ binstats(long (*fn)(Stats *s0, Stats *s1, void *arg), void *arg, int i, j, lo, hi, m; vlong tot; Statbin *b; - + t = stats.now; - + /* negative times mean relative to now. */ if(t0 <= 0) t0 += t; @@ -170,7 +170,7 @@ binstats(long (*fn)(Stats *s0, Stats *s1, void *arg), void *arg, if(t1 <= t0) t0 = t1 - 60*10; if(0) fprint(2, "stats %ld-%ld\n", t0, t1); - + /* binary search to find t0-1 or close */ lo = stattime; hi = stattime+nstathist; @@ -208,5 +208,5 @@ binstats(long (*fn)(Stats *s0, Stats *s1, void *arg), void *arg, b->avg = tot / b->nsamp; if(b->nsamp==0 && i>0) *b = bin[i-1]; - } + } } diff --git a/src/cmd/venti/srv/syncindex0.c b/src/cmd/venti/srv/syncindex0.c index be3a2ea06..9928ca03f 100644 --- a/src/cmd/venti/srv/syncindex0.c +++ b/src/cmd/venti/srv/syncindex0.c @@ -11,10 +11,10 @@ syncarenaindex(Arena *arena, u64int a0) ClumpInfo ci; IAddr ia; AState as; - + if(arena->diskstats.clumps == arena->memstats.clumps) return 0; - + memset(&as, 0, sizeof as); as.arena = arena; as.stats = arena->diskstats; @@ -68,10 +68,10 @@ syncindex(Index *ix) continue; } flushdcache(); - + if(arena->memstats.clumps == arena->diskstats.clumps) continue; - + fprint(2, "%T %s: indexing %d clumps...\n", arena->name, arena->memstats.clumps - arena->diskstats.clumps); diff --git a/src/cmd/venti/srv/venti.c b/src/cmd/venti/srv/venti.c index 2a3cc6694..1725537a2 100644 --- a/src/cmd/venti/srv/venti.c +++ b/src/cmd/venti/srv/venti.c @@ -159,7 +159,7 @@ threadmain(int argc, char *argv[]) /* * block cache: need a block for every arena and every process */ - minbcmem = maxblocksize * + minbcmem = maxblocksize * (mainindex->narenas + mainindex->nsects*4 + 16); if(bcmem < minbcmem) bcmem = minbcmem; diff --git a/src/cmd/venti/srv/verifyarena.c b/src/cmd/venti/srv/verifyarena.c index f53d17f2c..47340dcf6 100644 --- a/src/cmd/venti/srv/verifyarena.c +++ b/src/cmd/venti/srv/verifyarena.c @@ -127,12 +127,12 @@ verifyarena(char *name, vlong len) scorecp(arena.score, &data[arena.blocksize - VtScoreSize]); if(namecmp(arena.name, head.name) != 0){ - fprint(2, "%T %s: wrong name in trailer: %s vs. %s\n", + fprint(2, "%T %s: wrong name in trailer: %s vs. %s\n", name, head.name, arena.name); return; } if(arena.version != head.version){ - fprint(2, "%T %s: wrong version in trailer: %d vs. %d\n", + fprint(2, "%T %s: wrong version in trailer: %d vs. %d\n", name, head.version, arena.version); return; } @@ -160,7 +160,7 @@ static int shouldcheck(char *name, char **s, int n) { int i; - + if(n == 0) return 1; @@ -209,7 +209,7 @@ threadmain(int argc, char *argv[]) verifyarena("", 0); threadexitsall(nil); } - + if((part = initpart(argv[0], OREAD)) == nil) sysfatal("open partition %s: %r", argv[0]); fd = part->fd; @@ -228,7 +228,7 @@ threadmain(int argc, char *argv[]) if(preadblock((uchar*)table, ap.tabsize, ap.tabbase) < 0) sysfatal("reading arena part directory: %r"); table[ap.tabsize] = 0; - + nline = atoi(table); p = strchr(table, '\n'); if(p) diff --git a/src/cmd/venti/srv/wrarena.c b/src/cmd/venti/srv/wrarena.c index 1e274ca79..df8f7fd89 100644 --- a/src/cmd/venti/srv/wrarena.c +++ b/src/cmd/venti/srv/wrarena.c @@ -45,7 +45,7 @@ vtsendthread(void *v) } /* * All the send threads try to exit right when - * threadmain is calling threadexitsall. + * threadmain is calling threadexitsall. * Either libthread or the Linux NPTL pthreads library * can't handle this condition (I suspect NPTL but have * not confirmed this) and we get a seg fault in exit. diff --git a/src/cmd/venti/srv/xml.c b/src/cmd/venti/srv/xml.c index e91afa054..9538d7782 100644 --- a/src/cmd/venti/srv/xml.c +++ b/src/cmd/venti/srv/xml.c @@ -65,4 +65,3 @@ void xmlamap(Hio *hout, AMap *s, char *tag, int indent){ xmlu64int(hout, s->stop, "stop"); hprint(hout, "/>\n"); } - diff --git a/src/cmd/venti/srv/zblock.c b/src/cmd/venti/srv/zblock.c index afff08010..80b240647 100644 --- a/src/cmd/venti/srv/zblock.c +++ b/src/cmd/venti/srv/zblock.c @@ -93,4 +93,3 @@ zblock2packet(ZBlock *zb, u32int size) packetappend(p, zb->data, size); return p; } - diff --git a/src/cmd/venti/sync.c b/src/cmd/venti/sync.c index 9d817a72e..965f19ed8 100644 --- a/src/cmd/venti/sync.c +++ b/src/cmd/venti/sync.c @@ -20,7 +20,7 @@ threadmain(int argc, char *argv[]) fmtinstall('V', vtscorefmt); fmtinstall('F', vtfcallfmt); - + ARGBEGIN{ case 'h': host = EARGF(usage()); diff --git a/src/cmd/venti/writefile.c b/src/cmd/venti/writefile.c index 211171261..3aff69ddc 100644 --- a/src/cmd/venti/writefile.c +++ b/src/cmd/venti/writefile.c @@ -85,13 +85,13 @@ threadmain(int argc, char *argv[]) if(vtfilegetentry(f, &e) < 0) sysfatal("vtfilegetentry: %r"); vtfileunlock(f); - + // write directory entry memset(&root, 0, sizeof root); vtentrypack(&e, buf, 0); if(vtwrite(z, root.score, VtDirType, buf, VtEntrySize) < 0) sysfatal("vtwrite dir: %r"); - + // write root strcpy(root.name, "data"); strcpy(root.type, "file"); @@ -99,8 +99,7 @@ threadmain(int argc, char *argv[]) vtrootpack(&root, buf); if(vtwrite(z, score, VtRootType, buf, VtRootSize) < 0) sysfatal("vtwrite root: %r"); - + print("file:%V\n", score); threadexitsall(0); } - diff --git a/src/cmd/zerotrunc.c b/src/cmd/zerotrunc.c index ce6fafeac..2ff1d53f1 100644 --- a/src/cmd/zerotrunc.c +++ b/src/cmd/zerotrunc.c @@ -23,4 +23,3 @@ main(void) } exits(0); } - diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c index b49cd4df1..0fb3410e9 100644 --- a/src/lib9/_p9dir.c +++ b/src/lib9/_p9dir.c @@ -34,7 +34,7 @@ static vlong disksize(int fd, struct stat *st) { off_t mediasize; - + if(ioctl(fd, DIOCGMEDIASIZE, &mediasize) >= 0) return mediasize; return 0; @@ -155,7 +155,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * sz += strlen(s)+1; if(d){ if(*str+strlen(s)+1 > estr) - d->uid = "oops"; + d->uid = "oops"; else{ strcpy(*str, s); d->uid = *str; @@ -178,7 +178,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * sz += strlen(s)+1; if(d){ if(*str + strlen(s)+1 > estr) - d->gid = "oops"; + d->gid = "oops"; else{ strcpy(*str, s); d->gid = *str; @@ -240,4 +240,3 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * return sz; } - diff --git a/src/lib9/_p9translate.c b/src/lib9/_p9translate.c index 84cd65cae..74df43c58 100644 --- a/src/lib9/_p9translate.c +++ b/src/lib9/_p9translate.c @@ -3,7 +3,7 @@ /* * I don't want too many of these, - * but the ones we have are just too useful. + * but the ones we have are just too useful. */ static struct { char *old; diff --git a/src/lib9/announce.c b/src/lib9/announce.c index cbf5b0735..1587988e5 100644 --- a/src/lib9/announce.c +++ b/src/lib9/announce.c @@ -153,4 +153,3 @@ p9accept(int cfd, char *dir) /* need to dup because the listen fd will be closed */ return dup(fd); } - diff --git a/src/lib9/atoi.c b/src/lib9/atoi.c index 66ecb4eff..c0f7251dd 100644 --- a/src/lib9/atoi.c +++ b/src/lib9/atoi.c @@ -6,4 +6,3 @@ atoi(char *s) { return strtol(s, 0, 0); } - diff --git a/src/lib9/atol.c b/src/lib9/atol.c index d67138342..6ead3004c 100644 --- a/src/lib9/atol.c +++ b/src/lib9/atol.c @@ -6,4 +6,3 @@ atol(char *s) { return strtol(s, 0, 0); } - diff --git a/src/lib9/atoll.c b/src/lib9/atoll.c index 6c345df66..d4ce0a94c 100644 --- a/src/lib9/atoll.c +++ b/src/lib9/atoll.c @@ -6,4 +6,3 @@ atoll(char *s) { return strtoll(s, 0, 0); } - diff --git a/src/lib9/await.c b/src/lib9/await.c index e96055f27..8b96865ca 100644 --- a/src/lib9/await.c +++ b/src/lib9/await.c @@ -55,7 +55,7 @@ static struct { SIGUSR2, "sys: usr2", SIGPIPE, "sys: write on closed pipe", }; - + char* _p9sigstr(int sig, char *tmp) { @@ -134,4 +134,3 @@ awaitfor(int pid, char *str, int n) { return _await(pid, str, n, 0); } - diff --git a/src/lib9/convD2M.c b/src/lib9/convD2M.c index 30c0d4961..e1ef00c54 100644 --- a/src/lib9/convD2M.c +++ b/src/lib9/convD2M.c @@ -12,10 +12,10 @@ sizeD2M(Dir *d) sv[1] = d->uid; sv[2] = d->gid; sv[3] = d->muid; - + fixlen = STATFIXLEN; nstr = 4; - + ns = 0; for(i = 0; i < nstr; i++) if(sv[i]) @@ -44,7 +44,7 @@ convD2M(Dir *d, uchar *buf, uint nbuf) fixlen = STATFIXLEN; nstr = 4; - + ns = 0; for(i = 0; i < nstr; i++){ if(sv[i]) @@ -93,7 +93,7 @@ convD2M(Dir *d, uchar *buf, uint nbuf) memmove(p, sv[i], ns); p += ns; } - + if(ss != p - buf) return 0; diff --git a/src/lib9/convM2D.c b/src/lib9/convM2D.c index 504110b2d..410fa6037 100644 --- a/src/lib9/convM2D.c +++ b/src/lib9/convM2D.c @@ -38,7 +38,7 @@ convM2D(uchar *buf, uint nbuf, Dir *d, char *strs) int i, ns, nstr; if(nbuf < STATFIXLEN) - return 0; + return 0; p = buf; ebuf = buf + nbuf; @@ -93,6 +93,6 @@ convM2D(uchar *buf, uint nbuf, Dir *d, char *strs) d->muid = nullstring; d->ext = nullstring; } - + return p - buf; } diff --git a/src/lib9/crypt.c b/src/lib9/crypt.c old mode 100755 new mode 100644 diff --git a/src/lib9/ctime.c b/src/lib9/ctime.c index 9fcd62008..97ebfd2fb 100644 --- a/src/lib9/ctime.c +++ b/src/lib9/ctime.c @@ -178,4 +178,3 @@ ct_numb(char *cp, int n) cp[0] = (n/10)%10 + '0'; cp[1] = n%10 + '0'; } - diff --git a/src/lib9/debugmalloc.c b/src/lib9/debugmalloc.c index 8df272196..51a2c61f5 100644 --- a/src/lib9/debugmalloc.c +++ b/src/lib9/debugmalloc.c @@ -74,7 +74,7 @@ mark(void *v, ulong pc, ulong n, ulong magic) p = (char*)(u+4)+n; memmove(p, END, 4); return u+4; - } + } } void @@ -104,7 +104,7 @@ setrealloctag(void *v, ulong t) u = mark(v, 0, 0, 0); u[3] = t; } - + void* p9malloc(ulong n) { diff --git a/src/lib9/dial.c b/src/lib9/dial.c index 1ce3a1473..c3dd17624 100644 --- a/src/lib9/dial.c +++ b/src/lib9/dial.c @@ -92,7 +92,7 @@ p9dial(char *addr, char *local, char *dummy2, int *dummy3) if((s = socket(ss.ss_family, proto, 0)) < 0) return -1; - + if(local){ buf = strdup(local); if(buf == nil){ @@ -155,4 +155,3 @@ p9dial(char *addr, char *local, char *dummy2, int *dummy3) } return s; } - diff --git a/src/lib9/dirfstat.c b/src/lib9/dirfstat.c index d1922bf91..37b59a0b0 100644 --- a/src/lib9/dirfstat.c +++ b/src/lib9/dirfstat.c @@ -26,4 +26,3 @@ dirfstat(int fd) _p9dir(&st, &st, tmp, d, &str, str+nstr); return d; } - diff --git a/src/lib9/dirfwstat.c b/src/lib9/dirfwstat.c index 95e184447..27ed37a84 100644 --- a/src/lib9/dirfwstat.c +++ b/src/lib9/dirfwstat.c @@ -54,4 +54,3 @@ dirfwstat(int fd, Dir *dir) } return ret; } - diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c index 40fbe3c74..c232eb8d8 100644 --- a/src/lib9/dirread.c +++ b/src/lib9/dirread.c @@ -18,7 +18,7 @@ mygetdents(int fd, struct dirent *buf, int n) nn = getdirentries(fd, (void*)buf, n, &off); return nn; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) static int mygetdents(int fd, struct dirent *buf, int n) { @@ -93,7 +93,7 @@ dirpackage(int fd, char *buf, int n, Dir **dp) return -1; if(fchdir(fd) < 0) return -1; - + p = buf; nstr = 0; diff --git a/src/lib9/dirstat.c b/src/lib9/dirstat.c index 187dea7a5..a644b6b54 100644 --- a/src/lib9/dirstat.c +++ b/src/lib9/dirstat.c @@ -29,4 +29,3 @@ dirstat(char *file) _p9dir(&lst, &st, file, d, &str, str+nstr); return d; } - diff --git a/src/lib9/errstr.c b/src/lib9/errstr.c index caf715323..9493e8421 100644 --- a/src/lib9/errstr.c +++ b/src/lib9/errstr.c @@ -78,4 +78,3 @@ werrstr(char *fmt, ...) va_end(arg); errstr(buf, ERRMAX); } - diff --git a/src/lib9/execl.c b/src/lib9/execl.c index 988d20723..63b86d6dd 100644 --- a/src/lib9/execl.c +++ b/src/lib9/execl.c @@ -26,4 +26,3 @@ execl(char *prog, ...) free(argv); return -1; } - diff --git a/src/lib9/exitcode.c b/src/lib9/exitcode.c index f65836e1f..797e9d50c 100644 --- a/src/lib9/exitcode.c +++ b/src/lib9/exitcode.c @@ -6,4 +6,3 @@ exitcode(char *s) { return 1; } - diff --git a/src/lib9/fmt/dofmt.c b/src/lib9/fmt/dofmt.c index 353c76e37..f714f8ff9 100644 --- a/src/lib9/fmt/dofmt.c +++ b/src/lib9/fmt/dofmt.c @@ -478,7 +478,7 @@ __ifmt(Fmt *f) if(fl & FmtApost) __needsep(&ndig, &grouping); } - + /* * Zero values don't get 0x. */ diff --git a/src/lib9/fmt/fltfmt.c b/src/lib9/fmt/fltfmt.c index bfeb7e509..4045ffd83 100644 --- a/src/lib9/fmt/fltfmt.c +++ b/src/lib9/fmt/fltfmt.c @@ -26,22 +26,22 @@ enum */ static double pows10[] = { - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, - 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39, - 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49, - 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, - 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69, - 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79, - 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89, - 1e90, 1e91, 1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99, - 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109, - 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119, - 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129, - 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139, - 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, - 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, + 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39, + 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49, + 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, + 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69, + 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79, + 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89, + 1e90, 1e91, 1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99, + 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109, + 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119, + 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129, + 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139, + 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, + 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, }; #define npows10 ((int)(sizeof(pows10)/sizeof(pows10[0]))) #define pow10(x) fmtpow10(x) @@ -110,7 +110,7 @@ xadd1(char *a, int n) /* * subtract 1 from the decimal integer string a. * if 10000 underflows into 09999, make it 99999 - * and return 1 to tell caller to move the virtual + * and return 1 to tell caller to move the virtual * decimal point. this way, xsub1 is inverse of xadd1. */ static int @@ -206,7 +206,7 @@ xdtoa(double f, char *s, int *exp, int *neg, int *ns) *ns = 1; return; } - + /* * find g,e such that f = g*10^e. * guess 10-exponent using 2-exponent, then fine tune. @@ -298,7 +298,7 @@ xdtoa(double f, char *s, int *exp, int *neg, int *ns) e = ee; } } - + /* * bump last few digits down to 0 as we can. */ @@ -342,13 +342,13 @@ __efgfmt(Fmt *fmt) int c, chr, dotwid, e, exp, fl, ndigits, neg, newndigits; int pad, point, prec, realchr, sign, sufwid, ucase, wid, z1, z2; Rune r, *rs, *rt; - + if(fmt->flags&FmtLong) f = va_arg(fmt->args, long double); else f = va_arg(fmt->args, double); - - /* + + /* * extract formatting flags */ fl = fmt->flags; @@ -425,7 +425,7 @@ __efgfmt(Fmt *fmt) exp += ndigits-prec; ndigits = prec; } - + /* * extra rules for %g (implemented below): * trailing zeros removed after decimal unless FmtSharp. @@ -435,12 +435,12 @@ __efgfmt(Fmt *fmt) /* fall through to %e */ default: case 'e': - /* + /* * one significant digit before decimal, no leading zeros. */ point = 1; z1 = 0; - + /* * decimal point is after ndigits digits right now. * slide to be after first. @@ -537,11 +537,11 @@ __efgfmt(Fmt *fmt) } z2 = 0; ndigits = newndigits; - } + } sufwid = 0; break; } - + /* * if %g is given without FmtSharp, remove trailing zeros. * must do after truncation, so that e.g. print %.3g 1.001 @@ -665,4 +665,3 @@ __efgfmt(Fmt *fmt) } return 0; } - diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h index 1519ea42d..5c8eb2cbd 100644 --- a/src/lib9/fmt/fmtdef.h +++ b/src/lib9/fmt/fmtdef.h @@ -102,4 +102,3 @@ int __strfmt(Fmt *f); # define VA_COPY(a,b) (a) = (b) # define VA_END(a) #endif - diff --git a/src/lib9/fmt/fmtlocale.c b/src/lib9/fmt/fmtlocale.c index 9ebdced38..33ca4011a 100644 --- a/src/lib9/fmt/fmtlocale.c +++ b/src/lib9/fmt/fmtlocale.c @@ -37,7 +37,7 @@ int __needsep(int *ndig, char **grouping) { int group; - + (*ndig)++; group = *(unsigned char*)*grouping; /* CHAR_MAX means no further grouping. \0 means we got the empty string */ @@ -52,4 +52,3 @@ __needsep(int *ndig, char **grouping) } return 0; } - diff --git a/src/lib9/fmt/fmtnull.c b/src/lib9/fmt/fmtnull.c index aa5124a5c..22ac078f7 100644 --- a/src/lib9/fmt/fmtnull.c +++ b/src/lib9/fmt/fmtnull.c @@ -30,4 +30,3 @@ fmtnullinit(Fmt *f) fmtlocaleinit(f, nil, nil, nil); return 0; } - diff --git a/src/lib9/fmt/fmtprint.c b/src/lib9/fmt/fmtprint.c index 868127e0a..41fc8332a 100644 --- a/src/lib9/fmt/fmtprint.c +++ b/src/lib9/fmt/fmtprint.c @@ -33,4 +33,3 @@ fmtprint(Fmt *f, char *fmt, ...) return 0; return n; } - diff --git a/src/lib9/fmt/fmtvprint.c b/src/lib9/fmt/fmtvprint.c index 66d3929f0..694a6cf88 100644 --- a/src/lib9/fmt/fmtvprint.c +++ b/src/lib9/fmt/fmtvprint.c @@ -34,4 +34,3 @@ fmtvprint(Fmt *f, char *fmt, va_list args) return 0; return n; } - diff --git a/src/lib9/fmt/nan64.c b/src/lib9/fmt/nan64.c index d408695d5..78c3fde38 100644 --- a/src/lib9/fmt/nan64.c +++ b/src/lib9/fmt/nan64.c @@ -2,7 +2,7 @@ /* * 64-bit IEEE not-a-number routines. - * This is big/little-endian portable assuming that + * This is big/little-endian portable assuming that * the 64-bit doubles and 64-bit integers have the * same byte ordering. */ @@ -51,7 +51,7 @@ int __isNaN(double d) { uvlong x; - + x = d2u(d); /* IEEE 754: exponent bits 0x7FF and non-zero mantissa */ return (x&uvinf) == uvinf && (x&~uvneginf) != 0; @@ -67,7 +67,7 @@ int __isInf(double d, int sign) { uvlong x; - + x = d2u(d); if(sign == 0) return x==uvinf || x==uvneginf; diff --git a/src/lib9/fmt/plan9.h b/src/lib9/fmt/plan9.h index 0872ac71a..0de44f148 100644 --- a/src/lib9/fmt/plan9.h +++ b/src/lib9/fmt/plan9.h @@ -35,4 +35,3 @@ typedef uintptr_t uintptr; #undef nelem #define nelem(x) (sizeof (x)/sizeof (x)[0]) - diff --git a/src/lib9/fmt/runesnprint.c b/src/lib9/fmt/runesnprint.c index 50b4813d5..afc3f506b 100644 --- a/src/lib9/fmt/runesnprint.c +++ b/src/lib9/fmt/runesnprint.c @@ -16,4 +16,3 @@ runesnprint(Rune *buf, int len, char *fmt, ...) va_end(args); return n; } - diff --git a/src/lib9/fmt/runevseprint.c b/src/lib9/fmt/runevseprint.c index 24e2f178f..213351ab8 100644 --- a/src/lib9/fmt/runevseprint.c +++ b/src/lib9/fmt/runevseprint.c @@ -26,4 +26,3 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args) *(Rune*)f.to = '\0'; return (Rune*)f.to; } - diff --git a/src/lib9/fmt/runevsmprint.c b/src/lib9/fmt/runevsmprint.c index ef273752a..de29d2c3d 100644 --- a/src/lib9/fmt/runevsmprint.c +++ b/src/lib9/fmt/runevsmprint.c @@ -1,8 +1,8 @@ /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ /* - * Plan 9 port version must include libc.h in order to + * Plan 9 port version must include libc.h in order to * get Plan 9 debugging malloc, which sometimes returns - * different pointers than the standard malloc. + * different pointers than the standard malloc. */ #ifdef PLAN9PORT #include diff --git a/src/lib9/fmt/snprint.c b/src/lib9/fmt/snprint.c index 64d2da433..d019b456a 100644 --- a/src/lib9/fmt/snprint.c +++ b/src/lib9/fmt/snprint.c @@ -15,4 +15,3 @@ snprint(char *buf, int len, char *fmt, ...) va_end(args); return n; } - diff --git a/src/lib9/fmt/vseprint.c b/src/lib9/fmt/vseprint.c index 1b92d2a9b..8266c65d5 100644 --- a/src/lib9/fmt/vseprint.c +++ b/src/lib9/fmt/vseprint.c @@ -25,4 +25,3 @@ vseprint(char *buf, char *e, char *fmt, va_list args) *(char*)f.to = '\0'; return (char*)f.to; } - diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c index 9576f8003..0a88e98fa 100644 --- a/src/lib9/fmt/vsmprint.c +++ b/src/lib9/fmt/vsmprint.c @@ -1,8 +1,8 @@ /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ /* - * Plan 9 port version must include libc.h in order to + * Plan 9 port version must include libc.h in order to * get Plan 9 debugging malloc, which sometimes returns - * different pointers than the standard malloc. + * different pointers than the standard malloc. */ #ifdef PLAN9PORT #include diff --git a/src/lib9/get9root.c b/src/lib9/get9root.c index 3ef704c93..07e2872c5 100644 --- a/src/lib9/get9root.c +++ b/src/lib9/get9root.c @@ -15,4 +15,3 @@ get9root(void) s = "/usr/local/plan9"; return s; } - diff --git a/src/lib9/getnetconn.c b/src/lib9/getnetconn.c index 9fa8a9e0d..e88516cf2 100644 --- a/src/lib9/getnetconn.c +++ b/src/lib9/getnetconn.c @@ -27,7 +27,7 @@ convert(int s, struct sockaddr *sa, char **lsys, char **lserv, char **laddr) socklen_t sn; int n; char *net; - + switch(sa->sa_family){ case AF_INET: sin = (void*)sa; @@ -158,4 +158,3 @@ freenetconninfo(NetConnInfo *nci) xfree(nci->raddr); free(nci); } - diff --git a/src/lib9/getns.c b/src/lib9/getns.c index 2421a6498..35bbeebd3 100644 --- a/src/lib9/getns.c +++ b/src/lib9/getns.c @@ -49,7 +49,7 @@ nsfromdisplay(void) if(strcmp(p, ".0") == 0) *p = 0; } - + /* turn /tmp/launch/:0 into _tmp_launch_:0 (OS X 10.5) */ for(p=disp; *p; p++) if(*p == '/') diff --git a/src/lib9/jmp.c b/src/lib9/jmp.c index 6f928bab3..5ec21e7f2 100644 --- a/src/lib9/jmp.c +++ b/src/lib9/jmp.c @@ -14,4 +14,3 @@ p9notejmp(void *x, p9jmp_buf buf, int val) USED(x); siglongjmp((void*)buf, val); } - diff --git a/src/lib9/malloc.c b/src/lib9/malloc.c index 7b6b59dc2..33593aa2f 100644 --- a/src/lib9/malloc.c +++ b/src/lib9/malloc.c @@ -13,7 +13,7 @@ void* p9malloc(ulong n) { void *v; - + if(n == 0) n++; lock(&malloclock); @@ -36,7 +36,7 @@ void* p9calloc(ulong a, ulong b) { void *v; - + if(a*b == 0) a = b = 1; diff --git a/src/lib9/netmkaddr.c b/src/lib9/netmkaddr.c index 832f7e280..420c2cf8b 100644 --- a/src/lib9/netmkaddr.c +++ b/src/lib9/netmkaddr.c @@ -25,7 +25,7 @@ netmkaddr(char *linear, char *defnet, char *defsrv) } /* allow host:service in deference to Unix convention */ if((cp = strchr(linear, ':')) != nil){ - snprint(addr, sizeof(addr), "%s!%.*s!%s", + snprint(addr, sizeof(addr), "%s!%.*s!%s", defnet, utfnlen(linear, cp-linear), linear, cp+1); return addr; diff --git a/src/lib9/notify.c b/src/lib9/notify.c index c32238757..adb3815b7 100644 --- a/src/lib9/notify.c +++ b/src/lib9/notify.c @@ -1,7 +1,7 @@ /* - * Signal handling for Plan 9 programs. - * We stubbornly use the strings from Plan 9 instead - * of the enumerated Unix constants. + * Signal handling for Plan 9 programs. + * We stubbornly use the strings from Plan 9 instead + * of the enumerated Unix constants. * There are some weird translations. In particular, * a "kill" note is the same as SIGTERM in Unix. * There is no equivalent note to Unix's SIGKILL, since @@ -110,7 +110,7 @@ Jmp *(*_notejmpbuf)(void) = getonejmp; static void noteinit(void); /* - * Actual signal handler. + * Actual signal handler. */ static void (*notifyf)(void*, char*); /* Plan 9 handler */ @@ -193,7 +193,7 @@ notesetenable(int sig, int enabled) sigemptyset(&mask); sigaddset(&mask, sig); sigprocmask(enabled ? SIG_UNBLOCK : SIG_BLOCK, &mask, &omask); - return !sigismember(&omask, sig); + return !sigismember(&omask, sig); } int @@ -270,4 +270,3 @@ noteinit(void) notifyseton(sig->sig, !(sig->flags&NoNotify)); } } - diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c index 9d4e2d077..c999f49c1 100644 --- a/src/lib9/opentemp.c +++ b/src/lib9/opentemp.c @@ -17,4 +17,3 @@ opentemp(char *template, int mode) close(fd); return fd1; } - diff --git a/src/lib9/pin.c b/src/lib9/pin.c index 3b15d3b8a..c50587fc0 100644 --- a/src/lib9/pin.c +++ b/src/lib9/pin.c @@ -8,4 +8,3 @@ nop(void) void (*_pin)(void) = nop; void (*_unpin)(void) = nop; - diff --git a/src/lib9/postnote.c b/src/lib9/postnote.c index b8ef94278..68e6d2f66 100644 --- a/src/lib9/postnote.c +++ b/src/lib9/postnote.c @@ -30,5 +30,3 @@ postnote(int who, int pid, char *msg) return killpg(pid, sig); } } - - diff --git a/src/lib9/priv.c b/src/lib9/priv.c index e64e9194f..fb493c721 100644 --- a/src/lib9/priv.c +++ b/src/lib9/priv.c @@ -29,4 +29,3 @@ privmem(int i) up = _p9uproc(0); return &up->priv[i]; } - diff --git a/src/lib9/quote.c b/src/lib9/quote.c index f850009ad..8ab659232 100644 --- a/src/lib9/quote.c +++ b/src/lib9/quote.c @@ -92,7 +92,7 @@ quotestrdup(char *s) if(__needsquotes(s, "elen) == 0) return strdup(s); - + ret = malloc(quotelen+1); if(ret == nil) return nil; @@ -118,7 +118,7 @@ quoterunestrdup(Rune *s) if(__runeneedsquotes(s, "elen) == 0) return runestrdup(s); - + ret = malloc((quotelen+1)*sizeof(Rune)); if(ret == nil) return nil; diff --git a/src/lib9/rfork.c b/src/lib9/rfork.c index bbd08b0ac..c737b49dd 100644 --- a/src/lib9/rfork.c +++ b/src/lib9/rfork.c @@ -76,7 +76,7 @@ p9rfork(int flags) pid = strtol(buf, &q, 0); }else{ /* - * Child - fork a new child whose wait message can't + * Child - fork a new child whose wait message can't * get back to the parent because we're going to exit! */ signal(SIGCHLD, SIG_IGN); diff --git a/src/lib9/searchpath.c b/src/lib9/searchpath.c index 3b8e7daab..75e0695fc 100644 --- a/src/lib9/searchpath.c +++ b/src/lib9/searchpath.c @@ -59,4 +59,3 @@ searchpath(char *name) free(path); return nil; } - diff --git a/src/lib9/sendfd.c b/src/lib9/sendfd.c index e2abb7599..e73225e2d 100644 --- a/src/lib9/sendfd.c +++ b/src/lib9/sendfd.c @@ -31,7 +31,7 @@ sendfd(int s, int fd) struct cmsghdr *cmsg; int n; char cms[CMSG_SPACE(sizeof(int))]; - + buf[0] = 0; iov.iov_base = buf; iov.iov_len = 1; diff --git a/src/lib9/strdup.c b/src/lib9/strdup.c index 5ca31866f..5c67f0b60 100644 --- a/src/lib9/strdup.c +++ b/src/lib9/strdup.c @@ -14,4 +14,3 @@ strdup(char *s) memmove(t, s, l+1); return t; } - diff --git a/src/lib9/sysfatal.c b/src/lib9/sysfatal.c index 00229db04..11f4234c6 100644 --- a/src/lib9/sysfatal.c +++ b/src/lib9/sysfatal.c @@ -18,4 +18,3 @@ sysfatal(char *fmt, ...) fprint(2, "%s: %s\n", argv0 ? argv0 : "", buf); exits("fatal"); } - diff --git a/src/lib9/testfltfmt.c b/src/lib9/testfltfmt.c index 06ab5a603..c602ce452 100644 --- a/src/lib9/testfltfmt.c +++ b/src/lib9/testfltfmt.c @@ -142,9 +142,9 @@ doit(int just, int plus, int alt, int zero, int width, int prec, int spec) && !numclose(ref, buf)) { d1 = fmtstrtod(ref, 0); d2 = fmtstrtod(buf, 0); - fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n", - format, - ref, d1==fmtvals[i] ? "" : " (ref is inexact!)", + fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n", + format, + ref, d1==fmtvals[i] ? "" : " (ref is inexact!)", buf, d2==fmtvals[i] ? "" : " (fmt is inexact!)"); // exits("oops"); } @@ -156,9 +156,9 @@ doit(int just, int plus, int alt, int zero, int width, int prec, int spec) && !numclose(ref, buf)) { d1 = fmtstrtod(ref, 0); d2 = fmtstrtod(buf, 0); - fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n", - format, - ref, d1==fmtvals[i] ? "" : " (ref is inexact!)", + fprintf(stderr, "%s: ref='%s'%s fmt='%s'%s\n", + format, + ref, d1==fmtvals[i] ? "" : " (ref is inexact!)", buf, d2==fmtvals[i] ? "" : " (fmt is inexact!)"); // exits("oops"); } diff --git a/src/lib9/testfmt.c b/src/lib9/testfmt.c index fd2b7039f..11708ba30 100644 --- a/src/lib9/testfmt.c +++ b/src/lib9/testfmt.c @@ -90,14 +90,14 @@ main(int argc, char **argv) verify(smprint("%d", 23), "23"); verify(smprint("%i", 23), "23"); verify(smprint("%Zi", 1234, 23), "23"); - + /* ANSI and their wacky corner cases */ verify(smprint("%.0d", 0), ""); verify(smprint("%.0o", 0), ""); verify(smprint("%.0x", 0), ""); verify(smprint("%#.0o", 0), "0"); verify(smprint("%#.0x", 0), ""); - + /* difficult floating point tests that many libraries get wrong */ verify(smprint("%.100f", 1.0), "1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); verify(smprint("%.100g", 1.0), "1"); @@ -112,7 +112,7 @@ main(int argc, char **argv) verify(smprint("%3$d %4$*5$06d %2$d %1$d", 444, 333, 111, 222, 20), "111 000222 333 444"); verify(smprint("%3$hd %4$*5$06d %2$d %1$d", 444, 333, (short)111, 222, 20), "111 000222 333 444"); verify(smprint("%3$\xe2\x98\xba""d %5$06d %2$d %1$d", 444, 333, 555, 111, 222), "111 000222 333 444"); - + /* test %'d formats */ verify(smprint("%'d %'d %'d", 1, 2222, 33333333), "1 2,222 33,333,333"); verify(smprint("%'019d", 0), "000,000,000,000,000"); diff --git a/src/lib9/testprint.c b/src/lib9/testprint.c index 242befb4e..b2c04208f 100644 --- a/src/lib9/testprint.c +++ b/src/lib9/testprint.c @@ -5,7 +5,7 @@ void main(int argc, char **argv) { char c; - + c = argv[1][strlen(argv[1])-1]; if(c == 'f' || c == 'e' || c == 'g' || c == 'F' || c == 'E' || c == 'G') print(argv[1], atof(argv[2])); diff --git a/src/lib9/time.c b/src/lib9/time.c index 367063678..92ad2ca47 100644 --- a/src/lib9/time.c +++ b/src/lib9/time.c @@ -55,4 +55,3 @@ p9time(long *tt) *tt = t; return t; } - diff --git a/src/lib9/tm2sec.c b/src/lib9/tm2sec.c index 5edf439d1..58bbe9927 100644 --- a/src/lib9/tm2sec.c +++ b/src/lib9/tm2sec.c @@ -103,7 +103,7 @@ tm2sec(Tm *tm) secs -= ti->tzoff; } } - + if(secs < 0) secs = 0; return secs; diff --git a/src/lib9/u64.c b/src/lib9/u64.c index a17bdf1d5..84e5fe0ed 100644 --- a/src/lib9/u64.c +++ b/src/lib9/u64.c @@ -35,7 +35,7 @@ dec64(uchar *out, int lim, char *in, int n) b24 = 0; i = 0; while(n-- > 0){ - + c = t64d[*(uchar*)in++]; if(c == INVAL) continue; diff --git a/src/lib9/udp.c b/src/lib9/udp.c index a11647236..a9c4cb686 100644 --- a/src/lib9/udp.c +++ b/src/lib9/udp.c @@ -49,4 +49,3 @@ udpwrite(int fd, Udphdr *hdr, void *buf, long n) *(u16int*)&sin.sin_port = *(u16int*)hdr->rport; return sendto(fd, buf, n, 0, (struct sockaddr*)&sin, sizeof sin); } - diff --git a/src/lib9/unsharp.c b/src/lib9/unsharp.c index b7db700c0..251cae5d9 100644 --- a/src/lib9/unsharp.c +++ b/src/lib9/unsharp.c @@ -3,7 +3,7 @@ /* * I don't want too many of these, - * but the ones we have are just too useful. + * but the ones we have are just too useful. */ static struct { char *old; diff --git a/src/lib9/utf/lib9.h b/src/lib9/utf/lib9.h index e6128ae4d..450f28f08 100644 --- a/src/lib9/utf/lib9.h +++ b/src/lib9/utf/lib9.h @@ -14,4 +14,3 @@ typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; - diff --git a/src/lib9/utf/plan9.h b/src/lib9/utf/plan9.h index e40e33eb6..1ca8ace72 100644 --- a/src/lib9/utf/plan9.h +++ b/src/lib9/utf/plan9.h @@ -26,4 +26,3 @@ typedef unsigned long ulong; #undef nelem #define nelem(x) (sizeof (x)/sizeof (x)[0]) - diff --git a/src/lib9/utf/rune.c b/src/lib9/utf/rune.c index f5944806f..bb2d82cb5 100644 --- a/src/lib9/utf/rune.c +++ b/src/lib9/utf/rune.c @@ -155,7 +155,7 @@ runetochar(char *str, Rune *rune) str[2] = Tx | (c & Maskx); return 3; } - + /* * four character sequence * 010000-1FFFFF => T4 Tx Tx Tx diff --git a/src/lib9/utf/runestrdup.c b/src/lib9/utf/runestrdup.c index 8170e7bcb..4f9d6f424 100644 --- a/src/lib9/utf/runestrdup.c +++ b/src/lib9/utf/runestrdup.c @@ -18,8 +18,8 @@ #include "utf.h" Rune* -runestrdup(Rune *s) -{ +runestrdup(Rune *s) +{ Rune *ns; ns = malloc(sizeof(Rune)*(runestrlen(s) + 1)); diff --git a/src/lib9/utf/utfdef.h b/src/lib9/utf/utfdef.h index 1ff41813b..1db7076d5 100644 --- a/src/lib9/utf/utfdef.h +++ b/src/lib9/utf/utfdef.h @@ -30,4 +30,3 @@ typedef long long vlong; #undef nelem #define nelem ((void*)0) - diff --git a/src/lib9/wait.c b/src/lib9/wait.c index 31d8c02af..17d767865 100644 --- a/src/lib9/wait.c +++ b/src/lib9/wait.c @@ -51,4 +51,3 @@ waitfor(int pid) return _wait(awaitfor(pid, buf, sizeof buf-1), buf); } - diff --git a/src/lib9/waitpid.c b/src/lib9/waitpid.c index 3df8ef89c..4c90bb786 100644 --- a/src/lib9/waitpid.c +++ b/src/lib9/waitpid.c @@ -17,4 +17,3 @@ waitpid(void) } return atoi(fld[0]); } - diff --git a/src/lib9/zoneinfo.c b/src/lib9/zoneinfo.c index 91f1885a8..f8ae442dd 100644 --- a/src/lib9/zoneinfo.c +++ b/src/lib9/zoneinfo.c @@ -4,7 +4,7 @@ /* * Access local time entries of zoneinfo files. * Formats 0 and 2 are supported, and 4-byte timestamps - * + * * Copyright © 2008 M. Teichgräber * Contributed under the terms of the Lucent Public License 1.02. */ diff --git a/src/lib9/zoneinfo.h b/src/lib9/zoneinfo.h index 55e60df9f..e2ea963d5 100644 --- a/src/lib9/zoneinfo.h +++ b/src/lib9/zoneinfo.h @@ -16,4 +16,3 @@ struct Tinfo extern int zonelookuptinfo(Tinfo*, tlong); extern int zonetinfo(Tinfo*, int); extern void zonedump(int fd); - diff --git a/src/lib9p/_post.c b/src/lib9p/_post.c index 151e45ffa..56f614fe6 100644 --- a/src/lib9p/_post.c +++ b/src/lib9p/_post.c @@ -75,4 +75,3 @@ _post3(Postcrud *p) close(p->s->srvfd); free(p); } - diff --git a/src/lib9p/file.c b/src/lib9p/file.c index a18b09236..ea083993b 100644 --- a/src/lib9p/file.c +++ b/src/lib9p/file.c @@ -86,7 +86,7 @@ removefile(File *f) { File *fp; Filelist *fl; - + fp = f->parent; if(fp == nil){ werrstr("no parent"); @@ -261,7 +261,7 @@ mkqid(vlong path, long vers, int type) return q; } - + Tree* alloctree(char *uid, char *gid, ulong mode, void (*destroy)(File*)) { diff --git a/src/lib9p/intmap.c b/src/lib9p/intmap.c index 1be11ce0f..152493a31 100644 --- a/src/lib9p/intmap.c +++ b/src/lib9p/intmap.c @@ -62,7 +62,7 @@ freemap(Intmap *map, void (*destroy)(void*)) free(p); } } - + free(map); } @@ -74,7 +74,7 @@ llookup(Intmap *map, ulong id) for(lf=&map->hash[hashid(id)]; *lf; lf=&(*lf)->link) if((*lf)->id == id) break; - return lf; + return lf; } /* @@ -121,7 +121,7 @@ insertkey(Intmap *map, ulong id, void *v) ov = nil; } wunlock(&map->rwlock); - return ov; + return ov; } int @@ -144,7 +144,7 @@ caninsertkey(Intmap *map, ulong id, void *v) rv = 1; } wunlock(&map->rwlock); - return rv; + return rv; } void* diff --git a/src/lib9p/mem.c b/src/lib9p/mem.c index 397bca0f1..88d24cd43 100644 --- a/src/lib9p/mem.c +++ b/src/lib9p/mem.c @@ -39,4 +39,3 @@ estrdup9p(char *s) setmalloctag(t, getcallerpc(&s)); return t; } - diff --git a/src/lib9p/parse.c b/src/lib9p/parse.c index 753ae79db..b8dff3d37 100644 --- a/src/lib9p/parse.c +++ b/src/lib9p/parse.c @@ -70,7 +70,7 @@ respondcmderror(Req *r, Cmdbuf *cb, char *fmt, ...) va_list arg; char *p, *e; char err[ERRMAX]; - + e = err+ERRMAX-10; va_start(arg, fmt); p = vseprint(err, e, fmt, arg); diff --git a/src/lib9p/post.c b/src/lib9p/post.c index 09296a889..4ee99bc8d 100644 --- a/src/lib9p/post.c +++ b/src/lib9p/post.c @@ -21,4 +21,3 @@ postmountsrv(Srv *s, char *name, char *mtpt, int flag) _post3(p); } } - diff --git a/src/lib9p/req.c b/src/lib9p/req.c index 83347050b..9acbcdc5b 100644 --- a/src/lib9p/req.c +++ b/src/lib9p/req.c @@ -33,7 +33,7 @@ freereqpool(Reqpool *p) { freemap(p->map, (void(*)(void*))p->destroy); free(p); -} +} Req* allocreq(Reqpool *pool, ulong tag) diff --git a/src/lib9p/srv.c b/src/lib9p/srv.c index d12e35223..c3d654793 100644 --- a/src/lib9p/srv.c +++ b/src/lib9p/srv.c @@ -98,7 +98,7 @@ if(chatty9p) if(chatty9p) if(r->error) fprint(2, "<-%d- %F: %s\n", s->infd, &r->ifcall, r->error); - else + else fprint(2, "<-%d- %F\n", s->infd, &r->ifcall); return r; @@ -378,7 +378,7 @@ sopen(Srv *srv, Req *r) default: assert(0); case OREAD: - p = AREAD; + p = AREAD; break; case OWRITE: p = AWRITE; @@ -387,7 +387,7 @@ sopen(Srv *srv, Req *r) p = AREAD|AWRITE; break; case OEXEC: - p = AEXEC; + p = AEXEC; break; } if(r->ifcall.mode&OTRUNC) @@ -588,7 +588,7 @@ rremove(Req *r, char *error, char *errbuf) return; if(r->fid->file){ if(removefile(r->fid->file) < 0){ - snprint(errbuf, ERRMAX, "remove %s: %r", + snprint(errbuf, ERRMAX, "remove %s: %r", r->fid->file->dir.name); r->error = errbuf; } @@ -614,8 +614,8 @@ sstat(Srv *srv, Req *r) if(r->d.muid) r->d.muid = estrdup9p(r->d.muid); } - if(srv->stat) - srv->stat(r); + if(srv->stat) + srv->stat(r); else if(r->fid->file) respond(r, nil); else @@ -720,7 +720,7 @@ srv(Srv *srv) while(r = getreq(srv)){ if(r->error){ respond(r, r->error); - continue; + continue; } switch(r->ifcall.type){ default: @@ -760,7 +760,7 @@ respond(Req *r, char *error) assert(r->pool); goto free; } - + assert(r->responded == 0); r->error = error; @@ -812,8 +812,8 @@ if(chatty9p) * There is a race here - we must remove the entry before * the write, so that if the client is very fast and reuses the * tag, the read loop won't think it is still in use. - * - * By removing the entry before the write, we open up a + * + * By removing the entry before the write, we open up a * race with incoming Tflush messages. Specifically, an * incoming Tflush might not see r even though it has not * yet been responded to. It would then send an Rflush @@ -833,12 +833,12 @@ if(chatty9p) * There are no references other than in our r->flush array, * so no one else should be accessing r concurrently. * Close the fid now, before responding to the message. - * + * * If the client is behaving (there are no outstanding T-messages * that reference r->fid) and the message is a Tclunk or Tremove, - * then this closefid will call destroyfid. - * - * This means destroyfid can't piddle around + * then this closefid will call destroyfid. + * + * This means destroyfid can't piddle around * indefinitely (we're holding srv->wlock!), but it provides * for tighter semantics as to when destroyfid is called. * @@ -899,4 +899,3 @@ postfd(char *name, int pfd) fprint(2, "postfd successful\n"); return 0; } - diff --git a/src/lib9pclient/access.c b/src/lib9pclient/access.c old mode 100755 new mode 100644 diff --git a/src/lib9pclient/close.c b/src/lib9pclient/close.c index 9303b17dd..34737b31b 100644 --- a/src/lib9pclient/close.c +++ b/src/lib9pclient/close.c @@ -33,7 +33,7 @@ fsfremove(CFid *fid) { int n; Fcall tx, rx; - + tx.type = Tremove; tx.fid = fid->fid; n = _fsrpc(fid->fs, &tx, &rx, 0); diff --git a/src/lib9pclient/create.c b/src/lib9pclient/create.c index 62e26b229..f18b6547e 100644 --- a/src/lib9pclient/create.c +++ b/src/lib9pclient/create.c @@ -26,7 +26,7 @@ fscreate(CFsys *fs, char *name, int mode, ulong perm) { CFid *fid; char *p, *dir, *elem; - + p = strrchr(name, '/'); if(p == nil){ dir = ""; diff --git a/src/lib9pclient/fs.c b/src/lib9pclient/fs.c index c6b1c3e92..f1b9b0857 100644 --- a/src/lib9pclient/fs.c +++ b/src/lib9pclient/fs.c @@ -26,7 +26,7 @@ fsinit(int fd) { CFsys *fs; int n; - + fmtinstall('F', fcallfmt); fmtinstall('D', dirfmt); fmtinstall('M', dirmodefmt); @@ -48,7 +48,7 @@ fsinit(int fd) fs->iorecv = ioproc(); fs->iosend = ioproc(); muxinit(&fs->mux); - + strcpy(fs->version, "9P2000"); if((n = fsversion(fs, 8192, fs->version, sizeof fs->version)) < 0){ werrstr("fsversion: %r"); diff --git a/src/lib9pclient/ns.c b/src/lib9pclient/ns.c index a9cc29e66..65225ecbc 100644 --- a/src/lib9pclient/ns.c +++ b/src/lib9pclient/ns.c @@ -65,4 +65,3 @@ nsopen(char *name, char *aname, char *fname, int mode) fsunmount(fs); return fid; } - diff --git a/src/lib9pclient/print.c b/src/lib9pclient/print.c index 7ed444503..5effa78b1 100644 --- a/src/lib9pclient/print.c +++ b/src/lib9pclient/print.c @@ -65,4 +65,3 @@ fsvprint(CFid *fd, char *fmt, va_list args) return -1; return n; } - diff --git a/src/lib9pclient/read.c b/src/lib9pclient/read.c index 605372884..ea94e9aa4 100644 --- a/src/lib9pclient/read.c +++ b/src/lib9pclient/read.c @@ -43,7 +43,7 @@ fspread(CFid *fid, void *buf, long n, vlong offset) } } free(freep); - + return rx.count; } @@ -68,5 +68,3 @@ fsreadn(CFid *fid, void *buf, long n) } return tot; } - - diff --git a/src/lib9pclient/remove.c b/src/lib9pclient/remove.c index b0ce2da8d..4f0e85c8a 100644 --- a/src/lib9pclient/remove.c +++ b/src/lib9pclient/remove.c @@ -16,4 +16,3 @@ fsremove(CFsys *fs, char *name) return -1; return fsfremove(fid); } - diff --git a/src/lib9pclient/stat.c b/src/lib9pclient/stat.c index 9c69446aa..96450fbd4 100644 --- a/src/lib9pclient/stat.c +++ b/src/lib9pclient/stat.c @@ -15,7 +15,7 @@ fsdirstat(CFsys *fs, char *name) if((fid = fswalk(fs->root, name)) == nil) return nil; - + d = fsdirfstat(fid); fsclose(fid); return d; @@ -51,4 +51,3 @@ fsdirfstat(CFid *fid) } return d; } - diff --git a/src/lib9pclient/wstat.c b/src/lib9pclient/wstat.c index 26e44f8e8..633f39e39 100644 --- a/src/lib9pclient/wstat.c +++ b/src/lib9pclient/wstat.c @@ -15,7 +15,7 @@ fsdirwstat(CFsys *fs, char *name, Dir *d) if((fid = fswalk(fs->root, name)) == nil) return -1; - + n = fsdirfwstat(fid, d); fsclose(fid); return n; diff --git a/src/libString/s_getline.c b/src/libString/s_getline.c index 86c9bf0c9..38252a736 100644 --- a/src/libString/s_getline.c +++ b/src/libString/s_getline.c @@ -9,7 +9,7 @@ * Leading whitespace and newlines are removed. * * Empty lines and lines starting with '#' are ignored. - */ + */ extern char * s_getline(Biobuf *fp, String *to) { diff --git a/src/libString/s_grow.c b/src/libString/s_grow.c index 5cf2a1414..62cda996c 100644 --- a/src/libString/s_grow.c +++ b/src/libString/s_grow.c @@ -4,7 +4,7 @@ /* grow a String's allocation by at least `incr' bytes */ extern String* -s_grow(String *s, int incr) +s_grow(String *s, int incr) { char *cp; int size; @@ -31,4 +31,3 @@ s_grow(String *s, int incr) return s; } - diff --git a/src/libString/s_memappend.c b/src/libString/s_memappend.c index 27b69850e..8cbacd185 100644 --- a/src/libString/s_memappend.c +++ b/src/libString/s_memappend.c @@ -17,4 +17,3 @@ s_memappend(String *to, char *from, int n) s_terminate(to); return to; } - diff --git a/src/libString/s_nappend.c b/src/libString/s_nappend.c index fb41f9328..32470a9e4 100644 --- a/src/libString/s_nappend.c +++ b/src/libString/s_nappend.c @@ -15,4 +15,3 @@ s_nappend(String *to, char *from, int n) s_terminate(to); return to; } - diff --git a/src/libString/s_parse.c b/src/libString/s_parse.c index bcf2aef9d..6691356f0 100644 --- a/src/libString/s_parse.c +++ b/src/libString/s_parse.c @@ -19,13 +19,13 @@ s_parse(String *from, String *to) from->ptr++; for (;*from->ptr != '\'' && *from->ptr != '\0'; from->ptr++) s_putc(to, *from->ptr); - if (*from->ptr == '\'') + if (*from->ptr == '\'') from->ptr++; } else if (*from->ptr == '"') { from->ptr++; for (;*from->ptr != '"' && *from->ptr != '\0'; from->ptr++) s_putc(to, *from->ptr); - if (*from->ptr == '"') + if (*from->ptr == '"') from->ptr++; } else { for (;!isspace(*from->ptr) && *from->ptr != '\0'; from->ptr++) diff --git a/src/libString/s_rdinstack.c b/src/libString/s_rdinstack.c index 520f16a68..c859b2c51 100644 --- a/src/libString/s_rdinstack.c +++ b/src/libString/s_rdinstack.c @@ -89,7 +89,7 @@ rdline(Biobuf *fp, String *to) * Leading whitespace and newlines are removed. * Lines starting with #include cause us to descend into the new file. * Empty lines and other lines starting with '#' are ignored. - */ + */ extern char * s_rdinstack(Sinstack *sp, String *to) { diff --git a/src/libString/s_read.c b/src/libString/s_read.c index 7745d677a..20583ef25 100644 --- a/src/libString/s_read.c +++ b/src/libString/s_read.c @@ -11,7 +11,7 @@ enum /* Append up to 'len' input bytes to the string 'to'. * * Returns the number of characters read. - */ + */ extern int s_read(Biobuf *fp, String *to, int len) { diff --git a/src/libString/s_read_line.c b/src/libString/s_read_line.c index b1de5ac45..e5e2a1d93 100644 --- a/src/libString/s_read_line.c +++ b/src/libString/s_read_line.c @@ -7,7 +7,7 @@ * * Returns a pointer to the character string (or 0). * Trailing newline is left on. - */ + */ extern char * s_read_line(Biobuf *fp, String *to) { diff --git a/src/libacme/acme.c b/src/libacme/acme.c index 8904b4c20..3fd9d4fc0 100644 --- a/src/libacme/acme.c +++ b/src/libacme/acme.c @@ -45,7 +45,7 @@ openwin(int id, CFid *ctl) { char buf[100]; Win *w; - + mountacme(); if(ctl == nil){ snprint(buf, sizeof buf, "%d/ctl", id); @@ -166,7 +166,7 @@ int winopenfd(Win *w, char *name, int mode) { char buf[100]; - + snprint(buf, sizeof buf, "%d/%s", w->id, name); return fsopenfd(acmefs, buf, mode); } @@ -243,7 +243,7 @@ winreadaddr(Win *w, uint *q1) char buf[40], *p; uint q0; int n; - + n = fspread(wfid(w, "addr"), buf, sizeof buf-1, 0); if(n <= 0) return -1; @@ -271,7 +271,7 @@ winmread(Win *w, char *file) { char *buf; int n, tot, m; - + m = 128; buf = emalloc(m+1); tot = 0; @@ -568,7 +568,7 @@ eventreader(void *v) Event e[2]; Win *w; int i; - + w = v; i = 0; for(;;){ diff --git a/src/libauth/attr.c b/src/libauth/attr.c index 8adeefe6c..be8d1ad31 100644 --- a/src/libauth/attr.c +++ b/src/libauth/attr.c @@ -174,4 +174,3 @@ _strfindattr(Attr *a, char *n) return nil; return a->val; } - diff --git a/src/libauth/auth_proxy.c b/src/libauth/auth_proxy.c index 257bafe76..a5fe44117 100644 --- a/src/libauth/auth_proxy.c +++ b/src/libauth/auth_proxy.c @@ -5,7 +5,7 @@ #include <9pclient.h> #include "authlocal.h" -enum { +enum { ARgiveup = 100 }; @@ -291,4 +291,3 @@ fsauth_proxy(CFid *fid, AuthGetkey *getkey, char *fmt, ...) auth_freerpc(rpc); return ai; } - diff --git a/src/libauth/auth_respond.c b/src/libauth/auth_respond.c index b3cf6665f..4e2719003 100644 --- a/src/libauth/auth_respond.c +++ b/src/libauth/auth_respond.c @@ -61,5 +61,5 @@ auth_respond(void *chal, uint nchal, char *user, uint nuser, void *resp, uint nr _freeattr(a); auth_freerpc(rpc); - return nresp; + return nresp; } diff --git a/src/libauth/fsamount.c b/src/libauth/fsamount.c index bece208a3..4cb33bbd1 100644 --- a/src/libauth/fsamount.c +++ b/src/libauth/fsamount.c @@ -11,7 +11,7 @@ fsamount(int fd, char *aname) CFid *afid, *fid; AuthInfo *ai; CFsys *fs; - + fs = fsinit(fd); if(fs == nil) return nil; @@ -30,4 +30,3 @@ fsamount(int fd, char *aname) fssetroot(fs, fid); return fs; } - diff --git a/src/libauth/nsamount.c b/src/libauth/nsamount.c index 1447904ac..4e9b827af 100644 --- a/src/libauth/nsamount.c +++ b/src/libauth/nsamount.c @@ -11,7 +11,7 @@ nsamount(char *name, char *aname) CFid *afid, *fid; AuthInfo *ai; CFsys *fs; - + fs = nsinit(name); if(fs == nil) return nil; @@ -30,4 +30,3 @@ nsamount(char *name, char *aname) fssetroot(fs, fid); return fs; } - diff --git a/src/libauthsrv/convM2T.c b/src/libauthsrv/convM2T.c index 372825a87..427520a53 100644 --- a/src/libauthsrv/convM2T.c +++ b/src/libauthsrv/convM2T.c @@ -25,4 +25,3 @@ convM2T(char *ap, Ticket *f, char *key) STRING(key, DESKEYLEN); USED(p); } - diff --git a/src/libauthsrv/convPR2M.c b/src/libauthsrv/convPR2M.c index 8b2422f1b..7efc0b2dd 100644 --- a/src/libauthsrv/convPR2M.c +++ b/src/libauthsrv/convPR2M.c @@ -25,4 +25,3 @@ convPR2M(Passwordreq *f, char *ap, char *key) encrypt(key, ap, n); return n; } - diff --git a/src/libauthsrv/convTR2M.c b/src/libauthsrv/convTR2M.c index 3a7610a71..04000aad4 100644 --- a/src/libauthsrv/convTR2M.c +++ b/src/libauthsrv/convTR2M.c @@ -24,4 +24,3 @@ convTR2M(Ticketreq *f, char *ap) n = p - (uchar*)ap; return n; } - diff --git a/src/libauthsrv/readnvram.c b/src/libauthsrv/readnvram.c index f65db9846..337203f78 100644 --- a/src/libauthsrv/readnvram.c +++ b/src/libauthsrv/readnvram.c @@ -45,7 +45,7 @@ static char* xreadcons(char *prompt, char *def, int secret, char *buf, int nbuf) { char *p; - + p = readcons(prompt, def, secret); if(p == nil) return nil; @@ -280,7 +280,7 @@ finddosfile(int fd, char *file) if(rootsects <= 0 || rootsects > 64) return -1; - /* + /* * read root. it is contiguous to make stuff like * this easier */ @@ -305,4 +305,3 @@ finddosfile(int fd, char *file) */ return rootoff + rootsects*sectsize + (n-2)*sectsize*b->clustsize; } - diff --git a/src/libbio/bcat.c b/src/libbio/bcat.c index 7c9b39e93..cc8e53d82 100644 --- a/src/libbio/bcat.c +++ b/src/libbio/bcat.c @@ -14,7 +14,7 @@ bcat(Biobuf *b, char *name) fprint(2, "writing during %s: %r\n", name); } if(n < 0) - fprint(2, "reading %s: %r\n", name); + fprint(2, "reading %s: %r\n", name); } int diff --git a/src/libbio/brdstr.c b/src/libbio/brdstr.c index 52baf5171..30d40db4c 100644 --- a/src/libbio/brdstr.c +++ b/src/libbio/brdstr.c @@ -99,7 +99,7 @@ Brdstr(Biobuf *bp, int delim, int nulldelim) } ip += j; } - + /* * full buffer without finding; add to user string and continue */ diff --git a/src/libbio/bvprint.c b/src/libbio/bvprint.c index 60b105fa5..0b1aaf6b9 100644 --- a/src/libbio/bvprint.c +++ b/src/libbio/bvprint.c @@ -1,7 +1,7 @@ #include "lib9.h" #include -static int +static int fmtBflush(Fmt *f) { Biobuf *bp; diff --git a/src/libbio/lib9.std.h b/src/libbio/lib9.std.h index 180471e16..e4897023a 100644 --- a/src/libbio/lib9.std.h +++ b/src/libbio/lib9.std.h @@ -23,4 +23,3 @@ typedef unsigned long long uvlong; #define seek(fd, offset, whence) lseek(fd, offset, whence) #define create(name, mode, perm) creat(name, perm) - diff --git a/src/libdisk/disk.c b/src/libdisk/disk.c index 3428c4675..0230d3290 100644 --- a/src/libdisk/disk.c +++ b/src/libdisk/disk.c @@ -16,16 +16,16 @@ mkwidth(Disk *disk) /* * Discover the disk geometry by various sleazeful means. - * + * * First, if there is a partition table in sector 0, * see if all the partitions have the same end head - * and sector; if so, we'll assume that that's the + * and sector; if so, we'll assume that that's the * right count. - * + * * If that fails, we'll try looking at the geometry that the ATA * driver supplied, if any, and translate that as a - * BIOS might. - * + * BIOS might. + * * If that too fails, which should only happen on a SCSI * disk with no currently defined partitions, we'll try * various common (h, s) pairs used by BIOSes when faking @@ -252,7 +252,7 @@ opensd(Disk *disk) } } - + disk->size = disk->secs * disk->secsize; if(disk->size <= 0) { strcpy(disk->part, ""); @@ -345,4 +345,3 @@ opendisk(char *disk, int rdonly, int noctl) d->type = Tfile; return openfile(d); } - diff --git a/src/libdisk/proto.c b/src/libdisk/proto.c index ee30fc92a..43e3d9c49 100644 --- a/src/libdisk/proto.c +++ b/src/libdisk/proto.c @@ -13,7 +13,7 @@ enum { #undef warn #define warn protowarn -#undef getmode +#undef getmode #define getmode protogetmode typedef struct File File; @@ -287,7 +287,7 @@ mkpath(Mkaux *mkaux, char *prefix, char *elem) static void setnames(Mkaux *mkaux, File *f) { - + if(f->old){ if(f->old[0] == '/') setname(mkaux, &mkaux->oldfile, f->old, ""); diff --git a/src/libdisk/scsi.c b/src/libdisk/scsi.c index 3f351053a..b790ef3b0 100644 --- a/src/libdisk/scsi.c +++ b/src/libdisk/scsi.c @@ -1,7 +1,7 @@ /* * Now thread-safe. * - * The codeqlock guarantees that once codes != nil, that pointer will never + * The codeqlock guarantees that once codes != nil, that pointer will never * change nor become invalid. * * The QLock in the Scsi structure moderates access to the raw device. @@ -62,7 +62,7 @@ getcodes(void) codes[n] = '\0'; qunlock(&codeqlock); } - + char* scsierror(int asc, int ascq) { @@ -228,11 +228,11 @@ scsi(Scsi *s, uchar *cmd, int ccount, void *v, int dcount, int io) if((n=_scsicmd(s, req, sizeof(req), sense, sizeof(sense), Sread, 0)) < 14) if(scsiverbose) fprint(2, "reqsense scsicmd %d: %r\n", n); - + if(_scsiready(s, 0) < 0) if(scsiverbose) fprint(2, "unit not ready\n"); - + key = sense[2]; code = sense[12]; if(code == 0x17 || code == 0x18) { /* recovered errors */ @@ -319,7 +319,7 @@ openscsi(char *dev) s->rawfd = rawfd; s->inquire = p; s->changetime = time(0); - + if(scsiready(s) < 0) goto Error1; diff --git a/src/libdiskfs/block.c b/src/libdiskfs/block.c index 94ea51116..552078a9e 100644 --- a/src/libdiskfs/block.c +++ b/src/libdiskfs/block.c @@ -46,7 +46,7 @@ blockput(Block *b) return; if(!b->_close){ fprint(2, "no blockPut\n"); - abort(); + abort(); } (*b->_close)(b); } diff --git a/src/libdiskfs/cache.c b/src/libdiskfs/cache.c index 7b06fa4f3..2888ae836 100644 --- a/src/libdiskfs/cache.c +++ b/src/libdiskfs/cache.c @@ -3,7 +3,7 @@ #include /* - * Disk cache. Caches by offset, so higher levels have + * Disk cache. Caches by offset, so higher levels have * to deal with alignment issues (if we get asked for the * blocks at offsets 0 and 1, we'll do two reads). */ @@ -43,7 +43,7 @@ addtohash(DiskCache *d, DiskCacheBlock *b, u64int offset) if(b->offset != ~(u64int)0){ fprint(2, "bad offset in addtohash\n"); - return; + return; } b->offset = offset; h = offset % d->nhash; @@ -227,8 +227,8 @@ diskcacheread(Disk *dd, u32int len, u64int offset) return b; } -/* - * It's okay to remove these from the hash table. +/* + * It's okay to remove these from the hash table. * Either the block is in use by someone or it is on * the lru list. If it's in use it will get put on the lru * list once the refs go away. @@ -264,7 +264,7 @@ diskcacheclose(Disk *dd) blockput(b->subblock); free(d); } - + /* needn't be fast */ static int isprime(int n) diff --git a/src/libdiskfs/ext2.c b/src/libdiskfs/ext2.c index b55f1eb3d..ce16f37d3 100644 --- a/src/libdiskfs/ext2.c +++ b/src/libdiskfs/ext2.c @@ -103,7 +103,7 @@ ext2blockread(Fsys *fsys, u64int vbno) if(bno != vbno) return nil; -/* +/* if(bno < fs->firstblock) return diskread(fs->disk, fs->blocksize, (u64int)bno*fs->blocksize); */ @@ -142,7 +142,7 @@ ext2blockread(Fsys *fsys, u64int vbno) if((bits[boff>>3] & (1<<(boff&7))) == 0){ if(debug) fprint(2, "block %d not allocated in group %d: bitblock %d/%lld bits[%d] = %#x\n", - boff, bno/fs->blockspergroup, + boff, bno/fs->blockspergroup, (int)bitblock, bitpos, boff>>3, @@ -174,7 +174,7 @@ ext2fileblock(Ext2 *fs, Inode *ino, u32int bno, int size) obno = bno; if(bno < NDIRBLOCKS){ if(debug) - fprint(2, "fileblock %d -> %d...", + fprint(2, "fileblock %d -> %d...", bno, ino->block[bno]); return ext2datablock(fs, ino->block[bno], size); } @@ -592,7 +592,7 @@ ext2readdir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, u64int coo if((ok = inoperm(&ino, au, AREAD)) != Nfs3Ok) return ok; - if(debug) print("readdir cookie %#llux ino.size %#llux\n", + if(debug) print("readdir cookie %#llux ino.size %#llux\n", (u64int)cookie, (u64int)ino.size); if(cookie >= ino.size){ diff --git a/src/libdiskfs/ext2.h b/src/libdiskfs/ext2.h index 7ddd400a9..f4c32ce3a 100644 --- a/src/libdiskfs/ext2.h +++ b/src/libdiskfs/ext2.h @@ -80,7 +80,7 @@ struct Super u32int revlevel; /* Revision level */ u16int defresuid; /* Default uid for reserved blocks */ u16int defresgid; /* Default gid for reserved blocks */ - + /* the following are only available with revlevel = 1 */ u32int firstino; /* First non-reserved inode */ u16int inosize; /* size of inode structure */ @@ -161,4 +161,3 @@ struct Ext2 Disk *disk; Fsys *fsys; }; - diff --git a/src/libdiskfs/fat.c b/src/libdiskfs/fat.c index 4d12512c8..0eb1c995e 100644 --- a/src/libdiskfs/fat.c +++ b/src/libdiskfs/fat.c @@ -8,4 +8,3 @@ fsysopenfat(Disk *disk) USED(disk); return nil; } - diff --git a/src/libdiskfs/ffs.c b/src/libdiskfs/ffs.c index d8e233924..70552e492 100644 --- a/src/libdiskfs/ffs.c +++ b/src/libdiskfs/ffs.c @@ -124,8 +124,8 @@ ffssync(Fsys *fsys) fs->nfrag = fsblk->nfrag; fs->ndfrag = fsblk->ndfrag; /* - * used to use - * fs->blockspergroup = (u64int)fsblk->_cylspergroup * + * used to use + * fs->blockspergroup = (u64int)fsblk->_cylspergroup * * fsblk->secspercyl * BYTESPERSEC / fsblk->blocksize; * for UFS1, but this should work for both UFS1 and UFS2 */ @@ -190,7 +190,7 @@ ffsclose(Fsys *fsys) free(fs); free(fsys); } - + static int checkfsblk(Fsblk *super) { @@ -311,7 +311,7 @@ ffsdatablock(Ffs *fs, u64int bno, int size) blockput(b); return nil; } - + return b; } @@ -319,7 +319,7 @@ static u64int ifetch(Ffs *fs, u64int bno, u32int off) { Block *b; - + if(bno == BADBNO) return BADBNO; b = ffsdatablock(fs, bno, fs->blocksize); @@ -352,10 +352,10 @@ ffsfileblockno(Ffs *fs, Inode *ino, u64int bno) if(bno < ppb*ppb) return ifetch(fs, ifetch(fs, ino->ib[1], bno/ppb), bno%ppb); bno -= ppb*ppb; - + if(bno/ppb/ppb/ppb == 0) /* bno < ppb*ppb*ppb w/o overflow */ return ifetch(fs, ifetch(fs, ifetch(fs, ino->ib[2], bno/ppb/ppb), (bno/ppb)%ppb), bno%ppb); - + fprint(2, "ffsfileblock %llud: way too big\n", bno+NDADDR+ppb+ppb*ppb); return BADBNO; } @@ -364,7 +364,7 @@ static Block* ffsfileblock(Ffs *fs, Inode *ino, u64int bno, int size) { u64int b; - + b = ffsfileblockno(fs, ino, bno); if(b == ~0) return nil; @@ -396,7 +396,7 @@ static void inode1to2(Inode1 *i1, Inode *i2) { int i; - + memset(i2, 0, sizeof *i2); i2->mode = i1->mode; i2->nlink = i1->nlink; @@ -777,7 +777,7 @@ ffsxfileblock(Fsys *fsys, Nfs3Handle *h, u64int offset) Inode ino; Nfs3Status ok; Ffs *fs; - + fs = fsys->priv; if((ok = handle2ino(fs, h, nil, &ino)) != Nfs3Ok){ nfs3errstr(ok); diff --git a/src/libdiskfs/ffs.h b/src/libdiskfs/ffs.h index 6a5a387d3..d7881f15f 100644 --- a/src/libdiskfs/ffs.h +++ b/src/libdiskfs/ffs.h @@ -40,7 +40,7 @@ enum FSMAGIC = 0x011954, FSMAGIC2 = 0x19540119, FSCHECKSUM = 0x7c269d38, - + /* Fsblk.inodefmt */ FS42INODEFMT = -1, FS44INODEFMT = 2, @@ -341,4 +341,3 @@ struct Ffs Disk *disk; }; - diff --git a/src/libdiskfs/hfs.c b/src/libdiskfs/hfs.c index 6784dab40..03e97a15a 100644 --- a/src/libdiskfs/hfs.c +++ b/src/libdiskfs/hfs.c @@ -89,7 +89,7 @@ fsysopenhfs(Disk *disk) fsys->_readdir = hfsreaddir; fsys->_close = hfsclose; fsys->disk = disk; - + if(hfswrapper(fsys) < 0 || hfssync(fsys) < 0) goto error; @@ -130,7 +130,7 @@ hfswrapper(Fsys *fsys) int magic, hfsstart, subsig, substart, subnblocks; u32int hfsblocksize; u64int offset, size; - + fs = fsys->priv; disk = fsys->disk; if((b = diskread(disk, 162, 1024)) == nil) @@ -143,12 +143,12 @@ hfswrapper(Fsys *fsys) substart = get16(mdb+126); subnblocks = get16(mdb+128); blockput(b); - + if(magic != Hfssig) return 0; if(subsig != Hfsplussig && subsig != Hfsxsig) return 0; - + offset = hfsstart*512 + substart*hfsblocksize; size = subnblocks*hfsblocksize; @@ -748,7 +748,7 @@ hfsreaddir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, if(ino.u.nentries>>31) return Nfs3ErrIo; nentries = ino.u.nentries*2; /* even data, odd resource */ - + i = cookie>>32; cnid = cookie&0xFFFFFFFF; if(debug) print("readdir %ud %ud %ud...", cnid, i, nentries); @@ -784,7 +784,7 @@ hfsreaddir(Fsys *fsys, SunAuthUnix *au, Nfs3Handle *h, u32int count, goto badparent; i++; } - + memset(&e, 0, sizeof e); for(; ifork->cnid, for debugging prints */ - + Block *block; /* a node in the tree */ u32int nno; Node node; - + int rno; /* a record in the node */ int klen; - uchar *key; + uchar *key; int dlen; uchar *data; }; diff --git a/src/libdiskfs/kfs.c b/src/libdiskfs/kfs.c index 51d7c5e30..216ad2775 100644 --- a/src/libdiskfs/kfs.c +++ b/src/libdiskfs/kfs.c @@ -8,4 +8,3 @@ fsysopenkfs(Disk *disk) USED(disk); return nil; } - diff --git a/src/libdiskfs/part.c b/src/libdiskfs/part.c index dc5d171f8..0da5a2346 100644 --- a/src/libdiskfs/part.c +++ b/src/libdiskfs/part.c @@ -27,7 +27,7 @@ static int diskpartsync(Disk *dd) { DiskPart *d = (DiskPart*)dd; - + if(d->subdisk) return disksync(d->subdisk); return 0; @@ -37,7 +37,7 @@ static void diskpartclose(Disk *dd) { DiskPart *d = (DiskPart*)dd; - + if(d->subdisk) diskclose(d->subdisk); free(d); @@ -47,18 +47,18 @@ Disk* diskpart(Disk *subdisk, u64int offset, u64int size) { DiskPart *d; - + d = mallocz(sizeof(DiskPart), 1); if(d == nil) return nil; - + d->subdisk = subdisk; d->offset = offset; d->size = size; d->disk._read = diskpartread; d->disk._sync = diskpartsync; d->disk._close = diskpartclose; - + return &d->disk; } diff --git a/src/libdiskfs/venti.c b/src/libdiskfs/venti.c index a497d5e06..c6f15cae1 100644 --- a/src/libdiskfs/venti.c +++ b/src/libdiskfs/venti.c @@ -159,4 +159,3 @@ diskopenventi(VtCache *c, uchar score[VtScoreSize]) _nfilereads_darwin_sucks(); /* force Darwin ld to pull in file.o */ return nil; } - diff --git a/src/libdiskfs/vfile.c b/src/libdiskfs/vfile.c index 72ca0446c..d9be4b123 100644 --- a/src/libdiskfs/vfile.c +++ b/src/libdiskfs/vfile.c @@ -31,5 +31,3 @@ diskVentiRead(Disk *dd, u32int len, u64int offset) walk down blocks return the one } - - diff --git a/src/libdraw/allocimagemix.c b/src/libdraw/allocimagemix.c index 09d60ec9c..6d2b2d156 100644 --- a/src/libdraw/allocimagemix.c +++ b/src/libdraw/allocimagemix.c @@ -10,7 +10,7 @@ allocimagemix(Display *d, u32int color1, u32int color3) if(qmask == nil) qmask = allocimage(d, Rect(0,0,1,1), GREY8, 1, 0x3F3F3FFF); - + if(d->screenimage->depth <= 8){ /* create a 2×2 texture */ t = allocimage(d, Rect(0,0,1,1), d->screenimage->chan, 0, color1); if(t == nil) diff --git a/src/libdraw/arith.c b/src/libdraw/arith.c index 1b19fc1c4..d7c067a3f 100644 --- a/src/libdraw/arith.c +++ b/src/libdraw/arith.c @@ -201,4 +201,3 @@ Pfmt(Fmt *f) p = va_arg(f->args, Point); return fmtprint(f, "[%d %d]", p.x, p.y); } - diff --git a/src/libdraw/buildfont.c b/src/libdraw/buildfont.c index 02d976e17..5425ad446 100644 --- a/src/libdraw/buildfont.c +++ b/src/libdraw/buildfont.c @@ -154,7 +154,7 @@ freefont(Font *f) f->display->firstfont = f->next; } - if(f->lodpi != f) + if(f->lodpi != f) freefont(f->lodpi); if(f->hidpi != f) freefont(f->hidpi); diff --git a/src/libdraw/chan.c b/src/libdraw/chan.c index 5e94b0161..0cf2b668e 100644 --- a/src/libdraw/chan.c +++ b/src/libdraw/chan.c @@ -42,7 +42,7 @@ strtochan(char *s) p++; while(*p && !isspace((uchar)*p)){ - if((q = strchr(channames, p[0])) == nil) + if((q = strchr(channames, p[0])) == nil) return 0; t = q-channames; if(p[1] < '0' || p[1] > '9') diff --git a/src/libdraw/computil.c b/src/libdraw/computil.c index 30a3d11e6..b1dc2999b 100644 --- a/src/libdraw/computil.c +++ b/src/libdraw/computil.c @@ -3,7 +3,7 @@ #include /* - * compressed data are seuences of byte codes. + * compressed data are seuences of byte codes. * if the first byte b has the 0x80 bit set, the next (b^0x80)+1 bytes * are data. otherwise, it's two bytes specifying a previous string to repeat. */ diff --git a/src/libdraw/draw.c b/src/libdraw/draw.c index d3f83e885..f72d35dff 100644 --- a/src/libdraw/draw.c +++ b/src/libdraw/draw.c @@ -15,7 +15,7 @@ _setdrawop(Display *d, Drawop op) a[1] = op; } } - + static void draw1(Image *dst, Rectangle *r, Image *src, Point *p0, Image *mask, Point *p1, Drawop op) { diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index f0b1d388a..ef0356b8b 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -23,10 +23,10 @@ int _displayconnect(Display *d) { int pid, p[2]; - + fmtinstall('W', drawfcallfmt); fmtinstall('H', encodefmt); - + if(pipe(p) < 0) return -1; if((pid=fork()) < 0){ @@ -84,7 +84,7 @@ _displaymux(Display *d) d->mux->settag = drawsettag; d->mux->aux = d; muxinit(d->mux); - + return 0; } @@ -94,7 +94,7 @@ drawsend(Mux *mux, void *vmsg) int n; uchar *msg; Display *d; - + msg = vmsg; GET(msg, n); d = mux->aux; @@ -148,7 +148,7 @@ drawgettag(Mux *mux, void *vmsg) { uchar *msg; USED(mux); - + msg = vmsg; return msg[4]; } @@ -158,7 +158,7 @@ drawsettag(Mux *mux, void *vmsg, uint tag) { uchar *msg; USED(mux); - + msg = vmsg; msg[4] = tag; return 0; @@ -169,7 +169,7 @@ displayrpc(Display *d, Wsysmsg *tx, Wsysmsg *rx, void **freep) { int n, nn; void *tpkt, *rpkt; - + n = sizeW2M(tx); tpkt = malloc(n); if(freep) @@ -295,7 +295,7 @@ int _displaycursor(Display *d, Cursor *c, Cursor2 *c2) { Wsysmsg tx, rx; - + tx.type = Tcursor2; if(c == nil){ memset(&tx.cursor, 0, sizeof tx.cursor); @@ -316,7 +316,7 @@ int _displaybouncemouse(Display *d, Mouse *m) { Wsysmsg tx, rx; - + tx.type = Tbouncemouse; tx.mouse = *m; return displayrpc(d, &tx, &rx, nil); @@ -326,7 +326,7 @@ int _displaylabel(Display *d, char *label) { Wsysmsg tx, rx; - + tx.type = Tlabel; tx.label = label; return displayrpc(d, &tx, &rx, nil); @@ -338,7 +338,7 @@ _displayrdsnarf(Display *d) void *p; char *s; Wsysmsg tx, rx; - + tx.type = Trdsnarf; if(displayrpc(d, &tx, &rx, &p) < 0) return nil; @@ -351,7 +351,7 @@ int _displaywrsnarf(Display *d, char *snarf) { Wsysmsg tx, rx; - + tx.type = Twrsnarf; tx.snarf = snarf; return displayrpc(d, &tx, &rx, nil); @@ -362,7 +362,7 @@ _displayrddraw(Display *d, void *v, int n) { void *p; Wsysmsg tx, rx; - + tx.type = Trddraw; tx.count = n; if(displayrpc(d, &tx, &rx, &p) < 0) @@ -376,7 +376,7 @@ int _displaywrdraw(Display *d, void *v, int n) { Wsysmsg tx, rx; - + tx.type = Twrdraw; tx.count = n; tx.data = v; @@ -398,7 +398,7 @@ int _displayresize(Display *d, Rectangle r) { Wsysmsg tx, rx; - + tx.type = Tresize; tx.rect = r; return displayrpc(d, &tx, &rx, nil); @@ -409,7 +409,7 @@ canreadfd(int fd) { fd_set rs, ws, xs; struct timeval tv; - + FD_ZERO(&rs); FD_ZERO(&ws); FD_ZERO(&xs); @@ -423,4 +423,3 @@ canreadfd(int fd) return 1; return 0; } - diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index 09051bbc0..c74b3fafb 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -17,7 +17,7 @@ static int PUTSTRING(uchar *p, char *s) { int n; - + if(s == nil) s = ""; n = strlen(s); @@ -30,14 +30,14 @@ static int GETSTRING(uchar *p, char **s) { int n; - + GET(p, n); memmove(p, p+4, n); *s = (char*)p; p[n] = 0; return n+4; } - + uint sizeW2M(Wsysmsg *m) { @@ -96,7 +96,7 @@ uint convW2M(Wsysmsg *m, uchar *p, uint n) { int nn; - + nn = sizeW2M(m); if(n < nn || nn == 0 || n < 6) return 0; @@ -188,7 +188,7 @@ convW2M(Wsysmsg *m, uchar *p, uint n) PUT(p+14, m->rect.max.x); PUT(p+18, m->rect.max.y); break; - } + } return nn; } @@ -196,7 +196,7 @@ uint convM2W(uchar *p, uint n, Wsysmsg *m) { int nn; - + if(n < 6) return 0; GET(p, nn); @@ -288,7 +288,7 @@ convM2W(uchar *p, uint n, Wsysmsg *m) GET(p+14, m->rect.max.x); GET(p+18, m->rect.max.y); break; - } + } return nn; } @@ -313,7 +313,7 @@ int drawfcallfmt(Fmt *fmt) { Wsysmsg *m; - + m = va_arg(fmt->args, Wsysmsg*); fmtprint(fmt, "tag=%d ", m->tag); switch(m->type){ @@ -325,7 +325,7 @@ drawfcallfmt(Fmt *fmt) return fmtprint(fmt, "Trdmouse"); case Rrdmouse: return fmtprint(fmt, "Rrdmouse x=%d y=%d buttons=%d msec=%d resized=%d", - m->mouse.xy.x, m->mouse.xy.y, + m->mouse.xy.x, m->mouse.xy.y, m->mouse.buttons, m->mouse.msec, m->resized); case Tbouncemouse: return fmtprint(fmt, "Tbouncemouse x=%d y=%d buttons=%d", diff --git a/src/libdraw/drawrepl.c b/src/libdraw/drawrepl.c index c72fee26a..77c20d43a 100644 --- a/src/libdraw/drawrepl.c +++ b/src/libdraw/drawrepl.c @@ -20,4 +20,3 @@ drawrepl(Rectangle r, Point p) p.y = drawreplxy(r.min.y, r.max.y, p.y); return p; } - diff --git a/src/libdraw/event.c b/src/libdraw/event.c index b369c0200..9d7e10c23 100644 --- a/src/libdraw/event.c +++ b/src/libdraw/event.c @@ -187,7 +187,7 @@ static Ebuf* newebuf(Slave *s, int n) { Ebuf *eb; - + eb = malloc(sizeof(*eb) - sizeof(eb->u.buf) + n); if(eb == nil) drawerror(display, "events: out of memory"); @@ -205,7 +205,7 @@ startrpc(int type) { uchar buf[100]; Wsysmsg w; - + w.type = type; convW2M(&w, buf, sizeof buf); return muxrpcstart(display->mux, buf); @@ -217,7 +217,7 @@ finishrpc(Muxrpc *r, Wsysmsg *w) uchar *p; void *v; int n; - + if(!muxrpccanfinish(r, &v)) return 0; p = v; @@ -245,9 +245,9 @@ extract(int canblock) * Also make sure that we don't interfere with app-specific locking. */ if(display->locking){ - /* - * if locking is being done by program, - * this means it can't depend on automatic + /* + * if locking is being done by program, + * this means it can't depend on automatic * flush in emouse() etc. */ if(canqlock(&display->qlock)){ @@ -311,7 +311,7 @@ extract(int canblock) max = eslave[i].fd; } } - + if(!canblock){ tv.tv_sec = 0; tv.tv_usec = 0; @@ -437,4 +437,3 @@ ereadmouse(Mouse *m) eresized(1); return 1; } - diff --git a/src/libdraw/font.c b/src/libdraw/font.c index c0235c4b3..34121aafa 100644 --- a/src/libdraw/font.c +++ b/src/libdraw/font.c @@ -54,7 +54,7 @@ cachechars(Font *f, char **ss, Rune **rr, ushort *cp, int max, int *wp, char **s c++; h++; } - + /* * Not found; toss out oldest entry */ @@ -91,7 +91,7 @@ cachechars(Font *f, char **ss, Rune **rr, ushort *cp, int max, int *wp, char **s break; } c = &f->cache[h]; /* may have reallocated f->cache */ - + Found: wid += c->width; c->age = f->age; diff --git a/src/libdraw/getsubfont.c b/src/libdraw/getsubfont.c index ba6753909..ec4ccfe3e 100644 --- a/src/libdraw/getsubfont.c +++ b/src/libdraw/getsubfont.c @@ -73,14 +73,14 @@ scalesubfont(Subfont *f, int scale) int y, x, x2, j; uchar *src, *dst; int srcn, dstn, n, mask, v, pack; - + r = f->bits->r; r2 = r; r2.min.x *= scale; r2.min.y *= scale; r2.max.x *= scale; r2.max.y *= scale; - + srcn = bytesperline(r, f->bits->depth); src = malloc(srcn); dstn = bytesperline(r2, f->bits->depth); @@ -111,7 +111,7 @@ scalesubfont(Subfont *f, int scale) f->bits = i; f->height *= scale; f->ascent *= scale; - + for(j=0; jn; j++) { f->info[j].x *= scale; f->info[j].top *= scale; diff --git a/src/libdraw/icossin2.c b/src/libdraw/icossin2.c index aa864e1a3..c8cfebc80 100644 --- a/src/libdraw/icossin2.c +++ b/src/libdraw/icossin2.c @@ -3,7 +3,7 @@ #include /* - * Sine and Cosine of arctangents, calculated by + * Sine and Cosine of arctangents, calculated by * (sin(atan(index/100.0))*1024.+0.5) * (cos(atan(index/100.0))*1024.+0.5) * To use, get rational tangent between 0<=tan<=1, scale by 100, diff --git a/src/libdraw/init.c b/src/libdraw/init.c index 350365fe1..31d901440 100644 --- a/src/libdraw/init.c +++ b/src/libdraw/init.c @@ -90,7 +90,7 @@ geninitdraw(char *devdir, void(*error)(Display*, char*), char *fontname, char *l visibleclicks = p != nil && *p == '1'; if(visibleclicks) { Font *f; - + f = display->defaultfont; mousebuttons = allocimage(display, Rect(0,0,64,22), screen->chan, 0, DWhite); border(mousebuttons, mousebuttons->r, 1, display->black, ZP); @@ -129,7 +129,7 @@ getimage0(Display *d, Image *image) /* * If there's an old screen, it has id 0. The 'J' request below - * will try to install the new screen as id 0, so the old one + * will try to install the new screen as id 0, so the old one * must be freed first. */ if(image){ @@ -172,7 +172,7 @@ getimage0(Display *d, Image *image) image->clipr.min.y = atoi(info+9*12); image->clipr.max.x = atoi(info+10*12); image->clipr.max.y = atoi(info+11*12); - + a = bufimage(d, 3); a[0] = 'q'; a[1] = 1; @@ -193,9 +193,9 @@ getwindow(Display *d, int ref) { Image *i, *oi; Font *f; - + /* XXX check for destroyed? */ - + /* * Libdraw promises not to change the value of "screen", * so we have to reuse the image structure @@ -262,7 +262,7 @@ _initdisplay(void (*error)(Display*, char*), char *label) free(disp->buf); goto Error2; } - + if(_displaymux(disp) < 0 || _displayconnect(disp) < 0 || _displayinit(disp, label, winsize) < 0) @@ -276,7 +276,7 @@ _initdisplay(void (*error)(Display*, char*), char *label) image = getimage0(disp, nil); if(image == nil) goto Error4; - + disp->image = image; disp->white = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DWhite); disp->black = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DBlack); @@ -285,7 +285,7 @@ _initdisplay(void (*error)(Display*, char*), char *label) free(disp->black); goto Error4; } - + disp->opaque = disp->white; disp->transparent = disp->black; @@ -390,7 +390,7 @@ flushimage(Display *d, int visible) r = rectaddpt(r, _drawmouse.xy); r = rectaddpt(r, Pt(-Dx(mousebuttons->r)/2, -Dy(mousebuttons->r)-3)); drawop(mousesave, mousesave->r, screen, nil, r.min, S); - + r1 = rectaddpt(Rect(0, 0, 22, 22), r.min); if(_drawmouse.buttons & 1) drawop(screen, r1, mousebuttons, nil, ZP, S); @@ -404,7 +404,7 @@ flushimage(Display *d, int visible) drawop(screen, r, mousesave, nil, ZP, S); return ret; } - + if(visible){ *d->bufp++ = 'v'; /* five bytes always reserved for this */ if(d->_isnewdisplay){ diff --git a/src/libdraw/iprint.c b/src/libdraw/iprint.c index 206044e7f..58654868a 100644 --- a/src/libdraw/iprint.c +++ b/src/libdraw/iprint.c @@ -4,7 +4,7 @@ int iprint(char *fmt, ...) -{ +{ va_list arg; va_start(arg, fmt); diff --git a/src/libdraw/keyboard.c b/src/libdraw/keyboard.c index 755ffbd32..ef7b58022 100644 --- a/src/libdraw/keyboard.c +++ b/src/libdraw/keyboard.c @@ -25,7 +25,7 @@ _ioproc(void *arg) { Rune r; Keyboardctl *kc; - + kc = arg; threadsetname("kbdproc"); for(;;){ @@ -49,4 +49,3 @@ initkeyboard(char *file) proccreate(_ioproc, kc, 32*1024); return kc; } - diff --git a/src/libdraw/mouse.c b/src/libdraw/mouse.c index fc486be43..64a7f73da 100644 --- a/src/libdraw/mouse.c +++ b/src/libdraw/mouse.c @@ -93,4 +93,3 @@ setcursor2(Mousectl *mc, Cursor *c, Cursor2 *c2) { _displaycursor(mc->display, c, c2); } - diff --git a/src/libdraw/newwindow.c b/src/libdraw/newwindow.c index 88784adf5..e77b54dbf 100644 --- a/src/libdraw/newwindow.c +++ b/src/libdraw/newwindow.c @@ -24,4 +24,3 @@ newwindow(char *str) strcpy(buf, "new"); return mount(fd, -1, "/dev", MBEFORE, buf); } - diff --git a/src/libdraw/openfont.c b/src/libdraw/openfont.c index 366664ae9..9312eb437 100644 --- a/src/libdraw/openfont.c +++ b/src/libdraw/openfont.c @@ -10,7 +10,7 @@ parsefontscale(char *name, char **base) { char *p; int scale; - + p = name; scale = 0; while('0' <= *p && *p <= '9') { @@ -24,7 +24,7 @@ parsefontscale(char *name, char **base) scale = 1; } return scale; -} +} extern char _defontfile[]; @@ -114,7 +114,7 @@ swapfont(Font *targ, Font **oldp, Font **newp) if(targ != *oldp) sysfatal("bad swapfont %p %p %p", targ, *oldp, *newp); - + old = *oldp; new = *newp; @@ -175,12 +175,12 @@ hidpiname(Font *f) { char *p, *q; int size; - + // If font name has form x,y return y. p = strchr(f->namespec, ','); if(p != nil) return strdup(p+1); - + // If font name is /mnt/font/Name/Size/font, scale Size. if(strncmp(f->name, "/mnt/font/", 10) == 0) { p = strchr(f->name+10, '/'); @@ -191,9 +191,9 @@ hidpiname(Font *f) while('0' <= *q && *q <= '9') size = size*10 + *q++ - '0'; return smprint("%.*s%d%s", utfnlen(f->name, p-f->name), f->name, size*2, q); - } + } - // Otherwise use pixel doubling. + // Otherwise use pixel doubling. scale: return smprint("%d*%s", f->scale*2, f->name); } @@ -210,7 +210,7 @@ loadhidpi(Font *f) swapfont(f, &f->lodpi, &f->hidpi); return; } - + name = hidpiname(f); fnew = openfont1(f->display, name); if(fnew == nil) @@ -227,7 +227,7 @@ openfont(Display *d, char *name) Font *f; char *p; char *namespec; - + // If font name has form x,y use x for lodpi, y for hidpi. name = strdup(name); namespec = strdup(name); @@ -240,7 +240,7 @@ openfont(Display *d, char *name) f->lodpi = f; free(f->namespec); f->namespec = namespec; - + /* add to display list for when dpi changes */ /* d can be nil when invoked from mc. */ if(d != nil) { @@ -252,12 +252,12 @@ openfont(Display *d, char *name) else d->firstfont = f; d->lastfont = f; - + /* if this is a hi-dpi display, find hi-dpi version and swap */ if(d->dpi >= DefaultDPI*3/2) loadhidpi(f); } - + free(name); return f; @@ -270,7 +270,7 @@ _fontpipe(char *name) char c; char buf[1024], *argv[10]; int nbuf, pid; - + if(pipe(p) < 0) return -1; pid = rfork(RFNOWAIT|RFFDG|RFPROC); @@ -294,7 +294,7 @@ _fontpipe(char *name) _exit(0); } close(p[1]); - + // success marked with leading \001. // otherwise an error happened. for(nbuf=0; nbufref = 1; if(name){ /* - * if already caching this subfont, leave older + * if already caching this subfont, leave older * (and hopefully more widely used) copy in cache. - * this case should not happen -- we got called + * this case should not happen -- we got called * because cachechars needed this subfont and it * wasn't in the cache. */ diff --git a/src/libdraw/subfontname.c b/src/libdraw/subfontname.c index e6059d0e8..d247cb616 100644 --- a/src/libdraw/subfontname.c +++ b/src/libdraw/subfontname.c @@ -11,7 +11,7 @@ subfontname(char *cfname, char *fname, int maxdepth) { char *t, *u, *tmp1, *tmp2, *base; int i, scale; - + scale = parsefontscale(fname, &base); t = strdup(cfname); /* t is the return string */ diff --git a/src/libdraw/unix.c b/src/libdraw/unix.c index 76bc75d0d..be45b75a5 100644 --- a/src/libdraw/unix.c +++ b/src/libdraw/unix.c @@ -12,4 +12,3 @@ _drawflength(int fd) return -1; return s.st_size; } - diff --git a/src/libdraw/wsys.c b/src/libdraw/wsys.c index d9632503d..572bc1d2a 100644 --- a/src/libdraw/wsys.c +++ b/src/libdraw/wsys.c @@ -27,4 +27,3 @@ drawresizewindow(Rectangle r) { _displayresize(display, r); } - diff --git a/src/libframe/frdelete.c b/src/libframe/frdelete.c index e333abd8b..d7c3f5ea9 100644 --- a/src/libframe/frdelete.c +++ b/src/libframe/frdelete.c @@ -60,7 +60,7 @@ frdelete(Frame *f, ulong p0, ulong p1) r.max.x += b->wid; draw(f->b, r, f->b, nil, pt1); cn1 += b->nrune; - + /* blank remainder of line */ r.min.x = r.max.x; r.max.x += w0 - b->wid; diff --git a/src/libframe/frdraw.c b/src/libframe/frdraw.c index 05a45fe2c..9573b1c8b 100644 --- a/src/libframe/frdraw.c +++ b/src/libframe/frdraw.c @@ -62,7 +62,7 @@ frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text) Point qt; uint p; char *ptr; - + if(p0 > p1) sysfatal("libframe: frdrawsel0 p0=%lud > p1=%lud", p0, p1); diff --git a/src/libgeometry/quaternion.c b/src/libgeometry/quaternion.c index 1f920f5a8..0da221450 100644 --- a/src/libgeometry/quaternion.c +++ b/src/libgeometry/quaternion.c @@ -10,7 +10,7 @@ * qunit(q) returns a unit quaternion parallel to q * The following only work on unit quaternions and rotation matrices: * slerp(q, r, a) returns q*(r*q^-1)^a - * qmid(q, r) slerp(q, r, .5) + * qmid(q, r) slerp(q, r, .5) * qsqrt(q) qmid(q, (Quaternion){1,0,0,0}) * qtom(m, q) converts a unit quaternion q into a rotation matrix m * mtoq(m) returns a quaternion equivalent to a rotation matrix m @@ -93,7 +93,7 @@ Quaternion mtoq(Matrix mat){ */ Quaternion qu; double tr, s; - + tr = mat[0][0] + mat[1][1] + mat[2][2]; if (tr >= 0.0) { s = sqrt(tr + mat[3][3]); diff --git a/src/libgeometry/tstack.c b/src/libgeometry/tstack.c index bc41c4acf..a6cea9947 100644 --- a/src/libgeometry/tstack.c +++ b/src/libgeometry/tstack.c @@ -1,6 +1,6 @@ /*% cc -gpc % * These transformation routines maintain stacks of transformations - * and their inverses. + * and their inverses. * t=pushmat(t) push matrix stack * t=popmat(t) pop matrix stack * rot(t, a, axis) multiply stack top by rotation diff --git a/src/libhtml/build.c b/src/libhtml/build.c index 78b6efff4..b2387006f 100644 --- a/src/libhtml/build.c +++ b/src/libhtml/build.c @@ -1815,7 +1815,7 @@ getitems(ItemSource* is, uchar* data, int datalen) tab = newtable(++is->ntables, aalign(tok), adimen(tok, Awidth), - aflagval(tok, Aborder), + aflagval(tok, Aborder), auintval(tok, Acellspacing, TABSP), auintval(tok, Acellpadding, TABPAD), makebackground(nil, acolorval(tok, Abgcolor, ps->curbg.color)), @@ -1916,8 +1916,8 @@ getitems(ItemSource* is, uchar* data, int datalen) flags |= TFisth; c = newtablecell(curtab->cells==nil? 1 : curtab->cells->cellid+1, auintval(tok, Arowspan, 1), - auintval(tok, Acolspan, 1), - aalign(tok), + auintval(tok, Acolspan, 1), + aalign(tok), adimen(tok, Awidth), auintval(tok, Aheight, 0), makebackground(nil, acolorval(tok, Abgcolor, tr->background.color)), @@ -4440,7 +4440,7 @@ validtable(Table* t) /* only when parsing is done is t->nrow set > 0 */ if(ok && t->nrow > 0 && t->ncol > 0) { /* table is "finished" */ - for(i = 0; i < t->nrow && ok; i++) + for(i = 0; i < t->nrow && ok; i++) ok = validtablerow(t->rows+i); for(j = 0; j < t->ncol && ok; j++) ok = validtablecol(t->cols+j); diff --git a/src/libhtml/lex.c b/src/libhtml/lex.c index 258807dd0..49c5f502e 100644 --- a/src/libhtml/lex.c +++ b/src/libhtml/lex.c @@ -31,11 +31,11 @@ Rune **tagnames; char *_tagnames[] = { " ", "!", - "a", + "a", "abbr", "acronym", "address", - "applet", + "applet", "area", "b", "base", @@ -614,7 +614,7 @@ buftostr(Rune* s, Rune* buf, int j) buf[j] = 0; if(s == nil) tmp = _Strndup(buf, j); - else + else tmp = _Strdup2(s, buf); free(s); return tmp; diff --git a/src/libhttpd/redirected.c b/src/libhttpd/redirected.c index c2419457c..3602d8751 100644 --- a/src/libhttpd/redirected.c +++ b/src/libhttpd/redirected.c @@ -24,7 +24,7 @@ hredirected(HConnect *c, char *how, char *uri) *s = '/'; } - n = snprint(c->xferbuf, HBufSize, + n = snprint(c->xferbuf, HBufSize, "Redirection\r\n" "

Redirection

\r\n" "Your selection can be found here.

\r\n", uri); diff --git a/src/libip/BSD.c b/src/libip/BSD.c index 9bf2db0c2..573061634 100644 --- a/src/libip/BSD.c +++ b/src/libip/BSD.c @@ -22,7 +22,7 @@ static void sockaddr2ip(uchar *ip, struct sockaddr *sa) { struct sockaddr_in *sin; - + sin = (struct sockaddr_in*)sa; memmove(ip, v4prefix, IPaddrlen); memmove(ip+IPv4off, &sin->sin_addr, 4); @@ -59,7 +59,7 @@ readipifc(char *net, Ipifc *ifc, int index) mib[3] = 0; mib[4] = NET_RT_IFLIST; mib[5] = 0; - + n = 0; if(sysctl(mib, 6, nil, &n, nil, 0) < 0) return nil; @@ -115,7 +115,7 @@ readipifc(char *net, Ipifc *ifc, int index) continue; *lastlifc = lifc; lastlifc = &lifc->next; - } + } sockaddr2ip(ip, sa); switch(i){ case RTAX_IFA: diff --git a/src/libip/Linux.c b/src/libip/Linux.c index edc67e897..3a1411b9d 100644 --- a/src/libip/Linux.c +++ b/src/libip/Linux.c @@ -16,7 +16,7 @@ * Thanks to Erik Quanstrom. */ static int -netlinkrequest(int fd, int type, int (*fn)(struct nlmsghdr *h, Ipifc**, int), +netlinkrequest(int fd, int type, int (*fn)(struct nlmsghdr *h, Ipifc**, int), Ipifc **ifc, int index) { char buf[1024]; @@ -64,7 +64,7 @@ devsocket(void) /* we couldn't care less which one; just want to talk to the kernel! */ static int dumb[3] = { AF_INET, AF_PACKET, AF_INET6 }; int i, fd; - + for(i=0; i= 0) return fd; @@ -76,7 +76,7 @@ parsertattr(struct rtattr **dst, int ndst, struct nlmsghdr *h, int type, int ski { struct rtattr *src; int len; - + len = h->nlmsg_len - NLMSG_LENGTH(skip); if(len < 0 || h->nlmsg_type != type){ werrstr("attrs too short"); @@ -95,7 +95,7 @@ static void rta2ip(int af, uchar *ip, struct rtattr *rta) { memset(ip, 0, IPaddrlen); - + switch(af){ case AF_INET: memmove(ip, v4prefix, IPv4off); @@ -115,7 +115,7 @@ getlink(struct nlmsghdr *h, Ipifc **ipifclist, int index) struct rtattr *attr[IFLA_MAX+1]; struct ifinfomsg *ifi; Ipifc *ifc; - + ifi = (struct ifinfomsg*)NLMSG_DATA(h); if(index >= 0 && ifi->ifi_index != index) return 0; @@ -172,7 +172,7 @@ getlink(struct nlmsghdr *h, Ipifc **ipifclist, int index) if(ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0 && ifr.ifr_hwaddr.sa_family == ARPHRD_ETHER) memmove(ifc->ether, ifr.ifr_hwaddr.sa_data, 6); - + close(fd); } return 0; @@ -186,7 +186,7 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index) Iplifc *lifc, **l; struct ifaddrmsg *ifa; struct rtattr *attr[IFA_MAX+1]; - + USED(index); ifa = (struct ifaddrmsg*)NLMSG_DATA(h); @@ -197,7 +197,7 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index) return 0; if(parsertattr(attr, nelem(attr), h, RTM_NEWADDR, sizeof(struct ifaddrmsg)) < 0) return -1; - + lifc = mallocz(sizeof *lifc, 1); if(lifc == nil) return -1; @@ -211,13 +211,13 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index) return 0; rta2ip(ifa->ifa_family, lifc->ip, attr[IFA_ADDRESS]); - + mask = ifa->ifa_prefixlen/8; if(ifa->ifa_family == AF_INET) mask += IPv4off; memset(lifc->mask, 0xFF, mask); memmove(lifc->net, lifc->ip, mask); - + if(attr[IFA_CACHEINFO]){ struct ifa_cacheinfo *ci; @@ -236,7 +236,7 @@ readipifc(char *net, Ipifc *ifc, int index) USED(net); freeipifc(ifc); ifc = nil; - + fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if(fd < 0) return nil; @@ -250,4 +250,3 @@ readipifc(char *net, Ipifc *ifc, int index) close(fd); return ifc; } - diff --git a/src/libip/freeipifc.c b/src/libip/freeipifc.c index 7899facc0..1b3bf0210 100644 --- a/src/libip/freeipifc.c +++ b/src/libip/freeipifc.c @@ -17,4 +17,3 @@ freeipifc(Ipifc *i) free(i); } } - diff --git a/src/libip/myetheraddr.c b/src/libip/myetheraddr.c index a6b12def4..3849bfe80 100644 --- a/src/libip/myetheraddr.c +++ b/src/libip/myetheraddr.c @@ -8,7 +8,7 @@ int myetheraddr(uchar *to, char *dev) { Ipifc *ifclist, *ifc; - + ifclist = readipifc(nil, nil, -1); for(ifc=ifclist; ifc; ifc=ifc->next){ if(dev && strcmp(ifc->dev, dev) != 0) @@ -23,4 +23,3 @@ myetheraddr(uchar *to, char *dev) werrstr("no ethernet devices"); return -1; } - diff --git a/src/libip/myipaddr.c b/src/libip/myipaddr.c index bbde18f78..24faf9ffd 100644 --- a/src/libip/myipaddr.c +++ b/src/libip/myipaddr.c @@ -42,4 +42,3 @@ myipaddr(uchar *ip, char *net) freeipifc(ifc); return -1; } - diff --git a/src/libip/none.c b/src/libip/none.c index 80110a64a..caf5cf8f6 100644 --- a/src/libip/none.c +++ b/src/libip/none.c @@ -8,7 +8,7 @@ readipifc(char *net, Ipifc *ipifc, int index) USED(net); USED(ipifc); USED(index); - + werrstr("not implemented"); return nil; } diff --git a/src/libip/parseip.c b/src/libip/parseip.c index c0dd55ccd..dba614ce3 100644 --- a/src/libip/parseip.c +++ b/src/libip/parseip.c @@ -129,7 +129,7 @@ v4parsecidr(uchar *addr, uchar *mask, char *from) *a++ = 0xff; if(i > 0) *a = ~((1<<(8-i))-1); - } else + } else memcpy(mask, defmask(addr), IPv4addrlen); return p; } diff --git a/src/libip/udp.c b/src/libip/udp.c index ae413a248..07f6403da 100644 --- a/src/libip/udp.c +++ b/src/libip/udp.c @@ -50,4 +50,3 @@ udpwrite(int fd, Udphdr *hdr, void *buf, long n) memmove(&sin.sin_port, hdr->rport, 2); return sendto(fd, buf, n, 0, (struct sockaddr*)&sin, sizeof sin); } - diff --git a/src/libmach/DragonFly.c b/src/libmach/DragonFly.c index 92ffdb925..33bd8e9c6 100644 --- a/src/libmach/DragonFly.c +++ b/src/libmach/DragonFly.c @@ -43,7 +43,7 @@ unmapproc(Map *map) for(i=0; inseg; i++) while(inseg && map->seg[i].pid){ map->nseg--; - memmove(&map->seg[i], &map->seg[i+1], + memmove(&map->seg[i], &map->seg[i+1], (map->nseg-i)*sizeof(map->seg[0])); } } diff --git a/src/libmach/FreeBSD.c b/src/libmach/FreeBSD.c index 7cf5c1f44..80c8935a3 100644 --- a/src/libmach/FreeBSD.c +++ b/src/libmach/FreeBSD.c @@ -43,7 +43,7 @@ unmapproc(Map *map) for(i=0; inseg; i++) while(inseg && map->seg[i].pid){ map->nseg--; - memmove(&map->seg[i], &map->seg[i+1], + memmove(&map->seg[i], &map->seg[i+1], (map->nseg-i)*sizeof(map->seg[0])); } } diff --git a/src/libmach/Linux.c b/src/libmach/Linux.c index 005d6b388..30b40bbf8 100644 --- a/src/libmach/Linux.c +++ b/src/libmach/Linux.c @@ -1,6 +1,6 @@ /* * process interface for Linux. - * + * * Uses ptrace for registers and data, * /proc for some process status. * There's not much point to worrying about @@ -59,7 +59,7 @@ ptraceattach(int pid) werrstr("ptrace attach %d: %r", pid); return -1; } - + if(ctlproc(pid, "waitstop") < 0){ fprint(2, "waitstop: %r"); ptrace(PTRACE_DETACH, pid, 0, 0); @@ -79,7 +79,7 @@ unmapproc(Map *map) for(i=0; inseg; i++) while(inseg && map->seg[i].pid){ map->nseg--; - memmove(&map->seg[i], &map->seg[i+1], + memmove(&map->seg[i], &map->seg[i+1], (map->nseg-i)*sizeof(map->seg[0])); } } @@ -272,7 +272,7 @@ isstopped(int pid) return *p == 'T'; } -/* /proc/pid/stat contains +/* /proc/pid/stat contains pid command in parens 0. state @@ -456,4 +456,3 @@ proctextfile(int pid) return pbuf; return nil; } - diff --git a/src/libmach/cmdline.c b/src/libmach/cmdline.c index 36d0fb930..18643e10e 100644 --- a/src/libmach/cmdline.c +++ b/src/libmach/cmdline.c @@ -134,7 +134,7 @@ attachargs(int argc, char **argv, int omode, int verbose) mapfile(symhdr, 0, cormap, nil); } - if(corpid) + if(corpid) attachproc(corpid); if(corhdr) attachcore(corhdr); @@ -200,4 +200,3 @@ attachdynamic(int verbose) elfdl386mapdl(verbose); return 0; } - diff --git a/src/libmach/crack.c b/src/libmach/crack.c index 5695b7eb8..a2106f050 100644 --- a/src/libmach/crack.c +++ b/src/libmach/crack.c @@ -10,7 +10,7 @@ Mach *mach; extern Mach mach386; extern Mach machpower; -static Mach *machs[] = +static Mach *machs[] = { &mach386, &machpower, @@ -125,7 +125,7 @@ unmapfile(Fhdr *fp, Map *map) for(i=0; inseg; i++){ while(inseg && map->seg[i].fd == fp->fd){ map->nseg--; - memmove(&map->seg[i], &map->seg[i+1], + memmove(&map->seg[i], &map->seg[i+1], (map->nseg-i)*sizeof(map->seg[0])); } } @@ -149,4 +149,3 @@ coreregs(Fhdr *fp, uint id) werrstr("thread not found"); return nil; } - diff --git a/src/libmach/crackelf.c b/src/libmach/crackelf.c index 22f4307e5..1b051eec2 100644 --- a/src/libmach/crackelf.c +++ b/src/libmach/crackelf.c @@ -13,7 +13,7 @@ static struct uint mtype; Mach *mach; char *name; -} mtab[] = +} mtab[] = { /* Font Tab 4 */ ElfMachSparc, MSPARC, nil, "sparc", ElfMach386, M386, &mach386, "386", @@ -29,7 +29,7 @@ static struct uint etype; uint atype; char *aname; -} atab[] = +} atab[] = { /* Font Tab 4 */ ElfAbiSystemV, ALINUX, "linux", /* [sic] */ ElfAbiLinux, ALINUX, "linux", @@ -41,7 +41,7 @@ static struct uint mtype; uint atype; void (*elfcore)(Fhdr*, Elf*, ElfNote*); -} ctab[] = +} ctab[] = { /* Font Tab 4 */ M386, ALINUX, elfcorelinux386, M386, ANONE, elfcorelinux386, /* [sic] */ @@ -273,13 +273,13 @@ mapelf(Fhdr *fp, u64int base, Map *map, Regs **regs) if(addseg(map, s) < 0) return -1; } - } + } } if(fp->nthread && regs) *regs = coreregs(fp, fp->thread[0].id); - return 0; + return 0; } static int @@ -301,4 +301,3 @@ unpacknote(Elf *elf, uchar *a, uchar *ea, ElfNote *note, uchar **pa) *pa = a; return 0; } - diff --git a/src/libmach/crackmacho.c b/src/libmach/crackmacho.c index 77b0339bb..25d1aa7ab 100644 --- a/src/libmach/crackmacho.c +++ b/src/libmach/crackmacho.c @@ -12,7 +12,7 @@ static struct Mach *mach; char *name; int (*coreregs)(Macho*, uchar**); -} mtab[] = +} mtab[] = { MachoCpuPower, MPOWER, &machpower, "powerpc", coreregsmachopower, }; @@ -190,7 +190,7 @@ mapmacho(Fhdr *fp, u64int base, Map *map, Regs **rp) if((r = mallocz(sizeof *r, 1)) == nil) return -1; r->r.rw = _uregrw; - r->ureg = u; + r->ureg = u; *rp = &r->r; } noregs: diff --git a/src/libmach/demangler.c b/src/libmach/demangler.c index a2a9b9636..c6bb8756b 100644 --- a/src/libmach/demangler.c +++ b/src/libmach/demangler.c @@ -9,10 +9,10 @@ main(void) Biobuf b, bout; char *p, *s; char buf[100000]; - + Binit(&b, 0, OREAD); Binit(&bout, 1, OWRITE); - + while((p = Brdline(&b, '\n')) != nil){ p[Blinelen(&b)-1] = 0; werrstr("no error"); diff --git a/src/libmach/dwarf.h b/src/libmach/dwarf.h index bd0fe56d9..31e13900c 100644 --- a/src/libmach/dwarf.h +++ b/src/libmach/dwarf.h @@ -458,4 +458,3 @@ int dwarfgetinfounit(Dwarf*, ulong, DwarfBlock*); extern int dwarf386nregs; extern char *dwarf386regs[]; extern char *dwarf386fp; - diff --git a/src/libmach/dwarf386.c b/src/libmach/dwarf386.c index 3cefeea2f..cd13194c2 100644 --- a/src/libmach/dwarf386.c +++ b/src/libmach/dwarf386.c @@ -5,7 +5,7 @@ #include "dwarf.h" char* -dwarf386regs[] = +dwarf386regs[] = { "AX", "CX", @@ -18,5 +18,3 @@ dwarf386regs[] = }; int dwarf386nregs = nelem(dwarf386regs); - - diff --git a/src/libmach/dwarfabbrev.c b/src/libmach/dwarfabbrev.c index 503d51492..24418ef30 100644 --- a/src/libmach/dwarfabbrev.c +++ b/src/libmach/dwarfabbrev.c @@ -2,7 +2,7 @@ * Dwarf abbreviation parsing code. * * The convention here is that calling dwarfgetabbrevs relinquishes - * access to any abbrevs returned previously. Will have to add + * access to any abbrevs returned previously. Will have to add * explicit reference counting if this turns out not to be acceptable. */ @@ -129,4 +129,3 @@ dwarfgetabbrev(Dwarf *d, ulong off, ulong num) } return findabbrev(a, na, num); } - diff --git a/src/libmach/dwarfaranges.c b/src/libmach/dwarfaranges.c index 212995881..7e7152d33 100644 --- a/src/libmach/dwarfaranges.c +++ b/src/libmach/dwarfaranges.c @@ -60,4 +60,3 @@ dwarfaddrtounit(Dwarf *d, ulong addr, ulong *unit) werrstr("address 0x%lux is not listed in dwarf debugging symbols", addr); return -1; } - diff --git a/src/libmach/dwarfcfa.c b/src/libmach/dwarfcfa.c index 4980c2cf0..ee3030097 100644 --- a/src/libmach/dwarfcfa.c +++ b/src/libmach/dwarfcfa.c @@ -1,11 +1,11 @@ /* * Dwarf call frame unwinding. * - * The call frame unwinding values are encoded using a state machine - * like the pc<->line mapping, but it's a different machine. - * The expressions to generate the old values are similar in function to the + * The call frame unwinding values are encoded using a state machine + * like the pc<->line mapping, but it's a different machine. + * The expressions to generate the old values are similar in function to the * ``dwarf expressions'' used for locations in the code, but of course not - * the same encoding. + * the same encoding. */ #include #include @@ -97,7 +97,7 @@ dwarfunwind(Dwarf *d, ulong pc, DwarfExpr *cfa, DwarfExpr *ra, DwarfExpr *r, int /* * XXX This turns out to be much more expensive than the actual * running of the machine in dexec. It probably makes sense to - * cache the last 10 or so fde's we've found, since stack traces + * cache the last 10 or so fde's we've found, since stack traces * will keep asking for the same info over and over. */ static int @@ -167,7 +167,7 @@ findfde(Dwarf *d, ulong pc, State *s, DwarfBuf *fde) } werrstr("cannot find call frame information for pc 0x%lux", pc); return -1; - + } static int @@ -209,7 +209,7 @@ dexec(DwarfBuf *b, State *s, int locstop) if(locstop) return 0; continue; - + case 2: /* offset rule */ arg1 = c&0x3F; arg2 = dwarfget128(b); @@ -331,12 +331,12 @@ dexec(DwarfBuf *b, State *s, int locstop) s->cfa->offset = arg2; continue; - case 0x0D: /* def cfa register */ + case 0x0D: /* def cfa register */ arg1 = dwarfget128(b); if(trace) fprint(2, "cfa reg r%ld\n", arg1); if(s->cfa->type != RuleRegOff){ werrstr("change CFA register but CFA not in register+offset form"); - return -1; + return -1; } if(checkreg(s, arg1) < 0) return -1; @@ -390,6 +390,5 @@ dexec(DwarfBuf *b, State *s, int locstop) return -1; } } - /* not reached */ + /* not reached */ } - diff --git a/src/libmach/dwarfeval.c b/src/libmach/dwarfeval.c index 30c227b3f..30e68c2d0 100644 --- a/src/libmach/dwarfeval.c +++ b/src/libmach/dwarfeval.c @@ -59,4 +59,3 @@ OpCall4 = 0x99, /* 4-byte offset of DIE */ OpCallRef = 0x9A, /* 4- or 8- byte offset of DIE */ /* 0xE0-0xFF reserved for user-specific */ - diff --git a/src/libmach/dwarfget.c b/src/libmach/dwarfget.c index 3e9fe6506..fd3ec8172 100644 --- a/src/libmach/dwarfget.c +++ b/src/libmach/dwarfget.c @@ -215,4 +215,3 @@ dwarfget128s(DwarfBuf *b) } return v; } - diff --git a/src/libmach/dwarfinfo.c b/src/libmach/dwarfinfo.c index 4c0eacd8b..d6c2b79ed 100644 --- a/src/libmach/dwarfinfo.c +++ b/src/libmach/dwarfinfo.c @@ -128,7 +128,7 @@ dwarflookupnameinunit(Dwarf *d, ulong unit, char *name, DwarfSym *s) werrstr("symbol '%s' not found", name); return -1; } - + int dwarflookupsubname(Dwarf *d, DwarfSym *parent, char *name, DwarfSym *s) @@ -183,7 +183,7 @@ dwarflookupfn(Dwarf *d, ulong unit, ulong pc, DwarfSym *s) continue; if(s->attrs.lowpc <= pc && pc < s->attrs.highpc) return 0; - } + } werrstr("fn containing pc 0x%lux not found", pc); return -1; } @@ -291,11 +291,11 @@ dwarfnextsymat(Dwarf *d, DwarfSym *s, int depth) } /* - * The funny game with t and s make sure that + * The funny game with t and s make sure that * if we get to the end of a run of a particular * depth, we leave s so that a call to nextsymat with depth-1 * will actually produce the desired guy. We could change - * the interface to dwarfnextsym instead, but I'm scared + * the interface to dwarfnextsym instead, but I'm scared * to touch it. */ t = *s; diff --git a/src/libmach/dwarfopen.c b/src/libmach/dwarfopen.c index 728944f42..27e965a36 100644 --- a/src/libmach/dwarfopen.c +++ b/src/libmach/dwarfopen.c @@ -30,7 +30,7 @@ findsection(Elf *elf, char *name, ulong *off, ulong *len) *len = s->size; return s - elf->sect; } - + static int loadsection(Elf *elf, char *name, DwarfBlock *b) { diff --git a/src/libmach/dwarfpc.c b/src/libmach/dwarfpc.c index 31b6bb41c..628b3eb81 100644 --- a/src/libmach/dwarfpc.c +++ b/src/libmach/dwarfpc.c @@ -1,6 +1,6 @@ /* * Dwarf pc to source line conversion. - * + * * Maybe should do the reverse here, but what should the interface look like? * One possibility is to use the Plan 9 line2addr interface: * diff --git a/src/libmach/elf.c b/src/libmach/elf.c index 5b7494d98..b3cb9e8c1 100644 --- a/src/libmach/elf.c +++ b/src/libmach/elf.c @@ -343,7 +343,7 @@ unpackhdr(ElfHdr *h, void *v) h->e2 = e2; h->e4 = e4; h->e8 = e8; - + if(h->class == ElfClass64) goto b64; @@ -388,7 +388,7 @@ unpackprog(ElfHdr *h, ElfProg *p, void *v) if(h->class == ElfClass32) { ElfProgBytes *b; - + b = v; e4 = h->e4; p->type = e4(b->type); @@ -401,7 +401,7 @@ unpackprog(ElfHdr *h, ElfProg *p, void *v) p->align = e4(b->align); } else { ElfProgBytes64 *b; - + b = v; e4 = h->e4; e8 = h->e8; @@ -424,7 +424,7 @@ unpacksect(ElfHdr *h, ElfSect *s, void *v) if(h->class == ElfClass32) { ElfSectBytes *b; - + b = v; e4 = h->e4; s->name = (char*)(uintptr)e4(b->name); @@ -439,7 +439,7 @@ unpacksect(ElfHdr *h, ElfSect *s, void *v) s->entsize = e4(b->entsize); } else { ElfSectBytes64 *b; - + b = v; e4 = h->e4; e8 = h->e8; @@ -554,4 +554,3 @@ elfsym(Elf *elf, int i, ElfSym *sym) werrstr("symbol index out of range"); return -1; } - diff --git a/src/libmach/elfcorefreebsd386.c b/src/libmach/elfcorefreebsd386.c index 0d01d969d..bd146784f 100644 --- a/src/libmach/elfcorefreebsd386.c +++ b/src/libmach/elfcorefreebsd386.c @@ -117,4 +117,3 @@ corecmdfreebsd386(Elf *elf, ElfNote *note, char **pp) *pp = t; return 0; } - diff --git a/src/libmach/elfcorefreebsdamd64.c b/src/libmach/elfcorefreebsdamd64.c index fde6514f5..a5fc6ed79 100644 --- a/src/libmach/elfcorefreebsdamd64.c +++ b/src/libmach/elfcorefreebsdamd64.c @@ -83,7 +83,7 @@ elfcorefreebsdamd64(Fhdr *fp, Elf *elf, ElfNote *note) } l = &s->reg; u = malloc(sizeof(Ureg)); - + /* no byte order problems - just copying and rearranging */ u->ax = l->rax; u->bx = l->rbx; @@ -100,12 +100,12 @@ elfcorefreebsdamd64(Fhdr *fp, Elf *elf, ElfNote *note) u->r13 = l->r13; u->r14 = l->r14; u->r15 = l->r15; - + u->ds = l->ds; u->es = l->es; u->fs = l->fs; u->gs = l->gs; - + u->type = l->trapno; u->error = l->err; u->ip = l->rip; @@ -147,4 +147,3 @@ corecmdfreebsd386(Elf *elf, ElfNote *note, char **pp) *pp = t; return 0; } - diff --git a/src/libmach/elfcorelinux386.c b/src/libmach/elfcorelinux386.c index 6cd0a5f99..d32932882 100644 --- a/src/libmach/elfcorelinux386.c +++ b/src/libmach/elfcorelinux386.c @@ -12,8 +12,8 @@ typedef struct Status Status; typedef struct Psinfo Psinfo; /* - * UregLinux386 is 64-bit aligned within status, so we shouldn't - * have any packing problems. + * UregLinux386 is 64-bit aligned within status, so we shouldn't + * have any packing problems. */ struct Status { @@ -158,7 +158,7 @@ elfcorelinux386(Fhdr *fp, Elf *elf, ElfNote *note) (uint)m->swap4(st->sighold)); dprint("pid=%ud ppid=%ud pgrp=%ud sid=%ud\n", (uint)m->swap4(st->pid), - (uint)m->swap4(st->ppid), + (uint)m->swap4(st->ppid), (uint)m->swap4(st->pgrp), (uint)m->swap4(st->sid)); dprint("utime=%ud.%06ud stime=%ud.%06ud cutime=%ud.%06ud cstime=%ud.%06ud\n", @@ -199,4 +199,3 @@ elfcorelinux386(Fhdr *fp, Elf *elf, ElfNote *note) dprint("note %d\n", note->type); } } - diff --git a/src/libmach/elfdl386.c b/src/libmach/elfdl386.c index fc4e37fbc..a67ed13cf 100644 --- a/src/libmach/elfdl386.c +++ b/src/libmach/elfdl386.c @@ -131,4 +131,3 @@ elfdl386mapdl(int verbose) fprint(2, "syminit %s: %r\n", buf); } } - diff --git a/src/libmach/elfdynsym.c b/src/libmach/elfdynsym.c index 06bb41a63..0f3a974c0 100644 --- a/src/libmach/elfdynsym.c +++ b/src/libmach/elfdynsym.c @@ -3,4 +3,4 @@ #include "elf.h" int -elfsym(Elf *elf, ElfSect *symtab, ElfSect *strtab, int ndx, ElfSym * \ No newline at end of file +elfsym(Elf *elf, ElfSect *symtab, ElfSect *strtab, int ndx, ElfSym * diff --git a/src/libmach/fpformat.c b/src/libmach/fpformat.c index a94a096a9..c76cca3ee 100644 --- a/src/libmach/fpformat.c +++ b/src/libmach/fpformat.c @@ -35,7 +35,7 @@ fpformat(Map *map, Regdesc *rp, char *buf, uint n, uint modif) if (rp->format == 'F') return 1; return 2; - } + } /* treat it like 'f' */ if (get1(map, rp->offset, (uchar *)reg, 4) < 0) return -1; diff --git a/src/libmach/frame.c b/src/libmach/frame.c index 2b7f8b304..53450805a 100644 --- a/src/libmach/frame.c +++ b/src/libmach/frame.c @@ -49,13 +49,13 @@ stacktrace(Map *map, Regs *regs, Tracer trace) next = malloc(mach->nwindreg*sizeof(cur[0])); if(cur==nil || next==nil) goto out; - + /* * Initialize current registers using regs. */ if(rget(regs, mach->pc, &pc) < 0){ werrstr("cannot fetch initial pc: %r"); - goto out; + goto out; } for(i=0; inwindreg; i++){ diff --git a/src/libmach/hexify.c b/src/libmach/hexify.c index b095e8ffd..cf8537ef6 100644 --- a/src/libmach/hexify.c +++ b/src/libmach/hexify.c @@ -17,4 +17,3 @@ _hexify(char *buf, u64int p, int zeros) *buf++ = "0123456789abcdef"[p&0x0f]; return buf; } - diff --git a/src/libmach/loc.c b/src/libmach/loc.c index 9d5dc8578..00ce2e680 100644 --- a/src/libmach/loc.c +++ b/src/libmach/loc.c @@ -271,4 +271,3 @@ locsimplify(Map *map, Regs *regs, Loc loc, Loc *newloc) *newloc = loc; return 0; } - diff --git a/src/libmach/mach386.c b/src/libmach/mach386.c index 336cec352..109256304 100644 --- a/src/libmach/mach386.c +++ b/src/libmach/mach386.c @@ -128,10 +128,10 @@ Mach mach386 = }; /* - * The wrapper code around Linux system calls + * The wrapper code around Linux system calls * saves AX on the stack before calling some calls - * (at least, __libc_nanosleep), when running in - * threaded programs. + * (at least, __libc_nanosleep), when running in + * threaded programs. */ static void syscallhack(Map *map, Regs *regs, int *spoff) @@ -146,7 +146,7 @@ syscallhack(Map *map, Regs *regs, int *spoff) return; if(i386das(map, pc+2, 0, buf, sizeof buf) != 3 || strcmp(buf, "XCHGL\tAX,0(SP)") != 0) return; - *spoff += 4; + *spoff += 4; } int @@ -1968,14 +1968,14 @@ plocal(Instr *ip) Symbol s; char *name; Loc l, li; - + l.type = LOFFSET; l.offset = ip->disp; if(ip->base == SP) l.reg = "SP"; else l.reg = "BP"; - + li.type = LADDR; li.addr = ip->addr; if(findsym(li, CTEXT, &s) < 0) @@ -1989,7 +1989,7 @@ plocal(Instr *ip) if(name==nil && findlsym(&s, l, &s) >= 0) name = s.name; - + if(name) bprint(ip, "%s+", name); diff --git a/src/libmach/machamd64.c b/src/libmach/machamd64.c index f220ebcf7..d10257c83 100644 --- a/src/libmach/machamd64.c +++ b/src/libmach/machamd64.c @@ -171,10 +171,10 @@ Mach machamd64= 4, /* szreg */ 4, /* szfloat */ 8, /* szdouble */ - + amd64windregs, /* locations unwound in stack trace */ 17, - + {0xCC, 0, 0, 0}, /* break point: INT 3 */ 1, /* break point size */ diff --git a/src/libmach/macho.c b/src/libmach/macho.c index 38cb23745..ce74bcbbb 100644 --- a/src/libmach/macho.c +++ b/src/libmach/macho.c @@ -4,7 +4,7 @@ #include "macho.h" /* -http://www.channelu.com/NeXT/NeXTStep/3.3/nd/DevTools/14_MachO/MachO.htmld/ +http://www.channelu.com/NeXT/NeXTStep/3.3/nd/DevTools/14_MachO/MachO.htmld/ */ Macho* @@ -144,7 +144,7 @@ macholoadrel(Macho *m, MachoSect *sect) uchar *buf, *p; int i, n; uint32 v; - + if(sect->rel != nil || sect->nreloc == 0) return 0; rel = mallocz(sect->nreloc * sizeof r[0], 1); @@ -165,7 +165,7 @@ macholoadrel(Macho *m, MachoSect *sect) r = &rel[i]; p = buf+i*8; r->addr = m->e4(p); - + // TODO(rsc): Wrong interpretation for big-endian bitfields? v = m->e4(p+4); r->symnum = v & 0xFFFFFF; @@ -183,7 +183,7 @@ macholoadrel(Macho *m, MachoSect *sect) return 0; } -int +int macholoadsym(Macho *m, MachoSymtab *symtab) { char *strbuf; @@ -202,7 +202,7 @@ macholoadsym(Macho *m, MachoSymtab *symtab) free(strbuf); return -1; } - + symsize = 12; if(m->is64) symsize = 16; diff --git a/src/libmach/macho.h b/src/libmach/macho.h index 2b449f04c..3537c0fcc 100644 --- a/src/libmach/macho.h +++ b/src/libmach/macho.h @@ -62,7 +62,7 @@ struct MachoSect uint32 reloff; uint32 nreloc; uint32 flags; - + MachoRel *rel; }; @@ -82,7 +82,7 @@ struct MachoSymtab uint32 nsym; uint32 stroff; uint32 strsize; - + char *str; MachoSym *sym; }; diff --git a/src/libmach/machocorepower.c b/src/libmach/machocorepower.c index 9cd06afba..89fc564f7 100644 --- a/src/libmach/machocorepower.c +++ b/src/libmach/machocorepower.c @@ -170,4 +170,3 @@ coreregsmachopower(Macho *m, uchar **up) *up = (uchar*)u; return sizeof(*u); } - diff --git a/src/libmach/machpower.c b/src/libmach/machpower.c index 2799f37ae..dd26e45a7 100644 --- a/src/libmach/machpower.c +++ b/src/libmach/machpower.c @@ -960,7 +960,7 @@ static Spr sprname[] = { {26, "SRR0"}, {27, "SRR1"}, {284, "TBLW"}, - {285, "TBUW"}, + {285, "TBUW"}, {22, "DEC"}, {282, "EAR"}, {1008, "HID0"}, @@ -1213,7 +1213,7 @@ powerfoll(Map *map, Regs *regs, u64int pc, u64int *foll) if(!i.aa) foll[0] += pc; break; - + case 16: /* conditional branch */ foll[0] = i.bd; if(!i.aa) @@ -1246,7 +1246,7 @@ powerfoll(Map *map, Regs *regs, u64int pc, u64int *foll) #define FP_REG(x) (R31+4+8*(x)) #define REGSIZE sizeof(struct Ureg) -#define FPREGSIZE (8*33) +#define FPREGSIZE (8*33) Regdesc powerreglist[] = { @@ -1328,7 +1328,7 @@ Regdesc powerreglist[] = { 0 } }; -static char *powerwindregs[] = +static char *powerwindregs[] = { "PC", "SP", @@ -1404,4 +1404,3 @@ Mach machpower = powerhexinst, /* print instruction */ powerinstlen, /* instruction size calculation */ }; - diff --git a/src/libmach/mangle.c b/src/libmach/mangle.c index 852a29ea6..5bf49c9d4 100644 --- a/src/libmach/mangle.c +++ b/src/libmach/mangle.c @@ -3,19 +3,19 @@ #include #include -static char *(*demanglers[])(char*, char*) = +static char *(*demanglers[])(char*, char*) = { demanglegcc2, demanglegcc3, }; - + char* demangle(char *s, char *buf, int strip) { char *t; char *r, *w; int i, nangle, nparen; - + t = nil; for(i=0; i>", "rsh", "st", "sizeof", "sizeoftype", "sz", "sizeof", "sizeofexpr", - + 0,0,0 }; @@ -153,7 +153,7 @@ gccname(char **ps, char **pp, Gccstate *state) int i, n; char *os, *s, *t, *p; Gccstate nstate; - + s = *ps; os = s; p = *pp; @@ -170,7 +170,7 @@ gccname(char **ps, char **pp, Gccstate *state) goto suffix; } } - + /* basic types */ if((t = chartabsearch(typetab, *s)) != nil){ s++; @@ -178,7 +178,7 @@ gccname(char **ps, char **pp, Gccstate *state) p += strlen(t); goto suffix; } - + switch(*s){ default: bad: @@ -245,7 +245,7 @@ gccname(char **ps, char **pp, Gccstate *state) p -= 2; s++; break; - + case 'P': /* pointer to */ s++; if(!gccname(&s, &p, state)) @@ -282,7 +282,7 @@ gccname(char **ps, char **pp, Gccstate *state) s += 2; break; } - + /* standard name */ if(*s == 't'){ strcpy(p, "std::"); @@ -300,7 +300,7 @@ gccname(char **ps, char **pp, Gccstate *state) *p++ = *s++; } break; - + case 'T': /* previously-seen type??? T0_ also T_*/ t = s; for(; *s != '_'; s++){ @@ -312,9 +312,9 @@ gccname(char **ps, char **pp, Gccstate *state) s++; memmove(p, t, s-t); p += s-t; - break; + break; } - + suffix: if(*s == 'I'){ /* template suffix */ @@ -336,4 +336,3 @@ gccname(char **ps, char **pp, Gccstate *state) *pp = p; return 1; } - diff --git a/src/libmach/map.c b/src/libmach/map.c index 392efbedd..db8c15fc0 100644 --- a/src/libmach/map.c +++ b/src/libmach/map.c @@ -281,7 +281,7 @@ fdrw(Map *map, Seg *seg, u64int addr, void *a, uint n, int r) else nn = pwrite(seg->fd, a, n-tot, off+tot); if(nn < 0) - return -1; + return -1; if(nn == 0){ werrstr("partial %s at address 0x%lux in %s", r ? "read" : "write", off+tot, seg->file); diff --git a/src/libmach/regs.c b/src/libmach/regs.c index 07616c1fb..cdab6108d 100644 --- a/src/libmach/regs.c +++ b/src/libmach/regs.c @@ -59,4 +59,3 @@ _uregrw(Regs *regs, char *name, u64int *u, int isr) return 0; } } - diff --git a/src/libmach/stabs.c b/src/libmach/stabs.c index 18805a519..91950657c 100644 --- a/src/libmach/stabs.c +++ b/src/libmach/stabs.c @@ -51,4 +51,3 @@ stabsym(Stab *stabs, int i, StabSym *sym) sym->value = stabs->e4(p+8); return 0; } - diff --git a/src/libmach/stabs.h b/src/libmach/stabs.h index ad67cfe64..4743f780d 100644 --- a/src/libmach/stabs.h +++ b/src/libmach/stabs.h @@ -114,4 +114,3 @@ X function return variable */ int stabsym(Stab*, int, StabSym*); - diff --git a/src/libmach/sym.c b/src/libmach/sym.c index 6369cdd16..b165e125a 100644 --- a/src/libmach/sym.c +++ b/src/libmach/sym.c @@ -296,7 +296,7 @@ ffindsym(Fhdr *fhdr, Loc loc, uint class) * We want to find the largest index i such that * a[i] <= loc. This cannot be done with a simple * binary search. Instead we binary search to find - * where the location should be. + * where the location should be. */ lo = 0; hi = n; @@ -529,7 +529,7 @@ symopen(Fhdr *hdr) hdr->byname[i] = &hdr->sym[i]; qsort(hdr->byname, hdr->nsym, sizeof(hdr->byname[0]), bynamecmp); } - + hdr->byxname = malloc(hdr->nsym*sizeof(hdr->byxname[0])); if(hdr->byxname == nil){ fprint(2, "could not allocate table to sort by xname\n"); @@ -581,4 +581,3 @@ _addsym(Fhdr *fp, Symbol *sym) *s = *sym; return s; } - diff --git a/src/libmach/symdwarf.c b/src/libmach/symdwarf.c index 4552b0347..49a66dad4 100644 --- a/src/libmach/symdwarf.c +++ b/src/libmach/symdwarf.c @@ -79,7 +79,7 @@ typesize(Dwarf *dwarf, ulong unit, ulong tref, char *name) name, unit, tref); return 0; } - + if(ds.attrs.have.bytesize) return ds.attrs.bytesize; @@ -230,7 +230,7 @@ dwarftosym(Fhdr *fp, Dwarf *d, DwarfSym *ds, Symbol *s, int infn) { DwarfBuf buf; DwarfBlock b; - + memset(s, 0, sizeof *s); s->u.dwarf.uoff = ds->uoff; s->u.dwarf.unit = ds->unit; @@ -356,7 +356,7 @@ dwarfeval(Dwarf *d, Map *map, Regs *regs, ulong cfa, int rno, DwarfExpr e, u64in if(rget(regs, regname(d, e.reg), &uu) < 0) return -1; if(get4(map, uu+e.offset, &u4) < 0) - return -1; + return -1; *u = u4; return 0; case RuleLocation: @@ -465,4 +465,3 @@ _dwarfunwind(Fhdr *fhdr, Map *map, Regs *regs, u64int *next, Symbol *sym) free(e); return -1; } - diff --git a/src/libmach/symelf.c b/src/libmach/symelf.c index 40dec1132..dd1752eb2 100644 --- a/src/libmach/symelf.c +++ b/src/libmach/symelf.c @@ -118,4 +118,3 @@ symelf(Fhdr *fhdr) ret = 0; return ret; } - diff --git a/src/libmach/symmacho.c b/src/libmach/symmacho.c index 674190ffe..89e87fe7b 100644 --- a/src/libmach/symmacho.c +++ b/src/libmach/symmacho.c @@ -47,4 +47,3 @@ symmacho(Fhdr *fp) } return ret; } - diff --git a/src/libmach/symstabs.c b/src/libmach/symstabs.c index e253f023b..9afa4c164 100644 --- a/src/libmach/symstabs.c +++ b/src/libmach/symstabs.c @@ -112,7 +112,7 @@ stabcvtsym(StabSym *stab, Symbol *sym, char *dir, char *file, int i) } break; } - return 0; + return 0; } static int @@ -209,15 +209,15 @@ stabssyminit(Fhdr *fp) if(fun->u.stabs.frameptr == -1){ /* * Try to distinguish functions with a real frame pointer - * from functions with a virtual frame pointer, based on + * from functions with a virtual frame pointer, based on * whether the first parameter is in the right location and - * whether the autos have negative offsets. - * + * whether the autos have negative offsets. + * * This heuristic works most of the time. On the 386, we * cannot distinguish between a v. function with no autos * but a frame of size 4 and a f.p. function with no autos and * no frame. Anything else we'll get right. - * + * * Another way to go about this would be to have * mach-specific functions to inspect the function * prologues when we're not sure. What we have diff --git a/src/libmach/t.c b/src/libmach/t.c index 37d4b505c..0322dc35d 100644 --- a/src/libmach/t.c +++ b/src/libmach/t.c @@ -97,7 +97,7 @@ printparams(Symbol *fn, Regs *regs) int first = 0; ulong pc, sp, bp; - if(0) print("pc=%lux sp=%lux bp=%lux ", + if(0) print("pc=%lux sp=%lux bp=%lux ", (rget(regs, "PC", &pc), pc), (rget(regs, "SP", &sp), sp), (rget(regs, "BP", &bp), bp)); @@ -180,7 +180,7 @@ main(int argc, char **argv) if((e = td_thr_get_info(&ts[i], &info)) != TD_OK) sysfatal("td_thr_get_info: %s", terr(e)); print("%d: startfunc=%lux stkbase=%lux pc=%lux sp=%lux lid=%d\n", - i, info.ti_startfunc, info.ti_stkbase, info.ti_pc, info.ti_sp, info.ti_lid); + i, info.ti_startfunc, info.ti_stkbase, info.ti_pc, info.ti_sp, info.ti_lid); if((e = td_thr_getgregs(&ts[i], regs)) != TD_OK) sysfatal("td_thr_getregs: %s", terr(e)); print("%d: pc=%lux sp=%lux gs=%lux\n", i, regs[12], regs[15], regs[10]); @@ -233,7 +233,7 @@ td_get_allthreads(td_thragent_t *ta, td_thrhandle_t **pall) a.a = nil; a.n = 0; a.err = 0; - if((e = td_ta_thr_iter(ta, thritercb, &a, + if((e = td_ta_thr_iter(ta, thritercb, &a, TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, @@ -251,7 +251,7 @@ td_get_allthreads(td_thragent_t *ta, td_thrhandle_t **pall) return a.n; } -/* +/* td_err_e td_ta_map_id2thr(const td_thragent_t *ta_p, thread_t tid,td_thrhandle_t *th_p); */ diff --git a/src/libmach/ureg386.c b/src/libmach/ureg386.c index b2df1fe7e..06770d2d4 100644 --- a/src/libmach/ureg386.c +++ b/src/libmach/ureg386.c @@ -48,4 +48,3 @@ ureg2linux386(Ureg *u, UregLinux386 *l) l->esp = u->sp; l->xss = u->ss; } - diff --git a/src/libmemdraw/alloc-stub.c b/src/libmemdraw/alloc-stub.c index 2c92f6fee..ea4d1198e 100644 --- a/src/libmemdraw/alloc-stub.c +++ b/src/libmemdraw/alloc-stub.c @@ -14,4 +14,3 @@ freememimage(Memimage *m) { _freememimage(m); } - diff --git a/src/libmemdraw/alloc.c b/src/libmemdraw/alloc.c index fa23b5e03..af7f6d430 100644 --- a/src/libmemdraw/alloc.c +++ b/src/libmemdraw/alloc.c @@ -47,7 +47,7 @@ allocmemimaged(Rectangle r, u32int chan, Memdata *md, void *X) i->X = X; i->data = md; i->zero = sizeof(u32int)*l*r.min.y; - + if(r.min.x >= 0) i->zero += (r.min.x*d)/8; else diff --git a/src/libmemdraw/arctest.c b/src/libmemdraw/arctest.c index b3a8c2111..ad7fc326f 100644 --- a/src/libmemdraw/arctest.c +++ b/src/libmemdraw/arctest.c @@ -47,7 +47,7 @@ rdb(void) int iprint(char *fmt, ...) { - int n; + int n; va_list va; char buf[1024]; @@ -58,4 +58,3 @@ iprint(char *fmt, ...) write(1,buf,n); return 1; } - diff --git a/src/libmemdraw/draw-stub.c b/src/libmemdraw/draw-stub.c index 08e46a1c1..be411011f 100644 --- a/src/libmemdraw/draw-stub.c +++ b/src/libmemdraw/draw-stub.c @@ -7,7 +7,7 @@ void memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp, Memimage *mask, Point mp, int op) { Memdrawparam *par; - + if((par = _memimagedrawsetup(dst, r, src, sp, mask, mp, op)) == nil) return; _memimagedraw(par); @@ -24,4 +24,3 @@ pixelbits(Memimage *m, Point p) { return _pixelbits(m, p); } - diff --git a/src/libmemdraw/draw.c b/src/libmemdraw/draw.c index 4b9885863..4075023ed 100644 --- a/src/libmemdraw/draw.c +++ b/src/libmemdraw/draw.c @@ -65,7 +65,7 @@ memimageinit(void) mktables(); _memmkcmap(); - fmtinstall('R', Rfmt); + fmtinstall('R', Rfmt); fmtinstall('P', Pfmt); fmtinstall('b', __ifmt); @@ -166,7 +166,7 @@ void _memimagedraw(Memdrawparam *par) { /* - * Now that we've clipped the parameters down to be consistent, we + * Now that we've clipped the parameters down to be consistent, we * simply try sub-drawing routines in order until we find one that was able * to handle us. If the sub-drawing routine returns zero, it means it was * unable to satisfy the request, so we do not return. @@ -215,7 +215,7 @@ DBG print("alphadraw handled\n"); #undef DBG /* - * Clip the destination rectangle further based on the properties of the + * Clip the destination rectangle further based on the properties of the * source and mask rectangles. Once the destination rectangle is properly * clipped, adjust the source and mask rectangles to be the same size. * Then if source or mask is replicated, move its clipped rectangle @@ -343,7 +343,7 @@ static int replmul[1+8] = { a _ _ X _ _ X _ _ X _ _ X _ _ X _, a _ _ _ X _ _ _ X _ _ _ X _ _ _ X, a _ _ _ _ X _ _ _ _ X _ _ _ _ X _, - a _ _ _ _ _ X _ _ _ _ _ X _ _ _ _, + a _ _ _ _ _ X _ _ _ _ _ X _ _ _ _, a _ _ _ _ _ _ X _ _ _ _ _ _ X _ _, a _ _ _ _ _ _ _ X _ _ _ _ _ _ _ X, }; @@ -355,7 +355,7 @@ static void mktables(void) { int i, j, mask, sh, small; - + if(tablesbuilt) return; @@ -421,7 +421,7 @@ enum { /* giant rathole to customize functions with */ struct Param { Readfn *replcall; - Readfn *greymaskcall; + Readfn *greymaskcall; Readfn *convreadcall; Writefn *convwritecall; @@ -468,7 +468,7 @@ static Writefn* writefn(Memimage*); static Calcfn* boolcopyfn(Memimage*, Memimage*); static Readfn* convfn(Memimage*, Param*, Memimage*, Param*); -static Calcfn *alphacalc[Ncomp] = +static Calcfn *alphacalc[Ncomp] = { alphacalc0, /* Clear */ alphacalc14, /* DoutS */ @@ -570,14 +570,14 @@ dumpbuf(char *s, Buffer b, int n) { int i; uchar *p; - + print("%s", s); for(i=0; isrc; - mask = par->mask; + mask = par->mask; dst = par->dst; sr = par->sr; mr = par->mr; @@ -646,7 +646,7 @@ alphadraw(Memdrawparam *par) isgrey = dst->flags&Fgrey; /* - * Buffering when src and dst are the same bitmap is sufficient but not + * Buffering when src and dst are the same bitmap is sufficient but not * necessary. There are stronger conditions we could use. We could * check to see if the rectangles intersect, and if simply moving in the * correct y direction can avoid the need to buffer. @@ -807,7 +807,7 @@ static int chanmatch(Buffer *bdst, Buffer *bsrc) { uchar *drgb, *srgb; - + /* * first, r, g, b must be in the same place * in the rgba word. @@ -818,7 +818,7 @@ chanmatch(Buffer *bdst, Buffer *bsrc) || bdst->blu - drgb != bsrc->blu - srgb || bdst->grn - drgb != bsrc->grn - srgb) return 0; - + /* * that implies alpha is in the same place, * if it is there at all (it might be == &ones). @@ -827,7 +827,7 @@ chanmatch(Buffer *bdst, Buffer *bsrc) */ if(bdst->alpha == &ones) return 1; - + /* * if the destination is not ones but the src is, * then the simultaneous calculation will use @@ -835,7 +835,7 @@ chanmatch(Buffer *bdst, Buffer *bsrc) */ if(bsrc->alpha == &ones) return 0; - + /* * otherwise, alphas are in the same place. */ @@ -1526,7 +1526,7 @@ writecmap(Param *p, uchar *w, Buffer src) int i, dx, delta; cmap = p->img->cmap->rgb2cmap; - + delta = src.delta; red= src.red; grn = src.grn; @@ -1615,7 +1615,7 @@ readbyte(Param *p, uchar *buf, int y) if(r == end) r = begin; } - + b.alpha = copyalpha ? buf : &ones; b.rgba = (u32int*)buf; if(alphaonly){ @@ -1868,7 +1868,7 @@ genconv(Param *p, uchar *buf, int y) b.blu = b.grn = b.grey = b.alpha = nil; b.rgba = (u32int*)buf; b.delta = 0; - + return b; } @@ -2050,12 +2050,12 @@ _imgtorgba(Memimage *img, u32int val) case CMap: p = img->cmap->cmap2rgb+3*ov; r = *p++; - g = *p++; + g = *p++; b = *p; break; } } - return (r<<24)|(g<<16)|(b<<8)|a; + return (r<<24)|(g<<16)|(b<<8)|a; } u32int @@ -2148,14 +2148,14 @@ DBG print("sdval %lud, depth %d\n", v, dst->depth); dx -= (ppb-np); nb = 8 - np * dst->depth; /* no. bits used on right side of word */ lm = (1<r.min.x, nb, lm, ppb, m); +DBG print("np %d x %d nb %d lm %ux ppb %d m %ux\n", np, par->r.min.x, nb, lm, ppb, m); /* right edge */ np = par->r.max.x&m; /* no. pixels used on left side of word */ dx -= np; nb = 8 - np * dst->depth; /* no. bits unused on right side of word */ rm = ~((1<r.max.x, nb, rm, ppb, m); +DBG print("np %d x %d nb %d rm %ux ppb %d m %ux\n", np, par->r.max.x, nb, rm, ppb, m); DBG print("dx %d Dx %d\n", dx, Dx(par->r)); /* lm, rm are masks that are 1 where we should touch the bits */ @@ -2230,7 +2230,7 @@ DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", * the source is not replicated, memmove suffices. */ m = Simplemask|Fullmask; - if((par->state&(m|Replsrc))==m && src->depth >= 8 + if((par->state&(m|Replsrc))==m && src->depth >= 8 && src->chan == dst->chan && !(src->flags&Falpha) && (op == S || op == SoverD)){ uchar *sp, *dp; long swid, dwid, nb; @@ -2262,8 +2262,8 @@ DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", * they're all bit aligned, we can just use bit operators. This happens * when we're manipulating boolean masks, e.g. in the arc code. */ - if((par->state&(Simplemask|Simplesrc|Replmask|Replsrc))==0 - && dst->chan==GREY1 && src->chan==GREY1 && par->mask->chan==GREY1 + if((par->state&(Simplemask|Simplesrc|Replmask|Replsrc))==0 + && dst->chan==GREY1 && src->chan==GREY1 && par->mask->chan==GREY1 && (par->r.min.x&7)==(par->sr.min.x&7) && (par->r.min.x&7)==(par->mr.min.x&7)){ uchar *sp, *dp, *mp; uchar lm, rm; @@ -2352,7 +2352,7 @@ DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n", } return 1; } - return 0; + return 0; } #undef DBG @@ -2382,7 +2382,7 @@ chardraw(Memdrawparam *par) } gcc_black_box; if(0) if(drawdebug) iprint("chardraw? mf %lux md %d sf %lux dxs %d dys %d dd %d ddat %p sdat %p\n", - par->mask->flags, par->mask->depth, par->src->flags, + par->mask->flags, par->mask->depth, par->src->flags, Dx(par->src->r), Dy(par->src->r), par->dst->depth, par->dst->data, par->src->data); mask = par->mask; @@ -2417,7 +2417,7 @@ DBG print("bsh %d\n", bsh); * for loop counts from bsh to bsh+dx * * we want the bottom bits to be the amount - * to shift the pixels down, so for n≡0 (mod 8) we want + * to shift the pixels down, so for n≡0 (mod 8) we want * bottom bits 7. for n≡1, 6, etc. * the bits come from -n-1. */ @@ -2496,8 +2496,8 @@ DBG iprint("bits %lux sh %d...", bits, i); } } -DBG print("\n"); - return 1; +DBG print("\n"); + return 1; } #undef DBG @@ -2518,13 +2518,13 @@ membyteval(Memimage *src) bpp = src->depth; uc <<= (src->r.min.x&(7/src->depth))*src->depth; uc &= ~(0xFF>>bpp); - * pixel value is now in high part of byte. repeat throughout byte + * pixel value is now in high part of byte. repeat throughout byte val = uc; for(i=bpp; i<8; i<<=1) val |= val>>i; return val; } - * + * */ void @@ -2555,4 +2555,3 @@ _memfillcolor(Memimage *i, u32int val) break; } } - diff --git a/src/libmemdraw/drawtest.c b/src/libmemdraw/drawtest.c index 07cda45df..fb883d4e3 100644 --- a/src/libmemdraw/drawtest.c +++ b/src/libmemdraw/drawtest.c @@ -57,7 +57,7 @@ rdb(void) int iprint(char *fmt, ...) { - int n; + int n; va_list va; char buf[1024]; @@ -362,7 +362,7 @@ fill(Memimage *img, uchar *ucbits) } img->data->bdata = data; } - + } /* @@ -391,7 +391,7 @@ verifyonemask(void) drawonepixel(dst, dp, src, sp, mask, mp); memmove(mask->data->bdata, maskbits, mask->width*sizeof(u32int)*Yrange); memmove(savedstbits, dst->data->bdata, dst->width*sizeof(u32int)*Yrange); - + memmove(dst->data->bdata, dstbits, dst->width*sizeof(u32int)*Yrange); memimagedraw(dst, Rect(dp.x, dp.y, dp.x+1, dp.y+1), src, sp, mask, mp, SoverD); memmove(mask->data->bdata, maskbits, mask->width*sizeof(u32int)*Yrange); @@ -606,7 +606,7 @@ replicate(Memimage *i, Memimage *tmp) else r.max.y = r.min.y+3 + nrand(Yrange-(r.min.y+3)); } - assert(r.min.x >= 0); + assert(r.min.x >= 0); assert(r.max.x <= Xrange); assert(r.min.y >= 0); assert(r.max.y <= Yrange); @@ -871,7 +871,7 @@ getmask(Memimage *img, Point pt) #define DBG if(0) /* * Write a pixel to img at point pt. - * + * * We do this by reading a 32-bit little endian * value from p and then writing it back * after tweaking the appropriate bits. Because @@ -896,7 +896,7 @@ DBG print("v %.8lux...", v); /* * Sub-byte greyscale pixels. We need to skip the leftmost pt.x%npack pixels, * which is equivalent to skipping the rightmost npack - pt.x%npack - 1 pixels. - */ + */ npack = 8/bpp; sh = bpp*(npack - pt.x%npack - 1); bits = RGB2K(r,g,b); @@ -959,7 +959,7 @@ DBG print("v %.8lux\n", v); p[0] = v; p[1] = v>>8; p[2] = v>>16; - p[3] = v>>24; + p[3] = v>>24; } #undef DBG diff --git a/src/libmemdraw/ellipse.c b/src/libmemdraw/ellipse.c index 7dc45cd6f..a467c248b 100644 --- a/src/libmemdraw/ellipse.c +++ b/src/libmemdraw/ellipse.c @@ -83,24 +83,24 @@ step(State *s) while(s->x < s->a) { if(s->ee+s->b2x <= s->c1 || /* e(x+1,y-1/2) <= 0 */ s->ee+s->a2y <= s->c2) { /* e(x+1/2,y) <= 0 (rare) */ - s->dxe += s->d2xe; - s->ee += s->dxe; + s->dxe += s->d2xe; + s->ee += s->dxe; s->b2x += s->b2; - s->x++; + s->x++; continue; } - s->dye += s->d2ye; - s->ee += s->dye; + s->dye += s->d2ye; + s->ee += s->dye; s->a2y -= s->a2; if(s->ee-s->a2y <= s->c2) { /* e(x+1/2,y-1) <= 0 */ - s->dxe += s->d2xe; - s->ee += s->dxe; + s->dxe += s->d2xe; + s->ee += s->dxe; s->b2x += s->b2; return s->x++; } break; } - return s->x; + return s->x; } void @@ -132,7 +132,7 @@ memellipse(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, if(t < 0) { inb = -1; newstate(&out, a, y = b); - } else { + } else { inb = b - t; newstate(&out, a+t, y = b+t); } @@ -229,7 +229,7 @@ epoint(int x, int y, Param *p) memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op); } -/* +/* * a brushed horizontal or vertical line similarly specified */ static diff --git a/src/libmemdraw/fill-stub.c b/src/libmemdraw/fill-stub.c index d75459f17..37d2635b5 100644 --- a/src/libmemdraw/fill-stub.c +++ b/src/libmemdraw/fill-stub.c @@ -8,4 +8,3 @@ memfillcolor(Memimage *m, u32int val) { _memfillcolor(m, val); } - diff --git a/src/libmemdraw/hwdraw.c b/src/libmemdraw/hwdraw.c index 3f36250f2..59f63be2f 100644 --- a/src/libmemdraw/hwdraw.c +++ b/src/libmemdraw/hwdraw.c @@ -9,4 +9,3 @@ hwdraw(Memdrawparam *p) USED(p); return 0; /* could not satisfy request */ } - diff --git a/src/libmemdraw/iprint.c b/src/libmemdraw/iprint.c index 923b6b448..5243970be 100644 --- a/src/libmemdraw/iprint.c +++ b/src/libmemdraw/iprint.c @@ -9,4 +9,3 @@ iprint(char *fmt,...) USED(fmt); return -1; } - diff --git a/src/libmemdraw/load-stub.c b/src/libmemdraw/load-stub.c index b0d5fcee1..7cca3a6fd 100644 --- a/src/libmemdraw/load-stub.c +++ b/src/libmemdraw/load-stub.c @@ -8,4 +8,3 @@ loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata) { return _loadmemimage(i, r, data, ndata); } - diff --git a/src/libmp/port/crt.c b/src/libmp/port/crt.c index 6dc6eea68..85646abf2 100644 --- a/src/libmp/port/crt.c +++ b/src/libmp/port/crt.c @@ -53,7 +53,7 @@ crtpre(int n, mpint **m) mpfree(u); - return crt; + return crt; } void diff --git a/src/libmp/port/mpaux.c b/src/libmp/port/mpaux.c index ef94813a2..213a01307 100644 --- a/src/libmp/port/mpaux.c +++ b/src/libmp/port/mpaux.c @@ -186,4 +186,3 @@ mplowbits0(mpint *n) } return k; } - diff --git a/src/libmp/port/mpextendedgcd.c b/src/libmp/port/mpextendedgcd.c index 712db1706..696b16b09 100644 --- a/src/libmp/port/mpextendedgcd.c +++ b/src/libmp/port/mpextendedgcd.c @@ -63,7 +63,7 @@ mpextendedgcd(mpint *a, mpint *b, mpint *v, mpint *x, mpint *y) mpright(A, 1, A); mpright(B, 1, B); } - + /* print("%B %B %B %B %B %B\n", u, v, A, B, C, D); */ while(iseven(v)){ mpright(v, 1, v); @@ -74,7 +74,7 @@ mpextendedgcd(mpint *a, mpint *b, mpint *v, mpint *x, mpint *y) mpright(C, 1, C); mpright(D, 1, D); } - + /* print("%B %B %B %B %B %B\n", u, v, A, B, C, D); */ if(mpcmp(u, v) >= 0){ mpsub(u, v, u); diff --git a/src/libmp/port/mpfmt.c b/src/libmp/port/mpfmt.c index 7e34597dd..7da82ed76 100644 --- a/src/libmp/port/mpfmt.c +++ b/src/libmp/port/mpfmt.c @@ -200,4 +200,3 @@ mpfmt(Fmt *fmt) return 0; } } - diff --git a/src/libmp/port/mptobe.c b/src/libmp/port/mptobe.c index d49225e9e..a6e4f4579 100644 --- a/src/libmp/port/mptobe.c +++ b/src/libmp/port/mptobe.c @@ -29,7 +29,7 @@ mptobe(mpint *b, uchar *p, uint n, uchar **pp) else return 1; } - + s = p; e = s+n; suppress = 1; diff --git a/src/libmp/port/mptole.c b/src/libmp/port/mptole.c index 0b676ef65..ffefd48ed 100644 --- a/src/libmp/port/mptole.c +++ b/src/libmp/port/mptole.c @@ -30,7 +30,7 @@ mptole(mpint *b, uchar *p, uint n, uchar **pp) else return 0; } - + s = p; e = s+n; for(i = 0; i < b->top-1; i++){ diff --git a/src/libmp/port/mptouv.c b/src/libmp/port/mptouv.c index 9cb74ea46..b4aff1337 100644 --- a/src/libmp/port/mptouv.c +++ b/src/libmp/port/mptouv.c @@ -23,7 +23,7 @@ uvtomp(uvlong v, mpint *b) for(s = 0; s < VLDIGITS && v != 0; s++){ b->p[s] = v; /* !@*$&!@$ gcc gives warnings about the >> here - * when running on 64-bit machines, even though + * when running on 64-bit machines, even though * it's in dead code. fake it out with two shifts. if(sizeof(mpdigit) == sizeof(uvlong)) v = 0; diff --git a/src/libmp/port/mptov.c b/src/libmp/port/mptov.c index b24b8e3e7..349bf335e 100644 --- a/src/libmp/port/mptov.c +++ b/src/libmp/port/mptov.c @@ -29,7 +29,7 @@ vtomp(vlong v, mpint *b) for(s = 0; s < VLDIGITS && uv != 0; s++){ b->p[s] = uv; /* !@*$&!@$ gcc gives warnings about the >> here - * when running on 64-bit machines, even though + * when running on 64-bit machines, even though * it's in dead code. fake it out with two shifts. if(sizeof(mpdigit) == sizeof(uvlong)) uv = 0; diff --git a/src/libmp/port/os.h b/src/libmp/port/os.h index dae875d66..07a1f9765 100644 --- a/src/libmp/port/os.h +++ b/src/libmp/port/os.h @@ -1,3 +1,2 @@ #include #include - diff --git a/src/libmux/io.c b/src/libmux/io.c index 3a2a93319..644f07de5 100644 --- a/src/libmux/io.c +++ b/src/libmux/io.c @@ -7,7 +7,7 @@ /* * If you fork off two procs running muxrecvproc and muxsendproc, - * then muxrecv/muxsend (and thus muxrpc) will never block except on + * then muxrecv/muxsend (and thus muxrpc) will never block except on * rendevouses, which is nice when it's running in one thread of many. */ void @@ -137,9 +137,8 @@ _muxsend(Mux *mux, void *p) if(mux->send(mux, p) < 0){ qunlock(&mux->outlk); /* vthangup(mux); */ - return -1; + return -1; } qunlock(&mux->outlk); return 0; } - diff --git a/src/libmux/mux.c b/src/libmux/mux.c index 8257fb0e7..e77860795 100644 --- a/src/libmux/mux.c +++ b/src/libmux/mux.c @@ -30,7 +30,7 @@ static Muxrpc* allocmuxrpc(Mux *mux) { Muxrpc *r; - + /* must malloc because stack could be private */ r = mallocz(sizeof(Muxrpc), 1); if(r == nil){ @@ -40,7 +40,7 @@ allocmuxrpc(Mux *mux) r->mux = mux; r->r.l = &mux->lk; r->waiting = 1; - + return r; } @@ -49,7 +49,7 @@ tagmuxrpc(Muxrpc *r, void *tx) { int tag; Mux *mux; - + mux = r->mux; /* assign the tag, add selves to response queue */ qlock(&mux->lk); @@ -91,7 +91,7 @@ muxmsgandqlock(Mux *mux, void *p) fprint(2, "%s: bad rpc tag %ux (no one waiting on that tag)\n", argv0, tag); /* must leak packet! don't know how to free it! */ return; - } + } r2->p = p; dequeue(mux, r2); rwakeup(&r2->r); @@ -222,7 +222,7 @@ dequeue(Mux *mux, Muxrpc *r) r->next = nil; } -static int +static int gettag(Mux *mux, Muxrpc *r) { int i, mw; diff --git a/src/libndb/csipinfo.c b/src/libndb/csipinfo.c index 76f3d8e09..6ffaf1727 100644 --- a/src/libndb/csipinfo.c +++ b/src/libndb/csipinfo.c @@ -34,7 +34,7 @@ csipinfo(char *netroot, char *attr, char *val, char **list, int n) break; p = seprint(p, e, " %s", *list++); } - + if(write(fd, line, strlen(line)) < 0){ close(fd); return 0; diff --git a/src/libndb/dnsquery.c b/src/libndb/dnsquery.c index 4cf8735ad..74460b146 100644 --- a/src/libndb/dnsquery.c +++ b/src/libndb/dnsquery.c @@ -119,11 +119,11 @@ doquery(int fd, char *dn, char *type) snprint(buf, sizeof(buf), "!%s %s", dn, type); if(write(fd, buf, strlen(buf)) < 0) return nil; - + seek(fd, 0, 0); first = last = nil; - + for(;;){ n = read(fd, buf, sizeof(buf)-2); if(n <= 0) diff --git a/src/libndb/ndbaux.c b/src/libndb/ndbaux.c index 94246fc6a..a2688736c 100644 --- a/src/libndb/ndbaux.c +++ b/src/libndb/ndbaux.c @@ -60,7 +60,7 @@ _ndbparsetuple(char *cp, Ndbtuple **tp) } /* - * parse all tuples in a line. we assume that the + * parse all tuples in a line. we assume that the * line ends in a '\n'. * * the tuples are linked as a list using ->entry and diff --git a/src/libndb/ndbcache.c b/src/libndb/ndbcache.c index 80dbc35b4..d02530f52 100644 --- a/src/libndb/ndbcache.c +++ b/src/libndb/ndbcache.c @@ -9,7 +9,7 @@ struct Ndbcache char *attr; char *val; Ndbs s; - Ndbtuple *t; + Ndbtuple *t; }; enum diff --git a/src/libndb/ndbfree.c b/src/libndb/ndbfree.c index 647bff03c..506261319 100644 --- a/src/libndb/ndbfree.c +++ b/src/libndb/ndbfree.c @@ -61,5 +61,5 @@ ndbnew(char *attr, char *val) t->val = t->valbuf; if(val != nil) ndbsetval(t, val, strlen(val)); - return t; + return t; } diff --git a/src/libndb/ndbhash.c b/src/libndb/ndbhash.c index 4f9cb4b64..8dee18a5e 100644 --- a/src/libndb/ndbhash.c +++ b/src/libndb/ndbhash.c @@ -198,7 +198,7 @@ ndbsnext(Ndbs *s, char *attr, char *val) ndbfree(t); } else if(s->type == Cptr){ if(Bseek(&db->b, s->ptr, 0) < 0) - break; + break; s->ptr = s->ptr1; s->type = Cptr1; t = ndbparse(db); @@ -218,7 +218,7 @@ ndbsnext(Ndbs *s, char *attr, char *val) s->type = Cptr; } else { /* end of hash chain */ if(Bseek(&db->b, s->ptr, 0) < 0) - break; + break; s->ptr = NDBNAP; t = ndbparse(db); if(t == 0) diff --git a/src/libndb/ndbopen.c b/src/libndb/ndbopen.c index fdda79ec7..1002b4d68 100644 --- a/src/libndb/ndbopen.c +++ b/src/libndb/ndbopen.c @@ -77,7 +77,7 @@ doopen(char *file, char *rel) * Unrooted paths are taken relative to db we opened. */ if(file[0]!='/' && rel && (p=strrchr(rel, '/'))!=nil) - snprint(db->file, sizeof(db->file), "%.*s/%s", + snprint(db->file, sizeof(db->file), "%.*s/%s", utfnlen(rel, p-rel), rel, file); else strncpy(db->file, file, sizeof(db->file)-1); diff --git a/src/libndb/ndbreorder.c b/src/libndb/ndbreorder.c index 390d7818f..c25d7b5f3 100644 --- a/src/libndb/ndbreorder.c +++ b/src/libndb/ndbreorder.c @@ -27,7 +27,7 @@ ndbreorder(Ndbtuple *t, Ndbtuple *x) for(nt = t; nt->entry != last->line; nt = nt->entry) ; nt->entry = nil; - + /* switch */ for(nt = last; nt->entry != nil; nt = nt->entry) ; diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c index 0a771e2b9..1f6cbb58b 100644 --- a/src/libndb/sysdnsquery.c +++ b/src/libndb/sysdnsquery.c @@ -20,11 +20,11 @@ Ndbtuple* dnsquery(char *net, char *val, char *type) { static int init; - char rip[128]; + char rip[128]; Ndbtuple *t; USED(net); - + if(!init){ init = 1; fmtinstall('I', eipfmt); @@ -32,17 +32,17 @@ dnsquery(char *net, char *val, char *type) /* give up early on stupid questions - vwhois */ if(strcmp(val, "::") == 0 || strcmp(val, "0.0.0.0") == 0) return nil; - + /* zero out the error string */ werrstr(""); - + /* if this is a reverse lookup, first look up the domain name */ if(strcmp(type, "ptr") == 0){ mkptrname(val, rip, sizeof rip); t = doquery(rip, "ptr"); }else t = doquery(val, type); - + return t; } @@ -123,7 +123,7 @@ enum /* query types (all RR types are also queries) */ Tixfr= 251, /* incremental zone transfer */ Taxfr= 252, /* zone transfer */ - Tmailb= 253, /* { Tmb, Tmg, Tmr } */ + Tmailb= 253, /* { Tmb, Tmg, Tmr } */ Tall= 255, /* all records */ /* classes */ @@ -173,7 +173,7 @@ doquery(char *name, char *type) qdcount = (buf[4]<<8)|buf[5]; ancount = (buf[6]<<8)|buf[7]; - + p = buf+12; p = skipquestion(buf, buf+n, p, qdcount); p = unpack(buf, buf+n, p, &t, ancount); @@ -215,7 +215,7 @@ static char* type2name(int t) { int i; - + for(i=0; ientry){ print("%s=%q ", t->attr, t->val); if(t->line == t0){ @@ -32,4 +32,3 @@ main(int argc, char **argv) } exits(0); } - diff --git a/src/libplumb/event.c b/src/libplumb/event.c old mode 100755 new mode 100644 diff --git a/src/libplumb/fid.c b/src/libplumb/fid.c index 017f92c3e..8628f9f30 100644 --- a/src/libplumb/fid.c +++ b/src/libplumb/fid.c @@ -161,4 +161,3 @@ plumbrecvfid(CFid *fid) free(buf); return m; } - diff --git a/src/libplumb/mesg.c b/src/libplumb/mesg.c old mode 100755 new mode 100644 index c9379307c..acc0ac323 --- a/src/libplumb/mesg.c +++ b/src/libplumb/mesg.c @@ -338,4 +338,3 @@ plumbunpack(char *buf, int n) { return plumbunpackpartial(buf, n, nil); } - diff --git a/src/libregexp/lib9.std.h b/src/libregexp/lib9.std.h index 1d7aaa627..f309c094f 100644 --- a/src/libregexp/lib9.std.h +++ b/src/libregexp/lib9.std.h @@ -8,4 +8,3 @@ #define exits(x) exit(x && *x ? 1 : 0) #define nil 0 - diff --git a/src/libregexp/regcomp.c b/src/libregexp/regcomp.c index cd299a54a..c58b4d846 100644 --- a/src/libregexp/regcomp.c +++ b/src/libregexp/regcomp.c @@ -109,7 +109,7 @@ regerr2(char *s, int c) while(*s) *cp++ = *s++; *cp++ = c; - *cp = '\0'; + *cp = '\0'; rcerror(buf); } diff --git a/src/libsec/port/aes.c b/src/libsec/port/aes.c index 9cbb6bd90..7612842e1 100644 --- a/src/libsec/port/aes.c +++ b/src/libsec/port/aes.c @@ -138,13 +138,13 @@ static int rijndaelKeySetup(u32 erk[/*4*(Nr + 1)*/], u32 drk[/*4*(Nr + 1)*/], co * invert the order of the round keys and * apply the inverse MixColumn transform to all round keys but the first and the last */ - drk[0 ] = erk[4*Nr ]; + drk[0 ] = erk[4*Nr ]; drk[1 ] = erk[4*Nr + 1]; - drk[2 ] = erk[4*Nr + 2]; + drk[2 ] = erk[4*Nr + 2]; drk[3 ] = erk[4*Nr + 3]; - drk[4*Nr ] = erk[0 ]; + drk[4*Nr ] = erk[0 ]; drk[4*Nr + 1] = erk[1 ]; - drk[4*Nr + 2] = erk[2 ]; + drk[4*Nr + 2] = erk[2 ]; drk[4*Nr + 3] = erk[3 ]; erk += 4 * Nr; for (i = 1; i < Nr; i++) { @@ -1443,7 +1443,7 @@ static void rijndaelEncryptRound(const u32 rk[/*4*(Nr + 1)*/], int Nr, u8 block[ (Te4[(s1 >> 8) & 0xff] << 8) ^ (Te4[(s2 ) & 0xff] ) ^ rk[3]; - + s0 = t0; s1 = t1; s2 = t2; diff --git a/src/libsec/port/blowfish.c b/src/libsec/port/blowfish.c index 0eed2939a..abfe912eb 100644 --- a/src/libsec/port/blowfish.c +++ b/src/libsec/port/blowfish.c @@ -31,7 +31,7 @@ setupBFstate(BFstate *s, uchar key[], int keybytes, uchar *ivec) memmove(s->ivec, ivec, sizeof(s->ivec)); else memset(s->ivec, 0, sizeof(s->ivec)); - + memmove(s->pbox, pbox, sizeof(pbox)); memmove(s->sbox, sbox, sizeof(sbox)); @@ -238,7 +238,7 @@ bfECBdecrypt(uchar *buf, int n, BFstate *s) buf[0] = b[0]; } - return; + return; } static void @@ -258,11 +258,11 @@ bfencrypt(u32int *b, BFstate *s) for(i=1; i<16; i += 2) { r ^= pb[i]; - r ^= ( (sb[ (uchar) (l>>24)] + sb[256 + ((uchar) (l>>16))]) ^ + r ^= ( (sb[ (uchar) (l>>24)] + sb[256 + ((uchar) (l>>16))]) ^ sb[512 + ((uchar) (l>>8))]) + sb[768 +((uchar) l)]; l ^= pb[i+1]; - l ^= ( (sb[ (uchar) (r>>24)] + sb[256 + ((uchar) (r>>16))]) ^ + l ^= ( (sb[ (uchar) (r>>24)] + sb[256 + ((uchar) (r>>16))]) ^ sb[512 + ((uchar) (r>>8))]) + sb[768 +((uchar) r)]; } @@ -292,11 +292,11 @@ bfdecrypt(u32int *b, BFstate *s) for(i=16; i > 0; i -= 2) { r ^= pb[i]; - r ^= ( (sb[ (uchar) (l>>24)] + sb[256 + ((uchar) (l>>16))]) ^ + r ^= ( (sb[ (uchar) (l>>24)] + sb[256 + ((uchar) (l>>16))]) ^ sb[512 + ((uchar) (l>>8))]) + sb[768 +((uchar) l)]; l ^= pb[i-1]; - l ^= ( (sb[ (uchar) (r>>24)] + sb[256 + ((uchar) (r>>16))]) ^ + l ^= ( (sb[ (uchar) (r>>24)] + sb[256 + ((uchar) (r>>16))]) ^ sb[512 + ((uchar) (r>>8))]) + sb[768 +((uchar) r)]; } @@ -310,270 +310,268 @@ bfdecrypt(u32int *b, BFstate *s) } static u32int pbox[BFrounds+2] = { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b }; static u32int sbox[1024] = { - 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, - 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, - 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, - 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, - 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, - 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, - 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, - 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, - 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, - 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, - 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, - 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, - 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, - 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, - 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, - 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, - 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, - 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, - 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, - 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, - 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, - 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, - 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, - 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, - 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, - 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, - 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, - 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, - 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, - 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, - 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, - 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, - 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, - 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, - 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, - 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, - 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, - 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, - 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, - 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, - 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, - 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, - 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, - 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, - 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, - 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, - 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, - 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, - 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, - 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, - 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, - 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, - 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, - 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, - 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, - 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, - 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, - 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, - 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, - 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, - 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, - 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, - 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, - 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, - 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, - 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, - 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, - 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, - 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, - 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, - 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, - 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, - 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, - 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, - 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, - 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, - 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, - 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, - 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, - 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, - 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, - 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, - 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, - 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, - 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, - 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, - 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, - 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, - 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, - 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, - 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, - 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, - 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, - 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, - 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, - 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, - 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, - 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, - 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, - 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, - 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, - 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, - 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, - 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, - 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, - 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, - 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, - 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, - 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, - 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, - 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, - 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, - 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, - 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, - 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, - 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, - 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, - 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, - 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, - 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, - 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, - 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, - 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, - 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, - 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, - 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, - 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, - 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, - 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, - 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, - 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, - 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, - 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, - 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, - 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, - 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, - 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, - 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, - 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, - 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, - 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, - 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, - 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, - 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, - 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, - 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, - 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, - 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, - 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, - 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, - 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, - 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, - 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, - 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, - 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, - 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, - 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, - 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, - 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, - 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, - 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, - 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, - 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, - 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, - 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, - 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, - 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, - 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, - 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, - 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, - 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, - 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, - 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, - 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, - 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, - 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, - 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, - 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, - 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, - 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, - 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, - 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, - 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, - 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, - 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, - 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, - 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, - 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, - 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, - 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, - 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, - 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, - 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, - 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, - 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, - 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, - 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, - 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, - 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, - 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, - 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, - 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, - 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, - 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, - 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, - 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, - 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, - 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, - 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, - 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, - 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, - 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, - 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, - 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, - 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, - 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, - 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, - 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, - 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, - 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, - 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, - 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, - 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, - 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, - 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, - 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, - 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, - 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, - 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, - 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, - 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, - 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, - 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, - 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, - 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, - 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, - 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, - 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, - 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, - 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, - 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, - 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, - 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, - 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, - 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, - 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, - 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, - 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, - 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, - 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, - 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, - 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, - 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, - 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, - 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, - 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, + 0xd1310ba6L, 0x98dfb5acL, 0x2ffd72dbL, 0xd01adfb7L, + 0xb8e1afedL, 0x6a267e96L, 0xba7c9045L, 0xf12c7f99L, + 0x24a19947L, 0xb3916cf7L, 0x0801f2e2L, 0x858efc16L, + 0x636920d8L, 0x71574e69L, 0xa458fea3L, 0xf4933d7eL, + 0x0d95748fL, 0x728eb658L, 0x718bcd58L, 0x82154aeeL, + 0x7b54a41dL, 0xc25a59b5L, 0x9c30d539L, 0x2af26013L, + 0xc5d1b023L, 0x286085f0L, 0xca417918L, 0xb8db38efL, + 0x8e79dcb0L, 0x603a180eL, 0x6c9e0e8bL, 0xb01e8a3eL, + 0xd71577c1L, 0xbd314b27L, 0x78af2fdaL, 0x55605c60L, + 0xe65525f3L, 0xaa55ab94L, 0x57489862L, 0x63e81440L, + 0x55ca396aL, 0x2aab10b6L, 0xb4cc5c34L, 0x1141e8ceL, + 0xa15486afL, 0x7c72e993L, 0xb3ee1411L, 0x636fbc2aL, + 0x2ba9c55dL, 0x741831f6L, 0xce5c3e16L, 0x9b87931eL, + 0xafd6ba33L, 0x6c24cf5cL, 0x7a325381L, 0x28958677L, + 0x3b8f4898L, 0x6b4bb9afL, 0xc4bfe81bL, 0x66282193L, + 0x61d809ccL, 0xfb21a991L, 0x487cac60L, 0x5dec8032L, + 0xef845d5dL, 0xe98575b1L, 0xdc262302L, 0xeb651b88L, + 0x23893e81L, 0xd396acc5L, 0x0f6d6ff3L, 0x83f44239L, + 0x2e0b4482L, 0xa4842004L, 0x69c8f04aL, 0x9e1f9b5eL, + 0x21c66842L, 0xf6e96c9aL, 0x670c9c61L, 0xabd388f0L, + 0x6a51a0d2L, 0xd8542f68L, 0x960fa728L, 0xab5133a3L, + 0x6eef0b6cL, 0x137a3be4L, 0xba3bf050L, 0x7efb2a98L, + 0xa1f1651dL, 0x39af0176L, 0x66ca593eL, 0x82430e88L, + 0x8cee8619L, 0x456f9fb4L, 0x7d84a5c3L, 0x3b8b5ebeL, + 0xe06f75d8L, 0x85c12073L, 0x401a449fL, 0x56c16aa6L, + 0x4ed3aa62L, 0x363f7706L, 0x1bfedf72L, 0x429b023dL, + 0x37d0d724L, 0xd00a1248L, 0xdb0fead3L, 0x49f1c09bL, + 0x075372c9L, 0x80991b7bL, 0x25d479d8L, 0xf6e8def7L, + 0xe3fe501aL, 0xb6794c3bL, 0x976ce0bdL, 0x04c006baL, + 0xc1a94fb6L, 0x409f60c4L, 0x5e5c9ec2L, 0x196a2463L, + 0x68fb6fafL, 0x3e6c53b5L, 0x1339b2ebL, 0x3b52ec6fL, + 0x6dfc511fL, 0x9b30952cL, 0xcc814544L, 0xaf5ebd09L, + 0xbee3d004L, 0xde334afdL, 0x660f2807L, 0x192e4bb3L, + 0xc0cba857L, 0x45c8740fL, 0xd20b5f39L, 0xb9d3fbdbL, + 0x5579c0bdL, 0x1a60320aL, 0xd6a100c6L, 0x402c7279L, + 0x679f25feL, 0xfb1fa3ccL, 0x8ea5e9f8L, 0xdb3222f8L, + 0x3c7516dfL, 0xfd616b15L, 0x2f501ec8L, 0xad0552abL, + 0x323db5faL, 0xfd238760L, 0x53317b48L, 0x3e00df82L, + 0x9e5c57bbL, 0xca6f8ca0L, 0x1a87562eL, 0xdf1769dbL, + 0xd542a8f6L, 0x287effc3L, 0xac6732c6L, 0x8c4f5573L, + 0x695b27b0L, 0xbbca58c8L, 0xe1ffa35dL, 0xb8f011a0L, + 0x10fa3d98L, 0xfd2183b8L, 0x4afcb56cL, 0x2dd1d35bL, + 0x9a53e479L, 0xb6f84565L, 0xd28e49bcL, 0x4bfb9790L, + 0xe1ddf2daL, 0xa4cb7e33L, 0x62fb1341L, 0xcee4c6e8L, + 0xef20cadaL, 0x36774c01L, 0xd07e9efeL, 0x2bf11fb4L, + 0x95dbda4dL, 0xae909198L, 0xeaad8e71L, 0x6b93d5a0L, + 0xd08ed1d0L, 0xafc725e0L, 0x8e3c5b2fL, 0x8e7594b7L, + 0x8ff6e2fbL, 0xf2122b64L, 0x8888b812L, 0x900df01cL, + 0x4fad5ea0L, 0x688fc31cL, 0xd1cff191L, 0xb3a8c1adL, + 0x2f2f2218L, 0xbe0e1777L, 0xea752dfeL, 0x8b021fa1L, + 0xe5a0cc0fL, 0xb56f74e8L, 0x18acf3d6L, 0xce89e299L, + 0xb4a84fe0L, 0xfd13e0b7L, 0x7cc43b81L, 0xd2ada8d9L, + 0x165fa266L, 0x80957705L, 0x93cc7314L, 0x211a1477L, + 0xe6ad2065L, 0x77b5fa86L, 0xc75442f5L, 0xfb9d35cfL, + 0xebcdaf0cL, 0x7b3e89a0L, 0xd6411bd3L, 0xae1e7e49L, + 0x00250e2dL, 0x2071b35eL, 0x226800bbL, 0x57b8e0afL, + 0x2464369bL, 0xf009b91eL, 0x5563911dL, 0x59dfa6aaL, + 0x78c14389L, 0xd95a537fL, 0x207d5ba2L, 0x02e5b9c5L, + 0x83260376L, 0x6295cfa9L, 0x11c81968L, 0x4e734a41L, + 0xb3472dcaL, 0x7b14a94aL, 0x1b510052L, 0x9a532915L, + 0xd60f573fL, 0xbc9bc6e4L, 0x2b60a476L, 0x81e67400L, + 0x08ba6fb5L, 0x571be91fL, 0xf296ec6bL, 0x2a0dd915L, + 0xb6636521L, 0xe7b9f9b6L, 0xff34052eL, 0xc5855664L, + 0x53b02d5dL, 0xa99f8fa1L, 0x08ba4799L, 0x6e85076aL, + 0x4b7a70e9L, 0xb5b32944L, 0xdb75092eL, 0xc4192623L, + 0xad6ea6b0L, 0x49a7df7dL, 0x9cee60b8L, 0x8fedb266L, + 0xecaa8c71L, 0x699a17ffL, 0x5664526cL, 0xc2b19ee1L, + 0x193602a5L, 0x75094c29L, 0xa0591340L, 0xe4183a3eL, + 0x3f54989aL, 0x5b429d65L, 0x6b8fe4d6L, 0x99f73fd6L, + 0xa1d29c07L, 0xefe830f5L, 0x4d2d38e6L, 0xf0255dc1L, + 0x4cdd2086L, 0x8470eb26L, 0x6382e9c6L, 0x021ecc5eL, + 0x09686b3fL, 0x3ebaefc9L, 0x3c971814L, 0x6b6a70a1L, + 0x687f3584L, 0x52a0e286L, 0xb79c5305L, 0xaa500737L, + 0x3e07841cL, 0x7fdeae5cL, 0x8e7d44ecL, 0x5716f2b8L, + 0xb03ada37L, 0xf0500c0dL, 0xf01c1f04L, 0x0200b3ffL, + 0xae0cf51aL, 0x3cb574b2L, 0x25837a58L, 0xdc0921bdL, + 0xd19113f9L, 0x7ca92ff6L, 0x94324773L, 0x22f54701L, + 0x3ae5e581L, 0x37c2dadcL, 0xc8b57634L, 0x9af3dda7L, + 0xa9446146L, 0x0fd0030eL, 0xecc8c73eL, 0xa4751e41L, + 0xe238cd99L, 0x3bea0e2fL, 0x3280bba1L, 0x183eb331L, + 0x4e548b38L, 0x4f6db908L, 0x6f420d03L, 0xf60a04bfL, + 0x2cb81290L, 0x24977c79L, 0x5679b072L, 0xbcaf89afL, + 0xde9a771fL, 0xd9930810L, 0xb38bae12L, 0xdccf3f2eL, + 0x5512721fL, 0x2e6b7124L, 0x501adde6L, 0x9f84cd87L, + 0x7a584718L, 0x7408da17L, 0xbc9f9abcL, 0xe94b7d8cL, + 0xec7aec3aL, 0xdb851dfaL, 0x63094366L, 0xc464c3d2L, + 0xef1c1847L, 0x3215d908L, 0xdd433b37L, 0x24c2ba16L, + 0x12a14d43L, 0x2a65c451L, 0x50940002L, 0x133ae4ddL, + 0x71dff89eL, 0x10314e55L, 0x81ac77d6L, 0x5f11199bL, + 0x043556f1L, 0xd7a3c76bL, 0x3c11183bL, 0x5924a509L, + 0xf28fe6edL, 0x97f1fbfaL, 0x9ebabf2cL, 0x1e153c6eL, + 0x86e34570L, 0xeae96fb1L, 0x860e5e0aL, 0x5a3e2ab3L, + 0x771fe71cL, 0x4e3d06faL, 0x2965dcb9L, 0x99e71d0fL, + 0x803e89d6L, 0x5266c825L, 0x2e4cc978L, 0x9c10b36aL, + 0xc6150ebaL, 0x94e2ea78L, 0xa5fc3c53L, 0x1e0a2df4L, + 0xf2f74ea7L, 0x361d2b3dL, 0x1939260fL, 0x19c27960L, + 0x5223a708L, 0xf71312b6L, 0xebadfe6eL, 0xeac31f66L, + 0xe3bc4595L, 0xa67bc883L, 0xb17f37d1L, 0x018cff28L, + 0xc332ddefL, 0xbe6c5aa5L, 0x65582185L, 0x68ab9802L, + 0xeecea50fL, 0xdb2f953bL, 0x2aef7dadL, 0x5b6e2f84L, + 0x1521b628L, 0x29076170L, 0xecdd4775L, 0x619f1510L, + 0x13cca830L, 0xeb61bd96L, 0x0334fe1eL, 0xaa0363cfL, + 0xb5735c90L, 0x4c70a239L, 0xd59e9e0bL, 0xcbaade14L, + 0xeecc86bcL, 0x60622ca7L, 0x9cab5cabL, 0xb2f3846eL, + 0x648b1eafL, 0x19bdf0caL, 0xa02369b9L, 0x655abb50L, + 0x40685a32L, 0x3c2ab4b3L, 0x319ee9d5L, 0xc021b8f7L, + 0x9b540b19L, 0x875fa099L, 0x95f7997eL, 0x623d7da8L, + 0xf837889aL, 0x97e32d77L, 0x11ed935fL, 0x16681281L, + 0x0e358829L, 0xc7e61fd6L, 0x96dedfa1L, 0x7858ba99L, + 0x57f584a5L, 0x1b227263L, 0x9b83c3ffL, 0x1ac24696L, + 0xcdb30aebL, 0x532e3054L, 0x8fd948e4L, 0x6dbc3128L, + 0x58ebf2efL, 0x34c6ffeaL, 0xfe28ed61L, 0xee7c3c73L, + 0x5d4a14d9L, 0xe864b7e3L, 0x42105d14L, 0x203e13e0L, + 0x45eee2b6L, 0xa3aaabeaL, 0xdb6c4f15L, 0xfacb4fd0L, + 0xc742f442L, 0xef6abbb5L, 0x654f3b1dL, 0x41cd2105L, + 0xd81e799eL, 0x86854dc7L, 0xe44b476aL, 0x3d816250L, + 0xcf62a1f2L, 0x5b8d2646L, 0xfc8883a0L, 0xc1c7b6a3L, + 0x7f1524c3L, 0x69cb7492L, 0x47848a0bL, 0x5692b285L, + 0x095bbf00L, 0xad19489dL, 0x1462b174L, 0x23820e00L, + 0x58428d2aL, 0x0c55f5eaL, 0x1dadf43eL, 0x233f7061L, + 0x3372f092L, 0x8d937e41L, 0xd65fecf1L, 0x6c223bdbL, + 0x7cde3759L, 0xcbee7460L, 0x4085f2a7L, 0xce77326eL, + 0xa6078084L, 0x19f8509eL, 0xe8efd855L, 0x61d99735L, + 0xa969a7aaL, 0xc50c06c2L, 0x5a04abfcL, 0x800bcadcL, + 0x9e447a2eL, 0xc3453484L, 0xfdd56705L, 0x0e1e9ec9L, + 0xdb73dbd3L, 0x105588cdL, 0x675fda79L, 0xe3674340L, + 0xc5c43465L, 0x713e38d8L, 0x3d28f89eL, 0xf16dff20L, + 0x153e21e7L, 0x8fb03d4aL, 0xe6e39f2bL, 0xdb83adf7L, + 0xe93d5a68L, 0x948140f7L, 0xf64c261cL, 0x94692934L, + 0x411520f7L, 0x7602d4f7L, 0xbcf46b2eL, 0xd4a20068L, + 0xd4082471L, 0x3320f46aL, 0x43b7d4b7L, 0x500061afL, + 0x1e39f62eL, 0x97244546L, 0x14214f74L, 0xbf8b8840L, + 0x4d95fc1dL, 0x96b591afL, 0x70f4ddd3L, 0x66a02f45L, + 0xbfbc09ecL, 0x03bd9785L, 0x7fac6dd0L, 0x31cb8504L, + 0x96eb27b3L, 0x55fd3941L, 0xda2547e6L, 0xabca0a9aL, + 0x28507825L, 0x530429f4L, 0x0a2c86daL, 0xe9b66dfbL, + 0x68dc1462L, 0xd7486900L, 0x680ec0a4L, 0x27a18deeL, + 0x4f3ffea2L, 0xe887ad8cL, 0xb58ce006L, 0x7af4d6b6L, + 0xaace1e7cL, 0xd3375fecL, 0xce78a399L, 0x406b2a42L, + 0x20fe9e35L, 0xd9f385b9L, 0xee39d7abL, 0x3b124e8bL, + 0x1dc9faf7L, 0x4b6d1856L, 0x26a36631L, 0xeae397b2L, + 0x3a6efa74L, 0xdd5b4332L, 0x6841e7f7L, 0xca7820fbL, + 0xfb0af54eL, 0xd8feb397L, 0x454056acL, 0xba489527L, + 0x55533a3aL, 0x20838d87L, 0xfe6ba9b7L, 0xd096954bL, + 0x55a867bcL, 0xa1159a58L, 0xcca92963L, 0x99e1db33L, + 0xa62a4a56L, 0x3f3125f9L, 0x5ef47e1cL, 0x9029317cL, + 0xfdf8e802L, 0x04272f70L, 0x80bb155cL, 0x05282ce3L, + 0x95c11548L, 0xe4c66d22L, 0x48c1133fL, 0xc70f86dcL, + 0x07f9c9eeL, 0x41041f0fL, 0x404779a4L, 0x5d886e17L, + 0x325f51ebL, 0xd59bc0d1L, 0xf2bcc18fL, 0x41113564L, + 0x257b7834L, 0x602a9c60L, 0xdff8e8a3L, 0x1f636c1bL, + 0x0e12b4c2L, 0x02e1329eL, 0xaf664fd1L, 0xcad18115L, + 0x6b2395e0L, 0x333e92e1L, 0x3b240b62L, 0xeebeb922L, + 0x85b2a20eL, 0xe6ba0d99L, 0xde720c8cL, 0x2da2f728L, + 0xd0127845L, 0x95b794fdL, 0x647d0862L, 0xe7ccf5f0L, + 0x5449a36fL, 0x877d48faL, 0xc39dfd27L, 0xf33e8d1eL, + 0x0a476341L, 0x992eff74L, 0x3a6f6eabL, 0xf4f8fd37L, + 0xa812dc60L, 0xa1ebddf8L, 0x991be14cL, 0xdb6e6b0dL, + 0xc67b5510L, 0x6d672c37L, 0x2765d43bL, 0xdcd0e804L, + 0xf1290dc7L, 0xcc00ffa3L, 0xb5390f92L, 0x690fed0bL, + 0x667b9ffbL, 0xcedb7d9cL, 0xa091cf0bL, 0xd9155ea3L, + 0xbb132f88L, 0x515bad24L, 0x7b9479bfL, 0x763bd6ebL, + 0x37392eb3L, 0xcc115979L, 0x8026e297L, 0xf42e312dL, + 0x6842ada7L, 0xc66a2b3bL, 0x12754cccL, 0x782ef11cL, + 0x6a124237L, 0xb79251e7L, 0x06a1bbe6L, 0x4bfb6350L, + 0x1a6b1018L, 0x11caedfaL, 0x3d25bdd8L, 0xe2e1c3c9L, + 0x44421659L, 0x0a121386L, 0xd90cec6eL, 0xd5abea2aL, + 0x64af674eL, 0xda86a85fL, 0xbebfe988L, 0x64e4c3feL, + 0x9dbc8057L, 0xf0f7c086L, 0x60787bf8L, 0x6003604dL, + 0xd1fd8346L, 0xf6381fb0L, 0x7745ae04L, 0xd736fcccL, + 0x83426b33L, 0xf01eab71L, 0xb0804187L, 0x3c005e5fL, + 0x77a057beL, 0xbde8ae24L, 0x55464299L, 0xbf582e61L, + 0x4e58f48fL, 0xf2ddfda2L, 0xf474ef38L, 0x8789bdc2L, + 0x5366f9c3L, 0xc8b38e74L, 0xb475f255L, 0x46fcd9b9L, + 0x7aeb2661L, 0x8b1ddf84L, 0x846a0e79L, 0x915f95e2L, + 0x466e598eL, 0x20b45770L, 0x8cd55591L, 0xc902de4cL, + 0xb90bace1L, 0xbb8205d0L, 0x11a86248L, 0x7574a99eL, + 0xb77f19b6L, 0xe0a9dc09L, 0x662d09a1L, 0xc4324633L, + 0xe85a1f02L, 0x09f0be8cL, 0x4a99a025L, 0x1d6efe10L, + 0x1ab93d1dL, 0x0ba5a4dfL, 0xa186f20fL, 0x2868f169L, + 0xdcb7da83L, 0x573906feL, 0xa1e2ce9bL, 0x4fcd7f52L, + 0x50115e01L, 0xa70683faL, 0xa002b5c4L, 0x0de6d027L, + 0x9af88c27L, 0x773f8641L, 0xc3604c06L, 0x61a806b5L, + 0xf0177a28L, 0xc0f586e0L, 0x006058aaL, 0x30dc7d62L, + 0x11e69ed7L, 0x2338ea63L, 0x53c2dd94L, 0xc2c21634L, + 0xbbcbee56L, 0x90bcb6deL, 0xebfc7da1L, 0xce591d76L, + 0x6f05e409L, 0x4b7c0188L, 0x39720a3dL, 0x7c927c24L, + 0x86e3725fL, 0x724d9db9L, 0x1ac15bb4L, 0xd39eb8fcL, + 0xed545578L, 0x08fca5b5L, 0xd83d7cd3L, 0x4dad0fc4L, + 0x1e50ef5eL, 0xb161e6f8L, 0xa28514d9L, 0x6c51133cL, + 0x6fd5c7e7L, 0x56e14ec4L, 0x362abfceL, 0xddc6c837L, + 0xd79a3234L, 0x92638212L, 0x670efa8eL, 0x406000e0L, + 0x3a39ce37L, 0xd3faf5cfL, 0xabc27737L, 0x5ac52d1bL, + 0x5cb0679eL, 0x4fa33742L, 0xd3822740L, 0x99bc9bbeL, + 0xd5118e9dL, 0xbf0f7315L, 0xd62d1c7eL, 0xc700c47bL, + 0xb78c1b6bL, 0x21a19045L, 0xb26eb1beL, 0x6a366eb4L, + 0x5748ab2fL, 0xbc946e79L, 0xc6a376d2L, 0x6549c2c8L, + 0x530ff8eeL, 0x468dde7dL, 0xd5730a1dL, 0x4cd04dc6L, + 0x2939bbdbL, 0xa9ba4650L, 0xac9526e8L, 0xbe5ee304L, + 0xa1fad5f0L, 0x6a2d519aL, 0x63ef8ce2L, 0x9a86ee22L, + 0xc089c2b8L, 0x43242ef6L, 0xa51e03aaL, 0x9cf2d0a4L, + 0x83c061baL, 0x9be96a4dL, 0x8fe51550L, 0xba645bd6L, + 0x2826a2f9L, 0xa73a3ae1L, 0x4ba99586L, 0xef5562e9L, + 0xc72fefd3L, 0xf752f7daL, 0x3f046f69L, 0x77fa0a59L, + 0x80e4a915L, 0x87b08601L, 0x9b09e6adL, 0x3b3ee593L, + 0xe990fd5aL, 0x9e34d797L, 0x2cf0b7d9L, 0x022b8b51L, + 0x96d5ac3aL, 0x017da67dL, 0xd1cf3ed6L, 0x7c7d2d28L, + 0x1f9f25cfL, 0xadf2b89bL, 0x5ad6b472L, 0x5a88f54cL, + 0xe029ac71L, 0xe019a5e6L, 0x47b0acfdL, 0xed93fa9bL, + 0xe8d3c48dL, 0x283b57ccL, 0xf8d56629L, 0x79132e28L, + 0x785f0191L, 0xed756055L, 0xf7960e44L, 0xe3d35e8cL, + 0x15056dd4L, 0x88f46dbaL, 0x03a16125L, 0x0564f0bdL, + 0xc3eb9e15L, 0x3c9057a2L, 0x97271aecL, 0xa93a072aL, + 0x1b3f6d9bL, 0x1e6321f5L, 0xf59c66fbL, 0x26dcf319L, + 0x7533d928L, 0xb155fdf5L, 0x03563482L, 0x8aba3cbbL, + 0x28517711L, 0xc20ad9f8L, 0xabcc5167L, 0xccad925fL, + 0x4de81751L, 0x3830dc8eL, 0x379d5862L, 0x9320f991L, + 0xea7a90c2L, 0xfb3e7bceL, 0x5121ce64L, 0x774fbe32L, + 0xa8b6e37eL, 0xc3293d46L, 0x48de5369L, 0x6413e680L, + 0xa2ae0810L, 0xdd6db224L, 0x69852dfdL, 0x09072166L, + 0xb39a460aL, 0x6445c0ddL, 0x586cdecfL, 0x1c20c8aeL, + 0x5bbef7ddL, 0x1b588d40L, 0xccd2017fL, 0x6bb4e3bbL, + 0xdda26a7eL, 0x3a59ff45L, 0x3e350a44L, 0xbcb4cdd5L, + 0x72eacea8L, 0xfa6484bbL, 0x8d6612aeL, 0xbf3c6f47L, + 0xd29be463L, 0x542f5d9eL, 0xaec2771bL, 0xf64e6370L, + 0x740e0d8dL, 0xe75b1357L, 0xf8721671L, 0xaf537d5dL, + 0x4040cb08L, 0x4eb4e2ccL, 0x34d2466aL, 0x0115af84L, + 0xe1b00428L, 0x95983a1dL, 0x06b89fb4L, 0xce6ea048L, + 0x6f3f3b82L, 0x3520ab82L, 0x011a1d4bL, 0x277227f8L, + 0x611560b1L, 0xe7933fdcL, 0xbb3a792bL, 0x344525bdL, + 0xa08839e1L, 0x51ce794bL, 0x2f32c9b7L, 0xa01fbac9L, + 0xe01cc87eL, 0xbcc7d1f6L, 0xcf0111c3L, 0xa1e8aac7L, + 0x1a908749L, 0xd44fbd9aL, 0xd0dadecbL, 0xd50ada38L, + 0x0339c32aL, 0xc6913667L, 0x8df9317cL, 0xe0b12b4fL, + 0xf79e59b7L, 0x43f5bb3aL, 0xf2d519ffL, 0x27d9459cL, + 0xbf97222cL, 0x15e6fc2aL, 0x0f91fc71L, 0x9b941525L, + 0xfae59361L, 0xceb69cebL, 0xc2a86459L, 0x12baa8d1L, + 0xb6c1075eL, 0xe3056a0cL, 0x10d25065L, 0xcb03a442L, + 0xe0ec6e0eL, 0x1698db3bL, 0x4c98a0beL, 0x3278e964L, + 0x9f1f9532L, 0xe0d392dfL, 0xd3a0342bL, 0x8971f21eL, + 0x1b0a7441L, 0x4ba3348cL, 0xc5be7120L, 0xc37632d8L, + 0xdf359f8dL, 0x9b992f2eL, 0xe60b6f47L, 0x0fe3f11dL, + 0xe54cda54L, 0x1edad891L, 0xce6279cfL, 0xcd3e7e6fL, + 0x1618b166L, 0xfd2c1d05L, 0x848fd2c5L, 0xf6fb2299L, + 0xf523f357L, 0xa6327623L, 0x93a83531L, 0x56cccd02L, + 0xacf08162L, 0x5a75ebb5L, 0x6e163697L, 0x88d273ccL, + 0xde966292L, 0x81b949d0L, 0x4c50901bL, 0x71c65614L, + 0xe6c6c7bdL, 0x327a140aL, 0x45e1d006L, 0xc3f27b9aL, + 0xc9aa53fdL, 0x62a80f00L, 0xbb25bfe2L, 0x35bdd2f6L, + 0x71126905L, 0xb2040222L, 0xb6cbcf7cL, 0xcd769c2bL, + 0x53113ec0L, 0x1640e3d3L, 0x38abbd60L, 0x2547adf0L, + 0xba38209cL, 0xf746ce76L, 0x77afa1c5L, 0x20756060L, + 0x85cbfe4eL, 0x8ae88dd8L, 0x7aaaf9b0L, 0x4cf9aa7eL, + 0x1948c25cL, 0x02fb8a8cL, 0x01c36ae4L, 0xd6ebe1f9L, + 0x90d4f869L, 0xa65cdea0L, 0x3f09252dL, 0xc208e69fL, + 0xb74e6132L, 0xce77e25bL, 0x578fdfe3L, 0x3ac372e6L, }; - - diff --git a/src/libsec/port/des.c b/src/libsec/port/des.c index c54541c58..f14d2ea90 100644 --- a/src/libsec/port/des.c +++ b/src/libsec/port/des.c @@ -133,7 +133,7 @@ block_cipher(ulong key[32], uchar text[8], int decrypting) ^ fetch(5, v1, 8) ^ fetch(7, v1, 0); key += keystep; - + v0 = key[0]; v0 ^= (left >> 1) | (left << 31); right ^= fetch(0, v0, 24) @@ -229,7 +229,7 @@ triple_block_cipher(ulong expanded_key[3][32], uchar text[8], int ende) ^ fetch(5, v1, 8) ^ fetch(7, v1, 0); key += keystep; - + v0 = key[0]; v0 ^= (left >> 1) | (left << 31); right ^= fetch(0, v0, 24) @@ -409,21 +409,21 @@ des_key_setup(uchar key[8], ulong *ek) static uchar parity[128] = { - 0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, - 0x10, 0x13, 0x15, 0x16, 0x19, 0x1a, 0x1c, 0x1f, - 0x20, 0x23, 0x25, 0x26, 0x29, 0x2a, 0x2c, 0x2f, - 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e, - 0x40, 0x43, 0x45, 0x46, 0x49, 0x4a, 0x4c, 0x4f, - 0x51, 0x52, 0x54, 0x57, 0x58, 0x5b, 0x5d, 0x5e, - 0x61, 0x62, 0x64, 0x67, 0x68, 0x6b, 0x6d, 0x6e, - 0x70, 0x73, 0x75, 0x76, 0x79, 0x7a, 0x7c, 0x7f, - 0x80, 0x83, 0x85, 0x86, 0x89, 0x8a, 0x8c, 0x8f, - 0x91, 0x92, 0x94, 0x97, 0x98, 0x9b, 0x9d, 0x9e, - 0xa1, 0xa2, 0xa4, 0xa7, 0xa8, 0xab, 0xad, 0xae, - 0xb0, 0xb3, 0xb5, 0xb6, 0xb9, 0xba, 0xbc, 0xbf, - 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, 0xcb, 0xcd, 0xce, - 0xd0, 0xd3, 0xd5, 0xd6, 0xd9, 0xda, 0xdc, 0xdf, - 0xe0, 0xe3, 0xe5, 0xe6, 0xe9, 0xea, 0xec, 0xef, + 0x01, 0x02, 0x04, 0x07, 0x08, 0x0b, 0x0d, 0x0e, + 0x10, 0x13, 0x15, 0x16, 0x19, 0x1a, 0x1c, 0x1f, + 0x20, 0x23, 0x25, 0x26, 0x29, 0x2a, 0x2c, 0x2f, + 0x31, 0x32, 0x34, 0x37, 0x38, 0x3b, 0x3d, 0x3e, + 0x40, 0x43, 0x45, 0x46, 0x49, 0x4a, 0x4c, 0x4f, + 0x51, 0x52, 0x54, 0x57, 0x58, 0x5b, 0x5d, 0x5e, + 0x61, 0x62, 0x64, 0x67, 0x68, 0x6b, 0x6d, 0x6e, + 0x70, 0x73, 0x75, 0x76, 0x79, 0x7a, 0x7c, 0x7f, + 0x80, 0x83, 0x85, 0x86, 0x89, 0x8a, 0x8c, 0x8f, + 0x91, 0x92, 0x94, 0x97, 0x98, 0x9b, 0x9d, 0x9e, + 0xa1, 0xa2, 0xa4, 0xa7, 0xa8, 0xab, 0xad, 0xae, + 0xb0, 0xb3, 0xb5, 0xb6, 0xb9, 0xba, 0xbc, 0xbf, + 0xc1, 0xc2, 0xc4, 0xc7, 0xc8, 0xcb, 0xcd, 0xce, + 0xd0, 0xd3, 0xd5, 0xd6, 0xd9, 0xda, 0xdc, 0xdf, + 0xe0, 0xe3, 0xe5, 0xe6, 0xe9, 0xea, 0xec, 0xef, 0xf1, 0xf2, 0xf4, 0xf7, 0xf8, 0xfb, 0xfd, 0xfe, }; @@ -476,5 +476,5 @@ key_setup(uchar key[7], ulong *ek) uchar k64[8]; des56to64(key, k64); - des_key_setup(k64, ek); + des_key_setup(k64, ek); } diff --git a/src/libsec/port/des3ECB.c b/src/libsec/port/des3ECB.c index a03d7044e..cfd2ce966 100644 --- a/src/libsec/port/des3ECB.c +++ b/src/libsec/port/des3ECB.c @@ -17,7 +17,7 @@ des3ECBencrypt(uchar *p, int len, DES3state *s) triple_block_cipher(s->expanded, p, DES3EDE); p += 8; } - + if(len > 0){ for (i=0; i<8; i++) tmp[i] = i; @@ -37,7 +37,7 @@ des3ECBdecrypt(uchar *p, int len, DES3state *s) triple_block_cipher(s->expanded, p, DES3DED); p += 8; } - + if(len > 0){ for (i=0; i<8; i++) tmp[i] = i; diff --git a/src/libsec/port/desECB.c b/src/libsec/port/desECB.c index 0bc341419..b38ae4fd7 100644 --- a/src/libsec/port/desECB.c +++ b/src/libsec/port/desECB.c @@ -17,7 +17,7 @@ desECBencrypt(uchar *p, int len, DESstate *s) block_cipher(s->expanded, p, 0); p += 8; } - + if(len > 0){ for (i=0; i<8; i++) tmp[i] = i; @@ -37,7 +37,7 @@ desECBdecrypt(uchar *p, int len, DESstate *s) block_cipher(s->expanded, p, 1); p += 8; } - + if(len > 0){ for (i=0; i<8; i++) tmp[i] = i; diff --git a/src/libsec/port/egdecrypt.c b/src/libsec/port/egdecrypt.c index 245788006..31d4bdd57 100644 --- a/src/libsec/port/egdecrypt.c +++ b/src/libsec/port/egdecrypt.c @@ -17,7 +17,7 @@ egdecrypt(EGpriv *priv, mpint *in, mpint *out) delta = mpnew(0); mpright(in, shift, gamma); mpleft(gamma, shift, delta); - mpsub(in, delta, delta); + mpsub(in, delta, delta); mpexp(gamma, priv->secret, p, out); mpinvert(out, p, gamma); mpmul(gamma, delta, out); diff --git a/src/libsec/port/fastrand.c b/src/libsec/port/fastrand.c index 145712774..ca3c01954 100644 --- a/src/libsec/port/fastrand.c +++ b/src/libsec/port/fastrand.c @@ -2,7 +2,7 @@ #include #include -/* +/* * use the X917 random number generator to create random * numbers (faster than truerand() but not as random). */ @@ -10,7 +10,7 @@ ulong fastrand(void) { ulong x; - + genrandom((uchar*)&x, sizeof x); return x; } diff --git a/src/libsec/port/md4.c b/src/libsec/port/md4.c index dc4a8c2a8..6fb5c0026 100644 --- a/src/libsec/port/md4.c +++ b/src/libsec/port/md4.c @@ -37,58 +37,58 @@ struct MD4Table static MD4Table tab[] = { /* round 1 */ -/*[0]*/ { 0, S11}, - { 1, S12}, - { 2, S13}, - { 3, S14}, - { 4, S11}, - { 5, S12}, - { 6, S13}, - { 7, S14}, - { 8, S11}, - { 9, S12}, - { 10, S13}, - { 11, S14}, - { 12, S11}, - { 13, S12}, - { 14, S13}, +/*[0]*/ { 0, S11}, + { 1, S12}, + { 2, S13}, + { 3, S14}, + { 4, S11}, + { 5, S12}, + { 6, S13}, + { 7, S14}, + { 8, S11}, + { 9, S12}, + { 10, S13}, + { 11, S14}, + { 12, S11}, + { 13, S12}, + { 14, S13}, { 15, S14}, /* round 2 */ -/*[16]*/{ 0, S21}, - { 4, S22}, - { 8, S23}, - { 12, S24}, - { 1, S21}, - { 5, S22}, - { 9, S23}, - { 13, S24}, - { 2, S21}, - { 6, S22}, - { 10, S23}, - { 14, S24}, - { 3, S21}, - { 7, S22}, - { 11, S23}, +/*[16]*/{ 0, S21}, + { 4, S22}, + { 8, S23}, + { 12, S24}, + { 1, S21}, + { 5, S22}, + { 9, S23}, + { 13, S24}, + { 2, S21}, + { 6, S22}, + { 10, S23}, + { 14, S24}, + { 3, S21}, + { 7, S22}, + { 11, S23}, { 15, S24}, /* round 3 */ -/*[32]*/{ 0, S31}, - { 8, S32}, - { 4, S33}, - { 12, S34}, - { 2, S31}, - { 10, S32}, - { 6, S33}, - { 14, S34}, - { 1, S31}, - { 9, S32}, - { 5, S33}, - { 13, S34}, - { 3, S31}, - { 11, S32}, - { 7, S33}, - { 15, S34}, +/*[32]*/{ 0, S31}, + { 8, S32}, + { 4, S33}, + { 12, S34}, + { 2, S31}, + { 10, S32}, + { 6, S33}, + { 14, S34}, + { 1, S31}, + { 9, S32}, + { 5, S33}, + { 13, S34}, + { 3, S31}, + { 11, S32}, + { 7, S33}, + { 15, S34}, }; static void encode(uchar*, u32int*, ulong); @@ -110,7 +110,7 @@ md4block(uchar *p, ulong len, MD4state *s) d = s->state[3]; decode(x, p, 64); - + for(i = 0; i < 48; i++){ t = tab + i; switch(i>>4){ @@ -126,7 +126,7 @@ md4block(uchar *p, ulong len, MD4state *s) } a += x[t->x]; a = (a << t->rot) | (a >> (32 - t->rot)); - + /* rotate variables */ tmp = d; d = c; diff --git a/src/libsec/port/md5block.c b/src/libsec/port/md5block.c index 07fe22379..4183f929b 100644 --- a/src/libsec/port/md5block.c +++ b/src/libsec/port/md5block.c @@ -56,76 +56,76 @@ enum static u32int md5tab[] = { /* round 1 */ -/*[0]*/ 0xd76aa478, - 0xe8c7b756, - 0x242070db, - 0xc1bdceee, - 0xf57c0faf, - 0x4787c62a, - 0xa8304613, - 0xfd469501, - 0x698098d8, - 0x8b44f7af, - 0xffff5bb1, - 0x895cd7be, - 0x6b901122, - 0xfd987193, - 0xa679438e, +/*[0]*/ 0xd76aa478, + 0xe8c7b756, + 0x242070db, + 0xc1bdceee, + 0xf57c0faf, + 0x4787c62a, + 0xa8304613, + 0xfd469501, + 0x698098d8, + 0x8b44f7af, + 0xffff5bb1, + 0x895cd7be, + 0x6b901122, + 0xfd987193, + 0xa679438e, 0x49b40821, /* round 2 */ -/*[16]*/0xf61e2562, - 0xc040b340, - 0x265e5a51, - 0xe9b6c7aa, - 0xd62f105d, - 0x2441453, - 0xd8a1e681, - 0xe7d3fbc8, - 0x21e1cde6, - 0xc33707d6, - 0xf4d50d87, - 0x455a14ed, - 0xa9e3e905, - 0xfcefa3f8, - 0x676f02d9, +/*[16]*/0xf61e2562, + 0xc040b340, + 0x265e5a51, + 0xe9b6c7aa, + 0xd62f105d, + 0x2441453, + 0xd8a1e681, + 0xe7d3fbc8, + 0x21e1cde6, + 0xc33707d6, + 0xf4d50d87, + 0x455a14ed, + 0xa9e3e905, + 0xfcefa3f8, + 0x676f02d9, 0x8d2a4c8a, /* round 3 */ -/*[32]*/0xfffa3942, - 0x8771f681, - 0x6d9d6122, - 0xfde5380c, - 0xa4beea44, - 0x4bdecfa9, - 0xf6bb4b60, - 0xbebfbc70, - 0x289b7ec6, - 0xeaa127fa, - 0xd4ef3085, - 0x4881d05, - 0xd9d4d039, - 0xe6db99e5, - 0x1fa27cf8, - 0xc4ac5665, +/*[32]*/0xfffa3942, + 0x8771f681, + 0x6d9d6122, + 0xfde5380c, + 0xa4beea44, + 0x4bdecfa9, + 0xf6bb4b60, + 0xbebfbc70, + 0x289b7ec6, + 0xeaa127fa, + 0xd4ef3085, + 0x4881d05, + 0xd9d4d039, + 0xe6db99e5, + 0x1fa27cf8, + 0xc4ac5665, /* round 4 */ -/*[48]*/0xf4292244, - 0x432aff97, - 0xab9423a7, - 0xfc93a039, - 0x655b59c3, - 0x8f0ccc92, - 0xffeff47d, - 0x85845dd1, - 0x6fa87e4f, - 0xfe2ce6e0, - 0xa3014314, - 0x4e0811a1, - 0xf7537e82, - 0xbd3af235, - 0x2ad7d2bb, - 0xeb86d391, +/*[48]*/0xf4292244, + 0x432aff97, + 0xab9423a7, + 0xfc93a039, + 0x655b59c3, + 0x8f0ccc92, + 0xffeff47d, + 0x85845dd1, + 0x6fa87e4f, + 0xfe2ce6e0, + 0xa3014314, + 0x4e0811a1, + 0xf7537e82, + 0xbd3af235, + 0x2ad7d2bb, + 0xeb86d391, }; static void decode(u32int*, uchar*, ulong); @@ -146,7 +146,7 @@ _md5block(uchar *p, ulong len, u32int *s) d = s[3]; decode(x, p, 64); - + t = md5tab; sh = 0; for(; sh != 16; t += 4){ diff --git a/src/libsec/port/nfastrand.c b/src/libsec/port/nfastrand.c index 3ba77003d..a4d640dd7 100644 --- a/src/libsec/port/nfastrand.c +++ b/src/libsec/port/nfastrand.c @@ -8,7 +8,7 @@ ulong nfastrand(ulong n) { ulong m, r; - + /* * set m to the maximum multiple of n <= 2^31-1 * so we want a random number < m. diff --git a/src/libsec/port/readcert.c b/src/libsec/port/readcert.c index b8ddf6d2f..69a5a9d3e 100644 --- a/src/libsec/port/readcert.c +++ b/src/libsec/port/readcert.c @@ -64,4 +64,3 @@ readcertchain(char *filename) chp = decodepemchain(chfile, "CERTIFICATE"); return chp; } - diff --git a/src/libsec/port/rsadecrypt.c b/src/libsec/port/rsadecrypt.c index 82e2eeea0..147cafd8f 100644 --- a/src/libsec/port/rsadecrypt.c +++ b/src/libsec/port/rsadecrypt.c @@ -22,7 +22,7 @@ rsadecrypt(RSApriv *rsa, mpint *in, mpint *out) /* exponentiate the modular rep */ mpexp(v1, rsa->kp, rsa->p, v1); mpexp(v2, rsa->kq, rsa->q, v2); - + /* out = v1 + p*((v2-v1)*c2 mod q) */ mpsub(v2, v1, v2); mpmul(v2, rsa->c2, v2); diff --git a/src/libsec/port/rsafill.c b/src/libsec/port/rsafill.c index 7b7156140..cc123a239 100644 --- a/src/libsec/port/rsafill.c +++ b/src/libsec/port/rsafill.c @@ -58,4 +58,3 @@ rsafill(mpint *n, mpint *e, mpint *d, mpint *p, mpint *q) return rsa; } - diff --git a/src/libsec/port/rsatest.c b/src/libsec/port/rsatest.c index 9ff66b5c2..270e76943 100644 --- a/src/libsec/port/rsatest.c +++ b/src/libsec/port/rsatest.c @@ -27,7 +27,7 @@ main(void) strtomp("123456789abcdef123456789abcdef123456789abcdef123456789abcdef", nil, 16, clr); rsaencrypt(&rsa->pub, clr, enc); - + start = nsec(); for(n = 0; n < 10; n++) rsadecrypt(rsa, enc, clr); @@ -40,7 +40,7 @@ main(void) if(mpcmp(clr, clr2) != 0) print("%B != %B\n", clr, clr2); - + print("> "); while(p = Brdline(&b, '\n')){ n = Blinelen(&b); diff --git a/src/libsec/port/sha1block.c b/src/libsec/port/sha1block.c index 82566f210..6d7122630 100644 --- a/src/libsec/port/sha1block.c +++ b/src/libsec/port/sha1block.c @@ -42,7 +42,7 @@ _sha1block(uchar *p, ulong len, u32int *s) a += ((b<<5) | (b>>27)) + wp[4]; a += 0x5a827999 + (((d^e)&c)^e); c = (c<<30)|(c>>2); - + p += 20; } diff --git a/src/libsec/port/thumb.c b/src/libsec/port/thumb.c index cac95a436..6010342cc 100644 --- a/src/libsec/port/thumb.c +++ b/src/libsec/port/thumb.c @@ -94,4 +94,3 @@ initThumbprints(char *ok, char *crl) free(crltab); return table; } - diff --git a/src/libsec/port/tlshand.c b/src/libsec/port/tlshand.c index ae216716d..f12d8ce9a 100644 --- a/src/libsec/port/tlshand.c +++ b/src/libsec/port/tlshand.c @@ -1789,7 +1789,7 @@ tlsSecSecretc(TlsSec *sec, uchar *sid, int nsid, uchar *srandom, uchar *cert, in USED(sid); USED(nsid); - + memmove(sec->srandom, srandom, RandomSize); if(setVers(sec, vers) < 0) @@ -1918,7 +1918,7 @@ serverMasterSecret(TlsSec *sec, uchar *epm, int nepm) genrandom(pm->data, MasterSecretSize); } setMasterSecret(sec, pm); - memset(pm->data, 0, pm->len); + memset(pm->data, 0, pm->len); freebytes(pm); } diff --git a/src/libsec/port/x509.c b/src/libsec/port/x509.c index 2bbf85381..479002533 100644 --- a/src/libsec/port/x509.c +++ b/src/libsec/port/x509.c @@ -2123,7 +2123,7 @@ verify_signature(Bytes* signature, RSApub *pk, uchar *edigest, Elem **psigalg) return nil; return "digests did not match"; } - + RSApub* X509toRSApub(uchar *cert, int ncert, char *name, int nname) { diff --git a/src/libsunrpc/client.c b/src/libsunrpc/client.c index 692ab5916..44ead7d17 100644 --- a/src/libsunrpc/client.c +++ b/src/libsunrpc/client.c @@ -243,7 +243,7 @@ if(cli->chatty) fprint(2, "resend %lux %lud %lud\n", o->xid, t, o->t); if(nout == 0) a[1].op = CHANNOP; break; - + case 2: /* tag = <-flushchan */ for(i=0; itimerchan); free(cli); } - + void sunclientflushrpc(SunClient *cli, ulong tag) { diff --git a/src/libsunrpc/emalloc.c b/src/libsunrpc/emalloc.c index 8a09eda78..ce6174122 100644 --- a/src/libsunrpc/emalloc.c +++ b/src/libsunrpc/emalloc.c @@ -30,5 +30,3 @@ abort(); setrealloctag(v, getcallerpc(&n)); return v; } - - diff --git a/src/libsunrpc/mount3.c b/src/libsunrpc/mount3.c index d487c8064..4da94896a 100644 --- a/src/libsunrpc/mount3.c +++ b/src/libsunrpc/mount3.c @@ -709,7 +709,7 @@ static SunProc proc1[] = { (P)nfsmount3rexportpack, (P)nfsmount3rexportunpack, (S)nfsmount3rexportsize, (F)nfsmount3rexportprint, sizeof(NfsMount3RExport), }; -SunProg nfsmount3prog = +SunProg nfsmount3prog = { NfsMount3Program, NfsMount3Version, diff --git a/src/libsunrpc/nfs3.c b/src/libsunrpc/nfs3.c index 706d9c4f4..8cf52db1a 100644 --- a/src/libsunrpc/nfs3.c +++ b/src/libsunrpc/nfs3.c @@ -3377,7 +3377,7 @@ countEntryPlus(uchar *a, uchar *ea, uchar **pa, u32int *n) *pa = a; return 0; } - + int nfs3rreaddirplusunpack(uchar *a, uchar *ea, uchar **pa, Nfs3RReadDirPlus *x) { @@ -4042,7 +4042,7 @@ static SunProc proc[] = { (P)nfs3rcommitpack, (P)nfs3rcommitunpack, (S)nfs3rcommitsize, (F)nfs3rcommitprint, sizeof(Nfs3RCommit) }; -SunProg nfs3prog = +SunProg nfs3prog = { Nfs3Program, Nfs3Version, diff --git a/src/libsunrpc/portmap.c b/src/libsunrpc/portmap.c index 2bb401534..76a1dde1d 100644 --- a/src/libsunrpc/portmap.c +++ b/src/libsunrpc/portmap.c @@ -489,7 +489,7 @@ static SunProc proc[] = { (P)portRCallitPack, (P)portRCallitUnpack, (S)portRCallitSize, (F)portRCallitPrint, sizeof(PortRCallit), }; -SunProg portprog = +SunProg portprog = { PortProgram, PortVersion, diff --git a/src/libsunrpc/rpc.c b/src/libsunrpc/rpc.c index 4ebe1ec89..a4b3f011b 100644 --- a/src/libsunrpc/rpc.c +++ b/src/libsunrpc/rpc.c @@ -78,7 +78,7 @@ sunrpcpack(uchar *a, uchar *ea, uchar **pa, SunRpc *rpc) goto Err; break; } - + switch(rpc->status){ case SunSuccess: if(sunuint32pack(a, ea, &a, (x=MsgSuccess, &x)) < 0 @@ -538,4 +538,3 @@ sunfixedopaqueunpack(uchar *a, uchar *ea, uchar **pa, uchar *dat, u32int n) *pa = ea; return -1; } - diff --git a/src/libsunrpc/server.c b/src/libsunrpc/server.c index 6e024fca7..b94b76439 100644 --- a/src/libsunrpc/server.c +++ b/src/libsunrpc/server.c @@ -194,7 +194,7 @@ sunrpcreplythread(void *v) while((m = recvp(srv->creply)) != nil){ /* could record in cache here? */ sendp(m->creply, m); - } + } } int @@ -286,4 +286,3 @@ sunmsgdrop(SunMsg *m) free(m); return 0; } - diff --git a/src/libthread/386-ucontext.h b/src/libthread/386-ucontext.h index 21327d9bc..b1ee81b30 100644 --- a/src/libthread/386-ucontext.h +++ b/src/libthread/386-ucontext.h @@ -16,7 +16,7 @@ extern void setmcontext(mcontext_t*); * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer + * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the @@ -48,7 +48,7 @@ extern void setmcontext(mcontext_t*); * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer + * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the @@ -117,5 +117,3 @@ struct ucontext { stack_t uc_stack; int __spare__[8]; }; - - diff --git a/src/libthread/BSD.c b/src/libthread/BSD.c index b9e8888e4..737c0a63a 100644 --- a/src/libthread/BSD.c +++ b/src/libthread/BSD.c @@ -288,7 +288,7 @@ threadexitsall(char *msg) if(msg == nil) msg = ""; - /* + /* * Only one guy, ever, gets to run this. * If two guys do it, inevitably they end up * tripping over each other in the underlying @@ -401,4 +401,3 @@ _threadpexit(void) { _exit(0); } - diff --git a/src/libthread/Darwin-386.c b/src/libthread/Darwin-386.c index 3ad1941c9..b138e4200 100644 --- a/src/libthread/Darwin-386.c +++ b/src/libthread/Darwin-386.c @@ -28,4 +28,3 @@ swapcontext(ucontext_t *oucp, ucontext_t *ucp) setcontext(ucp); return 0; } - diff --git a/src/libthread/Darwin-power.c b/src/libthread/Darwin-power.c index efcdb18c6..3f2bf5669 100644 --- a/src/libthread/Darwin-power.c +++ b/src/libthread/Darwin-power.c @@ -7,7 +7,7 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) va_list arg; tos = (ulong*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/sizeof(ulong); - sp = tos - 16; + sp = tos - 16; ucp->mc.pc = (long)func; ucp->mc.sp = (long)sp; va_start(arg, argc); @@ -22,4 +22,3 @@ swapcontext(ucontext_t *oucp, ucontext_t *ucp) setcontext(ucp); return 0; } - diff --git a/src/libthread/Darwin-x86_64-swapcontext.c b/src/libthread/Darwin-x86_64-swapcontext.c index 0593e481d..27931456d 100644 --- a/src/libthread/Darwin-x86_64-swapcontext.c +++ b/src/libthread/Darwin-x86_64-swapcontext.c @@ -28,5 +28,3 @@ swapcontext(ucontext_t *oucp, ucontext_t *ucp) setcontext(ucp); return 0; } - - diff --git a/src/libthread/Linux-arm-swapcontext.c b/src/libthread/Linux-arm-swapcontext.c index 907fb0c3f..fc0dfddaa 100644 --- a/src/libthread/Linux-arm-swapcontext.c +++ b/src/libthread/Linux-arm-swapcontext.c @@ -22,5 +22,3 @@ swapcontext(ucontext_t *oucp, const ucontext_t *ucp) setcontext(ucp); return 0; } - - diff --git a/src/libthread/Linux-sparc64-swapcontext.c b/src/libthread/Linux-sparc64-swapcontext.c index a621b7a1b..e4800c19c 100644 --- a/src/libthread/Linux-sparc64-swapcontext.c +++ b/src/libthread/Linux-sparc64-swapcontext.c @@ -47,4 +47,3 @@ __swapcontext_ret: \n\ clr %o0 \n\ .size __swapcontext_ret, .-__swapcontext_ret \n\ "); - diff --git a/src/libthread/Linux.c b/src/libthread/Linux.c index 17e8c12bb..31577e876 100644 --- a/src/libthread/Linux.c +++ b/src/libthread/Linux.c @@ -6,13 +6,13 @@ static int timefmt(Fmt *fmt) { - static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; vlong ns; Tm tm; ns = nsec(); tm = *localtime(time(0)); - return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", + return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, (int)(ns%1000000000)/1000000); } @@ -246,8 +246,8 @@ startprocfn(void *v) /* * indirect through here so that parent need not wait for child zombie - * - * slight race - if child exits and then another process starts before we + * + * slight race - if child exits and then another process starts before we * manage to exit, we'll be running on a freed stack. */ static int @@ -314,7 +314,7 @@ threadexitsall(char *msg) if(msg == nil) msg = ""; - /* + /* * Only one guy, ever, gets to run this. * If two guys do it, inevitably they end up * tripping over each other in the underlying @@ -442,7 +442,7 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) { int i, *sp; va_list arg; - + sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; va_start(arg, argc); for(i=0; i<4 && i= 0) threadexits("threadexecl"); } - diff --git a/src/libthread/ioproc.h b/src/libthread/ioproc.h index f3a488d3c..831beade9 100644 --- a/src/libthread/ioproc.h +++ b/src/libthread/ioproc.h @@ -11,4 +11,3 @@ struct Ioproc char err[ERRMAX]; Ioproc *next; }; - diff --git a/src/libthread/power-ucontext.h b/src/libthread/power-ucontext.h index 27ed3390e..1985d98d2 100644 --- a/src/libthread/power-ucontext.h +++ b/src/libthread/power-ucontext.h @@ -34,4 +34,3 @@ void makecontext(ucontext_t*, void(*)(void), int, ...); int swapcontext(ucontext_t*, ucontext_t*); int _getmcontext(mcontext_t*); void _setmcontext(mcontext_t*); - diff --git a/src/libthread/sparc-ucontext.h b/src/libthread/sparc-ucontext.h index 0031d2a46..36b881710 100644 --- a/src/libthread/sparc-ucontext.h +++ b/src/libthread/sparc-ucontext.h @@ -21,4 +21,3 @@ void makecontext(ucontext_t*, void(*)(void), int, ...); int swapcontext(ucontext_t*, ucontext_t*); int _getmcontext(mcontext_t*); void _setmcontext(mcontext_t*); - diff --git a/src/libthread/test/thello.c b/src/libthread/test/thello.c index c5732165c..c237b7cdc 100644 --- a/src/libthread/test/thello.c +++ b/src/libthread/test/thello.c @@ -7,4 +7,3 @@ threadmain(int argc, char **argv) { print("hello, world\n"); } - diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 542a2437a..cbad185c4 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -137,7 +137,7 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) t->context.uc.uc_stack.ss_size = t->stksize-64; #if defined(__sun__) && !defined(__MAKECONTEXT_V2_SOURCE) /* sigh */ /* can avoid this with __MAKECONTEXT_V2_SOURCE but only on SunOS 5.9 */ - t->context.uc.uc_stack.ss_sp = + t->context.uc.uc_stack.ss_sp = (char*)t->context.uc.uc_stack.ss_sp +t->context.uc.uc_stack.ss_size; #endif @@ -164,7 +164,7 @@ _threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) /* defend against bad C libraries */ if(stack < (256<<10)) stack = 256<<10; - + t = threadalloc(fn, arg, stack); t->proc = p; addthreadinproc(p, t); @@ -228,7 +228,7 @@ threadidle(void) { int n; Proc *p; - + p = proc(); n = p->nswitch; lock(&p->lock); @@ -466,7 +466,7 @@ int threadid(void) { _Thread *t; - + t = proc()->thread; return t->id; } @@ -534,7 +534,7 @@ static void threadqunlock(QLock *l, ulong pc) { _Thread *ready; - + lock(&l->l); /*print("qlock unlock %p @%#x by %p (owner %p)\n", l, pc, (*threadnow)(), l->owner); */ if(l->owner == 0){ @@ -578,7 +578,7 @@ threadrlock(RWLock *l, int block, ulong pc) addthread(&l->rwaiting, (*threadnow)()); unlock(&l->l); _threadswitch(); - return 1; + return 1; } static int @@ -677,7 +677,7 @@ threadrwakeup(Rendez *r, int all, ulong pc) if((t = r->waiting.head) == nil) break; delthread(&r->waiting, t); - _threadready(t); + _threadready(t); } return i; } @@ -865,7 +865,7 @@ delproc(Proc *p) unlock(&_threadprocslock); } -/* +/* * notify - for now just use the usual mechanisms */ void @@ -901,14 +901,12 @@ threadinfo(void *v, char *s) fprint(2, "proc %p %s%s\n", (void*)p->osprocid, p->msg, p->sysproc ? " (sysproc)": ""); for(t=p->allthreads.head; t; t=t->allnext){ - fprint(2, "\tthread %d %s: %s %s\n", - t->id, - t == p->thread ? "Running" : + fprint(2, "\tthread %d %s: %s %s\n", + t->id, + t == p->thread ? "Running" : onrunqueue(p, t) ? "Ready" : "Sleeping", t->state, t->name); } } return 1; } - - diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 144a2136b..a8d52704d 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -28,7 +28,7 @@ extern void makecontext(ucontext_t*, void(*)(), int, ...); /* * OS X before 10.5 (Leopard) does not provide * swapcontext nor makecontext, so we have to use our own. - * In theory, Leopard does provide them, but when we use + * In theory, Leopard does provide them, but when we use * them, they seg fault. Maybe we're using them wrong. * So just use our own versions, even on Leopard. */ diff --git a/src/libthread/wait.c b/src/libthread/wait.c index 24538e586..ba2301f54 100644 --- a/src/libthread/wait.c +++ b/src/libthread/wait.c @@ -29,11 +29,11 @@ procwait(int pid) Waiter me; Waitmsg *msg; int i; - + memset(&me, 0, sizeof me); me.pid = pid; me.r.l = &waiting.lk; - + qlock(&waiting.lk); for(i=0; ipid == pid){ diff --git a/src/libthread/x86_64-ucontext.h b/src/libthread/x86_64-ucontext.h index 08c6d9a8e..e0640761c 100644 --- a/src/libthread/x86_64-ucontext.h +++ b/src/libthread/x86_64-ucontext.h @@ -40,4 +40,3 @@ void makecontext(ucontext_t*, void(*)(void), int, ...); int swapcontext(ucontext_t*, ucontext_t*); int libthread_getmcontext(mcontext_t*); void libthread_setmcontext(mcontext_t*); - diff --git a/src/libventi/cache.c b/src/libventi/cache.c index da0d103ec..aed19c55e 100644 --- a/src/libventi/cache.c +++ b/src/libventi/cache.c @@ -176,7 +176,7 @@ upheap(int i, VtBlock *b) u32int now; int p; VtCache *c; - + c = b->c; now = c->now; for(; i != 0; i = p){ @@ -200,7 +200,7 @@ downheap(int i, VtBlock *b) u32int now; int k; VtCache *c; - + c = b->c; now = c->now; for(; ; i = k){ @@ -291,7 +291,7 @@ vtcachebumpblock(VtCache *c) b->prev = nil; } - + if(0)fprint(2, "droping %x:%V\n", b->addr, b->score); /* set vtBlock to a reasonable state */ b->ref = 1; @@ -306,7 +306,7 @@ static VtBlock* vtcacheevict(VtCache *c, ulong size) { VtBlock *b; - + /* * If we were out of memory and put some blocks * to the side but now we have memory, grab one. @@ -317,7 +317,7 @@ vtcacheevict(VtCache *c, ulong size) b->next = nil; goto alloc; } - + /* * Otherwise, evict until we have memory. */ @@ -474,7 +474,7 @@ vtcacheglobal(VtCache *c, uchar score[VtScoreSize], int type, ulong size) /* * Lock b before unlocking c, so that others wait while we read. - * + * * You might think there is a race between this qlock(b) before qunlock(c) * and the qlock(c) while holding a qlock(b) in vtblockwrite. However, * the block here can never be the block in a vtblockwrite, so we're safe. @@ -542,7 +542,7 @@ if(0)fprint(2, "vtblockput: %d: %x %d %d\n", getpid(), b->addr, c->nheap, b->ios * b->nlock should probably stay at zero while * the vtBlock is unlocked, but diskThread and vtSleep * conspire to assume that they can just qlock(&b->lk); vtblockput(b), - * so we have to keep b->nlock set to 1 even + * so we have to keep b->nlock set to 1 even * when the vtBlock is unlocked. */ assert(b->nlock == 0); @@ -642,4 +642,3 @@ vtglobaltolocal(uchar score[VtScoreSize]) return NilBlock; return (score[16]<<24)|(score[17]<<16)|(score[18]<<8)|score[19]; } - diff --git a/src/libventi/client.c b/src/libventi/client.c index f76fd3433..14f4543f9 100644 --- a/src/libventi/client.c +++ b/src/libventi/client.c @@ -182,7 +182,7 @@ int vtgoodbye(VtConn *z) { VtFcall tx, rx; - + tx.msgtype = VtTgoodbye; vtfcallrpc(z, &tx, &rx); /* always fails: no VtRgoodbye */ return 0; diff --git a/src/libventi/cvt.h b/src/libventi/cvt.h index ef4c2f51d..4d61dbed1 100644 --- a/src/libventi/cvt.h +++ b/src/libventi/cvt.h @@ -12,4 +12,3 @@ #define U32PUT(p,v) (p)[0]=(v)>>24;(p)[1]=(v)>>16;(p)[2]=(v)>>8;(p)[3]=(v) #define U48PUT(p,v,t32) t32=(v)>>32;U16PUT(p,t32);t32=(v);U32PUT((p)+2,t32) #define U64PUT(p,v,t32) t32=(v)>>32;U32PUT(p,t32);t32=(v);U32PUT((p)+4,t32) - diff --git a/src/libventi/debug.c b/src/libventi/debug.c index e0452e48d..9549d89b2 100644 --- a/src/libventi/debug.c +++ b/src/libventi/debug.c @@ -14,4 +14,3 @@ vtdebug(VtConn *z, char *fmt, ...) vfprint(2, fmt, arg); va_end(arg); } - diff --git a/src/libventi/debugpacket.c b/src/libventi/debugpacket.c index 4c13bc87e..1fbfea6a2 100644 --- a/src/libventi/debugpacket.c +++ b/src/libventi/debugpacket.c @@ -19,7 +19,7 @@ Packet* packetalloc(void) { Packet *p; - + p = vtmallocz(sizeof *p); p->free = vtfree; p->arg = nil; @@ -52,7 +52,7 @@ int packetcmp(Packet *p, Packet *q) { int i, len; - + NOTFREE(p); NOTFREE(q); len = p->len; @@ -129,7 +129,7 @@ Packet* packetforeign(uchar *buf, int n, void (*free)(void*), void *a) { Packet *p; - + if(n < 0) abort(); p = packetalloc(); @@ -224,7 +224,7 @@ Packet* packetsplit(Packet *p, int n) { Packet *q; - + NOTFREE(p); q = packetalloc(); q->data = vtmalloc(n); @@ -262,4 +262,3 @@ packettrim(Packet *p, int offset, int n) p->len -= n; return 0; } - diff --git a/src/libventi/dtype.c b/src/libventi/dtype.c index 7886518e2..7b0867ba7 100644 --- a/src/libventi/dtype.c +++ b/src/libventi/dtype.c @@ -75,4 +75,3 @@ vtfromdisktype(uint n) return VtCorruptType; return fromdisk[n]; } - diff --git a/src/libventi/entry.c b/src/libventi/entry.c index 5e9a7c1fe..12fb9589f 100644 --- a/src/libventi/entry.c +++ b/src/libventi/entry.c @@ -21,7 +21,7 @@ vttobig(ulong n) { int shift; ulong n0; - + n0 = n; shift = 0; while(n >= (1<<(16 - 5))) { @@ -30,7 +30,7 @@ vttobig(ulong n) shift++; n >>= 1; } - + n = (n<<5) | shift; if(((n>>5)<<(n&31)) != n0) sysfatal("vttobig %#lux => %#lux failed", n0, n); @@ -111,11 +111,11 @@ vtentryunpack(VtEntry *e, uchar *p, int index) p += VtScoreSize; assert(p-op == VtEntrySize); - + if(!(e->flags & VtEntryActive)) return 0; - /* + /* * Some old vac files use psize==0 and dsize==0 when the * file itself has size 0 or is zeros. Just to make programs not * have to figure out what block sizes of 0 means, rewrite them. @@ -130,4 +130,3 @@ vtentryunpack(VtEntry *e, uchar *p, int index) return 0; } - diff --git a/src/libventi/file.c b/src/libventi/file.c index e97df39c6..8a0512481 100644 --- a/src/libventi/file.c +++ b/src/libventi/file.c @@ -4,7 +4,7 @@ * The single point of truth for the info about the VtFiles themselves * is the block data. Because of this, there is no explicit locking of * VtFile structures, and indeed there may be more than one VtFile - * structure for a given Venti file. They synchronize through the + * structure for a given Venti file. They synchronize through the * block cache. * * This is a bit simpler than fossil because there are no epochs @@ -182,7 +182,7 @@ _vtfilecreate(VtFile *r, int o, int psize, int dsize, int type) int epb; VtFile *rr; u32int offset; - + assert(ISLOCKED(r)); assert(type == VtDirType || type == VtDataType); @@ -574,7 +574,7 @@ growdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth) if(bb == nil) break; memmove(bb->data, b->score, VtScoreSize); - memmove(e->score, bb->score, VtScoreSize); + memmove(e->score, bb->score, VtScoreSize); e->type++; e->flags |= VtEntryLocal; vtblockput(b); @@ -671,7 +671,7 @@ mkindices(VtEntry *e, u32int bn, int *index) } return i; } - + VtBlock * vtfileblock(VtFile *r, u32int bn, int mode) { @@ -985,7 +985,7 @@ sizetodepth(uvlong s, int psize, int dsize) { int np; int d; - + /* determine pointer depth */ np = psize/VtScoreSize; s = (s + dsize - 1)/dsize; @@ -1125,7 +1125,7 @@ flushblock(VtCache *c, VtBlock *bb, uchar score[VtScoreSize], int ppb, int epb, vtentrypack(&e, b->data, i); } break; - + default: /* VtPointerTypeX */ for(i=0; idata+VtScoreSize*i, ppb, epb, type-1) < 0) @@ -1233,13 +1233,13 @@ vtfileflushbefore(VtFile *r, u64int offset) }else{ /* * interior node: pointer blocks. - * specifically, b = bi[i] is a block whose index[i-1]'th entry - * points at bi[i-1]. + * specifically, b = bi[i] is a block whose index[i-1]'th entry + * points at bi[i-1]. */ b = bi[i]; /* - * the index entries up to but not including index[i-1] point at + * the index entries up to but not including index[i-1] point at * finished blocks, so flush them for sure. */ for(j=0; jreadq); qunlock(&z->lk); } - diff --git a/src/libventi/log.c b/src/libventi/log.c index 0d67a98bd..a6738c7a9 100644 --- a/src/libventi/log.c +++ b/src/libventi/log.c @@ -36,7 +36,7 @@ vtlognames(int *pn) int i, nname, size; VtLog *l; char **s, *a, *e; - + qlock(&vl.lk); size = 0; nname = 0; @@ -45,7 +45,7 @@ vtlognames(int *pn) nname++; size += strlen(l->name)+1; } - + s = vtmalloc(nname*sizeof(char*)+size); a = (char*)(s+nname); e = (char*)s+nname*sizeof(char*)+size; @@ -111,12 +111,12 @@ vtlogopen(char *name, uint size) } strcpy(p, name); l->name = p; - + /* insert */ l->next = vl.hash[h]; vl.hash[h] = l; l->ref++; - + l->ref++; qunlock(&vl.lk); return l; @@ -192,10 +192,10 @@ void vtlogprint(VtLog *l, char *fmt, ...) { va_list arg; - + if(l == nil) return; - + va_start(arg, fmt); vtlogvprint(l, fmt, arg); va_end(arg); @@ -224,7 +224,7 @@ vtlogdump(int fd, VtLog *l) if(l == nil) return; - + c = l->w; for(i=0; inchunk; i++){ if(++c == l->chunk+l->nchunk) @@ -232,4 +232,3 @@ vtlogdump(int fd, VtLog *l) write(fd, c->p, c->wp-c->p); } } - diff --git a/src/libventi/mem.c b/src/libventi/mem.c index dea99a9d1..2f03de4e7 100644 --- a/src/libventi/mem.c +++ b/src/libventi/mem.c @@ -62,7 +62,7 @@ vtbrk(int n) align = IdealAlignment; else if(n > 8) align = 8; - else + else align = 4; lock(&lk); @@ -74,8 +74,8 @@ vtbrk(int n) nchunk++; } - assert(n + pad <= nbuf); - + assert(n + pad <= nbuf); + p = buf + pad; buf += pad + n; nbuf -= pad + n; @@ -83,4 +83,3 @@ vtbrk(int n) return p; } - diff --git a/src/libventi/packet.c b/src/libventi/packet.c index d19d85371..8d1628188 100644 --- a/src/libventi/packet.c +++ b/src/libventi/packet.c @@ -35,7 +35,7 @@ enum { FragLocalAlloc, FragGlobal }; - + struct Frag { int state; @@ -55,10 +55,10 @@ struct Packet ulong pc; Packet *next; - + Frag *first; Frag *last; - + Frag local[NLocalFrag]; }; @@ -80,7 +80,7 @@ static void checkpacket(Packet*); #endif /* - * the free list is primarily for speed, but it is + * the free list is primarily for speed, but it is * also necessary for packetsplit that packets * are never freed -- a packet can contain a different * packet's local fragments, thanks to packetsplit! @@ -157,7 +157,7 @@ packetfree(Packet *p) Packet * packetdup(Packet *p, int offset, int n) -{ +{ Frag *f, *ff; Packet *pp; @@ -179,7 +179,7 @@ packetdup(Packet *p, int offset, int n) /* skip offset */ for(f=p->first; offset >= FRAGSIZE(f); f=f->next) offset -= FRAGSIZE(f); - + /* first frag */ ff = fragdup(pp, f); ff->rp += offset; @@ -195,7 +195,7 @@ packetdup(Packet *p, int offset, int n) n -= FRAGSIZE(ff); pp->asize += FRAGASIZE(ff); } - + /* fix up last frag: note n <= 0 */ ff->wp += n; ff->next = nil; @@ -295,7 +295,7 @@ packettrim(Packet *p, int offset, int n) NOTFREE(p); return 0; } - + /* free before offset */ for(f=p->first; offset >= FRAGSIZE(f); f=ff) { p->asize -= FRAGASIZE(f); @@ -341,7 +341,7 @@ packetheader(Packet *p, int n) } p->size += n; - + /* try and fix in current frag */ f = p->first; if(f != nil) { @@ -377,7 +377,7 @@ packettrailer(Packet *p, int n) } p->size += n; - + /* try and fix in current frag */ if(p->first != nil) { f = p->last; @@ -433,7 +433,7 @@ packetprefix(Packet *p, uchar *buf, int n) nn = n; if(nn > MaxFragSize) nn = MaxFragSize; - f = fragalloc(p, nn, PEnd, p->first); + f = fragalloc(p, nn, PEnd, p->first); p->asize += FRAGASIZE(f); if(p->first == nil) p->last = f; @@ -470,7 +470,7 @@ packetappend(Packet *p, uchar *buf, int n) n -= nn; } } - + while(n > 0) { nn = n; if(nn > MaxFragSize) @@ -537,7 +537,7 @@ packetpeek(Packet *p, uchar *buf, int offset, int n) werrstr(EPacketSize); return nil; } - + /* skip up to offset */ for(f=p->first; offset >= FRAGSIZE(f); f=f->next) offset -= FRAGSIZE(f); @@ -586,7 +586,7 @@ packetfragments(Packet *p, IOchunk *io, int nio, int offset) NOTFREE(p); if(p->size == 0 || nio <= 0) return 0; - + if(offset < 0 || offset > p->size) { werrstr(EPacketOffset); return -1; @@ -599,7 +599,7 @@ packetfragments(Packet *p, IOchunk *io, int nio, int offset) eio = io + nio; for(; f != nil && io < eio; f=f->next) { io->addr = f->rp + offset; - io->len = f->wp - (f->rp + offset); + io->len = f->wp - (f->rp + offset); offset = 0; size += io->len; io++; @@ -633,7 +633,7 @@ packetstats(void) nbm = 0; for(m=freelist.bigmem; m; m=m->next) nbm++; - + fprint(2, "packet: %d/%d frag: %d/%d small mem: %d/%d big mem: %d/%d\n", np, freelist.npacket, nf, freelist.nfrag, @@ -651,7 +651,7 @@ packetsize(Packet *p) if(1) { Frag *f; int size = 0; - + for(f=p->first; f; f=f->next) size += FRAGSIZE(f); if(size != p->size) @@ -668,7 +668,7 @@ packetasize(Packet *p) if(0) { Frag *f; int asize = 0; - + for(f=p->first; f; f=f->next) asize += FRAGASIZE(f); if(asize != p->asize) @@ -764,7 +764,7 @@ fragalloc(Packet *p, int n, int pos, Frag *next) goto Found; } } - lock(&freelist.lk); + lock(&freelist.lk); f = freelist.frag; if(f != nil) freelist.frag = f->next; @@ -825,7 +825,7 @@ fragdup(Packet *p, Frag *f) Frag *ff; Mem *m; - m = f->mem; + m = f->mem; /* * m->rp && m->wp can be out of date when ref == 1 @@ -853,7 +853,7 @@ fragdup(Packet *p, Frag *f) unlock(&m->lk); } - + return ff; } @@ -877,7 +877,7 @@ fragfree(Frag *f) lock(&freelist.lk); f->next = freelist.frag; freelist.frag = f; - unlock(&freelist.lk); + unlock(&freelist.lk); } static Mem * @@ -915,7 +915,7 @@ memalloc(int n, int pos) m->bp = vtbrk(nn); m->ep = m->bp + nn; } - assert(m->ref == 0); + assert(m->ref == 0); m->ref = 1; switch(pos) { @@ -930,7 +930,7 @@ memalloc(int n, int pos) break; case PEnd: m->rp = m->ep - n; - break; + break; } /* check we did not blow it */ if(m->rp < m->bp) diff --git a/src/libventi/queue.c b/src/libventi/queue.c index bba630324..b898ea745 100644 --- a/src/libventi/queue.c +++ b/src/libventi/queue.c @@ -44,7 +44,7 @@ void _vtqdecref(Queue *q) { Qel *e; - + qlock(&q->lk); if(--q->ref > 0){ qunlock(&q->lk); diff --git a/src/libventi/rpc.c b/src/libventi/rpc.c index 8f2686337..2abe3e42f 100644 --- a/src/libventi/rpc.c +++ b/src/libventi/rpc.c @@ -1,9 +1,9 @@ /* - * Multiplexed Venti client. It would be nice if we + * Multiplexed Venti client. It would be nice if we * could turn this into a generic library routine rather * than keep it Venti specific. A user-level 9P client * could use something like this too. - * + * * (Actually it does - this should be replaced with libmux, * which should be renamed librpcmux.) * @@ -125,7 +125,7 @@ vtrpc(VtConn *z, Packet *p) return _vtrpc(z, p, nil); } -static int +static int gettag(VtConn *z, Rwait *r) { int i; @@ -176,4 +176,3 @@ abort(); r->done = 1; rwakeup(&r->r); } - diff --git a/src/libventi/send.c b/src/libventi/send.c index 4dbe115f3..96dfe9e6e 100644 --- a/src/libventi/send.c +++ b/src/libventi/send.c @@ -126,14 +126,14 @@ _vtrecv(VtConn *z) p = packetsplit(p, len); vtlog(VtServerLog, "%T %s: read packet %p len %d
\n", z->addr, p, len); return p; -Err: +Err: vtlog(VtServerLog, "%T %s: error reading packet: %r
\n", z->addr); - return nil; + return nil; } /* * If you fork off two procs running vtrecvproc and vtsendproc, - * then vtrecv/vtsend (and thus vtrpc) will never block except on + * then vtrecv/vtsend (and thus vtrpc) will never block except on * rendevouses, which is nice when it's running in one thread of many. */ void @@ -258,9 +258,8 @@ vtsend(VtConn *z, Packet *p) if(_vtsend(z, p) < 0){ qunlock(&z->outlk); vthangup(z); - return -1; + return -1; } qunlock(&z->outlk); return 0; } - diff --git a/src/libventi/server.c b/src/libventi/server.c index 917522007..58ce1d8d1 100644 --- a/src/libventi/server.c +++ b/src/libventi/server.c @@ -180,7 +180,7 @@ VtReq* vtgetreq(VtSrv *srv) { VtReq *r; - + r = _vtqrecv(srv->q); if (r != nil) vtlog(VtServerLog, "%T %s: vtgetreq %F
\n", ((VtSconn*)r->sc)->c->addr, &r->tx); @@ -215,4 +215,3 @@ vtrespond(VtReq *r) vtfcallclear(&r->rx); vtfree(r); } - diff --git a/src/libventi/strdup.c b/src/libventi/strdup.c index e191c390c..36fa6fc7e 100644 --- a/src/libventi/strdup.c +++ b/src/libventi/strdup.c @@ -15,4 +15,3 @@ vtstrdup(char *s) memmove(ss, s, n); return ss; } - diff --git a/src/libventi/string.c b/src/libventi/string.c index 9763149a1..b273b1820 100644 --- a/src/libventi/string.c +++ b/src/libventi/string.c @@ -47,4 +47,3 @@ vtgetstring(Packet *p, char **ps) *ps = s; return 0; } - diff --git a/src/libventi/time.c b/src/libventi/time.c index eb686b329..e105c624f 100644 --- a/src/libventi/time.c +++ b/src/libventi/time.c @@ -15,14 +15,13 @@ vttimefmt(Fmt *fmt) ns = nsec(); tm = *localtime(ns/1000000000); if(fmt->flags&FmtLong){ - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", - tm.year+1900, tm.mon+1, tm.mday, + return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", + tm.year+1900, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec, (int)(ns%1000000000)/1000000); }else{ - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d", - tm.year+1900, tm.mon+1, tm.mday, + return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d", + tm.year+1900, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec); } } - diff --git a/src/libventi/zero.c b/src/libventi/zero.c index c40aea969..33353c786 100644 --- a/src/libventi/zero.c +++ b/src/libventi/zero.c @@ -23,7 +23,7 @@ vtzeroextend(int type, uchar *buf, uint n, uint nn) } } -uint +uint vtzerotruncate(int type, uchar *buf, uint n) { uchar *p; diff --git a/src/libventi/zeroscore.c b/src/libventi/zeroscore.c index 6f22d72de..b58b13c2b 100644 --- a/src/libventi/zeroscore.c +++ b/src/libventi/zeroscore.c @@ -7,4 +7,3 @@ uchar vtzeroscore[VtScoreSize] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }; - From fafa622a5bdf71adfbb4334541c3b65f29c89ca9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 12 Jan 2020 15:05:40 -0500 Subject: [PATCH 114/323] all: fix or silence various gcc warnings As usual, gcc finds some real problems but also reports a ton of noise. Fix the problems and quiet the noise. --- bin/9c | 4 ++++ src/cmd/auth/factotum/p9cr.c | 2 ++ src/cmd/draw/tweak.c | 2 +- src/cmd/eqn/text.c | 2 +- src/cmd/grap/coord.c | 2 +- src/cmd/mk/archive.c | 2 +- src/cmd/paint/eenter.c | 1 + src/cmd/pic/input.c | 2 +- src/cmd/pic/pic.h | 2 +- src/cmd/rio/showevent/ShowEvent.c | 2 +- src/cmd/svgpic/input.c | 2 +- src/cmd/svgpic/pic.h | 2 +- src/cmd/tpic/input.c | 2 +- src/cmd/tpic/pic.h | 2 +- src/cmd/troff/t6.c | 6 +++--- src/lib9/_p9dialparse.c | 2 +- src/lib9/lrand.c | 12 +++++------- 17 files changed, 27 insertions(+), 22 deletions(-) diff --git a/bin/9c b/bin/9c index f21ea7544..20919e9ac 100755 --- a/bin/9c +++ b/bin/9c @@ -14,6 +14,10 @@ usegcc() -Wno-comment \ -Wno-sign-compare \ -Wno-unknown-pragmas \ + -Wno-misleading-indentation \ + -Wno-stringop-truncation \ + -Wno-stringop-overflow \ + -Wno-format-truncation \ -fno-omit-frame-pointer \ -fsigned-char \ " diff --git a/src/cmd/auth/factotum/p9cr.c b/src/cmd/auth/factotum/p9cr.c index 4f181e981..84860d161 100644 --- a/src/cmd/auth/factotum/p9cr.c +++ b/src/cmd/auth/factotum/p9cr.c @@ -290,6 +290,8 @@ p9crresp(ServerState *s, uchar *resp, int resplen) Ticket t; Ticketreq tr; + memset(&tr, 0, sizeof tr); // TODO: what should tr be initialized to? + if(xiowrite(s->asfd, resp, resplen) != resplen) return -1; diff --git a/src/cmd/draw/tweak.c b/src/cmd/draw/tweak.c index 0a71e2dd8..29e2b3d7e 100644 --- a/src/cmd/draw/tweak.c +++ b/src/cmd/draw/tweak.c @@ -1142,7 +1142,7 @@ textedit(Thing *t, char *tag) fc = f->info; for(i=0; i<=w && i<=f->n; i++) nfc[i] = fc[i]; - if(w+1 < i) + if(i < w+1) memset(nfc+i, 0, ((w+1)-i)*sizeof(Fontchar)); x = fc[f->n].x; for(; i<=w; i++) diff --git a/src/cmd/eqn/text.c b/src/cmd/eqn/text.c index 4ca0bbd9d..6e2c83259 100644 --- a/src/cmd/eqn/text.c +++ b/src/cmd/eqn/text.c @@ -257,7 +257,7 @@ trans(int c, char *p1) char *pad(int n) /* return the padding as a string */ { - static char buf[20]; + static char buf[30]; buf[0] = 0; if (n < 0) { diff --git a/src/cmd/grap/coord.c b/src/cmd/grap/coord.c index 72f0fc3ae..ea6404589 100644 --- a/src/cmd/grap/coord.c +++ b/src/cmd/grap/coord.c @@ -35,7 +35,7 @@ void coordlog(int n) /* remember log scaling */ void coord(Obj *p) /* set coord range */ { - static char buf[10]; + static char buf[20]; ncoord++; if (ncoord > 1 && strcmp(p->name, dflt_coord) == 0) { diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c index 026641bdd..5b0c1d007 100644 --- a/src/cmd/mk/archive.c +++ b/src/cmd/mk/archive.c @@ -202,7 +202,7 @@ atimes(char *ar) name[namelen] = 0; namelen = 0; }else{ - strncpy(name, h.name, sizeof(h.name)); + memmove(name, h.name, sizeof(h.name)); for(i = sizeof(h.name)-1; i > 0 && name[i] == ' '; i--) ; if(name[i] == '/') /* system V bug */ diff --git a/src/cmd/paint/eenter.c b/src/cmd/paint/eenter.c index 6c84f2fb8..d3d68a350 100644 --- a/src/cmd/paint/eenter.c +++ b/src/cmd/paint/eenter.c @@ -78,6 +78,7 @@ eenter(char *ask, char *buf, int len, Mouse *m) b = screen; sc = b->clipr; replclipr(b, 0, b->r); + t = ZP; while(!done){ p = stringsize(font, buf ? buf : ""); diff --git a/src/cmd/pic/input.c b/src/cmd/pic/input.c index a81f622ef..92e8d62df 100644 --- a/src/cmd/pic/input.c +++ b/src/cmd/pic/input.c @@ -435,7 +435,7 @@ double errcheck(double x, char *s) return x; } -char errbuf[200]; +char errbuf[1000]; void eprint(void); diff --git a/src/cmd/pic/pic.h b/src/cmd/pic/pic.h index 928d38dd1..cdaf71e59 100644 --- a/src/cmd/pic/pic.h +++ b/src/cmd/pic/pic.h @@ -9,7 +9,7 @@ extern void yyerror(char *); -extern char errbuf[200]; +extern char errbuf[1000]; #undef sprintf /* Snow Leopard */ diff --git a/src/cmd/rio/showevent/ShowEvent.c b/src/cmd/rio/showevent/ShowEvent.c index 56f620d52..12942e112 100644 --- a/src/cmd/rio/showevent/ShowEvent.c +++ b/src/cmd/rio/showevent/ShowEvent.c @@ -68,7 +68,7 @@ Time time; unsigned long min; unsigned long hr; unsigned long day; - static char buffer[32]; + static char buffer[50]; msec = time % 1000; time /= 1000; diff --git a/src/cmd/svgpic/input.c b/src/cmd/svgpic/input.c index a81f622ef..92e8d62df 100644 --- a/src/cmd/svgpic/input.c +++ b/src/cmd/svgpic/input.c @@ -435,7 +435,7 @@ double errcheck(double x, char *s) return x; } -char errbuf[200]; +char errbuf[1000]; void eprint(void); diff --git a/src/cmd/svgpic/pic.h b/src/cmd/svgpic/pic.h index 928d38dd1..cdaf71e59 100644 --- a/src/cmd/svgpic/pic.h +++ b/src/cmd/svgpic/pic.h @@ -9,7 +9,7 @@ extern void yyerror(char *); -extern char errbuf[200]; +extern char errbuf[1000]; #undef sprintf /* Snow Leopard */ diff --git a/src/cmd/tpic/input.c b/src/cmd/tpic/input.c index 6885f6503..85b7dbb57 100644 --- a/src/cmd/tpic/input.c +++ b/src/cmd/tpic/input.c @@ -438,7 +438,7 @@ errcheck(double x, char *s) return x; } -char errbuf[200]; +char errbuf[1000]; void yyerror(char *s) diff --git a/src/cmd/tpic/pic.h b/src/cmd/tpic/pic.h index a11c74782..104cacebf 100644 --- a/src/cmd/tpic/pic.h +++ b/src/cmd/tpic/pic.h @@ -11,7 +11,7 @@ #define dprintf if(dbg)printf -extern char errbuf[200]; +extern char errbuf[1000]; #undef sprintf /* Snow Leopard */ diff --git a/src/cmd/troff/t6.c b/src/cmd/troff/t6.c index 1e0dc9683..3a2d8d85f 100644 --- a/src/cmd/troff/t6.c +++ b/src/cmd/troff/t6.c @@ -723,15 +723,15 @@ setfp(int pos, int f, char *truename, int print) /* mount font f at position pos else strcpy(shortname, (char *) unpair(f)); if (truename && strrchr(truename, '/')) { /* .fp 1 R dir/file: use verbatim */ - sprintf(pathname, "%s", truename); + snprintf(pathname, NS, "%s", truename); if (fonts[pos].truename) free(fonts[pos].truename); fonts[pos].truename = strdupl(truename); } else if (truename) { /* synonym: .fp 1 R Avant */ - sprintf(pathname, "%s/dev%s/%s", fontdir, devname, truename); + snprintf(pathname, NS, "%s/dev%s/%s", fontdir, devname, truename); truename = 0; /* so doesn't get repeated by ptfpcmd */ } else /* vanilla: .fp 5 XX */ - sprintf(pathname, "%s/dev%s/%s", fontdir, devname, shortname); + snprintf(pathname, NS, "%s/dev%s/%s", fontdir, devname, shortname); if (truename == 0 && fonts[pos].truename != 0) { free(fonts[pos].truename); fonts[pos].truename = 0; diff --git a/src/lib9/_p9dialparse.c b/src/lib9/_p9dialparse.c index 2cc23574b..4e56f5ee8 100644 --- a/src/lib9/_p9dialparse.c +++ b/src/lib9/_p9dialparse.c @@ -72,7 +72,7 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport) if((port = strchr(host, '!')) == nil){ if(strcmp(net, "unix")==0 || strcmp(net, "net")==0){ Unix: - if(strlen(host)+1 > sizeof ((struct sockaddr_un*)&ss)->sun_path){ + if(strlen(host)+1 > sizeof ((struct sockaddr_un*)ss)->sun_path){ werrstr("unix socket name too long"); return -1; } diff --git a/src/lib9/lrand.c b/src/lib9/lrand.c index 8f536456d..3d1b05fed 100644 --- a/src/lib9/lrand.c +++ b/src/lib9/lrand.c @@ -63,17 +63,15 @@ p9lrand(void) lock(&lk); - rng_tap--; - if(rng_tap < rng_vec) { - if(rng_feed == 0) { + if(rng_tap <= rng_vec) { + if(rng_feed == 0) isrand(1); - rng_tap--; - } rng_tap += LEN; } - rng_feed--; - if(rng_feed < rng_vec) + rng_tap--; + if(rng_feed <= rng_vec) rng_feed += LEN; + rng_feed--; x = (*rng_feed + *rng_tap) & MASK; *rng_feed = x; From e0c4896ed41faa71445d9e0b1751aba5157343c9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 22:28:44 -0500 Subject: [PATCH 115/323] lib9: make a p9frexp function wrapping system frexp Under certain conditions it looks like frexp gets #defined to something else on macOS during system headers, which then breaks the declaration in libc.h. --- include/libc.h | 4 +++- src/lib9/frexp.c | 9 +++++++++ src/lib9/mkfile | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/lib9/frexp.c diff --git a/include/libc.h b/include/libc.h index 94d5b5ca5..4fa86b22e 100644 --- a/include/libc.h +++ b/include/libc.h @@ -383,7 +383,7 @@ extern int encodefmt(Fmt*); extern int dirmodefmt(Fmt*); extern int exitcode(char*); extern void exits(char*); -extern double frexp(double, int*); +extern double p9frexp(double, int*); extern ulong getcallerpc(void*); #if defined(__GNUC__) || defined(__clang__) #define getcallerpc(x) ((ulong)__builtin_return_address(0)) @@ -436,6 +436,8 @@ extern void (*_unpin)(void); #define atoll p9atoll #define encrypt p9encrypt #define decrypt p9decrypt +#undef frexp +#define frexp p9frexp #define getenv p9getenv #define getwd p9getwd #define longjmp p9longjmp diff --git a/src/lib9/frexp.c b/src/lib9/frexp.c new file mode 100644 index 000000000..fe3e2f73f --- /dev/null +++ b/src/lib9/frexp.c @@ -0,0 +1,9 @@ +#include +#define NOPLAN9DEFINES +#include + +double +p9frexp(double d, int *i) +{ + return frexp(d, i); +} diff --git a/src/lib9/mkfile b/src/lib9/mkfile index 943b597b9..7c37de420 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -22,6 +22,7 @@ FMTOFILES=\ fmtstr.$O\ fmtvprint.$O\ fprint.$O\ + frexp.$O\ nan64.$O\ print.$O\ runefmtstr.$O\ From 0158bceec78c7891a7ef672770bf42e65fd064dd Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 22:47:51 -0500 Subject: [PATCH 116/323] libthread: run first thread in proc on system stack For pthread systems that are fussy about which stack is used, this makes sure that threadmain runs on a system stack. If you only use proccreate (never threadcreate), all threads run on system stacks. --- man/man3/thread.3 | 8 +++++ src/libthread/test/tspawnloop.c | 4 +-- src/libthread/thread.c | 59 +++++++++++++++++++++++++-------- src/libthread/threadimpl.h | 1 - 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/man/man3/thread.3 b/man/man3/thread.3 index 0ebbddd0a..9088ae2e7 100644 --- a/man/man3/thread.3 +++ b/man/man3/thread.3 @@ -169,6 +169,14 @@ initialized to the desired value .B mainstacksize .B = .BR 1024 ). +When using the +.I pthread +library, +.B mainstacksize +is ignored, as is the stack size argument to +.BR proccreate : +the first thread in each proc +runs on the native system stack. .PP .I Threadcreate creates a new thread in the calling proc, returning a unique integer diff --git a/src/libthread/test/tspawnloop.c b/src/libthread/test/tspawnloop.c index 05636dc91..204328b8b 100644 --- a/src/libthread/test/tspawnloop.c +++ b/src/libthread/test/tspawnloop.c @@ -8,7 +8,7 @@ execproc(void *v) int i, fd[3]; char buf[100], *args[3]; - i = (int)v; + i = (int)(uintptr)v; sprint(buf, "%d", i); fd[0] = dup(0, -1); fd[1] = dup(1, -1); @@ -33,7 +33,7 @@ threadmain(int argc, char **argv) c = threadwaitchan(); for(i=0;; i++){ - proccreate(execproc, (void*)i, 16384); + proccreate(execproc, (void*)(uintptr)i, 16384); w = recvp(c); if(w == nil) sysfatal("exec/recvp failed: %r"); diff --git a/src/libthread/thread.c b/src/libthread/thread.c index cbad185c4..c84af855c 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -16,6 +16,7 @@ static int onlist(_Threadlist*, _Thread*); static void addthreadinproc(Proc*, _Thread*); static void delthreadinproc(Proc*, _Thread*); static void contextswitch(Context *from, Context *to); +static void procmain(Proc*); static void procscheduler(Proc*); static int threadinfo(void*, char*); @@ -112,8 +113,6 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) if(t == nil) sysfatal("threadalloc malloc: %r"); memset(t, 0, sizeof *t); - t->stk = (uchar*)(t+1); - t->stksize = stack; t->id = incref(&threadidref); //print("fn=%p arg=%p\n", fn, arg); t->startfn = fn; @@ -121,6 +120,10 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) //print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); /* do a reasonable initialization */ + if(stack == 0) + return t; + t->stk = (uchar*)(t+1); + t->stksize = stack; memset(&t->context.uc, 0, sizeof t->context.uc); sigemptyset(&zero); sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask); @@ -165,6 +168,8 @@ _threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) if(stack < (256<<10)) stack = 256<<10; + if(p->nthread == 0) + stack = 0; // not using it t = threadalloc(fn, arg, stack); t->proc = p; addthreadinproc(p, t); @@ -192,7 +197,7 @@ proccreate(void (*fn)(void*), void *arg, uint stack) p = procalloc(); t = _threadcreate(p, fn, arg, stack); id = t->id; /* t might be freed after _procstart */ - _procstart(p, procscheduler); + _procstart(p, procmain); return id; } @@ -204,7 +209,10 @@ _threadswitch(void) needstack(0); p = proc(); /*print("threadswtch %p\n", p); */ - contextswitch(&p->thread->context, &p->schedcontext); + if(p->thread->stk == nil) + procscheduler(p); + else + contextswitch(&p->thread->context, &p->schedcontext); } void @@ -311,15 +319,43 @@ contextswitch(Context *from, Context *to) } } +static void +procmain(Proc *p) +{ + _Thread *t; + + _threadsetproc(p); + + /* take out first thread to run on system stack */ + t = p->runqueue.head; + delthread(&p->runqueue, t); + memset(&t->context.uc, 0, sizeof t->context.uc); + + /* run it */ + p->thread = t; + t->startfn(t->startarg); + if(p->nthread != 0) + threadexits(nil); +} + static void procscheduler(Proc *p) { _Thread *t; - setproc(p); _threaddebug("scheduler enter"); //print("s %p\n", p); +Top: lock(&p->lock); + t = p->thread; + p->thread = nil; + if(t->exiting){ + delthreadinproc(p, t); + p->nthread--; +/*print("nthread %d\n", p->nthread); */ + free(t); + } + for(;;){ if((t = p->pinthread) != nil){ while(!onlist(&p->runqueue, t)){ @@ -356,16 +392,11 @@ procscheduler(Proc *p) p->nswitch++; _threaddebug("run %d (%s)", t->id, t->name); //print("run %p %p %p %p\n", t, *(uintptr*)(t->context.uc.mc.sp), t->context.uc.mc.di, t->context.uc.mc.si); + if(t->stk == nil) + return; contextswitch(&p->schedcontext, &t->context); /*print("back in scheduler\n"); */ - p->thread = nil; - lock(&p->lock); - if(t->exiting){ - delthreadinproc(p, t); - p->nthread--; -/*print("nthread %d\n", p->nthread); */ - free(t); - } + goto Top; } Out: @@ -749,7 +780,7 @@ main(int argc, char **argv) mainstacksize = 256*1024; atnotify(threadinfo, 1); _threadcreate(p, threadmainstart, nil, mainstacksize); - procscheduler(p); + procmain(p); sysfatal("procscheduler returned in threadmain!"); /* does not return */ return 0; diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index a8d52704d..437503c68 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -187,7 +187,6 @@ struct Proc }; #define proc() _threadproc() -#define setproc(p) _threadsetproc(p) extern Proc *_threadprocs; extern Lock _threadprocslock; From 0b6b451b71bc116c8b98cdbbfbec3fbca6c8fc17 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 22:49:02 -0500 Subject: [PATCH 117/323] libdraw: fix "mk" Should default to building the library, not getsubfont.o. --- src/libdraw/mkfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libdraw/mkfile b/src/libdraw/mkfile index fab6295b8..68d7d1b1c 100644 --- a/src/libdraw/mkfile +++ b/src/libdraw/mkfile @@ -70,7 +70,6 @@ HFILES=\ $PLAN9/include/mouse.h\ $PLAN9/include/keyboard.h\ -getsubfont.$O: defont.h - <$PLAN9/src/mksyslib +getsubfont.$O: defont.h From 386bd9cae471438a685234556111a01a666ca165 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 7 Jan 2020 17:17:39 +0000 Subject: [PATCH 118/323] cmd/venti/srv: split memory allocation call This splits a certain vtmallocz call in mkihash into two vtmallocz calls. The first issue this fixes is that the C aliasing rules were not respected in the code before this commit. The other thing is that this enables better memory alignment guarantees. Updates #313 Change-Id: Ia4f3e0fc85facc778193f5e977d4f99a1a9abd23 --- src/cmd/venti/srv/icache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/venti/srv/icache.c b/src/cmd/venti/srv/icache.c index 3663345de..700da7548 100644 --- a/src/cmd/venti/srv/icache.c +++ b/src/cmd/venti/srv/icache.c @@ -68,8 +68,8 @@ mkihash(int size1) size <<= 1; } - ih = vtmallocz(sizeof(IHash)+size*sizeof(ih->table[0])); - ih->table = (IEntry**)(ih+1); + ih = vtmallocz(sizeof(IHash)); + ih->table = vtmallocz(size * sizeof(ih->table[0])); ih->bits = bits; ih->size = size; return ih; From 185fd7db0513a14c91749bfab3fe7dc30a64f480 Mon Sep 17 00:00:00 2001 From: Edouard Klein Date: Thu, 23 May 2019 13:04:10 +0200 Subject: [PATCH 119/323] Make venti's doc more accurate --- man/man8/vbackup.8 | 2 +- man/man8/venti.8 | 31 ++++++++++++++++++++++++------- src/cmd/venti/srv/printarena.c | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/man/man8/vbackup.8 b/man/man8/vbackup.8 index 89da1da57..26ab9178b 100644 --- a/man/man8/vbackup.8 +++ b/man/man8/vbackup.8 @@ -394,7 +394,7 @@ Mount the backups on a client machine using .IR vmount : .IP .EX -# vmount udp!yourserver!nfs /dump +# vmount yourserver /dump # ls /dump/bob/2005 0510 0511 diff --git a/man/man8/venti.8 b/man/man8/venti.8 index d95edaa9b..4fd40df66 100644 --- a/man/man8/venti.8 +++ b/man/man8/venti.8 @@ -272,12 +272,30 @@ Set to .IR value . .TP -.BI /graph/ name / param / param / \fR... -A PNG image graphing the named run-time statistic over time. -The details of names and parameters are undocumented; -see +.BI /graph?arg= name [&arg2= name] &graph= type ¶m= value \fR... +A PNG image graphing the +.IT name +run-time statistic over time. +The details of names and parameters are mostly undocumented; +see the +.BR graphname +array in .B httpd.c -in the venti sources. +in the venti code for a list of possible statistics. The +.IR type +of graph defaults to raw, see the +.BR xgraph +function for a list of types. Possible +.IR param +include the timeframe +.BR (t0 +and +.BR t1) +, the y limits +.BR (min +and +.BR max) + etc. .TP .B /log A list of all debugging logs present in the server's memory. @@ -376,8 +394,7 @@ network address to announce venti service .TP .BI httpaddr " netaddr network address to announce HTTP service -(default -.BR tcp!*!http ) +(default is not to start the service) .TP .B queuewrites queue writes in memory diff --git a/src/cmd/venti/srv/printarena.c b/src/cmd/venti/srv/printarena.c index 399385caf..8650115f2 100644 --- a/src/cmd/venti/srv/printarena.c +++ b/src/cmd/venti/srv/printarena.c @@ -5,7 +5,7 @@ void usage(void) { - fprint(2, "usage: printarena arenafile [offset]\n"); + fprint(2, "usage: printarena [-o aoffset] arenafile [offset]\n"); threadexitsall("usage"); } From cc48e73a96c863784fb0bc46e69bccf509890827 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Mon, 13 Jan 2020 10:02:13 -0600 Subject: [PATCH 120/323] fontsrv: allow x11 hinting and disable autohint only (#254) Some truetype fonts have good manual hinting. Ignoring hinting makes the font render badly on low resolution screens. This commit only disables the freetype autohinter, and allows hinting. --- src/cmd/fontsrv/x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 4137f9ca4..0f6b97bbf 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -176,7 +176,7 @@ mksubfont(XFont *xf, char *name, int lo, int hi, int size, int antialias) e = 1; k = FT_Get_Char_Index(face, i); if(k != 0) { - e = FT_Load_Glyph(face, k, FT_LOAD_RENDER|FT_LOAD_NO_HINTING|(antialias ? 0:FT_LOAD_TARGET_MONO)); + e = FT_Load_Glyph(face, k, FT_LOAD_RENDER|FT_LOAD_NO_AUTOHINT|(antialias ? 0:FT_LOAD_TARGET_MONO)); } if(e || face->glyph->advance.x <= 0) { fc->width = 0; From fa7fecff33769e27653a51d1d15909d2b538194b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 11:04:53 -0500 Subject: [PATCH 121/323] wintext: add tmux support, use in ", "" Fixes #223. --- bin/quote1 | 11 +---------- bin/quote2 | 2 +- bin/wintext | 8 +++++++- man/man1/wintext.1 | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/bin/quote1 b/bin/quote1 index e0f7c8f93..f52480fd1 100755 --- a/bin/quote1 +++ b/bin/quote1 @@ -2,19 +2,10 @@ . 9.rc -fn text { - if(~ $winid [0-9]*) - 9p read acme/$winid/body - if not if(~ $text9term unix!*) - dial -e $text9term [1=2] exit notfound diff --git a/bin/wintext b/bin/wintext index 93fe40ea4..80a899576 100755 --- a/bin/wintext +++ b/bin/wintext @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash case "$winid" in [0-9]*) @@ -12,5 +12,11 @@ unix!*) exit 0 esac +case "$TMUX" in +?*) + tmux capture-pane -p + exit 0 +esac + echo 'no running window found' 2>&1 exit 1 diff --git a/man/man1/wintext.1 b/man/man1/wintext.1 index 12859f259..966b307b4 100644 --- a/man/man1/wintext.1 +++ b/man/man1/wintext.1 @@ -3,17 +3,17 @@ wintext, ", "" \- access text in current window .ds x \C'"' .ds xx \C'"'\^\^\^\^\C'"' -.ds y \*x\ -.ds yy \*(xx\ +.ds y \*x\^ +.ds yy \*(xx\^ .SH SYNOPSIS .B wintext .br -.B \*x\ +.B \*y [ .I prefix ] .br -.B \*(xx\ +.B \*(yy [ .I prefix ] @@ -22,9 +22,11 @@ wintext, ", "" \- access text in current window prints the text of the current .I win (see -.IR acme (1)) +.IR acme (1)), +.IR 9term (1), or -.IR 9term (1) +(Unix's) +.IR tmux (1) window to standard output. .PP .I \*y @@ -40,7 +42,7 @@ prints the last command executed. .I \*(yy prints the last command that .I \*y -would print and then executes it by piping it into +would print and then executes it by piping it into .IR rc (1). .PP Both @@ -82,7 +84,7 @@ command again: % \*(xx lc % lc r* ramfs rc read rio rm -% +% .EE .SH SEE ALSO .IR 9term (1), From d96e9e5dc39a356febed132703e46bf73bac6850 Mon Sep 17 00:00:00 2001 From: jvd23 <46013531+jvd23@users.noreply.github.com> Date: Mon, 13 Jan 2020 11:37:48 -0500 Subject: [PATCH 122/323] lib9: fix memory leak in dial of regular file (#284) --- src/lib9/dial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib9/dial.c b/src/lib9/dial.c index c3dd17624..81e3a830e 100644 --- a/src/lib9/dial.c +++ b/src/lib9/dial.c @@ -141,8 +141,10 @@ p9dial(char *addr, char *local, char *dummy2, int *dummy3) return -1; } /* Allow regular files in addition to Unix sockets. */ - if((s = open(unix, ORDWR)) >= 0) + if((s = open(unix, ORDWR)) >= 0){ + free(buf); return s; + } free(buf); if((s = socket(ss.ss_family, SOCK_STREAM, 0)) < 0){ werrstr("socket: %r"); From 7ba9f9467d95fa8d05bb04d36fd4c602e497f529 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 11:41:37 -0500 Subject: [PATCH 123/323] lib9/fmt: avoid racy access to installed fmt formats --- src/lib9/fmt/fmt.c | 35 ++++++++++++++++++++++------------- src/lib9/fmt/fmtdef.h | 6 ++++-- src/lib9/fmt/fmtlock.c | 14 ++++++++++++-- src/lib9/fmtlock2.c | 22 +++++++++++++++++----- 4 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index 66093fd0d..9c3f45d3b 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c @@ -72,7 +72,7 @@ static Convfmt knownfmt[] = { int (*fmtdoquote)(int); /* - * __fmtlock() must be set + * __fmtwlock() must be set */ static int __fmtinstall(int c, Fmts f) @@ -106,34 +106,43 @@ fmtinstall(int c, int (*f)(Fmt*)) { int ret; - __fmtlock(); + __fmtwlock(); ret = __fmtinstall(c, f); - __fmtunlock(); + __fmtwunlock(); return ret; } static Fmts fmtfmt(int c) { - Convfmt *p, *ep; + Convfmt *p, *ep, *kp; + /* conflict-free check - common case */ + __fmtrlock(); ep = &fmtalloc.fmt[fmtalloc.nfmt]; for(p=fmtalloc.fmt; pc == c){ - while(p->fmt == nil) /* loop until value is updated */ - ; + __fmtrunlock(); return p->fmt; } + __fmtrunlock(); /* is this a predefined format char? */ - __fmtlock(); - for(p=knownfmt; p->c; p++) - if(p->c == c){ - __fmtinstall(p->c, p->fmt); - __fmtunlock(); - return p->fmt; + for(kp=knownfmt; kp->c; kp++){ + if(kp->c == c){ + __fmtwlock(); + /* double-check fmtinstall didn't happen */ + for(p=fmtalloc.fmt; pc == c){ + __fmtwunlock(); + return p->fmt; + } + } + __fmtinstall(kp->c, kp->fmt); + __fmtwunlock(); + return kp->fmt; } - __fmtunlock(); + } return __badfmt; } diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h index 5c8eb2cbd..d547184d3 100644 --- a/src/lib9/fmt/fmtdef.h +++ b/src/lib9/fmt/fmtdef.h @@ -33,11 +33,13 @@ int __fmtFdFlush(Fmt *f); int __fmtcpy(Fmt *f, const void *vm, int n, int sz); void* __fmtdispatch(Fmt *f, void *fmt, int isrunes); void * __fmtflush(Fmt *f, void *t, int len); -void __fmtlock(void); int __fmtpad(Fmt *f, int n); double __fmtpow10(int n); int __fmtrcpy(Fmt *f, const void *vm, int n); -void __fmtunlock(void); +void __fmtrlock(void); +void __fmtrunlock(void); +void __fmtwlock(void); +void __fmtwunlock(void); int __ifmt(Fmt *f); int __isInf(double d, int sign); int __isNaN(double d); diff --git a/src/lib9/fmt/fmtlock.c b/src/lib9/fmt/fmtlock.c index cabe05f4a..eb9cd8451 100644 --- a/src/lib9/fmt/fmtlock.c +++ b/src/lib9/fmt/fmtlock.c @@ -5,11 +5,21 @@ #include "fmtdef.h" void -__fmtlock(void) +__fmtrlock(void) { } void -__fmtunlock(void) +__fmtrunlock(void) +{ +} + +void +__fmtwlock(void) +{ +} + +void +__fmtwunlock(void) { } diff --git a/src/lib9/fmtlock2.c b/src/lib9/fmtlock2.c index d711e6d48..b755daa38 100644 --- a/src/lib9/fmtlock2.c +++ b/src/lib9/fmtlock2.c @@ -1,16 +1,28 @@ #include #include -static Lock fmtlock; +static RWLock fmtlock; void -__fmtlock(void) +__fmtrlock(void) { - lock(&fmtlock); + rlock(&fmtlock); } void -__fmtunlock(void) +__fmtrunlock(void) { - unlock(&fmtlock); + runlock(&fmtlock); +} + +void +__fmtwlock(void) +{ + wlock(&fmtlock); +} + +void +__fmtwunlock(void) +{ + wunlock(&fmtlock); } From 4a3f20bceee7cef125f9a88bab32439f9fe4f773 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Thu, 22 Aug 2019 11:28:53 +0000 Subject: [PATCH 124/323] cmd/yacc: do not create an out of bounds pointer An out of bounds pointer/array index being created is an error in standard C. Updates #313 Change-Id: I7108fcde1a8e03017e9ab852adb737940489c827 --- src/cmd/yacc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/yacc.c b/src/cmd/yacc.c index 32990f62b..5db36d04b 100644 --- a/src/cmd/yacc.c +++ b/src/cmd/yacc.c @@ -2819,8 +2819,9 @@ stin(int i) for(n = -maxoff; n < ACTSIZE; n++) { flag = 0; for(r = q1; r < q2; r += 2) { - if((s = *r + n + amem) < amem) + if(*r + n < 0) goto nextn; + s = *r + n + amem; if(*s == 0) flag++; else From d2fae53d17c120530a6d12facd8e0fc297331821 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 25 Aug 2019 09:52:22 +0000 Subject: [PATCH 125/323] cmd/yacc: check for EOF in string constant in cpyact Change-Id: I3b41ab3f181080bcff89201d30f0bdf8aa20d55c --- src/cmd/yacc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/yacc.c b/src/cmd/yacc.c index 5db36d04b..7558bf3ba 100644 --- a/src/cmd/yacc.c +++ b/src/cmd/yacc.c @@ -2124,7 +2124,7 @@ cpyact(int offset) string: Bputrune(faction, c); - while(c = Bgetrune(finput)) { + while((c = Bgetrune(finput)) >= 0) { if(c == '\\') { Bputrune(faction, c); c = Bgetrune(finput); From eb4aea5072dcca2dfee2ff4d551352dae73a821c Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 25 Aug 2019 13:53:10 +0000 Subject: [PATCH 126/323] cmd/yacc: check that arg is safe to pass to isX functions The functions from require that their argument be representable as an unsigned char, anything else is an error. Change-Id: I9dafc49c431b7a2550b041603f27bac3c0010eea --- src/cmd/yacc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/cmd/yacc.c b/src/cmd/yacc.c index 7558bf3ba..32698c2a9 100644 --- a/src/cmd/yacc.c +++ b/src/cmd/yacc.c @@ -349,6 +349,7 @@ void finact(void); int defin(int, char*); void defout(int); char* cstash(char*); +int isvalidchar(long); long gettok(void); int fdtype(int); int chfind(int, char*); @@ -1680,6 +1681,12 @@ cstash(char *s) return temp; } +int +isvalidchar(long i) +{ + return (i & ~0xffUL) == 0; +} + long gettok(void) { @@ -1774,6 +1781,8 @@ gettok(void) default: /* number */ + if(!isvalidchar(c)) + return c; if(isdigit(c)) { numbval = c-'0'; base = (c=='0')? 8: 10; @@ -1784,8 +1793,8 @@ gettok(void) } if(islower(c) || isupper(c) || c=='_' || c=='.' || c=='$') { i = 0; - while(islower(c) || isupper(c) || isdigit(c) || - c == '-' || c=='_' || c=='.' || c=='$') { + while(isvalidchar(c) && (islower(c) || isupper(c) || isdigit(c) || + c == '-' || c=='_' || c=='.' || c=='$')) { if(reserve && isupper(c)) c += 'a'-'A'; rune = c; @@ -2028,7 +2037,7 @@ cpyact(int offset) s = -s; c = Bgetrune(finput); } - if(isdigit(c)) { + if(isvalidchar(c) && isdigit(c)) { j = 0; while(isdigit(c)) { j = j*10 + (c-'0'); @@ -2052,7 +2061,7 @@ cpyact(int offset) } goto loop; } - if(isupper(c) || islower(c) || c == '_' || c == '.') { + if(isvalidchar(c) && (isupper(c) || islower(c) || c == '_' || c == '.')) { int tok; /* tok used oustide for type info */ /* look for $name */ @@ -2963,7 +2972,7 @@ gtnm(void) sign = 0; val = 0; while((c=Bgetrune(finput)) != Beof) { - if(isdigit(c)) { + if(isvalidchar(c) && isdigit(c)) { val = val*10 + c-'0'; continue; } From bf59f0ed282f9c9b1ae0660e5af0ac86c0d247b5 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Sun, 25 Aug 2019 14:30:36 +0000 Subject: [PATCH 127/323] cmd/yacc: correctly detect end of file in gettok This prevents an infinite loop. Change-Id: I7eda6b9d032ca0daeb24b555954330d07f35c78b --- src/cmd/yacc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/yacc.c b/src/cmd/yacc.c index 32698c2a9..bd3f6aa4d 100644 --- a/src/cmd/yacc.c +++ b/src/cmd/yacc.c @@ -1805,6 +1805,8 @@ gettok(void) } } else return c; + if(c == Beof) + return ENDFILE; Bungetrune(finput); } tokname[i] = 0; From cc3d97d52a72d7eaceb5b636bcdf81c3e19f7a2e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 22:49:36 -0500 Subject: [PATCH 128/323] devdraw: update drawclient test program to run again --- src/cmd/devdraw/drawclient.c | 15 +++++++-------- src/cmd/devdraw/mkfile | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cmd/devdraw/drawclient.c b/src/cmd/devdraw/drawclient.c index f61392894..71c7142d1 100644 --- a/src/cmd/devdraw/drawclient.c +++ b/src/cmd/devdraw/drawclient.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include typedef struct Cmd Cmd; struct Cmd { @@ -29,7 +29,7 @@ startsrv(void) close(p[0]); dup(p[1], 0); dup(p[1], 1); - execl("o.drawsrv", "o.drawsrv", "-D", nil); + execl("./o.devdraw", "o.devdraw", "-D", nil); sysfatal("exec: %r"); } close(p[1]); @@ -47,7 +47,7 @@ fprint(2, "write %d to %d\n", n, fd); n = readwsysmsg(fd, buf, sizeof buf); nn = convM2W(buf, n, m); assert(nn == n); - if(m->op == Rerror) + if(m->type == Rerror) return -1; return 0; } @@ -58,10 +58,9 @@ cmdinit(int argc, char **argv) Wsysmsg m; memset(&m, 0, sizeof m); - m.op = Tinit; + m.type = Tinit; m.winsize = "100x100"; m.label = "label"; - m.font = ""; if(domsg(&m) < 0) sysfatal("domsg"); } @@ -72,7 +71,7 @@ cmdmouse(int argc, char **argv) Wsysmsg m; memset(&m, 0, sizeof m); - m.op = Trdmouse; + m.type = Trdmouse; if(domsg(&m) < 0) sysfatal("domsg"); print("%c %d %d %d\n", @@ -88,10 +87,10 @@ cmdkbd(int argc, char **argv) Wsysmsg m; memset(&m, 0, sizeof m); - m.op = Trdkbd; + m.type = Trdkbd; if(domsg(&m) < 0) sysfatal("domsg"); - print("%s\n", m.runes); + print("%d\n", m.rune); } Cmd cmdtab[] = { diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index 7f0c2a203..e60b427f3 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -20,7 +20,7 @@ HFILES=\ <$PLAN9/src/mkone -$O.drawclient: drawclient.$O drawfcall.$O +$O.drawclient: drawclient.$O $LD -o $target $prereq $O.snarf: x11-alloc.$O x11-cload.$O x11-draw.$O x11-fill.$O x11-get.$O x11-init.$O x11-itrans.$O x11-keysym2ucs.$O x11-load.$O x11-pixelbits.$O x11-unload.$O x11-wsys.$O snarf.$O latin1.$O devdraw.$O From f177c0ba18193fb89ad1b5d84eac2906e8c3b4f1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 19:49:33 -0500 Subject: [PATCH 129/323] devdraw: drop pre-metal macOS support We didn't start using Metal until macOS 10.14, but it was available on 10.13, which is currently the oldest Apple-supported version of macOS. Simplify by deleting the old code. --- src/cmd/devdraw/cocoa-screen.m | 1674 -------------------------------- src/cmd/devdraw/macargv.m | 3 - src/cmd/devdraw/mkwsysrules.sh | 16 +- 3 files changed, 5 insertions(+), 1688 deletions(-) delete mode 100644 src/cmd/devdraw/cocoa-screen.m diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m deleted file mode 100644 index 97128da21..000000000 --- a/src/cmd/devdraw/cocoa-screen.m +++ /dev/null @@ -1,1674 +0,0 @@ -/* - * Cocoa's event loop must be in main thread. - * - * Unless otherwise stated, all coordinate systems - * are bottom-left-based. - */ - -#define Cursor OSXCursor -#define Point OSXPoint -#define Rect OSXRect - -#import - -#undef Cursor -#undef Point -#undef Rect - -#include -#include -#include "cocoa-thread.h" -#include -#include -#include -#include -#include "cocoa-screen.h" -#include "osx-keycodes.h" -#include "devdraw.h" -#include "bigarrow.h" -#include "glendapng.h" - -// Use non-deprecated names. -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 -#define NSKeyDown NSEventTypeKeyDown -#define NSShiftKeyMask NSEventModifierFlagShift -#define NSAlternateKeyMask NSEventModifierFlagOption -#define NSCommandKeyMask NSEventModifierFlagCommand -#define NSResizableWindowMask NSWindowStyleMaskResizable -#define NSLeftMouseDown NSEventTypeLeftMouseDown -#define NSLeftMouseUp NSEventTypeLeftMouseUp -#define NSRightMouseDown NSEventTypeRightMouseDown -#define NSRightMouseUp NSEventTypeRightMouseUp -#define NSOtherMouseDown NSEventTypeOtherMouseDown -#define NSOtherMouseUp NSEventTypeOtherMouseUp -#define NSScrollWheel NSEventTypeScrollWheel -#define NSMouseMoved NSEventTypeMouseMoved -#define NSLeftMouseDragged NSEventTypeLeftMouseDragged -#define NSRightMouseDragged NSEventTypeRightMouseDragged -#define NSOtherMouseDragged NSEventTypeOtherMouseDragged -#define NSCompositeCopy NSCompositingOperationCopy -#define NSCompositeSourceIn NSCompositingOperationSourceIn -#define NSFlagsChanged NSEventTypeFlagsChanged -#define NSTitledWindowMask NSWindowStyleMaskTitled -#define NSClosableWindowMask NSWindowStyleMaskClosable -#define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable -#define NSBorderlessWindowMask NSWindowStyleMaskBorderless -#endif - -AUTOFRAMEWORK(Cocoa) - -#define LOG if(0)NSLog -#define panic sysfatal - -int usegestures = 0; -int useliveresizing = 0; -int useoldfullscreen = 0; -int usebigarrow = 0; - -static void setprocname(const char*); - -/* - * By default, devdraw uses retina displays. - * Set devdrawretina=0 in the environment to override. - */ -int devdrawretina = 1; - -void -usage(void) -{ - fprint(2, "usage: devdraw (don't run directly)\n"); - threadexitsall("usage"); -} - -@interface appdelegate : NSObject @end - -NSObject *myApp; - -void -threadmain(int argc, char **argv) -{ - char *envvar; - - /* - * Move the protocol off stdin/stdout so that - * any inadvertent prints don't screw things up. - */ - dup(0,3); - dup(1,4); - close(0); - close(1); - open("/dev/null", OREAD); - open("/dev/null", OWRITE); - - ARGBEGIN{ - case 'D': /* for good ps -a listings */ - break; - case 'f': - useoldfullscreen = 1; - break; - case 'g': - usegestures = 1; - break; - case 'b': - usebigarrow = 1; - break; - default: - usage(); - }ARGEND - - setprocname(argv0); - - if (envvar = getenv("devdrawretina")) - devdrawretina = atoi(envvar) > 0; - - if(OSX_VERSION < 100700) - [NSAutoreleasePool new]; - - [NSApplication sharedApplication]; - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - myApp = [appdelegate new]; - [NSApp setDelegate:myApp]; - [NSApp run]; -} - -#define WIN win.ofs[win.isofs] - -struct -{ - NSWindow *ofs[2]; /* ofs[1] for old fullscreen; ofs[0] else */ - int isofs; - int isnfs; - NSView *content; - NSBitmapImageRep *img; - int needimg; - int deferflush; - NSCursor *cursor; - CGFloat topointscale; - CGFloat topixelscale; -} win; - -struct -{ - NSCursor *bigarrow; - int kbuttons; - int mbuttons; - NSPoint mpos; - int mscroll; - int willactivate; -} in; - -static void hidebars(int); -static void flushimg(NSRect); -static void autoflushwin(int); -static void flushwin(void); -static void followzoombutton(NSRect); -static void getmousepos(void); -static void makeicon(void); -static void makemenu(void); -static void makewin(char*); -static void sendmouse(void); -static void kicklabel0(char*); -static void setcursor0(Cursor*); -static void togglefs(void); -static void acceptresizing(int); - -static NSCursor* makecursor(Cursor*); - -static NSSize winsizepixels(); -static NSSize winsizepoints(); -static NSRect scalerect(NSRect, CGFloat); -static NSPoint scalepoint(NSPoint, CGFloat); -static NSRect dilate(NSRect); - -@implementation appdelegate -- (void)applicationDidFinishLaunching:(id)arg -{ - in.bigarrow = makecursor(&bigarrow); - makeicon(); - makemenu(); - [NSApplication - detachDrawingThread:@selector(callservep9p:) - toTarget:[self class] withObject:nil]; -} - -- (void)windowDidBecomeKey:(id)arg -{ - getmousepos(); - sendmouse(); -} -- (void)windowDidResize:(id)arg -{ - getmousepos(); - sendmouse(); -} -- (void)windowWillStartLiveResize:(id)arg -{ - if(useliveresizing == 0) - [win.content setHidden:YES]; -} -- (void)windowDidEndLiveResize:(id)arg -{ - if(useliveresizing == 0) - [win.content setHidden:NO]; -} -- (void)windowDidChangeScreen:(id)arg -{ - if(win.isnfs || win.isofs) - hidebars(1); - [win.ofs[1] setFrame:[[WIN screen] frame] display:YES]; -} -- (BOOL)windowShouldZoom:(id)arg toFrame:(NSRect)r -{ - followzoombutton(r); - return YES; -} -- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(id)arg -{ - return YES; -} -- (void)applicationDidBecomeActive:(id)arg{ in.willactivate = 0;} -- (void)windowWillEnterFullScreen:(id)arg{ acceptresizing(1);} -- (void)windowDidEnterFullScreen:(id)arg{ win.isnfs = 1; hidebars(1);} -- (void)windowWillExitFullScreen:(id)arg{ win.isnfs = 0; hidebars(0);} -- (void)windowDidExitFullScreen:(id)arg -{ - NSButton *b; - - b = [WIN standardWindowButton:NSWindowMiniaturizeButton]; - - if([b isEnabled] == 0){ - [b setEnabled:YES]; - hidebars(0); - } -} -- (void)windowWillClose:(id)arg -{ - autoflushwin(0); /* can crash otherwise */ -} - -+ (void)callservep9p:(id)arg -{ - servep9p(); - [NSApp terminate:self]; -} -- (void)plumbmanual:(id)arg -{ - if(fork() != 0) - return; - execl("plumb", "plumb", "devdraw(1)", nil); -} -+ (void)callflushwin:(id)arg{ flushwin();} -- (void)calltogglefs:(id)arg{ togglefs();} - -+ (void)callflushimg:(NSValue*)v{ flushimg([v rectValue]);} -+ (void)callmakewin:(NSValue*)v{ makewin([v pointerValue]);} -+ (void)callsetcursor0:(NSValue*)v{ setcursor0([v pointerValue]);} -+ (void)callkicklabel0:(NSValue*)v{ kicklabel0([v pointerValue]);} -@end - -static Memimage* initimg(void); - -Memimage* -attachscreen(char *label, char *winsize) -{ - static int first = 1; - - if(first) - first = 0; - else - panic("attachscreen called twice"); - - if(label == nil) - label = "gnot a label"; - if(strcmp(label, "page") == 0) - useliveresizing = 1; - - /* - * Create window in main thread, else no cursor - * change while resizing. - */ - [appdelegate - performSelectorOnMainThread:@selector(callmakewin:) - withObject:[NSValue valueWithPointer:winsize] - waitUntilDone:YES]; -// makewin(winsize); - - kicklabel(label); - return initimg(); -} - -@interface appwin : NSWindow @end -@interface contentview : NSView @end - -@implementation appwin -- (NSTimeInterval)animationResizeTime:(NSRect)r -{ - return 0; -} -- (BOOL)canBecomeKeyWindow -{ - return YES; /* else no keyboard for old fullscreen */ -} -- (void)makeKeyAndOrderFront:(id)arg -{ - LOG(@"makeKeyAndOrderFront"); - - autoflushwin(1); - [win.content setHidden:NO]; - [super makeKeyAndOrderFront:arg]; -} -- (void)miniaturize:(id)arg -{ - [super miniaturize:arg]; - [NSApp hide:nil]; - - [win.content setHidden:YES]; - autoflushwin(0); -} -- (void)deminiaturize:(id)arg -{ - autoflushwin(1); - [win.content setHidden:NO]; - [super deminiaturize:arg]; -} - -- (NSDragOperation)draggingEntered:(id)arg -{ - NSPasteboard *b; - NSDragOperation op; - - op = [arg draggingSourceOperationMask]; - b = [arg draggingPasteboard]; - - if([[b types] containsObject:NSFilenamesPboardType]) - if(op&NSDragOperationLink) - return NSDragOperationLink; - - return NSDragOperationNone; -} - -- (BOOL)performDragOperation:(id)arg -{ - NSPasteboard *b; - NSArray *files; - int i, n; - - b = [arg draggingPasteboard]; - if(![[b types] containsObject:NSFilenamesPboardType]) - return NO; - - files = [b propertyListForType:NSFilenamesPboardType]; - n = [files count]; - for(i=0; i= 100700 - [w setCollectionBehavior: - NSWindowCollectionBehaviorFullScreenPrimary]; -#endif - [w setContentMinSize:NSMakeSize(128,128)]; - - [w registerForDraggedTypes:[NSArray arrayWithObjects: - NSFilenamesPboardType, nil]]; - - win.ofs[0] = w; - win.ofs[1] = [[appwin alloc] - initWithContentRect:sr - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered defer:YES]; - for(i=0; i<2; i++){ - [win.ofs[i] setAcceptsMouseMovedEvents:YES]; - [win.ofs[i] setDelegate:myApp]; - [win.ofs[i] setDisplaysWhenScreenProfileChanges:NO]; - } - win.isofs = 0; - win.content = [contentview new]; - [WIN setContentView:win.content]; - - topwin(); -} - -static Memimage* -initimg(void) -{ - Memimage *i; - NSSize size, ptsize; - Rectangle r; - - size = winsizepixels(); - LOG(@"initimg %.0f %.0f", size.width, size.height); - - r = Rect(0, 0, size.width, size.height); - i = allocmemimage(r, XBGR32); - if(i == nil) - panic("allocmemimage: %r"); - if(i->data == nil) - panic("i->data == nil"); - - win.img = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:&i->data->bdata - pixelsWide:Dx(r) - pixelsHigh:Dy(r) - bitsPerSample:8 - samplesPerPixel:3 - hasAlpha:NO - isPlanar:NO - colorSpaceName:NSDeviceRGBColorSpace - bytesPerRow:bytesperline(r, 32) - bitsPerPixel:32]; - ptsize = winsizepoints(); - [win.img setSize: ptsize]; - win.topixelscale = size.width / ptsize.width; - win.topointscale = 1.0f / win.topixelscale; - - // NOTE: This is not really the display DPI. - // On retina, topixelscale is 2; otherwise it is 1. - // This formula gives us 220 for retina, 110 otherwise. - // That's not quite right but it's close to correct. - // http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density#Apple - displaydpi = win.topixelscale * 110; - - return i; -} - -void -resizeimg(void) -{ - [win.img release]; - _drawreplacescreenimage(initimg()); - - mouseresized = 1; - sendmouse(); -} - -static void -waitimg(int msec) -{ - NSDate *limit; - int n; - - win.needimg = 1; - win.deferflush = 0; - - n = 0; - limit = [NSDate dateWithTimeIntervalSinceNow:msec/1000.0]; - do{ - [[NSRunLoop currentRunLoop] - runMode:@"waiting image" - beforeDate:limit]; - n++; - }while(win.needimg && [(NSDate*)[NSDate date] compare:limit]<0); - - win.deferflush = win.needimg; - - LOG(@"waitimg %s (%d loop)", win.needimg?"defer":"ok", n); -} - -void -_flushmemscreen(Rectangle r) -{ - static int n; - NSRect rect; - - LOG(@"_flushmemscreen"); - - if(n==0){ - n++; - return; /* to skip useless white init rect */ - }else - if(n==1){ - [WIN performSelectorOnMainThread: - @selector(makeKeyAndOrderFront:) - withObject:nil - waitUntilDone:NO]; - n++; - }else - if([win.content canDraw] == 0) - return; - - rect = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); - - // This can get blocked behind responding to mouse events, - // which need to acquire the zlock, so let go of it during - // the flush. Perhaps the waitUntilDone:YES is wrong? - zunlock(); - [appdelegate - performSelectorOnMainThread:@selector(callflushimg:) - withObject:[NSValue valueWithRect:rect] - waitUntilDone:YES - modes:[NSArray arrayWithObjects: - NSRunLoopCommonModes, - @"waiting image", nil]]; - zlock(); -} - -static void drawimg(NSRect, uint); -static void drawresizehandle(void); - -enum -{ - Pixel = 1, - Barsize = 4*Pixel, - Cornersize = 3*Pixel, - Handlesize = 3*Barsize + 1*Pixel, -}; - -/* - * |rect| is in pixel coordinates. - */ -static void -flushimg(NSRect rect) -{ - NSRect dr, r; - - if([win.content lockFocusIfCanDraw] == 0) - return; - - if(win.needimg){ - if(!NSEqualSizes(scalerect(rect, win.topointscale).size, [win.img size])){ - LOG(@"flushimg reject %.0f %.0f", - rect.size.width, rect.size.height); - [win.content unlockFocus]; - return; - } - win.needimg = 0; - }else - win.deferflush = 1; - - LOG(@"flushimg ok %.0f %.0f", rect.size.width, rect.size.height); - - /* - * Unless we are inside "drawRect", we have to round - * the corners ourselves, if this is the custom. - * "NSCompositeSourceIn" can do that, but we don't - * apply it to the whole rectangle, because this - * slows down trackpad scrolling considerably in - * Acme. - */ - r = [win.content bounds]; - rect = dilate(scalerect(rect, win.topointscale)); - r.size.height -= Cornersize; - dr = NSIntersectionRect(r, rect); - LOG(@"r %.0f %.0f %.0f %.0f", r.origin.x, r.origin.y, rect.size.width, rect.size.height); - LOG(@"rect in points %f %f %.0f %.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); - LOG(@"dr in points %f %f %.0f %.0f", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height); - drawimg(dr, NSCompositeCopy); - - r.origin.y = r.size.height; - r.size = NSMakeSize(Cornersize, Cornersize); - dr = NSIntersectionRect(r, rect); - drawimg(dr, NSCompositeSourceIn); - - r.origin.x = [win.img size].width - Cornersize; - dr = NSIntersectionRect(r, rect); - drawimg(dr, NSCompositeSourceIn); - - r.size.width = r.origin.x - Cornersize; - r.origin.x -= r.size.width; - dr = NSIntersectionRect(r, rect); - drawimg(dr, NSCompositeCopy); - - if(OSX_VERSION<100700 && win.isofs==0){ - r.origin.x = [win.img size].width - Handlesize; - r.origin.y = [win.img size].height - Handlesize; - r.size = NSMakeSize(Handlesize, Handlesize); - if(NSIntersectsRect(r, rect)) - drawresizehandle(); - } - [win.content unlockFocus]; -} - -static void -autoflushwin(int set) -{ - static NSTimer *t; - - if(set){ - if(t) - return; - /* - * We need "NSRunLoopCommonModes", otherwise the - * timer will not fire during live resizing. - */ - t = [NSTimer - timerWithTimeInterval:0.033 - target:[appdelegate class] - selector:@selector(callflushwin:) userInfo:nil - repeats:YES]; - [[NSRunLoop currentRunLoop] addTimer:t - forMode:NSRunLoopCommonModes]; - }else{ - [t invalidate]; - t = nil; - win.deferflush = 0; - } -} - -static void -flushwin(void) -{ - if(win.deferflush && win.needimg==0){ - [WIN flushWindow]; - win.deferflush = 0; - } -} - -/* - * |dr| is sized in points. What if I make it pixels? - */ -static void -drawimg(NSRect dr, uint op) -{ - CGContextRef c; - CGImageRef i; - NSRect sr; - - if(NSIsEmptyRect(dr)) - return; - - sr = [win.content convertRect:dr fromView:nil]; - LOG(@"before dr: %f %f %f %f\n", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height); - LOG(@"before sr: %f %f %f %f\n", sr.origin.x, sr.origin.y, sr.size.width, sr.size.height); - - dr = scalerect(dr, win.topixelscale); - sr = scalerect(sr, win.topixelscale); - - LOG(@"dr: %f %f %f %f\n", dr.origin.x, dr.origin.y, dr.size.width, dr.size.height); - LOG(@"sr: %f %f %f %f\n", sr.origin.x, sr.origin.y, sr.size.width, sr.size.height); - if(OSX_VERSION >= 100800){ - i = CGImageCreateWithImageInRect([win.img CGImage], NSRectToCGRect(dr)); - c = [[WIN graphicsContext] graphicsPort]; - - CGContextSaveGState(c); - if(op == NSCompositeSourceIn) - CGContextSetBlendMode(c, kCGBlendModeSourceIn); - LOG(@"wim.img size %f %f\n", [win.img size].width, [win.img size].height); - CGContextTranslateCTM(c, 0, [win.img size].height); - CGContextScaleCTM(c, win.topointscale, -win.topointscale); - CGContextDrawImage(c, NSRectToCGRect(sr), i); - CGContextRestoreGState(c); - - CGImageRelease(i); - }else{ - [win.img drawInRect:dr fromRect:sr - operation:op fraction:1 - respectFlipped:YES hints:nil]; - } -// NSFrameRect(dr); -} - -static void -drawresizehandle(void) -{ - NSColor *color[Barsize]; - NSPoint a,b; - Point c; - int i,j; - - c = Pt([win.img size].width, [win.img size].height); - - [[WIN graphicsContext] setShouldAntialias:NO]; - - color[0] = [NSColor clearColor]; - color[1] = [NSColor darkGrayColor]; - color[2] = [NSColor lightGrayColor]; - color[3] = [NSColor whiteColor]; - - for(i=1; i+Barsize <= Handlesize; ) - for(j=0; j0) - keystroke(k); - else - keystroke([s characterAtIndex:0]); - break; - - case NSFlagsChanged: - if(in.mbuttons || in.kbuttons){ - in.kbuttons = 0; - if(m & NSControlKeyMask) - in.kbuttons |= 1; - if(m & NSAlternateKeyMask) - in.kbuttons |= 2; - if(m & NSCommandKeyMask) - in.kbuttons |= 4; - sendmouse(); - }else - if(m&NSAlternateKeyMask && (omod&NSAlternateKeyMask)==0) - keystroke(Kalt); - break; - - default: - panic("getkey: unexpected event type"); - } - omod = m; -} - -/* - * Devdraw does not use NSTrackingArea, that often - * forgets to update the cursor on entering and on - * leaving the area, and that sometimes stops sending - * us MouseMove events, at least on OS X Lion. - */ -static void -updatecursor(void) -{ - NSCursor *c; - int isdown, isinside; - - isinside = NSPointInRect(in.mpos, [win.content bounds]); - isdown = (in.mbuttons || in.kbuttons); - - if(win.cursor && (isinside || isdown)) - c = win.cursor; - else if(isinside && usebigarrow) - c = in.bigarrow; - else - c = [NSCursor arrowCursor]; - [c set]; - - /* - * Without this trick, we can come back from the dock - * with a resize cursor. - */ - if(OSX_VERSION >= 100700) - [NSCursor unhide]; -} - -static void -acceptresizing(int set) -{ - uint old, style; - - old = [WIN styleMask]; - - if((old | NSResizableWindowMask) != Winstyle) - return; /* when entering new fullscreen */ - - if(set) - style = Winstyle; - else - style = Winstyle & ~NSResizableWindowMask; - - if(style != old) - [WIN setStyleMask:style]; -} - -static void -getmousepos(void) -{ - NSPoint p, q; - - p = [WIN mouseLocationOutsideOfEventStream]; - q = [win.content convertPoint:p fromView:nil]; - - /* q is in point coordinates. in.mpos is in pixels. */ - q = scalepoint(q, win.topixelscale); - - in.mpos.x = round(q.x); - in.mpos.y = round(q.y); - - updatecursor(); - - if(win.isnfs || win.isofs) - hidebars(1); - else if(OSX_VERSION>=100700 && [WIN inLiveResize]==0){ - if(p.x<12 && p.y<12 && p.x>2 && p.y>2) - acceptresizing(0); - else - acceptresizing(1); - } -} - -static void -getmouse(NSEvent *e) -{ - float d; - int b, m; - - if([WIN isKeyWindow] == 0) - return; - - getmousepos(); - - switch([e type]){ - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSOtherMouseDown: - case NSOtherMouseUp: - case NSRightMouseDown: - case NSRightMouseUp: - b = [NSEvent pressedMouseButtons]; - b = b&~6 | (b&4)>>1 | (b&2)<<1; - b = mouseswap(b); - - if(b == 1){ - m = [e modifierFlags]; - if(m & NSAlternateKeyMask){ - abortcompose(); - b = 2; - }else - if(m & NSCommandKeyMask) - b = 4; - } - in.mbuttons = b; - break; - - case NSScrollWheel: -#if OSX_VERSION >= 100700 - d = [e scrollingDeltaY]; -#else - d = [e deltaY]; -#endif - if(d>0) - in.mscroll = 8; - else - if(d<0) - in.mscroll = 16; - break; - - case NSMouseMoved: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: - break; - - default: - panic("getmouse: unexpected event type"); - } - sendmouse(); -} - -#define Minpinch 0.02 - -static void -getgesture(NSEvent *e) -{ - switch([e type]){ - case NSEventTypeMagnify: - if(fabs([e magnification]) > Minpinch) - togglefs(); - break; - } -} - -static void sendclick(int); - -static uint -msec(void) -{ - return nsec()/1000000; -} - -static void -gettouch(NSEvent *e, int type) -{ - static int tapping; - static uint taptime; - NSSet *set; - int p; - - switch(type){ - case NSTouchPhaseBegan: - p = NSTouchPhaseTouching; - set = [e touchesMatchingPhase:p inView:nil]; - if(set.count == 3){ - tapping = 1; - taptime = msec(); - }else - if(set.count > 3) - tapping = 0; - break; - - case NSTouchPhaseMoved: - tapping = 0; - break; - - case NSTouchPhaseEnded: - p = NSTouchPhaseTouching; - set = [e touchesMatchingPhase:p inView:nil]; - if(set.count == 0){ - if(tapping && msec()-taptime<400) - sendclick(2); - tapping = 0; - } - break; - - case NSTouchPhaseCancelled: - break; - - default: - panic("gettouch: unexpected event type"); - } -} - -static void -sendclick(int b) -{ - in.mbuttons = b; - sendmouse(); - in.mbuttons = 0; - sendmouse(); -} - -static void -sendmouse(void) -{ - NSSize size; - int b; - - size = winsizepixels(); - mouserect = Rect(0, 0, size.width, size.height); - - b = in.kbuttons | in.mbuttons | in.mscroll; - mousetrack(in.mpos.x, in.mpos.y, b, msec()); - in.mscroll = 0; -} - -/* - * |p| is in pixels. - */ -void -setmouse(Point p) -{ - NSPoint q; - NSRect r; - - if([NSApp isActive]==0 && in.willactivate==0) - return; - - if([WIN inLiveResize]) - return; - - in.mpos = scalepoint(NSMakePoint(p.x, p.y), win.topointscale); // race condition - - q = [win.content convertPoint:in.mpos toView:nil]; - q = [WIN convertRectToScreen:NSMakeRect(q.x, q.y, 0, 0)].origin; - - r = [[[NSScreen screens] objectAtIndex:0] frame]; - q.y = r.size.height - q.y; /* Quartz is top-left-based here */ - - CGWarpMouseCursorPosition(NSPointToCGPoint(q)); - CGAssociateMouseAndMouseCursorPosition(true); -} - -/* - * |r| is in points. - */ -static void -followzoombutton(NSRect r) -{ - NSRect wr; - Point p; - NSPoint pt; - - wr = [WIN frame]; - wr.origin.y += wr.size.height; - r.origin.y += r.size.height; - - getmousepos(); - pt.x = in.mpos.x; - pt.y = in.mpos.y; - pt = scalepoint(pt, win.topointscale); - pt.x = (r.origin.x - wr.origin.x) + pt.x; - pt.y = -(r.origin.y - wr.origin.y) + pt.y; - pt = scalepoint(pt, win.topixelscale); - - p.x = pt.x; - p.y = pt.y; - - setmouse(p); -} - -static void -togglefs(void) -{ - uint opt, tmp; - -#if OSX_VERSION >= 100700 - NSScreen *s, *s0; - - s = [WIN screen]; - s0 = [[NSScreen screens] objectAtIndex:0]; - - if((s==s0 && useoldfullscreen==0) || win.isnfs) { - [WIN toggleFullScreen:nil]; - return; - } -#endif - [win.content retain]; - [WIN orderOut:nil]; - [WIN setContentView:nil]; - - win.isofs = ! win.isofs; - hidebars(win.isofs); - - /* - * If we move the window from one space to another, - * ofs[0] and ofs[1] can be on different spaces. - * This "setCollectionBehavior" trick moves the - * window to the active space. - */ - opt = [WIN collectionBehavior]; - tmp = opt | NSWindowCollectionBehaviorCanJoinAllSpaces; - [WIN setContentView:win.content]; - [WIN setCollectionBehavior:tmp]; - [WIN makeKeyAndOrderFront:nil]; - [WIN setCollectionBehavior:opt]; - [win.content release]; -} - -enum -{ - Autohiddenbars = NSApplicationPresentationAutoHideDock - | NSApplicationPresentationAutoHideMenuBar, - - Hiddenbars = NSApplicationPresentationHideDock - | NSApplicationPresentationHideMenuBar, -}; - -static void -hidebars(int set) -{ - NSScreen *s,*s0; - uint old, opt; - - s = [WIN screen]; - s0 = [[NSScreen screens] objectAtIndex:0]; - old = [NSApp presentationOptions]; - -#if OSX_VERSION >= 100700 - /* This bit can get lost, resulting in dreadful bugs. */ - if(win.isnfs) - old |= NSApplicationPresentationFullScreen; -#endif - - if(set && s==s0) - opt = (old & ~Autohiddenbars) | Hiddenbars; - else - opt = old & ~(Autohiddenbars | Hiddenbars); - - if(opt != old) - [NSApp setPresentationOptions:opt]; -} - -static void -makemenu(void) -{ - NSMenu *m; - NSMenuItem *i0,*i1; - - m = [NSMenu new]; - i0 = [m addItemWithTitle:@"app" action:NULL keyEquivalent:@""]; - i1 = [m addItemWithTitle:@"help" action:NULL keyEquivalent:@""]; - [NSApp setMainMenu:m]; - [m release]; - - m = [[NSMenu alloc] initWithTitle:@"app"]; - [m addItemWithTitle:@"Full Screen" - action:@selector(calltogglefs:) - keyEquivalent:@"f"]; - [m addItemWithTitle:@"Hide" - action:@selector(hide:) - keyEquivalent:@"h"]; - [m addItemWithTitle:@"Quit" - action:@selector(terminate:) - keyEquivalent:@"q"]; - [i0 setSubmenu:m]; - [m release]; - - m = [[NSMenu alloc] initWithTitle:@"help"]; - [m addItemWithTitle:@"Plumb devdraw(1)" - action:@selector(plumbmanual:) - keyEquivalent:@""]; - [i1 setSubmenu:m]; - [m release]; -} - -// FIXME: Introduce a high-resolution Glenda image. -static void -makeicon(void) -{ - NSData *d; - NSImage *i; - - d = [[NSData alloc] - initWithBytes:glenda_png - length:(sizeof glenda_png)]; - - i = [[NSImage alloc] initWithData:d]; - [NSApp setApplicationIconImage:i]; - [[NSApp dockTile] display]; - [i release]; - [d release]; -} - -QLock snarfl; - -char* -getsnarf(void) -{ - NSPasteboard *pb; - NSString *s; - - pb = [NSPasteboard generalPasteboard]; - - qlock(&snarfl); - s = [pb stringForType:NSPasteboardTypeString]; - qunlock(&snarfl); - - if(s) - return strdup((char*)[s UTF8String]); - else - return nil; -} - -void -putsnarf(char *s) -{ - NSArray *t; - NSPasteboard *pb; - NSString *str; - - if(strlen(s) >= SnarfSize) - return; - - t = [NSArray arrayWithObject:NSPasteboardTypeString]; - pb = [NSPasteboard generalPasteboard]; - str = [[NSString alloc] initWithUTF8String:s]; - - qlock(&snarfl); - [pb declareTypes:t owner:nil]; - [pb setString:str forType:NSPasteboardTypeString]; - qunlock(&snarfl); - - [str release]; -} - -void -kicklabel(char *label) -{ - if(label == nil) - return; - - [appdelegate - performSelectorOnMainThread:@selector(callkicklabel0:) - withObject:[NSValue valueWithPointer:label] - waitUntilDone:YES]; -} - -static void -kicklabel0(char *label) { - NSString *s; - - s = [[NSString alloc] initWithUTF8String:label]; - [win.ofs[0] setTitle:s]; - [win.ofs[1] setTitle:s]; - [[NSApp dockTile] setBadgeLabel:s]; - [s release]; -} - -void -setcursor(Cursor *c, Cursor2 *c2) -{ - USED(c2); - - /* - * No cursor change unless in main thread. - */ - [appdelegate - performSelectorOnMainThread:@selector(callsetcursor0:) - withObject:[NSValue valueWithPointer:c] - waitUntilDone:YES]; -} - -static void -setcursor0(Cursor *c) -{ - NSCursor *d; - - d = win.cursor; - - if(c) - win.cursor = makecursor(c); - else - win.cursor = nil; - - updatecursor(); - - if(d) - [d release]; -} - -/* - * Cursors will be scaled on retina display. - */ -static NSCursor* -makecursor(Cursor *c) -{ - NSBitmapImageRep *r; - NSCursor *d; - NSImage *i; - NSPoint p; - int b; - uchar *plane[5]; - - r = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:nil - pixelsWide:16 - pixelsHigh:16 - bitsPerSample:1 - samplesPerPixel:2 - hasAlpha:YES - isPlanar:YES - colorSpaceName:NSDeviceWhiteColorSpace - bytesPerRow:2 - bitsPerPixel:1]; - - [r getBitmapDataPlanes:plane]; - - for(b=0; b<2*16; b++){ - plane[0][b] = ~c->set[b]; - plane[1][b] = c->clr[b]; - } - p = NSMakePoint(-c->offset.x, -c->offset.y); - i = [NSImage new]; - [i addRepresentation:r]; - [r release]; - - d = [[NSCursor alloc] initWithImage:i hotSpot:p]; - [i release]; - return d; -} - -void -topwin(void) -{ - [WIN performSelectorOnMainThread: - @selector(makeKeyAndOrderFront:) - withObject:nil - waitUntilDone:NO]; - - in.willactivate = 1; - [NSApp activateIgnoringOtherApps:YES]; -} - -static NSSize -winsizepoints() -{ - return [win.content bounds].size; -} - -static NSSize -winsizepixels() -{ -#if OSX_VERSION >= 100700 - if (OSX_VERSION >= 100700 && devdrawretina) - return [win.content convertSizeToBacking: winsizepoints()]; - else -#endif - return winsizepoints(); -} - -static NSRect -scalerect(NSRect r, CGFloat scale) -{ - r.origin.x *= scale; - r.origin.y *= scale; - r.size.width *= scale; - r.size.height *= scale; - return r; -} - -/* - * Expands rectangle |r|'s bounds to more inclusive integer bounds to - * eliminate 1 pixel gaps. - */ -static NSRect -dilate(NSRect r) -{ - if(win.topixelscale > 1.0f){ - r.origin.x = floorf(r.origin.x); - r.origin.y = floorf(r.origin.y); - r.size.width = ceilf(r.size.width + 0.5); - r.size.height = ceilf(r.size.height + 0.5); - } - return r; -} - -static NSPoint -scalepoint(NSPoint pt, CGFloat scale) -{ - pt.x *= scale; - pt.y *= scale; - return pt; -} - -static void -setprocname(const char *s) -{ - CFStringRef process_name; - - process_name = CFStringCreateWithBytes(nil, (uchar*)s, strlen(s), kCFStringEncodingUTF8, false); - - // Adapted from Chrome's mac_util.mm. - // http://src.chromium.org/viewvc/chrome/trunk/src/base/mac/mac_util.mm - // - // Copyright (c) 2012 The Chromium Authors. All rights reserved. - // - // Redistribution and use in source and binary forms, with or without - // modification, are permitted provided that the following conditions are - // met: - // - // * Redistributions of source code must retain the above copyright - // notice, this list of conditions and the following disclaimer. - // * Redistributions in binary form must reproduce the above - // copyright notice, this list of conditions and the following disclaimer - // in the documentation and/or other materials provided with the - // distribution. - // * Neither the name of Google Inc. nor the names of its - // contributors may be used to endorse or promote products derived from - // this software without specific prior written permission. - // - // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - // Warning: here be dragons! This is SPI reverse-engineered from WebKit's - // plugin host, and could break at any time (although realistically it's only - // likely to break in a new major release). - // When 10.7 is available, check that this still works, and update this - // comment for 10.8. - - // Private CFType used in these LaunchServices calls. - typedef CFTypeRef PrivateLSASN; - typedef PrivateLSASN (*LSGetCurrentApplicationASNType)(); - typedef OSStatus (*LSSetApplicationInformationItemType)(int, PrivateLSASN, - CFStringRef, - CFStringRef, - CFDictionaryRef*); - - static LSGetCurrentApplicationASNType ls_get_current_application_asn_func = - NULL; - static LSSetApplicationInformationItemType - ls_set_application_information_item_func = NULL; - static CFStringRef ls_display_name_key = NULL; - - static bool did_symbol_lookup = false; - if (!did_symbol_lookup) { - did_symbol_lookup = true; - CFBundleRef launch_services_bundle = - CFBundleGetBundleWithIdentifier(CFSTR("com.apple.LaunchServices")); - if (!launch_services_bundle) { - fprint(2, "Failed to look up LaunchServices bundle\n"); - return; - } - - ls_get_current_application_asn_func = - (LSGetCurrentApplicationASNType)( - CFBundleGetFunctionPointerForName( - launch_services_bundle, CFSTR("_LSGetCurrentApplicationASN"))); - if (!ls_get_current_application_asn_func) - fprint(2, "Could not find _LSGetCurrentApplicationASN\n"); - - ls_set_application_information_item_func = - (LSSetApplicationInformationItemType)( - CFBundleGetFunctionPointerForName( - launch_services_bundle, - CFSTR("_LSSetApplicationInformationItem"))); - if (!ls_set_application_information_item_func) - fprint(2, "Could not find _LSSetApplicationInformationItem\n"); - - CFStringRef* key_pointer = (CFStringRef*)( - CFBundleGetDataPointerForName(launch_services_bundle, - CFSTR("_kLSDisplayNameKey"))); - ls_display_name_key = key_pointer ? *key_pointer : NULL; - if (!ls_display_name_key) - fprint(2, "Could not find _kLSDisplayNameKey\n"); - - // Internally, this call relies on the Mach ports that are started up by the - // Carbon Process Manager. In debug builds this usually happens due to how - // the logging layers are started up; but in release, it isn't started in as - // much of a defined order. So if the symbols had to be loaded, go ahead - // and force a call to make sure the manager has been initialized and hence - // the ports are opened. - ProcessSerialNumber psn; - GetCurrentProcess(&psn); - } - if (!ls_get_current_application_asn_func || - !ls_set_application_information_item_func || - !ls_display_name_key) { - return; - } - - PrivateLSASN asn = ls_get_current_application_asn_func(); - // Constant used by WebKit; what exactly it means is unknown. - const int magic_session_constant = -2; - OSErr err = - ls_set_application_information_item_func(magic_session_constant, asn, - ls_display_name_key, - process_name, - NULL /* optional out param */); - if(err != noErr) - fprint(2, "Call to set process name failed\n"); -} - -void -resizewindow(Rectangle r) -{ - USED(r); -} diff --git a/src/cmd/devdraw/macargv.m b/src/cmd/devdraw/macargv.m index 8db56be7b..92df2a6f7 100644 --- a/src/cmd/devdraw/macargv.m +++ b/src/cmd/devdraw/macargv.m @@ -12,9 +12,6 @@ @interface appdelegate : NSObject @end void main(void) { - if(OSX_VERSION < 100700) - [NSAutoreleasePool new]; - [NSApplication sharedApplication]; NSObject *delegate = [appdelegate new]; [NSApp setDelegate:delegate]; diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index e94afbd36..a1dc56d36 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -22,13 +22,11 @@ fi if [ "x$WSYSTYPE" = "x" ]; then if [ "x`uname`" = "xDarwin" ]; then - if sw_vers | grep 'ProductVersion: 10\.[0-5]\.' >/dev/null; then - echo 1>&2 'OS X 10.5 and older are not supported' + if sw_vers | egrep 'ProductVersion: (10\.[0-9]\.|10\.1[012])$' >/dev/null; then + echo 1>&2 'OS X 10.12 and older are not supported' exit 1 - else - #echo 1>&2 'WARNING: OS X Lion is not working. Copy binaries from a Snow Leopard system.' - WSYSTYPE=osx-cocoa fi + WSYSTYPE=osx-cocoa elif [ -d "$X11" ]; then WSYSTYPE=x11 else @@ -54,12 +52,8 @@ if [ $WSYSTYPE = x11 ]; then XO=`ls x11-*.c 2>/dev/null | sed 's/\.c$/.o/'` echo 'WSYSOFILES=$WSYSOFILES '$XO elif [ $WSYSTYPE = osx-cocoa ]; then - if sw_vers|awk '/ProductVersion/{split($2,a,".");exit(a[2]<14)}' >/dev/null; then # 0 is true in sh. - echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-metal-objc.o cocoa-srv.o cocoa-thread.o' - else - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-objc.o cocoa-srv.o cocoa-thread.o' - fi + echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-metal-objc.o cocoa-srv.o cocoa-thread.o' echo 'MACARGV=macargv-objc.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' From db20f89c3286f277945ac4307f789a9980d31bf6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 19:54:43 -0500 Subject: [PATCH 130/323] devdraw: simplify mac file names Now that we only have Metal, we can drop the -metal. Also now that Carbon is gone we can drop the macargv.c, and then the -objc from object file names. --- .../{cocoa-screen-metal.m => cocoa-screen.m} | 0 src/cmd/devdraw/macargv.c | 90 ------------------- src/cmd/devdraw/mkfile | 9 +- src/cmd/devdraw/mkwsysrules.sh | 4 +- 4 files changed, 5 insertions(+), 98 deletions(-) rename src/cmd/devdraw/{cocoa-screen-metal.m => cocoa-screen.m} (100%) delete mode 100644 src/cmd/devdraw/macargv.c diff --git a/src/cmd/devdraw/cocoa-screen-metal.m b/src/cmd/devdraw/cocoa-screen.m similarity index 100% rename from src/cmd/devdraw/cocoa-screen-metal.m rename to src/cmd/devdraw/cocoa-screen.m diff --git a/src/cmd/devdraw/macargv.c b/src/cmd/devdraw/macargv.c deleted file mode 100644 index a5ea1ade7..000000000 --- a/src/cmd/devdraw/macargv.c +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include -#include - -AUTOFRAMEWORK(Carbon) - -static OSErr Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon); - -int -main(void) -{ - AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, Handler, 0, false); - RunApplicationEventLoop(); - return 0; -} - -static OSErr -GetFullPathname(FSSpec *fss, char *path, int len) -{ - FSRef fsr; - OSErr err; - - *path = '\0'; - err = FSpMakeFSRef(fss, &fsr); - if (err == fnfErr) { - /* FSSpecs can point to non-existing files, fsrefs can't. */ - FSSpec fss2; - int tocopy; - - err = FSMakeFSSpec(fss->vRefNum, fss->parID, - (unsigned char*)"", &fss2); - if (err) - return err; - err = FSpMakeFSRef(&fss2, &fsr); - if (err) - return err; - err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1); - if (err) - return err; - /* This part is not 100% safe: we append the filename part, but - ** I'm not sure that we don't run afoul of the various 8bit - ** encodings here. Will have to look this up at some point... - */ - strcat(path, "/"); - tocopy = fss->name[0]; - if ((strlen(path) + tocopy) >= len) - tocopy = len - strlen(path) - 1; - if (tocopy > 0) - strncat(path, (char*)fss->name+1, tocopy); - } - else { - if (err) - return err; - err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len); - if (err) - return err; - } - return 0; -} - -static void -chk(int err) -{ - if(err != 0) { - printf("err %d\n", err); - exit(1); - } -} - -static OSErr -Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon) -{ - AEDesc list; - DescType type; - FSSpec f; - AEKeyword keyword; - Size actual; - long len; - char s[1000]; - - chk(AEGetParamDesc(event, keyDirectObject, typeAEList, &list)); - chk(AECountItems(&list, &len)); - chk(AEGetNthPtr(&list, 1, typeFSS, &keyword, &type, (Ptr*)&f, sizeof(FSSpec), &actual)); - chk(GetFullPathname(&f, s, sizeof s)); - printf("%s\n", s); - fflush(stdout); - - // uncomment to keep handling more open events - exit(0); -} diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index e60b427f3..27613239c 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -37,13 +37,10 @@ latin1.h: $PLAN9/lib/keyboard $O.mklatinkbd $O.macargv: $MACARGV $LD -o $target $prereq -cocoa-screen-metal-objc.$O: cocoa-screen-metal.m - $CC $CFLAGS $OBJCFLAGS -o $target cocoa-screen-metal.m +%.$O: %.m + $CC $CFLAGS $OBJCFLAGS -o $target $stem.m -%-objc.$O: %.m - $CC $CFLAGS -o $target $stem.m - -CLEANFILES=$O.macargv $O.mklatinkbd latin1.h +CLEANFILES=$O.devdraw $O.macargv $O.mklatinkbd latin1.h install: mklatinkbd.install install:Q: diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index a1dc56d36..8ab67f76f 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -53,8 +53,8 @@ if [ $WSYSTYPE = x11 ]; then echo 'WSYSOFILES=$WSYSOFILES '$XO elif [ $WSYSTYPE = osx-cocoa ]; then echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen-metal-objc.o cocoa-srv.o cocoa-thread.o' - echo 'MACARGV=macargv-objc.o' + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen.o cocoa-srv.o cocoa-thread.o' + echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' fi From ce27d7babdf2ee09ff6d1f8d4a166c2208995774 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 20:03:31 -0500 Subject: [PATCH 131/323] devdraw: can use libthread directly now on macOS --- src/cmd/devdraw/cocoa-screen.m | 19 ++++++++++-------- src/cmd/devdraw/cocoa-srv.c | 2 +- src/cmd/devdraw/cocoa-thread.c | 35 ---------------------------------- src/cmd/devdraw/cocoa-thread.h | 34 --------------------------------- src/cmd/devdraw/mkwsysrules.sh | 2 +- 5 files changed, 13 insertions(+), 79 deletions(-) delete mode 100644 src/cmd/devdraw/cocoa-thread.c delete mode 100644 src/cmd/devdraw/cocoa-thread.h diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/cocoa-screen.m index 984ede033..64b2bf4c5 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/cocoa-screen.m @@ -12,7 +12,7 @@ #include #include -#include "cocoa-thread.h" +#include #include #include #include @@ -41,8 +41,8 @@ threadexitsall("usage"); } + @interface AppDelegate : NSObject -+ (void)callservep9p:(id)arg; + (void)makewin:(NSValue *)v; + (void)callkicklabel:(NSString *)v; + (void)callsetNeedsDisplayInRect:(NSValue *)v; @@ -108,14 +108,18 @@ @interface DrawLayer : CAMetalLayer } } -@implementation AppDelegate -+ (void)callservep9p:(id)arg +void +callservep9p(void *v) { + USED(v); + servep9p(); - [NSApp terminate:self]; + [NSApp terminate:myApp]; } +@implementation AppDelegate + + (void)makewin:(NSValue *)v { NSRect r, sr; @@ -331,9 +335,7 @@ - (void)applicationDidFinishLaunching:(id)arg [NSApp setApplicationIconImage:i]; [[NSApp dockTile] display]; - [NSThread - detachNewThreadSelector:@selector(callservep9p:) - toTarget:[self class] withObject:nil]; + proccreate(callservep9p, nil, 0); } - (NSApplicationPresentationOptions)window:(id)arg @@ -671,6 +673,7 @@ - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)r if(actualRange) *actualRange = sr; LOG(@"use range: %ld, %ld", sr.location, sr.length); + s = nil; if(sr.length) s = [[NSAttributedString alloc] initWithString:[_tmpText substringWithRange:sr]]; diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/cocoa-srv.c index dcb1801ac..2211a06f7 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/cocoa-srv.c @@ -4,7 +4,7 @@ #include #include -#include "cocoa-thread.h" +#include #include #include #include diff --git a/src/cmd/devdraw/cocoa-thread.c b/src/cmd/devdraw/cocoa-thread.c deleted file mode 100644 index 92b92d2cf..000000000 --- a/src/cmd/devdraw/cocoa-thread.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include "cocoa-thread.h" - -#ifndef TRY_LIBTHREAD - -static pthread_mutex_t initlock = PTHREAD_MUTEX_INITIALIZER; - -void -qlock(QLock *q) -{ - if(q->init == 0){ - pthread_mutex_lock(&initlock); - if(q->init == 0){ - pthread_mutex_init(&q->m, nil); - q->init = 1; - } - pthread_mutex_unlock(&initlock); - } - pthread_mutex_lock(&q->m); -} - -void -qunlock(QLock *q) -{ - pthread_mutex_unlock(&q->m); -} - -int -threadid(void) -{ - return pthread_mach_thread_np(pthread_self()); -} - -#endif diff --git a/src/cmd/devdraw/cocoa-thread.h b/src/cmd/devdraw/cocoa-thread.h deleted file mode 100644 index d5793f0a7..000000000 --- a/src/cmd/devdraw/cocoa-thread.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * I am too ignorant to know if Cocoa and Libthread - * can coexist: if I try to include thread.h, now - * that Devdraw uses Cocoa's threads (and timers), it - * crashes immediately; when Devdraw was using - * proccreate(), it could run a little while before to - * crash; the origin of those crashes is hard to - * ascertain, because other programs using Libthread - * (such as 9term, Acme, Plumber, and Sam) currently - * don't run when compiled with Xcode 4.1. - */ -//#define TRY_LIBTHREAD - -#ifdef TRY_LIBTHREAD - #include -#else - #define QLock DQLock - #define qlock dqlock - #define qunlock dqunlock - #define threadexitsall exits - #define threadmain main - - typedef struct QLock QLock; - - struct QLock - { - int init; - pthread_mutex_t m; - }; - - void qlock(QLock*); - void qunlock(QLock*); - int threadid(void); -#endif diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index 8ab67f76f..839ebab30 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -53,7 +53,7 @@ if [ $WSYSTYPE = x11 ]; then echo 'WSYSOFILES=$WSYSOFILES '$XO elif [ $WSYSTYPE = osx-cocoa ]; then echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen.o cocoa-srv.o cocoa-thread.o' + echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen.o cocoa-srv.o' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' From 933b98054f40bb224acda134d7bb77a023bcc57f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 20:07:15 -0500 Subject: [PATCH 132/323] devdraw: use consistent mac-* prefix on macOS files We were using osx- and cocoa- but it's not even OS X anymore. --- src/cmd/devdraw/{osx-draw.c => mac-draw.c} | 0 .../devdraw/{cocoa-screen.h => mac-screen.h} | 0 .../devdraw/{cocoa-screen.m => mac-screen.m} | 3 +- src/cmd/devdraw/{cocoa-srv.c => mac-srv.c} | 2 +- src/cmd/devdraw/mkwsysrules.sh | 6 +- src/cmd/devdraw/osx-keycodes.h | 189 ------------------ src/cmd/fontsrv/{osx.c => mac.c} | 0 src/cmd/fontsrv/mkfile | 2 - src/cmd/fontsrv/osx-cocoa.c | 1 - .../{osx-cocoa-snarfer.c => mac-snarfer.c} | 0 src/cmd/snarfer/mkfile | 2 +- src/cmd/snarfer/osx-snarfer.c | 1 - 12 files changed, 6 insertions(+), 200 deletions(-) rename src/cmd/devdraw/{osx-draw.c => mac-draw.c} (100%) rename src/cmd/devdraw/{cocoa-screen.h => mac-screen.h} (100%) rename src/cmd/devdraw/{cocoa-screen.m => mac-screen.m} (99%) rename src/cmd/devdraw/{cocoa-srv.c => mac-srv.c} (99%) delete mode 100644 src/cmd/devdraw/osx-keycodes.h rename src/cmd/fontsrv/{osx.c => mac.c} (100%) delete mode 100644 src/cmd/fontsrv/osx-cocoa.c rename src/cmd/snarfer/{osx-cocoa-snarfer.c => mac-snarfer.c} (100%) delete mode 100644 src/cmd/snarfer/osx-snarfer.c diff --git a/src/cmd/devdraw/osx-draw.c b/src/cmd/devdraw/mac-draw.c similarity index 100% rename from src/cmd/devdraw/osx-draw.c rename to src/cmd/devdraw/mac-draw.c diff --git a/src/cmd/devdraw/cocoa-screen.h b/src/cmd/devdraw/mac-screen.h similarity index 100% rename from src/cmd/devdraw/cocoa-screen.h rename to src/cmd/devdraw/mac-screen.h diff --git a/src/cmd/devdraw/cocoa-screen.m b/src/cmd/devdraw/mac-screen.m similarity index 99% rename from src/cmd/devdraw/cocoa-screen.m rename to src/cmd/devdraw/mac-screen.m index 64b2bf4c5..c115f8678 100644 --- a/src/cmd/devdraw/cocoa-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -17,8 +17,7 @@ #include #include #include -#include "cocoa-screen.h" -#include "osx-keycodes.h" +#include "mac-screen.h" #include "devdraw.h" #include "bigarrow.h" #include "glendapng.h" diff --git a/src/cmd/devdraw/cocoa-srv.c b/src/cmd/devdraw/mac-srv.c similarity index 99% rename from src/cmd/devdraw/cocoa-srv.c rename to src/cmd/devdraw/mac-srv.c index 2211a06f7..b0925eee5 100644 --- a/src/cmd/devdraw/cocoa-srv.c +++ b/src/cmd/devdraw/mac-srv.c @@ -11,7 +11,7 @@ #include #include #include -#include "cocoa-screen.h" +#include "mac-screen.h" #include "devdraw.h" typedef struct Kbdbuf Kbdbuf; diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index 839ebab30..8e9c30106 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -26,7 +26,7 @@ if [ "x$WSYSTYPE" = "x" ]; then echo 1>&2 'OS X 10.12 and older are not supported' exit 1 fi - WSYSTYPE=osx-cocoa + WSYSTYPE=mac elif [ -d "$X11" ]; then WSYSTYPE=x11 else @@ -51,9 +51,9 @@ if [ $WSYSTYPE = x11 ]; then echo 'HFILES=$HFILES $XHFILES' XO=`ls x11-*.c 2>/dev/null | sed 's/\.c$/.o/'` echo 'WSYSOFILES=$WSYSOFILES '$XO -elif [ $WSYSTYPE = osx-cocoa ]; then +elif [ $WSYSTYPE = mac ]; then echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' - echo 'WSYSOFILES=$WSYSOFILES osx-draw.o cocoa-screen.o cocoa-srv.o' + echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o mac-srv.o' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' diff --git a/src/cmd/devdraw/osx-keycodes.h b/src/cmd/devdraw/osx-keycodes.h deleted file mode 100644 index 52328ace0..000000000 --- a/src/cmd/devdraw/osx-keycodes.h +++ /dev/null @@ -1,189 +0,0 @@ -/* These are the Macintosh key scancode constants -- from Inside Macintosh */ -#define QZ_ESCAPE 0x35 -#define QZ_F1 0x7A -#define QZ_F2 0x78 -#define QZ_F3 0x63 -#define QZ_F4 0x76 -#define QZ_F5 0x60 -#define QZ_F6 0x61 -#define QZ_F7 0x62 -#define QZ_F8 0x64 -#define QZ_F9 0x65 -#define QZ_F10 0x6D -#define QZ_F11 0x67 -#define QZ_F12 0x6F -#define QZ_PRINT 0x69 -#define QZ_SCROLLOCK 0x6B -#define QZ_PAUSE 0x71 -#define QZ_POWER 0x7F -#define QZ_BACKQUOTE 0x32 -#define QZ_1 0x12 -#define QZ_2 0x13 -#define QZ_3 0x14 -#define QZ_4 0x15 -#define QZ_5 0x17 -#define QZ_6 0x16 -#define QZ_7 0x1A -#define QZ_8 0x1C -#define QZ_9 0x19 -#define QZ_0 0x1D -#define QZ_MINUS 0x1B -#define QZ_EQUALS 0x18 -#define QZ_BACKSPACE 0x33 -#define QZ_INSERT 0x72 -#define QZ_HOME 0x73 -#define QZ_PAGEUP 0x74 -#define QZ_NUMLOCK 0x47 -#define QZ_KP_EQUALS 0x51 -#define QZ_KP_DIVIDE 0x4B -#define QZ_KP_MULTIPLY 0x43 -#define QZ_TAB 0x30 -#define QZ_q 0x0C -#define QZ_w 0x0D -#define QZ_e 0x0E -#define QZ_r 0x0F -#define QZ_t 0x11 -#define QZ_y 0x10 -#define QZ_u 0x20 -#define QZ_i 0x22 -#define QZ_o 0x1F -#define QZ_p 0x23 -#define QZ_LEFTBRACKET 0x21 -#define QZ_RIGHTBRACKET 0x1E -#define QZ_BACKSLASH 0x2A -#define QZ_DELETE 0x75 -#define QZ_END 0x77 -#define QZ_PAGEDOWN 0x79 -#define QZ_KP7 0x59 -#define QZ_KP8 0x5B -#define QZ_KP9 0x5C -#define QZ_KP_MINUS 0x4E -#define QZ_CAPSLOCK 0x39 -#define QZ_a 0x00 -#define QZ_s 0x01 -#define QZ_d 0x02 -#define QZ_f 0x03 -#define QZ_g 0x05 -#define QZ_h 0x04 -#define QZ_j 0x26 -#define QZ_k 0x28 -#define QZ_l 0x25 -#define QZ_SEMICOLON 0x29 -#define QZ_QUOTE 0x27 -#define QZ_RETURN 0x24 -#define QZ_KP4 0x56 -#define QZ_KP5 0x57 -#define QZ_KP6 0x58 -#define QZ_KP_PLUS 0x45 -#define QZ_LSHIFT 0x38 -#define QZ_z 0x06 -#define QZ_x 0x07 -#define QZ_c 0x08 -#define QZ_v 0x09 -#define QZ_b 0x0B -#define QZ_n 0x2D -#define QZ_m 0x2E -#define QZ_COMMA 0x2B -#define QZ_PERIOD 0x2F -#define QZ_SLASH 0x2C -/* These are the same as the left versions - use left by default */ -#if 0 -#define QZ_RSHIFT 0x38 -#endif -#define QZ_UP 0x7E -#define QZ_KP1 0x53 -#define QZ_KP2 0x54 -#define QZ_KP3 0x55 -#define QZ_KP_ENTER 0x4C -#define QZ_LCTRL 0x3B -#define QZ_LALT 0x3A -#define QZ_LMETA 0x37 -#define QZ_SPACE 0x31 -/* These are the same as the left versions - use left by default */ -#if 0 -#define QZ_RMETA 0x37 -#define QZ_RALT 0x3A -#define QZ_RCTRL 0x3B -#endif -#define QZ_LEFT 0x7B -#define QZ_DOWN 0x7D -#define QZ_RIGHT 0x7C -#define QZ_KP0 0x52 -#define QZ_KP_PERIOD 0x41 - -/* Wierd, these keys are on my iBook under MacOS X */ -#define QZ_IBOOK_ENTER 0x34 -#define QZ_IBOOK_LEFT 0x3B -#define QZ_IBOOK_RIGHT 0x3C -#define QZ_IBOOK_DOWN 0x3D -#define QZ_IBOOK_UP 0x3E -#define KEY_ENTER 13 -#define KEY_TAB 9 - -#define KEY_BASE 0x100 - -/* Function keys */ -#define KEY_F (KEY_BASE+64) - -/* Control keys */ -#define KEY_CTRL (KEY_BASE) -#define KEY_BACKSPACE (KEY_CTRL+0) -#define KEY_DELETE (KEY_CTRL+1) -#define KEY_INSERT (KEY_CTRL+2) -#define KEY_HOME (KEY_CTRL+3) -#define KEY_END (KEY_CTRL+4) -#define KEY_PAGE_UP (KEY_CTRL+5) -#define KEY_PAGE_DOWN (KEY_CTRL+6) -#define KEY_ESC (KEY_CTRL+7) - -/* Control keys short name */ -#define KEY_BS KEY_BACKSPACE -#define KEY_DEL KEY_DELETE -#define KEY_INS KEY_INSERT -#define KEY_PGUP KEY_PAGE_UP -#define KEY_PGDOWN KEY_PAGE_DOWN -#define KEY_PGDWN KEY_PAGE_DOWN - -/* Cursor movement */ -#define KEY_CRSR (KEY_BASE+16) -#define KEY_RIGHT (KEY_CRSR+0) -#define KEY_LEFT (KEY_CRSR+1) -#define KEY_DOWN (KEY_CRSR+2) -#define KEY_UP (KEY_CRSR+3) - -/* Multimedia keyboard/remote keys */ -#define KEY_MM_BASE (0x100+384) -#define KEY_POWER (KEY_MM_BASE+0) -#define KEY_MENU (KEY_MM_BASE+1) -#define KEY_PLAY (KEY_MM_BASE+2) -#define KEY_PAUSE (KEY_MM_BASE+3) -#define KEY_PLAYPAUSE (KEY_MM_BASE+4) -#define KEY_STOP (KEY_MM_BASE+5) -#define KEY_FORWARD (KEY_MM_BASE+6) -#define KEY_REWIND (KEY_MM_BASE+7) -#define KEY_NEXT (KEY_MM_BASE+8) -#define KEY_PREV (KEY_MM_BASE+9) -#define KEY_VOLUME_UP (KEY_MM_BASE+10) -#define KEY_VOLUME_DOWN (KEY_MM_BASE+11) -#define KEY_MUTE (KEY_MM_BASE+12) - -/* Keypad keys */ -#define KEY_KEYPAD (KEY_BASE+32) -#define KEY_KP0 (KEY_KEYPAD+0) -#define KEY_KP1 (KEY_KEYPAD+1) -#define KEY_KP2 (KEY_KEYPAD+2) -#define KEY_KP3 (KEY_KEYPAD+3) -#define KEY_KP4 (KEY_KEYPAD+4) -#define KEY_KP5 (KEY_KEYPAD+5) -#define KEY_KP6 (KEY_KEYPAD+6) -#define KEY_KP7 (KEY_KEYPAD+7) -#define KEY_KP8 (KEY_KEYPAD+8) -#define KEY_KP9 (KEY_KEYPAD+9) -#define KEY_KPDEC (KEY_KEYPAD+10) -#define KEY_KPINS (KEY_KEYPAD+11) -#define KEY_KPDEL (KEY_KEYPAD+12) -#define KEY_KPENTER (KEY_KEYPAD+13) - -/* Special keys */ -#define KEY_INTERN (0x1000) -#define KEY_CLOSE_WIN (KEY_INTERN+0) diff --git a/src/cmd/fontsrv/osx.c b/src/cmd/fontsrv/mac.c similarity index 100% rename from src/cmd/fontsrv/osx.c rename to src/cmd/fontsrv/mac.c diff --git a/src/cmd/fontsrv/mkfile b/src/cmd/fontsrv/mkfile index 8ad99dbc0..218b7c73a 100644 --- a/src/cmd/fontsrv/mkfile +++ b/src/cmd/fontsrv/mkfile @@ -14,8 +14,6 @@ OFILES=\ <$PLAN9/src/mkone -osx-cocoa.$O: osx.c - showpjw: showpjw.c 9c showpjw.c 9l -o showpjw showpjw.o diff --git a/src/cmd/fontsrv/osx-cocoa.c b/src/cmd/fontsrv/osx-cocoa.c deleted file mode 100644 index 0e36b6e85..000000000 --- a/src/cmd/fontsrv/osx-cocoa.c +++ /dev/null @@ -1 +0,0 @@ -#include "osx.c" diff --git a/src/cmd/snarfer/osx-cocoa-snarfer.c b/src/cmd/snarfer/mac-snarfer.c similarity index 100% rename from src/cmd/snarfer/osx-cocoa-snarfer.c rename to src/cmd/snarfer/mac-snarfer.c diff --git a/src/cmd/snarfer/mkfile b/src/cmd/snarfer/mkfile index 66fa90155..66192085e 100644 --- a/src/cmd/snarfer/mkfile +++ b/src/cmd/snarfer/mkfile @@ -9,4 +9,4 @@ HFILES= <$PLAN9/src/mkone x11-snarfer.$O: snarfer.c -osx-snarfer.$O: snarfer.c +mac-snarfer.$O: snarfer.c diff --git a/src/cmd/snarfer/osx-snarfer.c b/src/cmd/snarfer/osx-snarfer.c deleted file mode 100644 index 613a8cc51..000000000 --- a/src/cmd/snarfer/osx-snarfer.c +++ /dev/null @@ -1 +0,0 @@ -#include "snarfer.c" From 88ed92aa40ab5aa0f563624c488ba2a120990329 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 8 Jan 2020 20:28:17 -0500 Subject: [PATCH 133/323] devdraw: move Client into devdraw.h and move global state in --- include/memdraw.h | 1 - src/cmd/devdraw/devdraw.c | 340 +++++++++++---------------------- src/cmd/devdraw/devdraw.h | 169 +++++++++++++++- src/cmd/devdraw/mac-screen.h | 15 +- src/cmd/devdraw/mac-screen.m | 80 ++++---- src/cmd/devdraw/mac-srv.c | 309 +++++++++++++----------------- src/cmd/devdraw/mkfile | 6 +- src/cmd/devdraw/mkwsysrules.sh | 2 + src/cmd/devdraw/mouseswap.c | 5 + src/cmd/devdraw/winsize.c | 5 + src/cmd/devdraw/x11-init.c | 3 +- 11 files changed, 470 insertions(+), 465 deletions(-) diff --git a/include/memdraw.h b/include/memdraw.h index a22dbe2bb..dc0e0b72f 100644 --- a/include/memdraw.h +++ b/include/memdraw.h @@ -216,7 +216,6 @@ extern Memdrawparam* _memimagedrawsetup(Memimage*, Rectangle, Memimage*, Point, Memimage*, Point, int); extern void _memimagedraw(Memdrawparam*); -extern void _drawreplacescreenimage(Memimage*); #if defined(__cplusplus) } diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 654ab4af6..e83f6f07b 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -8,154 +8,32 @@ #include #include #include +#include +#include +#include +#include #include "devdraw.h" extern void _flushmemscreen(Rectangle); -int forcedpi = 0; -int displaydpi = 100; - -#define NHASH (1<<5) -#define HASHMASK (NHASH-1) - -typedef struct Client Client; -typedef struct Draw Draw; -typedef struct DImage DImage; -typedef struct DScreen DScreen; -typedef struct CScreen CScreen; -typedef struct FChar FChar; -typedef struct Refresh Refresh; -typedef struct Refx Refx; -typedef struct DName DName; - -struct Draw -{ - QLock lk; - int clientid; - int nclient; - Client* client[1]; - int nname; - DName* name; - int vers; - int softscreen; -}; - -struct Client -{ - /*Ref r;*/ - DImage* dimage[NHASH]; - CScreen* cscreen; - Refresh* refresh; - Rendez refrend; - uchar* readdata; - int nreaddata; - int busy; - int clientid; - int slot; - int refreshme; - int infoid; - int op; -}; - -struct Refresh -{ - DImage* dimage; - Rectangle r; - Refresh* next; -}; - -struct Refx -{ - Client* client; - DImage* dimage; -}; - -struct DName -{ - char *name; - Client *client; - DImage* dimage; - int vers; -}; - -struct FChar -{ - int minx; /* left edge of bits */ - int maxx; /* right edge of bits */ - uchar miny; /* first non-zero scan-line */ - uchar maxy; /* last non-zero scan-line + 1 */ - schar left; /* offset of baseline */ - uchar width; /* width of baseline */ -}; - -/* - * Reference counts in DImages: - * one per open by original client - * one per screen image or fill - * one per image derived from this one by name - */ -struct DImage -{ - int id; - int ref; - char *name; - int vers; - Memimage* image; - int ascent; - int nfchar; - FChar* fchar; - DScreen* dscreen; /* 0 if not a window */ - DImage* fromname; /* image this one is derived from, by name */ - DImage* next; -}; - -struct CScreen -{ - DScreen* dscreen; - CScreen* next; -}; - -struct DScreen -{ - int id; - int public; - int ref; - DImage *dimage; - DImage *dfill; - Memscreen* screen; - Client* owner; - DScreen* next; -}; static Draw sdraw; -static Client *client0; -static Memimage *screenimage; -static Rectangle flushrect; -static int waste; -static DScreen* dscreen; +Client *client0; static int drawuninstall(Client*, int); static Memimage* drawinstall(Client*, int, Memimage*, DScreen*); -static void drawfreedimage(DImage*); +static void drawfreedimage(Client*, DImage*); void -_initdisplaymemimage(Memimage *m) +_initdisplaymemimage(Client *c, Memimage *m) { - screenimage = m; + c->screenimage = m; m->screenref = 1; - client0 = mallocz(sizeof(Client), 1); - if(client0 == nil){ - fprint(2, "initdraw: allocating client0: out of memory"); - abort(); - } - client0->slot = 0; - client0->clientid = ++sdraw.clientid; - client0->op = SoverD; - sdraw.client[0] = client0; - sdraw.nclient = 1; - sdraw.softscreen = 1; + c->slot = 0; + c->clientid = 1; + c->op = SoverD; } void -_drawreplacescreenimage(Memimage *m) +_drawreplacescreenimage(Client *c, Memimage *m) { /* * Replace the screen image because the screen @@ -171,14 +49,17 @@ _drawreplacescreenimage(Memimage *m) */ Memimage *om; + qlock(&c->inputlk); qlock(&sdraw.lk); - om = screenimage; - screenimage = m; + om = c->screenimage; + c->screenimage = m; m->screenref = 1; + c->mouse.resized = 1; if(om && --om->screenref == 0){ _freememimage(om); } qunlock(&sdraw.lk); + qunlock(&c->inputlk); } static @@ -222,57 +103,57 @@ drawrefresh(Memimage *m, Rectangle r, void *v) } static void -addflush(Rectangle r) +addflush(Client *c, Rectangle r) { int abb, ar, anbb; Rectangle nbb; - if(sdraw.softscreen==0 || !rectclip(&r, screenimage->r)) + if(/*sdraw.softscreen==0 ||*/ !rectclip(&r, c->screenimage->r)) return; - if(flushrect.min.x >= flushrect.max.x){ - flushrect = r; - waste = 0; + if(c->flushrect.min.x >= c->flushrect.max.x){ + c->flushrect = r; + c->waste = 0; return; } - nbb = flushrect; + nbb = c->flushrect; combinerect(&nbb, r); ar = Dx(r)*Dy(r); - abb = Dx(flushrect)*Dy(flushrect); + abb = Dx(c->flushrect)*Dy(c->flushrect); anbb = Dx(nbb)*Dy(nbb); /* * Area of new waste is area of new bb minus area of old bb, * less the area of the new segment, which we assume is not waste. * This could be negative, but that's OK. */ - waste += anbb-abb - ar; - if(waste < 0) - waste = 0; + c->waste += anbb-abb - ar; + if(c->waste < 0) + c->waste = 0; /* * absorb if: * total area is small * waste is less than half total area * rectangles touch */ - if(anbb<=1024 || waste*2waste*2flushrect, r)){ + c->flushrect = nbb; return; } /* emit current state */ - if(flushrect.min.x < flushrect.max.x) - _flushmemscreen(flushrect); - flushrect = r; - waste = 0; + if(c->flushrect.min.x < c->flushrect.max.x) + _flushmemscreen(c->flushrect); + c->flushrect = r; + c->waste = 0; } static void -dstflush(int dstid, Memimage *dst, Rectangle r) +dstflush(Client *c, int dstid, Memimage *dst, Rectangle r) { Memlayer *l; if(dstid == 0){ - combinerect(&flushrect, r); + combinerect(&c->flushrect, r); return; } /* how can this happen? -rsc, dec 12 2002 */ @@ -284,21 +165,21 @@ dstflush(int dstid, Memimage *dst, Rectangle r) if(l == nil) return; do{ - if(l->screen->image->data != screenimage->data) + if(l->screen->image->data != c->screenimage->data) return; r = rectaddpt(r, l->delta); l = l->screen->image->layer; }while(l); - addflush(r); + addflush(c, r); } static void -drawflush(void) +drawflush(Client *c) { - if(flushrect.min.x < flushrect.max.x) - _flushmemscreen(flushrect); - flushrect = Rect(10000, 10000, -10000, -10000); + if(c->flushrect.min.x < c->flushrect.max.x) + _flushmemscreen(c->flushrect); + c->flushrect = Rect(10000, 10000, -10000, -10000); } static @@ -312,12 +193,12 @@ drawcmp(char *a, char *b, int n) static DName* -drawlookupname(int n, char *str) +drawlookupname(Client *client, int n, char *str) { DName *name, *ename; - name = sdraw.name; - ename = &name[sdraw.nname]; + name = client->name; + ename = &name[client->nname]; for(; namename, str, n) == 0) return name; @@ -326,18 +207,18 @@ drawlookupname(int n, char *str) static int -drawgoodname(DImage *d) +drawgoodname(Client *client, DImage *d) { DName *n; /* if window, validate the screen's own images */ if(d->dscreen) - if(drawgoodname(d->dscreen->dimage) == 0 - || drawgoodname(d->dscreen->dfill) == 0) + if(drawgoodname(client, d->dscreen->dimage) == 0 + || drawgoodname(client, d->dscreen->dfill) == 0) return 0; if(d->name == nil) return 1; - n = drawlookupname(strlen(d->name), d->name); + n = drawlookupname(client, strlen(d->name), d->name); if(n==nil || n->vers!=d->vers) return 0; return 1; @@ -356,7 +237,7 @@ drawlookup(Client *client, int id, int checkname) * BUG: should error out but too hard. * Return 0 instead. */ - if(checkname && !drawgoodname(d)) + if(checkname && !drawgoodname(client, d)) return 0; return d; } @@ -367,11 +248,11 @@ drawlookup(Client *client, int id, int checkname) static DScreen* -drawlookupdscreen(int id) +drawlookupdscreen(Client *c, int id) { DScreen *s; - s = dscreen; + s = c->dscreen; while(s){ if(s->id == id) return s; @@ -466,9 +347,9 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df d->id = id; d->screen = s; d->public = public; - d->next = dscreen; + d->next = client->dscreen; d->owner = client; - dscreen = d; + client->dscreen = d; } c->dscreen = d; d->ref++; @@ -479,18 +360,18 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df static void -drawdelname(DName *name) +drawdelname(Client *client, DName *name) { int i; - i = name-sdraw.name; - memmove(name, name+1, (sdraw.nname-(i+1))*sizeof(DName)); - sdraw.nname--; + i = name-client->name; + memmove(name, name+1, (client->nname-(i+1))*sizeof(DName)); + client->nname--; } static void -drawfreedscreen(DScreen *this) +drawfreedscreen(Client *client, DScreen *this) { DScreen *ds, *next; @@ -499,9 +380,9 @@ drawfreedscreen(DScreen *this) fprint(2, "negative ref in drawfreedscreen\n"); if(this->ref > 0) return; - ds = dscreen; + ds = client->dscreen; if(ds == this){ - dscreen = this->next; + client->dscreen = this->next; goto Found; } while(next = ds->next){ /* assign = */ @@ -518,16 +399,16 @@ drawfreedscreen(DScreen *this) Found: if(this->dimage) - drawfreedimage(this->dimage); + drawfreedimage(client, this->dimage); if(this->dfill) - drawfreedimage(this->dfill); + drawfreedimage(client, this->dfill); free(this->screen); free(this); } static void -drawfreedimage(DImage *dimage) +drawfreedimage(Client *client, DImage *dimage) { int i; Memimage *l; @@ -540,13 +421,13 @@ drawfreedimage(DImage *dimage) return; /* any names? */ - for(i=0; inname; ) + if(client->name[i].dimage == dimage) + drawdelname(client, client->name+i); else i++; if(dimage->fromname){ /* acquired by name; owned by someone else*/ - drawfreedimage(dimage->fromname); + drawfreedimage(client, dimage->fromname); goto Return; } ds = dimage->dscreen; @@ -554,16 +435,16 @@ drawfreedimage(DImage *dimage) dimage->dscreen = nil; /* paranoia */ dimage->image = nil; if(ds){ - if(l->data == screenimage->data) - addflush(l->layer->screenr); + if(l->data == client->screenimage->data) + addflush(client, l->layer->screenr); if(l->layer->refreshfn == drawrefresh) /* else true owner will clean up */ free(l->layer->refreshptr); l->layer->refreshptr = nil; - if(drawgoodname(dimage)) + if(drawgoodname(client, dimage)) memldelete(l); else memlfree(l); - drawfreedscreen(ds); + drawfreedscreen(client, ds); }else{ if(l->screenref==0) freememimage(l); @@ -584,14 +465,14 @@ drawuninstallscreen(Client *client, CScreen *this) cs = client->cscreen; if(cs == this){ client->cscreen = this->next; - drawfreedscreen(this->dscreen); + drawfreedscreen(client, this->dscreen); free(this); return; } while(next = cs->next){ /* assign = */ if(next == this){ cs->next = this->next; - drawfreedscreen(this->dscreen); + drawfreedscreen(client, this->dscreen); free(this); return; } @@ -608,7 +489,7 @@ drawuninstall(Client *client, int id) for(l=&client->dimage[id&HASHMASK]; (d=*l) != nil; l=&d->next){ if(d->id == id){ *l = d->next; - drawfreedimage(d); + drawfreedimage(client, d); return 0; } } @@ -622,14 +503,14 @@ drawaddname(Client *client, DImage *di, int n, char *str, char **err) DName *name, *ename, *new, *t; char *ns; - name = sdraw.name; - ename = &name[sdraw.nname]; + name = client->name; + ename = &name[client->nname]; for(; namename, str, n) == 0){ *err = "image name in use"; return -1; } - t = mallocz((sdraw.nname+1)*sizeof(DName), 1); + t = mallocz((client->nname+1)*sizeof(DName), 1); ns = malloc(n+1); if(t == nil || ns == nil){ free(t); @@ -637,16 +518,16 @@ drawaddname(Client *client, DImage *di, int n, char *str, char **err) *err = "out of memory"; return -1; } - memmove(t, sdraw.name, sdraw.nname*sizeof(DName)); - free(sdraw.name); - sdraw.name = t; - new = &sdraw.name[sdraw.nname++]; + memmove(t, client->name, client->nname*sizeof(DName)); + free(client->name); + client->name = t; + new = &client->name[client->nname++]; new->name = ns; memmove(new->name, str, n); new->name[n] = 0; new->dimage = di; new->client = client; - new->vers = ++sdraw.vers; + new->vers = ++client->namevers; return 0; } @@ -738,12 +619,9 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx) } int -_drawmsgread(void *a, int n) +_drawmsgread(Client *cl, void *a, int n) { - Client *cl; - qlock(&sdraw.lk); - cl = client0; if(cl->readdata == nil){ werrstr("no draw data"); goto err; @@ -765,14 +643,13 @@ _drawmsgread(void *a, int n) } int -_drawmsgwrite(void *v, int n) +_drawmsgwrite(Client *client, void *v, int n) { char cbuf[40], *err, ibuf[12*12+1], *s; int c, ci, doflush, dstid, e0, e1, esize, j, m; int ni, nw, oesize, oldn, op, ox, oy, repl, scrnid, y; uchar *a, refresh, *u; u32int chan, value; - Client *client; CScreen *cs; DImage *di, *ddst, *dsrc, *font, *ll; DName *dn; @@ -790,7 +667,6 @@ _drawmsgwrite(void *v, int n) a = v; m = 0; oldn = n; - client = client0; while((n-=m) > 0){ a += m; @@ -844,7 +720,7 @@ _drawmsgwrite(void *v, int n) l = memlalloc(scrn, r, reffn, 0, value); if(l == 0) goto Edrawmem; - addflush(l->layer->screenr); + addflush(client, l->layer->screenr); l->clipr = clipr; rectclip(&l->clipr, r); if(drawinstall(client, dstid, l, dscrn) == 0){ @@ -891,7 +767,7 @@ _drawmsgwrite(void *v, int n) dstid = BGLONG(a+1); if(dstid == 0) goto Ebadarg; - if(drawlookupdscreen(dstid)) + if(drawlookupdscreen(client, dstid)) goto Escreenexists; ddst = drawlookup(client, BGLONG(a+5), 1); dsrc = drawlookup(client, BGLONG(a+9), 1); @@ -935,7 +811,7 @@ _drawmsgwrite(void *v, int n) drawpoint(&q, a+37); op = drawclientop(client); memdraw(dst, r, src, p, mask, q, op); - dstflush(dstid, dst, r); + dstflush(client, dstid, dst, r); continue; /* toggle debugging: 'D' val[1] */ @@ -984,7 +860,7 @@ _drawmsgwrite(void *v, int n) memarc(dst, p, e0, e1, c, src, sp, ox, oy, op); }else memellipse(dst, p, e0, e1, c, src, sp, op); - dstflush(dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1)); + dstflush(client, dstid, dst, Rect(p.x-e0-j, p.y-e1-j, p.x+e0+j+1, p.y+e1+j+1)); continue; /* free: 'f' id[4] */ @@ -1049,7 +925,7 @@ _drawmsgwrite(void *v, int n) goto Eshortdraw; if(drawlookup(client, 0, 0)) goto Eimageexists; - drawinstall(client, 0, screenimage, 0); + drawinstall(client, 0, client->screenimage, 0); client->infoid = 0; continue; @@ -1061,7 +937,7 @@ _drawmsgwrite(void *v, int n) if(client->infoid < 0) goto Enodrawimage; if(client->infoid == 0){ - i = screenimage; + i = client->screenimage; if(i == nil) goto Enodrawimage; }else{ @@ -1102,10 +978,10 @@ _drawmsgwrite(void *v, int n) err = "unknown query"; goto error; case 'd': /* dpi */ - if(forcedpi) - fmtprint(&fmt, "%11d ", forcedpi); + if(client->forcedpi) + fmtprint(&fmt, "%11d ", client->forcedpi); else - fmtprint(&fmt, "%11d ", displaydpi); + fmtprint(&fmt, "%11d ", client->displaydpi); break; } } @@ -1169,7 +1045,7 @@ _drawmsgwrite(void *v, int n) if(dstid==0 || dst->layer!=nil){ /* BUG: this is terribly inefficient: update maximal containing rect*/ r = memlinebbox(p, q, e0, e1, j); - dstflush(dstid, dst, insetrect(r, -(1+1+j))); + dstflush(client, dstid, dst, insetrect(r, -(1+1+j))); } continue; @@ -1198,7 +1074,7 @@ _drawmsgwrite(void *v, int n) dstid = BGLONG(a+1); if(drawlookup(client, dstid, 0)) goto Eimageexists; - dn = drawlookupname(j, (char*)a+6); + dn = drawlookupname(client, j, (char*)a+6); if(dn == nil) goto Enoname; s = malloc(j+1); @@ -1239,12 +1115,12 @@ _drawmsgwrite(void *v, int n) if(drawaddname(client, di, j, (char*)a+7, &err) < 0) goto error; else{ - dn = drawlookupname(j, (char*)a+7); + dn = drawlookupname(client, j, (char*)a+7); if(dn == nil) goto Enoname; if(dn->dimage != di) goto Ewrongname; - drawdelname(dn); + drawdelname(client, dn); } continue; @@ -1266,8 +1142,8 @@ _drawmsgwrite(void *v, int n) goto error; } if(ni > 0){ - addflush(r); - addflush(dst->layer->screenr); + addflush(client, r); + addflush(client, dst->layer->screenr); ll = drawlookup(client, BGLONG(a+1), 1); drawrefreshscreen(ll, client); } @@ -1316,7 +1192,7 @@ _drawmsgwrite(void *v, int n) if(pp == nil) goto Enomem; doflush = 0; - if(dstid==0 || (dst->layer && dst->layer->screen->image->data == screenimage->data)) + if(dstid==0 || (dst->layer && dst->layer->screen->image->data == client->screenimage->data)) doflush = 1; /* simplify test in loop */ ox = oy = 0; esize = 0; @@ -1353,12 +1229,12 @@ _drawmsgwrite(void *v, int n) combinerect(&r, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1)); } if(rectclip(&r, dst->clipr)) /* should perhaps be an arg to dstflush */ - dstflush(dstid, dst, r); + dstflush(client, dstid, dst, r); } pp[y] = p; } if(y == 1) - dstflush(dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1)); + dstflush(client, dstid, dst, Rect(p.x-esize, p.y-esize, p.x+esize+1, p.y+esize+1)); op = drawclientop(client); if(*a == 'p') mempoly(dst, pp, ni, e0, e1, j, src, sp, op); @@ -1462,7 +1338,7 @@ _drawmsgwrite(void *v, int n) } dst->clipr = clipr; p.y -= font->ascent; - dstflush(dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r))); + dstflush(client, dstid, dst, Rect(p.x, p.y, q.x, p.y+Dy(font->image->r))); continue; /* use public screen: 'S' id[4] chan[4] */ @@ -1473,7 +1349,7 @@ _drawmsgwrite(void *v, int n) dstid = BGLONG(a+1); if(dstid == 0) goto Ebadarg; - dscrn = drawlookupdscreen(dstid); + dscrn = drawlookupdscreen(client, dstid); if(dscrn==0 || (dscrn->public==0 && dscrn->owner!=client)) goto Enodrawscreen; if(dscrn->screen->image->chan != BGLONG(a+5)){ @@ -1522,9 +1398,9 @@ _drawmsgwrite(void *v, int n) memltofrontn(lp, nw); else memltorearn(lp, nw); - if(lp[0]->layer->screen->image->data == screenimage->data) + if(lp[0]->layer->screen->image->data == client->screenimage->data) for(j=0; jlayer->screenr); + addflush(client, lp[j]->layer->screenr); free(lp); ll = drawlookup(client, BGLONG(a+1+1+2), 1); drawrefreshscreen(ll, client); @@ -1533,7 +1409,7 @@ _drawmsgwrite(void *v, int n) /* visible: 'v' */ case 'v': m = 1; - drawflush(); + drawflush(client); continue; /* write: 'y' id[4] R[4*4] data[x*1] */ @@ -1555,7 +1431,7 @@ _drawmsgwrite(void *v, int n) err = "bad writeimage call"; goto error; } - dstflush(dstid, dst, r); + dstflush(client, dstid, dst, r); m += y; continue; } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index f768735f5..40a2ed4e2 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -1,10 +1,167 @@ -int _drawmsgread(void*, int); -int _drawmsgwrite(void*, int); -void _initdisplaymemimage(Memimage*); + +#define NHASH (1<<5) +#define HASHMASK (NHASH-1) + +typedef struct Kbdbuf Kbdbuf; +typedef struct Mousebuf Mousebuf; +typedef struct Tagbuf Tagbuf; + +typedef struct Client Client; +typedef struct Draw Draw; +typedef struct DImage DImage; +typedef struct DScreen DScreen; +typedef struct CScreen CScreen; +typedef struct FChar FChar; +typedef struct Refresh Refresh; +typedef struct Refx Refx; +typedef struct DName DName; + +struct Draw +{ + QLock lk; +}; + +struct Kbdbuf +{ + Rune r[256]; + int ri; + int wi; + int stall; + int alting; +}; + +struct Mousebuf +{ + Mouse m[256]; + Mouse last; + int ri; + int wi; + int stall; + int resized; +}; + +struct Tagbuf +{ + int t[256]; + int ri; + int wi; +}; + +struct Client +{ + /*Ref r;*/ + DImage* dimage[NHASH]; + CScreen* cscreen; + Refresh* refresh; + Rendez refrend; + uchar* readdata; + int nreaddata; + int busy; + int clientid; + int slot; + int refreshme; + int infoid; + int op; + + int displaydpi; + int forcedpi; + int waste; + Rectangle flushrect; + Memimage *screenimage; + DScreen* dscreen; + int nname; + DName* name; + int namevers; + + int rfd; + int wfd; + + QLock inputlk; + Kbdbuf kbd; + Mousebuf mouse; + Tagbuf kbdtags; + Tagbuf mousetags; + Rectangle mouserect; +}; + +struct Refresh +{ + DImage* dimage; + Rectangle r; + Refresh* next; +}; + +struct Refx +{ + Client* client; + DImage* dimage; +}; + +struct DName +{ + char *name; + Client *client; + DImage* dimage; + int vers; +}; + +struct FChar +{ + int minx; /* left edge of bits */ + int maxx; /* right edge of bits */ + uchar miny; /* first non-zero scan-line */ + uchar maxy; /* last non-zero scan-line + 1 */ + schar left; /* offset of baseline */ + uchar width; /* width of baseline */ +}; + +/* + * Reference counts in DImages: + * one per open by original client + * one per screen image or fill + * one per image derived from this one by name + */ +struct DImage +{ + int id; + int ref; + char *name; + int vers; + Memimage* image; + int ascent; + int nfchar; + FChar* fchar; + DScreen* dscreen; /* 0 if not a window */ + DImage* fromname; /* image this one is derived from, by name */ + DImage* next; +}; + +struct CScreen +{ + DScreen* dscreen; + CScreen* next; +}; + +struct DScreen +{ + int id; + int public; + int ref; + DImage *dimage; + DImage *dfill; + Memscreen* screen; + Client* owner; + DScreen* next; +}; + +int _drawmsgread(Client*, void*, int); +int _drawmsgwrite(Client*, void*, int); +void _initdisplaymemimage(Client*, Memimage*); +void _drawreplacescreenimage(Client*, Memimage*); + int _latin1(Rune*, int); int parsewinsize(char*, Rectangle*, int*); int mouseswap(int); -void abortcompose(void); +void abortcompose(Client*); -extern int displaydpi; -extern int forcedpi; +extern Client *client0; diff --git a/src/cmd/devdraw/mac-screen.h b/src/cmd/devdraw/mac-screen.h index b5e3c7010..7bc0920d8 100644 --- a/src/cmd/devdraw/mac-screen.h +++ b/src/cmd/devdraw/mac-screen.h @@ -1,6 +1,6 @@ #define setcursor dsetcursor -Memimage *attachscreen(char*, char*); +Memimage *attachscreen(Client*, char*, char*); void setmouse(Point); void setcursor(Cursor*, Cursor2*); void setlabel(char*); @@ -8,17 +8,12 @@ char* getsnarf(void); void putsnarf(char*); void topwin(void); -void mousetrack(int, int, int, uint); -void keystroke(int); +void mousetrack(Client*, int, int, int, uint); +void keystroke(Client*, int); void kicklabel(char*); -void servep9p(void); -void zlock(void); -void zunlock(void); +void servep9p(Client*); -void resizeimg(void); +void resizeimg(Client*); -Rectangle mouserect; - -int mouseresized; void resizewindow(Rectangle); diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index c115f8678..b71f653d0 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -15,10 +15,13 @@ #include #include #include -#include +#include +#include #include -#include "mac-screen.h" +#include +#include #include "devdraw.h" +#include "mac-screen.h" #include "bigarrow.h" #include "glendapng.h" @@ -31,7 +34,7 @@ static void setprocname(const char*); static uint keycvt(uint); static uint msec(void); -static Memimage* initimg(void); +static Memimage* initimg(Client*); void usage(void) @@ -48,6 +51,7 @@ + (void)callsetNeedsDisplayInRect:(NSValue *)v; + (void)callsetcursor:(NSValue *)v; @end @interface DevDrawView : NSView +@property (nonatomic) Client *client; - (void)clearInput; - (void)getmouse:(NSEvent *)e; - (void)sendmouse:(NSUInteger)b; @@ -96,6 +100,13 @@ @interface DrawLayer : CAMetalLayer usage(); }ARGEND + client0 = mallocz(sizeof(Client), 1); + client0->displaydpi = 100; + if(client0 == nil){ + fprint(2, "initdraw: allocating client0: out of memory"); + abort(); + } + setprocname(argv0); @autoreleasepool{ @@ -113,7 +124,9 @@ @interface DrawLayer : CAMetalLayer { USED(v); - servep9p(); + client0->rfd = 3; + client0->wfd = 4; + servep9p(client0); [NSApp terminate:myApp]; } @@ -167,6 +180,7 @@ + (void)makewin:(NSValue *)v [win setDelegate:myApp]; myContent = [DevDrawView new]; + myContent.client = client0; [win setContentView:myContent]; [myContent setWantsLayer:YES]; [myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; @@ -353,7 +367,7 @@ - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl - (void)windowDidResize:(NSNotification *)notification { if(![myContent inLiveResize] && img) { - resizeimg(); + resizeimg(myContent.client); } } @@ -463,7 +477,7 @@ - (void)flagsChanged:(NSEvent*)e b |= 4; [self sendmouse:b]; }else if(m & ~omod & NSEventModifierFlagOption) - keystroke(Kalt); + keystroke(self.client, Kalt); omod = m; } @@ -520,7 +534,7 @@ - (void)getmouse:(NSEvent *)e if(b == 1){ m = [e modifierFlags]; if(m & NSEventModifierFlagOption){ - abortcompose(); + abortcompose(self.client); b = 2; }else if(m & NSEventModifierFlagCommand) @@ -535,9 +549,9 @@ - (void)sendmouse:(NSUInteger)b p = [self.window convertPointToBacking: [self.window mouseLocationOutsideOfEventStream]]; - p.y = Dy(mouserect) - p.y; + p.y = Dy(self.client->mouserect) - p.y; // LOG(@"(%g, %g) <- sendmouse(%d)", p.x, p.y, (uint)b); - mousetrack(p.x, p.y, b, msec()); + mousetrack(self.client, p.x, p.y, b, msec()); if(b && _lastInputRect.size.width && _lastInputRect.size.height) [self resetLastInputRect]; } @@ -551,14 +565,14 @@ - (void)viewDidEndLiveResize { [super viewDidEndLiveResize]; if(img) - resizeimg(); + resizeimg(self.client); } - (void)viewDidChangeBackingProperties { [super viewDidChangeBackingProperties]; if(img) - resizeimg(); + resizeimg(self.client); } // conforms to protocol NSTextInputClient @@ -617,24 +631,24 @@ - (void)setMarkedText:(id)string LOG(@"text length %ld", _tmpText.length); for(i = 0; i <= _tmpText.length; ++i){ if(i == _markedRange.location) - keystroke('['); + keystroke(self.client, '['); if(_selectedRange.length){ if(i == _selectedRange.location) - keystroke('{'); + keystroke(self.client, '{'); if(i == NSMaxRange(_selectedRange)) - keystroke('}'); + keystroke(self.client, '}'); } if(i == NSMaxRange(_markedRange)) - keystroke(']'); + keystroke(self.client, ']'); if(i < _tmpText.length) - keystroke([_tmpText characterAtIndex:i]); + keystroke(self.client, [_tmpText characterAtIndex:i]); } int l; l = 1 + _tmpText.length - NSMaxRange(_selectedRange) + (_selectedRange.length > 0); LOG(@"move left %d", l); for(i = 0; i < l; ++i) - keystroke(Kleft); + keystroke(self.client, Kleft); } LOG(@"text: \"%@\" (%ld,%ld) (%ld,%ld)", _tmpText, @@ -649,7 +663,7 @@ - (void)unmarkText LOG(@"unmarkText"); len = [_tmpText length]; //for(i = 0; i < len; ++i) - // keystroke([_tmpText characterAtIndex:i]); + // keystroke(self.client, [_tmpText characterAtIndex:i]); [_tmpText deleteCharactersInRange:NSMakeRange(0, len)]; _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); @@ -691,7 +705,7 @@ - (void)insertText:(id)s len = [s length]; for(i = 0; i < len; ++i) - keystroke([s characterAtIndex:i]); + keystroke(self.client, [s characterAtIndex:i]); [_tmpText deleteCharactersInRange:NSMakeRange(0, _tmpText.length)]; _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); @@ -731,7 +745,7 @@ - (void)doCommandBySelector:(SEL)s k += Kcmd; } if(k>0) - keystroke(k); + keystroke(self.client, k); } // Helper for managing input rect approximately @@ -762,11 +776,11 @@ - (void)clearInput + (_selectedRange.length > 0); LOG(@"move right %d", l); for(i = 0; i < l; ++i) - keystroke(Kright); + keystroke(self.client, Kright); l = _tmpText.length+2+2*(_selectedRange.length > 0); LOG(@"backspace %d", l); for(uint i = 0; i < l; ++i) - keystroke(Kbs); + keystroke(self.client, Kbs); } } @@ -915,7 +929,7 @@ - (void)display } Memimage* -attachscreen(char *label, char *winsize) +attachscreen(Client *c, char *label, char *winsize) { LOG(@"attachscreen(%s, %s)", label, winsize); [AppDelegate @@ -924,12 +938,12 @@ - (void)display waitUntilDone:YES]; kicklabel(label); setcursor(nil, nil); - mouseresized = 0; - return initimg(); + c->mouse.resized = 0; + return initimg(c); } static Memimage* -initimg(void) +initimg(Client *c) { @autoreleasepool{ CGFloat scale; @@ -937,11 +951,11 @@ - (void)display MTLTextureDescriptor *textureDesc; size = [myContent convertSizeToBacking:[myContent bounds].size]; - mouserect = Rect(0, 0, size.width, size.height); + c->mouserect = Rect(0, 0, size.width, size.height); LOG(@"initimg %.0f %.0f", size.width, size.height); - img = allocmemimage(mouserect, XRGB32); + img = allocmemimage(c->mouserect, XRGB32); if(img == nil) panic("allocmemimage: %r"); if(img->data == nil) @@ -966,7 +980,7 @@ - (void)display // This formula gives us 220 for retina, 110 otherwise. // That's not quite right but it's close to correct. // https://en.wikipedia.org/wiki/Retina_display#Models - displaydpi = scale * 110; + c->displaydpi = scale * 110; } LOG(@"initimg return"); @@ -1109,13 +1123,9 @@ - (void)display } void -resizeimg(void) +resizeimg(Client *c) { - zlock(); - _drawreplacescreenimage(initimg()); - - mouseresized = 1; - zunlock(); + _drawreplacescreenimage(c, initimg(c)); [myContent sendmouse:0]; } diff --git a/src/cmd/devdraw/mac-srv.c b/src/cmd/devdraw/mac-srv.c index b0925eee5..6727ef631 100644 --- a/src/cmd/devdraw/mac-srv.c +++ b/src/cmd/devdraw/mac-srv.c @@ -7,70 +7,23 @@ #include #include #include +#include #include #include #include #include -#include "mac-screen.h" #include "devdraw.h" +#include "mac-screen.h" -typedef struct Kbdbuf Kbdbuf; -typedef struct Mousebuf Mousebuf; -typedef struct Fdbuf Fdbuf; -typedef struct Tagbuf Tagbuf; - -struct Kbdbuf -{ - Rune r[256]; - int ri; - int wi; - int stall; -}; - -struct Mousebuf -{ - Mouse m[256]; - Mouse last; - int ri; - int wi; - int stall; -}; - -struct Tagbuf -{ - int t[256]; - int ri; - int wi; -}; - -Kbdbuf kbd; -Mousebuf mouse; -Tagbuf kbdtags; -Tagbuf mousetags; - -void runmsg(Wsysmsg*); -void replymsg(Wsysmsg*); -void matchkbd(void); -void matchmouse(void); - - -QLock lk; -void -zlock(void) -{ - qlock(&lk); -} - -void -zunlock(void) -{ - qunlock(&lk); -} +void runmsg(Client*, Wsysmsg*); +void replymsg(Client*, Wsysmsg*); +void matchkbd(Client*); +void matchmouse(Client*); int trace = 0; void -servep9p(void) +servep9p(Client *c) { uchar buf[4], *mbuf; int nmbuf, n, nn; @@ -80,7 +33,7 @@ servep9p(void) mbuf = nil; nmbuf = 0; - while((n = read(3, buf, 4)) == 4){ + while((n = read(c->rfd, buf, 4)) == 4){ GET(buf, n); if(n > nmbuf){ free(mbuf); @@ -90,7 +43,7 @@ servep9p(void) nmbuf = n; } memmove(mbuf, buf, 4); - nn = readn(3, mbuf+4, n-4); + nn = readn(c->rfd, mbuf+4, n-4); if(nn != n-4) sysfatal("eof during message"); @@ -98,19 +51,19 @@ servep9p(void) if(convM2W(mbuf, nn+4, &m) <= 0) sysfatal("cannot convert message"); if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m); - runmsg(&m); + runmsg(c, &m); } } void -replyerror(Wsysmsg *m) +replyerror(Client *c, Wsysmsg *m) { char err[256]; rerrstr(err, sizeof err); m->type = Rerror; m->error = err; - replymsg(m); + replymsg(c, m); } /* @@ -118,7 +71,7 @@ replyerror(Wsysmsg *m) * Might queue for later (kbd, mouse read) */ void -runmsg(Wsysmsg *m) +runmsg(Client *c, Wsysmsg *m) { static uchar buf[65536]; int n; @@ -127,38 +80,38 @@ runmsg(Wsysmsg *m) switch(m->type){ case Tinit: memimageinit(); - i = attachscreen(m->label, m->winsize); - _initdisplaymemimage(i); - replymsg(m); + i = attachscreen(c, m->label, m->winsize); + _initdisplaymemimage(c, i); + replymsg(c, m); break; case Trdmouse: - zlock(); - mousetags.t[mousetags.wi++] = m->tag; - if(mousetags.wi == nelem(mousetags.t)) - mousetags.wi = 0; - if(mousetags.wi == mousetags.ri) + qlock(&c->inputlk); + c->mousetags.t[c->mousetags.wi++] = m->tag; + if(c->mousetags.wi == nelem(c->mousetags.t)) + c->mousetags.wi = 0; + if(c->mousetags.wi == c->mousetags.ri) sysfatal("too many queued mouse reads"); - mouse.stall = 0; - matchmouse(); - zunlock(); + c->mouse.stall = 0; + matchmouse(c); + qunlock(&c->inputlk); break; case Trdkbd: - zlock(); - kbdtags.t[kbdtags.wi++] = m->tag; - if(kbdtags.wi == nelem(kbdtags.t)) - kbdtags.wi = 0; - if(kbdtags.wi == kbdtags.ri) + qlock(&c->inputlk); + c->kbdtags.t[c->kbdtags.wi++] = m->tag; + if(c->kbdtags.wi == nelem(c->kbdtags.t)) + c->kbdtags.wi = 0; + if(c->kbdtags.wi == c->kbdtags.ri) sysfatal("too many queued keyboard reads"); - kbd.stall = 0; - matchkbd(); - zunlock(); + c->kbd.stall = 0; + matchkbd(c); + qunlock(&c->inputlk); break; case Tmoveto: setmouse(m->mouse.xy); - replymsg(m); + replymsg(c, m); break; case Tcursor: @@ -166,7 +119,7 @@ runmsg(Wsysmsg *m) setcursor(nil, nil); else setcursor(&m->cursor, nil); - replymsg(m); + replymsg(c, m); break; case Tcursor2: @@ -174,63 +127,63 @@ runmsg(Wsysmsg *m) setcursor(nil, nil); else setcursor(&m->cursor, &m->cursor2); - replymsg(m); + replymsg(c, m); break; case Tbouncemouse: // _xbouncemouse(&m->mouse); - replymsg(m); + replymsg(c, m); break; case Tlabel: kicklabel(m->label); - replymsg(m); + replymsg(c, m); break; case Trdsnarf: m->snarf = getsnarf(); - replymsg(m); + replymsg(c, m); free(m->snarf); break; case Twrsnarf: putsnarf(m->snarf); - replymsg(m); + replymsg(c, m); break; case Trddraw: - zlock(); + qlock(&c->inputlk); n = m->count; if(n > sizeof buf) n = sizeof buf; - n = _drawmsgread(buf, n); + n = _drawmsgread(c, buf, n); if(n < 0) - replyerror(m); + replyerror(c, m); else{ m->count = n; m->data = buf; - replymsg(m); + replymsg(c, m); } - zunlock(); + qunlock(&c->inputlk); break; case Twrdraw: - zlock(); - if(_drawmsgwrite(m->data, m->count) < 0) - replyerror(m); + qlock(&c->inputlk); + if(_drawmsgwrite(c, m->data, m->count) < 0) + replyerror(c, m); else - replymsg(m); - zunlock(); + replymsg(c, m); + qunlock(&c->inputlk); break; case Ttop: topwin(); - replymsg(m); + replymsg(c, m); break; case Tresize: resizewindow(m->rect); - replymsg(m); + replymsg(c, m); break; } } @@ -240,7 +193,7 @@ runmsg(Wsysmsg *m) */ QLock replylock; void -replymsg(Wsysmsg *m) +replymsg(Client *c, Wsysmsg *m) { int n; static uchar *mbuf; @@ -263,7 +216,7 @@ replymsg(Wsysmsg *m) nmbuf = n; } convW2M(m, mbuf, n); - if(write(4, mbuf, n) != n) + if(write(c->wfd, mbuf, n) != n) sysfatal("write: %r"); qunlock(&replylock); } @@ -272,21 +225,21 @@ replymsg(Wsysmsg *m) * Match queued kbd reads with queued kbd characters. */ void -matchkbd(void) +matchkbd(Client *c) { Wsysmsg m; - if(kbd.stall) + if(c->kbd.stall) return; - while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){ + while(c->kbd.ri != c->kbd.wi && c->kbdtags.ri != c->kbdtags.wi){ m.type = Rrdkbd; - m.tag = kbdtags.t[kbdtags.ri++]; - if(kbdtags.ri == nelem(kbdtags.t)) - kbdtags.ri = 0; - m.rune = kbd.r[kbd.ri++]; - if(kbd.ri == nelem(kbd.r)) - kbd.ri = 0; - replymsg(&m); + m.tag = c->kbdtags.t[c->kbdtags.ri++]; + if(c->kbdtags.ri == nelem(c->kbdtags.t)) + c->kbdtags.ri = 0; + m.rune = c->kbd.r[c->kbd.ri++]; + if(c->kbd.ri == nelem(c->kbd.r)) + c->kbd.ri = 0; + replymsg(c, &m); } } @@ -294,131 +247,129 @@ matchkbd(void) * Match queued mouse reads with queued mouse events. */ void -matchmouse(void) +matchmouse(Client *c) { Wsysmsg m; - while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){ + while(c->mouse.ri != c->mouse.wi && c->mousetags.ri != c->mousetags.wi){ m.type = Rrdmouse; - m.tag = mousetags.t[mousetags.ri++]; - if(mousetags.ri == nelem(mousetags.t)) - mousetags.ri = 0; - m.mouse = mouse.m[mouse.ri]; - m.resized = mouseresized; - mouseresized = 0; + m.tag = c->mousetags.t[c->mousetags.ri++]; + if(c->mousetags.ri == nelem(c->mousetags.t)) + c->mousetags.ri = 0; + m.mouse = c->mouse.m[c->mouse.ri]; + m.resized = c->mouse.resized; + c->mouse.resized = 0; /* if(m.resized) fprint(2, "sending resize\n"); */ - mouse.ri++; - if(mouse.ri == nelem(mouse.m)) - mouse.ri = 0; - replymsg(&m); + c->mouse.ri++; + if(c->mouse.ri == nelem(c->mouse.m)) + c->mouse.ri = 0; + replymsg(c, &m); } } void -mousetrack(int x, int y, int b, uint ms) +mousetrack(Client *c, int x, int y, int b, uint ms) { Mouse *m; - if(x < mouserect.min.x) - x = mouserect.min.x; - if(x > mouserect.max.x) - x = mouserect.max.x; - if(y < mouserect.min.y) - y = mouserect.min.y; - if(y > mouserect.max.y) - y = mouserect.max.y; + if(x < c->mouserect.min.x) + x = c->mouserect.min.x; + if(x > c->mouserect.max.x) + x = c->mouserect.max.x; + if(y < c->mouserect.min.y) + y = c->mouserect.min.y; + if(y > c->mouserect.max.y) + y = c->mouserect.max.y; - zlock(); + qlock(&c->inputlk); // If reader has stopped reading, don't bother. // If reader is completely caught up, definitely queue. // Otherwise, queue only button change events. - if(!mouse.stall) - if(mouse.wi == mouse.ri || mouse.last.buttons != b){ - m = &mouse.last; + if(!c->mouse.stall) + if(c->mouse.wi == c->mouse.ri || c->mouse.last.buttons != b){ + m = &c->mouse.last; m->xy.x = x; m->xy.y = y; m->buttons = b; m->msec = ms; - mouse.m[mouse.wi] = *m; - if(++mouse.wi == nelem(mouse.m)) - mouse.wi = 0; - if(mouse.wi == mouse.ri){ - mouse.stall = 1; - mouse.ri = 0; - mouse.wi = 1; - mouse.m[0] = *m; + c->mouse.m[c->mouse.wi] = *m; + if(++c->mouse.wi == nelem(c->mouse.m)) + c->mouse.wi = 0; + if(c->mouse.wi == c->mouse.ri){ + c->mouse.stall = 1; + c->mouse.ri = 0; + c->mouse.wi = 1; + c->mouse.m[0] = *m; } - matchmouse(); + matchmouse(c); } - zunlock(); + qunlock(&c->inputlk); } void -kputc(int c) +kputc(Client *c, int ch) { - zlock(); - kbd.r[kbd.wi++] = c; - if(kbd.wi == nelem(kbd.r)) - kbd.wi = 0; - if(kbd.ri == kbd.wi) - kbd.stall = 1; - matchkbd(); - zunlock(); + qlock(&c->inputlk); + c->kbd.r[c->kbd.wi++] = ch; + if(c->kbd.wi == nelem(c->kbd.r)) + c->kbd.wi = 0; + if(c->kbd.ri == c->kbd.wi) + c->kbd.stall = 1; + matchkbd(c); + qunlock(&c->inputlk); } -static int alting; - void -abortcompose(void) +abortcompose(Client *c) { - if(alting) - keystroke(Kalt); + if(c->kbd.alting) + keystroke(c, Kalt); } void -keystroke(int c) +keystroke(Client *c, int ch) { static Rune k[10]; static int nk; int i; - if(c == Kalt){ - alting = !alting; + if(ch == Kalt){ + c->kbd.alting = !c->kbd.alting; nk = 0; return; } - if(c == Kcmd+'r') { - if(forcedpi) - forcedpi = 0; - else if(displaydpi >= 200) - forcedpi = 100; + if(ch == Kcmd+'r') { + if(c->forcedpi) + c->forcedpi = 0; + else if(c->displaydpi >= 200) + c->forcedpi = 100; else - forcedpi = 225; - resizeimg(); + c->forcedpi = 225; + resizeimg(c); return; } - if(!alting){ - kputc(c); + if(!c->kbd.alting){ + kputc(c, ch); return; } if(nk >= nelem(k)) // should not happen nk = 0; - k[nk++] = c; - c = _latin1(k, nk); - if(c > 0){ - alting = 0; - kputc(c); + k[nk++] = ch; + ch = _latin1(k, nk); + if(ch > 0){ + c->kbd.alting = 0; + kputc(c, ch); nk = 0; return; } - if(c == -1){ - alting = 0; + if(ch == -1){ + c->kbd.alting = 0; for(i=0; i/dev/null | sed 's/\.c$/.o/'` echo 'WSYSOFILES=$WSYSOFILES '$XO + echo 'WSYSHFILES=x11-inc.h x11-keysym2ucs.h x11-memdraw.h' elif [ $WSYSTYPE = mac ]; then echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o mac-srv.o' + echo 'WSYSHFILES=mac-screen.h' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' diff --git a/src/cmd/devdraw/mouseswap.c b/src/cmd/devdraw/mouseswap.c index 29f33b7bf..d2dea6669 100644 --- a/src/cmd/devdraw/mouseswap.c +++ b/src/cmd/devdraw/mouseswap.c @@ -2,6 +2,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "devdraw.h" enum diff --git a/src/cmd/devdraw/winsize.c b/src/cmd/devdraw/winsize.c index 375401bf0..7d0a7b70b 100644 --- a/src/cmd/devdraw/winsize.c +++ b/src/cmd/devdraw/winsize.c @@ -2,6 +2,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "devdraw.h" int diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index 8935c9d15..4b5b570d2 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -232,7 +233,7 @@ _xattach(char *label, char *winsize) if (XrmGetResource(database, "Xft.dpi", "String", &dpitype, &dpires) == True) { if (dpires.addr) { - displaydpi=atoi(dpires.addr); + client0->displaydpi = atoi(dpires.addr); } } geom = smprint("%s.geometry", label); From 843e5af1986a2e8f1c4f6177dc4509501711a22c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 9 Jan 2020 00:40:32 -0500 Subject: [PATCH 134/323] devdraw: move per-window globals in mac-screen.m into Client --- src/cmd/devdraw/devdraw.h | 1 + src/cmd/devdraw/mac-screen.m | 141 +++++++++++++++++++-------------- src/cmd/devdraw/mkwsysrules.sh | 1 - 3 files changed, 81 insertions(+), 62 deletions(-) diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 40a2ed4e2..fe9532b3a 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -75,6 +75,7 @@ struct Client int rfd; int wfd; + void* view; QLock inputlk; Kbdbuf kbd; diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index b71f653d0..8ce8a0cdb 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -43,36 +43,35 @@ threadexitsall("usage"); } - -@interface AppDelegate : NSObject +@interface DrawLayer : CAMetalLayer +@end +@interface AppDelegate : NSObject + (void)makewin:(NSValue *)v; + (void)callkicklabel:(NSString *)v; + (void)callsetNeedsDisplayInRect:(NSValue *)v; + (void)callsetcursor:(NSValue *)v; @end -@interface DevDrawView : NSView -@property (nonatomic) Client *client; + +@interface DevDrawView : NSView +@property (nonatomic, assign) Client *client; +@property (nonatomic, assign) DrawLayer *dlayer; +@property (nonatomic, assign) NSWindow *win; +@property (nonatomic, assign) NSCursor *currentCursor; +@property (nonatomic, assign) Memimage *img; + - (void)clearInput; - (void)getmouse:(NSEvent *)e; - (void)sendmouse:(NSUInteger)b; - (void)resetLastInputRect; - (void)enlargeLastInputRect:(NSRect)r; @end -@interface DrawLayer : CAMetalLayer -@end static AppDelegate *myApp = NULL; -static DevDrawView *myContent = NULL; -static NSWindow *win = NULL; -static NSCursor *currentCursor = NULL; -static DrawLayer *layer; static id device; static id commandQueue; static id texture; -static Memimage *img = NULL; - static QLock snarfl; void @@ -164,7 +163,7 @@ + (void)makewin:(NSValue *)v r.size.height = fmin(Dy(wr), r.size.height); r = [NSWindow contentRectForFrameRect:r styleMask:Winstyle]; - win = [[NSWindow alloc] + NSWindow *win = [[NSWindow alloc] initWithContentRect:r styleMask:Winstyle backing:NSBackingStoreBuffered defer:NO]; @@ -177,13 +176,16 @@ + (void)makewin:(NSValue *)v [win setOpaque:YES]; [win setRestorable:NO]; [win setAcceptsMouseMovedEvents:YES]; - [win setDelegate:myApp]; - myContent = [DevDrawView new]; - myContent.client = client0; - [win setContentView:myContent]; - [myContent setWantsLayer:YES]; - [myContent setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; + DevDrawView *view = [DevDrawView new]; + client0->view = view; + view.client = client0; + view.win = win; + view.currentCursor = nil; + [win setContentView:view]; + [win setDelegate:view]; + [view setWantsLayer:YES]; + [view setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; device = nil; allDevices = MTLCopyAllDevices(); @@ -198,7 +200,8 @@ + (void)makewin:(NSValue *)v commandQueue = [device newCommandQueue]; - layer = (DrawLayer *)[myContent layer]; + DrawLayer *layer = (DrawLayer *)[view layer]; + view.dlayer = layer; layer.device = device; layer.pixelFormat = MTLPixelFormatBGRA8Unorm; layer.framebufferOnly = YES; @@ -220,8 +223,10 @@ + (void)makewin:(NSValue *)v + (void)callkicklabel:(NSString *)s { + DevDrawView *view = client0->view; + LOG(@"callkicklabel(%@)", s); - [win setTitle:s]; + [view.win setTitle:s]; [[NSApp dockTile] setBadgeLabel:s]; } @@ -230,19 +235,20 @@ + (void)callsetNeedsDisplayInRect:(NSValue *)v { NSRect r; dispatch_time_t time; + DevDrawView *view = client0->view; r = [v rectValue]; LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); - r = [win convertRectFromBacking:r]; + r = [view.win convertRectFromBacking:r]; LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); - [layer setNeedsDisplayInRect:r]; + [view.dlayer setNeedsDisplayInRect:r]; time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); dispatch_after(time, dispatch_get_main_queue(), ^(void){ - [layer setNeedsDisplayInRect:r]; + [view.dlayer setNeedsDisplayInRect:r]; }); - [myContent enlargeLastInputRect:r]; + [view enlargeLastInputRect:r]; } typedef struct Cursors Cursors; @@ -261,6 +267,7 @@ + (void)callsetcursor:(NSValue *)v NSPoint p; uchar *plane[5], *plane2[5]; uint b; + DevDrawView *view = client0->view; cs = [v pointerValue]; c = cs->c; @@ -321,9 +328,9 @@ + (void)callsetcursor:(NSValue *)v [i addRepresentation:r]; p = NSMakePoint(-c->offset.x, -c->offset.y); - currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; + view.currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; - [win invalidateCursorRectsForView:myContent]; + [view.win invalidateCursorRectsForView:view]; } - (void)applicationDidFinishLaunching:(id)arg @@ -363,19 +370,6 @@ - (NSApplicationPresentationOptions)window:(id)arg - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { return YES; } - -- (void)windowDidResize:(NSNotification *)notification -{ - if(![myContent inLiveResize] && img) { - resizeimg(myContent.client); - } -} - -- (void)windowDidBecomeKey:(id)arg -{ - [myContent sendmouse:0]; -} - @end @implementation DevDrawView @@ -400,6 +394,18 @@ - (id)init return self; } +- (void)windowDidResize:(NSNotification *)notification +{ + if(![self inLiveResize] && self.img) { + resizeimg(self.client); + } +} + +- (void)windowDidBecomeKey:(id)arg +{ + [self sendmouse:0]; +} + - (CALayer *)makeBackingLayer { LOG(@"makeBackingLayer"); @@ -558,20 +564,20 @@ - (void)sendmouse:(NSUInteger)b - (void)resetCursorRects { [super resetCursorRects]; - [self addCursorRect:self.bounds cursor:currentCursor]; + [self addCursorRect:self.bounds cursor:self.currentCursor]; } - (void)viewDidEndLiveResize { [super viewDidEndLiveResize]; - if(img) + if(self.img) resizeimg(self.client); } - (void)viewDidChangeBackingProperties { [super viewDidChangeBackingProperties]; - if(img) + if(self.img) resizeimg(self.client); } @@ -801,8 +807,9 @@ - (void)display @autoreleasepool{ id drawable; + DevDrawView *view = client0->view; - drawable = [layer nextDrawable]; + drawable = [view.dlayer nextDrawable]; if(!drawable){ LOG(@"display couldn't get drawable"); [self setNeedsDisplay]; @@ -945,20 +952,22 @@ - (void)display static Memimage* initimg(Client *c) { + DevDrawView *view = c->view; + @autoreleasepool{ CGFloat scale; NSSize size; MTLTextureDescriptor *textureDesc; - size = [myContent convertSizeToBacking:[myContent bounds].size]; + size = [view convertSizeToBacking:[view bounds].size]; c->mouserect = Rect(0, 0, size.width, size.height); LOG(@"initimg %.0f %.0f", size.width, size.height); - img = allocmemimage(c->mouserect, XRGB32); - if(img == nil) + view.img = allocmemimage(c->mouserect, XRGB32); + if(view.img == nil) panic("allocmemimage: %r"); - if(img->data == nil) + if(view.img->data == nil) panic("img->data == nil"); textureDesc = [MTLTextureDescriptor @@ -971,9 +980,9 @@ - (void)display textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; texture = [device newTextureWithDescriptor:textureDesc]; - scale = [win backingScaleFactor]; - [layer setDrawableSize:size]; - [layer setContentsScale:scale]; + scale = [view.win backingScaleFactor]; + [view.dlayer setDrawableSize:size]; + [view.dlayer setContentsScale:scale]; // NOTE: This is not really the display DPI. // On retina, scale is 2; otherwise it is 1. @@ -984,12 +993,14 @@ - (void)display } LOG(@"initimg return"); - return img; + return view.img; } void _flushmemscreen(Rectangle r) { + DevDrawView *view = client0->view; + LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); if(!rectinrect(r, Rect(0, 0, texture.width, texture.height))){ LOG(@"Rectangle is out of bounds, return."); @@ -1000,8 +1011,8 @@ - (void)display [texture replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) mipmapLevel:0 - withBytes:byteaddr(img, Pt(r.min.x, r.min.y)) - bytesPerRow:img->width*sizeof(u32int)]; + withBytes:byteaddr(view.img, Pt(r.min.x, r.min.y)) + bytesPerRow:view.img->width*sizeof(u32int)]; [AppDelegate performSelectorOnMainThread:@selector(callsetNeedsDisplayInRect:) withObject:[NSValue valueWithRect:NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r))] @@ -1012,15 +1023,17 @@ - (void)display void setmouse(Point p) { + DevDrawView *view = client0->view; + @autoreleasepool{ NSPoint q; LOG(@"setmouse(%d,%d)", p.x, p.y); - q = [win convertPointFromBacking:NSMakePoint(p.x, p.y)]; + q = [view.win convertPointFromBacking:NSMakePoint(p.x, p.y)]; LOG(@"(%g, %g) <- fromBacking", q.x, q.y); - q = [myContent convertPoint:q toView:nil]; + q = [view convertPoint:q toView:nil]; LOG(@"(%g, %g) <- toWindow", q.x, q.y); - q = [win convertPointToScreen:q]; + q = [view.win convertPointToScreen:q]; LOG(@"(%g, %g) <- toScreen", q.x, q.y); // Quartz has the origin of the "global display // coordinate space" at the top left of the primary @@ -1113,7 +1126,9 @@ - (void)display void topwin(void) { - [win + DevDrawView *view = client0->view; + + [view.win performSelectorOnMainThread: @selector(makeKeyAndOrderFront:) withObject:nil @@ -1125,19 +1140,23 @@ - (void)display void resizeimg(Client *c) { + DevDrawView *view = c->view; + _drawreplacescreenimage(c, initimg(c)); - [myContent sendmouse:0]; + [view sendmouse:0]; } void resizewindow(Rectangle r) { + DevDrawView *view = client0->view; + LOG(@"resizewindow %d %d %d %d", r.min.x, r.min.y, Dx(r), Dy(r)); dispatch_async(dispatch_get_main_queue(), ^(void){ NSSize s; - s = [myContent convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; - [win setContentSize:s]; + s = [view convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; + [view.win setContentSize:s]; }); } diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index ec660bd12..cd72120f1 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -53,7 +53,6 @@ if [ $WSYSTYPE = x11 ]; then echo 'WSYSOFILES=$WSYSOFILES '$XO echo 'WSYSHFILES=x11-inc.h x11-keysym2ucs.h x11-memdraw.h' elif [ $WSYSTYPE = mac ]; then - echo 'OBJCFLAGS=$OBJCFLAGS -fobjc-arc' echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o mac-srv.o' echo 'WSYSHFILES=mac-screen.h' echo 'MACARGV=macargv.o' From b1a086dee9bf5846b31323ba2c438f8853a9c87f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 9 Jan 2020 21:47:14 -0500 Subject: [PATCH 135/323] devdraw: refactor, clean up mac screen Also turn mac-srv.c into a generic srv.c, so we can remove the duplication with x11-srv.c. --- src/cmd/devdraw/devdraw.c | 8 +- src/cmd/devdraw/devdraw.h | 22 +- src/cmd/devdraw/mac-screen.h | 19 - src/cmd/devdraw/mac-screen.m | 827 +++++++++++++-------------- src/cmd/devdraw/mkfile | 3 +- src/cmd/devdraw/mkwsysrules.sh | 4 +- src/cmd/devdraw/{mac-srv.c => srv.c} | 114 ++-- 7 files changed, 492 insertions(+), 505 deletions(-) delete mode 100644 src/cmd/devdraw/mac-screen.h rename src/cmd/devdraw/{mac-srv.c => srv.c} (75%) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index e83f6f07b..77a3f44a2 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -14,8 +14,6 @@ #include #include "devdraw.h" -extern void _flushmemscreen(Rectangle); - static Draw sdraw; Client *client0; static int drawuninstall(Client*, int); @@ -32,6 +30,8 @@ _initdisplaymemimage(Client *c, Memimage *m) c->op = SoverD; } +// _drawreplacescreen replaces c's screen image with m. +// It is called by the host driver on the main host thread. void _drawreplacescreenimage(Client *c, Memimage *m) { @@ -141,7 +141,7 @@ addflush(Client *c, Rectangle r) } /* emit current state */ if(c->flushrect.min.x < c->flushrect.max.x) - _flushmemscreen(c->flushrect); + rpc_flushmemscreen(c, c->flushrect); c->flushrect = r; c->waste = 0; } @@ -178,7 +178,7 @@ void drawflush(Client *c) { if(c->flushrect.min.x < c->flushrect.max.x) - _flushmemscreen(c->flushrect); + rpc_flushmemscreen(c, c->flushrect); c->flushrect = Rect(10000, 10000, -10000, -10000); } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index fe9532b3a..30586228a 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -28,6 +28,8 @@ struct Kbdbuf int wi; int stall; int alting; + Rune k[10]; + int nk; }; struct Mousebuf @@ -75,7 +77,7 @@ struct Client int rfd; int wfd; - void* view; + const void* view; QLock inputlk; Kbdbuf kbd; @@ -163,6 +165,22 @@ void _drawreplacescreenimage(Client*, Memimage*); int _latin1(Rune*, int); int parsewinsize(char*, Rectangle*, int*); int mouseswap(int); -void abortcompose(Client*); + +void gfx_abortcompose(Client*); +void gfx_keystroke(Client*, int); +void gfx_mousetrack(Client*, int, int, int, uint); + +void rpc_setmouse(Client*, Point); +void rpc_setcursor(Client*, Cursor*, Cursor2*); +void rpc_setlabel(Client*, char*); +void rpc_resizeimg(Client*); +void rpc_resizewindow(Client*, Rectangle); +void rpc_topwin(Client*); +char* rpc_getsnarf(void); +void rpc_putsnarf(char*); +Memimage *rpc_attachscreen(Client*, char*, char*); +void rpc_flushmemscreen(Client*, Rectangle); extern Client *client0; + +void servep9p(Client*); diff --git a/src/cmd/devdraw/mac-screen.h b/src/cmd/devdraw/mac-screen.h deleted file mode 100644 index 7bc0920d8..000000000 --- a/src/cmd/devdraw/mac-screen.h +++ /dev/null @@ -1,19 +0,0 @@ -#define setcursor dsetcursor - -Memimage *attachscreen(Client*, char*, char*); -void setmouse(Point); -void setcursor(Cursor*, Cursor2*); -void setlabel(char*); -char* getsnarf(void); -void putsnarf(char*); -void topwin(void); - -void mousetrack(Client*, int, int, int, uint); -void keystroke(Client*, int); -void kicklabel(char*); - -void servep9p(Client*); - -void resizeimg(Client*); - -void resizewindow(Rectangle); diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 8ce8a0cdb..d756d3d75 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -21,7 +21,6 @@ #include #include #include "devdraw.h" -#include "mac-screen.h" #include "bigarrow.h" #include "glendapng.h" @@ -34,7 +33,6 @@ static void setprocname(const char*); static uint keycvt(uint); static uint msec(void); -static Memimage* initimg(Client*); void usage(void) @@ -43,34 +41,14 @@ threadexitsall("usage"); } -@interface DrawLayer : CAMetalLayer -@end -@interface AppDelegate : NSObject -+ (void)makewin:(NSValue *)v; -+ (void)callkicklabel:(NSString *)v; -+ (void)callsetNeedsDisplayInRect:(NSValue *)v; -+ (void)callsetcursor:(NSValue *)v; -@end - -@interface DevDrawView : NSView -@property (nonatomic, assign) Client *client; -@property (nonatomic, assign) DrawLayer *dlayer; -@property (nonatomic, assign) NSWindow *win; -@property (nonatomic, assign) NSCursor *currentCursor; -@property (nonatomic, assign) Memimage *img; +@class DrawView; +@class DrawLayer; -- (void)clearInput; -- (void)getmouse:(NSEvent *)e; -- (void)sendmouse:(NSUInteger)b; -- (void)resetLastInputRect; -- (void)enlargeLastInputRect:(NSRect)r; +@interface AppDelegate : NSObject @end static AppDelegate *myApp = NULL; -static id device; -static id commandQueue; -static id texture; static QLock snarfl; @@ -100,11 +78,13 @@ - (void)enlargeLastInputRect:(NSRect)r; }ARGEND client0 = mallocz(sizeof(Client), 1); - client0->displaydpi = 100; if(client0 == nil){ fprint(2, "initdraw: allocating client0: out of memory"); abort(); } + client0->displaydpi = 100; + client0->rfd = 3; + client0->wfd = 4; setprocname(argv0); @@ -117,22 +97,168 @@ - (void)enlargeLastInputRect:(NSRect)r; } } - void callservep9p(void *v) { USED(v); - client0->rfd = 3; - client0->wfd = 4; servep9p(client0); [NSApp terminate:myApp]; } @implementation AppDelegate +- (void)applicationDidFinishLaunching:(id)arg +{ + NSMenu *m, *sm; + NSData *d; + NSImage *i; -+ (void)makewin:(NSValue *)v + LOG(@"applicationDidFinishLaunching"); + + sm = [NSMenu new]; + [sm addItemWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"]; + [sm addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"]; + [sm addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; + m = [NSMenu new]; + [m addItemWithTitle:@"DEVDRAW" action:NULL keyEquivalent:@""]; + [m setSubmenu:sm forItem:[m itemWithTitle:@"DEVDRAW"]]; + [NSApp setMainMenu:m]; + + d = [[NSData alloc] initWithBytes:glenda_png length:(sizeof glenda_png)]; + i = [[NSImage alloc] initWithData:d]; + [NSApp setApplicationIconImage:i]; + [[NSApp dockTile] display]; + + proccreate(callservep9p, nil, 0); +} + +- (NSApplicationPresentationOptions)window:(id)arg + willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + NSApplicationPresentationOptions o; + o = proposedOptions; + o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); + o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + return o; +} + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { + return YES; +} +@end + +@interface DrawLayer : CAMetalLayer +@property (nonatomic, retain) id cmd; +@property (nonatomic, retain) id texture; +@end + +@implementation DrawLayer +- (void)display +{ + LOG(@"display"); + LOG(@"display query drawable"); + + @autoreleasepool{ + id drawable = [self nextDrawable]; + if(!drawable){ + LOG(@"display couldn't get drawable"); + [self setNeedsDisplay]; + return; + } + + LOG(@"display got drawable"); + + id cbuf = [self.cmd commandBuffer]; + id blit = [cbuf blitCommandEncoder]; + [blit copyFromTexture:self.texture + sourceSlice:0 + sourceLevel:0 + sourceOrigin:MTLOriginMake(0, 0, 0) + sourceSize:MTLSizeMake(self.texture.width, self.texture.height, self.texture.depth) + toTexture:drawable.texture + destinationSlice:0 + destinationLevel:0 + destinationOrigin:MTLOriginMake(0, 0, 0)]; + [blit endEncoding]; + + [cbuf presentDrawable:drawable]; + drawable = nil; + [cbuf addCompletedHandler:^(id cmdBuff){ + if(cmdBuff.error){ + NSLog(@"command buffer finished with error: %@", + cmdBuff.error.localizedDescription); + }else + LOG(@"command buffer finishes present drawable"); + }]; + [cbuf commit]; + } + LOG(@"display commit"); +} +@end + +@interface DrawView : NSView +@property (nonatomic, assign) Client *client; +@property (nonatomic, retain) DrawLayer *dlayer; +@property (nonatomic, retain) NSWindow *win; +@property (nonatomic, retain) NSCursor *currentCursor; +@property (nonatomic, assign) Memimage *img; + +- (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label; +- (void)topwin; +- (void)setlabel:(char*)label; +- (void)setcursor:(Cursor*)c cursor2:(Cursor2*)c2; +- (void)setmouse:(Point)p; +- (void)clearInput; +- (void)getmouse:(NSEvent*)e; +- (void)sendmouse:(NSUInteger)b; +- (void)resetLastInputRect; +- (void)enlargeLastInputRect:(NSRect)r; +@end + +@implementation DrawView +{ + NSMutableString *_tmpText; + NSRange _markedRange; + NSRange _selectedRange; + NSRect _lastInputRect; // The view is flipped, this is not. + BOOL _tapping; + NSUInteger _tapFingers; + NSUInteger _tapTime; +} + +- (id)init { + LOG(@"View init"); + self = [super init]; + [self setAllowedTouchTypes:NSTouchTypeMaskDirect|NSTouchTypeMaskIndirect]; + _tmpText = [[NSMutableString alloc] initWithCapacity:2]; + _markedRange = NSMakeRange(NSNotFound, 0); + _selectedRange = NSMakeRange(0, 0); + return self; +} + +- (CALayer*)makeBackingLayer { return [DrawLayer layer]; } +- (BOOL)wantsUpdateLayer { return YES; } +- (BOOL)isOpaque { return YES; } +- (BOOL)isFlipped { return YES; } +- (BOOL)acceptsFirstResponder { return YES; } + +// rpc_attachscreen allocates a new screen window with the given label and size +// and attaches it to client c (by setting c->view). +Memimage* +rpc_attachscreen(Client *c, char *label, char *winsize) +{ + LOG(@"attachscreen(%s, %s)", label, winsize); + + dispatch_sync(dispatch_get_main_queue(), ^(void) { + @autoreleasepool { + DrawView *view = [[DrawView new] attach:c winsize:winsize label:label]; + [view initimg]; + } + }); + return ((__bridge DrawView*)c->view).img; +} + +- (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { NSRect r, sr; Rectangle wr; int set; @@ -144,10 +270,10 @@ + (void)makewin:(NSValue *)v | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; + s = winsize; sr = [[NSScreen mainScreen] frame]; r = [[NSScreen mainScreen] visibleFrame]; - s = [v pointerValue]; LOG(@"makewin(%s)", s); if(s && *s){ if(parsewinsize(s, &wr, &set) < 0) @@ -177,17 +303,16 @@ + (void)makewin:(NSValue *)v [win setRestorable:NO]; [win setAcceptsMouseMovedEvents:YES]; - DevDrawView *view = [DevDrawView new]; - client0->view = view; - view.client = client0; - view.win = win; - view.currentCursor = nil; - [win setContentView:view]; - [win setDelegate:view]; - [view setWantsLayer:YES]; - [view setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; + client->view = CFBridgingRetain(self); + self.client = client; + self.win = win; + self.currentCursor = nil; + [win setContentView:self]; + [win setDelegate:self]; + [self setWantsLayer:YES]; + [self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; - device = nil; + id device = nil; allDevices = MTLCopyAllDevices(); for(id mtlDevice in allDevices) { if ([mtlDevice isLowPower] && ![mtlDevice isRemovable]) { @@ -198,18 +323,19 @@ + (void)makewin:(NSValue *)v if(!device) device = MTLCreateSystemDefaultDevice(); - commandQueue = [device newCommandQueue]; - - DrawLayer *layer = (DrawLayer *)[view layer]; - view.dlayer = layer; + DrawLayer *layer = (DrawLayer*)[self layer]; + self.dlayer = layer; layer.device = device; + layer.cmd = [device newCommandQueue]; layer.pixelFormat = MTLPixelFormatBGRA8Unorm; layer.framebufferOnly = YES; layer.opaque = YES; // We use a default transparent layer on top of the CAMetalLayer. // This seems to make fullscreen applications behave. - { + // Specifically, without this code if you enter full screen with Cmd-F, + // the screen goes black until the first mouse click. + if(1) { CALayer *stub = [CALayer layer]; stub.frame = CGRectMake(0, 0, 1, 1); [stub setNeedsDisplay]; @@ -218,64 +344,76 @@ + (void)makewin:(NSValue *)v [NSEvent setMouseCoalescingEnabled:NO]; - topwin(); + [self topwin]; + [self setlabel:label]; + [self setcursor:nil cursor2:nil]; + + return self; } -+ (void)callkicklabel:(NSString *)s +// rpc_topwin moves the window to the top of the desktop. +// Called from an RPC thread with no client lock held. +void +rpc_topwin(Client *c) { - DevDrawView *view = client0->view; - - LOG(@"callkicklabel(%@)", s); - [view.win setTitle:s]; - [[NSApp dockTile] setBadgeLabel:s]; + DrawView *view = (__bridge DrawView*)c->view; + dispatch_sync(dispatch_get_main_queue(), ^(void) { + [view topwin]; + }); } +- (void)topwin { + [self.win makeKeyAndOrderFront:nil]; + [NSApp activateIgnoringOtherApps:YES]; +} -+ (void)callsetNeedsDisplayInRect:(NSValue *)v +// rpc_setlabel updates the client window's label. +// If label == nil, the call is a no-op. +// Called from an RPC thread with no client lock held. +void +rpc_setlabel(Client *client, char *label) { - NSRect r; - dispatch_time_t time; - DevDrawView *view = client0->view; - - r = [v rectValue]; - LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); - r = [view.win convertRectFromBacking:r]; - LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", r.origin.x, r.origin.y, r.size.width, r.size.height); - [view.dlayer setNeedsDisplayInRect:r]; - - time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); - dispatch_after(time, dispatch_get_main_queue(), ^(void){ - [view.dlayer setNeedsDisplayInRect:r]; + DrawView *view = (__bridge DrawView*)client->view; + dispatch_sync(dispatch_get_main_queue(), ^(void){ + [view setlabel:label]; }); - - [view enlargeLastInputRect:r]; } -typedef struct Cursors Cursors; -struct Cursors { - Cursor *c; - Cursor2 *c2; -}; +- (void)setlabel:(char*)label { + LOG(@"setlabel(%s)", label); + if(label == nil) + return; + + @autoreleasepool{ + NSString *s = [[NSString alloc] initWithUTF8String:label]; + [self.win setTitle:s]; + [[NSApp dockTile] setBadgeLabel:s]; // TODO: Not with multiple windows + } +} -+ (void)callsetcursor:(NSValue *)v +// rpc_setcursor updates the client window's cursor image. +// Either c and c2 are both non-nil, or they are both nil to use the default arrow. +// Called from an RPC thread with no client lock held. +void +rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) { - Cursors *cs; - Cursor *c; - Cursor2 *c2; + DrawView *view = (__bridge DrawView*)client->view; + dispatch_sync(dispatch_get_main_queue(), ^(void){ + [view setcursor:c cursor2:c2]; + }); +} + +- (void)setcursor:(Cursor*)c cursor2:(Cursor2*)c2 { + if(!c) { + c = &bigarrow; + c2 = &bigarrow2; + } + NSBitmapImageRep *r, *r2; NSImage *i; NSPoint p; uchar *plane[5], *plane2[5]; uint b; - DevDrawView *view = client0->view; - - cs = [v pointerValue]; - c = cs->c; - if(!c) - c = &bigarrow; - c2 = cs->c2; - if(!c2) - c2 = &bigarrow2; r = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil @@ -311,125 +449,164 @@ + (void)callsetcursor:(NSValue *)v plane2[1][b] = c2->set[b] | c2->clr[b]; } - // For checking out the cursor bitmap image -/* - static BOOL saveimg = YES; - if(saveimg){ + static BOOL debug = NO; + if(debug){ NSData *data = [r representationUsingType: NSBitmapImageFileTypeBMP properties: @{}]; [data writeToFile: @"/tmp/r.bmp" atomically: NO]; data = [r2 representationUsingType: NSBitmapImageFileTypeBMP properties: @{}]; [data writeToFile: @"/tmp/r2.bmp" atomically: NO]; - saveimg = NO; + debug = NO; } -*/ i = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)]; [i addRepresentation:r2]; [i addRepresentation:r]; p = NSMakePoint(-c->offset.x, -c->offset.y); - view.currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; - - [view.win invalidateCursorRectsForView:view]; + self.currentCursor = [[NSCursor alloc] initWithImage:i hotSpot:p]; + [self.win invalidateCursorRectsForView:self]; } -- (void)applicationDidFinishLaunching:(id)arg -{ - NSMenu *m, *sm; - NSData *d; - NSImage *i; +- (void)initimg { +@autoreleasepool{ + CGFloat scale; + NSSize size; + MTLTextureDescriptor *textureDesc; - LOG(@"applicationDidFinishLaunching"); + size = [self convertSizeToBacking:[self bounds].size]; + self.client->mouserect = Rect(0, 0, size.width, size.height); - sm = [NSMenu new]; - [sm addItemWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"]; - [sm addItemWithTitle:@"Hide" action:@selector(hide:) keyEquivalent:@"h"]; - [sm addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"]; - m = [NSMenu new]; - [m addItemWithTitle:@"DEVDRAW" action:NULL keyEquivalent:@""]; - [m setSubmenu:sm forItem:[m itemWithTitle:@"DEVDRAW"]]; - [NSApp setMainMenu:m]; + LOG(@"initimg %.0f %.0f", size.width, size.height); - d = [[NSData alloc] initWithBytes:glenda_png length:(sizeof glenda_png)]; - i = [[NSImage alloc] initWithData:d]; - [NSApp setApplicationIconImage:i]; - [[NSApp dockTile] display]; + self.img = allocmemimage(self.client->mouserect, XRGB32); + if(self.img == nil) + panic("allocmemimage: %r"); + if(self.img->data == nil) + panic("img->data == nil"); - proccreate(callservep9p, nil, 0); -} + textureDesc = [MTLTextureDescriptor + texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm + width:size.width + height:size.height + mipmapped:NO]; + textureDesc.allowGPUOptimizedContents = YES; + textureDesc.usage = MTLTextureUsageShaderRead; + textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; + self.dlayer.texture = [self.dlayer.device newTextureWithDescriptor:textureDesc]; -- (NSApplicationPresentationOptions)window:(id)arg - willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { - NSApplicationPresentationOptions o; - o = proposedOptions; - o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); - o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; - return o; -} + scale = [self.win backingScaleFactor]; + [self.dlayer setDrawableSize:size]; + [self.dlayer setContentsScale:scale]; -- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { - return YES; + // NOTE: This is not really the display DPI. + // On retina, scale is 2; otherwise it is 1. + // This formula gives us 220 for retina, 110 otherwise. + // That's not quite right but it's close to correct. + // https://en.wikipedia.org/wiki/Retina_display#Models + self.client->displaydpi = scale * 110; } -@end - -@implementation DevDrawView -{ - NSMutableString *_tmpText; - NSRange _markedRange; - NSRange _selectedRange; - NSRect _lastInputRect; // The view is flipped, this is not. - BOOL _tapping; - NSUInteger _tapFingers; - NSUInteger _tapTime; + LOG(@"initimg return"); } -- (id)init +// rpc_flushmemscreen flushes changes to view.img's rectangle r +// to the on-screen window, making them visible. +// Called from an RPC thread with no client lock held. +void +rpc_flushmemscreen(Client *client, Rectangle r) { - LOG(@"View init"); - self = [super init]; - [self setAllowedTouchTypes:NSTouchTypeMaskDirect|NSTouchTypeMaskIndirect]; - _tmpText = [[NSMutableString alloc] initWithCapacity:2]; - _markedRange = NSMakeRange(NSNotFound, 0); - _selectedRange = NSMakeRange(0, 0); - return self; + DrawView *view = (__bridge DrawView*)client->view; + dispatch_async(dispatch_get_main_queue(), ^(void){ + [view flushmemscreen:r]; + }); } -- (void)windowDidResize:(NSNotification *)notification -{ - if(![self inLiveResize] && self.img) { - resizeimg(self.client); +- (void)flushmemscreen:(Rectangle)r { + LOG(@"flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); + if(!rectinrect(r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height))){ + LOG(@"Rectangle is out of bounds, return."); + return; + } + + @autoreleasepool{ + [self.dlayer.texture + replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) + mipmapLevel:0 + withBytes:byteaddr(self.img, Pt(r.min.x, r.min.y)) + bytesPerRow:self.img->width*sizeof(u32int)]; + + NSRect nr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); + dispatch_time_t time; + + LOG(@"callsetNeedsDisplayInRect(%g, %g, %g, %g)", nr.origin.x, nr.origin.y, nr.size.width, nr.size.height); + nr = [self.win convertRectFromBacking:nr]; + LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", nr.origin.x, nr.origin.y, nr.size.width, nr.size.height); + [self.dlayer setNeedsDisplayInRect:nr]; + + time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); + dispatch_after(time, dispatch_get_main_queue(), ^(void){ + [self.dlayer setNeedsDisplayInRect:nr]; + }); + + [self enlargeLastInputRect:nr]; } } -- (void)windowDidBecomeKey:(id)arg +// rpc_resizeimg forces the client window to discard its current window and make a new one. +// It is called when the user types Cmd-R to toggle whether retina mode is forced. +// Called from an RPC thread with no client lock held. +void +rpc_resizeimg(Client *c) { - [self sendmouse:0]; + DrawView *view = (__bridge DrawView*)c->view; + dispatch_sync(dispatch_get_main_queue(), ^(void){ + [view resizeimg]; + }); } -- (CALayer *)makeBackingLayer -{ - LOG(@"makeBackingLayer"); - return [DrawLayer layer]; +- (void)resizeimg { + [self initimg]; + _drawreplacescreenimage(self.client, self.img); + [self sendmouse:0]; } -- (BOOL)wantsUpdateLayer +- (void)windowDidResize:(NSNotification *)notification { + if(![self inLiveResize] && self.img) { + [self resizeimg]; + } +} +- (void)viewDidEndLiveResize { - return YES; + [super viewDidEndLiveResize]; + if(self.img) + [self resizeimg]; } -- (BOOL)isOpaque +- (void)viewDidChangeBackingProperties { - return YES; + [super viewDidChangeBackingProperties]; + if(self.img) + [self resizeimg]; } -- (BOOL)isFlipped +// rpc_resizewindow asks for the client window to be resized to size r. +// Called from an RPC thread with no client lock held. +void +rpc_resizewindow(Client *c, Rectangle r) { - return YES; + DrawView *view = (__bridge DrawView*)c->view; + + LOG(@"resizewindow %d %d %d %d", r.min.x, r.min.y, Dx(r), Dy(r)); + dispatch_async(dispatch_get_main_queue(), ^(void){ + NSSize s; + + s = [view convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; + [view.win setContentSize:s]; + }); } -- (BOOL)acceptsFirstResponder -{ - return YES; + +- (void)windowDidBecomeKey:(id)arg { + [self sendmouse:0]; } - (void)mouseMoved:(NSEvent*)e{ [self getmouse:e];} @@ -483,7 +660,7 @@ - (void)flagsChanged:(NSEvent*)e b |= 4; [self sendmouse:b]; }else if(m & ~omod & NSEventModifierFlagOption) - keystroke(self.client, Kalt); + gfx_keystroke(self.client, Kalt); omod = m; } @@ -540,7 +717,7 @@ - (void)getmouse:(NSEvent *)e if(b == 1){ m = [e modifierFlags]; if(m & NSEventModifierFlagOption){ - abortcompose(self.client); + gfx_abortcompose(self.client); b = 2; }else if(m & NSEventModifierFlagCommand) @@ -557,28 +734,51 @@ - (void)sendmouse:(NSUInteger)b [self.window mouseLocationOutsideOfEventStream]]; p.y = Dy(self.client->mouserect) - p.y; // LOG(@"(%g, %g) <- sendmouse(%d)", p.x, p.y, (uint)b); - mousetrack(self.client, p.x, p.y, b, msec()); + gfx_mousetrack(self.client, p.x, p.y, b, msec()); if(b && _lastInputRect.size.width && _lastInputRect.size.height) [self resetLastInputRect]; } -- (void)resetCursorRects { - [super resetCursorRects]; - [self addCursorRect:self.bounds cursor:self.currentCursor]; +// rpc_setmouse moves the mouse cursor. +// Called from an RPC thread with no client lock held. +void +rpc_setmouse(Client *c, Point p) +{ + DrawView *view = (__bridge DrawView*)c->view; + dispatch_async(dispatch_get_main_queue(), ^(void){ + [view setmouse:p]; + }); } -- (void)viewDidEndLiveResize -{ - [super viewDidEndLiveResize]; - if(self.img) - resizeimg(self.client); +-(void)setmouse:(Point)p { + @autoreleasepool{ + NSPoint q; + + LOG(@"setmouse(%d,%d)", p.x, p.y); + q = [self.win convertPointFromBacking:NSMakePoint(p.x, p.y)]; + LOG(@"(%g, %g) <- fromBacking", q.x, q.y); + q = [self convertPoint:q toView:nil]; + LOG(@"(%g, %g) <- toWindow", q.x, q.y); + q = [self.win convertPointToScreen:q]; + LOG(@"(%g, %g) <- toScreen", q.x, q.y); + // Quartz has the origin of the "global display + // coordinate space" at the top left of the primary + // screen with y increasing downward, while Cocoa has + // the origin at the bottom left of the primary screen + // with y increasing upward. We flip the coordinate + // with a negative sign and shift upward by the height + // of the primary screen. + q.y = NSScreen.screens[0].frame.size.height - q.y; + LOG(@"(%g, %g) <- setmouse", q.x, q.y); + CGWarpMouseCursorPosition(NSPointToCGPoint(q)); + CGAssociateMouseAndMouseCursorPosition(true); + } } -- (void)viewDidChangeBackingProperties -{ - [super viewDidChangeBackingProperties]; - if(self.img) - resizeimg(self.client); + +- (void)resetCursorRects { + [super resetCursorRects]; + [self addCursorRect:self.bounds cursor:self.currentCursor]; } // conforms to protocol NSTextInputClient @@ -637,24 +837,24 @@ - (void)setMarkedText:(id)string LOG(@"text length %ld", _tmpText.length); for(i = 0; i <= _tmpText.length; ++i){ if(i == _markedRange.location) - keystroke(self.client, '['); + gfx_keystroke(self.client, '['); if(_selectedRange.length){ if(i == _selectedRange.location) - keystroke(self.client, '{'); + gfx_keystroke(self.client, '{'); if(i == NSMaxRange(_selectedRange)) - keystroke(self.client, '}'); + gfx_keystroke(self.client, '}'); } if(i == NSMaxRange(_markedRange)) - keystroke(self.client, ']'); + gfx_keystroke(self.client, ']'); if(i < _tmpText.length) - keystroke(self.client, [_tmpText characterAtIndex:i]); + gfx_keystroke(self.client, [_tmpText characterAtIndex:i]); } int l; l = 1 + _tmpText.length - NSMaxRange(_selectedRange) + (_selectedRange.length > 0); LOG(@"move left %d", l); for(i = 0; i < l; ++i) - keystroke(self.client, Kleft); + gfx_keystroke(self.client, Kleft); } LOG(@"text: \"%@\" (%ld,%ld) (%ld,%ld)", _tmpText, @@ -669,7 +869,7 @@ - (void)unmarkText LOG(@"unmarkText"); len = [_tmpText length]; //for(i = 0; i < len; ++i) - // keystroke(self.client, [_tmpText characterAtIndex:i]); + // gfx_keystroke(self.client, [_tmpText characterAtIndex:i]); [_tmpText deleteCharactersInRange:NSMakeRange(0, len)]; _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); @@ -711,7 +911,7 @@ - (void)insertText:(id)s len = [s length]; for(i = 0; i < len; ++i) - keystroke(self.client, [s characterAtIndex:i]); + gfx_keystroke(self.client, [s characterAtIndex:i]); [_tmpText deleteCharactersInRange:NSMakeRange(0, _tmpText.length)]; _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); @@ -751,7 +951,7 @@ - (void)doCommandBySelector:(SEL)s k += Kcmd; } if(k>0) - keystroke(self.client, k); + gfx_keystroke(self.client, k); } // Helper for managing input rect approximately @@ -782,69 +982,13 @@ - (void)clearInput + (_selectedRange.length > 0); LOG(@"move right %d", l); for(i = 0; i < l; ++i) - keystroke(self.client, Kright); + gfx_keystroke(self.client, Kright); l = _tmpText.length+2+2*(_selectedRange.length > 0); LOG(@"backspace %d", l); for(uint i = 0; i < l; ++i) - keystroke(self.client, Kbs); - } -} - -@end - -@implementation DrawLayer - -- (void)display -{ - id cbuf; - id blit; - - LOG(@"display"); - - cbuf = [commandQueue commandBuffer]; - - LOG(@"display query drawable"); - -@autoreleasepool{ - id drawable; - DevDrawView *view = client0->view; - - drawable = [view.dlayer nextDrawable]; - if(!drawable){ - LOG(@"display couldn't get drawable"); - [self setNeedsDisplay]; - return; + gfx_keystroke(self.client, Kbs); } - - LOG(@"display got drawable"); - - blit = [cbuf blitCommandEncoder]; - [blit copyFromTexture:texture - sourceSlice:0 - sourceLevel:0 - sourceOrigin:MTLOriginMake(0, 0, 0) - sourceSize:MTLSizeMake(texture.width, texture.height, texture.depth) - toTexture:drawable.texture - destinationSlice:0 - destinationLevel:0 - destinationOrigin:MTLOriginMake(0, 0, 0)]; - [blit endEncoding]; - - [cbuf presentDrawable:drawable]; - drawable = nil; } - [cbuf addCompletedHandler:^(id cmdBuff){ - if(cmdBuff.error){ - NSLog(@"command buffer finished with error: %@", - cmdBuff.error.localizedDescription); - }else - LOG(@"command buffer finishes present drawable"); - }]; - [cbuf commit]; - - LOG(@"display commit"); -} - @end static uint @@ -935,122 +1079,9 @@ - (void)display } } -Memimage* -attachscreen(Client *c, char *label, char *winsize) -{ - LOG(@"attachscreen(%s, %s)", label, winsize); - [AppDelegate - performSelectorOnMainThread:@selector(makewin:) - withObject:[NSValue valueWithPointer:winsize] - waitUntilDone:YES]; - kicklabel(label); - setcursor(nil, nil); - c->mouse.resized = 0; - return initimg(c); -} - -static Memimage* -initimg(Client *c) -{ - DevDrawView *view = c->view; - -@autoreleasepool{ - CGFloat scale; - NSSize size; - MTLTextureDescriptor *textureDesc; - - size = [view convertSizeToBacking:[view bounds].size]; - c->mouserect = Rect(0, 0, size.width, size.height); - - LOG(@"initimg %.0f %.0f", size.width, size.height); - - view.img = allocmemimage(c->mouserect, XRGB32); - if(view.img == nil) - panic("allocmemimage: %r"); - if(view.img->data == nil) - panic("img->data == nil"); - - textureDesc = [MTLTextureDescriptor - texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm - width:size.width - height:size.height - mipmapped:NO]; - textureDesc.allowGPUOptimizedContents = YES; - textureDesc.usage = MTLTextureUsageShaderRead; - textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; - texture = [device newTextureWithDescriptor:textureDesc]; - - scale = [view.win backingScaleFactor]; - [view.dlayer setDrawableSize:size]; - [view.dlayer setContentsScale:scale]; - - // NOTE: This is not really the display DPI. - // On retina, scale is 2; otherwise it is 1. - // This formula gives us 220 for retina, 110 otherwise. - // That's not quite right but it's close to correct. - // https://en.wikipedia.org/wiki/Retina_display#Models - c->displaydpi = scale * 110; -} - LOG(@"initimg return"); - - return view.img; -} - -void -_flushmemscreen(Rectangle r) -{ - DevDrawView *view = client0->view; - - LOG(@"_flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); - if(!rectinrect(r, Rect(0, 0, texture.width, texture.height))){ - LOG(@"Rectangle is out of bounds, return."); - return; - } - - @autoreleasepool{ - [texture - replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) - mipmapLevel:0 - withBytes:byteaddr(view.img, Pt(r.min.x, r.min.y)) - bytesPerRow:view.img->width*sizeof(u32int)]; - [AppDelegate - performSelectorOnMainThread:@selector(callsetNeedsDisplayInRect:) - withObject:[NSValue valueWithRect:NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r))] - waitUntilDone:NO]; - } -} - -void -setmouse(Point p) -{ - DevDrawView *view = client0->view; - - @autoreleasepool{ - NSPoint q; - - LOG(@"setmouse(%d,%d)", p.x, p.y); - q = [view.win convertPointFromBacking:NSMakePoint(p.x, p.y)]; - LOG(@"(%g, %g) <- fromBacking", q.x, q.y); - q = [view convertPoint:q toView:nil]; - LOG(@"(%g, %g) <- toWindow", q.x, q.y); - q = [view.win convertPointToScreen:q]; - LOG(@"(%g, %g) <- toScreen", q.x, q.y); - // Quartz has the origin of the "global display - // coordinate space" at the top left of the primary - // screen with y increasing downward, while Cocoa has - // the origin at the bottom left of the primary screen - // with y increasing upward. We flip the coordinate - // with a negative sign and shift upward by the height - // of the primary screen. - q.y = NSScreen.screens[0].frame.size.height - q.y; - LOG(@"(%g, %g) <- setmouse", q.x, q.y); - CGWarpMouseCursorPosition(NSPointToCGPoint(q)); - CGAssociateMouseAndMouseCursorPosition(true); - } -} - +// TODO char* -getsnarf(void) +rpc_getsnarf(void) { NSPasteboard *pb; NSString *s; @@ -1069,8 +1100,9 @@ - (void)display } } +// TODO void -putsnarf(char *s) +rpc_putsnarf(char *s) { NSArray *t; NSPasteboard *pb; @@ -1091,75 +1123,6 @@ - (void)display } } -void -kicklabel(char *label) -{ - NSString *s; - - LOG(@"kicklabel(%s)", label); - if(label == nil) - return; - - @autoreleasepool{ - s = [[NSString alloc] initWithUTF8String:label]; - [AppDelegate - performSelectorOnMainThread:@selector(callkicklabel:) - withObject:s - waitUntilDone:NO]; - } -} - -void -setcursor(Cursor *c, Cursor2 *c2) -{ - Cursors cs; - - cs.c = c; - cs.c2 = c2; - - [AppDelegate - performSelectorOnMainThread:@selector(callsetcursor:) - withObject:[NSValue valueWithPointer:&cs] - waitUntilDone:YES]; -} - -void -topwin(void) -{ - DevDrawView *view = client0->view; - - [view.win - performSelectorOnMainThread: - @selector(makeKeyAndOrderFront:) - withObject:nil - waitUntilDone:YES]; - - [NSApp activateIgnoringOtherApps:YES]; -} - -void -resizeimg(Client *c) -{ - DevDrawView *view = c->view; - - _drawreplacescreenimage(c, initimg(c)); - [view sendmouse:0]; -} - -void -resizewindow(Rectangle r) -{ - DevDrawView *view = client0->view; - - LOG(@"resizewindow %d %d %d %d", r.min.x, r.min.y, Dx(r), Dy(r)); - dispatch_async(dispatch_get_main_queue(), ^(void){ - NSSize s; - - s = [view convertSizeFromBacking:NSMakeSize(Dx(r), Dy(r))]; - [view.win setContentSize:s]; - }); -} - static void setprocname(const char *s) { diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index 6546b5903..7ecf7dc17 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -9,6 +9,7 @@ WSYSOFILES=\ devdraw.$O\ latin1.$O\ mouseswap.$O\ + srv.$O\ winsize.$O\ <|sh ./mkwsysrules.sh @@ -42,7 +43,7 @@ $O.macargv: $MACARGV $LD -o $target $prereq %.$O: %.m - $CC $CFLAGS $OBJCFLAGS -o $target $stem.m + $CC $CFLAGS $OBJCFLAGS -fobjc-arc -o $target $stem.m CLEANFILES=$O.devdraw $O.macargv $O.drawclient $O.mklatinkbd latin1.h diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index cd72120f1..122e9123d 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -53,8 +53,8 @@ if [ $WSYSTYPE = x11 ]; then echo 'WSYSOFILES=$WSYSOFILES '$XO echo 'WSYSHFILES=x11-inc.h x11-keysym2ucs.h x11-memdraw.h' elif [ $WSYSTYPE = mac ]; then - echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o mac-srv.o' - echo 'WSYSHFILES=mac-screen.h' + echo 'WSYSOFILES=$WSYSOFILES mac-draw.o mac-screen.o' + echo 'WSYSHFILES=' echo 'MACARGV=macargv.o' elif [ $WSYSTYPE = nowsys ]; then echo 'WSYSOFILES=nowsys.o' diff --git a/src/cmd/devdraw/mac-srv.c b/src/cmd/devdraw/srv.c similarity index 75% rename from src/cmd/devdraw/mac-srv.c rename to src/cmd/devdraw/srv.c index 6727ef631..0e7540be9 100644 --- a/src/cmd/devdraw/mac-srv.c +++ b/src/cmd/devdraw/srv.c @@ -13,12 +13,11 @@ #include #include #include "devdraw.h" -#include "mac-screen.h" -void runmsg(Client*, Wsysmsg*); -void replymsg(Client*, Wsysmsg*); -void matchkbd(Client*); -void matchmouse(Client*); +static void runmsg(Client*, Wsysmsg*); +static void replymsg(Client*, Wsysmsg*); +static void matchkbd(Client*); +static void matchmouse(Client*); int trace = 0; @@ -55,7 +54,7 @@ servep9p(Client *c) } } -void +static void replyerror(Client *c, Wsysmsg *m) { char err[256]; @@ -70,7 +69,7 @@ replyerror(Client *c, Wsysmsg *m) * Handle a single wsysmsg. * Might queue for later (kbd, mouse read) */ -void +static void runmsg(Client *c, Wsysmsg *m) { static uchar buf[65536]; @@ -80,7 +79,7 @@ runmsg(Client *c, Wsysmsg *m) switch(m->type){ case Tinit: memimageinit(); - i = attachscreen(c, m->label, m->winsize); + i = rpc_attachscreen(c, m->label, m->winsize); _initdisplaymemimage(c, i); replymsg(c, m); break; @@ -110,23 +109,25 @@ runmsg(Client *c, Wsysmsg *m) break; case Tmoveto: - setmouse(m->mouse.xy); + rpc_setmouse(c, m->mouse.xy); replymsg(c, m); break; case Tcursor: if(m->arrowcursor) - setcursor(nil, nil); - else - setcursor(&m->cursor, nil); + rpc_setcursor(c, nil, nil); + else { + scalecursor(&m->cursor2, &m->cursor); + rpc_setcursor(c, &m->cursor, &m->cursor2); + } replymsg(c, m); break; case Tcursor2: if(m->arrowcursor) - setcursor(nil, nil); + rpc_setcursor(c, nil, nil); else - setcursor(&m->cursor, &m->cursor2); + rpc_setcursor(c, &m->cursor, &m->cursor2); replymsg(c, m); break; @@ -136,12 +137,12 @@ runmsg(Client *c, Wsysmsg *m) break; case Tlabel: - kicklabel(m->label); + rpc_setlabel(c, m->label); replymsg(c, m); break; case Trdsnarf: - m->snarf = getsnarf(); + m->snarf = rpc_getsnarf(); replymsg(c, m); free(m->snarf); break; @@ -177,12 +178,12 @@ runmsg(Client *c, Wsysmsg *m) break; case Ttop: - topwin(); + rpc_topwin(c); replymsg(c, m); break; case Tresize: - resizewindow(m->rect); + rpc_resizewindow(c, m->rect); replymsg(c, m); break; } @@ -192,7 +193,7 @@ runmsg(Client *c, Wsysmsg *m) * Reply to m. */ QLock replylock; -void +static void replymsg(Client *c, Wsysmsg *m) { int n; @@ -224,7 +225,7 @@ replymsg(Client *c, Wsysmsg *m) /* * Match queued kbd reads with queued kbd characters. */ -void +static void matchkbd(Client *c) { Wsysmsg m; @@ -243,14 +244,18 @@ matchkbd(Client *c) } } -/* - * Match queued mouse reads with queued mouse events. - */ -void +// matchmouse matches queued mouse reads with queued mouse events. +// It must be called with c->inputlk held. +static void matchmouse(Client *c) { Wsysmsg m; + if(canqlock(&c->inputlk)) { + fprint(2, "misuse of matchmouse\n"); + abort(); + } + while(c->mouse.ri != c->mouse.wi && c->mousetags.ri != c->mousetags.wi){ m.type = Rrdmouse; m.tag = c->mousetags.t[c->mousetags.ri++]; @@ -271,10 +276,11 @@ matchmouse(Client *c) } void -mousetrack(Client *c, int x, int y, int b, uint ms) +gfx_mousetrack(Client *c, int x, int y, int b, uint ms) { Mouse *m; + qlock(&c->inputlk); if(x < c->mouserect.min.x) x = c->mouserect.min.x; if(x > c->mouserect.max.x) @@ -284,7 +290,6 @@ mousetrack(Client *c, int x, int y, int b, uint ms) if(y > c->mouserect.max.y) y = c->mouserect.max.y; - qlock(&c->inputlk); // If reader has stopped reading, don't bother. // If reader is completely caught up, definitely queue. // Otherwise, queue only button change events. @@ -310,36 +315,50 @@ mousetrack(Client *c, int x, int y, int b, uint ms) qunlock(&c->inputlk); } -void +// kputc adds ch to the keyboard buffer. +// It must be called with c->inputlk held. +static void kputc(Client *c, int ch) { - qlock(&c->inputlk); + if(canqlock(&c->inputlk)) { + fprint(2, "misuse of kputc\n"); + abort(); + } + c->kbd.r[c->kbd.wi++] = ch; if(c->kbd.wi == nelem(c->kbd.r)) c->kbd.wi = 0; if(c->kbd.ri == c->kbd.wi) c->kbd.stall = 1; matchkbd(c); - qunlock(&c->inputlk); } +// gfx_abortcompose stops any pending compose sequence, +// because a mouse button has been clicked. +// It is called from the graphics thread with no locks held. void -abortcompose(Client *c) +gfx_abortcompose(Client *c) { - if(c->kbd.alting) - keystroke(c, Kalt); + qlock(&c->inputlk); + if(c->kbd.alting) { + c->kbd.alting = 0; + c->kbd.nk = 0; + } + qunlock(&c->inputlk); } +// gfx_keystroke records a single-rune keystroke. +// It is called from the graphics thread with no locks held. void -keystroke(Client *c, int ch) +gfx_keystroke(Client *c, int ch) { - static Rune k[10]; - static int nk; int i; + qlock(&c->inputlk); if(ch == Kalt){ c->kbd.alting = !c->kbd.alting; - nk = 0; + c->kbd.nk = 0; + qunlock(&c->inputlk); return; } if(ch == Kcmd+'r') { @@ -349,30 +368,35 @@ keystroke(Client *c, int ch) c->forcedpi = 100; else c->forcedpi = 225; - resizeimg(c); + qunlock(&c->inputlk); + rpc_resizeimg(c); return; } if(!c->kbd.alting){ kputc(c, ch); + qunlock(&c->inputlk); return; } - if(nk >= nelem(k)) // should not happen - nk = 0; - k[nk++] = ch; - ch = _latin1(k, nk); + if(c->kbd.nk >= nelem(c->kbd.k)) // should not happen + c->kbd.nk = 0; + c->kbd.k[c->kbd.nk++] = ch; + ch = _latin1(c->kbd.k, c->kbd.nk); if(ch > 0){ c->kbd.alting = 0; kputc(c, ch); - nk = 0; + c->kbd.nk = 0; + qunlock(&c->inputlk); return; } if(ch == -1){ c->kbd.alting = 0; - for(i=0; ikbd.nk; i++) + kputc(c, c->kbd.k[i]); + c->kbd.nk = 0; + qunlock(&c->inputlk); return; } // need more input + qunlock(&c->inputlk); return; } From 41547af3f614061dd2c94bb52ae118f146925743 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 10 Jan 2020 00:11:55 -0500 Subject: [PATCH 136/323] devdraw: more cleanup, clearer locking --- src/cmd/devdraw/devdraw.c | 130 ++++++++--------- src/cmd/devdraw/devdraw.h | 91 ++++++++---- src/cmd/devdraw/latin1.c | 2 +- src/cmd/devdraw/mac-screen.m | 271 ++++++++++++++--------------------- src/cmd/devdraw/srv.c | 138 ++++++++++++------ src/cmd/devdraw/x11-init.c | 2 +- src/cmd/devdraw/x11-itrans.c | 4 +- src/cmd/devdraw/x11-srv.c | 4 +- 8 files changed, 329 insertions(+), 313 deletions(-) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 77a3f44a2..e3040779d 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -14,14 +14,12 @@ #include #include "devdraw.h" -static Draw sdraw; -Client *client0; static int drawuninstall(Client*, int); static Memimage* drawinstall(Client*, int, Memimage*, DScreen*); static void drawfreedimage(Client*, DImage*); void -_initdisplaymemimage(Client *c, Memimage *m) +draw_initdisplaymemimage(Client *c, Memimage *m) { c->screenimage = m; m->screenref = 1; @@ -30,10 +28,10 @@ _initdisplaymemimage(Client *c, Memimage *m) c->op = SoverD; } -// _drawreplacescreen replaces c's screen image with m. +// gfx_replacescreenimage replaces c's screen image with m. // It is called by the host driver on the main host thread. void -_drawreplacescreenimage(Client *c, Memimage *m) +gfx_replacescreenimage(Client *c, Memimage *m) { /* * Replace the screen image because the screen @@ -49,21 +47,21 @@ _drawreplacescreenimage(Client *c, Memimage *m) */ Memimage *om; - qlock(&c->inputlk); - qlock(&sdraw.lk); + qlock(&c->drawlk); om = c->screenimage; c->screenimage = m; m->screenref = 1; - c->mouse.resized = 1; if(om && --om->screenref == 0){ _freememimage(om); } - qunlock(&sdraw.lk); - qunlock(&c->inputlk); + qunlock(&c->drawlk); + + qlock(&c->eventlk); + c->mouse.resized = 1; + qunlock(&c->eventlk); } -static -void +static void drawrefreshscreen(DImage *l, Client *client) { while(l != nil && l->dscreen == nil) @@ -72,8 +70,7 @@ drawrefreshscreen(DImage *l, Client *client) l->dscreen->owner->refreshme = 1; } -static -void +static void drawrefresh(Memimage *m, Rectangle r, void *v) { Refx *x; @@ -106,7 +103,7 @@ static void addflush(Client *c, Rectangle r) { int abb, ar, anbb; - Rectangle nbb; + Rectangle nbb, fr; if(/*sdraw.softscreen==0 ||*/ !rectclip(&r, c->screenimage->r)) return; @@ -140,14 +137,20 @@ addflush(Client *c, Rectangle r) return; } /* emit current state */ - if(c->flushrect.min.x < c->flushrect.max.x) - rpc_flushmemscreen(c, c->flushrect); + fr = c->flushrect; c->flushrect = r; c->waste = 0; + if(fr.min.x < fr.max.x) { + // Unlock drawlk because rpc_flush may want to run on gfx thread, + // and gfx thread might be blocked on drawlk trying to install a new screen + // during a resize. + qunlock(&c->drawlk); + rpc_flush(c, fr); + qlock(&c->drawlk); + } } -static -void +static void dstflush(Client *c, int dstid, Memimage *dst, Rectangle r) { Memlayer *l; @@ -173,17 +176,24 @@ dstflush(Client *c, int dstid, Memimage *dst, Rectangle r) addflush(c, r); } -static -void +static void drawflush(Client *c) { - if(c->flushrect.min.x < c->flushrect.max.x) - rpc_flushmemscreen(c, c->flushrect); + Rectangle r; + + r = c->flushrect; c->flushrect = Rect(10000, 10000, -10000, -10000); + if(r.min.x < r.max.x) { + // Unlock drawlk because rpc_flush may want to run on gfx thread, + // and gfx thread might be blocked on drawlk trying to install a new screen + // during a resize. + qunlock(&c->drawlk); + rpc_flush(c, r); + qlock(&c->drawlk); + } } -static -int +static int drawcmp(char *a, char *b, int n) { if(strlen(a) != n) @@ -191,8 +201,7 @@ drawcmp(char *a, char *b, int n) return memcmp(a, b, n); } -static -DName* +static DName* drawlookupname(Client *client, int n, char *str) { DName *name, *ename; @@ -205,8 +214,7 @@ drawlookupname(Client *client, int n, char *str) return 0; } -static -int +static int drawgoodname(Client *client, DImage *d) { DName *n; @@ -224,8 +232,7 @@ drawgoodname(Client *client, DImage *d) return 1; } -static -DImage* +static DImage* drawlookup(Client *client, int id, int checkname) { DImage *d; @@ -246,8 +253,7 @@ drawlookup(Client *client, int id, int checkname) return 0; } -static -DScreen* +static DScreen* drawlookupdscreen(Client *c, int id) { DScreen *s; @@ -261,8 +267,7 @@ drawlookupdscreen(Client *c, int id) return 0; } -static -DScreen* +static DScreen* drawlookupscreen(Client *client, int id, CScreen **cs) { CScreen *s; @@ -279,8 +284,7 @@ drawlookupscreen(Client *client, int id, CScreen **cs) return 0; } -static -Memimage* +static Memimage* drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen) { DImage *d; @@ -304,8 +308,7 @@ drawinstall(Client *client, int id, Memimage *i, DScreen *dscreen) return i; } -static -Memscreen* +static Memscreen* drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *dfill, int public) { Memscreen *s; @@ -358,8 +361,7 @@ drawinstallscreen(Client *client, DScreen *d, int id, DImage *dimage, DImage *df return d->screen; } -static -void +static void drawdelname(Client *client, DName *name) { int i; @@ -369,8 +371,7 @@ drawdelname(Client *client, DName *name) client->nname--; } -static -void +static void drawfreedscreen(Client *client, DScreen *this) { DScreen *ds, *next; @@ -406,8 +407,7 @@ drawfreedscreen(Client *client, DScreen *this) free(this); } -static -void +static void drawfreedimage(Client *client, DImage *dimage) { int i; @@ -456,8 +456,7 @@ drawfreedimage(Client *client, DImage *dimage) free(dimage); } -static -void +static void drawuninstallscreen(Client *client, CScreen *this) { CScreen *cs, *next; @@ -480,8 +479,7 @@ drawuninstallscreen(Client *client, CScreen *this) } } -static -int +static int drawuninstall(Client *client, int id) { DImage *d, **l; @@ -496,8 +494,7 @@ drawuninstall(Client *client, int id) return -1; } -static -int +static int drawaddname(Client *client, DImage *di, int n, char *str, char **err) { DName *name, *ename, *new, *t; @@ -541,8 +538,7 @@ drawclientop(Client *cl) return op; } -static -Memimage* +static Memimage* drawimage(Client *client, uchar *a) { DImage *d; @@ -553,8 +549,7 @@ drawimage(Client *client, uchar *a) return d->image; } -static -void +static void drawrectangle(Rectangle *r, uchar *a) { r->min.x = BGLONG(a+0*4); @@ -563,16 +558,14 @@ drawrectangle(Rectangle *r, uchar *a) r->max.y = BGLONG(a+3*4); } -static -void +static void drawpoint(Point *p, uchar *a) { p->x = BGLONG(a+0*4); p->y = BGLONG(a+1*4); } -static -Point +static Point drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int index, int op) { FChar *fc; @@ -592,8 +585,7 @@ drawchar(Memimage *dst, Point p, Memimage *src, Point *sp, DImage *font, int ind return p; } -static -uchar* +static uchar* drawcoord(uchar *p, uchar *maxp, int oldx, int *newx) { int b, x; @@ -619,9 +611,9 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx) } int -_drawmsgread(Client *cl, void *a, int n) +draw_dataread(Client *cl, void *a, int n) { - qlock(&sdraw.lk); + qlock(&cl->drawlk); if(cl->readdata == nil){ werrstr("no draw data"); goto err; @@ -634,16 +626,16 @@ _drawmsgread(Client *cl, void *a, int n) memmove(a, cl->readdata, cl->nreaddata); free(cl->readdata); cl->readdata = nil; - qunlock(&sdraw.lk); + qunlock(&cl->drawlk); return n; err: - qunlock(&sdraw.lk); + qunlock(&cl->drawlk); return -1; } int -_drawmsgwrite(Client *client, void *v, int n) +draw_datawrite(Client *client, void *v, int n) { char cbuf[40], *err, ibuf[12*12+1], *s; int c, ci, doflush, dstid, e0, e1, esize, j, m; @@ -663,7 +655,7 @@ _drawmsgwrite(Client *client, void *v, int n) Refreshfn reffn; Refx *refx; - qlock(&sdraw.lk); + qlock(&client->drawlk); a = v; m = 0; oldn = n; @@ -1436,7 +1428,7 @@ _drawmsgwrite(Client *client, void *v, int n) continue; } } - qunlock(&sdraw.lk); + qunlock(&client->drawlk); return oldn - n; Enodrawimage: @@ -1506,6 +1498,6 @@ _drawmsgwrite(Client *client, void *v, int n) error: werrstr("%s", err); - qunlock(&sdraw.lk); + qunlock(&client->drawlk); return -1; } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 30586228a..dd7fc8ba1 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -7,7 +7,6 @@ typedef struct Mousebuf Mousebuf; typedef struct Tagbuf Tagbuf; typedef struct Client Client; -typedef struct Draw Draw; typedef struct DImage DImage; typedef struct DScreen DScreen; typedef struct CScreen CScreen; @@ -16,11 +15,6 @@ typedef struct Refresh Refresh; typedef struct Refx Refx; typedef struct DName DName; -struct Draw -{ - QLock lk; -}; - struct Kbdbuf { Rune r[256]; @@ -51,6 +45,19 @@ struct Tagbuf struct Client { + int rfd; + + // wfdlk protects writes to wfd, which can be issued from either + // the RPC thread or the graphics thread. + QLock wfdlk; + int wfd; + uchar* mbuf; + int nmbuf; + + // drawlk protects the draw data structures. + // It can be acquired by an RPC thread or a graphics thread + // but must not be held on one thread while waiting for the other. + QLock drawlk; /*Ref r;*/ DImage* dimage[NHASH]; CScreen* cscreen; @@ -64,7 +71,6 @@ struct Client int refreshme; int infoid; int op; - int displaydpi; int forcedpi; int waste; @@ -75,11 +81,11 @@ struct Client DName* name; int namevers; - int rfd; - int wfd; + // Only accessed/modified by the graphics thread. const void* view; - QLock inputlk; + // eventlk protects the keyboard and mouse events. + QLock eventlk; Kbdbuf kbd; Mousebuf mouse; Tagbuf kbdtags; @@ -157,30 +163,59 @@ struct DScreen DScreen* next; }; -int _drawmsgread(Client*, void*, int); -int _drawmsgwrite(Client*, void*, int); -void _initdisplaymemimage(Client*, Memimage*); -void _drawreplacescreenimage(Client*, Memimage*); - -int _latin1(Rune*, int); -int parsewinsize(char*, Rectangle*, int*); -int mouseswap(int); - +// For the most part, the graphics driver-specific code in files +// like mac-screen.m runs in the graphics library's main thread, +// while the RPC service code in srv.c runs on the RPC service thread. +// The exceptions in each file, which are called by the other, +// are marked with special prefixes: gfx_* indicates code that +// is in srv.c but nonetheless runs on the main graphics thread, +// while rpc_* indicates code that is in, say, mac-screen.m but +// nonetheless runs on the RPC service thread. +// +// The gfx_* and rpc_* calls typically synchronize with the other +// code in the file by acquiring a lock (or running a callback on the +// target thread, which amounts to the same thing). +// To avoid deadlock, callers of those routines must not hold any locks. + +// gfx_* routines are called on the graphics thread, +// invoked from graphics driver callbacks to do RPC work. +// No locks are held on entry. void gfx_abortcompose(Client*); void gfx_keystroke(Client*, int); +void gfx_main(void); void gfx_mousetrack(Client*, int, int, int, uint); +void gfx_replacescreenimage(Client*, Memimage*); +void gfx_started(void); -void rpc_setmouse(Client*, Point); -void rpc_setcursor(Client*, Cursor*, Cursor2*); -void rpc_setlabel(Client*, char*); +// rpc_* routines are called on the RPC thread, +// invoked by the RPC server code to do graphics work. +// No locks are held on entry. +Memimage *rpc_attach(Client*, char*, char*); +char* rpc_getsnarf(void); +void rpc_putsnarf(char*); void rpc_resizeimg(Client*); void rpc_resizewindow(Client*, Rectangle); +void rpc_serve(Client*); +void rpc_setcursor(Client*, Cursor*, Cursor2*); +void rpc_setlabel(Client*, char*); +void rpc_setmouse(Client*, Point); +void rpc_shutdown(void); void rpc_topwin(Client*); -char* rpc_getsnarf(void); -void rpc_putsnarf(char*); -Memimage *rpc_attachscreen(Client*, char*, char*); -void rpc_flushmemscreen(Client*, Rectangle); +void rpc_main(void); + +// TODO: rpc_flush is called from draw_datawrite, +// which holds c->drawlk. Is this OK? +void rpc_flush(Client*, Rectangle); -extern Client *client0; +// draw* routines are called on the RPC thread, +// invoked by the RPC server to do pixel pushing. +// c->drawlk is held on entry. +int draw_dataread(Client*, void*, int); +int draw_datawrite(Client*, void*, int); +void draw_initdisplaymemimage(Client*, Memimage*); + +// utility routines +int latin1(Rune*, int); +int mouseswap(int); +int parsewinsize(char*, Rectangle*, int*); -void servep9p(Client*); diff --git a/src/cmd/devdraw/latin1.c b/src/cmd/devdraw/latin1.c index 2fa9e29d2..a3d13a088 100644 --- a/src/cmd/devdraw/latin1.c +++ b/src/cmd/devdraw/latin1.c @@ -46,7 +46,7 @@ unicode(Rune *k) * is minus the required n. */ int -_latin1(Rune *k, int n) +latin1(Rune *k, int n) { struct cvlist *l; int c; diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index d756d3d75..2ce6bb34b 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -34,13 +34,6 @@ static uint keycvt(uint); static uint msec(void); -void -usage(void) -{ - fprint(2, "usage: devdraw (don't run directly)\n"); - threadexitsall("usage"); -} - @class DrawView; @class DrawLayer; @@ -49,43 +42,9 @@ @interface AppDelegate : NSObject static AppDelegate *myApp = NULL; - -static QLock snarfl; - void -threadmain(int argc, char **argv) +gfx_main(void) { - /* - * Move the protocol off stdin/stdout so that - * any inadvertent prints don't screw things up. - */ - dup(0,3); - dup(1,4); - close(0); - close(1); - open("/dev/null", OREAD); - open("/dev/null", OWRITE); - - ARGBEGIN{ - case 'D': /* for good ps -a listings */ - break; - case 'f': /* fall through for backward compatibility */ - case 'g': - case 'b': - break; - default: - usage(); - }ARGEND - - client0 = mallocz(sizeof(Client), 1); - if(client0 == nil){ - fprint(2, "initdraw: allocating client0: out of memory"); - abort(); - } - client0->displaydpi = 100; - client0->rfd = 3; - client0->wfd = 4; - setprocname(argv0); @autoreleasepool{ @@ -97,12 +56,10 @@ @interface AppDelegate : NSObject } } + void -callservep9p(void *v) +rpc_shutdown(void) { - USED(v); - - servep9p(client0); [NSApp terminate:myApp]; } @@ -128,8 +85,8 @@ - (void)applicationDidFinishLaunching:(id)arg i = [[NSImage alloc] initWithData:d]; [NSApp setApplicationIconImage:i]; [[NSApp dockTile] display]; - - proccreate(callservep9p, nil, 0); + + gfx_started(); } - (NSApplicationPresentationOptions)window:(id)arg @@ -242,10 +199,10 @@ - (BOOL)isOpaque { return YES; } - (BOOL)isFlipped { return YES; } - (BOOL)acceptsFirstResponder { return YES; } -// rpc_attachscreen allocates a new screen window with the given label and size +// rpc_attach allocates a new screen window with the given label and size // and attaches it to client c (by setting c->view). Memimage* -rpc_attachscreen(Client *c, char *label, char *winsize) +rpc_attach(Client *c, char *label, char *winsize) { LOG(@"attachscreen(%s, %s)", label, winsize); @@ -468,71 +425,73 @@ - (void)setcursor:(Cursor*)c cursor2:(Cursor2*)c2 { } - (void)initimg { -@autoreleasepool{ - CGFloat scale; - NSSize size; - MTLTextureDescriptor *textureDesc; - - size = [self convertSizeToBacking:[self bounds].size]; - self.client->mouserect = Rect(0, 0, size.width, size.height); - - LOG(@"initimg %.0f %.0f", size.width, size.height); - - self.img = allocmemimage(self.client->mouserect, XRGB32); - if(self.img == nil) - panic("allocmemimage: %r"); - if(self.img->data == nil) - panic("img->data == nil"); - - textureDesc = [MTLTextureDescriptor - texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm - width:size.width - height:size.height - mipmapped:NO]; - textureDesc.allowGPUOptimizedContents = YES; - textureDesc.usage = MTLTextureUsageShaderRead; - textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; - self.dlayer.texture = [self.dlayer.device newTextureWithDescriptor:textureDesc]; - - scale = [self.win backingScaleFactor]; - [self.dlayer setDrawableSize:size]; - [self.dlayer setContentsScale:scale]; - - // NOTE: This is not really the display DPI. - // On retina, scale is 2; otherwise it is 1. - // This formula gives us 220 for retina, 110 otherwise. - // That's not quite right but it's close to correct. - // https://en.wikipedia.org/wiki/Retina_display#Models - self.client->displaydpi = scale * 110; -} - LOG(@"initimg return"); + @autoreleasepool { + CGFloat scale; + NSSize size; + MTLTextureDescriptor *textureDesc; + + size = [self convertSizeToBacking:[self bounds].size]; + self.client->mouserect = Rect(0, 0, size.width, size.height); + + LOG(@"initimg %.0f %.0f", size.width, size.height); + + self.img = allocmemimage(self.client->mouserect, XRGB32); + if(self.img == nil) + panic("allocmemimage: %r"); + if(self.img->data == nil) + panic("img->data == nil"); + + textureDesc = [MTLTextureDescriptor + texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm + width:size.width + height:size.height + mipmapped:NO]; + textureDesc.allowGPUOptimizedContents = YES; + textureDesc.usage = MTLTextureUsageShaderRead; + textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; + self.dlayer.texture = [self.dlayer.device newTextureWithDescriptor:textureDesc]; + + scale = [self.win backingScaleFactor]; + [self.dlayer setDrawableSize:size]; + [self.dlayer setContentsScale:scale]; + + // NOTE: This is not really the display DPI. + // On retina, scale is 2; otherwise it is 1. + // This formula gives us 220 for retina, 110 otherwise. + // That's not quite right but it's close to correct. + // https://en.wikipedia.org/wiki/Retina_display#Models + self.client->displaydpi = scale * 110; + } } -// rpc_flushmemscreen flushes changes to view.img's rectangle r +// rpc_flush flushes changes to view.img's rectangle r // to the on-screen window, making them visible. // Called from an RPC thread with no client lock held. void -rpc_flushmemscreen(Client *client, Rectangle r) +rpc_flush(Client *client, Rectangle r) { DrawView *view = (__bridge DrawView*)client->view; dispatch_async(dispatch_get_main_queue(), ^(void){ - [view flushmemscreen:r]; + [view flush:r]; }); } -- (void)flushmemscreen:(Rectangle)r { - LOG(@"flushmemscreen(%d,%d,%d,%d)", r.min.x, r.min.y, Dx(r), Dy(r)); - if(!rectinrect(r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height))){ - LOG(@"Rectangle is out of bounds, return."); - return; - } - +- (void)flush:(Rectangle)r { @autoreleasepool{ + if(!rectclip(&r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height)) || !rectclip(&r, self.img->r)) + return; + + // self.client->drawlk protects the pixel data in self.img. + // In addition to avoiding a technical data race, + // the lock avoids drawing partial updates, which makes + // animations like sweeping windows much less flickery. + qlock(&self.client->drawlk); [self.dlayer.texture replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) mipmapLevel:0 withBytes:byteaddr(self.img, Pt(r.min.x, r.min.y)) bytesPerRow:self.img->width*sizeof(u32int)]; + qunlock(&self.client->drawlk); NSRect nr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); dispatch_time_t time; @@ -565,7 +524,7 @@ - (void)flushmemscreen:(Rectangle)r { - (void)resizeimg { [self initimg]; - _drawreplacescreenimage(self.client, self.img); + gfx_replacescreenimage(self.client, self.img); [self sendmouse:0]; } @@ -750,7 +709,7 @@ - (void)sendmouse:(NSUInteger)b }); } --(void)setmouse:(Point)p { +- (void)setmouse:(Point)p { @autoreleasepool{ NSPoint q; @@ -782,21 +741,10 @@ - (void)resetCursorRects { } // conforms to protocol NSTextInputClient -- (BOOL)hasMarkedText -{ - LOG(@"hasMarkedText"); - return _markedRange.location != NSNotFound; -} -- (NSRange)markedRange -{ - LOG(@"markedRange"); - return _markedRange; -} -- (NSRange)selectedRange -{ - LOG(@"selectedRange"); - return _selectedRange; -} +- (BOOL)hasMarkedText { return _markedRange.location != NSNotFound; } +- (NSRange)markedRange { return _markedRange; } +- (NSRange)selectedRange { return _selectedRange; } + - (void)setMarkedText:(id)string selectedRange:(NSRange)sRange replacementRange:(NSRange)rRange @@ -861,8 +809,8 @@ - (void)setMarkedText:(id)string _markedRange.location, _markedRange.length, _selectedRange.location, _selectedRange.length); } -- (void)unmarkText -{ + +- (void)unmarkText { //NSUInteger i; NSUInteger len; @@ -874,12 +822,13 @@ - (void)unmarkText _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); } -- (NSArray *)validAttributesForMarkedText -{ + +- (NSArray*)validAttributesForMarkedText { LOG(@"validAttributesForMarkedText"); return @[]; } -- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)r + +- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)r actualRange:(NSRangePointer)actualRange { NSRange sr; @@ -899,9 +848,8 @@ - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)r LOG(@" return %@", s); return s; } -- (void)insertText:(id)s - replacementRange:(NSRange)r -{ + +- (void)insertText:(id)s replacementRange:(NSRange)r { NSUInteger i; NSUInteger len; @@ -916,22 +864,22 @@ - (void)insertText:(id)s _markedRange = NSMakeRange(NSNotFound, 0); _selectedRange = NSMakeRange(0, 0); } + - (NSUInteger)characterIndexForPoint:(NSPoint)point { LOG(@"characterIndexForPoint: %g, %g", point.x, point.y); return 0; } -- (NSRect)firstRectForCharacterRange:(NSRange)r - actualRange:(NSRangePointer)actualRange -{ + +- (NSRect)firstRectForCharacterRange:(NSRange)r actualRange:(NSRangePointer)actualRange { LOG(@"firstRectForCharacterRange: (%ld, %ld) (%ld, %ld)", r.location, r.length, actualRange->location, actualRange->length); if(actualRange) *actualRange = r; return [[self window] convertRectToScreen:_lastInputRect]; } -- (void)doCommandBySelector:(SEL)s -{ + +- (void)doCommandBySelector:(SEL)s { NSEvent *e; NSEventModifierFlags m; uint c, k; @@ -955,8 +903,7 @@ - (void)doCommandBySelector:(SEL)s } // Helper for managing input rect approximately -- (void)resetLastInputRect -{ +- (void)resetLastInputRect { LOG(@"resetLastInputRect"); _lastInputRect.origin.x = 0.0; _lastInputRect.origin.y = 0.0; @@ -964,8 +911,7 @@ - (void)resetLastInputRect _lastInputRect.size.height = 0.0; } -- (void)enlargeLastInputRect:(NSRect)r -{ +- (void)enlargeLastInputRect:(NSRect)r { r.origin.y = [self bounds].size.height - r.origin.y - r.size.height; _lastInputRect = NSUnionRect(_lastInputRect, r); LOG(@"update last input rect (%g, %g, %g, %g)", @@ -973,8 +919,7 @@ - (void)enlargeLastInputRect:(NSRect)r _lastInputRect.size.width, _lastInputRect.size.height); } -- (void)clearInput -{ +- (void)clearInput { if(_tmpText.length){ uint i; int l; @@ -1079,48 +1024,42 @@ - (void)clearInput } } -// TODO +// rpc_getsnarf reads the current pasteboard as a plain text string. +// Called from an RPC thread with no client lock held. char* rpc_getsnarf(void) { - NSPasteboard *pb; - NSString *s; - - @autoreleasepool{ - pb = [NSPasteboard generalPasteboard]; - - qlock(&snarfl); - s = [pb stringForType:NSPasteboardTypeString]; - qunlock(&snarfl); - - if(s) - return strdup((char *)[s UTF8String]); - else - return nil; - } + char __block *ret; + + ret = nil; + dispatch_sync(dispatch_get_main_queue(), ^(void) { + @autoreleasepool { + NSPasteboard *pb = [NSPasteboard generalPasteboard]; + NSString *s = [pb stringForType:NSPasteboardTypeString]; + if(s) + ret = strdup((char*)[s UTF8String]); + } + }); + return ret; } -// TODO +// rpc_putsnarf writes the given text to the pasteboard. +// Called from an RPC thread with no client lock held. void rpc_putsnarf(char *s) { - NSArray *t; - NSPasteboard *pb; - NSString *str; - - if(strlen(s) >= SnarfSize) + if(s == nil || strlen(s) >= SnarfSize) return; - @autoreleasepool{ - t = [NSArray arrayWithObject:NSPasteboardTypeString]; - pb = [NSPasteboard generalPasteboard]; - str = [[NSString alloc] initWithUTF8String:s]; - - qlock(&snarfl); - [pb declareTypes:t owner:nil]; - [pb setString:str forType:NSPasteboardTypeString]; - qunlock(&snarfl); - } + dispatch_sync(dispatch_get_main_queue(), ^(void) { + @autoreleasepool{ + NSArray *t = [NSArray arrayWithObject:NSPasteboardTypeString]; + NSPasteboard *pb = [NSPasteboard generalPasteboard]; + NSString *str = [[NSString alloc] initWithUTF8String:s]; + [pb declareTypes:t owner:nil]; + [pb setString:str forType:NSPasteboardTypeString]; + } + }); } static void diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 0e7540be9..5169c1131 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -18,18 +18,72 @@ static void runmsg(Client*, Wsysmsg*); static void replymsg(Client*, Wsysmsg*); static void matchkbd(Client*); static void matchmouse(Client*); +static void serve(void*); +static Client *client0; int trace = 0; +static void +usage(void) +{ + fprint(2, "usage: devdraw (don't run directly)\n"); + threadexitsall("usage"); +} + void -servep9p(Client *c) +threadmain(int argc, char **argv) { + /* + * Move the protocol off stdin/stdout so that + * any inadvertent prints don't screw things up. + */ + dup(0,3); + dup(1,4); + close(0); + close(1); + open("/dev/null", OREAD); + open("/dev/null", OWRITE); + + ARGBEGIN{ + case 'D': /* for good ps -a listings */ + break; + case 'f': /* fall through for backward compatibility */ + case 'g': + case 'b': + break; + default: + usage(); + }ARGEND + + fmtinstall('W', drawfcallfmt); + + client0 = mallocz(sizeof(Client), 1); + if(client0 == nil){ + fprint(2, "initdraw: allocating client0: out of memory"); + abort(); + } + client0->displaydpi = 100; + client0->rfd = 3; + client0->wfd = 4; + + gfx_main(); +} + +void +gfx_started(void) +{ + proccreate(serve, client0, 0); +} + +static void +serve(void *v) +{ + Client *c; uchar buf[4], *mbuf; int nmbuf, n, nn; Wsysmsg m; - fmtinstall('W', drawfcallfmt); - + c = v; mbuf = nil; nmbuf = 0; while((n = read(c->rfd, buf, 4)) == 4){ @@ -52,6 +106,9 @@ servep9p(Client *c) if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m); runmsg(c, &m); } + + rpc_shutdown(); + threadexitsall(nil); } static void @@ -79,13 +136,13 @@ runmsg(Client *c, Wsysmsg *m) switch(m->type){ case Tinit: memimageinit(); - i = rpc_attachscreen(c, m->label, m->winsize); - _initdisplaymemimage(c, i); + i = rpc_attach(c, m->label, m->winsize); + draw_initdisplaymemimage(c, i); replymsg(c, m); break; case Trdmouse: - qlock(&c->inputlk); + qlock(&c->eventlk); c->mousetags.t[c->mousetags.wi++] = m->tag; if(c->mousetags.wi == nelem(c->mousetags.t)) c->mousetags.wi = 0; @@ -93,11 +150,11 @@ runmsg(Client *c, Wsysmsg *m) sysfatal("too many queued mouse reads"); c->mouse.stall = 0; matchmouse(c); - qunlock(&c->inputlk); + qunlock(&c->eventlk); break; case Trdkbd: - qlock(&c->inputlk); + qlock(&c->eventlk); c->kbdtags.t[c->kbdtags.wi++] = m->tag; if(c->kbdtags.wi == nelem(c->kbdtags.t)) c->kbdtags.wi = 0; @@ -105,7 +162,7 @@ runmsg(Client *c, Wsysmsg *m) sysfatal("too many queued keyboard reads"); c->kbd.stall = 0; matchkbd(c); - qunlock(&c->inputlk); + qunlock(&c->eventlk); break; case Tmoveto: @@ -148,16 +205,15 @@ runmsg(Client *c, Wsysmsg *m) break; case Twrsnarf: - putsnarf(m->snarf); + rpc_putsnarf(m->snarf); replymsg(c, m); break; case Trddraw: - qlock(&c->inputlk); n = m->count; if(n > sizeof buf) n = sizeof buf; - n = _drawmsgread(c, buf, n); + n = draw_dataread(c, buf, n); if(n < 0) replyerror(c, m); else{ @@ -165,16 +221,13 @@ runmsg(Client *c, Wsysmsg *m) m->data = buf; replymsg(c, m); } - qunlock(&c->inputlk); break; case Twrdraw: - qlock(&c->inputlk); - if(_drawmsgwrite(c, m->data, m->count) < 0) + if(draw_datawrite(c, m->data, m->count) < 0) replyerror(c, m); else replymsg(c, m); - qunlock(&c->inputlk); break; case Ttop: @@ -192,13 +245,10 @@ runmsg(Client *c, Wsysmsg *m) /* * Reply to m. */ -QLock replylock; static void replymsg(Client *c, Wsysmsg *m) { int n; - static uchar *mbuf; - static int nmbuf; /* T -> R msg */ if(m->type%2 == 0) @@ -208,18 +258,18 @@ replymsg(Client *c, Wsysmsg *m) /* copy to output buffer */ n = sizeW2M(m); - qlock(&replylock); - if(n > nmbuf){ - free(mbuf); - mbuf = malloc(n); - if(mbuf == nil) + qlock(&c->wfdlk); + if(n > c->nmbuf){ + free(c->mbuf); + c->mbuf = malloc(n); + if(c->mbuf == nil) sysfatal("out of memory"); - nmbuf = n; + c->nmbuf = n; } - convW2M(m, mbuf, n); - if(write(c->wfd, mbuf, n) != n) + convW2M(m, c->mbuf, n); + if(write(c->wfd, c->mbuf, n) != n) sysfatal("write: %r"); - qunlock(&replylock); + qunlock(&c->wfdlk); } /* @@ -245,13 +295,13 @@ matchkbd(Client *c) } // matchmouse matches queued mouse reads with queued mouse events. -// It must be called with c->inputlk held. +// It must be called with c->eventlk held. static void matchmouse(Client *c) { Wsysmsg m; - if(canqlock(&c->inputlk)) { + if(canqlock(&c->eventlk)) { fprint(2, "misuse of matchmouse\n"); abort(); } @@ -280,7 +330,7 @@ gfx_mousetrack(Client *c, int x, int y, int b, uint ms) { Mouse *m; - qlock(&c->inputlk); + qlock(&c->eventlk); if(x < c->mouserect.min.x) x = c->mouserect.min.x; if(x > c->mouserect.max.x) @@ -312,15 +362,15 @@ gfx_mousetrack(Client *c, int x, int y, int b, uint ms) } matchmouse(c); } - qunlock(&c->inputlk); + qunlock(&c->eventlk); } // kputc adds ch to the keyboard buffer. -// It must be called with c->inputlk held. +// It must be called with c->eventlk held. static void kputc(Client *c, int ch) { - if(canqlock(&c->inputlk)) { + if(canqlock(&c->eventlk)) { fprint(2, "misuse of kputc\n"); abort(); } @@ -339,12 +389,12 @@ kputc(Client *c, int ch) void gfx_abortcompose(Client *c) { - qlock(&c->inputlk); + qlock(&c->eventlk); if(c->kbd.alting) { c->kbd.alting = 0; c->kbd.nk = 0; } - qunlock(&c->inputlk); + qunlock(&c->eventlk); } // gfx_keystroke records a single-rune keystroke. @@ -354,11 +404,11 @@ gfx_keystroke(Client *c, int ch) { int i; - qlock(&c->inputlk); + qlock(&c->eventlk); if(ch == Kalt){ c->kbd.alting = !c->kbd.alting; c->kbd.nk = 0; - qunlock(&c->inputlk); + qunlock(&c->eventlk); return; } if(ch == Kcmd+'r') { @@ -368,24 +418,24 @@ gfx_keystroke(Client *c, int ch) c->forcedpi = 100; else c->forcedpi = 225; - qunlock(&c->inputlk); + qunlock(&c->eventlk); rpc_resizeimg(c); return; } if(!c->kbd.alting){ kputc(c, ch); - qunlock(&c->inputlk); + qunlock(&c->eventlk); return; } if(c->kbd.nk >= nelem(c->kbd.k)) // should not happen c->kbd.nk = 0; c->kbd.k[c->kbd.nk++] = ch; - ch = _latin1(c->kbd.k, c->kbd.nk); + ch = latin1(c->kbd.k, c->kbd.nk); if(ch > 0){ c->kbd.alting = 0; kputc(c, ch); c->kbd.nk = 0; - qunlock(&c->inputlk); + qunlock(&c->eventlk); return; } if(ch == -1){ @@ -393,10 +443,10 @@ gfx_keystroke(Client *c, int ch) for(i=0; ikbd.nk; i++) kputc(c, c->kbd.k[i]); c->kbd.nk = 0; - qunlock(&c->inputlk); + qunlock(&c->eventlk); return; } // need more input - qunlock(&c->inputlk); + qunlock(&c->eventlk); return; } diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c index 4b5b570d2..f9cf0868d 100644 --- a/src/cmd/devdraw/x11-init.c +++ b/src/cmd/devdraw/x11-init.c @@ -733,6 +733,6 @@ _xreplacescreenimage(void) XFreePixmap(_x.display, _x.nextscreenpm); _x.nextscreenpm = pixmap; _x.screenr = r; - _drawreplacescreenimage(m); + gfx_replacescreenimage(m); return 1; } diff --git a/src/cmd/devdraw/x11-itrans.c b/src/cmd/devdraw/x11-itrans.c index bdf7d2b2e..12034d1b4 100644 --- a/src/cmd/devdraw/x11-itrans.c +++ b/src/cmd/devdraw/x11-itrans.c @@ -146,7 +146,7 @@ abortcompose(void) static Rune* sendrune(Rune); -extern int _latin1(Rune*, int); +extern int latin1(Rune*, int); static Rune* xtoplan9latin1(XEvent *e) { @@ -182,7 +182,7 @@ sendrune(Rune r) return nil; } k[nk++] = r; - n = _latin1(k, nk); + n = latin1(k, nk); if(n > 0){ alting = 0; k[0] = n; diff --git a/src/cmd/devdraw/x11-srv.c b/src/cmd/devdraw/x11-srv.c index 4d72415b1..cfede6f59 100644 --- a/src/cmd/devdraw/x11-srv.c +++ b/src/cmd/devdraw/x11-srv.c @@ -365,7 +365,7 @@ runmsg(Wsysmsg *m) n = m->count; if(n > sizeof buf) n = sizeof buf; - n = _drawmsgread(buf, n); + n = draw_dataread(buf, n); if(n < 0) replyerror(m); else{ @@ -376,7 +376,7 @@ runmsg(Wsysmsg *m) break; case Twrdraw: - if(_drawmsgwrite(m->data, m->count) < 0) + if(draw_datawrite(m->data, m->count) < 0) replyerror(m); else replymsg(m); From dbf57689c45611b8da9e269c24e409ee33a877d5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 11 Jan 2020 05:52:59 -0500 Subject: [PATCH 137/323] libdraw: connect to devdraw via $wsysid when set --- include/drawfcall.h | 6 ++++ src/libdraw/drawclient.c | 64 +++++++++++++++++++++++++++++++++++++++- src/libdraw/drawfcall.c | 16 ++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) diff --git a/include/drawfcall.h b/include/drawfcall.h index acab98c5e..8b9656d55 100644 --- a/include/drawfcall.h +++ b/include/drawfcall.h @@ -25,6 +25,9 @@ tag[1] Rrdkbd rune[2] tag[1] Tlabel label[s] tag[1] Rlabel +tag[1] Tctxt wsysid[s] +tag[1] Rctxt + tag[1] Tinit winsize[s] label[s] font[s] tag[1] Rinit @@ -94,6 +97,8 @@ enum { Rresize, Tcursor2 = 28, Rcursor2, + Tctxt = 30, + Rctxt, Tmax, }; @@ -116,6 +121,7 @@ struct Wsysmsg char *label; char *snarf; char *error; + char *id; uchar *data; uint count; Rectangle rect; diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index ef0356b8b..9376f9c00 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -22,11 +22,69 @@ static int canreadfd(int); int _displayconnect(Display *d) { - int pid, p[2]; + int pid, p[2], fd, nbuf, n; + char *wsysid, *addr, *id; + uchar *buf; + Wsysmsg w; fmtinstall('W', drawfcallfmt); fmtinstall('H', encodefmt); + wsysid = getenv("wsysid"); + if(wsysid != nil) { + // Connect to running devdraw service. + // wsysid=devdrawname/id + id = strchr(wsysid, '/'); + if(id == nil) { + werrstr("invalid $wsysid"); + return -1; + } + *id++ = '\0'; + addr = smprint("unix!%s/%s", getns(), wsysid); + if(addr == nil) + return -1; + fd = dial(addr, 0, 0, 0); + free(addr); + if(fd < 0) + return -1; + nbuf = strlen(id) + 500; + buf = malloc(nbuf); + if(buf == nil) { + close(fd); + return -1; + } + memset(&w, 0, sizeof w); + w.type = Tctxt; + w.id = id; + n = convW2M(&w, buf, nbuf); + if(write(fd, buf, n) != n) { + close(fd); + werrstr("wsys short write: %r"); + return -1; + } + n = readwsysmsg(fd, buf, nbuf); + if(n < 0) { + close(fd); + werrstr("wsys short read: %r"); + return -1; + } + if(convM2W(buf, n, &w) <= 0) { + close(fd); + werrstr("wsys decode error"); + return -1; + } + if(w.type != Rctxt) { + close(fd); + if(w.type == Rerror) + werrstr("%s", w.error); + else + werrstr("wsys rpc phase error (%d)", w.type); + return -1; + } + d->srvfd = fd; + return 0; + } + if(pipe(p) < 0) return -1; if((pid=fork()) < 0){ @@ -36,6 +94,10 @@ _displayconnect(Display *d) } if(pid == 0){ char *devdraw; + + devdraw = getenv("DEVDRAW"); + if(devdraw == nil) + devdraw = "devdraw"; close(p[0]); dup(p[1], 0); dup(p[1], 1); diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index c74b3fafb..eea140956 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -51,6 +51,7 @@ sizeW2M(Wsysmsg *m) case Rcursor2: case Trdkbd: case Rlabel: + case Rctxt: case Rinit: case Trdsnarf: case Rwrsnarf: @@ -74,6 +75,9 @@ sizeW2M(Wsysmsg *m) return 4+1+1+2; case Tlabel: return 4+1+1+_stringsize(m->label); + case Tctxt: + return 4+1+1 + +_stringsize(m->id); case Tinit: return 4+1+1 +_stringsize(m->winsize) @@ -114,6 +118,7 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Rcursor2: case Trdkbd: case Rlabel: + case Rctxt: case Rinit: case Trdsnarf: case Rwrsnarf: @@ -164,6 +169,9 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Tlabel: PUTSTRING(p+6, m->label); break; + case Tctxt: + PUTSTRING(p+6, m->id); + break; case Tinit: p += 6; p += PUTSTRING(p, m->winsize); @@ -214,6 +222,7 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Rcursor2: case Trdkbd: case Rlabel: + case Rctxt: case Rinit: case Trdsnarf: case Rwrsnarf: @@ -264,6 +273,9 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Tlabel: GETSTRING(p+6, &m->label); break; + case Tctxt: + GETSTRING(p+6, &m->id); + break; case Tinit: p += 6; p += GETSTRING(p, &m->winsize); @@ -352,6 +364,10 @@ drawfcallfmt(Fmt *fmt) return fmtprint(fmt, "Tlabel label='%s'", m->label); case Rlabel: return fmtprint(fmt, "Rlabel"); + case Tctxt: + return fmtprint(fmt, "Tctxt id='%s'", m->id); + case Rctxt: + return fmtprint(fmt, "Rctxt"); case Tinit: return fmtprint(fmt, "Tinit label='%s' winsize='%s'", m->label, m->winsize); case Rinit: From 2cb85891ba58a83263ef30dc9799d1fda9fb71af Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 11 Jan 2020 06:02:08 -0500 Subject: [PATCH 138/323] cmapcube: don't crash on initdraw failure --- src/cmd/draw/cmapcube.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/draw/cmapcube.c b/src/cmd/draw/cmapcube.c index 4d56322b6..fd234d60a 100644 --- a/src/cmd/draw/cmapcube.c +++ b/src/cmd/draw/cmapcube.c @@ -185,7 +185,8 @@ void main(int argc, char **argv){ break; }ARGEND - initdraw(0,0,0); + if(initdraw(0,0,0) < 0) + sysfatal("initdraw: %r"); ncolor=256; for(i=0;i!=ncolor;i++) color[i] = allocimage(display, Rect(0, 0, 1, 1), CMAP8, 1, cmap2rgba(i)); From 892b3c4687eacf6b090bb9a5196ce882e113c423 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 11 Jan 2020 06:10:14 -0500 Subject: [PATCH 139/323] devdraw: multiclient mode --- src/cmd/devdraw/devdraw.h | 3 + src/cmd/devdraw/mac-screen.m | 15 ++-- src/cmd/devdraw/srv.c | 139 ++++++++++++++++++++++++++--------- 3 files changed, 115 insertions(+), 42 deletions(-) diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index dd7fc8ba1..06ce4f8a4 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -54,6 +54,8 @@ struct Client uchar* mbuf; int nmbuf; + char* wsysid; + // drawlk protects the draw data structures. // It can be acquired by an RPC thread or a graphics thread // but must not be held on one thread while waiting for the other. @@ -219,3 +221,4 @@ int latin1(Rune*, int); int mouseswap(int); int parsewinsize(char*, Rectangle*, int*); +extern Client *client0; // set in single-client mode diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 2ce6bb34b..b3a211019 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -30,6 +30,8 @@ #define LOG if(0)NSLog +// TODO: Maintain list of views for dock menu. + static void setprocname(const char*); static uint keycvt(uint); static uint msec(void); @@ -45,7 +47,8 @@ @interface AppDelegate : NSObject void gfx_main(void) { - setprocname(argv0); + if(client0) + setprocname(argv0); @autoreleasepool{ [NSApplication sharedApplication]; @@ -99,7 +102,7 @@ - (NSApplicationPresentationOptions)window:(id)arg } - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { - return YES; + return client0 != nil; } @end @@ -232,10 +235,7 @@ - (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { r = [[NSScreen mainScreen] visibleFrame]; LOG(@"makewin(%s)", s); - if(s && *s){ - if(parsewinsize(s, &wr, &set) < 0) - sysfatal("%r"); - }else{ + if(s == nil || *s == '\0' || parsewinsize(s, &wr, &set) < 0) { wr = Rect(0, 0, sr.size.width*2/3, sr.size.height*2/3); set = 0; } @@ -344,7 +344,8 @@ - (void)setlabel:(char*)label { @autoreleasepool{ NSString *s = [[NSString alloc] initWithUTF8String:label]; [self.win setTitle:s]; - [[NSApp dockTile] setBadgeLabel:s]; // TODO: Not with multiple windows + if(client0) + [[NSApp dockTile] setBadgeLabel:s]; } } diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 5169c1131..23422ad66 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -18,10 +18,14 @@ static void runmsg(Client*, Wsysmsg*); static void replymsg(Client*, Wsysmsg*); static void matchkbd(Client*); static void matchmouse(Client*); -static void serve(void*); -static Client *client0; +static void serveproc(void*); +static void listenproc(void*); +Client *client0; int trace = 0; +static char *srvname; +static int afd; +static char adir[40]; static void usage(void) @@ -33,17 +37,6 @@ usage(void) void threadmain(int argc, char **argv) { - /* - * Move the protocol off stdin/stdout so that - * any inadvertent prints don't screw things up. - */ - dup(0,3); - dup(1,4); - close(0); - close(1); - open("/dev/null", OREAD); - open("/dev/null", OWRITE); - ARGBEGIN{ case 'D': /* for good ps -a listings */ break; @@ -51,32 +44,89 @@ threadmain(int argc, char **argv) case 'g': case 'b': break; + case 's': + // TODO: Update usage, man page. + srvname = EARGF(usage()); + break; default: usage(); }ARGEND - fmtinstall('W', drawfcallfmt); + if(srvname == nil) { + client0 = mallocz(sizeof(Client), 1); + if(client0 == nil){ + fprint(2, "initdraw: allocating client0: out of memory"); + abort(); + } + client0->displaydpi = 100; + client0->rfd = 3; + client0->wfd = 4; - client0 = mallocz(sizeof(Client), 1); - if(client0 == nil){ - fprint(2, "initdraw: allocating client0: out of memory"); - abort(); + /* + * Move the protocol off stdin/stdout so that + * any inadvertent prints don't screw things up. + */ + dup(0,3); + dup(1,4); + close(0); + close(1); + open("/dev/null", OREAD); + open("/dev/null", OWRITE); } - client0->displaydpi = 100; - client0->rfd = 3; - client0->wfd = 4; + fmtinstall('W', drawfcallfmt); gfx_main(); } void gfx_started(void) { - proccreate(serve, client0, 0); + char *addr; + + if(srvname == nil) { + // Legacy mode: serving single client on pipes. + proccreate(serveproc, client0, 0); + return; + } + + // Server mode. + addr = smprint("unix!%s/%s", getns(), srvname); + if(addr == nil) + sysfatal("out of memory"); + + if((afd = announce(addr, adir)) < 0) + sysfatal("announce %s: %r", addr); + + proccreate(listenproc, nil, 0); +} + +static void +listenproc(void *v) +{ + Client *c; + int fd; + char dir[40]; + + USED(v); + + for(;;) { + fd = listen(adir, dir); + if(fd < 0) + sysfatal("listen: %r"); + c = mallocz(sizeof(Client), 1); + if(c == nil){ + fprint(2, "initdraw: allocating client0: out of memory"); + abort(); + } + c->displaydpi = 100; + c->rfd = fd; + c->wfd = fd; + proccreate(serveproc, c, 0); + } } static void -serve(void *v) +serveproc(void *v) { Client *c; uchar buf[4], *mbuf; @@ -92,23 +142,29 @@ serve(void *v) free(mbuf); mbuf = malloc(4+n); if(mbuf == nil) - sysfatal("malloc: %r"); + sysfatal("out of memory"); nmbuf = n; } memmove(mbuf, buf, 4); nn = readn(c->rfd, mbuf+4, n-4); - if(nn != n-4) - sysfatal("eof during message"); + if(nn != n-4) { + fprint(2, "serveproc: eof during message\n"); + break; + } /* pick off messages one by one */ - if(convM2W(mbuf, nn+4, &m) <= 0) - sysfatal("cannot convert message"); + if(convM2W(mbuf, nn+4, &m) <= 0) { + fprint(2, "serveproc: cannot convert message\n"); + break; + } if(trace) fprint(2, "%ud [%d] <- %W\n", nsec()/1000000, threadid(), &m); runmsg(c, &m); } - rpc_shutdown(); - threadexitsall(nil); + if(c == client0) { + rpc_shutdown(); + threadexitsall(nil); + } } static void @@ -134,6 +190,11 @@ runmsg(Client *c, Wsysmsg *m) Memimage *i; switch(m->type){ + case Tctxt: + c->wsysid = strdup(m->id); + replymsg(c, m); + break; + case Tinit: memimageinit(); i = rpc_attach(c, m->label, m->winsize); @@ -143,11 +204,15 @@ runmsg(Client *c, Wsysmsg *m) case Trdmouse: qlock(&c->eventlk); + if((c->mousetags.wi+1)%nelem(c->mousetags.t) == c->mousetags.ri) { + qunlock(&c->eventlk); + werrstr("too many queued mouse reads"); + replyerror(c, m); + break; + } c->mousetags.t[c->mousetags.wi++] = m->tag; if(c->mousetags.wi == nelem(c->mousetags.t)) c->mousetags.wi = 0; - if(c->mousetags.wi == c->mousetags.ri) - sysfatal("too many queued mouse reads"); c->mouse.stall = 0; matchmouse(c); qunlock(&c->eventlk); @@ -155,11 +220,15 @@ runmsg(Client *c, Wsysmsg *m) case Trdkbd: qlock(&c->eventlk); + if((c->kbdtags.wi+1)%nelem(c->kbdtags.t) == c->kbdtags.ri) { + qunlock(&c->eventlk); + werrstr("too many queued keyboard reads"); + replyerror(c, m); + break; + } c->kbdtags.t[c->kbdtags.wi++] = m->tag; if(c->kbdtags.wi == nelem(c->kbdtags.t)) c->kbdtags.wi = 0; - if(c->kbdtags.wi == c->kbdtags.ri) - sysfatal("too many queued keyboard reads"); c->kbd.stall = 0; matchkbd(c); qunlock(&c->eventlk); @@ -268,7 +337,7 @@ replymsg(Client *c, Wsysmsg *m) } convW2M(m, c->mbuf, n); if(write(c->wfd, c->mbuf, n) != n) - sysfatal("write: %r"); + fprint(2, "client write: %r\n"); qunlock(&c->wfdlk); } From 50923426bf684402160dd7748f14560afd447b73 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 12 Jan 2020 14:53:46 -0500 Subject: [PATCH 140/323] devdraw: x11 working again Need to think a bit more about locking, but overall it's a working devdraw. Multiclient mode may not be working but nothing is using it yet. --- src/cmd/devdraw/devdraw.c | 7 + src/cmd/devdraw/devdraw.h | 15 +- src/cmd/devdraw/mac-screen.m | 54 +- src/cmd/devdraw/mkfile | 5 +- src/cmd/devdraw/snarf.c | 109 -- src/cmd/devdraw/srv.c | 2 +- src/cmd/devdraw/x11-alloc.c | 4 +- src/cmd/devdraw/x11-inc.h | 2 - src/cmd/devdraw/x11-init.c | 738 -------------- src/cmd/devdraw/x11-itrans.c | 741 -------------- src/cmd/devdraw/x11-memdraw.h | 66 +- src/cmd/devdraw/x11-screen.c | 1759 +++++++++++++++++++++++++++++++++ src/cmd/devdraw/x11-srv.c | 637 ------------ src/cmd/devdraw/x11-wsys.c | 45 - 14 files changed, 1844 insertions(+), 2340 deletions(-) delete mode 100644 src/cmd/devdraw/snarf.c delete mode 100644 src/cmd/devdraw/x11-init.c delete mode 100644 src/cmd/devdraw/x11-itrans.c create mode 100644 src/cmd/devdraw/x11-screen.c delete mode 100644 src/cmd/devdraw/x11-srv.c delete mode 100644 src/cmd/devdraw/x11-wsys.c diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index e3040779d..086574ef1 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -144,9 +144,11 @@ addflush(Client *c, Rectangle r) // Unlock drawlk because rpc_flush may want to run on gfx thread, // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. + rpc_gfxdrawunlock(); qunlock(&c->drawlk); rpc_flush(c, fr); qlock(&c->drawlk); + rpc_gfxdrawlock(); } } @@ -187,9 +189,11 @@ drawflush(Client *c) // Unlock drawlk because rpc_flush may want to run on gfx thread, // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. + rpc_gfxdrawunlock(); qunlock(&c->drawlk); rpc_flush(c, r); qlock(&c->drawlk); + rpc_gfxdrawlock(); } } @@ -656,6 +660,7 @@ draw_datawrite(Client *client, void *v, int n) Refx *refx; qlock(&client->drawlk); + rpc_gfxdrawlock(); a = v; m = 0; oldn = n; @@ -1428,6 +1433,7 @@ draw_datawrite(Client *client, void *v, int n) continue; } } + rpc_gfxdrawunlock(); qunlock(&client->drawlk); return oldn - n; @@ -1498,6 +1504,7 @@ draw_datawrite(Client *client, void *v, int n) error: werrstr("%s", err); + rpc_gfxdrawunlock(); qunlock(&client->drawlk); return -1; } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 06ce4f8a4..4980ed905 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -85,7 +85,7 @@ struct Client // Only accessed/modified by the graphics thread. const void* view; - + // eventlk protects the keyboard and mouse events. QLock eventlk; Kbdbuf kbd; @@ -204,14 +204,19 @@ void rpc_setmouse(Client*, Point); void rpc_shutdown(void); void rpc_topwin(Client*); void rpc_main(void); - -// TODO: rpc_flush is called from draw_datawrite, -// which holds c->drawlk. Is this OK? +void rpc_bouncemouse(Client*, Mouse); void rpc_flush(Client*, Rectangle); +// rpc_gfxdrawlock and rpc_gfxdrawunlock +// are called around drawing operations to lock and unlock +// access to the graphics display, for systems where the +// individual memdraw operations use the graphics display (X11, not macOS). +void rpc_gfxdrawlock(void); +void rpc_gfxdrawunlock(void); + // draw* routines are called on the RPC thread, // invoked by the RPC server to do pixel pushing. -// c->drawlk is held on entry. +// No locks are held on entry. int draw_dataread(Client*, void*, int); int draw_datawrite(Client*, void*, int); void draw_initdisplaymemimage(Client*, Memimage*); diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index b3a211019..47df3dc52 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -88,7 +88,7 @@ - (void)applicationDidFinishLaunching:(id)arg i = [[NSImage alloc] initWithData:d]; [NSApp setApplicationIconImage:i]; [[NSApp dockTile] display]; - + gfx_started(); } @@ -124,9 +124,9 @@ - (void)display [self setNeedsDisplay]; return; } - + LOG(@"display got drawable"); - + id cbuf = [self.cmd commandBuffer]; id blit = [cbuf blitCommandEncoder]; [blit copyFromTexture:self.texture @@ -139,7 +139,7 @@ - (void)display destinationLevel:0 destinationOrigin:MTLOriginMake(0, 0, 0)]; [blit endEncoding]; - + [cbuf presentDrawable:drawable]; drawable = nil; [cbuf addCompletedHandler:^(id cmdBuff){ @@ -208,7 +208,7 @@ - (BOOL)acceptsFirstResponder { return YES; } rpc_attach(Client *c, char *label, char *winsize) { LOG(@"attachscreen(%s, %s)", label, winsize); - + dispatch_sync(dispatch_get_main_queue(), ^(void) { @autoreleasepool { DrawView *view = [[DrawView new] attach:c winsize:winsize label:label]; @@ -268,7 +268,7 @@ - (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { [win setDelegate:self]; [self setWantsLayer:YES]; [self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay]; - + id device = nil; allDevices = MTLCopyAllDevices(); for(id mtlDevice in allDevices) { @@ -304,7 +304,7 @@ - (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { [self topwin]; [self setlabel:label]; [self setcursor:nil cursor2:nil]; - + return self; } @@ -430,18 +430,18 @@ - (void)initimg { CGFloat scale; NSSize size; MTLTextureDescriptor *textureDesc; - + size = [self convertSizeToBacking:[self bounds].size]; self.client->mouserect = Rect(0, 0, size.width, size.height); - + LOG(@"initimg %.0f %.0f", size.width, size.height); - + self.img = allocmemimage(self.client->mouserect, XRGB32); if(self.img == nil) panic("allocmemimage: %r"); if(self.img->data == nil) panic("img->data == nil"); - + textureDesc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm width:size.width @@ -451,11 +451,11 @@ - (void)initimg { textureDesc.usage = MTLTextureUsageShaderRead; textureDesc.cpuCacheMode = MTLCPUCacheModeWriteCombined; self.dlayer.texture = [self.dlayer.device newTextureWithDescriptor:textureDesc]; - + scale = [self.win backingScaleFactor]; [self.dlayer setDrawableSize:size]; [self.dlayer setContentsScale:scale]; - + // NOTE: This is not really the display DPI. // On retina, scale is 2; otherwise it is 1. // This formula gives us 220 for retina, 110 otherwise. @@ -481,7 +481,7 @@ - (void)flush:(Rectangle)r { @autoreleasepool{ if(!rectclip(&r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height)) || !rectclip(&r, self.img->r)) return; - + // self.client->drawlk protects the pixel data in self.img. // In addition to avoiding a technical data race, // the lock avoids drawing partial updates, which makes @@ -501,12 +501,12 @@ - (void)flush:(Rectangle)r { nr = [self.win convertRectFromBacking:nr]; LOG(@"setNeedsDisplayInRect(%g, %g, %g, %g)", nr.origin.x, nr.origin.y, nr.size.width, nr.size.height); [self.dlayer setNeedsDisplayInRect:nr]; - + time = dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC); dispatch_after(time, dispatch_get_main_queue(), ^(void){ [self.dlayer setNeedsDisplayInRect:nr]; }); - + [self enlargeLastInputRect:nr]; } } @@ -1031,7 +1031,7 @@ - (void)clearInput { rpc_getsnarf(void) { char __block *ret; - + ret = nil; dispatch_sync(dispatch_get_main_queue(), ^(void) { @autoreleasepool { @@ -1063,6 +1063,26 @@ - (void)clearInput { }); } +// rpc_bouncemouse is for sending a mouse event +// back to the X11 window manager rio(1). +// Does not apply here. +void +rpc_bouncemouse(Client *c, Mouse m) +{ +} + +// We don't use the graphics thread state during memimagedraw, +// so rpc_gfxdrawlock and rpc_gfxdrawunlock are no-ops. +void +rpc_gfxdrawlock(void) +{ +} + +void +rpc_gfxdrawunlock(void) +{ +} + static void setprocname(const char *s) { diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile index 7ecf7dc17..6bcf18909 100644 --- a/src/cmd/devdraw/mkfile +++ b/src/cmd/devdraw/mkfile @@ -28,9 +28,6 @@ HFILES=\ $O.drawclient: drawclient.$O $LD -o $target $prereq -$O.snarf: x11-alloc.$O x11-cload.$O x11-draw.$O x11-fill.$O x11-get.$O x11-init.$O x11-itrans.$O x11-keysym2ucs.$O x11-load.$O x11-pixelbits.$O x11-unload.$O x11-wsys.$O snarf.$O latin1.$O devdraw.$O - $LD -o $target $prereq - $O.mklatinkbd: mklatinkbd.$O $LD -o $target $prereq @@ -48,7 +45,7 @@ $O.macargv: $MACARGV CLEANFILES=$O.devdraw $O.macargv $O.drawclient $O.mklatinkbd latin1.h install: mklatinkbd.install -install:Q: +install:Q: if [ $MACARGV ]; then mk $MKFLAGS macargv.install fi diff --git a/src/cmd/devdraw/snarf.c b/src/cmd/devdraw/snarf.c deleted file mode 100644 index 4d350654d..000000000 --- a/src/cmd/devdraw/snarf.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include "x11-inc.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "x11-memdraw.h" -#include "devdraw.h" - -#undef time - -#define MouseMask (\ - ButtonPressMask|\ - ButtonReleaseMask|\ - PointerMotionMask|\ - Button1MotionMask|\ - Button2MotionMask|\ - Button3MotionMask) - -#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|EnterWindowMask|LeaveWindowMask - -void runxevent(XEvent*); - -void -usage(void) -{ - fprint(2, "usage: snarf [-a] [-o | text]\n"); - exits("usage"); -} - -void -main(int argc, char **argv) -{ - int apple; - int out; - - apple = 0; - out = 0; - - ARGBEGIN{ - case 'a': - apple = 1; - break; - case 'o': - out = 1; - break; - default: - usage(); - }ARGEND - - if(out && argc != 0) - usage(); - if(!out && argc != 1) - usage(); - - _x.fd = -1; - - memimageinit(); - _xattach("snarf", "20x20"); - - XSelectInput(_x.display, _x.drawable, Mask); - XFlush(_x.display); - - if(out){ - char *s; - if(apple) - s = _applegetsnarf(); - else - s = _xgetsnarf(); - write(1, s, strlen(s)); - write(1, "\n", 1); - exits(0); - }else{ - _xputsnarf(argv[0]); - for(;;){ - XEvent event; - XNextEvent(_x.display, &event); - runxevent(&event); - } - } -} - -/* - * Handle an incoming X event. - */ -void -runxevent(XEvent *xev) -{ - switch(xev->type){ - case Expose: - _xexpose(xev); - break; - - case DestroyNotify: - if(_xdestroy(xev)) - exits(0); - break; - - case SelectionRequest: - _xselect(xev); - break; - } -} diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 23422ad66..bfeb7c386 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -258,7 +258,7 @@ runmsg(Client *c, Wsysmsg *m) break; case Tbouncemouse: - // _xbouncemouse(&m->mouse); + rpc_bouncemouse(c, m->mouse); replymsg(c, m); break; diff --git a/src/cmd/devdraw/x11-alloc.c b/src/cmd/devdraw/x11-alloc.c index 9d85b4514..cee930647 100644 --- a/src/cmd/devdraw/x11-alloc.c +++ b/src/cmd/devdraw/x11-alloc.c @@ -21,7 +21,7 @@ _xallocmemimage(Rectangle r, u32int chan, int pixmap) m = _allocmemimage(r, chan); if(chan != GREY1 && chan != _x.chan) return m; - if(_x.display == 0) + if(_x.display == 0 || _x.windows == nil) return m; /* @@ -49,7 +49,7 @@ _xallocmemimage(Rectangle r, u32int chan, int pixmap) if(pixmap != PMundef) xm->pixmap = pixmap; else - xm->pixmap = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), d); + xm->pixmap = XCreatePixmap(_x.display, _x.windows->drawable, Dx(r), Dy(r), d); /* * We want to align pixels on word boundaries. diff --git a/src/cmd/devdraw/x11-inc.h b/src/cmd/devdraw/x11-inc.h index 1ac27d657..dca3ebcdb 100644 --- a/src/cmd/devdraw/x11-inc.h +++ b/src/cmd/devdraw/x11-inc.h @@ -31,5 +31,3 @@ #undef Screen #undef Visual #undef Window - -void sendalt(void); diff --git a/src/cmd/devdraw/x11-init.c b/src/cmd/devdraw/x11-init.c deleted file mode 100644 index f9cf0868d..000000000 --- a/src/cmd/devdraw/x11-init.c +++ /dev/null @@ -1,738 +0,0 @@ -/* - * Some of the stuff in this file is not X-dependent and should be elsewhere. - */ -#include -#include "x11-inc.h" -#include -#include -#include -#include -#include -#include -#include -#include "x11-memdraw.h" -#include "devdraw.h" - -static void plan9cmap(void); -static int setupcmap(XWindow); -static XGC xgc(XDrawable, int, int); - -Xprivate _x; - -static int -xerror(XDisplay *d, XErrorEvent *e) -{ - char buf[200]; - - if(e->request_code == 42) /* XSetInputFocus */ - return 0; - if(e->request_code == 18) /* XChangeProperty */ - return 0; - /* - * BadDrawable happens in apps that get resized a LOT, - * e.g. when KDE is configured to resize continuously - * during a window drag. - */ - if(e->error_code == 9) /* BadDrawable */ - return 0; - - fprint(2, "X error: error_code=%d, request_code=%d, minor=%d disp=%p\n", - e->error_code, e->request_code, e->minor_code, d); - XGetErrorText(d, e->error_code, buf, sizeof buf); - fprint(2, "%s\n", buf); - return 0; -} - -static int -xioerror(XDisplay *d) -{ - /*print("X I/O error\n"); */ - exit(0); - /*sysfatal("X I/O error\n");*/ - abort(); - return -1; -} - - -Memimage* -_xattach(char *label, char *winsize) -{ - char *argv[2], *disp; - int i, havemin, height, mask, n, width, x, xrootid, y; - Rectangle r; - XClassHint classhint; - XDrawable pmid; - XPixmapFormatValues *pfmt; - XScreen *xscreen; - XSetWindowAttributes attr; - XSizeHints normalhint; - XTextProperty name; - XVisualInfo xvi; - XWindow xrootwin; - XWindowAttributes wattr; - XWMHints hint; - Atom atoms[2]; - - /* - if(XInitThreads() == 0){ - fprint(2, "XInitThreads failed\n"); - abort(); - } - */ - - /* - * Connect to X server. - */ - _x.display = XOpenDisplay(NULL); - if(_x.display == nil){ - disp = getenv("DISPLAY"); - werrstr("XOpenDisplay %s: %r", disp ? disp : ":0"); - free(disp); - return nil; - } - _x.fd = ConnectionNumber(_x.display); - XSetErrorHandler(xerror); - XSetIOErrorHandler(xioerror); - xrootid = DefaultScreen(_x.display); - xrootwin = DefaultRootWindow(_x.display); - - /* - * Figure out underlying screen format. - */ - if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi) - || XMatchVisualInfo(_x.display, xrootid, 24, DirectColor, &xvi)){ - _x.vis = xvi.visual; - _x.depth = 24; - } - else - if(XMatchVisualInfo(_x.display, xrootid, 16, TrueColor, &xvi) - || XMatchVisualInfo(_x.display, xrootid, 16, DirectColor, &xvi)){ - _x.vis = xvi.visual; - _x.depth = 16; - } - else - if(XMatchVisualInfo(_x.display, xrootid, 15, TrueColor, &xvi) - || XMatchVisualInfo(_x.display, xrootid, 15, DirectColor, &xvi)){ - _x.vis = xvi.visual; - _x.depth = 15; - } - else - if(XMatchVisualInfo(_x.display, xrootid, 8, PseudoColor, &xvi) - || XMatchVisualInfo(_x.display, xrootid, 8, StaticColor, &xvi)){ - if(_x.depth > 8){ - werrstr("can't deal with colormapped depth %d screens", - _x.depth); - goto err0; - } - _x.vis = xvi.visual; - _x.depth = 8; - } - else{ - _x.depth = DefaultDepth(_x.display, xrootid); - if(_x.depth != 8){ - werrstr("can't understand depth %d screen", _x.depth); - goto err0; - } - _x.vis = DefaultVisual(_x.display, xrootid); - } - - if(DefaultDepth(_x.display, xrootid) == _x.depth) - _x.usetable = 1; - - /* - * _x.depth is only the number of significant pixel bits, - * not the total number of pixel bits. We need to walk the - * display list to find how many actual bits are used - * per pixel. - */ - _x.chan = 0; - pfmt = XListPixmapFormats(_x.display, &n); - for(i=0; iclass != StaticColor){ - plan9cmap(); - setupcmap(xrootwin); - } - - /* - * We get to choose the initial rectangle size. - * This is arbitrary. In theory we should read the - * command line and allow the traditional X options. - */ - mask = 0; - x = 0; - y = 0; - if(winsize && winsize[0]){ - if(parsewinsize(winsize, &r, &havemin) < 0) - sysfatal("%r"); - }else{ - /* - * Parse the various X resources. Thanks to Peter Canning. - */ - char *screen_resources, *display_resources, *geom, - *geomrestype, *home, *file, *dpitype; - XrmDatabase database; - XrmValue geomres, dpires; - - database = XrmGetDatabase(_x.display); - screen_resources = XScreenResourceString(xscreen); - if(screen_resources != nil){ - XrmCombineDatabase(XrmGetStringDatabase(screen_resources), &database, False); - XFree(screen_resources); - } - - display_resources = XResourceManagerString(_x.display); - if(display_resources == nil){ - home = getenv("HOME"); - if(home!=nil && (file=smprint("%s/.Xdefaults", home)) != nil){ - XrmCombineFileDatabase(file, &database, False); - free(file); - } - free(home); - }else - XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False); - - if (XrmGetResource(database, "Xft.dpi", "String", &dpitype, &dpires) == True) { - if (dpires.addr) { - client0->displaydpi = atoi(dpires.addr); - } - } - geom = smprint("%s.geometry", label); - if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres)) - mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height); - XrmDestroyDatabase(database); - free(geom); - - if((mask & WidthValue) && (mask & HeightValue)){ - r = Rect(0, 0, width, height); - }else{ - r = Rect(0, 0, WidthOfScreen(xscreen)*3/4, - HeightOfScreen(xscreen)*3/4); - if(Dx(r) > Dy(r)*3/2) - r.max.x = r.min.x + Dy(r)*3/2; - if(Dy(r) > Dx(r)*3/2) - r.max.y = r.min.y + Dx(r)*3/2; - } - if(mask & XNegative){ - x += WidthOfScreen(xscreen); - } - if(mask & YNegative){ - y += HeightOfScreen(xscreen); - } - havemin = 0; - } - screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); - windowrect = r; - - memset(&attr, 0, sizeof attr); - attr.colormap = _x.cmap; - attr.background_pixel = ~0; - attr.border_pixel = 0; - _x.drawable = XCreateWindow( - _x.display, /* display */ - xrootwin, /* parent */ - x, /* x */ - y, /* y */ - Dx(r), /* width */ - Dy(r), /* height */ - 0, /* border width */ - _x.depth, /* depth */ - InputOutput, /* class */ - _x.vis, /* visual */ - /* valuemask */ - CWBackPixel|CWBorderPixel|CWColormap, - &attr /* attributes (the above aren't?!) */ - ); - - /* - * Label and other properties required by ICCCCM. - */ - memset(&name, 0, sizeof name); - if(label == nil) - label = "pjw-face-here"; - name.value = (uchar*)label; - name.encoding = XA_STRING; - name.format = 8; - name.nitems = strlen((char*)name.value); - - memset(&normalhint, 0, sizeof normalhint); - normalhint.flags = PSize|PMaxSize; - if(winsize && winsize[0]){ - normalhint.flags &= ~PSize; - normalhint.flags |= USSize; - normalhint.width = Dx(r); - normalhint.height = Dy(r); - }else{ - if((mask & WidthValue) && (mask & HeightValue)){ - normalhint.flags &= ~PSize; - normalhint.flags |= USSize; - normalhint.width = width; - normalhint.height = height; - } - if((mask & WidthValue) && (mask & HeightValue)){ - normalhint.flags |= USPosition; - normalhint.x = x; - normalhint.y = y; - } - } - - normalhint.max_width = WidthOfScreen(xscreen); - normalhint.max_height = HeightOfScreen(xscreen); - - memset(&hint, 0, sizeof hint); - hint.flags = InputHint|StateHint; - hint.input = 1; - hint.initial_state = NormalState; - - memset(&classhint, 0, sizeof classhint); - classhint.res_name = label; - classhint.res_class = label; - - argv[0] = label; - argv[1] = nil; - - XSetWMProperties( - _x.display, /* display */ - _x.drawable, /* window */ - &name, /* XA_WM_NAME property */ - &name, /* XA_WM_ICON_NAME property */ - argv, /* XA_WM_COMMAND */ - 1, /* argc */ - &normalhint, /* XA_WM_NORMAL_HINTS */ - &hint, /* XA_WM_HINTS */ - &classhint /* XA_WM_CLASSHINTS */ - ); - XFlush(_x.display); - - if(havemin){ - XWindowChanges ch; - - memset(&ch, 0, sizeof ch); - ch.x = r.min.x; - ch.y = r.min.y; - XConfigureWindow(_x.display, _x.drawable, CWX|CWY, &ch); - /* - * Must pretend origin is 0,0 for X. - */ - r = Rect(0,0,Dx(r),Dy(r)); - } - /* - * Look up clipboard atom. - */ - _x.clipboard = XInternAtom(_x.display, "CLIPBOARD", False); - _x.utf8string = XInternAtom(_x.display, "UTF8_STRING", False); - _x.targets = XInternAtom(_x.display, "TARGETS", False); - _x.text = XInternAtom(_x.display, "TEXT", False); - _x.compoundtext = XInternAtom(_x.display, "COMPOUND_TEXT", False); - _x.takefocus = XInternAtom(_x.display, "WM_TAKE_FOCUS", False); - _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False); - _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False); - - atoms[0] = _x.takefocus; - atoms[1] = _x.losefocus; - XChangeProperty(_x.display, _x.drawable, _x.wmprotos, XA_ATOM, 32, - PropModeReplace, (uchar*)atoms, 2); - - /* - * Put the window on the screen, check to see what size we actually got. - */ - XMapWindow(_x.display, _x.drawable); - XSync(_x.display, False); - - if(!XGetWindowAttributes(_x.display, _x.drawable, &wattr)) - fprint(2, "XGetWindowAttributes failed\n"); - else if(wattr.width && wattr.height){ - if(wattr.width != Dx(r) || wattr.height != Dy(r)){ - r.max.x = wattr.width; - r.max.y = wattr.height; - } - }else - fprint(2, "XGetWindowAttributes: bad attrs\n"); - - /* - * Allocate our local backing store. - */ - _x.screenr = r; - _x.screenpm = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth); - _x.nextscreenpm = _x.screenpm; - _x.screenimage = _xallocmemimage(r, _x.chan, _x.screenpm); - - /* - * Allocate some useful graphics contexts for the future. - */ - _x.gcfill = xgc(_x.screenpm, FillSolid, -1); - _x.gccopy = xgc(_x.screenpm, -1, -1); - _x.gcsimplesrc = xgc(_x.screenpm, FillStippled, -1); - _x.gczero = xgc(_x.screenpm, -1, -1); - _x.gcreplsrc = xgc(_x.screenpm, FillTiled, -1); - - pmid = XCreatePixmap(_x.display, _x.drawable, 1, 1, 1); - _x.gcfill0 = xgc(pmid, FillSolid, 0); - _x.gccopy0 = xgc(pmid, -1, -1); - _x.gcsimplesrc0 = xgc(pmid, FillStippled, -1); - _x.gczero0 = xgc(pmid, -1, -1); - _x.gcreplsrc0 = xgc(pmid, FillTiled, -1); - XFreePixmap(_x.display, pmid); - - return _x.screenimage; - -err0: - /* - * Should do a better job of cleaning up here. - */ - XCloseDisplay(_x.display); - return nil; -} - -int -_xsetlabel(char *label) -{ - XTextProperty name; - - /* - * Label and other properties required by ICCCCM. - */ - memset(&name, 0, sizeof name); - if(label == nil) - label = "pjw-face-here"; - name.value = (uchar*)label; - name.encoding = XA_STRING; - name.format = 8; - name.nitems = strlen((char*)name.value); - - XSetWMProperties( - _x.display, /* display */ - _x.drawable, /* window */ - &name, /* XA_WM_NAME property */ - &name, /* XA_WM_ICON_NAME property */ - nil, /* XA_WM_COMMAND */ - 0, /* argc */ - nil, /* XA_WM_NORMAL_HINTS */ - nil, /* XA_WM_HINTS */ - nil /* XA_WM_CLASSHINTS */ - ); - XFlush(_x.display); - return 0; -} - -/* - * Create a GC with a particular fill style and XXX. - * Disable generation of GraphicsExpose/NoExpose events in the GC. - */ -static XGC -xgc(XDrawable d, int fillstyle, int foreground) -{ - XGC gc; - XGCValues v; - - memset(&v, 0, sizeof v); - v.function = GXcopy; - v.graphics_exposures = False; - gc = XCreateGC(_x.display, d, GCFunction|GCGraphicsExposures, &v); - if(fillstyle != -1) - XSetFillStyle(_x.display, gc, fillstyle); - if(foreground != -1) - XSetForeground(_x.display, gc, 0); - return gc; -} - - -/* - * Initialize map with the Plan 9 rgbv color map. - */ -static void -plan9cmap(void) -{ - int r, g, b, cr, cg, cb, v, num, den, idx, v7, idx7; - static int once; - - if(once) - return; - once = 1; - - for(r=0; r!=4; r++) - for(g = 0; g != 4; g++) - for(b = 0; b!=4; b++) - for(v = 0; v!=4; v++){ - den=r; - if(g > den) - den=g; - if(b > den) - den=b; - /* divide check -- pick grey shades */ - if(den==0) - cr=cg=cb=v*17; - else { - num=17*(4*den+v); - cr=r*num/den; - cg=g*num/den; - cb=b*num/den; - } - idx = r*64 + v*16 + ((g*4 + b + v - r) & 15); - _x.map[idx].red = cr*0x0101; - _x.map[idx].green = cg*0x0101; - _x.map[idx].blue = cb*0x0101; - _x.map[idx].pixel = idx; - _x.map[idx].flags = DoRed|DoGreen|DoBlue; - - v7 = v >> 1; - idx7 = r*32 + v7*16 + g*4 + b; - if((v & 1) == v7){ - _x.map7to8[idx7][0] = idx; - if(den == 0) { /* divide check -- pick grey shades */ - cr = ((255.0/7.0)*v7)+0.5; - cg = cr; - cb = cr; - } - else { - num=17*15*(4*den+v7*2)/14; - cr=r*num/den; - cg=g*num/den; - cb=b*num/den; - } - _x.map7[idx7].red = cr*0x0101; - _x.map7[idx7].green = cg*0x0101; - _x.map7[idx7].blue = cb*0x0101; - _x.map7[idx7].pixel = idx7; - _x.map7[idx7].flags = DoRed|DoGreen|DoBlue; - } - else - _x.map7to8[idx7][1] = idx; - } -} - -/* - * Initialize and install the rgbv color map as a private color map - * for this application. It gets the best colors when it has the - * cursor focus. - * - * We always choose the best depth possible, but that might not - * be the default depth. On such "suboptimal" systems, we have to allocate an - * empty color map anyway, according to Axel Belinfante. - */ -static int -setupcmap(XWindow w) -{ - char buf[30]; - int i; - u32int p, pp; - XColor c; - - if(_x.depth <= 1) - return 0; - - if(_x.depth >= 24) { - if(_x.usetable == 0) - _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); - - /* - * The pixel value returned from XGetPixel needs to - * be converted to RGB so we can call rgb2cmap() - * to translate between 24 bit X and our color. Unfortunately, - * the return value appears to be display server endian - * dependant. Therefore, we run some heuristics to later - * determine how to mask the int value correctly. - * Yeah, I know we can look at _x.vis->byte_order but - * some displays say MSB even though they run on LSB. - * Besides, this is more anal. - */ - c = _x.map[19]; /* known to have different R, G, B values */ - if(!XAllocColor(_x.display, _x.cmap, &c)){ - werrstr("XAllocColor: %r"); - return -1; - } - p = c.pixel; - pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff); - if(pp != _x.map[19].pixel) { - /* check if endian is other way */ - pp = rgb2cmap(p&0xff,(p>>8)&0xff,(p>>16)&0xff); - if(pp != _x.map[19].pixel){ - werrstr("cannot detect X server byte order"); - return -1; - } - - switch(_x.chan){ - case RGB24: - _x.chan = BGR24; - break; - case XRGB32: - _x.chan = XBGR32; - break; - default: - werrstr("cannot byteswap channel %s", - chantostr(buf, _x.chan)); - break; - } - } - }else if(_x.vis->class == TrueColor || _x.vis->class == DirectColor){ - /* - * Do nothing. We have no way to express a - * mixed-endian 16-bit screen, so pretend they don't exist. - */ - if(_x.usetable == 0) - _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); - }else if(_x.vis->class == PseudoColor){ - if(_x.usetable == 0){ - _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll); - XStoreColors(_x.display, _x.cmap, _x.map, 256); - for(i = 0; i < 256; i++){ - _x.tox11[i] = i; - _x.toplan9[i] = i; - } - }else{ - for(i = 0; i < 128; i++){ - c = _x.map7[i]; - if(!XAllocColor(_x.display, _x.cmap, &c)){ - werrstr("can't allocate colors in 7-bit map"); - return -1; - } - _x.tox11[_x.map7to8[i][0]] = c.pixel; - _x.tox11[_x.map7to8[i][1]] = c.pixel; - _x.toplan9[c.pixel] = _x.map7to8[i][0]; - } - } - }else{ - werrstr("unsupported visual class %d", _x.vis->class); - return -1; - } - return 0; -} - -void -_flushmemscreen(Rectangle r) -{ - if(_x.nextscreenpm != _x.screenpm){ - qlock(&_x.screenlock); - XSync(_x.display, False); - XFreePixmap(_x.display, _x.screenpm); - _x.screenpm = _x.nextscreenpm; - qunlock(&_x.screenlock); - } - - if(r.min.x >= r.max.x || r.min.y >= r.max.y) - return; - XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y, - Dx(r), Dy(r), r.min.x, r.min.y); - XFlush(_x.display); -} - -void -_xexpose(XEvent *e) -{ - XExposeEvent *xe; - Rectangle r; - - qlock(&_x.screenlock); - if(_x.screenpm != _x.nextscreenpm){ - qunlock(&_x.screenlock); - return; - } - xe = (XExposeEvent*)e; - r.min.x = xe->x; - r.min.y = xe->y; - r.max.x = xe->x+xe->width; - r.max.y = xe->y+xe->height; - XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y, - Dx(r), Dy(r), r.min.x, r.min.y); - XSync(_x.display, False); - qunlock(&_x.screenlock); -} - -int -_xdestroy(XEvent *e) -{ - XDestroyWindowEvent *xe; - - xe = (XDestroyWindowEvent*)e; - if(xe->window == _x.drawable){ - _x.destroyed = 1; - return 1; - } - return 0; -} - -int -_xconfigure(XEvent *e) -{ - Rectangle r; - XConfigureEvent *xe = (XConfigureEvent*)e; - - if(!fullscreen){ - int rx, ry; - XWindow w; - if(XTranslateCoordinates(_x.display, _x.drawable, DefaultRootWindow(_x.display), 0, 0, &rx, &ry, &w)) - windowrect = Rect(rx, ry, rx+xe->width, ry+xe->height); - } - - if(xe->width == Dx(_x.screenr) && xe->height == Dy(_x.screenr)) - return 0; - r = Rect(0, 0, xe->width, xe->height); - - qlock(&_x.screenlock); - if(_x.screenpm != _x.nextscreenpm){ - XCopyArea(_x.display, _x.screenpm, _x.drawable, _x.gccopy, r.min.x, r.min.y, - Dx(r), Dy(r), r.min.x, r.min.y); - XSync(_x.display, False); - } - qunlock(&_x.screenlock); - _x.newscreenr = r; - return 1; -} - -int -_xreplacescreenimage(void) -{ - Memimage *m; - XDrawable pixmap; - Rectangle r; - - r = _x.newscreenr; - - pixmap = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth); - m = _xallocmemimage(r, _x.chan, pixmap); - if(_x.nextscreenpm != _x.screenpm) - XFreePixmap(_x.display, _x.nextscreenpm); - _x.nextscreenpm = pixmap; - _x.screenr = r; - gfx_replacescreenimage(m); - return 1; -} diff --git a/src/cmd/devdraw/x11-itrans.c b/src/cmd/devdraw/x11-itrans.c deleted file mode 100644 index 12034d1b4..000000000 --- a/src/cmd/devdraw/x11-itrans.c +++ /dev/null @@ -1,741 +0,0 @@ -/* input event and data structure translation */ - -#include -#include "x11-inc.h" -#ifdef __APPLE__ -#define APPLESNARF -#define Boolean AppleBoolean -#define Rect AppleRect -#define EventMask AppleEventMask -#define Point ApplePoint -#define Cursor AppleCursor -#include -AUTOFRAMEWORK(Carbon) -#undef Boolean -#undef Rect -#undef EventMask -#undef Point -#undef Cursor -#endif -#include -#include -#include -#include -#include -#include -#include "x11-memdraw.h" -#include "x11-keysym2ucs.h" -#undef time - -static KeySym -__xtoplan9kbd(XEvent *e) -{ - KeySym k; - - if(e->xany.type != KeyPress) - return -1; - needstack(64*1024); /* X has some *huge* buffers in openobject */ - /* and they're even bigger on SuSE */ - XLookupString((XKeyEvent*)e,NULL,0,&k,NULL); - if(k == NoSymbol) - return -1; - - if(k&0xFF00){ - switch(k){ - case XK_BackSpace: - case XK_Tab: - case XK_Escape: - case XK_Delete: - case XK_KP_0: - case XK_KP_1: - case XK_KP_2: - case XK_KP_3: - case XK_KP_4: - case XK_KP_5: - case XK_KP_6: - case XK_KP_7: - case XK_KP_8: - case XK_KP_9: - case XK_KP_Divide: - case XK_KP_Multiply: - case XK_KP_Subtract: - case XK_KP_Add: - case XK_KP_Decimal: - k &= 0x7F; - break; - case XK_Linefeed: - k = '\r'; - break; - case XK_KP_Space: - k = ' '; - break; - case XK_Home: - case XK_KP_Home: - k = Khome; - break; - case XK_Left: - case XK_KP_Left: - k = Kleft; - break; - case XK_Up: - case XK_KP_Up: - k = Kup; - break; - case XK_Down: - case XK_KP_Down: - k = Kdown; - break; - case XK_Right: - case XK_KP_Right: - k = Kright; - break; - case XK_Page_Down: - case XK_KP_Page_Down: - k = Kpgdown; - break; - case XK_End: - case XK_KP_End: - k = Kend; - break; - case XK_Page_Up: - case XK_KP_Page_Up: - k = Kpgup; - break; - case XK_Insert: - case XK_KP_Insert: - k = Kins; - break; - case XK_KP_Enter: - case XK_Return: - k = '\n'; - break; - case XK_Alt_L: - case XK_Meta_L: /* Shift Alt on PCs */ - case XK_Alt_R: - case XK_Meta_R: /* Shift Alt on PCs */ - case XK_Multi_key: - return -1; - default: /* not ISO-1 or tty control */ - if(k>0xff) { - k = _p9keysym2ucs(k); - if(k==-1) return -1; - } - } - } - - /* Compensate for servers that call a minus a hyphen */ - if(k == XK_hyphen) - k = XK_minus; - /* Do control mapping ourselves if translator doesn't */ - if(e->xkey.state&ControlMask) - k &= 0x9f; - if(k == NoSymbol) { - return -1; - } - - return k+0; -} - -int alting; - -void -abortcompose(void) -{ - alting = 0; -} - -static Rune* sendrune(Rune); - -extern int latin1(Rune*, int); -static Rune* -xtoplan9latin1(XEvent *e) -{ - Rune r; - - r = __xtoplan9kbd(e); - if(r == -1) - return nil; - return sendrune(r); -} - -void -sendalt(void) -{ - sendrune(Kalt); -} - -static Rune* -sendrune(Rune r) -{ - static Rune k[10]; - static int nk; - int n; - - if(alting){ - /* - * Kludge for Mac's X11 3-button emulation. - * It treats Command+Button as button 3, but also - * ends up sending XK_Meta_L twice. - */ - if(r == Kalt){ - alting = 0; - return nil; - } - k[nk++] = r; - n = latin1(k, nk); - if(n > 0){ - alting = 0; - k[0] = n; - k[1] = 0; - return k; - } - if(n == -1){ - alting = 0; - k[nk] = 0; - return k; - } - /* n < -1, need more input */ - return nil; - }else if(r == Kalt){ - alting = 1; - nk = 0; - return nil; - }else{ - k[0] = r; - k[1] = 0; - return k; - } -} - -int -_xtoplan9kbd(XEvent *e) -{ - static Rune *r; - - if(e == (XEvent*)-1){ - assert(r); - r--; - return 0; - } - if(e) - r = xtoplan9latin1(e); - if(r && *r) - return *r++; - return -1; -} - -int -_xtoplan9mouse(XEvent *e, Mouse *m) -{ - int s; - XButtonEvent *be; - XMotionEvent *me; - - if(_x.putsnarf != _x.assertsnarf){ - _x.assertsnarf = _x.putsnarf; - XSetSelectionOwner(_x.display, XA_PRIMARY, _x.drawable, CurrentTime); - if(_x.clipboard != None) - XSetSelectionOwner(_x.display, _x.clipboard, _x.drawable, CurrentTime); - XFlush(_x.display); - } - - switch(e->type){ - case ButtonPress: - be = (XButtonEvent*)e; - - /* - * Fake message, just sent to make us announce snarf. - * Apparently state and button are 16 and 8 bits on - * the wire, since they are truncated by the time they - * get to us. - */ - if(be->send_event - && (~be->state&0xFFFF)==0 - && (~be->button&0xFF)==0) - return -1; - /* BUG? on mac need to inherit these from elsewhere? */ - m->xy.x = be->x; - m->xy.y = be->y; - s = be->state; - m->msec = be->time; - switch(be->button){ - case 1: - s |= Button1Mask; - break; - case 2: - s |= Button2Mask; - break; - case 3: - s |= Button3Mask; - break; - case 4: - s |= Button4Mask; - break; - case 5: - s |= Button5Mask; - break; - } - break; - case ButtonRelease: - be = (XButtonEvent*)e; - m->xy.x = be->x; - m->xy.y = be->y; - s = be->state; - m->msec = be->time; - switch(be->button){ - case 1: - s &= ~Button1Mask; - break; - case 2: - s &= ~Button2Mask; - break; - case 3: - s &= ~Button3Mask; - break; - case 4: - s &= ~Button4Mask; - break; - case 5: - s &= ~Button5Mask; - break; - } - break; - - case MotionNotify: - me = (XMotionEvent*)e; - s = me->state; - m->xy.x = me->x; - m->xy.y = me->y; - m->msec = me->time; - return 0; // do not set buttons - - default: - return -1; - } - - m->buttons = 0; - if(s & Button1Mask) - m->buttons |= 1; - if(s & Button2Mask) - m->buttons |= 2; - if(s & Button3Mask) - m->buttons |= 4; - if(s & Button4Mask) - m->buttons |= 8; - if(s & Button5Mask) - m->buttons |= 16; - return 0; -} - -void -_xmoveto(Point p) -{ - XWarpPointer(_x.display, None, _x.drawable, 0, 0, 0, 0, p.x, p.y); - XFlush(_x.display); -} - -static int -revbyte(int b) -{ - int r; - - r = 0; - r |= (b&0x01) << 7; - r |= (b&0x02) << 5; - r |= (b&0x04) << 3; - r |= (b&0x08) << 1; - r |= (b&0x10) >> 1; - r |= (b&0x20) >> 3; - r |= (b&0x40) >> 5; - r |= (b&0x80) >> 7; - return r; -} - -static void -xcursorarrow(void) -{ - if(_x.cursor != 0){ - XFreeCursor(_x.display, _x.cursor); - _x.cursor = 0; - } - XUndefineCursor(_x.display, _x.drawable); - XFlush(_x.display); -} - - -void -_xsetcursor(Cursor *c) -{ - XColor fg, bg; - XCursor xc; - Pixmap xsrc, xmask; - int i; - uchar src[2*16], mask[2*16]; - - if(c == nil){ - xcursorarrow(); - return; - } - for(i=0; i<2*16; i++){ - src[i] = revbyte(c->set[i]); - mask[i] = revbyte(c->set[i] | c->clr[i]); - } - - fg = _x.map[0]; - bg = _x.map[255]; - xsrc = XCreateBitmapFromData(_x.display, _x.drawable, (char*)src, 16, 16); - xmask = XCreateBitmapFromData(_x.display, _x.drawable, (char*)mask, 16, 16); - xc = XCreatePixmapCursor(_x.display, xsrc, xmask, &fg, &bg, -c->offset.x, -c->offset.y); - if(xc != 0) { - XDefineCursor(_x.display, _x.drawable, xc); - if(_x.cursor != 0) - XFreeCursor(_x.display, _x.cursor); - _x.cursor = xc; - } - XFreePixmap(_x.display, xsrc); - XFreePixmap(_x.display, xmask); - XFlush(_x.display); -} - -struct { - QLock lk; - char buf[SnarfSize]; -#ifdef APPLESNARF - Rune rbuf[SnarfSize]; - PasteboardRef apple; -#endif -} clip; - -static uchar* -_xgetsnarffrom(XWindow w, Atom clipboard, Atom target, int timeout0, int timeout) -{ - Atom prop, type; - ulong len, lastlen, dummy; - int fmt, i; - uchar *data, *xdata; - - /* - * We should be waiting for SelectionNotify here, but it might never - * come, and we have no way to time out. Instead, we will clear - * local property #1, request our buddy to fill it in for us, and poll - * until he's done or we get tired of waiting. - */ - prop = 1; - XChangeProperty(_x.display, _x.drawable, prop, target, 8, PropModeReplace, (uchar*)"", 0); - XConvertSelection(_x.display, clipboard, target, prop, _x.drawable, CurrentTime); - XFlush(_x.display); - lastlen = 0; - timeout0 = (timeout0 + 9)/10; - timeout = (timeout + 9)/10; - for(i=0; i 0){ - XFree(xdata); - break; - } - lastlen = len; - XFree(xdata); - } - if(len == 0) - return nil; - - /* get the property */ - xdata = nil; - XGetWindowProperty(_x.display, _x.drawable, prop, 0, SnarfSize/sizeof(ulong), 0, - AnyPropertyType, &type, &fmt, &len, &dummy, &xdata); - if((type != target && type != XA_STRING && type != _x.utf8string) || len == 0){ - if(xdata) - XFree(xdata); - return nil; - } - if(xdata){ - data = (uchar*)strdup((char*)xdata); - XFree(xdata); - return data; - } - return nil; -} - -char* -_xgetsnarf(void) -{ - uchar *data; - Atom clipboard; - XWindow w; - - qlock(&clip.lk); - /* - * Have we snarfed recently and the X server hasn't caught up? - */ - if(_x.putsnarf != _x.assertsnarf) - goto mine; - - /* - * Is there a primary selection (highlighted text in an xterm)? - */ - clipboard = XA_PRIMARY; - w = XGetSelectionOwner(_x.display, XA_PRIMARY); - if(w == _x.drawable){ - mine: - data = (uchar*)strdup(clip.buf); - goto out; - } - - /* - * If not, is there a clipboard selection? - */ - if(w == None && _x.clipboard != None){ - clipboard = _x.clipboard; - w = XGetSelectionOwner(_x.display, _x.clipboard); - if(w == _x.drawable) - goto mine; - } - - /* - * If not, give up. - */ - if(w == None){ - data = nil; - goto out; - } - - if((data = _xgetsnarffrom(w, clipboard, _x.utf8string, 10, 100)) == nil) - if((data = _xgetsnarffrom(w, clipboard, XA_STRING, 10, 100)) == nil){ - /* nothing left to do */ - } - -out: - qunlock(&clip.lk); - return (char*)data; -} - -void -__xputsnarf(char *data) -{ - XButtonEvent e; - - if(strlen(data) >= SnarfSize) - return; - qlock(&clip.lk); - strcpy(clip.buf, data); - /* leave note for mouse proc to assert selection ownership */ - _x.putsnarf++; - - /* send mouse a fake event so snarf is announced */ - memset(&e, 0, sizeof e); - e.type = ButtonPress; - e.window = _x.drawable; - e.state = ~0; - e.button = ~0; - XSendEvent(_x.display, _x.drawable, True, ButtonPressMask, (XEvent*)&e); - XFlush(_x.display); - qunlock(&clip.lk); -} - -int -_xselect(XEvent *e) -{ - char *name; - XEvent r; - XSelectionRequestEvent *xe; - Atom a[4]; - - memset(&r, 0, sizeof r); - xe = (XSelectionRequestEvent*)e; -if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d (sizeof atom=%d)\n", - xe->target, xe->requestor, xe->property, xe->selection, sizeof a[0]); - r.xselection.property = xe->property; - if(xe->target == _x.targets){ - a[0] = _x.utf8string; - a[1] = XA_STRING; - a[2] = _x.text; - a[3] = _x.compoundtext; - XChangeProperty(_x.display, xe->requestor, xe->property, XA_ATOM, - 32, PropModeReplace, (uchar*)a, nelem(a)); - }else if(xe->target == XA_STRING - || xe->target == _x.utf8string - || xe->target == _x.text - || xe->target == _x.compoundtext - || ((name = XGetAtomName(_x.display, xe->target)) && strcmp(name, "text/plain;charset=UTF-8") == 0)){ - /* text/plain;charset=UTF-8 seems nonstandard but is used by Synergy */ - /* if the target is STRING we're supposed to reply with Latin1 XXX */ - qlock(&clip.lk); - XChangeProperty(_x.display, xe->requestor, xe->property, xe->target, - 8, PropModeReplace, (uchar*)clip.buf, strlen(clip.buf)); - qunlock(&clip.lk); - }else{ - if(strcmp(name, "TIMESTAMP") != 0) - fprint(2, "%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target); - r.xselection.property = None; - } - - r.xselection.display = xe->display; - /* r.xselection.property filled above */ - r.xselection.target = xe->target; - r.xselection.type = SelectionNotify; - r.xselection.requestor = xe->requestor; - r.xselection.time = xe->time; - r.xselection.send_event = True; - r.xselection.selection = xe->selection; - XSendEvent(_x.display, xe->requestor, False, 0, &r); - XFlush(_x.display); - return 0; -} - -#ifdef APPLESNARF -char* -_applegetsnarf(void) -{ - char *s, *t; - CFArrayRef flavors; - CFDataRef data; - CFIndex nflavor, ndata, j; - CFStringRef type; - ItemCount nitem; - PasteboardItemID id; - PasteboardSyncFlags flags; - UInt32 i; - -/* fprint(2, "applegetsnarf\n"); */ - qlock(&clip.lk); - if(clip.apple == nil){ - if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){ - fprint(2, "apple pasteboard create failed\n"); - qunlock(&clip.lk); - return nil; - } - } - flags = PasteboardSynchronize(clip.apple); - if(flags&kPasteboardClientIsOwner){ - s = strdup(clip.buf); - qunlock(&clip.lk); - return s; - } - if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){ - fprint(2, "apple pasteboard get item count failed\n"); - qunlock(&clip.lk); - return nil; - } - for(i=1; i<=nitem; i++){ - if(PasteboardGetItemIdentifier(clip.apple, i, &id) != noErr) - continue; - if(PasteboardCopyItemFlavors(clip.apple, id, &flavors) != noErr) - continue; - nflavor = CFArrayGetCount(flavors); - for(j=0; j= SnarfSize) - return; - qlock(&clip.lk); - strcpy(clip.buf, s); - runesnprint(clip.rbuf, nelem(clip.rbuf), "%s", s); - if(clip.apple == nil){ - if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){ - fprint(2, "apple pasteboard create failed\n"); - qunlock(&clip.lk); - return; - } - } - if(PasteboardClear(clip.apple) != noErr){ - fprint(2, "apple pasteboard clear failed\n"); - qunlock(&clip.lk); - return; - } - flags = PasteboardSynchronize(clip.apple); - if((flags&kPasteboardModified) || !(flags&kPasteboardClientIsOwner)){ - fprint(2, "apple pasteboard cannot assert ownership\n"); - qunlock(&clip.lk); - return; - } - cfdata = CFDataCreate(kCFAllocatorDefault, - (uchar*)clip.rbuf, runestrlen(clip.rbuf)*2); - if(cfdata == nil){ - fprint(2, "apple pasteboard cfdatacreate failed\n"); - qunlock(&clip.lk); - return; - } - if(PasteboardPutItemFlavor(clip.apple, (PasteboardItemID)1, - CFSTR("public.utf16-plain-text"), cfdata, 0) != noErr){ - fprint(2, "apple pasteboard putitem failed\n"); - CFRelease(cfdata); - qunlock(&clip.lk); - return; - } - /* CFRelease(cfdata); ??? */ - qunlock(&clip.lk); -} -#endif /* APPLESNARF */ - -void -_xputsnarf(char *data) -{ -#ifdef APPLESNARF - _appleputsnarf(data); -#endif - __xputsnarf(data); -} - -/* - * Send the mouse event back to the window manager. - * So that 9term can tell rio to pop up its button3 menu. - */ -void -_xbouncemouse(Mouse *m) -{ - XButtonEvent e; - XWindow dw; - - e.type = ButtonPress; - e.state = 0; - e.button = 0; - if(m->buttons&1) - e.button = 1; - else if(m->buttons&2) - e.button = 2; - else if(m->buttons&4) - e.button = 3; - e.same_screen = 1; - XTranslateCoordinates(_x.display, _x.drawable, - DefaultRootWindow(_x.display), - m->xy.x, m->xy.y, &e.x_root, &e.y_root, &dw); - e.root = DefaultRootWindow(_x.display); - e.window = e.root; - e.subwindow = None; - e.x = e.x_root; - e.y = e.y_root; -#undef time - e.time = CurrentTime; - XUngrabPointer(_x.display, m->msec); - XSendEvent(_x.display, e.root, True, ButtonPressMask, (XEvent*)&e); - XFlush(_x.display); -} diff --git a/src/cmd/devdraw/x11-memdraw.h b/src/cmd/devdraw/x11-memdraw.h index d2cab13bf..0c78b9b64 100644 --- a/src/cmd/devdraw/x11-memdraw.h +++ b/src/cmd/devdraw/x11-memdraw.h @@ -4,6 +4,7 @@ typedef struct Xmem Xmem; typedef struct Xprivate Xprivate; +typedef struct Xwin Xwin; enum { @@ -26,7 +27,6 @@ struct Xprivate { XDisplay *display; int fd; /* of display */ int depth; /* of screen */ - XDrawable drawable; XColor map[256]; XColor map7[128]; uchar map7to8[128][2]; @@ -50,12 +50,6 @@ struct Xprivate { u32int gczeropixmap; XGC gczero0; u32int gczero0pixmap; - Rectangle newscreenr; - Memimage* screenimage; - QLock screenlock; - XDrawable screenpm; - XDrawable nextscreenpm; - Rectangle screenr; int toplan9[256]; int tox11[256]; int usetable; @@ -70,9 +64,35 @@ struct Xprivate { Atom wmprotos; uint putsnarf; uint assertsnarf; + int kbuttons; + int kstate; + int altdown; + + Xwin* windows; +}; + +struct Client; + +struct Xwin +{ + XDrawable drawable; + struct Client* client; + + Rectangle newscreenr; + Memimage* screenimage; + XDrawable screenpm; + XDrawable nextscreenpm; + Rectangle screenr; + Rectangle screenrect; + Rectangle windowrect; + int fullscreen; int destroyed; + + Xwin* next; }; +void xlock(void); +void xunlock(void); extern Xprivate _x; extern Memimage *_xallocmemimage(Rectangle, u32int, int); @@ -83,35 +103,3 @@ extern void _xfreexdata(Memimage*); extern XImage *_xgetxdata(Memimage*, Rectangle); extern void _xputxdata(Memimage*, Rectangle); -struct Mouse; -extern int _xtoplan9mouse(XEvent*, struct Mouse*); -extern int _xtoplan9kbd(XEvent*); -extern void _xexpose(XEvent*); -extern int _xselect(XEvent*); -extern int _xconfigure(XEvent*); -extern int _xdestroy(XEvent*); -extern void _flushmemscreen(Rectangle); -extern void _xmoveto(Point); -struct Cursor; -extern void _xsetcursor(struct Cursor*); -extern void _xbouncemouse(Mouse*); -extern int _xsetlabel(char*); -extern Memimage* _xattach(char*, char*); -extern char* _xgetsnarf(void); -extern void _xputsnarf(char *data); -extern void _xtopwindow(void); -extern void _xresizewindow(Rectangle); -extern void _xmovewindow(Rectangle); -extern int _xreplacescreenimage(void); - -#define MouseMask (\ - ButtonPressMask|\ - ButtonReleaseMask|\ - PointerMotionMask|\ - Button1MotionMask|\ - Button2MotionMask|\ - Button3MotionMask) - -extern Rectangle screenrect; -extern Rectangle windowrect; -extern int fullscreen; diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c new file mode 100644 index 000000000..8026e1e6b --- /dev/null +++ b/src/cmd/devdraw/x11-screen.c @@ -0,0 +1,1759 @@ +#include +#include "x11-inc.h" +#include "x11-keysym2ucs.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "x11-memdraw.h" +#include "devdraw.h" + +#undef time + +static void plan9cmap(void); +static int setupcmap(XWindow); +static XGC xgc(XDrawable, int, int); +#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|KeyReleaseMask|EnterWindowMask|LeaveWindowMask|FocusChangeMask + +#define MouseMask (\ + ButtonPressMask|\ + ButtonReleaseMask|\ + PointerMotionMask|\ + Button1MotionMask|\ + Button2MotionMask|\ + Button3MotionMask) + +Xprivate _x; + +static void runxevent(XEvent *xev); +static int _xconfigure(Xwin *w, XEvent *e); +static int _xdestroy(Xwin *w, XEvent *e); +static void _xexpose(Xwin *w, XEvent *e); +static int _xreplacescreenimage(Client *client); +static int _xtoplan9mouse(Xwin *w, XEvent *e, Mouse *m); +static void _xmovewindow(Xwin *w, Rectangle r); +static int _xtoplan9kbd(XEvent *e); +static int _xselect(XEvent *e); + +static Xwin* +newxwin(Client *c) +{ + Xwin *w; + + w = mallocz(sizeof *w, 1); + if(w == nil) + sysfatal("out of memory"); + w->client = c; + w->next = _x.windows; + _x.windows = w; + c->view = w; + return w; +} + +static Xwin* +findxwin(XDrawable d) +{ + Xwin *w, **l; + + for(l=&_x.windows; (w=*l) != nil; l=&w->next) { + if(w->drawable == d) { + /* move to front */ + *l = w->next; + w->next = _x.windows; + _x.windows = w; + return w; + } + } + return nil; +} + +static int +xerror(XDisplay *d, XErrorEvent *e) +{ + char buf[200]; + + if(e->request_code == 42) /* XSetInputFocus */ + return 0; + if(e->request_code == 18) /* XChangeProperty */ + return 0; + /* + * BadDrawable happens in apps that get resized a LOT, + * e.g. when KDE is configured to resize continuously + * during a window drag. + */ + if(e->error_code == 9) /* BadDrawable */ + return 0; + + fprint(2, "X error: error_code=%d, request_code=%d, minor=%d disp=%p\n", + e->error_code, e->request_code, e->minor_code, d); + XGetErrorText(d, e->error_code, buf, sizeof buf); + fprint(2, "%s\n", buf); + return 0; +} + +static int +xioerror(XDisplay *d) +{ + /*print("X I/O error\n"); */ + exit(0); + /*sysfatal("X I/O error\n");*/ + abort(); + return -1; +} + +static void xloop(void); + +static QLock xlk; + +void +xlock(void) +{ + qlock(&xlk); +} + +void +xunlock(void) +{ + qunlock(&xlk); +} + +void +gfx_main(void) +{ + char *disp; + int i, n, xrootid; + XPixmapFormatValues *pfmt; + XScreen *xscreen; + XVisualInfo xvi; + XWindow xrootwin; + + /* + if(XInitThreads() == 0) + sysfatal("XInitThread: %r"); + */ + + /* + * Connect to X server. + */ + _x.display = XOpenDisplay(NULL); + if(_x.display == nil){ + disp = getenv("DISPLAY"); + werrstr("XOpenDisplay %s: %r", disp ? disp : ":0"); + free(disp); + sysfatal("%r"); + } + _x.fd = ConnectionNumber(_x.display); + XSetErrorHandler(xerror); + XSetIOErrorHandler(xioerror); + xrootid = DefaultScreen(_x.display); + xrootwin = DefaultRootWindow(_x.display); + + /* + * Figure out underlying screen format. + */ + if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi) + || XMatchVisualInfo(_x.display, xrootid, 24, DirectColor, &xvi)){ + _x.vis = xvi.visual; + _x.depth = 24; + } + else + if(XMatchVisualInfo(_x.display, xrootid, 16, TrueColor, &xvi) + || XMatchVisualInfo(_x.display, xrootid, 16, DirectColor, &xvi)){ + _x.vis = xvi.visual; + _x.depth = 16; + } + else + if(XMatchVisualInfo(_x.display, xrootid, 15, TrueColor, &xvi) + || XMatchVisualInfo(_x.display, xrootid, 15, DirectColor, &xvi)){ + _x.vis = xvi.visual; + _x.depth = 15; + } + else + if(XMatchVisualInfo(_x.display, xrootid, 8, PseudoColor, &xvi) + || XMatchVisualInfo(_x.display, xrootid, 8, StaticColor, &xvi)){ + if(_x.depth > 8){ + werrstr("can't deal with colormapped depth %d screens", + _x.depth); + goto err0; + } + _x.vis = xvi.visual; + _x.depth = 8; + } + else{ + _x.depth = DefaultDepth(_x.display, xrootid); + if(_x.depth != 8){ + werrstr("can't understand depth %d screen", _x.depth); + goto err0; + } + _x.vis = DefaultVisual(_x.display, xrootid); + } + + if(DefaultDepth(_x.display, xrootid) == _x.depth) + _x.usetable = 1; + + /* + * _x.depth is only the number of significant pixel bits, + * not the total number of pixel bits. We need to walk the + * display list to find how many actual bits are used + * per pixel. + */ + _x.chan = 0; + pfmt = XListPixmapFormats(_x.display, &n); + for(i=0; iclass != StaticColor){ + plan9cmap(); + setupcmap(xrootwin); + } + gfx_started(); + xloop(); + +err0: + XCloseDisplay(_x.display); + sysfatal("%r"); +} + +static void +xloop(void) +{ + fd_set rd, wr, xx; + XEvent event; + + xlock(); + _x.fd = ConnectionNumber(_x.display); + for(;;) { + FD_ZERO(&rd); + FD_ZERO(&wr); + FD_ZERO(&xx); + FD_SET(_x.fd, &rd); + FD_SET(_x.fd, &xx); + if(_x.windows != nil) + XSelectInput(_x.display, _x.windows->drawable, Mask); // TODO: when is this needed? + XFlush(_x.display); + xunlock(); + + again: + if(select(_x.fd+1, &rd, &wr, &xx, nil) < 0) { + if(errno == EINTR) + goto again; + sysfatal("select: %r"); // TODO: quiet exit? + } + + xlock(); + while(XPending(_x.display)) { + XNextEvent(_x.display, &event); + runxevent(&event); + } + } +} + +/* + * Handle an incoming X event. + */ +static void +runxevent(XEvent *xev) +{ + int c; + KeySym k; + static Mouse m; + XButtonEvent *be; + XKeyEvent *ke; + Xwin *w; + +#ifdef SHOWEVENT + static int first = 1; + if(first){ + dup(create("/tmp/devdraw.out", OWRITE, 0666), 1); + setbuf(stdout, 0); + first = 0; + } +#endif + + if(xev == 0) + return; + +#ifdef SHOWEVENT + print("\n"); + ShowEvent(xev); +#endif + + w = nil; + switch(xev->type){ + case Expose: + w = findxwin(((XExposeEvent*)xev)->window); + break; + case DestroyNotify: + w = findxwin(((XDestroyWindowEvent*)xev)->window); + break; + case ConfigureNotify: + w = findxwin(((XConfigureEvent*)xev)->window); + break; + case ButtonPress: + case ButtonRelease: + w = findxwin(((XButtonEvent*)xev)->window); + break; + case MotionNotify: + w = findxwin(((XMotionEvent*)xev)->window); + break; + case KeyRelease: + case KeyPress: + w = findxwin(((XKeyEvent*)xev)->window); + break; + case FocusOut: + w = findxwin(((XFocusChangeEvent*)xev)->window); + break; + } + if(w == nil) + w = _x.windows; + + switch(xev->type){ + case Expose: + _xexpose(w, xev); + break; + + case DestroyNotify: + if(_xdestroy(w, xev)) + threadexitsall(nil); + break; + + case ConfigureNotify: + if(_xconfigure(w, xev)) + _xreplacescreenimage(w->client); + break; + + case ButtonPress: + be = (XButtonEvent*)xev; + if(be->button == 1) { + if(_x.kstate & ControlMask) + be->button = 2; + else if(_x.kstate & Mod1Mask) + be->button = 3; + } + // fall through + case ButtonRelease: + _x.altdown = 0; + // fall through + case MotionNotify: + if(_xtoplan9mouse(w, xev, &m) < 0) + return; + gfx_mousetrack(w->client, m.xy.x, m.xy.y, m.buttons|_x.kbuttons, m.msec); + break; + + case KeyRelease: + case KeyPress: + ke = (XKeyEvent*)xev; + XLookupString(ke, NULL, 0, &k, NULL); + c = ke->state; + switch(k) { + case XK_Alt_L: + case XK_Meta_L: /* Shift Alt on PCs */ + case XK_Alt_R: + case XK_Meta_R: /* Shift Alt on PCs */ + case XK_Multi_key: + if(xev->type == KeyPress) + _x.altdown = 1; + else if(_x.altdown) { + _x.altdown = 0; + gfx_keystroke(w->client, Kalt); + } + break; + } + + switch(k) { + case XK_Control_L: + if(xev->type == KeyPress) + c |= ControlMask; + else + c &= ~ControlMask; + goto kbutton; + case XK_Alt_L: + case XK_Shift_L: + if(xev->type == KeyPress) + c |= Mod1Mask; + else + c &= ~Mod1Mask; + kbutton: + _x.kstate = c; + if(m.buttons || _x.kbuttons) { + _x.altdown = 0; // used alt + _x.kbuttons = 0; + if(c & ControlMask) + _x.kbuttons |= 2; + if(c & Mod1Mask) + _x.kbuttons |= 4; + gfx_mousetrack(w->client, m.xy.x, m.xy.y, m.buttons|_x.kbuttons, m.msec); + break; + } + } + + if(xev->type != KeyPress) + break; + if(k == XK_F11){ + w->fullscreen = !w->fullscreen; + _xmovewindow(w, w->fullscreen ? w->screenrect : w->windowrect); + return; + } + if((c = _xtoplan9kbd(xev)) < 0) + return; + gfx_keystroke(w->client, c); + break; + + case FocusOut: + /* + * Some key combinations (e.g. Alt-Tab) can cause us + * to see the key down event without the key up event, + * so clear out the keyboard state when we lose the focus. + */ + _x.kstate = 0; + _x.altdown = 0; + gfx_abortcompose(w->client); + break; + + case SelectionRequest: + _xselect(xev); + break; + } +} + + +static Memimage* +xattach(Client *client, char *label, char *winsize) +{ + char *argv[2]; + int havemin, height, mask, width, x, y; + Rectangle r; + XClassHint classhint; + XDrawable pmid; + XScreen *xscreen; + XSetWindowAttributes attr; + XSizeHints normalhint; + XTextProperty name; + XWindow xrootwin; + XWindowAttributes wattr; + XWMHints hint; + Atom atoms[2]; + Xwin *w; + + USED(client); + xscreen = DefaultScreenOfDisplay(_x.display); + xrootwin = DefaultRootWindow(_x.display); + + /* + * We get to choose the initial rectangle size. + * This is arbitrary. In theory we should read the + * command line and allow the traditional X options. + */ + mask = 0; + x = 0; + y = 0; + if(winsize && winsize[0]){ + if(parsewinsize(winsize, &r, &havemin) < 0) + sysfatal("%r"); + }else{ + /* + * Parse the various X resources. Thanks to Peter Canning. + */ + char *screen_resources, *display_resources, *geom, + *geomrestype, *home, *file, *dpitype; + XrmDatabase database; + XrmValue geomres, dpires; + + database = XrmGetDatabase(_x.display); + screen_resources = XScreenResourceString(xscreen); + if(screen_resources != nil){ + XrmCombineDatabase(XrmGetStringDatabase(screen_resources), &database, False); + XFree(screen_resources); + } + + display_resources = XResourceManagerString(_x.display); + if(display_resources == nil){ + home = getenv("HOME"); + if(home!=nil && (file=smprint("%s/.Xdefaults", home)) != nil){ + XrmCombineFileDatabase(file, &database, False); + free(file); + } + free(home); + }else + XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False); + + if (XrmGetResource(database, "Xft.dpi", "String", &dpitype, &dpires) == True) { + if (dpires.addr) { + client->displaydpi = atoi(dpires.addr); + } + } + geom = smprint("%s.geometry", label); + if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres)) + mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height); + XrmDestroyDatabase(database); + free(geom); + + if((mask & WidthValue) && (mask & HeightValue)){ + r = Rect(0, 0, width, height); + }else{ + r = Rect(0, 0, WidthOfScreen(xscreen)*3/4, + HeightOfScreen(xscreen)*3/4); + if(Dx(r) > Dy(r)*3/2) + r.max.x = r.min.x + Dy(r)*3/2; + if(Dy(r) > Dx(r)*3/2) + r.max.y = r.min.y + Dx(r)*3/2; + } + if(mask & XNegative){ + x += WidthOfScreen(xscreen); + } + if(mask & YNegative){ + y += HeightOfScreen(xscreen); + } + havemin = 0; + } + w = newxwin(client); + w->screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); + w->windowrect = r; + + memset(&attr, 0, sizeof attr); + attr.colormap = _x.cmap; + attr.background_pixel = ~0; + attr.border_pixel = 0; + w->drawable = XCreateWindow( + _x.display, /* display */ + xrootwin, /* parent */ + x, /* x */ + y, /* y */ + Dx(r), /* width */ + Dy(r), /* height */ + 0, /* border width */ + _x.depth, /* depth */ + InputOutput, /* class */ + _x.vis, /* visual */ + /* valuemask */ + CWBackPixel|CWBorderPixel|CWColormap, + &attr /* attributes (the above aren't?!) */ + ); + + /* + * Label and other properties required by ICCCCM. + */ + memset(&name, 0, sizeof name); + if(label == nil) + label = "pjw-face-here"; + name.value = (uchar*)label; + name.encoding = XA_STRING; + name.format = 8; + name.nitems = strlen((char*)name.value); + + memset(&normalhint, 0, sizeof normalhint); + normalhint.flags = PSize|PMaxSize; + if(winsize && winsize[0]){ + normalhint.flags &= ~PSize; + normalhint.flags |= USSize; + normalhint.width = Dx(r); + normalhint.height = Dy(r); + }else{ + if((mask & WidthValue) && (mask & HeightValue)){ + normalhint.flags &= ~PSize; + normalhint.flags |= USSize; + normalhint.width = width; + normalhint.height = height; + } + if((mask & WidthValue) && (mask & HeightValue)){ + normalhint.flags |= USPosition; + normalhint.x = x; + normalhint.y = y; + } + } + + normalhint.max_width = WidthOfScreen(xscreen); + normalhint.max_height = HeightOfScreen(xscreen); + + memset(&hint, 0, sizeof hint); + hint.flags = InputHint|StateHint; + hint.input = 1; + hint.initial_state = NormalState; + + memset(&classhint, 0, sizeof classhint); + classhint.res_name = label; + classhint.res_class = label; + + argv[0] = label; + argv[1] = nil; + + XSetWMProperties( + _x.display, /* display */ + w->drawable, /* window */ + &name, /* XA_WM_NAME property */ + &name, /* XA_WM_ICON_NAME property */ + argv, /* XA_WM_COMMAND */ + 1, /* argc */ + &normalhint, /* XA_WM_NORMAL_HINTS */ + &hint, /* XA_WM_HINTS */ + &classhint /* XA_WM_CLASSHINTS */ + ); + XFlush(_x.display); + + if(havemin){ + XWindowChanges ch; + + memset(&ch, 0, sizeof ch); + ch.x = r.min.x; + ch.y = r.min.y; + XConfigureWindow(_x.display, w->drawable, CWX|CWY, &ch); + /* + * Must pretend origin is 0,0 for X. + */ + r = Rect(0,0,Dx(r),Dy(r)); + } + /* + * Look up clipboard atom. + */ + if(_x.clipboard == 0) { + _x.clipboard = XInternAtom(_x.display, "CLIPBOARD", False); + _x.utf8string = XInternAtom(_x.display, "UTF8_STRING", False); + _x.targets = XInternAtom(_x.display, "TARGETS", False); + _x.text = XInternAtom(_x.display, "TEXT", False); + _x.compoundtext = XInternAtom(_x.display, "COMPOUND_TEXT", False); + _x.takefocus = XInternAtom(_x.display, "WM_TAKE_FOCUS", False); + _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False); + _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False); + } + + atoms[0] = _x.takefocus; + atoms[1] = _x.losefocus; + XChangeProperty(_x.display, w->drawable, _x.wmprotos, XA_ATOM, 32, + PropModeReplace, (uchar*)atoms, 2); + + /* + * Put the window on the screen, check to see what size we actually got. + */ + XMapWindow(_x.display, w->drawable); + XSync(_x.display, False); + + if(!XGetWindowAttributes(_x.display, w->drawable, &wattr)) + fprint(2, "XGetWindowAttributes failed\n"); + else if(wattr.width && wattr.height){ + if(wattr.width != Dx(r) || wattr.height != Dy(r)){ + r.max.x = wattr.width; + r.max.y = wattr.height; + } + }else + fprint(2, "XGetWindowAttributes: bad attrs\n"); + + /* + * Allocate our local backing store. + */ + w->screenr = r; + w->screenpm = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth); + w->nextscreenpm = w->screenpm; + w->screenimage = _xallocmemimage(r, _x.chan, w->screenpm); + client->mouserect = r; + + /* + * Allocate some useful graphics contexts for the future. + * These can be used with any drawable matching w->drawable's + * pixel format (which is all the drawables we create). + */ + if(_x.gcfill == 0) { + _x.gcfill = xgc(w->screenpm, FillSolid, -1); + _x.gccopy = xgc(w->screenpm, -1, -1); + _x.gcsimplesrc = xgc(w->screenpm, FillStippled, -1); + _x.gczero = xgc(w->screenpm, -1, -1); + _x.gcreplsrc = xgc(w->screenpm, FillTiled, -1); + + pmid = XCreatePixmap(_x.display, w->drawable, 1, 1, 1); + _x.gcfill0 = xgc(pmid, FillSolid, 0); + _x.gccopy0 = xgc(pmid, -1, -1); + _x.gcsimplesrc0 = xgc(pmid, FillStippled, -1); + _x.gczero0 = xgc(pmid, -1, -1); + _x.gcreplsrc0 = xgc(pmid, FillTiled, -1); + XFreePixmap(_x.display, pmid); + } + + return w->screenimage; +} + +Memimage* +rpc_attach(Client *client, char *label, char *winsize) +{ + Memimage *m; + + xlock(); + m = xattach(client, label, winsize); + xunlock(); + return m; +} + +void +rpc_setlabel(Client *client, char *label) +{ + Xwin *w = (Xwin*)client->view; + XTextProperty name; + + /* + * Label and other properties required by ICCCCM. + */ + xlock(); + memset(&name, 0, sizeof name); + if(label == nil) + label = "pjw-face-here"; + name.value = (uchar*)label; + name.encoding = XA_STRING; + name.format = 8; + name.nitems = strlen((char*)name.value); + + XSetWMProperties( + _x.display, /* display */ + w->drawable, /* window */ + &name, /* XA_WM_NAME property */ + &name, /* XA_WM_ICON_NAME property */ + nil, /* XA_WM_COMMAND */ + 0, /* argc */ + nil, /* XA_WM_NORMAL_HINTS */ + nil, /* XA_WM_HINTS */ + nil /* XA_WM_CLASSHINTS */ + ); + XFlush(_x.display); + xunlock(); +} + +/* + * Create a GC with a particular fill style and XXX. + * Disable generation of GraphicsExpose/NoExpose events in the GC. + */ +static XGC +xgc(XDrawable d, int fillstyle, int foreground) +{ + XGC gc; + XGCValues v; + + memset(&v, 0, sizeof v); + v.function = GXcopy; + v.graphics_exposures = False; + gc = XCreateGC(_x.display, d, GCFunction|GCGraphicsExposures, &v); + if(fillstyle != -1) + XSetFillStyle(_x.display, gc, fillstyle); + if(foreground != -1) + XSetForeground(_x.display, gc, 0); + return gc; +} + + +/* + * Initialize map with the Plan 9 rgbv color map. + */ +static void +plan9cmap(void) +{ + int r, g, b, cr, cg, cb, v, num, den, idx, v7, idx7; + static int once; + + if(once) + return; + once = 1; + + for(r=0; r!=4; r++) + for(g = 0; g != 4; g++) + for(b = 0; b!=4; b++) + for(v = 0; v!=4; v++){ + den=r; + if(g > den) + den=g; + if(b > den) + den=b; + /* divide check -- pick grey shades */ + if(den==0) + cr=cg=cb=v*17; + else { + num=17*(4*den+v); + cr=r*num/den; + cg=g*num/den; + cb=b*num/den; + } + idx = r*64 + v*16 + ((g*4 + b + v - r) & 15); + _x.map[idx].red = cr*0x0101; + _x.map[idx].green = cg*0x0101; + _x.map[idx].blue = cb*0x0101; + _x.map[idx].pixel = idx; + _x.map[idx].flags = DoRed|DoGreen|DoBlue; + + v7 = v >> 1; + idx7 = r*32 + v7*16 + g*4 + b; + if((v & 1) == v7){ + _x.map7to8[idx7][0] = idx; + if(den == 0) { /* divide check -- pick grey shades */ + cr = ((255.0/7.0)*v7)+0.5; + cg = cr; + cb = cr; + } + else { + num=17*15*(4*den+v7*2)/14; + cr=r*num/den; + cg=g*num/den; + cb=b*num/den; + } + _x.map7[idx7].red = cr*0x0101; + _x.map7[idx7].green = cg*0x0101; + _x.map7[idx7].blue = cb*0x0101; + _x.map7[idx7].pixel = idx7; + _x.map7[idx7].flags = DoRed|DoGreen|DoBlue; + } + else + _x.map7to8[idx7][1] = idx; + } +} + +/* + * Initialize and install the rgbv color map as a private color map + * for this application. It gets the best colors when it has the + * cursor focus. + * + * We always choose the best depth possible, but that might not + * be the default depth. On such "suboptimal" systems, we have to allocate an + * empty color map anyway, according to Axel Belinfante. + */ +static int +setupcmap(XWindow w) +{ + char buf[30]; + int i; + u32int p, pp; + XColor c; + + if(_x.depth <= 1) + return 0; + + if(_x.depth >= 24) { + if(_x.usetable == 0) + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); + + /* + * The pixel value returned from XGetPixel needs to + * be converted to RGB so we can call rgb2cmap() + * to translate between 24 bit X and our color. Unfortunately, + * the return value appears to be display server endian + * dependant. Therefore, we run some heuristics to later + * determine how to mask the int value correctly. + * Yeah, I know we can look at _x.vis->byte_order but + * some displays say MSB even though they run on LSB. + * Besides, this is more anal. + */ + c = _x.map[19]; /* known to have different R, G, B values */ + if(!XAllocColor(_x.display, _x.cmap, &c)){ + werrstr("XAllocColor: %r"); + return -1; + } + p = c.pixel; + pp = rgb2cmap((p>>16)&0xff,(p>>8)&0xff,p&0xff); + if(pp != _x.map[19].pixel) { + /* check if endian is other way */ + pp = rgb2cmap(p&0xff,(p>>8)&0xff,(p>>16)&0xff); + if(pp != _x.map[19].pixel){ + werrstr("cannot detect X server byte order"); + return -1; + } + + switch(_x.chan){ + case RGB24: + _x.chan = BGR24; + break; + case XRGB32: + _x.chan = XBGR32; + break; + default: + werrstr("cannot byteswap channel %s", + chantostr(buf, _x.chan)); + break; + } + } + }else if(_x.vis->class == TrueColor || _x.vis->class == DirectColor){ + /* + * Do nothing. We have no way to express a + * mixed-endian 16-bit screen, so pretend they don't exist. + */ + if(_x.usetable == 0) + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocNone); + }else if(_x.vis->class == PseudoColor){ + if(_x.usetable == 0){ + _x.cmap = XCreateColormap(_x.display, w, _x.vis, AllocAll); + XStoreColors(_x.display, _x.cmap, _x.map, 256); + for(i = 0; i < 256; i++){ + _x.tox11[i] = i; + _x.toplan9[i] = i; + } + }else{ + for(i = 0; i < 128; i++){ + c = _x.map7[i]; + if(!XAllocColor(_x.display, _x.cmap, &c)){ + werrstr("can't allocate colors in 7-bit map"); + return -1; + } + _x.tox11[_x.map7to8[i][0]] = c.pixel; + _x.tox11[_x.map7to8[i][1]] = c.pixel; + _x.toplan9[c.pixel] = _x.map7to8[i][0]; + } + } + }else{ + werrstr("unsupported visual class %d", _x.vis->class); + return -1; + } + return 0; +} + +void +rpc_shutdown(void) +{ +} + +void +rpc_flush(Client *client, Rectangle r) +{ + Xwin *w = (Xwin*)client->view; + + xlock(); + if(w->nextscreenpm != w->screenpm){ + XSync(_x.display, False); + XFreePixmap(_x.display, w->screenpm); + w->screenpm = w->nextscreenpm; + } + + if(r.min.x >= r.max.x || r.min.y >= r.max.y) { + xunlock(); + return; + } + + XCopyArea(_x.display, w->screenpm, w->drawable, _x.gccopy, r.min.x, r.min.y, + Dx(r), Dy(r), r.min.x, r.min.y); + XFlush(_x.display); + xunlock(); +} + +static void +_xexpose(Xwin *w, XEvent *e) +{ + XExposeEvent *xe; + Rectangle r; + + if(w->screenpm != w->nextscreenpm) + return; + xe = (XExposeEvent*)e; + r.min.x = xe->x; + r.min.y = xe->y; + r.max.x = xe->x+xe->width; + r.max.y = xe->y+xe->height; + XCopyArea(_x.display, w->screenpm, w->drawable, _x.gccopy, r.min.x, r.min.y, + Dx(r), Dy(r), r.min.x, r.min.y); + XSync(_x.display, False); +} + +static int +_xdestroy(Xwin *w, XEvent *e) +{ + XDestroyWindowEvent *xe; + + xe = (XDestroyWindowEvent*)e; + if(xe->window == w->drawable){ + w->destroyed = 1; + return 1; + } + return 0; +} + +static int +_xconfigure(Xwin *w, XEvent *e) +{ + Rectangle r; + XConfigureEvent *xe = (XConfigureEvent*)e; + + if(!w->fullscreen){ + int rx, ry; + XWindow xw; + if(XTranslateCoordinates(_x.display, w->drawable, DefaultRootWindow(_x.display), 0, 0, &rx, &ry, &xw)) + w->windowrect = Rect(rx, ry, rx+xe->width, ry+xe->height); + } + + if(xe->width == Dx(w->screenr) && xe->height == Dy(w->screenr)) + return 0; + r = Rect(0, 0, xe->width, xe->height); + + if(w->screenpm != w->nextscreenpm){ + XCopyArea(_x.display, w->screenpm, w->drawable, _x.gccopy, r.min.x, r.min.y, + Dx(r), Dy(r), r.min.x, r.min.y); + XSync(_x.display, False); + } + w->newscreenr = r; + return 1; +} + +static int +_xreplacescreenimage(Client *client) +{ + Memimage *m; + XDrawable pixmap; + Rectangle r; + Xwin *w; + + w = (Xwin*)client->view; + r = w->newscreenr; + pixmap = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth); + m = _xallocmemimage(r, _x.chan, pixmap); + if(w->nextscreenpm != w->screenpm) + XFreePixmap(_x.display, w->nextscreenpm); + w->nextscreenpm = pixmap; + w->screenr = r; + client->mouserect = r; + gfx_replacescreenimage(client, m); + return 1; +} + +void +rpc_resizeimg(Client *client) +{ + xlock(); + _xreplacescreenimage(client); + xunlock(); +} + +void +rpc_gfxdrawlock(void) +{ + xlock(); +} + +void +rpc_gfxdrawunlock(void) +{ + xunlock(); +} +void +rpc_topwin(Client *client) +{ + Xwin *w = (Xwin*)client->view; + + xlock(); + XMapRaised(_x.display, w->drawable); + XSetInputFocus(_x.display, w->drawable, RevertToPointerRoot, + CurrentTime); + XFlush(_x.display); + xunlock(); +} + +void +rpc_resizewindow(Client *client, Rectangle r) +{ + Xwin *w = (Xwin*)client->view; + XWindowChanges e; + int value_mask; + + xlock(); + memset(&e, 0, sizeof e); + value_mask = CWX|CWY|CWWidth|CWHeight; + e.width = Dx(r); + e.height = Dy(r); + XConfigureWindow(_x.display, w->drawable, value_mask, &e); + XFlush(_x.display); + xunlock(); +} + +static void +_xmovewindow(Xwin *w, Rectangle r) +{ + XWindowChanges e; + int value_mask; + + memset(&e, 0, sizeof e); + value_mask = CWX|CWY|CWWidth|CWHeight; + e.x = r.min.x; + e.y = r.min.y; + e.width = Dx(r); + e.height = Dy(r); + XConfigureWindow(_x.display, w->drawable, value_mask, &e); + XFlush(_x.display); +} + +static int +_xtoplan9kbd(XEvent *e) +{ + KeySym k; + + if(e->xany.type != KeyPress) + return -1; + needstack(64*1024); /* X has some *huge* buffers in openobject */ + /* and they're even bigger on SuSE */ + XLookupString((XKeyEvent*)e,NULL,0,&k,NULL); + if(k == NoSymbol) + return -1; + + if(k&0xFF00){ + switch(k){ + case XK_BackSpace: + case XK_Tab: + case XK_Escape: + case XK_Delete: + case XK_KP_0: + case XK_KP_1: + case XK_KP_2: + case XK_KP_3: + case XK_KP_4: + case XK_KP_5: + case XK_KP_6: + case XK_KP_7: + case XK_KP_8: + case XK_KP_9: + case XK_KP_Divide: + case XK_KP_Multiply: + case XK_KP_Subtract: + case XK_KP_Add: + case XK_KP_Decimal: + k &= 0x7F; + break; + case XK_Linefeed: + k = '\r'; + break; + case XK_KP_Space: + k = ' '; + break; + case XK_Home: + case XK_KP_Home: + k = Khome; + break; + case XK_Left: + case XK_KP_Left: + k = Kleft; + break; + case XK_Up: + case XK_KP_Up: + k = Kup; + break; + case XK_Down: + case XK_KP_Down: + k = Kdown; + break; + case XK_Right: + case XK_KP_Right: + k = Kright; + break; + case XK_Page_Down: + case XK_KP_Page_Down: + k = Kpgdown; + break; + case XK_End: + case XK_KP_End: + k = Kend; + break; + case XK_Page_Up: + case XK_KP_Page_Up: + k = Kpgup; + break; + case XK_Insert: + case XK_KP_Insert: + k = Kins; + break; + case XK_KP_Enter: + case XK_Return: + k = '\n'; + break; + case XK_Alt_L: + case XK_Meta_L: /* Shift Alt on PCs */ + case XK_Alt_R: + case XK_Meta_R: /* Shift Alt on PCs */ + case XK_Multi_key: + return -1; + default: /* not ISO-1 or tty control */ + if(k>0xff) { + k = _p9keysym2ucs(k); + if(k==-1) return -1; + } + } + } + + /* Compensate for servers that call a minus a hyphen */ + if(k == XK_hyphen) + k = XK_minus; + /* Do control mapping ourselves if translator doesn't */ + if(e->xkey.state&ControlMask) + k &= 0x9f; + if(k == NoSymbol) { + return -1; + } + + return k+0; +} + +static int +_xtoplan9mouse(Xwin *w, XEvent *e, Mouse *m) +{ + int s; + XButtonEvent *be; + XMotionEvent *me; + + if(_x.putsnarf != _x.assertsnarf){ + _x.assertsnarf = _x.putsnarf; + XSetSelectionOwner(_x.display, XA_PRIMARY, w->drawable, CurrentTime); + if(_x.clipboard != None) + XSetSelectionOwner(_x.display, _x.clipboard, w->drawable, CurrentTime); + XFlush(_x.display); + } + + switch(e->type){ + case ButtonPress: + be = (XButtonEvent*)e; + + /* + * Fake message, just sent to make us announce snarf. + * Apparently state and button are 16 and 8 bits on + * the wire, since they are truncated by the time they + * get to us. + */ + if(be->send_event + && (~be->state&0xFFFF)==0 + && (~be->button&0xFF)==0) + return -1; + /* BUG? on mac need to inherit these from elsewhere? */ + m->xy.x = be->x; + m->xy.y = be->y; + s = be->state; + m->msec = be->time; + switch(be->button){ + case 1: + s |= Button1Mask; + break; + case 2: + s |= Button2Mask; + break; + case 3: + s |= Button3Mask; + break; + case 4: + s |= Button4Mask; + break; + case 5: + s |= Button5Mask; + break; + } + break; + case ButtonRelease: + be = (XButtonEvent*)e; + m->xy.x = be->x; + m->xy.y = be->y; + s = be->state; + m->msec = be->time; + switch(be->button){ + case 1: + s &= ~Button1Mask; + break; + case 2: + s &= ~Button2Mask; + break; + case 3: + s &= ~Button3Mask; + break; + case 4: + s &= ~Button4Mask; + break; + case 5: + s &= ~Button5Mask; + break; + } + break; + + case MotionNotify: + me = (XMotionEvent*)e; + s = me->state; + m->xy.x = me->x; + m->xy.y = me->y; + m->msec = me->time; + return 0; // do not set buttons + + default: + return -1; + } + + m->buttons = 0; + if(s & Button1Mask) + m->buttons |= 1; + if(s & Button2Mask) + m->buttons |= 2; + if(s & Button3Mask) + m->buttons |= 4; + if(s & Button4Mask) + m->buttons |= 8; + if(s & Button5Mask) + m->buttons |= 16; + return 0; +} + +void +rpc_setmouse(Client *client, Point p) +{ + Xwin *w = (Xwin*)client->view; + + xlock(); + XWarpPointer(_x.display, None, w->drawable, 0, 0, 0, 0, p.x, p.y); + XFlush(_x.display); + xunlock(); +} + +static int +revbyte(int b) +{ + int r; + + r = 0; + r |= (b&0x01) << 7; + r |= (b&0x02) << 5; + r |= (b&0x04) << 3; + r |= (b&0x08) << 1; + r |= (b&0x10) >> 1; + r |= (b&0x20) >> 3; + r |= (b&0x40) >> 5; + r |= (b&0x80) >> 7; + return r; +} + +static void +xcursorarrow(Xwin *w) +{ + if(_x.cursor != 0){ + XFreeCursor(_x.display, _x.cursor); + _x.cursor = 0; + } + XUndefineCursor(_x.display, w->drawable); + XFlush(_x.display); +} + + +void +rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) +{ + Xwin *w = (Xwin*)client->view; + XColor fg, bg; + XCursor xc; + Pixmap xsrc, xmask; + int i; + uchar src[2*16], mask[2*16]; + + USED(c2); + + xlock(); + if(c == nil){ + xcursorarrow(w); + xunlock(); + return; + } + for(i=0; i<2*16; i++){ + src[i] = revbyte(c->set[i]); + mask[i] = revbyte(c->set[i] | c->clr[i]); + } + + fg = _x.map[0]; + bg = _x.map[255]; + xsrc = XCreateBitmapFromData(_x.display, w->drawable, (char*)src, 16, 16); + xmask = XCreateBitmapFromData(_x.display, w->drawable, (char*)mask, 16, 16); + xc = XCreatePixmapCursor(_x.display, xsrc, xmask, &fg, &bg, -c->offset.x, -c->offset.y); + if(xc != 0) { + XDefineCursor(_x.display, w->drawable, xc); + if(_x.cursor != 0) + XFreeCursor(_x.display, _x.cursor); + _x.cursor = xc; + } + XFreePixmap(_x.display, xsrc); + XFreePixmap(_x.display, xmask); + XFlush(_x.display); + xunlock(); +} + +struct { + QLock lk; + char buf[SnarfSize]; +#ifdef APPLESNARF + Rune rbuf[SnarfSize]; + PasteboardRef apple; +#endif +} clip; + +static uchar* +_xgetsnarffrom(Xwin *w, XWindow xw, Atom clipboard, Atom target, int timeout0, int timeout) +{ + Atom prop, type; + ulong len, lastlen, dummy; + int fmt, i; + uchar *data, *xdata; + + /* + * We should be waiting for SelectionNotify here, but it might never + * come, and we have no way to time out. Instead, we will clear + * local property #1, request our buddy to fill it in for us, and poll + * until he's done or we get tired of waiting. + */ + prop = 1; + XChangeProperty(_x.display, w->drawable, prop, target, 8, PropModeReplace, (uchar*)"", 0); + XConvertSelection(_x.display, clipboard, target, prop, w->drawable, CurrentTime); + XFlush(_x.display); + lastlen = 0; + timeout0 = (timeout0 + 9)/10; + timeout = (timeout + 9)/10; + for(i=0; idrawable, prop, 0, 0, 0, AnyPropertyType, + &type, &fmt, &dummy, &len, &xdata); + if(lastlen == len && len > 0){ + XFree(xdata); + break; + } + lastlen = len; + XFree(xdata); + } + if(len == 0) + return nil; + + /* get the property */ + xdata = nil; + XGetWindowProperty(_x.display, w->drawable, prop, 0, SnarfSize/sizeof(ulong), 0, + AnyPropertyType, &type, &fmt, &len, &dummy, &xdata); + if((type != target && type != XA_STRING && type != _x.utf8string) || len == 0){ + if(xdata) + XFree(xdata); + return nil; + } + if(xdata){ + data = (uchar*)strdup((char*)xdata); + XFree(xdata); + return data; + } + return nil; +} + +char* +rpc_getsnarf(void) +{ + uchar *data; + Atom clipboard; + XWindow xw; + Xwin *w; + + qlock(&clip.lk); + xlock(); + w = _x.windows; + /* + * Have we snarfed recently and the X server hasn't caught up? + */ + if(_x.putsnarf != _x.assertsnarf) + goto mine; + + /* + * Is there a primary selection (highlighted text in an xterm)? + */ + clipboard = XA_PRIMARY; + xw = XGetSelectionOwner(_x.display, XA_PRIMARY); + // TODO check more + if(xw == w->drawable){ + mine: + data = (uchar*)strdup(clip.buf); + goto out; + } + + /* + * If not, is there a clipboard selection? + */ + if(xw == None && _x.clipboard != None){ + clipboard = _x.clipboard; + xw = XGetSelectionOwner(_x.display, _x.clipboard); + if(xw == w->drawable) + goto mine; + } + + /* + * If not, give up. + */ + if(xw == None){ + data = nil; + goto out; + } + + if((data = _xgetsnarffrom(w, xw, clipboard, _x.utf8string, 10, 100)) == nil) + if((data = _xgetsnarffrom(w, xw, clipboard, XA_STRING, 10, 100)) == nil){ + /* nothing left to do */ + } + +out: + xunlock(); + qunlock(&clip.lk); + return (char*)data; +} + +void +__xputsnarf(char *data) +{ + XButtonEvent e; + Xwin *w; + + if(strlen(data) >= SnarfSize) + return; + qlock(&clip.lk); + xlock(); + w = _x.windows; + strcpy(clip.buf, data); + /* leave note for mouse proc to assert selection ownership */ + _x.putsnarf++; + + /* send mouse a fake event so snarf is announced */ + memset(&e, 0, sizeof e); + e.type = ButtonPress; + e.window = w->drawable; + e.state = ~0; + e.button = ~0; + XSendEvent(_x.display, w->drawable, True, ButtonPressMask, (XEvent*)&e); + XFlush(_x.display); + xunlock(); + qunlock(&clip.lk); +} + +static int +_xselect(XEvent *e) +{ + char *name; + XEvent r; + XSelectionRequestEvent *xe; + Atom a[4]; + + memset(&r, 0, sizeof r); + xe = (XSelectionRequestEvent*)e; +if(0) fprint(2, "xselect target=%d requestor=%d property=%d selection=%d (sizeof atom=%d)\n", + xe->target, xe->requestor, xe->property, xe->selection, sizeof a[0]); + r.xselection.property = xe->property; + if(xe->target == _x.targets){ + a[0] = _x.utf8string; + a[1] = XA_STRING; + a[2] = _x.text; + a[3] = _x.compoundtext; + XChangeProperty(_x.display, xe->requestor, xe->property, XA_ATOM, + 32, PropModeReplace, (uchar*)a, nelem(a)); + }else if(xe->target == XA_STRING + || xe->target == _x.utf8string + || xe->target == _x.text + || xe->target == _x.compoundtext + || ((name = XGetAtomName(_x.display, xe->target)) && strcmp(name, "text/plain;charset=UTF-8") == 0)){ + /* text/plain;charset=UTF-8 seems nonstandard but is used by Synergy */ + /* if the target is STRING we're supposed to reply with Latin1 XXX */ + qlock(&clip.lk); + XChangeProperty(_x.display, xe->requestor, xe->property, xe->target, + 8, PropModeReplace, (uchar*)clip.buf, strlen(clip.buf)); + qunlock(&clip.lk); + }else{ + if(strcmp(name, "TIMESTAMP") != 0) + fprint(2, "%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target); + r.xselection.property = None; + } + + r.xselection.display = xe->display; + /* r.xselection.property filled above */ + r.xselection.target = xe->target; + r.xselection.type = SelectionNotify; + r.xselection.requestor = xe->requestor; + r.xselection.time = xe->time; + r.xselection.send_event = True; + r.xselection.selection = xe->selection; + XSendEvent(_x.display, xe->requestor, False, 0, &r); + XFlush(_x.display); + return 0; +} + +#ifdef APPLESNARF +char* +_applegetsnarf(void) +{ + char *s, *t; + CFArrayRef flavors; + CFDataRef data; + CFIndex nflavor, ndata, j; + CFStringRef type; + ItemCount nitem; + PasteboardItemID id; + PasteboardSyncFlags flags; + UInt32 i; + +/* fprint(2, "applegetsnarf\n"); */ + qlock(&clip.lk); + if(clip.apple == nil){ + if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){ + fprint(2, "apple pasteboard create failed\n"); + qunlock(&clip.lk); + return nil; + } + } + flags = PasteboardSynchronize(clip.apple); + if(flags&kPasteboardClientIsOwner){ + s = strdup(clip.buf); + qunlock(&clip.lk); + return s; + } + if(PasteboardGetItemCount(clip.apple, &nitem) != noErr){ + fprint(2, "apple pasteboard get item count failed\n"); + qunlock(&clip.lk); + return nil; + } + for(i=1; i<=nitem; i++){ + if(PasteboardGetItemIdentifier(clip.apple, i, &id) != noErr) + continue; + if(PasteboardCopyItemFlavors(clip.apple, id, &flavors) != noErr) + continue; + nflavor = CFArrayGetCount(flavors); + for(j=0; j= SnarfSize) + return; + qlock(&clip.lk); + strcpy(clip.buf, s); + runesnprint(clip.rbuf, nelem(clip.rbuf), "%s", s); + if(clip.apple == nil){ + if(PasteboardCreate(kPasteboardClipboard, &clip.apple) != noErr){ + fprint(2, "apple pasteboard create failed\n"); + qunlock(&clip.lk); + return; + } + } + if(PasteboardClear(clip.apple) != noErr){ + fprint(2, "apple pasteboard clear failed\n"); + qunlock(&clip.lk); + return; + } + flags = PasteboardSynchronize(clip.apple); + if((flags&kPasteboardModified) || !(flags&kPasteboardClientIsOwner)){ + fprint(2, "apple pasteboard cannot assert ownership\n"); + qunlock(&clip.lk); + return; + } + cfdata = CFDataCreate(kCFAllocatorDefault, + (uchar*)clip.rbuf, runestrlen(clip.rbuf)*2); + if(cfdata == nil){ + fprint(2, "apple pasteboard cfdatacreate failed\n"); + qunlock(&clip.lk); + return; + } + if(PasteboardPutItemFlavor(clip.apple, (PasteboardItemID)1, + CFSTR("public.utf16-plain-text"), cfdata, 0) != noErr){ + fprint(2, "apple pasteboard putitem failed\n"); + CFRelease(cfdata); + qunlock(&clip.lk); + return; + } + /* CFRelease(cfdata); ??? */ + qunlock(&clip.lk); +} +#endif /* APPLESNARF */ + +void +rpc_putsnarf(char *data) +{ +#ifdef APPLESNARF + _appleputsnarf(data); +#endif + __xputsnarf(data); +} + +/* + * Send the mouse event back to the window manager. + * So that 9term can tell rio to pop up its button3 menu. + */ +void +rpc_bouncemouse(Client *c, Mouse m) +{ + Xwin *w = (Xwin*)c->view; + XButtonEvent e; + XWindow dw; + + xlock(); + e.type = ButtonPress; + e.state = 0; + e.button = 0; + if(m.buttons&1) + e.button = 1; + else if(m.buttons&2) + e.button = 2; + else if(m.buttons&4) + e.button = 3; + e.same_screen = 1; + XTranslateCoordinates(_x.display, w->drawable, + DefaultRootWindow(_x.display), + m.xy.x, m.xy.y, &e.x_root, &e.y_root, &dw); + e.root = DefaultRootWindow(_x.display); + e.window = e.root; + e.subwindow = None; + e.x = e.x_root; + e.y = e.y_root; +#undef time + e.time = CurrentTime; + XUngrabPointer(_x.display, m.msec); + XSendEvent(_x.display, e.root, True, ButtonPressMask, (XEvent*)&e); + XFlush(_x.display); + xunlock(); +} diff --git a/src/cmd/devdraw/x11-srv.c b/src/cmd/devdraw/x11-srv.c deleted file mode 100644 index cfede6f59..000000000 --- a/src/cmd/devdraw/x11-srv.c +++ /dev/null @@ -1,637 +0,0 @@ -/* - * Window system protocol server. - * Use select and a single proc and single stack - * to avoid aggravating the X11 library, which is - * subtle and quick to anger. - */ - -// #define SHOWEVENT - -#include -#include -#include -#ifdef SHOWEVENT -#include -#endif -#include "x11-inc.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "x11-memdraw.h" -#include "devdraw.h" - -#undef time - -#define MouseMask (\ - ButtonPressMask|\ - ButtonReleaseMask|\ - PointerMotionMask|\ - Button1MotionMask|\ - Button2MotionMask|\ - Button3MotionMask) - -#define Mask MouseMask|ExposureMask|StructureNotifyMask|KeyPressMask|KeyReleaseMask|EnterWindowMask|LeaveWindowMask|FocusChangeMask - -typedef struct Kbdbuf Kbdbuf; -typedef struct Mousebuf Mousebuf; -typedef struct Fdbuf Fdbuf; -typedef struct Tagbuf Tagbuf; - -struct Kbdbuf -{ - Rune r[32]; - int ri; - int wi; - int stall; -}; - -struct Mousebuf -{ - Mouse m[32]; - int ri; - int wi; - int stall; - int resized; -}; - -struct Tagbuf -{ - int t[32]; - int ri; - int wi; -}; - -struct Fdbuf -{ - uchar buf[2*MAXWMSG]; - uchar *rp; - uchar *wp; - uchar *ep; -}; - -Kbdbuf kbd; -Mousebuf mouse; -Fdbuf fdin; -Fdbuf fdout; -Tagbuf kbdtags; -Tagbuf mousetags; - -void fdslide(Fdbuf*); -void runmsg(Wsysmsg*); -void replymsg(Wsysmsg*); -void runxevent(XEvent*); -void matchkbd(void); -void matchmouse(void); -int fdnoblock(int); - -int chatty; -int drawsleep; -int fullscreen; - -Rectangle windowrect; -Rectangle screenrect; - -void -usage(void) -{ - fprint(2, "usage: devdraw (don't run directly)\n"); - exits("usage"); -} - -void -bell(void *v, char *msg) -{ - if(strcmp(msg, "alarm") == 0) - drawsleep = drawsleep ? 0 : 1000; - noted(NCONT); -} - -void -main(int argc, char **argv) -{ - int n, top, firstx; - fd_set rd, wr, xx; - Wsysmsg m; - XEvent event; - - /* - * Move the protocol off stdin/stdout so that - * any inadvertent prints don't screw things up. - */ - dup(0, 3); - dup(1, 4); - close(0); - close(1); - open("/dev/null", OREAD); - open("/dev/null", OWRITE); - - /* reopens stdout if debugging */ - runxevent(0); - - fmtinstall('W', drawfcallfmt); - - ARGBEGIN{ - case 'D': - chatty++; - break; - default: - usage(); - }ARGEND - - /* - * Ignore arguments. They're only for good ps -a listings. - */ - - notify(bell); - - fdin.rp = fdin.wp = fdin.buf; - fdin.ep = fdin.buf+sizeof fdin.buf; - - fdout.rp = fdout.wp = fdout.buf; - fdout.ep = fdout.buf+sizeof fdout.buf; - - fdnoblock(3); - fdnoblock(4); - - firstx = 1; - _x.fd = -1; - for(;;){ - /* set up file descriptors */ - FD_ZERO(&rd); - FD_ZERO(&wr); - FD_ZERO(&xx); - /* - * Don't read unless there's room *and* we haven't - * already filled the output buffer too much. - */ - if(fdout.wp < fdout.buf+MAXWMSG && fdin.wp < fdin.ep) - FD_SET(3, &rd); - if(fdout.wp > fdout.rp) - FD_SET(4, &wr); - FD_SET(3, &xx); - FD_SET(4, &xx); - top = 4; - if(_x.fd >= 0){ - if(firstx){ - firstx = 0; - XSelectInput(_x.display, _x.drawable, Mask); - } - FD_SET(_x.fd, &rd); - FD_SET(_x.fd, &xx); - XFlush(_x.display); - if(_x.fd > top) - top = _x.fd; - } - - if(chatty) - fprint(2, "select %d...\n", top+1); - /* wait for something to happen */ - again: - if(select(top+1, &rd, &wr, &xx, NULL) < 0){ - if(errno == EINTR) - goto again; - if(chatty) - fprint(2, "select failure\n"); - exits(0); - } - if(chatty) - fprint(2, "got select...\n"); - - { - /* read what we can */ - n = 1; - while(fdin.wp < fdin.ep && (n = read(3, fdin.wp, fdin.ep-fdin.wp)) > 0) - fdin.wp += n; - if(n == 0){ - if(chatty) - fprint(2, "eof\n"); - exits(0); - } - if(n < 0 && errno != EAGAIN) - sysfatal("reading wsys msg: %r"); - - /* pick off messages one by one */ - while((n = convM2W(fdin.rp, fdin.wp-fdin.rp, &m)) > 0){ - /* fprint(2, "<- %W\n", &m); */ - runmsg(&m); - fdin.rp += n; - } - - /* slide data to beginning of buf */ - fdslide(&fdin); - } - { - /* write what we can */ - n = 1; - while(fdout.rp < fdout.wp && (n = write(4, fdout.rp, fdout.wp-fdout.rp)) > 0) - fdout.rp += n; - if(n == 0) - sysfatal("short write writing wsys"); - if(n < 0 && errno != EAGAIN) - sysfatal("writing wsys msg: %r"); - - /* slide data to beginning of buf */ - fdslide(&fdout); - } - { - /* - * Read an X message if we can. - * (XPending actually calls select to make sure - * the display's fd is readable and then reads - * in any waiting data before declaring whether - * there are events on the queue.) - */ - while(XPending(_x.display)){ - XNextEvent(_x.display, &event); - runxevent(&event); - } - } - } -} - -int -fdnoblock(int fd) -{ - return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL)|O_NONBLOCK); -} - -void -fdslide(Fdbuf *fb) -{ - int n; - - n = fb->wp - fb->rp; - if(n > 0) - memmove(fb->buf, fb->rp, n); - fb->rp = fb->buf; - fb->wp = fb->rp+n; -} - -void -replyerror(Wsysmsg *m) -{ - char err[256]; - - rerrstr(err, sizeof err); - m->type = Rerror; - m->error = err; - replymsg(m); -} - - - -/* - * Handle a single wsysmsg. - * Might queue for later (kbd, mouse read) - */ -void -runmsg(Wsysmsg *m) -{ - uchar buf[65536]; - int n; - Memimage *i; - - switch(m->type){ - case Tinit: - memimageinit(); - i = _xattach(m->label, m->winsize); - _initdisplaymemimage(i); - replymsg(m); - break; - - case Trdmouse: - mousetags.t[mousetags.wi++] = m->tag; - if(mousetags.wi == nelem(mousetags.t)) - mousetags.wi = 0; - if(mousetags.wi == mousetags.ri) - sysfatal("too many queued mouse reads"); - /* fprint(2, "mouse unstall\n"); */ - mouse.stall = 0; - matchmouse(); - break; - - case Trdkbd: - kbdtags.t[kbdtags.wi++] = m->tag; - if(kbdtags.wi == nelem(kbdtags.t)) - kbdtags.wi = 0; - if(kbdtags.wi == kbdtags.ri) - sysfatal("too many queued keyboard reads"); - kbd.stall = 0; - matchkbd(); - break; - - case Tmoveto: - _xmoveto(m->mouse.xy); - replymsg(m); - break; - - case Tcursor: - case Tcursor2: - if(m->arrowcursor) - _xsetcursor(nil); - else - _xsetcursor(&m->cursor); - replymsg(m); - break; - - case Tbouncemouse: - _xbouncemouse(&m->mouse); - replymsg(m); - break; - - case Tlabel: - _xsetlabel(m->label); - replymsg(m); - break; - - case Trdsnarf: - m->snarf = _xgetsnarf(); - replymsg(m); - free(m->snarf); - break; - - case Twrsnarf: - _xputsnarf(m->snarf); - replymsg(m); - break; - - case Trddraw: - n = m->count; - if(n > sizeof buf) - n = sizeof buf; - n = draw_dataread(buf, n); - if(n < 0) - replyerror(m); - else{ - m->count = n; - m->data = buf; - replymsg(m); - } - break; - - case Twrdraw: - if(draw_datawrite(m->data, m->count) < 0) - replyerror(m); - else - replymsg(m); - break; - - case Ttop: - _xtopwindow(); - replymsg(m); - break; - - case Tresize: - _xresizewindow(m->rect); - replymsg(m); - break; - } -} - -/* - * Reply to m. - */ -void -replymsg(Wsysmsg *m) -{ - int n; - - /* T -> R msg */ - if(m->type%2 == 0) - m->type++; - - /* fprint(2, "-> %W\n", m); */ - /* copy to output buffer */ - n = sizeW2M(m); - if(fdout.wp+n > fdout.ep) - sysfatal("out of space for reply message"); - convW2M(m, fdout.wp, n); - fdout.wp += n; -} - -/* - * Match queued kbd reads with queued kbd characters. - */ -void -matchkbd(void) -{ - Wsysmsg m; - - if(kbd.stall) - return; - while(kbd.ri != kbd.wi && kbdtags.ri != kbdtags.wi){ - m.type = Rrdkbd; - m.tag = kbdtags.t[kbdtags.ri++]; - if(kbdtags.ri == nelem(kbdtags.t)) - kbdtags.ri = 0; - m.rune = kbd.r[kbd.ri++]; - if(kbd.ri == nelem(kbd.r)) - kbd.ri = 0; - replymsg(&m); - } -} - -/* - * Match queued mouse reads with queued mouse events. - */ -void -matchmouse(void) -{ - Wsysmsg m; - - while(mouse.ri != mouse.wi && mousetags.ri != mousetags.wi){ - m.type = Rrdmouse; - m.tag = mousetags.t[mousetags.ri++]; - if(mousetags.ri == nelem(mousetags.t)) - mousetags.ri = 0; - m.mouse = mouse.m[mouse.ri]; - m.resized = mouse.resized; - /* - if(m.resized) - fprint(2, "sending resize\n"); - */ - mouse.resized = 0; - mouse.ri++; - if(mouse.ri == nelem(mouse.m)) - mouse.ri = 0; - replymsg(&m); - } -} - -static int kbuttons; -static int altdown; -static int kstate; - -static void -sendmouse(Mouse m) -{ - m.buttons |= kbuttons; - mouse.m[mouse.wi] = m; - mouse.wi++; - if(mouse.wi == nelem(mouse.m)) - mouse.wi = 0; - if(mouse.wi == mouse.ri){ - mouse.stall = 1; - mouse.ri = 0; - mouse.wi = 1; - mouse.m[0] = m; - /* fprint(2, "mouse stall\n"); */ - } - matchmouse(); -} - -/* - * Handle an incoming X event. - */ -void -runxevent(XEvent *xev) -{ - int c; - KeySym k; - static Mouse m; - XButtonEvent *be; - XKeyEvent *ke; - -#ifdef SHOWEVENT - static int first = 1; - if(first){ - dup(create("/tmp/devdraw.out", OWRITE, 0666), 1); - setbuf(stdout, 0); - first = 0; - } -#endif - - if(xev == 0) - return; - -#ifdef SHOWEVENT - print("\n"); - ShowEvent(xev); -#endif - - switch(xev->type){ - case Expose: - _xexpose(xev); - break; - - case DestroyNotify: - if(_xdestroy(xev)) - exits(0); - break; - - case ConfigureNotify: - if(_xconfigure(xev)){ - mouse.resized = 1; - _xreplacescreenimage(); - sendmouse(m); - } - break; - - case ButtonPress: - be = (XButtonEvent*)xev; - if(be->button == 1) { - if(kstate & ControlMask) - be->button = 2; - else if(kstate & Mod1Mask) - be->button = 3; - } - // fall through - case ButtonRelease: - altdown = 0; - // fall through - case MotionNotify: - if(mouse.stall) - return; - if(_xtoplan9mouse(xev, &m) < 0) - return; - sendmouse(m); - break; - - case KeyRelease: - case KeyPress: - ke = (XKeyEvent*)xev; - XLookupString(ke, NULL, 0, &k, NULL); - c = ke->state; - switch(k) { - case XK_Alt_L: - case XK_Meta_L: /* Shift Alt on PCs */ - case XK_Alt_R: - case XK_Meta_R: /* Shift Alt on PCs */ - case XK_Multi_key: - if(xev->type == KeyPress) - altdown = 1; - else if(altdown) { - altdown = 0; - sendalt(); - } - break; - } - - switch(k) { - case XK_Control_L: - if(xev->type == KeyPress) - c |= ControlMask; - else - c &= ~ControlMask; - goto kbutton; - case XK_Alt_L: - case XK_Shift_L: - if(xev->type == KeyPress) - c |= Mod1Mask; - else - c &= ~Mod1Mask; - kbutton: - kstate = c; - if(m.buttons || kbuttons) { - altdown = 0; // used alt - kbuttons = 0; - if(c & ControlMask) - kbuttons |= 2; - if(c & Mod1Mask) - kbuttons |= 4; - sendmouse(m); - break; - } - } - - if(xev->type != KeyPress) - break; - if(k == XK_F11){ - fullscreen = !fullscreen; - _xmovewindow(fullscreen ? screenrect : windowrect); - return; - } - if(kbd.stall) - return; - if((c = _xtoplan9kbd(xev)) < 0) - return; - kbd.r[kbd.wi++] = c; - if(kbd.wi == nelem(kbd.r)) - kbd.wi = 0; - if(kbd.ri == kbd.wi) - kbd.stall = 1; - matchkbd(); - break; - - case FocusOut: - /* - * Some key combinations (e.g. Alt-Tab) can cause us - * to see the key down event without the key up event, - * so clear out the keyboard state when we lose the focus. - */ - kstate = 0; - altdown = 0; - abortcompose(); - break; - - case SelectionRequest: - _xselect(xev); - break; - } -} diff --git a/src/cmd/devdraw/x11-wsys.c b/src/cmd/devdraw/x11-wsys.c deleted file mode 100644 index 82a7d32c1..000000000 --- a/src/cmd/devdraw/x11-wsys.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include "x11-inc.h" -#include -#include -#include -#include "x11-memdraw.h" - -void -_xtopwindow(void) -{ - XMapRaised(_x.display, _x.drawable); - XSetInputFocus(_x.display, _x.drawable, RevertToPointerRoot, - CurrentTime); - XFlush(_x.display); -} - -void -_xresizewindow(Rectangle r) -{ - XWindowChanges e; - int value_mask; - - memset(&e, 0, sizeof e); - value_mask = CWX|CWY|CWWidth|CWHeight; - e.width = Dx(r); - e.height = Dy(r); - XConfigureWindow(_x.display, _x.drawable, value_mask, &e); - XFlush(_x.display); -} - -void -_xmovewindow(Rectangle r) -{ - XWindowChanges e; - int value_mask; - - memset(&e, 0, sizeof e); - value_mask = CWX|CWY|CWWidth|CWHeight; - e.x = r.min.x; - e.y = r.min.y; - e.width = Dx(r); - e.height = Dy(r); - XConfigureWindow(_x.display, _x.drawable, value_mask, &e); - XFlush(_x.display); -} From 04da0159764152b99b7dd0f33ace7d97ae7c2aa1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 16:47:16 -0500 Subject: [PATCH 141/323] devdraw: AUTOFRAMEWORK CoreFoundation on macOS Fixes #273. --- src/cmd/devdraw/mac-screen.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 47df3dc52..8929e6b3f 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -27,6 +27,7 @@ AUTOFRAMEWORK(Cocoa) AUTOFRAMEWORK(Metal) AUTOFRAMEWORK(QuartzCore) +AUTOFRAMEWORK(CoreFoundation) #define LOG if(0)NSLog From be263a722e8957d99f2a51bb11106103bf878b44 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 16:48:58 -0500 Subject: [PATCH 142/323] lib9: rm unused _p9translate.c Fixes #238. --- src/lib9/_p9translate.c | 46 ----------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 src/lib9/_p9translate.c diff --git a/src/lib9/_p9translate.c b/src/lib9/_p9translate.c deleted file mode 100644 index 74df43c58..000000000 --- a/src/lib9/_p9translate.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include - -/* - * I don't want too many of these, - * but the ones we have are just too useful. - */ -static struct { - char *old; - char *new; -} replace[] = { - "#9", nil, /* must be first */ - "#d", "/dev/fd", -}; - -char* -plan9translate(char *old) -{ - char *new; - int i, olen, nlen, len; - - if(replace[0].new == nil){ - replace[0].new = getenv("PLAN9"); - if(replace[0].new == nil) - replace[0].new = "/usr/local/plan9"; - } - - for(i=0; i"; - strcpy(new, replace[i].new); - strcpy(new+nlen, old+olen); - assert(strlen(new) == len); - return new; - } - return old; -} From ac6456a0cc67ca33c7b9c64cf7a4598961de8911 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 16:53:30 -0500 Subject: [PATCH 143/323] clock: import from plan 9 Fixes #250. --- man/man1/date.1 | 13 +++--- src/cmd/draw/clock.c | 104 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 src/cmd/draw/clock.c diff --git a/man/man1/date.1 b/man/man1/date.1 index 1ce96f384..10db8dfe8 100644 --- a/man/man1/date.1 +++ b/man/man1/date.1 @@ -1,6 +1,6 @@ .TH DATE 1 .SH NAME -date \- date and time +date, clock \- date and time .SH SYNOPSIS .B date [ @@ -8,8 +8,8 @@ date \- date and time ] [ .I seconds ] -.\" .br -.\" .B clock +.br +.B clock .SH DESCRIPTION Print the date, in the format .PP @@ -34,6 +34,9 @@ If the optional argument .I seconds is present, it is used as the time to convert rather than the real time. +.PP +.I Clock +draws a simple analog clock in its window. .\" .SH FILES .\" .TF /adm/timezone/local .\" .TP @@ -54,5 +57,5 @@ the real time. .\" draws a simple analog clock in its window. .SH SOURCE .B \*9/src/cmd/date.c -.\" .br -.\" .B \*9/src/cmd/draw/clock.c +.br +.B \*9/src/cmd/draw/clock.c diff --git a/src/cmd/draw/clock.c b/src/cmd/draw/clock.c new file mode 100644 index 000000000..b804e1f4e --- /dev/null +++ b/src/cmd/draw/clock.c @@ -0,0 +1,104 @@ +#include +#include +#include +#include + +Image *hrhand, *minhand; +Image *dots, *back; + +Point +circlept(Point c, int r, int degrees) +{ + double rad; + rad = (double) degrees * PI/180.0; + c.x += cos(rad)*r; + c.y -= sin(rad)*r; + return c; +} + +void +redraw(Image *screen) +{ + static int tm, ntm; + static Rectangle r; + static Point c; + static int rad; + int i; + int anghr, angmin; + static Tm tms; + static Tm ntms; + + ntm = time(0); + if(ntm == tm && eqrect(screen->r, r)) + return; + + ntms = *localtime(ntm); + anghr = 90-(ntms.hour*5 + ntms.min/12)*6; + angmin = 90-ntms.min*6; + tm = ntm; + tms = ntms; + r = screen->r; + c = divpt(addpt(r.min, r.max), 2); + rad = Dx(r) < Dy(r) ? Dx(r) : Dy(r); + rad /= 2; + rad -= 8; + + draw(screen, screen->r, back, nil, ZP); + for(i=0; i<12; i++) + fillellipse(screen, circlept(c, rad, i*(360/12)), 2, 2, dots, ZP); + + line(screen, c, circlept(c, (rad*3)/4, angmin), 0, 0, 1, minhand, ZP); + line(screen, c, circlept(c, rad/2, anghr), 0, 0, 1, hrhand, ZP); + + flushimage(display, 1); +} + +void +eresized(int new) +{ + if(new && getwindow(display, Refnone) < 0) + fprint(2,"can't reattach to window"); + redraw(screen); +} + +void +main(int argc, char **argv) +{ + Event e; + Mouse m; + Menu menu; + char *mstr[] = {"exit", 0}; + int key, timer; + int t; + + USED(argc); + USED(argv); + + if (initdraw(0, 0, "clock") < 0) + sysfatal("initdraw failed"); + back = allocimagemix(display, DPalebluegreen, DWhite); + + hrhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DDarkblue); + minhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPaleblue); + dots = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DBlue); + redraw(screen); + + einit(Emouse); + t = (30*1000); + timer = etimer(0, t); + + menu.item = mstr; + menu.lasthit = 0; + for(;;) { + key = event(&e); + if(key == Emouse) { + m = e.mouse; + if(m.buttons & 4) { + if(emenuhit(3, &m, &menu) == 0) + exits(0); + } + } else if(key == timer) { + redraw(screen); + } + } +} From 93f9789c048d9bfd75192adce3ed9a3ff8a68fbc Mon Sep 17 00:00:00 2001 From: Nicola Girardi Date: Mon, 22 Jul 2019 18:39:56 +0000 Subject: [PATCH 144/323] cmd/9pfuse: ignore FMODE_EXEC open flag Improved error message in case of unexpected open flags. The message unexpected open flags requested=0100040 unhandled=040 prompted me to clear the FMODE_EXEC flag, although I wonder if I shouldn't have set OEXEC (0x3) instead. --- src/cmd/9pfuse/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index 0d4adb08c..0df610022 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -51,6 +51,14 @@ # endif #endif +#ifndef FMODE_EXEC +# if defined(__linux__) +# define FMODE_EXEC 040 +# else +# define FMODE_EXEC 0 +# endif +#endif + int debug; char *argv0; char *aname = ""; @@ -583,7 +591,7 @@ _fuseopen(FuseMsg *m, int isdir) flags = in->flags; openmode = flags&3; flags &= ~3; - flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC); + flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|FMODE_EXEC); #ifdef O_NOFOLLOW flags &= ~O_NOFOLLOW; #endif @@ -602,13 +610,14 @@ _fuseopen(FuseMsg *m, int isdir) openmode |= OTRUNC; flags &= ~O_TRUNC; } + /* * Could translate but not standard 9P: * O_DIRECT -> ODIRECT * O_NONBLOCK -> ONONBLOCK */ if(flags){ - fprint(2, "unexpected open flags %#uo\n", (uint)in->flags); + fprint(2, "unexpected open flags requested=%#uo unhandled=%#uo\n", (uint)in->flags, (uint)flags); replyfuseerrno(m, EACCES); return; } From 369923f6fca5a713698dbac76c486ddb28f43721 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 17:00:27 -0500 Subject: [PATCH 145/323] libthread: fix nbrecvul, recvul to match man page, Plan 9 They return 0 on failure, not -1. Bug introduced in my original libthread-for-Unix code. Fixes #230. --- src/libthread/channel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libthread/channel.c b/src/libthread/channel.c index b6b2e3e63..53af86e6b 100644 --- a/src/libthread/channel.c +++ b/src/libthread/channel.c @@ -397,7 +397,7 @@ chanrecvul(Channel *c) if(_chanop(c, CHANRCV, &val, 1) > 0) return val; - return -1; + return 0; } int @@ -413,5 +413,5 @@ channbrecvul(Channel *c) if(_chanop(c, CHANRCV, &val, 0) > 0) return val; - return -1; + return 0; } From 1c78140d83ed1f3a2ced027a64113dcf187971fb Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 17:04:06 -0500 Subject: [PATCH 146/323] TODO: remove, not updated in 15 years --- README.md | 6 +++--- TODO | 12 ------------ 2 files changed, 3 insertions(+), 15 deletions(-) delete mode 100644 TODO diff --git a/README.md b/README.md index 1409d5a5d..631dde280 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Installation ------------ To install, run ./INSTALL. It builds mk and then uses mk to -run the rest of the installation. +run the rest of the installation. For more details, see install(1), at install.txt in this directory and at https://9fans.github.io/plan9port/man/man1/install.html. @@ -22,7 +22,7 @@ or differences from Plan 9. Helping out ----------- -If you'd like to help out, great! The TODO file contains a small list. +If you'd like to help out, great! If you port this code to other architectures, please share your changes so others can benefit. @@ -30,7 +30,7 @@ so others can benefit. Git --- -You can use Git to keep your local copy up-to-date as we make +You can use Git to keep your local copy up-to-date as we make changes and fix bugs. See the git(1) man page here ("9 man git") for details on using Git. diff --git a/TODO b/TODO deleted file mode 100644 index 5378a404b..000000000 --- a/TODO +++ /dev/null @@ -1,12 +0,0 @@ -BUGS - - libdraw sometimes gets initial window size wrong. - -PORTS - - acme Mail in some form? - - upas/fs in some form? - -FEATURES - - add NTFS, FAT to libdiskfs? - - more granular packaging (in progress) - - finish adding 9P2000.u (in progress) - From fa588406f02b5f2adf666211bef03fbee30a61b0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 17:07:44 -0500 Subject: [PATCH 147/323] 9pfuse: do not fswalk("..") f is open, so walk will fail. The comments say we only need one directory anyway. Fixes #277. --- src/cmd/9pfuse/main.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index 0df610022..69d1ad75d 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -885,7 +885,7 @@ fusereadlink(FuseMsg *m) * are stored in m->d,nd,d0. */ int canpack(Dir*, uvlong, uchar**, uchar*); -Dir *dotdirs(CFid*); +Dir *dotdir(CFid*); void fusereaddir(FuseMsg *m) { @@ -902,8 +902,8 @@ fusereaddir(FuseMsg *m) if(in->offset == 0){ fsseek(ff->fid, 0, 0); free(ff->d0); - ff->d0 = ff->d = dotdirs(ff->fid); - ff->nd = 2; + ff->d0 = ff->d = dotdir(ff->fid); + ff->nd = 1; } n = in->size; if(n > fusemaxwrite) @@ -944,20 +944,13 @@ fusereaddir(FuseMsg *m) * We could add .. too, but it isn't necessary. */ Dir* -dotdirs(CFid *f) +dotdir(CFid *f) { Dir *d; - CFid *f1; - d = emalloc(2*sizeof *d); + d = emalloc(1*sizeof *d); d[0].name = "."; d[0].qid = fsqid(f); - d[1].name = ".."; - f1 = fswalk(f, ".."); - if(f1){ - d[1].qid = fsqid(f1); - fsclose(f1); - } return d; } From 59b460f845ee7d2e0156a4ba43fbe75c2531489b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 17:09:39 -0500 Subject: [PATCH 148/323] vac, unvac: allow 128MB cache size, up from 4MB When a directory has lots of children, vac crashes because it runs out of cache. Fixes #266. --- src/cmd/vac/unvac.c | 2 +- src/cmd/vac/vac.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/vac/unvac.c b/src/cmd/vac/unvac.c index a265893fc..a117a250c 100644 --- a/src/cmd/vac/unvac.c +++ b/src/cmd/vac/unvac.c @@ -94,7 +94,7 @@ threadmain(int argc, char *argv[]) if(vtconnect(conn) < 0) sysfatal("vtconnect: %r"); - fs = vacfsopen(conn, argv[0], VtOREAD, 4<<20); + fs = vacfsopen(conn, argv[0], VtOREAD, 128<<20); if(fs == nil) sysfatal("vacfsopen: %r"); diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c index 7e4414825..4555a9075 100644 --- a/src/cmd/vac/vac.c +++ b/src/cmd/vac/vac.c @@ -15,7 +15,7 @@ usage(void) enum { BlockSize = 8*1024, - CacheSize = 4<<20, + CacheSize = 128<<20, }; struct From d2df5d6cbd345e101732fe7d22bb5b3baa5fb61a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 18:15:57 -0500 Subject: [PATCH 149/323] acme: fix crash in X |cat with multiple windows Fixes #9. Fixes #219. Fixes #222. Fixes #330. --- src/cmd/acme/ecmd.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/cmd/acme/ecmd.c b/src/cmd/acme/ecmd.c index 75cf710f1..f7613172b 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; } @@ -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; ibody, 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; ibody; + 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); From 9962d916e88f66014f1008d4356a2d395ae8d31b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 18:26:15 -0500 Subject: [PATCH 150/323] tmac: fix troff -ms .KS after .1C Fixes #233. --- tmac/tmac.s | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tmac/tmac.s b/tmac/tmac.s index 6f111869f..4a7a2eace 100644 --- a/tmac/tmac.s +++ b/tmac/tmac.s @@ -438,7 +438,7 @@ .if n \{\ . sp 2 . A1 -. sp +. sp . ns . I1 . if \\n(NA-1 .sp 2 @@ -557,7 +557,7 @@ ABSTRACT .ls 1 .pn 2 .WB -.ls +.ls .sp 3v \\*(DY .sp |9i @@ -991,7 +991,7 @@ Computing Science Technical Report No. \\*(MN .fi .if (\\n(nl+1v)>(\\n(.p-\\n(FM) \{\ . if \\n(NX>1 .RC -. if \\n(NX<1 .bp\} +. if \\n(NX<=1 .bp\} .nr TD 0 .. .de KD @@ -1039,7 +1039,7 @@ Computing Science Technical Report No. \\*(MN .if !\\n(dn .nr WF 0 .if \\n(FC<=1 .if \\n(XX=0 \{\ . if \\n(NX>1 .RC -. if \\n(NX<1 'bp\} +. if \\n(NX<=1 'bp\} .nr FC -1 .if \\n(ML>0 .ne \\n(MLu .. @@ -1221,9 +1221,9 @@ Piscataway, New Jersey 08854 .ps \\n(PS-2 .vs \\n(.s+2p .ev -.if !\\n(KG .nr FP 0 +.if !\\n(KG .nr FP 0 .if \\n(GA>1 .if \\n(KG=0 .nr GA 0 \" next UNIX must be flagged. -.nr KG 0 +.nr KG 0 .if \\n(FP \{\ . FS . FG From 6c17f630901eec2a4b54b70748d7fbc9b47eecd8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 19:20:34 -0500 Subject: [PATCH 151/323] mk: treat X= as empty list in rc shell This brings mk's behavior when using rc in line with Plan 9's. The existing code is for Unix environment data structures but also was assuming Unix shell semantics where empty and missing variables are mostly equivalent. The Plan 9 code (/sys/src/cmd/mk/plan9.c in the distribution) explicitly removes /env/name (creating an empty list) when the value is missing or an empty string. Fixes #255. --- src/cmd/mk/unix.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/cmd/mk/unix.c b/src/cmd/mk/unix.c index 37f05b717..66bdb1ffb 100644 --- a/src/cmd/mk/unix.c +++ b/src/cmd/mk/unix.c @@ -53,20 +53,26 @@ readenv(void) void exportenv(Envy *e, Shell *sh) { - int i; + int w, n; char **p; + Envy *e1; static char buf[16384]; - p = 0; - for(i = 0; e->name; e++, i++) { - p = (char**) Realloc(p, (i+2)*sizeof(char*)); + n = 0; + for(e1 = e; e1->name; e1++) + n++; + p = Malloc((n+1)*sizeof(char*)); + w = 0; + for(; e->name; e++) { + if(sh == &rcshell && (e->values == 0 || e->values->s == 0 || e->values->s[0] == 0)) + continue; /* do not write empty string for empty list */ if(e->values) snprint(buf, sizeof buf, "%s=%s", e->name, wtos(e->values, sh->iws)); else snprint(buf, sizeof buf, "%s=", e->name); - p[i] = strdup(buf); + p[w++] = strdup(buf); } - p[i] = 0; + p[w] = 0; environ = p; } From 3a62e5630748d788166a50ed34b7f0dc6d43a5ee Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 19:30:02 -0500 Subject: [PATCH 152/323] lib9: do not fetch disk size for character devices Real disk devices should be block devices anyway. One user reported the disksize check causing a system reboot during vac of a tree with an "interesting" device. Fixes #103. --- src/lib9/_p9dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c index 0fb3410e9..58c63573e 100644 --- a/src/lib9/_p9dir.c +++ b/src/lib9/_p9dir.c @@ -230,7 +230,7 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char * d->qid.path = ('c'<<16)|st->st_rdev; } /* fetch real size for disks */ - if(S_ISBLK(lst->st_mode) || S_ISCHR(lst->st_mode)){ + if(S_ISBLK(lst->st_mode)){ if((fd = open(name, O_RDONLY)) >= 0){ d->length = disksize(fd, st); close(fd); From 81d992e35f12d53e6799d20c744ffb4e6a49787d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 20:00:51 -0500 Subject: [PATCH 153/323] acme: factor out tag parsing code --- src/cmd/acme/fns.h | 1 + src/cmd/acme/look.c | 18 ++++++++---------- src/cmd/acme/wind.c | 30 +++++++++++++++++++----------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h index 8dc023781..fece1dbdc 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*); Runestr runestr(Rune*, uint); Range range(int, int); diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 44e23ccac..7b70e2423 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, &i); slash = -1; - for(m=0; m= 0; i--){ + if(b[i] == '/'){ + slash = i; break; + } } if(slash < 0) goto Rescue; diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 820955b0b..5950ef0e9 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -440,6 +440,23 @@ wincleartag(Window *w) textsetselect(&w->tag, w->tag.q0, w->tag.q1); } +Rune* +parsetag(Window *w, int *len) +{ + int i; + Rune *r; + + r = runemalloc(w->tag.file->b.nc+1); + bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc); + r[w->tag.file->b.nc] = '\0'; + + for(i=0; itag.file->b.nc; i++) + if(r[i]==' ' || r[i]=='\t') + break; + *len = i; + return r; +} + void winsettag1(Window *w) { @@ -458,12 +475,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; itag.file->b.nc; i++) - if(old[i]==' ' || old[i]=='\t') - break; + old = parsetag(w, &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); @@ -584,11 +596,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; itag.file->b.nc; i++) - if(r[i]==' ' || r[i]=='\t') - break; + r = parsetag(w, &i); if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){ seq++; filemark(w->body.file); From 6bddb06b710066a4086dbe77822d02cafecb935b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 21:58:40 -0500 Subject: [PATCH 154/323] acme: one more place to use parsetag --- src/cmd/acme/wind.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 5950ef0e9..156835da7 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -419,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 Date: Tue, 14 Jan 2020 04:05:03 +0100 Subject: [PATCH 155/323] mk: fix hash function (#315) Avoid signed integer overflow using ulong instead of long h. --- src/cmd/mk/symtab.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cmd/mk/symtab.c b/src/cmd/mk/symtab.c index 17674c437..2bb28ba8d 100644 --- a/src/cmd/mk/symtab.c +++ b/src/cmd/mk/symtab.c @@ -1,7 +1,7 @@ #include "mk.h" #define NHASH 4099 -#define HASHMUL 79L /* this is a good value */ +#define HASHMUL 79UL /* this is a good value */ static Symtab *hash[NHASH]; void @@ -21,14 +21,12 @@ syminit(void) Symtab * symlook(char *sym, int space, void *install) { - long h; + ulong h; char *p; Symtab *s; for(p = sym, h = space; *p; h += *p++) h *= HASHMUL; - if(h < 0) - h = ~h; h %= NHASH; for(s = hash[h]; s; s = s->next) if((s->space == space) && (strcmp(s->name, sym) == 0)) @@ -47,7 +45,7 @@ symlook(char *sym, int space, void *install) void symdel(char *sym, int space) { - long h; + ulong h; char *p; Symtab *s, *ls; @@ -55,8 +53,6 @@ symdel(char *sym, int space) for(p = sym, h = space; *p; h += *p++) h *= HASHMUL; - if(h < 0) - h = ~h; h %= NHASH; for(s = hash[h], ls = 0; s; ls = s, s = s->next) if((s->space == space) && (strcmp(s->name, sym) == 0)){ From 7b1c85f6e8031a50e8e6f5977d12bea820e921ca Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 20:02:54 -0500 Subject: [PATCH 156/323] acme: allow spaces in window names There are many things we could do to make this work. an environment variable to control the character. Another option would be to use U+00A0 (non-breaking space), which renders the same as space. This change avoids changing the separator character and instead assumes that if the left side of the tag already ends in " Del Snarf |" then what comes before that is the file name. Acme already aggressively preserves the "Del Snarf |", so this should work decently well as a stop-gap. We can always try something else later. Fixes #26. Fixes #104. Fixes #329. --- src/cmd/acme/look.c | 2 +- src/cmd/acme/wind.c | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 7b70e2423..bde8b2c95 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -610,7 +610,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e) if(nname == -1) nname = n; for(i=0; i, and turn that into an include diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 156835da7..248680fe3 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -439,16 +439,31 @@ wincleartag(Window *w) Rune* parsetag(Window *w, int *len) { + static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0 }; + static Rune Lspacepipe[] = { ' ', '|', 0 }; + static Rune Ltabpipe[] = { ' ', '|', 0 }; int i; - Rune *r; + Rune *r, *p, *pipe; r = runemalloc(w->tag.file->b.nc+1); bufread(&w->tag.file->b, 0, r, w->tag.file->b.nc); r[w->tag.file->b.nc] = '\0'; - for(i=0; itag.file->b.nc; i++) - if(r[i]==' ' || r[i]=='\t') - break; + /* + * " |" 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; itag.file->b.nc; i++) + if(r[i]==' ' || r[i]=='\t') + break; + } *len = i; return r; } From 86bfd6075d7e7bf1f68097f11dbef94439e1f605 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:11:19 -0500 Subject: [PATCH 157/323] acme: fix movetodel for spaces in file names --- src/cmd/acme/wind.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 248680fe3..2782dbc71 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -110,18 +110,15 @@ windrawbutton(Window *w) int delrunepos(Window *w) { - int n; - Rune rune; + Rune *r; + int i; - for(n=0; ntag.file->b.nc; n++) { - bufread(&w->tag.file->b, n, &rune, 1); - if(rune == ' ') - break; - } - n += 2; - if(n >= w->tag.file->b.nc) + r = parsetag(w, &i); + free(r); + i += 2; + if(i >= w->tag.file->b.nc) return -1; - return n; + return i; } void @@ -441,7 +438,7 @@ parsetag(Window *w, int *len) { static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ', 'S', 'n', 'a', 'r', 'f', 0 }; static Rune Lspacepipe[] = { ' ', '|', 0 }; - static Rune Ltabpipe[] = { ' ', '|', 0 }; + static Rune Ltabpipe[] = { '\t', '|', 0 }; int i; Rune *r, *p, *pipe; From 125cfe1c0d29541135eac6da676ed9b48930e38b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:11:45 -0500 Subject: [PATCH 158/323] mouse(3): fix definition of Mousectl --- man/man3/mouse.3 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/man/man3/mouse.3 b/man/man3/mouse.3 index 216c72b01..b5061fd92 100644 --- a/man/man3/mouse.3 +++ b/man/man3/mouse.3 @@ -88,15 +88,15 @@ returns a structure through which one may access the mouse: typedef struct Mousectl Mousectl; struct Mousectl { - Mouse; - Channel *c; /* chan(Mouse)[16] */ + Mouse m; + Channel *c; /* chan(Mouse)[16] */ Channel *resizec; /* chan(int)[2] */ char *file; int mfd; /* to mouse file */ int cfd; /* to cursor file */ int pid; /* of slave proc */ - Image* image; /* of associated window/display */ + Image* image; /* of associated window/display */ }; .EE .PP @@ -142,7 +142,9 @@ to reconnect to the window. .I Readmouse updates the .B Mouse -structure held in the +structure +.B m +held in the .BR Mousectl , blocking if the state has not changed since the last .I readmouse From 573169dd88ac5ca0cf75d09464dddba398e83011 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:17:16 -0500 Subject: [PATCH 159/323] acme: fix buffer overflow introduced in parsetag refactor --- src/cmd/acme/fns.h | 2 +- src/cmd/acme/look.c | 2 +- src/cmd/acme/wind.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h index fece1dbdc..c0339c230 100644 --- a/src/cmd/acme/fns.h +++ b/src/cmd/acme/fns.h @@ -95,7 +95,7 @@ void flushwarnings(void); void startplumbing(void); long nlcount(Text*, long, long, long*); long nlcounttopos(Text*, long, long, long); -Rune* parsetag(Window*, int*); +Rune* parsetag(Window*, int, int*); Runestr runestr(Rune*, uint); Range range(int, int); diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index bde8b2c95..35667c6c3 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -490,7 +490,7 @@ dirname(Text *t, Rune *r, int n) goto Rescue; if(n>=1 && r[0]=='/') goto Rescue; - b = parsetag(t->w, &i); + b = parsetag(t->w, n, &i); slash = -1; for(i--; i >= 0; i--){ if(b[i] == '/'){ diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 2782dbc71..0cba59205 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -113,7 +113,7 @@ delrunepos(Window *w) Rune *r; int i; - r = parsetag(w, &i); + r = parsetag(w, 0, &i); free(r); i += 2; if(i >= w->tag.file->b.nc) @@ -416,7 +416,7 @@ wincleartag(Window *w) /* w must be committed */ n = w->tag.file->b.nc; - r = parsetag(w, &i); + r = parsetag(w, 0, &i); for(; itag.file->b.nc+1); + 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'; @@ -483,7 +483,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 = parsetag(w, &i); + 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); @@ -604,7 +604,7 @@ wincommit(Window *w, Text *t) textcommit(f->text[i], FALSE); /* no-op for t */ if(t->what == Body) return; - r = parsetag(w, &i); + r = parsetag(w, 0, &i); if(runeeq(r, i, w->body.file->name, w->body.file->nname) == FALSE){ seq++; filemark(w->body.file); From 481b596d9389076d686832e0a3c26fc7b550c532 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:26:26 -0500 Subject: [PATCH 160/323] libthread: fix fault in teardown of proc Fixes #332. --- src/libthread/thread.c | 1 + src/libthread/threadimpl.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index c84af855c..d041efccc 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -429,6 +429,7 @@ procscheduler(Proc *p) unlock(&p->lock); _threadsetproc(nil); free(p); + _threadpexit(); } void diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 437503c68..76ca57e5c 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -197,7 +197,7 @@ extern Channel *_dowaitchan; extern void _procstart(Proc*, void (*fn)(Proc*)); extern _Thread *_threadcreate(Proc*, void(*fn)(void*), void*, uint); -extern void _threadexit(void); +extern void _procexit(void); extern Proc *_threadproc(void); extern void _threadsetproc(Proc*); extern int _threadlock(Lock*, int, ulong); From b741db607a9033364fdab4151512ffbad2153ac9 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Mon, 13 Jan 2020 22:33:59 -0600 Subject: [PATCH 161/323] devdraw: correctly hide Mac menu bar (#335) `window:willUseFullScreenPresentationOptions:` is an instance method of the protocol `NSWindowDelegate`. --- src/cmd/devdraw/mac-screen.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 8929e6b3f..f0278e0d9 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -93,15 +93,6 @@ - (void)applicationDidFinishLaunching:(id)arg gfx_started(); } -- (NSApplicationPresentationOptions)window:(id)arg - willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { - NSApplicationPresentationOptions o; - o = proposedOptions; - o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); - o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; - return o; -} - - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication { return client0 != nil; } @@ -936,6 +927,15 @@ - (void)clearInput { gfx_keystroke(self.client, Kbs); } } + +- (NSApplicationPresentationOptions)window:(id)arg + willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + NSApplicationPresentationOptions o; + o = proposedOptions; + o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); + o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + return o; +} @end static uint From 952a9afae06b4e13b1e0da3e768bbd4bf64b9ec5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:38:04 -0500 Subject: [PATCH 162/323] INSTALL: do not rm config after setting it up Fixes #334. --- INSTALL | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index 502eff417..0291e7135 100755 --- a/INSTALL +++ b/INSTALL @@ -23,6 +23,13 @@ x-r) exit 1 esac +echo "+ Mailing list: https://groups.google.com/group/plan9port-dev" +echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/" +echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls" +echo " " +echo "* Resetting $PLAN9/config" +rm -f config + PLAN9=`pwd` export PLAN9 PATH=/bin:/usr/bin:$PLAN9/bin:$PATH export PATH case `uname` in @@ -58,13 +65,6 @@ DragonFly|*BSD) ;; esac -echo "+ Mailing list: https://groups.google.com/group/plan9port-dev" -echo "+ Issue tracker: https://github.com/9fans/plan9port/issues/" -echo "+ Submitting changes: https://github.com/9fans/plan9port/pulls" -echo " " -echo "* Resetting $PLAN9/config" -rm -f config - ( if [ `uname` = Linux ]; then # On Linux, we use the kernel version to decide whether From 3d1382b98a502d0c34d5ba2c462396acc515016e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 13 Jan 2020 23:56:29 -0500 Subject: [PATCH 163/323] devdraw: hide dock in full screen mode Unfortunately this hides the dock even if it is on a different screen. We need to figure out how to tell. But this is more usable than not. Probably. --- src/cmd/devdraw/mac-screen.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index f0278e0d9..e02a25240 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -936,6 +936,19 @@ - (NSApplicationPresentationOptions)window:(id)arg o |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; return o; } + +- (void)windowWillEnterFullScreen:(NSNotification*)notification { + // TODO: This should only be done if the window + // is on the screen with the dock. + // But how can you tell which window has the dock? + [[NSApplication sharedApplication] + setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; +} + +- (void)windowDidExitFullScreen:(NSNotification*)notification { + [[NSApplication sharedApplication] + setPresentationOptions:NSApplicationPresentationDefault]; +} @end static uint From 4c54893156cf2489081fe63eb37a0e4d3ede1e05 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 12:06:34 -0500 Subject: [PATCH 164/323] devdraw: do not force-hide menu and dock during full screen on mac This hides the menu on dock on all screens which is more than we want. The code was added to fix a problem with Catalina that I can no longer reproduce, so I guess it works now. Fixes #336. --- src/cmd/devdraw/mac-screen.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index e02a25240..5e23c43a7 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -930,6 +930,13 @@ - (void)clearInput { - (NSApplicationPresentationOptions)window:(id)arg willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { + // The default for full-screen is to auto-hide the dock and menu bar, + // but the menu bar in particular comes back when the cursor is just + // near the top of the screen, which makes acme's top tag line very difficult to use. + // Disable the menu bar entirely. + // In theory this code disables the dock entirely too, but if you drag the mouse + // down far enough off the bottom of the screen the dock still unhides. + // That's OK. NSApplicationPresentationOptions o; o = proposedOptions; o &= ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar); @@ -938,16 +945,21 @@ - (NSApplicationPresentationOptions)window:(id)arg } - (void)windowWillEnterFullScreen:(NSNotification*)notification { - // TODO: This should only be done if the window - // is on the screen with the dock. - // But how can you tell which window has the dock? + // This is a heavier-weight way to make sure the menu bar and dock go away, + // but this affects all screens even though the app is running on full screen + // on only one screen, so it's not great. The behavior from the + // willUseFullScreenPresentationOptions seems to be enough for now. + /* [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock]; + */ } - (void)windowDidExitFullScreen:(NSNotification*)notification { + /* [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationDefault]; + */ } @end From 4ae529dbfe8573ae105d0d66f7f453c4f850fa1f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 13:18:29 -0500 Subject: [PATCH 165/323] libdraw: use proper pipe for default font data May fix a deadlock / missing font on OpenBSD. Fixes #308. --- src/libdraw/getsubfont.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/libdraw/getsubfont.c b/src/libdraw/getsubfont.c index ec4ccfe3e..1cc234ef9 100644 --- a/src/libdraw/getsubfont.c +++ b/src/libdraw/getsubfont.c @@ -53,15 +53,25 @@ _getsubfont(Display *d, char *name) static int defaultpipe(void) { - int p[2]; + int p[2], pid; - // assuming defontdata (<5k) fits in pipe buffer. - // especially reasonable since p9pipe is actually - // a socket pair. + // Used to assume that defontdata (<5k) fit in the + // pipe buffer, especially since p9pipe is actually + // a socket pair. But OpenBSD in particular saw hangs, + // so feed the pipe it the "right" way with a subprocess. if(pipe(p) < 0) return -1; - write(p[1], defontdata, sizeof defontdata); - close(p[1]); + if((pid = fork()) < 0) { + close(p[0]); + close(p[1]); + return -1; + } + if(pid == 0) { + close(p[0]); + write(p[1], defontdata, sizeof defontdata); + close(p[1]); + _exit(0); + } return p[0]; } From 8c573cab6819c69142389d36b978b3c683771afe Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 12:40:09 -0500 Subject: [PATCH 166/323] libthread: use mmap to allocate OpenBSD stacks Should fix faults on OpenBSD. Fixes #218. Fixes #226. --- src/libthread/Darwin-x86_64-swapcontext.c | 8 ++++++++ src/libthread/stkmalloc.c | 13 ++++++++++++ src/libthread/stkmmap.c | 25 +++++++++++++++++++++++ src/libthread/sysofiles.sh | 12 +++++------ src/libthread/thread.c | 9 ++++++-- src/libthread/threadimpl.h | 2 ++ 6 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 src/libthread/stkmalloc.c create mode 100644 src/libthread/stkmmap.c diff --git a/src/libthread/Darwin-x86_64-swapcontext.c b/src/libthread/Darwin-x86_64-swapcontext.c index 27931456d..c29ddb5ee 100644 --- a/src/libthread/Darwin-x86_64-swapcontext.c +++ b/src/libthread/Darwin-x86_64-swapcontext.c @@ -16,6 +16,14 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) va_end(arg); sp = (uintptr*)((char*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size); + /* + * Stack pointer at call instruction (before return address + * gets pushed) must be 16-byte aligned. + */ + if((uintptr)sp%4) + abort(); + while((uintptr)sp%16 != 0) + sp--; *--sp = 0; // fn's return address *--sp = (uintptr)fn; // return address of setcontext uc->mc.sp = (uintptr)sp; diff --git a/src/libthread/stkmalloc.c b/src/libthread/stkmalloc.c new file mode 100644 index 000000000..083aea1b9 --- /dev/null +++ b/src/libthread/stkmalloc.c @@ -0,0 +1,13 @@ +#include "threadimpl.h" + +void* +_threadstkalloc(int n) +{ + return malloc(n); +} + +void +_threadstkfree(void *v, int n) +{ + free(v); +} diff --git a/src/libthread/stkmmap.c b/src/libthread/stkmmap.c new file mode 100644 index 000000000..f4a246308 --- /dev/null +++ b/src/libthread/stkmmap.c @@ -0,0 +1,25 @@ +#include +#include +#include "threadimpl.h" + +#ifndef MAP_STACK +#define MAP_STACK 0 +#endif + +void* +_threadstkalloc(int n) +{ + void *p; + + p = mmap(nil, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_STACK, -1, 0); + if(p == (void*)-1) + return nil; + return p; +} + +void +_threadstkfree(void *v, int n) +{ + if(n > 0) + munmap(v, n); +} diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 9eeea606b..f76b975ad 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -6,22 +6,22 @@ tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}" case "$tag" in *-Linux-2.[0-5]*) # will have to fix this for linux power pc - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; *-FreeBSD-[0-4].*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; *-NetBSD-*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; *-Darwin-10.[5-6].* | *-Darwin-[89].*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME-${OBJTYPE}.o pthread.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME-${OBJTYPE}.o pthread.o stkmalloc.o ;; *-OpenBSD-*) - echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o + echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o ;; *) - echo pthread.o + echo pthread.o stkmalloc.o esac case "$OBJTYPE-$SYSNAME" in diff --git a/src/libthread/thread.c b/src/libthread/thread.c index d041efccc..2e654863f 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -109,7 +109,7 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) ulong z; /* allocate the task and stack together */ - t = malloc(sizeof *t+stack); + t = malloc(sizeof *t); if(t == nil) sysfatal("threadalloc malloc: %r"); memset(t, 0, sizeof *t); @@ -122,7 +122,9 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) /* do a reasonable initialization */ if(stack == 0) return t; - t->stk = (uchar*)(t+1); + t->stk = _threadstkalloc(stack); + if(t->stk == nil) + sysfatal("threadalloc malloc stack: %r"); t->stksize = stack; memset(&t->context.uc, 0, sizeof t->context.uc); sigemptyset(&zero); @@ -353,6 +355,7 @@ procscheduler(Proc *p) delthreadinproc(p, t); p->nthread--; /*print("nthread %d\n", p->nthread); */ + _threadstkfree(t->stk, t->stksize); free(t); } @@ -509,6 +512,8 @@ needstack(int n) _Thread *t; t = proc()->thread; + if(t->stk == nil) + return; if((char*)&t <= (char*)t->stk || (char*)&t - (char*)t->stk < 256+n){ diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 76ca57e5c..6671f23cf 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -209,3 +209,5 @@ extern void _threadsetupdaemonize(void); extern void _threaddodaemonize(char*); extern void _threadpexit(void); extern void _threaddaemonize(void); +extern void *_threadstkalloc(int); +extern void _threadstkfree(void*, int); From a0691bc460cbef889d017a640034f3321bd36b9d Mon Sep 17 00:00:00 2001 From: phonologus <59876118+phonologus@users.noreply.github.com> Date: Tue, 14 Jan 2020 19:52:18 +0000 Subject: [PATCH 167/323] tar: remove /bin/ when invoking compressors --- src/cmd/tar.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cmd/tar.c b/src/cmd/tar.c index 61e9c4a63..6698675e0 100644 --- a/src/cmd/tar.c +++ b/src/cmd/tar.c @@ -179,7 +179,6 @@ static int push(int fd, char *cmd, int input, Pushstate *ps) { int nfd, pifds[2]; - String *s; ps->open = 0; ps->fd = fd; @@ -197,11 +196,7 @@ push(int fd, char *cmd, int input, Pushstate *ps) dup(pifds[Rd], Stdin); close(pifds[input? Rd: Wr]); dup(fd, (input? Stdin: Stdout)); - s = s_new(); - if (cmd[0] != '/') - s_append(s, "/bin/"); - s_append(s, cmd); - execl(s_to_c(s), cmd, nil); + execl(cmd, cmd, nil); sysfatal("can't exec %s: %r", cmd); default: nfd = pifds[input? Rd: Wr]; From d28913a9e6609fef96f5baf6e9f4d5055ede744c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 16:38:34 -0500 Subject: [PATCH 168/323] acme: save/restore multiline tags in Dump/Load The dump substitutes each \n in a multiline tag with a 0xff byte. Since it is not valid UTF it cannot occur in an ordinary dump file. Old acmes will just read it in as an error rune. Fixes #135. Fixes #153. --- src/cmd/acme/rows.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 83c645942..7a64fabf9 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(nfile->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 Date: Tue, 14 Jan 2020 18:03:05 -0500 Subject: [PATCH 169/323] lib9: make formatting lock-free again First use of . We will see if any supported systems don't have it yet. (C11 was so last decade.) Fixes #338. --- src/lib9/fmt/fmt.c | 165 ++++++++++++++++++----------------------- src/lib9/fmt/fmtdef.h | 6 +- src/lib9/fmt/fmtlock.c | 14 +--- src/lib9/fmtlock2.c | 22 ++---- 4 files changed, 83 insertions(+), 124 deletions(-) diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index 9c3f45d3b..a86482c32 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c @@ -1,102 +1,107 @@ /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ #include #include +#include #include "plan9.h" #include "fmt.h" #include "fmtdef.h" enum { - Maxfmt = 64 + Maxfmt = 128 }; typedef struct Convfmt Convfmt; struct Convfmt { int c; - volatile Fmts fmt; /* for spin lock in fmtfmt; avoids race due to write order */ + Fmts fmt; }; static struct { - /* lock by calling __fmtlock, __fmtunlock */ - int nfmt; + /* + * lock updates to fmt by calling __fmtlock, __fmtunlock. + * reads can start at nfmt and work backward without + * further locking. later fmtinstalls take priority over earlier + * ones because of the backwards loop. + * once installed, a format is never overwritten. + */ + _Atomic int nfmt; Convfmt fmt[Maxfmt]; -} fmtalloc; - -static Convfmt knownfmt[] = { - ' ', __flagfmt, - '#', __flagfmt, - '%', __percentfmt, - '\'', __flagfmt, - '+', __flagfmt, - ',', __flagfmt, - '-', __flagfmt, - 'C', __runefmt, /* Plan 9 addition */ - 'E', __efgfmt, -#ifndef PLAN9PORT - 'F', __efgfmt, /* ANSI only */ -#endif - 'G', __efgfmt, -#ifndef PLAN9PORT - 'L', __flagfmt, /* ANSI only */ -#endif - 'S', __runesfmt, /* Plan 9 addition */ - 'X', __ifmt, - 'b', __ifmt, /* Plan 9 addition */ - 'c', __charfmt, - 'd', __ifmt, - 'e', __efgfmt, - 'f', __efgfmt, - 'g', __efgfmt, - 'h', __flagfmt, -#ifndef PLAN9PORT - 'i', __ifmt, /* ANSI only */ -#endif - 'l', __flagfmt, - 'n', __countfmt, - 'o', __ifmt, - 'p', __ifmt, - 'r', __errfmt, - 's', __strfmt, -#ifdef PLAN9PORT - 'u', __flagfmt, -#else - 'u', __ifmt, -#endif - 'x', __ifmt, - 0, nil, +} fmtalloc = { + #ifdef PLAN9PORT + ATOMIC_VAR_INIT(27), + #else + ATOMIC_VAR_INIT(30), + #endif + { + {' ', __flagfmt}, + {'#', __flagfmt}, + {'%', __percentfmt}, + {'\'', __flagfmt}, + {'+', __flagfmt}, + {',', __flagfmt}, + {'-', __flagfmt}, + {'C', __runefmt}, /* Plan 9 addition */ + {'E', __efgfmt}, + #ifndef PLAN9PORT + {'F', __efgfmt}, /* ANSI only */ + #endif + {'G', __efgfmt}, + #ifndef PLAN9PORT + {'L', __flagfmt}, /* ANSI only */ + #endif + {'S', __runesfmt}, /* Plan 9 addition */ + {'X', __ifmt}, + {'b', __ifmt}, /* Plan 9 addition */ + {'c', __charfmt}, + {'d', __ifmt}, + {'e', __efgfmt}, + {'f', __efgfmt}, + {'g', __efgfmt}, + {'h', __flagfmt}, + #ifndef PLAN9PORT + {'i', __ifmt}, /* ANSI only */ + #endif + {'l', __flagfmt}, + {'n', __countfmt}, + {'o', __ifmt}, + {'p', __ifmt}, + {'r', __errfmt}, + {'s', __strfmt}, + #ifdef PLAN9PORT + {'u', __flagfmt}, + #else + {'u', __ifmt}, + #endif + {'x', __ifmt}, + } }; - int (*fmtdoquote)(int); /* - * __fmtwlock() must be set + * __fmtlock() must be set */ static int __fmtinstall(int c, Fmts f) { - Convfmt *p, *ep; + Convfmt *p; + int i; if(c<=0 || c>=65536) return -1; if(!f) f = __badfmt; - ep = &fmtalloc.fmt[fmtalloc.nfmt]; - for(p=fmtalloc.fmt; pc == c) - break; - - if(p == &fmtalloc.fmt[Maxfmt]) + i = atomic_load(&fmtalloc.nfmt); + if(i == Maxfmt) return -1; - + p = &fmtalloc.fmt[i]; + p->c = c; p->fmt = f; - if(p == ep){ /* installing a new format character */ - fmtalloc.nfmt++; - p->c = c; - } + atomic_store(&fmtalloc.nfmt, i+1); return 0; } @@ -106,43 +111,21 @@ fmtinstall(int c, int (*f)(Fmt*)) { int ret; - __fmtwlock(); + __fmtlock(); ret = __fmtinstall(c, f); - __fmtwunlock(); + __fmtunlock(); return ret; } static Fmts fmtfmt(int c) { - Convfmt *p, *ep, *kp; - - /* conflict-free check - common case */ - __fmtrlock(); - ep = &fmtalloc.fmt[fmtalloc.nfmt]; - for(p=fmtalloc.fmt; pc == c){ - __fmtrunlock(); + Convfmt *p, *ep; + + ep = &fmtalloc.fmt[atomic_load(&fmtalloc.nfmt)]; + for(p=ep; p-- > fmtalloc.fmt; ) + if(p->c == c) return p->fmt; - } - __fmtrunlock(); - - /* is this a predefined format char? */ - for(kp=knownfmt; kp->c; kp++){ - if(kp->c == c){ - __fmtwlock(); - /* double-check fmtinstall didn't happen */ - for(p=fmtalloc.fmt; pc == c){ - __fmtwunlock(); - return p->fmt; - } - } - __fmtinstall(kp->c, kp->fmt); - __fmtwunlock(); - return kp->fmt; - } - } return __badfmt; } diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h index d547184d3..2bafd36d8 100644 --- a/src/lib9/fmt/fmtdef.h +++ b/src/lib9/fmt/fmtdef.h @@ -36,10 +36,8 @@ void * __fmtflush(Fmt *f, void *t, int len); int __fmtpad(Fmt *f, int n); double __fmtpow10(int n); int __fmtrcpy(Fmt *f, const void *vm, int n); -void __fmtrlock(void); -void __fmtrunlock(void); -void __fmtwlock(void); -void __fmtwunlock(void); +void __fmtlock(void); +void __fmtunlock(void); int __ifmt(Fmt *f); int __isInf(double d, int sign); int __isNaN(double d); diff --git a/src/lib9/fmt/fmtlock.c b/src/lib9/fmt/fmtlock.c index eb9cd8451..cabe05f4a 100644 --- a/src/lib9/fmt/fmtlock.c +++ b/src/lib9/fmt/fmtlock.c @@ -5,21 +5,11 @@ #include "fmtdef.h" void -__fmtrlock(void) +__fmtlock(void) { } void -__fmtrunlock(void) -{ -} - -void -__fmtwlock(void) -{ -} - -void -__fmtwunlock(void) +__fmtunlock(void) { } diff --git a/src/lib9/fmtlock2.c b/src/lib9/fmtlock2.c index b755daa38..d711e6d48 100644 --- a/src/lib9/fmtlock2.c +++ b/src/lib9/fmtlock2.c @@ -1,28 +1,16 @@ #include #include -static RWLock fmtlock; +static Lock fmtlock; void -__fmtrlock(void) +__fmtlock(void) { - rlock(&fmtlock); + lock(&fmtlock); } void -__fmtrunlock(void) +__fmtunlock(void) { - runlock(&fmtlock); -} - -void -__fmtwlock(void) -{ - wlock(&fmtlock); -} - -void -__fmtwunlock(void) -{ - wunlock(&fmtlock); + unlock(&fmtlock); } From 40d787ab1276f191bcf030748a954d6708d83228 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 18:05:51 -0500 Subject: [PATCH 170/323] libdraw: send hangup to process when window is lost This matches the Plan 9 behavior a bit better. Fixes #30. --- src/libdraw/mouse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libdraw/mouse.c b/src/libdraw/mouse.c index 64a7f73da..382efae52 100644 --- a/src/libdraw/mouse.c +++ b/src/libdraw/mouse.c @@ -52,8 +52,12 @@ _ioproc(void *arg) one = 1; resized = 0; for(;;){ - if(_displayrdmouse(mc->display, &m, &resized) < 0) + if(_displayrdmouse(mc->display, &m, &resized) < 0) { + if(postnote(PNPROC, getpid(), "hangup") < 0) + fprint(2, "postnote: %r\n"); + sleep(10*1000); threadexitsall("mouse read error"); + } if(resized) send(mc->resizec, &one); send(mc->c, &m); From 1f799495e4aa89be5f32e3fcda8da342f3057f3c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 19:43:32 -0500 Subject: [PATCH 171/323] devdraw: notify window resize promptly on x11 Fixes #339. --- src/cmd/devdraw/devdraw.c | 5 +---- src/cmd/devdraw/devdraw.h | 1 + src/cmd/devdraw/mac-screen.m | 1 - src/cmd/devdraw/srv.c | 18 ++++++++++++++++++ src/cmd/devdraw/x11-screen.c | 16 ++++++++-------- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 086574ef1..b4c373ad3 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -55,10 +55,7 @@ gfx_replacescreenimage(Client *c, Memimage *m) _freememimage(om); } qunlock(&c->drawlk); - - qlock(&c->eventlk); - c->mouse.resized = 1; - qunlock(&c->eventlk); + gfx_mouseresized(c); } static void diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 4980ed905..6829ab32b 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -187,6 +187,7 @@ void gfx_keystroke(Client*, int); void gfx_main(void); void gfx_mousetrack(Client*, int, int, int, uint); void gfx_replacescreenimage(Client*, Memimage*); +void gfx_mouseresized(Client*); void gfx_started(void); // rpc_* routines are called on the RPC thread, diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 5e23c43a7..4bc3f088a 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -518,7 +518,6 @@ - (void)flush:(Rectangle)r { - (void)resizeimg { [self initimg]; gfx_replacescreenimage(self.client, self.img); - [self sendmouse:0]; } - (void)windowDidResize:(NSNotification *)notification { diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index bfeb7c386..c98a865f2 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -394,12 +394,30 @@ matchmouse(Client *c) } } +void +gfx_mouseresized(Client *c) +{ + gfx_mousetrack(c, -1, -1, -1, -1); +} + void gfx_mousetrack(Client *c, int x, int y, int b, uint ms) { Mouse *m; qlock(&c->eventlk); + if(x == -1 && y == -1 && b == -1 && ms == -1) { + Mouse *copy; + // repeat last mouse event for resize + if(c->mouse.ri == 0) + copy = &c->mouse.m[nelem(c->mouse.m)-1]; + else + copy = &c->mouse.m[c->mouse.ri-1]; + x = copy->xy.x; + y = copy->xy.y; + b = copy->buttons; + ms = copy->msec; + } if(x < c->mouserect.min.x) x = c->mouserect.min.x; if(x > c->mouserect.max.x) diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 8026e1e6b..c3a6fa33b 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -44,7 +44,7 @@ static Xwin* newxwin(Client *c) { Xwin *w; - + w = mallocz(sizeof *w, 1); if(w == nil) sysfatal("out of memory"); @@ -59,7 +59,7 @@ static Xwin* findxwin(XDrawable d) { Xwin *w, **l; - + for(l=&_x.windows; (w=*l) != nil; l=&w->next) { if(w->drawable == d) { /* move to front */ @@ -658,7 +658,7 @@ xattach(Client *client, char *label, char *winsize) _x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False); _x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False); } - + atoms[0] = _x.takefocus; atoms[1] = _x.losefocus; XChangeProperty(_x.display, w->drawable, _x.wmprotos, XA_ATOM, 32, @@ -700,7 +700,7 @@ xattach(Client *client, char *label, char *winsize) _x.gcsimplesrc = xgc(w->screenpm, FillStippled, -1); _x.gczero = xgc(w->screenpm, -1, -1); _x.gcreplsrc = xgc(w->screenpm, FillTiled, -1); - + pmid = XCreatePixmap(_x.display, w->drawable, 1, 1, 1); _x.gcfill0 = xgc(pmid, FillSolid, 0); _x.gccopy0 = xgc(pmid, -1, -1); @@ -729,7 +729,7 @@ rpc_setlabel(Client *client, char *label) { Xwin *w = (Xwin*)client->view; XTextProperty name; - + /* * Label and other properties required by ICCCCM. */ @@ -1032,7 +1032,7 @@ _xreplacescreenimage(Client *client) XDrawable pixmap; Rectangle r; Xwin *w; - + w = (Xwin*)client->view; r = w->newscreenr; pixmap = XCreatePixmap(_x.display, w->drawable, Dx(r), Dy(r), _x.depth); @@ -1527,7 +1527,7 @@ __xputsnarf(char *data) { XButtonEvent e; Xwin *w; - + if(strlen(data) >= SnarfSize) return; qlock(&clip.lk); @@ -1730,7 +1730,7 @@ rpc_bouncemouse(Client *c, Mouse m) Xwin *w = (Xwin*)c->view; XButtonEvent e; XWindow dw; - + xlock(); e.type = ButtonPress; e.state = 0; From 5c06214952017d03f5e36bd1fbf25c1969922d80 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 19:46:47 -0500 Subject: [PATCH 172/323] venti/buildindex: fix hang on large indexes Fixes #93. --- src/cmd/venti/srv/buildindex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/venti/srv/buildindex.c b/src/cmd/venti/srv/buildindex.c index faf4b4144..540f0fdc1 100644 --- a/src/cmd/venti/srv/buildindex.c +++ b/src/cmd/venti/srv/buildindex.c @@ -164,7 +164,7 @@ threadmain(int argc, char *argv[]) } /* wait for arena procs to finish */ - for(nfinish=0; nfinish Date: Wed, 15 Jan 2020 08:28:14 +0000 Subject: [PATCH 173/323] soelim: import from Plan9 Add entry in lib/moveplan9.files to trigger relocation during INSTALL. --- bin/soelim | 16 ++++++++++++++++ lib/moveplan9.files | 1 + man/man1/soelim.1 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100755 bin/soelim create mode 100755 man/man1/soelim.1 diff --git a/bin/soelim b/bin/soelim new file mode 100755 index 000000000..2ba3de996 --- /dev/null +++ b/bin/soelim @@ -0,0 +1,16 @@ +#!/usr/local/plan9/bin/rc +# joyless reimplementation of soelim +# the $0 recursion is a bit ugly + +# canonicalise troff commands first with sed into ". so file" form. +# but the space after the dot has to come out; tbl can't cope with it. +# friggin' html macros can be longer than two characters; grrr. +sed '/^[.'']/{ + s/([^\\])\\".*$/\1/ +# s/^(.)[ ]*([^ \\][^ \\])[ ]*/\1 \2 / + s/^(.)[ ]*([^ \\][^ \\])/\1 \2/ +}' $* | awk ' BEGIN { me = "'$0'" } + $1 !~ /^[.'']$/ { print; next } + $2 == "so" { system(me " " $3) ; next } + $2 == "nx" { system(me " " $3) ; exit } + { print }' | sed 's/^([.'']) /\1/' diff --git a/lib/moveplan9.files b/lib/moveplan9.files index 3ce2d5960..165351033 100644 --- a/lib/moveplan9.files +++ b/lib/moveplan9.files @@ -17,6 +17,7 @@ bin/netfilestat bin/quote1 bin/quote2 bin/sig +bin/soelim bin/spell bin/src bin/ssam diff --git a/man/man1/soelim.1 b/man/man1/soelim.1 new file mode 100755 index 000000000..78b4e2ebd --- /dev/null +++ b/man/man1/soelim.1 @@ -0,0 +1,30 @@ +.TH SOELIM 1 +.\" .so in the NAME line confuses the ptx machinery; sorry +.SH NAME +soelim \- preprocess so inclusion commands in troff input +.SH SYNOPSIS +.B soelim +[ +.I files ... +] +.SH DESCRIPTION +.I Soelim +reads the specified files or the standard input and performs +the textual inclusion implied by +.IR troff (1) +directives of the form +.sp +.ti +2m +.B "\&.so some_file +.sp +when they appear at the beginning of input lines. This is useful when +using programs such as +.IR tbl (1) +that do not normally do this, allowing +placement of individual tables or other text objects in separate files +to be run as a part of a large document. +.SH SOURCE +.B /rc/bin/soelim +.SH "SEE ALSO" +.IR deroff (1), +.IR troff (1) From e0434ae42450a56c3817d4e4857cb6d0da8ed548 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 15 Jan 2020 09:59:50 +0000 Subject: [PATCH 174/323] soelim: manpage fixes. --- man/man1/soelim.1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/man/man1/soelim.1 b/man/man1/soelim.1 index 78b4e2ebd..6378d4149 100755 --- a/man/man1/soelim.1 +++ b/man/man1/soelim.1 @@ -13,10 +13,9 @@ reads the specified files or the standard input and performs the textual inclusion implied by .IR troff (1) directives of the form -.sp -.ti +2m +.TP .B "\&.so some_file -.sp +.PP when they appear at the beginning of input lines. This is useful when using programs such as .IR tbl (1) @@ -24,7 +23,7 @@ that do not normally do this, allowing placement of individual tables or other text objects in separate files to be run as a part of a large document. .SH SOURCE -.B /rc/bin/soelim +.B \*9/bin/soelim .SH "SEE ALSO" .IR deroff (1), .IR troff (1) From dc24d309d591eb59168a84f233bb8dfb1795c5a2 Mon Sep 17 00:00:00 2001 From: Oleg Nemanov Date: Wed, 15 Jan 2020 10:57:41 +0300 Subject: [PATCH 175/323] 9pfuse: update errortab --- src/cmd/9pfuse/errstr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/9pfuse/errstr.c b/src/cmd/9pfuse/errstr.c index e3a122e4c..ef5da00f3 100644 --- a/src/cmd/9pfuse/errstr.c +++ b/src/cmd/9pfuse/errstr.c @@ -21,6 +21,7 @@ static Error errortab[] = { { "exist", ENOENT }, { "no such", ENOENT }, { "not found", ENOENT }, + { "not implemented", ENOSYS}, { "input/output", EIO }, { "timeout", ETIMEDOUT }, { "timed out", ETIMEDOUT }, @@ -42,6 +43,7 @@ static Error errortab[] = { { "invalid", EINVAL }, { "read-only", EROFS }, { "read only", EROFS }, + { "stale ", ESTALE}, #ifdef EPROTO { "proto", EPROTO }, #else From a9b462061c05f8cd4e1f85b05522770293c8a468 Mon Sep 17 00:00:00 2001 From: markvanatten Date: Wed, 15 Jan 2020 14:43:01 +0100 Subject: [PATCH 176/323] winwatch: port based Plan 9 winwatch Port of Plan 9's winwatch(1). --- man/man1/winwatch.1 | 57 +++++ src/cmd/rio/mkfile | 2 +- src/cmd/rio/winwatch.c | 538 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 596 insertions(+), 1 deletion(-) create mode 100644 man/man1/winwatch.1 create mode 100644 src/cmd/rio/winwatch.c diff --git a/man/man1/winwatch.1 b/man/man1/winwatch.1 new file mode 100644 index 000000000..afbf541da --- /dev/null +++ b/man/man1/winwatch.1 @@ -0,0 +1,57 @@ +.TH WINWATCH 1 +.SH NAME +winwatch \- monitor rio windows +.SH SYNOPSIS +.B winwatch +[ +.B -e +.I exclude +] [ +.B -f +.I font +] [ +.B -n +] [ +.B -s +] +.SH DESCRIPTION +.I Winwatch +displays the labels of all current +.IR rio (1) +windows, refreshing the display every second. +Right clicking a window's label unhides, raises and gives focus to that window. +Typing +.B q +or +DEL +quits +.IR winwatch . +.PP +If the +.B -e +flag +is given, +windows matching the regular expression +.I exclude +are not shown. +With the +.B -n +option, +the +label is defined as the window’s name instead of its class, +and with +.B -s +the labels are sorted by alphabet (case insensitive) +instead of by order of appearance. +Winwatch is unicode aware. +.SH EXAMPLE +Excluding winwatch and stats from being shown. +.IP +.EX +% winwatch -e '^(winwatch|stats)$' +.EE +.SH SOURCE +.B \*9/src/cmd/winwatch.c +.SH SEE ALSO +.IR rio (1), +.IR regexp (7). diff --git a/src/cmd/rio/mkfile b/src/cmd/rio/mkfile index 8b8ea46a7..20202e22d 100644 --- a/src/cmd/rio/mkfile +++ b/src/cmd/rio/mkfile @@ -16,7 +16,7 @@ RIOFILES=\ CFLAGS=$CFLAGS -DDEBUG HFILES=dat.h fns.h -TARG=rio xshove +TARG=rio winwatch xshove # need to add lib64 when it exists (on x86-64), but # Darwin complains about the nonexistant directory diff --git a/src/cmd/rio/winwatch.c b/src/cmd/rio/winwatch.c new file mode 100644 index 000000000..66ec8cbed --- /dev/null +++ b/src/cmd/rio/winwatch.c @@ -0,0 +1,538 @@ +/* slightly modified from +https://github.com/fhs/misc/blob/master/cmd/winwatch/winwatch.c +so as to deal with memory leaks and certain X errors */ + +#include +#include +#include +#include +#include +#include +#include "../devdraw/x11-inc.h" + +AUTOLIB(X11); + +typedef struct Win Win; +struct Win { + XWindow n; + int dirty; + char *label; + Rectangle r; +}; + +XDisplay *dpy; +XWindow root; +Atom net_active_window; +Reprog *exclude = nil; +Win *win; +int nwin; +int mwin; +int onwin; +int rows, cols; +int sortlabels; +int showwmnames; +Font *font; +Image *lightblue; + +XErrorHandler oldxerrorhandler; + +enum { + PAD = 3, + MARGIN = 5 +}; + +static jmp_buf savebuf; + +int +winwatchxerrorhandler(XDisplay *disp, XErrorEvent *xe) +{ + char buf[100]; + + XGetErrorText(disp, xe->error_code, buf, 100); + fprintf(stderr, "winwatch: X error %s, request code %d\n", buf, + xe->request_code); + XFlush(disp); + XSync(disp, False); + XSetErrorHandler(oldxerrorhandler); + longjmp(savebuf, 1); +} + +void* +erealloc(void *v, ulong n) +{ + v = realloc(v, n); + if (v == nil) + sysfatal("out of memory reallocating"); + return v; +} + +char* +estrdup(char *s) +{ + s = strdup(s); + if (s == nil) + sysfatal("out of memory allocating"); + return s; +} + +char* +getproperty(XWindow w, Atom a) +{ + uchar *p; + int fmt; + Atom type; + ulong n, dummy; + int s; + + n = 100; + p = nil; + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XGetWindowProperty(dpy, w, a, 0, 100L, 0, + AnyPropertyType, &type, &fmt, &n, &dummy, &p); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + + if (s == 0) + return (char *) p; + else { + free(p); + return nil; + } +} + +XWindow +findname(XWindow w) +{ + int i; + uint nxwin; + XWindow dw1, dw2, *xwin; + char *p; + int s; + Atom net_wm_name; + + p = getproperty(w, XA_WM_NAME); + if (p) { + free(p); + return w; + } + + net_wm_name = XInternAtom (dpy, "_NET_WM_NAME", FALSE); + p = getproperty(w, net_wm_name); + if (p) { + free(p); + return w; + } + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XQueryTree(dpy, w, &dw1, &dw2, &xwin, &nxwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + if (s == 0) { + if (xwin != NULL) + XFree(xwin); + return 0; + } + + for (i = 0; i < nxwin; i++) { + w = findname(xwin[i]); + if (w != 0) { + XFree(xwin); + return w; + } + } + + XFree(xwin); + + return 0; +} + +int +wcmp(const void *w1, const void *w2) +{ + return *(XWindow *) w1 - *(XWindow *) w2; +} + +/* unicode-aware case-insensitive strcmp, taken from golang’s gc/subr.c */ + +int +_cistrcmp(char *p, char *q) +{ + Rune rp, rq; + + while(*p || *q) { + if(*p == 0) + return +1; + if(*q == 0) + return -1; + p += chartorune(&rp, p); + q += chartorune(&rq, q); + rp = tolowerrune(rp); + rq = tolowerrune(rq); + if(rp < rq) + return -1; + if(rp > rq) + return +1; + } + return 0; +} + +int +winlabelcmp(const void *w1, const void *w2) +{ + const Win *p1 = (Win *) w1; + const Win *p2 = (Win *) w2; + return _cistrcmp(p1->label, p2->label); +} + +void +refreshwin(void) +{ + XWindow dw1, dw2, *xwin; + XClassHint class; + XWindowAttributes attr; + char *label; + char *wmname; + int i, nw; + uint nxwin; + Status s; + Atom net_wm_name; + + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XQueryTree(dpy, root, &dw1, &dw2, &xwin, &nxwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + if (s == 0) { + if (xwin != NULL) + XFree(xwin); + return; + } + qsort(xwin, nxwin, sizeof(xwin[0]), wcmp); + + nw = 0; + for (i = 0; i < nxwin; i++) { + memset(&attr, 0, sizeof attr); + xwin[i] = findname(xwin[i]); + if (xwin[i] == 0) + continue; + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XGetWindowAttributes(dpy, xwin[i], &attr); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + if (s == 0) + continue; + if (attr.width <= 0 || attr.override_redirect + || attr.map_state != IsViewable) + continue; + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XGetClassHint(dpy, xwin[i], &class); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + if (s == 0) + continue; + + if (exclude != nil && regexec(exclude, class.res_name, nil, 0)) { + free(class.res_name); + free(class.res_class); + continue; + } + + net_wm_name = XInternAtom (dpy, "_NET_WM_NAME", FALSE); + wmname = getproperty(xwin[i], net_wm_name); + + if (wmname == nil) { + wmname = getproperty(xwin[i], XA_WM_NAME); + if (wmname == nil) { + free(class.res_name); + free(class.res_class); + continue; + } + } + + if (showwmnames == 1) + label = wmname; + else + label = class.res_name; + + if (nw < nwin && win[nw].n == xwin[i] + && strcmp(win[nw].label, label) == 0) { + nw++; + free(wmname); + free(class.res_name); + free(class.res_class); + continue; + } + + if (nw < nwin) { + free(win[nw].label); + win[nw].label = nil; + } + + if (nw >= mwin) { + mwin += 8; + win = erealloc(win, mwin * sizeof(win[0])); + } + win[nw].n = xwin[i]; + win[nw].label = estrdup(label); + win[nw].dirty = 1; + win[nw].r = Rect(0, 0, 0, 0); + free(wmname); + free(class.res_name); + free(class.res_class); + nw++; + } + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + XFree(xwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + while (nwin > nw) + free(win[--nwin].label); + nwin = nw; + + if (sortlabels == 1) + qsort(win, nwin, sizeof(struct Win), winlabelcmp); + + return; +} + +void +drawnowin(int i) +{ + Rectangle r; + + r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, + font->height); + r = rectaddpt(rectaddpt + (r, + Pt(MARGIN + (PAD + Dx(r)) * (i / rows), + MARGIN + (PAD + Dy(r)) * (i % rows))), + screen->r.min); + draw(screen, insetrect(r, -1), lightblue, nil, ZP); +} + +void +drawwin(int i) +{ + draw(screen, win[i].r, lightblue, nil, ZP); + _string(screen, addpt(win[i].r.min, Pt(2, 0)), display->black, ZP, + font, win[i].label, nil, strlen(win[i].label), + win[i].r, nil, ZP, SoverD); + border(screen, win[i].r, 1, display->black, ZP); + win[i].dirty = 0; +} + +int +geometry(void) +{ + int i, ncols, z; + Rectangle r; + + z = 0; + rows = (Dy(screen->r) - 2 * MARGIN + PAD) / (font->height + PAD); + if (rows * cols < nwin || rows * cols >= nwin * 2) { + ncols = nwin <= 0 ? 1 : (nwin + rows - 1) / rows; + if (ncols != cols) { + cols = ncols; + z = 1; + } + } + + r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, + font->height); + for (i = 0; i < nwin; i++) + win[i].r = + rectaddpt(rectaddpt + (r, + Pt(MARGIN + (PAD + Dx(r)) * (i / rows), + MARGIN + (PAD + Dy(r)) * (i % rows))), + screen->r.min); + + return z; +} + +void +redraw(Image *screen, int all) +{ + int i; + + all |= geometry(); + if (all) + draw(screen, screen->r, lightblue, nil, ZP); + for (i = 0; i < nwin; i++) + if (all || win[i].dirty) + drawwin(i); + if (!all) + for (; i < onwin; i++) + drawnowin(i); + + onwin = nwin; +} + +void +eresized(int new) +{ + if (new && getwindow(display, Refmesg) < 0) + fprint(2, "can't reattach to window"); + geometry(); + redraw(screen, 1); +} + + +void +selectwin(XWindow win) +{ + XEvent ev; + long mask; + + memset(&ev, 0, sizeof ev); + ev.xclient.type = ClientMessage; + ev.xclient.serial = 0; + ev.xclient.send_event = True; + ev.xclient.message_type = net_active_window; + ev.xclient.window = win; + ev.xclient.format = 32; + mask = SubstructureRedirectMask | SubstructureNotifyMask; + + XSendEvent(dpy, root, False, mask, &ev); + XMapRaised(dpy, win); + XSync(dpy, False); +} + + +void +click(Mouse m) +{ + int i, j; + + if (m.buttons == 0 || (m.buttons & ~4)) + return; + + for (i = 0; i < nwin; i++) + if (ptinrect(m.xy, win[i].r)) + break; + if (i == nwin) + return; + + do + m = emouse(); + while (m.buttons == 4); + + if (m.buttons != 0) { + do + m = emouse(); + while (m.buttons); + return; + } + + for (j = 0; j < nwin; j++) + if (ptinrect(m.xy, win[j].r)) + break; + if (j != i) + return; + + selectwin(win[i].n); +} + +void +usage(void) +{ + fprint(2, + "usage: winwatch [-e exclude] [-W winsize] [-f font] [-n] [-s]\n"); + exits("usage"); +} + +void +main(int argc, char **argv) +{ + char *fontname; + int Etimer; + Event e; + + sortlabels = 0; + showwmnames = 0; + + fontname = "/lib/font/bit/lucsans/unicode.8.font"; + + ARGBEGIN { + case 'W': + winsize = EARGF(usage()); + break; + case 'f': + fontname = EARGF(usage()); + break; + case 'e': + exclude = regcomp(EARGF(usage())); + if (exclude == nil) + sysfatal("Bad regexp"); + break; + case 's': + sortlabels = 1; + break; + case 'n': + showwmnames = 1; + break; + default: + usage(); + } + ARGEND if (argc) + usage(); + + /* moved up from original winwatch.c for p9p because there can be only one but we want to restart when needed */ + einit(Emouse | Ekeyboard); + Etimer = etimer(0, 1000); + + dpy = XOpenDisplay(""); + + if (dpy == nil) + sysfatal("open display: %r"); + + root = DefaultRootWindow(dpy); + net_active_window = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); + + initdraw(0, 0, "winwatch"); + lightblue = allocimagemix(display, DPalebluegreen, DWhite); + if (lightblue == nil) + sysfatal("allocimagemix: %r"); + if ((font = openfont(display, fontname)) == nil) + sysfatal("font '%s' not found", fontname); + + + /* reentry point upon X server errors */ + setjmp(savebuf); + + refreshwin(); + redraw(screen, 1); + + for (;;) { + switch (eread(Emouse | Ekeyboard | Etimer, &e)) { + case Ekeyboard: + if (e.kbdc == 0x7F || e.kbdc == 'q') + exits(0); + break; + case Emouse: + if (e.mouse.buttons) + click(e.mouse); + /* fall through */ + default: /* Etimer */ + refreshwin(); + redraw(screen, 0); + break; + } + } +} From 0ac4bfee32fce9dc336751aa219ca4dbdf3e8ecd Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Wed, 15 Jan 2020 14:15:31 +0000 Subject: [PATCH 177/323] clock: Remove unused static variable in clock.c `struct Tm tms` was set but never referenced; noticed in a compiler warning. Remove it. Signed-off-by: Dan Cross --- src/cmd/draw/clock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cmd/draw/clock.c b/src/cmd/draw/clock.c index b804e1f4e..b5d028b69 100644 --- a/src/cmd/draw/clock.c +++ b/src/cmd/draw/clock.c @@ -25,7 +25,6 @@ redraw(Image *screen) static int rad; int i; int anghr, angmin; - static Tm tms; static Tm ntms; ntm = time(0); @@ -36,7 +35,6 @@ redraw(Image *screen) anghr = 90-(ntms.hour*5 + ntms.min/12)*6; angmin = 90-ntms.min*6; tm = ntm; - tms = ntms; r = screen->r; c = divpt(addpt(r.min, r.max), 2); rad = Dx(r) < Dy(r) ? Dx(r) : Dy(r); From 6510a2d3530132753a6a1dfb2589e9ad82bc271c Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Wed, 15 Jan 2020 14:47:39 +0000 Subject: [PATCH 178/323] winwatch: Plan 9-ify. This is new code, and custom to plan9port. Make it conform more closely to plan9 style. Signed-off-by: Dan Cross --- src/cmd/rio/winwatch.c | 838 ++++++++++++++++++++--------------------- 1 file changed, 412 insertions(+), 426 deletions(-) diff --git a/src/cmd/rio/winwatch.c b/src/cmd/rio/winwatch.c index 66ec8cbed..1a93e78c7 100644 --- a/src/cmd/rio/winwatch.c +++ b/src/cmd/rio/winwatch.c @@ -1,23 +1,25 @@ -/* slightly modified from -https://github.com/fhs/misc/blob/master/cmd/winwatch/winwatch.c -so as to deal with memory leaks and certain X errors */ +/* + * slightly modified from + * https://github.com/fhs/misc/blob/master/cmd/winwatch/winwatch.c + * so as to deal with memory leaks and certain X errors + */ #include #include #include #include #include -#include +#include #include "../devdraw/x11-inc.h" AUTOLIB(X11); typedef struct Win Win; struct Win { - XWindow n; - int dirty; - char *label; - Rectangle r; + XWindow n; + int dirty; + char *label; + Rectangle r; }; XDisplay *dpy; @@ -37,502 +39,486 @@ Image *lightblue; XErrorHandler oldxerrorhandler; enum { - PAD = 3, - MARGIN = 5 + PAD = 3, + MARGIN = 5 }; static jmp_buf savebuf; -int +int winwatchxerrorhandler(XDisplay *disp, XErrorEvent *xe) { - char buf[100]; - - XGetErrorText(disp, xe->error_code, buf, 100); - fprintf(stderr, "winwatch: X error %s, request code %d\n", buf, - xe->request_code); - XFlush(disp); - XSync(disp, False); - XSetErrorHandler(oldxerrorhandler); - longjmp(savebuf, 1); + char buf[100]; + + XGetErrorText(disp, xe->error_code, buf, 100); + fprint(2, "winwatch: X error %s, request code %d\n", + buf, xe->request_code); + XFlush(disp); + XSync(disp, False); + XSetErrorHandler(oldxerrorhandler); + longjmp(savebuf, 1); + return(0); /* Not reached */ } void* erealloc(void *v, ulong n) { - v = realloc(v, n); - if (v == nil) - sysfatal("out of memory reallocating"); - return v; + v = realloc(v, n); + if(v==nil) + sysfatal("out of memory reallocating"); + return v; } char* estrdup(char *s) { - s = strdup(s); - if (s == nil) - sysfatal("out of memory allocating"); - return s; + s = strdup(s); + if(s==nil) + sysfatal("out of memory allocating"); + return(s); } char* getproperty(XWindow w, Atom a) { - uchar *p; - int fmt; - Atom type; - ulong n, dummy; - int s; - - n = 100; - p = nil; - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - s = XGetWindowProperty(dpy, w, a, 0, 100L, 0, - AnyPropertyType, &type, &fmt, &n, &dummy, &p); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - - if (s == 0) - return (char *) p; - else { - free(p); - return nil; - } + uchar *p; + int fmt; + Atom type; + ulong n, dummy; + int s; + + n = 100; + p = nil; + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XGetWindowProperty(dpy, w, a, 0, 100L, 0, + AnyPropertyType, &type, &fmt, &n, &dummy, &p); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + if(s!=0){ + XFree(p); + return(nil); + } + + return((char*)p); } -XWindow +XWindow findname(XWindow w) { - int i; - uint nxwin; - XWindow dw1, dw2, *xwin; - char *p; - int s; - Atom net_wm_name; - - p = getproperty(w, XA_WM_NAME); - if (p) { - free(p); - return w; - } - - net_wm_name = XInternAtom (dpy, "_NET_WM_NAME", FALSE); - p = getproperty(w, net_wm_name); - if (p) { - free(p); - return w; - } - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - s = XQueryTree(dpy, w, &dw1, &dw2, &xwin, &nxwin); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - if (s == 0) { - if (xwin != NULL) - XFree(xwin); - return 0; - } - - for (i = 0; i < nxwin; i++) { - w = findname(xwin[i]); - if (w != 0) { - XFree(xwin); - return w; - } - } - - XFree(xwin); - - return 0; + int i; + uint nxwin; + XWindow dw1, dw2, *xwin; + char *p; + int s; + Atom net_wm_name; + + p = getproperty(w, XA_WM_NAME); + if(p){ + free(p); + return(w); + } + + net_wm_name = XInternAtom(dpy, "_NET_WM_NAME", FALSE); + p = getproperty(w, net_wm_name); + if(p){ + free(p); + return(w); + } + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XQueryTree(dpy, w, &dw1, &dw2, &xwin, &nxwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + if(s == 0) { + if (xwin != NULL) + XFree(xwin); + return 0; + } + + for (i = 0; i < nxwin; i++) { + w = findname(xwin[i]); + if (w != 0) { + XFree(xwin); + return w; + } + } + XFree(xwin); + + return 0; } -int +int wcmp(const void *w1, const void *w2) { - return *(XWindow *) w1 - *(XWindow *) w2; + return *(XWindow *) w1 - *(XWindow *) w2; } /* unicode-aware case-insensitive strcmp, taken from golang’s gc/subr.c */ -int +int _cistrcmp(char *p, char *q) { - Rune rp, rq; - - while(*p || *q) { - if(*p == 0) - return +1; - if(*q == 0) - return -1; - p += chartorune(&rp, p); - q += chartorune(&rq, q); - rp = tolowerrune(rp); - rq = tolowerrune(rq); - if(rp < rq) - return -1; - if(rp > rq) - return +1; - } - return 0; + Rune rp, rq; + + while(*p || *q) { + if(*p == 0) + return +1; + if(*q == 0) + return -1; + p += chartorune(&rp, p); + q += chartorune(&rq, q); + rp = tolowerrune(rp); + rq = tolowerrune(rq); + if(rp < rq) + return -1; + if(rp > rq) + return +1; + } + return 0; } -int +int winlabelcmp(const void *w1, const void *w2) { - const Win *p1 = (Win *) w1; - const Win *p2 = (Win *) w2; - return _cistrcmp(p1->label, p2->label); + const Win *p1 = (Win *) w1; + const Win *p2 = (Win *) w2; + return _cistrcmp(p1->label, p2->label); } -void +void refreshwin(void) { - XWindow dw1, dw2, *xwin; - XClassHint class; - XWindowAttributes attr; - char *label; - char *wmname; - int i, nw; - uint nxwin; - Status s; - Atom net_wm_name; - - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - s = XQueryTree(dpy, root, &dw1, &dw2, &xwin, &nxwin); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - if (s == 0) { - if (xwin != NULL) - XFree(xwin); - return; - } - qsort(xwin, nxwin, sizeof(xwin[0]), wcmp); - - nw = 0; - for (i = 0; i < nxwin; i++) { - memset(&attr, 0, sizeof attr); - xwin[i] = findname(xwin[i]); - if (xwin[i] == 0) - continue; - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - s = XGetWindowAttributes(dpy, xwin[i], &attr); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - if (s == 0) - continue; - if (attr.width <= 0 || attr.override_redirect - || attr.map_state != IsViewable) - continue; - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - s = XGetClassHint(dpy, xwin[i], &class); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - if (s == 0) - continue; - - if (exclude != nil && regexec(exclude, class.res_name, nil, 0)) { - free(class.res_name); - free(class.res_class); - continue; - } - - net_wm_name = XInternAtom (dpy, "_NET_WM_NAME", FALSE); - wmname = getproperty(xwin[i], net_wm_name); - - if (wmname == nil) { - wmname = getproperty(xwin[i], XA_WM_NAME); - if (wmname == nil) { - free(class.res_name); - free(class.res_class); - continue; - } - } - - if (showwmnames == 1) - label = wmname; - else - label = class.res_name; - - if (nw < nwin && win[nw].n == xwin[i] - && strcmp(win[nw].label, label) == 0) { - nw++; - free(wmname); - free(class.res_name); - free(class.res_class); - continue; - } - - if (nw < nwin) { - free(win[nw].label); - win[nw].label = nil; - } - - if (nw >= mwin) { - mwin += 8; - win = erealloc(win, mwin * sizeof(win[0])); - } - win[nw].n = xwin[i]; - win[nw].label = estrdup(label); - win[nw].dirty = 1; - win[nw].r = Rect(0, 0, 0, 0); - free(wmname); - free(class.res_name); - free(class.res_class); - nw++; - } - - oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); - XFree(xwin); - XFlush(dpy); - XSync(dpy, False); - XSetErrorHandler(oldxerrorhandler); - - while (nwin > nw) - free(win[--nwin].label); - nwin = nw; - - if (sortlabels == 1) - qsort(win, nwin, sizeof(struct Win), winlabelcmp); - - return; + XWindow dw1, dw2, *xwin; + XClassHint class; + XWindowAttributes attr; + char *label; + char *wmname; + int i, nw; + uint nxwin; + Status s; + Atom net_wm_name; + + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + s = XQueryTree(dpy, root, &dw1, &dw2, &xwin, &nxwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + if(s==0){ + if(xwin!=NULL) + XFree(xwin); + return; + } + qsort(xwin, nxwin, sizeof(xwin[0]), wcmp); + + nw = 0; + for(i=0; i=mwin){ + mwin += 8; + win = erealloc(win, mwin * sizeof(win[0])); + } + win[nw].n = xwin[i]; + win[nw].label = estrdup(label); + win[nw].dirty = 1; + win[nw].r = Rect(0, 0, 0, 0); + free(wmname); + free(class.res_name); + free(class.res_class); + nw++; + } + + oldxerrorhandler = XSetErrorHandler(winwatchxerrorhandler); + XFree(xwin); + XFlush(dpy); + XSync(dpy, False); + XSetErrorHandler(oldxerrorhandler); + + while(nwin>nw) + free(win[--nwin].label); + nwin = nw; + + if(sortlabels==1) + qsort(win, nwin, sizeof(struct Win), winlabelcmp); } -void +void drawnowin(int i) { - Rectangle r; - - r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, - font->height); - r = rectaddpt(rectaddpt - (r, - Pt(MARGIN + (PAD + Dx(r)) * (i / rows), - MARGIN + (PAD + Dy(r)) * (i % rows))), - screen->r.min); - draw(screen, insetrect(r, -1), lightblue, nil, ZP); + Rectangle r; + + r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, font->height); + r = rectaddpt( + rectaddpt(r, + Pt(MARGIN + (PAD + Dx(r)) * (i / rows), + MARGIN + (PAD + Dy(r)) * (i % rows))), + screen->r.min); + draw(screen, insetrect(r, -1), lightblue, nil, ZP); } -void +void drawwin(int i) { - draw(screen, win[i].r, lightblue, nil, ZP); - _string(screen, addpt(win[i].r.min, Pt(2, 0)), display->black, ZP, - font, win[i].label, nil, strlen(win[i].label), - win[i].r, nil, ZP, SoverD); - border(screen, win[i].r, 1, display->black, ZP); - win[i].dirty = 0; + draw(screen, win[i].r, lightblue, nil, ZP); + _string(screen, addpt(win[i].r.min, Pt(2, 0)), display->black, ZP, + font, win[i].label, nil, strlen(win[i].label), + win[i].r, nil, ZP, SoverD); + border(screen, win[i].r, 1, display->black, ZP); + win[i].dirty = 0; } -int +int geometry(void) { - int i, ncols, z; - Rectangle r; - - z = 0; - rows = (Dy(screen->r) - 2 * MARGIN + PAD) / (font->height + PAD); - if (rows * cols < nwin || rows * cols >= nwin * 2) { - ncols = nwin <= 0 ? 1 : (nwin + rows - 1) / rows; - if (ncols != cols) { - cols = ncols; - z = 1; - } - } - - r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, - font->height); - for (i = 0; i < nwin; i++) - win[i].r = - rectaddpt(rectaddpt - (r, - Pt(MARGIN + (PAD + Dx(r)) * (i / rows), - MARGIN + (PAD + Dy(r)) * (i % rows))), - screen->r.min); - - return z; + int i, ncols, z; + Rectangle r; + + z = 0; + rows = (Dy(screen->r) - 2 * MARGIN + PAD) / (font->height + PAD); + if(rows*cols=nwin*2){ + ncols = 1; + if(nwin>0) + ncols = (nwin + rows - 1) / rows; + if(ncols!=cols){ + cols = ncols; + z = 1; + } + } + + r = Rect(0, 0, (Dx(screen->r) - 2 * MARGIN + PAD) / cols - PAD, font->height); + for(i=0; ir.min); + + return z; } -void +void redraw(Image *screen, int all) { - int i; - - all |= geometry(); - if (all) - draw(screen, screen->r, lightblue, nil, ZP); - for (i = 0; i < nwin; i++) - if (all || win[i].dirty) - drawwin(i); - if (!all) - for (; i < onwin; i++) - drawnowin(i); - - onwin = nwin; + int i; + + all |= geometry(); + if(all) + draw(screen, screen->r, lightblue, nil, ZP); + for(i=0; i Date: Wed, 15 Jan 2020 11:54:20 +0000 Subject: [PATCH 179/323] compress: import Plan9 compress Add #define USED(x)... boilerplate compress: import Plan9 manpage. --- man/man1/compress.1 | 237 +++++++ src/cmd/compress/compress.c | 1274 +++++++++++++++++++++++++++++++++++ src/cmd/compress/mkfile | 15 + 3 files changed, 1526 insertions(+) create mode 100644 man/man1/compress.1 create mode 100755 src/cmd/compress/compress.c create mode 100755 src/cmd/compress/mkfile diff --git a/man/man1/compress.1 b/man/man1/compress.1 new file mode 100644 index 000000000..7dda3e18b --- /dev/null +++ b/man/man1/compress.1 @@ -0,0 +1,237 @@ +.TH COMPRESS 1 +.SH NAME +compress, uncompress, zcat \- compress and expand data +.SH SYNOPSIS +.B compress +[ +.B \-f +] [ +.B \-v +] [ +.B \-c +] [ +.B \-V +] [ +.B \-b +.I bits +] [ +.I "name \&..." +] +.PP +.B uncompress +[ +.B \-f +] [ +.B \-v +] [ +.B \-c +] [ +.B \-V +] [ +.I "name \&..." +] +.PP +.B zcat +[ +.B \-V +] [ +.I "name \&..." +] +.SH DESCRIPTION +.I Compress +reduces the size of the named files using adaptive Lempel-Ziv coding. +Whenever possible, +each file is replaced by one with the extension +.B "\&.Z," +while keeping the same ownership modes, access and modification times. +If no files are specified, the standard input is compressed to the +standard output. +Compressed files can be restored to their original form using +.I uncompress +or +.I zcat. +.PP +The +.B \-f +option will force compression of +.I name. +This is useful for compressing an entire directory, +even if some of the files do not actually shrink. +If +.B \-f +is not given and +.I compress +is run in the foreground, +the user is prompted as to whether an existing file should be overwritten. +.PP +The +.B \-c +option makes +.I compress/uncompress +write to the standard output; no files are changed. +The nondestructive behavior of +.I zcat +is identical to that of +.I uncompress +.B \-c. +.PP +.I Compress +uses the modified Lempel-Ziv algorithm popularized in +"A Technique for High Performance Data Compression", +Terry A. Welch, +.I "IEEE Computer," +vol. 17, no. 6 (June 1984), pp. 8-19. +Common substrings in the file are first replaced by 9-bit codes 257 and up. +When code 512 is reached, the algorithm switches to 10-bit codes and +continues to use more bits until the +limit specified by the +.B \-b +flag is reached (default 16). +.I Bits +must be between 9 and 16. The default can be changed in the source to allow +.I compress +to be run on a smaller machine. +.PP +After the +.I bits +limit is attained, +.I compress +periodically checks the compression ratio. If it is increasing, +.I compress +continues to use the existing code dictionary. However, +if the compression ratio decreases, +.I compress +discards the table of substrings and rebuilds it from scratch. This allows +the algorithm to adapt to the next "block" of the file. +.PP +Note that the +.B \-b +flag is omitted for +.I uncompress, +since the +.I bits +parameter specified during compression +is encoded within the output, along with +a magic number to ensure that neither decompression of random data nor +recompression of compressed data is attempted. +.PP +.ne 8 +The amount of compression obtained depends on the size of the +input, the number of +.I bits +per code, and the distribution of common substrings. +Typically, text such as source code or English +is reduced by 50\-60%. +Compression is generally much better than that achieved by +Huffman coding (as used in +.IR pack ), +or adaptive Huffman coding +.RI ( compact ), +and takes less time to compute. +.PP +Under the +.B \-v +option, +a message is printed yielding the percentage of +reduction for each file compressed. +.PP +If the +.B \-V +option is specified, the current version and compile options are printed on +stderr. +.PP +Exit status is normally 0; +if the last file is larger after (attempted) compression, the status is 2; +if an error occurs, exit status is 1. +.SH "SEE ALSO" +pack(1), compact(1) +.SH "DIAGNOSTICS" +Usage: compress [\-dfvcV] [\-b maxbits] [file ...] +.in +8 +Invalid options were specified on the command line. +.in -8 +Missing maxbits +.in +8 +Maxbits must follow +.BR \-b \. +.in -8 +.IR file : +not in compressed format +.in +8 +The file specified to +.I uncompress +has not been compressed. +.in -8 +.IR file : +compressed with +.I xx +bits, can only handle +.I yy +bits +.in +8 +.I File +was compressed by a program that could deal with +more +.I bits +than the compress code on this machine. +Recompress the file with smaller +.IR bits \. +.in -8 +.IR file : +already has .Z suffix -- no change +.in +8 +The file is assumed to be already compressed. +Rename the file and try again. +.in -8 +.IR file : +filename too long to tack on .Z +.in +8 +The file cannot be compressed because its name is longer than +12 characters. +Rename and try again. +This message does not occur on BSD systems. +.in -8 +.I file +already exists; do you wish to overwrite (y or n)? +.in +8 +Respond "y" if you want the output file to be replaced; "n" if not. +.in -8 +uncompress: corrupt input +.in +8 +A SIGSEGV violation was detected which usually means that the input file has +been corrupted. +.in -8 +Compression: +.I "xx.xx%" +.in +8 +Percentage of the input saved by compression. +(Relevant only for +.BR \-v \.) +.in -8 +-- not a regular file: unchanged +.in +8 +When the input file is not a regular file, +(e.g. a directory), it is +left unaltered. +.in -8 +-- has +.I xx +other links: unchanged +.in +8 +The input file has links; it is left unchanged. See +.IR ln "(1)" +for more information. +.in -8 +-- file unchanged +.in +8 +No savings is achieved by +compression. The input remains virgin. +.in -8 +.SH SOURCE +.B \*9/src/cmd/compress/compress.c +.SH "BUGS" +Although compressed files are compatible between machines with large memory, +.BR \-b \12 +should be used for file transfer to architectures with +a small process data space (64KB or less, as exhibited by the DEC PDP +series, the Intel 80286, etc.) diff --git a/src/cmd/compress/compress.c b/src/cmd/compress/compress.c new file mode 100755 index 000000000..808762cad --- /dev/null +++ b/src/cmd/compress/compress.c @@ -0,0 +1,1274 @@ +/* + * compress - File compression ala IEEE Computer, June 1984. + * + * Algorithm from "A Technique for High Performance Data Compression", + * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19. + * + * Usage: compress [-dfvc] [-b bits] [file ...] + * Inputs: + * -b: limit the max number of bits/code. + * -c: write output on stdout, don't remove original. + * -d: decompress instead. + * -f: Forces output file to be generated, even if one already + * exists, and even if no space is saved by compressing. + * If -f is not used, the user will be prompted if stdin is + * a tty, otherwise, the output file will not be overwritten. + * -v: Write compression statistics + * + * file ...: Files to be compressed. If none specified, stdin is used. + * Outputs: + * file.Z: Compressed form of file with same mode, owner, and utimes + * or stdout (if stdin used as input) + * + * Assumptions: + * When filenames are given, replaces with the compressed version + * (.Z suffix) only if the file decreases in size. + * Algorithm: + * Modified Lempel-Ziv method (LZW). Basically finds common + * substrings and replaces them with a variable size code. This is + * deterministic, and can be done on the fly. Thus, the decompression + * procedure needs no input table, but tracks the way the table was built. + + * Authors: Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) + * Jim McKie (decvax!mcvax!jim) + * Steve Davies (decvax!vax135!petsd!peora!srd) + * Ken Turkowski (decvax!decwrl!turtlevax!ken) + * James A. Woods (decvax!ihnp4!ames!jaw) + * Joe Orost (decvax!vax135!petsd!joe) + */ + +#ifndef USED +# define USED(x) if(x);else +#endif + +#define _PLAN9_SOURCE +#define _BSD_EXTENSION +#define _POSIX_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define min(a,b) ((a>b) ? b : a) + +#define BITS 16 +#define HSIZE 69001 /* 95% occupancy */ + +/* + * a code_int must be able to hold 2**BITS values of type int, and also -1 + */ +typedef long code_int; +typedef long count_int; + +static char rcs_ident[] = "$Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $"; + +uchar magic_header[] = { 0x1F, 0x9D }; /* 1F 9D */ + +/* Defines for third byte of header */ +#define BIT_MASK 0x1f +#define BLOCK_MASK 0x80 +/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is + a fourth header byte (for expansion). +*/ +#define INIT_BITS 9 /* initial number of bits/code */ + +#define ARGVAL() (*++(*argv) || (--argc && *++argv)) + +int n_bits; /* number of bits/code */ +int maxbits = BITS; /* user settable max # bits/code */ +code_int maxcode; /* maximum code, given n_bits */ +code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */ + +#define MAXCODE(n_bits) ((1 << (n_bits)) - 1) + +count_int htab[HSIZE]; +ushort codetab[HSIZE]; + +#define htabof(i) htab[i] +#define codetabof(i) codetab[i] + +code_int hsize = HSIZE; /* for dynamic table sizing */ +count_int fsize; + +/* + * To save much memory, we overlay the table used by compress() with those + * used by decompress(). The tab_prefix table is the same size and type + * as the codetab. The tab_suffix table needs 2**BITS characters. We + * get this from the beginning of htab. The output stack uses the rest + * of htab, and contains characters. There is plenty of room for any + * possible stack (stack used to be 8000 characters). + */ + +#define tab_prefixof(i) codetabof(i) +#define tab_suffixof(i) ((uchar *)(htab))[i] +#define de_stack ((uchar *)&tab_suffixof(1< 0; argc--, argv++) { + if (**argv == '-') { /* A flag argument */ + while (*++(*argv)) { /* Process all flags in this arg */ + switch (**argv) { + case 'C': + block_compress = 0; + break; +#ifdef DEBUG + case 'D': + debug = 1; + break; + case 'V': + verbose = 1; + version(); + break; +#else + case 'V': + version(); + break; +#endif + case 'b': + if (!ARGVAL()) { + fprintf(stderr, "Missing maxbits\n"); + Usage(); + exit(1); + } + maxbits = atoi(*argv); + goto nextarg; + case 'c': + zcat_flg = 1; + break; + case 'd': + do_decomp = 1; + break; + case 'f': + case 'F': + overwrite = 1; + force = 1; + break; + case 'n': + nomagic = 1; + break; + case 'q': + quiet = 1; + break; + case 'v': + quiet = 0; + break; + default: + fprintf(stderr, "Unknown flag: '%c'; ", **argv); + Usage(); + exit(1); + } + } + } else { /* Input file name */ + *fileptr++ = *argv; /* Build input file list */ + *fileptr = NULL; + /* process nextarg; */ + } +nextarg: + continue; + } + + if(maxbits < INIT_BITS) maxbits = INIT_BITS; + if (maxbits > BITS) maxbits = BITS; + maxmaxcode = 1 << maxbits; + + if (*filelist != NULL) { + for (fileptr = filelist; *fileptr; fileptr++) { + exit_stat = 0; + if (do_decomp != 0) { /* DECOMPRESSION */ + /* Check for .Z suffix */ + if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") != 0) { + /* No .Z: tack one on */ + strcpy(tempname, *fileptr); + strcat(tempname, ".Z"); + *fileptr = tempname; + } + /* Open input file */ + if ((freopen(*fileptr, "r", stdin)) == NULL) { + perror(*fileptr); + continue; + } + /* Check the magic number */ + if (nomagic == 0) { + if ((getchar() != (magic_header[0] & 0xFF)) + || (getchar() != (magic_header[1] & 0xFF))) { + fprintf(stderr, "%s: not in compressed format\n", + *fileptr); + continue; + } + maxbits = getchar(); /* set -b from file */ + block_compress = maxbits & BLOCK_MASK; + maxbits &= BIT_MASK; + maxmaxcode = 1 << maxbits; + if(maxbits > BITS) { + fprintf(stderr, + "%s: compressed with %d bits, can only handle %d bits\n", + *fileptr, maxbits, BITS); + continue; + } + } + /* Generate output filename */ + strcpy(ofname, *fileptr); + ofname[strlen(*fileptr) - 2] = '\0'; /* Strip off .Z */ + } else { /* COMPRESSION */ + if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") == 0) { + fprintf(stderr, + "%s: already has .Z suffix -- no change\n", + *fileptr); + continue; + } + /* Open input file */ + if ((freopen(*fileptr, "r", stdin)) == NULL) { + perror(*fileptr); + continue; + } + (void) stat(*fileptr, &statbuf); + fsize = (long) statbuf.st_size; + /* + * tune hash table size for small files -- ad hoc, + * but the sizes match earlier #defines, which + * serve as upper bounds on the number of output codes. + */ + hsize = HSIZE; + if (fsize < (1 << 12)) + hsize = min(5003, HSIZE); + else if (fsize < (1 << 13)) + hsize = min(9001, HSIZE); + else if (fsize < (1 << 14)) + hsize = min (18013, HSIZE); + else if (fsize < (1 << 15)) + hsize = min (35023, HSIZE); + else if (fsize < 47000) + hsize = min (50021, HSIZE); + + /* Generate output filename */ + strcpy(ofname, *fileptr); +#ifndef BSD4_2 + if ((cp=strrchr(ofname,'/')) != NULL) + cp++; + else + cp = ofname; + /* + *** changed 12 to 25; should be NAMELEN-3, but I don't want + * to fight the headers. ehg 5 Nov 92 ** + */ + if (strlen(cp) > 25) { + fprintf(stderr, "%s: filename too long to tack on .Z\n", + cp); + continue; + } +#endif + strcat(ofname, ".Z"); + } + /* Check for overwrite of existing file */ + if (overwrite == 0 && zcat_flg == 0 && + stat(ofname, &statbuf) == 0) { + char response[2]; + + response[0] = 'n'; + fprintf(stderr, "%s already exists;", ofname); + if (foreground()) { + fprintf(stderr, + " do you wish to overwrite %s (y or n)? ", + ofname); + fflush(stderr); + (void) read(2, response, 2); + while (response[1] != '\n') + if (read(2, response+1, 1) < 0) { + /* Ack! */ + perror("stderr"); + break; + } + } + if (response[0] != 'y') { + fprintf(stderr, "\tnot overwritten\n"); + continue; + } + } + if(zcat_flg == 0) { /* Open output file */ + if (freopen(ofname, "w", stdout) == NULL) { + perror(ofname); + continue; + } + if(!quiet) + fprintf(stderr, "%s: ", *fileptr); + } + + /* Actually do the compression/decompression */ + if (do_decomp == 0) + compress(); +#ifndef DEBUG + else + decompress(); +#else + else if (debug == 0) + decompress(); + else + printcodes(); + if (verbose) + dump_tab(); +#endif /* DEBUG */ + if(zcat_flg == 0) { + copystat(*fileptr, ofname); /* Copy stats */ + if (exit_stat == 1 || !quiet) + putc('\n', stderr); + } + } + } else { /* Standard input */ + if (do_decomp == 0) { + compress(); +#ifdef DEBUG + if(verbose) + dump_tab(); +#endif + if(!quiet) + putc('\n', stderr); + } else { + /* Check the magic number */ + if (nomagic == 0) { + if ((getchar()!=(magic_header[0] & 0xFF)) + || (getchar()!=(magic_header[1] & 0xFF))) { + fprintf(stderr, "stdin: not in compressed format\n"); + exit(1); + } + maxbits = getchar(); /* set -b from file */ + block_compress = maxbits & BLOCK_MASK; + maxbits &= BIT_MASK; + maxmaxcode = 1 << maxbits; + fsize = 100000; /* assume stdin large for USERMEM */ + if(maxbits > BITS) { + fprintf(stderr, + "stdin: compressed with %d bits, can only handle %d bits\n", + maxbits, BITS); + exit(1); + } + } +#ifndef DEBUG + decompress(); +#else + if (debug == 0) + decompress(); + else + printcodes(); + if (verbose) + dump_tab(); +#endif /* DEBUG */ + } + } + exit(exit_stat); + return 0; +} + +static int offset; +long in_count = 1; /* length of input */ +long bytes_out; /* length of compressed output */ +long out_count = 0; /* # of codes output (for debugging) */ + +/* + * compress stdin to stdout + * + * Algorithm: use open addressing double hashing (no chaining) on the + * prefix code / next character combination. We do a variant of Knuth's + * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime + * secondary probe. Here, the modular division first probe is gives way + * to a faster exclusive-or manipulation. Also do block compression with + * an adaptive reset, whereby the code table is cleared when the compression + * ratio decreases, but after the table fills. The variable-length output + * codes are re-sized at this point, and a special CLEAR code is generated + * for the decompressor. Late addition: construct the table according to + * file size for noticeable speed improvement on small files. Please direct + * questions about this implementation to ames!jaw. + */ +void +compress(void) +{ + code_int ent, hsize_reg; + code_int i; + int c, disp, hshift; + long fcode; + + if (nomagic == 0) { + putchar(magic_header[0]); + putchar(magic_header[1]); + putchar((char)(maxbits | block_compress)); + if(ferror(stdout)) + writeerr(); + } + offset = 0; + bytes_out = 3; /* includes 3-byte header mojo */ + out_count = 0; + clear_flg = 0; + ratio = 0; + in_count = 1; + checkpoint = CHECK_GAP; + maxcode = MAXCODE(n_bits = INIT_BITS); + free_ent = (block_compress? FIRST: 256); + + ent = getchar (); + + hshift = 0; + for (fcode = (long)hsize; fcode < 65536L; fcode *= 2) + hshift++; + hshift = 8 - hshift; /* set hash code range bound */ + + hsize_reg = hsize; + cl_hash( (count_int) hsize_reg); /* clear hash table */ + + while ((c = getchar()) != EOF) { + in_count++; + fcode = (long) (((long) c << maxbits) + ent); + i = ((c << hshift) ^ ent); /* xor hashing */ + + if (htabof (i) == fcode) { + ent = codetabof(i); + continue; + } else if ((long)htabof(i) < 0 ) /* empty slot */ + goto nomatch; + disp = hsize_reg - i; /* secondary hash (after G. Knott) */ + if (i == 0) + disp = 1; +probe: + if ((i -= disp) < 0) + i += hsize_reg; + + if (htabof (i) == fcode) { + ent = codetabof(i); + continue; + } + if ((long)htabof(i) > 0) + goto probe; +nomatch: + output((code_int)ent); + out_count++; + ent = c; + if (free_ent < maxmaxcode) { + codetabof(i) = free_ent++; /* code -> hashtable */ + htabof(i) = fcode; + } else if ((count_int)in_count >= checkpoint && block_compress) + cl_block (); + } + /* + * Put out the final code. + */ + output( (code_int)ent ); + out_count++; + output( (code_int)-1 ); + + /* + * Print out stats on stderr + */ + if(zcat_flg == 0 && !quiet) { +#ifdef DEBUG + fprintf( stderr, + "%ld chars in, %ld codes (%ld bytes) out, compression factor: ", + in_count, out_count, bytes_out ); + prratio( stderr, in_count, bytes_out ); + fprintf( stderr, "\n"); + fprintf( stderr, "\tCompression as in compact: " ); + prratio( stderr, in_count-bytes_out, in_count ); + fprintf( stderr, "\n"); + fprintf( stderr, "\tLargest code (of last block) was %d (%d bits)\n", + free_ent - 1, n_bits ); +#else /* !DEBUG */ + fprintf( stderr, "Compression: " ); + prratio( stderr, in_count-bytes_out, in_count ); +#endif /* DEBUG */ + } + if(bytes_out > in_count) /* exit(2) if no savings */ + exit_stat = 2; +} + +/* + * TAG( output ) + * + * Output the given code. + * Inputs: + * code: A n_bits-bit integer. If == -1, then EOF. This assumes + * that n_bits =< (long)wordsize - 1. + * Outputs: + * Outputs code to the file. + * Assumptions: + * Chars are 8 bits long. + * Algorithm: + * Maintain a BITS character long buffer (so that 8 codes will + * fit in it exactly). When the buffer fills up empty it and start over. + */ + +static char buf[BITS]; + +uchar lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00}; +uchar rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; + +void +output( code ) +code_int code; +{ +#ifdef DEBUG + static int col = 0; +#endif + int r_off = offset, bits= n_bits; + char *bp = buf; + +#ifdef DEBUG + if (verbose) + fprintf(stderr, "%5d%c", code, + (col+=6) >= 74? (col = 0, '\n'): ' '); +#endif + if (code >= 0) { + /* + * byte/bit numbering on the VAX is simulated by the + * following code + */ + /* + * Get to the first byte. + */ + bp += (r_off >> 3); + r_off &= 7; + /* + * Since code is always >= 8 bits, only need to mask the first + * hunk on the left. + */ + *bp = (*bp & rmask[r_off]) | (code << r_off) & lmask[r_off]; + bp++; + bits -= 8 - r_off; + code >>= 8 - r_off; + /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ + if ( bits >= 8 ) { + *bp++ = code; + code >>= 8; + bits -= 8; + } + /* Last bits. */ + if(bits) + *bp = code; + + offset += n_bits; + if ( offset == (n_bits << 3) ) { + bp = buf; + bits = n_bits; + bytes_out += bits; + do { + putchar(*bp++); + } while(--bits); + offset = 0; + } + + /* + * If the next entry is going to be too big for the code size, + * then increase it, if possible. + */ + if ( free_ent > maxcode || (clear_flg > 0)) { + /* + * Write the whole buffer, because the input side won't + * discover the size increase until after it has read it. + */ + if ( offset > 0 ) { + if( fwrite( buf, 1, n_bits, stdout ) != n_bits) + writeerr(); + bytes_out += n_bits; + } + offset = 0; + + if ( clear_flg ) { + maxcode = MAXCODE (n_bits = INIT_BITS); + clear_flg = 0; + } else { + n_bits++; + if ( n_bits == maxbits ) + maxcode = maxmaxcode; + else + maxcode = MAXCODE(n_bits); + } +#ifdef DEBUG + if ( debug ) { + fprintf(stderr, + "\nChange to %d bits\n", n_bits); + col = 0; + } +#endif + } + } else { + /* + * At EOF, write the rest of the buffer. + */ + if ( offset > 0 ) + fwrite( buf, 1, (offset + 7) / 8, stdout ); + bytes_out += (offset + 7) / 8; + offset = 0; + fflush( stdout ); +#ifdef DEBUG + if ( verbose ) + fprintf( stderr, "\n" ); +#endif + if( ferror( stdout ) ) + writeerr(); + } +} + +/* + * Decompress stdin to stdout. This routine adapts to the codes in the + * file building the "string" table on-the-fly; requiring no table to + * be stored in the compressed file. The tables used herein are shared + * with those of the compress() routine. See the definitions above. + */ +void +decompress(void) +{ + int finchar; + code_int code, oldcode, incode; + uchar *stackp; + + /* + * As above, initialize the first 256 entries in the table. + */ + maxcode = MAXCODE(n_bits = INIT_BITS); + for (code = 255; code >= 0; code--) { + tab_prefixof(code) = 0; + tab_suffixof(code) = (uchar)code; + } + free_ent = (block_compress? FIRST: 256); + + finchar = oldcode = getcode(); + if(oldcode == -1) /* EOF already? */ + return; /* Get out of here */ + putchar((char)finchar); /* first code must be 8 bits = char */ + if(ferror(stdout)) /* Crash if can't write */ + writeerr(); + stackp = de_stack; + + while ((code = getcode()) > -1) { + if ((code == CLEAR) && block_compress) { + for (code = 255; code >= 0; code--) + tab_prefixof(code) = 0; + clear_flg = 1; + free_ent = FIRST - 1; + if ((code = getcode()) == -1) /* O, untimely death! */ + break; + } + incode = code; + /* + * Special case for KwKwK string. + */ + if (code >= free_ent) { + *stackp++ = finchar; + code = oldcode; + } + + /* + * Generate output characters in reverse order + */ + while (code >= 256) { + *stackp++ = tab_suffixof(code); + code = tab_prefixof(code); + } + *stackp++ = finchar = tab_suffixof(code); + + /* + * And put them out in forward order + */ + do { + putchar(*--stackp); + } while (stackp > de_stack); + + /* + * Generate the new entry. + */ + if ( (code=free_ent) < maxmaxcode ) { + tab_prefixof(code) = (ushort)oldcode; + tab_suffixof(code) = finchar; + free_ent = code+1; + } + /* + * Remember previous code. + */ + oldcode = incode; + } + fflush(stdout); + if(ferror(stdout)) + writeerr(); +} + +/* + * TAG( getcode ) + * + * Read one code from the standard input. If EOF, return -1. + * Inputs: + * stdin + * Outputs: + * code or -1 is returned. + */ +code_int +getcode() +{ + int r_off, bits; + code_int code; + static int offset = 0, size = 0; + static uchar buf[BITS]; + uchar *bp = buf; + + if ( clear_flg > 0 || offset >= size || free_ent > maxcode ) { + /* + * If the next entry will be too big for the current code + * size, then we must increase the size. This implies reading + * a new buffer full, too. + */ + if ( free_ent > maxcode ) { + n_bits++; + if ( n_bits == maxbits ) + maxcode = maxmaxcode; /* won't get any bigger now */ + else + maxcode = MAXCODE(n_bits); + } + if ( clear_flg > 0) { + maxcode = MAXCODE(n_bits = INIT_BITS); + clear_flg = 0; + } + size = fread(buf, 1, n_bits, stdin); + if (size <= 0) + return -1; /* end of file */ + offset = 0; + /* Round size down to integral number of codes */ + size = (size << 3) - (n_bits - 1); + } + r_off = offset; + bits = n_bits; + /* + * Get to the first byte. + */ + bp += (r_off >> 3); + r_off &= 7; + /* Get first part (low order bits) */ + code = (*bp++ >> r_off); + bits -= (8 - r_off); + r_off = 8 - r_off; /* now, offset into code word */ + /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ + if (bits >= 8) { + code |= *bp++ << r_off; + r_off += 8; + bits -= 8; + } + /* high order bits. */ + code |= (*bp & rmask[bits]) << r_off; + offset += n_bits; + return code; +} + +#ifdef DEBUG +printcodes() +{ + /* + * Just print out codes from input file. For debugging. + */ + code_int code; + int col = 0, bits; + + bits = n_bits = INIT_BITS; + maxcode = MAXCODE(n_bits); + free_ent = ((block_compress) ? FIRST : 256 ); + while ( ( code = getcode() ) >= 0 ) { + if ( (code == CLEAR) && block_compress ) { + free_ent = FIRST - 1; + clear_flg = 1; + } + else if ( free_ent < maxmaxcode ) + free_ent++; + if ( bits != n_bits ) { + fprintf(stderr, "\nChange to %d bits\n", n_bits ); + bits = n_bits; + col = 0; + } + fprintf(stderr, "%5d%c", code, (col+=6) >= 74 ? (col = 0, '\n') : ' ' ); + } + putc( '\n', stderr ); + exit( 0 ); +} + +code_int sorttab[1<= 0) { + sorttab[codetabof(i)] = i; + } + } + first = block_compress ? FIRST : 256; + for(i = first; i < free_ent; i++) { + fprintf(stderr, "%5d: \"", i); + de_stack[--stack_top] = '\n'; + de_stack[--stack_top] = '"'; + stack_top = in_stack((htabof(sorttab[i])>>maxbits)&0xff, + stack_top); + for(ent=htabof(sorttab[i]) & ((1< 256; + ent=htabof(sorttab[ent]) & ((1<> maxbits, + stack_top); + } + stack_top = in_stack(ent, stack_top); + fwrite( &de_stack[stack_top], 1, STACK_SIZE-stack_top, stderr); + stack_top = STACK_SIZE; + } + } else if(!debug) { /* decompressing */ + + for ( i = 0; i < free_ent; i++ ) { + ent = i; + c = tab_suffixof(ent); + if ( isascii(c) && isprint(c) ) + fprintf( stderr, "%5d: %5d/'%c' \"", + ent, tab_prefixof(ent), c ); + else + fprintf( stderr, "%5d: %5d/\\%03o \"", + ent, tab_prefixof(ent), c ); + de_stack[--stack_top] = '\n'; + de_stack[--stack_top] = '"'; + for ( ; ent != NULL; + ent = (ent >= FIRST ? tab_prefixof(ent) : NULL) ) { + stack_top = in_stack(tab_suffixof(ent), stack_top); + } + fwrite( &de_stack[stack_top], 1, STACK_SIZE - stack_top, stderr ); + stack_top = STACK_SIZE; + } + } +} + +int +in_stack(int c, int stack_top) +{ + if ( (isascii(c) && isprint(c) && c != '\\') || c == ' ' ) { + de_stack[--stack_top] = c; + } else { + switch( c ) { + case '\n': de_stack[--stack_top] = 'n'; break; + case '\t': de_stack[--stack_top] = 't'; break; + case '\b': de_stack[--stack_top] = 'b'; break; + case '\f': de_stack[--stack_top] = 'f'; break; + case '\r': de_stack[--stack_top] = 'r'; break; + case '\\': de_stack[--stack_top] = '\\'; break; + default: + de_stack[--stack_top] = '0' + c % 8; + de_stack[--stack_top] = '0' + (c / 8) % 8; + de_stack[--stack_top] = '0' + c / 64; + break; + } + de_stack[--stack_top] = '\\'; + } + return stack_top; +} +#endif /* DEBUG */ + +void +writeerr(void) +{ + perror(ofname); + unlink(ofname); + exit(1); +} + +void +copystat(ifname, ofname) +char *ifname, *ofname; +{ + int mode; + time_t timep[2]; /* should be struct utimbuf */ + struct stat statbuf; + + fclose(stdout); + if (stat(ifname, &statbuf)) { /* Get stat on input file */ + perror(ifname); + return; + } + if (!S_ISREG(statbuf.st_mode)) { + if (quiet) + fprintf(stderr, "%s: ", ifname); + fprintf(stderr, " -- not a regular file: unchanged"); + exit_stat = 1; + } else if (exit_stat == 2 && !force) { + /* No compression: remove file.Z */ + if (!quiet) + fprintf(stderr, " -- file unchanged"); + } else { /* Successful Compression */ + exit_stat = 0; + mode = statbuf.st_mode & 0777; + if (chmod(ofname, mode)) /* Copy modes */ + perror(ofname); + /* Copy ownership */ + chown(ofname, statbuf.st_uid, statbuf.st_gid); + timep[0] = statbuf.st_atime; + timep[1] = statbuf.st_mtime; + /* Update last accessed and modified times */ + utime(ofname, (struct utimbuf *)timep); +// if (unlink(ifname)) /* Remove input file */ +// perror(ifname); + return; /* success */ + } + + /* Unsuccessful return -- one of the tests failed */ + if (unlink(ofname)) + perror(ofname); +} + +/* + * This routine returns 1 if we are running in the foreground and stderr + * is a tty. + */ +int +foreground(void) +{ + if(bgnd_flag) /* background? */ + return 0; + else /* foreground */ + return isatty(2); /* and stderr is a tty */ +} + +void +onintr(int x) +{ + USED(x); + unlink(ofname); + exit(1); +} + +void +oops(int x) /* wild pointer -- assume bad input */ +{ + USED(x); + if (do_decomp == 1) + fprintf(stderr, "uncompress: corrupt input\n"); + unlink(ofname); + exit(1); +} + +void +cl_block(void) /* table clear for block compress */ +{ + long rat; + + checkpoint = in_count + CHECK_GAP; +#ifdef DEBUG + if ( debug ) { + fprintf ( stderr, "count: %ld, ratio: ", in_count ); + prratio ( stderr, in_count, bytes_out ); + fprintf ( stderr, "\n"); + } +#endif /* DEBUG */ + + if (in_count > 0x007fffff) { /* shift will overflow */ + rat = bytes_out >> 8; + if (rat == 0) /* Don't divide by zero */ + rat = 0x7fffffff; + else + rat = in_count / rat; + } else + rat = (in_count << 8) / bytes_out; /* 8 fractional bits */ + if (rat > ratio) + ratio = rat; + else { + ratio = 0; +#ifdef DEBUG + if (verbose) + dump_tab(); /* dump string table */ +#endif + cl_hash((count_int)hsize); + free_ent = FIRST; + clear_flg = 1; + output((code_int)CLEAR); +#ifdef DEBUG + if (debug) + fprintf(stderr, "clear\n"); +#endif /* DEBUG */ + } +} + +void +cl_hash(count_int hsize) /* reset code table */ +{ + count_int *htab_p = htab+hsize; + long i; + long m1 = -1; + + i = hsize - 16; + do { /* might use Sys V memset(3) here */ + *(htab_p-16) = m1; + *(htab_p-15) = m1; + *(htab_p-14) = m1; + *(htab_p-13) = m1; + *(htab_p-12) = m1; + *(htab_p-11) = m1; + *(htab_p-10) = m1; + *(htab_p-9) = m1; + *(htab_p-8) = m1; + *(htab_p-7) = m1; + *(htab_p-6) = m1; + *(htab_p-5) = m1; + *(htab_p-4) = m1; + *(htab_p-3) = m1; + *(htab_p-2) = m1; + *(htab_p-1) = m1; + htab_p -= 16; + } while ((i -= 16) >= 0); + for ( i += 16; i > 0; i-- ) + *--htab_p = m1; +} + +void +prratio(stream, num, den) +FILE *stream; +long num, den; +{ + int q; /* Doesn't need to be long */ + + if(num > 214748L) /* 2147483647/10000 */ + q = num / (den / 10000L); + else + q = 10000L * num / den; /* Long calculations, though */ + if (q < 0) { + putc('-', stream); + q = -q; + } + fprintf(stream, "%d.%02d%%", q / 100, q % 100); +} + +void +version(void) +{ + fprintf(stderr, "%s\n", rcs_ident); + fprintf(stderr, "Options: "); +#ifdef DEBUG + fprintf(stderr, "DEBUG, "); +#endif +#ifdef BSD4_2 + fprintf(stderr, "BSD4_2, "); +#endif + fprintf(stderr, "BITS = %d\n", BITS); +} + +/* + * The revision-history novel: + * + * $Header: compress.c,v 4.0 85/07/30 12:50:00 joe Release $ + * $Log: compress.c,v $ + * Revision 4.0 85/07/30 12:50:00 joe + * Removed ferror() calls in output routine on every output except first. + * Prepared for release to the world. + * + * Revision 3.6 85/07/04 01:22:21 joe + * Remove much wasted storage by overlaying hash table with the tables + * used by decompress: tab_suffix[1<putc] and + * added signal catcher [plus beef in writeerr()] to delete effluvia. + * + * Revision 2.0 84/08/28 22:00:00 petsd!joe + * Add check for foreground before prompting user. Insert maxbits into + * compressed file. Force file being uncompressed to end with ".Z". + * Added "-c" flag and "zcat". Prepared for release. + * + * Revision 1.10 84/08/24 18:28:00 turtlevax!ken + * Will only compress regular files (no directories), added a magic number + * header (plus an undocumented -n flag to handle old files without headers), + * added -f flag to force overwriting of possibly existing destination file, + * otherwise the user is prompted for a response. Will tack on a .Z to a + * filename if it doesn't have one when decompressing. Will only replace + * file if it was compressed. + * + * Revision 1.9 84/08/16 17:28:00 turtlevax!ken + * Removed scanargs(), getopt(), added .Z extension and unlimited number of + * filenames to compress. Flags may be clustered (-Ddvb12) or separated + * (-D -d -v -b 12), or combination thereof. Modes and other status is + * copied with copystat(). -O bug for 4.2 seems to have disappeared with + * 1.8. + * + * Revision 1.8 84/08/09 23:15:00 joe + * Made it compatible with vax version, installed jim's fixes/enhancements + * + * Revision 1.6 84/08/01 22:08:00 joe + * Sped up algorithm significantly by sorting the compress chain. + * + * Revision 1.5 84/07/13 13:11:00 srd + * Added C version of vax asm routines. Changed structure to arrays to + * save much memory. Do unsigned compares where possible (faster on + * Perkin-Elmer) + * + * Revision 1.4 84/07/05 03:11:11 thomas + * Clean up the code a little and lint it. (Lint complains about all + * the regs used in the asm, but I'm not going to "fix" this.) + * + * Revision 1.3 84/07/05 02:06:54 thomas + * Minor fixes. + * + * Revision 1.2 84/07/05 00:27:27 thomas + * Add variable bit length output. + */ diff --git a/src/cmd/compress/mkfile b/src/cmd/compress/mkfile new file mode 100755 index 000000000..5af1958dc --- /dev/null +++ b/src/cmd/compress/mkfile @@ -0,0 +1,15 @@ +<$PLAN9/src/mkhdr + +TARG=\ + compress \ + zcat \ + uncompress + +$O.uncompress:Q: $O.compress + cp $prereq $target + +$O.zcat:Q: $O.compress + cp $prereq $target + +<$PLAN9/src/mkmany + From 2c3c82126b2e59d7951596adb863514eff45cf29 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 15 Jan 2020 12:14:44 +0000 Subject: [PATCH 180/323] compress: remove (not distributed) from tar(1) manpage. --- man/man1/tar.1 | 1 - 1 file changed, 1 deletion(-) diff --git a/man/man1/tar.1 b/man/man1/tar.1 index 4a18d6c8d..80e3f40b0 100644 --- a/man/man1/tar.1 +++ b/man/man1/tar.1 @@ -127,7 +127,6 @@ for and .BR .tbz2 ; .I compress -(not distributed) for .B .tar.Z and From e75dbb6af8fbea53c62efb7176ed2d25a47557c9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 10:48:20 -0500 Subject: [PATCH 181/323] factotum: update for new nbrecvul return value Unclear whether the old semantics were the right ones, but at least this preserves what they've been for the past however many years. --- src/cmd/auth/factotum/confirm.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/cmd/auth/factotum/confirm.c b/src/cmd/auth/factotum/confirm.c index 105a46dbb..8451e8ae4 100644 --- a/src/cmd/auth/factotum/confirm.c +++ b/src/cmd/auth/factotum/confirm.c @@ -128,17 +128,33 @@ needkeywrite(char *s) int needkey(Conv *c, Attr *a) { + ulong u; + if(c == nil || *needkeyinuse == 0) return -1; lbappend(&needkeybuf, "needkey tag=%lud %A", c->tag, a); flog("needkey %A", a); - return nbrecvul(c->keywait); + + // Note: This code used to "return nbrecvul(c->keywait)." + // In Jan 2020 we changed nbrecvul to match Plan 9 and + // the man page and return 0 on "no data available" instead + // of -1. This new code with an explicit nbrecv preserves the + // code's old semantics, distinguishing a sent 0 from "no data". + // That said, this code seems to return -1 unconditionally: + // the c->keywait channel is unbuffered, and the only sending + // to it is done with an nbsendul, which won't block waiting for + // a receiver. So there is no sender for nbrecv to find here. + if(nbrecv(c->keywait, &u) < 0) + return -1; + return u; } int badkey(Conv *c, Key *k, char *msg, Attr *a) { + ulong u; + if(c == nil || *needkeyinuse == 0) return -1; @@ -146,5 +162,17 @@ badkey(Conv *c, Key *k, char *msg, Attr *a) c->tag, k->attr, k->privattr, msg, a); flog("badkey %A / %N / %s / %A", k->attr, k->privattr, msg, a); - return nbrecvul(c->keywait); + + // Note: This code used to "return nbrecvul(c->keywait)." + // In Jan 2020 we changed nbrecvul to match Plan 9 and + // the man page and return 0 on "no data available" instead + // of -1. This new code with an explicit nbrecv preserves the + // code's old semantics, distinguishing a sent 0 from "no data". + // That said, this code seems to return -1 unconditionally: + // the c->keywait channel is unbuffered, and the only sending + // to it is done with an nbsendul, which won't block waiting for + // a receiver. So there is no sender for nbrecv to find here. + if(nbrecv(c->keywait, &u) < 0) + return -1; + return u; } From ba60bab3cd247284977ff99573db0c1f3d056953 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:09:16 -0500 Subject: [PATCH 182/323] devdraw: actually send resize event on resize Fixes #340. Fixes #343. --- src/cmd/devdraw/srv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index c98a865f2..570091bcb 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -37,6 +37,8 @@ usage(void) void threadmain(int argc, char **argv) { + char *p; + ARGBEGIN{ case 'D': /* for good ps -a listings */ break; @@ -52,6 +54,10 @@ threadmain(int argc, char **argv) usage(); }ARGEND + fmtinstall('H', encodefmt); + if((p = getenv("DEVDRAWTRACE")) != nil) + trace = atoi(p); + if(srvname == nil) { client0 = mallocz(sizeof(Client), 1); if(client0 == nil){ @@ -417,6 +423,7 @@ gfx_mousetrack(Client *c, int x, int y, int b, uint ms) y = copy->xy.y; b = copy->buttons; ms = copy->msec; + c->mouse.resized = 1; } if(x < c->mouserect.min.x) x = c->mouserect.min.x; From fe2b2de9844749c876df209bb8d9413e0074cbcf Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:25:36 -0500 Subject: [PATCH 183/323] devdraw: set windowrect correctly on x11 if window gets unexpected size Fixes #54. --- src/cmd/devdraw/x11-screen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index c3a6fa33b..d01e84961 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -550,8 +550,6 @@ xattach(Client *client, char *label, char *winsize) havemin = 0; } w = newxwin(client); - w->screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); - w->windowrect = r; memset(&attr, 0, sizeof attr); attr.colormap = _x.cmap; @@ -679,6 +677,8 @@ xattach(Client *client, char *label, char *winsize) } }else fprint(2, "XGetWindowAttributes: bad attrs\n"); + w->screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen)); + w->windowrect = r; /* * Allocate our local backing store. From d46053106d746260ce0ab39458332bc31ce6948b Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Wed, 15 Jan 2020 16:51:14 +0000 Subject: [PATCH 184/323] libmach: Fix type errors in FreeBSD.c The ptrace handlers wanted to take u64int arguments, not ulong. Signed-off-by: Dan Cross --- src/libmach/FreeBSD.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libmach/FreeBSD.c b/src/libmach/FreeBSD.c index 80c8935a3..de8647c61 100644 --- a/src/libmach/FreeBSD.c +++ b/src/libmach/FreeBSD.c @@ -30,8 +30,8 @@ struct PtraceRegs int pid; }; -static int ptracerw(Map*, Seg*, ulong, void*, uint, int); -static int ptraceregrw(Regs*, char*, ulong*, int); +static int ptracerw(Map*, Seg*, u64int, void*, uint, int); +static int ptraceregrw(Regs*, char*, u64int*, int); void unmapproc(Map *map) @@ -92,7 +92,7 @@ detachproc(int pid) } static int -ptracerw(Map *map, Seg *seg, ulong addr, void *v, uint n, int isr) +ptracerw(Map *map, Seg *seg, u64int addr, void *v, uint n, int isr) { int i; u32int u; @@ -167,7 +167,7 @@ reg2freebsd(char *reg) } static int -ptraceregrw(Regs *regs, char *name, ulong *val, int isr) +ptraceregrw(Regs *regs, char *name, u64int *val, int isr) { int pid; ulong addr; From 4241cae2a1ffe7a499ffd9d028e001fea7a678d6 Mon Sep 17 00:00:00 2001 From: Nicola Girardi Date: Sat, 22 Jun 2019 11:44:24 +0100 Subject: [PATCH 185/323] cmd/rio: xshove: set geometry by window id --- src/cmd/rio/xshove.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cmd/rio/xshove.c b/src/cmd/rio/xshove.c index e235874eb..7358987e0 100644 --- a/src/cmd/rio/xshove.c +++ b/src/cmd/rio/xshove.c @@ -27,6 +27,7 @@ struct Win int y; int dx; int dy; + char *idstr; char *class; char *instance; char *name; @@ -143,6 +144,9 @@ getinfo(void) if(attr.width <= 0 || attr.override_redirect || attr.map_state != IsViewable) continue; ww->xw = xwin[i]; + char idstr[9]; + snprint(idstr, sizeof(idstr), "%08x", (uint)ww->xw); + ww->idstr = strdup(idstr); ww->x = attr.x; ww->y = attr.y; ww->dx = attr.width; @@ -196,7 +200,8 @@ shove(char *name, char *geom) for(i=0; iinstance && strstr(ww->instance, name) - || ww->class && strstr(ww->class, name)){ + || ww->class && strstr(ww->class, name) + || ww->idstr && strstr(ww->idstr, name)){ int value_mask; XWindowChanges e; From 0be57355f912dbedb76cea1a7a4f9a1deb5bde2b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 15 Jan 2020 11:59:45 -0500 Subject: [PATCH 186/323] devdraw: avoid deadlock in x11 resize Fixes #347. --- src/cmd/devdraw/x11-inc.h | 1 + src/cmd/devdraw/x11-screen.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/cmd/devdraw/x11-inc.h b/src/cmd/devdraw/x11-inc.h index dca3ebcdb..ab4c25053 100644 --- a/src/cmd/devdraw/x11-inc.h +++ b/src/cmd/devdraw/x11-inc.h @@ -17,6 +17,7 @@ #include #include #ifdef SHOWEVENT +#include #include "../rio/showevent/ShowEvent.c" #endif diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index d01e84961..62f49f2f7 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -1042,7 +1042,9 @@ _xreplacescreenimage(Client *client) w->nextscreenpm = pixmap; w->screenr = r; client->mouserect = r; + xunlock(); gfx_replacescreenimage(client, m); + xlock(); return 1; } From 3ef80ba5f5c29a8367d32353a9620ec4cf9cb880 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Thu, 16 Jan 2020 16:46:58 +0000 Subject: [PATCH 187/323] lib9: putenv wraps POSIX setenv, not legacy putenv POSIX setenv does everything that p9putenv's body, so just delegate to that. Signed-off-by: Dan Cross --- src/lib9/getenv.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/lib9/getenv.c b/src/lib9/getenv.c index 384196cf4..5dfc85779 100644 --- a/src/lib9/getenv.c +++ b/src/lib9/getenv.c @@ -16,11 +16,5 @@ p9getenv(char *s) int p9putenv(char *s, char *v) { - char *t; - - t = smprint("%s=%s", s, v); - if(t == nil) - return -1; - putenv(t); - return 0; + return setenv(s, v, 1); } From 7bf2db4c2ae30c0f7b320e57060715bf6279e98a Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Thu, 16 Jan 2020 16:54:19 +0000 Subject: [PATCH 188/323] malloc: remove locking The issue manifests in fork: POSIX fork mandates that a fork'd process is created with a single thread. If a multithreaded program forks, and some thread was in malloc() when the fork() happened, then in the child the lock will be held but there will be no thread to release it. We assume the system malloc() must already know how to deal with this and is thread-safe, but it won't know about our custom spinlock. Judging that this is no longer necessary (the lock code was added 15 years ago) we remove it. Signed-off-by: Dan Cross --- src/cmd/9term/malloc.c | 10 ---------- src/lib9/debugmalloc.c | 9 --------- src/lib9/malloc.c | 25 +++---------------------- 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/src/cmd/9term/malloc.c b/src/cmd/9term/malloc.c index 9132235b3..7b590bc4b 100644 --- a/src/cmd/9term/malloc.c +++ b/src/cmd/9term/malloc.c @@ -7,8 +7,6 @@ #define NOPLAN9DEFINES #include -static Lock malloclock; - void* p9malloc(ulong n) { @@ -16,9 +14,7 @@ p9malloc(ulong n) if(n == 0) n++; - lock(&malloclock); v = malloc(n); - unlock(&malloclock); print("p9malloc %lud => %p; pc %lux\n", n, v, getcallerpc(&n)); return v; } @@ -28,10 +24,8 @@ p9free(void *v) { if(v == nil) return; - lock(&malloclock); print("p9free %p; pc %lux\n", v, getcallerpc(&v)); free(v); - unlock(&malloclock); } void* @@ -42,9 +36,7 @@ p9calloc(ulong a, ulong b) if(a*b == 0) a = b = 1; - lock(&malloclock); v = calloc(a*b, 1); - unlock(&malloclock); print("p9calloc %lud %lud => %p; pc %lux\n", a, b, v, getcallerpc(&a)); return v; } @@ -54,9 +46,7 @@ p9realloc(void *v, ulong n) { void *vv; - lock(&malloclock); vv = realloc(v, n); - unlock(&malloclock); print("p9realloc %p %lud => %p; pc %lux\n", v, n, vv, getcallerpc(&v)); return vv; } diff --git a/src/lib9/debugmalloc.c b/src/lib9/debugmalloc.c index 51a2c61f5..744af835e 100644 --- a/src/lib9/debugmalloc.c +++ b/src/lib9/debugmalloc.c @@ -6,7 +6,6 @@ * The Unix libc routines cannot be trusted to do their own locking. * Sad but apparently true. */ -static Lock malloclock; static int mallocpid; /* @@ -112,11 +111,9 @@ p9malloc(ulong n) if(n == 0) n++; /*fprint(2, "%s %d malloc\n", argv0, getpid()); */ - lock(&malloclock); mallocpid = getpid(); v = malloc(n+Overhead); v = mark(v, getcallerpc(&n), n, MallocMagic); - unlock(&malloclock); /*fprint(2, "%s %d donemalloc\n", argv0, getpid()); */ return v; } @@ -128,11 +125,9 @@ p9free(void *v) return; /*fprint(2, "%s %d free\n", argv0, getpid()); */ - lock(&malloclock); mallocpid = getpid(); v = mark(v, getcallerpc(&v), 0, FreeMagic); free(v); - unlock(&malloclock); /*fprint(2, "%s %d donefree\n", argv0, getpid()); */ } @@ -142,11 +137,9 @@ p9calloc(ulong a, ulong b) void *v; /*fprint(2, "%s %d calloc\n", argv0, getpid()); */ - lock(&malloclock); mallocpid = getpid(); v = calloc(a*b+Overhead, 1); v = mark(v, getcallerpc(&a), a*b, CallocMagic); - unlock(&malloclock); /*fprint(2, "%s %d donecalloc\n", argv0, getpid()); */ return v; } @@ -155,12 +148,10 @@ void* p9realloc(void *v, ulong n) { /*fprint(2, "%s %d realloc\n", argv0, getpid()); */ - lock(&malloclock); mallocpid = getpid(); v = mark(v, getcallerpc(&v), 0, CheckMagic); v = realloc(v, n+Overhead); v = mark(v, getcallerpc(&v), n, ReallocMagic); - unlock(&malloclock); /*fprint(2, "%s %d donerealloc\n", argv0, getpid()); */ return v; } diff --git a/src/lib9/malloc.c b/src/lib9/malloc.c index 33593aa2f..695ff8bc0 100644 --- a/src/lib9/malloc.c +++ b/src/lib9/malloc.c @@ -7,50 +7,31 @@ #define NOPLAN9DEFINES #include -static Lock malloclock; void* p9malloc(ulong n) { - void *v; - if(n == 0) n++; - lock(&malloclock); - v = malloc(n); - unlock(&malloclock); - return v; + return malloc(n); } void p9free(void *v) { - if(v == nil) - return; - lock(&malloclock); free(v); - unlock(&malloclock); } void* p9calloc(ulong a, ulong b) { - void *v; - if(a*b == 0) a = b = 1; - - lock(&malloclock); - v = calloc(a*b, 1); - unlock(&malloclock); - return v; + return calloc(a, b); } void* p9realloc(void *v, ulong n) { - lock(&malloclock); - v = realloc(v, n); - unlock(&malloclock); - return v; + return realloc(v, n); } From 23a23689807560ee80806a339be0f7e7cef6340d Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Thu, 16 Jan 2020 17:01:44 +0000 Subject: [PATCH 189/323] libthread: NetBSD supports pthreads, remove ancient systems in sysofiles.sh Signed-off-by: Dan Cross --- src/libthread/sysofiles.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index f76b975ad..e1eb8f033 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -4,15 +4,8 @@ test -f $PLAN9/config && . $PLAN9/config tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}" case "$tag" in -*-Linux-2.[0-5]*) - # will have to fix this for linux power pc - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o - ;; -*-FreeBSD-[0-4].*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o - ;; *-NetBSD-*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o ;; *-Darwin-10.[5-6].* | *-Darwin-[89].*) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME-${OBJTYPE}.o pthread.o stkmalloc.o From 1d0d432ccb000b28de3309db5f8299357a46c903 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 16 Jan 2020 12:07:42 -0500 Subject: [PATCH 190/323] devdraw: abort alt sequence on window change on macOS Fixes #3. --- src/cmd/devdraw/mac-screen.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 4bc3f088a..dedbfb84b 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -560,6 +560,10 @@ - (void)windowDidBecomeKey:(id)arg { [self sendmouse:0]; } +- (void)windowDidResignKey:(id)arg { + gfx_abortcompose(self.client); +} + - (void)mouseMoved:(NSEvent*)e{ [self getmouse:e];} - (void)mouseDown:(NSEvent*)e{ [self getmouse:e];} - (void)mouseDragged:(NSEvent*)e{ [self getmouse:e];} From 83b1e7a39b1e5af82846c7e9632b802c39d96f83 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Thu, 16 Jan 2020 17:22:00 +0000 Subject: [PATCH 191/323] 9fs: remove tip (dead?), redirect sources to 9p.io Fixes #195. Signed-off-by: Dan Cross --- bin/9fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/9fs b/bin/9fs index fffdc35b3..467b3191d 100755 --- a/bin/9fs +++ b/bin/9fs @@ -19,10 +19,8 @@ fn srv1 { ns=`{namespace} switch($1){ -case tip - srv1 -a tip utumno.tip9ug.jp case sources - srv1 -n sources sources.cs.bell-labs.com + srv1 -n sources 9p.io case * srv1 $1 $1 } From 57157d856e4bf66326771e8036062eb6881280ca Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Mon, 20 Jan 2020 02:43:55 +0100 Subject: [PATCH 192/323] libthread: rm unused ARM (get|set)mcontext (#354) They were just a duplicate of my(get|set)mcontext from the other assembly file, and unused from threadimpl.h. Change-Id: Id8003e5177ed9d37a7f0210037acbe55bbf7f708 --- src/libthread/Linux-arm-asm.s | 43 ----------------------------------- 1 file changed, 43 deletions(-) diff --git a/src/libthread/Linux-arm-asm.s b/src/libthread/Linux-arm-asm.s index 5a285bf20..721ea43b5 100644 --- a/src/libthread/Linux-arm-asm.s +++ b/src/libthread/Linux-arm-asm.s @@ -8,46 +8,3 @@ _tas: swp r3, r3, [r0] mov r0, r3 mov pc, lr - -.globl getmcontext -getmcontext: - str r1, [r0,#4] - str r2, [r0,#8] - str r3, [r0,#12] - str r4, [r0,#16] - str r5, [r0,#20] - str r6, [r0,#24] - str r7, [r0,#28] - str r8, [r0,#32] - str r9, [r0,#36] - str r10, [r0,#40] - str r11, [r0,#44] - str r12, [r0,#48] - str r13, [r0,#52] - str r14, [r0,#56] - /* store 1 as r0-to-restore */ - mov r1, #1 - str r1, [r0] - /* return 0 */ - mov r0, #0 - mov pc, lr - -.globl setmcontext -setmcontext: - ldr r1, [r0,#4] - ldr r2, [r0,#8] - ldr r3, [r0,#12] - ldr r4, [r0,#16] - ldr r5, [r0,#20] - ldr r6, [r0,#24] - ldr r7, [r0,#28] - ldr r8, [r0,#32] - ldr r9, [r0,#36] - ldr r10, [r0,#40] - ldr r11, [r0,#44] - ldr r12, [r0,#48] - ldr r13, [r0,#52] - ldr r14, [r0,#56] - ldr r0, [r0] - mov pc, lr - From d15607b9ddd9872b48fe3ac8c68f9637044be310 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 20:51:28 -0500 Subject: [PATCH 193/323] libthread: rm OpenBSD.c This should have been deleted in 20f5692b (2012-07-14), which removed the mkfile and sysofiles.sh references to it. --- src/libthread/OpenBSD.c | 145 ---------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 src/libthread/OpenBSD.c diff --git a/src/libthread/OpenBSD.c b/src/libthread/OpenBSD.c deleted file mode 100644 index 80a509775..000000000 --- a/src/libthread/OpenBSD.c +++ /dev/null @@ -1,145 +0,0 @@ -#include "threadimpl.h" -#include "BSD.c" - -#include - -struct thread_tag { - struct thread_tag *next; - spinlock_t l; - volatile int key; - void *data; -}; - -static spinlock_t mlock; -static spinlock_t dl_lock; -static spinlock_t tag_lock; -static struct thread_tag *thread_tag_store = nil; -static uint nextkey = 0; - -void -_thread_malloc_lock(void) -{ - _spinlock(&mlock); -} - -void -_thread_malloc_unlock(void) -{ - _spinunlock(&mlock); -} - -void -_thread_malloc_init(void) -{ -} - -/* - * for ld.so - */ -void -_thread_dl_lock(int t) -{ - if(t) - _spinunlock(&dl_lock); - else - _spinlock(&dl_lock); -} - -/* - * for libc - */ -static void -_thread_tag_init(void **tag) -{ - struct thread_tag *t; - - _spinlock(&tag_lock); - if(*tag == nil) { - t = malloc(sizeof (*t)); - if(t != nil) { - memset(&t->l, 0, sizeof(t->l)); - t->key = nextkey++; - *tag = t; - } - } - _spinunlock(&tag_lock); -} - -void -_thread_tag_lock(void **tag) -{ - struct thread_tag *t; - - if(*tag == nil) - _thread_tag_init(tag); - t = *tag; - _spinlock(&t->l); -} - -void -_thread_tag_unlock(void **tag) -{ - struct thread_tag *t; - - if(*tag == nil) - _thread_tag_init(tag); - t = *tag; - _spinunlock(&t->l); -} - -static void * -_thread_tag_insert(struct thread_tag *t, void *v) -{ - t->data = v; - t->next = thread_tag_store; - thread_tag_store = t; - return t; -} - -static void * -_thread_tag_lookup(struct thread_tag *tag, int size) -{ - struct thread_tag *t; - void *p; - - _spinlock(&tag->l); - for(t = thread_tag_store; t != nil; t = t->next) - if(t->key == tag->key) - break; - if(t == nil) { - p = malloc(size); - if(p == nil) { - _spinunlock(&tag->l); - return nil; - } - _thread_tag_insert(tag, p); - } - _spinunlock(&tag->l); - return tag->data; -} - -void * -_thread_tag_storage(void **tag, void *storage, size_t n, void *err) -{ - struct thread_tag *t; - void *r; - - if(*tag == nil) - _thread_tag_init(tag); - t = *tag; - - r = _thread_tag_lookup(t, n); - if(r == nil) - r = err; - else - memcpy(r, storage, n); - return r; -} - -void -_pthreadinit(void) -{ - __isthreaded = 1; - dlctl(nil, DL_SETTHREADLCK, _thread_dl_lock); - signal(SIGUSR2, sigusr2handler); -} From 8dcb18f71b1917713d4743ab10968c527acdc62e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:25:33 -0500 Subject: [PATCH 194/323] libthread: rm FreeBSD 4 code Pretty sure FreeBSD 4 is gone now. :-) --- include/u.h | 6 +- src/libthread/BSD.c | 403 -------------------------------- src/libthread/FreeBSD-386-asm.s | 52 ----- src/libthread/FreeBSD.c | 34 --- src/libthread/OpenBSD-386-asm.s | 53 ++++- src/libthread/mkfile | 1 - src/libthread/threadimpl.h | 9 - 7 files changed, 54 insertions(+), 504 deletions(-) delete mode 100644 src/libthread/BSD.c delete mode 100644 src/libthread/FreeBSD-386-asm.s delete mode 100644 src/libthread/FreeBSD.c diff --git a/include/u.h b/include/u.h index d0cd6396f..8a715b1ed 100644 --- a/include/u.h +++ b/include/u.h @@ -86,10 +86,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #elif defined(__FreeBSD__) # include # include -# if __FreeBSD_version >= 500000 -# define PLAN9PORT_USING_PTHREADS 1 -# include -# endif +# define PLAN9PORT_USING_PTHREADS 1 +# include # if !defined(_POSIX_SOURCE) # undef _NEEDUSHORT # undef _NEEDUINT diff --git a/src/libthread/BSD.c b/src/libthread/BSD.c deleted file mode 100644 index 737c0a63a..000000000 --- a/src/libthread/BSD.c +++ /dev/null @@ -1,403 +0,0 @@ -#undef exits -#undef _exits - -extern int __isthreaded; - -/* - * spin locks - */ -extern int _tas(int*); - -void -_threadunlock(Lock *l, ulong pc) -{ - USED(pc); - - l->held = 0; -} - -int -_threadlock(Lock *l, int block, ulong pc) -{ - int i; - - USED(pc); - - /* once fast */ - if(!_tas(&l->held)) - return 1; - if(!block) - return 0; - - /* a thousand times pretty fast */ - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - sleep(0); - } - /* increasingly slow */ - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1); - } - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10); - } - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100); - } - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1000); - } - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10*1000); - } - /* now nice and slow */ - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100*1000); - } - /* take your time */ - while(_tas(&l->held)) - usleep(1000*1000); - return 1; -} - -/* - * For libc. - */ - -typedef struct { - volatile long access_lock; - volatile long lock_owner; - volatile char *fname; - volatile int lineno; -} spinlock_t; - -void -_spinlock(spinlock_t *lk) -{ - lock((Lock*)&lk->access_lock); -} - -void -_spinunlock(spinlock_t *lk) -{ - unlock((Lock*)&lk->access_lock); -} - - - -/* - * sleep and wakeup - */ -static void -ign(int x) -{ - USED(x); -} - -static void /*__attribute__((constructor))*/ -ignusr1(int restart) -{ - struct sigaction sa; - - memset(&sa, 0, sizeof sa); - sa.sa_handler = ign; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGUSR1); - if(restart) - sa.sa_flags = SA_RESTART; - sigaction(SIGUSR1, &sa, nil); -} - -void -_procsleep(_Procrendez *r) -{ - sigset_t mask; - - /* - * Go to sleep. - * - * Block USR1, set the handler to interrupt system calls, - * unlock the vouslock so our waker can wake us, - * and then suspend. - */ -again: - r->asleep = 1; - r->pid = getpid(); - - sigprocmask(SIG_SETMASK, nil, &mask); - sigaddset(&mask, SIGUSR1); - sigprocmask(SIG_SETMASK, &mask, nil); - ignusr1(0); - unlock(r->l); - sigdelset(&mask, SIGUSR1); - sigsuspend(&mask); - - /* - * We're awake. Make USR1 not interrupt system calls. - */ - lock(r->l); - ignusr1(1); - if(r->asleep && r->pid == getpid()){ - /* Didn't really wake up - signal from something else */ - goto again; - } -} - -void -_procwakeup(_Procrendez *r) -{ - if(r->asleep){ - r->asleep = 0; - assert(r->pid >= 1); - kill(r->pid, SIGUSR1); - } -} - -void -_procwakeupandunlock(_Procrendez *r) -{ - _procwakeup(r); - unlock(r->l); -} - - -/* - * process creation and exit - */ -typedef struct Stackfree Stackfree; -struct Stackfree -{ - Stackfree *next; - int pid; -}; -static Lock stacklock; -static Stackfree *stackfree; - -static void -delayfreestack(uchar *stk) -{ - Stackfree *sf; - - sf = (Stackfree*)stk; - sf->pid = getpid(); - lock(&stacklock); - sf->next = stackfree; - stackfree = sf; - unlock(&stacklock); -} - -static void -dofreestacks(void) -{ - Stackfree *sf, *last, *next; - - if(stackfree==nil || !canlock(&stacklock)) - return; - - for(last=nil,sf=stackfree; sf; last=sf,sf=next){ - next = sf->next; - if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH){ - free(sf); - if(last) - last->next = next; - else - stackfree = next; - sf = last; - } - } - unlock(&stacklock); -} - -static int -startprocfn(void *v) -{ - void **a; - uchar *stk; - void (*fn)(void*); - Proc *p; - - a = (void**)v; - fn = a[0]; - p = a[1]; - stk = a[2]; - free(a); - p->osprocid = getpid(); - - (*fn)(p); - - delayfreestack(stk); - _exit(0); - return 0; -} - -void -_procstart(Proc *p, void (*fn)(Proc*)) -{ - void **a; - uchar *stk; - int pid; - - dofreestacks(); - a = malloc(3*sizeof a[0]); - if(a == nil) - sysfatal("_procstart malloc: %r"); - stk = malloc(65536); - if(stk == nil) - sysfatal("_procstart malloc stack: %r"); - - a[0] = fn; - a[1] = p; - a[2] = stk; - - pid = rfork_thread(RFPROC|RFMEM|RFNOWAIT, stk+65536-64, startprocfn, a); - if(pid < 0){ - fprint(2, "_procstart rfork_thread: %r\n"); - abort(); - } -} - -static char *threadexitsmsg; -void -sigusr2handler(int s) -{ -/* fprint(2, "%d usr2 %d\n", time(0), getpid()); */ - if(threadexitsmsg) - _exits(threadexitsmsg); -} - -void -threadexitsall(char *msg) -{ - static int pid[1024]; - int i, npid, mypid; - Proc *p; - - if(msg == nil) - msg = ""; - - /* - * Only one guy, ever, gets to run this. - * If two guys do it, inevitably they end up - * tripping over each other in the underlying - * C library exit() implementation, which is - * trying to run the atexit handlers and apparently - * not thread safe. This has been observed on - * both Linux and OpenBSD. Sigh. - */ - { - static Lock onelock; - if(!canlock(&onelock)) - _exits(threadexitsmsg); - threadexitsmsg = msg; - } - - if(msg == nil) - msg = ""; - mypid = getpid(); - lock(&_threadprocslock); - threadexitsmsg = msg; - npid = 0; - for(p=_threadprocs; p; p=p->next) - if(p->osprocid != mypid && p->osprocid >= 1) - pid[npid++] = p->osprocid; - for(i=0; ipid == pid) - return p; - if(p->pid == 0){ - print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h); - break; - } - } - fprint(2, "myperproc %d: cannot find self\n", pid); - abort(); - return nil; -} - -static Perproc* -newperproc(void) -{ - int i, pid, h; - Perproc *p; - - lock(&perlock); - pid = getpid(); - h = pid%nelem(perproc); - for(i=0; ipid == pid || p->pid == -1 || p->pid == 0){ - p->pid = pid; - unlock(&perlock); - return p; - } - } - fprint(2, "newperproc %d: out of procs\n", pid); - abort(); - return nil; -} - -Proc* -_threadproc(void) -{ - return myperproc()->proc; -} - -void -_threadsetproc(Proc *p) -{ - Perproc *pp; - - if(p) - p->osprocid = getpid(); - pp = newperproc(); - pp->proc = p; - if(p == nil) - pp->pid = -1; -} - -void -_threadpexit(void) -{ - _exit(0); -} diff --git a/src/libthread/FreeBSD-386-asm.s b/src/libthread/FreeBSD-386-asm.s deleted file mode 100644 index 421698534..000000000 --- a/src/libthread/FreeBSD-386-asm.s +++ /dev/null @@ -1,52 +0,0 @@ -.globl _tas -_tas: - movl $0xCAFEBABE, %eax - movl 4(%esp), %ecx - xchgl %eax, 0(%ecx) - ret - -.globl getmcontext -getmcontext: - movl 4(%esp), %eax - - movl %fs, 8(%eax) - movl %es, 12(%eax) - movl %ds, 16(%eax) - movl %ss, 76(%eax) - movl %edi, 20(%eax) - movl %esi, 24(%eax) - movl %ebp, 28(%eax) - movl %ebx, 36(%eax) - movl %edx, 40(%eax) - movl %ecx, 44(%eax) - - movl $1, 48(%eax) /* %eax */ - movl (%esp), %ecx /* %eip */ - movl %ecx, 60(%eax) - leal 4(%esp), %ecx /* %esp */ - movl %ecx, 72(%eax) - - movl 44(%eax), %ecx /* restore %ecx */ - movl $0, %eax - ret - -.globl setmcontext -setmcontext: - movl 4(%esp), %eax - - movl 8(%eax), %fs - movl 12(%eax), %es - movl 16(%eax), %ds - movl 76(%eax), %ss - movl 20(%eax), %edi - movl 24(%eax), %esi - movl 28(%eax), %ebp - movl 36(%eax), %ebx - movl 40(%eax), %edx - movl 44(%eax), %ecx - - movl 72(%eax), %esp - pushl 60(%eax) /* new %eip */ - movl 48(%eax), %eax - ret - diff --git a/src/libthread/FreeBSD.c b/src/libthread/FreeBSD.c deleted file mode 100644 index 5c2824650..000000000 --- a/src/libthread/FreeBSD.c +++ /dev/null @@ -1,34 +0,0 @@ -#include "threadimpl.h" - -#include "BSD.c" - -/* - * FreeBSD 4 and earlier needs the context functions. - */ -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - int *sp; - - sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4; - sp -= argc; - memmove(sp, &argc+1, argc*sizeof(int)); - *--sp = 0; /* return address */ - ucp->uc_mcontext.mc_eip = (long)func; - ucp->uc_mcontext.mc_esp = (int)sp; -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} - -void -_pthreadinit(void) -{ - __isthreaded = 1; - signal(SIGUSR2, sigusr2handler); -} diff --git a/src/libthread/OpenBSD-386-asm.s b/src/libthread/OpenBSD-386-asm.s index dad1b5368..421698534 100644 --- a/src/libthread/OpenBSD-386-asm.s +++ b/src/libthread/OpenBSD-386-asm.s @@ -1 +1,52 @@ -#include "FreeBSD-386-asm.s" +.globl _tas +_tas: + movl $0xCAFEBABE, %eax + movl 4(%esp), %ecx + xchgl %eax, 0(%ecx) + ret + +.globl getmcontext +getmcontext: + movl 4(%esp), %eax + + movl %fs, 8(%eax) + movl %es, 12(%eax) + movl %ds, 16(%eax) + movl %ss, 76(%eax) + movl %edi, 20(%eax) + movl %esi, 24(%eax) + movl %ebp, 28(%eax) + movl %ebx, 36(%eax) + movl %edx, 40(%eax) + movl %ecx, 44(%eax) + + movl $1, 48(%eax) /* %eax */ + movl (%esp), %ecx /* %eip */ + movl %ecx, 60(%eax) + leal 4(%esp), %ecx /* %esp */ + movl %ecx, 72(%eax) + + movl 44(%eax), %ecx /* restore %ecx */ + movl $0, %eax + ret + +.globl setmcontext +setmcontext: + movl 4(%esp), %eax + + movl 8(%eax), %fs + movl 12(%eax), %es + movl 16(%eax), %ds + movl 76(%eax), %ss + movl 20(%eax), %edi + movl 24(%eax), %esi + movl 28(%eax), %ebp + movl 36(%eax), %ebx + movl 40(%eax), %edx + movl 44(%eax), %ecx + + movl 72(%eax), %esp + pushl 60(%eax) /* new %eip */ + movl 48(%eax), %eax + ret + diff --git a/src/libthread/mkfile b/src/libthread/mkfile index f621ac607..31c4c7e5d 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -16,7 +16,6 @@ OFILES=\ <$PLAN9/src/mksyslib HFILES=thread.h threadimpl.h -FreeBSD.$O: BSD.c NetBSD.$O: Linux.c tprimes: test/tprimes.$O diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 6671f23cf..e26ffe6b3 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -15,15 +15,6 @@ #include "libc.h" #include "thread.h" -#if defined(__FreeBSD__) && __FreeBSD__ < 5 -extern int getmcontext(mcontext_t*); -extern void setmcontext(mcontext_t*); -#define setcontext(u) setmcontext(&(u)->uc_mcontext) -#define getcontext(u) getmcontext(&(u)->uc_mcontext) -extern int swapcontext(ucontext_t*, ucontext_t*); -extern void makecontext(ucontext_t*, void(*)(), int, ...); -#endif - #if defined(__APPLE__) /* * OS X before 10.5 (Leopard) does not provide From 52397aaf2b240015533fa46f1767c20f45296465 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 20:57:09 -0500 Subject: [PATCH 195/323] libthread: rm Darwin pre-11.0.0 support Darwin 11.0.0 was Mac OS X 10.7.0 aka Lion. The previous version was Snow Leopard, which has been unsupported by Apple since February 2014. --- src/libthread/Darwin-386-asm.s | 52 -------------------- src/libthread/Darwin-386.c | 30 ------------ src/libthread/Darwin-power-asm.s | 83 -------------------------------- src/libthread/Darwin-power.c | 24 --------- src/libthread/sysofiles.sh | 3 -- 5 files changed, 192 deletions(-) delete mode 100644 src/libthread/Darwin-386-asm.s delete mode 100644 src/libthread/Darwin-386.c delete mode 100644 src/libthread/Darwin-power-asm.s delete mode 100644 src/libthread/Darwin-power.c diff --git a/src/libthread/Darwin-386-asm.s b/src/libthread/Darwin-386-asm.s deleted file mode 100644 index 46c96e94c..000000000 --- a/src/libthread/Darwin-386-asm.s +++ /dev/null @@ -1,52 +0,0 @@ -.globl _tas -_tas: - movl $0xCAFEBABE, %eax - movl 4(%esp), %ecx - xchgl %eax, 0(%ecx) - ret - -.globl _getmcontext -_getmcontext: - movl 4(%esp), %eax - - movl %fs, 8(%eax) - movl %es, 12(%eax) - movl %ds, 16(%eax) - movl %ss, 76(%eax) - movl %edi, 20(%eax) - movl %esi, 24(%eax) - movl %ebp, 28(%eax) - movl %ebx, 36(%eax) - movl %edx, 40(%eax) - movl %ecx, 44(%eax) - - movl $1, 48(%eax) /* %eax */ - movl (%esp), %ecx /* %eip */ - movl %ecx, 60(%eax) - leal 4(%esp), %ecx /* %esp */ - movl %ecx, 72(%eax) - - movl 44(%eax), %ecx /* restore %ecx */ - movl $0, %eax - ret - -.globl _setmcontext -_setmcontext: - movl 4(%esp), %eax - - movl 8(%eax), %fs - movl 12(%eax), %es - movl 16(%eax), %ds - movl 76(%eax), %ss - movl 20(%eax), %edi - movl 24(%eax), %esi - movl 28(%eax), %ebp - movl 36(%eax), %ebx - movl 40(%eax), %edx - movl 44(%eax), %ecx - - movl 72(%eax), %esp - pushl 60(%eax) /* new %eip */ - movl 48(%eax), %eax - ret - diff --git a/src/libthread/Darwin-386.c b/src/libthread/Darwin-386.c deleted file mode 100644 index b138e4200..000000000 --- a/src/libthread/Darwin-386.c +++ /dev/null @@ -1,30 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - int *sp; - - sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4; - sp -= argc; - /* - * Stack pointer at call instruction (before return address - * gets pushed) must be 16-byte aligned. - */ - if((uintptr)sp%4) - abort(); - while((uintptr)sp%16) - sp--; - memmove(sp, &argc+1, argc*sizeof(int)); - *--sp = 0; /* return address */ - ucp->uc_mcontext.mc_eip = (long)func; - ucp->uc_mcontext.mc_esp = (int)sp; -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/Darwin-power-asm.s b/src/libthread/Darwin-power-asm.s deleted file mode 100644 index a064b5eaf..000000000 --- a/src/libthread/Darwin-power-asm.s +++ /dev/null @@ -1,83 +0,0 @@ -/* get FPR and VR use flags with sc 0x7FF3 */ -/* get vsave with mfspr reg, 256 */ - -.text -.align 2 - -.globl __getmcontext - -__getmcontext: /* xxx: instruction scheduling */ - mflr r0 - mfcr r5 - mfctr r6 - mfxer r7 - stw r0, 0*4(r3) - stw r5, 1*4(r3) - stw r6, 2*4(r3) - stw r7, 3*4(r3) - - stw r1, 4*4(r3) - stw r2, 5*4(r3) - li r5, 1 /* return value for setmcontext */ - stw r5, 6*4(r3) - - stw r13, (0+7)*4(r3) /* callee-save GPRs */ - stw r14, (1+7)*4(r3) /* xxx: block move */ - stw r15, (2+7)*4(r3) - stw r16, (3+7)*4(r3) - stw r17, (4+7)*4(r3) - stw r18, (5+7)*4(r3) - stw r19, (6+7)*4(r3) - stw r20, (7+7)*4(r3) - stw r21, (8+7)*4(r3) - stw r22, (9+7)*4(r3) - stw r23, (10+7)*4(r3) - stw r24, (11+7)*4(r3) - stw r25, (12+7)*4(r3) - stw r26, (13+7)*4(r3) - stw r27, (14+7)*4(r3) - stw r28, (15+7)*4(r3) - stw r29, (16+7)*4(r3) - stw r30, (17+7)*4(r3) - stw r31, (18+7)*4(r3) - - li r3, 0 /* return */ - blr - -.globl __setmcontext - -__setmcontext: - lwz r13, (0+7)*4(r3) /* callee-save GPRs */ - lwz r14, (1+7)*4(r3) /* xxx: block move */ - lwz r15, (2+7)*4(r3) - lwz r16, (3+7)*4(r3) - lwz r17, (4+7)*4(r3) - lwz r18, (5+7)*4(r3) - lwz r19, (6+7)*4(r3) - lwz r20, (7+7)*4(r3) - lwz r21, (8+7)*4(r3) - lwz r22, (9+7)*4(r3) - lwz r23, (10+7)*4(r3) - lwz r24, (11+7)*4(r3) - lwz r25, (12+7)*4(r3) - lwz r26, (13+7)*4(r3) - lwz r27, (14+7)*4(r3) - lwz r28, (15+7)*4(r3) - lwz r29, (16+7)*4(r3) - lwz r30, (17+7)*4(r3) - lwz r31, (18+7)*4(r3) - - lwz r1, 4*4(r3) - lwz r2, 5*4(r3) - - lwz r0, 0*4(r3) - mtlr r0 - lwz r0, 1*4(r3) - mtcr r0 /* mtcrf 0xFF, r0 */ - lwz r0, 2*4(r3) - mtctr r0 - lwz r0, 3*4(r3) - mtxer r0 - - lwz r3, 6*4(r3) - blr diff --git a/src/libthread/Darwin-power.c b/src/libthread/Darwin-power.c deleted file mode 100644 index 3f2bf5669..000000000 --- a/src/libthread/Darwin-power.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - ulong *sp, *tos; - va_list arg; - - tos = (ulong*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/sizeof(ulong); - sp = tos - 16; - ucp->mc.pc = (long)func; - ucp->mc.sp = (long)sp; - va_start(arg, argc); - ucp->mc.r3 = va_arg(arg, long); - va_end(arg); -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index e1eb8f033..30a4c3388 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -7,9 +7,6 @@ case "$tag" in *-NetBSD-*) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o ;; -*-Darwin-10.[5-6].* | *-Darwin-[89].*) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME-${OBJTYPE}.o pthread.o stkmalloc.o - ;; *-OpenBSD-*) echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o ;; From c181e39eeab0eb8cad274b7b22ce5343bd55630d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:01:30 -0500 Subject: [PATCH 196/323] libthread: rm unused sparc-ucontext.h More dead code. --- src/libthread/sparc-ucontext.h | 23 ----------------------- src/libthread/threadimpl.h | 14 -------------- 2 files changed, 37 deletions(-) delete mode 100644 src/libthread/sparc-ucontext.h diff --git a/src/libthread/sparc-ucontext.h b/src/libthread/sparc-ucontext.h deleted file mode 100644 index 36b881710..000000000 --- a/src/libthread/sparc-ucontext.h +++ /dev/null @@ -1,23 +0,0 @@ -#define setcontext(u) _setmcontext(&(u)->mc) -#define getcontext(u) _getmcontext(&(u)->mc) -typedef struct mcontext mcontext_t; -typedef struct ucontext ucontext_t; -struct mcontext -{ - int r[16]; -}; - -struct ucontext -{ - struct { - void *ss_sp; - uint ss_size; - } uc_stack; - sigset_t uc_sigmask; - mcontext_t mc; -}; - -void makecontext(ucontext_t*, void(*)(void), int, ...); -int swapcontext(ucontext_t*, ucontext_t*); -int _getmcontext(mcontext_t*); -void _setmcontext(mcontext_t*); diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index e26ffe6b3..5b6d74cc8 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -55,20 +55,6 @@ extern pid_t rfork_thread(int, void*, int(*)(void*), void*); #endif -/* THIS DOES NOT WORK! Don't do this! -(At least, not on Solaris. Maybe this is right for Linux, -in which case it should say if defined(__linux__) && defined(__sun__), -but surely the latter would be defined(__sparc__). - -#if defined(__sun__) -# define mcontext libthread_mcontext -# define mcontext_t libthread_mcontext_t -# define ucontext libthread_ucontext -# define ucontext_t libthread_ucontext_t -# include "sparc-ucontext.h" -#endif -*/ - #if defined(__arm__) int mygetmcontext(ulong*); void mysetmcontext(const ulong*); From 8d82ccefd2b4b058e20ae0a7e3d9ef9b6b8cf8c3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:03:56 -0500 Subject: [PATCH 197/323] libthread: remove Linux 2.4 code Linux.c was for Linux 2.4 and is no longer used directly, only indirectly because NetBSD.c was a 1-line file #including Linux.c. So mv Linux.c NetBSD.c. Also rm Linux-*-asm.s which was for Linux 2.4 as well. --- src/libthread/Linux-386-asm.s | 7 - src/libthread/Linux-arm-asm.s | 10 - src/libthread/Linux-power-asm.s | 16 -- src/libthread/Linux-sparc64-asm.s | 16 -- src/libthread/Linux.c | 462 ----------------------------- src/libthread/NetBSD.c | 463 +++++++++++++++++++++++++++++- src/libthread/mkfile | 1 - 7 files changed, 462 insertions(+), 513 deletions(-) delete mode 100644 src/libthread/Linux-386-asm.s delete mode 100644 src/libthread/Linux-arm-asm.s delete mode 100644 src/libthread/Linux-power-asm.s delete mode 100644 src/libthread/Linux-sparc64-asm.s delete mode 100644 src/libthread/Linux.c diff --git a/src/libthread/Linux-386-asm.s b/src/libthread/Linux-386-asm.s deleted file mode 100644 index 197f12b54..000000000 --- a/src/libthread/Linux-386-asm.s +++ /dev/null @@ -1,7 +0,0 @@ -.globl _tas -_tas: - movl $0xCAFEBABE, %eax - movl 4(%esp), %ecx - xchgl %eax, 0(%ecx) - ret - diff --git a/src/libthread/Linux-arm-asm.s b/src/libthread/Linux-arm-asm.s deleted file mode 100644 index 721ea43b5..000000000 --- a/src/libthread/Linux-arm-asm.s +++ /dev/null @@ -1,10 +0,0 @@ - -.globl _tas -_tas: - mov r3, #0xCA000000 - add r3, r3, #0xFE0000 - add r3, r3, #0xBA00 - add r3, r3, #0xBE - swp r3, r3, [r0] - mov r0, r3 - mov pc, lr diff --git a/src/libthread/Linux-power-asm.s b/src/libthread/Linux-power-asm.s deleted file mode 100644 index d6e21c157..000000000 --- a/src/libthread/Linux-power-asm.s +++ /dev/null @@ -1,16 +0,0 @@ - .globl _tas -_tas: - li %r0, 0 - mr %r4, %r3 - lis %r5, 0xcafe - ori %r5, %r5, 0xbabe -1: - lwarx %r3, %r0, %r4 - cmpwi %r3, 0 - bne 2f - stwcx. %r5, %r0, %r4 - bne- 1b -2: - sync - blr - diff --git a/src/libthread/Linux-sparc64-asm.s b/src/libthread/Linux-sparc64-asm.s deleted file mode 100644 index 422a1b244..000000000 --- a/src/libthread/Linux-sparc64-asm.s +++ /dev/null @@ -1,16 +0,0 @@ -! Actually sparc32 assembly. -! Debian's sparc64 port is a 32-bit user space. - - .section ".text", #alloc, #execinstr - .align 8 - .skip 16 - .global _tas -! .type _tas,2 -_tas: - or %g0,1,%o1 - swap [%o0],%o1 ! o0 points to lock; key is first word - retl - mov %o1, %o0 - - .size _tas,(.-_tas) - diff --git a/src/libthread/Linux.c b/src/libthread/Linux.c deleted file mode 100644 index 31577e876..000000000 --- a/src/libthread/Linux.c +++ /dev/null @@ -1,462 +0,0 @@ -#include "threadimpl.h" - -#undef exits -#undef _exits - -static int -timefmt(Fmt *fmt) -{ - static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - vlong ns; - Tm tm; - ns = nsec(); - tm = *localtime(time(0)); - return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", - mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, - (int)(ns%1000000000)/1000000); -} - -/* - * spin locks - */ -extern int _tas(int*); - -void -_threadunlock(Lock *l, ulong pc) -{ - USED(pc); - - l->held = 0; -} - -int -_threadlock(Lock *l, int block, ulong pc) -{ - int i; -static int first=1; -if(first) {first=0; fmtinstall('\001', timefmt);} - - USED(pc); - - /* once fast */ - if(!_tas(&l->held)) - return 1; - if(!block) - return 0; - - /* a thousand times pretty fast */ - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - sched_yield(); - } - /* now increasingly slow */ - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1); - } -fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10); - } -fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100); - } -fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1000); - } -fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10*1000); - } -fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc); - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100*1000); - } -fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc); - /* take your time */ - while(_tas(&l->held)) - usleep(1000*1000); - return 1; -} - -/* - * sleep and wakeup - */ -static void -ign(int x) -{ - USED(x); -} - -static void /*__attribute__((constructor))*/ -ignusr1(int restart) -{ - struct sigaction sa; - - memset(&sa, 0, sizeof sa); - sa.sa_handler = ign; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGUSR1); - if(restart) - sa.sa_flags = SA_RESTART; - sigaction(SIGUSR1, &sa, nil); -} - -void -_procsleep(_Procrendez *r) -{ - sigset_t mask; - - /* - * Go to sleep. - * - * Block USR1, set the handler to interrupt system calls, - * unlock the vouslock so our waker can wake us, - * and then suspend. - */ -again: - r->asleep = 1; - r->pid = getpid(); - - sigprocmask(SIG_SETMASK, nil, &mask); - sigaddset(&mask, SIGUSR1); - sigprocmask(SIG_SETMASK, &mask, nil); - ignusr1(0); - unlock(r->l); - sigdelset(&mask, SIGUSR1); - sigsuspend(&mask); - - /* - * We're awake. Make USR1 not interrupt system calls. - */ - lock(r->l); - ignusr1(1); - if(r->asleep && r->pid == getpid()){ - /* Didn't really wake up - signal from something else */ - goto again; - } -} - -void -_procwakeupandunlock(_Procrendez *r) -{ - int pid; - - pid = 0; - if(r->asleep){ - r->asleep = 0; - assert(r->pid >= 1); - pid = r->pid; - } - assert(r->l); - unlock(r->l); - if(pid) - kill(pid, SIGUSR1); -} - -/* - * process creation and exit - */ -typedef struct Stackfree Stackfree; -struct Stackfree -{ - Stackfree *next; - int pid; - int pid1; -}; -static Lock stacklock; -static Stackfree *stackfree; - -static void -delayfreestack(uchar *stk, int pid, int pid1) -{ - Stackfree *sf; - - sf = (Stackfree*)stk; - sf->pid = pid; - sf->pid1 = pid1; - lock(&stacklock); - sf->next = stackfree; - stackfree = sf; - unlock(&stacklock); -} - -static void -dofreestacks(void) -{ - Stackfree *sf, *last, *next; - - if(stackfree==nil || !canlock(&stacklock)) - return; - - for(last=nil,sf=stackfree; sf; last=sf,sf=next){ - next = sf->next; - if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH) - if(sf->pid1 >= 1 && kill(sf->pid1, 0) < 0 && errno == ESRCH){ - free(sf); - if(last) - last->next = next; - else - stackfree = next; - sf = last; - } - } - unlock(&stacklock); -} - -static int -startprocfn(void *v) -{ - void **a; - uchar *stk; - void (*fn)(void*); - Proc *p; - int pid0, pid1; - - a = (void**)v; - fn = a[0]; - p = a[1]; - stk = a[2]; - pid0 = (int)a[4]; - pid1 = getpid(); - free(a); - p->osprocid = pid1; - - (*fn)(p); - - delayfreestack(stk, pid0, pid1); - _exit(0); - return 0; -} - -/* - * indirect through here so that parent need not wait for child zombie - * - * slight race - if child exits and then another process starts before we - * manage to exit, we'll be running on a freed stack. - */ -static int -trampnowait(void *v) -{ - void **a; - int *kidpid; - - a = (void*)v; - kidpid = a[3]; - a[4] = (void*)getpid(); - *kidpid = clone(startprocfn, a[2]+65536-512, CLONE_VM|CLONE_FILES, a); - _exit(0); - return 0; -} - -void -_procstart(Proc *p, void (*fn)(Proc*)) -{ - void **a; - uchar *stk; - int pid, kidpid, status; - - dofreestacks(); - a = malloc(5*sizeof a[0]); - if(a == nil) - sysfatal("_procstart malloc: %r"); - stk = malloc(65536); - if(stk == nil) - sysfatal("_procstart malloc stack: %r"); - - a[0] = fn; - a[1] = p; - a[2] = stk; - a[3] = &kidpid; - kidpid = -1; - - pid = clone(trampnowait, stk+65536-16, CLONE_VM|CLONE_FILES, a); - if(pid > 0) - if(wait4(pid, &status, __WALL, 0) < 0) - fprint(2, "ffork wait4: %r\n"); - if(pid < 0 || kidpid < 0){ - fprint(2, "_procstart clone: %r\n"); - abort(); - } -} - -static char *threadexitsmsg; -void -sigusr2handler(int s) -{ -/* fprint(2, "%d usr2 %d\n", time(0), getpid()); */ - if(threadexitsmsg) - _exits(threadexitsmsg); -} - -void -threadexitsall(char *msg) -{ - static int pid[1024]; - int i, npid, mypid; - Proc *p; - - if(msg == nil) - msg = ""; - - /* - * Only one guy, ever, gets to run this. - * If two guys do it, inevitably they end up - * tripping over each other in the underlying - * C library exit() implementation, which is - * trying to run the atexit handlers and apparently - * not thread safe. This has been observed on - * both Linux and OpenBSD. Sigh. - */ - { - static Lock onelock; - if(!canlock(&onelock)) - _exits(threadexitsmsg); - threadexitsmsg = msg; - } - - mypid = getpid(); - lock(&_threadprocslock); - npid = 0; - for(p=_threadprocs; p; p=p->next) - if(p->osprocid != mypid && p->osprocid >= 1) - pid[npid++] = p->osprocid; - for(i=0; ipid == pid) - return p; - if(p->pid == 0){ - print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h); - break; - } - } - fprint(2, "myperproc %d (%s): cannot find self\n", pid, argv0); - abort(); - return nil; -} - -static Perproc* -newperproc(void) -{ - int i, pid, h; - Perproc *p; - - lock(&perlock); - pid = getpid(); - h = pid%nelem(perproc); - for(i=0; ipid == pid || p->pid == -1 || p->pid == 0){ - p->pid = pid; - unlock(&perlock); - return p; - } - } - fprint(2, "newperproc %d: out of procs\n", pid); - abort(); - return nil; -} - -Proc* -_threadproc(void) -{ - return myperproc()->proc; -} - -void -_threadsetproc(Proc *p) -{ - Perproc *pp; - - if(p) - p->osprocid = getpid(); - pp = newperproc(); - pp->proc = p; - if(p == nil) - pp->pid = -1; -} - -void -_pthreadinit(void) -{ - signal(SIGUSR2, sigusr2handler); -} - -void -_threadpexit(void) -{ - _exit(0); -} - -#ifdef __arm__ -void -makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) -{ - int i, *sp; - va_list arg; - - sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; - va_start(arg, argc); - for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); - va_end(arg); - uc->uc_mcontext.gregs[13] = (uint)sp; - uc->uc_mcontext.gregs[14] = (uint)fn; -} - -int -swapcontext(ucontext_t *oucp, const ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} -#endif diff --git a/src/libthread/NetBSD.c b/src/libthread/NetBSD.c index 37dabe9c9..31577e876 100644 --- a/src/libthread/NetBSD.c +++ b/src/libthread/NetBSD.c @@ -1 +1,462 @@ -#include "Linux.c" +#include "threadimpl.h" + +#undef exits +#undef _exits + +static int +timefmt(Fmt *fmt) +{ + static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + vlong ns; + Tm tm; + ns = nsec(); + tm = *localtime(time(0)); + return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", + mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, + (int)(ns%1000000000)/1000000); +} + +/* + * spin locks + */ +extern int _tas(int*); + +void +_threadunlock(Lock *l, ulong pc) +{ + USED(pc); + + l->held = 0; +} + +int +_threadlock(Lock *l, int block, ulong pc) +{ + int i; +static int first=1; +if(first) {first=0; fmtinstall('\001', timefmt);} + + USED(pc); + + /* once fast */ + if(!_tas(&l->held)) + return 1; + if(!block) + return 0; + + /* a thousand times pretty fast */ + for(i=0; i<1000; i++){ + if(!_tas(&l->held)) + return 1; + sched_yield(); + } + /* now increasingly slow */ + for(i=0; i<10; i++){ + if(!_tas(&l->held)) + return 1; + usleep(1); + } +fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc); + for(i=0; i<10; i++){ + if(!_tas(&l->held)) + return 1; + usleep(10); + } +fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc); + for(i=0; i<10; i++){ + if(!_tas(&l->held)) + return 1; + usleep(100); + } +fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc); + for(i=0; i<10; i++){ + if(!_tas(&l->held)) + return 1; + usleep(1000); + } +fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc); + for(i=0; i<10; i++){ + if(!_tas(&l->held)) + return 1; + usleep(10*1000); + } +fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc); + for(i=0; i<1000; i++){ + if(!_tas(&l->held)) + return 1; + usleep(100*1000); + } +fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc); + /* take your time */ + while(_tas(&l->held)) + usleep(1000*1000); + return 1; +} + +/* + * sleep and wakeup + */ +static void +ign(int x) +{ + USED(x); +} + +static void /*__attribute__((constructor))*/ +ignusr1(int restart) +{ + struct sigaction sa; + + memset(&sa, 0, sizeof sa); + sa.sa_handler = ign; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGUSR1); + if(restart) + sa.sa_flags = SA_RESTART; + sigaction(SIGUSR1, &sa, nil); +} + +void +_procsleep(_Procrendez *r) +{ + sigset_t mask; + + /* + * Go to sleep. + * + * Block USR1, set the handler to interrupt system calls, + * unlock the vouslock so our waker can wake us, + * and then suspend. + */ +again: + r->asleep = 1; + r->pid = getpid(); + + sigprocmask(SIG_SETMASK, nil, &mask); + sigaddset(&mask, SIGUSR1); + sigprocmask(SIG_SETMASK, &mask, nil); + ignusr1(0); + unlock(r->l); + sigdelset(&mask, SIGUSR1); + sigsuspend(&mask); + + /* + * We're awake. Make USR1 not interrupt system calls. + */ + lock(r->l); + ignusr1(1); + if(r->asleep && r->pid == getpid()){ + /* Didn't really wake up - signal from something else */ + goto again; + } +} + +void +_procwakeupandunlock(_Procrendez *r) +{ + int pid; + + pid = 0; + if(r->asleep){ + r->asleep = 0; + assert(r->pid >= 1); + pid = r->pid; + } + assert(r->l); + unlock(r->l); + if(pid) + kill(pid, SIGUSR1); +} + +/* + * process creation and exit + */ +typedef struct Stackfree Stackfree; +struct Stackfree +{ + Stackfree *next; + int pid; + int pid1; +}; +static Lock stacklock; +static Stackfree *stackfree; + +static void +delayfreestack(uchar *stk, int pid, int pid1) +{ + Stackfree *sf; + + sf = (Stackfree*)stk; + sf->pid = pid; + sf->pid1 = pid1; + lock(&stacklock); + sf->next = stackfree; + stackfree = sf; + unlock(&stacklock); +} + +static void +dofreestacks(void) +{ + Stackfree *sf, *last, *next; + + if(stackfree==nil || !canlock(&stacklock)) + return; + + for(last=nil,sf=stackfree; sf; last=sf,sf=next){ + next = sf->next; + if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH) + if(sf->pid1 >= 1 && kill(sf->pid1, 0) < 0 && errno == ESRCH){ + free(sf); + if(last) + last->next = next; + else + stackfree = next; + sf = last; + } + } + unlock(&stacklock); +} + +static int +startprocfn(void *v) +{ + void **a; + uchar *stk; + void (*fn)(void*); + Proc *p; + int pid0, pid1; + + a = (void**)v; + fn = a[0]; + p = a[1]; + stk = a[2]; + pid0 = (int)a[4]; + pid1 = getpid(); + free(a); + p->osprocid = pid1; + + (*fn)(p); + + delayfreestack(stk, pid0, pid1); + _exit(0); + return 0; +} + +/* + * indirect through here so that parent need not wait for child zombie + * + * slight race - if child exits and then another process starts before we + * manage to exit, we'll be running on a freed stack. + */ +static int +trampnowait(void *v) +{ + void **a; + int *kidpid; + + a = (void*)v; + kidpid = a[3]; + a[4] = (void*)getpid(); + *kidpid = clone(startprocfn, a[2]+65536-512, CLONE_VM|CLONE_FILES, a); + _exit(0); + return 0; +} + +void +_procstart(Proc *p, void (*fn)(Proc*)) +{ + void **a; + uchar *stk; + int pid, kidpid, status; + + dofreestacks(); + a = malloc(5*sizeof a[0]); + if(a == nil) + sysfatal("_procstart malloc: %r"); + stk = malloc(65536); + if(stk == nil) + sysfatal("_procstart malloc stack: %r"); + + a[0] = fn; + a[1] = p; + a[2] = stk; + a[3] = &kidpid; + kidpid = -1; + + pid = clone(trampnowait, stk+65536-16, CLONE_VM|CLONE_FILES, a); + if(pid > 0) + if(wait4(pid, &status, __WALL, 0) < 0) + fprint(2, "ffork wait4: %r\n"); + if(pid < 0 || kidpid < 0){ + fprint(2, "_procstart clone: %r\n"); + abort(); + } +} + +static char *threadexitsmsg; +void +sigusr2handler(int s) +{ +/* fprint(2, "%d usr2 %d\n", time(0), getpid()); */ + if(threadexitsmsg) + _exits(threadexitsmsg); +} + +void +threadexitsall(char *msg) +{ + static int pid[1024]; + int i, npid, mypid; + Proc *p; + + if(msg == nil) + msg = ""; + + /* + * Only one guy, ever, gets to run this. + * If two guys do it, inevitably they end up + * tripping over each other in the underlying + * C library exit() implementation, which is + * trying to run the atexit handlers and apparently + * not thread safe. This has been observed on + * both Linux and OpenBSD. Sigh. + */ + { + static Lock onelock; + if(!canlock(&onelock)) + _exits(threadexitsmsg); + threadexitsmsg = msg; + } + + mypid = getpid(); + lock(&_threadprocslock); + npid = 0; + for(p=_threadprocs; p; p=p->next) + if(p->osprocid != mypid && p->osprocid >= 1) + pid[npid++] = p->osprocid; + for(i=0; ipid == pid) + return p; + if(p->pid == 0){ + print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h); + break; + } + } + fprint(2, "myperproc %d (%s): cannot find self\n", pid, argv0); + abort(); + return nil; +} + +static Perproc* +newperproc(void) +{ + int i, pid, h; + Perproc *p; + + lock(&perlock); + pid = getpid(); + h = pid%nelem(perproc); + for(i=0; ipid == pid || p->pid == -1 || p->pid == 0){ + p->pid = pid; + unlock(&perlock); + return p; + } + } + fprint(2, "newperproc %d: out of procs\n", pid); + abort(); + return nil; +} + +Proc* +_threadproc(void) +{ + return myperproc()->proc; +} + +void +_threadsetproc(Proc *p) +{ + Perproc *pp; + + if(p) + p->osprocid = getpid(); + pp = newperproc(); + pp->proc = p; + if(p == nil) + pp->pid = -1; +} + +void +_pthreadinit(void) +{ + signal(SIGUSR2, sigusr2handler); +} + +void +_threadpexit(void) +{ + _exit(0); +} + +#ifdef __arm__ +void +makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) +{ + int i, *sp; + va_list arg; + + sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; + va_start(arg, argc); + for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); + va_end(arg); + uc->uc_mcontext.gregs[13] = (uint)sp; + uc->uc_mcontext.gregs[14] = (uint)fn; +} + +int +swapcontext(ucontext_t *oucp, const ucontext_t *ucp) +{ + if(getcontext(oucp) == 0) + setcontext(ucp); + return 0; +} +#endif diff --git a/src/libthread/mkfile b/src/libthread/mkfile index 31c4c7e5d..a083fd013 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -16,7 +16,6 @@ OFILES=\ <$PLAN9/src/mksyslib HFILES=thread.h threadimpl.h -NetBSD.$O: Linux.c tprimes: test/tprimes.$O 9l -o $target test/$target.$O From cb8f7357867a2a5d0bd742ceeb77bce9ad5f435c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:10:11 -0500 Subject: [PATCH 198/323] all: remove Linux 2.4 vs 2.6 detection Linux 2.4 is dead. (The libthread code hasn't worked for Linux 2.4 for a long time.) --- INSTALL | 23 +++------------------- bin/9c | 14 +++---------- bin/9l | 17 ++++++---------- include/u.h | 6 ++---- lib/linux-isnptl.c | 16 --------------- man/man1/9c.1 | 12 +++++------- man/man1/install.1 | 23 ++++++---------------- src/libthread/README.Linux | 40 -------------------------------------- src/libthread/sysofiles.sh | 7 +++---- 9 files changed, 28 insertions(+), 130 deletions(-) delete mode 100644 lib/linux-isnptl.c delete mode 100644 src/libthread/README.Linux diff --git a/INSTALL b/INSTALL index 0291e7135..11d350058 100755 --- a/INSTALL +++ b/INSTALL @@ -66,23 +66,6 @@ DragonFly|*BSD) esac ( -if [ `uname` = Linux ]; then - # On Linux, we use the kernel version to decide whether - # to use pthreads or not. On 2.6 versions that aren't - # linking with NPTL by default, pretend to be an older kernel. - echo "* Running on Linux: checking for NPTL..." - gcc lib/linux-isnptl.c -lpthread - if ./a.out >/dev/null - then - echo " NPTL found." - echo "SYSVERSION=2.6.x" >>$PLAN9/config - else - echo " NPTL not found." - echo "SYSVERSION=2.4.x" >>$PLAN9/config - fi - rm -f ./a.out -fi - if [ `uname` = SunOS ]; then # On Solaris x86, uname -p cannot be trusted. echo "* Running on Solaris: checking architecture..." @@ -168,7 +151,7 @@ if $dobuild; then echo "* Error: mk failed to build." exit 1 fi - + echo "* Building everything (be patient)..." mk clean mk libs-nuke @@ -216,13 +199,13 @@ if $doinstall; then mk man ) fi - + if [ -x LOCAL.INSTALL ]; then echo "* Running local modifications..." echo cd `pwd`';' ./LOCAL.INSTALL ./LOCAL.INSTALL fi - + echo "* Done. " echo " " echo "* Add these to your profile environment." diff --git a/bin/9c b/bin/9c index 20919e9ac..b07d01492 100755 --- a/bin/9c +++ b/bin/9c @@ -93,28 +93,20 @@ case "$tag" in useclang cflags="$ngflags -g3 -m32" ;; -*Darwin*) usegcc +*Darwin*) usegcc cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; -*Linux*) usegcc +*Linux*) usegcc case "${CC9:-gcc}" in tcc) cc=tcc cflags="-c -g" ;; esac - case "${SYSVERSION:-`uname -r`}" in - 2.4.*) - cflags="$cflags -D__Linux24__" - ;; - 2.6.*) - cflags="$cflags -D__Linux26__" - ;; - esac ;; *OSF1*) cc=${CC9:-cc}; cflags="-g -O -c" ;; *SunOS*-cc) cc=cc; - cflags="-mt -g -O -c -xCC -D__sun__" + cflags="-mt -g -O -c -xCC -D__sun__" u=`uname` v=`uname -r` s=`echo $u$v | tr '. ' '__'` diff --git a/bin/9l b/bin/9l index 8af271543..a10aab728 100755 --- a/bin/9l +++ b/bin/9l @@ -25,12 +25,7 @@ case "$tag" in *Linux*) ld=${CC9:-gcc} userpath=true - extralibs="$extralibs -lutil -lresolv" - case "${SYSVERSION:-`uname -r`}" in - 2.6.* | [3-9].* | [1-9][0-9].*) - extralibs="$extralibs -lpthread" - ;; - esac + extralibs="$extralibs -lutil -lresolv -lpthread" ;; *Darwin*x86_64*) ld="${CC9:-gcc} -m64" @@ -41,7 +36,7 @@ case "$tag" in *SunOS*) ld="${CC9:-cc} -g" extralibs="$extralibs -lrt -lpthread -lsocket -lnsl" - # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH + # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH for i in "$libsl $@" do case "$i" in @@ -106,7 +101,7 @@ then lpaths="$lpaths $l" esac done - + if $verbose then echo "ofiles $ofiles" @@ -309,7 +304,7 @@ then frameworks="" for i in $autoframeworks - do + do frameworks="-framework $i $frameworks" done fi @@ -335,8 +330,8 @@ fi xtmp="${TMPDIR-/tmp}/9l.$$.$USER.out" xxout() { - sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | - egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' + sed 's/.*: In function `[^:]*: *//' $xtmp | egrep . | + egrep -v 'is (often|almost always) misused|is dangerous, better use|text-based stub' rm -f $xtmp } diff --git a/include/u.h b/include/u.h index 8a715b1ed..3bea890e3 100644 --- a/include/u.h +++ b/include/u.h @@ -66,10 +66,8 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #if defined(__linux__) # include -# if defined(__Linux26__) -# include -# define PLAN9PORT_USING_PTHREADS 1 -# endif +# include +# define PLAN9PORT_USING_PTHREADS 1 # if defined(__USE_MISC) # undef _NEEDUSHORT # undef _NEEDUINT diff --git a/lib/linux-isnptl.c b/lib/linux-isnptl.c deleted file mode 100644 index e4c23c637..000000000 --- a/lib/linux-isnptl.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include - -int -main(void) -{ - ulong x; - - x = (ulong)pthread_self(); - printf("%lx\n", x); - if(x < 1024*1024) - exit(1); /* NOT NPTL */ - exit(0); -} diff --git a/man/man1/9c.1 b/man/man1/9c.1 index fb04a2961..8d24d67d5 100644 --- a/man/man1/9c.1 +++ b/man/man1/9c.1 @@ -79,9 +79,7 @@ to the include path. .I 9c also defines .B __sun__ -on SunOS systems and -.B __Linux26__ -on Linux systems with 2.6-series kernels. +on SunOS systems. .PP .I 9a assembles the named files into object files for the current system. @@ -136,13 +134,13 @@ but always provides the following key characters: .TP .B d -Delete -.I files +Delete +.I files from the archive file. .TP .B r Replace -.I files +.I files in the archive file, or add them if missing. .TP .B t @@ -181,7 +179,7 @@ Normally will create a new archive when .I afile does not exist, and give a warning. -Option +Option .B c discards any old contents and suppresses the warning. .PD diff --git a/man/man1/install.1 b/man/man1/install.1 index be35bd354..8fcc9e418 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -32,7 +32,7 @@ rebuilds and installs everything, and then cleans up. .PP There are a few files in tree which have the root hard-coded in them. -After the build, +After the build, .I INSTALL edits these files to replace the string .B /usr/local/plan9 @@ -71,31 +71,20 @@ expectations of certain package management systems. .PP At the end of the installation, .I INSTALL -prints suggested settings for the environment variables +prints suggested settings for the environment variables .B $PLAN9 and .BR $PATH . .PP -Plan 9 from User Space uses different threading implementations on Linux 2.6 and -later kernels than on 2.4 and earlier; -and on FreeBSD 5 and later kernels than on FreeBSD 4 and earlier. -Running binaries from one class on another will not work. -.PP -Some Linux 2.6 systems (e.g., Gentoo) do not use the new NPTL pthread library -even though the kernel supports them. On these systems, plan9port must -fall back on the threading code intended for Linux 2.4. To accomplish this, .I INSTALL -checks whether the running system uses NPTL and sets -.B SYSVERSION -in -.B \*9/config -accordingly. +writes various autodetected settings to +.BR \*9/config . The file .B \*9/LOCAL.config is appended to .B config after this auto-detection and can be used to override the choices. -If +If .B LOCAL.config contains a line .B WSYSTYPE=nowsys @@ -110,7 +99,7 @@ On Ubuntu, it suffices to install xorg-dev. can safely be repeated to rebuild the system from scratch. .PP Once the system is built for the first time, -it can be maintained and rebuilt using +it can be maintained and rebuilt using .IR mk (1). To rebuild individual commands or libraries, run diff --git a/src/libthread/README.Linux b/src/libthread/README.Linux deleted file mode 100644 index 04c491a8b..000000000 --- a/src/libthread/README.Linux +++ /dev/null @@ -1,40 +0,0 @@ -Thread support on Linux is confused by the recent thread local storage (TLS) -support that has been put into the ELF tool chain. The TLS libraries are -installed in /lib/tls on most Linux systems. - -We provide two different implementations of the os-dependent parts -of libthread for Linux. The first is intended for use on Linux 2.4 and earlier -kernels, which do not support TLS. It is in Linux.c and Linuxasm.c and -does not use the pthread interface. The second is intended for Linux 2.6 -and later kernels, which do support TLS. It is in pthread.c and uses the -standard pthread interface. It expects to be linked against the TLS-aware -thread library aka NPTL. - -If you use Linux.c and Linuxasm.c with TLS libraries, they do not -set up the TLS properly so you will get incorrect programs. -For example, there will only be one errno among all the procs -in your program instead of one per proc. The pthread NPTL -implementation is needed to use the TLS libraries properly. - -If you use pthread.c without TLS libraries (i.e., with the old Linux -pthread library known as LinuxThreads), then you will also get -incorrect programs, although more obviously so. The LinuxThreads -library assumes it can look at the stack pointer to distinguish between -threads, but libthread does its own stack management, breaking this -assumption. If you run a pthread-compiled program with the -LinuxThreads library, LinuxThreads itself will cause a segmentation -fault in __pthread_getspecific() the first time it is called from a -non-standard stack. - -So, it is important that you compile binaries that match your -system's choice of TLS vs. not-TLS libraries. The hard part is figuring -out which your system has chosen. Plan9port looks at the kernel -version you are running and assumes that on kernels that support -TLS (2.6+) you will be using TLS. - -Apparently Gentoo and maybe other distributions do not follow this rule. -They use non-TLS libraries even on kernels that can support TLS. -To accomodate them, you can add a line SYSVERSION=2.4 to $PLAN9/config -to force the build to think you are running an old kernel. -The INSTALL script sets up this file automatically on Linux systems. - diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 30a4c3388..fd60f1314 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -2,12 +2,11 @@ test -f $PLAN9/config && . $PLAN9/config -tag="$OBJTYPE-$SYSNAME-${SYSVERSION:-`uname -r`}-${CC9:-cc}" -case "$tag" in -*-NetBSD-*) +case "$SYSNAME" in +NetBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o ;; -*-OpenBSD-*) +OpenBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o ;; *) From ac8042dfa9819f76ccfedd4aa36c1239322808b8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 21:14:20 -0500 Subject: [PATCH 199/323] libthread: rm NetBSD pthread reference in sysofiles.sh It may be that pthreads on NetBSD is now good enough, but the build as written (introduced in 23a2368 at my suggestion) is certainly broken, since both NetBSD.c and pthread.c define the same functions. If NetBSD does support pthreads now, then a few things should happen together: - libthread/sysofiles.sh should drop its top NetBSD case entirely - libthread/NetBSD.c should be deleted - libthread/NetBSD-*-asm.s should be deleted - include/u.h's NetBSD case should define PLAN9PORT_USING_PTHREADS and #include For now, restore to less clearly broken build. --- src/libthread/sysofiles.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index fd60f1314..9a7301a8e 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -4,7 +4,7 @@ test -f $PLAN9/config && . $PLAN9/config case "$SYSNAME" in NetBSD) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o pthread.o stkmalloc.o + echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; OpenBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o From 41b3e8b9893a8561af7e85ca98444bc284b4013d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 22:39:22 -0500 Subject: [PATCH 200/323] libthread: use consistent stack calculation code in makecontext Also reduce duplication: makecontext is per-arch not per-os-arch. May fix #353. --- .../{OpenBSD-386.c => 386-ucontext.c} | 2 +- src/libthread/COPYRIGHT | 6 +-- src/libthread/Darwin-x86_64-swapcontext.c | 38 ------------------- src/libthread/NetBSD.c | 25 ------------ ...Linux-arm-swapcontext.c => arm-ucontext.c} | 2 +- src/libthread/mkfile | 4 +- .../{OpenBSD-power.c => power-ucontext.c} | 6 ++- ...arc64-swapcontext.c => sparc64-ucontext.c} | 0 src/libthread/sysofiles.sh | 29 ++++++++++---- src/libthread/threadimpl.h | 3 ++ .../{OpenBSD-x86_64.c => x86_64-ucontext.c} | 4 +- 11 files changed, 36 insertions(+), 83 deletions(-) rename src/libthread/{OpenBSD-386.c => 386-ucontext.c} (87%) delete mode 100644 src/libthread/Darwin-x86_64-swapcontext.c rename src/libthread/{Linux-arm-swapcontext.c => arm-ucontext.c} (88%) rename src/libthread/{OpenBSD-power.c => power-ucontext.c} (75%) rename src/libthread/{Linux-sparc64-swapcontext.c => sparc64-ucontext.c} (100%) rename src/libthread/{OpenBSD-x86_64.c => x86_64-ucontext.c} (77%) diff --git a/src/libthread/OpenBSD-386.c b/src/libthread/386-ucontext.c similarity index 87% rename from src/libthread/OpenBSD-386.c rename to src/libthread/386-ucontext.c index 89bfedcd9..3afa9513d 100644 --- a/src/libthread/OpenBSD-386.c +++ b/src/libthread/386-ucontext.c @@ -5,7 +5,7 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) { int *sp; - sp = (int*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/4; + sp = USPALIGN(ucp, 4); sp -= argc; memmove(sp, &argc+1, argc*sizeof(int)); *--sp = 0; /* return address */ diff --git a/src/libthread/COPYRIGHT b/src/libthread/COPYRIGHT index f4ee354e9..d08209658 100644 --- a/src/libthread/COPYRIGHT +++ b/src/libthread/COPYRIGHT @@ -45,9 +45,9 @@ Contains parts of an earlier library that has: === -The above notices do *NOT* apply to Linux-sparc64-context.S -or to Linux-sparc64-swapcontext.c. Those are functions from +The above notices do *NOT* apply to Linux-sparc64-context.S +or to sparc64-ucontext.c. Those are functions from the GNU C library and are provided for systems that use the GNU C -library but somehow are missing those functions. They are +library but somehow are missing those functions. They are distributed under the Lesser GPL; see COPYING.SPARC64-CONTEXT. diff --git a/src/libthread/Darwin-x86_64-swapcontext.c b/src/libthread/Darwin-x86_64-swapcontext.c deleted file mode 100644 index c29ddb5ee..000000000 --- a/src/libthread/Darwin-x86_64-swapcontext.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) -{ - uintptr *sp; - va_list arg; - -//fprint(2, "makecontext %d\n", argc); - if(argc != 2) - sysfatal("libthread: makecontext misused"); - va_start(arg, argc); - uc->mc.di = va_arg(arg, uint); - uc->mc.si = va_arg(arg, uint); -//fprint(2, "%ux %ux\n", uc->mc.di, uc->mc.si); - va_end(arg); - - sp = (uintptr*)((char*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size); - /* - * Stack pointer at call instruction (before return address - * gets pushed) must be 16-byte aligned. - */ - if((uintptr)sp%4) - abort(); - while((uintptr)sp%16 != 0) - sp--; - *--sp = 0; // fn's return address - *--sp = (uintptr)fn; // return address of setcontext - uc->mc.sp = (uintptr)sp; -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/NetBSD.c b/src/libthread/NetBSD.c index 31577e876..2b14146b8 100644 --- a/src/libthread/NetBSD.c +++ b/src/libthread/NetBSD.c @@ -435,28 +435,3 @@ _threadpexit(void) { _exit(0); } - -#ifdef __arm__ -void -makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) -{ - int i, *sp; - va_list arg; - - sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; - va_start(arg, argc); - for(i=0; i<4 && iuc_mcontext.gregs[i] = va_arg(arg, uint); - va_end(arg); - uc->uc_mcontext.gregs[13] = (uint)sp; - uc->uc_mcontext.gregs[14] = (uint)fn; -} - -int -swapcontext(ucontext_t *oucp, const ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} -#endif diff --git a/src/libthread/Linux-arm-swapcontext.c b/src/libthread/arm-ucontext.c similarity index 88% rename from src/libthread/Linux-arm-swapcontext.c rename to src/libthread/arm-ucontext.c index fc0dfddaa..512ca973d 100644 --- a/src/libthread/Linux-arm-swapcontext.c +++ b/src/libthread/arm-ucontext.c @@ -6,7 +6,7 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) int i, *sp; va_list arg; - sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4; + sp = USPALIGN(uc, 4); va_start(arg, argc); for(i=0; i<4 && iuc_mcontext.arm_r0)[i] = va_arg(arg, uint); diff --git a/src/libthread/mkfile b/src/libthread/mkfile index a083fd013..45b780393 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -37,8 +37,8 @@ OpenBSD-%-asm.$O: OpenBSD-%-asm.S Linux-sparc64-context.$O: Linux-sparc64-context.S $CC -m64 -mcpu=v9 $CFLAGS Linux-sparc64-context.S -Linux-sparc64-swapcontext.$O: Linux-sparc64-swapcontext.c - $CC -m64 -mcpu=v9 $CFLAGS Linux-sparc64-swapcontext.c +sparc64-ucontext.$O: sparc64-ucontext.c + $CC -m64 -mcpu=v9 $CFLAGS sparc64-ucontext.c test:V: tprimes tspawn primes 1 10007 >p1.txt diff --git a/src/libthread/OpenBSD-power.c b/src/libthread/power-ucontext.c similarity index 75% rename from src/libthread/OpenBSD-power.c rename to src/libthread/power-ucontext.c index eab711f22..32a8e931f 100644 --- a/src/libthread/OpenBSD-power.c +++ b/src/libthread/power-ucontext.c @@ -6,12 +6,14 @@ makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ulong *sp, *tos; va_list arg; - tos = (ulong*)ucp->uc_stack.ss_sp+ucp->uc_stack.ss_size/sizeof(ulong); - sp = (ulong*)((ulong)(tos-16) & ~15); + if(argc != 2) + sysfatal("libthread: makecontext misused"); + sp = USPALIGN(ucp, 16); ucp->mc.pc = (long)func; ucp->mc.sp = (long)sp; va_start(arg, argc); ucp->mc.r3 = va_arg(arg, long); + ucp->mc.r4 = va_arg(arg, long); va_end(arg); } diff --git a/src/libthread/Linux-sparc64-swapcontext.c b/src/libthread/sparc64-ucontext.c similarity index 100% rename from src/libthread/Linux-sparc64-swapcontext.c rename to src/libthread/sparc64-ucontext.c diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 9a7301a8e..8a65d0f63 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -7,24 +7,37 @@ NetBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; OpenBSD) - echo ${SYSNAME}-${OBJTYPE}-asm.o ${SYSNAME}-${OBJTYPE}.o pthread.o stkmmap.o + echo ${SYSNAME}-${OBJTYPE}-asm.o pthread.o stkmmap.o ;; *) echo pthread.o stkmalloc.o esac +# Various libc don't supply swapcontext, makecontext, so we do. case "$OBJTYPE-$SYSNAME" in -sparc64-Linux) - # Debian glibc doesn't supply swapcontext, makecontext - # so we supply our own copy from the latest glibc. - echo Linux-sparc64-context.o Linux-sparc64-swapcontext.o +386-OpenBSD) + echo 386-ucontext.o ;; arm-Linux) - # ARM doesn't supply them either. - echo Linux-arm-context.o Linux-arm-swapcontext.o + echo arm-ucontext.o + echo Linux-arm-context.o # setcontext, getcontext + ;; +arm-NetBSD) + echo arm-ucontext.o + ;; +power-OpenBSD) + echo power-ucontext.o + ;; +sparc64-Linux) + echo sparc64-ucontext.o + echo Linux-sparc64-swapcontext.o # setcontext, getcontext ;; x86_64-Darwin) - echo Darwin-x86_64-asm.o Darwin-x86_64-swapcontext.o + echo x86_64-ucontext.o + echo Darwin-x86_64-asm.o # setcontext, getcontext + ;; +x86_64-OpenBSD) + echo x86_64-ucontext.o ;; esac diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 5b6d74cc8..cceb1b8e7 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -188,3 +188,6 @@ extern void _threadpexit(void); extern void _threaddaemonize(void); extern void *_threadstkalloc(int); extern void _threadstkfree(void*, int); + +#define USPALIGN(ucp, align) \ + (void*)((((uintptr)(ucp)->uc_stack.ss_sp+(ucp)->uc_stack.ss_size)-(align))&~((align)-1)) diff --git a/src/libthread/OpenBSD-x86_64.c b/src/libthread/x86_64-ucontext.c similarity index 77% rename from src/libthread/OpenBSD-x86_64.c rename to src/libthread/x86_64-ucontext.c index 27931456d..5d1aaefc1 100644 --- a/src/libthread/OpenBSD-x86_64.c +++ b/src/libthread/x86_64-ucontext.c @@ -6,16 +6,14 @@ makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) uintptr *sp; va_list arg; -//fprint(2, "makecontext %d\n", argc); if(argc != 2) sysfatal("libthread: makecontext misused"); va_start(arg, argc); uc->mc.di = va_arg(arg, uint); uc->mc.si = va_arg(arg, uint); -//fprint(2, "%ux %ux\n", uc->mc.di, uc->mc.si); va_end(arg); - sp = (uintptr*)((char*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size); + sp = USPALIGN(uc, 16); *--sp = 0; // fn's return address *--sp = (uintptr)fn; // return address of setcontext uc->mc.sp = (uintptr)sp; From 37e7d24c0cb9fd2d18ab332980c31cf470454d93 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 22:52:04 -0500 Subject: [PATCH 201/323] libthread: rm OpenBSD tas implementations OpenBSD is using pthreads now, so no need for tas. --- src/libthread/OpenBSD-386-asm.s | 9 +-------- src/libthread/OpenBSD-power-asm.S | 15 --------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/libthread/OpenBSD-386-asm.s b/src/libthread/OpenBSD-386-asm.s index 421698534..ed18d2f0b 100644 --- a/src/libthread/OpenBSD-386-asm.s +++ b/src/libthread/OpenBSD-386-asm.s @@ -1,10 +1,3 @@ -.globl _tas -_tas: - movl $0xCAFEBABE, %eax - movl 4(%esp), %ecx - xchgl %eax, 0(%ecx) - ret - .globl getmcontext getmcontext: movl 4(%esp), %eax @@ -17,7 +10,7 @@ getmcontext: movl %esi, 24(%eax) movl %ebp, 28(%eax) movl %ebx, 36(%eax) - movl %edx, 40(%eax) + movl %edx, 40(%eax) movl %ecx, 44(%eax) movl $1, 48(%eax) /* %eax */ diff --git a/src/libthread/OpenBSD-power-asm.S b/src/libthread/OpenBSD-power-asm.S index 03b46e7be..36035eb56 100644 --- a/src/libthread/OpenBSD-power-asm.S +++ b/src/libthread/OpenBSD-power-asm.S @@ -1,18 +1,3 @@ -ENTRY(_tas) - li %r0, 0 - mr %r4, %r3 - lis %r5, 0xcafe - ori %r5, %r5, 0xbabe -1: - lwarx %r3, %r0, %r4 - cmpwi %r3, 0 - bne 2f - stwcx. %r5, %r0, %r4 - bne- 1b -2: - sync - blr - ENTRY(_getmcontext) /* xxx: instruction scheduling */ mflr %r0 mfcr %r5 From 4698bde2367f971fed3924f2dee736e0dfe37bb9 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 23:00:26 -0500 Subject: [PATCH 202/323] libthread: clean up sysofiles.sh a bit more --- src/libthread/sysofiles.sh | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 8a65d0f63..20811cdfe 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -7,37 +7,22 @@ NetBSD) echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o ;; OpenBSD) - echo ${SYSNAME}-${OBJTYPE}-asm.o pthread.o stkmmap.o + echo pthread.o stkmmap.o ;; *) echo pthread.o stkmalloc.o esac # Various libc don't supply swapcontext, makecontext, so we do. -case "$OBJTYPE-$SYSNAME" in -386-OpenBSD) - echo 386-ucontext.o - ;; -arm-Linux) - echo arm-ucontext.o - echo Linux-arm-context.o # setcontext, getcontext - ;; -arm-NetBSD) - echo arm-ucontext.o - ;; -power-OpenBSD) - echo power-ucontext.o - ;; -sparc64-Linux) - echo sparc64-ucontext.o - echo Linux-sparc64-swapcontext.o # setcontext, getcontext - ;; -x86_64-Darwin) - echo x86_64-ucontext.o - echo Darwin-x86_64-asm.o # setcontext, getcontext - ;; -x86_64-OpenBSD) - echo x86_64-ucontext.o +case "$SYSNAME-$OBJTYPE" in +Darwin-x86_64 | Linux-arm | Linux-sparc64 | NetBSD-arm | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) + echo $OBJTYPE-ucontext.o ;; esac +# A few libc don't supply setcontext, getcontext, so we do. +case "$SYSNAME-$OBJTYPE" in +Darwin-x86_64 | Linux-arm | Linux-sparc64 | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) + echo $SYSNAME-$OBJTYPE-asm.o + ;; +esac From f6c9f7b14c9dce53fff6020200b28c4e25621e87 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 19 Jan 2020 23:04:03 -0500 Subject: [PATCH 203/323] libthread: fix test deps, cleanup in mkfile --- src/libthread/mkfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libthread/mkfile b/src/libthread/mkfile index 45b780393..8a77a3161 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -24,6 +24,8 @@ tspawn: test/tspawn.$O tspawnloop: test/tspawnloop.$O 9l -o $target test/$target.$O +tprimes tspawn tspawnloop: $PLAN9/lib/$LIB + %.$O: %.c $CC -o $target $CFLAGS -I. $stem.c @@ -50,4 +52,5 @@ test:V: tprimes tspawn echo tspawn should take 3 seconds, not 6 $PLAN9/bin/time ./tspawn sleep 3 >/dev/null -CLEANFILES=p1.txt p2.txt tp1.txt tp2.txt test/*.$O +CLEANFILES=p1.txt p2.txt tp1.txt tp2.txt test/*.$O tprimes tspawn + From 93e2e820a5551ba3d0a1e0f0fbd4c5eb65e18ce6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 24 Jan 2020 13:08:36 -0500 Subject: [PATCH 204/323] acme: report close failure in Put, this time for sure Missed in 0b349f6f that Bterm is not closing fd. --- src/cmd/acme/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index 1d50f92fe..be7936ae0 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -699,7 +699,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; @@ -763,9 +763,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 } @@ -785,10 +786,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; @@ -821,11 +821,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: From 4197af4122bc06cf4062ca2d1d5bc8f973e37cf1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 24 Jan 2020 13:09:55 -0500 Subject: [PATCH 205/323] libthread: comment stack border a bit more --- src/libthread/thread.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 2e654863f..f657b5b24 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -136,10 +136,16 @@ threadalloc(void (*fn)(void*), void *arg, uint stack) sysfatal("threadalloc getcontext: %r"); //print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); - /* call makecontext to do the real work. */ - /* leave a few words open on both ends */ - t->context.uc.uc_stack.ss_sp = (void*)(t->stk+8); - t->context.uc.uc_stack.ss_size = t->stksize-64; + /* + * Call makecontext to do the real work. + * To avoid various mistakes on other system software, + * debuggers, and so on, don't get too close to both + * ends of the stack. Just staying away is much easier + * than debugging everything (outside our control) + * that has off-by-one errors. + */ + t->context.uc.uc_stack.ss_sp = (void*)(t->stk+64); + t->context.uc.uc_stack.ss_size = t->stksize-2*64; #if defined(__sun__) && !defined(__MAKECONTEXT_V2_SOURCE) /* sigh */ /* can avoid this with __MAKECONTEXT_V2_SOURCE but only on SunOS 5.9 */ t->context.uc.uc_stack.ss_sp = From f66f0a587b48337388296c8f1820f9b3dbfd0085 Mon Sep 17 00:00:00 2001 From: Martin Palma Date: Mon, 3 Feb 2020 20:59:58 +0100 Subject: [PATCH 206/323] devdraw: fix `cmd-r` to toggle retina vs. non-retina mode on macOS (#361) and not unexpectedly quitting an application. Fixes #360 --- src/cmd/devdraw/mac-screen.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index dedbfb84b..c6e58341d 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -510,7 +510,7 @@ - (void)flush:(Rectangle)r { rpc_resizeimg(Client *c) { DrawView *view = (__bridge DrawView*)c->view; - dispatch_sync(dispatch_get_main_queue(), ^(void){ + dispatch_async(dispatch_get_main_queue(), ^(void){ [view resizeimg]; }); } From 0237dec768a4ee36ae9e18ce8566d2c999d78410 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 11 Feb 2020 09:18:57 +0000 Subject: [PATCH 207/323] libthread: fix ARM build by renaming file Fixes #363 Change-Id: Ic8ad5ccce3935fdf00732d78d3024b535db90447 --- src/libthread/{Linux-arm-context.s => Linux-arm-asm.s} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/libthread/{Linux-arm-context.s => Linux-arm-asm.s} (100%) diff --git a/src/libthread/Linux-arm-context.s b/src/libthread/Linux-arm-asm.s similarity index 100% rename from src/libthread/Linux-arm-context.s rename to src/libthread/Linux-arm-asm.s From 92aa0e13ad8cec37936998a66eb728bfca88d689 Mon Sep 17 00:00:00 2001 From: Larkin Nickle Date: Sat, 22 Feb 2020 16:26:25 -0500 Subject: [PATCH 208/323] Fix broken references to plan9.bell-labs.com/plan9 Fixes #357 --- dist/deb.html | 2 +- dist/main.html | 6 +++--- dist/pkg/main | 2 +- dist/unix.html | 12 ++++++------ install.txt | 2 +- man/man1/0intro.1 | 2 +- unix/NOTICE.bio | 2 +- unix/NOTICE.fmt | 2 +- unix/NOTICE.mk | 2 +- unix/NOTICE.regexp | 2 +- unix/NOTICE.utf | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dist/deb.html b/dist/deb.html index 840f67556..b02020855 100644 --- a/dist/deb.html +++ b/dist/deb.html @@ -20,7 +20,7 @@
Plan 9 from User Space (aka plan9port) is a port of many Plan 9 programs from their native - Plan 9 + Plan 9 environment to Unix-like operating systems.
diff --git a/dist/main.html b/dist/main.html index f0b519113..2cc944ed1 100644 --- a/dist/main.html +++ b/dist/main.html @@ -41,7 +41,7 @@
Plan 9 from User Space (aka plan9port) is a port of many Plan 9 programs from their native - Plan 9 + Plan 9 environment to Unix-like operating systems.
@@ -89,7 +89,7 @@ Most obviously, plan9port derives from - Plan 9 from Bell Labs + Plan 9 from Bell Labs and would not exist without the work of the Plan 9 team over the past many years. @@ -173,7 +173,7 @@ of Plan 9 from User Space for Windows. Only for reference.
- + Sean Quinlan's 9pm − a port of an earlier Plan 9 (including sam(1)) to Windows
diff --git a/dist/pkg/main b/dist/pkg/main index 52e5efdad..c779a0289 100644 --- a/dist/pkg/main +++ b/dist/pkg/main @@ -5,7 +5,7 @@ depends=plan9port-^(base bin devel dict dist faces font-asian \ desc='Plan 9 from User Space Plan 9 is a distributed computing environment built at Bell Labs starting in the late 1980s. The system can be obtained from Bell Labs - at http://plan9.bell-labs.com/plan9 and runs on PCs and a variety + at http://9p.io/plan9 and runs on PCs and a variety of other platforms. Plan 9 became a convenient platform for experimenting with new ideas, applications, and services. . diff --git a/dist/unix.html b/dist/unix.html index 0e8394c26..9948da2f4 100644 --- a/dist/unix.html +++ b/dist/unix.html @@ -19,7 +19,7 @@
- These are ports of Plan 9's + These are ports of Plan 9's UTF-8, formatted print, buffered I/O, and regular expression libraries, along with mk, a simple replacement for make.

@@ -82,7 +82,7 @@
license: original Bell Labs MIT-like - or Lucent Public License + or Lucent Public License @@ -119,7 +119,7 @@
License: original Bell Labs MIT-like - or Lucent Public License + or Lucent Public License @@ -146,7 +146,7 @@
License: Vita Nuova MIT-like - or Lucent Public License + or Lucent Public License
@@ -175,7 +175,7 @@
License: original Bell Labs MIT-like - or Lucent Public License + or Lucent Public License @@ -200,7 +200,7 @@
License: Vita Nuova MIT-like - or Lucent Public License + or Lucent Public License
diff --git a/install.txt b/install.txt index 2de7fa3a5..6e0e9d3e4 100644 --- a/install.txt +++ b/install.txt @@ -7,7 +7,7 @@ DESCRIPTION Plan 9 is a distributed computing environment built at Bell Labs starting in the late 1980s. The system can be obtained - from Bell Labs at http://plan9.bell-labs.com/plan9 and runs + from Bell Labs at http://9p.io/plan9 and runs on PCs and a variety of other platforms. Plan 9 became a convenient platform for experimenting with new ideas, appli- cations, and services. diff --git a/man/man1/0intro.1 b/man/man1/0intro.1 index f018fc8a2..161349330 100644 --- a/man/man1/0intro.1 +++ b/man/man1/0intro.1 @@ -5,7 +5,7 @@ intro \- introduction to Plan 9 from User Space Plan 9 is a distributed computing environment built at Bell Labs starting in the late 1980s. The system can be obtained from Bell Labs at -.B http://plan9.bell-labs.com/plan9 +.B http://9p.io/plan9 and runs on PCs and a variety of other platforms. Plan 9 became a convenient platform for experimenting with new ideas, applications, and services. diff --git a/unix/NOTICE.bio b/unix/NOTICE.bio index 42bc739fd..24bef790d 100644 --- a/unix/NOTICE.bio +++ b/unix/NOTICE.bio @@ -30,5 +30,5 @@ THE SOFTWARE. ---- This software is also made available under the Lucent Public License -version 1.02; see http://plan9.bell-labs.com/plan9dist/license.html +version 1.02; see http://9p.io/plan9/license.html diff --git a/unix/NOTICE.fmt b/unix/NOTICE.fmt index 43f24ce63..e40240709 100644 --- a/unix/NOTICE.fmt +++ b/unix/NOTICE.fmt @@ -21,5 +21,5 @@ to Russ Cox . ---- This software is also made available under the Lucent Public License -version 1.02; see http://plan9.bell-labs.com/plan9dist/license.html +version 1.02; see http://9p.io/plan9/license.html diff --git a/unix/NOTICE.mk b/unix/NOTICE.mk index 017fb80e1..4fb98fb76 100644 --- a/unix/NOTICE.mk +++ b/unix/NOTICE.mk @@ -30,5 +30,5 @@ THE SOFTWARE. ---- This software is also made available under the Lucent Public License -version 1.02; see http://plan9.bell-labs.com/plan9dist/license.html +version 1.02; see http://9p.io/plan9/license.html diff --git a/unix/NOTICE.regexp b/unix/NOTICE.regexp index 02856cfca..686891c1d 100644 --- a/unix/NOTICE.regexp +++ b/unix/NOTICE.regexp @@ -21,5 +21,5 @@ to Russ Cox . ---- This software is also made available under the Lucent Public License -version 1.02; see http://plan9.bell-labs.com/plan9dist/license.html +version 1.02; see http://9p.io/plan9/license.html diff --git a/unix/NOTICE.utf b/unix/NOTICE.utf index 43f24ce63..e40240709 100644 --- a/unix/NOTICE.utf +++ b/unix/NOTICE.utf @@ -21,5 +21,5 @@ to Russ Cox . ---- This software is also made available under the Lucent Public License -version 1.02; see http://plan9.bell-labs.com/plan9dist/license.html +version 1.02; see http://9p.io/plan9/license.html From 4650064aa757c217fa72f8819a2cf67c689bcdef Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 30 Mar 2020 09:54:45 -0400 Subject: [PATCH 209/323] acme: scale window bodies on resize, not including tag space This avoids reopening collapsed windows after a large vertical resize. --- src/cmd/acme/cols.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c index 63c33ac11..63247a84f 100644 --- a/src/cmd/acme/cols.c +++ b/src/cmd/acme/cols.c @@ -232,7 +232,7 @@ colmousebut(Column *c) void colresize(Column *c, Rectangle r) { - int i; + int i, old, new; Rectangle r1, r2; Window *w; @@ -245,6 +245,8 @@ colresize(Column *c, Rectangle r) r1.max.y += Border; draw(screen, r1, display->black, nil, ZP); r1.max.y = r.max.y; + new = Dy(r) - c->nw*(Border + font->height); + old = Dy(c->r) - c->nw*(Border + font->height); for(i=0; inw; i++){ w = c->w[i]; w->maxlines = 0; @@ -252,8 +254,8 @@ colresize(Column *c, Rectangle r) r1.max.y = r.max.y; else{ r1.max.y = r1.min.y; - if(Dy(c->r) != 0){ - r1.max.y += (Dy(w->r)+Border)*Dy(r)/Dy(c->r); + if(new > 0 && old > 0 && Dy(w->r) > Border+font->height){ + r1.max.y += (Dy(w->r)-Border-font->height)*new/old + Border + font->height; } } r1.max.y = max(r1.max.y, r1.min.y + Border+font->height); From c1c1b5267fd5e14be531a4b22ed0124b35d427cb Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 29 Apr 2020 11:21:35 +0100 Subject: [PATCH 210/323] 9c: added explicit -fcommon to gcc defaults. Version 10 of gcc enforces -fno-common which breaks a lot of things. This fix reverts to the pre-10 behaviour. The real fix is to clean up stray redefinitions which should be declarations. --- bin/9c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/9c b/bin/9c index b07d01492..0f836d241 100755 --- a/bin/9c +++ b/bin/9c @@ -20,6 +20,7 @@ usegcc() -Wno-format-truncation \ -fno-omit-frame-pointer \ -fsigned-char \ + -fcommon \ " # want to put -fno-optimize-sibling-calls here but # that option only works with gcc3+ it seems From 47d4646eebac34c0b94951cfcf1b81ed2ca513e1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 4 May 2020 18:34:19 -0400 Subject: [PATCH 211/323] rc: add recursive descent parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old yacc-based parser is available with the -Y flag, which will probably be removed at some point. The new -D flag dumps a parse tree of the input, without executing it. This allows comparing the output of rc -D and rc -DY on different scripts to see that the two parsers behave the same. The rc paper ends by saying: It is remarkable that in the four most recent editions of the UNIX system programmer’s manual the Bourne shell grammar described in the manual page does not admit the command who|wc. This is surely an oversight, but it suggests something darker: nobody really knows what the Bourne shell’s grammar is. Even examination of the source code is little help. The parser is implemented by recursive descent, but the routines corresponding to the syntactic categories all have a flag argument that subtly changes their operation depending on the context. Rc’s parser is implemented using yacc, so I can say precisely what the grammar is. The new recursive descent parser here has no such flags. It is a straightforward translation of the yacc. The new parser will make it easier to handle free carats in more generality as well as potentially allow the use of unquoted = as a word character. Going through this exercise has highlighted a few dark corners here as well. For example, I was surprised to find that x >f | y >f x | y are different commands (the latter redirects y's output). It is similarly surprising that a=b x | y sets a during the execution of y. It is also a bit counter-intuitive x | y | z x | if(c) y | z are not both 3-phase pipelines. These are certainly not things we should change, but they are not entirely obvious from the man page description, undercutting the quoted claim a bit. On the other hand, who | wc is clearly accepted by the grammar in the manual page, and the new parser still handles that test case. --- src/cmd/rc/checkparse | 14 ++ src/cmd/rc/code.c | 10 + src/cmd/rc/exec.c | 4 +- src/cmd/rc/fns.h | 1 + src/cmd/rc/io.c | 5 +- src/cmd/rc/io.h | 1 + src/cmd/rc/lex.c | 7 +- src/cmd/rc/mkfile | 1 + src/cmd/rc/parse.c | 532 ++++++++++++++++++++++++++++++++++++++++++ src/cmd/rc/pcmd.c | 115 +++++++++ src/cmd/rc/simple.c | 1 + src/cmd/rc/syn.y | 10 +- src/cmd/rc/test.rc | 38 +++ 13 files changed, 730 insertions(+), 9 deletions(-) create mode 100755 src/cmd/rc/checkparse create mode 100644 src/cmd/rc/parse.c create mode 100644 src/cmd/rc/test.rc diff --git a/src/cmd/rc/checkparse b/src/cmd/rc/checkparse new file mode 100755 index 000000000..cccc40585 --- /dev/null +++ b/src/cmd/rc/checkparse @@ -0,0 +1,14 @@ +#!/bin/bash + +files="$@" +if [ $# = 0 ]; then + files=$(echo ./test.rc; + grep -l '^#!/usr/local/plan9/bin/rc' /usr/local/plan9/bin/{*,*/*} 2>/dev/null; + grep -l '^#!/bin/rc' $HOME/pub/plan9/rc/bin/{*,*/*} 2>/dev/null) +fi + +for i in $files +do + echo '#' $i + diff <(./o.rc -DY $i 2>&1) <(./o.rc -D $i 2>&1) +done diff --git a/src/cmd/rc/code.c b/src/cmd/rc/code.c index eeaa3ed88..208476ae3 100644 --- a/src/cmd/rc/code.c +++ b/src/cmd/rc/code.c @@ -41,6 +41,16 @@ stuffdot(int a) int compile(tree *t) { + if(flag['D']) { + struct io *s; + s = openstr(); + pfmt(s, "compile: %u\n", t); + write(2, s->strp, strlen(s->strp)); + closeio(s); + if(eflagok) // made it out of rcmain - stop executing commands, just print them + t = nil; + } + ncode = 100; codebuf = (code *)emalloc(ncode*sizeof codebuf[0]); codep = 0; diff --git a/src/cmd/rc/exec.c b/src/cmd/rc/exec.c index 172acfa3e..0320976a2 100644 --- a/src/cmd/rc/exec.c +++ b/src/cmd/rc/exec.c @@ -139,7 +139,7 @@ main(int argc, char *argv[]) /* needed for rcmain later */ putenv("PLAN9", unsharp("#9")); - argc = getflags(argc, argv, "SsrdiIlxepvVc:1m:1[command]", 1); + argc = getflags(argc, argv, "DSYsrdiIlxepvVc:1m:1[command]", 1); if(argc==-1) usage("[file [arg ...]]"); if(argv[0][0]=='-') @@ -901,7 +901,7 @@ Xrdcmds(void) promptstr="% "; } Noerror(); - if(yyparse()){ + if((flag['Y'] ? yyparse : parse)()){ if(!p->iflag || p->eof && !Eintr()){ if(p->cmdfile) efree(p->cmdfile); diff --git a/src/cmd/rc/fns.h b/src/cmd/rc/fns.h index c4d201dcb..5721d6175 100644 --- a/src/cmd/rc/fns.h +++ b/src/cmd/rc/fns.h @@ -65,3 +65,4 @@ int wordchr(int); void yyerror(char*); int yylex(void); int yyparse(void); +int parse(void); diff --git a/src/cmd/rc/io.c b/src/cmd/rc/io.c index bb8af4ab4..c2e9d7b46 100644 --- a/src/cmd/rc/io.c +++ b/src/cmd/rc/io.c @@ -44,7 +44,10 @@ pfmt(io *f, char *fmt, ...) pstr(f, va_arg(ap, char *)); break; case 't': - pcmd(f, va_arg(ap, struct tree *)); + pcmd(f, va_arg(ap, tree *)); + break; + case 'u': + pcmdu(f, va_arg(ap, tree *)); break; case 'v': pval(f, va_arg(ap, struct word *)); diff --git a/src/cmd/rc/io.h b/src/cmd/rc/io.h index 21cc6b8e8..6c75cc5bc 100644 --- a/src/cmd/rc/io.h +++ b/src/cmd/rc/io.h @@ -25,6 +25,7 @@ void pquo(io*, char*); void pwrd(io*, char*); void pstr(io*, char*); void pcmd(io*, tree*); +void pcmdu(io*, tree*); void pval(io*, word*); void pfnc(io*, thread*); void pfmt(io*, char*, ...); diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index 973ddee8d..0bdbbb4b8 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -188,7 +188,7 @@ yylex(void) { int c, d = nextc(); char *w = tok; - struct tree *t; + tree *t; yylval.tree = 0; /* * Embarassing sneakiness: if the last token read was a quoted or unquoted @@ -331,6 +331,11 @@ yylex(void) yylval.tree = t; if(t->type==PIPE) skipnl(); + if(t->type==REDIR) { + skipwhite(); + if(nextc() == '{') + t->type = REDIRW; + } return t->type; case '\'': lastdol = 0; diff --git a/src/cmd/rc/mkfile b/src/cmd/rc/mkfile index 79b407f88..c1e77aef5 100644 --- a/src/cmd/rc/mkfile +++ b/src/cmd/rc/mkfile @@ -10,6 +10,7 @@ OFILES=\ here.$O\ io.$O\ lex.$O\ + parse.$O\ pcmd.$O\ pfnc.$O\ simple.$O\ diff --git a/src/cmd/rc/parse.c b/src/cmd/rc/parse.c new file mode 100644 index 000000000..6071bdffe --- /dev/null +++ b/src/cmd/rc/parse.c @@ -0,0 +1,532 @@ +#include "rc.h" +#include "io.h" +#include "fns.h" + +static tree* body(int tok, int *ptok); +static tree* brace(int tok); +static tree* cmd(int tok, int *ptok); +static tree* cmd2(int tok, int *ptok); +static tree* cmd3(int tok, int *ptok); +static tree* cmd4(int tok, int *ptok); +static tree* cmds(int tok, int *ptok, int nlok); +static tree* epilog(int tok, int *ptok); +static int iswordtok(int tok); +static tree* line(int tok, int *ptok); +static tree* paren(int tok); +static tree* yyredir(int tok, int *ptok); +static tree* yyword(int tok, int *ptok); +static tree* word1(int tok, int *ptok); +static tree* words(int tok, int *ptok); + +static jmp_buf yyjmp; + +static void +syntax(int tok) +{ + char buf[100]; + snprint(buf, sizeof buf, "syntax error %d", tok); + yyerror(buf); + longjmp(yyjmp, 1); +} + +int +parse(void) +{ + tree *t; + int tok; + + if(setjmp(yyjmp)) + return 1; + + // rc: { return 1;} + // | line '\n' {return !compile($1);} + + tok = yylex(); + if(tok == EOF) + return 1; + t = line(tok, &tok); + if(tok != '\n') + yyerror("missing newline at end of line"); + yylval.tree = t; + return !compile(t); +} + +static tree* +line(int tok, int *ptok) +{ + return cmds(tok, ptok, 0); +} + +static tree* +body(int tok, int *ptok) +{ + return cmds(tok, ptok, 1); +} + +static tree* +cmds(int tok, int *ptok, int nlok) +{ + tree *t, **last, *t2; + + // line: cmd + // | cmdsa line {$$=tree2(';', $1, $2);} + // cmdsa: cmd ';' + // | cmd '&' {$$=tree1('&', $1);} + + // body: cmd + // | cmdsan body {$$=tree2(';', $1, $2);} + // cmdsan: cmdsa + // | cmd '\n' + + t = nil; + last = nil; + for(;;) { + t2 = cmd(tok, &tok); + if(tok == '&') + t2 = tree1('&', t2); + if(t2 != nil) { + // slot into list t + if(last == nil) { + t = t2; + last = &t; + } else { + *last = tree2(';', *last, t2); + last = &(*last)->child[1]; + } + } + if(tok != ';' && tok != '&' && (!nlok || tok != '\n')) + break; + tok = yylex(); + } + *ptok = tok; + return t; +} + +static tree* +brace(int tok) +{ + tree *t; + + // brace: '{' body '}' {$$=tree1(BRACE, $2);} + + if(tok != '{') + syntax(tok); + t = body(yylex(), &tok); + if(tok != '}') + syntax(tok); + return tree1(BRACE, t); +} + +static tree* +paren(int tok) +{ + tree *t; + + // paren: '(' body ')' {$$=tree1(PCMD, $2);} + + if(tok != '(') + syntax(tok); + t = body(yylex(), &tok); + if(tok != ')') + syntax(tok); + return tree1(PCMD, t); +} + +static tree* +epilog(int tok, int *ptok) +{ + tree *t, *r; + + // epilog: {$$=0;} + // | redir epilog {$$=mung2($1, $1->child[0], $2);} + + if(tok != REDIR && tok != DUP) { + *ptok = tok; + return nil; + } + + r = yyredir(tok, &tok); + t = epilog(tok, &tok); + *ptok = tok; + return mung2(r, r->child[0], t); +} + +static tree* +yyredir(int tok, int *ptok) +{ + tree *r, *w; + + // redir: REDIR word {$$=mung1($1, $1->rtype==HERE?heredoc($2):$2);} + // | DUP + + switch(tok) { + default: + syntax(tok); + case DUP: + r = yylval.tree; + *ptok = yylex(); + break; + case REDIR: + r = yylval.tree; + w = yyword(yylex(), ptok); + r = mung1(r, r->rtype==HERE?heredoc(w):w); + break; + } + return r; +} + +static tree* +cmd(int tok, int *ptok) +{ + tree *t1, *t2, *t3, *t4; + + switch(tok) { + default: + return cmd2(tok, ptok); + + case IF: + // | IF paren {skipnl();} cmd {$$=mung2($1, $2, $4);} + // | IF NOT {skipnl();} cmd {$$=mung1($2, $4);} + t1 = yylval.tree; + tok = yylex(); + if(tok == NOT) { + t1 = yylval.tree; + skipnl(); + t2 = cmd(yylex(), ptok); + return mung1(t1, t2); + } + t2 = paren(tok); + skipnl(); + t3 = cmd(yylex(), ptok); + return mung2(t1, t2, t3); + + case FOR: + // | FOR '(' word IN words ')' {skipnl();} cmd + // {$$=mung3($1, $3, $5 ? $5 : tree1(PAREN, $5), $8);} + // | FOR '(' word ')' {skipnl();} cmd + // {$$=mung3($1, $3, (tree *)0, $6);} + t1 = yylval.tree; + tok = yylex(); + if(tok != '(') + syntax(tok); + t2 = yyword(yylex(), &tok); + switch(tok) { + default: + syntax(tok); + case ')': + t3 = nil; + break; + case IN: + t3 = words(yylex(), &tok); + if(t3 == nil) + t3 = tree1(PAREN, nil); + if(tok != ')') + syntax(tok); + break; + } + skipnl(); + t4 = cmd(yylex(), ptok); + return mung3(t1, t2, t3, t4); + + case WHILE: + // | WHILE paren {skipnl();} cmd + // {$$=mung2($1, $2, $4);} + t1 = yylval.tree; + t2 = paren(yylex()); + skipnl(); + t3 = cmd(yylex(), ptok); + return mung2(t1, t2, t3); + + case SWITCH: + // | SWITCH word {skipnl();} brace + // {$$=tree2(SWITCH, $2, $4);} + t1 = yyword(yylex(), &tok); + while(tok == '\n') + tok = yylex(); + t2 = brace(tok); + *ptok = yylex(); + return tree2(SWITCH, t1, t2); + } +} + +static tree* +cmd2(int tok, int *ptok) +{ + int op; + tree *t1, *t2; + + // | cmd ANDAND cmd {$$=tree2(ANDAND, $1, $3);} + // | cmd OROR cmd {$$=tree2(OROR, $1, $3);} + + t1 = cmd3(tok, &tok); + while(tok == ANDAND || tok == OROR) { + op = tok; + t2 = cmd3(yylex(), &tok); + t1 = tree2(op, t1, t2); + } + *ptok = tok; + return t1; +} + +static tree* +cmd3(int tok, int *ptok) +{ + tree *t1, *t2, *t3; + + // | cmd PIPE cmd {$$=mung2($2, $1, $3);} + t1 = cmd4(tok, &tok); + while(tok == PIPE) { + t2 = yylval.tree; + t3 = cmd4(yylex(), &tok); + t1 = mung2(t2, t1, t3); + } + *ptok = tok; + return t1; +} + +static tree* +cmd4(int tok, int *ptok) +{ + tree *t1, *t2, *t3; + + switch(tok) { + case ';': + case '&': + case '\n': + *ptok = tok; + return nil; + + case IF: + case FOR: + case SWITCH: + case WHILE: + // Note: cmd: a && for(x) y && b is a && {for (x) {y && b}}. + return cmd(tok, ptok); + + case FN: + // | FN words brace {$$=tree2(FN, $2, $3);} + // | FN words {$$=tree1(FN, $2);} + t1 = words(yylex(), &tok); + if(tok != '{') { + *ptok = tok; + return tree1(FN, t1); + } + t2 = brace(tok); + *ptok = yylex(); + return tree2(FN, t1, t2); + + case TWIDDLE: + // | TWIDDLE word words {$$=mung2($1, $2, $3);} + t1 = yylval.tree; + t2 = yyword(yylex(), &tok); + t3 = words(tok, ptok); + return mung2(t1, t2, t3); + + case BANG: + case SUBSHELL: + // | BANG cmd {$$=mung1($1, $2);} + // | SUBSHELL cmd {$$=mung1($1, $2);} + // Note: cmd3: ! x | y is !{x | y} not {!x} | y. + t1 = yylval.tree; + return mung1(t1, cmd3(yylex(), ptok)); + + case REDIR: + case DUP: + // | redir cmd %prec BANG {$$=mung2($1, $1->child[0], $2);} + // Note: cmd3: {>x echo a | tr a-z A-Z} writes A to x. + t1 = yyredir(tok, &tok); + t2 = cmd3(tok, ptok); + return mung2(t1, t1->child[0], t2); + + case '{': + // | brace epilog {$$=epimung($1, $2);} + t1 = brace(tok); + tok = yylex(); + t2 = epilog(tok, ptok); + return epimung(t1, t2); + } + + if(!iswordtok(tok)) { + *ptok = tok; + return nil; + } + + // cmd: ... + // | simple {$$=simplemung($1);} + // | assign cmd %prec BANG {$$=mung3($1, $1->child[0], $1->child[1], $2);} + // assign: first '=' word {$$=tree2('=', $1, $3);} + // Note: first is same as word except for disallowing all the leading keywords, + // but all those keywords have been picked off in the switch above. + // Except NOT, but disallowing that in yacc was likely a mistake anyway: + // there's no ambiguity in not=1 or not x y z. + t1 = yyword(tok, &tok); + if(tok == '=') { + // assignment + // Note: cmd3: {x=1 true | echo $x} echoes 1. + t1 = tree2('=', t1, yyword(yylex(), &tok)); + t2 = cmd3(tok, ptok); + return mung3(t1, t1->child[0], t1->child[1], t2); + } + + // simple: first + // | simple word {$$=tree2(ARGLIST, $1, $2);} + // | simple redir {$$=tree2(ARGLIST, $1, $2);} + for(;;) { + if(tok == REDIR || tok == DUP) { + t1 = tree2(ARGLIST, t1, yyredir(tok, &tok)); + } else if(iswordtok(tok)) { + t1 = tree2(ARGLIST, t1, yyword(tok, &tok)); + } else { + break; + } + } + *ptok = tok; + return simplemung(t1); +} + +static tree* +words(int tok, int *ptok) +{ + tree *t; + + // words: {$$=(tree*)0;} + // | words word {$$=tree2(WORDS, $1, $2);} + + t = nil; + while(iswordtok(tok)) + t = tree2(WORDS, t, yyword(tok, &tok)); + *ptok = tok; + return t; +} + +static tree* +yyword(int tok, int *ptok) +{ + tree *t; + + // word: keyword {lastword=1; $1->type=WORD;} + // | comword + // | word '^' word {$$=tree2('^', $1, $3);} + // comword: '$' word {$$=tree1('$', $2);} + // | '$' word SUB words ')' {$$=tree2(SUB, $2, $4);} + // | '"' word {$$=tree1('"', $2);} + // | COUNT word {$$=tree1(COUNT, $2);} + // | WORD + // | '`' brace {$$=tree1('`', $2);} + // | '(' words ')' {$$=tree1(PAREN, $2);} + // | REDIR brace {$$=mung1($1, $2); $$->type=PIPEFD;} + // keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN + // + // factored into: + // + // word: word1 + // | word '^' word1 + // + // word1: keyword | comword + + t = word1(tok, &tok); + while(tok == '^') + t = tree2('^', t, word1(yylex(), &tok)); + *ptok = tok; + return t; +} + +static tree* +word1(int tok, int *ptok) +{ + tree *w, *sub, *t; + + switch(tok) { + default: + syntax(tok); + + case WORD: + case FOR: + case IN: + case WHILE: + case IF: + case NOT: + case TWIDDLE: + case BANG: + case SUBSHELL: + case SWITCH: + case FN: + // | WORD + // keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN + t = yylval.tree; + t->type = WORD; + lastword = 1; + *ptok = yylex(); + return t; + + case '$': + // comword: '$' word1 {$$=tree1('$', $2);} + // | '$' word1 SUB words ')' {$$=tree2(SUB, $2, $4);} + w = word1(yylex(), &tok); + if(tok == SUB) { + sub = words(yylex(), &tok); + if(tok != ')') + syntax(tok); + *ptok = yylex(); + return tree2(SUB, w, sub); + } + *ptok = tok; + return tree1('$', w); + + case '"': + // | '"' word1 {$$=tree1('"', $2);} + return tree1('"', word1(yylex(), ptok)); + + case COUNT: + // | COUNT word1 {$$=tree1(COUNT, $2);} + return tree1(COUNT, word1(yylex(), ptok)); + + case '`': + // | '`' brace {$$=tree1('`', $2);} + t = tree1('`', brace(yylex())); + *ptok = yylex(); + return t; + + case '(': + // | '(' words ')' {$$=tree1(PAREN, $2);} + t = tree1(PAREN, words(yylex(), &tok)); + if(tok != ')') + syntax(tok); + *ptok = yylex(); + return t; + + case REDIRW: + // | REDIRW brace {$$=mung1($1, $2); $$->type=PIPEFD;} + t = yylval.tree; + t = mung1(t, brace(yylex())); + t->type = PIPEFD; + *ptok = yylex(); + return t; + } +} + +static int +iswordtok(int tok) +{ + switch(tok) { + case FOR: + case IN: + case WHILE: + case IF: + case NOT: + case TWIDDLE: + case BANG: + case SUBSHELL: + case SWITCH: + case FN: + case '$': + case '"': + case COUNT: + case WORD: + case '`': + case '(': + case REDIRW: + return 1; + } + return 0; +} diff --git a/src/cmd/rc/pcmd.c b/src/cmd/rc/pcmd.c index 8caf60a28..26bd883bc 100644 --- a/src/cmd/rc/pcmd.c +++ b/src/cmd/rc/pcmd.c @@ -145,3 +145,118 @@ pcmd(io *f, tree *t) break; } } + +void +pcmdu(io *f, tree *t) /* unambiguous */ +{ + if(t==0) { + pfmt(f, ""); + return; + } + + switch(t->type){ + default: pfmt(f, "(bad %d %p %p %p)", t->type, c0, c1, c2); + break; + case '$': pfmt(f, "($ %u)", c0); + break; + case '"': pfmt(f, "($\" %u)", c0); + break; + case '&': pfmt(f, "(& %u)", c0); + break; + case '^': pfmt(f, "(^ %u %u)", c0, c1); + break; + case '`': pfmt(f, "(` %u)", c0); + break; + case ANDAND: pfmt(f, "(&& %u %u)", c0, c1); + break; + case BANG: pfmt(f, "(! %u)", c0); + break; + case BRACE: pfmt(f, "(brace %u)", c0); + break; + case COUNT: pfmt(f, "($# %u)", c0); + break; + case FN: pfmt(f, "(fn %u %u)", c0, c1); + break; + case IF: pfmt(f, "(if %u %u)", c0, c1); + break; + case NOT: pfmt(f, "(if not %u)", c0); + break; + case OROR: pfmt(f, "(|| %u %u)", c0, c1); + break; + case PCMD: + case PAREN: pfmt(f, "(paren %u)", c0); + break; + case SUB: pfmt(f, "($sub %u %u)", c0, c1); + break; + case SIMPLE: pfmt(f, "(simple %u)", c0); + break; + case SUBSHELL: pfmt(f, "(@ %u)", c0); + break; + case SWITCH: pfmt(f, "(switch %u %u)", c0, c1); + break; + case TWIDDLE: pfmt(f, "(~ %u %u)", c0, c1); + break; + case WHILE: pfmt(f, "(while %u %u)", c0, c1); + break; + case ARGLIST: + pfmt(f, "(arglist %u %u)", c0, c1); + break; + case ';': + pfmt(f, "(; %u %u)", c0, c1); + break; + case WORDS: + pfmt(f, "(words %u %u)", c0, c1); + break; + case FOR: + pfmt(f, "(for %u %u %u)", c0, c1, c2); + break; + case WORD: + if(t->quoted) + pfmt(f, "%Q", t->str); + else pdeglob(f, t->str); + break; + case DUP: + if(t->rtype==DUPFD) + pfmt(f, "(>[%d=%d]", t->fd1, t->fd0); /* yes, fd1, then fd0; read lex.c */ + else + pfmt(f, "(>[%d=]", t->fd0); /*)*/ + pfmt(f, " %u)", c1); + break; + case PIPEFD: + case REDIR: + pfmt(f, "("); + switch(t->rtype){ + case HERE: + pchr(f, '<'); + case READ: + case RDWR: + pchr(f, '<'); + if(t->rtype==RDWR) + pchr(f, '>'); + if(t->fd0!=0) + pfmt(f, "[%d]", t->fd0); + break; + case APPEND: + pchr(f, '>'); + case WRITE: + pchr(f, '>'); + if(t->fd0!=1) + pfmt(f, "[%d]", t->fd0); + break; + } + pfmt(f, "%u %u)", c0, c1); + break; + case '=': + pfmt(f, "(%u=%u %u)", c0, c1, c2); + break; + case PIPE: + pfmt(f, "(|"); + if(t->fd1==0){ + if(t->fd0!=1) + pfmt(f, "[%d]", t->fd0); + } + else pfmt(f, "[%d=%d]", t->fd0, t->fd1); + pfmt(f, " %u %u", c0, c1); + break; + } +} diff --git a/src/cmd/rc/simple.c b/src/cmd/rc/simple.c index d587227ad..a7d78f6fc 100644 --- a/src/cmd/rc/simple.c +++ b/src/cmd/rc/simple.c @@ -322,6 +322,7 @@ execdot(void) static int first = 1; char file[512]; word *path; + if(first){ dotcmds[0].i = 1; dotcmds[1].f = Xmark; diff --git a/src/cmd/rc/syn.y b/src/cmd/rc/syn.y index c7de35313..5c98ef80c 100644 --- a/src/cmd/rc/syn.y +++ b/src/cmd/rc/syn.y @@ -1,5 +1,5 @@ %term FOR IN WHILE IF NOT TWIDDLE BANG SUBSHELL SWITCH FN -%term WORD REDIR DUP PIPE SUB +%term WORD REDIR REDIRW DUP PIPE SUB %term SIMPLE ARGLIST WORDS BRACE PAREN PCMD PIPEFD /* not used in syntax */ /* operator priorities -- lowest first */ %left IF WHILE FOR SWITCH ')' NOT @@ -19,7 +19,7 @@ %type line paren brace body cmdsa cmdsan assign epilog redir %type cmd simple first word comword keyword words %type NOT FOR IN WHILE IF TWIDDLE BANG SUBSHELL SWITCH FN -%type WORD REDIR DUP PIPE +%type WORD REDIR REDIRW DUP PIPE %% rc: { return 1;} | line '\n' {return !compile($1);} @@ -45,7 +45,7 @@ cmd: {$$=0;} | IF NOT {skipnl();} cmd {$$=mung1($2, $4);} | FOR '(' word IN words ')' {skipnl();} cmd /* - * if ``words'' is nil, we need a tree element to distinguish between + * if ``words'' is nil, we need a tree element to distinguish between * for(i in ) and for(i), the former being a loop over the empty set * and the latter being the implicit argument loop. so if $5 is nil * (the empty set), we represent it as "()". don't parenthesize non-nil @@ -73,7 +73,7 @@ cmd: {$$=0;} simple: first | simple word {$$=tree2(ARGLIST, $1, $2);} | simple redir {$$=tree2(ARGLIST, $1, $2);} -first: comword +first: comword | first '^' word {$$=tree2('^', $1, $3);} word: keyword {lastword=1; $1->type=WORD;} | comword @@ -85,7 +85,7 @@ comword: '$' word {$$=tree1('$', $2);} | WORD | '`' brace {$$=tree1('`', $2);} | '(' words ')' {$$=tree1(PAREN, $2);} -| REDIR brace {$$=mung1($1, $2); $$->type=PIPEFD;} +| REDIRW brace {$$=mung1($1, $2); $$->type=PIPEFD;} keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN words: {$$=(struct tree*)0;} | words word {$$=tree2(WORDS, $1, $2);} diff --git a/src/cmd/rc/test.rc b/src/cmd/rc/test.rc new file mode 100644 index 000000000..8cb11e0f7 --- /dev/null +++ b/src/cmd/rc/test.rc @@ -0,0 +1,38 @@ +# test for parser + +{a; b; c} +x=y a && b || c +x=y a | b | c +x=y for(i) a | b +>x for(i) a | b +>x a || b && c +a >x || b && c +a | for(i) b | c +fn x {y; z} | b && c +if (x) y +if not z +`{} >x >[1=2]y >[3=] z Date: Mon, 4 May 2020 22:52:27 -0400 Subject: [PATCH 212/323] rc: move newline handling into parser --- src/cmd/rc/checkparse | 6 ++++-- src/cmd/rc/lex.c | 24 ++++++++++++++++-------- src/cmd/rc/parse.c | 27 +++++++++++++++------------ src/cmd/rc/pcmd.c | 5 ++++- src/cmd/rc/syn.y | 2 +- src/cmd/rc/test.rc | 27 +++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 24 deletions(-) diff --git a/src/cmd/rc/checkparse b/src/cmd/rc/checkparse index cccc40585..1ff84667b 100755 --- a/src/cmd/rc/checkparse +++ b/src/cmd/rc/checkparse @@ -9,6 +9,8 @@ fi for i in $files do - echo '#' $i - diff <(./o.rc -DY $i 2>&1) <(./o.rc -D $i 2>&1) + if ! diff <(./o.rc -DY $i 2>&1) <(./o.rc -D $i 2>&1); then + echo '#' $i + exit 1 + fi done diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index 0bdbbb4b8..583384798 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -102,15 +102,17 @@ pprompt(void) doprompt = 0; } -void +int skipwhite(void) { - int c; + int c, skipped; + skipped = 0; for(;;){ c = nextc(); /* Why did this used to be if(!inquote && c=='#') ?? */ if(c=='#'){ incomm = 1; + skipped = 1; for(;;){ c = nextc(); if(c=='\n' || c==EOF) { @@ -120,9 +122,12 @@ skipwhite(void) advance(); } } - if(c==' ' || c=='\t') + if(c==' ' || c=='\t') { + skipped = 1; advance(); - else return; + } + else + return skipped; } } @@ -210,7 +215,8 @@ yylex(void) } } inquote = 0; - skipwhite(); + if(skipwhite() && flag['Z']) + return SP; switch(c = advance()){ case EOF: lastdol = 0; @@ -231,7 +237,8 @@ yylex(void) case '&': lastdol = 0; if(nextis('&')){ - skipnl(); + if(flag['Y']) + skipnl(); strcpy(tok, "&&"); return ANDAND; } @@ -240,7 +247,8 @@ yylex(void) case '|': lastdol = 0; if(nextis(c)){ - skipnl(); + if(flag['Y']) + skipnl(); strcpy(tok, "||"); return OROR; } @@ -329,7 +337,7 @@ yylex(void) } *w='\0'; yylval.tree = t; - if(t->type==PIPE) + if(t->type==PIPE && flag['Y']) skipnl(); if(t->type==REDIR) { skipwhite(); diff --git a/src/cmd/rc/parse.c b/src/cmd/rc/parse.c index 6071bdffe..466b7da28 100644 --- a/src/cmd/rc/parse.c +++ b/src/cmd/rc/parse.c @@ -20,6 +20,14 @@ static tree* words(int tok, int *ptok); static jmp_buf yyjmp; +static int +dropnl(int tok) +{ + while(tok == '\n') + tok = yylex(); + return tok; +} + static void syntax(int tok) { @@ -191,13 +199,11 @@ cmd(int tok, int *ptok) tok = yylex(); if(tok == NOT) { t1 = yylval.tree; - skipnl(); - t2 = cmd(yylex(), ptok); + t2 = cmd(dropnl(yylex()), ptok); return mung1(t1, t2); } t2 = paren(tok); - skipnl(); - t3 = cmd(yylex(), ptok); + t3 = cmd(dropnl(yylex()), ptok); return mung2(t1, t2, t3); case FOR: @@ -224,8 +230,7 @@ cmd(int tok, int *ptok) syntax(tok); break; } - skipnl(); - t4 = cmd(yylex(), ptok); + t4 = cmd(dropnl(yylex()), ptok); return mung3(t1, t2, t3, t4); case WHILE: @@ -233,16 +238,14 @@ cmd(int tok, int *ptok) // {$$=mung2($1, $2, $4);} t1 = yylval.tree; t2 = paren(yylex()); - skipnl(); - t3 = cmd(yylex(), ptok); + t3 = cmd(dropnl(yylex()), ptok); return mung2(t1, t2, t3); case SWITCH: // | SWITCH word {skipnl();} brace // {$$=tree2(SWITCH, $2, $4);} t1 = yyword(yylex(), &tok); - while(tok == '\n') - tok = yylex(); + tok = dropnl(tok); // doesn't work in yacc grammar but works here! t2 = brace(tok); *ptok = yylex(); return tree2(SWITCH, t1, t2); @@ -261,7 +264,7 @@ cmd2(int tok, int *ptok) t1 = cmd3(tok, &tok); while(tok == ANDAND || tok == OROR) { op = tok; - t2 = cmd3(yylex(), &tok); + t2 = cmd3(dropnl(yylex()), &tok); t1 = tree2(op, t1, t2); } *ptok = tok; @@ -277,7 +280,7 @@ cmd3(int tok, int *ptok) t1 = cmd4(tok, &tok); while(tok == PIPE) { t2 = yylval.tree; - t3 = cmd4(yylex(), &tok); + t3 = cmd4(dropnl(yylex()), &tok); t1 = mung2(t2, t1, t3); } *ptok = tok; diff --git a/src/cmd/rc/pcmd.c b/src/cmd/rc/pcmd.c index 26bd883bc..cae847379 100644 --- a/src/cmd/rc/pcmd.c +++ b/src/cmd/rc/pcmd.c @@ -244,7 +244,10 @@ pcmdu(io *f, tree *t) /* unambiguous */ pfmt(f, "[%d]", t->fd0); break; } - pfmt(f, "%u %u)", c0, c1); + if(t->rtype == HERE) + pfmt(f, "HERE %u)", c1); + else + pfmt(f, "%u %u)", c0, c1); break; case '=': pfmt(f, "(%u=%u %u)", c0, c1, c2); diff --git a/src/cmd/rc/syn.y b/src/cmd/rc/syn.y index 5c98ef80c..e3decd414 100644 --- a/src/cmd/rc/syn.y +++ b/src/cmd/rc/syn.y @@ -1,4 +1,4 @@ -%term FOR IN WHILE IF NOT TWIDDLE BANG SUBSHELL SWITCH FN +%term FOR IN WHILE IF NOT TWIDDLE BANG SUBSHELL SWITCH FN SP %term WORD REDIR REDIRW DUP PIPE SUB %term SIMPLE ARGLIST WORDS BRACE PAREN PCMD PIPEFD /* not used in syntax */ /* operator priorities -- lowest first */ diff --git a/src/cmd/rc/test.rc b/src/cmd/rc/test.rc index 8cb11e0f7..5c6581327 100644 --- a/src/cmd/rc/test.rc +++ b/src/cmd/rc/test.rc @@ -36,3 +36,30 @@ $#$x x for in while if not ~ ! @ switch fn x not$y a;b;c +if(x) +y +if(x) +{ +y +} +if not +z +for(x) +y +for(x in y) +z +while(x) +y +# yacc doesn't accept a newline before the brace +# even though the rule is written as if it would +switch x { +} +switch (x) { +} +z +x && +y +x || +y +x | +y From 7d6a248f2c68d70f58387afc69e73e695c3d940c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 4 May 2020 23:20:08 -0400 Subject: [PATCH 213/323] rc: move free carat handling into parser This fixes at least one shell script (printfont) that expected 'x'`{y}'z' to mean 'x'^`{y}^'z' as it now does. Before it meant: 'x'^`{y} 'z' One surprise is that adjacent lists get a free carat: (x y z)(1 2 3) is (x1 y2 z3) This doesn't affect any rc script in Plan 9 or plan9port. --- man/man1/rc.1 | 26 +------- src/cmd/rc/lex.c | 6 +- src/cmd/rc/parse.c | 158 +++++++++++++++++++++++++-------------------- src/cmd/rc/syn.y | 2 +- src/cmd/rc/test.rc | 11 ++++ 5 files changed, 106 insertions(+), 97 deletions(-) diff --git a/man/man1/rc.1 b/man/man1/rc.1 index 7ea8998a1..df7af05b5 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -290,28 +290,10 @@ then one operand must have one component, and the other must be non-empty, and concatenation is distributive. .PD .SS Free Carets -In most circumstances, -.I rc +.I Rc will insert the .B ^ operator automatically between words that are not separated by white space. -Whenever one of -.B $ -.B ' -.B ` -follows a quoted or unquoted word or an unquoted word follows a quoted word -with no intervening blanks or tabs, -a -.B ^ -is inserted between the two. -If an unquoted word immediately follows a -.BR $ -and contains a character other than an alphanumeric, underscore, -or -.BR * , -a -.B ^ -is inserted before the first such character. Thus .IP .B cc -$flags $stem.c @@ -367,7 +349,7 @@ or .I Fd1 is a previously opened file descriptor and .I fd0 -becomes a new copy (in the sense of +becomes a new copy (in the sense of .IR dup (3)) of it. A file descriptor may be closed by writing @@ -477,7 +459,7 @@ is executed. The .I command is executed once for each -.IR argument +.IR argument with that argument assigned to .IR name . If the argument list is omitted, @@ -982,8 +964,6 @@ changes .PP Functions that use here documents don't work. .PP -Free carets don't get inserted next to keywords. -.PP The .BI <{ command } syntax depends on the underlying operating system diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index 583384798..48bd70ded 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -202,7 +202,7 @@ yylex(void) * if the next character is the first character of a simple or compound word, * we insert a `^' before it. */ - if(lastword){ + if(lastword && flag['Y']){ lastword = 0; if(d=='('){ advance(); @@ -215,8 +215,8 @@ yylex(void) } } inquote = 0; - if(skipwhite() && flag['Z']) - return SP; + if(skipwhite() && !flag['Y']) + return ' '; switch(c = advance()){ case EOF: lastdol = 0; diff --git a/src/cmd/rc/parse.c b/src/cmd/rc/parse.c index 466b7da28..11be951ba 100644 --- a/src/cmd/rc/parse.c +++ b/src/cmd/rc/parse.c @@ -23,7 +23,15 @@ static jmp_buf yyjmp; static int dropnl(int tok) { - while(tok == '\n') + while(tok == ' ' || tok == '\n') + tok = yylex(); + return tok; +} + +static int +dropsp(int tok) +{ + while(tok == ' ') tok = yylex(); return tok; } @@ -49,7 +57,7 @@ parse(void) // rc: { return 1;} // | line '\n' {return !compile($1);} - tok = yylex(); + tok = dropsp(yylex()); if(tok == EOF) return 1; t = line(tok, &tok); @@ -117,6 +125,7 @@ brace(int tok) // brace: '{' body '}' {$$=tree1(BRACE, $2);} + tok = dropsp(tok); if(tok != '{') syntax(tok); t = body(yylex(), &tok); @@ -132,6 +141,7 @@ paren(int tok) // paren: '(' body ')' {$$=tree1(PCMD, $2);} + tok = dropsp(tok); if(tok != '(') syntax(tok); t = body(yylex(), &tok); @@ -172,11 +182,12 @@ yyredir(int tok, int *ptok) syntax(tok); case DUP: r = yylval.tree; - *ptok = yylex(); + *ptok = dropsp(yylex()); break; case REDIR: r = yylval.tree; - w = yyword(yylex(), ptok); + w = yyword(yylex(), &tok); + *ptok = dropsp(tok); r = mung1(r, r->rtype==HERE?heredoc(w):w); break; } @@ -186,17 +197,67 @@ yyredir(int tok, int *ptok) static tree* cmd(int tok, int *ptok) { - tree *t1, *t2, *t3, *t4; - + tok = dropsp(tok); switch(tok) { default: return cmd2(tok, ptok); + } +} + +static tree* +cmd2(int tok, int *ptok) +{ + int op; + tree *t1, *t2; + + // | cmd ANDAND cmd {$$=tree2(ANDAND, $1, $3);} + // | cmd OROR cmd {$$=tree2(OROR, $1, $3);} + + t1 = cmd3(tok, &tok); + while(tok == ANDAND || tok == OROR) { + op = tok; + t2 = cmd3(dropnl(yylex()), &tok); + t1 = tree2(op, t1, t2); + } + *ptok = tok; + return t1; +} + +static tree* +cmd3(int tok, int *ptok) +{ + tree *t1, *t2, *t3; + + // | cmd PIPE cmd {$$=mung2($2, $1, $3);} + t1 = cmd4(tok, &tok); + while(tok == PIPE) { + t2 = yylval.tree; + t3 = cmd4(dropnl(yylex()), &tok); + t1 = mung2(t2, t1, t3); + } + *ptok = tok; + return t1; +} + +static tree* +cmd4(int tok, int *ptok) +{ + tree *t1, *t2, *t3, *t4; + + tok = dropsp(tok); + switch(tok) { + case ';': + case '&': + case '\n': + *ptok = tok; + return nil; + case IF: // | IF paren {skipnl();} cmd {$$=mung2($1, $2, $4);} // | IF NOT {skipnl();} cmd {$$=mung1($2, $4);} t1 = yylval.tree; - tok = yylex(); + tok = dropsp(yylex()); if(tok == NOT) { t1 = yylval.tree; t2 = cmd(dropnl(yylex()), ptok); @@ -212,7 +273,7 @@ cmd(int tok, int *ptok) // | FOR '(' word ')' {skipnl();} cmd // {$$=mung3($1, $3, (tree *)0, $6);} t1 = yylval.tree; - tok = yylex(); + tok = dropsp(yylex()); if(tok != '(') syntax(tok); t2 = yyword(yylex(), &tok); @@ -247,62 +308,8 @@ cmd(int tok, int *ptok) t1 = yyword(yylex(), &tok); tok = dropnl(tok); // doesn't work in yacc grammar but works here! t2 = brace(tok); - *ptok = yylex(); + *ptok = dropsp(yylex()); return tree2(SWITCH, t1, t2); - } -} - -static tree* -cmd2(int tok, int *ptok) -{ - int op; - tree *t1, *t2; - - // | cmd ANDAND cmd {$$=tree2(ANDAND, $1, $3);} - // | cmd OROR cmd {$$=tree2(OROR, $1, $3);} - - t1 = cmd3(tok, &tok); - while(tok == ANDAND || tok == OROR) { - op = tok; - t2 = cmd3(dropnl(yylex()), &tok); - t1 = tree2(op, t1, t2); - } - *ptok = tok; - return t1; -} - -static tree* -cmd3(int tok, int *ptok) -{ - tree *t1, *t2, *t3; - - // | cmd PIPE cmd {$$=mung2($2, $1, $3);} - t1 = cmd4(tok, &tok); - while(tok == PIPE) { - t2 = yylval.tree; - t3 = cmd4(dropnl(yylex()), &tok); - t1 = mung2(t2, t1, t3); - } - *ptok = tok; - return t1; -} - -static tree* -cmd4(int tok, int *ptok) -{ - tree *t1, *t2, *t3; - - switch(tok) { - case ';': - case '&': - case '\n': - *ptok = tok; - return nil; - - case IF: - case FOR: - case SWITCH: - case WHILE: // Note: cmd: a && for(x) y && b is a && {for (x) {y && b}}. return cmd(tok, ptok); @@ -315,7 +322,7 @@ cmd4(int tok, int *ptok) return tree1(FN, t1); } t2 = brace(tok); - *ptok = yylex(); + *ptok = dropsp(yylex()); return tree2(FN, t1, t2); case TWIDDLE: @@ -344,7 +351,7 @@ cmd4(int tok, int *ptok) case '{': // | brace epilog {$$=epimung($1, $2);} t1 = brace(tok); - tok = yylex(); + tok = dropsp(yylex()); t2 = epilog(tok, ptok); return epimung(t1, t2); } @@ -396,6 +403,7 @@ words(int tok, int *ptok) // | words word {$$=tree2(WORDS, $1, $2);} t = nil; + tok = dropsp(tok); while(iswordtok(tok)) t = tree2(WORDS, t, yyword(tok, &tok)); *ptok = tok; @@ -428,9 +436,19 @@ yyword(int tok, int *ptok) // word1: keyword | comword t = word1(tok, &tok); - while(tok == '^') - t = tree2('^', t, word1(yylex(), &tok)); - *ptok = tok; + for(;;) { + if(iswordtok(tok)) { + t = tree2('^', t, word1(tok, &tok)); + continue; + } + tok = dropsp(tok); + if(tok == '^') { + t = tree2('^', t, word1(yylex(), &tok)); + continue; + } + break; + } + *ptok = dropsp(tok); return t; } @@ -439,6 +457,7 @@ word1(int tok, int *ptok) { tree *w, *sub, *t; + tok = dropsp(tok); switch(tok) { default: syntax(tok); @@ -458,7 +477,6 @@ word1(int tok, int *ptok) // keyword: FOR|IN|WHILE|IF|NOT|TWIDDLE|BANG|SUBSHELL|SWITCH|FN t = yylval.tree; t->type = WORD; - lastword = 1; *ptok = yylex(); return t; @@ -466,7 +484,7 @@ word1(int tok, int *ptok) // comword: '$' word1 {$$=tree1('$', $2);} // | '$' word1 SUB words ')' {$$=tree2(SUB, $2, $4);} w = word1(yylex(), &tok); - if(tok == SUB) { + if(tok == '(') { sub = words(yylex(), &tok); if(tok != ')') syntax(tok); diff --git a/src/cmd/rc/syn.y b/src/cmd/rc/syn.y index e3decd414..5c98ef80c 100644 --- a/src/cmd/rc/syn.y +++ b/src/cmd/rc/syn.y @@ -1,4 +1,4 @@ -%term FOR IN WHILE IF NOT TWIDDLE BANG SUBSHELL SWITCH FN SP +%term FOR IN WHILE IF NOT TWIDDLE BANG SUBSHELL SWITCH FN %term WORD REDIR REDIRW DUP PIPE SUB %term SIMPLE ARGLIST WORDS BRACE PAREN PCMD PIPEFD /* not used in syntax */ /* operator priorities -- lowest first */ diff --git a/src/cmd/rc/test.rc b/src/cmd/rc/test.rc index 5c6581327..7a83ad17c 100644 --- a/src/cmd/rc/test.rc +++ b/src/cmd/rc/test.rc @@ -1,5 +1,9 @@ # test for parser +a +a b +a|b +a | b {a; b; c} x=y a && b || c x=y a | b | c @@ -63,3 +67,10 @@ x || y x | y +switch x {y} && z +switch x {} | y + +OPTIONS=$OPTIONS' /axescount '^`{echo $1 | sed s/-a//}^' def' + +# bug in old printfont script - expected more free carats +# OPTIONS=$OPTIONS' /axescount '`{echo $1 | sed s/-a//}' def' From ff74f7cdda7b08da6fe7c8bbcca990305fd6b547 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 4 May 2020 23:31:59 -0400 Subject: [PATCH 214/323] rc: allow unquoted = in command arguments dd fans rejoice! Also helps with commands like go test -run=x. --- man/man1/rc.1 | 2 +- src/cmd/rc/parse.c | 28 ++++++++++++++++++---------- src/cmd/rc/test.rc | 9 +++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/man/man1/rc.1 b/man/man1/rc.1 index df7af05b5..add334fab 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -109,7 +109,7 @@ The simplest kind of argument is the unquoted word: a sequence of one or more characters none of which is a blank, tab, newline, or any of the following: .EX - # ; & | ^ $ = ` ' { } ( ) < > + # ; & | ^ $ ` ' { } ( ) < > .EE An unquoted word that contains any of the characters .B * diff --git a/src/cmd/rc/parse.c b/src/cmd/rc/parse.c index 11be951ba..a46931dcf 100644 --- a/src/cmd/rc/parse.c +++ b/src/cmd/rc/parse.c @@ -14,7 +14,7 @@ static int iswordtok(int tok); static tree* line(int tok, int *ptok); static tree* paren(int tok); static tree* yyredir(int tok, int *ptok); -static tree* yyword(int tok, int *ptok); +static tree* yyword(int tok, int *ptok, int eqok); static tree* word1(int tok, int *ptok); static tree* words(int tok, int *ptok); @@ -186,7 +186,7 @@ yyredir(int tok, int *ptok) break; case REDIR: r = yylval.tree; - w = yyword(yylex(), &tok); + w = yyword(yylex(), &tok, 1); *ptok = dropsp(tok); r = mung1(r, r->rtype==HERE?heredoc(w):w); break; @@ -276,7 +276,7 @@ cmd4(int tok, int *ptok) tok = dropsp(yylex()); if(tok != '(') syntax(tok); - t2 = yyword(yylex(), &tok); + t2 = yyword(yylex(), &tok, 1); switch(tok) { default: syntax(tok); @@ -305,7 +305,7 @@ cmd4(int tok, int *ptok) case SWITCH: // | SWITCH word {skipnl();} brace // {$$=tree2(SWITCH, $2, $4);} - t1 = yyword(yylex(), &tok); + t1 = yyword(yylex(), &tok, 1); tok = dropnl(tok); // doesn't work in yacc grammar but works here! t2 = brace(tok); *ptok = dropsp(yylex()); @@ -328,7 +328,7 @@ cmd4(int tok, int *ptok) case TWIDDLE: // | TWIDDLE word words {$$=mung2($1, $2, $3);} t1 = yylval.tree; - t2 = yyword(yylex(), &tok); + t2 = yyword(yylex(), &tok, 1); t3 = words(tok, ptok); return mung2(t1, t2, t3); @@ -369,11 +369,11 @@ cmd4(int tok, int *ptok) // but all those keywords have been picked off in the switch above. // Except NOT, but disallowing that in yacc was likely a mistake anyway: // there's no ambiguity in not=1 or not x y z. - t1 = yyword(tok, &tok); + t1 = yyword(tok, &tok, 0); if(tok == '=') { // assignment // Note: cmd3: {x=1 true | echo $x} echoes 1. - t1 = tree2('=', t1, yyword(yylex(), &tok)); + t1 = tree2('=', t1, yyword(yylex(), &tok, 1)); t2 = cmd3(tok, ptok); return mung3(t1, t1->child[0], t1->child[1], t2); } @@ -385,7 +385,7 @@ cmd4(int tok, int *ptok) if(tok == REDIR || tok == DUP) { t1 = tree2(ARGLIST, t1, yyredir(tok, &tok)); } else if(iswordtok(tok)) { - t1 = tree2(ARGLIST, t1, yyword(tok, &tok)); + t1 = tree2(ARGLIST, t1, yyword(tok, &tok, 1)); } else { break; } @@ -405,13 +405,13 @@ words(int tok, int *ptok) t = nil; tok = dropsp(tok); while(iswordtok(tok)) - t = tree2(WORDS, t, yyword(tok, &tok)); + t = tree2(WORDS, t, yyword(tok, &tok, 1)); *ptok = tok; return t; } static tree* -yyword(int tok, int *ptok) +yyword(int tok, int *ptok, int eqok) { tree *t; @@ -436,6 +436,8 @@ yyword(int tok, int *ptok) // word1: keyword | comword t = word1(tok, &tok); + if(tok == '=' && !eqok) + goto out; for(;;) { if(iswordtok(tok)) { t = tree2('^', t, word1(tok, &tok)); @@ -448,6 +450,7 @@ yyword(int tok, int *ptok) } break; } +out: *ptok = dropsp(tok); return t; } @@ -480,6 +483,10 @@ word1(int tok, int *ptok) *ptok = yylex(); return t; + case '=': + *ptok = yylex(); + return token("=", WORD); + case '$': // comword: '$' word1 {$$=tree1('$', $2);} // | '$' word1 SUB words ')' {$$=tree2(SUB, $2, $4);} @@ -547,6 +554,7 @@ iswordtok(int tok) case '`': case '(': case REDIRW: + case '=': return 1; } return 0; diff --git a/src/cmd/rc/test.rc b/src/cmd/rc/test.rc index 7a83ad17c..f667b8401 100644 --- a/src/cmd/rc/test.rc +++ b/src/cmd/rc/test.rc @@ -74,3 +74,12 @@ OPTIONS=$OPTIONS' /axescount '^`{echo $1 | sed s/-a//}^' def' # bug in old printfont script - expected more free carats # OPTIONS=$OPTIONS' /axescount '`{echo $1 | sed s/-a//}' def' + +(x) = y +x=y +x = y + +# works now! +# x y=z +# x =y +# x -flag=y From 601e07b63653d0fed91594ebba261b733d017653 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 5 May 2020 08:29:45 -0400 Subject: [PATCH 215/323] rc: clean up parser levels, disallow free carats on lists --- src/cmd/rc/checkparse | 13 ++++++++++--- src/cmd/rc/lex.c | 2 +- src/cmd/rc/parse.c | 45 +++++++++++++++++-------------------------- src/cmd/rc/test.rc | 8 ++++++++ 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/cmd/rc/checkparse b/src/cmd/rc/checkparse index 1ff84667b..0a1472b2e 100755 --- a/src/cmd/rc/checkparse +++ b/src/cmd/rc/checkparse @@ -1,16 +1,23 @@ #!/bin/bash +aflag=false +if [ "$1" = -a ]; then + aflag=true + shift +fi + files="$@" if [ $# = 0 ]; then files=$(echo ./test.rc; grep -l '^#!/usr/local/plan9/bin/rc' /usr/local/plan9/bin/{*,*/*} 2>/dev/null; - grep -l '^#!/bin/rc' $HOME/pub/plan9/rc/bin/{*,*/*} 2>/dev/null) + grep -R -l '^#!/bin/rc' $HOME/pub/plan9 | egrep -v 'plan9/(lib/(oui|pci)|sys/man|sys/lib/man|sys/lib/scsicodes)' 2>/dev/null) fi for i in $files do if ! diff <(./o.rc -DY $i 2>&1) <(./o.rc -D $i 2>&1); then - echo '#' $i - exit 1 + echo '^^^' $i + ! $aflag && exit 1 fi done + diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index 48bd70ded..e4410c002 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -206,7 +206,7 @@ yylex(void) lastword = 0; if(d=='('){ advance(); - strcpy(tok, "( [SUB]"); + strcpy(tok, "("); return SUB; } if(wordchr(d) || d=='\'' || d=='`' || d=='$' || d=='"'){ diff --git a/src/cmd/rc/parse.c b/src/cmd/rc/parse.c index a46931dcf..dd1021903 100644 --- a/src/cmd/rc/parse.c +++ b/src/cmd/rc/parse.c @@ -7,7 +7,6 @@ static tree* brace(int tok); static tree* cmd(int tok, int *ptok); static tree* cmd2(int tok, int *ptok); static tree* cmd3(int tok, int *ptok); -static tree* cmd4(int tok, int *ptok); static tree* cmds(int tok, int *ptok, int nlok); static tree* epilog(int tok, int *ptok); static int iswordtok(int tok); @@ -39,9 +38,8 @@ dropsp(int tok) static void syntax(int tok) { - char buf[100]; - snprint(buf, sizeof buf, "syntax error %d", tok); - yyerror(buf); + USED(tok); + yyerror("syntax error"); longjmp(yyjmp, 1); } @@ -196,17 +194,6 @@ yyredir(int tok, int *ptok) static tree* cmd(int tok, int *ptok) -{ - tok = dropsp(tok); - switch(tok) { - default: - return cmd2(tok, ptok); - - } -} - -static tree* -cmd2(int tok, int *ptok) { int op; tree *t1, *t2; @@ -214,10 +201,11 @@ cmd2(int tok, int *ptok) // | cmd ANDAND cmd {$$=tree2(ANDAND, $1, $3);} // | cmd OROR cmd {$$=tree2(OROR, $1, $3);} - t1 = cmd3(tok, &tok); + tok = dropsp(tok); + t1 = cmd2(tok, &tok); while(tok == ANDAND || tok == OROR) { op = tok; - t2 = cmd3(dropnl(yylex()), &tok); + t2 = cmd2(dropnl(yylex()), &tok); t1 = tree2(op, t1, t2); } *ptok = tok; @@ -225,15 +213,15 @@ cmd2(int tok, int *ptok) } static tree* -cmd3(int tok, int *ptok) +cmd2(int tok, int *ptok) { tree *t1, *t2, *t3; // | cmd PIPE cmd {$$=mung2($2, $1, $3);} - t1 = cmd4(tok, &tok); + t1 = cmd3(tok, &tok); while(tok == PIPE) { t2 = yylval.tree; - t3 = cmd4(dropnl(yylex()), &tok); + t3 = cmd3(dropnl(yylex()), &tok); t1 = mung2(t2, t1, t3); } *ptok = tok; @@ -241,7 +229,7 @@ cmd3(int tok, int *ptok) } static tree* -cmd4(int tok, int *ptok) +cmd3(int tok, int *ptok) { tree *t1, *t2, *t3, *t4; @@ -336,16 +324,16 @@ cmd4(int tok, int *ptok) case SUBSHELL: // | BANG cmd {$$=mung1($1, $2);} // | SUBSHELL cmd {$$=mung1($1, $2);} - // Note: cmd3: ! x | y is !{x | y} not {!x} | y. + // Note: cmd2: ! x | y is !{x | y} not {!x} | y. t1 = yylval.tree; - return mung1(t1, cmd3(yylex(), ptok)); + return mung1(t1, cmd2(yylex(), ptok)); case REDIR: case DUP: // | redir cmd %prec BANG {$$=mung2($1, $1->child[0], $2);} - // Note: cmd3: {>x echo a | tr a-z A-Z} writes A to x. + // Note: cmd2: {>x echo a | tr a-z A-Z} writes A to x. t1 = yyredir(tok, &tok); - t2 = cmd3(tok, ptok); + t2 = cmd2(tok, ptok); return mung2(t1, t1->child[0], t2); case '{': @@ -372,9 +360,9 @@ cmd4(int tok, int *ptok) t1 = yyword(tok, &tok, 0); if(tok == '=') { // assignment - // Note: cmd3: {x=1 true | echo $x} echoes 1. + // Note: cmd2: {x=1 true | echo $x} echoes 1. t1 = tree2('=', t1, yyword(yylex(), &tok, 1)); - t2 = cmd3(tok, ptok); + t2 = cmd2(tok, ptok); return mung3(t1, t1->child[0], t1->child[1], t2); } @@ -440,6 +428,9 @@ yyword(int tok, int *ptok, int eqok) goto out; for(;;) { if(iswordtok(tok)) { + // No free carats around parens. + if(t->type == PAREN || tok == '(') + syntax(tok); t = tree2('^', t, word1(tok, &tok)); continue; } diff --git a/src/cmd/rc/test.rc b/src/cmd/rc/test.rc index f667b8401..4a33d87c1 100644 --- a/src/cmd/rc/test.rc +++ b/src/cmd/rc/test.rc @@ -83,3 +83,11 @@ x = y # x y=z # x =y # x -flag=y + +>z x | y + +# rejected now, was like parens were spaces before. +# echo Formatting Venti arenas and indices (this takes a while). + + +# echo $STATLINE(1)^$STATLINE(3)' '$STATLINE(2)' '$STATLINE(4)' '$LSLINE(6) From b962b25ecaf6ddb11a36235d4a9849a147b4f6a3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 5 May 2020 08:35:48 -0400 Subject: [PATCH 216/323] rc(1): mention /etc/shells in BUGS section --- man/man1/rc.1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/man/man1/rc.1 b/man/man1/rc.1 index add334fab..792cdc95b 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -989,3 +989,9 @@ and then .B fstab ensures causes FreeBSD to mount the file system automatically at boot time.) +.PP +Some systems require +.B \*9/bin/rc +to be listed in +.B /etc/shells +before it can be used as a login shell. From acffdcb6eed3385e1566c0ac86fb6b4bc130664b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 5 May 2020 09:30:15 -0400 Subject: [PATCH 217/323] 9term.app: respect user-set shell instead of forcing bash --- mac/9term.app/Contents/MacOS/9term | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/mac/9term.app/Contents/MacOS/9term b/mac/9term.app/Contents/MacOS/9term index e5ef2735c..b5a46bc89 100755 --- a/mac/9term.app/Contents/MacOS/9term +++ b/mac/9term.app/Contents/MacOS/9term @@ -1,9 +1,29 @@ #!/bin/bash -cd $HOME -. ~/.bashrc +fshell=$(finger $(whoami) | sed -n 's/.*Shell: //p' | sed 1q) +SHELL=${fshell:-$SHELL} PLAN9=${PLAN9:-/usr/local/plan9} +cd $HOME +case "$SHELL" in +*/rc) + echo ' + if(! ~ $PLAN9/bin $path) + path=($path $PLAN9/bin) + $PLAN9/bin/9term -l -W600x800 & + ' | $SHELL -l + exit 0 + ;; +*/bash) + . ~/.bash_profile + ;; +*) + . ~/.profile + ;; +esac + if ! [[ :$PATH: =~ :$PLAN9/bin: ]] then PATH=$PATH:$PLAN9/bin fi $PLAN9/bin/9term -l -W600x800 & +exit 0 + From c3c9c7b6ae7c6a8bf9c6d040d3af89e020fd92de Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 7 May 2020 08:37:51 -0400 Subject: [PATCH 218/323] fmt: disable use of stdatomic on AIX XL C and old GCC C11 is apparently too new for these systems. Fixes #55. --- src/lib9/fmt/fmt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index a86482c32..fdfff65dc 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c @@ -1,7 +1,28 @@ /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ #include #include + +/* + * As of 2020, older systems like RHEL 6 and AIX still do not have C11 atomics. + * On those systems, make the code use volatile int accesses and hope for the best. + * (Most uses of fmtinstall are not actually racing with calls to print that lookup + * formats. The code used volatile here for years without too many problems, + * even though that's technically racy. A mutex is not OK, because we want to + * be able to call print from signal handlers.) + * + * RHEL is using an old GCC (atomics were added in GCC 4.8). + * AIX is using its own IBM compiler (XL C). + */ +#if __IBMC__ || !__clang__ && __GNUC__ && (__GNUC__ < 4 || (__GNUC__==4 && __GNUC_MINOR__<8)) +#warning not using C11 stdatomic on legacy system +#define _Atomic volatile +#define atomic_load(x) (*(x)) +#define atomic_store(x, y) (*(x)=(y)) +#define ATOMIC_VAR_INIT(x) (x) +#else #include +#endif + #include "plan9.h" #include "fmt.h" #include "fmtdef.h" From 4982d4ebc3bd4924d73f2f2ad584309e9ec97435 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:52:02 -0700 Subject: [PATCH 219/323] all: update build scripts to fix AIX XL/C compatibility --- bin/9c | 19 ++++++++++++++++++- bin/9l | 13 +++++++------ include/u.h | 4 ++-- src/cmd/mkfile | 2 +- src/mk.AIX-power | 2 ++ src/mkmk.sh | 6 +++++- 6 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 src/mk.AIX-power diff --git a/bin/9c b/bin/9c index 0f836d241..320a1634c 100755 --- a/bin/9c +++ b/bin/9c @@ -82,6 +82,23 @@ useclang() cflags="$ngflags -g" } +usexlc() +{ + cc=${CC9:-xlc_r} + ngflags=" \ + -c \ + -O0 \ + -qmaxmem=-1 \ + -qsuppress=1506-236 \ + -qsuppress=1506-358 \ + -qsuppress=1500-010 \ + -qsuppress=1506-224 \ + -qsuppress=1506-1300 \ + -qsuppress=1506-342 \ + " + cflags="$ngflags -g -qfullpath" +} + tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" case "$tag" in *DragonFly*gcc*|*BSD*gcc*) usegcc ;; @@ -120,7 +137,7 @@ case "$tag" in cflags="$ngflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; -*AIX*) usegcc +*AIX*) usexlc cflags="$ngflags -g -D__AIX__" ;; *) diff --git a/bin/9l b/bin/9l index a10aab728..398adbd8a 100755 --- a/bin/9l +++ b/bin/9l @@ -61,8 +61,9 @@ case "$tag" in esac ;; *AIX*) - ld=${CC9:-gcc} - nmflags="-B" + ld="${CC9:-xlc_r} -g -O0" + nmflags="-A -B" + extralibs="$extralibs -lpthread" ;; *) echo do not know how to link on "$tag" 1>&2 @@ -113,8 +114,8 @@ then then a=` nm $nmflags $ofiles | - grep '__p9l_autolib_[a-zA-Z0-9+-]*$' | - sed 's/.*__p9l_autolib_//' | + grep '__p9l_autolib_[a-zA-Z0-9+-]*' | + sed 's/.*__p9l_autolib_//; s/:.*//' | sort -u ` for i in $a @@ -144,8 +145,8 @@ then do b=` nm $lpath/lib$i.a 2>/dev/null | - grep '__p9l_autolib_[a-zA-Z0-9+-]*$' | - sed 's/.*__p9l_autolib_//' | + grep '__p9l_autolib_[a-zA-Z0-9+-]*' | + sed 's/.*__p9l_autolib_//; s/:.*//' | sort -u | egrep -v '^(thread|draw)$' ` diff --git a/include/u.h b/include/u.h index 3bea890e3..137b61612 100644 --- a/include/u.h +++ b/include/u.h @@ -20,7 +20,7 @@ extern "C" { #define _NETBSD_SOURCE 1 /* NetBSD */ #define _SVID_SOURCE 1 #define _DEFAULT_SOURCE 1 -#if !defined(__APPLE__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__AIX__) # define _XOPEN_SOURCE 1000 # define _XOPEN_SOURCE_EXTENDED 1 #endif @@ -33,7 +33,7 @@ extern "C" { # define __LONG_LONG_SUPPORTED #endif #if defined(__AIX__) -# define _XOPEN_SOURCE 1 +# define _XOPEN_SOURCE 600 #endif #if defined(__APPLE__) # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */ diff --git a/src/cmd/mkfile b/src/cmd/mkfile index bc8b5a0db..2d0c657e6 100644 --- a/src/cmd/mkfile +++ b/src/cmd/mkfile @@ -27,7 +27,7 @@ $PLAN9/bin/lex: $PLAN9/bin/yacc # This should not be necessary. $PLAN9/bin/yacc: $O.yacc - install -c $O.yacc $PLAN9/bin/yacc + $INSTALL -c $O.yacc $PLAN9/bin/yacc $O.yacc: yacc.$O $LD -o $target $prereq yacc.$O: yacc.c diff --git a/src/mk.AIX-power b/src/mk.AIX-power new file mode 100644 index 000000000..39f8ee8a2 --- /dev/null +++ b/src/mk.AIX-power @@ -0,0 +1,2 @@ +INSTALL=installbsd + diff --git a/src/mkmk.sh b/src/mkmk.sh index dae87ddfb..0d52d3f92 100644 --- a/src/mkmk.sh +++ b/src/mkmk.sh @@ -211,5 +211,9 @@ echo cd `pwd` 9c word.c 9c unix.c 9l -o o.mk arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rc.o rule.o run.o sh.o shell.o shprint.o symtab.o var.o varsub.o word.o unix.o -install o.mk $PLAN9/bin/mk +if [ `uname` = AIX ]; then + installbsd o.mk $PLAN9/bin/mk +else + install o.mk $PLAN9/bin/mk +fi cd .. From f84d54a0337f9e101c8baeb51272f33b05b2a0e1 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:52:40 -0700 Subject: [PATCH 220/323] mk: support Big Archive Format under AIX --- src/cmd/mk/archive.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c index 5b0c1d007..6d646979e 100644 --- a/src/cmd/mk/archive.c +++ b/src/cmd/mk/archive.c @@ -1,5 +1,9 @@ #include "mk.h" +#if defined(__AIX__) +#define ARMAG "\n" +#else #define ARMAG "!\n" +#endif #define SARMAG (sizeof(ARMAG) - sizeof("")) #define ARFMAG "`\n" From 5802b09e9d8ceadd2cefdccfd0391c04e492369b Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:53:21 -0700 Subject: [PATCH 221/323] all: fix #includes for AIX, add a few AIX "implementation" files --- include/u.h | 4 ++++ src/cmd/9term/AIX.c | 2 ++ src/cmd/9term/bsdpty.c | 2 ++ src/cmd/auxstats/AIX.c | 9 +++++++++ src/cmd/draw/mc.c | 3 +++ src/cmd/vbackup/mount-AIX.c | 1 + src/lib9/readcons.c | 2 ++ src/libip/AIX.c | 1 + src/libmach/AIX.c | 1 + 9 files changed, 25 insertions(+) create mode 100644 src/cmd/9term/AIX.c create mode 100644 src/cmd/auxstats/AIX.c create mode 100644 src/cmd/vbackup/mount-AIX.c create mode 100644 src/libip/AIX.c create mode 100644 src/libmach/AIX.c diff --git a/include/u.h b/include/u.h index 137b61612..10fc72573 100644 --- a/include/u.h +++ b/include/u.h @@ -6,6 +6,8 @@ extern "C" { #endif +#define HAS_SYS_TERMIOS 1 + #define __BSD_VISIBLE 1 /* FreeBSD 5.x */ #if defined(__sun__) # define __EXTENSIONS__ 1 /* SunOS */ @@ -34,6 +36,8 @@ extern "C" { #endif #if defined(__AIX__) # define _XOPEN_SOURCE 600 +# define _ALL_SOURCE +# undef HAS_SYS_TERMIOS #endif #if defined(__APPLE__) # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */ diff --git a/src/cmd/9term/AIX.c b/src/cmd/9term/AIX.c new file mode 100644 index 000000000..b7ccbf0f4 --- /dev/null +++ b/src/cmd/9term/AIX.c @@ -0,0 +1,2 @@ +#define TIOCSCTTY 0x540E +#include "bsdpty.c" diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c index d64e4c2fc..3710a18d6 100644 --- a/src/cmd/9term/bsdpty.c +++ b/src/cmd/9term/bsdpty.c @@ -5,7 +5,9 @@ #include #include #include +#ifdef HAS_SYS_TERMIOS #include +#endif #ifdef __linux__ #include #endif diff --git a/src/cmd/auxstats/AIX.c b/src/cmd/auxstats/AIX.c new file mode 100644 index 000000000..33ebdedc1 --- /dev/null +++ b/src/cmd/auxstats/AIX.c @@ -0,0 +1,9 @@ +#include +#include +#include +#include "dat.h" + +void (*statfn[])(int) = +{ + 0 +}; diff --git a/src/cmd/draw/mc.c b/src/cmd/draw/mc.c index ee112194f..f1bcc82a2 100644 --- a/src/cmd/draw/mc.c +++ b/src/cmd/draw/mc.c @@ -9,7 +9,10 @@ */ #include #include +#include +#ifdef HAS_SYS_TERMIOS #include +#endif #include #include #include diff --git a/src/cmd/vbackup/mount-AIX.c b/src/cmd/vbackup/mount-AIX.c new file mode 100644 index 000000000..3dde4fdfc --- /dev/null +++ b/src/cmd/vbackup/mount-AIX.c @@ -0,0 +1 @@ +#include "mount-none.c" diff --git a/src/lib9/readcons.c b/src/lib9/readcons.c index 8de44b8f9..c07e59710 100644 --- a/src/lib9/readcons.c +++ b/src/lib9/readcons.c @@ -2,7 +2,9 @@ #define NOPLAN9DEFINES #include #include +#ifdef HAS_SYS_TERMIOS #include +#endif static int rawx(int fd, int echoing) diff --git a/src/libip/AIX.c b/src/libip/AIX.c new file mode 100644 index 000000000..48c87c621 --- /dev/null +++ b/src/libip/AIX.c @@ -0,0 +1 @@ +#include "none.c" diff --git a/src/libmach/AIX.c b/src/libmach/AIX.c new file mode 100644 index 000000000..3626e7c69 --- /dev/null +++ b/src/libmach/AIX.c @@ -0,0 +1 @@ +#include "nosys.c" From bd6f12068b28ba7eb96a3cd495e2201c852682b7 Mon Sep 17 00:00:00 2001 From: Kurt H Maier Date: Thu, 7 May 2020 17:55:15 -0700 Subject: [PATCH 222/323] fmt: adjust GCC version check atomics were added in GCC 4.9: https://gcc.gnu.org/gcc-4.9/changes.html --- src/lib9/fmt/fmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib9/fmt/fmt.c b/src/lib9/fmt/fmt.c index fdfff65dc..47b186a48 100644 --- a/src/lib9/fmt/fmt.c +++ b/src/lib9/fmt/fmt.c @@ -10,10 +10,10 @@ * even though that's technically racy. A mutex is not OK, because we want to * be able to call print from signal handlers.) * - * RHEL is using an old GCC (atomics were added in GCC 4.8). + * RHEL is using an old GCC (atomics were added in GCC 4.9). * AIX is using its own IBM compiler (XL C). */ -#if __IBMC__ || !__clang__ && __GNUC__ && (__GNUC__ < 4 || (__GNUC__==4 && __GNUC_MINOR__<8)) +#if __IBMC__ || !__clang__ && __GNUC__ && (__GNUC__ < 4 || (__GNUC__==4 && __GNUC_MINOR__<9)) #warning not using C11 stdatomic on legacy system #define _Atomic volatile #define atomic_load(x) (*(x)) From 58fdc083addda3f95eb8895f474da5a52f145be0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 12:35:03 -0400 Subject: [PATCH 223/323] lib9: merge create, open, dirread into open.c Preparation for using opendir. --- src/lib9/create.c | 75 ------------- src/lib9/dirread.c | 207 ---------------------------------- src/lib9/mkfile | 2 - src/lib9/open.c | 270 +++++++++++++++++++++++++++++++++++++++++++++ src/mkmk.sh | 11 +- 5 files changed, 273 insertions(+), 292 deletions(-) delete mode 100644 src/lib9/create.c delete mode 100644 src/lib9/dirread.c diff --git a/src/lib9/create.c b/src/lib9/create.c deleted file mode 100644 index e4e3c715e..000000000 --- a/src/lib9/create.c +++ /dev/null @@ -1,75 +0,0 @@ -#define _GNU_SOURCE /* for Linux O_DIRECT */ -#include -#define NOPLAN9DEFINES -#include -#include -#include -#include -#include -#ifndef O_DIRECT -#define O_DIRECT 0 -#endif - -int -p9create(char *path, int mode, ulong perm) -{ - int fd, cexec, umode, rclose, lock, rdwr; - struct flock fl; - - rdwr = mode&3; - lock = mode&OLOCK; - cexec = mode&OCEXEC; - rclose = mode&ORCLOSE; - mode &= ~(ORCLOSE|OCEXEC|OLOCK); - - /* XXX should get mode mask right? */ - fd = -1; - if(perm&DMDIR){ - if(mode != OREAD){ - werrstr("bad mode in directory create"); - goto out; - } - if(mkdir(path, perm&0777) < 0) - goto out; - fd = open(path, O_RDONLY); - }else{ - umode = (mode&3)|O_CREAT|O_TRUNC; - mode &= ~(3|OTRUNC); - if(mode&ODIRECT){ - umode |= O_DIRECT; - mode &= ~ODIRECT; - } - if(mode&OEXCL){ - umode |= O_EXCL; - mode &= ~OEXCL; - } - if(mode&OAPPEND){ - umode |= O_APPEND; - mode &= ~OAPPEND; - } - if(mode){ - werrstr("unsupported mode in create"); - goto out; - } - fd = open(path, umode, perm); - } -out: - if(fd >= 0){ - if(lock){ - fl.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; - if(fcntl(fd, F_SETLK, &fl) < 0){ - close(fd); - werrstr("lock: %r"); - return -1; - } - } - if(cexec) - fcntl(fd, F_SETFL, FD_CLOEXEC); - if(rclose) - remove(path); - } - return fd; -} diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c deleted file mode 100644 index c232eb8d8..000000000 --- a/src/lib9/dirread.c +++ /dev/null @@ -1,207 +0,0 @@ -#include -#define NOPLAN9DEFINES -#include -#include -#include - -extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); - -#if defined(__linux__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - off_t off; - int nn; - - /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */ - off = p9seek(fd, 0, 1); - nn = getdirentries(fd, (void*)buf, n, &off); - return nn; -} -#elif defined(__APPLE__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - long off; - return getdirentries(fd, (void*)buf, n, &off); -} -#elif defined(__FreeBSD__) || defined(__DragonFly__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - off_t off; - return getdirentries(fd, (void*)buf, n, &off); -} -#elif defined(__sun__) || defined(__NetBSD__) || defined(__OpenBSD__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - return getdents(fd, (void*)buf, n); -} -#elif defined(__AIX__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - return getdirent(fd, (void*)buf, n); -} -#endif - -#if defined(__DragonFly__) -static inline int d_reclen(struct dirent *de) { return _DIRENT_DIRSIZ(de); } -#else -static inline int d_reclen(struct dirent *de) { return de->d_reclen; } -#endif - -static int -countde(char *p, int n) -{ - char *e; - int m; - struct dirent *de; - - e = p+n; - m = 0; - while(p < e){ - de = (struct dirent*)p; - if(d_reclen(de) <= 4+2+2+1 || p+d_reclen(de) > e) - break; - if(de->d_name[0]=='.' && de->d_name[1]==0) - de->d_name[0] = 0; - else if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0) - de->d_name[0] = 0; - m++; - p += d_reclen(de); - } - return m; -} - -static int -dirpackage(int fd, char *buf, int n, Dir **dp) -{ - int oldwd; - char *p, *str, *estr; - int i, nstr, m; - struct dirent *de; - struct stat st, lst; - Dir *d; - - n = countde(buf, n); - if(n <= 0) - return n; - - if((oldwd = open(".", O_RDONLY)) < 0) - return -1; - if(fchdir(fd) < 0) - return -1; - - p = buf; - nstr = 0; - - for(i=0; id_name[0] == 0) - /* nothing */ {} - else if(lstat(de->d_name, &lst) < 0) - de->d_name[0] = 0; - else{ - st = lst; - if(S_ISLNK(lst.st_mode)) - stat(de->d_name, &st); - nstr += _p9dir(&lst, &st, de->d_name, nil, nil, nil); - } - p += d_reclen(de); - } - - d = malloc(sizeof(Dir)*n+nstr); - if(d == nil){ - fchdir(oldwd); - close(oldwd); - return -1; - } - str = (char*)&d[n]; - estr = str+nstr; - - p = buf; - m = 0; - for(i=0; id_name[0] != 0 && lstat(de->d_name, &lst) >= 0){ - st = lst; - if((lst.st_mode&S_IFMT) == S_IFLNK) - stat(de->d_name, &st); - _p9dir(&lst, &st, de->d_name, &d[m++], &str, estr); - } - p += d_reclen(de); - } - - fchdir(oldwd); - close(oldwd); - *dp = d; - return m; -} - -long -dirread(int fd, Dir **dp) -{ - char *buf; - struct stat st; - int n; - - *dp = 0; - - if(fstat(fd, &st) < 0) - return -1; - - if(st.st_blksize < 8192) - st.st_blksize = 8192; - - buf = malloc(st.st_blksize); - if(buf == nil) - return -1; - - n = mygetdents(fd, (void*)buf, st.st_blksize); - if(n < 0){ - free(buf); - return -1; - } - n = dirpackage(fd, buf, n, dp); - free(buf); - return n; -} - - -long -dirreadall(int fd, Dir **d) -{ - uchar *buf, *nbuf; - long n, ts; - struct stat st; - - if(fstat(fd, &st) < 0) - return -1; - - if(st.st_blksize < 8192) - st.st_blksize = 8192; - - buf = nil; - ts = 0; - for(;;){ - nbuf = realloc(buf, ts+st.st_blksize); - if(nbuf == nil){ - free(buf); - return -1; - } - buf = nbuf; - n = mygetdents(fd, (void*)(buf+ts), st.st_blksize); - if(n <= 0) - break; - ts += n; - } - if(ts >= 0) - ts = dirpackage(fd, (char*)buf, ts, d); - free(buf); - if(ts == 0 && n < 0) - return -1; - return ts; -} diff --git a/src/lib9/mkfile b/src/lib9/mkfile index 7c37de420..6fb3d4a7a 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -86,14 +86,12 @@ LIB9OFILES=\ convM2D.$O\ convM2S.$O\ convS2M.$O\ - create.$O\ crypt.$O\ ctime.$O\ dial.$O\ dirfstat.$O\ dirfwstat.$O\ dirmodefmt.$O\ - dirread.$O\ dirstat.$O\ dirwstat.$O\ dup.$O\ diff --git a/src/lib9/open.c b/src/lib9/open.c index a0573ae7f..44a4feeef 100644 --- a/src/lib9/open.c +++ b/src/lib9/open.c @@ -2,11 +2,79 @@ #include #define NOPLAN9DEFINES #include +#include +#include #include +#include +#include #ifndef O_DIRECT #define O_DIRECT 0 #endif +int +p9create(char *path, int mode, ulong perm) +{ + int fd, cexec, umode, rclose, lock, rdwr; + struct flock fl; + + rdwr = mode&3; + lock = mode&OLOCK; + cexec = mode&OCEXEC; + rclose = mode&ORCLOSE; + mode &= ~(ORCLOSE|OCEXEC|OLOCK); + + /* XXX should get mode mask right? */ + fd = -1; + if(perm&DMDIR){ + if(mode != OREAD){ + werrstr("bad mode in directory create"); + goto out; + } + if(mkdir(path, perm&0777) < 0) + goto out; + fd = open(path, O_RDONLY); + }else{ + umode = (mode&3)|O_CREAT|O_TRUNC; + mode &= ~(3|OTRUNC); + if(mode&ODIRECT){ + umode |= O_DIRECT; + mode &= ~ODIRECT; + } + if(mode&OEXCL){ + umode |= O_EXCL; + mode &= ~OEXCL; + } + if(mode&OAPPEND){ + umode |= O_APPEND; + mode &= ~OAPPEND; + } + if(mode){ + werrstr("unsupported mode in create"); + goto out; + } + fd = open(path, umode, perm); + } +out: + if(fd >= 0){ + if(lock){ + fl.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + if(fcntl(fd, F_SETLK, &fl) < 0){ + close(fd); + werrstr("lock: %r"); + return -1; + } + } + if(cexec) + fcntl(fd, F_SETFL, FD_CLOEXEC); + if(rclose) + remove(path); + } + return fd; +} + int p9open(char *name, int mode) { @@ -60,3 +128,205 @@ p9open(char *name, int mode) } return fd; } + +extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); + +#if defined(__linux__) +static int +mygetdents(int fd, struct dirent *buf, int n) +{ + off_t off; + int nn; + + /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */ + off = p9seek(fd, 0, 1); + nn = getdirentries(fd, (void*)buf, n, &off); + return nn; +} +#elif defined(__APPLE__) +static int +mygetdents(int fd, struct dirent *buf, int n) +{ + long off; + return getdirentries(fd, (void*)buf, n, &off); +} +#elif defined(__FreeBSD__) || defined(__DragonFly__) +static int +mygetdents(int fd, struct dirent *buf, int n) +{ + off_t off; + return getdirentries(fd, (void*)buf, n, &off); +} +#elif defined(__sun__) || defined(__NetBSD__) || defined(__OpenBSD__) +static int +mygetdents(int fd, struct dirent *buf, int n) +{ + return getdents(fd, (void*)buf, n); +} +#elif defined(__AIX__) +static int +mygetdents(int fd, struct dirent *buf, int n) +{ + return getdirent(fd, (void*)buf, n); +} +#endif + +#if defined(__DragonFly__) +static inline int d_reclen(struct dirent *de) { return _DIRENT_DIRSIZ(de); } +#else +static inline int d_reclen(struct dirent *de) { return de->d_reclen; } +#endif + +static int +countde(char *p, int n) +{ + char *e; + int m; + struct dirent *de; + + e = p+n; + m = 0; + while(p < e){ + de = (struct dirent*)p; + if(d_reclen(de) <= 4+2+2+1 || p+d_reclen(de) > e) + break; + if(de->d_name[0]=='.' && de->d_name[1]==0) + de->d_name[0] = 0; + else if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0) + de->d_name[0] = 0; + m++; + p += d_reclen(de); + } + return m; +} + +static int +dirpackage(int fd, char *buf, int n, Dir **dp) +{ + int oldwd; + char *p, *str, *estr; + int i, nstr, m; + struct dirent *de; + struct stat st, lst; + Dir *d; + + n = countde(buf, n); + if(n <= 0) + return n; + + if((oldwd = open(".", O_RDONLY)) < 0) + return -1; + if(fchdir(fd) < 0) + return -1; + + p = buf; + nstr = 0; + + for(i=0; id_name[0] == 0) + /* nothing */ {} + else if(lstat(de->d_name, &lst) < 0) + de->d_name[0] = 0; + else{ + st = lst; + if(S_ISLNK(lst.st_mode)) + stat(de->d_name, &st); + nstr += _p9dir(&lst, &st, de->d_name, nil, nil, nil); + } + p += d_reclen(de); + } + + d = malloc(sizeof(Dir)*n+nstr); + if(d == nil){ + fchdir(oldwd); + close(oldwd); + return -1; + } + str = (char*)&d[n]; + estr = str+nstr; + + p = buf; + m = 0; + for(i=0; id_name[0] != 0 && lstat(de->d_name, &lst) >= 0){ + st = lst; + if((lst.st_mode&S_IFMT) == S_IFLNK) + stat(de->d_name, &st); + _p9dir(&lst, &st, de->d_name, &d[m++], &str, estr); + } + p += d_reclen(de); + } + + fchdir(oldwd); + close(oldwd); + *dp = d; + return m; +} + +long +dirread(int fd, Dir **dp) +{ + char *buf; + struct stat st; + int n; + + *dp = 0; + + if(fstat(fd, &st) < 0) + return -1; + + if(st.st_blksize < 8192) + st.st_blksize = 8192; + + buf = malloc(st.st_blksize); + if(buf == nil) + return -1; + + n = mygetdents(fd, (void*)buf, st.st_blksize); + if(n < 0){ + free(buf); + return -1; + } + n = dirpackage(fd, buf, n, dp); + free(buf); + return n; +} + + +long +dirreadall(int fd, Dir **d) +{ + uchar *buf, *nbuf; + long n, ts; + struct stat st; + + if(fstat(fd, &st) < 0) + return -1; + + if(st.st_blksize < 8192) + st.st_blksize = 8192; + + buf = nil; + ts = 0; + for(;;){ + nbuf = realloc(buf, ts+st.st_blksize); + if(nbuf == nil){ + free(buf); + return -1; + } + buf = nbuf; + n = mygetdents(fd, (void*)(buf+ts), st.st_blksize); + if(n <= 0) + break; + ts += n; + } + if(ts >= 0) + ts = dirpackage(fd, (char*)buf, ts, d); + free(buf); + if(ts == 0 && n < 0) + return -1; + return ts; +} diff --git a/src/mkmk.sh b/src/mkmk.sh index 0d52d3f92..8094c3eab 100644 --- a/src/mkmk.sh +++ b/src/mkmk.sh @@ -20,14 +20,12 @@ echo cd `pwd` 9c convM2D.c 9c convM2S.c 9c convS2M.c -9c create.c 9c crypt.c 9c ctime.c 9c dial.c 9c dirfstat.c 9c dirfwstat.c 9c dirmodefmt.c -9c dirread.c 9c dirstat.c 9c dirwstat.c 9c dup.c @@ -109,6 +107,7 @@ echo cd `pwd` 9c -Ifmt fmt/fmtstr.c 9c -Ifmt fmt/fmtvprint.c 9c -Ifmt fmt/fprint.c +9c frexp.c 9c -Ifmt fmt/nan64.c 9c -Ifmt fmt/print.c 9c -Ifmt fmt/runefmtstr.c @@ -150,7 +149,7 @@ echo cd `pwd` 9c utf/utfrrune.c 9c utf/utfrune.c 9c utf/utfutf.c -9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o frand.o get9root.o getcallerpc.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o +9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o frand.o get9root.o getcallerpc.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o frexp.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o cd .. cd libbio echo cd `pwd` @@ -211,9 +210,5 @@ echo cd `pwd` 9c word.c 9c unix.c 9l -o o.mk arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rc.o rule.o run.o sh.o shell.o shprint.o symtab.o var.o varsub.o word.o unix.o -if [ `uname` = AIX ]; then - installbsd o.mk $PLAN9/bin/mk -else - install o.mk $PLAN9/bin/mk -fi +install o.mk $PLAN9/bin/mk cd .. From 6fd4e901ce48f2e056c505c81320f786175588ff Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 12:37:11 -0400 Subject: [PATCH 224/323] lib9: add close More preparation for opendir. --- include/libc.h | 4 +++- src/lib9/open.c | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/libc.h b/include/libc.h index 4fa86b22e..7b4c38131 100644 --- a/include/libc.h +++ b/include/libc.h @@ -747,7 +747,7 @@ extern int awaitnohang(char*, int); /* extern int bind(char*, char*, int); give up */ /* extern int brk(void*); */ extern int p9chdir(char*); -extern int close(int); +extern int p9close(int); extern int p9create(char*, int, ulong); extern int p9dup(int, int); extern int errstr(char*, uint); @@ -822,6 +822,8 @@ extern ulong rendezvous(ulong, ulong); #define create p9create #undef open #define open p9open +#undef close +#define close p9close #define pipe p9pipe #define waitfor p9waitfor #define write p9write diff --git a/src/lib9/open.c b/src/lib9/open.c index 44a4feeef..439106941 100644 --- a/src/lib9/open.c +++ b/src/lib9/open.c @@ -129,6 +129,13 @@ p9open(char *name, int mode) return fd; } +int +p9close(int fd) +{ + return close(fd); +} + + extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); #if defined(__linux__) From 16f60479e16e3714b376e633c6b902a32e0607ea Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 12:38:32 -0400 Subject: [PATCH 225/323] lib9: move seek into open.c More preparation for opendir. --- src/lib9/mkfile | 1 - src/lib9/open.c | 7 ++++++- src/lib9/seek.c | 8 -------- src/mkmk.sh | 3 +-- 4 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 src/lib9/seek.c diff --git a/src/lib9/mkfile b/src/lib9/mkfile index 6fb3d4a7a..db267dfed 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -139,7 +139,6 @@ LIB9OFILES=\ readn.$O\ rfork.$O\ searchpath.$O\ - seek.$O\ sendfd.$O\ sleep.$O\ strdup.$O\ diff --git a/src/lib9/open.c b/src/lib9/open.c index 439106941..ffee79310 100644 --- a/src/lib9/open.c +++ b/src/lib9/open.c @@ -129,13 +129,18 @@ p9open(char *name, int mode) return fd; } +vlong +p9seek(int fd, vlong offset, int whence) +{ + return lseek(fd, offset, whence); +} + int p9close(int fd) { return close(fd); } - extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); #if defined(__linux__) diff --git a/src/lib9/seek.c b/src/lib9/seek.c deleted file mode 100644 index b626355fb..000000000 --- a/src/lib9/seek.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -vlong -seek(int fd, vlong offset, int whence) -{ - return lseek(fd, offset, whence); -} diff --git a/src/mkmk.sh b/src/mkmk.sh index 8094c3eab..89c311f36 100644 --- a/src/mkmk.sh +++ b/src/mkmk.sh @@ -73,7 +73,6 @@ echo cd `pwd` 9c readn.c 9c rfork.c 9c searchpath.c -9c seek.c 9c sendfd.c 9c sleep.c 9c strdup.c @@ -149,7 +148,7 @@ echo cd `pwd` 9c utf/utfrrune.c 9c utf/utfrune.c 9c utf/utfutf.c -9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o frand.o get9root.o getcallerpc.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o frexp.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o +9ar rsc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o crypt.o ctime.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o exitcode.o fcallfmt.o frand.o get9root.o getcallerpc.o getenv.o getfields.o getnetconn.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pin.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tm2sec.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o write.o zoneinfo.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlocale.o fmtlock2.o fmtnull.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o frexp.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o cd .. cd libbio echo cd `pwd` From 8cb7308f3a24249ed091c7decf22005c64099783 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:02:07 -0400 Subject: [PATCH 226/323] lib9: use opendir/readdir to read directories getdirentries(2) has been deprecated on macOS since 10.5 (ten releases ago). Using it requires disabling 64-bit inodes, but that in turn makes binaries incompatible with some dynamic libraries, most notably ASAN. At some point getdirentries(2) will actually be removed. For both these reasons, switch to opendir/readdir. A little clunky since we have to keep the DIR* hidden away to preserve the int fd interfaces, but it lets us remove a bunch of OS-specific code too. --- include/u.h | 3 - src/lib9/open.c | 370 ++++++++++++++++++++++++------------------------ 2 files changed, 187 insertions(+), 186 deletions(-) diff --git a/include/u.h b/include/u.h index 10fc72573..297df70ae 100644 --- a/include/u.h +++ b/include/u.h @@ -39,9 +39,6 @@ extern "C" { # define _ALL_SOURCE # undef HAS_SYS_TERMIOS #endif -#if defined(__APPLE__) -# define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */ -#endif #define _LARGEFILE64_SOURCE 1 #define _FILE_OFFSET_BITS 64 diff --git a/src/lib9/open.c b/src/lib9/open.c index ffee79310..65ea99ec7 100644 --- a/src/lib9/open.c +++ b/src/lib9/open.c @@ -1,15 +1,76 @@ #define _GNU_SOURCE /* for Linux O_DIRECT */ #include -#define NOPLAN9DEFINES +#include +#include #include -#include -#include -#include #include -#include -#ifndef O_DIRECT -#define O_DIRECT 0 -#endif +#define NOPLAN9DEFINES +#include + +static struct { + Lock lk; + DIR **d; + int nd; +} dirs; + +static int +dirput(int fd, DIR *d) +{ + int i, nd; + DIR **dp; + + if(fd < 0) { + werrstr("invalid fd"); + return -1; + } + lock(&dirs.lk); + if(fd >= dirs.nd) { + nd = dirs.nd*2; + if(nd <= fd) + nd = fd+1; + dp = realloc(dirs.d, nd*sizeof dirs.d[0]); + if(dp == nil) { + werrstr("out of memory"); + unlock(&dirs.lk); + return -1; + } + for(i=dirs.nd; i= 0 && S_ISDIR(st.st_mode)) { + d = fdopendir(fd); + if(d == nil) { + close(fd); + return -1; + } + if(dirput(fd, d) < 0) { + closedir(d); + return -1; + } + } if(rclose) remove(name); } @@ -132,213 +206,143 @@ p9open(char *name, int mode) vlong p9seek(int fd, vlong offset, int whence) { + DIR *d; + + if((d = dirget(fd)) != nil) { + if(whence == 1 && offset == 0) + return telldir(d); + if(whence == 0) { + seekdir(d, offset); + return 0; + } + werrstr("bad seek in directory"); + return -1; + } + return lseek(fd, offset, whence); } int p9close(int fd) { + DIR *d; + + if((d = dirdel(fd)) != nil) + return closedir(d); return close(fd); } -extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); - -#if defined(__linux__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - off_t off; - int nn; - - /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */ - off = p9seek(fd, 0, 1); - nn = getdirentries(fd, (void*)buf, n, &off); - return nn; -} -#elif defined(__APPLE__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - long off; - return getdirentries(fd, (void*)buf, n, &off); -} -#elif defined(__FreeBSD__) || defined(__DragonFly__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - off_t off; - return getdirentries(fd, (void*)buf, n, &off); -} -#elif defined(__sun__) || defined(__NetBSD__) || defined(__OpenBSD__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - return getdents(fd, (void*)buf, n); -} -#elif defined(__AIX__) -static int -mygetdents(int fd, struct dirent *buf, int n) -{ - return getdirent(fd, (void*)buf, n); -} -#endif +typedef struct DirBuild DirBuild; +struct DirBuild { + Dir *d; + int nd; + int md; + char *str; + char *estr; +}; -#if defined(__DragonFly__) -static inline int d_reclen(struct dirent *de) { return _DIRENT_DIRSIZ(de); } -#else -static inline int d_reclen(struct dirent *de) { return de->d_reclen; } -#endif +extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*); static int -countde(char *p, int n) +dirbuild1(DirBuild *b, struct stat *lst, struct stat *st, char *name) { - char *e; - int m; - struct dirent *de; - - e = p+n; - m = 0; - while(p < e){ - de = (struct dirent*)p; - if(d_reclen(de) <= 4+2+2+1 || p+d_reclen(de) > e) - break; - if(de->d_name[0]=='.' && de->d_name[1]==0) - de->d_name[0] = 0; - else if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0) - de->d_name[0] = 0; - m++; - p += d_reclen(de); + int i, nstr; + Dir *d; + int md, mstr; + char *lo, *hi, *newlo; + + nstr = _p9dir(lst, st, name, nil, nil, nil); + if(b->md-b->nd < 1 || b->estr-b->str < nstr) { + // expand either d space or str space or both. + md = b->md; + if(b->md-b->nd < 1) { + md *= 2; + if(md < 16) + md = 16; + } + mstr = b->estr-(char*)&b->d[b->md]; + if(b->estr-b->str < nstr) { + mstr += nstr; + mstr += mstr/2; + } + if(mstr < 512) + mstr = 512; + d = realloc(b->d, md*sizeof d[0] + mstr); + if(d == nil) + return -1; + // move strings and update pointers in Dirs + lo = (char*)&b->d[b->md]; + newlo = (char*)&d[md]; + hi = b->str; + memmove(newlo, lo+((char*)d-(char*)b->d), hi-lo); + for(i=0; ind; i++) { + if(lo <= d[i].name && d[i].name < hi) + d[i].name += newlo - lo; + if(lo <= d[i].uid && d[i].uid < hi) + d[i].uid += newlo - lo; + if(lo <= d[i].gid && d[i].gid < hi) + d[i].gid += newlo - lo; + if(lo <= d[i].muid && d[i].muid < hi) + d[i].muid += newlo - lo; + } + b->d = d; + b->md = md; + b->str += newlo - lo; + b->estr = newlo + mstr; } - return m; + _p9dir(lst, st, name, &b->d[b->nd], &b->str, b->estr); + b->nd++; + return 0; } -static int -dirpackage(int fd, char *buf, int n, Dir **dp) +static long +dirreadmax(int fd, Dir **dp, int max) { - int oldwd; - char *p, *str, *estr; - int i, nstr, m; + int i; + DIR *dir; + DirBuild b; struct dirent *de; struct stat st, lst; - Dir *d; - - n = countde(buf, n); - if(n <= 0) - return n; - - if((oldwd = open(".", O_RDONLY)) < 0) - return -1; - if(fchdir(fd) < 0) - return -1; - - p = buf; - nstr = 0; - - for(i=0; id_name[0] == 0) - /* nothing */ {} - else if(lstat(de->d_name, &lst) < 0) - de->d_name[0] = 0; - else{ - st = lst; - if(S_ISLNK(lst.st_mode)) - stat(de->d_name, &st); - nstr += _p9dir(&lst, &st, de->d_name, nil, nil, nil); - } - p += d_reclen(de); - } - d = malloc(sizeof(Dir)*n+nstr); - if(d == nil){ - fchdir(oldwd); - close(oldwd); + if((dir = dirget(fd)) == nil) { + werrstr("not a directory"); return -1; } - str = (char*)&d[n]; - estr = str+nstr; - p = buf; - m = 0; - for(i=0; id_name[0] != 0 && lstat(de->d_name, &lst) >= 0){ - st = lst; - if((lst.st_mode&S_IFMT) == S_IFLNK) - stat(de->d_name, &st); - _p9dir(&lst, &st, de->d_name, &d[m++], &str, estr); + memset(&b, 0, sizeof b); + for(i=0; max == -1 || id_name[de->d_namlen] != 0) + sysfatal("bad readdir"); + if(de->d_name[0]=='.' && de->d_name[1]==0) + continue; + if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0) + continue; + if(fstatat(fd, de->d_name, &lst, AT_SYMLINK_NOFOLLOW) < 0) + continue; + st = lst; + if(S_ISLNK(lst.st_mode)) + fstatat(fd, de->d_name, &st, 0); + dirbuild1(&b, &lst, &st, de->d_name); } - - fchdir(oldwd); - close(oldwd); - *dp = d; - return m; + *dp = b.d; + return b.nd; } long dirread(int fd, Dir **dp) { - char *buf; - struct stat st; - int n; - - *dp = 0; - - if(fstat(fd, &st) < 0) - return -1; - - if(st.st_blksize < 8192) - st.st_blksize = 8192; - - buf = malloc(st.st_blksize); - if(buf == nil) - return -1; - - n = mygetdents(fd, (void*)buf, st.st_blksize); - if(n < 0){ - free(buf); - return -1; - } - n = dirpackage(fd, buf, n, dp); - free(buf); - return n; + return dirreadmax(fd, dp, 10); } - long -dirreadall(int fd, Dir **d) +dirreadall(int fd, Dir **dp) { - uchar *buf, *nbuf; - long n, ts; - struct stat st; - - if(fstat(fd, &st) < 0) - return -1; - - if(st.st_blksize < 8192) - st.st_blksize = 8192; - - buf = nil; - ts = 0; - for(;;){ - nbuf = realloc(buf, ts+st.st_blksize); - if(nbuf == nil){ - free(buf); - return -1; - } - buf = nbuf; - n = mygetdents(fd, (void*)(buf+ts), st.st_blksize); - if(n <= 0) - break; - ts += n; - } - if(ts >= 0) - ts = dirpackage(fd, (char*)buf, ts, d); - free(buf); - if(ts == 0 && n < 0) - return -1; - return ts; + return dirreadmax(fd, dp, -1); } From 154140a22b1c697f6a3edb3e5913efded1be082a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:06:31 -0400 Subject: [PATCH 227/323] mk: replace overlapping strcpy with memmove Found by ASAN. --- src/cmd/mk/env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/mk/env.c b/src/cmd/mk/env.c index d7c6481d7..e01aa21ae 100644 --- a/src/cmd/mk/env.c +++ b/src/cmd/mk/env.c @@ -123,7 +123,8 @@ buildenv(Job *j, int slot) qp = strchr(cp+1, ')'); if(qp){ *qp = 0; - strcpy(w->s, cp+1); + /* strcpy, but might overlap */ + memmove(w->s, cp+1, strlen(cp+1)+1); l = &w->next; w = w->next; continue; From 9444b8e4bc847f8fd9d02466976b962288cedf31 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:07:52 -0400 Subject: [PATCH 228/323] 9c, 9l: accept CC9FLAGS from config Also, if CC9FLAGS includes -fsanitize=address (ASAN), predefine PLAN9PORT_ASAN for use by programs that need to know (mainly libthread). The 9c script used to have a variable called ngflags, which was ccflags except -g (ng stood for "no g"), but nothing needs it split out anymore, so simplify to just ccflags. --- bin/9c | 34 +++++++++++++++++++++++----------- bin/9l | 14 +++++++------- man/man1/install.1 | 9 +++++++++ 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/bin/9c b/bin/9c index 320a1634c..dd8992933 100755 --- a/bin/9c +++ b/bin/9c @@ -4,7 +4,7 @@ test -f $PLAN9/config && . $PLAN9/config usegcc() { cc=${CC9:-gcc} - ngflags=" \ + cflags=" \ -O2 \ -c \ -Wall \ @@ -24,7 +24,12 @@ usegcc() " # want to put -fno-optimize-sibling-calls here but # that option only works with gcc3+ it seems - cflags="$ngflags -ggdb" + cflags="$cflags -ggdb" + cflags="$cflags $CC9FLAGS" + case "$cflags" in + *sanitize=address*) + cflags="$cflags -DPLAN9PORT_ASAN" + esac } quiet() @@ -60,7 +65,7 @@ quiet() useclang() { cc=${CC9:-clang} - ngflags=" \ + cflags=" \ -O2 \ -c \ -Wall \ @@ -79,13 +84,19 @@ useclang() -fsigned-char \ -fno-caret-diagnostics \ " - cflags="$ngflags -g" + cflags="$cflags -g" + cflags="$cflags $CC9FLAGS" + + case "$cflags" in + *sanitize=address*) + cflags="$cflags -DPLAN9PORT_ASAN" + esac } usexlc() { cc=${CC9:-xlc_r} - ngflags=" \ + cflags=" \ -c \ -O0 \ -qmaxmem=-1 \ @@ -96,7 +107,8 @@ usexlc() -qsuppress=1506-1300 \ -qsuppress=1506-342 \ " - cflags="$ngflags -g -qfullpath" + cflags="$cflags -g -qfullpath" + cflags="$cflags $CC9FLAGS" } tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" @@ -105,14 +117,14 @@ case "$tag" in *DragonFly*clang|*BSD*clang*) useclang ;; *Darwin-x86_64*) useclang - cflags="$ngflags -g3 -m64" + cflags="$cflags -g3 -m64" ;; *Darwin*clang*) useclang - cflags="$ngflags -g3 -m32" + cflags="$cflags -g3 -m32" ;; *Darwin*) usegcc - cflags="$ngflags -g3 -no-cpp-precomp -m32" ;; + cflags="$cflags -g3 -no-cpp-precomp -m32" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; *Linux*) usegcc case "${CC9:-gcc}" in @@ -134,11 +146,11 @@ case "$tag" in u=`uname` v=`uname -r` s=`echo $u$v | tr '. ' '__'` - cflags="$ngflags -g" + cflags="$cflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; *AIX*) usexlc - cflags="$ngflags -g -D__AIX__" + cflags="$cflags -g -D__AIX__" ;; *) echo 9c does not know how to compile on "$tag" 1>&2 diff --git a/bin/9l b/bin/9l index 398adbd8a..875e103ab 100755 --- a/bin/9l +++ b/bin/9l @@ -12,29 +12,29 @@ extralibs="-lm" tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}" case "$tag" in *DragonFly*|*BSD*) - ld=${CC9:-gcc} + ld="${CC9:-gcc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil" ;; *OSF1*) - ld=${CC9:-cc} + ld="${CC9:-cc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil" nmflags="-B" ;; *Linux*) - ld=${CC9:-gcc} + ld="${CC9:-gcc} $CC9FLAGS" userpath=true extralibs="$extralibs -lutil -lresolv -lpthread" ;; *Darwin*x86_64*) - ld="${CC9:-gcc} -m64" + ld="${CC9:-gcc} -m64 $CC9FLAGS" ;; *Darwin*) - ld="${CC9:-gcc} -m32" + ld="${CC9:-gcc} -m32 $CC9FLAGS" ;; *SunOS*) - ld="${CC9:-cc} -g" + ld="${CC9:-cc} -g $CC9FLAGS" extralibs="$extralibs -lrt -lpthread -lsocket -lnsl" # Record paths to shared libraries to avoid needing LD_LIBRARY_PATH for i in "$libsl $@" @@ -61,7 +61,7 @@ case "$tag" in esac ;; *AIX*) - ld="${CC9:-xlc_r} -g -O0" + ld="${CC9:-xlc_r} -g -O0 $CC9FLAGS" nmflags="-A -B" extralibs="$extralibs -lpthread" ;; diff --git a/man/man1/install.1 b/man/man1/install.1 index 8fcc9e418..17411af26 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -89,6 +89,15 @@ If contains a line .B WSYSTYPE=nowsys then the system is built without using X11. +.B LOCAL.config +may also list settings for +.B CC9 +(the host C compiler) +and +.B CC9FLAGS +(any additional flags to pass to the compiler). +Values more complex than single words should be quoted +with single quotes. .PP On most Linux systems, the X11 header packages need to be installed to build using X11. On Debian. the required packages are From 06687f70ba7a5836c2e872648a85a724a5a1d486 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:09:43 -0400 Subject: [PATCH 229/323] INSTALL: build mk all the time If mk gets into a bad state, it's not obvious that you can remove the binary to force the rebuild. Also, not rebuilding means that bugs in mkmk.sh are not noticed. Just rebuild from scratch every time. It doesn't take too long compared to the rest of INSTALL. --- INSTALL | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 11d350058..49a4d9a40 100755 --- a/INSTALL +++ b/INSTALL @@ -143,10 +143,9 @@ echo "* Compiler version:" cd src if $dobuild; then - if [ ! -x ../bin/mk ]; then - echo "* Building mk..." - ../dist/buildmk 2>&1 | sed 's/^[+] //' - fi + echo "* Building mk..." + ../dist/buildmk 2>&1 | sed 's/^[+] //' + if [ ! -x ../bin/mk ]; then echo "* Error: mk failed to build." exit 1 From baef953da253314657be9adea8f371bfbf4ba09e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 08:24:54 -0400 Subject: [PATCH 230/323] libthread: add pthreadperthread mode and use under ASAN ASAN can't deal with the coroutine stacks. In theory we can call into ASAN runtime to let it know about them, but ASAN still has problems with fork or exit happening from a non-system stack. Bypass all possible problems by just having a full OS thread for each libthread thread. The threads are still cooperatively scheduled within a proc (in thos mode, a group of OS threads). Setting the environment variable LIBTHREAD=pthreadperthread will enable the pthreadperthread mode, as will building with CC9FLAGS='-fsanitize=address' in $PLAN9/config. This solution is much more general than ASAN - for example if you are trying to find all the thread stacks in a reproducible crash you can use pthreadperthread mode with any debugger that knows only about OS threads. --- src/libthread/channel.c | 2 +- src/libthread/pthread.c | 33 ++++++++++++++++++ src/libthread/thread.c | 70 ++++++++++++++++++++++++++++++++++---- src/libthread/threadimpl.h | 33 ++++++++++++------ 4 files changed, 120 insertions(+), 18 deletions(-) diff --git a/src/libthread/channel.c b/src/libthread/channel.c index 53af86e6b..9efb7a62c 100644 --- a/src/libthread/channel.c +++ b/src/libthread/channel.c @@ -141,7 +141,7 @@ altdequeue(Alt *a) delarray(ar, i); return; } - fprint(2, "cannot find self in altdq\n"); + fprint(2, "cannot find self in altdequeue\n"); abort(); } diff --git a/src/libthread/pthread.c b/src/libthread/pthread.c index 46bb396a2..5e022f0b1 100644 --- a/src/libthread/pthread.c +++ b/src/libthread/pthread.c @@ -99,6 +99,23 @@ startprocfn(void *v) pthread_exit(0); } +static void +startpthreadfn(void *v) +{ + void **a; + Proc *p; + _Thread *t; + + a = (void**)v; + p = a[0]; + t = a[1]; + free(a); + t->osprocid = pthread_self(); + pthread_detach(t->osprocid); + _threadpthreadmain(p, t); + pthread_exit(0); +} + void _procstart(Proc *p, void (*fn)(Proc*)) { @@ -116,6 +133,22 @@ _procstart(Proc *p, void (*fn)(Proc*)) } } +void +_threadpthreadstart(Proc *p, _Thread *t) +{ + void **a; + + a = malloc(3*sizeof a[0]); + if(a == nil) + sysfatal("_pthreadstart malloc: %r"); + a[0] = p; + a[1] = t; + if(pthread_create(&t->osprocid, nil, (void*(*)(void*))startpthreadfn, (void*)a) < 0){ + fprint(2, "pthread_create: %r\n"); + abort(); + } +} + static pthread_key_t prockey; Proc* diff --git a/src/libthread/thread.c b/src/libthread/thread.c index f657b5b24..f579b5675 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -7,6 +7,7 @@ static uint threadnsysproc; static Lock threadnproclock; static Ref threadidref; static Proc *threadmainproc; +static int pthreadperthread; static void addproc(Proc*); static void delproc(Proc*); @@ -176,12 +177,16 @@ _threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) if(stack < (256<<10)) stack = 256<<10; - if(p->nthread == 0) + if(p->nthread == 0 || pthreadperthread) stack = 0; // not using it t = threadalloc(fn, arg, stack); t->proc = p; - addthreadinproc(p, t); + if(p->nthread == 0) + p->thread0 = t; + else if(pthreadperthread) + _threadpthreadstart(p, t); p->nthread++; + addthreadinproc(p, t); _threadready(t); return t; } @@ -209,6 +214,29 @@ proccreate(void (*fn)(void*), void *arg, uint stack) return id; } +// For pthreadperthread mode, procswitch flips +// between the threads. +static void +procswitch(Proc *p, _Thread *from, _Thread *to) +{ +// fprint(2, "procswitch %p %d %d\n", p, from?from->id:-1, to?to->id:-1); + lock(&p->schedlock); + from->schedrend.l = &p->schedlock; + if(to) { + p->schedthread = to; + to->schedrend.l = &p->schedlock; + _procwakeup(&to->schedrend); + } + if(p->schedthread != from) { + if(from->exiting) { + unlock(&p->schedlock); + _threadpexit(); + } + _procsleep(&from->schedrend); + } + unlock(&p->schedlock); +} + void _threadswitch(void) { @@ -216,9 +244,13 @@ _threadswitch(void) needstack(0); p = proc(); + /*print("threadswtch %p\n", p); */ - if(p->thread->stk == nil) + + if(p->thread == p->thread0) procscheduler(p); + else if(pthreadperthread) + procswitch(p, p->thread, p->thread0); else contextswitch(&p->thread->context, &p->schedcontext); } @@ -346,6 +378,15 @@ procmain(Proc *p) threadexits(nil); } +void +_threadpthreadmain(Proc *p, _Thread *t) +{ + _threadsetproc(p); + procswitch(p, t, nil); + t->startfn(t->startarg); + threadexits(nil); +} + static void procscheduler(Proc *p) { @@ -401,9 +442,12 @@ procscheduler(Proc *p) p->nswitch++; _threaddebug("run %d (%s)", t->id, t->name); //print("run %p %p %p %p\n", t, *(uintptr*)(t->context.uc.mc.sp), t->context.uc.mc.di, t->context.uc.mc.si); - if(t->stk == nil) + if(t == p->thread0) return; - contextswitch(&p->schedcontext, &t->context); + if(pthreadperthread) + procswitch(p, p->thread0, t); + else + contextswitch(&p->schedcontext, &t->context); /*print("back in scheduler\n"); */ goto Top; } @@ -757,10 +801,24 @@ int main(int argc, char **argv) { Proc *p; + char *opts; argv0 = argv[0]; - if(getenv("NOLIBTHREADDAEMONIZE") == nil) + opts = getenv("LIBTHREAD"); + if(opts == nil) + opts = ""; + + pthreadperthread = (strstr(opts, "pthreadperthread") != nil); +#ifdef PLAN9PORT_ASAN + // ASAN can't deal with the coroutine stack switches. + // In theory it has support for informing it about stack switches, + // but even with those calls added it can't deal with things + // like fork or exit from a coroutine stack. + // Easier to just run in pthread-per-thread mode. + pthreadperthread = 1; +#endif + if(strstr(opts, "nodaemon") || getenv("NOLIBTHREADDAEMONIZE") == nil) _threadsetupdaemonize(); threadargc = argc; diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index cceb1b8e7..c73738436 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -102,6 +102,17 @@ struct Execjob Channel *c; }; +struct _Procrendez +{ + Lock *l; + int asleep; +#ifdef PLAN9PORT_USING_PTHREADS + pthread_cond_t cond; +#else + int pid; +#endif +}; + struct _Thread { _Thread *next; @@ -112,6 +123,11 @@ struct _Thread void (*startfn)(void*); void *startarg; uint id; +#ifdef PLAN9PORT_USING_PTHREADS + pthread_t osprocid; +#else + int osprocid; +#endif uchar *stk; uint stksize; int exiting; @@ -120,17 +136,7 @@ struct _Thread char state[256]; void *udata; Alt *alt; -}; - -struct _Procrendez -{ - Lock *l; - int asleep; -#ifdef PLAN9PORT_USING_PTHREADS - pthread_cond_t cond; -#else - int pid; -#endif + _Procrendez schedrend; }; extern void _procsleep(_Procrendez*); @@ -149,6 +155,7 @@ struct Proc #endif Lock lock; int nswitch; + _Thread *thread0; _Thread *thread; _Thread *pinthread; _Threadlist runqueue; @@ -157,6 +164,8 @@ struct Proc uint nthread; uint sysproc; _Procrendez runrend; + Lock schedlock; + _Thread *schedthread; Context schedcontext; void *udata; Jmp sigjmp; @@ -188,6 +197,8 @@ extern void _threadpexit(void); extern void _threaddaemonize(void); extern void *_threadstkalloc(int); extern void _threadstkfree(void*, int); +extern void _threadpthreadmain(Proc*, _Thread*); +extern void _threadpthreadstart(Proc*, _Thread*); #define USPALIGN(ucp, align) \ (void*)((((uintptr)(ucp)->uc_stack.ss_sp+(ucp)->uc_stack.ss_size)-(align))&~((align)-1)) From 162d0d5cd94fabab822ac66655be8957151cef99 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 22:31:38 -0400 Subject: [PATCH 231/323] libthread: handle spurious _procsleep wakeups, fix $LIBTHREAD handling --- src/libthread/pthread.c | 4 +++- src/libthread/thread.c | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/libthread/pthread.c b/src/libthread/pthread.c index 5e022f0b1..35f6ffe39 100644 --- a/src/libthread/pthread.c +++ b/src/libthread/pthread.c @@ -50,13 +50,15 @@ _threadunlock(Lock *lk, ulong pc) abort(); } +/* note: _procsleep can have spurious wakeups, like pthread_cond_wait */ void _procsleep(_Procrendez *r) { /* r is protected by r->l, which we hold */ pthread_cond_init(&r->cond, 0); r->asleep = 1; - pthread_cond_wait(&r->cond, &r->l->mutex); + if(pthread_cond_wait(&r->cond, &r->l->mutex) != 0) + sysfatal("pthread_cond_wait: %r"); pthread_cond_destroy(&r->cond); r->asleep = 0; } diff --git a/src/libthread/thread.c b/src/libthread/thread.c index f579b5675..902942d9a 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -54,9 +54,9 @@ _threaddebug(char *fmt, ...) va_end(arg); t = proc()->thread; if(t) - fprint(fd, "%d.%d: %s\n", getpid(), t->id, buf); + fprint(fd, "%p %d.%d: %s\n", proc(), getpid(), t->id, buf); else - fprint(fd, "%d._: %s\n", getpid(), buf); + fprint(fd, "%p %d._: %s\n", proc(), getpid(), buf); } static _Thread* @@ -219,20 +219,28 @@ proccreate(void (*fn)(void*), void *arg, uint stack) static void procswitch(Proc *p, _Thread *from, _Thread *to) { -// fprint(2, "procswitch %p %d %d\n", p, from?from->id:-1, to?to->id:-1); + _threaddebug("procswitch %p %d %d", p, from?from->id:-1, to?to->id:-1); lock(&p->schedlock); from->schedrend.l = &p->schedlock; if(to) { p->schedthread = to; to->schedrend.l = &p->schedlock; + _threaddebug("procswitch wakeup %p %d", p, to->id); _procwakeup(&to->schedrend); } if(p->schedthread != from) { if(from->exiting) { unlock(&p->schedlock); _threadpexit(); + _threaddebug("procswitch exit wakeup!!!\n"); } - _procsleep(&from->schedrend); + while(p->schedthread != from) { + _threaddebug("procswitch sleep %p %d", p, from->id); + _procsleep(&from->schedrend); + _threaddebug("procswitch awake %p %d", p, from->id); + } + if(p->schedthread != from) + sysfatal("_procswitch %p %p oops", p->schedthread, from); } unlock(&p->schedlock); } @@ -448,6 +456,7 @@ procscheduler(Proc *p) procswitch(p, p->thread0, t); else contextswitch(&p->schedcontext, &t->context); + _threaddebug("back in scheduler"); /*print("back in scheduler\n"); */ goto Top; } @@ -589,6 +598,10 @@ threadqlock(QLock *l, int block, ulong pc) if(l->owner == nil){ l->owner = (*threadnow)(); /*print("qlock %p @%#x by %p\n", l, pc, l->owner); */ + if(l->owner == nil) { + fprint(2, "%s: qlock uncontended owner=nil oops\n", argv0); + abort(); + } unlock(&l->l); return 1; } @@ -613,6 +626,11 @@ threadqlock(QLock *l, int block, ulong pc) argv0, pc, l->owner, (*threadnow)()); abort(); } + if(l->owner == nil) { + fprint(2, "%s: qlock threadswitch owner=nil oops\n", argv0); + abort(); + } + /*print("qlock wakeup %p @%#x by %p\n", l, pc, (*threadnow)()); */ return 1; } @@ -818,7 +836,7 @@ main(int argc, char **argv) // Easier to just run in pthread-per-thread mode. pthreadperthread = 1; #endif - if(strstr(opts, "nodaemon") || getenv("NOLIBTHREADDAEMONIZE") == nil) + if(strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) _threadsetupdaemonize(); threadargc = argc; From 94d381ec9d579e5336f3817b68cf4d1a8a7333db Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 25 Jan 2020 14:31:52 -0500 Subject: [PATCH 232/323] devdraw: use indirect impl interface Setting up for a real window system. --- src/cmd/devdraw/devdraw.c | 4 ++-- src/cmd/devdraw/devdraw.h | 23 +++++++++++++--------- src/cmd/devdraw/mac-screen.m | 38 ++++++++++++++++++++++++++++-------- src/cmd/devdraw/srv.c | 26 +++++++++++++----------- 4 files changed, 61 insertions(+), 30 deletions(-) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index b4c373ad3..6269dfdaf 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -143,7 +143,7 @@ addflush(Client *c, Rectangle r) // during a resize. rpc_gfxdrawunlock(); qunlock(&c->drawlk); - rpc_flush(c, fr); + c->impl->rpc_flush(c, fr); qlock(&c->drawlk); rpc_gfxdrawlock(); } @@ -188,7 +188,7 @@ drawflush(Client *c) // during a resize. rpc_gfxdrawunlock(); qunlock(&c->drawlk); - rpc_flush(c, r); + c->impl->rpc_flush(c, r); qlock(&c->drawlk); rpc_gfxdrawlock(); } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 6829ab32b..1dac2d506 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -7,6 +7,7 @@ typedef struct Mousebuf Mousebuf; typedef struct Tagbuf Tagbuf; typedef struct Client Client; +typedef struct ClientImpl ClientImpl; typedef struct DImage DImage; typedef struct DScreen DScreen; typedef struct CScreen CScreen; @@ -43,6 +44,18 @@ struct Tagbuf int wi; }; +struct ClientImpl +{ + void (*rpc_resizeimg)(Client*); + void (*rpc_resizewindow)(Client*, Rectangle); + void (*rpc_setcursor)(Client*, Cursor*, Cursor2*); + void (*rpc_setlabel)(Client*, char*); + void (*rpc_setmouse)(Client*, Point); + void (*rpc_topwin)(Client*); + void (*rpc_bouncemouse)(Client*, Mouse); + void (*rpc_flush)(Client*, Rectangle); +}; + struct Client { int rfd; @@ -82,6 +95,7 @@ struct Client int nname; DName* name; int namevers; + ClientImpl* impl; // Only accessed/modified by the graphics thread. const void* view; @@ -196,17 +210,8 @@ void gfx_started(void); Memimage *rpc_attach(Client*, char*, char*); char* rpc_getsnarf(void); void rpc_putsnarf(char*); -void rpc_resizeimg(Client*); -void rpc_resizewindow(Client*, Rectangle); -void rpc_serve(Client*); -void rpc_setcursor(Client*, Cursor*, Cursor2*); -void rpc_setlabel(Client*, char*); -void rpc_setmouse(Client*, Point); void rpc_shutdown(void); -void rpc_topwin(Client*); void rpc_main(void); -void rpc_bouncemouse(Client*, Mouse); -void rpc_flush(Client*, Rectangle); // rpc_gfxdrawlock and rpc_gfxdrawunlock // are called around drawing operations to lock and unlock diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index c6e58341d..9454be05d 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -37,6 +37,27 @@ static uint keycvt(uint); static uint msec(void); +static void rpc_resizeimg(Client*); +static void rpc_resizewindow(Client*, Rectangle); +static void rpc_serve(Client*); +static void rpc_setcursor(Client*, Cursor*, Cursor2*); +static void rpc_setlabel(Client*, char*); +static void rpc_setmouse(Client*, Point); +static void rpc_topwin(Client*); +static void rpc_bouncemouse(Client*, Mouse); +static void rpc_flush(Client*, Rectangle); + +static ClientImpl macimpl = { + rpc_resizeimg, + rpc_resizewindow, + rpc_setcursor, + rpc_setlabel, + rpc_setmouse, + rpc_topwin, + rpc_bouncemouse, + rpc_flush +}; + @class DrawView; @class DrawLayer; @@ -201,6 +222,7 @@ - (BOOL)acceptsFirstResponder { return YES; } { LOG(@"attachscreen(%s, %s)", label, winsize); + c->impl = &macimpl; dispatch_sync(dispatch_get_main_queue(), ^(void) { @autoreleasepool { DrawView *view = [[DrawView new] attach:c winsize:winsize label:label]; @@ -302,7 +324,7 @@ - (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { // rpc_topwin moves the window to the top of the desktop. // Called from an RPC thread with no client lock held. -void +static void rpc_topwin(Client *c) { DrawView *view = (__bridge DrawView*)c->view; @@ -319,7 +341,7 @@ - (void)topwin { // rpc_setlabel updates the client window's label. // If label == nil, the call is a no-op. // Called from an RPC thread with no client lock held. -void +static void rpc_setlabel(Client *client, char *label) { DrawView *view = (__bridge DrawView*)client->view; @@ -344,7 +366,7 @@ - (void)setlabel:(char*)label { // rpc_setcursor updates the client window's cursor image. // Either c and c2 are both non-nil, or they are both nil to use the default arrow. // Called from an RPC thread with no client lock held. -void +static void rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) { DrawView *view = (__bridge DrawView*)client->view; @@ -460,7 +482,7 @@ - (void)initimg { // rpc_flush flushes changes to view.img's rectangle r // to the on-screen window, making them visible. // Called from an RPC thread with no client lock held. -void +static void rpc_flush(Client *client, Rectangle r) { DrawView *view = (__bridge DrawView*)client->view; @@ -506,7 +528,7 @@ - (void)flush:(Rectangle)r { // rpc_resizeimg forces the client window to discard its current window and make a new one. // It is called when the user types Cmd-R to toggle whether retina mode is forced. // Called from an RPC thread with no client lock held. -void +static void rpc_resizeimg(Client *c) { DrawView *view = (__bridge DrawView*)c->view; @@ -541,7 +563,7 @@ - (void)viewDidChangeBackingProperties // rpc_resizewindow asks for the client window to be resized to size r. // Called from an RPC thread with no client lock held. -void +static void rpc_resizewindow(Client *c, Rectangle r) { DrawView *view = (__bridge DrawView*)c->view; @@ -696,7 +718,7 @@ - (void)sendmouse:(NSUInteger)b // rpc_setmouse moves the mouse cursor. // Called from an RPC thread with no client lock held. -void +static void rpc_setmouse(Client *c, Point p) { DrawView *view = (__bridge DrawView*)c->view; @@ -1095,7 +1117,7 @@ - (void)windowDidExitFullScreen:(NSNotification*)notification { // rpc_bouncemouse is for sending a mouse event // back to the X11 window manager rio(1). // Does not apply here. -void +static void rpc_bouncemouse(Client *c, Mouse m) { } diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 570091bcb..bdfc16547 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -54,6 +54,7 @@ threadmain(int argc, char **argv) usage(); }ARGEND + memimageinit(); fmtinstall('H', encodefmt); if((p = getenv("DEVDRAWTRACE")) != nil) trace = atoi(p); @@ -202,8 +203,11 @@ runmsg(Client *c, Wsysmsg *m) break; case Tinit: - memimageinit(); i = rpc_attach(c, m->label, m->winsize); + if(i == nil) { + replyerror(c, m); + break; + } draw_initdisplaymemimage(c, i); replymsg(c, m); break; @@ -241,35 +245,35 @@ runmsg(Client *c, Wsysmsg *m) break; case Tmoveto: - rpc_setmouse(c, m->mouse.xy); + c->impl->rpc_setmouse(c, m->mouse.xy); replymsg(c, m); break; case Tcursor: if(m->arrowcursor) - rpc_setcursor(c, nil, nil); + c->impl->rpc_setcursor(c, nil, nil); else { scalecursor(&m->cursor2, &m->cursor); - rpc_setcursor(c, &m->cursor, &m->cursor2); + c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2); } replymsg(c, m); break; case Tcursor2: if(m->arrowcursor) - rpc_setcursor(c, nil, nil); + c->impl->rpc_setcursor(c, nil, nil); else - rpc_setcursor(c, &m->cursor, &m->cursor2); + c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2); replymsg(c, m); break; case Tbouncemouse: - rpc_bouncemouse(c, m->mouse); + c->impl->rpc_bouncemouse(c, m->mouse); replymsg(c, m); break; case Tlabel: - rpc_setlabel(c, m->label); + c->impl->rpc_setlabel(c, m->label); replymsg(c, m); break; @@ -306,12 +310,12 @@ runmsg(Client *c, Wsysmsg *m) break; case Ttop: - rpc_topwin(c); + c->impl->rpc_topwin(c); replymsg(c, m); break; case Tresize: - rpc_resizewindow(c, m->rect); + c->impl->rpc_resizewindow(c, m->rect); replymsg(c, m); break; } @@ -513,7 +517,7 @@ gfx_keystroke(Client *c, int ch) else c->forcedpi = 225; qunlock(&c->eventlk); - rpc_resizeimg(c); + c->impl->rpc_resizeimg(c); return; } if(!c->kbd.alting){ From 587933c16132d880a06ff99bd087e64a3a04975e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 25 Jan 2020 14:33:20 -0500 Subject: [PATCH 233/323] devdraw: use global drawlk instead of per-client Setting up for a real window system. --- src/cmd/devdraw/devdraw.c | 26 ++++++++++++++------------ src/cmd/devdraw/devdraw.h | 5 +++-- src/cmd/devdraw/mac-screen.m | 7 +++---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 6269dfdaf..234cdf1b2 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -14,6 +14,8 @@ #include #include "devdraw.h" +QLock drawlk; + static int drawuninstall(Client*, int); static Memimage* drawinstall(Client*, int, Memimage*, DScreen*); static void drawfreedimage(Client*, DImage*); @@ -47,14 +49,14 @@ gfx_replacescreenimage(Client *c, Memimage *m) */ Memimage *om; - qlock(&c->drawlk); + qlock(&drawlk); om = c->screenimage; c->screenimage = m; m->screenref = 1; if(om && --om->screenref == 0){ _freememimage(om); } - qunlock(&c->drawlk); + qunlock(&drawlk); gfx_mouseresized(c); } @@ -142,9 +144,9 @@ addflush(Client *c, Rectangle r) // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. rpc_gfxdrawunlock(); - qunlock(&c->drawlk); + qunlock(&drawlk); c->impl->rpc_flush(c, fr); - qlock(&c->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); } } @@ -187,9 +189,9 @@ drawflush(Client *c) // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. rpc_gfxdrawunlock(); - qunlock(&c->drawlk); + qunlock(&drawlk); c->impl->rpc_flush(c, r); - qlock(&c->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); } } @@ -614,7 +616,7 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx) int draw_dataread(Client *cl, void *a, int n) { - qlock(&cl->drawlk); + qlock(&drawlk); if(cl->readdata == nil){ werrstr("no draw data"); goto err; @@ -627,11 +629,11 @@ draw_dataread(Client *cl, void *a, int n) memmove(a, cl->readdata, cl->nreaddata); free(cl->readdata); cl->readdata = nil; - qunlock(&cl->drawlk); + qunlock(&drawlk); return n; err: - qunlock(&cl->drawlk); + qunlock(&drawlk); return -1; } @@ -656,7 +658,7 @@ draw_datawrite(Client *client, void *v, int n) Refreshfn reffn; Refx *refx; - qlock(&client->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); a = v; m = 0; @@ -1431,7 +1433,7 @@ draw_datawrite(Client *client, void *v, int n) } } rpc_gfxdrawunlock(); - qunlock(&client->drawlk); + qunlock(&drawlk); return oldn - n; Enodrawimage: @@ -1502,6 +1504,6 @@ draw_datawrite(Client *client, void *v, int n) error: werrstr("%s", err); rpc_gfxdrawunlock(); - qunlock(&client->drawlk); + qunlock(&drawlk); return -1; } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 1dac2d506..261d04d1e 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -56,6 +56,8 @@ struct ClientImpl void (*rpc_flush)(Client*, Rectangle); }; +extern QLock drawlk; + struct Client { int rfd; @@ -69,10 +71,9 @@ struct Client char* wsysid; - // drawlk protects the draw data structures. + // drawlk protects the draw data structures for all clients. // It can be acquired by an RPC thread or a graphics thread // but must not be held on one thread while waiting for the other. - QLock drawlk; /*Ref r;*/ DImage* dimage[NHASH]; CScreen* cscreen; diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 9454be05d..ad9c029e7 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -39,7 +39,6 @@ static void rpc_resizeimg(Client*); static void rpc_resizewindow(Client*, Rectangle); -static void rpc_serve(Client*); static void rpc_setcursor(Client*, Cursor*, Cursor2*); static void rpc_setlabel(Client*, char*); static void rpc_setmouse(Client*, Point); @@ -496,17 +495,17 @@ - (void)flush:(Rectangle)r { if(!rectclip(&r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height)) || !rectclip(&r, self.img->r)) return; - // self.client->drawlk protects the pixel data in self.img. + // drawlk protects the pixel data in self.img. // In addition to avoiding a technical data race, // the lock avoids drawing partial updates, which makes // animations like sweeping windows much less flickery. - qlock(&self.client->drawlk); + qlock(&drawlk); [self.dlayer.texture replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) mipmapLevel:0 withBytes:byteaddr(self.img, Pt(r.min.x, r.min.y)) bytesPerRow:self.img->width*sizeof(u32int)]; - qunlock(&self.client->drawlk); + qunlock(&drawlk); NSRect nr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); dispatch_time_t time; From c53ad837a734f7570badcb3666ccb3604e7e6467 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 17:03:42 -0400 Subject: [PATCH 234/323] lib9: avoid unportable use of d_namlen in dirread Fixes #395. --- src/lib9/open.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib9/open.c b/src/lib9/open.c index 65ea99ec7..2354268bb 100644 --- a/src/lib9/open.c +++ b/src/lib9/open.c @@ -318,8 +318,7 @@ dirreadmax(int fd, Dir **dp, int max) return -1; break; } - if(de->d_name[de->d_namlen] != 0) - sysfatal("bad readdir"); + // Note: not all systems have d_namlen. Assume NUL-terminated. if(de->d_name[0]=='.' && de->d_name[1]==0) continue; if(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0) From 84167be4ad170c879db48493438f507c2d40d28d Mon Sep 17 00:00:00 2001 From: Gabriel Diaz Date: Mon, 18 May 2020 17:38:16 +0200 Subject: [PATCH 235/323] devdraw: use indirect impl interface in x11 --- src/cmd/devdraw/x11-screen.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 62f49f2f7..0bbc25d69 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -40,6 +40,26 @@ static void _xmovewindow(Xwin *w, Rectangle r); static int _xtoplan9kbd(XEvent *e); static int _xselect(XEvent *e); +static void rpc_resizeimg(Client*); +static void rpc_resizewindow(Client*, Rectangle); +static void rpc_setcursor(Client*, Cursor*, Cursor2*); +static void rpc_setlabel(Client*, char*); +static void rpc_setmouse(Client*, Point); +static void rpc_topwin(Client*); +static void rpc_bouncemouse(Client*, Mouse); +static void rpc_flush(Client*, Rectangle); + +static ClientImpl x11impl = { + rpc_resizeimg, + rpc_resizewindow, + rpc_setcursor, + rpc_setlabel, + rpc_setmouse, + rpc_topwin, + rpc_bouncemouse, + rpc_flush +}; + static Xwin* newxwin(Client *c) { @@ -51,6 +71,7 @@ newxwin(Client *c) w->client = c; w->next = _x.windows; _x.windows = w; + c->impl = &x11impl; c->view = w; return w; } From d4a4b66a401d8988441dd663bf1664e11c045797 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 19:55:01 -0400 Subject: [PATCH 236/323] diff: rename class to fix AIX math.h defines a function named class on AIX. --- src/cmd/diff/diffreg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/diff/diffreg.c b/src/cmd/diff/diffreg.c index ed4d17b8e..478c1b1b4 100644 --- a/src/cmd/diff/diffreg.c +++ b/src/cmd/diff/diffreg.c @@ -66,6 +66,9 @@ * 3*(number of k-candidates installed), typically about * 6n words for files of length n. */ + +#define class diffclass + /* TIDY THIS UP */ struct cand { int x; From 079f5e94459fe5afccf749764d81ab88c59f055a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:29:00 -0400 Subject: [PATCH 237/323] libdiskfs: avoid problematic internal constant names AIX defines some of these constants in its C header files. --- src/libdiskfs/ext2.h | 33 +++++++++++++++++++++++++++++++++ src/libdiskfs/ffs.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/libdiskfs/ext2.h b/src/libdiskfs/ext2.h index f4c32ce3a..bf98a9ac8 100644 --- a/src/libdiskfs/ext2.h +++ b/src/libdiskfs/ext2.h @@ -27,6 +27,39 @@ enum NAMELEN = 255, + /* 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 EXT2_IEXEC + #define IWRITE EXT2_IWRITE + #define IREAD EXT2_IREAD + #define ISVTX EXT2_ISVTX + #define ISGID EXT2_ISGID + #define ISUID EXT2_ISUID + #define IFMT EXT2_IFMT + #define IFIFO EXT2_IFIFO + #define IFCHR EXT2_IFCHR + #define IFDIR EXT2_IFDIR + #define IFBLK EXT2_IFBLK + #define IFREG EXT2_IFREG + #define IFLNK EXT2_IFLNK + #define IFSOCK EXT2_IFSOCK + #define IFWHT EXT2_IFWHT + /* permissions in Inode.mode */ IEXEC = 00100, IWRITE = 0200, diff --git a/src/libdiskfs/ffs.h b/src/libdiskfs/ffs.h index d7881f15f..b8675448f 100644 --- a/src/libdiskfs/ffs.h +++ b/src/libdiskfs/ffs.h @@ -72,6 +72,39 @@ enum NDADDR = 12, NIADDR = 3, + /* 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 FFS_IEXEC + #define IWRITE FFS_IWRITE + #define IREAD FFS_IREAD + #define ISVTX FFS_ISVTX + #define ISGID FFS_ISGID + #define ISUID FFS_ISUID + #define IFMT FFS_IFMT + #define IFIFO FFS_IFIFO + #define IFCHR FFS_IFCHR + #define IFDIR FFS_IFDIR + #define IFBLK FFS_IFBLK + #define IFREG FFS_IFREG + #define IFLNK FFS_IFLNK + #define IFSOCK FFS_IFSOCK + #define IFWHT FFS_IFWHT + /* permissions in Inode.mode */ IEXEC = 00100, IWRITE = 0200, From dea4dbdba6e8a4652e682627dce50503bca5c4b4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:31:22 -0400 Subject: [PATCH 238/323] acme: avoid global named "class" For AIX. --- src/cmd/acme/regx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/acme/regx.c b/src/cmd/acme/regx.c index 56ea900c6..ec5745631 100644 --- a/src/cmd/acme/regx.c +++ b/src/cmd/acme/regx.c @@ -15,6 +15,9 @@ Rangeset sel; Rune *lastregexp; +#undef class +#define class regxclass /* some systems declare "class" in system headers */ + /* * Machine Information */ From 20c841bac102e777a3a1723724fa5d31018fefcc Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:32:59 -0400 Subject: [PATCH 239/323] rc: avoid problematic internal names "var", "thread" For AIX. --- src/cmd/rc/rc.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/rc/rc.h b/src/cmd/rc/rc.h index 46ff95106..2fd6758b6 100644 --- a/src/cmd/rc/rc.h +++ b/src/cmd/rc/rc.h @@ -33,6 +33,12 @@ #undef pipe /* so that /dev/fd works */ #define searchpath rcsearchpath /* avoid new libc function */ +/* some systems define a global "var", "thread" */ +#undef var +#define var rcvar +#undef thread +#define thread rcthread + typedef struct tree tree; typedef struct word word; typedef struct io io; From 7a371bf93652573b3d57d50466d3ea22a6eebff2 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Wed, 13 May 2020 22:39:53 -0700 Subject: [PATCH 240/323] lib9: use __builtin_return_address on IBM XL/C --- include/libc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libc.h b/include/libc.h index 7b4c38131..4bb537d67 100644 --- a/include/libc.h +++ b/include/libc.h @@ -385,7 +385,7 @@ extern int exitcode(char*); extern void exits(char*); extern double p9frexp(double, int*); extern ulong getcallerpc(void*); -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) || defined(__clang__) || defined(__IBMC__) #define getcallerpc(x) ((ulong)__builtin_return_address(0)) #endif extern char* p9getenv(char*); From 53bf1f1ccf9a6fee9437649216ac047f80590fae Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 18 May 2020 12:20:48 -0700 Subject: [PATCH 241/323] 9l: xlc_r automatically adds -lpthread. --- bin/9l | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/9l b/bin/9l index 875e103ab..b4f915840 100755 --- a/bin/9l +++ b/bin/9l @@ -63,7 +63,6 @@ case "$tag" in *AIX*) ld="${CC9:-xlc_r} -g -O0 $CC9FLAGS" nmflags="-A -B" - extralibs="$extralibs -lpthread" ;; *) echo do not know how to link on "$tag" 1>&2 From fa157263c8f510318f1f119a2d4843281e506eba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:38:54 -0400 Subject: [PATCH 242/323] 9c: fix tab --- bin/9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/9c b/bin/9c index dd8992933..a22a0a087 100755 --- a/bin/9c +++ b/bin/9c @@ -149,7 +149,7 @@ case "$tag" in cflags="$cflags -g" cflags="$cflags -D__sun__ -D__${s}__" ;; -*AIX*) usexlc +*AIX*) usexlc cflags="$cflags -g -D__AIX__" ;; *) From 6c1235d234dfe290c61c492a1779c7a3ad2f7fc6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:46:16 -0400 Subject: [PATCH 243/323] build: use installbsd instead of install on AIX Even in mkmk.sh. --- dist/buildmk | 2 +- src/mk.AIX-power | 2 -- src/mkenv | 1 + src/mkfile | 3 ++- src/mkhdr | 3 --- src/mkmk.sh | 2 +- 6 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 src/mk.AIX-power diff --git a/dist/buildmk b/dist/buildmk index c559570cd..cd11417c0 100755 --- a/dist/buildmk +++ b/dist/buildmk @@ -2,5 +2,5 @@ # run this in the src directory . ../src/mkenv -export SYSNAME OBJTYPE +export SYSNAME OBJTYPE INSTALL sh -x mkmk.sh diff --git a/src/mk.AIX-power b/src/mk.AIX-power deleted file mode 100644 index 39f8ee8a2..000000000 --- a/src/mk.AIX-power +++ /dev/null @@ -1,2 +0,0 @@ -INSTALL=installbsd - diff --git a/src/mkenv b/src/mkenv index 6ff746e08..6c89f141b 100644 --- a/src/mkenv +++ b/src/mkenv @@ -20,3 +20,4 @@ OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' s;.*aarch64.*;arm64; s;.*arm64.*;arm64; '` +INSTALL=`[ $(uname) = AIX ] && echo installbsd || echo install` diff --git a/src/mkfile b/src/mkfile index 8ddaee207..4740780db 100644 --- a/src/mkfile +++ b/src/mkfile @@ -30,11 +30,12 @@ mkmk.sh:VD: (cd lib9; mk -n -a install) echo cd .. for i in libbio libregexp cmd/mk - do + do (cd $i; echo cd $i; echo 'echo cd `pwd`'; mk -n -a install) echo cd .. done ) | sed ' + s/'$INSTALL'/$INSTALL/g s/'$SYSNAME'/$SYSNAME/g s/'$OBJTYPE'/$OBJTYPE/g s;'$PLAN9';$PLAN9;g diff --git a/src/mkhdr b/src/mkhdr index 24889cded..35a2ccc54 100644 --- a/src/mkhdr +++ b/src/mkhdr @@ -11,7 +11,6 @@ CC=9c LD=9l AS=9a AR=9ar -INSTALL=install CFLAGS= LDFLAGS= AFLAGS= @@ -24,5 +23,3 @@ LIB= SHORTLIB=9 <|cat $PLAN9/config 2>/dev/null || true -<|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true - diff --git a/src/mkmk.sh b/src/mkmk.sh index 89c311f36..dfccd3694 100644 --- a/src/mkmk.sh +++ b/src/mkmk.sh @@ -209,5 +209,5 @@ echo cd `pwd` 9c word.c 9c unix.c 9l -o o.mk arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rc.o rule.o run.o sh.o shell.o shprint.o symtab.o var.o varsub.o word.o unix.o -install o.mk $PLAN9/bin/mk +$INSTALL o.mk $PLAN9/bin/mk cd .. From b4cc38f94321c71e8d19fbbd4691e72f7c0d817b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:58:09 -0400 Subject: [PATCH 244/323] build: drop _XOPEN_SOURCE in u.h on AIX --- include/u.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/u.h b/include/u.h index 297df70ae..f84e348a6 100644 --- a/include/u.h +++ b/include/u.h @@ -35,7 +35,6 @@ extern "C" { # define __LONG_LONG_SUPPORTED #endif #if defined(__AIX__) -# define _XOPEN_SOURCE 600 # define _ALL_SOURCE # undef HAS_SYS_TERMIOS #endif From d25d0ca1a3682d97df67f62789767562aa5bf1b3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 23:45:03 -0400 Subject: [PATCH 245/323] devdraw, libdraw: handle keyboard runes > U+FFFF Runes in Plan 9 were limited to the 16-bit BMP when I drew up the RPC protocol between graphical programs and devdraw a long time ago. Now that they can be 32-bit, use a 32-bit wire encoding too. A new message number to avoid problems with other clients (like 9fans.net/go). Add keyboard shortcut alt : , for U+1F602, face with tears of joy, to test that it all works. --- include/drawfcall.h | 11 ++++++++--- lib/keyboard | 1 + src/cmd/devdraw/mklatinkbd.c | 2 +- src/cmd/devdraw/srv.c | 9 +++++++-- src/libdraw/drawclient.c | 2 +- src/libdraw/drawfcall.c | 15 +++++++++++++++ src/libdraw/event.c | 2 +- 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/include/drawfcall.h b/include/drawfcall.h index 8b9656d55..b8535fb65 100644 --- a/include/drawfcall.h +++ b/include/drawfcall.h @@ -22,8 +22,11 @@ tag[1] Rbouncemouse tag[1] Trdkbd tag[1] Rrdkbd rune[2] +tag[1] Trdkbd4 +tag[1] Rrdkbd4 rune[4] + tag[1] Tlabel label[s] -tag[1] Rlabel +tag[1] Rlabel tag[1] Tctxt wsysid[s] tag[1] Rctxt @@ -31,7 +34,7 @@ tag[1] Rctxt tag[1] Tinit winsize[s] label[s] font[s] tag[1] Rinit -tag[1] Trdsnarf +tag[1] Trdsnarf tag[1] Rrdsnarf snarf[s] tag[1] Twrsnarf snarf[s] @@ -47,7 +50,7 @@ tag[1] Ttop tag[1] Rtop tag[1] Tresize rect[4*4] -tag[1] Rresize +tag[1] Rresize */ @@ -99,6 +102,8 @@ enum { Rcursor2, Tctxt = 30, Rctxt, + Trdkbd4 = 32, + Rrdkbd4, Tmax, }; diff --git a/lib/keyboard b/lib/keyboard index a1574a365..1a0e85a50 100644 --- a/lib/keyboard +++ b/lib/keyboard @@ -584,3 +584,4 @@ F015 ZA  raw alt (plan 9 specific) F016 ZS  raw shift (plan 9 specific) F017 ZC  raw ctl (plan 9 specific) +1F602 :, 😂 face with tears of joy diff --git a/src/cmd/devdraw/mklatinkbd.c b/src/cmd/devdraw/mklatinkbd.c index db34b6ece..50dd26b05 100644 --- a/src/cmd/devdraw/mklatinkbd.c +++ b/src/cmd/devdraw/mklatinkbd.c @@ -191,7 +191,7 @@ readfile(char *fname) r = strtol(line, nil, 16); p = strchr(line, ' '); - if(r == 0 || p != line+4 || p[0] != ' ' || p[1] != ' ') { + if(r == 0 || (p != line+4 && p != line+5) || p[0] != ' ' || (p == line+4 && p[1] != ' ')) { fprint(2, "%s:%d: cannot parse line\n", fname, lineno); continue; } diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index bdfc16547..05a08fda4 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -229,6 +229,7 @@ runmsg(Client *c, Wsysmsg *m) break; case Trdkbd: + case Trdkbd4: qlock(&c->eventlk); if((c->kbdtags.wi+1)%nelem(c->kbdtags.t) == c->kbdtags.ri) { qunlock(&c->eventlk); @@ -236,7 +237,7 @@ runmsg(Client *c, Wsysmsg *m) replyerror(c, m); break; } - c->kbdtags.t[c->kbdtags.wi++] = m->tag; + c->kbdtags.t[c->kbdtags.wi++] = (m->tag<<1) | (m->type==Trdkbd4); if(c->kbdtags.wi == nelem(c->kbdtags.t)) c->kbdtags.wi = 0; c->kbd.stall = 0; @@ -357,13 +358,17 @@ replymsg(Client *c, Wsysmsg *m) static void matchkbd(Client *c) { + int tag; Wsysmsg m; if(c->kbd.stall) return; while(c->kbd.ri != c->kbd.wi && c->kbdtags.ri != c->kbdtags.wi){ + tag = c->kbdtags.t[c->kbdtags.ri++]; m.type = Rrdkbd; - m.tag = c->kbdtags.t[c->kbdtags.ri++]; + if(tag&1) + m.type = Rrdkbd4; + m.tag = tag>>1; if(c->kbdtags.ri == nelem(c->kbdtags.t)) c->kbdtags.ri = 0; m.rune = c->kbd.r[c->kbd.ri++]; diff --git a/src/libdraw/drawclient.c b/src/libdraw/drawclient.c index 9376f9c00..c38f4801b 100644 --- a/src/libdraw/drawclient.c +++ b/src/libdraw/drawclient.c @@ -333,7 +333,7 @@ _displayrdkbd(Display *d, Rune *r) { Wsysmsg tx, rx; - tx.type = Trdkbd; + tx.type = Trdkbd4; if(displayrpc(d, &tx, &rx, nil) < 0) return -1; *r = rx.rune; diff --git a/src/libdraw/drawfcall.c b/src/libdraw/drawfcall.c index eea140956..941153844 100644 --- a/src/libdraw/drawfcall.c +++ b/src/libdraw/drawfcall.c @@ -50,6 +50,7 @@ sizeW2M(Wsysmsg *m) case Rcursor: case Rcursor2: case Trdkbd: + case Trdkbd4: case Rlabel: case Rctxt: case Rinit: @@ -73,6 +74,8 @@ sizeW2M(Wsysmsg *m) return 4+1+1+_stringsize(m->error); case Rrdkbd: return 4+1+1+2; + case Rrdkbd4: + return 4+1+1+4; case Tlabel: return 4+1+1+_stringsize(m->label); case Tctxt: @@ -117,6 +120,7 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Rcursor: case Rcursor2: case Trdkbd: + case Trdkbd4: case Rlabel: case Rctxt: case Rinit: @@ -166,6 +170,9 @@ convW2M(Wsysmsg *m, uchar *p, uint n) case Rrdkbd: PUT2(p+6, m->rune); break; + case Rrdkbd4: + PUT(p+6, m->rune); + break; case Tlabel: PUTSTRING(p+6, m->label); break; @@ -221,6 +228,7 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Rcursor: case Rcursor2: case Trdkbd: + case Trdkbd4: case Rlabel: case Rctxt: case Rinit: @@ -270,6 +278,9 @@ convM2W(uchar *p, uint n, Wsysmsg *m) case Rrdkbd: GET2(p+6, m->rune); break; + case Rrdkbd4: + GET(p+6, m->rune); + break; case Tlabel: GETSTRING(p+6, &m->label); break; @@ -360,6 +371,10 @@ drawfcallfmt(Fmt *fmt) return fmtprint(fmt, "Trdkbd"); case Rrdkbd: return fmtprint(fmt, "Rrdkbd rune=%C", m->rune); + case Trdkbd4: + return fmtprint(fmt, "Trdkbd4"); + case Rrdkbd4: + return fmtprint(fmt, "Rrdkbd4 rune=%C", m->rune); case Tlabel: return fmtprint(fmt, "Tlabel label='%s'", m->label); case Rlabel: diff --git a/src/libdraw/event.c b/src/libdraw/event.c index 9d7e10c23..e2d5f7072 100644 --- a/src/libdraw/event.c +++ b/src/libdraw/event.c @@ -284,7 +284,7 @@ extract(int canblock) } }else if(i == Skeyboard){ if(eslave[i].rpc == nil) - eslave[i].rpc = startrpc(Trdkbd); + eslave[i].rpc = startrpc(Trdkbd4); if(eslave[i].rpc){ /* if ready, don't block in select */ if(eslave[i].rpc->p) From bfe4377e409ce271c479665e6ef966a7b6008626 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 23:51:35 -0400 Subject: [PATCH 246/323] man: update man pages to say $HOME when accurate Fixes #386. --- man/man1/acid.1 | 30 +++++++++++++++--------------- man/man1/acme.1 | 8 ++++---- man/man1/rc.1 | 4 ++++ man/man1/sam.1 | 28 ++++++++++++++-------------- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/man/man1/acid.1 b/man/man1/acid.1 index e76aeb25f..ed0b24db9 100644 --- a/man/man1/acid.1 +++ b/man/man1/acid.1 @@ -48,7 +48,7 @@ is a programmable symbolic debugger. It can inspect one or more processes that share an address space. A program to be debugged may be specified by the process id of a running or defunct process, -or by the name of the program's text file +or by the name of the program's text file .RB ( a.out by default). At the prompt, @@ -63,7 +63,7 @@ Allow the textfile to be modified. Print variable renamings at startup. .TP .BI -l " library -Load from +Load from .I library at startup; see below. .TP @@ -84,8 +84,8 @@ obtains standard function definitions from the library file architecture-dependent functions from .BR \*9/acid/$objtype , user-specified functions from -.BR $home/lib/acid , -and further functions from +.BR $HOME/lib/acid , +and further functions from .B -l files. Definitions in any file may override previously defined functions. @@ -106,7 +106,7 @@ to create .I acid functions for examining data structures. .SS Language -Symbols of the program being debugged become integer +Symbols of the program being debugged become integer variables whose values are addresses. Contents of addresses are obtained by indirection. Local variables are qualified by @@ -114,7 +114,7 @@ function name, for example .BR main:argv . When program symbols conflict with .I acid -words, distinguishing +words, distinguishing .B $ signs are prefixed. Such renamings are reported at startup; option @@ -127,7 +127,7 @@ and formats are inferred from assignments. Truth values false/true are attributed to zero/nonzero integers or floats and to empty/nonempty lists or strings. Lists are sequences of expressions surrounded by -.BR {\^} +.BR {\^} and separated by commas. .PP Expressions are much as in C, @@ -219,7 +219,7 @@ Same as .BR spr();gpr() . .TP .BI fmt( expr , format ) -Expression +Expression .I expr with format given by the character value of expression .IR format . @@ -243,7 +243,7 @@ List current source directories. Add a source directory to the list. .TP .BI filepc( where ) -Convert a string of the form +Convert a string of the form .IB sourcefile : linenumber to a machine address. .TP @@ -288,7 +288,7 @@ interpreted according to a string of format codes. .BI dump( address , n , string\fP) Like .BR mem (), -repeated for +repeated for .I n consecutive blocks. .TP @@ -300,7 +300,7 @@ Start a new process with arguments given as a string and halt at the first instruction. .TP .B new() -Like +Like .IR newproc (), but take arguments (except .BR argv[0] ) @@ -308,7 +308,7 @@ from string variable .BR progargs . .TP .B win() -Like +Like .IR new (), but run the process in a separate window. .TP @@ -337,7 +337,7 @@ When a pid or core file is specified on the command line, .I acid will, as part of its startup, determine the set of shared libraries in use by the process image and map those at appropriate locations. -If +If .I acid is started without a pid or core file and is subsequently attached to a process via @@ -414,7 +414,7 @@ acid: *argv0 acid: bpset(ls) acid: cont() 70094: breakpoint ls ADD $-0x16c8,R29 -acid: +acid: .EE .PP Display elements of a linked list of structures: @@ -499,7 +499,7 @@ acid: cont() .br .B \*9/acid/truss .br -.B $home/lib/acid +.B $HOME/lib/acid .SH SOURCE .B \*9/src/cmd/acid .SH "SEE ALSO" diff --git a/man/man1/acme.1 b/man/man1/acme.1 index 182bcc7b6..f21566f91 100644 --- a/man/man1/acme.1 +++ b/man/man1/acme.1 @@ -300,7 +300,7 @@ Delete window without checking for dirtiness. Write the state of .I acme to the file name, if specified, or -.B $home/acme.dump +.B $HOME/acme.dump by default. .TP .B Edit @@ -403,7 +403,7 @@ commands named as arguments. Restore the state of .I acme from a file (default -.BR $home/acme.dump ) +.BR $HOME/acme.dump ) created by the .B Dump command. @@ -745,9 +745,9 @@ and .I awd reside. .SH FILES -.TF $home/acme.dump +.TF $HOME/acme.dump .TP -.B $home/acme.dump +.B $HOME/acme.dump default file for .B Dump and diff --git a/man/man1/rc.1 b/man/man1/rc.1 index 792cdc95b..7553707d0 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -806,6 +806,10 @@ is set to its process id. .B $home The default directory for .BR cd . +Defaults to +.B $HOME +or else +.LR / . .TP .B $ifs The input field separators used in backquote substitutions. diff --git a/man/man1/sam.1 b/man/man1/sam.1 index 460fd6d6d..8e771833f 100644 --- a/man/man1/sam.1 +++ b/man/man1/sam.1 @@ -1,7 +1,7 @@ .TH SAM 1 .ds a \fR*\ \fP .SH NAME -sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular expressions +sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular expressions .SH SYNOPSIS .B sam [ @@ -43,7 +43,7 @@ The options are .TP .B -a Autoindent. In this mode, when a newline character is typed -in the terminal interface, +in the terminal interface, .I samterm copies leading white space on the current line to the new line. .TP @@ -121,7 +121,7 @@ is the beginning of the file. .TP .BI ? regexp ? The substring that matches the regular expression, -found by looking toward the end +found by looking toward the end .RB ( / ) or beginning .RB ( ? ) @@ -248,7 +248,7 @@ or is reversed. .PP It is an error for a compound address to represent a malformed substring. -Some useful idioms: +Some useful idioms: .IB a1 +- \%(\f2a1\fB-+\f1) selects the line containing @@ -258,7 +258,7 @@ locates the first match of the expression in the file. (The form .B 0;// sets dot unnecessarily.) -.BI ./ regexp /// +.BI ./ regexp /// finds the second following occurrence of the expression, and .BI .,/ regexp / @@ -276,7 +276,7 @@ newline may not appear literally; .B \en may be typed for newline; and .B \e/ -quotes the delimiter, here +quotes the delimiter, here .LR / . Backslash is otherwise interpreted literally, except in .B s @@ -284,7 +284,7 @@ commands. .PP Most commands may be prefixed by an address to indicate their range of operation. -Those that may not are marked with a +Those that may not are marked with a .L * below. If a command takes @@ -347,12 +347,12 @@ Substitute .I text for the first match to the regular expression in the range. Set dot to the modified range. -In +In .I text the character .B & stands for the string -that matched the expression. +that matched the expression. Backslash behaves as usual unless followed by a digit: .BI \e d @@ -500,7 +500,7 @@ Plan 9 command. .BI \*acd " directory Change working directory. If no directory is specified, -.B $home +.B $HOME is used. .PD .PP @@ -543,7 +543,7 @@ For each match of the regular expression in the range, run the command with dot set to the match. Set dot to the last match. If the regular -expression and its slashes are omitted, +expression and its slashes are omitted, .L /.*\en/ is assumed. Null string matches potentially occur before every character @@ -652,7 +652,7 @@ If no address is specified (the command is a newline) dot is extended in either direction to line boundaries and printed. If dot is thereby unchanged, it is set to -.B .+1 +.B .+1 and printed. .PD .SS Grouping and multiple changes @@ -713,7 +713,7 @@ of a rectangle. from the command window or the whole screen, depending on where the null rectangle is. .TF resize -.TP +.TP .B new Create a new, empty file. .TP @@ -819,7 +819,7 @@ typed in a command. Send the text in dot, or the snarf buffer if dot is the null string, as if it were typed to the command window. Saves the sent text in the snarf buffer. -(Command window only.) +(Command window only.) .PD .SS Simulated buttons For systems without a three-button mouse, the keyboard modifier From a6ad39aaaa36b8aadc5c35bfc803afbde32918c0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 26 May 2020 11:24:18 -0400 Subject: [PATCH 247/323] libdraw: handle larger number of subfonts --- include/draw.h | 5 +++-- man/man3/cachechars.3 | 2 +- src/libdraw/openfont.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/draw.h b/include/draw.h index 926cc7486..9a22e6b62 100644 --- a/include/draw.h +++ b/include/draw.h @@ -311,8 +311,8 @@ struct Font Display *display; short height; /* max height of image, interline spacing */ short ascent; /* top of image to baseline */ - short width; /* widest so far; used in caching only */ - short nsub; /* number of subfonts */ + short width; /* widest so far; used in caching only */ + int nsub; /* number of subfonts */ u32int age; /* increasing counter; used for LRU */ int maxdepth; /* maximum depth of all loaded subfonts */ int ncache; /* size of cache */ @@ -516,6 +516,7 @@ extern Display *display; extern Font *font; extern Image *screen; extern Screen *_screen; +extern int drawmousemask; /* set bits to disable receiving those buttons */ extern int _cursorfd; extern int _drawdebug; /* set to 1 to see errors from flushimage */ extern void _setdrawop(Display*, Drawop); diff --git a/man/man3/cachechars.3 b/man/man3/cachechars.3 index b0c7abfac..f2d82f190 100644 --- a/man/man3/cachechars.3 +++ b/man/man3/cachechars.3 @@ -165,7 +165,7 @@ struct Font { short height; /* max ht of image;interline space*/ short ascent; /* top of image to baseline */ short width; /* widest so far; used in caching */ - short nsub; /* number of subfonts */ + int nsub; /* number of subfonts */ ulong age; /* increasing counter; for LRU */ int ncache; /* size of cache */ int nsubf; /* size of subfont list */ diff --git a/src/libdraw/openfont.c b/src/libdraw/openfont.c index 9312eb437..8714a8c7f 100644 --- a/src/libdraw/openfont.c +++ b/src/libdraw/openfont.c @@ -69,7 +69,7 @@ openfont1(Display *d, char *name) n = _drawflength(fd); if(fd < 0 && strncmp(fname, "/mnt/font/", 10) == 0) { fd = _fontpipe(fname+10); - n = 128*1024; + n = 1024*1024; } if(fd < 0){ free(nambuf); From 5f0fa185d0a978b45de5bf206193769596c056b5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 26 May 2020 11:36:59 -0400 Subject: [PATCH 248/323] fontsrv: handle non-BMP runes on X11 Have to adjust algorithms to deal with much larger number of subfont files as well. --- src/cmd/fontsrv/a.h | 9 ++++--- src/cmd/fontsrv/mac.c | 6 +++-- src/cmd/fontsrv/main.c | 53 ++++++++++++++++++------------------------ src/cmd/fontsrv/x11.c | 19 ++++++++------- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/cmd/fontsrv/a.h b/src/cmd/fontsrv/a.h index 164b1bd6c..2eeb404f6 100644 --- a/src/cmd/fontsrv/a.h +++ b/src/cmd/fontsrv/a.h @@ -4,19 +4,22 @@ int nxfont; enum { SubfontSize = 32, - SubfontMask = (1<<16)/SubfontSize - 1, + MaxSubfont = (Runemax+1)/SubfontSize, }; struct XFont { char *name; int loaded; - uchar range[(1<<16)/SubfontSize]; // range[i] == whether to have subfont i*SubfontSize to (i+1)*SubfontSize - 1. - int nrange; + uchar range[MaxSubfont]; // range[i] = fontfile starting at i*SubfontSize exists + ushort file[MaxSubfont]; // file[i] == fontfile i's lo rune / SubfontSize + int nfile; int unit; double height; double originy; void (*loadheight)(XFont*, int, int*, int*); + char *fonttext; + int nfonttext; // fontconfig workarround, as FC_FULLNAME does not work for matching fonts. char *fontfile; diff --git a/src/cmd/fontsrv/mac.c b/src/cmd/fontsrv/mac.c index b4dadd90a..9829b5a89 100644 --- a/src/cmd/fontsrv/mac.c +++ b/src/cmd/fontsrv/mac.c @@ -200,9 +200,12 @@ load(XFont *f) f->loadheight = fontheight; // enable all Unicode ranges + if(nelem(f->file) > 0xffff) + sysfatal("too many subfiles"); // f->file holds ushorts for(i=0; irange); i++) { f->range[i] = 1; - f->nrange++; + f->file[i] = i; + f->nfile++; } } @@ -233,7 +236,6 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) if(font == nil) return nil; - bbox = CTFontGetBoundingBox(font); x = (int)(bbox.size.width*2 + 0.99999999); diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index ebab62497..b2189be98 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -52,7 +52,7 @@ enum #define QFONT(p) (((p) >> 4) & 0xFFFF) #define QSIZE(p) (((p) >> 20) & 0xFF) #define QANTIALIAS(p) (((p) >> 28) & 0x1) -#define QRANGE(p) (((p) >> 29) & SubfontMask) +#define QRANGE(p) (((p) >> 29) & 0xFFFFFF) static int sizes[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 28 }; static vlong @@ -102,7 +102,7 @@ dostat(vlong path, Qid *qid, Dir *dir) case Qfontfile: f = &xfont[QFONT(path)]; load(f); - length = 11+1+11+1+f->nrange*(6+1+6+1+9+1); + length = 11+1+11+1+f->nfile*(6+1+6+1+9+1); name = "font"; break; @@ -189,9 +189,9 @@ xwalk1(Fid *fid, char *name, Qid *qid) goto NotFound; p++; n = strtoul(p, &p, 16); - if(p != name+5 || n%SubfontSize != 0 || strcmp(p, ".bit") != 0 || !f->range[(n/SubfontSize) & SubfontMask]) + if(p < name+5 || p > name+5 && name[1] == '0' || n%SubfontSize != 0 || n/SubfontSize >= MaxSubfont || strcmp(p, ".bit") != 0 || !f->range[n/SubfontSize]) goto NotFound; - path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n/SubfontSize) & SubfontMask); + path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, n/SubfontSize); break; } Found: @@ -229,7 +229,6 @@ sizegen(int i, Dir *d, void *v) vlong path; Fid *fid; XFont *f; - int j; fid = v; path = fid->qid.path; @@ -240,15 +239,10 @@ sizegen(int i, Dir *d, void *v) i--; f = &xfont[QFONT(path)]; load(f); - for(j=0; jrange); j++) { - if(f->range[j] == 0) - continue; - if(i == 0) { - path += Qsubfontfile - Qsizedir; - path += qpath(0, 0, 0, 0, j); - goto Done; - } - i--; + if(i < f->nfile) { + path += Qsubfontfile - Qsizedir; + path += qpath(0, 0, 0, 0, f->file[i]); + goto Done; } return -1; @@ -315,23 +309,22 @@ xread(Req *r) readstr(r, "font missing\n"); break; } - height = 0; - ascent = 0; - if(f->unit > 0) { - height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; - ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); - } - if(f->loadheight != nil) - f->loadheight(f, QSIZE(path), &height, &ascent); - fmtprint(&fmt, "%11d %11d\n", height, ascent); - for(i=0; irange); i++) { - if(f->range[i] == 0) - continue; - fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", i*SubfontSize, ((i+1)*SubfontSize) - 1, i*SubfontSize); + if(f->fonttext == nil) { + height = 0; + ascent = 0; + if(f->unit > 0) { + height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; + ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); + } + if(f->loadheight != nil) + f->loadheight(f, QSIZE(path), &height, &ascent); + fmtprint(&fmt, "%11d %11d\n", height, ascent); + for(i=0; infile; i++) + fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", f->file[i]*SubfontSize, ((f->file[i]+1)*SubfontSize) - 1, f->file[i]*SubfontSize); + f->fonttext = fmtstrflush(&fmt); + f->nfonttext = strlen(f->fonttext); } - data = fmtstrflush(&fmt); - readstr(r, data); - free(data); + readbuf(r, f->fonttext, f->nfonttext); break; case Qsubfontfile: f = &xfont[QFONT(path)]; diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 0f6b97bbf..c78ad0366 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -85,20 +85,23 @@ load(XFont *f) int idx = charcode/SubfontSize; - if(charcode > 0xffff) + if(charcode > Runemax) break; - if(!f->range[idx]) { + if(!f->range[idx]) f->range[idx] = 1; - f->nrange++; - } } + FT_Done_Face(face); + // libdraw expects U+0000 to be present - if(!f->range[0]) { + if(!f->range[0]) f->range[0] = 1; - f->nrange++; - } - FT_Done_Face(face); + + // fix up file list + for(i=0; irange); i++) + if(f->range[i]) + f->file[f->nfile++] = i; + f->loaded = 1; } From 2c70acc3ab751ab1ccb1999f1d22310ad8c35b27 Mon Sep 17 00:00:00 2001 From: dzklaim Date: Sat, 30 May 2020 01:02:10 +0000 Subject: [PATCH 249/323] fontsrv: scale f->originy to match f->height on x11 Co-authored-by: dzklaim --- src/cmd/fontsrv/x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index c78ad0366..417dcfa6c 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -78,7 +78,7 @@ load(XFont *f) } f->unit = face->units_per_EM; f->height = (int)((face->ascender - face->descender) * 1.35); - f->originy = face->descender; // bbox.yMin (or descender) is negative, becase the baseline is y-coord 0 + f->originy = face->descender * 1.35; // bbox.yMin (or descender) is negative, because the baseline is y-coord 0 for(charcode=FT_Get_First_Char(face, &glyph_index); glyph_index != 0; charcode=FT_Get_Next_Char(face, charcode, &glyph_index)) { From 3850e6e177677885074c8896ef24534894726ad5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 29 May 2020 21:19:32 -0400 Subject: [PATCH 250/323] devdraw: accept 5- and 6-byte Unicode hex values Alt X 1234 for U+1234 Alt X X 12345 for U+12345 Alt X X X 103456 for U+103456. --- man/man7/keyboard.7 | 21 ++++++++++++++------- src/cmd/devdraw/latin1.c | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/man/man7/keyboard.7 b/man/man7/keyboard.7 index bc7cb5afb..07bfb9602 100644 --- a/man/man7/keyboard.7 +++ b/man/man7/keyboard.7 @@ -58,7 +58,7 @@ The up arrow scrolls backward. .PP Characters in Plan 9 are runes (see .IR utf (7)). -Any 16-bit rune can be typed using a compose key followed by several +Any rune can be typed using a compose key followed by several other keys. The compose key is also generally near the lower right of the main key area: the @@ -72,14 +72,21 @@ key on the SLC, the key on the Magnum, and either .B Alt key on the PC. -After typing the compose key, type a capital -.L X -and exactly four hexadecimal characters (digits and +To type a single rune with the value specified by +a given four-digit hexadecimal number, +type the compose key, +then a capital +.LR X , +and then the four hexadecimal digits (decimal digits and .L a to -.LR f ) -to type a single rune with the value represented by -the typed number. +.LR f ). +For a longer rune, type +.L X +twice followed by five digits, +or type +.L X +three times followed by six digits. There are shorthands for many characters, comprising the compose key followed by a two- or three-character sequence. The full list is too long to repeat here, but is contained in the file diff --git a/src/cmd/devdraw/latin1.c b/src/cmd/devdraw/latin1.c index a3d13a088..87c0be458 100644 --- a/src/cmd/devdraw/latin1.c +++ b/src/cmd/devdraw/latin1.c @@ -17,16 +17,15 @@ static struct cvlist }; /* - * Given 5 characters k[0]..k[4], find the rune or return -1 for failure. + * Given 5 characters k[0]..k[n], find the rune or return -1 for failure. */ static long -unicode(Rune *k) +unicode(Rune *k, int n) { long i, c; - k++; /* skip 'X' */ c = 0; - for(i=0; i<4; i++,k++){ + for(i=0; i Runemax) + return -1; } return c; } @@ -53,10 +54,32 @@ latin1(Rune *k, int n) char* p; if(k[0] == 'X'){ - if(n>=5) - return unicode(k); - else - return -5; + if(n < 2) + return -2; + if(k[1] == 'X') { + if(n < 3) + return -3; + if(k[2] == 'X') { + if(n < 9) { + if(unicode(k+3, n-3) < 0) + return -1; + return -(n+1); + } + return unicode(k+3, 6); + } + if(n < 7) { + if(unicode(k+2, n-2) < 0) + return -1; + return -(n+1); + } + return unicode(k+2, 5); + } + if(n < 5) { + if(unicode(k+1, n-1) < 0) + return -1; + return -(n+1); + } + return unicode(k+1, 4); } for(l=latintab; l->ld!=0; l++) From 95220bf88775deab4a037264d08b21bacc612d70 Mon Sep 17 00:00:00 2001 From: sean Date: Thu, 21 May 2020 16:10:30 +0100 Subject: [PATCH 251/323] ed: handle Unicode beyond the BMP correctly in list mode. List mode was constrained to the BMP. This change introduces the following new list mode convention, using Go string literal syntax: Non-printing ASCII characters display as \xhh. Non-ASCII characters in the BMP display as \uhhhh. Characters beyond the BMP display as \Uhhhhhhhh. --- man/man1/ed.1 | 12 ++++++++++-- src/cmd/ed.c | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/man/man1/ed.1 b/man/man1/ed.1 index 00eb095a3..9b161b297 100644 --- a/man/man1/ed.1 +++ b/man/man1/ed.1 @@ -441,10 +441,18 @@ a backspace as .LR \eb , backslashes as .LR \e\e , -and non-printing characters as +and non-printing ASCII characters as a backslash, an .LR x , -and four hexadecimal digits. +and two hexadecimal digits. +non-ASCII characters in the Basic Multilingual Plane +are printed as a backslash, a small +.LR u , +and four hexadecimal digits; and characters above the +Basic Multilingual Plane are printed as a backslash, +a big +.LR U , +and six hexadecimal digits. Long lines are folded, with the second and subsequent sub-lines indented one tab stop. If the last character in the line is a blank, diff --git a/src/cmd/ed.c b/src/cmd/ed.c index 8b0f36e54..a04f0d3f4 100644 --- a/src/cmd/ed.c +++ b/src/cmd/ed.c @@ -21,6 +21,12 @@ enum EOF = -1 }; +enum +{ + LINELEN = 70, /* max number of glyphs in a display line */ + BELL = 6 /* A char could require up to BELL glyphs to display */ +}; + void (*oldhup)(int); void (*oldquit)(int); int* addr1; @@ -40,7 +46,7 @@ int ichanged; int io; Biobuf iobuf; int lastc; -char line[70]; +char line[LINELEN]; Rune* linebp; Rune linebuf[LBSIZE]; int listf; @@ -1543,7 +1549,7 @@ putchr(int ac) *lp++ = 'n'; } } else { - if(col > (72-6-2)) { + if(col > (LINELEN-BELL)) { col = 8; *lp++ = '\\'; *lp++ = '\n'; @@ -1558,15 +1564,32 @@ putchr(int ac) if(c == '\t') c = 't'; col++; - } else - if(c<' ' || c>='\177') { + } else if (c<' ' || c=='\177') { *lp++ = '\\'; *lp++ = 'x'; - *lp++ = hex[c>>12]; - *lp++ = hex[c>>8&0xF]; - *lp++ = hex[c>>4&0xF]; - c = hex[c&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; + col += 3; + } else if (c>'\177' && c<=0xFFFF) { + *lp++ = '\\'; + *lp++ = 'u'; + *lp++ = hex[(c>>12)&0xF]; + *lp++ = hex[(c>>8)&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; col += 5; + } else if (c>0xFFFF) { + *lp++ = '\\'; + *lp++ = 'U'; + *lp++ = hex[(c>>28)&0xF]; + *lp++ = hex[(c>>24)&0xF]; + *lp++ = hex[(c>>20)&0xF]; + *lp++ = hex[(c>>16)&0xF]; + *lp++ = hex[(c>>12)&0xF]; + *lp++ = hex[(c>>8)&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; + col += 9; } } } @@ -1574,7 +1597,7 @@ putchr(int ac) rune = c; lp += runetochar(lp, &rune); - if(c == '\n' || lp >= &line[sizeof(line)-5]) { + if(c == '\n' || lp >= &line[LINELEN-BELL]) { linp = line; write(oflag? 2: 1, line, lp-line); return; From 01b505613590f3107c4a8849b18da2cbefd98466 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 29 May 2020 21:42:54 -0400 Subject: [PATCH 252/323] ed(1): fix documentation for list mode I changed from 6 to 8 digits but forgot to update the man page. --- man/man1/ed.1 | 72 +++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/man/man1/ed.1 b/man/man1/ed.1 index 9b161b297..41071c7ea 100644 --- a/man/man1/ed.1 +++ b/man/man1/ed.1 @@ -35,7 +35,7 @@ of character counts by .LR r , and .L w -commands and of the confirming +commands and of the confirming .L ! by .L ! @@ -46,7 +46,7 @@ commands. Write all output to the standard error file except writing by .L w commands. -If no +If no .I file is given, make .B /dev/stdout @@ -62,7 +62,7 @@ in the buffer have no effect on the file until a (write) command is given. The copy of the text being edited resides -in a temporary file called the +in a temporary file called the .IR buffer . .PP Commands to @@ -78,7 +78,7 @@ These addresses specify one or more lines in the buffer. Missing addresses are supplied by default. .PP In general, only one command may appear on a line. -Certain commands allow the +Certain commands allow the addition of text to the buffer. While .I ed @@ -87,13 +87,13 @@ to be in .I "input mode." In this mode, no commands are recognized; all input is merely collected. -Input mode is left by typing a period +Input mode is left by typing a period .L . alone at the beginning of a line. .PP .I Ed -supports the +supports the .I "regular expression" notation described in .IR regexp (7). @@ -108,7 +108,7 @@ the regular expression metacharacters as an ordinary character, that character may be preceded by .RB ` \e '. This also applies to the character bounding the regular -expression (often +expression (often .LR / ) and to .L \e @@ -132,7 +132,7 @@ customarily called `dot', addresses the current line. .TP 2. -The character +The character .L $ addresses the last line of the buffer. .TP @@ -163,7 +163,7 @@ If necessary the search wraps around to the beginning of the buffer. .TP 6. -A regular expression enclosed in queries +A regular expression enclosed in queries .L ? addresses the line found by searching backward from the current line @@ -173,7 +173,7 @@ If necessary the search wraps around to the end of the buffer. .TP 7. -An address followed by a plus sign +An address followed by a plus sign .L + or a minus sign .L - @@ -182,7 +182,7 @@ followed by a decimal number specifies that address plus The plus sign may be omitted. .TP 8. -An address followed by +An address followed by .L + (or .LR - ) @@ -190,20 +190,20 @@ followed by a regular expression enclosed in slashes specifies the first matching line following (or preceding) that address. The search wraps around if necessary. -The +The .L + may be omitted, so .L 0/x/ addresses the .I first -line in the buffer with an +line in the buffer with an .LR x . -Enclosing the regular expression in +Enclosing the regular expression in .L ? reverses the search direction. .TP 9. -If an address begins with +If an address begins with .L + or .L - @@ -214,7 +214,7 @@ is understood to mean .LR .-5 . .TP 10. -If an address ends with +If an address ends with .L + or .LR - , @@ -236,9 +236,9 @@ line less 2. .TP 11. To maintain compatibility with earlier versions of the editor, -the character +the character .L ^ -in addresses is +in addresses is equivalent to .LR - . .PP @@ -254,7 +254,7 @@ Addresses are separated from each other typically by a comma .LR , . They may also be separated by a semicolon .LR ; . -In this case the current line +In this case the current line is set to the previous address before the next address is interpreted. If no address precedes a comma or semicolon, line 1 is assumed; @@ -285,7 +285,7 @@ and append it after the addressed line. Dot is left on the last line input, if there were any, otherwise at the addressed line. -Address +Address .L 0 is legal for this command; text is placed at the beginning of the buffer. @@ -293,7 +293,7 @@ at the beginning of the buffer. .RB (\|\fL.,.\fP\|) \|b [ +- ][\fIpagesize\fP][ pln\fR] Browse. Print a `page', normally 20 lines. -The optional +The optional .L + (default) or .L - @@ -305,11 +305,11 @@ is the number of lines in a page. The optional .LR p , .LR n , -or +or .L l causes printing in the specified format, initially .LR p . -Pagesize and format are remembered between +Pagesize and format are remembered between .L b commands. Dot is left at the last line displayed. @@ -397,7 +397,7 @@ and .L v are not permitted in the command list. Any character other than space or newline may -be used instead of +be used instead of .L / to delimit the regular expression. The second and third forms mean @@ -452,7 +452,7 @@ and four hexadecimal digits; and characters above the Basic Multilingual Plane are printed as a backslash, a big .LR U , -and six hexadecimal digits. +and eight hexadecimal digits. Long lines are folded, with the second and subsequent sub-lines indented one tab stop. If the last character in the line is a blank, @@ -542,13 +542,13 @@ defaults to 1 if missing), the .IR n th matched string is replaced by the replacement specified. -If the global replacement indicator +If the global replacement indicator .L g appears after the command, all subsequent matches on the line are also replaced. It is an error for the substitution to fail on all addressed lines. Any character other than space or newline -may be used instead of +may be used instead of .L / to delimit the regular expression and the replacement. @@ -560,7 +560,7 @@ The second may be omitted if the replacement is empty. .IP -An ampersand +An ampersand .L & appearing in the replacement is replaced by the string matching the regular expression. @@ -584,7 +584,7 @@ is determined by counting occurrences of .L ( starting from the left. .IP -A literal +A literal .LR & , .LR / , .L \e @@ -594,7 +594,7 @@ by prefixing it with .TP .RB (\|\fL.,.\fP\|) \|t\|\fIa Transfer. -Copy the addressed lines +Copy the addressed lines after the line addressed by .IR a . Dot is left at the last line of the copy. @@ -622,7 +622,7 @@ it is created with mode 666 (readable and writable by everyone). If no .I filename is given, the remembered file name, if any, is used. -The file name is remembered if there were no +The file name is remembered if there were no remembered file name already. Dot is unchanged. If the write is successful, the number of characters written is @@ -638,7 +638,7 @@ Print the line number of the addressed line. Dot is unchanged. .TP .BI ! shell\ command -Send the remainder of the line after the +Send the remainder of the line after the .L ! to .IR rc (1) @@ -647,7 +647,7 @@ Dot is unchanged. .TP .RB (\| .+1 )\| An address without a command is taken as a -.L p +.L p command. A terminal .L / @@ -657,11 +657,11 @@ A blank line alone is equivalent to it is useful for stepping through text. .PP -If an interrupt signal +If an interrupt signal .SM (DEL) is sent, .I ed -prints a +prints a .L ? and returns to its command level. .PP @@ -679,7 +679,7 @@ and all characters after the last newline. .SH SOURCE .B \*9/src/cmd/ed.c .SH "SEE ALSO" -.IR sam (1), +.IR sam (1), .IR sed (1), .IR regexp (7) .SH DIAGNOSTICS From 799f330f6de8ff65a7bdf7e0d1b12cd3c10981ba Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 30 May 2020 06:35:27 -0400 Subject: [PATCH 253/323] osxvers: use swvers -productVersion to skip one awk call Fixes #406. Suggested by nms42. --- bin/osxvers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/osxvers b/bin/osxvers index 4af44da24..6ebeb11f3 100755 --- a/bin/osxvers +++ b/bin/osxvers @@ -3,5 +3,5 @@ u=`uname` case "$u" in Darwin) - sw_vers | awk '$1 == "ProductVersion:" {print $2}' | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}' + sw_vers -productVersion | awk -F. '{printf("CFLAGS=$CFLAGS -DOSX_VERSION=%d%02d%02d\n", $1, $2, $3)}' esac From c3d31baca0a73a9e8033db8a0b47093233c636c1 Mon Sep 17 00:00:00 2001 From: Gregor Best Date: Thu, 4 Jun 2020 19:55:26 +0200 Subject: [PATCH 254/323] fontsrv: fix compilation on X11 (#420) --- src/cmd/fontsrv/x11.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 417dcfa6c..c1d10197f 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -61,6 +61,7 @@ load(XFont *f) FT_Error e; FT_ULong charcode; FT_UInt glyph_index; + int i; if(f->loaded) return; From 329831171dd6ef81c113f101093c7b4947381003 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Date: Mon, 15 Jun 2020 22:18:03 -0500 Subject: [PATCH 255/323] libthread: use libc functions in ucontext for macOS (#417) --- src/libthread/Darwin-x86_64-asm.s | 44 ------------------------------- src/libthread/sysofiles.sh | 4 +-- src/libthread/threadimpl.h | 36 +------------------------ 3 files changed, 3 insertions(+), 81 deletions(-) delete mode 100644 src/libthread/Darwin-x86_64-asm.s diff --git a/src/libthread/Darwin-x86_64-asm.s b/src/libthread/Darwin-x86_64-asm.s deleted file mode 100644 index d50d3b6d9..000000000 --- a/src/libthread/Darwin-x86_64-asm.s +++ /dev/null @@ -1,44 +0,0 @@ -.text -.align 8 - -.globl _libthread_getmcontext -_libthread_getmcontext: - movq $1, 0*8(%rdi) // rax - movq %rbx, 1*8(%rdi) - movq %rcx, 2*8(%rdi) - movq %rdx, 3*8(%rdi) - movq %rsi, 4*8(%rdi) - movq %rdi, 5*8(%rdi) - movq %rbp, 6*8(%rdi) - movq %rsp, 7*8(%rdi) - movq %r8, 8*8(%rdi) - movq %r9, 9*8(%rdi) - movq %r10, 10*8(%rdi) - movq %r11, 11*8(%rdi) - movq %r12, 12*8(%rdi) - movq %r13, 13*8(%rdi) - movq %r14, 14*8(%rdi) - movq %r15, 15*8(%rdi) - movq $0, %rax - ret - -.globl _libthread_setmcontext -_libthread_setmcontext: - movq 0*8(%rdi), %rax - movq 1*8(%rdi), %rbx - movq 2*8(%rdi), %rcx - movq 3*8(%rdi), %rdx - movq 4*8(%rdi), %rsi - // %rdi later - movq 6*8(%rdi), %rbp - movq 7*8(%rdi), %rsp - movq 8*8(%rdi), %r8 - movq 9*8(%rdi), %r9 - movq 10*8(%rdi), %r10 - movq 11*8(%rdi), %r11 - movq 12*8(%rdi), %r12 - movq 13*8(%rdi), %r13 - movq 14*8(%rdi), %r14 - movq 15*8(%rdi), %r15 - movq 5*8(%rdi), %rdi - ret diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 20811cdfe..833afbe02 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -15,14 +15,14 @@ esac # Various libc don't supply swapcontext, makecontext, so we do. case "$SYSNAME-$OBJTYPE" in -Darwin-x86_64 | Linux-arm | Linux-sparc64 | NetBSD-arm | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) +Linux-arm | Linux-sparc64 | NetBSD-arm | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) echo $OBJTYPE-ucontext.o ;; esac # A few libc don't supply setcontext, getcontext, so we do. case "$SYSNAME-$OBJTYPE" in -Darwin-x86_64 | Linux-arm | Linux-sparc64 | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) +Linux-arm | Linux-sparc64 | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) echo $SYSNAME-$OBJTYPE-asm.o ;; esac diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index c73738436..8d22a161c 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -7,7 +7,7 @@ #include #if !defined(__OpenBSD__) # if defined(__APPLE__) -# define _XOPEN_SOURCE /* for Snow Leopard */ +# define _XOPEN_SOURCE /* for Snow Leopard */ # endif # include #endif @@ -15,31 +15,6 @@ #include "libc.h" #include "thread.h" -#if defined(__APPLE__) - /* - * OS X before 10.5 (Leopard) does not provide - * swapcontext nor makecontext, so we have to use our own. - * In theory, Leopard does provide them, but when we use - * them, they seg fault. Maybe we're using them wrong. - * So just use our own versions, even on Leopard. - */ -# define mcontext libthread_mcontext -# define mcontext_t libthread_mcontext_t -# define ucontext libthread_ucontext -# define ucontext_t libthread_ucontext_t -# define swapcontext libthread_swapcontext -# define makecontext libthread_makecontext -# if defined(__i386__) -# include "386-ucontext.h" -# elif defined(__x86_64__) -# include "x86_64-ucontext.h" -# elif defined(__ppc__) || defined(__power__) -# include "power-ucontext.h" -# else -# error "unknown architecture" -# endif -#endif - #if defined(__OpenBSD__) # define mcontext libthread_mcontext # define mcontext_t libthread_mcontext_t @@ -82,15 +57,6 @@ enum struct Context { ucontext_t uc; -#ifdef __APPLE__ - /* - * On Snow Leopard, etc., the context routines exist, - * so we use them, but apparently they write past the - * end of the ucontext_t. Sigh. We put some extra - * scratch space here for them. - */ - uchar buf[1024]; -#endif }; struct Execjob From 95ab1308b410ad8547e38e47ec4a36f560dcece5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 22 Jun 2020 11:20:42 -0400 Subject: [PATCH 256/323] 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 diff --git a/src/cmd/dformat b/src/cmd/dformat deleted file mode 100755 index f14b58414..000000000 --- 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") } -' $* From 951446a77417743b8ed900cb1b5a1ae08522840e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 18 Jul 2020 19:51:24 -0400 Subject: [PATCH 257/323] draw: use int for Cacheinfo x field With very large fonts (72pt or so) I see bad cache glyphs, and this fixes it. Not entirely sure exactly which code is overflowing, but something is. --- include/draw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/draw.h b/include/draw.h index 9a22e6b62..3b55504d7 100644 --- a/include/draw.h +++ b/include/draw.h @@ -290,7 +290,7 @@ struct Cachefont struct Cacheinfo { - ushort x; /* left edge of bits */ + int x; /* left edge of bits */ uchar width; /* width of baseline */ schar left; /* offset of baseline */ Rune value; /* value of character at this slot in cache */ From 057d8a76a9d840994edf453f97245efb295d9582 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 18 Jul 2020 19:52:58 -0400 Subject: [PATCH 258/323] acme: add font control message --- man/man4/acme.4 | 7 ++++++- src/cmd/acme/xfid.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/man/man4/acme.4 b/man/man4/acme.4 index 7449dbd29..5305253e9 100644 --- a/man/man4/acme.4 +++ b/man/man4/acme.4 @@ -20,7 +20,7 @@ serves a variety of files for reading, writing, and controlling windows. Some of them are virtual versions of system files for dealing with the virtual console; others control operations -of +of .I acme itself. When a command is run under @@ -234,6 +234,11 @@ Equivalent to the .B Get interactive command with no arguments; accepts no arguments. .TP +.BI font " path +Equivalent to the +.B Font +interactive command with a single (required) argument. +.TP .B limit=addr When the .B ctl diff --git a/src/cmd/acme/xfid.c b/src/cmd/acme/xfid.c index 9c7be2c04..e7d9f4cb7 100644 --- a/src/cmd/acme/xfid.c +++ b/src/cmd/acme/xfid.c @@ -701,6 +701,24 @@ xfidctlwrite(Xfid *x, Window *w) 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; 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: [PATCH 259/323] devdraw, libdraw: fix memory leaks by freeing getns() malloced string (#431) --- src/cmd/devdraw/srv.c | 8 ++++++-- src/libdraw/drawclient.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 05a08fda4..479e41e0f 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/libdraw/drawclient.c b/src/libdraw/drawclient.c index c38f4801b..2ac1b2325 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); From dd7c4e51044ce779cb695d6b52bbba0982a42e28 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 22 Jul 2020 20:03:29 -0400 Subject: [PATCH 260/323] fontsrv(4): update man page for size of fontsrv subfonts Fixes #432. --- man/man4/fontsrv.4 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man/man4/fontsrv.4 b/man/man4/fontsrv.4 index 3fb0d66b9..2ba7f2c18 100644 --- a/man/man4/fontsrv.4 +++ b/man/man4/fontsrv.4 @@ -31,13 +31,13 @@ and posted at (default .IR font ). .PP -The +The .B -p -option changes +option changes .IR fontsrv 's behavior: rather than serve a file system, .I fontsrv -prints to standard output the contents of the named +prints to standard output the contents of the named .IR path . If .I path @@ -66,19 +66,19 @@ Each size directory contains a file and subfont files named .BR x0000.bit , -.BR x0100.bit , +.BR x0020.bit , and so on -representing 256-character Unicode ranges. +representing 32-character Unicode ranges. .PP .I Openfont (see .IR graphics (3)) -recognizes font paths beginning with +recognizes font paths beginning with .B /mnt/font and implements them by invoking .IR fontsrv ; it need not be running already. -See +See .IR font (7) for a full discussion of font name syntaxes. .SH EXAMPLES @@ -95,7 +95,7 @@ or: % fontsrv -p . .EE .LP -Run +Run .IR acme (1) using the operating system's Monaco as the fixed-width font: .IP From a1c4307800c7f1ef9c5d71ba4c6c3642837e2877 Mon Sep 17 00:00:00 2001 From: James Cook Date: Sat, 8 Aug 2020 01:54:00 +0000 Subject: [PATCH 261/323] 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(-) diff --git a/src/cmd/touch.c b/src/cmd/touch.c index 471e2b17d..261418154 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; } From 977b25a76ae8263e53fb4eb1abfc395769f23e3d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 13 Aug 2020 23:41:59 -0400 Subject: [PATCH 262/323] tmac: introduce real manual reference macro instead of overloading IR The overloading of IR emits magic \X'...' sequences that turn into HTML manual links. But not all such IR invocations should be manual links; those had to be written to avoid the IR macro before. Worse, the \X'...' ending the IR causes troff to emit only a single space after a period. Defining a new IM macro for manual references fixes both problems. Fixes #441. --- man/man1/0intro.1 | 148 ++++++++++++++++++------------------- man/man1/9.1 | 14 ++-- man/man1/9c.1 | 2 +- man/man1/9p.1 | 14 ++-- man/man1/9term.1 | 18 ++--- man/man1/acid.1 | 14 ++-- man/man1/acme.1 | 42 +++++------ man/man1/acmeevent.1 | 22 +++--- man/man1/ascii.1 | 12 +-- man/man1/astro.1 | 2 +- man/man1/awk.1 | 6 +- man/man1/bc.1 | 6 +- man/man1/bundle.1 | 10 +-- man/man1/calendar.1 | 2 +- man/man1/cat.1 | 8 +- man/man1/cleanname.1 | 2 +- man/man1/col.1 | 8 +- man/man1/colors.1 | 6 +- man/man1/comm.1 | 4 +- man/man1/core.1 | 8 +- man/man1/crop.1 | 12 +-- man/man1/date.1 | 2 +- man/man1/db.1 | 10 +-- man/man1/dc.1 | 4 +- man/man1/dd.1 | 2 +- man/man1/deroff.1 | 16 ++-- man/man1/devdraw.1 | 8 +- man/man1/dial.1 | 4 +- man/man1/dict.1 | 6 +- man/man1/diff.1 | 8 +- man/man1/doctype.1 | 14 ++-- man/man1/ed.1 | 10 +-- man/man1/eqn.1 | 8 +- man/man1/freq.1 | 4 +- man/man1/git.1 | 12 +-- man/man1/grap.1 | 4 +- man/man1/graph.1 | 4 +- man/man1/grep.1 | 12 +-- man/man1/gview.1 | 2 +- man/man1/gzip.1 | 4 +- man/man1/hist.1 | 8 +- man/man1/hoc.1 | 4 +- man/man1/htmlroff.1 | 18 ++--- man/man1/idiff.1 | 4 +- man/man1/install.1 | 14 ++-- man/man1/join.1 | 4 +- man/man1/jpg.1 | 10 +-- man/man1/kill.1 | 12 +-- man/man1/label.1 | 12 +-- man/man1/lex.1 | 2 +- man/man1/look.1 | 2 +- man/man1/ls.1 | 12 +-- man/man1/man.1 | 12 +-- man/man1/map.1 | 4 +- man/man1/mc.1 | 18 ++--- man/man1/mk.1 | 24 +++--- man/man1/mk9660.1 | 27 +++---- man/man1/mkdir.1 | 4 +- man/man1/mount.1 | 10 +-- man/man1/namespace.1 | 6 +- man/man1/ndb.1 | 14 ++-- man/man1/netfiles.1 | 26 +++---- man/man1/page.1 | 97 ++++++++++++------------ man/man1/paint.1 | 14 ++-- man/man1/passwd.1 | 2 +- man/man1/pem.1 | 6 +- man/man1/pic.1 | 8 +- man/man1/plot.1 | 8 +- man/man1/plumb.1 | 6 +- man/man1/pr.1 | 4 +- man/man1/proof.1 | 6 +- man/man1/ps.1 | 6 +- man/man1/psfonts.1 | 10 +-- man/man1/pwd.1 | 4 +- man/man1/rc.1 | 12 +-- man/man1/readcons.1 | 2 +- man/man1/resample.1 | 8 +- man/man1/rio.1 | 16 ++-- man/man1/rm.1 | 2 +- man/man1/rsa.1 | 8 +- man/man1/sam.1 | 18 ++--- man/man1/scat.1 | 8 +- man/man1/secstore.1 | 8 +- man/man1/secstored.1 | 4 +- man/man1/sed.1 | 8 +- man/man1/seq.1 | 2 +- man/man1/sftpcache.1 | 12 +-- man/man1/sleep.1 | 2 +- man/man1/snarfer.1 | 13 ++-- man/man1/soelim.1 | 8 +- man/man1/sort.1 | 4 +- man/man1/spell.1 | 6 +- man/man1/split.1 | 8 +- man/man1/src.1 | 12 +-- man/man1/ssam.1 | 4 +- man/man1/ssh-agent.1 | 20 ++--- man/man1/strings.1 | 2 +- man/man1/sum.1 | 4 +- man/man1/tar.1 | 8 +- man/man1/tbl.1 | 8 +- man/man1/tcs.1 | 4 +- man/man1/test.1 | 2 +- man/man1/time.1 | 2 +- man/man1/touch.1 | 6 +- man/man1/tr.1 | 2 +- man/man1/tr2post.1 | 13 ++-- man/man1/troff.1 | 16 ++-- man/man1/troff2html.1 | 25 ++++--- man/man1/tweak.1 | 12 +-- man/man1/uniq.1 | 2 +- man/man1/vac.1 | 25 ++++--- man/man1/venti.1 | 16 ++-- man/man1/web.1 | 4 +- man/man1/wintext.1 | 16 ++-- man/man1/winwatch.1 | 6 +- man/man1/xd.1 | 2 +- man/man1/yacc.1 | 6 +- man/man1/yesterday.1 | 6 +- man/man3/0intro.3 | 54 +++++++------- man/man3/9p-cmdbuf.3 | 4 +- man/man3/9p-fid.3 | 8 +- man/man3/9p-file.3 | 4 +- man/man3/9p-intmap.3 | 4 +- man/man3/9p.3 | 18 ++--- man/man3/9pclient.3 | 22 +++--- man/man3/acme.3 | 28 +++---- man/man3/addpt.3 | 2 +- man/man3/aes.3 | 20 ++--- man/man3/allocimage.3 | 20 ++--- man/man3/arg.3 | 4 +- man/man3/arith3.3 | 2 +- man/man3/atof.3 | 4 +- man/man3/auth.3 | 20 ++--- man/man3/authsrv.3 | 8 +- man/man3/bin.3 | 4 +- man/man3/bio.3 | 20 ++--- man/man3/blowfish.3 | 20 ++--- man/man3/cachechars.3 | 20 ++--- man/man3/cleanname.3 | 2 +- man/man3/color.3 | 16 ++-- man/man3/complete.3 | 8 +- man/man3/ctime.3 | 8 +- man/man3/des.3 | 20 ++--- man/man3/dial.3 | 4 +- man/man3/dirread.3 | 16 ++-- man/man3/draw.3 | 16 ++-- man/man3/drawfcall.3 | 12 +-- man/man3/dsa.3 | 22 +++--- man/man3/dup.3 | 2 +- man/man3/elgamal.3 | 20 ++--- man/man3/encode.3 | 4 +- man/man3/encrypt.3 | 2 +- man/man3/errstr.3 | 8 +- man/man3/event.3 | 22 +++--- man/man3/exec.3 | 18 ++--- man/man3/exits.3 | 8 +- man/man3/fcall.3 | 14 ++-- man/man3/flate.3 | 2 +- man/man3/fmtinstall.3 | 20 ++--- man/man3/frame.3 | 12 +-- man/man3/genrandom.3 | 8 +- man/man3/get9root.3 | 6 +- man/man3/getenv.3 | 4 +- man/man3/getfields.3 | 8 +- man/man3/getns.3 | 4 +- man/man3/getsnarf.3 | 4 +- man/man3/getuser.3 | 4 +- man/man3/getwd.3 | 6 +- man/man3/graphics.3 | 80 ++++++++++---------- man/man3/html.3 | 2 +- man/man3/ioproc.3 | 22 +++--- man/man3/ip.3 | 4 +- man/man3/isalpharune.3 | 2 +- man/man3/keyboard.3 | 14 ++-- man/man3/lock.3 | 2 +- man/man3/mach-cmd.3 | 14 ++-- man/man3/mach-file.3 | 6 +- man/man3/mach-map.3 | 16 ++-- man/man3/mach-stack.3 | 4 +- man/man3/mach-swap.3 | 2 +- man/man3/mach-symbol.3 | 14 ++-- man/man3/mach.3 | 24 +++--- man/man3/malloc.3 | 8 +- man/man3/matrix.3 | 2 +- man/man3/memdraw.3 | 101 ++++++++++++------------- man/man3/memlayer.3 | 22 +++--- man/man3/memory.3 | 2 +- man/man3/mouse.3 | 30 ++++---- man/man3/mousescrollsize.3 | 8 +- man/man3/mp.3 | 4 +- man/man3/mux.3 | 6 +- man/man3/ndb.3 | 10 +-- man/man3/needstack.3 | 6 +- man/man3/notify.3 | 20 ++--- man/man3/open.3 | 12 +-- man/man3/opentemp.3 | 4 +- man/man3/pipe.3 | 14 ++-- man/man3/plumb.3 | 24 +++--- man/man3/post9pservice.3 | 12 +-- man/man3/postnote.3 | 4 +- man/man3/prime.3 | 10 +-- man/man3/print.3 | 18 ++--- man/man3/proto.3 | 25 ++++--- man/man3/pushtls.3 | 18 ++--- man/man3/qball.3 | 2 +- man/man3/quaternion.3 | 8 +- man/man3/quote.3 | 22 +++--- man/man3/rand.3 | 8 +- man/man3/rc4.3 | 20 ++--- man/man3/read.3 | 8 +- man/man3/readcolmap.3 | 10 +-- man/man3/readcons.3 | 2 +- man/man3/regexp.3 | 6 +- man/man3/rfork.3 | 12 +-- man/man3/rsa.3 | 22 +++--- man/man3/rune.3 | 4 +- man/man3/runestrcat.3 | 8 +- man/man3/searchpath.3 | 8 +- man/man3/sechash.3 | 14 ++-- man/man3/seek.3 | 6 +- man/man3/sendfd.3 | 12 +-- man/man3/setjmp.3 | 9 ++- man/man3/sleep.3 | 6 +- man/man3/stat.3 | 10 +-- man/man3/strcat.3 | 10 +-- man/man3/string.3 | 2 +- man/man3/stringsize.3 | 14 ++-- man/man3/subfont.3 | 28 +++---- man/man3/sysfatal.3 | 14 ++-- man/man3/thread.3 | 28 +++---- man/man3/time.3 | 2 +- man/man3/udpread.3 | 2 +- man/man3/venti-cache.3 | 16 ++-- man/man3/venti-client.3 | 14 ++-- man/man3/venti-conn.3 | 22 +++--- man/man3/venti-fcall.3 | 16 ++-- man/man3/venti-file.3 | 12 +-- man/man3/venti-log.3 | 8 +- man/man3/venti-mem.3 | 4 +- man/man3/venti-packet.3 | 4 +- man/man3/venti-server.3 | 12 +-- man/man3/venti-zero.3 | 4 +- man/man3/venti.3 | 50 ++++++------- man/man3/wait.3 | 16 ++-- man/man3/window.3 | 16 ++-- man/man4/0intro.4 | 14 ++-- man/man4/9import.4 | 16 ++-- man/man4/9pserve.4 | 8 +- man/man4/acme.4 | 15 ++-- man/man4/factotum.4 | 72 +++++++++--------- man/man4/fontsrv.4 | 12 +-- man/man4/fossil.4 | 34 ++++----- man/man4/import.4 | 6 +- man/man4/plumber.4 | 18 ++--- man/man4/ramfs.4 | 6 +- man/man4/smugfs.4 | 6 +- man/man4/srv.4 | 10 +-- man/man4/tapefs.4 | 8 +- man/man4/vacfs.4 | 11 +-- man/man7/color.7 | 14 ++-- man/man7/face.7 | 10 +-- man/man7/font.7 | 22 +++--- man/man7/htmlroff.7 | 6 +- man/man7/image.7 | 46 ++++++------ man/man7/keyboard.7 | 28 +++---- man/man7/man.7 | 6 +- man/man7/map.7 | 2 +- man/man7/mhtml.7 | 18 ++--- man/man7/mpictures.7 | 4 +- man/man7/ms.7 | 20 ++--- man/man7/ndb.7 | 6 +- man/man7/plot.7 | 2 +- man/man7/plumb.7 | 18 ++--- man/man7/regexp.7 | 6 +- man/man7/thumbprint.7 | 4 +- man/man7/utf.7 | 8 +- man/man7/venti.7 | 28 +++---- man/man8/fossilcons.8 | 18 ++--- man/man8/getflags.8 | 10 +-- man/man8/listen1.8 | 8 +- man/man8/mkfs.8 | 8 +- man/man8/vbackup.8 | 12 +-- man/man8/venti-backup.8 | 4 +- man/man8/venti-fmt.8 | 12 +-- man/man8/venti.8 | 20 ++--- man/man9/0intro.9p | 18 ++--- man/man9/attach.9p | 4 +- man/man9/clunk.9p | 2 +- man/man9/flush.9p | 4 +- man/man9/open.9p | 4 +- man/man9/openfd.9p | 8 +- man/man9/read.9p | 2 +- man/man9/remove.9p | 2 +- man/man9/stat.9p | 4 +- man/man9/version.9p | 2 +- man/man9/walk.9p | 4 +- tmac/tmac.an | 7 +- 297 files changed, 1790 insertions(+), 1774 deletions(-) diff --git a/man/man1/0intro.1 b/man/man1/0intro.1 index 161349330..5c45aefe9 100644 --- a/man/man1/0intro.1 +++ b/man/man1/0intro.1 @@ -32,15 +32,15 @@ they expect the environment variable to contain the name of the root of the tree. See -.IR install (1) +.IM install (1) for details about installation. .PP Many of the familiar Unix commands, for example -.IR cat (1), -.IR ls (1), +.IM cat (1) , +.IM ls (1) , and -.IR wc (1), +.IM wc (1) , are present, but in their Plan 9 forms: .I cat takes no options, @@ -50,12 +50,12 @@ and .I wc counts UTF characters. In some cases, the differences are quite noticeable: -.IR grep (1) +.IM grep (1) and -.IR sed (1) +.IM sed (1) expect Plan 9 regular expressions (see -.IR regexp (7)), +.IM regexp (7) ), which are closest to what Unix calls extended regular expressions. Because of these differences, it is not recommended to put .B $PLAN9/bin @@ -63,16 +63,16 @@ before the usual system .B bin directories in your search path. Instead, put it at the end of your path and use the -.IR 9 (1) +.IM 9 (1) script when you want to invoke the Plan 9 version of a traditional Unix command. .PP Occasionally the Plan 9 programs have been changed to adapt to Unix. -.IR Mk (1) +.IM Mk (1) now allows mkfiles to choose their own shell, and -.IR rc (1) +.IM rc (1) has a .I ulimit builtin and manages @@ -80,14 +80,14 @@ builtin and manages .PP Many of the graphical programs from Plan 9 are present, including -.IR sam (1) +.IM sam (1) and -.IR acme (1). +.IM acme (1) . An X11 window manager -.IR rio (1) +.IM rio (1) mimics Plan 9's window system, with command windows implemented by the external program -.IR 9term (1). +.IM 9term (1) . Following the style of X Windows, these programs run in new windows rather than the one in which they are invoked. They all take a @@ -101,10 +101,10 @@ The argument is one of \fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR. .PP The -.IR plumber (4) +.IM plumber (4) helps to connect the various Plan 9 programs together, and fittings like -.IR web (1) +.IM web (1) connect it to external programs such as web browsers; one can click on a URL in .I acme @@ -119,17 +119,17 @@ with file servers by reading and writing files. This cannot be done directly on Unix. Instead the servers listen for 9P connections on Unix domain sockets; clients connect to these sockets and speak 9P directly using the -.IR 9pclient (3) +.IM 9pclient (3) library. -.IR Intro (4) +.IM Intro (4) tells more of the story. The effect is not as clean as on Plan 9, but it gets the job done and still provides a uniform and easy-to-understand mechanism. The -.IR 9p (1) +.IM 9p (1) client can be used in shell scripts or by hand to carry out simple interactions with servers. -.IR Netfiles (1) +.IM Netfiles (1) is an experimental client for acme. .SS External databases Some programs rely on large databases that would be @@ -146,7 +146,7 @@ The shell scripts and .I 9l (see -.IR 9c (1)) +.IM 9c (1) ) provide a simple interface to the underlying system compiler and linker, similar to the .I 2c @@ -165,22 +165,22 @@ so that no options are needed. .PP The only way to write multithreaded programs is to use the -.IR thread (3) +.IM thread (3) library. -.IR Rfork (3) +.IM Rfork (3) exists but is not as capable as on Plan 9. There are many unfortunate by necessary preprocessor diversions to make Plan 9 and Unix libraries coexist. See -.IR intro (3) +.IM intro (3) for details. .PP The debuggers -.IR acid (1) +.IM acid (1) and -.IR db (1) +.IM db (1) and the debugging library -.IR mach (3) +.IM mach (3) are works in progress. They are platform-independent, so that x86 Linux core dumps can be inspected on PowerPC Mac OS X machines, @@ -203,22 +203,22 @@ but that it is the extent to which they have been developed and exercised. .SS Porting programs The vast majority of the familiar Plan 9 programs have been ported, including the Unicode-aware -.IR troff (1). +.IM troff (1) . .PP Of the more recent additions to Plan 9, -.IR factotum (4), -.IR secstore (1), +.IM factotum (4) , +.IM secstore (1) , and -.IR secstored (1), -.IR vac (1), -.IR vacfs (4), +.IM secstored (1) , +.IM vac (1) , +.IM vacfs (4) , and -.IR venti (8) +.IM venti (8) are all ported. .PP A backup system providing a dump file system built atop Venti is in progress; see -.IR vbackup (8). +.IM vbackup (8) . .SS Porting to new systems Porting the tree to new operating systems or architectures should be straightforward, as system-specific code has been @@ -240,9 +240,9 @@ need to write any system specific code at all. .PP There are other smaller system dependencies, such as the terminal handling code in -.IR 9term (1) +.IM 9term (1) and the implementation of -.IR getcallerpc (3), +.IM getcallerpc (3) , but these are usually simple and are not on the critical path for getting the system up and running. .SH SEE ALSO @@ -255,7 +255,7 @@ The manual pages are in a Unix style tree, with names like instead of Plan 9's simpler .BR $PLAN9/man/1/cat , so that the Unix -.IR man (1) +.IM man (1) utility can handle it. Some systems, for example Debian Linux, deduce the man page locations from the search path, so that @@ -300,52 +300,52 @@ describes the Plan 9 file protocol 9P. These pages describe parts of the system that are new or different from Plan 9 from Bell Labs: .IP -.IR 9 (1), -.IR 9c (1), -.IR 9p (1), -.IR 9term (1), +.IM 9 (1) , +.IM 9c (1) , +.IM 9p (1) , +.IM 9term (1) , .I acidtypes in -.IR acid (1), -.IR dial (1), -.IR git (1), -.IR label (1), +.IM acid (1) , +.IM dial (1) , +.IM git (1) , +.IM label (1) , the .B MKSHELL variable in -.IR mk (1), -.IR namespace (1), -.IR netfiles (1), -.IR page (1), -.IR psfonts (1), -.IR rio (1), -.IR web (1), -.IR wintext (1) +.IM mk (1) , +.IM namespace (1) , +.IM netfiles (1) , +.IM page (1) , +.IM psfonts (1) , +.IM rio (1) , +.IM web (1) , +.IM wintext (1) .IP -.IR intro (3), -.IR 9pclient (3), +.IM intro (3) , +.IM 9pclient (3) , the .B unix network in -.IR dial (3), -.IR exits (3), -.IR get9root (3), -.IR getns (3), -.IR notify (3), -.IR post9pservice (3), -.IR rfork (3), -.IR searchpath (3), -.IR sendfd (3), -.IR udpread (3), -.IR venti (3), -.IR wait (3), -.IR wctl (3) +.IM dial (3) , +.IM exits (3) , +.IM get9root (3) , +.IM getns (3) , +.IM notify (3) , +.IM post9pservice (3) , +.IM rfork (3) , +.IM searchpath (3) , +.IM sendfd (3) , +.IM udpread (3) , +.IM venti (3) , +.IM wait (3) , +.IM wctl (3) .IP -.IR intro (4), -.IR 9pserve (4), -.IR import (4), +.IM intro (4) , +.IM 9pserve (4) , +.IM import (4) , .IP -.IR vbackup (8) +.IM vbackup (8) .IP .IR openfd (9p) .SH DIAGNOSTICS @@ -356,4 +356,4 @@ exit with string statuses. In fact, exiting with an empty status corresponds to exiting with status 0, and exiting with any non-empty string corresponds to exiting with status 1. See -.IR exits (3). +.IM exits (3) . diff --git a/man/man1/9.1 b/man/man1/9.1 index a115260d5..b39ca885e 100644 --- a/man/man1/9.1 +++ b/man/man1/9.1 @@ -12,7 +12,7 @@ .B . .B 9 (from -.IR sh (1)) +.IM sh (1) ) .PP .B 9.rc .I cmd @@ -24,7 +24,7 @@ .B . .B 9.rc (from -.IR rc (1)) +.IM rc (1) ) .PP .B u .I cmd @@ -36,7 +36,7 @@ .B . .B u (from -.IR sh (1)) +.IM sh (1) ) .PP .B u.rc .I cmd @@ -48,7 +48,7 @@ .B . .B u.rc (from -.IR rc (1)) +.IM rc (1) ) .SH DESCRIPTION Because Plan 9 supplies commands with the same name as but different behavior than many basic Unix system commands @@ -86,7 +86,7 @@ in order to make the current shell start running in the Plan 9 environment. is the same as .I 9 but written for use by the shell -.IR rc (1). +.IM rc (1) . .PP .I U and @@ -106,7 +106,7 @@ $ 9 grep '[α-ζ]' /etc/passwd .EE .PP Start an -.IR rc (1) +.IM rc (1) with the Plan 9 commands in the path before the system commands, and then run the Unix .IR ls : @@ -124,7 +124,7 @@ $ 9 rc .br .B \*9/bin/u.rc .SH SEE ALSO -.IR intro (1) +.IM intro (1) .SH BUGS Some shell configurations (notably, oh-my-zsh) diff --git a/man/man1/9c.1 b/man/man1/9c.1 index 8d24d67d5..14bb618d8 100644 --- a/man/man1/9c.1 +++ b/man/man1/9c.1 @@ -164,7 +164,7 @@ With .BR t , give a long listing of all information about the files, somewhat like a listing by -.IR ls (1), +.IM ls (1) , showing .br .ns diff --git a/man/man1/9p.1 b/man/man1/9p.1 index 762e72205..3a77e244f 100644 --- a/man/man1/9p.1 +++ b/man/man1/9p.1 @@ -121,11 +121,11 @@ copy a line from standard input to the file. Print errors, but don't give up. .B Rdwr is useful for interacting with servers like -.IR factotum (4). +.IM factotum (4) . .TP .B ls Print a directory listing in the format of -.IR ls (1). +.IM ls (1) . The .B -d and @@ -150,12 +150,12 @@ it connects to the Unix domain socket .I service in the name space directory (see -.IR intro (4)) +.IM intro (4) ) and then accesses .IR subpath . .SH EXAMPLE To update -.IR plumber (4)'s +.IM plumber (4) 's copy of your plumbing rules after editing .BR $HOME/lib/plumbing : .IP @@ -164,7 +164,7 @@ cat $HOME/lib/plumbing | 9p write plumb/rules .EE .PP To display the contents of the current -.IR acme (4) +.IM acme (4) window: .IP .EX @@ -173,6 +173,6 @@ window: .SH SOURCE .B \*9/src/cmd/9p.c .SH SEE ALSO -.IR intro (4), +.IM intro (4) , .IR intro (9p), -.IR 9pclient (3) +.IM 9pclient (3) diff --git a/man/man1/9term.1 b/man/man1/9term.1 index b07061398..bf0ee27f6 100644 --- a/man/man1/9term.1 +++ b/man/man1/9term.1 @@ -58,7 +58,7 @@ uses the imported value of .B $font if set; otherwise it uses the graphics system default. (See -.IR font (7) +.IM font (7) for a full discussion of font syntaxes.) .PP .I 9term @@ -96,7 +96,7 @@ Characters typed on the keyboard replace the selected text; if this text is not empty, it is placed in a .I snarf buffer common to all windows but distinct from that of -.IR sam (1). +.IM sam (1) . .PP Programs access the text in the window at a single point maintained automatically by @@ -163,7 +163,7 @@ and erases the character before the word. .PP An ACK character (control-F) or Insert character triggers file name completion for the preceding string (see -.IR complete (3)). +.IM complete (3) ). .PP Text may be moved vertically within the window. A scroll bar on the left of the window shows in its clear portion what fragment of the @@ -201,7 +201,7 @@ EOT, so the terminal must be set up with EOT as the ``eof'' character. .I 9term runs -.IR stty (1) +.IM stty (1) to establish this when the terminal is created. .PP .I 9term @@ -231,13 +231,13 @@ are a few common ones where they fall short. First, programs using the GNU readline library typically disable terminal echo and perform echoing themselves. The most common example is the shell -.IR bash (1). +.IM bash (1) . Disabling the use of readline with .RB `` "set +o emacs" '' .RI [ sic ] usually restores the desired behavior. Second, remote terminal programs such as -.IR ssh (1) +.IM ssh (1) typically run with echo disabled, relying on the remote system to echo characters as desired. Plan 9's @@ -279,7 +279,7 @@ The menu item sends the contents of the selection (not the snarf buffer) to the .I plumber (see -.IR plumb (1)). +.IM plumb (1) ). If the selection is empty, it sends the white-space-delimited text containing the selection (typing cursor). A typical use of this feature is to tell the editor to find the source of an error @@ -323,7 +323,7 @@ Not a .IR 9term bug: when running -.IR bash (1) +.IM bash (1) in .RB `` "set +o emacs" '' mode, its handling of interrupts is broken. @@ -334,4 +334,4 @@ character typed. .PP Unix makes everything harder. .SH SEE ALSO -.IR wintext (1) +.IM wintext (1) diff --git a/man/man1/acid.1 b/man/man1/acid.1 index ed0b24db9..a593f1c02 100644 --- a/man/man1/acid.1 +++ b/man/man1/acid.1 @@ -70,7 +70,7 @@ at startup; see below. .BI -m " machine Assume instructions are for the given CPU type (see -.IR mach (3)) +.IM mach (3) ) instead of using the executable header to select the CPU type. .TP @@ -145,7 +145,7 @@ subscripts counted from 0. .BI delete " list", " subscript .PP Format codes are the same as in -.IR db (1). +.IM db (1) . Formats may be attached to (unary) expressions with .BR \e , e.g. @@ -230,7 +230,7 @@ Print 10 lines of source around the program address. .BI Bsrc( address ) Get the source line for the program address into a window of a running -.IR sam (1) +.IM sam (1) and select it. .TP .BI line( address ) @@ -323,7 +323,7 @@ Make the given process current. .TP .BI rc( string ) Escape to the shell, -.IR rc (1), +.IM rc (1) , to execute the command string. .TP .BI include( string ) @@ -449,7 +449,7 @@ notation) .BR *array . .PP Trace the system calls executed by -.IR ls (1) +.IM ls (1) (neither does this one): .IP .EX @@ -503,8 +503,8 @@ acid: cont() .SH SOURCE .B \*9/src/cmd/acid .SH "SEE ALSO" -.IR mk (1), -.IR db (1) +.IM mk (1) , +.IM db (1) .br Phil Winterbottom, ``Acid Manual''. diff --git a/man/man1/acme.1 b/man/man1/acme.1 index f21566f91..a631d3c37 100644 --- a/man/man1/acme.1 +++ b/man/man1/acme.1 @@ -45,7 +45,7 @@ The interactive interface uses the keyboard and mouse; external programs use a set of files served by .IR acme ; these are discussed in -.IR acme (4). +.IM acme (4) . .PP Any named .I files @@ -86,7 +86,7 @@ The option instructs .I acme to use FUSE (see -.IR 9pfuse (4)) +.IM 9pfuse (4) ) to mount itself at .IR mtpt . (Experimental.) @@ -98,10 +98,10 @@ windows are in two parts: a one-line above a multi-line .IR body . The body typically contains an image of a file, as in -.IR sam (1), +.IM sam (1) , or the output of a program, as in an -.IR rio (1) +.IM rio (1) window. The tag contains a number of blank-separated words, followed by a vertical bar character, followed by anything. @@ -118,9 +118,9 @@ a slash. .SS Scrolling Each window has a scroll bar to the left of the body. The scroll bar behaves much as in -.IR sam (1) +.IM sam (1) or -.IR rio (1) +.IM rio (1) except that scrolling occurs when the button is pressed, rather than released, and continues as long as the mouse button is held down in the scroll bar. @@ -131,7 +131,7 @@ down the scroll bar speeds up the rate of scrolling. .B -r reverses the scrolling behavior of buttons 1 and 3, to behave more like -.IR xterm (1).) +.IM xterm (1) .) .SS Layout .I Acme windows are arranged in columns. By default, it creates two columns when starting; @@ -164,7 +164,7 @@ pre-loads them with useful commands. Also, the tag across the top maintains a list of executing long-running commands. .SS Typing The behavior of typed text is similar to that in -.IR rio (1) +.IM rio (1) except that the characters are delivered to the tag or body under the mouse; there is no `click to type'. (The experimental option @@ -172,7 +172,7 @@ except that the characters are delivered to the tag or body under the mouse; the causes typing to go to the most recently clicked-at or made window.) The usual backspacing conventions apply. As in -.IR sam (1) +.IM sam (1) but not .IR rio , the ESC key selects the text typed since the last mouse action, @@ -249,7 +249,7 @@ is identified by the context of the command. These error windows are created when needed. .SS "Mouse button 1 Mouse button 1 selects text just as in -.IR sam (1) +.IM sam (1) or .IR rio (1) , including the usual double-clicking conventions. @@ -305,7 +305,7 @@ by default. .TP .B Edit Treat the argument as a text editing command in the style of -.IR sam (1). +.IM sam (1) . The full .B Sam language is implemented except for the commands @@ -379,7 +379,7 @@ With no arguments, prints the supplementary list. This command is largely superseded by plumbing (see -.IR plumb (7)). +.IM plumb (7) ). .TP .B Indent Set the autoindent mode according to the argument: @@ -507,7 +507,7 @@ If the text indicated with button 2 is not a recognized built-in, it is executed a shell command. For example, indicating .B date with button 2 runs -.IR date (1). +.IM date (1) . The standard and error outputs of commands are sent to the error window associated with the directory from which the command was run, which will be created if @@ -525,7 +525,7 @@ in a window containing executing .B mk will run -.IR mk (1) +.IM mk (1) in .BR /home/rob/sam , producing output in a window labeled @@ -539,12 +539,12 @@ and .B $winid set to the window's id number (see -.IR acme (4)). +.IM acme (4) ). .PP The environment variable .B $acmeshell determines which shell is used to execute such commands; the -.IR rc (1) +.IM rc (1) shell is used by default. .SS "Mouse button 3 Pointing at text with button 3 instructs @@ -574,7 +574,7 @@ command adds directories to the standard list.) .PP If the text begins with a colon, it is taken to be an address, in the style of -.IR sam (1), +.IM sam (1) , within the body of the window containing the text. The address is evaluated, the resulting text highlighted, and the mouse moved to it. Thus, in @@ -644,7 +644,7 @@ then execute clicking button 1 while 2 is held down. .PP When an external command (e.g. -.IR echo (1)) +.IM echo (1) ) is executed this way, the extra argument is passed as expected and an environment variable .B $acmeaddr @@ -677,7 +677,7 @@ window and runs a (default .BR $SHELL ) in it, turning the window into something analogous to an -.IR 9term (1) +.IM 9term (1) window. Executing text in a .I win @@ -686,7 +686,7 @@ window with button .BR Send . .I Win windows follow the same scrolling heuristic as in -.IR 9term (1): +.IM 9term (1) : the window scrolls on output only if the window is displaying the end of the buffer. .PP .I Awd @@ -774,7 +774,7 @@ MIPS-specific binaries for applications .br .B \*9/bin/awd .SH SEE ALSO -.IR acme (4) +.IM acme (4) .br Rob Pike, .I diff --git a/man/man1/acmeevent.1 b/man/man1/acmeevent.1 index d5ff0830e..52e6d60b8 100644 --- a/man/man1/acmeevent.1 +++ b/man/man1/acmeevent.1 @@ -61,7 +61,7 @@ acmeevent, acme.rc \- shell script support for acme clients and .I acme.rc make it easy to write simple -.IR acme (1) +.IM acme (1) client programs as shell scripts. .PP .I Acme @@ -69,14 +69,14 @@ clients read the .B event files (see -.IR acme (4)) +.IM acme (4) ) for the windows they control, reacting to the events. The events are presented in a format that is easy to read with C programs but hard to read with shell scripts. .PP .I Acmeevent reads an -.IR acme (4) +.IM acme (4) event stream from standard input, printing a shell-friendly version of the events, one per line, on standard output. Each output line from @@ -165,7 +165,7 @@ above); below). .I Flag remains from the -.IR acme (4) +.IM acme (4) event format. Because .IR eq0 , @@ -174,7 +174,7 @@ and .I chordarg are explicit in each event (unlike in -.IR acme (4) +.IM acme (4) events), .I flag can usually be ignored. @@ -221,7 +221,7 @@ window. .PP .I Acme.rc is a library of -.IR rc (1) +.IM rc (1) shell functions useful for writing acme clients. .PP .I Newwindow @@ -259,14 +259,14 @@ The most commonly-used command is .BR clean , which marks the window as clean. See -.IR acme (4) +.IM acme (4) for a full list of commands. .PP .I Windump sets the window's dump directory and dump command (see -.IR acme (4)). +.IM acme (4) ). If either argument is omitted or is .BR - , that argument is not set. @@ -381,9 +381,9 @@ for the full implementation. .br .B \*9/lib/acme.rc .SH SEE ALSO -.IR acme (1), -.IR acme (4), -.IR rc (1) +.IM acme (1) , +.IM acme (4) , +.IM rc (1) .SH BUGS There is more that could be done to ease the writing of complicated clients. diff --git a/man/man1/ascii.1 b/man/man1/ascii.1 index 0857805e9..611c7c6dd 100644 --- a/man/man1/ascii.1 +++ b/man/man1/ascii.1 @@ -91,7 +91,7 @@ control characters or insert newlines. is similar; it converts between .SM UTF and character values from the Unicode Standard (see -.IR utf (7)). +.IM utf (7) ). If given a range of hexadecimal numbers, .I unicode prints a table of the specified Unicode characters \(em their values and @@ -126,7 +126,7 @@ The file contains a table of characters and descriptions, sorted in hexadecimal order, suitable for -.IR look (1) +.IM look (1) on the lower case .I hex values of characters. @@ -154,7 +154,7 @@ table of characters and descriptions. .br .B \*9/src/cmd/unicode.c .SH "SEE ALSO" -.IR look (1), -.IR tcs (1), -.IR utf (7), -.IR font (7) +.IM look (1) , +.IM tcs (1) , +.IM utf (7) , +.IM font (7) diff --git a/man/man1/astro.1 b/man/man1/astro.1 index af5e7afa4..a143f2cf5 100644 --- a/man/man1/astro.1 +++ b/man/man1/astro.1 @@ -114,7 +114,7 @@ default latitude (N), longitude (W), and elevation (meters) .SH SOURCE .B \*9/src/cmd/astro .SH SEE ALSO -.IR scat (1) +.IM scat (1) .SH BUGS The .B k diff --git a/man/man1/awk.1 b/man/man1/awk.1 index 9a933b709..da6389bf8 100644 --- a/man/man1/awk.1 +++ b/man/man1/awk.1 @@ -377,7 +377,7 @@ Patterns are arbitrary Boolean combinations of regular expressions and relational expressions. Regular expressions are as in -.IR regexp (7). +.IM regexp (7) . Isolated regular expressions in a pattern apply to the entire line. Regular expressions may also occur in @@ -534,8 +534,8 @@ BEGIN { # Simulate echo(1) .SH SOURCE .B \*9/src/cmd/awk .SH SEE ALSO -.IR sed (1), -.IR regexp (7), +.IM sed (1) , +.IM regexp (7) , .br A. V. Aho, B. W. Kernighan, P. J. Weinberger, .I diff --git a/man/man1/bc.1 b/man/man1/bc.1 index 571943409..ee314735c 100644 --- a/man/man1/bc.1 +++ b/man/man1/bc.1 @@ -218,7 +218,7 @@ Assignment to .B scale influences the number of digits to be retained on arithmetic operations in the manner of -.IR dc (1). +.IM dc (1) . Assignments to .B ibase or @@ -235,7 +235,7 @@ empty square brackets must follow the array name. .PP .I Bc is actually a preprocessor for -.IR dc (1), +.IM dc (1) , which it invokes automatically, unless the .B -c (compile only) @@ -273,7 +273,7 @@ mathematical library .B \*9/src/cmd/bc.y .SH "SEE ALSO" .IR dc (1), -.IR hoc (1) +.IM hoc (1) .SH BUGS No .LR && , diff --git a/man/man1/bundle.1 b/man/man1/bundle.1 index 36bcd8d05..b954fdb12 100644 --- a/man/man1/bundle.1 +++ b/man/man1/bundle.1 @@ -7,20 +7,20 @@ bundle \- collect files for distribution .SH DESCRIPTION .I Bundle writes on its standard output a shell script for -.IR rc (1) +.IM rc (1) or a Bourne shell which, when executed, will recreate the original .IR files . Its main use is for distributing small numbers of text files by -.IR mail (1). +.IM mail (1) . .PP Although less refined than standard archives from .I 9ar (see -.IR 9c (1)) +.IM 9c (1) ) or -.IR tar (1), +.IM tar (1) , a .IR bundle file @@ -49,7 +49,7 @@ cd gift; sh horse; mk (in .IR 9c (1)), .IR tar (1), -.IR mail (1) +.IM mail (1) .SH BUGS .I Bundle will not create directories and is unsatisfactory for non-text files. diff --git a/man/man1/calendar.1 b/man/man1/calendar.1 index 14c6f911c..5c3b2760c 100644 --- a/man/man1/calendar.1 +++ b/man/man1/calendar.1 @@ -43,7 +43,7 @@ processing at the end of the week. On Friday and Saturday, events through Monday are printed. .PP To have your calendar mailed to you every day, use -.IR cron (8). +.IM cron (8) . .SH FILES .TF $HOME/lib/calendar .TP diff --git a/man/man1/cat.1 b/man/man1/cat.1 index 0738206aa..d44817927 100644 --- a/man/man1/cat.1 +++ b/man/man1/cat.1 @@ -51,7 +51,7 @@ copies to standard output exactly one line from the named .IR file , default standard input. It is useful in interactive -.IR rc (1) +.IM rc (1) scripts. .PP The @@ -76,11 +76,11 @@ characters and the characters that precede them. It is useful to use as .B $PAGER with the Unix version of -.IR man (1) +.IM man (1) when run inside a .I win (see -.IR acme (1)) +.IM acme (1) ) window. .SH SOURCE .B \*9/src/cmd/cat.c @@ -89,7 +89,7 @@ window. .br .B \*9/bin/nobs .SH SEE ALSO -.IR cp (1) +.IM cp (1) .SH DIAGNOSTICS .I Read exits with status diff --git a/man/man1/cleanname.1 b/man/man1/cleanname.1 index 02ad0baa2..50e63f3c8 100644 --- a/man/man1/cleanname.1 +++ b/man/man1/cleanname.1 @@ -29,4 +29,4 @@ before processing. .SH SOURCE .B \*9/src/cmd/cleanname.c .SH SEE ALSO -.IR cleanname (3). +.IM cleanname (3) . diff --git a/man/man1/col.1 b/man/man1/col.1 index 1cdcbcba4..426bb7bc9 100644 --- a/man/man1/col.1 +++ b/man/man1/col.1 @@ -14,11 +14,11 @@ and half line feeds (ESC-9 and ESC-8) as produced by .I nroff for .2C in -.IR ms (7) +.IM ms (7) or -.IR man (7) +.IM man (7) and for -.IR tbl (1). +.IM tbl (1) . .I Col is a pure filter. It normally emits only full line feeds; @@ -47,7 +47,7 @@ paginate the output. .SH SOURCE .B \*9/src/cmd/col.c .SH SEE ALSO -.IR pr (1) +.IM pr (1) .SH BUGS .I Col can't back up more than 128 lines or diff --git a/man/man1/colors.1 b/man/man1/colors.1 index 9e850621a..27b439e91 100644 --- a/man/man1/colors.1 +++ b/man/man1/colors.1 @@ -17,13 +17,13 @@ colors, cmapcube \- display color map .I Colors presents a grid showing the colors in the RGBV color map (see -.IR color (7)). +.IM color (7) ). .PP Clicking mouse button 1 over a color in the grid will display the map index for that color, its red, green, and blue components, and the 32-bit hexadecimal color value as defined in -.IR allocimage (3). +.IM allocimage (3) . If the .B -x option is specified, the components will also be listed in hexadecimal. @@ -53,4 +53,4 @@ to black or white. .SH SOURCE .B \*9/src/cmd/draw/colors.c .SH SEE ALSO -.IR color (7) +.IM color (7) diff --git a/man/man1/comm.1 b/man/man1/comm.1 index 1e5d24dc5..afb2dc257 100644 --- a/man/man1/comm.1 +++ b/man/man1/comm.1 @@ -41,7 +41,7 @@ Print lines common to two sorted files. .SH SOURCE .B \*9/src/cmd/comm.c .SH "SEE ALSO" -.IR sort (1), +.IM sort (1) , .IR cmp (1), .IR diff (1), -.IR uniq (1) +.IM uniq (1) diff --git a/man/man1/core.1 b/man/man1/core.1 index 51d235fbd..e19c7520d 100644 --- a/man/man1/core.1 +++ b/man/man1/core.1 @@ -35,7 +35,7 @@ The command, if run, prints a stack trace of the executing thread at the time of the core dump; see -.IR db (1). +.IM db (1) . .PP If no arguments are given, .I core @@ -50,6 +50,6 @@ searches the current directory. .SH SOURCE .B \*9/src/cmd/core.c .SH "SEE ALSO -.IR acid (1), -.IR db (1), -.IR core (5) +.IM acid (1) , +.IM db (1) , +.IM core (5) diff --git a/man/man1/crop.1 b/man/man1/crop.1 index 1df8bf91e..a1cd59255 100644 --- a/man/man1/crop.1 +++ b/man/man1/crop.1 @@ -53,9 +53,9 @@ crop, iconv \- frame, crop, and convert image .SH DESCRIPTION .I Crop reads an -.IR image (7) +.IM image (7) file (default standard input), crops it, and writes it as a compressed -.IR image (7) +.IM image (7) file to standard output. There are two ways to specify a crop, by color value or by geometry. They may be combined in a single run of @@ -65,7 +65,7 @@ in which case the color value crop will be done first. The .B -c option takes a red-green-blue triplet as described in -.IR color (3). +.IM color (3) . (For example, white is .B 255 @@ -118,7 +118,7 @@ changes the format of pixels in the image Pixels in the image are converted according to the channel descriptor .IR chandesc , (see -.IR image (7)). +.IM image (7) ). For example, to convert a 4-bit-per-pixel grey-scale image to an 8-bit-per-pixel color-mapped image, .I chandesc @@ -139,8 +139,8 @@ crop -c 255 255 255 -i -10 -b 255 150 150 imagefile > cropped .SH SOURCE .B \*9/src/cmd/draw/crop.c .SH SEE ALSO -.IR image (7), -.IR color (3) +.IM image (7) , +.IM color (3) .SH BUGS .I Iconv should be able to do Floyd-Steinberg error diffusion or dithering diff --git a/man/man1/date.1 b/man/man1/date.1 index 10db8dfe8..b5ad47818 100644 --- a/man/man1/date.1 +++ b/man/man1/date.1 @@ -28,7 +28,7 @@ epoch, 00:00:00 GMT, January 1, 1970. The conversion from Greenwich Mean Time to local time depends on the .B $timezone environment variable; see -.IR ctime (3). +.IM ctime (3) . .PP If the optional argument .I seconds diff --git a/man/man1/db.1 b/man/man1/db.1 index 03355508c..c87ea4a30 100644 --- a/man/man1/db.1 +++ b/man/man1/db.1 @@ -45,11 +45,11 @@ specifies the memory image of a process. A .I pid gives the id of an executing process to be accessed via -.IR ptrace (2). +.IM ptrace (2) . A .I corefile specifies the name of a core dump (see -.IR core (5) +.IM core (5) on your system of choice) containing the memory image of a terminated process. This manual refers to the memory image specified by @@ -628,7 +628,7 @@ Dot is assigned to the variable or register named. .TP .B ! The rest of the line is passed to -.IR rc (1) +.IM rc (1) for execution. .TP .BI $ modifier @@ -969,8 +969,8 @@ is one the breakpoint will fire. Beware that local variables may be stored in registers; see the BUGS section. .SH "SEE ALSO" -.IR acid (1), -.IR core (1) +.IM acid (1) , +.IM core (1) .SH SOURCE .B \*9/src/cmd/db .SH DIAGNOSTICS diff --git a/man/man1/dc.1 b/man/man1/dc.1 index 5394580a4..ad5cf3106 100644 --- a/man/man1/dc.1 +++ b/man/man1/dc.1 @@ -235,8 +235,8 @@ lyx .SH SOURCE .B \*9/src/cmd/dc.c .SH "SEE ALSO" -.IR bc (1), -.IR hoc (1) +.IM bc (1) , +.IM hoc (1) .SH DIAGNOSTICS .I x .LR "is unimplemented" , diff --git a/man/man1/dd.1 b/man/man1/dd.1 index 63b35e145..948e80cb4 100644 --- a/man/man1/dd.1 +++ b/man/man1/dd.1 @@ -191,7 +191,7 @@ options become a simple file copy. .SH SOURCE .B \*9/src/cmd/dd.c .SH "SEE ALSO" -.IR cp (1) +.IM cp (1) .SH DIAGNOSTICS .I Dd reports the number of full + partial input and output diff --git a/man/man1/deroff.1 b/man/man1/deroff.1 index 9d159f9e4..90fba52d5 100644 --- a/man/man1/deroff.1 +++ b/man/man1/deroff.1 @@ -16,13 +16,13 @@ reads each file in sequence and removes all .I nroff and -.IR troff (1) +.IM troff (1) requests and non-text arguments, backslash constructions, and constructs of preprocessors such as -.IR eqn (1), -.IR pic (1), +.IM eqn (1) , +.IM pic (1) , and -.IR tbl (1). +.IM tbl (1) . Remaining text is written on the standard output. .I Deroff follows files included by @@ -67,7 +67,7 @@ requests. Remove titles, attachments, etc., as well as ordinary .IR troff constructs, from -.IR ms (7) +.IM ms (7) or .I mm documents. @@ -84,7 +84,7 @@ does for and .I latex (see -.IR tex (1)) +.IM tex (1) ) files what .B deroff -wi does for @@ -96,8 +96,8 @@ files. .B \*9/src/cmd/delatex.lx .SH "SEE ALSO" .IR troff (1), -.IR tex (1), -.IR spell (1) +.IM tex (1) , +.IM spell (1) .SH BUGS These filters are not complete interpreters of .I troff diff --git a/man/man1/devdraw.1 b/man/man1/devdraw.1 index 009f5a94d..eda04893b 100644 --- a/man/man1/devdraw.1 +++ b/man/man1/devdraw.1 @@ -5,7 +5,7 @@ devdraw \- draw device simulator invoked via .I initdraw (see -.IR graphics (3)) +.IM graphics (3) ) .SH DESCRIPTION .I Devdraw serves a custom graphics protocol and is the only program @@ -20,9 +20,9 @@ to use all available physical pixels on a retina display. .SH SOURCE .B \*9/src/cmd/devdraw .SH "SEE ALSO -.IR draw (3), -.IR drawfcall (3), -.IR graphics (3) +.IM draw (3) , +.IM drawfcall (3) , +.IM graphics (3) .SH BUGS .I Devdraw should probably present a standard 9P server diff --git a/man/man1/dial.1 b/man/man1/dial.1 index 7fc50bcdb..a27c2026b 100644 --- a/man/man1/dial.1 +++ b/man/man1/dial.1 @@ -12,7 +12,7 @@ dial \- connect to a remote service connects to the network address .I addr (see -.IR dial (3)) +.IM dial (3) ) and then copies data from the connection to standard output, and from standard input to the connection. .PP @@ -27,4 +27,4 @@ to exit only in response to end of file on the network connection. .SH SOURCE .B \*9/src/cmd/dial.c .SH SEE ALSO -.IR dial (3) +.IM dial (3) diff --git a/man/man1/dict.1 b/man/man1/dict.1 index d382acc47..209aca410 100644 --- a/man/man1/dict.1 +++ b/man/man1/dict.1 @@ -53,7 +53,7 @@ Print a pronunciation key. .PD .PP Patterns are regular expressions (see -.IR regexp (7)), +.IM regexp (7) ), with an implicit leading .L ^ and trailing @@ -154,7 +154,7 @@ searches for dictionaries in the directory named by .PP .I Adict is a dictionary browser for -.IR acme (1). +.IM acme (1) . When run with no arguments, it creates a new .I acme window named @@ -193,7 +193,7 @@ window. dictionaries .PD .SH "SEE ALSO" -.IR regexp (7) +.IM regexp (7) .SH SOURCE .B \*9/src/cmd/dict .br diff --git a/man/man1/diff.1 b/man/man1/diff.1 index fd42643d3..cffbf0b65 100644 --- a/man/man1/diff.1 +++ b/man/man1/diff.1 @@ -19,7 +19,7 @@ two directories are compared by the method of .I diff for text files and -.IR cmp (1) +.IM cmp (1) otherwise. If more than two file names are given, then each argument is compared to the last argument as above. @@ -140,9 +140,9 @@ differences. .SH SOURCE .B \*9/src/cmd/diff .SH "SEE ALSO" -.IR cmp (1), -.IR comm (1), -.IR ed (1) +.IM cmp (1) , +.IM comm (1) , +.IM ed (1) .SH DIAGNOSTICS Exit status is the empty string for no differences, diff --git a/man/man1/doctype.1 b/man/man1/doctype.1 index da33653aa..fb9d3b055 100644 --- a/man/man1/doctype.1 +++ b/man/man1/doctype.1 @@ -17,16 +17,16 @@ doctype \- intuit command line for formatting a document .SH DESCRIPTION .I Doctype examines a -.IR troff (1) +.IM troff (1) input file to deduce the appropriate text formatting command and prints it on standard output. .I Doctype recognizes input for -.IR troff (1), +.IM troff (1) , related preprocessors like -.IR eqn (1), +.IM eqn (1) , and the -.IR ms (7) +.IM ms (7) and .I mm macro packages. @@ -56,8 +56,8 @@ Typeset files named .IR eqn (1), .IR tbl (1), .IR pic (1), -.IR grap (1), -.IR ms (7), -.IR man (7) +.IM grap (1) , +.IM ms (7) , +.IM man (7) .SH BUGS In true A.I. style, its best guesses are inspired rather than accurate. diff --git a/man/man1/ed.1 b/man/man1/ed.1 index 41071c7ea..64bf4860b 100644 --- a/man/man1/ed.1 +++ b/man/man1/ed.1 @@ -96,7 +96,7 @@ beginning of a line. supports the .I "regular expression" notation described in -.IR regexp (7). +.IM regexp (7) . Regular expressions are used in addresses to specify lines and in one command (see @@ -641,7 +641,7 @@ Dot is unchanged. Send the remainder of the line after the .L ! to -.IR rc (1) +.IM rc (1) to be interpreted as a command. Dot is unchanged. .TP @@ -679,9 +679,9 @@ and all characters after the last newline. .SH SOURCE .B \*9/src/cmd/ed.c .SH "SEE ALSO" -.IR sam (1), -.IR sed (1), -.IR regexp (7) +.IM sam (1) , +.IM sed (1) , +.IM regexp (7) .SH DIAGNOSTICS .BI ? name for inaccessible file; diff --git a/man/man1/eqn.1 b/man/man1/eqn.1 index bf4bac68f..723b2dc34 100644 --- a/man/man1/eqn.1 +++ b/man/man1/eqn.1 @@ -15,7 +15,7 @@ eqn \- typeset mathematics .SH DESCRIPTION .I Eqn is a -.IR troff (1) +.IM troff (1) preprocessor for typesetting mathematics on a typesetter. @@ -34,7 +34,7 @@ named in the option (default .BR -Tutf ; see -.IR troff (1)). +.IM troff (1) ). When run with other preprocessor filters, .I eqn usually comes last. @@ -299,7 +299,7 @@ Mathematical words like .LR cos , .L log are made Roman automatically. -.IR Troff (1) +.IM Troff (1) four-character escapes like .L \e(lh (\(lh) can be used anywhere. @@ -319,7 +319,7 @@ font descriptions for PostScript .B \*9/src/cmd/eqn .SH "SEE ALSO" .IR troff (1), -.IR tbl (1) +.IM tbl (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual''. diff --git a/man/man1/freq.1 b/man/man1/freq.1 index cbbd4152e..3c9c0fac4 100644 --- a/man/man1/freq.1 +++ b/man/man1/freq.1 @@ -36,5 +36,5 @@ character, respectively. .SH SOURCE .B \*9/src/cmd/freq.c .SH SEE ALSO -.IR utf (7), -.IR wc (1) +.IM utf (7) , +.IM wc (1) diff --git a/man/man1/git.1 b/man/man1/git.1 index 9b29b5121..2583141c4 100644 --- a/man/man1/git.1 +++ b/man/man1/git.1 @@ -1,5 +1,5 @@ .TH GIT 1 -.SH NAME +.SH NAME git, hg, cvs, codereview \- introduction to using plan9port Git repository .SH SYNOPSIS .B git @@ -17,7 +17,7 @@ git, hg, cvs, codereview \- introduction to using plan9port Git repository .I path ... ] .PP -.B gitk +.B gitk .PP .B web .B https://9fans.github.io/plan9port @@ -37,13 +37,13 @@ which it will create. After .B git .BR clone , -the other commands listed +the other commands listed should be run within the .B plan9 directory tree. .PP Git downloads the entire revision history -of Plan 9 from User Space +of Plan 9 from User Space in addition to the current tree. .PP .I Git @@ -55,7 +55,7 @@ current file tree. .I Git .I diff runs Unix's -.IR diff (1) +.IM diff (1) to compare the files in the local tree with the corresponding files in the revision history. The special revision @@ -76,7 +76,7 @@ directory containing Git local repository list of files and wildcards to exclude from Git operations .SH SEE ALSO Unix's -\fIgit\fR(1), +.IR git (1), .HR http://git-scm.com/doc .PP .HR https://9fans.github.io/plan9port/ diff --git a/man/man1/grap.1 b/man/man1/grap.1 index beda727df..40effe127 100644 --- a/man/man1/grap.1 +++ b/man/man1/grap.1 @@ -9,7 +9,7 @@ grap \- pic preprocessor for drawing graphs .SH DESCRIPTION .I Grap is a -.IR pic (1) +.IM pic (1) preprocessor for drawing graphs on a typesetter. Graphs are surrounded by the .I troff @@ -407,7 +407,7 @@ definitions of standard plotting characters, e.g., bullet .B \*9/src/cmd/grap .SH "SEE ALSO" .IR pic (1), -.IR troff (1) +.IM troff (1) .br J. L. Bentley and B. W. Kernighan, ``GRAP\(emA Language for Typesetting Graphs'', diff --git a/man/man1/graph.1 b/man/man1/graph.1 index bb6d25da9..4f1fbed18 100644 --- a/man/man1/graph.1 +++ b/man/man1/graph.1 @@ -89,7 +89,7 @@ The next argument is Next argument is one or more of the characters .B bcgkmrwy, choosing pen colors by their initial letter, as in -.IR plot (7). +.IM plot (7) . Successive curves will cycle through the colors in the given order. .TP .B -s @@ -145,7 +145,7 @@ is reversed. .B \*9/src/cmd/graph .SH "SEE ALSO" .IR plot (1), -.IR grap (1) +.IM grap (1) .SH BUGS Segments that run out of bounds are dropped, not windowed. Logarithmic axes may not be reversed. diff --git a/man/man1/grep.1 b/man/man1/grep.1 index 238906218..18632766b 100644 --- a/man/man1/grep.1 +++ b/man/man1/grep.1 @@ -27,7 +27,7 @@ searches the input for lines that match the .IR pattern , a regular expression as defined in -.IR regexp (7) +.IM regexp (7) with the addition of a newline character as an alternative (substitute for .BR | ) @@ -114,11 +114,11 @@ If no files are listed, it searches all files matching .br .B \*9/bin/g .SH SEE ALSO -.IR ed (1), -.IR awk (1), -.IR sed (1), -.IR sam (1), -.IR regexp (7) +.IM ed (1) , +.IM awk (1) , +.IM sed (1) , +.IM sam (1) , +.IM regexp (7) .SH DIAGNOSTICS Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. diff --git a/man/man1/gview.1 b/man/man1/gview.1 index 6b0be4c7a..153299659 100644 --- a/man/man1/gview.1 +++ b/man/man1/gview.1 @@ -144,7 +144,7 @@ awk 'BEGIN{for(x=.1;x<500;x+=.1)print x,sin(x)/x}' | gview .SH SOURCE .B \*9/src/cmd/draw/gview.c .SH SEE ALSO -.IR awk (1) +.IM awk (1) .SH BUGS The user interface for the .I slant diff --git a/man/man1/gzip.1 b/man/man1/gzip.1 index 683ba3a55..593b713fa 100644 --- a/man/man1/gzip.1 +++ b/man/man1/gzip.1 @@ -150,8 +150,8 @@ Produce debugging output. .br .B \*9/src/cmd/bzip2 .SH SEE ALSO -.IR tar (1), -.IR compress (1) +.IM tar (1) , +.IM compress (1) .SH BUGS .I Unzip can only extract files which are uncompressed or compressed diff --git a/man/man1/hist.1 b/man/man1/hist.1 index 82175e7e1..41a2b402c 100644 --- a/man/man1/hist.1 +++ b/man/man1/hist.1 @@ -41,7 +41,7 @@ option enables verbose debugging printout. The .B -d option causes -.IR diff (1) +.IM diff (1) .B -c to be run for each adjacent pair of dump files, while .B -b @@ -73,11 +73,11 @@ by convention, root of dump file system .SH SOURCE .B \*9/src/cmd/hist.c .SH SEE ALSO -.IR yesterday (1), -.IR vbackup (8) +.IM yesterday (1) , +.IM vbackup (8) .SH BUGS Should be called .IR history , but that name is taken by -.IR sh (1). +.IM sh (1) . diff --git a/man/man1/hoc.1 b/man/man1/hoc.1 index f73ec8a8b..561752008 100644 --- a/man/man1/hoc.1 +++ b/man/man1/hoc.1 @@ -133,8 +133,8 @@ for(i=1; i<12; i++) print gcd(i,12) .SH SOURCE .B \*9/src/cmd/hoc .SH "SEE ALSO" -.IR bc (1), -.IR dc (1) +.IM bc (1) , +.IM dc (1) .br B. W. Kernighan and R. Pike, .I diff --git a/man/man1/htmlroff.1 b/man/man1/htmlroff.1 index 4dff65c84..28d243c77 100644 --- a/man/man1/htmlroff.1 +++ b/man/man1/htmlroff.1 @@ -21,7 +21,7 @@ htmlroff \- HTML formatting and typesetting .SH DESCRIPTION .I Htmlroff accepts -.IR troff (1) +.IM troff (1) input in the named .I files and formats it as HTML for viewing in a web browser. @@ -63,7 +63,7 @@ HTML entity sequences and so on). .I Htmlroff invokes -.IR tcs (1) +.IM tcs (1) for the conversion. .TP .B -v @@ -73,7 +73,7 @@ Generate debugging output and warnings about suspicious input. Most .I troff input files, especially those using the -.IR ms (7) +.IM ms (7) macros, can be used unaltered. In general, the macro file .B tmac.html @@ -83,10 +83,10 @@ as in .B -ms .BR -mhtml . .PP -.IR Htmlroff (7) +.IM Htmlroff (7) describes the changes to the input language. .PP -.IR Mhtml (7) +.IM Mhtml (7) describes the new macros. .SH EXAMPLES Format the Plan 9 web page: @@ -113,7 +113,7 @@ to Unicode characters like α. .SH SOURCE .B \*9/src/cmd/htmlroff .SH "SEE ALSO -.IR tcs (1), -.IR troff (1), -.IR htmlroff (7), -.IR mhtml (7) +.IM tcs (1) , +.IM troff (1) , +.IM htmlroff (7) , +.IM mhtml (7) diff --git a/man/man1/idiff.1 b/man/man1/idiff.1 index e8d37615d..c0ffebcfe 100644 --- a/man/man1/idiff.1 +++ b/man/man1/idiff.1 @@ -50,7 +50,7 @@ and prompt again. .PP .I Idiff invokes -.IR diff (1) +.IM diff (1) to compare the files. The .B -b @@ -66,7 +66,7 @@ passed to .SH SOURCE .B \*9/src/cmd/idiff.c .SH "SEE ALSO -.IR diff (1) +.IM diff (1) .br Kernighan and Pike, .IR "The Unix Programming Environment" , diff --git a/man/man1/install.1 b/man/man1/install.1 index 17411af26..6097f4358 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -15,7 +15,7 @@ cd \*9; ./INSTALL .SH DESCRIPTION To obtain the Plan 9 tree, use Git (see -.IR git (1)) +.IM git (1) ) or download a tar file from .HR https://9fans.github.io/plan9port "" . .PP @@ -25,7 +25,7 @@ usual place is In the root of the tree, run .BR ./INSTALL . This script builds the Plan 9 build program -.IR mk (1) +.IM mk (1) if necessary, cleans all previously built object files and libraries out of the tree, rebuilds and installs everything, and then cleans up. @@ -109,7 +109,7 @@ can safely be repeated to rebuild the system from scratch. .PP Once the system is built for the first time, it can be maintained and rebuilt using -.IR mk (1). +.IM mk (1) . To rebuild individual commands or libraries, run .B mk @@ -119,7 +119,7 @@ and .B clean in the appropriate source directory (see -.IR src (1)). +.IM src (1) ). .SH FILES .TP .B \*9/lib/moveplan9.files @@ -132,7 +132,7 @@ the script that edits the files .TP .B \*9/src/mkmk.sh the shell script used to build -.IR mk (1) +.IM mk (1) .TP .B \*9/dist/manweb the shell script that builds the HTML manual @@ -148,5 +148,5 @@ logged output from the last run of a summary of .B install.log .SH SEE ALSO -.IR intro (1), -.IR git (1) +.IM intro (1) , +.IM git (1) diff --git a/man/man1/join.1 b/man/man1/join.1 index 1c0ec9f9c..13741be36 100644 --- a/man/man1/join.1 +++ b/man/man1/join.1 @@ -114,7 +114,7 @@ birthdays empty. The layout of .B /adm/users is given in -.IR passwd (5); +.IM passwd (5) ; .B bdays contains sorted lines like .LR "ken:Feb\ 4,\ 1953" . @@ -132,7 +132,7 @@ Print all pairs of users with identical userids. .SH "SEE ALSO" .IR sort (1), .IR comm (1), -.IR awk (1) +.IM awk (1) .SH BUGS With default field separation, the collating sequence is that of diff --git a/man/man1/jpg.1 b/man/man1/jpg.1 index a59033b6b..bdc9110bc 100644 --- a/man/man1/jpg.1 +++ b/man/man1/jpg.1 @@ -122,7 +122,7 @@ Typing a .BR q , DEL, or control-D exits the program. For a more user-friendly interface, use -.IR page (1), +.IM page (1) , which invokes these programs to convert the images to standard format, displays them, and offers scrolling, panning, and menu-driven navigation among the files. .PP @@ -147,7 +147,7 @@ any of the following options: .TP .B -c Convert the image to a Plan 9 representation, as defined by -.IR image (7), +.IM image (7) , and write it to standard output. .TP .B -9 @@ -156,7 +156,7 @@ Like but produce an uncompressed image. This saves processing time, particularly when the output is being piped to another program such as -.IR page (1), +.IM page (1) , since it avoids compression and decompression. .TP .B -t @@ -235,8 +235,8 @@ space in the image. The icon file is written to standard output. .SH SOURCE .B \*9/src/cmd/jpg .SH "SEE ALSO" -.IR page (1), -.IR image (7). +.IM page (1) , +.IM image (7) . .SH BUGS Writing an animated GIF using .I togif diff --git a/man/man1/kill.1 b/man/man1/kill.1 index 5b61d8a10..ee311017c 100644 --- a/man/man1/kill.1 +++ b/man/man1/kill.1 @@ -19,18 +19,18 @@ prints commands that will cause all processes with .I name and owned by the current user to be terminated. Each command is commented with an output line from -.IR ps (1) +.IM ps (1) describing the process that would be killed. Use the .B send command of -.IR 9term (1), +.IM 9term (1) , or pipe the output of .I kill into -.IR rc (1) +.IM rc (1) or -.IR sh (1) +.IM sh (1) to execute the commands. .PP .I Kill @@ -60,8 +60,8 @@ signal. .SH SOURCE .B \*9/bin .SH "SEE ALSO" -.IR ps (1), -.IR notify (3) +.IM ps (1) , +.IM notify (3) .SH BUGS .I Stop and diff --git a/man/man1/label.1 b/man/man1/label.1 index 1748b0be9..92334f197 100644 --- a/man/man1/label.1 +++ b/man/man1/label.1 @@ -14,12 +14,12 @@ label, awd \- set window label sets the label of the current .I win (see -.IR acme (1)) +.IM acme (1) ) or X terminal window .RI ( e.g., -.IR 9term (1) +.IM 9term (1) or -.IR xterm (1)) +.IM xterm (1) ) by echoing a special control sequence to standard output. .PP .I Acme @@ -38,7 +38,7 @@ sets the window name to the current directory with a suffix, using the name of the current system by default. .SH EXAMPLE One can use the following -.IR sh (1) +.IM sh (1) function to keep the label up-to-date in response to .I cd commands: @@ -55,7 +55,7 @@ alias cd=_cd cd . .EE .PP -.IR Rc (1) +.IM Rc (1) installs a similar .B fn .B cd @@ -77,4 +77,4 @@ fn cd { .SH BUGS .I Awd is also documented in -.IR acme (1). +.IM acme (1) . diff --git a/man/man1/lex.1 b/man/man1/lex.1 index 6955e7914..fe99bd6c8 100644 --- a/man/man1/lex.1 +++ b/man/man1/lex.1 @@ -65,7 +65,7 @@ output template .SH "SEE ALSO" .IR yacc (1), -.IR sed (1) +.IM sed (1) .br M. E. Lesk and E. Schmidt, `LEX\(emLexical Analyzer Generator', diff --git a/man/man1/look.1 b/man/man1/look.1 index 02d2cb4b3..20f46a962 100644 --- a/man/man1/look.1 +++ b/man/man1/look.1 @@ -74,7 +74,7 @@ is assumed, with collating sequence .B \*9/src/cmd/look.c .SH "SEE ALSO" .IR sort (1), -.IR grep (1) +.IM grep (1) .SH DIAGNOSTICS The exit status is .RB `` "not found" '' diff --git a/man/man1/ls.1 b/man/man1/ls.1 index edaf11cfb..b4a5f7727 100644 --- a/man/man1/ls.1 +++ b/man/man1/ls.1 @@ -29,7 +29,7 @@ is the same as but sets the .B -p option and pipes the output through -.IR mc (1). +.IM mc (1) . .PP There are a number of options: .TP @@ -42,7 +42,7 @@ List in long format, giving mode (see below), file system type (e.g., for devices, the .B # code letter that names it; see -.IR intro (3)), +.IM intro (3) ), the instance or subdevice number, owner, group, size in bytes, and time of last modification for each file. @@ -60,7 +60,7 @@ Print only the final path element of each file name. List the .I qid (see -.IR stat (3)) +.IM stat (3) ) of each file; the printed fields are in the order path, version, and type. .TP @@ -99,7 +99,7 @@ otherwise. .TP .B -Q By default, printed file names are quoted if they contain characters special to -.IR rc (1). +.IM rc (1) . The .B -Q flag disables this behavior. @@ -168,5 +168,5 @@ if none of the above permissions is granted. .br .B \*9/bin/lc .SH SEE ALSO -.IR stat (3), -.IR mc (1) +.IM stat (3) , +.IM mc (1) diff --git a/man/man1/man.1 b/man/man1/man.1 index ec35b7ad1..cdab681ad 100644 --- a/man/man1/man.1 +++ b/man/man1/man.1 @@ -45,7 +45,7 @@ The options are: .TP .B -h Print the pages to HTML and send to a web browser with -.IR web (1). +.IM web (1) . .TP .B -n (Default) @@ -54,17 +54,17 @@ Print the pages on the standard output using .TP .B -p Run -.IR proof (1) +.IM proof (1) on the specified man pages. .TP .B -P Run -.IR page (1) +.IM page (1) on the specified man pages. .TP .B -t Run -.IR troff (1) +.IM troff (1) and send its output to standard output. .TP @@ -106,8 +106,8 @@ index for .br .B \*9/bin/lookman .SH "SEE ALSO" -.IR page (1), -.IR proof (1) +.IM page (1) , +.IM proof (1) .SH BUGS The manual was intended to be typeset; some detail is sacrificed on text terminals. .PP diff --git a/man/man1/map.1 b/man/man1/map.1 index c03200215..e5c253041 100644 --- a/man/man1/map.1 +++ b/man/man1/map.1 @@ -305,7 +305,7 @@ tracks appear as dot-dashed lines if the plotting filter supports them.) The .I file contains -.IR plot (7)-style +.IM plot (7) -style data for .L : or @@ -640,7 +640,7 @@ Map driver program .B \*9/src/cmd/map .SH "SEE ALSO" .IR map (7), -.IR plot (1) +.IM plot (1) .SH DIAGNOSTICS `Map seems to be empty'\(ema coarse survey found zero extent within the diff --git a/man/man1/mc.1 b/man/man1/mc.1 index e914cbabf..4727df5fb 100644 --- a/man/man1/mc.1 +++ b/man/man1/mc.1 @@ -18,10 +18,10 @@ splits the input into as many columns as will fit in .I N print positions. If run in a -.IR 9term (1), -.IR xterm (1), +.IM 9term (1) , +.IM xterm (1) , or -.IR acme (1) +.IM acme (1) window, the default .I N is the number of blanks that will fit across the window; @@ -36,14 +36,14 @@ is printed separately. .SH SOURCE .B \*9/src/cmd/draw/mc.c .SH "SEE ALSO" -.IR 9term (1), -.IR acme (1), -.IR acme (4), -.IR xterm (1), -.IR pr (1), +.IM 9term (1) , +.IM acme (1) , +.IM acme (4) , +.IM xterm (1) , +.IM pr (1) , .I lc in -.IR ls (1) +.IM ls (1) .SH BUGS On systems with high-DPI screens, .I 9term diff --git a/man/man1/mk.1 b/man/man1/mk.1 index 0698ef5b7..4b5e94d4c 100644 --- a/man/man1/mk.1 +++ b/man/man1/mk.1 @@ -29,7 +29,7 @@ contains a .I rule for each target that identifies the files and other targets upon which it depends and an -.IR sh (1) +.IM sh (1) script, a .IR recipe , to update the target. @@ -157,7 +157,7 @@ In the recipe of a meta-rule, the environment variable contains the string matched by the .BR % . For example, a meta-rule to compile a C program using -.IR 9c (1) +.IM 9c (1) might be: .IP .EX @@ -207,7 +207,7 @@ References to variables are replaced by the variables' values. Special characters may be quoted using single quotes .BR \&'' as in -.IR sh (1). +.IM sh (1) . .PP Assignments and rules are distinguished by the first unquoted occurrence of @@ -246,7 +246,7 @@ A legal reference of the form or .B ${name} is expanded as in -.IR sh (1). +.IM sh (1) . A reference of the form .BI ${name: A % B = C\fL%\fID\fL}\fR, where @@ -315,9 +315,9 @@ or .BR rcsh , .I mk uses -.IR rc (1)'s +.IM rc (1) 's quoting rules; otherwise it uses -.IR sh (1)'s. +.IM sh (1) 's. The .B MKSHELL variable is consulted when the mkfile is read, not when it is executed, @@ -523,7 +523,7 @@ of the aggregate Currently, the only aggregates supported are .I 9ar (see -.IR 9c (1)) +.IM 9c (1) ) archives. .SS Attributes The colon separating the target from the prerequisites @@ -567,12 +567,12 @@ In the rule, .B % has no special meaning. The target is interpreted as a regular expression as defined in -.IR regexp (7). +.IM regexp (7) . The prerequisites may contain references to subexpressions in form .BI \e n\f1, as in the substitute command of -.IR sed (1). +.IM sed (1) . .TP .B U The targets are considered to have been updated @@ -625,7 +625,7 @@ Regular expression meta-rules: .EE .PP A correct way to deal with -.IR yacc (1) +.IM yacc (1) grammars. The file .B lex.c @@ -656,8 +656,8 @@ x.tab.h:Pcmp -s: y.tab.h .SH SOURCE .B \*9/src/cmd/mk .SH SEE ALSO -.IR sh (1), -.IR regexp (7) +.IM sh (1) , +.IM regexp (7) .PP A. Hume, ``Mk: a Successor to Make'' diff --git a/man/man1/mk9660.1 b/man/man1/mk9660.1 index 0d655cf01..34c21eb83 100644 --- a/man/man1/mk9660.1 +++ b/man/man1/mk9660.1 @@ -71,11 +71,11 @@ the current directory). The .I proto file is formatted as described in -.IR proto (3). +.IM proto (3) . .PP The created CD image will be in ISO-9660 format, but by default the file names will -be stored in UTF-8 with no imposed length +be stored in UTF-8 with no imposed length or character restrictions. The .B -c @@ -84,7 +84,7 @@ flag causes to use only file names in ``8.3'' form that use digits, letters, and underscore. File names that do not conform are changed -to +to .BI D nnnnnn (for directories) or @@ -122,7 +122,7 @@ and .B \e are allowed in Plan 9 file names but not in Joliet file names; non-conforming file names are translated -and a +and a .B _CONFORM.MAP file written as in the case of the @@ -133,7 +133,7 @@ If the .B -r flag is given, Rock Ridge extensions are written in the format of the system use sharing protocol; -this format provides Posix-style file metadata and is +this format provides Posix-style file metadata and is common on Unix platforms. .PP The options @@ -155,13 +155,13 @@ if unspecified, the base name of .I proto is used. .PP -The +The .B -: -flag causes +flag causes .B mk9660 to replace colons in scanned file names with spaces; this is the inverse of the map applied by Plan 9's -\fIdossrv\fR(4) +.IR dossrv (4) and is useful for writing Joliet CDs containing data from FAT file systems. .PP @@ -189,10 +189,11 @@ on standard error. is similar in specification to .I mk9660 but creates and updates backup CD images in the style of -the +the .I dump file system -(see Plan 9's \fIfs\fR(4)). +(see Plan 9's +.IR fs (4)). The dump is file-based rather than block-based: if a file's contents have not changed since the last backup, only its directory entry will be rewritten. @@ -202,7 +203,7 @@ The option specifies a time (in seconds since January 1, 1970) to be used for naming the dump directory. .PP -The +The .B -m option specifies a maximum size for the image; if a backup would cause the image to grow larger than @@ -212,7 +213,7 @@ it will not be written, and will exit with a non-empty status. .SH EXAMPLE .PP -Create an image of the Plan 9 source tree, +Create an image of the Plan 9 source tree, including a conformant ISO-9660 directory tree, Plan 9 extensions in the system use fields, and a Joliet directory tree. @@ -223,7 +224,7 @@ mk9660 -9cj -s /n/bootes -p srcproto cdimage .SH SOURCE \*9/src/cmd/9660 .SH "SEE ALSO -.IR proto (3) +.IM proto (3) .\" .SH "SEE ALSO" .\" .I 9660srv .\" (in diff --git a/man/man1/mkdir.1 b/man/man1/mkdir.1 index e658847cf..ece75f347 100644 --- a/man/man1/mkdir.1 +++ b/man/man1/mkdir.1 @@ -28,11 +28,11 @@ The flag sets the permissions to be used when creating the directory. The default is 0777. .SH "SEE ALSO" -.IR rm (1) +.IM rm (1) .br .IR cd in -.IR rc (1) +.IM rc (1) .SH SOURCE .B \*9/src/cmd/mkdir.c .SH DIAGNOSTICS diff --git a/man/man1/mount.1 b/man/man1/mount.1 index ec9f016e4..51f1c785f 100644 --- a/man/man1/mount.1 +++ b/man/man1/mount.1 @@ -15,7 +15,7 @@ mounts a 9P server's files into the file system. is typically either the name of a Unix domain socket (see -.IR namespace (1)) +.IM namespace (1) ) or the name or IP address of a machine serving 9P over TCP port 564. .PP @@ -29,7 +29,7 @@ On Linux, .I mount uses the native 9P kernel module when present. Otherwise it tries to use -.IR 9pfuse (4) +.IM 9pfuse (4) with the FUSE file system module. Using the 9P kernel module requires root access. FUSE can often be used by regular users. @@ -45,7 +45,7 @@ should be invoked as .BR mount . .SH EXAMPLES Mount -.IR acme (4) +.IM acme (4) onto .B /mnt/acme : .IP @@ -64,6 +64,6 @@ cat /mnt/plumb/rules .br .B \*9/bin/unmount .SH SEE ALSO -.IR intro (4), +.IM intro (4) , .IR intro (9p), -.IR 9pfuse (4) +.IM 9pfuse (4) diff --git a/man/man1/namespace.1 b/man/man1/namespace.1 index e02a65097..238877e1a 100644 --- a/man/man1/namespace.1 +++ b/man/man1/namespace.1 @@ -7,9 +7,9 @@ namespace \- print name space directory .I Namespace prints the directory representing the current name space. See -.IR intro (4). +.IM intro (4) . .SH SOURCE .B \*9/src/cmd/namespace.c .SH SEE ALSO -.IR getns (3), -.IR intro (4) +.IM getns (3) , +.IM intro (4) diff --git a/man/man1/ndb.1 b/man/man1/ndb.1 index b37509c0b..a92b05b1a 100644 --- a/man/man1/ndb.1 +++ b/man/man1/ndb.1 @@ -24,9 +24,9 @@ ndbquery, ndbmkhash, ndbmkdb, ndbipquery, ndbmkhosts \- network database The network database holds administrative information used by .I authdial (see -.IR authsrv (3)) +.IM authsrv (3) ) and -.IR secstored (1). +.IM secstored (1) . .PP .I Ndbquery searches the database for an attribute of type @@ -46,7 +46,7 @@ of all the matched entries is returned. uses .I ndbipinfo (see -.IR ndb (3)) +.IM ndb (3) ) to search for the values of the attributes .I rattr corresponding to the system @@ -382,7 +382,7 @@ and by the ndb library routines. .PP .I Ndbmkdb is used in concert with -.IR awk (1) +.IM awk (1) scripts to convert uucp systems files and IP host files into database files. @@ -395,7 +395,7 @@ it is necessary to run .I ndbmkhash whenever the files are modified. It may be profitable to control this by a frequent -.IR cron (8) +.IM cron (8) job. .PP .I Ndbmkhosts @@ -439,5 +439,5 @@ hash files for .SH SOURCE .B \*9/src/cmd/ndb .SH SEE ALSO -.IR ndb (3), -.IR ndb (7) +.IM ndb (3) , +.IM ndb (7) diff --git a/man/man1/netfiles.1 b/man/man1/netfiles.1 index 69f519b11..11ab979dc 100644 --- a/man/man1/netfiles.1 +++ b/man/man1/netfiles.1 @@ -21,7 +21,7 @@ Netfiles, netfileget, netfileput, netfilestat \- network file access inside acme .SH DESCRIPTION .B Netfiles presents remote file systems in -.IR acme (4) +.IM acme (4) windows. Each window is named .BI /n/ system / path @@ -35,7 +35,7 @@ reads names of windows to create from the plumbing channel .B netfileedit (see -.IR plumber (4) +.IM plumber (4) and the example section below). In a .IR netfiles -controlled @@ -60,13 +60,13 @@ The three first check to see if .I system is a service in the current name space (see -.IR intro (4)). +.IM intro (4) ). If so, they use -.IR 9p (1) +.IM 9p (1) to access it. Otherwise, they assume that the system is a network name and use -.IR ssh (1)'s +.IM ssh (1) 's .I sftp to access it. .PP @@ -100,7 +100,7 @@ or .SH EXAMPLES The following plumbing rule (see -.IR plumb (7)) +.IM plumb (7) ) passes .B /n/ paths to @@ -118,17 +118,17 @@ plumb client Netfiles .SH SOURCE .B \*9/src/cmd/netfiles .SH SEE ALSO -.IR 9p (1), -.IR ssh (1), -.IR ssh-agent (1), -.IR intro (4), -.IR acme (4), -.IR factotum (4), +.IM 9p (1) , +.IM ssh (1) , +.IM ssh-agent (1) , +.IM intro (4) , +.IM acme (4) , +.IM factotum (4) , .HR http://v9fs.sf.net .SH BUGS .I Netfiles depends on -.IR sftpcache (1), +.IM sftpcache (1) , which only works with OpenSSH versions 4.3 and earlier; later versions do not print the .B sftp> diff --git a/man/man1/page.1 b/man/man1/page.1 index 99fba2b3f..4284bda2c 100644 --- a/man/man1/page.1 +++ b/man/man1/page.1 @@ -1,7 +1,7 @@ .TH PAGE 1 .SH NAME -page \- view -FAX, +page \- view +FAX, image, graphic, PostScript, PDF, and typesetter output files @@ -24,23 +24,24 @@ It can be used to display the individual pages of a PostScript, PDF, -or -.IR troff (1) -or -Unix's \fItex\fR(1) +or +.IM troff (1) +or +Unix's +.IR tex (1) device-independent output file. .I Troff -or +or .I tex output is simply converted to PostScript in order to be viewed. It can also be used to view any number of graphics files -(such as a +(such as a FAX -page, +page, a Plan 9 -.IR image (7) +.IM image (7) file, an Inferno bitmap file, or other common format). .I Page displays these @@ -53,26 +54,26 @@ By default, .I page runs in the window in which it is started and leaves the window unchanged. -The +The .B -R -option causes -.I page +option causes +.I page to grow the window if necessary to display the page being viewed. The .B -w -option causes -.I page +option causes +.I page to create a new window for itself. The newly created window will grow as under the .B -R option. -If being used to display +If being used to display multipage documents, only one file may be specified on the command line. .PP -The -.B -p +The +.B -p option sets the resolution for PostScript and PDF files, in pixels per inch. The default is 100 ppi. @@ -85,13 +86,13 @@ When viewing a document, will try to guess the true bounding box, usually rounding up from the file's bounding box to 8½×11 or A4 size. -The +The .B -b option causes it to respect the bounding box given in the file. As a more general problem, some PostScript files claim to conform to Adobe's Document Structuring Conventions but do not. -The +The .B -P option enables a slightly slower and slightly more skeptical version of the PostScript processing code. @@ -101,34 +102,35 @@ that can only be viewed with the option, and there are PostScript documents that can only be viewed without it. .PP -When viewing images with +When viewing images with .IR page , -it listens to the +it listens to the .B image plumbing channel -(see -.IR plumber (4)) +(see +.IM plumber (4) ) for more images to display. -The +The .B -i -option causes +option causes .I page -to not load any graphics files nor to read +to not load any graphics files nor to read from standard input but rather to listen for ones to load from the plumbing channel. .PP -The +The .B -v option turns on extra debugging output, and the .B -V option turns on even more debugging output. -The +The .B -a -option causes +option causes .I page to call -Unix's \fIabort\fR(3) +Unix's +.IR abort (3) rather than exit cleanly on errors, to facilitate debugging. .PP @@ -145,7 +147,7 @@ The button 2 menu operations are: Restores the image to the original. All modifications are lost. .TP .B Zoom -Prompts the user to sweep a rectangle on the image which is +Prompts the user to sweep a rectangle on the image which is expanded proportionally to the rectangle. .TP .B Fit window @@ -164,7 +166,7 @@ Displays the next page. Displays the previous page. .TP .B Zerox -Displays the current image in a new page window. +Displays the current image in a new page window. Useful for selecting important pages from large documents. .TP .B Reverse @@ -189,14 +191,14 @@ toggles whether images are displayed upside-down. Typing a .B r reverses the order in which pages are displayed. -Typing a +Typing a .B w will write the currently viewed page to a new file as a compressed -.IR image (7) +.IM image (7) file. When possible, the filename is of the form .IR basename . pagenum . bit . -Typing a +Typing a .B d removes an image from the working set. .PP @@ -208,13 +210,14 @@ changing pages when panning off the top or bottom of the page. .PP .I Page calls -Unix's \fIgs\fR(1) +Unix's +.IR gs (1) to draw each page of PostScript and PDF .IR files . It also calls a variety of conversion programs, such as those described in -.IR jpg (1), +.IM jpg (1) , to convert the various raster graphics formats into Inferno bitmap files. Pages are converted ``on the fly,'' as needed. @@ -232,11 +235,11 @@ Browse the Inferno bitmap library. man -t page | page -w Preview this manual in a new window. .SH "SEE ALSO -.IR gs (1), -.IR jpg (1), -.IR proof (1), -.IR tex (1), -.IR troff (1) +.IM gs (1) , +.IM jpg (1) , +.IM proof (1) , +.IM tex (1) , +.IM troff (1) .SH SOURCE .B \*9/src/cmd/page .SH DIAGNOSTICS @@ -254,19 +257,19 @@ When viewing multipage PostScript files that do not contain .RB `` %%Page '' comments, the button 3 menu only contains ``this page'' and ``next page'': -correctly determining +correctly determining page boundaries in Postscript code is not computable in the general case. .PP If .I page has trouble viewing a Postscript file, -it might not be exactly conforming: try viewing it with the +it might not be exactly conforming: try viewing it with the .B -P option. .PP The interface to the plumber is unsatisfactory. In particular, -document references cannot be sent +document references cannot be sent via plumbing messages. .PP There are too many keyboard commands and menu items. @@ -274,7 +277,7 @@ There are too many keyboard commands and menu items. Displaying a PostScript or PDF file depends both on having GhostScript (see -.IR gs (1)) +.IM gs (1) ) installed and on the underlying operating system providing a file descriptor device tree at .BR /dev/fd . diff --git a/man/man1/paint.1 b/man/man1/paint.1 index 2bcbf245c..fa37ceb74 100644 --- a/man/man1/paint.1 +++ b/man/man1/paint.1 @@ -19,7 +19,7 @@ If the optional argument is specified, then it is read and used as the canvas. .I Paint only recognizes Plan 9 bitmap format (see -.IR image (6)). +.IM image (6) ). .PP A number of immediate keyboard commands are recognized: .TP @@ -74,12 +74,12 @@ Quits the program. .SH SOURCE .B /sys/src/cmd/paint.c .SH "SEE ALSO" -.IR resample (1), -.IR rotate (1), -.IR crop (1), -.IR jpg (1), -.IR page (1), -.IR image (6) +.IM resample (1) , +.IM rotate (1) , +.IM crop (1) , +.IM jpg (1) , +.IM page (1) , +.IM image (6) .SH HISTORY .I Paint first appeared in 9front (October, 2011). diff --git a/man/man1/passwd.1 b/man/man1/passwd.1 index f6843b399..d31f3a8bc 100644 --- a/man/man1/passwd.1 +++ b/man/man1/passwd.1 @@ -36,7 +36,7 @@ It is a substitute for a SecureNet box. .br .B \*9/src/cmd/auth/passwd.c .SH "SEE ALSO" -.IR encrypt (3) +.IM encrypt (3) .PP Robert Morris and Ken Thompson, ``UNIX Password Security,'' diff --git a/man/man1/pem.1 b/man/man1/pem.1 index 391cd5cce..b18ee2514 100644 --- a/man/man1/pem.1 +++ b/man/man1/pem.1 @@ -20,7 +20,7 @@ Privacy Enhanced Mail program but now commonly used for other applications, notably TLS. PEM encodes data in base 64 (see -.IR encode (3)) +.IM encode (3) ) between lines of the form: .IP .EX @@ -33,7 +33,7 @@ where may be any string describing the encoded data. The most common use of PEM format on Plan 9 is for encoding X.509 certificates; see -.IR rsa (1). +.IM rsa (1) . .PP .I Pemdecode extracts the named @@ -62,4 +62,4 @@ hello world .SH SOURCE .B \*9/src/cmd/auth .SH "SEE ALSO -.IR rsa (1) +.IM rsa (1) diff --git a/man/man1/pic.1 b/man/man1/pic.1 index 0ee526fe1..bacc1dcb6 100644 --- a/man/man1/pic.1 +++ b/man/man1/pic.1 @@ -31,7 +31,7 @@ pic, tpic, svgpic \- troff and tex preprocessors for drawing pictures .SH DESCRIPTION .I Pic is a -.IR troff (1) +.IM troff (1) preprocessor for drawing figures on a typesetter. .I Pic code is contained between @@ -300,7 +300,7 @@ statement removes the definition of a macro. .PP .I Tpic is a -.IR tex (1) +.IM tex (1) preprocessor that accepts .IR pic language. @@ -345,8 +345,8 @@ A: ellipse .B \*9/src/cmd/pic .SH "SEE ALSO" .IR grap (1), -.IR doctype (1), -.IR troff (1) +.IM doctype (1) , +.IM troff (1) .br B. W. Kernighan, ``PIC\(ema Graphics Language for Typesetting'', diff --git a/man/man1/plot.1 b/man/man1/plot.1 index 3c8803f84..8485bcd5d 100644 --- a/man/man1/plot.1 +++ b/man/man1/plot.1 @@ -14,7 +14,7 @@ from the .I files or standard input, drawing the results in a newly created -.IR rio (1) +.IM rio (1) window. Plot persists until a newline is typed in the window. Various options may be interspersed with the @@ -31,7 +31,7 @@ Erase the screen. .TP .BI -c " col" Set the foreground color (see -.IR plot (7) +.IM plot (7) for color names). .TP .BI -f " fill" @@ -57,5 +57,5 @@ middle of the screen. .SH SOURCE .B \*9/src/cmd/plot .SH "SEE ALSO" -.IR rio (1), -.IR plot (7) +.IM rio (1) , +.IM plot (7) diff --git a/man/man1/plumb.1 b/man/man1/plumb.1 index 3fa162524..a6295342f 100644 --- a/man/man1/plumb.1 +++ b/man/man1/plumb.1 @@ -83,6 +83,6 @@ default rules file .SH SOURCE .B \*9/src/cmd/plumb .SH "SEE ALSO" -.IR plumb (3), -.IR plumber (4), -.IR plumb (7) +.IM plumb (3) , +.IM plumber (4) , +.IM plumb (7) diff --git a/man/man1/pr.1 b/man/man1/pr.1 index 860c026cc..f7069ac0a 100644 --- a/man/man1/pr.1 +++ b/man/man1/pr.1 @@ -106,5 +106,5 @@ characters instead of the default 72. .SH SOURCE .B \*9/src/cmd/pr.c .SH "SEE ALSO" -.IR cat (1), -.IR lp (1) +.IM cat (1) , +.IM lp (1) diff --git a/man/man1/proof.1 b/man/man1/proof.1 index 2a1de0841..fe5db6d3f 100644 --- a/man/man1/proof.1 +++ b/man/man1/proof.1 @@ -22,7 +22,7 @@ proof \- troff output interpreter .SH DESCRIPTION .I Proof reads -.IR troff (1) +.IM troff (1) intermediate language from .I file or standard input @@ -126,8 +126,8 @@ into screen fonts and character numbers .B \*9/src/cmd/proof .SH SEE ALSO .IR lp (1), -.IR gs (1), -.IR page (1) +.IM gs (1) , +.IM page (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual'' diff --git a/man/man1/ps.1 b/man/man1/ps.1 index bb655d181..c597060ff 100644 --- a/man/man1/ps.1 +++ b/man/man1/ps.1 @@ -102,6 +102,6 @@ to print the arguments for the process. Newlines in arguments will be translate .br .B \*9/bin/psu .SH "SEE ALSO" -.IR acid (1), -.IR db (1), -.IR kill (1) +.IM acid (1) , +.IM db (1) , +.IM kill (1) diff --git a/man/man1/psfonts.1 b/man/man1/psfonts.1 index c408f54a7..223c74f52 100644 --- a/man/man1/psfonts.1 +++ b/man/man1/psfonts.1 @@ -16,9 +16,9 @@ psfonts, psdownload \- add necessary fonts to PostScript document for printing ] .SH DESCRIPTION Plan 9's -.IR troff (1) +.IM troff (1) and -.IR tr2post (1) +.IM tr2post (1) use non-standard PostScript fonts (found in .BR \*9/postscript/font ). @@ -114,12 +114,12 @@ Continue running even after fatal errors occur. .PD .SH EXAMPLE See -.IR tr2post (1) +.IM tr2post (1) for an example. .SH SOURCE .B \*9/bin/psfonts .br .B \*9/src/cmd/postscript/download .SH SEE ALSO -.IR troff (1), -.IR tr2post (1) +.IM troff (1) , +.IM tr2post (1) diff --git a/man/man1/pwd.1 b/man/man1/pwd.1 index 0a3e06684..1464302df 100644 --- a/man/man1/pwd.1 +++ b/man/man1/pwd.1 @@ -18,8 +18,8 @@ such as constructing shell prompts. .SH SEE ALSO .I cd in -.IR rc (1), -.IR getwd (3) +.IM rc (1) , +.IM getwd (3) .SH BUGS .I Pwd is not provided. diff --git a/man/man1/rc.1 b/man/man1/rc.1 index 7553707d0..1d6a008b2 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -50,7 +50,7 @@ exits or is terminated, the variable .B $status gets the process's wait message (see -.IR wait (3)); +.IM wait (3) ); it will be the null string if the command was successful. .PP A long command line may be continued on subsequent lines by typing @@ -83,7 +83,7 @@ in a directory in .B $path is the program to be executed. To be executable, the user must have execute permission (see -.IR stat (3)) +.IM stat (3) ) and the file must be either an executable binary for the current machine's CPU type, or a shell script. Shell scripts begin with a line containing the full path name of a shell @@ -350,7 +350,7 @@ or is a previously opened file descriptor and .I fd0 becomes a new copy (in the sense of -.IR dup (3)) +.IM dup (3) ) of it. A file descriptor may be closed by writing .BI >[ fd0 =] @@ -543,7 +543,7 @@ function definition. A function with a special name will be called when .I rc receives a corresponding note; see -.IR notify (3). +.IM notify (3) . The valid note names (and corresponding notes) are .B sighup .RB ( hangup ), @@ -662,7 +662,7 @@ is composed of the bitwise OR of the .B rfork flags specified by the option letters (see -.IR fork (2)). +.IM fork (2) ). If no .I flags are given, they default to @@ -829,7 +829,7 @@ parsing the .B $PATH variable (as in -.IR sh (1)) +.IM sh (1) ) or by .BR "path=(.\ /bin)" . The variables diff --git a/man/man1/readcons.1 b/man/man1/readcons.1 index 8fa1c392e..d85452b7c 100644 --- a/man/man1/readcons.1 +++ b/man/man1/readcons.1 @@ -27,4 +27,4 @@ is printed instead of an empty string. .SH SOURCE .B \*9/src/cmd/readcons.c .SH SEE ALSO -.IR readcons (3) +.IM readcons (3) diff --git a/man/man1/resample.1 b/man/man1/resample.1 index f41d9e512..4b41ca081 100755 --- a/man/man1/resample.1 +++ b/man/man1/resample.1 @@ -40,19 +40,19 @@ and .PP The input should be a Plan 9 image as described in -.IR image (7), +.IM image (7) , and the output will be a compressed 24-bit .B r8g8b8 image. To uncompress the image or change the pixel format, use .I iconv (see -.IR crop (1)). +.IM crop (1) ). .PP .SH SOURCE .B \*9/src/cmd/resample.c .SH "SEE ALSO -.IR crop (1), -.IR image (7) +.IM crop (1) , +.IM image (7) .SH BUGS Faster algorithms exist, but this implementation produces correct pictures. diff --git a/man/man1/rio.1 b/man/man1/rio.1 index 1fc0619d8..d22ad3e41 100644 --- a/man/man1/rio.1 +++ b/man/man1/rio.1 @@ -68,15 +68,15 @@ specifies an alternative program to run when the .I New menu item is selected. The default is to try -.IR 9term (1) +.IM 9term (1) and then to fall back to -.IR xterm (1). +.IM xterm (1) . The .B \-s option has no effect. It formerly set the scrolling mode for new windows and is recognized to avoid breaking scripts. See -.IR 9term (1) +.IM 9term (1) for a description of scrolling behavior. .PP The @@ -137,11 +137,11 @@ Very small windows may not be created. The new window is created running .IR termprog , by default -.IR 9term (1) +.IM 9term (1) or, if .I 9term is not available, -.IR xterm (1). +.IM xterm (1) . .TP .B Resize Change the size and location of a window. @@ -165,7 +165,7 @@ Deleting a window causes a .L hangup note to be sent to all processes in the window's process group (see -.IR notify (3)). +.IM notify (3) ). .TP .B Hide Hide a window. Click in the window to be hidden (gunsight cursor); @@ -241,8 +241,8 @@ starts a particular program.) .PP There is a currently a compiled-in limit of 128 hidden windows. .SH "SEE ALSO" -.IR 9term (1), -.IR xterm (1) +.IM 9term (1) , +.IM xterm (1) .PP As mentioned above, .I rio diff --git a/man/man1/rm.1 b/man/man1/rm.1 index 83bc81727..ce0ea1c13 100644 --- a/man/man1/rm.1 +++ b/man/man1/rm.1 @@ -25,4 +25,4 @@ and the directory itself. .SH SOURCE .B \*9/src/cmd/rm.c .SH "SEE ALSO" -.IR remove (3) +.IM remove (3) diff --git a/man/man1/rsa.1 b/man/man1/rsa.1 index b01c979d9..2ba0d8b03 100644 --- a/man/man1/rsa.1 +++ b/man/man1/rsa.1 @@ -85,7 +85,7 @@ Plan 9 represents DSA and RSA keys as attribute-value pair lists prefixed with the string .BR key ; this is the generic key format used by -.IR factotum (4). +.IM factotum (4) . A full DSA private key has the following attributes: .TP .B proto @@ -334,9 +334,9 @@ scp auth.keys unix:.ssh/authorized_keys .SH SOURCE .B \*9/src/cmd/auth .SH "SEE ALSO -.IR factotum (4), -.IR pem (1), -.IR ssh (1) +.IM factotum (4) , +.IM pem (1) , +.IM ssh (1) .SH BUGS There are too many key formats. .PP diff --git a/man/man1/sam.1 b/man/man1/sam.1 index 8e771833f..c928b6679 100644 --- a/man/man1/sam.1 +++ b/man/man1/sam.1 @@ -51,7 +51,7 @@ copies leading white space on the current line to the new line. Do not `download' the terminal part of .IR sam . Editing will be done with the command language only, as in -.IR ed (1). +.IM ed (1) . .TP .BI -r " machine Run the host part remotely @@ -69,7 +69,7 @@ for debugging. .PD .SS Regular expressions Regular expressions are as in -.IR regexp (7) +.IM regexp (7) with the addition of .BR \en to represent newlines. @@ -698,7 +698,7 @@ There is usually a `current window', marked with a dark border, to which typed text and editing commands apply. Text may be typed and edited as in -.IR rio (1); +.IM rio (1) ; also the escape key (ESC) selects (sets dot to) text typed since the last mouse button hit. .PP @@ -798,7 +798,7 @@ the white-space-delimited block of text is sent as a plumb message with a .B click attribute defining where the selection lies (see -.IR plumb (7)). +.IM plumb (7) ). .TP .B look Search forward for the next occurrence of the literal text in dot. @@ -909,11 +909,11 @@ source for the separate terminal part .TP .B \*9/bin/E .SH SEE ALSO -.IR ed (1), -.IR sed (1), -.IR grep (1), -.IR rio (1), -.IR regexp (7). +.IM ed (1) , +.IM sed (1) , +.IM grep (1) , +.IM rio (1) , +.IM regexp (7) . .PP Rob Pike, ``The text editor sam''. diff --git a/man/man1/scat.1 b/man/man1/scat.1 index 57369ab5f..1fef52336 100644 --- a/man/man1/scat.1 +++ b/man/man1/scat.1 @@ -10,7 +10,7 @@ outside the solar system and implements database-like manipulations on sets of such objects. It also provides an interface to -.IR astro (1) +.IM astro (1) to plot the locations of solar system objects. Finally, it displays images from the Space Telescope Science Institute's @@ -119,7 +119,7 @@ The names and .B comet refer to the earth's penumbra at lunar distance and the comet installed in the current -.IR astro (1). +.IM astro (1) . The output is the planet's name, right ascension and declination, azimuth and altitude, and phase for the moon and sun, as shown by .BR astro . @@ -182,7 +182,7 @@ collects all objects in the patches that cover the current set. .TP .BI astro " option" Run -.IR astro (1) +.IM astro (1) with the specified .I options (to which will be appended @@ -324,7 +324,7 @@ Draw a map of the Pleiades. .SH SOURCE .B \*9/src/cmd/scat .SH SEE ALSO -.IR astro (1) +.IM astro (1) .br .B \*9/sky/constelnames\ \ the three-letter abbreviations of the constellation names. diff --git a/man/man1/secstore.1 b/man/man1/secstore.1 index 01c7903b0..6c25c7303 100644 --- a/man/man1/secstore.1 +++ b/man/man1/secstore.1 @@ -97,7 +97,7 @@ Option .B -n says that the password should be read from NVRAM (see -.IR authsrv (3)) +.IM authsrv (3) ) instead of from .BR /dev/tty . .PP @@ -107,7 +107,7 @@ or the server specified by option .BR -s . .PP For example, to add a secret to the file read by -.IR factotum (4), +.IM factotum (4) , run .sp .EX @@ -192,8 +192,8 @@ block chaining (CBC) mode. .br .B \*9/src/cmd/auth/secstore .SH SEE ALSO -.IR factotum (4), -.IR secstored (1) +.IM factotum (4) , +.IM secstored (1) .SH BUGS There is deliberately no backup of files on the secstore, so .B -r diff --git a/man/man1/secstored.1 b/man/man1/secstored.1 index 3eee78bef..d21ff5e59 100644 --- a/man/man1/secstored.1 +++ b/man/man1/secstored.1 @@ -18,7 +18,7 @@ username .PP .I Secstored serves requests from -.IR secstore (1). +.IM secstore (1) . The .B -R option supplements the password check with a @@ -61,4 +61,4 @@ for mapping local userid to RADIUS userid .SH SOURCE .B \*9/src/cmd/auth/secstore .SH SEE ALSO -.IR secstore (1) +.IM secstore (1) diff --git a/man/man1/sed.1 b/man/man1/sed.1 index 7f2b5f134..8df5285e1 100644 --- a/man/man1/sed.1 +++ b/man/man1/sed.1 @@ -78,7 +78,7 @@ that addresses the last line of input, or a context address, .BI / regular-expression / \f1, in the style of -.IR regexp (7), +.IM regexp (7) , with the added convention that .L \en matches a @@ -235,7 +235,7 @@ in the pattern space. Any character may be used instead of .LR / . For a fuller description see -.IR regexp (7). +.IM regexp (7) . .I Flags is zero or more of .RS @@ -374,8 +374,8 @@ formatted manuscript. .IR grep (1), .IR awk (1), .IR lex (1), -.IR sam (1), -.IR regexp (7) +.IM sam (1) , +.IM regexp (7) .br L. E. McMahon, `SED \(em A Non-interactive Text Editor', diff --git a/man/man1/seq.1 b/man/man1/seq.1 index 3f295c041..eea10dfaf 100644 --- a/man/man1/seq.1 +++ b/man/man1/seq.1 @@ -38,7 +38,7 @@ The options are .TP "\w'\fL-f \fIformat\fLXX'u" .BI -f format Use the -.IR print (3)-style +.IM print (3) -style .I format .IR print for printing each (floating point) number. diff --git a/man/man1/sftpcache.1 b/man/man1/sftpcache.1 index 28499b48d..aec061f4b 100644 --- a/man/man1/sftpcache.1 +++ b/man/man1/sftpcache.1 @@ -7,7 +7,7 @@ sftpcache \- cache sftp connections .SH DESCRIPTION .I Sftpcache multiplexes clients onto persistent -.IR sftp (1) +.IM sftp (1) connections. It runs .I sftp @@ -16,7 +16,7 @@ and posts a socket named .IB system .sftp in the name space directory (see -.IR intro (4)). +.IM intro (4) ). Clients can connect to the socket, one at a time, to interact with the .I sftp @@ -24,13 +24,13 @@ session. .PP .I Sftpcache is used by -.IR netfiles (1). +.IM netfiles (1) . .SH SOURCE .B \*9/src/cmd/sftpcache.c .SH SEE ALSO -.IR ssh (1), -.IR sftp (1), -.IR netfiles (1) +.IM ssh (1) , +.IM sftp (1) , +.IM netfiles (1) .SH BUGS .I Sftpcache only works with OpenSSH versions 4.3 and earlier; diff --git a/man/man1/sleep.1 b/man/man1/sleep.1 index 3eb617b46..a6a19a381 100644 --- a/man/man1/sleep.1 +++ b/man/man1/sleep.1 @@ -28,4 +28,4 @@ while (){ .SH SOURCE .B \*9/src/cmd/sleep.c .SH "SEE ALSO" -.IR sleep (3) +.IM sleep (3) diff --git a/man/man1/snarfer.1 b/man/man1/snarfer.1 index 54200b4b2..db8ce1987 100644 --- a/man/man1/snarfer.1 +++ b/man/man1/snarfer.1 @@ -13,30 +13,31 @@ Each time a program changes the snarf buffer contents, .I snarfer copies the new contents and then takes over control of the buffer. -Because the snarf buffer contents are managed by +Because the snarf buffer contents are managed by .I snarfer instead of by individual programs, the contents remain available even after the program that wrote them exits. .PP -The +The .B -v option, intended for debugging, causes .I snarfer to print the new snarf buffer contents each time it changes. .PP -On Mac OS X, +On Mac OS X, running .I snarfer keeps the X11 snarf buffer in sync with the Carbon snarf buffer, working around a bug in the OS X X11 server. See -.IR getsnarf (3) +.IM getsnarf (3) for more details. .SH SOURCE .B \*9/src/cmd/snarfer .SH SEE ALSO -Unix's \fIxclipboard\fR(1), -.IR getsnarf (3) +Unix's +.IR xclipboard (1), +.IM getsnarf (3) .SH BUGS Both .I xclipboard diff --git a/man/man1/soelim.1 b/man/man1/soelim.1 index 6378d4149..6b8f46527 100755 --- a/man/man1/soelim.1 +++ b/man/man1/soelim.1 @@ -11,19 +11,19 @@ soelim \- preprocess so inclusion commands in troff input .I Soelim reads the specified files or the standard input and performs the textual inclusion implied by -.IR troff (1) +.IM troff (1) directives of the form .TP .B "\&.so some_file .PP when they appear at the beginning of input lines. This is useful when using programs such as -.IR tbl (1) +.IM tbl (1) that do not normally do this, allowing placement of individual tables or other text objects in separate files to be run as a part of a large document. .SH SOURCE .B \*9/bin/soelim .SH "SEE ALSO" -.IR deroff (1), -.IR troff (1) +.IM deroff (1) , +.IM troff (1) diff --git a/man/man1/sort.1 b/man/man1/sort.1 index e68a53fcb..d732374c7 100644 --- a/man/man1/sort.1 +++ b/man/man1/sort.1 @@ -242,8 +242,8 @@ come out in their original order. .SH SOURCE .B \*9/src/cmd/sort.c .SH SEE ALSO -.IR uniq (1), -.IR look (1) +.IM uniq (1) , +.IM look (1) .SH DIAGNOSTICS .I Sort comments and exits with non-null status for various trouble diff --git a/man/man1/spell.1 b/man/man1/spell.1 index 5d27609bc..3e7388eb3 100644 --- a/man/man1/spell.1 +++ b/man/man1/spell.1 @@ -31,7 +31,7 @@ not sanctioned there\(emon the standard output. .PP .I Spell ignores constructs of -.IR troff (1) +.IM troff (1) and its standard preprocessors. It understands these options: .TP @@ -82,10 +82,10 @@ the script source for .I sprog .SH SEE ALSO -.IR deroff (1) +.IM deroff (1) .SH BUGS The heuristics of -.IR deroff (1) +.IM deroff (1) used to excise formatting information are imperfect. .PP The spelling list's coverage is uneven; diff --git a/man/man1/split.1 b/man/man1/split.1 index 9b2c976f9..440cf7eb7 100644 --- a/man/man1/split.1 +++ b/man/man1/split.1 @@ -41,7 +41,7 @@ File divisions occur at each line that matches a regular .IR expression ; see -.IR regexp (7). +.IM regexp (7) . Multiple .B -e options may appear. @@ -77,6 +77,6 @@ to lower case. .B \*9/src/cmd/split.c .SH SEE ALSO .IR sed (1), -.IR awk (1), -.IR grep (1), -.IR regexp (7) +.IM awk (1) , +.IM grep (1) , +.IM regexp (7) diff --git a/man/man1/src.1 b/man/man1/src.1 index 5f6a29cff..94f69b4f3 100644 --- a/man/man1/src.1 +++ b/man/man1/src.1 @@ -19,11 +19,11 @@ examines the named to find the corresponding source code, which is then sent to the editor using .B B (see -.IR sam (1)). +.IM sam (1) ). If .I file is an -.IR rc (1) +.IM rc (1) script, the source is the file itself. If .I file @@ -35,7 +35,7 @@ and will point the editor at the line that begins the definition. .I Src uses -.IR db (1) +.IM db (1) to extract the symbol table information that identifies the source. .PP .I Src @@ -78,6 +78,6 @@ src -s strcmp rc .SH SOURCE .B \*9/bin/src .SH "SEE ALSO" -.IR db (1), -.IR plumb (1), -.IR sam (1). +.IM db (1) , +.IM plumb (1) , +.IM sam (1) . diff --git a/man/man1/ssam.1 b/man/man1/ssam.1 index 6dbdc2364..17a105aa5 100755 --- a/man/man1/ssam.1 +++ b/man/man1/ssam.1 @@ -63,8 +63,8 @@ Count frequency of words read from standard input. .B \*9/bin/ssam .SH SEE ALSO .IR sed (1), -.IR sam (1), -.IR regexp (7) +.IM sam (1) , +.IM regexp (7) .PP Rob Pike, ``The text editor sam''. diff --git a/man/man1/ssh-agent.1 b/man/man1/ssh-agent.1 index 1617e17f6..2300ab9df 100644 --- a/man/man1/ssh-agent.1 +++ b/man/man1/ssh-agent.1 @@ -10,9 +10,9 @@ ssh-agent \- SSH authentication agent .SH DESCRIPTION .I Ssh-agent presents -.IR factotum (4) +.IM factotum (4) using the interface that -.IR ssh (1) +.IM ssh (1) requires. .PP Once @@ -33,7 +33,7 @@ via a Unix socket named .B ssh-agent.socket in the name space directory (see -.IR intro (4)). +.IM intro (4) ). Note that although the socket is posted in the name space directory, it is not for 9P conversations. .I Ssh @@ -81,10 +81,10 @@ Invoke this one with .B 9 .BR ssh-agent ; see -.IR 9 (1). +.IM 9 (1) . .SH EXAMPLES Assume -.IR factotum (4) +.IM factotum (4) is already running and initialized with keys. .PP Start a new agent, copying the commands by hand: @@ -103,7 +103,7 @@ $ .EE .PP Start the agent from -.IR sh (1): +.IM sh (1) : .IP .EX $ eval `9 ssh-agent -e` @@ -111,7 +111,7 @@ $ .EE .PP Start the agent from -.IR rc (1): +.IM rc (1) : .IP .EX % eval `{9 ssh-agent} @@ -128,9 +128,9 @@ tux% ^D .SH SOURCE .B \*9/src/cmd/auth/ssh-agent.c .SH SEE ALSO -.IR ssh (1), -.IR rsa (1), -.IR factotum (4) +.IM ssh (1) , +.IM rsa (1) , +.IM factotum (4) .SH BUGS A surprise rather than a bug: .I ssh-agent diff --git a/man/man1/strings.1 b/man/man1/strings.1 index d04dc41fe..c4d950ed6 100644 --- a/man/man1/strings.1 +++ b/man/man1/strings.1 @@ -25,4 +25,4 @@ line with the offset of the continuation line. .SH SOURCE .B \*9/src/cmd/strings.c .SH SEE ALSO -.IR nm (1) +.IM nm (1) diff --git a/man/man1/sum.1 b/man/man1/sum.1 index b95851db0..3d674cb31 100644 --- a/man/man1/sum.1 +++ b/man/man1/sum.1 @@ -73,5 +73,5 @@ summed. .br .B \*9/src/cmd/sha1sum.c .SH "SEE ALSO" -.IR cmp (1), -.IR wc (1) +.IM cmp (1) , +.IM wc (1) diff --git a/man/man1/tar.1 b/man/man1/tar.1 index 80e3f40b0..a7455fbe1 100644 --- a/man/man1/tar.1 +++ b/man/man1/tar.1 @@ -112,14 +112,14 @@ archive entries. .B z Operate on compressed tar archives. The type of compression is inferred from the file name extension: -.IR gzip (1) +.IM gzip (1) for .B .tar.gz and .BR .tgz ; .I bzip2 (see -.IR gzip (1)) +.IM gzip (1) ) for .BR .tar.bz , .BR .tbz , @@ -153,8 +153,8 @@ can be used to copy hierarchies thus: .SH SEE ALSO .I 9ar in -.IR 9c (1), -.IR bundle (1) +.IM 9c (1) , +.IM bundle (1) .SH BUGS There is no way to ask for any but the last occurrence of a file. diff --git a/man/man1/tbl.1 b/man/man1/tbl.1 index ce13a4a49..c727fb2bd 100644 --- a/man/man1/tbl.1 +++ b/man/man1/tbl.1 @@ -11,7 +11,7 @@ tbl \- format tables for nroff or troff is a preprocessor for formatting tables for .I nroff or -.IR troff (1). +.IM troff (1) . The input .I files are copied to the standard output, @@ -74,7 +74,7 @@ recognize and .I y as -.IR eqn (1) +.IM eqn (1) delimiters .PD .RE @@ -275,8 +275,8 @@ Bernardsville 2018 3.30 .B \*9/src/cmd/tbl .SH SEE ALSO .IR troff (1), -.IR eqn (1), -.IR doctype (1) +.IM eqn (1) , +.IM doctype (1) .br M. E. Lesk and L. L. Cherry, ``TBL\(ema Program to Format Tables'', diff --git a/man/man1/tcs.1 b/man/man1/tcs.1 index f23d1ceef..6e32b5f1d 100644 --- a/man/man1/tcs.1 +++ b/man/man1/tcs.1 @@ -36,7 +36,7 @@ is the .SM UTF encoding described in -.IR utf (7). +.IM utf (7) . The .B -l option lists the character sets known to @@ -164,4 +164,4 @@ Print an up to date list of the supported character sets. .SH SEE ALSO .IR ascii (1), .IR rune (3), -.IR utf (7). +.IM utf (7) . diff --git a/man/man1/test.1 b/man/man1/test.1 index 9957b29d7..3553804fd 100644 --- a/man/man1/test.1 +++ b/man/man1/test.1 @@ -182,7 +182,7 @@ and must be enclosed in quotes. .I Test is a dubious way to check for specific character strings: it uses a process to do what an -.IR rc (1) +.IM rc (1) match or switch statement can do. The first example is not only inefficient but wrong, because .I test diff --git a/man/man1/time.1 b/man/man1/time.1 index 57a0a5668..91e338319 100644 --- a/man/man1/time.1 +++ b/man/man1/time.1 @@ -18,4 +18,4 @@ followed by the command line. .SH SOURCE .B \*9/src/cmd/time.c .SH "SEE ALSO" -.IR prof (1) +.IM prof (1) diff --git a/man/man1/touch.1 b/man/man1/touch.1 index a02440d2c..086d4a828 100644 --- a/man/man1/touch.1 +++ b/man/man1/touch.1 @@ -27,9 +27,9 @@ is present. .SH SOURCE .B \*9/src/cmd/touch.c .SH SEE ALSO -.IR ls (1), -.IR stat (3), -.IR chmod (1) +.IM ls (1) , +.IM stat (3) , +.IM chmod (1) .SH BUGS .I Touch will not touch directories. diff --git a/man/man1/tr.1 b/man/man1/tr.1 index cef4a1775..3746e48eb 100644 --- a/man/man1/tr.1 +++ b/man/man1/tr.1 @@ -94,4 +94,4 @@ tr -cs A-Za-z ' .SH SOURCE .B \*9/src/cmd/tr.c .SH "SEE ALSO" -.IR sed (1) +.IM sed (1) diff --git a/man/man1/tr2post.1 b/man/man1/tr2post.1 index 3a54e4d22..4d047f4ff 100644 --- a/man/man1/tr2post.1 +++ b/man/man1/tr2post.1 @@ -15,7 +15,7 @@ converts .I files (or standard input), which should be the device-independent output of -.IR troff (1), +.IM troff (1) , into the PostScript printer language. .PP The options are: @@ -29,7 +29,8 @@ to stretch the PostScript output (default 1.0). Set a comment in the PostScript output marking the number of copies that should be printed. The comment is intended for ancient versions of the Unix -\fIlp\fR(1) and is not recognized by any current printer +.IR lp (1) +and is not recognized by any current printer or print spooler. .TP .BI -d @@ -46,11 +47,11 @@ logical pages per physical page Using this option emits PostScript with invalid document structuring comments. It will print fine but will not view correctly in -.IR gv (1) +.IM gv (1) or .I psv (see -.IR page (1)). +.IM page (1) ). .TP .BI -o " pagelist Print only the pages in the @@ -109,5 +110,5 @@ psv /tmp/a.ps .SH SOURCE .B \*9/src/cmd/postscript/tr2post .SH SEE ALSO -.IR troff (1), -.IR psfonts (1) +.IM troff (1) , +.IM psfonts (1) diff --git a/man/man1/troff.1 b/man/man1/troff.1 index 7af3f3c1c..acce30a73 100644 --- a/man/man1/troff.1 +++ b/man/man1/troff.1 @@ -176,18 +176,18 @@ font width tables for .SH SOURCE .B \*9/src/cmd/troff .SH "SEE ALSO" -.IR lpr (1), -.IR proof (1), -.IR tr2post (1), +.IM lpr (1) , +.IM proof (1) , +.IM tr2post (1) , .IR eqn (1), .IR tbl (1), .IR pic (1), -.IR grap (1), +.IM grap (1) , .IR doctype (1), -.IR ms (7), -.IR image (7), -.IR tex (1), -.IR deroff (1) +.IM ms (7) , +.IM image (7) , +.IM tex (1) , +.IM deroff (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual'' diff --git a/man/man1/troff2html.1 b/man/man1/troff2html.1 index a40e22f0e..98ea62a8f 100644 --- a/man/man1/troff2html.1 +++ b/man/man1/troff2html.1 @@ -13,7 +13,7 @@ troff2html \- convert troff output into HTML .SH DESCRIPTION .I Troff2html reads the -.IR troff (1) +.IM troff (1) output in the named .IR files , default standard input, @@ -25,12 +25,13 @@ does a tolerable job with straight output, but it is helped by annotations, described below. Its main use is for .B man2html -(see Plan 9's \fIhttpd\fR(8)), +(see Plan 9's +.IR httpd (8)), which converts -.IR man (1) +.IM man (1) pages into HTML and depends on a specially annotated set of -.IR man (7) +.IM man (7) macros, invoked by .B troff .BR -manhtml . @@ -57,25 +58,25 @@ x X html manref end cp 1 .EE .PP which are used to create HTML hyperlinks around text of the form -.IR cp (1) +.IM cp (1) pointing to .BR /magic/man2html/1/cp . .PP .I Troff2html is new and experimental; in time, it may improve and subsume Plan 9's -\fIms2html\fR(1). +.IR ms2html (1). On the one hand, because it uses the input, .B ms2html can handle -.IR pic (1), -.IR eqn (1), +.IM pic (1) , +.IM eqn (1) , etc., which .I troff2html does not handle at all; on the other hand, .B ms2html understands only -.IR ms (7) +.IM ms (7) documents and is easily confused by complex .B troff constructions. @@ -83,13 +84,13 @@ constructions. has the reverse properties: it does not handle the preprocessors but its output is reliable and (modulo helper annotations) is independent of macro package. .SH SEE ALSO -.IR troff (1), +.IM troff (1) , Plan 9's -\fIms2html\fR(1), +.IR ms2html (1), .I man2html in Plan 9's -\fIhttpd\fR(8). +.IR httpd (8). .SH BUGS .B Troff and HTML have different models, and they don't mesh well in all cases. diff --git a/man/man1/tweak.1 b/man/man1/tweak.1 index ac52a9b59..09b96af37 100644 --- a/man/man1/tweak.1 +++ b/man/man1/tweak.1 @@ -35,14 +35,14 @@ If the file is a subfont, a second line presents a hexadecimal 16-bit .B offset to be applied to character values from the subfont (typically as stored in a font file; see -.IR font (7)); +.IM font (7) ); and the subfont's .BR n , .BR height , and .B ascent as defined in -.IR cachechars (3). +.IM cachechars (3) . .PP By means described below, magnified views of portions of the images may be displayed. @@ -61,7 +61,7 @@ default font; the character's and .BR width as defined in -.IR cachechars (3); +.IM cachechars (3) ; and .BR iwidth , the physical width of the image in the subfont's image. @@ -158,9 +158,9 @@ The program will complain once about modified but unwritten files. .SH SOURCE .B \*9/src/cmd/draw/tweak.c .SH "SEE ALSO" -.IR cachechars (3), -.IR image (7), -.IR font (7) +.IM cachechars (3) , +.IM image (7) , +.IM font (7) .SH BUGS For a program written to adjust width tables in fonts, .I tweak diff --git a/man/man1/uniq.1 b/man/man1/uniq.1 index ae17f0955..98e2cc7bb 100644 --- a/man/man1/uniq.1 +++ b/man/man1/uniq.1 @@ -56,4 +56,4 @@ Fields are skipped before characters. .IR sort (1) .SH BUGS Field selection and comparison should be compatible with -.IR sort (1). +.IM sort (1) . diff --git a/man/man1/vac.1 b/man/man1/vac.1 index 39f7c00ff..489e677f2 100644 --- a/man/man1/vac.1 +++ b/man/man1/vac.1 @@ -53,7 +53,7 @@ is used on a file tree that shares data with an existing archive, the consumptio storage will be approximately equal to an incremental backup. This reduction in storage consumption occurs transparently to the user. .PP -As an optimization, the +As an optimization, the .B -d and .B -q @@ -78,7 +78,8 @@ the files under an extra two levels of directory hierarchy named .I yyyy/mmdd (year, month, day) in the style of the dump file system -(see Plan 9's \fIfs\fR(4)). +(see Plan 9's +.IR fs (4)). If .I vacfile already exists, an additional backup day is added to the @@ -89,7 +90,7 @@ Typically, this option is used as part of a nightly backup script. This option cannot be used with .B -d -or +or .BR -f . .TP .BI -b " blocksize @@ -114,13 +115,13 @@ Do not include the file or directory specified by This option may be repeated multiple times. .I Exclude can be a shell pattern as accepted by -.IR rc (1), -with one extension: +.IM rc (1) , +with one extension: .B \&... matches any sequence of characters including slashes. .TP .BI -f " vacfile -The results of +The results of .I vac are placed in .IR vacfile , @@ -136,7 +137,7 @@ The network address of the Venti server. The default is taken from the environment variable .BR venti . .\" If this variable does not exist, then the default is the -.\" metaname +.\" metaname .\" .BR $venti , .\" which can be configured via .\" .IR ndb (6). @@ -155,7 +156,7 @@ the archive to be unpacked. .TP .B -q Increase the performance of the -.B -a +.B -a or .B -d options by detecting unchanged files based on a match of the files name and other meta data, @@ -169,9 +170,9 @@ Produce more verbose output on standard error, including the name of the files a and the vac archives that are expanded and merged. .TP .BI -x " excfile -Read exclude patterns from the file +Read exclude patterns from the file .IR excfile . -Blank lines and lines beginning with +Blank lines and lines beginning with .B # are ignored. All other lines should be of the form @@ -224,5 +225,5 @@ If listing files, print metadata in addition to the names. .SH SOURCE .B \*9/src/cmd/vac .SH "SEE ALSO" -.IR vacfs (4), -.IR venti (8) +.IM vacfs (4) , +.IM venti (8) diff --git a/man/man1/venti.1 b/man/man1/venti.1 index e14052aa7..6231e40ba 100644 --- a/man/man1/venti.1 +++ b/man/man1/venti.1 @@ -40,7 +40,7 @@ read, write, copy \- simple Venti clients .SH DESCRIPTION Venti is a SHA1-addressed block storage server. See -.IR venti (7) +.IM venti (7) for a full introduction. .PP .I Read @@ -167,13 +167,13 @@ messages send/received. .SH SOURCE .B \*9/src/cmd/venti .SH SEE ALSO -.IR vac (1), -.IR venti (3), -.IR vacfs (4), -.IR venti (7), -.IR vbackup (8), -.IR venti (8), -.IR venti-fmt (8) +.IM vac (1) , +.IM venti (3) , +.IM vacfs (4) , +.IM venti (7) , +.IM vbackup (8) , +.IM venti (8) , +.IM venti-fmt (8) .SH BUGS There should be programs to read and write venti files and directories. diff --git a/man/man1/web.1 b/man/man1/web.1 index 06d304df1..1abdcc009 100644 --- a/man/man1/web.1 +++ b/man/man1/web.1 @@ -81,7 +81,7 @@ URL passed to and .I wmail are invoked as start commands in the -.IR plumber (4)'s +.IM plumber (4) 's rules for opening web pages and writing mail messages. .SH FILES .TP @@ -93,4 +93,4 @@ and .SH SOURCE .B \*9/bin .SH SEE ALSO -.IR plumber (4) +.IM plumber (4) diff --git a/man/man1/wintext.1 b/man/man1/wintext.1 index 966b307b4..269db2e0e 100644 --- a/man/man1/wintext.1 +++ b/man/man1/wintext.1 @@ -22,11 +22,11 @@ wintext, ", "" \- access text in current window prints the text of the current .I win (see -.IR acme (1)), -.IR 9term (1), +.IM acme (1) ), +.IM 9term (1) , or (Unix's) -.IR tmux (1) +.IM tmux (1) window to standard output. .PP .I \*y @@ -43,7 +43,7 @@ prints the last command executed. prints the last command that .I \*y would print and then executes it by piping it into -.IR rc (1). +.IM rc (1) . .PP Both .I \*y @@ -61,7 +61,7 @@ or .BR # . .SH EXAMPLES Print the -.IR ls (1) +.IM ls (1) and .I lc commands executed in this window: @@ -87,8 +87,8 @@ ramfs rc read rio rm % .EE .SH SEE ALSO -.IR 9term (1), -.IR acme (1) +.IM 9term (1) , +.IM acme (1) .SH SOURCE .B \*9/bin .SH BUGS @@ -96,5 +96,5 @@ ramfs rc read rio rm and .I \*(yy are hard to type in shells other than -.IR rc (1). +.IM rc (1) . .\" and in troff! diff --git a/man/man1/winwatch.1 b/man/man1/winwatch.1 index afbf541da..fc4afbacf 100644 --- a/man/man1/winwatch.1 +++ b/man/man1/winwatch.1 @@ -17,7 +17,7 @@ winwatch \- monitor rio windows .SH DESCRIPTION .I Winwatch displays the labels of all current -.IR rio (1) +.IM rio (1) windows, refreshing the display every second. Right clicking a window's label unhides, raises and gives focus to that window. Typing @@ -53,5 +53,5 @@ Excluding winwatch and stats from being shown. .SH SOURCE .B \*9/src/cmd/winwatch.c .SH SEE ALSO -.IR rio (1), -.IR regexp (7). +.IM rio (1) , +.IM regexp (7) . diff --git a/man/man1/xd.1 b/man/man1/xd.1 index 5ec167bdc..d291210b4 100644 --- a/man/man1/xd.1 +++ b/man/man1/xd.1 @@ -91,7 +91,7 @@ followed by an asterisk. .SH SOURCE .B \*9/src/cmd/xd.c .SH "SEE ALSO" -.IR db (1) +.IM db (1) .SH BUGS The various output formats don't line up properly in the output of .IR xd . diff --git a/man/man1/yacc.1 b/man/man1/yacc.1 index cbd1eb73a..3fbd47c2d 100644 --- a/man/man1/yacc.1 +++ b/man/man1/yacc.1 @@ -23,7 +23,7 @@ to produce a program This program must be loaded with a lexical analyzer function, .B yylex(void) (often generated by -.IR lex (1)), +.IM lex (1) ), with a .B main(int argc, char *argv[]) program, and with an error handling routine, @@ -115,7 +115,7 @@ option reverses this. The parser accepts .SM UTF input text (see -.IR utf (7)), +.IM utf (7) ), which has a couple of effects. First, the return value of .B yylex() @@ -156,7 +156,7 @@ parser prototype using stdio .SH SOURCE .B \*9/src/cmd/yacc.c .SH "SEE ALSO" -.IR lex (1) +.IM lex (1) .br S. C. Johnson and R. Sethi, ``Yacc: A parser generator'', diff --git a/man/man1/yesterday.1 b/man/man1/yesterday.1 index 665c7b221..f18cf3756 100644 --- a/man/man1/yesterday.1 +++ b/man/man1/yesterday.1 @@ -91,8 +91,8 @@ by convention, root of the dump file system .SH SOURCE .B \*9/bin/yesterday .SH SEE ALSO -.IR diff (1), -.IR hist (1), -.IR vbackup (8) +.IM diff (1) , +.IM hist (1) , +.IM vbackup (8) .SH BUGS It's hard to use this command without singing. diff --git a/man/man3/0intro.3 b/man/man3/0intro.3 index e544cc8d8..0fe209c68 100644 --- a/man/man3/0intro.3 +++ b/man/man3/0intro.3 @@ -49,7 +49,7 @@ automatically, so it is rarely necessary to tell the loader which libraries a program needs; see -.IR 9c (1). +.IM 9c (1) . .PP The library to which a function belongs is defined by the header file that defines its interface. @@ -121,7 +121,7 @@ and plus macros that define the layout of .IR jmp_buf (see -.IR setjmp (3)); +.IM setjmp (3) ); .\" definitions of the bits in the floating-point control register .\" as used by .\" .IR getfcr (2); @@ -198,27 +198,27 @@ by or .I create (see -.IR open (3)). +.IM open (3) ). These calls return an integer called a .IR "file descriptor" which identifies the file to subsequent I/O calls, notably -.IR read (3) +.IM read (3) and .IR write . The system allocates the numbers by selecting the lowest unused descriptor. They are allocated dynamically; there is no visible limit to the number of file descriptors a process may have open. They may be reassigned using -.IR dup (3). +.IM dup (3) . File descriptors are indices into a kernel resident .IR "file descriptor table" . Each process has an associated file descriptor table. In threaded programs (see -.IR thread (3)), +.IM thread (3) ), the file descriptor table is shared by all the procs. .PP By convention, @@ -236,22 +236,22 @@ Files are normally read or written in sequential order. The I/O position in the file is called the .IR "file offset" and may be set arbitrarily using the -.IR seek (3) +.IM seek (3) system call. .PP Directories may be opened like regular files. Instead of reading them with -.IR read (3), +.IM read (3) , use the .B Dir structure-based routines described in -.IR dirread (3). +.IM dirread (3) . The entry corresponding to an arbitrary file can be retrieved by .IR dirstat (see -.IR stat (3)) +.IM stat (3) ) or .IR dirfstat ; .I dirwstat @@ -262,9 +262,9 @@ write back entries, thus changing the properties of a file. New files are made with .I create (see -.IR open (3)) +.IM open (3) ) and deleted with -.IR remove (3). +.IM remove (3) . Directories may not directly be written; .IR create , .IR remove , @@ -273,27 +273,27 @@ and .I fwstat alter them. .PP -.IR Pipe (3) +.IM Pipe (3) creates a connected pair of file descriptors, useful for bidirectional local communication. .SS "Process execution and control" A new process is created when an existing one calls -.IR fork (2). +.IM fork (2) . The new (child) process starts out with copies of the address space and most other attributes of the old (parent) process. In particular, the child starts out running the same program as the parent; -.IR exec (3) +.IM exec (3) will bring in a different one. .PP Each process has a unique integer process id; a set of open files, indexed by file descriptor; and a current working directory (changed by -.IR chdir (2)). +.IM chdir (2) ). .PP Each process has a set of attributes \(em memory, open files, name space, etc. \(em that may be shared or unique. @@ -302,9 +302,9 @@ Flags to control the sharing of these attributes. .PP A process terminates by calling -.IR exits (3). +.IM exits (3) . A parent process may call -.IR wait (3) +.IM wait (3) to wait for some child to terminate. A bit of status information may be passed from @@ -317,14 +317,14 @@ The Plan 9 interface persists here, although the functionality does not. Instead, empty strings are converted to exit status 0 and non-empty strings to 1. .PP A process can go to sleep for a specified time by calling -.IR sleep (3). +.IM sleep (3) . .PP There is a .I notification mechanism for telling a process about events such as address faults, floating point faults, and messages from other processes. A process uses -.IR notify (3) +.IM notify (3) to register the function to be called (the .IR "notification handler" ) when such events occur. @@ -334,12 +334,12 @@ the main C library works properly in multiprocess programs; .IR malloc , .IR print , and the other routines use locks (see -.IR lock (3)) +.IM lock (3) ) to synchronize access to their data structures. The graphics library defined in .B is also multi-process capable; details are in -.IR graphics (3). +.IM graphics (3) . In general, though, multiprocess programs should use some form of synchronization to protect shared data. .PP @@ -365,12 +365,12 @@ Therefore, a program that shouldn't block unexpectedly will use a process to serve the I/O request, passing the result to the main processes over a channel when the request completes. For examples of this design, see -.IR ioproc (3) +.IM ioproc (3) or -.IR mouse (3). +.IM mouse (3) . .SH SEE ALSO .IR nm (1), -.IR 9c (1) +.IM 9c (1) .SH DIAGNOSTICS Math functions in .I libc @@ -378,14 +378,14 @@ return special values when the function is undefined for the given arguments or when the value is not representable (see -.IR nan (3)). +.IM nan (3) ). .PP Some of the functions in .I libc are system calls and many others employ system calls in their implementation. All system calls return integers, with \-1 indicating that an error occurred; -.IR errstr (3) +.IM errstr (3) recovers a string describing the error. Some user-level library functions also use the .I errstr diff --git a/man/man3/9p-cmdbuf.3 b/man/man3/9p-cmdbuf.3 index 6aca825bb..804f6332c 100644 --- a/man/man3/9p-cmdbuf.3 +++ b/man/man3/9p-cmdbuf.3 @@ -44,7 +44,7 @@ bytes at using .I tokenize (see -.IR getfields (3)). +.IM getfields (3) ). It returns a .B Cmdbuf structure holding pointers to each field in the message. @@ -116,4 +116,4 @@ is a good example. .SH SOURCE .B \*9/src/lib9p/parse.c .SH SEE ALSO -.IR 9p (3) +.IM 9p (3) diff --git a/man/man3/9p-fid.3 b/man/man3/9p-fid.3 index ddc3e093c..b87ea2538 100644 --- a/man/man3/9p-fid.3 +++ b/man/man3/9p-fid.3 @@ -73,7 +73,7 @@ and .BR Reqpool s. They are primarily used by the 9P server loop described in -.IR 9p (3). +.IM 9p (3) . .PP .B Fid structures are intended to represent @@ -115,7 +115,7 @@ element points at a .B File structure (see -.IR 9p-file (3)) +.IM 9p-file (3) ) corresponding to the fid. The .B aux @@ -200,5 +200,5 @@ structures. .SH SOURCE .B \*9/src/lib9p .SH SEE ALSO -.IR 9p (3), -.IR 9p-file (3) +.IM 9p (3) , +.IM 9p-file (3) diff --git a/man/man3/9p-file.3 b/man/man3/9p-file.3 index 80866177d..52c19bfdf 100644 --- a/man/man3/9p-file.3 +++ b/man/man3/9p-file.3 @@ -144,7 +144,7 @@ When creating new file references by copying pointers, call .I incref (see -.IR lock (3)) +.IM lock (3) ) to update the reference count. To note the removal of a reference to a file, call .IR closefile . @@ -218,6 +218,6 @@ return nf; .SH SOURCE .B \*9/src/lib9p/file.c .SH SEE ALSO -.IR 9p (3) +.IM 9p (3) .SH BUGS The reference counting is cumbersome. diff --git a/man/man3/9p-intmap.3 b/man/man3/9p-intmap.3 index 9d4dfef0b..7e7db303f 100644 --- a/man/man3/9p-intmap.3 +++ b/man/man3/9p-intmap.3 @@ -122,5 +122,5 @@ and .SH SOURCE .B \*9/src/lib9p/intmap.c .SH SEE ALSO -.IR 9p (3), -.IR 9p-fid (3) +.IM 9p (3) , +.IM 9p-fid (3) diff --git a/man/man3/9p.3 b/man/man3/9p.3 index 6dc4c9c17..eac5a3d60 100644 --- a/man/man3/9p.3 +++ b/man/man3/9p.3 @@ -110,13 +110,13 @@ and .B Fid structures are allocated one-to-one with uncompleted requests and active fids, and are described in -.IR 9p-fid (3). +.IM 9p-fid (3) . .PP The behavior of .I srv depends on whether there is a file tree (see -.IR 9p-file (3)) +.IM 9p-file (3) ) associated with the server, that is, whether the .B tree @@ -178,11 +178,11 @@ as .BI /srv/ name . .IP Fork a child process via -.IR rfork (3) +.IM rfork (3) or .I procrfork (see -.IR thread (3)), +.IM thread (3) ), using the .BR RFFDG , .RR RFNOTEG , @@ -214,7 +214,7 @@ The parent returns to the caller. .LP If any error occurs during this process, the entire process is terminated by calling -.IR sysfatal (3). +.IM sysfatal (3) . .SS Service functions The functions in a .B Srv @@ -332,7 +332,7 @@ where is the program name variable as set by .I ARGBEGIN (see -.IR arg (3)). +.IM arg (3) ). .TP .I Attach The @@ -707,7 +707,7 @@ the service loop (which runs in a separate process from its caller) terminates using .I _exits (see -.IR exits (3)). +.IM exits (3) ). .PD .PP If the @@ -752,6 +752,6 @@ or is maintained elsewhere. .SH SOURCE .B \*9/src/lib9p .SH SEE ALSO -.IR 9p-fid (3), -.IR 9p-file (3), +.IM 9p-fid (3) , +.IM 9p-file (3) , .IR intro (9p) diff --git a/man/man3/9pclient.3 b/man/man3/9pclient.3 index 1bb868cce..a4c80d8be 100644 --- a/man/man3/9pclient.3 +++ b/man/man3/9pclient.3 @@ -149,7 +149,7 @@ connects to a service named .I name in the current name space directory (see -.IR intro (4)). +.IM intro (4) ). Both attach to the root of the file system using the attach name .IR aname . @@ -228,7 +228,7 @@ the allocated structures will be freed and the file descriptor corresponding to the connection will be closed (see -.IR close (2)). +.IM close (2) ). Fids are not reference counted: when .I fsclose is called, the clunk transaction and freeing of storage @@ -308,7 +308,7 @@ sets the offset; the and .I type arguments are used as in -.IR seek (3). +.IM seek (3) . Calling .I fspread or @@ -340,7 +340,7 @@ for the given fid. .PP .I Fsaccess behaves like Unix's -.IR access (2). +.IM access (2) . .I Fsremove removes the named path. .I Fsfremove @@ -358,7 +358,7 @@ are like and .I vfprint (see -.IR print (3)) +.IM print (3) ) but write to .BR CFid* s. .PP @@ -376,7 +376,7 @@ is similar but reads the entire directory. The returned pointer should be freed with .I free (see -.IR malloc (3)) +.IM malloc (3) ) when no longer needed. .PP .I Fsdirfstat @@ -396,7 +396,7 @@ structure returned by should be freed with .I free (see -.IR malloc (3)) +.IM malloc (3) ) when no longer needed. .PP .I Fsdirstat @@ -418,7 +418,7 @@ opens a file on the 9P server for reading or writing but returns a Unix file descriptor instead of a fid structure. The file descriptor is actually one end of a -.IR pipe (2). +.IM pipe (2) . A proxy process on the other end is ferrying data between the pipe and the 9P fid. Because of the implementation as a pipe, @@ -443,18 +443,18 @@ If the flag is set, the library calls .I threadexitsall (see -.IR thread (3)) +.IM thread (3) ) when it detects EOF on a 9P connection. .SH SOURCE .B \*9/src/lib9pclient .SH SEE ALSO -.IR intro (4), +.IM intro (4) , .IR intro (9p), .I fsaopen and .I nsaopen in -.IR auth (3) +.IM auth (3) .SH BUGS The implementation should use a special version string to distinguish between diff --git a/man/man3/acme.3 b/man/man3/acme.3 index 1683061a1..d2f116ae6 100644 --- a/man/man3/acme.3 +++ b/man/man3/acme.3 @@ -141,7 +141,7 @@ char* evsmprint(char *fmt, va_list arg) .SH DESCRIPTION .I Libacme provides a simple C interface for interacting with -.IR acme (1) +.IM acme (1) windows. .PP A @@ -168,7 +168,7 @@ Most of the library routines access files in the window's .I acme directory. See -.IR acme (4) +.IM acme (4) for details. Many library routines take a format string .I fmt @@ -179,11 +179,11 @@ denotes the result of formatting the string and arguments using .I smprint (see -.IR print (3)). +.IM print (3) ). .PP .I Pipetowin runs the -.IR rc (1) +.IM rc (1) command line .I fmt\fR, \fP... with @@ -199,7 +199,7 @@ Otherwise the command inherits the caller's standard error. .PP .I Pipewinto runs the -.IR rc (1) +.IM rc (1) command line .I fmt\fR, \fP... with the window's @@ -300,7 +300,7 @@ to position relative to .I type (see -.IR seek (3)). +.IM seek (3) ). .PP .I Winwrite writes the @@ -317,7 +317,7 @@ The fields correspond to the fields in .IR acme 's event messages. See -.IR acme (4) +.IM acme (4) for detailed explanations. The fields are: .TP @@ -384,7 +384,7 @@ that it should be handled internally. returns a pointer to a .B Channel (see -.IR thread (3)) +.IM thread (3) ) on which event structures (not pointers) can be read. The first call to .I wineventchan @@ -404,20 +404,20 @@ after calling and .I evsmprint are like -.IR malloc (3), +.IM malloc (3) , .IR realloc , .IR strdup (see -.IR strcat (3)), +.IM strcat (3) ), and .IR vsmprint (see -.IR print (3)), +.IM print (3) ), but they call -.IR sysfatal (3) +.IM sysfatal (3) on error rather than returning nil. .SH SOURCE .B \*9/src/libacme .SH SEE ALSO -.IR acme (1), -.IR acme (4) +.IM acme (1) , +.IM acme (4) diff --git a/man/man3/addpt.3 b/man/man3/addpt.3 index c00a1de1c..5a22abeb3 100644 --- a/man/man3/addpt.3 +++ b/man/man3/addpt.3 @@ -185,4 +185,4 @@ They are implemented as macros. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3) +.IM graphics (3) diff --git a/man/man3/aes.3 b/man/man3/aes.3 index 06f42de54..c9c74155b 100644 --- a/man/man3/aes.3 +++ b/man/man3/aes.3 @@ -39,13 +39,13 @@ cryptographically strongly unpredictable. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR blowfish (3), -.IR des (3), -.IR dsa (3), -.IR elgamal (3), -.IR rc4 (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM blowfish (3) , +.IM des (3) , +.IM dsa (3) , +.IM elgamal (3) , +.IM rc4 (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/allocimage.3 b/man/man3/allocimage.3 index 8bfd323dc..72ee805e6 100644 --- a/man/man3/allocimage.3 +++ b/man/man3/allocimage.3 @@ -135,7 +135,7 @@ The field will have been set to the identifying number used by .B /dev/draw (see -.IR draw (3)), +.IM draw (3) ), and the .I cache field will be zero. @@ -148,7 +148,7 @@ The field will be set to the number of bits per pixel specified by the channel descriptor (see -.IR image (7)). +.IM image (7) ). .I Allocimage returns 0 if the server has run out of image memory. .PP @@ -191,7 +191,7 @@ These routines permit unrelated applications sharing a display to share an image for example they provide the mechanism behind .B getwindow (see -.IR graphics (3)). +.IM graphics (3) ). .PP The RGB values in a color are .I premultiplied @@ -214,7 +214,7 @@ values between image and user space or external files. There is a fixed format for the exchange and storage of image data (see -.IR image (7)). +.IM image (7) ). .PP .I Unloadimage reads a rectangle of pixels from image @@ -271,7 +271,7 @@ but for bytes of compressed image .I data (see -.IR image (7)). +.IM image (7) ). On each call to .IR cloadimage, the @@ -289,7 +289,7 @@ return the number of bytes copied. .PP .I Readimage creates an image from data contained in an external file (see -.IR image (7) +.IM image (7) for the file format); .I fd is a file descriptor obtained by opening such a file for reading. @@ -333,10 +333,10 @@ To allocate a single-pixel replicated image that may be used to paint a region r .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IR graphics (3), -.IR draw (3), -.IR draw (3), -.IR image (7) +.IM graphics (3) , +.IM draw (3) , +.IM draw (3) , +.IM image (7) .SH DIAGNOSTICS These functions return pointer 0 or integer \-1 on failure, usually due to insufficient memory. diff --git a/man/man3/arg.3 b/man/man3/arg.3 index 3124930dc..1d6dbab15 100644 --- a/man/man3/arg.3 +++ b/man/man3/arg.3 @@ -20,7 +20,7 @@ These macros assume the names and .I argv are in scope; see -.IR exec (3). +.IM exec (3) . .I ARGBEGIN and .I ARGEND @@ -58,7 +58,7 @@ but instead of returning zero runs .I code and, if that returns, calls -.IR abort (3). +.IM abort (3) . A typical value for .I code is diff --git a/man/man3/arith3.3 b/man/man3/arith3.3 index 1e764c7b9..198cce35f 100644 --- a/man/man3/arith3.3 +++ b/man/man3/arith3.3 @@ -266,4 +266,4 @@ Subtract the coordinates of two points. .SH SOURCE .B \*9/src/libgeometry .SH "SEE ALSO -.IR matrix (3) +.IM matrix (3) diff --git a/man/man3/atof.3 b/man/man3/atof.3 index 0da223796..ce2ca723e 100644 --- a/man/man3/atof.3 +++ b/man/man3/atof.3 @@ -129,7 +129,7 @@ after calling .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IR fscanf (3) +.IM fscanf (3) .SH DIAGNOSTICS Zero is returned if the beginning of the input string is not interpretable as a number; even in this case, @@ -175,4 +175,4 @@ are preprocessor macros defined as and .IR p9atoll ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/auth.3 b/man/man3/auth.3 index 24189822e..747b9555d 100644 --- a/man/man3/auth.3 +++ b/man/man3/auth.3 @@ -95,7 +95,7 @@ CFsys* nsamount(char *name, char *aname); .SH DESCRIPTION .PP This library, in concert with -.IR factotum (4), +.IM factotum (4) , is used to authenticate users. It provides the primary interface to .IR factotum . @@ -168,7 +168,7 @@ It provides the primary interface to The following routines use the .B AuthInfo structure returned after a successful authentication by -.IR factotum (4). +.IM factotum (4) . .PP .ne 8 .EX @@ -212,11 +212,11 @@ file, as opened by An .B sprint (see -.IR print (3)) +.IM print (3) ) of .I fmt and the variable arg list yields a key template (see -.IR factotum (4)) +.IM factotum (4) ) specifying the key to use. The template must specify at least the protocol ( .BI proto= xxx ) @@ -258,7 +258,7 @@ arranges a connection to either by opening .B /mnt/factotum/rpc or by using -.IR 9pclient (3) +.IM 9pclient (3) to connect to a .B factotum service posted in the current name space. @@ -266,7 +266,7 @@ The returned connection is freed using .IR auth_freerpc . Individual commands can be sent to -.IR factotum (4) +.IM factotum (4) by invoking .IR auth_rpc . .PP @@ -418,7 +418,7 @@ and but execute the protocol on a .B CFid* (see -.IR 9pclient (3)) +.IM 9pclient (3) ) instead of a file descriptor. .PP .I Fsamount @@ -429,15 +429,15 @@ are like and .I nsmount (see -.IR 9pclient (3)) +.IM 9pclient (3) ) but use .I factotum to authenticate to the file servers. .SH SOURCE .B \*9/src/libauth .SH SEE ALSO -.IR factotum (4), -.IR authsrv (3) +.IM factotum (4) , +.IM authsrv (3) .SH DIAGNOSTICS These routines set .IR errstr . diff --git a/man/man3/authsrv.3 b/man/man3/authsrv.3 index a0b68578e..2b2113bc2 100644 --- a/man/man3/authsrv.3 +++ b/man/man3/authsrv.3 @@ -68,7 +68,7 @@ If is non-nil, the network database (see -.IR ndb (1)) +.IM ndb (1) ) is queried for an entry which contains .B authdom=\fIad\fP or @@ -212,10 +212,10 @@ to recieve an answer. .SH SOURCE .B \*9/src/libauthsrv .SH SEE ALSO -.IR passwd (1), -.IR dial (3), +.IM passwd (1) , +.IM dial (3) , Plan 9's -\fIauthsrv\fR(6). +.IR authsrv (6). .SH DIAGNOSTICS These routines set .IR errstr . diff --git a/man/man3/bin.3 b/man/man3/bin.3 index c888193f8..3ab9ba90c 100644 --- a/man/man3/bin.3 +++ b/man/man3/bin.3 @@ -82,7 +82,7 @@ are ignored, and the result is the same as calling and .I bingrow allocate large chunks of memory using -.IR malloc (3) +.IM malloc (3) and return pieces of these chunks. The chunks are .IR free 'd @@ -91,7 +91,7 @@ upon a call to .SH SOURCE .B \*9/src/libbin .SH SEE ALSO -.IR malloc (3) +.IM malloc (3) .SH DIAGNOSTICS .I binalloc and diff --git a/man/man3/bio.3 b/man/man3/bio.3 index 0c48bea6e..1f7b82212 100644 --- a/man/man3/bio.3 +++ b/man/man3/bio.3 @@ -93,7 +93,7 @@ for mode or creates for mode .BR OWRITE . It calls -.IR malloc (3) +.IM malloc (3) to allocate a buffer. .PP .I Bfdopen @@ -104,7 +104,7 @@ for mode or .BR OWRITE . It calls -.IR malloc (3) +.IM malloc (3) to allocate a buffer. .PP .I Binit @@ -173,7 +173,7 @@ of the most recent string returned by .PP .I Brdstr returns a -.IR malloc (3)-allocated +.IM malloc (3) -allocated buffer containing the next line of input delimited by .IR delim , terminated by a NUL (0) byte. @@ -225,7 +225,7 @@ may back up a maximum of five bytes. uses .I charstod (see -.IR atof (3)) +.IM atof (3) ) and .I Bgetc to read the formatted @@ -246,7 +246,7 @@ and a negative value is returned if a read error occurred. .PP .I Bseek applies -.IR seek (3) +.IM seek (3) to .IR bp . It returns the new file offset. @@ -278,7 +278,7 @@ on the output stream. .PP .I Bprint is a buffered interface to -.IR print (3). +.IM print (3) . If this causes a .IR write to occur and there is an error, @@ -325,10 +325,10 @@ written. .SH SOURCE .B \*9/src/libbio .SH SEE ALSO -.IR open (3), -.IR print (3), -.IR exits (3), -.IR utf (7), +.IM open (3) , +.IM print (3) , +.IM exits (3) , +.IM utf (7) , .SH DIAGNOSTICS .I Bio routines that return integers yield diff --git a/man/man3/blowfish.3 b/man/man3/blowfish.3 index 20d43f662..2ae83f4d3 100644 --- a/man/man3/blowfish.3 +++ b/man/man3/blowfish.3 @@ -40,13 +40,13 @@ must be a multiple of eight bytes as padding is currently unsupported. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR des (3), -.IR dsa (3), -.IR elgamal (3), -.IR rc4 (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM des (3) , +.IM dsa (3) , +.IM elgamal (3) , +.IM rc4 (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/cachechars.3 b/man/man3/cachechars.3 index f2d82f190..95b172e92 100644 --- a/man/man3/cachechars.3 +++ b/man/man3/cachechars.3 @@ -30,7 +30,7 @@ A may contain too many characters to hold in memory simultaneously. The graphics library and draw device (see -.IR draw (3)) +.IM draw (3) ) cooperate to solve this problem by maintaining a cache of recently used character images. The details of this cooperation need not be known by most programs: @@ -127,7 +127,7 @@ A .B Font consists of an overall height and ascent and a collection of subfonts together with the ranges of runes (see -.IR utf (7)) +.IM utf (7) ) they represent. Fonts are described by the following structures. .IP @@ -181,7 +181,7 @@ The and .LR ascent fields of Font are described in -.IR graphics (3). +.IM graphics (3) . .L Sub contains .L nsub @@ -302,12 +302,12 @@ for replacement when the cache is full. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR allocimage (3), -.IR draw (3), -.IR subfont (3), -.IR image (7), -.IR font (7) +.IM graphics (3) , +.IM allocimage (3) , +.IM draw (3) , +.IM subfont (3) , +.IM image (7) , +.IM font (7) .SH DIAGNOSTICS All of the functions use the graphics error function (see -.IR graphics (3)). +.IM graphics (3) ). diff --git a/man/man3/cleanname.3 b/man/man3/cleanname.3 index efb7d8231..8486cd90f 100644 --- a/man/man3/cleanname.3 +++ b/man/man3/cleanname.3 @@ -31,4 +31,4 @@ must contain room for at least two bytes. .SH SOURCE .B \*9/src/lib9/cleanname.c .SH SEE ALSO -.IR cleanname (1) +.IM cleanname (1) diff --git a/man/man3/color.3 b/man/man3/color.3 index 5428337b3..0c1b88213 100644 --- a/man/man3/color.3 +++ b/man/man3/color.3 @@ -19,7 +19,7 @@ int cmap2rgba(int col) .SH DESCRIPTION These routines convert between `true color' red/green/blue triples and the Plan 9 color map. See -.IR color (7) +.IM color (7) for a description of RGBV, the standard color map. .PP .I Rgb2cmap @@ -41,16 +41,16 @@ and the next 8 representing blue, then green, then red, as for .I cmap2rgba shifted up 8 bits. This 32-bit representation is the format used by -.IR draw (3) +.IM draw (3) and -.IR memdraw (3) +.IM memdraw (3) library routines that take colors as arguments. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR allocimage (3), -.IR draw (3), -.IR image (7), -.IR color (7) +.IM graphics (3) , +.IM allocimage (3) , +.IM draw (3) , +.IM image (7) , +.IM color (7) diff --git a/man/man3/complete.3 b/man/man3/complete.3 index 52702acca..b0f9fcea8 100644 --- a/man/man3/complete.3 +++ b/man/man3/complete.3 @@ -86,15 +86,15 @@ function frees a structure and its contents. .PP In -.IR rio (1) +.IM rio (1) and -.IR acme (1), +.IM acme (1) , file name completion is triggered by a control-F character or an Insert character. .SH SOURCE .B \*9/src/libcomplete .SH SEE ALSO -.IR rio (1), -.IR acme (1) +.IM rio (1) , +.IM acme (1) .SH DIAGNOSTICS The .I complete diff --git a/man/man3/ctime.3 b/man/man3/ctime.3 index 5491d39fd..db6591343 100644 --- a/man/man3/ctime.3 +++ b/man/man3/ctime.3 @@ -26,7 +26,7 @@ long tm2sec(Tm *tm) converts a time .I clock such as returned by -.IR time (3) +.IM time (3) into .SM ASCII (sic) @@ -85,8 +85,8 @@ is not .br .B \*9/src/lib9/tm2sec.c .SH "SEE ALSO" -.IR date (1), -.IR time (3) +.IM date (1) , +.IM time (3) .SH BUGS The return values point to static data whose content is overwritten by each call. @@ -112,4 +112,4 @@ are preprocessor macros defined as and .IR p9tm2sec ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/des.3 b/man/man3/des.3 index 3c3cd2014..5381f2e37 100644 --- a/man/man3/des.3 +++ b/man/man3/des.3 @@ -132,13 +132,13 @@ using .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR blowfish (3), -.IR dsa (3), -.IR elgamal (3), -.IR rc4 (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM blowfish (3) , +.IM dsa (3) , +.IM elgamal (3) , +.IM rc4 (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/dial.3 b/man/man3/dial.3 index 39092ae09..f34b1c54d 100644 --- a/man/man3/dial.3 +++ b/man/man3/dial.3 @@ -264,7 +264,7 @@ int callkremvax(void) .EE .PP Connect to a Unix socket served by -.IR acme (4): +.IM acme (4) : .IP .EX int dialacme(void) @@ -346,4 +346,4 @@ are preprocessor macros defined as .IR p9announce , and so on; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/dirread.3 b/man/man3/dirread.3 index 2522e9a69..b0386a23a 100644 --- a/man/man3/dirread.3 +++ b/man/man3/dirread.3 @@ -19,11 +19,11 @@ long dirreadall(int fd, Dir **buf) #define DIRMAX (sizeof(Dir)+STATMAX) .SH DESCRIPTION The data returned by a -.IR read (3) +.IM read (3) on a directory is a set of complete directory entries in a machine-independent format, exactly equivalent to the result of a -.IR stat (3) +.IM stat (3) on each file or subdirectory in the directory. .I Dirread decodes the directory entries into a machine-dependent form. @@ -35,11 +35,11 @@ structures whose address is returned in .B *buf (see -.IR stat (3) +.IM stat (3) for the layout of a .BR Dir ). The array is allocated with -.IR malloc (3) +.IM malloc (3) each time .I dirread is called. @@ -50,7 +50,7 @@ is like but reads in the entire directory; by contrast, .I dirread steps through a directory one -.IR read (3) +.IM read (3) at a time. .PP Directory entries have variable length. @@ -85,9 +85,9 @@ The file offset is advanced by the number of bytes actually read. .SH SOURCE .B \*9/src/lib9/dirread.c .SH SEE ALSO -.IR intro (3), -.IR open (3), -.IR read (3) +.IM intro (3) , +.IM open (3) , +.IM read (3) .SH DIAGNOSTICS .I Dirread and diff --git a/man/man3/draw.3 b/man/man3/draw.3 index 1fa5dea1d..c91ab541f 100644 --- a/man/man3/draw.3 +++ b/man/man3/draw.3 @@ -259,7 +259,7 @@ The clipping region may be modified dynamically using .TP .B chan The pixel channel format descriptor, as described in -.IR image (7). +.IM image (7) . The value should not be modified after the image is created. .TP .B depth @@ -268,7 +268,7 @@ number of bits per pixel in the picture; it is identically .B chantodepth(chan) (see -.IR graphics (3)) +.IM graphics (3) ) and is provided as a convenience. The value should not be modified after the image is created. .TP @@ -712,7 +712,7 @@ what is to .B atan (see -.IR sin (3)). +.IM sin (3) ). .TP .BI border( dst\fP,\fP\ r\fP,\fP\ i\fP,\fP\ color\fP,\fP\ sp\fP) .I Border @@ -810,11 +810,11 @@ is non-zero. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR stringsize (3), -.IR color (7), -.IR utf (7), -.IR addpt (3) +.IM graphics (3) , +.IM stringsize (3) , +.IM color (7) , +.IM utf (7) , +.IM addpt (3) .PP T. Porter, T. Duff. ``Compositing Digital Images'', diff --git a/man/man3/drawfcall.3 b/man/man3/drawfcall.3 index 1c8d376b1..ecdc272ae 100644 --- a/man/man3/drawfcall.3 +++ b/man/man3/drawfcall.3 @@ -30,15 +30,15 @@ int readwsysmsg(int fd, uchar *buf, uint nbuf) uint sizeW2M(Wsysmsg *w) .SH DESCRIPTION These routines are analogues of the routines described in -.IR fcall (3). +.IM fcall (3) . They manipulate graphics device protocol messages rather than 9P protocol messages. The graphics device protocol is used for internal communication between the -.IR devdraw (1) +.IM devdraw (1) graphics server and the -.IR draw (3) +.IM draw (3) library. A .B Wsysmsg @@ -48,6 +48,6 @@ The protocol is intentionally undocumented and may change. .SH SOURCE .B \*9/src/libdraw/drawfcall.c .SH SEE ALSO -.IR devdraw (1), -.IR draw (3), -.IR graphics (3) +.IM devdraw (1) , +.IM draw (3) , +.IM graphics (3) diff --git a/man/man3/dsa.3 b/man/man3/dsa.3 index 41532b89e..0a3c34a12 100644 --- a/man/man3/dsa.3 +++ b/man/man3/dsa.3 @@ -84,7 +84,7 @@ and generated by .IR DSAprimes (see -.IR prime (3)). +.IM prime (3) ). Otherwise, .B p and @@ -128,17 +128,17 @@ are provided to manage signature storage. converts an ASN1 formatted DSA private key into the corresponding .B DSApriv structure; see -.IR rsa (3) +.IM rsa (3) for other ASN1 routines. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR blowfish (3), -.IR des (3), -.IR rc4 (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM blowfish (3) , +.IM des (3) , +.IM rc4 (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/dup.3 b/man/man3/dup.3 index 392e6fe63..e313c0682 100644 --- a/man/man3/dup.3 +++ b/man/man3/dup.3 @@ -36,4 +36,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9dup ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/elgamal.3 b/man/man3/elgamal.3 index 2fc75ac64..9fe4e6987 100644 --- a/man/man3/elgamal.3 +++ b/man/man3/elgamal.3 @@ -113,13 +113,13 @@ are provided to manage signature storage. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR blowfish (3), -.IR des (3), -.IR dsa (3), -.IR rc4 (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM blowfish (3) , +.IM des (3) , +.IM dsa (3) , +.IM rc4 (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/encode.3 b/man/man3/encode.3 index fde8296c8..e3a94860d 100644 --- a/man/man3/encode.3 +++ b/man/man3/encode.3 @@ -49,9 +49,9 @@ of 8. .PP .I Encodefmt can be used with -.IR fmtinstall (3) +.IM fmtinstall (3) and -.IR print (3) +.IM print (3) to print encoded representations of byte arrays. The verbs are .TP diff --git a/man/man3/encrypt.3 b/man/man3/encrypt.3 index 1f44689d3..70ff003ed 100644 --- a/man/man3/encrypt.3 +++ b/man/man3/encrypt.3 @@ -84,4 +84,4 @@ are preprocessor macros defined as and .IR p9decrypt ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/errstr.3 b/man/man3/errstr.3 index 3964d8d5c..5bc7bf091 100644 --- a/man/man3/errstr.3 +++ b/man/man3/errstr.3 @@ -53,7 +53,7 @@ the result is an empty string. The verb .B r in -.IR print (3) +.IM print (3) calls .I errstr and outputs the error string. @@ -92,8 +92,8 @@ will reset .I Errstr always returns 0. .SH SEE ALSO -.IR intro (3), -.IR perror (3) +.IM intro (3) , +.IM perror (3) .SH BUGS The implementation sets .I errno @@ -104,4 +104,4 @@ When .I errno is set to other values, the error string is synthesized using -.IR strerror (3). +.IM strerror (3) . diff --git a/man/man3/event.3 b/man/man3/event.3 index 5991a17d3..56ddeb346 100644 --- a/man/man3/event.3 +++ b/man/man3/event.3 @@ -93,12 +93,12 @@ enum{ These routines provide an interface to multiple sources of input for unthreaded programs. Threaded programs (see -.IR thread (3)) +.IM thread (3) ) should instead use the threaded mouse and keyboard interface described in -.IR mouse (3) +.IM mouse (3) and -.IR keyboard (3). +.IM keyboard (3) . .PP .I Einit must be called first. @@ -113,7 +113,7 @@ the mouse and keyboard events will be enabled; in this case, .IR initdraw (see -.IR graphics (3)) +.IM graphics (3) ) must have already been called. The user must provide a function called .IR eresized @@ -123,7 +123,7 @@ is running has been resized; the argument is a flag specifying whether the program must call .I getwindow (see -.IR graphics (3)) +.IM graphics (3) ) to re-establish a connection to its window. After resizing (and perhaps calling .IR getwindow ), @@ -266,7 +266,7 @@ The return is the same as for .IR eread . .PP As described in -.IR graphics (3), +.IM graphics (3) , the graphics functions are buffered. .IR Event , .IR eread , @@ -370,15 +370,15 @@ changes the cursor image to that described by the .B Cursor .I c (see -.IR mouse (3)). +.IM mouse (3) ). If .B c is nil, it restores the image to the default arrow. .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IR rio (1), -.IR graphics (3), -.IR plumb (3), +.IM rio (1) , +.IM graphics (3) , +.IM plumb (3) , .\" .IR cons (3), -.IR draw (3) +.IM draw (3) diff --git a/man/man3/exec.3 b/man/man3/exec.3 index 1a0a8a871..cc921dbdd 100644 --- a/man/man3/exec.3 +++ b/man/man3/exec.3 @@ -25,11 +25,11 @@ points to the name of the file to be executed; it must not be a directory, and the permissions must allow the current user to execute it (see -.IR stat (3)). +.IM stat (3) ). It should also be a valid binary image, as defined by the local operating system, or a shell script (see -.IR rc (1)). +.IM rc (1) ). The first line of a shell script must begin with .L #! @@ -92,24 +92,24 @@ files remain open across .B OCEXEC OR'd into the open mode; see -.IR open (3)); +.IM open (3) ); and the working directory and environment (see -.IR getenv (3)) +.IM getenv (3) ) remain the same. However, a newly .I exec'ed process has no notification handlers (see -.IR notify (3)). +.IM notify (3) ). .SH SOURCE .B \*9/src/lib9/exec.c .br .B \*9/src/lib9/execl.c .SH SEE ALSO -.IR prof (1), -.IR intro (3), -.IR stat (3) +.IM prof (1) , +.IM intro (3) , +.IM stat (3) .SH DIAGNOSTICS If these functions fail, they return and set .IR errstr . @@ -138,4 +138,4 @@ are preprocessor macros defined as and .IR p9execl ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/exits.3 b/man/man3/exits.3 index 1bab40af8..c1d47ea87 100644 --- a/man/man3/exits.3 +++ b/man/man3/exits.3 @@ -39,7 +39,7 @@ explanation of the reason for exiting, or a null pointer or empty string to indicate normal termination. The string is passed to the parent process, prefixed by the name and process id of the exiting process, when the parent does a -.IR wait (3). +.IM wait (3) . .PP Before calling .I _exits @@ -85,8 +85,8 @@ cancels a previous registration of an exit function. .br .B \*9/src/lib9/_exits.c .SH "SEE ALSO" -.IR fork (2), -.IR wait (3) +.IM fork (2) , +.IM wait (3) .SH BUGS Because of limitations of Unix, the exit status of a process can only be an 8-bit integer. @@ -117,4 +117,4 @@ are preprocessor macros defined as and .IR p9atexitdont ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/fcall.3 b/man/man3/fcall.3 index fe696a4ba..6dc4bf5cc 100644 --- a/man/man3/fcall.3 +++ b/man/man3/fcall.3 @@ -225,7 +225,7 @@ by a successful call to Another structure is .BR Dir , used by the routines described in -.IR stat (3). +.IM stat (3) . .I ConvM2D converts the machine-independent form starting at .I ap @@ -293,7 +293,7 @@ contain a validly formatted machine-independent entry suitable as an argument, for example, for the .B wstat (see -.IR stat (3)) +.IM stat (3) ) system call. It checks that the sizes of all the elements of the the entry sum to exactly .IR nbuf , @@ -321,7 +321,7 @@ for an incorrectly formatted entry. and .I dirmodefmt are formatting routines, suitable for -.IR fmtinstall (3). +.IM fmtinstall (3) . They convert .BR Dir* , .BR Fcall* , @@ -343,7 +343,7 @@ with format letter .PP .I Read9pmsg calls -.IR read (3) +.IM read (3) multiple times, if necessary, to read an entire 9P message into .BR buf . The return value is 0 for end of file, or -1 for error; it does not return @@ -351,7 +351,7 @@ partial messages. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IR intro (3), -.IR 9p (3), -.IR stat (3), +.IM intro (3) , +.IM 9p (3) , +.IM stat (3) , .IR intro (9p) diff --git a/man/man3/flate.3 b/man/man3/flate.3 index b7b1a1975..cd90c1f2a 100644 --- a/man/man3/flate.3 +++ b/man/man3/flate.3 @@ -173,7 +173,7 @@ The block functions return the number of bytes produced when they succeed. .I Mkcrctab allocates (using -.IR malloc (3)), +.IM malloc (3) ), initializes, and returns a table for rapid computation of 32 bit CRC values using the polynomial .IR poly . .I Blockcrc diff --git a/man/man3/fmtinstall.3 b/man/man3/fmtinstall.3 index da766d776..93bded761 100644 --- a/man/man3/fmtinstall.3 +++ b/man/man3/fmtinstall.3 @@ -94,16 +94,16 @@ int fmtrunestrcpy(Fmt *f, Rune *s); int errfmt(Fmt *f); .SH DESCRIPTION The interface described here allows the construction of custom -.IR print (3) +.IM print (3) verbs and output routines. In essence, they provide access to the workings of the formatted print code. .PP The -.IR print (3) +.IM print (3) suite maintains its state with a data structure called .BR Fmt . A typical call to -.IR print (3) +.IM print (3) or its relatives initializes a .B Fmt structure, passes it to subsidiary routines to process the output, @@ -154,7 +154,7 @@ to generate the output. These behave like .B fprint (see -.IR print (3)) +.IM print (3) ) or .B vfprint except that the characters are buffered until @@ -207,7 +207,7 @@ In are the width and precision, and .IB fp ->flags the decoded flags for the verb (see -.IR print (3) +.IM print (3) for a description of these items). The standard flag values are: .B FmtSign @@ -282,7 +282,7 @@ produced. .PP Some internal functions may be useful to format primitive types. They honor the width, precision and flags as described in -.IR print (3). +.IM print (3) . .I Fmtrune formats a single character .BR r . @@ -307,7 +307,7 @@ regardless of whether the output is bytes or runes. This function prints an error message with a variable number of arguments and then quits. Compared to the corresponding example in -.IR print (3), +.IM print (3) , this version uses a smaller buffer, will never truncate the output message, but might generate multiple .B write @@ -364,9 +364,9 @@ main(...) .SH SOURCE .B \*9/src/lib9/fmt .SH SEE ALSO -.IR print (3), -.IR utf (7), -.IR errstr (3) +.IM print (3) , +.IM utf (7) , +.IM errstr (3) .SH DIAGNOSTICS These routines return negative numbers or nil for errors and set .IR errstr . diff --git a/man/man3/frame.3 b/man/man3/frame.3 index 1e063802c..4fb2f8b69 100644 --- a/man/man3/frame.3 +++ b/man/man3/frame.3 @@ -73,9 +73,9 @@ enum{ This library supports .I frames of editable text in a single font on raster displays, such as in -.IR sam (1) +.IM sam (1) and -.IR 9term (1). +.IM 9term (1) . Frames may hold any character except NUL (0). Long lines are folded and tabs are at fixed intervals. .PP @@ -239,7 +239,7 @@ If a .B Frame is being moved but not resized, that is, if the shape of its containing rectangle is unchanged, it is sufficient to use -.IR draw (3) +.IM draw (3) to copy the containing rectangle from the old to the new location and then call .I frsetrects to establish the new geometry. @@ -357,6 +357,6 @@ and .SH SOURCE .B \*9/src/libframe .SH SEE ALSO -.IR graphics (3), -.IR draw (3), -.IR cachechars (3). +.IM graphics (3) , +.IM draw (3) , +.IM cachechars (3) . diff --git a/man/man3/genrandom.3 b/man/man3/genrandom.3 index ddf481e4c..320ecd14f 100644 --- a/man/man3/genrandom.3 +++ b/man/man3/genrandom.3 @@ -25,11 +25,11 @@ number generator. The X9.17 generator is seeded by 24 truly random bytes read via .I truerand (see -.IR rand (3)). +.IM rand (3) ). .PP .I Prng uses the native -.IR rand (3) +.IM rand (3) pseudo-random number generator to fill the buffer. Used with .IR srand , this function can produce a reproducible stream of pseudo random @@ -38,8 +38,8 @@ numbers useful in testing. Both functions may be passed to .I mprand (see -.IR mp (3)). +.IM mp (3) ). .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3) +.IM mp (3) diff --git a/man/man3/get9root.3 b/man/man3/get9root.3 index 52fb6f094..343ad9d6d 100644 --- a/man/man3/get9root.3 +++ b/man/man3/get9root.3 @@ -49,7 +49,7 @@ if different from should be freed with .I free (see -.IR malloc (3)) +.IM malloc (3) ) when no longer needed. .PP As a convention, programs should never @@ -57,7 +57,7 @@ As a convention, programs should never paths obtained from user input. .SH EXAMPLE The -.IR plumber (4) +.IM plumber (4) uses this code to find unrooted file names included by plumb rules. .IP .EX @@ -69,7 +69,7 @@ fd = open(unsharp(buf), OREAD); .br .B \*9/src/lib9/unsharp.c .SH SEE ALSO -.IR intro (4) +.IM intro (4) .SH BUGS .I Get9root could be smarter about finding the tree when diff --git a/man/man3/getenv.3 b/man/man3/getenv.3 index a817b6ef7..3ce0a316b 100644 --- a/man/man3/getenv.3 +++ b/man/man3/getenv.3 @@ -18,7 +18,7 @@ int putenv(char *name, char *val) fetches the environment value associated with .I name into memory allocated with -.IR malloc (3), +.IM malloc (3) , 0-terminates it, and returns a pointer to that area. If no file exists, 0 @@ -44,4 +44,4 @@ are preprocessor macros defined as and .IR p9putenv ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/getfields.3 b/man/man3/getfields.3 index feaf10d85..19741b855 100644 --- a/man/man3/getfields.3 +++ b/man/man3/getfields.3 @@ -75,9 +75,9 @@ with non-zero, except that fields may be quoted using single quotes, in the manner of -.IR rc (1). +.IM rc (1) . See -.IR quote (3) +.IM quote (3) for related quote-handling software. .PP .I Tokenize @@ -91,5 +91,5 @@ set to \f5"\et\er\en "\fP. .SH SEE ALSO .I strtok in -.IR strcat (3), -.IR quote (3). +.IM strcat (3) , +.IM quote (3) . diff --git a/man/man3/getns.3 b/man/man3/getns.3 index b2e03f93d..a23a856b1 100644 --- a/man/man3/getns.3 +++ b/man/man3/getns.3 @@ -14,9 +14,9 @@ returns a pointer to a malloced string that contains the path to the name space directory for the current process. The name space directory is a clumsy substitute for Plan 9's per-process name spaces; see -.IR intro (4) +.IM intro (4) for details. .SH SOURCE .B \*9/src/lib9/getns.c .SH SEE ALSO -.IR intro (4) +.IM intro (4) diff --git a/man/man3/getsnarf.3 b/man/man3/getsnarf.3 index 938aae3f2..323b6ab54 100644 --- a/man/man3/getsnarf.3 +++ b/man/man3/getsnarf.3 @@ -20,7 +20,7 @@ returns a copy of the current buffer; the returned pointer should be freed with .I free (see -.IR malloc (3)) +.IM malloc (3) ) when no longer needed. .PP .I Putsnarf @@ -36,4 +36,4 @@ will convert as necessary. .SH SOURCE .B \*9/src/libdraw/snarf.c .SH SEE ALSO -.IR snarfer (1) +.IM snarfer (1) diff --git a/man/man3/getuser.3 b/man/man3/getuser.3 index 41e78e3d9..dae84a230 100644 --- a/man/man3/getuser.3 +++ b/man/man3/getuser.3 @@ -19,7 +19,7 @@ name of the user who owns the current process. .I Getuser calls -.IR getuid (2) +.IM getuid (2) and then reads .B /etc/passwd to find the corresponding name. @@ -33,7 +33,7 @@ looks first for an environment variable If there is no such variable, .I sysname calls -.IR gethostname (2) +.IM gethostname (2) and truncates the returned name at the first dot. If .I gethostname diff --git a/man/man3/getwd.3 b/man/man3/getwd.3 index 245914f34..9bb36d309 100644 --- a/man/man3/getwd.3 +++ b/man/man3/getwd.3 @@ -23,10 +23,10 @@ bytes in the buffer provided. .SH SOURCE .B \*9/src/lib9/getwd.c .SH "SEE ALSO" -.IR pwd (1) +.IM pwd (1) .SH DIAGNOSTICS On error, zero is returned. -.IR Errstr (3) +.IM Errstr (3) may be consulted for more information. .SH BUGS To avoid name conflicts with the underlying system, @@ -34,4 +34,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9getwd ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/graphics.3 b/man/man3/graphics.3 index 4f58451a0..42b797f44 100644 --- a/man/man3/graphics.3 +++ b/man/man3/graphics.3 @@ -107,7 +107,7 @@ extern Font *font A .B Display structure represents a connection to the graphics device, -.IR draw (3), +.IM draw (3) , holding all graphics resources associated with the connection, including in particular raster image data in use by the client program. The structure is defined (in part) as: @@ -135,7 +135,7 @@ A .B Point is a location in an Image (see below and -.IR draw (3)), +.IM draw (3) ), such as the display, and is defined as: .IP .EX @@ -184,18 +184,18 @@ contains the coordinates of the first point beyond the rectangle. The .B Image data structure is defined in -.IR draw (3). +.IM draw (3) . .PP A .B Font is a set of character images, indexed by runes (see -.IR utf (7)). +.IM utf (7) ). The images are organized into .BR Subfonts , each containing the images for a small, contiguous set of runes. The detailed format of these data structures, which are described in detail in -.IR cachechars (3), +.IM cachechars (3) , is immaterial for most applications. .B Font and @@ -210,7 +210,7 @@ and the distance from the top of the highest character to the bottom of the lowest character (and hence, the interline spacing). See -.IR cachechars (3) +.IM cachechars (3) for more details. .PP .I Buildfont @@ -221,7 +221,7 @@ returning a pointer that can be used by .B string (see -.IR draw (3)) +.IM draw (3) ) to draw characters from the font. .I Openfont does the same, but reads the description @@ -231,7 +231,7 @@ frees a font. In contrast to Plan 9, font names in Plan 9 from User Space are a small language describing the desired font. See -.IR font (7) +.IM font (7) for details. .PP A @@ -274,7 +274,7 @@ structure representing the connection), (an .B Image representing the display memory itself or, if -.IR rio (1) +.IM rio (1) is running, the client's window), and .B font @@ -287,7 +287,7 @@ which is written to .B /dev/label if non-nil so that it can be used to identify the window when hidden (see -.IR rio (1)). +.IM rio (1) ). The font is created by reading the named .I font file. If @@ -301,7 +301,7 @@ if is not set, it imports the default (usually minimal) font from the operating system. (See -.IR font (7) +.IM font (7) for a full discussion of font syntaxes.) The global .I font @@ -322,7 +322,7 @@ is nil, the library provides a default, called Another effect of .I initdraw is that it installs -.IR print (3) +.IM print (3) formats .I Pfmt and @@ -360,9 +360,9 @@ and files; and .I ref specifies the refresh function to be used to create the window, if running under -.IR rio (1) +.IM rio (1) (see -.IR window (3)). +.IM window (3) ). .\" .PP .\" The function .\" .I newwindow @@ -435,11 +435,11 @@ by looking in to find the name of the window and opening it using .B namedimage (see -.IR allocimage (3)). +.IM allocimage (3) ). The resulting window will be created using the refresh method .I ref (see -.IR window (3)); +.IM window (3) ); this should almost always be .B Refnone because @@ -456,7 +456,7 @@ defining the window (or the overall display, if no window system is running); an a pointer to the .B Screen representing the root of the window's hierarchy. (See -.IR window (3). +.IM window (3) . The overloading of the .B screen word is an unfortunate historical accident.) @@ -528,15 +528,15 @@ the window boundaries; otherwise is a no-op. .PP The graphics functions described in -.IR draw (3), -.IR allocimage (3), -.IR cachechars (3), +.IM draw (3) , +.IM allocimage (3) , +.IM cachechars (3) , and -.IR subfont (3) +.IM subfont (3) are implemented by writing commands to files under .B /dev/draw (see -.IR draw (3)); +.IM draw (3) ); the writes are buffered, so the functions may not take effect immediately. .I Flushimage flushes the buffer, doing all pending graphics operations. @@ -546,7 +546,7 @@ is non-zero, any changes are also copied from the `soft screen' (if any) in the driver to the visible frame buffer. The various allocation routines in the library flush automatically, as does the event package (see -.IR event (3)); +.IM event (3) ); most programs do not need to call .IR flushimage . It returns \-1 on error. @@ -563,13 +563,13 @@ and .I chantostr convert between the channel descriptor strings used by -.IR image (7) +.IM image (7) and the internal .B ulong representation used by the graphics protocol (see -.IR draw (3)'s +.IM draw (3) 's .B b message). .B Chantostr @@ -599,7 +599,7 @@ if(getwindow(display, Refnone) < 0) .EE .PP To create and set up a new -.IR rio (1) +.IM rio (1) window, .IP .EX @@ -630,23 +630,23 @@ if(gengetwindow(display, "/tmp/winname", .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IR rio (1), -.IR addpt (3), -.IR allocimage (3), -.IR cachechars (3), -.IR subfont (3), -.IR draw (3), -.IR event (3), -.IR frame (3), -.IR print (3), -.IR window (3), -.IR draw (3), +.IM rio (1) , +.IM addpt (3) , +.IM allocimage (3) , +.IM cachechars (3) , +.IM subfont (3) , +.IM draw (3) , +.IM event (3) , +.IM frame (3) , +.IM print (3) , +.IM window (3) , +.IM draw (3) , .\" .IR rio (4), -.IR image (7), -.IR font (7) +.IM image (7) , +.IM font (7) .SH DIAGNOSTICS An error function may call -.IR errstr (3) +.IM errstr (3) for further diagnostics. .SH BUGS The names diff --git a/man/man3/html.3 b/man/man3/html.3 index 7dc486ae4..f99fda1b4 100644 --- a/man/man3/html.3 +++ b/man/man3/html.3 @@ -1411,7 +1411,7 @@ would not otherwise fit), and .SH SOURCE .B \*9/src/libhtml .SH SEE ALSO -.IR fmt (1) +.IM fmt (1) .PP W3C World Wide Web Consortium, ``HTML 4.01 Specification''. diff --git a/man/man3/ioproc.3 b/man/man3/ioproc.3 index a87fa775b..2645a228f 100644 --- a/man/man3/ioproc.3 +++ b/man/man3/ioproc.3 @@ -80,14 +80,14 @@ and execute the similarly named library or system calls (see -.IR close (2), -.IR dial (3), -.IR open (3), -.IR read (3), -.IR fcall (3), -.IR sendfd (3), +.IM close (2) , +.IM dial (3) , +.IM open (3) , +.IM read (3) , +.IM fcall (3) , +.IM sendfd (3) , and -.IR sleep (3)) +.IM sleep (3) ) in the slave process associated with .IR io . It is an error to execute more than one call @@ -187,10 +187,10 @@ ioread(Ioproc *io, int fd, void *a, long n) .SH SOURCE .B \*9/src/libthread .SH SEE ALSO -.IR dial (3), -.IR open (3), -.IR read (3), -.IR thread (3) +.IM dial (3) , +.IM open (3) , +.IM read (3) , +.IM thread (3) .SH BUGS .I Iointerrupt is currently unimplemented. diff --git a/man/man3/ip.3 b/man/man3/ip.3 index 2d9e8289d..c8305dea4 100644 --- a/man/man3/ip.3 +++ b/man/man3/ip.3 @@ -126,7 +126,7 @@ The string representation of Ethernet addresses is exactly .PP .I Eipfmt is a -.IR print (3) +.IM print (3) formatter for Ethernet (verb .BR E ) addresses, @@ -340,4 +340,4 @@ point to point. .SH SOURCE .B \*9/src/libip .SH SEE ALSO -.IR print (3) +.IM print (3) diff --git a/man/man3/isalpharune.3 b/man/man3/isalpharune.3 index 7b5cf301f..eeaf3ebcb 100644 --- a/man/man3/isalpharune.3 +++ b/man/man3/isalpharune.3 @@ -35,7 +35,7 @@ in particular a subset of their properties as defined in the Unicode standard. Unicode defines some characters as alphabetic and specifies three cases: upper, lower, and title. Analogously to -.IR isalpha (3) +.IM isalpha (3) for .SM ASCII\c , diff --git a/man/man3/keyboard.3 b/man/man3/keyboard.3 index 4641b86dc..6c1bf026e 100644 --- a/man/man3/keyboard.3 +++ b/man/man3/keyboard.3 @@ -23,14 +23,14 @@ void closekeyboard(Keyboard *kc) .SH DESCRIPTION These functions access and control a keyboard interface for character-at-a-time I/O in a multi-threaded environment, usually in combination with -.IR mouse (3). +.IM mouse (3) . They use the message-passing .B Channel interface in the threads library (see -.IR thread (3)); +.IM thread (3) ); programs that wish a more event-driven, single-threaded approach should use -.IR event (3). +.IM event (3) . .PP .I Initkeyboard opens a connection to the keyboard and returns a @@ -86,10 +86,10 @@ structure. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR draw (3), -.IR event (3), -.IR thread (3). +.IM graphics (3) , +.IM draw (3) , +.IM event (3) , +.IM thread (3) . .SH BUGS Because the interface delivers complete runes, there is no way to report lesser actions such as diff --git a/man/man3/lock.3 b/man/man3/lock.3 index adc75d1fc..31882bb0c 100644 --- a/man/man3/lock.3 +++ b/man/man3/lock.3 @@ -80,7 +80,7 @@ are rendezvous points. Locks and rendezvous points have trivial implementations in programs not using the thread library (see -.IR thread (3)), +.IM thread (3) ), since such programs have no concurrency. .PP Used carelessly, spin locks can be expensive and can easily generate deadlocks. diff --git a/man/man3/mach-cmd.3 b/man/man3/mach-cmd.3 index ac6b3bbdf..08563eb75 100644 --- a/man/man3/mach-cmd.3 +++ b/man/man3/mach-cmd.3 @@ -64,7 +64,7 @@ fields) of all currently open headers (see .I symopen in -.IR mach-symbol (3)). +.IM mach-symbol (3) ). When dynamically linked objects have been attached, they are present in this linked list, and therefore included in searches by @@ -73,7 +73,7 @@ and therefore included in searches by and .I findsym (see -.IR mach-symbol (3)). +.IM mach-symbol (3) ). .TP .I corhdr The file header for the core dump, if any. @@ -118,9 +118,9 @@ loaded. uses all of these functions while parsing an argument vector as would be passed to a debugger like -.IR db (1) +.IM db (1) or -.IR acid (1). +.IM acid (1) . It expects a list of executable files, core dump files, or process ids, given in any order. If extra arguments are given (for example, more than one executable, or both @@ -133,9 +133,9 @@ fills them in as best it can. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO -.IR mach (3), -.IR mach-file (3), -.IR mach-map (3) +.IM mach (3) , +.IM mach-file (3) , +.IM mach-map (3) .SH BUGS The interface needs to be changed to support multiple threads, each with its own register set. diff --git a/man/man3/mach-file.3 b/man/man3/mach-file.3 index 19a10b813..22a61aa0d 100644 --- a/man/man3/mach-file.3 +++ b/man/man3/mach-file.3 @@ -161,10 +161,10 @@ The memory at should be freed via .I free (see -.IR malloc (3)) +.IM malloc (3) ) when no longer needed. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IR mach (3), -.IR mach-map (3) +.IM mach (3) , +.IM mach-map (3) diff --git a/man/man3/mach-map.3 b/man/man3/mach-map.3 index c58225721..94e73a223 100644 --- a/man/man3/mach-map.3 +++ b/man/man3/mach-map.3 @@ -133,10 +133,10 @@ via data structures that provides access to an address space and register set. The functions described in -.IR mach-file (3) +.IM mach-file (3) are typically used to construct these maps. Related library functions described in -.IR mach-symbol (3) +.IM mach-symbol (3) provide similar access to symbol tables. .PP Each @@ -178,7 +178,7 @@ The .B rw function is most commonly used to provide access to executing processes via -.IR ptrace (2) +.IM ptrace (2) and to zeroed segments. .PP .I Allocmap @@ -346,7 +346,7 @@ such locations are useful for passing specific constants to functions expect locations, such as .I unwind (see -.IR mach-stack (3)). +.IM mach-stack (3) ). .PP .I Loccmp compares two locations, returning negative, zero, or positive @@ -360,7 +360,7 @@ which are ordered before indirections. .PP .I Locfmt is a -.IR print (3)-verb +.IM print (3) -verb that formats a .B Loc structure @@ -371,7 +371,7 @@ Indirection locations are needed in some contexts (e.g., when using .I findlsym (see -.IR mach-symbol (3))), +.IM mach-symbol (3) )), but bothersome in most. .I Locsimplify rewrites indirections as absolute memory addresses, by evaluating @@ -397,8 +397,8 @@ function families as necessary. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IR mach (3), -.IR mach-file (3) +.IM mach (3) , +.IM mach-file (3) .SH DIAGNOSTICS These routines set .IR errstr . diff --git a/man/man3/mach-stack.3 b/man/man3/mach-stack.3 index d75f641f5..abf413943 100644 --- a/man/man3/mach-stack.3 +++ b/man/man3/mach-stack.3 @@ -68,7 +68,7 @@ a new .I rget function, and a symbol (see -.IR mach-symbol (3)) +.IM mach-symbol (3) ) describing the current function (nil if no symbol is known). The value returned by the tracer @@ -180,6 +180,6 @@ trace(Map *map, ulong pc, ulong callerpc, .SH SOURCE .B \*9/src/libmach .SH SEE ALSO -.IR mach (3) +.IM mach (3) .SH BUGS Need to talk about Regs diff --git a/man/man3/mach-swap.3 b/man/man3/mach-swap.3 index eb6091f32..39b18ef9d 100644 --- a/man/man3/mach-swap.3 +++ b/man/man3/mach-swap.3 @@ -114,4 +114,4 @@ and low 32-bits are in .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IR mach (3) +.IM mach (3) diff --git a/man/man3/mach-symbol.3 b/man/man3/mach-symbol.3 index e14a7b2e0..fc7bbd281 100644 --- a/man/man3/mach-symbol.3 +++ b/man/man3/mach-symbol.3 @@ -61,10 +61,10 @@ int fnbound(ulong pc, ulong bounds[2]) .SH DESCRIPTION These functions provide machine-independent access to the symbol table of an executable file or executing process. -.IR Mach (3), -.IR mach-file (3), +.IM Mach (3) , +.IM mach-file (3) , and -.IR mach-map (3) +.IM mach-map (3) describe additional library functions for accessing executable files and executing processes. .PP @@ -74,7 +74,7 @@ uses the data in the structure filled by .I crackhdr (see -.IR mach-file (3)) +.IM mach-file (3) ) to initialize in-memory structures used to access the symbol tables contained in the file. .IR Symclose @@ -371,6 +371,6 @@ in the system error buffer where it is available via .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IR mach (3), -.IR mach-file (3), -.IR mach-map (3) +.IM mach (3) , +.IM mach-file (3) , +.IM mach-map (3) diff --git a/man/man3/mach.3 b/man/man3/mach.3 index 9c065d002..71742155c 100644 --- a/man/man3/mach.3 +++ b/man/man3/mach.3 @@ -40,7 +40,7 @@ points at the structure for the architecture being debugged. It is set implicitly by .I crackhdr (see -.IR mach-file (3)) +.IM mach-file (3) ) and can be set explicitly by calling .I machbyname or @@ -66,31 +66,31 @@ Mac OS X). Other manual pages describe the library functions in detail. .PP -.IR Mach-cmd (3) +.IM Mach-cmd (3) describes some convenience routines for attaching to processes and core files. .PP -.IR Mach-file (3) +.IM Mach-file (3) describes the manipulation of binary files. .PP -.IR Mach-map (3) +.IM Mach-map (3) describes the interface to address spaces and register sets in executable files and executing programs. .PP -.IR Mach-stack (3) +.IM Mach-stack (3) describes support for unwinding the stack. .PP -.IR Mach-swap (3) +.IM Mach-swap (3) describes helper functions for accessing data in a particular byte order. .PP -.IR Mach-symbol (3) +.IM Mach-symbol (3) describes the interface to debugging symbol information. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO -.IR mach-file (3), -.IR mach-map (3), -.IR mach-stack (3), -.IR mach-swap (3), -.IR mach-symbol (3) +.IM mach-file (3) , +.IM mach-map (3) , +.IM mach-stack (3) , +.IM mach-swap (3) , +.IM mach-symbol (3) diff --git a/man/man3/malloc.3 b/man/man3/malloc.3 index 1cdff5776..300b9c5b0 100644 --- a/man/man3/malloc.3 +++ b/man/man3/malloc.3 @@ -132,8 +132,8 @@ the source of allocation. .SH SEE ALSO .I trump (in -.IR acid (1)), -.IR getcallerpc (3) +.IM acid (1) ), +.IM getcallerpc (3) .SH DIAGNOSTICS .I Malloc, realloc and @@ -153,7 +153,7 @@ The library for .I acid can be used to obtain traces of malloc execution; see -.IR acid (1). +.IM acid (1) . .SH BUGS The different specification of .I calloc @@ -182,4 +182,4 @@ are preprocessor macros defined as and .IR p9free ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/matrix.3 b/man/man3/matrix.3 index 7291725c6..b66170efd 100644 --- a/man/man3/matrix.3 +++ b/man/man3/matrix.3 @@ -347,4 +347,4 @@ coordinates. .SH SOURCE .B \*9/src/libgeometry/matrix.c .SH "SEE ALSO -.IR arith3 (3) +.IM arith3 (3) diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3 index 243cfe161..89e073b92 100644 --- a/man/man3/memdraw.3 +++ b/man/man3/memdraw.3 @@ -168,46 +168,46 @@ type defines memory-resident rectangular pictures and the methods to draw upon t differ from .BR Image s (see -.IR draw (3)) +.IM draw (3) ) in that they are manipulated directly in user memory rather than by RPCs to the .B /dev/draw hierarchy. The .Bmemdraw -library is the basis for the kernel -.IR draw (3) +library is the basis for the kernel +.IM draw (3) driver and also used by a number of programs that must manipulate images without a display. .PP -The -.BR r, +The +.BR r, .BR clipr , .BR depth , .BR nchan , and -.BR chan +.BR chan structure elements are identical to the ones of the same name -in the +in the .B Image structure. .PP The .B flags -element of the +element of the .B Memimage structure holds a number of bits of information about the image. In particular, it subsumes the purpose of the .B repl -element of +element of .B Image structures. .PP .I Memimageinit initializes various static data that the library depends on, -as well as the replicated solid color images +as well as the replicated solid color images .BR memopaque , .BR memtransparent , .BR memblack , @@ -216,15 +216,15 @@ and It should be called before referring to any of these images and before calling any of the other library functions. .PP -Each +Each .B Memimage -points at a +points at a .B Memdata structure that in turn points at the actual pixel data for the image. -This allows multiple images to be associated with the same +This allows multiple images to be associated with the same .BR Memdata . The first word of the data pointed at by -the +the .B base element of .B Memdata @@ -232,18 +232,19 @@ points back at the .B Memdata structure, so that in the Plan 9 kernel, the memory allocator (see -Plan 9's \fIpool\fR(3)) +Plan 9's +.IR pool (3)) can compact image memory using .IR memimagemove . .PP Because images can have different coordinate systems, -the +the .B zero -element of the +element of the .B Memimage structure contains the offset that must be added -to the +to the .B bdata element of the corresponding .B Memdata @@ -261,18 +262,18 @@ do not include the origin, although one should only dereference pointers corresponding to pixels within the image rectangle. .I Wordaddr and -.IR byteaddr -perform these calculations, +.IR byteaddr +perform these calculations, returning pointers to the word and byte, respectively, that contain the beginning of the data for a given pixel. .PP .I Allocmemimage -allocates +allocates images with a given rectangle and channel descriptor -(see +(see .B strtochan in -.IR graphics (3)), +.IM graphics (3) ), creating a fresh .B Memdata structure and associated storage. @@ -282,7 +283,7 @@ is similar but uses the supplied structure rather than a new one. The .I readmemimage -function reads an uncompressed bitmap +function reads an uncompressed bitmap from the given file descriptor, while .I creadmemimage @@ -293,7 +294,7 @@ writes a compressed representation of to file descriptor .IR fd . For more on bitmap formats, see -.IR image (7). +.IM image (7) . .I Freememimage frees images returned by any of these routines. The @@ -315,7 +316,7 @@ data, respectively. When calling .IR cloadmemimage , the buffer must contain an -integral number of +integral number of compressed chunks of data that exactly cover the rectangle. .I Unloadmemimage retrieves the uncompressed pixel data for a given rectangle of an image. @@ -324,8 +325,8 @@ and \-1 in case of an error. .PP .I Memfillcolor fills an image with the given color, a 32-bit number as -described in -.IR color (3). +described in +.IM color (3) . .PP .IR Memarc , .IR mempoly , @@ -334,7 +335,7 @@ described in .IR memimageline , and .I memimagedraw -are identical to the +are identical to the .IR arc , .IR poly , .IR ellipse , @@ -343,40 +344,40 @@ are identical to the and .IR gendraw , routines described in -.IR draw (3), +.IM draw (3) , except that they operate on .BR Memimage s -rather than +rather than .BR Image s. -Similarly, +Similarly, .IR allocmemsubfont , .IR openmemsubfont , .IR freememsubfont , .IR memsubfontwidth , and .I memimagestring -are the +are the .B Memimage -analogues of +analogues of .IR allocsubfont , .IR openfont , .IR freesubfont , .IR strsubfontwidth , and .B string -(see -.IR subfont (3) +(see +.IM subfont (3) and -.IR graphics (3)), +.IM graphics (3) ), except that they operate -only on +only on .BR Memsubfont s rather than .BR Font s. .PP .I Drawclip takes the images involved in a draw operation, -together with the destination rectangle +together with the destination rectangle .B dr and source and mask alignment points @@ -407,7 +408,7 @@ an end of a given style. .PP The .I hwdraw -and +and .I iprint functions are no-op stubs that may be overridden by clients of the library. @@ -415,7 +416,7 @@ of the library. is called at each call to .I memimagedraw with the current request's parameters. -If it can satisfy the request, it should do so +If it can satisfy the request, it should do so and return 1. If it cannot satisfy the request, it should return 0. This allows (for instance) the kernel to take advantage @@ -432,15 +433,15 @@ prints to a serial line rather than the screen, for obvious reasons. .SH SOURCE .B \*9/src/libmemdraw .SH SEE ALSO -.IR addpt (3), -.IR color (3), -.IR draw (3), -.IR graphics (3), -.IR memlayer (3), -.IR stringsize (3), -.IR subfont (3), -.IR color (7), -.IR utf (7) +.IM addpt (3) , +.IM color (3) , +.IM draw (3) , +.IM graphics (3) , +.IM memlayer (3) , +.IM stringsize (3) , +.IM subfont (3) , +.IM color (7) , +.IM utf (7) .SH BUGS .I Memimagestring is unusual in using a subfont rather than a font, diff --git a/man/man3/memlayer.3 b/man/man3/memlayer.3 index a40efdc7a..c13a72a45 100644 --- a/man/man3/memlayer.3 +++ b/man/man3/memlayer.3 @@ -97,18 +97,18 @@ int memunload(Memimage *i, Rectangle r, .PP .SH DESCRIPTION These functions build upon the -.IR memdraw (3) +.IM memdraw (3) interface to maintain overlapping graphical windows on in-memory images. They are used by the kernel to implement the windows interface presented by -.IR draw (3) +.IM draw (3) and -.IR window (3) +.IM window (3) and probably have little use outside of the kernel. .PP The basic function is to extend the definition of a .B Memimage (see -.IR memdraw (3)) +.IM memdraw (3) ) to include overlapping windows defined by the .B Memlayer type. @@ -270,7 +270,7 @@ They have the signatures of and .I memimageline (see -.IR memdraw (3)) +.IM memdraw (3) ) but accept .B Memlayer or @@ -294,12 +294,12 @@ bytes of data in .I buf are in compressed image format (see -.IR image (7)). +.IM image (7) ). .SH SOURCE .B \*9/src/libmemlayer .SH SEE ALSO -.IR graphics (3), -.IR memdraw (3), -.IR stringsize (3), -.IR window (3), -.IR draw (3) +.IM graphics (3) , +.IM memdraw (3) , +.IM stringsize (3) , +.IM window (3) , +.IM draw (3) diff --git a/man/man3/memory.3 b/man/man3/memory.3 index 51e54479f..fefb9ba3a 100644 --- a/man/man3/memory.3 +++ b/man/man3/memory.3 @@ -109,7 +109,7 @@ All these routines have portable C implementations in .\" Most also have machine-dependent assembly language implementations in .\" .BR \*9/lib9/$objtype . .SH SEE ALSO -.IR strcat (3) +.IM strcat (3) .SH BUGS ANSI C does not require .I memcpy diff --git a/man/man3/mouse.3 b/man/man3/mouse.3 index b5061fd92..6974dfa63 100644 --- a/man/man3/mouse.3 +++ b/man/man3/mouse.3 @@ -49,9 +49,9 @@ They use the message-passing .B Channel interface in the threads library (see -.IR thread (3)); +.IM thread (3) ); programs that wish a more event-driven, single-threaded approach should use -.IR event (3). +.IM event (3) . .PP The state of the mouse is recorded in a structure, .BR Mouse , @@ -107,7 +107,7 @@ are a naming the device file connected to the mouse and an .I Image (see -.IR draw (3)) +.IM draw (3) ) on which the mouse will be visible. Typically the file is nil, @@ -136,7 +136,7 @@ The actual value sent may be discarded; the receipt of the message tells the program that it should call .B getwindow (see -.IR graphics (3)) +.IM graphics (3) ) to reconnect to the window. .PP .I Readmouse @@ -152,7 +152,7 @@ or message sent on the channel. It calls .B flushimage (see -.IR graphics (3)) +.IM graphics (3) ) before blocking, so any buffered graphics requests are displayed. .PP .I Closemouse @@ -174,14 +174,14 @@ is nil, the cursor is set to the default. The format of the cursor data is spelled out in .B and described in -.IR graphics (3). +.IM graphics (3) . .PP .I Getrect returns the dimensions of a rectangle swept by the user, using the mouse, in the manner -.IR rio (1) +.IM rio (1) or -.IR sam (1) +.IM sam (1) uses to create a new window. The .I but @@ -220,7 +220,7 @@ struct Menu behaves the same as its namesake .I emenuhit described in -.IR event (3), +.IM event (3) , with two exceptions. First, it uses a .B Mousectl @@ -230,7 +230,7 @@ it creates the menu as a true window on the .B Screen .I scr (see -.IR window (3)), +.IM window (3) ), permitting the menu to be displayed in parallel with other activities on the display. If .I scr @@ -244,8 +244,8 @@ restoring the display when the menu is removed. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR draw (3), -.IR event (3), -.IR keyboard (3), -.IR thread (3). +.IM graphics (3) , +.IM draw (3) , +.IM event (3) , +.IM keyboard (3) , +.IM thread (3) . diff --git a/man/man3/mousescrollsize.3 b/man/man3/mousescrollsize.3 index 981473568..4595a68d5 100644 --- a/man/man3/mousescrollsize.3 +++ b/man/man3/mousescrollsize.3 @@ -28,15 +28,15 @@ causes a half-window scroll increment. .PP .I Mousescrollsize is used by -.IR 9term (1) +.IM 9term (1) and -.IR acme (1) +.IM acme (1) to set their scrolling behavior. .SH SOURCE .B \*9/src/libdraw/scroll.c .SH SEE ALSO -.IR 9term (1), -.IR acme (1) +.IM 9term (1) , +.IM acme (1) .SH BUGS .I Libdraw expects up and down scroll wheel events to be expressed as clicks of mouse buttons 4 and 5, diff --git a/man/man3/mp.3 b/man/man3/mp.3 index f0028c3f6..ad61ed904 100644 --- a/man/man3/mp.3 +++ b/man/man3/mp.3 @@ -315,9 +315,9 @@ is the buffer is allocated. .I Mpfmt can be used with -.IR fmtinstall (3) +.IM fmtinstall (3) and -.IR print (3) +.IM print (3) to print hexadecimal representations of .BR mpint s. .PP diff --git a/man/man3/mux.3 b/man/man3/mux.3 index 0c429fba9..180528b9e 100644 --- a/man/man3/mux.3 +++ b/man/man3/mux.3 @@ -123,7 +123,7 @@ nil if an error occurred. .I Muxprocs allocates new procs (see -.IR thread (3)) +.IM thread (3) ) in which to run .I send and @@ -146,7 +146,7 @@ that need to remain active. .I Libmux also provides a non-blocking interface, useful for programs forced to use a -.IR select (3)-based +.IM select (3) -based main loop. .I Muxrpcstart runs the first half of @@ -176,7 +176,7 @@ with .SH SOURCE .B \*9/src/libmux .SH SEE ALSO -.IR thread (3), +.IM thread (3) , .IR intro (9p) .SH BUGS .I Libmux diff --git a/man/man3/ndb.3 b/man/man3/ndb.3 index 14c845b65..2392f3ff5 100644 --- a/man/man3/ndb.3 +++ b/man/man3/ndb.3 @@ -88,13 +88,13 @@ Ndbtuple* ndbsubstitute(Ndbtuple *t, Ndbtuple *from, Ndbtuple *to); These routines are used by network administrative programs to search the network database. They operate on the database files described in -.IR ndb (7). +.IM ndb (7) . .PP .I Ndbopen opens the database .I file and calls -.IR malloc (3) +.IM malloc (3) to allocate a buffer for it. If .I file @@ -128,7 +128,7 @@ is used to find each successive match. On a successful search both return a linked list of .I Ndbtuple structures acquired by -.IR malloc (3) +.IM malloc (3) that represent the attribute/value pairs in the entry. On failure they return zero. @@ -450,8 +450,8 @@ directory of network database files .SH SOURCE .B \*9/src/libndb .SH SEE ALSO -.IR ndb (1) -.IR ndb (7) +.IM ndb (1) +.IM ndb (7) .SH DIAGNOSTICS .IR Ndbgetvalue and diff --git a/man/man3/needstack.3 b/man/man3/needstack.3 index 071b89165..c19d15534 100644 --- a/man/man3/needstack.3 +++ b/man/man3/needstack.3 @@ -45,7 +45,7 @@ is a no-op. .I Needstack should be thought of as a comment checked at run time, like -.IR assert (3). +.IM assert (3) . .SH EXAMPLE The X Window library implementation of .I XLookupString @@ -57,7 +57,7 @@ before making calls to .IR XLookupString . If a thread (in this case, the keyboard-reading thread used inside the -.IR draw (3) +.IM draw (3) library) does not allocate a large enough stack, the problem is diagnosed immediately rather than left to corrupt memory. @@ -66,4 +66,4 @@ immediately rather than left to corrupt memory. .br .B \*9/src/libthread .SH SEE ALSO -.IR thread (3) +.IM thread (3) diff --git a/man/man3/notify.3 b/man/man3/notify.3 index 7dd768e74..269fe4b07 100644 --- a/man/man3/notify.3 +++ b/man/man3/notify.3 @@ -33,12 +33,12 @@ or writing on a closed pipe, a is posted to communicate the exception. A note may also be posted by another process via -.IR postnote (3). +.IM postnote (3) . On Unix, notes are implemented as signals. .PP When a note is received, the action taken depends on the note. See -.IR signal (7) +.IM signal (7) for the full description of the defaults. .PP The default actions may be overridden. @@ -53,10 +53,10 @@ replaces the previous handler, if any. An argument of zero cancels a previous handler, restoring the default action. A -.IR fork (2) +.IM fork (2) system call leaves the handler registered in both the parent and the child; -.IR exec (3) +.IM exec (3) restores the default behavior. Handlers may not perform floating point operations. .PP @@ -112,17 +112,17 @@ set up with using the .I notejmp function (see -.IR setjmp (3)). +.IM setjmp (3) ). .PP Unix provides a fixed set of notes (typically there are 32) called .IR signals . It also allows a process to block certain notes from being delivered (see -.IR sigprocmask (2)) +.IM sigprocmask (2) ) and to ignore certain notes by setting the signal hander to the special value .B SIG_IGN (see -.IR signal (2)). +.IM signal (2) ). .I Noteenable and .I notedisable @@ -137,7 +137,7 @@ is called upon receipt of the note; if the handler is not called, the note is di Regardless of the origin of the note or the presence of a handler, if the process is being debugged (see -.IR ptrace (2)) +.IM ptrace (2) ) the arrival of a note puts the process in the .B Stopped state and awakens the debugger. @@ -252,7 +252,7 @@ are usually generated by the operating system. .br .B \*9/src/lib9/atnotify.c .SH SEE ALSO -.IR intro (3), +.IM intro (3) , .I notejmp in -.IR setjmp (3) +.IM setjmp (3) diff --git a/man/man3/open.3 b/man/man3/open.3 index 750aa65c7..adc38feb1 100644 --- a/man/man3/open.3 +++ b/man/man3/open.3 @@ -34,7 +34,7 @@ says to truncate the file to zero length before opening it; .B OCEXEC says to close the file when an -.IR exec (3) +.IM exec (3) or .I execl system call is made; @@ -48,7 +48,7 @@ are always appended to the end of the file. fails if the file does not exist or the user does not have permission to open it for the requested purpose (see -.IR stat (3) +.IM stat (3) for a description of permissions). The user must have write permission on the .I file @@ -61,7 +61,7 @@ system call (unlike the implicit .I open in -.IR exec (3)), +.IM exec (3) ), .B OEXEC is actually identical to .BR OREAD . @@ -143,8 +143,8 @@ allows the file descriptor to be reused. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IR intro (3), -.IR stat (3) +.IM intro (3) , +.IM stat (3) .SH DIAGNOSTICS These functions set .IR errstr . @@ -169,4 +169,4 @@ are preprocessor macros defined as and .IR p9create ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/opentemp.3 b/man/man3/opentemp.3 index 63af2da7f..33c0b060a 100644 --- a/man/man3/opentemp.3 +++ b/man/man3/opentemp.3 @@ -25,7 +25,7 @@ to .L z are tried until the name of a file that does not yet exist (see -.IR access (2)) +.IM access (2) ) is generated. .I Opentemp then opens the file for the given @@ -49,4 +49,4 @@ will never return the same name. .SH "SEE ALSO .I create in -.IR open (3) +.IM open (3) diff --git a/man/man3/pipe.3 b/man/man3/pipe.3 index 10decb696..c134eaa27 100644 --- a/man/man3/pipe.3 +++ b/man/man3/pipe.3 @@ -25,7 +25,7 @@ is available for reading from After the pipe has been established, cooperating processes created by subsequent -.IR fork (2) +.IM fork (2) calls may pass data through the pipe with .I read @@ -53,14 +53,14 @@ calls. .\" .IR stat (3)). .PP When all the data has been read from a pipe and the writer has closed the pipe or exited, -.IR read (3) +.IM read (3) will return 0 bytes. Writes to a pipe with no reader will generate a note .BR "sys: write on closed pipe" . .SH SOURCE .B \*9/src/lib9/pipe.c .SH SEE ALSO -.IR intro (3), -.IR read (3) +.IM intro (3) , +.IM read (3) .SH DIAGNOSTICS Sets .IR errstr . @@ -79,7 +79,7 @@ Unix pipes are not guaranteed to be bidirectional. In order to ensure a bidirectional channel, .I p9pipe creates Unix domain sockets via the -.IR socketpair (2) +.IM socketpair (2) instead of Unix pipes. .PP The implementation of pipes as Unix domain sockets @@ -89,11 +89,11 @@ Unix's dup device. If a Unix domain socket is open as file descriptor 0, some implementations disallow the opening of .BR /dev/fd/0 ; instead one must -.IR connect (2) +.IM connect (2) to it. If this functionality is important (as it is for -.IR rc (1)), +.IM rc (1) ), one must .B #undef .B pipe diff --git a/man/man3/plumb.3 b/man/man3/plumb.3 index fa78a2b5a..28185a882 100644 --- a/man/man3/plumb.3 +++ b/man/man3/plumb.3 @@ -68,7 +68,7 @@ Plumbmsg* plumbrecvfid(CFid *fid) int plumbsendtofid(CFid *fid, Plumbmsg *m) .SH DESCRIPTION These routines manipulate -.IR plumb (7) +.IM plumb (7) messages, transmitting them, receiving them, and converting them between text and these data structures: .IP @@ -99,7 +99,7 @@ struct Plumbattr opens the named plumb .IR port , using -.IR open (3) +.IM open (3) mode .IR omode . If @@ -108,11 +108,11 @@ begins with a slash, it is taken as a literal file name; otherwise .I plumbopen searches for the location of the -.IR plumber (4) +.IM plumber (4) service and opens the port there. .PP For programs using the -.IR event (3) +.IM event (3) interface, .I eplumb registers, using the given @@ -121,9 +121,9 @@ receipt of messages from the named .IR port . .PP The library mounts the -.IR plumber (4) +.IM plumber (4) service on demand (using the -.IR 9pclient (3)) +.IM 9pclient (3) ) library and reuses the mount instance for future calls to .IR plumbopen . @@ -157,7 +157,7 @@ to frees all the data associated with the message .IR m , all the components of which must therefore have been allocated with -.IR malloc (3). +.IM malloc (3) . .PP .I Plumbrecv returns the next message available on the file descriptor @@ -259,7 +259,7 @@ The file descriptor returned by is created with .I fsopenfd (see -.IR 9pclient (3)), +.IM 9pclient (3) ), which masks information about read and write errors. This is acceptable for use in .I plumbrecv @@ -276,10 +276,10 @@ that preserves the exact error details. .SH SOURCE .B \*9/src/libplumb .SH SEE ALSO -.IR plumb (1), -.IR event (3), -.IR plumber (4), -.IR plumb (7) +.IM plumb (1) , +.IM event (3) , +.IM plumber (4) , +.IM plumb (7) .SH DIAGNOSTICS When appropriate, including when a .I plumbsend diff --git a/man/man3/post9pservice.3 b/man/man3/post9pservice.3 index c3b69d71c..4bf1a68b1 100644 --- a/man/man3/post9pservice.3 +++ b/man/man3/post9pservice.3 @@ -11,11 +11,11 @@ int post9pservice(int fd, char *name, char *mtpt) .SH DESCRIPTION .I Post9pservice invokes -.IR 9pserve (4) +.IM 9pserve (4) to post a new 9P service in the current ``name space'' (see -.IR intro (4)) +.IM intro (4) ) named .IR name . Clients connecting to the posted service @@ -30,10 +30,10 @@ is non-nil, mounts the service on .IR mtpt , using -.IR 9pfuse (4). +.IM 9pfuse (4) . .SH "SEE ALSO -.IR intro (4), -.IR 9pfuse (4), -.IR 9pserve (4) +.IM intro (4) , +.IM 9pfuse (4) , +.IM 9pserve (4) .SH SOURCE .B \*9/src/lib9/post9p.c diff --git a/man/man3/postnote.3 b/man/man3/postnote.3 index 7c323964e..3dd7796d0 100644 --- a/man/man3/postnote.3 +++ b/man/man3/postnote.3 @@ -38,8 +38,8 @@ Returns zero if the write succeeds, otherwise \-1. .SH SOURCE .B \*9/src/lib9/postnote.c .SH "SEE ALSO" -.IR notify (3), -.IR intro (3) +.IM notify (3) , +.IM intro (3) .SH DIAGNOSTICS Sets .IR errstr . diff --git a/man/man3/prime.3 b/man/man3/prime.3 index 01a308e8a..4e4987d3f 100644 --- a/man/man3/prime.3 +++ b/man/man3/prime.3 @@ -93,8 +93,8 @@ slow algorithm. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR aes (3) -.IR blowfish (3), -.IR des (3), -.IR elgamal (3), -.IR rsa (3), +.IM aes (3) +.IM blowfish (3) , +.IM des (3) , +.IM elgamal (3) , +.IM rsa (3) , diff --git a/man/man3/print.3 b/man/man3/print.3 index a701bc040..997b5cb3a 100644 --- a/man/man3/print.3 +++ b/man/man3/print.3 @@ -67,7 +67,7 @@ writes to the named output file descriptor: a buffered form is described in -.IR bio (3). +.IM bio (3) . .I Sprint places text followed by the NUL character @@ -104,7 +104,7 @@ is like .IR sprint , except that it prints into and returns a string of the required length, which is allocated by -.IR malloc (3). +.IM malloc (3) . .PP The routines .IR runesprint , @@ -361,7 +361,7 @@ The .B S verb is similar, but it interprets its pointer as an array of runes (see -.IR utf (7)); +.IM utf (7) ); the runes are converted to .SM UTF before output. @@ -389,10 +389,10 @@ but that will change if pointers and integers are different sizes. The .B r verb takes no arguments; it copies the error string returned by a call to -.IR errstr (3). +.IM errstr (3) . .PP Custom verbs may be installed using -.IR fmtinstall (3). +.IM fmtinstall (3) . .SH EXAMPLE This function prints an error message with a variable number of arguments and then quits. @@ -415,9 +415,9 @@ void fatal(char *msg, ...) .SH SOURCE .B \*9/src/lib9/fmt .SH SEE ALSO -.IR fmtinstall (3), -.IR fprintf (3), -.IR utf (7) +.IM fmtinstall (3) , +.IM fprintf (3) , +.IM utf (7) .SH DIAGNOSTICS Routines that write to a file descriptor or call .IR malloc @@ -425,7 +425,7 @@ set .IR errstr . .SH BUGS The formatting is close to that specified for ANSI -.IR fprintf (3); +.IM fprintf (3) ; the main difference is that .B b and diff --git a/man/man3/proto.3 b/man/man3/proto.3 index 2d5da3afc..eceb63813 100644 --- a/man/man3/proto.3 +++ b/man/man3/proto.3 @@ -24,7 +24,7 @@ int rdproto(char *proto, char *root, Protoenum *enm, .I Rdproto reads and interprets the named .I proto -file relative to the +file relative to the root directory .IR root . .PP @@ -45,9 +45,9 @@ The fifth field is the name of the file from which to copy; this file is read from the current name space, not the source file tree. All fields except the first are optional. -Specifying +Specifying .B - -for permissions, owner, or group +for permissions, owner, or group causes .I rdproto to fetch the corresponding information @@ -92,29 +92,29 @@ Only the and .B length fields are guaranteed to be valid. -The argument +The argument .I a is the same argument passed to .IR rdproto ; typically it points at some extra state used by the enumeration function. .PP -When files or directories do not exist or -cannot be read by +When files or directories do not exist or +cannot be read by .IR rdproto , -it formats a warning message, calls +it formats a warning message, calls .IR warn , -and continues processing; +and continues processing; if .I warn -is nil, +is nil, .I rdproto prints the warning message to standard error. .PP .I Rdproto returns zero if -.I proto +.I proto was processed, \-1 if it could not be opened. .SH FILES .TF /sys/lib/sysconfig/proto/portproto @@ -127,5 +127,6 @@ generic prototype file. .SH SOURCE .B \*9/src/libdisk/proto.c .SH SEE ALSO -.IR mk9660 (1), -Plan 9's \fImkfs\fR(8) +.IM mk9660 (1) , +Plan 9's +.IR mkfs (8) diff --git a/man/man3/pushtls.3 b/man/man3/pushtls.3 index fa0a080ca..21730d337 100644 --- a/man/man3/pushtls.3 +++ b/man/man3/pushtls.3 @@ -46,7 +46,7 @@ TLS is nearly the same as SSL 3.0, and the software should interoperate with implementations of either standard. .PP To use just the record layer, as described in Plan 9's -\fItls\fR(3), +.IR tls (3), call .I pushtls to open the record layer device, connect to the communications channel @@ -108,7 +108,7 @@ used by a client to resume a previously negotiated security association. On output, the connection directory is set, as with .B listen (see -.IR dial (3)). +.IM dial (3) ). The input .I cert is freed and a freshly allocated copy of the remote's certificate @@ -149,7 +149,7 @@ The private key corresponding to .I cert.pem should have been previously loaded into factotum. (See -.IR rsa (3) +.IM rsa (3) .\" XXX should be rsa(8) for more about key generation.) By setting @@ -164,10 +164,10 @@ known to the client. is not required for the ongoing conversation and may be freed by the application whenever convenient. .SH FILES -.TP +.TP .B /sys/lib/tls thumbprints of trusted services -.TP +.TP .B /sys/lib/ssl PEM certificate files .SH SOURCE @@ -175,12 +175,12 @@ PEM certificate files .\" .br .B \*9/src/libsec/port .SH "SEE ALSO" -.IR dial (3), -.IR thumbprint (7); +.IM dial (3) , +.IM thumbprint (7) ; Plan 9's -\fIfactotum\fR(4) +.IR factotum (4) and -\fItls\fR(3) +.IR tls (3) .SH DIAGNOSTICS return \-1 on failure. .SH BUGS diff --git a/man/man3/qball.3 b/man/man3/qball.3 index 5929ece2d..785158c69 100644 --- a/man/man3/qball.3 +++ b/man/man3/qball.3 @@ -68,7 +68,7 @@ and normal to the axis. .SH SOURCE .B \*9/src/libgeometry/qball.c .SH SEE ALSO -.IR quaternion (3) +.IM quaternion (3) .br Ken Shoemake, ``Animating Rotation with Quaternion Curves'', diff --git a/man/man3/quaternion.3 b/man/man3/quaternion.3 index 224baea72..f51a1e7f2 100644 --- a/man/man3/quaternion.3 +++ b/man/man3/quaternion.3 @@ -121,7 +121,7 @@ The following routines operate on rotations or orientations represented as unit .TP .B mtoq Convert a rotation matrix (see -.IR matrix (3)) +.IM matrix (3) ) to a unit quaternion. .TP .B qtom @@ -148,12 +148,12 @@ This is just a rotation about the same axis by half the angle. .SH SOURCE .B \*9/src/libgeometry/quaternion.c .SH SEE ALSO -.IR matrix (3), -.IR qball (3) +.IM matrix (3) , +.IM qball (3) .SH BUGS To avoid name conflicts with NetBSD, .I qdiv is a preprocessor macro defined as .IR p9qdiv ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/quote.3 b/man/man3/quote.3 index ae6c6c28f..d34e4893d 100644 --- a/man/man3/quote.3 +++ b/man/man3/quote.3 @@ -58,10 +58,10 @@ The empty string is represented by two quotes, The first four functions act as variants of .B strdup (see -.IR strcat (3)). +.IM strcat (3) ). Each returns a freshly allocated copy of the string, created using -.IR malloc (3). +.IM malloc (3) . .I Quotestrdup returns a quoted copy of .IR s , @@ -75,7 +75,7 @@ The versions of these functions do the same for .CW Rune strings (see -.IR runestrcat (3)). +.IM runestrcat (3) ). .PP The string returned by .I quotestrdup @@ -124,13 +124,13 @@ blanks, control characters, and quotes are always quoted. is provided as a .I doquote function that flags any character special to -.IR rc (1). +.IM rc (1) . .PP .I Quotestrfmt and .I quoterunestrfmt are -.IR print (3) +.IM print (3) formatting routines that produce quoted strings as output. They may be installed by hand, but .I quotefmtinstall @@ -154,21 +154,21 @@ statements so the compiler can type-check uses of and .B %Q in -.IR print (3) +.IM print (3) format strings. .SH SOURCE .B \*9/src/lib9/quote.c .br .B \*9/src/lib9/fmt/fmtquote.c .SH "SEE ALSO -.IR rc (1), -.IR malloc (3), -.IR print (3), -.IR strcat (3) +.IM rc (1) , +.IM malloc (3) , +.IM print (3) , +.IM strcat (3) .SH BUGS Because it is provided by the format library, .I doquote is a preprocessor macro defined as .IR fmtdoquote ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/rand.3 b/man/man3/rand.3 index 3eaa05f53..8d35e444b 100644 --- a/man/man3/rand.3 +++ b/man/man3/rand.3 @@ -125,7 +125,7 @@ truly random bytes read from .PP .I Prng uses the native -.IR rand (3) +.IM rand (3) pseudo-random number generator to fill the buffer. Used with .IR srand , this function can produce a reproducible stream of pseudo random @@ -138,7 +138,7 @@ and may be passed to .I mprand (see -.IR mp (3)). +.IM mp (3) ). .PP .I Fastrand uses @@ -161,7 +161,7 @@ to return a uniform .B \*9/src/libsec/port .SH "SEE ALSO .\" .IR cons (3), -.IR mp (3) +.IM mp (3) .SH BUGS .I Truerand and @@ -181,7 +181,7 @@ are preprocessor macros defined as .IR p9lrand , and so on; see -.IR intro (3). +.IM intro (3) . .ie \n(HT .ds HT " .el .ds HT " (see HTML-formatted man page for link) .PP diff --git a/man/man3/rc4.3 b/man/man3/rc4.3 index 026c8352f..1b7888d9d 100644 --- a/man/man3/rc4.3 +++ b/man/man3/rc4.3 @@ -43,13 +43,13 @@ structure keeps track of the algorithm. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR blowfish (3), -.IR des (3), -.IR dsa (3), -.IR elgamal (3), -.IR rsa (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM blowfish (3) , +.IM des (3) , +.IM dsa (3) , +.IM elgamal (3) , +.IM rsa (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) diff --git a/man/man3/read.3 b/man/man3/read.3 index cd4dbf3d2..a176ad6d9 100644 --- a/man/man3/read.3 +++ b/man/man3/read.3 @@ -65,7 +65,7 @@ if this is not the same as requested. and .I Pwrite equivalent to a -.IR seek (3) +.IM seek (3) to .I offset followed by a @@ -83,10 +83,10 @@ without interference. .SH SOURCE .B \*9/src/lib9/readn.c .SH SEE ALSO -.IR intro (3), +.IM intro (3) , .IR open (3), -.IR dup (3), -.IR pipe (3) +.IM dup (3) , +.IM pipe (3) .SH DIAGNOSTICS These functions set .IR errstr . diff --git a/man/man3/readcolmap.3 b/man/man3/readcolmap.3 index 82ccdcfd6..d559cdabe 100644 --- a/man/man3/readcolmap.3 +++ b/man/man3/readcolmap.3 @@ -63,14 +63,14 @@ Both return 0 on success, or \-1 on error, setting .PP Changing the hardware color map does not change the color map used by the -.IR draw (3) +.IM draw (3) operator to convert between mapped and true color or greyscale images, which is described in -.IR color (7). +.IM color (7) . .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IR graphics (3), -.IR draw (3), -.IR color (7) +.IM graphics (3) , +.IM draw (3) , +.IM color (7) diff --git a/man/man3/readcons.3 b/man/man3/readcons.3 index dd284b970..cf2df9bad 100644 --- a/man/man3/readcons.3 +++ b/man/man3/readcons.3 @@ -31,7 +31,7 @@ is non-zero, the input is not echoed to the screen. A stripped-down version of .I netkey (see -.IR passwd (1)): +.IM passwd (1) ): .IP .EX pass = readcons("password", nil, 1); diff --git a/man/man3/regexp.3 b/man/man3/regexp.3 index 069e1d232..a7a5ac8b1 100644 --- a/man/man3/regexp.3 +++ b/man/man3/regexp.3 @@ -42,11 +42,11 @@ compiles a regular expression and returns a pointer to the generated description. The space is allocated by -.IR malloc (3) +.IM malloc (3) and may be released by .IR free . Regular expressions are exactly as in -.IR regexp (7). +.IM regexp (7) . .PP .I Regcomplit is like @@ -196,7 +196,7 @@ array elements should be used. .SH SOURCE .B \*9/src/libregexp .SH "SEE ALSO" -.IR grep (1) +.IM grep (1) .SH DIAGNOSTICS .I Regcomp returns diff --git a/man/man3/rfork.3 b/man/man3/rfork.3 index d1d383cc5..df5048f77 100644 --- a/man/man3/rfork.3 +++ b/man/man3/rfork.3 @@ -15,14 +15,14 @@ int rfork(int flags) is a partial implementation of the Plan 9 system call. It can be used to manipulate some process state and to create new processes a la -.IR fork (2). +.IM fork (2) . It cannot be used to create shared-memory processes (Plan 9's .B RFMEM flag); for that functionality use .I proccreate (see -.IR thread (3)). +.IM thread (3) ). .PP The .I flags @@ -45,7 +45,7 @@ If set, the child process will be dissociated from the parent. Upon exit the child will leave no .B Waitmsg (see -.IR wait (3)) +.IM wait (3) ) for the parent to collect. .\" .TP .\" .B RFNAMEG @@ -81,9 +81,9 @@ for the parent to collect. Each process is a member of a group of processes that all receive notes when a note is sent to the group (see -.IR postnote (3) +.IM postnote (3) and -.IR signal (2)). +.IM signal (2) ). The group of a new process is by default the same as its parent, but if .B RFNOTEG is set (regardless of @@ -154,7 +154,7 @@ will sleep, if necessary, until required process resources are available. Calling .B rfork(RFFDG|RFPROC) is equivalent to calling -.IR fork (2). +.IM fork (2) . .SH SOURCE .B \*9/src/lib9/rfork.c .SH DIAGNOSTICS diff --git a/man/man3/rsa.3 b/man/man3/rsa.3 index 0c1396a89..8bea1aab4 100644 --- a/man/man3/rsa.3 +++ b/man/man3/rsa.3 @@ -197,7 +197,7 @@ The subject line is conventionally of the form using the quoting conventions of .I tokenize (see -.IR getfields (3)). +.IM getfields (3) ). .PP .I X509req creates an X.509 certification request. @@ -241,14 +241,14 @@ struct PEMChain .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR mp (3), -.IR aes (3), -.IR blowfish (3), -.IR des (3), -.IR dsa (3), -.IR elgamal (3), -.IR rc4 (3), -.IR sechash (3), -.IR prime (3), -.IR rand (3) +.IM mp (3) , +.IM aes (3) , +.IM blowfish (3) , +.IM des (3) , +.IM dsa (3) , +.IM elgamal (3) , +.IM rc4 (3) , +.IM sechash (3) , +.IM prime (3) , +.IM rand (3) .\" .IR pem (8) diff --git a/man/man3/rune.3 b/man/man3/rune.3 index 5bb2224ee..d4fcf89d1 100644 --- a/man/man3/rune.3 +++ b/man/man3/rune.3 @@ -189,5 +189,5 @@ returns .br .B \*9/src/lib9/utf/utfrune.c .SH SEE ALSO -.IR utf (7), -.IR tcs (1) +.IM utf (7) , +.IM tcs (1) diff --git a/man/man3/runestrcat.3 b/man/man3/runestrcat.3 index 347c7219f..eff637e41 100644 --- a/man/man3/runestrcat.3 +++ b/man/man3/runestrcat.3 @@ -56,12 +56,12 @@ Rune* runestrstr(Rune *s1, Rune *s2) .SH DESCRIPTION These functions are rune string analogues of the corresponding functions in -.IR strcat (3). +.IM strcat (3) . .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IR memory (3), -.IR rune (3), -.IR strcat (3) +.IM memory (3) , +.IM rune (3) , +.IM strcat (3) .SH BUGS The outcome of overlapping moves varies among implementations. diff --git a/man/man3/searchpath.3 b/man/man3/searchpath.3 index e0709b2e9..77c91f94c 100644 --- a/man/man3/searchpath.3 +++ b/man/man3/searchpath.3 @@ -13,9 +13,9 @@ char* searchpath(char *name) searches for the executable .I name in the same way that -.IR sh (1) +.IM sh (1) and -.IR rc (1) +.IM rc (1) do. .PP The environment variable @@ -32,9 +32,9 @@ returns a pointer to a malloced string containing a path or simply .IR name ) suitable for use in -.IR open (3) +.IM open (3) or -.IR exec (3). +.IM exec (3) . .PP If .I name diff --git a/man/man3/sechash.3 b/man/man3/sechash.3 index d8b1cd48c..a7c6970d4 100644 --- a/man/man3/sechash.3 +++ b/man/man3/sechash.3 @@ -138,14 +138,14 @@ and .I sha1unpickle unmarshal a pickled digest. All four routines return a pointer to a newly -.IR malloc (3)'d +.IM malloc (3) 'd object. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IR aes (3), -.IR blowfish (3), -.IR des (3), -.IR elgamal (3), -.IR rc4 (3), -.IR rsa (3) +.IM aes (3) , +.IM blowfish (3) , +.IM des (3) , +.IM elgamal (3) , +.IM rc4 (3) , +.IM rsa (3) diff --git a/man/man3/seek.3 b/man/man3/seek.3 index 36c594c4b..a95f37ff4 100644 --- a/man/man3/seek.3 +++ b/man/man3/seek.3 @@ -39,8 +39,8 @@ Seeking in a pipe is a no-op. .SH SOURCE .B \*9/src/lib9/seek.c .SH SEE ALSO -.IR intro (3), -.IR open (3) +.IM intro (3) , +.IM open (3) .SH DIAGNOSTICS Sets .IR errstr . @@ -50,4 +50,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9seek ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/sendfd.3 b/man/man3/sendfd.3 index 771bd9ae5..82fd8a499 100644 --- a/man/man3/sendfd.3 +++ b/man/man3/sendfd.3 @@ -20,14 +20,14 @@ and can be used to pass an open file descriptor over a Unix domain socket from one process to another. Since -.IR pipe (3) +.IM pipe (3) is implemented with -.IR socketpair (2) +.IM socketpair (2) instead of -.IR pipe (2), +.IM pipe (2) , .I socket can be a file descriptor obtained from -.IR pipe (3). +.IM pipe (3) . .PP .I Sendfd sends the file descriptor @@ -51,7 +51,7 @@ will not. .SH SOURCE .B \*9/src/lib9/sendfd.c .SH SEE ALSO -.IR socketpair (2), +.IM socketpair (2) , .I sendmsg in -.IR send (2) +.IM send (2) diff --git a/man/man3/setjmp.3 b/man/man3/setjmp.3 index 1210c1712..16fb0387e 100644 --- a/man/man3/setjmp.3 +++ b/man/man3/setjmp.3 @@ -46,7 +46,7 @@ was called. is the same as .I longjmp except that it is to be called from within a note handler (see -.IR notify (3)). +.IM notify (3) ). The .I uregs argument should be the first argument passed to the note handler. @@ -58,7 +58,7 @@ can also be used to switch stacks. .SH SOURCE .B \*9/src/lib9/jmp.c .SH SEE ALSO -.IR notify (3) +.IM notify (3) .SH BUGS .PP .I Notejmp @@ -78,10 +78,11 @@ are preprocessor macros defined as and .IR p9jmp_buf ; see -.IR intro (3). +.IM intro (3) . .PP .I P9setjmp is implemented as a preprocessor macro that calls .I sigsetjmp (see -Unix's \fIsetjmp\fR(3)). +Unix's +.IR setjmp (3)). diff --git a/man/man3/sleep.3 b/man/man3/sleep.3 index 0afa71d22..0bccc15f8 100644 --- a/man/man3/sleep.3 +++ b/man/man3/sleep.3 @@ -27,7 +27,7 @@ Sleep returns \-1 if interrupted, 0 otherwise. causes an .B alarm note (see -.IR notify (3)) +.IM notify (3) ) to be sent to the invoking process after the number of milliseconds given by the argument. Successive calls to @@ -39,7 +39,7 @@ the alarm clock. .SH SOURCE .B \*9/src/lib9/sleep.c .SH SEE ALSO -.IR intro (3) +.IM intro (3) .SH DIAGNOSTICS These functions set .IR errstr . @@ -53,4 +53,4 @@ are preprocessor macros defined as and .IR p9alarm ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/stat.3 b/man/man3/stat.3 index a992f9a53..253833f64 100644 --- a/man/man3/stat.3 +++ b/man/man3/stat.3 @@ -105,7 +105,7 @@ struct Dir { .EE .PP The returned structure is allocated by -.IR malloc (3); +.IM malloc (3) ; freeing it also frees the associated strings. .PP This structure and @@ -283,9 +283,9 @@ to retrieve the initial values first. .SH SOURCE .B \*9/src/lib9/dirstat.c .SH SEE ALSO -.IR intro (3), -.IR fcall (3), -.IR dirread (3), +.IM intro (3) , +.IM fcall (3) , +.IM dirread (3) , .IR stat (9p) .SH DIAGNOSTICS The @@ -305,7 +305,7 @@ or is too short for the returned data, the return value will be .B BIT16SZ (see -.IR fcall (3)) +.IM fcall (3) ) and the two bytes returned will contain the initial count field of the returned data; diff --git a/man/man3/strcat.3 b/man/man3/strcat.3 index 2baa90909..3cf294778 100644 --- a/man/man3/strcat.3 +++ b/man/man3/strcat.3 @@ -222,7 +222,7 @@ is returned. returns a pointer to a distinct copy of the null-terminated string .I s in space obtained from -.IR malloc (3) +.IM malloc (3) or .L 0 if no space can be obtained. @@ -244,14 +244,14 @@ operates analogously, but ignores ASCII case differences when comparing strings. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IR memory (3), -.IR rune (3), -.IR runestrcat (3) +.IM memory (3) , +.IM rune (3) , +.IM runestrcat (3) .SH BUGS These routines know nothing about .SM UTF. Use the routines in -.IR rune (3) +.IM rune (3) as appropriate. Note, however, that the definition of .SM UTF diff --git a/man/man3/string.3 b/man/man3/string.3 index 9b88e8d4b..7862bb280 100644 --- a/man/man3/string.3 +++ b/man/man3/string.3 @@ -268,4 +268,4 @@ The input stack has a maximum depth of 32 nested include files. .SH SOURCE .B \*9/src/libString .SH SEE ALSO -.IR bio (3) +.IM bio (3) diff --git a/man/man3/stringsize.3 b/man/man3/stringsize.3 index cbf154531..3ad0054cf 100644 --- a/man/man3/stringsize.3 +++ b/man/man3/stringsize.3 @@ -57,13 +57,13 @@ are analogous, but accept an array of runes rather than .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IR addpt (3), -.IR cachechars (3), -.IR subfont (3), -.IR draw (3), -.IR draw (3), -.IR image (7), -.IR font (7) +.IM addpt (3) , +.IM cachechars (3) , +.IM subfont (3) , +.IM draw (3) , +.IM draw (3) , +.IM image (7) , +.IM font (7) .SH DIAGNOSTICS Because strings are loaded dynamically, these routines may generate I/O to the server and produce calls to the graphics error function. diff --git a/man/man3/subfont.3 b/man/man3/subfont.3 index 5e1b09ab6..e321b7da5 100644 --- a/man/man3/subfont.3 +++ b/man/man3/subfont.3 @@ -53,13 +53,13 @@ Font* mkfont(Subfont *f, Rune min) .SH DESCRIPTION Subfonts are the components of fonts that hold the character images. A font comprises an array of subfonts; see -.IR cachechars (3). +.IM cachechars (3) . A new .B Subfont is allocated and initialized with .IR allocsubfont . See -.IR cachechars (3) +.IM cachechars (3) for the meaning of .IR n , .IR height , @@ -81,7 +81,7 @@ The appropriate fields of the returned structure are set to the passed arguments, and the image is registered as a subfont with the graphics device -.IR draw (3). +.IM draw (3) . .I Allocsubfont returns 0 on failure. .PP @@ -97,7 +97,7 @@ on if .B f->info was not allocated by -.IR malloc (3) +.IM malloc (3) it should be zeroed before calling .IR subffree . .PP @@ -150,7 +150,7 @@ Although it is principally a routine internal to the library, may be substituted by the application to provide a less file-oriented subfont naming scheme. .PP The format of a subfont file is described in -.IR font (7). +.IM font (7) . Briefly, it contains a image with all the characters in it, followed by a subfont header, followed by character information. .I Readsubfont @@ -181,13 +181,13 @@ the part of a subfont file that comes after the image. It should be preceded by a call to .IR writeimage (see -.IR allocimage (3)). +.IM allocimage (3) ). .PP .I Stringsubfont is analogous to .B string (see -.IR draw (3)) +.IM draw (3) ) for subfonts. Rather than use the underlying font caching primitives, it calls .B draw @@ -224,12 +224,12 @@ bitmap font file tree .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR allocimage (3), -.IR draw (3), -.IR cachechars (3), -.IR image (7), -.IR font (7) +.IM graphics (3) , +.IM allocimage (3) , +.IM draw (3) , +.IM cachechars (3) , +.IM image (7) , +.IM font (7) .SH DIAGNOSTICS All of the functions use the graphics error function (see -.IR graphics (3)). +.IM graphics (3) ). diff --git a/man/man3/sysfatal.3 b/man/man3/sysfatal.3 index c1e9b83c7..8684ea127 100644 --- a/man/man3/sysfatal.3 +++ b/man/man3/sysfatal.3 @@ -16,17 +16,17 @@ void sysfatal(char *fmt, ...) prints to standard error the name of the running program, a colon and a space, the message described by the -.IR print (3) +.IM print (3) format string .I fmt and subsequent arguments, and a newline. It then calls -.IR exits (3) +.IM exits (3) with the formatted message as argument. The program's name is the value of .BR argv0 , which will be set if the program uses the -.IR arg (3) +.IM arg (3) interface to process its arguments. If .B argv0 @@ -44,7 +44,7 @@ The message is a line with several fields: the name of the machine writing the message; the date and time; the message specified by the -.IR print (3) +.IM print (3) format .I fmt and any following arguments; @@ -60,9 +60,9 @@ can be used safely in multi-threaded programs. .br .B \*9/src/lib9/syslog.c .SH "SEE ALSO" -.IR intro (3), -.IR errstr (3), +.IM intro (3) , +.IM errstr (3) , the .B %r format in -.IR print (3) +.IM print (3) diff --git a/man/man3/thread.3 b/man/man3/thread.3 index 9088ae2e7..41ac565f3 100644 --- a/man/man3/thread.3 +++ b/man/man3/thread.3 @@ -267,10 +267,10 @@ in arbitrary ways and should synchronize their actions using .B qlocks (see -.IR lock (3)) +.IM lock (3) ) or channel communication. System calls such as -.IR read (3) +.IM read (3) block the entire proc; all threads in a proc block until the system call finishes. .PP @@ -364,7 +364,7 @@ are threaded analogues of and .I execl (see -.IR exec (3)); +.IM exec (3) ); on success, they replace the calling thread and invoke the external program, never returning. @@ -400,7 +400,7 @@ and .I threadexec will duplicate (see -.IR dup (3)) +.IM dup (3) ) the three file descriptors in .I fd onto standard input, output, and error for the external program @@ -443,14 +443,14 @@ stop the running of the program. returns a channel of pointers to .B Waitmsg structures (see -.IR wait (3)). +.IM wait (3) ). When an exec'ed process exits, a pointer to a .B Waitmsg is sent to this channel. These .B Waitmsg structures have been allocated with -.IR malloc (3) +.IM malloc (3) and should be freed after use. .PP A @@ -611,13 +611,13 @@ calls. .PP .I Chanprint formats its arguments in the manner of -.IR print (3) +.IM print (3) and sends the result to the channel .IR c. The string delivered by .I chanprint is allocated with -.IR malloc (3) +.IM malloc (3) and should be freed upon receipt. .PP Thread library functions do not return on failure; @@ -628,10 +628,10 @@ Threaded programs should use in place of .I atnotify (see -.IR notify (3)). +.IM notify (3) ). .PP It is safe to use -.IR sysfatal (3) +.IM sysfatal (3) in threaded programs. .I Sysfatal will print the error string and call @@ -673,7 +673,7 @@ To create new processes, use .SH FILES .B \*9/acid/thread contains useful -.IR acid (1) +.IM acid (1) functions for debugging threaded programs. .PP .B \*9/src/libthread/test @@ -681,8 +681,8 @@ contains some example programs. .SH SOURCE .B \*9/src/libthread .SH SEE ALSO -.IR intro (3), -.IR ioproc (3) +.IM intro (3) , +.IM ioproc (3) .SH BUGS To avoid name conflicts, .IR alt , @@ -707,7 +707,7 @@ and so on. is defined as a macro that expands to .IR threadyield . See -.IR intro (3). +.IM intro (3) . .PP Threadint, threadintgrp, diff --git a/man/man3/time.3 b/man/man3/time.3 index dfcafaf90..583a2d7fd 100644 --- a/man/man3/time.3 +++ b/man/man3/time.3 @@ -41,4 +41,4 @@ are preprocessor macros defined as and .IR p9nsec ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/udpread.3 b/man/man3/udpread.3 index 11412596a..80142526e 100644 --- a/man/man3/udpread.3 +++ b/man/man3/udpread.3 @@ -65,4 +65,4 @@ to send a response back to the sender of the original packet. .SH SOURCE .B \*9/src/lib9/udp.c .SH SEE ALSO -.IR ip (3) +.IM ip (3) diff --git a/man/man3/venti-cache.3 b/man/man3/venti-cache.3 index 54e46c619..8c2bd33d8 100644 --- a/man/man3/venti-cache.3 +++ b/man/man3/venti-cache.3 @@ -112,9 +112,9 @@ the block's cache address. allocates a new cache using the client connection .I z (see -.IR venti-conn (3) +.IM venti-conn (3) and -.IR venti-client (3)), +.IM venti-client (3) ), with .I maxmem bytes of memory. @@ -195,7 +195,7 @@ The default function is .I vtwrite (see -.IR venti-client (3)); +.IM venti-client (3) ); .I vtsetcachewrite sets it. .I Vtsetcachewrite @@ -230,8 +230,8 @@ or, more commonly, that cache blocks are being leaked. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3), -.IR venti-client (3), -.IR venti-conn (3), -.IR venti-file (3), -.IR venti (7) +.IM venti (3) , +.IM venti-client (3) , +.IM venti-conn (3) , +.IM venti-file (3) , +.IM venti (7) diff --git a/man/man3/venti-client.3 b/man/man3/venti-client.3 index cc8d14f49..e475ef300 100644 --- a/man/man3/venti-client.3 +++ b/man/man3/venti-client.3 @@ -53,7 +53,7 @@ int vtping(VtConn *z) extern int ventidoublechecksha1; /* default 1 */ .SH DESCRIPTION These routines execute the client side of the -.IR venti (7) +.IM venti (7) protocol. .PP .I Vtrpc @@ -84,7 +84,7 @@ is typically called only indirectly, via calls .I vtversion (see -.IR venti-conn (3)) +.IM venti-conn (3) ) and .IR vthello , in that order, returning success only @@ -171,14 +171,14 @@ in the same proc should start separate procs running and .I vtrecvproc as described in -.IR venti-conn (3). +.IM venti-conn (3) . .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3), -.IR venti-conn (3), -.IR venti-packet (3), -.IR venti (7) +.IM venti (3) , +.IM venti-conn (3) , +.IM venti-packet (3) , +.IM venti (7) .SH DIAGNOSTICS .I Vtrpc and diff --git a/man/man3/venti-conn.3 b/man/man3/venti-conn.3 index ea597de3a..0c1b95d54 100644 --- a/man/man3/venti-conn.3 +++ b/man/man3/venti-conn.3 @@ -90,21 +90,21 @@ for reading and writing. .I Vtdial dials the given network address (see -.IR dial (3)) +.IM dial (3) ) and returns a corresponding connection. It returns nil if the connection cannot be established. .PP .I Vtversion exchanges version information with the remote side as described in -.IR venti (7). +.IM venti (7) . The negotiated version is stored in .IB z ->version \fR. .PP .I Vtsend writes a packet (see -.IR venti-packet (3)) +.IM venti-packet (3) ) on the connection .IR z . The packet @@ -115,7 +115,7 @@ be returned by .I vtsend will add the two-byte length field (see -.IR venti (7)) +.IM venti (7) ) at the begnning. .I Vtsend frees @@ -137,7 +137,7 @@ and block until the packet can be written or read from the network. In a threaded program (see -.IR thread (3)), +.IM thread (3) ), this may not be desirable. If the caller arranges for .IR vtsendproc @@ -192,12 +192,12 @@ as they are sent or received. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (1), -.IR venti (3), -.IR venti-client (3), -.IR venti-packet (3), -.IR venti-server (3), -.IR venti (7) +.IM venti (1) , +.IM venti (3) , +.IM venti-client (3) , +.IM venti-packet (3) , +.IM venti-server (3) , +.IM venti (7) .SH DIAGNOSTICS Routines that return pointers return nil on error. Routines returning integers return 0 on success, \-1 on error. diff --git a/man/man3/venti-fcall.3 b/man/man3/venti-fcall.3 index ed3916ffd..e463c141f 100644 --- a/man/man3/venti-fcall.3 +++ b/man/man3/venti-fcall.3 @@ -109,7 +109,7 @@ converts a .B VtEntry structure describing a Venti file (see -.IR venti (7)) +.IM venti (7) ) into a 40-byte .RB ( VtEntrySize ) structure at @@ -122,7 +122,7 @@ converts a .B VtFcall structure describing a Venti protocol message (see -.IR venti (7)) +.IM venti (7) ) into a packet. .I Vtfcallunpack does the reverse conversion. @@ -130,7 +130,7 @@ does the reverse conversion. The fields in a .B VtFcall are named after the protocol fields described in -.IR venti (7), +.IM venti (7) , except that the .B type field is renamed @@ -158,7 +158,7 @@ and the packet The block type enumeration defined in .B (presented in -.IR venti (7)) +.IM venti (7) ) differs from the one used on disk and in the network protocol. The disk and network representation uses different @@ -232,7 +232,7 @@ is nil, the label is ignored. and .I vtscorefmt are -.IR print (3) +.IM print (3) formatters to print .B VtFcall structures and scores. @@ -244,9 +244,9 @@ is installed as .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (1), -.IR venti (3), -.IR venti (7) +.IM venti (1) , +.IM venti (3) , +.IM venti (7) .SH DIAGNOSTICS .IR Vtentrypack , .IR vtfcallpack , diff --git a/man/man3/venti-file.3 b/man/man3/venti-file.3 index 5378bf5c2..01003f783 100644 --- a/man/man3/venti-file.3 +++ b/man/man3/venti-file.3 @@ -99,7 +99,7 @@ void vtfileunlock(VtFile *f); .SH DESCRIPTION These routines provide a simple interface to create and manipulate Venti file trees (see -.IR venti (7)). +.IM venti (7) ). .PP .I Vtfilecreateroot creates a new Venti file. @@ -226,7 +226,7 @@ if an error is encountered. .I Vtfilewrite writes to an in-memory copy of the data blocks (see -.IR venti-cache (3)) +.IM venti-cache (3) ) instead of writing directly to Venti. .I Vtfileflush writes all copied blocks associated with @@ -319,7 +319,7 @@ in the same directory block. .SH SOURCE .B \*9/src/libventi/file.c .SH SEE ALSO -.IR venti-cache (3), -.IR venti-conn (3), -.IR venti-client (3), -.IR venti (7) +.IM venti-cache (3) , +.IM venti-conn (3) , +.IM venti-client (3) , +.IM venti (7) diff --git a/man/man3/venti-log.3 b/man/man3/venti-log.3 index 6b74c6cd4..0d05af2ef 100644 --- a/man/man3/venti-log.3 +++ b/man/man3/venti-log.3 @@ -122,9 +122,9 @@ passed nil log structures. .PP The server library (see -.IR venti-conn (3) +.IM venti-conn (3) and -.IR venti-server (3)) +.IM venti-server (3) ) writes debugging information to the log named .IR VtServerLog , which defaults to the string @@ -132,5 +132,5 @@ which defaults to the string .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3), -.IR venti (8) +.IM venti (3) , +.IM venti (8) diff --git a/man/man3/venti-mem.3 b/man/man3/venti-mem.3 index 0a872a0a3..6877f0b68 100644 --- a/man/man3/venti-mem.3 +++ b/man/man3/venti-mem.3 @@ -35,7 +35,7 @@ void vtfree(void *ptr) .SH DESCRIPTION These routines allocate and free memory. On failure, they print an error message and call -.IR sysfatal (3). +.IM sysfatal (3) . They do not return. .PP .I Vtbrk @@ -63,4 +63,4 @@ when no longer needed. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3) +.IM venti (3) diff --git a/man/man3/venti-packet.3 b/man/man3/venti-packet.3 index 3ed8d6fe4..0f7386904 100644 --- a/man/man3/venti-packet.3 +++ b/man/man3/venti-packet.3 @@ -129,7 +129,7 @@ because fragments may not be filled completely. compares the data sections of two packets as .I memcmp (see -.IR memory (3)) +.IM memory (3) ) would. .PP .I Packetconcat @@ -260,7 +260,7 @@ bytes at offset .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3) +.IM venti (3) .SH DIAGNOSTICS These functions return errors only when passed invalid inputs, diff --git a/man/man3/venti-server.3 b/man/man3/venti-server.3 index 810852e14..54b8cb4ac 100644 --- a/man/man3/venti-server.3 +++ b/man/man3/venti-server.3 @@ -33,7 +33,7 @@ VtReq* vtgetreq(VtSrv *srv) void vtrespond(VtReq *req) .SH DESCRIPTION These routines execute the server side of the -.IR venti (7) +.IM venti (7) protocol. .PP .I Vtsrvhello @@ -115,8 +115,8 @@ blocks written to it and returns error on all reads. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (3), -.IR venti-conn (3), -.IR venti-packet (3), -.IR venti (7), -.IR venti (8) +.IM venti (3) , +.IM venti-conn (3) , +.IM venti-packet (3) , +.IM venti (7) , +.IM venti (8) diff --git a/man/man3/venti-zero.3 b/man/man3/venti-zero.3 index 270b76801..4ee8f9401 100644 --- a/man/man3/venti-zero.3 +++ b/man/man3/venti-zero.3 @@ -52,5 +52,5 @@ is the score of the zero-length block. .br .B \*9/src/libventi/zeroscore.c .SH SEE ALSO -.IR venti (3), -.IR venti (7) +.IM venti (3) , +.IM venti (7) diff --git a/man/man3/venti.3 b/man/man3/venti.3 index 632d5998e..368b70ebf 100644 --- a/man/man3/venti.3 +++ b/man/man3/venti.3 @@ -15,61 +15,61 @@ This manual page describes general utility functions. .PP Other manual pages describe the library functions in detail. .PP -.IR Venti-cache (3) +.IM Venti-cache (3) describes a simple in-memory block cache to help clients. .PP -.IR Venti-conn (3) +.IM Venti-conn (3) describes routines for manipulating network connections between Venti clients and servers. -.IR Venti-client (3) +.IM Venti-client (3) and -.IR venti-server (3) +.IM venti-server (3) describe routines for writing clients and servers on top of these. .PP -.IR Venti-fcall (3) +.IM Venti-fcall (3) describes the C representation of Venti protocol messages and data structures. It also describes routines that convert between the C representation and the network and disk representations. .PP -.IR Venti-file (3) +.IM Venti-file (3) describes routines for writing clients that manipulate Venti file trees (see -.IR venti (7)). +.IM venti (7) ). .PP -.IR Venti-log (3) +.IM Venti-log (3) describes routines to access in-memory log buffers as well as the logging that is done automatically by the library. .PP -.IR Venti-mem (3) +.IM Venti-mem (3) describes wrappers around the canonical -.IR malloc (3) +.IM malloc (3) routines that abort on error. .PP -.IR Venti-packet (3) +.IM Venti-packet (3) describes routines for manipulating zero-copy chains of data buffers. .PP -.IR Venti-zero (3) +.IM Venti-zero (3) describes routines to zero truncate and zero extend blocks (see -.IR venti (7)). +.IM venti (7) ). .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IR venti (1), -.IR venti-cache (3), -.IR venti-client (3), -.IR venti-fcall (3), -.IR venti-file (3) -.IR venti-log (3), -.IR venti-mem (3), -.IR venti-packet (3), -.IR venti-server (3), -.IR venti-zero (3), -.IR venti (7), -.IR venti (8) +.IM venti (1) , +.IM venti-cache (3) , +.IM venti-client (3) , +.IM venti-fcall (3) , +.IM venti-file (3) +.IM venti-log (3) , +.IM venti-mem (3) , +.IM venti-packet (3) , +.IM venti-server (3) , +.IM venti-zero (3) , +.IM venti (7) , +.IM venti (8) diff --git a/man/man3/wait.3 b/man/man3/wait.3 index 28d5d731e..c51df3c36 100644 --- a/man/man3/wait.3 +++ b/man/man3/wait.3 @@ -29,9 +29,9 @@ int awaitfor(int pid, char *s, int n) .SH DESCRIPTION .I Wait causes a process to wait for any child process (see -.IR fork (2) +.IM fork (2) and -.IR rfork (3)) +.IM rfork (3) ) to exit. It returns a .B Waitmsg @@ -62,7 +62,7 @@ the time spent in system calls, and the child's elapsed real time, all in units of milliseconds. .B Msg contains the message that the child specified in -.IR exits (3). +.IM exits (3) . For a normal exit, .B msg[0] is zero, @@ -78,7 +78,7 @@ returns immediately, with return value nil. The .B Waitmsg structure is allocated by -.IR malloc (3) +.IM malloc (3) and should be freed after use. For programs that only need the pid of the exiting program, .I waitpid @@ -114,7 +114,7 @@ The filled-in buffer may be parsed (after appending a NUL) using .IR tokenize (see -.IR getfields (3)); +.IM getfields (3) ); the resulting fields are, in order, pid, the three times, and the exit string, which will be .B '' @@ -139,8 +139,8 @@ returns .PP .B \*9/src/lib9/await.c .SH "SEE ALSO" -.IR rfork (3), -.IR exits (3), +.IM rfork (3) , +.IM exits (3) , .SH DIAGNOSTICS These routines set .IR errstr . @@ -156,4 +156,4 @@ are preprocessor macros defined as and .IR p9waitfor ; see -.IR intro (3). +.IM intro (3) . diff --git a/man/man3/window.3 b/man/man3/window.3 index 582504437..2663171f5 100644 --- a/man/man3/window.3 +++ b/man/man3/window.3 @@ -121,7 +121,7 @@ to color the window initially, and a refresh method The refresh methods are .BR Refbackup , which provides backing store and is the method used by -.IR rio (1) +.IM rio (1) for its clients; .BR Refnone , which provides no refresh and is designed for temporary uses @@ -142,7 +142,7 @@ pointer that may be treated like any other image. In particular, it is freed by calling .B freeimage (see -.IR allocimage (3)). +.IM allocimage (3) ). The following functions, however, apply only to windows, not regular images. .PP .B Bottomwindow @@ -199,13 +199,13 @@ and screen position .RI ( scr ). Their usage is shown in the Examples section. .PP -.IR Rio (1) +.IM Rio (1) creates its client windows with backing store, .BR Refbackup . The graphics initialization routine, .B initdraw (see -.IR graphics (3)), +.IM graphics (3) ), builds a .B Screen upon this, and then allocates upon that another window indented @@ -234,10 +234,10 @@ actual screen position of the window unless it is recorded separately. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IR graphics (3), -.IR draw (3), -.IR cachechars (3), -.IR draw (3) +.IM graphics (3) , +.IM draw (3) , +.IM cachechars (3) , +.IM draw (3) .SH BUGS The refresh method .B Refmesg diff --git a/man/man4/0intro.4 b/man/man4/0intro.4 index 1e4c81d2c..598a03fbd 100644 --- a/man/man4/0intro.4 +++ b/man/man4/0intro.4 @@ -15,7 +15,7 @@ In Plan 9, the kernel mount device \fImnt\fR(3) acts as a client to the 9P servers mounted in the current name space, translating system calls such as -.IR open (2) +.IM open (2) into 9P transactions such as .IR open (9p). The kernel also multiplexes the potentially many processes onto a single 9P conversation @@ -30,17 +30,17 @@ On Unix, 9P clients do not access servers via the traditional file system call interface. Only the Unix name space can be accessed that way. Instead, 9P clients use the -.IR 9pclient (3) +.IM 9pclient (3) library to connect and interact directly with particular 9P servers. The -.IR 9p (1) +.IM 9p (1) command-line client is useful for interactive use and in shell scripts. .PP To preserve the façade of a single 9P conversation with each server, 9P servers invoke -.IR 9pserve (4), +.IM 9pserve (4) , typically via -.IR post9pservice (3). +.IM post9pservice (3) . .I 9pserve announces a 9P service at a particular network address and multiplexes the clients that connect to @@ -58,7 +58,7 @@ Setting the .B $NAMESPACE environment variable overrides this default. The -.IR namespace (1) +.IM namespace (1) command prints the current name space directory. .PP Occasionally it is useful to be able to connect the input or output @@ -73,7 +73,7 @@ implementation of (see also .I fsopenfd in -.IR 9pclient (3)) +.IM 9pclient (3) ) returns the read or write end of a pipe; a helper process transfers data between the other end of the pipe and the 9P server. diff --git a/man/man4/9import.4 b/man/man4/9import.4 index e5b177cfb..5bcafe52a 100644 --- a/man/man4/9import.4 +++ b/man/man4/9import.4 @@ -19,7 +19,7 @@ tool allows an arbitrary on a remote .I system, with the capability of running the Plan 9 -.IR exportfs (4) +.IM exportfs (4) service, to be imported into the local name space. Usually @@ -31,7 +31,7 @@ A process is started on the remote machine, with authority of the user of .IR 9import , to perform work for the local machine using the -.IR exportfs (4) +.IM exportfs (4) service. The default port used is TCP 17007. If @@ -55,11 +55,11 @@ Use .I keypattern to select a key to authenticate to the remote side (see -.IR auth (2)). +.IM auth (2) ). .TP .B -p Push the -.IR aan (8) +.IM aan (8) filter onto the connection to protect against temporary network outages. .TP @@ -69,11 +69,11 @@ Post the connection's mountable file descriptor as .SH SOURCE .B \*9/src/cmd/9import.c .SH SEE ALSO -.IR srv (4), -.IR aan (8), -.IR listen1 (8), +.IM srv (4) , +.IM aan (8) , +.IM listen1 (8) , .B cs in -.IR ndb (7) +.IM ndb (7) .SH BUGS Encryption is not implemented. diff --git a/man/man4/9pserve.4 b/man/man4/9pserve.4 index cd34d931c..7eaa975f0 100644 --- a/man/man4/9pserve.4 +++ b/man/man4/9pserve.4 @@ -50,7 +50,7 @@ and clunks any outstanding fids belonging to the client. .PP .I 9pserve is typically not invoked directly; use -.IR post9pservice (3) +.IM post9pservice (3) instead. .PP The options are: @@ -73,7 +73,7 @@ rewrite all attach messages to use and .IR afid ; used to implement -.IR srv (4)'s +.IM srv (4) 's .B -a option .TP @@ -90,8 +90,8 @@ instead assume 9P2000 and a maximum message size of .IR msize .PD .SH "SEE ALSO -.IR intro (4), +.IM intro (4) , .IR intro (9p), -.IR 9pfuse (4) +.IM 9pfuse (4) .SH SOURCE .B \*9/src/cmd/9pserve.c diff --git a/man/man4/acme.4 b/man/man4/acme.4 index 5305253e9..1ed287fb3 100644 --- a/man/man4/acme.4 +++ b/man/man4/acme.4 @@ -15,7 +15,7 @@ acme \- control files for text windows \&... ] .SH DESCRIPTION The text window system -.IR acme (1) +.IM acme (1) serves a variety of files for reading, writing, and controlling windows. Some of them are virtual versions of system files for dealing @@ -28,12 +28,13 @@ When a command is run under a directory holding these files is posted as the 9P service .B acme (using -.IR 9pserve (4)). +.IM 9pserve (4) ). .PP Some of these files supply virtual versions of services available from the underlying environment, in particular the character terminal files in Plan 9's -\fIcons\fR(3). -(Unlike in Plan 9's \fIrio\fR(1), +.IR cons (3). +(Unlike in Plan 9's +.IR rio (1), each command under .I acme sees the same set of files; there is not a distinct @@ -46,7 +47,7 @@ Other files are unique to is a subdirectory used by .B win (see -.IR acme (1)) +.IM acme (1) ) as a mount point for the .I acme files associated with the window in which @@ -435,5 +436,5 @@ except that reads stop at the end address. .SH SOURCE .B \*9/src/cmd/acme .SH SEE ALSO -.IR rio (1), -.IR acme (1) +.IM rio (1) , +.IM acme (1) diff --git a/man/man4/factotum.4 b/man/man4/factotum.4 index 3a2d3d7cc..453965df9 100644 --- a/man/man4/factotum.4 +++ b/man/man4/factotum.4 @@ -10,7 +10,7 @@ factotum \- authentication agent ] [ .B -s .I srvname -] +] .\" [ .\" .B -m .\" .I mtpt @@ -79,7 +79,7 @@ same user id as it. For select protocols such as it can also act as a client for other processes provided its user id may speak for the other process' user id (see Plan 9's -\fIauthsrv\fR(6)). +.IR authsrv (6)). .I Factotum can act in the role of server for any process. .PP @@ -127,7 +127,7 @@ RSA encryption and signatures, used by SSH and TLS. passwords in the clear. .TP .B vnc -.IR vnc (1)'s +.IM vnc (1) 's challenge/response. .TP .B wep @@ -186,7 +186,7 @@ cpu server. On starting, it will attempt to get a key from NVRAM using .B readnvram (see -.IR authsrv (3)), +.IM authsrv (3) ), prompting for anything it needs. It will never subsequently prompt for a key that it doesn't have. @@ -227,7 +227,7 @@ the kernel at boot time. .PP A .I "key tuple -is a space delimited list of +is a space delimited list of .IB attribute = value pairs. An attribute whose name begins with an exclamation point .RB ( ! ) @@ -245,7 +245,7 @@ specific to each supported protocol. .PP All keys can have additional attibutes that act either as comments or as selectors to distinguish them in the -.IR auth (3) +.IM auth (3) library calls. .PP The factotum owner can use any key stored by factotum. @@ -305,9 +305,9 @@ such as and .B auth_challenge (see -.IR auth (3)) +.IM auth (3) ) to specify which key and protocol to use for an authentication. -Like a key tuple, a key template is also a list of +Like a key tuple, a key template is also a list of .IB attribute = value pairs. It must specify at least the protocol and enough @@ -367,7 +367,7 @@ turned on by the option. .PP By default when factotum starts it looks for a -.IR secstore (1) +.IM secstore (1) account on $auth for the user and, if one exists, prompts for a secstore password in order to fetch the file @@ -385,11 +385,11 @@ sets a public/private keypair for ssh authentication, generated by .B ssh_genkey (see -.IR ssh (1)). +.IM ssh (1) ). .PD .SS "Confirming key use .PP -The +The .B confirm file provides a connection from .I factotum @@ -397,7 +397,7 @@ to a confirmation server, normally the program .IR auth/fgui . Whenever a key with the .B confirm -attribute is used, +attribute is used, .I factotum requires confirmation of its use. If no process has .B confirm @@ -429,7 +429,7 @@ the same user id as .IR factotum . .SS "Prompting for keys .PP -The +The .B needkey file provides a connection from .I factotum @@ -481,11 +481,11 @@ RPC's) until done if successful, reading back an .I AuthInfo structure (see -.IR authsrv (3)). +.IM authsrv (3) ). .PP The RPC protocol is normally embodied by one of the routines in -.IR auth (3). +.IM auth (3) . We describe it here should anyone want to extend the library. .PP @@ -545,7 +545,7 @@ necessary authentication has succeeded, an .B AuthInfo structure (see -.IR auth (3)) +.IM auth (3) ) can be retrieved with an .B authinfo RPC @@ -621,7 +621,7 @@ is expected to be a long hexadecimal string. These are useful for manually debugging of binary protocols. .TP .B authinfo -retrieve the AuthInfo structure. +retrieve the AuthInfo structure. The possible replies are: .RS .TP @@ -661,7 +661,7 @@ with its own roles and required key attributes. and .I p9cr are used to authenticate to Plan 9 systems; -valid +valid .BR role s are .B client @@ -691,7 +691,7 @@ is a meta-protocol that negotiates a protocol .RB ( p9sk1 or .BR p9sk2 ) -and an authentication domain and then invokes the +and an authentication domain and then invokes the given protocol with a .B dom= attribute. @@ -703,7 +703,7 @@ and are intended to be proxied via .I auth_proxy (see -.IR auth (3)). +.IM auth (3) ). .\" The protocols follow .\" .IR p9any (7) .\" and @@ -736,7 +736,7 @@ before being sent over the network. .PP .I Vnc is the challenge-response protocol used by -.IR vnc (1); +.IM vnc (1) ; valid roles are .B client and @@ -746,7 +746,7 @@ The client protocol requires a key with attribute .BR !password . Conventionally, client keys also have -.B user +.B user and .B server attributes. @@ -763,7 +763,7 @@ except that the challenge and response are not textual. and .I cram are challenge-response protocols typically -used to authenticate +used to authenticate to mail servers. The client protocols require .B proto=apop @@ -774,7 +774,7 @@ keys with and .B !password attributes. -Conventionally, client keys also have +Conventionally, client keys also have .B server attributes. The server protocol requires a @@ -828,7 +828,7 @@ structure (defined in .PP .I Pass is a client-only protocol that hands out passwords -from +from .B proto=pass keys with .B user @@ -840,7 +840,7 @@ a string: a space-separated quoted user name and password that can be parsed with .I tokenize (see -.IR getfields (3)). +.IM getfields (3) ). Conventionally, client keys have distinguishing attributes like .B service @@ -860,7 +860,7 @@ keys with .BR !key2 , or .B !key3 -attributes. +attributes. The protocol with .I factotum is: @@ -873,7 +873,7 @@ opens the device's control file, sets the wireless secret using the key, and turns on encryption. If the key has an .B essid -attribute, +attribute, .I factotum uses it to set the wireless station ID. .PP @@ -891,7 +891,7 @@ uses keys with .B ek and -.B n +.B n attributes, large integers specifying the public half of the key. If a key is to be used for decryption or signing, @@ -905,13 +905,13 @@ and .BR !dk specifying the private half of the key; see -.IR rsa (3). +.IM rsa (3) . Conventionally, .I rsa keys also have .B service attributes specifying the context in which the key is used: -.B ssh +.B ssh (SSH version 1), .B ssh-rsa (SSH version 2), @@ -946,7 +946,7 @@ and The hash function must be known to .I factotum because the signature encodes the type of hash used. -The +The .B encrypt and .B verify @@ -972,11 +972,11 @@ attributes. If the key is to be used for signing, it must also have a .B !secret attribute; see -.IR dsa (3). +.IM dsa (3) . Conventionally, .I dsa keys -also have +also have .B service attributes specifying the context in which the key is used: .B ssh-dss @@ -992,7 +992,7 @@ Unlike .IR rsa , the .I dsa -protocol ignores the +protocol ignores the .B hash attribute; it always uses SHA1. .PP @@ -1019,4 +1019,4 @@ The response is a hexadecimal string of length 32. .SH SOURCE .B \*9/src/cmd/auth/factotum .SH SEE ALSO -.IR ssh-agent (1) +.IM ssh-agent (1) diff --git a/man/man4/fontsrv.4 b/man/man4/fontsrv.4 index 2ba7f2c18..a270b2f10 100644 --- a/man/man4/fontsrv.4 +++ b/man/man4/fontsrv.4 @@ -20,7 +20,7 @@ fontsrv \- file system access to host fonts presents the host window system's fonts in the standard Plan 9 format (see -.IR font (7)). +.IM font (7) ). It serves a virtual directory tree mounted at .I mtpt (if the @@ -72,14 +72,14 @@ representing 32-character Unicode ranges. .PP .I Openfont (see -.IR graphics (3)) +.IM graphics (3) ) recognizes font paths beginning with .B /mnt/font and implements them by invoking .IR fontsrv ; it need not be running already. See -.IR font (7) +.IM font (7) for a full discussion of font name syntaxes. .SH EXAMPLES List the fonts on the system: @@ -96,7 +96,7 @@ or: .EE .LP Run -.IR acme (1) +.IM acme (1) using the operating system's Monaco as the fixed-width font: .IP .EX @@ -104,7 +104,7 @@ using the operating system's Monaco as the fixed-width font: .EE .LP Run -.IR sam (1) +.IM sam (1) using the same font: .IP .EX @@ -113,7 +113,7 @@ using the same font: .SH SOURCE .B \*9/src/cmd/fontsrv .SH SEE ALSO -.IR font (7) +.IM font (7) .SH BUGS .PP Due to OS X restrictions, diff --git a/man/man4/fossil.4 b/man/man4/fossil.4 index 7c06f2f7a..6072a39a1 100644 --- a/man/man4/fossil.4 +++ b/man/man4/fossil.4 @@ -148,10 +148,10 @@ will be named The attach name used in .I mount (see -.IR bind (1), -.IR bind (2) +.IM bind (1) , +.IM bind (2) and -.IR attach (5)) +.IM attach (5) ) selects a file system to be served and optionally a subtree, in the format @@ -163,7 +163,7 @@ An empty attach name selects normally requires all users except .L none to provide authentication tickets on each -.IR attach (5). +.IM attach (5) . To keep just anyone from connecting, .L none is only allowed to attach after another user @@ -179,7 +179,7 @@ flag to or .B srv (see -.IR fossilcons (8)). +.IM fossilcons (8) ). .PP The groups called .B noworld @@ -207,7 +207,7 @@ readable by the world but writable only to the developers. starts a new instance of the fossil file server. It is configured mainly through console commands, documented in -.IR fossilcons (8). +.IM fossilcons (8) . .PP The options are: .TF "-c\fI cmd @@ -239,7 +239,7 @@ and which starts a file server console on .BI /srv/ cons \fR. See -.IR fossilcons (8) +.IM fossilcons (8) for more information. .TP .BI -f " file @@ -269,7 +269,7 @@ for inconsistencies. is deprecated in favor of the console .B check command (see -.IR fossilcons (8)). +.IM fossilcons (8) ). .I Flchk prints .I fossil @@ -375,7 +375,7 @@ system stored on Venti at The score should have been generated by .I fossil rather than by -.IR vac (1), +.IM vac (1) , so that the appropriate snapshot metadata is present. .PD .PP @@ -450,7 +450,7 @@ See the discussion of the and .B uname commands in -.IR fossilcons (8) +.IM fossilcons (8) for more about the user table. .ne 3 .PP @@ -488,13 +488,13 @@ command to prepare the script. .SH SOURCE .B \*9/src/cmd/fossil .SH SEE ALSO -.IR yesterday (1), -.IR fs (3), -.IR fs (4), -.IR srv (4), -.IR fossilcons (8), -.IR loadfossil (8), -.IR venti (8) +.IM yesterday (1) , +.IM fs (3) , +.IM fs (4) , +.IM srv (4) , +.IM fossilcons (8) , +.IM loadfossil (8) , +.IM venti (8) .SH BUGS It is possible that the disk format (but not the Venti format) will change in the future, to make the disk a full cache diff --git a/man/man4/import.4 b/man/man4/import.4 index 9dd81d724..7d67a4493 100644 --- a/man/man4/import.4 +++ b/man/man4/import.4 @@ -48,7 +48,7 @@ the path have different meanings on the two systems.) connects to .I system using -.IR ssh (1). +.IM ssh (1) . It invokes .I import on the remote system to carry out the remote @@ -109,5 +109,5 @@ sam & .SH SOURCE .B \*9/src/cmd/import.c .SH SEE ALSO -.IR 9pserve (4), -.IR intro (4) +.IM 9pserve (4) , +.IM intro (4) diff --git a/man/man4/plumber.4 b/man/man4/plumber.4 index 88801eb4d..a86f032a0 100644 --- a/man/man4/plumber.4 +++ b/man/man4/plumber.4 @@ -14,17 +14,17 @@ plumber \- file system for interprocess messaging The .I plumber is a user-level file server that receives, examines, rewrites, and dispatches -.IR plumb (7) +.IM plumb (7) messages between programs. Its behavior is programmed by a .I plumbing file (default .BR $HOME/lib/plumbing ) in the format of -.IR plumb (7). +.IM plumb (7) . .PP Its services are posted via -.IR 9pserve (4) +.IM 9pserve (4) as .BR plumb , and consist of two @@ -39,14 +39,14 @@ for dispatching messages to applications. Programs use .B fswrite (see -.IR 9pclient (3)) +.IM 9pclient (3) ) to deliver messages to the .B send file, and .I fsread to receive them from the corresponding port. For example, -.IR sam (1)'s +.IM sam (1) 's .B plumb menu item or the .B B @@ -115,13 +115,13 @@ statements .TP .B plumb mount name for -.IR plumber (4). +.IM plumber (4) . .SH SOURCE .B \*9/src/cmd/plumb .SH "SEE ALSO" -.IR plumb (1), -.IR plumb (3), -.IR plumb (7) +.IM plumb (1) , +.IM plumb (3) , +.IM plumb (7) .\" .SH BUGS .\" .IR Plumber 's .\" file name space is fixed, so it is difficult to plumb diff --git a/man/man4/ramfs.4 b/man/man4/ramfs.4 index 25ae4bf67..20e72b385 100644 --- a/man/man4/ramfs.4 +++ b/man/man4/ramfs.4 @@ -21,7 +21,7 @@ By default posts its service as .B ramfs using -.IR 9pserve (4). +.IM 9pserve (4) . .PP The .B -S @@ -46,5 +46,5 @@ It can also be used to provide high-performance temporary files. .SH SOURCE .B \*9/src/cmd/ramfs.c .SH "SEE ALSO" -.IR 9p (3), -.IR 9pserve (4) +.IM 9p (3) , +.IM 9pserve (4) diff --git a/man/man4/smugfs.4 b/man/man4/smugfs.4 index 4fb8c7f0f..fdea4e470 100644 --- a/man/man4/smugfs.4 +++ b/man/man4/smugfs.4 @@ -24,7 +24,7 @@ is a user-level file system that provides access to images stored on the SmugMug photo sharing service. It logs in after obtaining a password from -.IR factotum (4) +.IM factotum (4) using .B server=smugmug.com and @@ -32,7 +32,7 @@ and (if any) as key criteria (see -.IR auth (3)). +.IM auth (3) ). Then .I smugfs serves a virtual directory tree mounted at @@ -265,7 +265,7 @@ SmugMug, If multiple categories or albums have the same name, only one will be accessible via the file system interface. Renaming the accessible one via Unix's -.IR mv (1) +.IM mv (1) will resolve the problem. .PP Boolean values appear as diff --git a/man/man4/srv.4 b/man/man4/srv.4 index 856f88ff3..469b2b4ca 100644 --- a/man/man4/srv.4 +++ b/man/man4/srv.4 @@ -22,7 +22,7 @@ srv, 9fs \- start network file service dials the given address and initializes the connection to serve the 9P protocol. It then posts the resulting connection in the current name space (see -.IR intro (4)) +.IM intro (4) ) as .I srvname (default @@ -70,7 +70,7 @@ available as service .IR sources . .I 9fs is an -.IR rc (1) +.IM rc (1) script; examine it to see what local conventions apply. .SH EXAMPLES List the root directory on @@ -98,6 +98,6 @@ sudo mount -t 9p -o trans=unix,uname=$USER,dfltuid=`id -u`,dfltgid=`id -g` .br .B \*9/bin/9fs .SH "SEE ALSO -.IR dial (3), -.IR intro (4), -.IR netfiles (1) +.IM dial (3) , +.IM intro (4) , +.IM netfiles (1) diff --git a/man/man4/tapefs.4 b/man/man4/tapefs.4 index 3297e2a42..b8843173a 100644 --- a/man/man4/tapefs.4 +++ b/man/man4/tapefs.4 @@ -91,7 +91,7 @@ Tenth Edition research Unix systems (4KB block size). .PP .I Zipfs interprets zip archives (see -.IR gzip (1)). +.IM gzip (1) ). .SH SOURCE .PP These commands are constructed in a highly stereotyped @@ -103,7 +103,7 @@ in .BR \*9/src/cmd/tapefs , which in turn derive substantially from -.IR ramfs (4). +.IM ramfs (4) . .SH "SEE ALSO -.IR intro (7), -.IR ramfs (4). +.IM intro (7) , +.IM ramfs (4) . diff --git a/man/man4/vacfs.4 b/man/man4/vacfs.4 index 143e782bf..0c92ff60c 100644 --- a/man/man4/vacfs.4 +++ b/man/man4/vacfs.4 @@ -26,7 +26,7 @@ vacfs \- a Venti-based file system .SH DESCRIPTION .I Vacfs interprets the file system created by -.IR vac (1) +.IM vac (1) so that it can be mounted into a Plan 9 file hierarchy. The data for the file system is stored on a Venti server with a root fingerprint specified in @@ -37,7 +37,7 @@ clients are not authenticated, and groups are assumed to contain a single member with the same name. These restrictions should eventually be removed. .PP -Options to +Options to .I vacfs are: .TP @@ -49,7 +49,7 @@ The network address of the Venti server. The default is taken from the environment variable .BR venti . If this variable does not exist, then the default is the -metaname +metaname .BR $venti . .\" which can be configured via .\" .IR ndb (6). @@ -81,5 +81,6 @@ The amount of memory, in bytes, allocated to the block cache. The default is 16M .SH SOURCE .B \*9/src/cmd/vac .SH "SEE ALSO" -.IR vac (1), -Plan 9's \fIventi\fR(8) +.IM vac (1) , +Plan 9's +.IR venti (8) diff --git a/man/man7/color.7 b/man/man7/color.7 index c8b536a0c..7e9a39b77 100644 --- a/man/man7/color.7 +++ b/man/man7/color.7 @@ -121,11 +121,11 @@ which is scaled so 0 represents fully transparent and 255 represents opaque colo The alpha is .I premultiplied into the other channels, as described in the paper by Porter and Duff cited in -.IR draw (3). +.IM draw (3) . The function .B setalpha (see -.IR allocimage (3)) +.IM allocimage (3) ) aids the initialization of color values with non-trivial alpha. .PP The packing of pixels into bytes and words is odd. @@ -138,13 +138,13 @@ the byte ordering is blue, green, red. .PP To maintain a constant external representation, the -.IR draw (3) +.IM draw (3) interface as well as the various graphics libraries represent colors by 32-bit numbers, as described in -.IR color (3). +.IM color (3) . .SH "SEE ALSO" -.IR color (3), -.IR graphics (3), -.IR draw (3) +.IM color (3) , +.IM graphics (3) , +.IM draw (3) diff --git a/man/man7/face.7 b/man/man7/face.7 index 08b04a463..a69aac989 100644 --- a/man/man7/face.7 +++ b/man/man7/face.7 @@ -25,13 +25,13 @@ per color)). The large files serve no special purpose; they are stored as images (see -.IR image (7)). +.IM image (7) ). The small files are the `icons' displayed by .B faces and .B seemail (see Plan 9's -\fIfaces\fR(1)); +.IR faces (1)); for depths less than 4, their format is special. .PP One- and two-bit deep icons are stored as text, one line of the file to one scan line @@ -110,6 +110,6 @@ which then appears as a domain name in the .B .dict files. .SH "SEE ALSO" -.IR mail (1), -.IR tweak (1), -.IR image (7) +.IM mail (1) , +.IM tweak (1) , +.IM image (7) diff --git a/man/man7/font.7 b/man/man7/font.7 index 45331d4d2..a11ca53c8 100644 --- a/man/man7/font.7 +++ b/man/man7/font.7 @@ -5,7 +5,7 @@ font, subfont \- external format for fonts and subfonts .B #include .SH DESCRIPTION Fonts and subfonts are described in -.IR cachechars (3). +.IM cachechars (3) . .PP External bitmap fonts are described by a plain text file that can be read using .IR openfont . @@ -21,7 +21,7 @@ with an optional starting position within the subfont, and the file name names an external file suitable for .I readsubfont (see -.IR graphics (3)). +.IM graphics (3) ). The minimum number of a covered range is mapped to the specified starting position (default zero) of the corresponding subfont. @@ -36,11 +36,11 @@ that can be read and written using and .I writesubfont (see -.IR subfont (3)). +.IM subfont (3) ). The format for subfont files is: an image containing character glyphs, followed by a subfont header, followed by character information. The image has the format for external image files described in -.IR image (7). +.IM image (7) . The subfont header has 3 decimal strings: .BR n , @@ -72,7 +72,7 @@ are irrelevant. .PP Note that the convention of using the character with value zero (NUL) to represent characters of zero width (see -.IR draw (3)) +.IM draw (3) ) means that fonts should have, as their zeroth character, one with non-zero width. .SS "Font Names @@ -121,7 +121,7 @@ The command .B . lists the available fonts. See -.IR fontsrv (4) +.IM fontsrv (4) for more. .PP If the font name has the form @@ -136,7 +136,7 @@ The Plan 9 bitmap fonts were designed for screens with pixel density around 100 When used on screens with pixel density above 200 DPI, the bitmap fonts are automatically pixel doubled. Similarly, fonts loaded from -.IR fontsrv (4) +.IM fontsrv (4) are automatically doubled in size by varying the effective .I size path element. @@ -184,7 +184,7 @@ a system-installed vector font on high-density displays: .B \*9/font/* font directories .SH "SEE ALSO" -.IR graphics (3), -.IR draw (3), -.IR cachechars (3), -.IR subfont (3) +.IM graphics (3) , +.IM draw (3) , +.IM cachechars (3) , +.IM subfont (3) diff --git a/man/man7/htmlroff.7 b/man/man7/htmlroff.7 index e908c3ff5..56874b1bb 100644 --- a/man/man7/htmlroff.7 +++ b/man/man7/htmlroff.7 @@ -2,7 +2,7 @@ .SH NAME htmlroff \- HTML formatting and typesetting .SH DESCRIPTION -.IR Htmlroff (1) +.IM Htmlroff (1) accepts .I troff input with a few extensions and changes. @@ -200,7 +200,7 @@ inside .B tags. This heuristic handles simple equations formatted by -.IR eqn (1). +.IM eqn (1) . .SS Conditional input .PP To make it easier to write input files that can be formatted by both @@ -315,7 +315,7 @@ For example, redefines the .B PS macro that marks the beginning of a -.IR pic (1) +.IM pic (1) picture: .IP .EX diff --git a/man/man7/image.7 b/man/man7/image.7 index 6e613f9c6..b412742fc 100644 --- a/man/man7/image.7 +++ b/man/man7/image.7 @@ -5,9 +5,9 @@ image \- external format for images .B #include .SH DESCRIPTION Images are described in -.IR graphics (3), +.IM graphics (3) , and the definition of pixel values is in -.IR color (7). +.IM color (7) . Fonts and images are stored in external files in machine-independent formats. .PP @@ -21,7 +21,7 @@ and and .B writememimage (see -.IR memdraw (3)). +.IM memdraw (3) ). An uncompressed image file starts with 5 strings: .BR chan , @@ -34,10 +34,10 @@ Each is right-justified and blank padded in 11 characters, followed by a blank. The .B chan value is a textual string describing the pixel format -(see +(see .B strtochan in -.IR graphics (3) +.IM graphics (3) and the discussion of channel descriptors below), and the rectangle coordinates are decimal strings. The rest of the file contains the @@ -49,7 +49,7 @@ consists of the byte containing pixel .B r.min.x and all the bytes up to and including the byte containing pixel .BR r.max.x -1. -For images with depth +For images with depth .I d less than eight, a pixel with x-coordinate = .I x @@ -73,11 +73,11 @@ The and .B unloadimage functions described in -.IR allocimage (3) +.IM allocimage (3) also deal with rows in this format, stored in user memory. .PP The channel format string is a sequence of two-character channel descriptions, -each comprising a letter +each comprising a letter .RB ( r for red, .B g @@ -95,10 +95,10 @@ and for ``don't care'') followed by a number of bits per pixel. The sum of the channel bits per pixel is the -depth of the image, which must be either +depth of the image, which must be either a divisor or a multiple of eight. It is an error to have more than -one of any channel but +one of any channel but .BR x . An image must have either a greyscale channel; a color mapped channel; or red, green, and blue channels. @@ -110,13 +110,13 @@ In particular .B 'r8g8b8' pixels have byte ordering blue, green, and red within the file. See -.IR color (7) +.IM color (7) for more details of the pixel format. .PP A venerable yet deprecated format replaces the channel string with a decimal .IR ldepth , -which is the base two logarithm of the number +which is the base two logarithm of the number of bits per pixel in the image. In this case, .IR ldepth s @@ -177,9 +177,9 @@ Some small images, in particular 48\(mu48 face files as used by .I seemail (see Plan 9's -\fIfaces\fR(1) +.IR faces (1) and -.IR face (7)) +.IM face (7) ) and 16\(mu16 cursors, can be stored textually, suitable for inclusion in C source. Each line of text represents one scan line as a @@ -188,18 +188,18 @@ bytes, shorts, or words in C format. For cursors, each line defines a pair of bytes. (It takes two images to define a cursor; each must be stored separately to be processed by programs such as -.IR tweak (1).) +.IM tweak (1) .) Face files of one bit per pixel are stored as a sequence of shorts, those of larger pixel sizes as a sequence of longs. Software that reads these files must deduce the image size from the input; there is no header. These formats reflect history rather than design. .SH "SEE ALSO" -.IR jpg (1), -.IR tweak (1), -.IR graphics (3), -.IR draw (3), -.IR allocimage (3), -.IR color (7), -.IR face (7), -.IR font (7) +.IM jpg (1) , +.IM tweak (1) , +.IM graphics (3) , +.IM draw (3) , +.IM allocimage (3) , +.IM color (7) , +.IM face (7) , +.IM font (7) diff --git a/man/man7/keyboard.7 b/man/man7/keyboard.7 index 07bfb9602..56c0d3aee 100644 --- a/man/man7/keyboard.7 +++ b/man/man7/keyboard.7 @@ -49,15 +49,15 @@ in particular, control-J is a line feed and control-M a carriage return. .PP The down arrow, used by -.IR 9term (1), -.IR acme (1), +.IM 9term (1) , +.IM acme (1) , and -.IR sam (1), +.IM sam (1) , causes windows to scroll forward. The up arrow scrolls backward. .PP Characters in Plan 9 are runes (see -.IR utf (7)). +.IM utf (7) ). Any rune can be typed using a compose key followed by several other keys. The compose key is also generally near the lower right of the main key area: @@ -92,11 +92,11 @@ the compose key followed by a two- or three-character sequence. The full list is too long to repeat here, but is contained in the file .L \*9/lib/keyboard in a format suitable for -.IR grep (1) +.IM grep (1) or -.IR look (1). +.IM look (1) . To add a sequence, edit that file and then rebuild -.IR devdraw (1). +.IM devdraw (1) . .PP There are several rules guiding the design of the sequences, as illustrated by the following examples. @@ -235,10 +235,10 @@ to run them automatically at startup. sorted table of characters and keyboard sequences .PD .SH "SEE ALSO" -.IR intro (1), -.IR ascii (1), -.IR tcs (1), -.IR 9term (1), -.IR acme (1), -.IR sam (1), -.IR utf (7) +.IM intro (1) , +.IM ascii (1) , +.IM tcs (1) , +.IM 9term (1) , +.IM acme (1) , +.IM sam (1) , +.IM utf (7) diff --git a/man/man7/man.7 b/man/man7/man.7 index 0e2b52bab..98fae1c3e 100644 --- a/man/man7/man.7 +++ b/man/man7/man.7 @@ -82,9 +82,9 @@ font- or size-setting macros. The .B -man macros admit equations and tables in the style of -.IR eqn (1) +.IM eqn (1) and -.IR tbl (1), +.IM tbl (1) , but do not support arguments on .B .EQ and @@ -113,7 +113,7 @@ The root directory of the Plan 9 installation. .B \*9/tmac/tmac.antimes .SH SEE ALSO .IR troff (1), -.IR man (1) +.IM man (1) .SH REQUESTS .ta \w'.TH n c x 'u +\w'Cause 'u +\w'Argument\ 'u .di xx diff --git a/man/man7/map.7 b/man/man7/map.7 index 80e1eebff..72925e414 100644 --- a/man/man7/map.7 +++ b/man/man7/map.7 @@ -80,7 +80,7 @@ in the map file. Both the map file and the index file are ordered by patch latitude and longitude. .SH "SEE ALSO" -.IR map (7) +.IM map (7) .br The data comes from the World Data Bank I and II and U.S. Government sources: the Census Bureau, Geological diff --git a/man/man7/mhtml.7 b/man/man7/mhtml.7 index dcf49868d..95439641f 100644 --- a/man/man7/mhtml.7 +++ b/man/man7/mhtml.7 @@ -19,14 +19,14 @@ mhtml \- macros for formatting HTML \&... .SH DESCRIPTION This package of -.IR htmlroff (1) +.IM htmlroff (1) macro definitions provides convenient macros for formatting HTML. It is usually used along with -.IR troff (1) +.IM troff (1) macro packages such as -.IR man (7) +.IM man (7) and -.IR ms (7). +.IM ms (7) . .I Mhtml replaces some macros defined in the other packages, so it should be listed after them on the @@ -64,7 +64,7 @@ before invoking Accumulate footnotes and print them at the end of the document under a \fBNotes\fP heading. These replace the macros in -.IR ms (7). +.IM ms (7) . To emit the notes accumulated so far, invoke .BR .NOTES . .TP @@ -75,7 +75,7 @@ and .B .PE with a PNG image corresponding to the output of running -.IR troff (1) +.IM troff (1) on the input. .TP .B .TS\fR, \fP.TE @@ -100,6 +100,6 @@ percent of the current output width. .SH FILES .B \*9/tmac/tmac.html .SH SEE ALSO -.IR htmlroff (1), -.IR htmlroff (7), -.IR ms (7) +.IM htmlroff (1) , +.IM htmlroff (7) , +.IM ms (7) diff --git a/man/man7/mpictures.7 b/man/man7/mpictures.7 index d6dbf964d..c6eaf555c 100644 --- a/man/man7/mpictures.7 +++ b/man/man7/mpictures.7 @@ -10,7 +10,7 @@ mpictures \- picture inclusion macros .SH DESCRIPTION .I Mpictures macros insert PostScript pictures into -.IR troff (1) +.IM troff (1) documents. The macros are: .TP @@ -129,7 +129,7 @@ comment is present, the picture is assumed to fill an 8.5\(mu11-inch page. Nothing prevents the picture from being placed off the page. .SH SEE ALSO -.IR troff (1) +.IM troff (1) .SH DIAGNOSTICS A picture file that can't be read by the PostScript postprocessor is replaced by white space. diff --git a/man/man7/ms.7 b/man/man7/ms.7 index 931dad1b5..7d50c89ac 100644 --- a/man/man7/ms.7 +++ b/man/man7/ms.7 @@ -18,7 +18,7 @@ ms \- macros for formatting manuscripts This package of .I nroff and -.IR troff (1) +.IM troff (1) macro definitions provides a canned formatting facility for tech%nical papers in various formats. .PP @@ -38,11 +38,11 @@ impunity after the first .LR .na . .PP Output of the -.IR eqn (1), -.IR tbl (1), -.IR pic (1) +.IM eqn (1) , +.IM tbl (1) , +.IM pic (1) and -.IR grap (1) +.IM grap (1) preprocessors for equations, tables, pictures, and graphs is acceptable as input. .SH FILES @@ -57,8 +57,8 @@ Tenth Edition, Volume 2. .br .IR eqn (1), .IR troff (1), -.IR tbl (1), -.IR pic (1) +.IM tbl (1) , +.IM pic (1) .SH REQUESTS .ta \w'..ND \fIdate\fR 'u +\w'Initial 'u +\w'Cause 'u .br @@ -153,7 +153,7 @@ Implies produced by .I neqn or -.IR eqn (1). +.IM eqn (1) . .ti0 \fL\&.EQ\fP \fIx y\fR - yes Display equation. Equation number is @@ -234,7 +234,7 @@ is subsection level (default 1). \fL\&.P2\fP - yes End program display. .ti0 \fL\&.PE\fP - yes End picture; see -.IR pic (1). +.IM pic (1) . .ti0 \fL\&.PF\fP - yes End picture; restore vertical position. @@ -280,7 +280,7 @@ font automatically bold. Default is 5 10 15 ... .ti0 \fL\&.TE\fP - yes End table; see -.IR tbl (1). +.IM tbl (1) . .ti0 \fL\&.TH\fP - yes End heading section of table. .ti0 diff --git a/man/man7/ndb.7 b/man/man7/ndb.7 index 4387f99d2..9ab448fe5 100644 --- a/man/man7/ndb.7 +++ b/man/man7/ndb.7 @@ -59,7 +59,7 @@ Within tuples, pairs on the same line bind tighter than pairs on different lines. .PP Programs search the database directly using the routines in -.IR ndb (3). +.IM ndb (3) . .\" or indirectly using .\" .B ndb/cs .\" and @@ -292,8 +292,8 @@ tcp=9fs port=564 first database file searched .SH "SEE ALSO" .\" .IR dial (2), -.IR ndb (1), -.IR ndb (3) +.IM ndb (1) , +.IM ndb (3) .\" .IR dhcpd (8), .\" .IR ipconfig (8), .\" .IR con (1) diff --git a/man/man7/plot.7 b/man/man7/plot.7 index d4550f51e..31cb41a00 100644 --- a/man/man7/plot.7 +++ b/man/man7/plot.7 @@ -340,4 +340,4 @@ Restore previous environment. .PD .SH "SEE ALSO" .IR plot (1), -.IR graph (1) +.IM graph (1) diff --git a/man/man7/plumb.7 b/man/man7/plumb.7 index fd30ee04d..446b4340a 100644 --- a/man/man7/plumb.7 +++ b/man/man7/plumb.7 @@ -6,7 +6,7 @@ plumb \- format of plumb messages and rules .SH DESCRIPTION .SS "Message format The messages formed by the -.IR plumb (3) +.IM plumb (3) library are formatted for transmission between processes into textual form, using newlines to separate the fields. @@ -61,7 +61,7 @@ A missing field is represented by an empty line. The .B plumber (see -.IR plumb (1)) +.IM plumb (1) ) receives messages on its .B send port (applications @@ -271,7 +271,7 @@ rule should be specified in a rule set. .RE .PP The arguments to all rules may contain quoted strings, exactly as in -.IR rc (1). +.IM rc (1) . They may also contain simple string variables, identified by a leading dollar sign .BR $ . Variables may be set, between rule sets, by assignment statements in the style of @@ -341,7 +341,7 @@ field of the message. .B $plan9 The root directory of the Plan 9 tree (see -.IR get9root (3)). +.IM get9root (3) ). .RE .SH EXAMPLE The following is a modest, representative file of plumbing rules. @@ -403,7 +403,7 @@ default rules file. .TP .B plumb service name for -.IR plumber (4). +.IM plumber (4) . .TP .B \*9/plumb directory for @@ -416,7 +416,7 @@ public macro definitions. .B \*9/plumb/basic basic rule set. .SH "SEE ALSO" -.IR plumb (1), -.IR plumb (3), -.IR plumber (4), -.IR regexp (7) +.IM plumb (1) , +.IM plumb (3) , +.IM plumber (4) , +.IM regexp (7) diff --git a/man/man7/regexp.7 b/man/man7/regexp.7 index 91e73adc5..dbc5a9a16 100644 --- a/man/man7/regexp.7 +++ b/man/man7/regexp.7 @@ -4,9 +4,9 @@ regexp \- Plan 9 regular expression notation .SH DESCRIPTION This manual page describes the regular expression syntax used by the Plan 9 regular expression library -.IR regexp (3). +.IM regexp (3) . It is the form used by -.IR egrep (1) +.IM egrep (1) before .I egrep got complicated. @@ -130,4 +130,4 @@ A match to any part of a regular expression extends as far as possible without preventing a match to the remainder of the regular expression. .SH "SEE ALSO" -.IR regexp (3) +.IM regexp (3) diff --git a/man/man7/thumbprint.7 b/man/man7/thumbprint.7 index 743172de6..4d90f4377 100644 --- a/man/man7/thumbprint.7 +++ b/man/man7/thumbprint.7 @@ -9,7 +9,7 @@ for example by calling and .B okThumbprint (see -.IR pushtls (3)), +.IM pushtls (3) ), check the remote side's public key by comparing against thumbprints from a trusted list. The list is maintained by people who set local policies @@ -38,4 +38,4 @@ For example, a web server might have thumbprint x509 sha1=8fe472d31b360a8303cd29f92bd734813cbd923c cn=*.cs.bell-labs.com .EE .SH "SEE ALSO" -.IR pushtls (3) +.IM pushtls (3) diff --git a/man/man7/utf.7 b/man/man7/utf.7 index a24094576..0a963c8cd 100644 --- a/man/man7/utf.7 +++ b/man/man7/utf.7 @@ -57,7 +57,7 @@ in order to work properly with non-\c .SM ASCII input. See -.IR rune (3). +.IM rune (3) . .PP Letting numbers be binary, a rune x is converted to a multibyte @@ -85,7 +85,7 @@ In the inverse mapping, any sequence except those described above is incorrect and is converted to rune hexadecimal 0080. .SH "SEE ALSO" -.IR ascii (1), -.IR tcs (1), -.IR rune (3), +.IM ascii (1) , +.IM tcs (1) , +.IM rune (3) , .IR "The Unicode Standard" . diff --git a/man/man7/venti.7 b/man/man7/venti.7 index 382bf67bd..960920fcd 100644 --- a/man/man7/venti.7 +++ b/man/man7/venti.7 @@ -14,19 +14,19 @@ of clients. This manual page documents the basic concepts of block storage using Venti as well as the Venti network protocol. .PP -.IR Venti (1) +.IM Venti (1) documents some simple clients. -.IR Vac (1), -.IR vacfs (4), +.IM Vac (1) , +.IM vacfs (4) , and -.IR vbackup (8) +.IM vbackup (8) are more complex clients. .PP -.IR Venti (3) +.IM Venti (3) describes a C library interface for accessing Venti servers and manipulating Venti data structures. .PP -.IR Venti (8) +.IM Venti (8) describes the programs used to run a Venti server. .PP .SS "Scores @@ -40,11 +40,11 @@ Scores may have an optional prefix, typically used to describe the format of the data. For example, -.IR vac (1) +.IM vac (1) uses a .B vac: prefix, while -.IR vbackup (8) +.IM vbackup (8) uses prefixes corresponding to the file system types: .BR ext2: , @@ -93,7 +93,7 @@ Keeping this parallel representation is a minor annoyance but makes it possible for general programs like .I venti/copy (see -.IR venti (1)) +.IM venti (1) ) to traverse the block tree without knowing the specific details of any particular program's data. .SS "Block Types @@ -202,7 +202,7 @@ Text strings are represented similarly, using a two-byte count with the text itself stored as a UTF-encoded sequence of Unicode characters (see -.IR utf (7)). +.IM utf (7) ). Text strings are not .SM NUL\c -terminated: @@ -395,7 +395,7 @@ Use and .I vtfromdisktype (see -.IR venti (3)) +.IM venti (3) ) to convert a block type enumeration value .RB ( VtDataType , etc.) @@ -457,9 +457,9 @@ in the packet may be either 2 or 4 bytes; the total packet length distinguishes the two cases. .SH SEE ALSO -.IR venti (1), -.IR venti (3), -.IR venti (8) +.IM venti (1) , +.IM venti (3) , +.IM venti (8) .br Sean Quinlan and Sean Dorward, ``Venti: a new approach to archival storage'', diff --git a/man/man8/fossilcons.8 b/man/man8/fossilcons.8 index b59b6b6a7..49a42e094 100644 --- a/man/man8/fossilcons.8 +++ b/man/man8/fossilcons.8 @@ -340,7 +340,7 @@ con /srv/fscons .SH DESCRIPTION These are configuration and maintenance commands executed at the console of a -.IR fossil (4) +.IM fossil (4) file server. The commands are split into three groups above: file server configuration, @@ -372,11 +372,11 @@ a file in any file system served by .I 9p executes a 9P transaction; the arguments are in the same format used by -.IR 9pcon (8). +.IM 9pcon (8) . .PP .I Bind behaves similarly to -.IR bind (1). +.IM bind (1) . It is useful when fossil is started without devices it needs configured into its namespace. @@ -389,7 +389,7 @@ standard error. .PP .I Echo behaves identically to -.IR echo (1), +.IM echo (1) , writing to the console. .PP .I Listen @@ -492,7 +492,7 @@ the string used to represent this user in the 9P protocol .TP .I leader the group's leader (see Plan 9's -.IR stat (5) +.IM stat (5) for a description of the special privileges held by a group leader) .TP .I members @@ -821,7 +821,7 @@ removing a non-empty directory. A subsequent .I flchk (see -.IR fossil (4)) +.IM fossil (4) ) will identify the abandoned storage so it can be reclaimed with .I bfree commands. @@ -1013,7 +1013,7 @@ takes a temporary snapshot of the current file system, recording it in .BI /snapshot/ yyyy / mmdd / hhmm \fR, as described in -.IR fossil (4). +.IM fossil (4) . The .B -a flag causes @@ -1021,7 +1021,7 @@ flag causes to take an archival snapshot, recording it in .BI /archive/ yyyy / mmdd \fR, also described in -.IR fossil (4). +.IM fossil (4) . By default the snapshot is taken of .BR /active , the root of the active file system. @@ -1132,7 +1132,7 @@ writes dirty blocks in memory to the disk. .PP .I Vac prints the Venti score for a -.IR vac (1) +.IM vac (1) archive containing the tree rooted at .IR dir , diff --git a/man/man8/getflags.8 b/man/man8/getflags.8 index 86c295b9c..02c774f57 100644 --- a/man/man8/getflags.8 +++ b/man/man8/getflags.8 @@ -16,7 +16,7 @@ not take arguments, or a letter followed by the space-separated names of its arguments. .I Getflags prints an -.IR rc (1) +.IM rc (1) script on standard output which initializes the environment variable .BI $flag x @@ -51,15 +51,15 @@ and .BR $0 , the program name (see -.IR rc (1)). +.IM rc (1) ). If run under -.IR sh (1), +.IM sh (1) , which does not set .BR $0 , the program name must be given explicitly on the command line. .SH EXAMPLE Parse the arguments for Plan 9's -.IR leak (1): +.IM leak (1) : .IP .EX flagfmt='b,s,f binary,r res,x width' @@ -74,4 +74,4 @@ if(! ifs=() eval `{getflags $*} || ~ $#* 0){ .br .B \*9/src/cmd/usage.c .SH SEE ALSO -.IR arg (3) +.IM arg (3) diff --git a/man/man8/listen1.8 b/man/man8/listen1.8 index 534766bfd..2de33f1fc 100644 --- a/man/man8/listen1.8 +++ b/man/man8/listen1.8 @@ -17,9 +17,7 @@ listen1 \- listen for calls on a network device .I Listen1 is a lightweight listener intended for personal use, modeled from Inferno's -.\" write out this way so automatic programs -.\" don't try to make it into a real man page reference. -\fIlisten\fR(1). +.IR listen (1). It announces on .IR address , @@ -28,7 +26,7 @@ running .I args... for each incoming connection; the network directory is passed in the environment -as +as .BR $net . The .B -v @@ -36,4 +34,4 @@ flag causes verbose logging on standard output. .SH SOURCE .B \*9/src/cmd/listen1.c .SH "SEE ALSO" -.IR dial (3) +.IM dial (3) diff --git a/man/man8/mkfs.8 b/man/man8/mkfs.8 index 2eaba6c1c..fb4fa2e60 100644 --- a/man/man8/mkfs.8 +++ b/man/man8/mkfs.8 @@ -34,7 +34,7 @@ copies files from the file tree to a .B kfs file system (see -.IR kfs (4)). +.IM kfs (4) ). The kfs service is mounted on .I root (default @@ -47,7 +47,7 @@ The .I proto files are read (see -.IR proto (2) +.IM proto (2) for their format) and any files specified in them that are out of date are copied to .BR /n/kfs . @@ -183,5 +183,5 @@ disk/mkext -u -d /n/newfs < arch .br .B \*9/src/cmd/disk/mkext.c .SH "SEE ALSO" -.IR prep (8), -.IR tar (1) +.IM prep (8) , +.IM tar (1) diff --git a/man/man8/vbackup.8 b/man/man8/vbackup.8 index 26ab9178b..e212435ed 100644 --- a/man/man8/vbackup.8 +++ b/man/man8/vbackup.8 @@ -70,7 +70,7 @@ back up Unix file systems to Venti .SH DESCRIPTION These programs back up and restore standard Unix file system images stored in -.IR venti (8). +.IM venti (8) . Images stored in .I venti are named by @@ -102,7 +102,7 @@ The argument .I disk should be a disk or disk partition device that would be appropriate to pass to -.IR mount (8). +.IM mount (8) . .PP The optional argument .I score @@ -135,7 +135,7 @@ The default is the name returned by .I sysname (see -.IR getuser (3)). +.IM getuser (3) ). The default .I mtpt is the place where @@ -149,7 +149,7 @@ command. The default is the name returned by .I sysname (see -.IR getuser (3)). +.IM getuser (3) ). .TP .B -n No-op mode: do not write any blocks to the server @@ -207,7 +207,7 @@ to zero unused blocks instead. .PP .I Vftp presents an -.IR ftp (1)-like +.IM ftp (1) -like interface to a physical or backed-up disk image. It is used mainly for debugging. Type @@ -228,7 +228,7 @@ must be run by the user Because .I address is passed to the host OS kernel rather than interpreted by -.IR dial (3), +.IM dial (3) , it must be only an IP address, not a full dial address. .PP .I Vnfs diff --git a/man/man8/venti-backup.8 b/man/man8/venti-backup.8 index 10614a501..88bad8f33 100644 --- a/man/man8/venti-backup.8 +++ b/man/man8/venti-backup.8 @@ -104,8 +104,8 @@ for a version that does this. .SH SOURCE .B \*9/src/cmd/venti/srv .SH SEE ALSO -.IR venti (7), -.IR venti (8) +.IM venti (7) , +.IM venti (8) .SH BUGS .I Wrarena can't read a pipe or network connection containing an arena; diff --git a/man/man8/venti-fmt.8 b/man/man8/venti-fmt.8 index 7c44754f6..19679ca0e 100644 --- a/man/man8/venti-fmt.8 +++ b/man/man8/venti-fmt.8 @@ -99,9 +99,9 @@ syncindex \- prepare and maintain a venti server These commands aid in the setup, maintenance, and debugging of venti servers. See -.IR venti (7) +.IM venti (7) for an overview of the venti system and -.IR venti (8) +.IM venti (8) for an overview of the data structures used by the venti server. .PP Note that the units for the various sizes in the following @@ -195,7 +195,7 @@ formats the given .I file as a Bloom filter (see -.IR venti (7)). +.IM venti (7) ). The options are: .TF "\fL-s\fI size" .PD @@ -264,7 +264,7 @@ overflow. The total size of the index should be about 2% to 10% of the total size of the arenas, but the exact percentage depends both on the index block size and the compressed size of blocks stored. See the discussion in -.IR venti (8) +.IM venti (8) for more. .PP .I Fmtindex @@ -401,8 +401,8 @@ Increase the verbosity of output. .SH SOURCE .B \*9/src/cmd/venti/srv .SH SEE ALSO -.IR venti (7), -.IR venti (8) +.IM venti (7) , +.IM venti (8) .SH BUGS .I Buildindex should allow an individual index section to be rebuilt. diff --git a/man/man8/venti.8 b/man/man8/venti.8 index 4fd40df66..d6c26903f 100644 --- a/man/man8/venti.8 +++ b/man/man8/venti.8 @@ -40,7 +40,7 @@ venti \- archival storage server .I Venti is a SHA1-addressed archival storage server. See -.IR venti (7) +.IM venti (7) for a full introduction to the system. This page documents the structure and operation of the server. .PP @@ -138,7 +138,7 @@ less than 10 are not very useful; greater than 24 are probably a waste of memory. .I Fmtbloom (see -.IR venti-fmt (8)) +.IM venti-fmt (8) ) can be given either .I nhash or @@ -220,7 +220,7 @@ The venti server announces two network services, one .BR venti , 17034) serving the venti protocol as described in -.IR venti (7), +.IM venti (7) , and one serving HTTP (conventionally TCP port .BR http , @@ -333,7 +333,7 @@ with or .I fmtisect (see -.IR venti-fmt (8)). +.IM venti-fmt (8) ). In particular, only the configuration needs to be changed if a component is moved to a different file. .PP @@ -506,11 +506,11 @@ Start the server and check the storage statistics: .SH SOURCE .B \*9/src/cmd/venti/srv .SH "SEE ALSO" -.IR venti (1), -.IR venti (3), -.IR venti (7), -.IR venti-backup (8) -.IR venti-fmt (8) +.IM venti (1) , +.IM venti (3) , +.IM venti (7) , +.IM venti-backup (8) +.IM venti-fmt (8) .br Sean Quinlan and Sean Dorward, ``Venti: a new approach to archival storage'', @@ -523,7 +523,7 @@ Venti should not require the user to decide how to partition its memory usage. .PP Users of shells other than -.IR rc (1) +.IM rc (1) will not be able to use the program names shown. One solution is to define .B "V=$PLAN9/bin/venti" diff --git a/man/man9/0intro.9p b/man/man9/0intro.9p index 397486f83..f432cf519 100644 --- a/man/man9/0intro.9p +++ b/man/man9/0intro.9p @@ -21,7 +21,7 @@ such a machine is called, somewhat confusingly, a Another possibility for a server is to synthesize files on demand, perhaps based on information on data structures maintained in memory; the -.IR plumber (4) +.IM plumber (4) server is an example of such a server. .PP A @@ -63,7 +63,7 @@ bytes of data. Text strings are represented this way, with the text itself stored as a UTF-8 encoded sequence of Unicode characters (see -.IR utf (7)). +.IM utf (7) ). Text strings in 9P messages are not .SM NUL\c -terminated: @@ -114,7 +114,7 @@ Plan 9 names may contain any printable character (that is, any character outside hexadecimal 00-1F and 80-9F) except slash.) Messages are transported in byte form to allow for machine independence; -.IR fcall (3) +.IM fcall (3) describes routines that convert to and from this form into a machine-dependent C structure. .SH MESSAGES @@ -348,7 +348,7 @@ a ``current file'' on the server. Fids are somewhat like file descriptors in a user process, but they are not restricted to files open for I/O: directories being examined, files being accessed by -.IR stat (3) +.IM stat (3) calls, and so on \(em all files being manipulated by the operating system \(em are identified by fids. Fids are chosen by the client. @@ -461,7 +461,7 @@ to have their input or output attached to fids on 9P servers. See .IR openfd (9p) and -.IR 9pclient (3) +.IM 9pclient (3) for details. .PP The @@ -475,7 +475,7 @@ access permissions (read, write and execute for owner, group and public), access and modification times, and owner and group identifications (see -.IR stat (3)). +.IM stat (3) ). The owner and group identifications are textual names. The .B wstat @@ -523,12 +523,12 @@ into 9P messages. .SS Unix On Unix, 9P services are posted as Unix domain sockets in a well-known directory (see -.IR getns (3) +.IM getns (3) and -.IR 9pserve (4)). +.IM 9pserve (4) ). Clients connect to these servers using a 9P client library (see -.IR 9pclient (3)). +.IM 9pclient (3) ). .SH DIRECTORIES Directories are created by .B create diff --git a/man/man9/attach.9p b/man/man9/attach.9p index ddcf7476d..3a5104d5d 100644 --- a/man/man9/attach.9p +++ b/man/man9/attach.9p @@ -122,7 +122,7 @@ and and .I fsauth (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generate .B attach and @@ -163,6 +163,6 @@ transactions. .\" .B mount .\" system call on an uninitialized connection. .SH SEE ALSO -.IR 9pclient (3), +.IM 9pclient (3) , .IR version (9P), Plan 9's \fIauthsrv\fR(6) diff --git a/man/man9/clunk.9p b/man/man9/clunk.9p index ef3ecdc47..3277c4b05 100644 --- a/man/man9/clunk.9p +++ b/man/man9/clunk.9p @@ -41,7 +41,7 @@ generated by and .I fsunmount (see -.IR 9pclient (3)) +.IM 9pclient (3) ) and indirectly by other actions such as failed .I fsopen calls. diff --git a/man/man9/flush.9p b/man/man9/flush.9p index 9d3ea2675..d0987cac4 100644 --- a/man/man9/flush.9p +++ b/man/man9/flush.9p @@ -99,11 +99,11 @@ flushing a and flushing an invalid tag. .SH ENTRY POINTS The -.IR 9pclient (3) +.IM 9pclient (3) library does not generate .B flush transactions.. -.IR 9pserve (4) +.IM 9pserve (4) generates .B flush transactions to cancel transactions pending when a client hangs up. diff --git a/man/man9/open.9p b/man/man9/open.9p index b8ed973ae..1f74eb07d 100644 --- a/man/man9/open.9p +++ b/man/man9/open.9p @@ -160,7 +160,7 @@ in this case, the .I fscreate call (see -.IR 9pclient (3)) +.IM 9pclient (3) ) uses .B open with truncation. @@ -209,7 +209,7 @@ again. and .I fscreate (see -.IR 9pclient (3)) +.IM 9pclient (3) ) both generate .B open messages; only diff --git a/man/man9/openfd.9p b/man/man9/openfd.9p index 89aa254f9..56fb392a2 100644 --- a/man/man9/openfd.9p +++ b/man/man9/openfd.9p @@ -43,18 +43,18 @@ it cannot be .PP .I Openfd is implemented by -.IR 9pserve (4). +.IM 9pserve (4) . 9P servers that post their services using -.IR 9pserve (4) +.IM 9pserve (4) (or indirectly via -.IR post9pservice (3)) +.IM post9pservice (3) ) will never see a .B Topenfd message. .SH ENTRY POINTS .I Fsopenfd (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generates an .B openfd message. diff --git a/man/man9/read.9p b/man/man9/read.9p index a68f153e9..515f85c31 100644 --- a/man/man9/read.9p +++ b/man/man9/read.9p @@ -114,7 +114,7 @@ to be transferred atomically. and .I fswrite (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generate the corresponding messages. Because they take an offset parameter, the .I fspread diff --git a/man/man9/remove.9p b/man/man9/remove.9p index a9a844a1a..79a646a10 100644 --- a/man/man9/remove.9p +++ b/man/man9/remove.9p @@ -45,7 +45,7 @@ so other fids typically remain usable. .SH ENTRY POINTS .I Fsremove (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generates .B remove messages. diff --git a/man/man9/stat.9p b/man/man9/stat.9p index ab68133d9..b92f2d69f 100644 --- a/man/man9/stat.9p +++ b/man/man9/stat.9p @@ -88,7 +88,7 @@ The and .I convD2M routines (see -.IR fcall (3)) +.IM fcall (3) ) convert between directory entries and a C structure called a .BR Dir . .PP @@ -263,7 +263,7 @@ messages are generated by and .IR fsdirstat (see -.IR 9pclient (3)). +.IM 9pclient (3) ). .PP .B Wstat messages are generated by diff --git a/man/man9/version.9p b/man/man9/version.9p index c4961217a..99f30239b 100644 --- a/man/man9/version.9p +++ b/man/man9/version.9p @@ -91,7 +91,7 @@ requests is called a .SH ENTRY POINTS .I Fsversion (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generates .B version messages; diff --git a/man/man9/walk.9p b/man/man9/walk.9p index 49777f214..b48b947bb 100644 --- a/man/man9/walk.9p +++ b/man/man9/walk.9p @@ -149,13 +149,13 @@ may be packed in a single message. This constant is called .B MAXWELEM in -.IR fcall (3). +.IM fcall (3) . Despite this restriction, the system imposes no limit on the number of elements in a file name, only the number that may be transmitted in a single message. .SH ENTRY POINTS .I Fswalk (see -.IR 9pclient (3)) +.IM 9pclient (3) ) generates walk messages. One or more walk messages may be generated by any call that evaluates file names: diff --git a/tmac/tmac.an b/tmac/tmac.an index 6d2e9c590..c759a59ee 100644 --- a/tmac/tmac.an +++ b/tmac/tmac.an @@ -205,7 +205,12 @@ .. .de IR .nh -.}S 2 1 \& "\Xhtml manref start \\$1 \\$2\\$1" "\\$2\Xhtml manref end \\$1 \\$2" "\\$3" "\\$4" "\\$5" "\\$6" +.}S 2 1 \& "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" +.HY +.}f +.. +.de IM +.}S 2 1 \& "\Xhtml manref start \\$1 \\$2\\$1" "\\$2\Xhtml manref end \\$1 \\$2\\$3" .HY .}f .. From 9843fc0d82c68c78059ccb167e8402def5a4ee1f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Aug 2020 09:10:54 -0400 Subject: [PATCH 263/323] 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(-) diff --git a/src/cmd/fontsrv/mac.c b/src/cmd/fontsrv/mac.c index 9829b5a89..c5a2e0f1e 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; From d32deab17bfffa5bffc5fab3e6577558e40888c5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Aug 2020 20:07:38 -0400 Subject: [PATCH 264/323] tmac: rename IM (italic manual) to MR (manual reference) Suggested by G. Brandon Robinson. --- man/man1/0intro.1 | 148 ++++++++++++++++++------------------- man/man1/9.1 | 14 ++-- man/man1/9c.1 | 2 +- man/man1/9p.1 | 14 ++-- man/man1/9term.1 | 18 ++--- man/man1/acid.1 | 14 ++-- man/man1/acme.1 | 42 +++++------ man/man1/acmeevent.1 | 22 +++--- man/man1/ascii.1 | 12 +-- man/man1/astro.1 | 2 +- man/man1/awk.1 | 6 +- man/man1/bc.1 | 6 +- man/man1/bundle.1 | 10 +-- man/man1/calendar.1 | 2 +- man/man1/cat.1 | 8 +- man/man1/cleanname.1 | 2 +- man/man1/col.1 | 8 +- man/man1/colors.1 | 6 +- man/man1/comm.1 | 4 +- man/man1/core.1 | 8 +- man/man1/crop.1 | 12 +-- man/man1/date.1 | 2 +- man/man1/db.1 | 10 +-- man/man1/dc.1 | 4 +- man/man1/dd.1 | 2 +- man/man1/deroff.1 | 16 ++-- man/man1/devdraw.1 | 8 +- man/man1/dial.1 | 4 +- man/man1/dict.1 | 6 +- man/man1/diff.1 | 8 +- man/man1/doctype.1 | 14 ++-- man/man1/ed.1 | 10 +-- man/man1/eqn.1 | 8 +- man/man1/freq.1 | 4 +- man/man1/git.1 | 2 +- man/man1/grap.1 | 4 +- man/man1/graph.1 | 4 +- man/man1/grep.1 | 12 +-- man/man1/gview.1 | 2 +- man/man1/gzip.1 | 4 +- man/man1/hist.1 | 8 +- man/man1/hoc.1 | 4 +- man/man1/htmlroff.1 | 18 ++--- man/man1/idiff.1 | 4 +- man/man1/install.1 | 14 ++-- man/man1/join.1 | 4 +- man/man1/jpg.1 | 10 +-- man/man1/kill.1 | 12 +-- man/man1/label.1 | 12 +-- man/man1/lex.1 | 2 +- man/man1/look.1 | 2 +- man/man1/ls.1 | 12 +-- man/man1/man.1 | 12 +-- man/man1/map.1 | 4 +- man/man1/mc.1 | 18 ++--- man/man1/mk.1 | 24 +++--- man/man1/mk9660.1 | 4 +- man/man1/mkdir.1 | 4 +- man/man1/mount.1 | 10 +-- man/man1/namespace.1 | 6 +- man/man1/ndb.1 | 14 ++-- man/man1/netfiles.1 | 26 +++---- man/man1/page.1 | 22 +++--- man/man1/paint.1 | 14 ++-- man/man1/passwd.1 | 2 +- man/man1/pem.1 | 6 +- man/man1/pic.1 | 8 +- man/man1/plot.1 | 8 +- man/man1/plumb.1 | 6 +- man/man1/pr.1 | 4 +- man/man1/proof.1 | 6 +- man/man1/ps.1 | 6 +- man/man1/psfonts.1 | 10 +-- man/man1/pwd.1 | 4 +- man/man1/rc.1 | 12 +-- man/man1/readcons.1 | 2 +- man/man1/resample.1 | 8 +- man/man1/rio.1 | 16 ++-- man/man1/rm.1 | 2 +- man/man1/rsa.1 | 8 +- man/man1/sam.1 | 18 ++--- man/man1/scat.1 | 8 +- man/man1/secstore.1 | 8 +- man/man1/secstored.1 | 4 +- man/man1/sed.1 | 8 +- man/man1/seq.1 | 2 +- man/man1/sftpcache.1 | 12 +-- man/man1/sleep.1 | 2 +- man/man1/snarfer.1 | 4 +- man/man1/soelim.1 | 8 +- man/man1/sort.1 | 4 +- man/man1/spell.1 | 6 +- man/man1/split.1 | 8 +- man/man1/src.1 | 12 +-- man/man1/ssam.1 | 4 +- man/man1/ssh-agent.1 | 20 ++--- man/man1/strings.1 | 2 +- man/man1/sum.1 | 4 +- man/man1/tar.1 | 8 +- man/man1/tbl.1 | 8 +- man/man1/tcs.1 | 4 +- man/man1/test.1 | 2 +- man/man1/time.1 | 2 +- man/man1/touch.1 | 6 +- man/man1/tr.1 | 2 +- man/man1/tr2post.1 | 10 +-- man/man1/troff.1 | 16 ++-- man/man1/troff2html.1 | 16 ++-- man/man1/tweak.1 | 12 +-- man/man1/uniq.1 | 2 +- man/man1/vac.1 | 6 +- man/man1/venti.1 | 16 ++-- man/man1/web.1 | 4 +- man/man1/wintext.1 | 16 ++-- man/man1/winwatch.1 | 6 +- man/man1/xd.1 | 2 +- man/man1/yacc.1 | 6 +- man/man1/yesterday.1 | 6 +- man/man3/0intro.3 | 54 +++++++------- man/man3/9p-cmdbuf.3 | 4 +- man/man3/9p-fid.3 | 8 +- man/man3/9p-file.3 | 4 +- man/man3/9p-intmap.3 | 4 +- man/man3/9p.3 | 18 ++--- man/man3/9pclient.3 | 22 +++--- man/man3/acme.3 | 28 +++---- man/man3/addpt.3 | 2 +- man/man3/aes.3 | 20 ++--- man/man3/allocimage.3 | 20 ++--- man/man3/arg.3 | 4 +- man/man3/arith3.3 | 2 +- man/man3/atof.3 | 4 +- man/man3/auth.3 | 20 ++--- man/man3/authsrv.3 | 6 +- man/man3/bin.3 | 4 +- man/man3/bio.3 | 20 ++--- man/man3/blowfish.3 | 20 ++--- man/man3/cachechars.3 | 20 ++--- man/man3/cleanname.3 | 2 +- man/man3/color.3 | 16 ++-- man/man3/complete.3 | 8 +- man/man3/ctime.3 | 8 +- man/man3/des.3 | 20 ++--- man/man3/dial.3 | 4 +- man/man3/dirread.3 | 16 ++-- man/man3/draw.3 | 16 ++-- man/man3/drawfcall.3 | 12 +-- man/man3/dsa.3 | 22 +++--- man/man3/dup.3 | 2 +- man/man3/elgamal.3 | 20 ++--- man/man3/encode.3 | 4 +- man/man3/encrypt.3 | 2 +- man/man3/errstr.3 | 8 +- man/man3/event.3 | 22 +++--- man/man3/exec.3 | 18 ++--- man/man3/exits.3 | 8 +- man/man3/fcall.3 | 14 ++-- man/man3/flate.3 | 2 +- man/man3/fmtinstall.3 | 20 ++--- man/man3/frame.3 | 12 +-- man/man3/genrandom.3 | 8 +- man/man3/get9root.3 | 6 +- man/man3/getenv.3 | 4 +- man/man3/getfields.3 | 8 +- man/man3/getns.3 | 4 +- man/man3/getsnarf.3 | 4 +- man/man3/getuser.3 | 4 +- man/man3/getwd.3 | 6 +- man/man3/graphics.3 | 80 ++++++++++---------- man/man3/html.3 | 2 +- man/man3/ioproc.3 | 22 +++--- man/man3/ip.3 | 4 +- man/man3/isalpharune.3 | 2 +- man/man3/keyboard.3 | 14 ++-- man/man3/lock.3 | 2 +- man/man3/mach-cmd.3 | 14 ++-- man/man3/mach-file.3 | 6 +- man/man3/mach-map.3 | 16 ++-- man/man3/mach-stack.3 | 4 +- man/man3/mach-swap.3 | 2 +- man/man3/mach-symbol.3 | 14 ++-- man/man3/mach.3 | 24 +++--- man/man3/malloc.3 | 8 +- man/man3/matrix.3 | 2 +- man/man3/memdraw.3 | 34 ++++----- man/man3/memlayer.3 | 22 +++--- man/man3/memory.3 | 2 +- man/man3/mouse.3 | 30 ++++---- man/man3/mousescrollsize.3 | 8 +- man/man3/mp.3 | 4 +- man/man3/mux.3 | 6 +- man/man3/ndb.3 | 10 +-- man/man3/needstack.3 | 6 +- man/man3/notify.3 | 20 ++--- man/man3/open.3 | 12 +-- man/man3/opentemp.3 | 4 +- man/man3/pipe.3 | 14 ++-- man/man3/plumb.3 | 24 +++--- man/man3/post9pservice.3 | 12 +-- man/man3/postnote.3 | 4 +- man/man3/prime.3 | 10 +-- man/man3/print.3 | 18 ++--- man/man3/proto.3 | 2 +- man/man3/pushtls.3 | 8 +- man/man3/qball.3 | 2 +- man/man3/quaternion.3 | 8 +- man/man3/quote.3 | 22 +++--- man/man3/rand.3 | 8 +- man/man3/rc4.3 | 20 ++--- man/man3/read.3 | 8 +- man/man3/readcolmap.3 | 10 +-- man/man3/readcons.3 | 2 +- man/man3/regexp.3 | 6 +- man/man3/rfork.3 | 12 +-- man/man3/rsa.3 | 22 +++--- man/man3/rune.3 | 4 +- man/man3/runestrcat.3 | 8 +- man/man3/searchpath.3 | 8 +- man/man3/sechash.3 | 14 ++-- man/man3/seek.3 | 6 +- man/man3/sendfd.3 | 12 +-- man/man3/setjmp.3 | 6 +- man/man3/sleep.3 | 6 +- man/man3/stat.3 | 10 +-- man/man3/strcat.3 | 10 +-- man/man3/string.3 | 2 +- man/man3/stringsize.3 | 14 ++-- man/man3/subfont.3 | 28 +++---- man/man3/sysfatal.3 | 14 ++-- man/man3/thread.3 | 28 +++---- man/man3/time.3 | 2 +- man/man3/udpread.3 | 2 +- man/man3/venti-cache.3 | 16 ++-- man/man3/venti-client.3 | 14 ++-- man/man3/venti-conn.3 | 22 +++--- man/man3/venti-fcall.3 | 16 ++-- man/man3/venti-file.3 | 12 +-- man/man3/venti-log.3 | 8 +- man/man3/venti-mem.3 | 4 +- man/man3/venti-packet.3 | 4 +- man/man3/venti-server.3 | 12 +-- man/man3/venti-zero.3 | 4 +- man/man3/venti.3 | 50 ++++++------- man/man3/wait.3 | 16 ++-- man/man3/window.3 | 16 ++-- man/man4/0intro.4 | 14 ++-- man/man4/9import.4 | 16 ++-- man/man4/9pserve.4 | 8 +- man/man4/acme.4 | 10 +-- man/man4/factotum.4 | 30 ++++---- man/man4/fontsrv.4 | 12 +-- man/man4/fossil.4 | 34 ++++----- man/man4/import.4 | 6 +- man/man4/plumber.4 | 18 ++--- man/man4/ramfs.4 | 6 +- man/man4/smugfs.4 | 6 +- man/man4/srv.4 | 10 +-- man/man4/tapefs.4 | 8 +- man/man4/vacfs.4 | 4 +- man/man7/color.7 | 14 ++-- man/man7/face.7 | 8 +- man/man7/font.7 | 22 +++--- man/man7/htmlroff.7 | 6 +- man/man7/image.7 | 32 ++++---- man/man7/keyboard.7 | 28 +++---- man/man7/man.7 | 6 +- man/man7/map.7 | 2 +- man/man7/mhtml.7 | 18 ++--- man/man7/mpictures.7 | 4 +- man/man7/ms.7 | 20 ++--- man/man7/ndb.7 | 6 +- man/man7/plot.7 | 2 +- man/man7/plumb.7 | 18 ++--- man/man7/regexp.7 | 6 +- man/man7/thumbprint.7 | 4 +- man/man7/utf.7 | 8 +- man/man7/venti.7 | 28 +++---- man/man8/fossilcons.8 | 18 ++--- man/man8/getflags.8 | 10 +-- man/man8/listen1.8 | 2 +- man/man8/mkfs.8 | 8 +- man/man8/vbackup.8 | 12 +-- man/man8/venti-backup.8 | 4 +- man/man8/venti-fmt.8 | 12 +-- man/man8/venti.8 | 20 ++--- tmac/tmac.an | 5 +- 286 files changed, 1591 insertions(+), 1588 deletions(-) diff --git a/man/man1/0intro.1 b/man/man1/0intro.1 index 5c45aefe9..780be91da 100644 --- a/man/man1/0intro.1 +++ b/man/man1/0intro.1 @@ -32,15 +32,15 @@ they expect the environment variable to contain the name of the root of the tree. See -.IM install (1) +.MR install (1) for details about installation. .PP Many of the familiar Unix commands, for example -.IM cat (1) , -.IM ls (1) , +.MR cat (1) , +.MR ls (1) , and -.IM wc (1) , +.MR wc (1) , are present, but in their Plan 9 forms: .I cat takes no options, @@ -50,12 +50,12 @@ and .I wc counts UTF characters. In some cases, the differences are quite noticeable: -.IM grep (1) +.MR grep (1) and -.IM sed (1) +.MR sed (1) expect Plan 9 regular expressions (see -.IM regexp (7) ), +.MR regexp (7) ), which are closest to what Unix calls extended regular expressions. Because of these differences, it is not recommended to put .B $PLAN9/bin @@ -63,16 +63,16 @@ before the usual system .B bin directories in your search path. Instead, put it at the end of your path and use the -.IM 9 (1) +.MR 9 (1) script when you want to invoke the Plan 9 version of a traditional Unix command. .PP Occasionally the Plan 9 programs have been changed to adapt to Unix. -.IM Mk (1) +.MR Mk (1) now allows mkfiles to choose their own shell, and -.IM rc (1) +.MR rc (1) has a .I ulimit builtin and manages @@ -80,14 +80,14 @@ builtin and manages .PP Many of the graphical programs from Plan 9 are present, including -.IM sam (1) +.MR sam (1) and -.IM acme (1) . +.MR acme (1) . An X11 window manager -.IM rio (1) +.MR rio (1) mimics Plan 9's window system, with command windows implemented by the external program -.IM 9term (1) . +.MR 9term (1) . Following the style of X Windows, these programs run in new windows rather than the one in which they are invoked. They all take a @@ -101,10 +101,10 @@ The argument is one of \fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR. .PP The -.IM plumber (4) +.MR plumber (4) helps to connect the various Plan 9 programs together, and fittings like -.IM web (1) +.MR web (1) connect it to external programs such as web browsers; one can click on a URL in .I acme @@ -119,17 +119,17 @@ with file servers by reading and writing files. This cannot be done directly on Unix. Instead the servers listen for 9P connections on Unix domain sockets; clients connect to these sockets and speak 9P directly using the -.IM 9pclient (3) +.MR 9pclient (3) library. -.IM Intro (4) +.MR Intro (4) tells more of the story. The effect is not as clean as on Plan 9, but it gets the job done and still provides a uniform and easy-to-understand mechanism. The -.IM 9p (1) +.MR 9p (1) client can be used in shell scripts or by hand to carry out simple interactions with servers. -.IM Netfiles (1) +.MR Netfiles (1) is an experimental client for acme. .SS External databases Some programs rely on large databases that would be @@ -146,7 +146,7 @@ The shell scripts and .I 9l (see -.IM 9c (1) ) +.MR 9c (1) ) provide a simple interface to the underlying system compiler and linker, similar to the .I 2c @@ -165,22 +165,22 @@ so that no options are needed. .PP The only way to write multithreaded programs is to use the -.IM thread (3) +.MR thread (3) library. -.IM Rfork (3) +.MR Rfork (3) exists but is not as capable as on Plan 9. There are many unfortunate by necessary preprocessor diversions to make Plan 9 and Unix libraries coexist. See -.IM intro (3) +.MR intro (3) for details. .PP The debuggers -.IM acid (1) +.MR acid (1) and -.IM db (1) +.MR db (1) and the debugging library -.IM mach (3) +.MR mach (3) are works in progress. They are platform-independent, so that x86 Linux core dumps can be inspected on PowerPC Mac OS X machines, @@ -203,22 +203,22 @@ but that it is the extent to which they have been developed and exercised. .SS Porting programs The vast majority of the familiar Plan 9 programs have been ported, including the Unicode-aware -.IM troff (1) . +.MR troff (1) . .PP Of the more recent additions to Plan 9, -.IM factotum (4) , -.IM secstore (1) , +.MR factotum (4) , +.MR secstore (1) , and -.IM secstored (1) , -.IM vac (1) , -.IM vacfs (4) , +.MR secstored (1) , +.MR vac (1) , +.MR vacfs (4) , and -.IM venti (8) +.MR venti (8) are all ported. .PP A backup system providing a dump file system built atop Venti is in progress; see -.IM vbackup (8) . +.MR vbackup (8) . .SS Porting to new systems Porting the tree to new operating systems or architectures should be straightforward, as system-specific code has been @@ -240,9 +240,9 @@ need to write any system specific code at all. .PP There are other smaller system dependencies, such as the terminal handling code in -.IM 9term (1) +.MR 9term (1) and the implementation of -.IM getcallerpc (3) , +.MR getcallerpc (3) , but these are usually simple and are not on the critical path for getting the system up and running. .SH SEE ALSO @@ -255,7 +255,7 @@ The manual pages are in a Unix style tree, with names like instead of Plan 9's simpler .BR $PLAN9/man/1/cat , so that the Unix -.IM man (1) +.MR man (1) utility can handle it. Some systems, for example Debian Linux, deduce the man page locations from the search path, so that @@ -300,52 +300,52 @@ describes the Plan 9 file protocol 9P. These pages describe parts of the system that are new or different from Plan 9 from Bell Labs: .IP -.IM 9 (1) , -.IM 9c (1) , -.IM 9p (1) , -.IM 9term (1) , +.MR 9 (1) , +.MR 9c (1) , +.MR 9p (1) , +.MR 9term (1) , .I acidtypes in -.IM acid (1) , -.IM dial (1) , -.IM git (1) , -.IM label (1) , +.MR acid (1) , +.MR dial (1) , +.MR git (1) , +.MR label (1) , the .B MKSHELL variable in -.IM mk (1) , -.IM namespace (1) , -.IM netfiles (1) , -.IM page (1) , -.IM psfonts (1) , -.IM rio (1) , -.IM web (1) , -.IM wintext (1) +.MR mk (1) , +.MR namespace (1) , +.MR netfiles (1) , +.MR page (1) , +.MR psfonts (1) , +.MR rio (1) , +.MR web (1) , +.MR wintext (1) .IP -.IM intro (3) , -.IM 9pclient (3) , +.MR intro (3) , +.MR 9pclient (3) , the .B unix network in -.IM dial (3) , -.IM exits (3) , -.IM get9root (3) , -.IM getns (3) , -.IM notify (3) , -.IM post9pservice (3) , -.IM rfork (3) , -.IM searchpath (3) , -.IM sendfd (3) , -.IM udpread (3) , -.IM venti (3) , -.IM wait (3) , -.IM wctl (3) +.MR dial (3) , +.MR exits (3) , +.MR get9root (3) , +.MR getns (3) , +.MR notify (3) , +.MR post9pservice (3) , +.MR rfork (3) , +.MR searchpath (3) , +.MR sendfd (3) , +.MR udpread (3) , +.MR venti (3) , +.MR wait (3) , +.MR wctl (3) .IP -.IM intro (4) , -.IM 9pserve (4) , -.IM import (4) , +.MR intro (4) , +.MR 9pserve (4) , +.MR import (4) , .IP -.IM vbackup (8) +.MR vbackup (8) .IP .IR openfd (9p) .SH DIAGNOSTICS @@ -356,4 +356,4 @@ exit with string statuses. In fact, exiting with an empty status corresponds to exiting with status 0, and exiting with any non-empty string corresponds to exiting with status 1. See -.IM exits (3) . +.MR exits (3) . diff --git a/man/man1/9.1 b/man/man1/9.1 index b39ca885e..34c150d21 100644 --- a/man/man1/9.1 +++ b/man/man1/9.1 @@ -12,7 +12,7 @@ .B . .B 9 (from -.IM sh (1) ) +.MR sh (1) ) .PP .B 9.rc .I cmd @@ -24,7 +24,7 @@ .B . .B 9.rc (from -.IM rc (1) ) +.MR rc (1) ) .PP .B u .I cmd @@ -36,7 +36,7 @@ .B . .B u (from -.IM sh (1) ) +.MR sh (1) ) .PP .B u.rc .I cmd @@ -48,7 +48,7 @@ .B . .B u.rc (from -.IM rc (1) ) +.MR rc (1) ) .SH DESCRIPTION Because Plan 9 supplies commands with the same name as but different behavior than many basic Unix system commands @@ -86,7 +86,7 @@ in order to make the current shell start running in the Plan 9 environment. is the same as .I 9 but written for use by the shell -.IM rc (1) . +.MR rc (1) . .PP .I U and @@ -106,7 +106,7 @@ $ 9 grep '[α-ζ]' /etc/passwd .EE .PP Start an -.IM rc (1) +.MR rc (1) with the Plan 9 commands in the path before the system commands, and then run the Unix .IR ls : @@ -124,7 +124,7 @@ $ 9 rc .br .B \*9/bin/u.rc .SH SEE ALSO -.IM intro (1) +.MR intro (1) .SH BUGS Some shell configurations (notably, oh-my-zsh) diff --git a/man/man1/9c.1 b/man/man1/9c.1 index 14bb618d8..dd15926d7 100644 --- a/man/man1/9c.1 +++ b/man/man1/9c.1 @@ -164,7 +164,7 @@ With .BR t , give a long listing of all information about the files, somewhat like a listing by -.IM ls (1) , +.MR ls (1) , showing .br .ns diff --git a/man/man1/9p.1 b/man/man1/9p.1 index 3a77e244f..4580587db 100644 --- a/man/man1/9p.1 +++ b/man/man1/9p.1 @@ -121,11 +121,11 @@ copy a line from standard input to the file. Print errors, but don't give up. .B Rdwr is useful for interacting with servers like -.IM factotum (4) . +.MR factotum (4) . .TP .B ls Print a directory listing in the format of -.IM ls (1) . +.MR ls (1) . The .B -d and @@ -150,12 +150,12 @@ it connects to the Unix domain socket .I service in the name space directory (see -.IM intro (4) ) +.MR intro (4) ) and then accesses .IR subpath . .SH EXAMPLE To update -.IM plumber (4) 's +.MR plumber (4) 's copy of your plumbing rules after editing .BR $HOME/lib/plumbing : .IP @@ -164,7 +164,7 @@ cat $HOME/lib/plumbing | 9p write plumb/rules .EE .PP To display the contents of the current -.IM acme (4) +.MR acme (4) window: .IP .EX @@ -173,6 +173,6 @@ window: .SH SOURCE .B \*9/src/cmd/9p.c .SH SEE ALSO -.IM intro (4) , +.MR intro (4) , .IR intro (9p), -.IM 9pclient (3) +.MR 9pclient (3) diff --git a/man/man1/9term.1 b/man/man1/9term.1 index bf0ee27f6..2e0426341 100644 --- a/man/man1/9term.1 +++ b/man/man1/9term.1 @@ -58,7 +58,7 @@ uses the imported value of .B $font if set; otherwise it uses the graphics system default. (See -.IM font (7) +.MR font (7) for a full discussion of font syntaxes.) .PP .I 9term @@ -96,7 +96,7 @@ Characters typed on the keyboard replace the selected text; if this text is not empty, it is placed in a .I snarf buffer common to all windows but distinct from that of -.IM sam (1) . +.MR sam (1) . .PP Programs access the text in the window at a single point maintained automatically by @@ -163,7 +163,7 @@ and erases the character before the word. .PP An ACK character (control-F) or Insert character triggers file name completion for the preceding string (see -.IM complete (3) ). +.MR complete (3) ). .PP Text may be moved vertically within the window. A scroll bar on the left of the window shows in its clear portion what fragment of the @@ -201,7 +201,7 @@ EOT, so the terminal must be set up with EOT as the ``eof'' character. .I 9term runs -.IM stty (1) +.MR stty (1) to establish this when the terminal is created. .PP .I 9term @@ -231,13 +231,13 @@ are a few common ones where they fall short. First, programs using the GNU readline library typically disable terminal echo and perform echoing themselves. The most common example is the shell -.IM bash (1) . +.MR bash (1) . Disabling the use of readline with .RB `` "set +o emacs" '' .RI [ sic ] usually restores the desired behavior. Second, remote terminal programs such as -.IM ssh (1) +.MR ssh (1) typically run with echo disabled, relying on the remote system to echo characters as desired. Plan 9's @@ -279,7 +279,7 @@ The menu item sends the contents of the selection (not the snarf buffer) to the .I plumber (see -.IM plumb (1) ). +.MR plumb (1) ). If the selection is empty, it sends the white-space-delimited text containing the selection (typing cursor). A typical use of this feature is to tell the editor to find the source of an error @@ -323,7 +323,7 @@ Not a .IR 9term bug: when running -.IM bash (1) +.MR bash (1) in .RB `` "set +o emacs" '' mode, its handling of interrupts is broken. @@ -334,4 +334,4 @@ character typed. .PP Unix makes everything harder. .SH SEE ALSO -.IM wintext (1) +.MR wintext (1) diff --git a/man/man1/acid.1 b/man/man1/acid.1 index a593f1c02..ec17c00fd 100644 --- a/man/man1/acid.1 +++ b/man/man1/acid.1 @@ -70,7 +70,7 @@ at startup; see below. .BI -m " machine Assume instructions are for the given CPU type (see -.IM mach (3) ) +.MR mach (3) ) instead of using the executable header to select the CPU type. .TP @@ -145,7 +145,7 @@ subscripts counted from 0. .BI delete " list", " subscript .PP Format codes are the same as in -.IM db (1) . +.MR db (1) . Formats may be attached to (unary) expressions with .BR \e , e.g. @@ -230,7 +230,7 @@ Print 10 lines of source around the program address. .BI Bsrc( address ) Get the source line for the program address into a window of a running -.IM sam (1) +.MR sam (1) and select it. .TP .BI line( address ) @@ -323,7 +323,7 @@ Make the given process current. .TP .BI rc( string ) Escape to the shell, -.IM rc (1) , +.MR rc (1) , to execute the command string. .TP .BI include( string ) @@ -449,7 +449,7 @@ notation) .BR *array . .PP Trace the system calls executed by -.IM ls (1) +.MR ls (1) (neither does this one): .IP .EX @@ -503,8 +503,8 @@ acid: cont() .SH SOURCE .B \*9/src/cmd/acid .SH "SEE ALSO" -.IM mk (1) , -.IM db (1) +.MR mk (1) , +.MR db (1) .br Phil Winterbottom, ``Acid Manual''. diff --git a/man/man1/acme.1 b/man/man1/acme.1 index a631d3c37..852a8f7f1 100644 --- a/man/man1/acme.1 +++ b/man/man1/acme.1 @@ -45,7 +45,7 @@ The interactive interface uses the keyboard and mouse; external programs use a set of files served by .IR acme ; these are discussed in -.IM acme (4) . +.MR acme (4) . .PP Any named .I files @@ -86,7 +86,7 @@ The option instructs .I acme to use FUSE (see -.IM 9pfuse (4) ) +.MR 9pfuse (4) ) to mount itself at .IR mtpt . (Experimental.) @@ -98,10 +98,10 @@ windows are in two parts: a one-line above a multi-line .IR body . The body typically contains an image of a file, as in -.IM sam (1) , +.MR sam (1) , or the output of a program, as in an -.IM rio (1) +.MR rio (1) window. The tag contains a number of blank-separated words, followed by a vertical bar character, followed by anything. @@ -118,9 +118,9 @@ a slash. .SS Scrolling Each window has a scroll bar to the left of the body. The scroll bar behaves much as in -.IM sam (1) +.MR sam (1) or -.IM rio (1) +.MR rio (1) except that scrolling occurs when the button is pressed, rather than released, and continues as long as the mouse button is held down in the scroll bar. @@ -131,7 +131,7 @@ down the scroll bar speeds up the rate of scrolling. .B -r reverses the scrolling behavior of buttons 1 and 3, to behave more like -.IM xterm (1) .) +.MR xterm (1) .) .SS Layout .I Acme windows are arranged in columns. By default, it creates two columns when starting; @@ -164,7 +164,7 @@ pre-loads them with useful commands. Also, the tag across the top maintains a list of executing long-running commands. .SS Typing The behavior of typed text is similar to that in -.IM rio (1) +.MR rio (1) except that the characters are delivered to the tag or body under the mouse; there is no `click to type'. (The experimental option @@ -172,7 +172,7 @@ except that the characters are delivered to the tag or body under the mouse; the causes typing to go to the most recently clicked-at or made window.) The usual backspacing conventions apply. As in -.IM sam (1) +.MR sam (1) but not .IR rio , the ESC key selects the text typed since the last mouse action, @@ -249,7 +249,7 @@ is identified by the context of the command. These error windows are created when needed. .SS "Mouse button 1 Mouse button 1 selects text just as in -.IM sam (1) +.MR sam (1) or .IR rio (1) , including the usual double-clicking conventions. @@ -305,7 +305,7 @@ by default. .TP .B Edit Treat the argument as a text editing command in the style of -.IM sam (1) . +.MR sam (1) . The full .B Sam language is implemented except for the commands @@ -379,7 +379,7 @@ With no arguments, prints the supplementary list. This command is largely superseded by plumbing (see -.IM plumb (7) ). +.MR plumb (7) ). .TP .B Indent Set the autoindent mode according to the argument: @@ -507,7 +507,7 @@ If the text indicated with button 2 is not a recognized built-in, it is executed a shell command. For example, indicating .B date with button 2 runs -.IM date (1) . +.MR date (1) . The standard and error outputs of commands are sent to the error window associated with the directory from which the command was run, which will be created if @@ -525,7 +525,7 @@ in a window containing executing .B mk will run -.IM mk (1) +.MR mk (1) in .BR /home/rob/sam , producing output in a window labeled @@ -539,12 +539,12 @@ and .B $winid set to the window's id number (see -.IM acme (4) ). +.MR acme (4) ). .PP The environment variable .B $acmeshell determines which shell is used to execute such commands; the -.IM rc (1) +.MR rc (1) shell is used by default. .SS "Mouse button 3 Pointing at text with button 3 instructs @@ -574,7 +574,7 @@ command adds directories to the standard list.) .PP If the text begins with a colon, it is taken to be an address, in the style of -.IM sam (1) , +.MR sam (1) , within the body of the window containing the text. The address is evaluated, the resulting text highlighted, and the mouse moved to it. Thus, in @@ -644,7 +644,7 @@ then execute clicking button 1 while 2 is held down. .PP When an external command (e.g. -.IM echo (1) ) +.MR echo (1) ) is executed this way, the extra argument is passed as expected and an environment variable .B $acmeaddr @@ -677,7 +677,7 @@ window and runs a (default .BR $SHELL ) in it, turning the window into something analogous to an -.IM 9term (1) +.MR 9term (1) window. Executing text in a .I win @@ -686,7 +686,7 @@ window with button .BR Send . .I Win windows follow the same scrolling heuristic as in -.IM 9term (1) : +.MR 9term (1) : the window scrolls on output only if the window is displaying the end of the buffer. .PP .I Awd @@ -774,7 +774,7 @@ MIPS-specific binaries for applications .br .B \*9/bin/awd .SH SEE ALSO -.IM acme (4) +.MR acme (4) .br Rob Pike, .I diff --git a/man/man1/acmeevent.1 b/man/man1/acmeevent.1 index 52e6d60b8..24fde4f50 100644 --- a/man/man1/acmeevent.1 +++ b/man/man1/acmeevent.1 @@ -61,7 +61,7 @@ acmeevent, acme.rc \- shell script support for acme clients and .I acme.rc make it easy to write simple -.IM acme (1) +.MR acme (1) client programs as shell scripts. .PP .I Acme @@ -69,14 +69,14 @@ clients read the .B event files (see -.IM acme (4) ) +.MR acme (4) ) for the windows they control, reacting to the events. The events are presented in a format that is easy to read with C programs but hard to read with shell scripts. .PP .I Acmeevent reads an -.IM acme (4) +.MR acme (4) event stream from standard input, printing a shell-friendly version of the events, one per line, on standard output. Each output line from @@ -165,7 +165,7 @@ above); below). .I Flag remains from the -.IM acme (4) +.MR acme (4) event format. Because .IR eq0 , @@ -174,7 +174,7 @@ and .I chordarg are explicit in each event (unlike in -.IM acme (4) +.MR acme (4) events), .I flag can usually be ignored. @@ -221,7 +221,7 @@ window. .PP .I Acme.rc is a library of -.IM rc (1) +.MR rc (1) shell functions useful for writing acme clients. .PP .I Newwindow @@ -259,14 +259,14 @@ The most commonly-used command is .BR clean , which marks the window as clean. See -.IM acme (4) +.MR acme (4) for a full list of commands. .PP .I Windump sets the window's dump directory and dump command (see -.IM acme (4) ). +.MR acme (4) ). If either argument is omitted or is .BR - , that argument is not set. @@ -381,9 +381,9 @@ for the full implementation. .br .B \*9/lib/acme.rc .SH SEE ALSO -.IM acme (1) , -.IM acme (4) , -.IM rc (1) +.MR acme (1) , +.MR acme (4) , +.MR rc (1) .SH BUGS There is more that could be done to ease the writing of complicated clients. diff --git a/man/man1/ascii.1 b/man/man1/ascii.1 index 611c7c6dd..99265f467 100644 --- a/man/man1/ascii.1 +++ b/man/man1/ascii.1 @@ -91,7 +91,7 @@ control characters or insert newlines. is similar; it converts between .SM UTF and character values from the Unicode Standard (see -.IM utf (7) ). +.MR utf (7) ). If given a range of hexadecimal numbers, .I unicode prints a table of the specified Unicode characters \(em their values and @@ -126,7 +126,7 @@ The file contains a table of characters and descriptions, sorted in hexadecimal order, suitable for -.IM look (1) +.MR look (1) on the lower case .I hex values of characters. @@ -154,7 +154,7 @@ table of characters and descriptions. .br .B \*9/src/cmd/unicode.c .SH "SEE ALSO" -.IM look (1) , -.IM tcs (1) , -.IM utf (7) , -.IM font (7) +.MR look (1) , +.MR tcs (1) , +.MR utf (7) , +.MR font (7) diff --git a/man/man1/astro.1 b/man/man1/astro.1 index a143f2cf5..b24cfa3fa 100644 --- a/man/man1/astro.1 +++ b/man/man1/astro.1 @@ -114,7 +114,7 @@ default latitude (N), longitude (W), and elevation (meters) .SH SOURCE .B \*9/src/cmd/astro .SH SEE ALSO -.IM scat (1) +.MR scat (1) .SH BUGS The .B k diff --git a/man/man1/awk.1 b/man/man1/awk.1 index da6389bf8..395dfa96d 100644 --- a/man/man1/awk.1 +++ b/man/man1/awk.1 @@ -377,7 +377,7 @@ Patterns are arbitrary Boolean combinations of regular expressions and relational expressions. Regular expressions are as in -.IM regexp (7) . +.MR regexp (7) . Isolated regular expressions in a pattern apply to the entire line. Regular expressions may also occur in @@ -534,8 +534,8 @@ BEGIN { # Simulate echo(1) .SH SOURCE .B \*9/src/cmd/awk .SH SEE ALSO -.IM sed (1) , -.IM regexp (7) , +.MR sed (1) , +.MR regexp (7) , .br A. V. Aho, B. W. Kernighan, P. J. Weinberger, .I diff --git a/man/man1/bc.1 b/man/man1/bc.1 index ee314735c..497481301 100644 --- a/man/man1/bc.1 +++ b/man/man1/bc.1 @@ -218,7 +218,7 @@ Assignment to .B scale influences the number of digits to be retained on arithmetic operations in the manner of -.IM dc (1) . +.MR dc (1) . Assignments to .B ibase or @@ -235,7 +235,7 @@ empty square brackets must follow the array name. .PP .I Bc is actually a preprocessor for -.IM dc (1) , +.MR dc (1) , which it invokes automatically, unless the .B -c (compile only) @@ -273,7 +273,7 @@ mathematical library .B \*9/src/cmd/bc.y .SH "SEE ALSO" .IR dc (1), -.IM hoc (1) +.MR hoc (1) .SH BUGS No .LR && , diff --git a/man/man1/bundle.1 b/man/man1/bundle.1 index b954fdb12..b48803433 100644 --- a/man/man1/bundle.1 +++ b/man/man1/bundle.1 @@ -7,20 +7,20 @@ bundle \- collect files for distribution .SH DESCRIPTION .I Bundle writes on its standard output a shell script for -.IM rc (1) +.MR rc (1) or a Bourne shell which, when executed, will recreate the original .IR files . Its main use is for distributing small numbers of text files by -.IM mail (1) . +.MR mail (1) . .PP Although less refined than standard archives from .I 9ar (see -.IM 9c (1) ) +.MR 9c (1) ) or -.IM tar (1) , +.MR tar (1) , a .IR bundle file @@ -49,7 +49,7 @@ cd gift; sh horse; mk (in .IR 9c (1)), .IR tar (1), -.IM mail (1) +.MR mail (1) .SH BUGS .I Bundle will not create directories and is unsatisfactory for non-text files. diff --git a/man/man1/calendar.1 b/man/man1/calendar.1 index 5c3b2760c..5a305699b 100644 --- a/man/man1/calendar.1 +++ b/man/man1/calendar.1 @@ -43,7 +43,7 @@ processing at the end of the week. On Friday and Saturday, events through Monday are printed. .PP To have your calendar mailed to you every day, use -.IM cron (8) . +.MR cron (8) . .SH FILES .TF $HOME/lib/calendar .TP diff --git a/man/man1/cat.1 b/man/man1/cat.1 index d44817927..7ff12e69b 100644 --- a/man/man1/cat.1 +++ b/man/man1/cat.1 @@ -51,7 +51,7 @@ copies to standard output exactly one line from the named .IR file , default standard input. It is useful in interactive -.IM rc (1) +.MR rc (1) scripts. .PP The @@ -76,11 +76,11 @@ characters and the characters that precede them. It is useful to use as .B $PAGER with the Unix version of -.IM man (1) +.MR man (1) when run inside a .I win (see -.IM acme (1) ) +.MR acme (1) ) window. .SH SOURCE .B \*9/src/cmd/cat.c @@ -89,7 +89,7 @@ window. .br .B \*9/bin/nobs .SH SEE ALSO -.IM cp (1) +.MR cp (1) .SH DIAGNOSTICS .I Read exits with status diff --git a/man/man1/cleanname.1 b/man/man1/cleanname.1 index 50e63f3c8..1f59e6772 100644 --- a/man/man1/cleanname.1 +++ b/man/man1/cleanname.1 @@ -29,4 +29,4 @@ before processing. .SH SOURCE .B \*9/src/cmd/cleanname.c .SH SEE ALSO -.IM cleanname (3) . +.MR cleanname (3) . diff --git a/man/man1/col.1 b/man/man1/col.1 index 426bb7bc9..77d4d46bf 100644 --- a/man/man1/col.1 +++ b/man/man1/col.1 @@ -14,11 +14,11 @@ and half line feeds (ESC-9 and ESC-8) as produced by .I nroff for .2C in -.IM ms (7) +.MR ms (7) or -.IM man (7) +.MR man (7) and for -.IM tbl (1) . +.MR tbl (1) . .I Col is a pure filter. It normally emits only full line feeds; @@ -47,7 +47,7 @@ paginate the output. .SH SOURCE .B \*9/src/cmd/col.c .SH SEE ALSO -.IM pr (1) +.MR pr (1) .SH BUGS .I Col can't back up more than 128 lines or diff --git a/man/man1/colors.1 b/man/man1/colors.1 index 27b439e91..b85f3d8b0 100644 --- a/man/man1/colors.1 +++ b/man/man1/colors.1 @@ -17,13 +17,13 @@ colors, cmapcube \- display color map .I Colors presents a grid showing the colors in the RGBV color map (see -.IM color (7) ). +.MR color (7) ). .PP Clicking mouse button 1 over a color in the grid will display the map index for that color, its red, green, and blue components, and the 32-bit hexadecimal color value as defined in -.IM allocimage (3) . +.MR allocimage (3) . If the .B -x option is specified, the components will also be listed in hexadecimal. @@ -53,4 +53,4 @@ to black or white. .SH SOURCE .B \*9/src/cmd/draw/colors.c .SH SEE ALSO -.IM color (7) +.MR color (7) diff --git a/man/man1/comm.1 b/man/man1/comm.1 index afb2dc257..86d4c34ac 100644 --- a/man/man1/comm.1 +++ b/man/man1/comm.1 @@ -41,7 +41,7 @@ Print lines common to two sorted files. .SH SOURCE .B \*9/src/cmd/comm.c .SH "SEE ALSO" -.IM sort (1) , +.MR sort (1) , .IR cmp (1), .IR diff (1), -.IM uniq (1) +.MR uniq (1) diff --git a/man/man1/core.1 b/man/man1/core.1 index e19c7520d..caf6351ba 100644 --- a/man/man1/core.1 +++ b/man/man1/core.1 @@ -35,7 +35,7 @@ The command, if run, prints a stack trace of the executing thread at the time of the core dump; see -.IM db (1) . +.MR db (1) . .PP If no arguments are given, .I core @@ -50,6 +50,6 @@ searches the current directory. .SH SOURCE .B \*9/src/cmd/core.c .SH "SEE ALSO -.IM acid (1) , -.IM db (1) , -.IM core (5) +.MR acid (1) , +.MR db (1) , +.MR core (5) diff --git a/man/man1/crop.1 b/man/man1/crop.1 index a1cd59255..c47afac65 100644 --- a/man/man1/crop.1 +++ b/man/man1/crop.1 @@ -53,9 +53,9 @@ crop, iconv \- frame, crop, and convert image .SH DESCRIPTION .I Crop reads an -.IM image (7) +.MR image (7) file (default standard input), crops it, and writes it as a compressed -.IM image (7) +.MR image (7) file to standard output. There are two ways to specify a crop, by color value or by geometry. They may be combined in a single run of @@ -65,7 +65,7 @@ in which case the color value crop will be done first. The .B -c option takes a red-green-blue triplet as described in -.IM color (3) . +.MR color (3) . (For example, white is .B 255 @@ -118,7 +118,7 @@ changes the format of pixels in the image Pixels in the image are converted according to the channel descriptor .IR chandesc , (see -.IM image (7) ). +.MR image (7) ). For example, to convert a 4-bit-per-pixel grey-scale image to an 8-bit-per-pixel color-mapped image, .I chandesc @@ -139,8 +139,8 @@ crop -c 255 255 255 -i -10 -b 255 150 150 imagefile > cropped .SH SOURCE .B \*9/src/cmd/draw/crop.c .SH SEE ALSO -.IM image (7) , -.IM color (3) +.MR image (7) , +.MR color (3) .SH BUGS .I Iconv should be able to do Floyd-Steinberg error diffusion or dithering diff --git a/man/man1/date.1 b/man/man1/date.1 index b5ad47818..7d68b94fc 100644 --- a/man/man1/date.1 +++ b/man/man1/date.1 @@ -28,7 +28,7 @@ epoch, 00:00:00 GMT, January 1, 1970. The conversion from Greenwich Mean Time to local time depends on the .B $timezone environment variable; see -.IM ctime (3) . +.MR ctime (3) . .PP If the optional argument .I seconds diff --git a/man/man1/db.1 b/man/man1/db.1 index c87ea4a30..5c2cc9db7 100644 --- a/man/man1/db.1 +++ b/man/man1/db.1 @@ -45,11 +45,11 @@ specifies the memory image of a process. A .I pid gives the id of an executing process to be accessed via -.IM ptrace (2) . +.MR ptrace (2) . A .I corefile specifies the name of a core dump (see -.IM core (5) +.MR core (5) on your system of choice) containing the memory image of a terminated process. This manual refers to the memory image specified by @@ -628,7 +628,7 @@ Dot is assigned to the variable or register named. .TP .B ! The rest of the line is passed to -.IM rc (1) +.MR rc (1) for execution. .TP .BI $ modifier @@ -969,8 +969,8 @@ is one the breakpoint will fire. Beware that local variables may be stored in registers; see the BUGS section. .SH "SEE ALSO" -.IM acid (1) , -.IM core (1) +.MR acid (1) , +.MR core (1) .SH SOURCE .B \*9/src/cmd/db .SH DIAGNOSTICS diff --git a/man/man1/dc.1 b/man/man1/dc.1 index ad5cf3106..70597dcca 100644 --- a/man/man1/dc.1 +++ b/man/man1/dc.1 @@ -235,8 +235,8 @@ lyx .SH SOURCE .B \*9/src/cmd/dc.c .SH "SEE ALSO" -.IM bc (1) , -.IM hoc (1) +.MR bc (1) , +.MR hoc (1) .SH DIAGNOSTICS .I x .LR "is unimplemented" , diff --git a/man/man1/dd.1 b/man/man1/dd.1 index 948e80cb4..6e942fd8b 100644 --- a/man/man1/dd.1 +++ b/man/man1/dd.1 @@ -191,7 +191,7 @@ options become a simple file copy. .SH SOURCE .B \*9/src/cmd/dd.c .SH "SEE ALSO" -.IM cp (1) +.MR cp (1) .SH DIAGNOSTICS .I Dd reports the number of full + partial input and output diff --git a/man/man1/deroff.1 b/man/man1/deroff.1 index 90fba52d5..1489aaddb 100644 --- a/man/man1/deroff.1 +++ b/man/man1/deroff.1 @@ -16,13 +16,13 @@ reads each file in sequence and removes all .I nroff and -.IM troff (1) +.MR troff (1) requests and non-text arguments, backslash constructions, and constructs of preprocessors such as -.IM eqn (1) , -.IM pic (1) , +.MR eqn (1) , +.MR pic (1) , and -.IM tbl (1) . +.MR tbl (1) . Remaining text is written on the standard output. .I Deroff follows files included by @@ -67,7 +67,7 @@ requests. Remove titles, attachments, etc., as well as ordinary .IR troff constructs, from -.IM ms (7) +.MR ms (7) or .I mm documents. @@ -84,7 +84,7 @@ does for and .I latex (see -.IM tex (1) ) +.MR tex (1) ) files what .B deroff -wi does for @@ -96,8 +96,8 @@ files. .B \*9/src/cmd/delatex.lx .SH "SEE ALSO" .IR troff (1), -.IM tex (1) , -.IM spell (1) +.MR tex (1) , +.MR spell (1) .SH BUGS These filters are not complete interpreters of .I troff diff --git a/man/man1/devdraw.1 b/man/man1/devdraw.1 index eda04893b..da36b8e2a 100644 --- a/man/man1/devdraw.1 +++ b/man/man1/devdraw.1 @@ -5,7 +5,7 @@ devdraw \- draw device simulator invoked via .I initdraw (see -.IM graphics (3) ) +.MR graphics (3) ) .SH DESCRIPTION .I Devdraw serves a custom graphics protocol and is the only program @@ -20,9 +20,9 @@ to use all available physical pixels on a retina display. .SH SOURCE .B \*9/src/cmd/devdraw .SH "SEE ALSO -.IM draw (3) , -.IM drawfcall (3) , -.IM graphics (3) +.MR draw (3) , +.MR drawfcall (3) , +.MR graphics (3) .SH BUGS .I Devdraw should probably present a standard 9P server diff --git a/man/man1/dial.1 b/man/man1/dial.1 index a27c2026b..0245ba16e 100644 --- a/man/man1/dial.1 +++ b/man/man1/dial.1 @@ -12,7 +12,7 @@ dial \- connect to a remote service connects to the network address .I addr (see -.IM dial (3) ) +.MR dial (3) ) and then copies data from the connection to standard output, and from standard input to the connection. .PP @@ -27,4 +27,4 @@ to exit only in response to end of file on the network connection. .SH SOURCE .B \*9/src/cmd/dial.c .SH SEE ALSO -.IM dial (3) +.MR dial (3) diff --git a/man/man1/dict.1 b/man/man1/dict.1 index 209aca410..f4654ea3b 100644 --- a/man/man1/dict.1 +++ b/man/man1/dict.1 @@ -53,7 +53,7 @@ Print a pronunciation key. .PD .PP Patterns are regular expressions (see -.IM regexp (7) ), +.MR regexp (7) ), with an implicit leading .L ^ and trailing @@ -154,7 +154,7 @@ searches for dictionaries in the directory named by .PP .I Adict is a dictionary browser for -.IM acme (1) . +.MR acme (1) . When run with no arguments, it creates a new .I acme window named @@ -193,7 +193,7 @@ window. dictionaries .PD .SH "SEE ALSO" -.IM regexp (7) +.MR regexp (7) .SH SOURCE .B \*9/src/cmd/dict .br diff --git a/man/man1/diff.1 b/man/man1/diff.1 index cffbf0b65..c92f45ef4 100644 --- a/man/man1/diff.1 +++ b/man/man1/diff.1 @@ -19,7 +19,7 @@ two directories are compared by the method of .I diff for text files and -.IM cmp (1) +.MR cmp (1) otherwise. If more than two file names are given, then each argument is compared to the last argument as above. @@ -140,9 +140,9 @@ differences. .SH SOURCE .B \*9/src/cmd/diff .SH "SEE ALSO" -.IM cmp (1) , -.IM comm (1) , -.IM ed (1) +.MR cmp (1) , +.MR comm (1) , +.MR ed (1) .SH DIAGNOSTICS Exit status is the empty string for no differences, diff --git a/man/man1/doctype.1 b/man/man1/doctype.1 index fb9d3b055..199323f0e 100644 --- a/man/man1/doctype.1 +++ b/man/man1/doctype.1 @@ -17,16 +17,16 @@ doctype \- intuit command line for formatting a document .SH DESCRIPTION .I Doctype examines a -.IM troff (1) +.MR troff (1) input file to deduce the appropriate text formatting command and prints it on standard output. .I Doctype recognizes input for -.IM troff (1) , +.MR troff (1) , related preprocessors like -.IM eqn (1) , +.MR eqn (1) , and the -.IM ms (7) +.MR ms (7) and .I mm macro packages. @@ -56,8 +56,8 @@ Typeset files named .IR eqn (1), .IR tbl (1), .IR pic (1), -.IM grap (1) , -.IM ms (7) , -.IM man (7) +.MR grap (1) , +.MR ms (7) , +.MR man (7) .SH BUGS In true A.I. style, its best guesses are inspired rather than accurate. diff --git a/man/man1/ed.1 b/man/man1/ed.1 index 64bf4860b..8dd6f5355 100644 --- a/man/man1/ed.1 +++ b/man/man1/ed.1 @@ -96,7 +96,7 @@ beginning of a line. supports the .I "regular expression" notation described in -.IM regexp (7) . +.MR regexp (7) . Regular expressions are used in addresses to specify lines and in one command (see @@ -641,7 +641,7 @@ Dot is unchanged. Send the remainder of the line after the .L ! to -.IM rc (1) +.MR rc (1) to be interpreted as a command. Dot is unchanged. .TP @@ -679,9 +679,9 @@ and all characters after the last newline. .SH SOURCE .B \*9/src/cmd/ed.c .SH "SEE ALSO" -.IM sam (1) , -.IM sed (1) , -.IM regexp (7) +.MR sam (1) , +.MR sed (1) , +.MR regexp (7) .SH DIAGNOSTICS .BI ? name for inaccessible file; diff --git a/man/man1/eqn.1 b/man/man1/eqn.1 index 723b2dc34..e50a500d4 100644 --- a/man/man1/eqn.1 +++ b/man/man1/eqn.1 @@ -15,7 +15,7 @@ eqn \- typeset mathematics .SH DESCRIPTION .I Eqn is a -.IM troff (1) +.MR troff (1) preprocessor for typesetting mathematics on a typesetter. @@ -34,7 +34,7 @@ named in the option (default .BR -Tutf ; see -.IM troff (1) ). +.MR troff (1) ). When run with other preprocessor filters, .I eqn usually comes last. @@ -299,7 +299,7 @@ Mathematical words like .LR cos , .L log are made Roman automatically. -.IM Troff (1) +.MR Troff (1) four-character escapes like .L \e(lh (\(lh) can be used anywhere. @@ -319,7 +319,7 @@ font descriptions for PostScript .B \*9/src/cmd/eqn .SH "SEE ALSO" .IR troff (1), -.IM tbl (1) +.MR tbl (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual''. diff --git a/man/man1/freq.1 b/man/man1/freq.1 index 3c9c0fac4..4a55130ae 100644 --- a/man/man1/freq.1 +++ b/man/man1/freq.1 @@ -36,5 +36,5 @@ character, respectively. .SH SOURCE .B \*9/src/cmd/freq.c .SH SEE ALSO -.IM utf (7) , -.IM wc (1) +.MR utf (7) , +.MR wc (1) diff --git a/man/man1/git.1 b/man/man1/git.1 index 2583141c4..8387407a4 100644 --- a/man/man1/git.1 +++ b/man/man1/git.1 @@ -55,7 +55,7 @@ current file tree. .I Git .I diff runs Unix's -.IM diff (1) +.MR diff (1) to compare the files in the local tree with the corresponding files in the revision history. The special revision diff --git a/man/man1/grap.1 b/man/man1/grap.1 index 40effe127..d36916dc1 100644 --- a/man/man1/grap.1 +++ b/man/man1/grap.1 @@ -9,7 +9,7 @@ grap \- pic preprocessor for drawing graphs .SH DESCRIPTION .I Grap is a -.IM pic (1) +.MR pic (1) preprocessor for drawing graphs on a typesetter. Graphs are surrounded by the .I troff @@ -407,7 +407,7 @@ definitions of standard plotting characters, e.g., bullet .B \*9/src/cmd/grap .SH "SEE ALSO" .IR pic (1), -.IM troff (1) +.MR troff (1) .br J. L. Bentley and B. W. Kernighan, ``GRAP\(emA Language for Typesetting Graphs'', diff --git a/man/man1/graph.1 b/man/man1/graph.1 index 4f1fbed18..f8a1e0888 100644 --- a/man/man1/graph.1 +++ b/man/man1/graph.1 @@ -89,7 +89,7 @@ The next argument is Next argument is one or more of the characters .B bcgkmrwy, choosing pen colors by their initial letter, as in -.IM plot (7) . +.MR plot (7) . Successive curves will cycle through the colors in the given order. .TP .B -s @@ -145,7 +145,7 @@ is reversed. .B \*9/src/cmd/graph .SH "SEE ALSO" .IR plot (1), -.IM grap (1) +.MR grap (1) .SH BUGS Segments that run out of bounds are dropped, not windowed. Logarithmic axes may not be reversed. diff --git a/man/man1/grep.1 b/man/man1/grep.1 index 18632766b..5fe3a9f72 100644 --- a/man/man1/grep.1 +++ b/man/man1/grep.1 @@ -27,7 +27,7 @@ searches the input for lines that match the .IR pattern , a regular expression as defined in -.IM regexp (7) +.MR regexp (7) with the addition of a newline character as an alternative (substitute for .BR | ) @@ -114,11 +114,11 @@ If no files are listed, it searches all files matching .br .B \*9/bin/g .SH SEE ALSO -.IM ed (1) , -.IM awk (1) , -.IM sed (1) , -.IM sam (1) , -.IM regexp (7) +.MR ed (1) , +.MR awk (1) , +.MR sed (1) , +.MR sam (1) , +.MR regexp (7) .SH DIAGNOSTICS Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. diff --git a/man/man1/gview.1 b/man/man1/gview.1 index 153299659..8961b625a 100644 --- a/man/man1/gview.1 +++ b/man/man1/gview.1 @@ -144,7 +144,7 @@ awk 'BEGIN{for(x=.1;x<500;x+=.1)print x,sin(x)/x}' | gview .SH SOURCE .B \*9/src/cmd/draw/gview.c .SH SEE ALSO -.IM awk (1) +.MR awk (1) .SH BUGS The user interface for the .I slant diff --git a/man/man1/gzip.1 b/man/man1/gzip.1 index 593b713fa..2f78c89f6 100644 --- a/man/man1/gzip.1 +++ b/man/man1/gzip.1 @@ -150,8 +150,8 @@ Produce debugging output. .br .B \*9/src/cmd/bzip2 .SH SEE ALSO -.IM tar (1) , -.IM compress (1) +.MR tar (1) , +.MR compress (1) .SH BUGS .I Unzip can only extract files which are uncompressed or compressed diff --git a/man/man1/hist.1 b/man/man1/hist.1 index 41a2b402c..bec129a8e 100644 --- a/man/man1/hist.1 +++ b/man/man1/hist.1 @@ -41,7 +41,7 @@ option enables verbose debugging printout. The .B -d option causes -.IM diff (1) +.MR diff (1) .B -c to be run for each adjacent pair of dump files, while .B -b @@ -73,11 +73,11 @@ by convention, root of dump file system .SH SOURCE .B \*9/src/cmd/hist.c .SH SEE ALSO -.IM yesterday (1) , -.IM vbackup (8) +.MR yesterday (1) , +.MR vbackup (8) .SH BUGS Should be called .IR history , but that name is taken by -.IM sh (1) . +.MR sh (1) . diff --git a/man/man1/hoc.1 b/man/man1/hoc.1 index 561752008..24075b0b0 100644 --- a/man/man1/hoc.1 +++ b/man/man1/hoc.1 @@ -133,8 +133,8 @@ for(i=1; i<12; i++) print gcd(i,12) .SH SOURCE .B \*9/src/cmd/hoc .SH "SEE ALSO" -.IM bc (1) , -.IM dc (1) +.MR bc (1) , +.MR dc (1) .br B. W. Kernighan and R. Pike, .I diff --git a/man/man1/htmlroff.1 b/man/man1/htmlroff.1 index 28d243c77..197c2f04e 100644 --- a/man/man1/htmlroff.1 +++ b/man/man1/htmlroff.1 @@ -21,7 +21,7 @@ htmlroff \- HTML formatting and typesetting .SH DESCRIPTION .I Htmlroff accepts -.IM troff (1) +.MR troff (1) input in the named .I files and formats it as HTML for viewing in a web browser. @@ -63,7 +63,7 @@ HTML entity sequences and so on). .I Htmlroff invokes -.IM tcs (1) +.MR tcs (1) for the conversion. .TP .B -v @@ -73,7 +73,7 @@ Generate debugging output and warnings about suspicious input. Most .I troff input files, especially those using the -.IM ms (7) +.MR ms (7) macros, can be used unaltered. In general, the macro file .B tmac.html @@ -83,10 +83,10 @@ as in .B -ms .BR -mhtml . .PP -.IM Htmlroff (7) +.MR Htmlroff (7) describes the changes to the input language. .PP -.IM Mhtml (7) +.MR Mhtml (7) describes the new macros. .SH EXAMPLES Format the Plan 9 web page: @@ -113,7 +113,7 @@ to Unicode characters like α. .SH SOURCE .B \*9/src/cmd/htmlroff .SH "SEE ALSO -.IM tcs (1) , -.IM troff (1) , -.IM htmlroff (7) , -.IM mhtml (7) +.MR tcs (1) , +.MR troff (1) , +.MR htmlroff (7) , +.MR mhtml (7) diff --git a/man/man1/idiff.1 b/man/man1/idiff.1 index c0ffebcfe..49a2df6b7 100644 --- a/man/man1/idiff.1 +++ b/man/man1/idiff.1 @@ -50,7 +50,7 @@ and prompt again. .PP .I Idiff invokes -.IM diff (1) +.MR diff (1) to compare the files. The .B -b @@ -66,7 +66,7 @@ passed to .SH SOURCE .B \*9/src/cmd/idiff.c .SH "SEE ALSO -.IM diff (1) +.MR diff (1) .br Kernighan and Pike, .IR "The Unix Programming Environment" , diff --git a/man/man1/install.1 b/man/man1/install.1 index 6097f4358..4b173d181 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -15,7 +15,7 @@ cd \*9; ./INSTALL .SH DESCRIPTION To obtain the Plan 9 tree, use Git (see -.IM git (1) ) +.MR git (1) ) or download a tar file from .HR https://9fans.github.io/plan9port "" . .PP @@ -25,7 +25,7 @@ usual place is In the root of the tree, run .BR ./INSTALL . This script builds the Plan 9 build program -.IM mk (1) +.MR mk (1) if necessary, cleans all previously built object files and libraries out of the tree, rebuilds and installs everything, and then cleans up. @@ -109,7 +109,7 @@ can safely be repeated to rebuild the system from scratch. .PP Once the system is built for the first time, it can be maintained and rebuilt using -.IM mk (1) . +.MR mk (1) . To rebuild individual commands or libraries, run .B mk @@ -119,7 +119,7 @@ and .B clean in the appropriate source directory (see -.IM src (1) ). +.MR src (1) ). .SH FILES .TP .B \*9/lib/moveplan9.files @@ -132,7 +132,7 @@ the script that edits the files .TP .B \*9/src/mkmk.sh the shell script used to build -.IM mk (1) +.MR mk (1) .TP .B \*9/dist/manweb the shell script that builds the HTML manual @@ -148,5 +148,5 @@ logged output from the last run of a summary of .B install.log .SH SEE ALSO -.IM intro (1) , -.IM git (1) +.MR intro (1) , +.MR git (1) diff --git a/man/man1/join.1 b/man/man1/join.1 index 13741be36..f9c9d543c 100644 --- a/man/man1/join.1 +++ b/man/man1/join.1 @@ -114,7 +114,7 @@ birthdays empty. The layout of .B /adm/users is given in -.IM passwd (5) ; +.MR passwd (5) ; .B bdays contains sorted lines like .LR "ken:Feb\ 4,\ 1953" . @@ -132,7 +132,7 @@ Print all pairs of users with identical userids. .SH "SEE ALSO" .IR sort (1), .IR comm (1), -.IM awk (1) +.MR awk (1) .SH BUGS With default field separation, the collating sequence is that of diff --git a/man/man1/jpg.1 b/man/man1/jpg.1 index bdc9110bc..037672213 100644 --- a/man/man1/jpg.1 +++ b/man/man1/jpg.1 @@ -122,7 +122,7 @@ Typing a .BR q , DEL, or control-D exits the program. For a more user-friendly interface, use -.IM page (1) , +.MR page (1) , which invokes these programs to convert the images to standard format, displays them, and offers scrolling, panning, and menu-driven navigation among the files. .PP @@ -147,7 +147,7 @@ any of the following options: .TP .B -c Convert the image to a Plan 9 representation, as defined by -.IM image (7) , +.MR image (7) , and write it to standard output. .TP .B -9 @@ -156,7 +156,7 @@ Like but produce an uncompressed image. This saves processing time, particularly when the output is being piped to another program such as -.IM page (1) , +.MR page (1) , since it avoids compression and decompression. .TP .B -t @@ -235,8 +235,8 @@ space in the image. The icon file is written to standard output. .SH SOURCE .B \*9/src/cmd/jpg .SH "SEE ALSO" -.IM page (1) , -.IM image (7) . +.MR page (1) , +.MR image (7) . .SH BUGS Writing an animated GIF using .I togif diff --git a/man/man1/kill.1 b/man/man1/kill.1 index ee311017c..f82b48776 100644 --- a/man/man1/kill.1 +++ b/man/man1/kill.1 @@ -19,18 +19,18 @@ prints commands that will cause all processes with .I name and owned by the current user to be terminated. Each command is commented with an output line from -.IM ps (1) +.MR ps (1) describing the process that would be killed. Use the .B send command of -.IM 9term (1) , +.MR 9term (1) , or pipe the output of .I kill into -.IM rc (1) +.MR rc (1) or -.IM sh (1) +.MR sh (1) to execute the commands. .PP .I Kill @@ -60,8 +60,8 @@ signal. .SH SOURCE .B \*9/bin .SH "SEE ALSO" -.IM ps (1) , -.IM notify (3) +.MR ps (1) , +.MR notify (3) .SH BUGS .I Stop and diff --git a/man/man1/label.1 b/man/man1/label.1 index 92334f197..6688972d5 100644 --- a/man/man1/label.1 +++ b/man/man1/label.1 @@ -14,12 +14,12 @@ label, awd \- set window label sets the label of the current .I win (see -.IM acme (1) ) +.MR acme (1) ) or X terminal window .RI ( e.g., -.IM 9term (1) +.MR 9term (1) or -.IM xterm (1) ) +.MR xterm (1) ) by echoing a special control sequence to standard output. .PP .I Acme @@ -38,7 +38,7 @@ sets the window name to the current directory with a suffix, using the name of the current system by default. .SH EXAMPLE One can use the following -.IM sh (1) +.MR sh (1) function to keep the label up-to-date in response to .I cd commands: @@ -55,7 +55,7 @@ alias cd=_cd cd . .EE .PP -.IM Rc (1) +.MR Rc (1) installs a similar .B fn .B cd @@ -77,4 +77,4 @@ fn cd { .SH BUGS .I Awd is also documented in -.IM acme (1) . +.MR acme (1) . diff --git a/man/man1/lex.1 b/man/man1/lex.1 index fe99bd6c8..a740c2e87 100644 --- a/man/man1/lex.1 +++ b/man/man1/lex.1 @@ -65,7 +65,7 @@ output template .SH "SEE ALSO" .IR yacc (1), -.IM sed (1) +.MR sed (1) .br M. E. Lesk and E. Schmidt, `LEX\(emLexical Analyzer Generator', diff --git a/man/man1/look.1 b/man/man1/look.1 index 20f46a962..731d616e7 100644 --- a/man/man1/look.1 +++ b/man/man1/look.1 @@ -74,7 +74,7 @@ is assumed, with collating sequence .B \*9/src/cmd/look.c .SH "SEE ALSO" .IR sort (1), -.IM grep (1) +.MR grep (1) .SH DIAGNOSTICS The exit status is .RB `` "not found" '' diff --git a/man/man1/ls.1 b/man/man1/ls.1 index b4a5f7727..863f8e222 100644 --- a/man/man1/ls.1 +++ b/man/man1/ls.1 @@ -29,7 +29,7 @@ is the same as but sets the .B -p option and pipes the output through -.IM mc (1) . +.MR mc (1) . .PP There are a number of options: .TP @@ -42,7 +42,7 @@ List in long format, giving mode (see below), file system type (e.g., for devices, the .B # code letter that names it; see -.IM intro (3) ), +.MR intro (3) ), the instance or subdevice number, owner, group, size in bytes, and time of last modification for each file. @@ -60,7 +60,7 @@ Print only the final path element of each file name. List the .I qid (see -.IM stat (3) ) +.MR stat (3) ) of each file; the printed fields are in the order path, version, and type. .TP @@ -99,7 +99,7 @@ otherwise. .TP .B -Q By default, printed file names are quoted if they contain characters special to -.IM rc (1) . +.MR rc (1) . The .B -Q flag disables this behavior. @@ -168,5 +168,5 @@ if none of the above permissions is granted. .br .B \*9/bin/lc .SH SEE ALSO -.IM stat (3) , -.IM mc (1) +.MR stat (3) , +.MR mc (1) diff --git a/man/man1/man.1 b/man/man1/man.1 index cdab681ad..2fc8c1f5b 100644 --- a/man/man1/man.1 +++ b/man/man1/man.1 @@ -45,7 +45,7 @@ The options are: .TP .B -h Print the pages to HTML and send to a web browser with -.IM web (1) . +.MR web (1) . .TP .B -n (Default) @@ -54,17 +54,17 @@ Print the pages on the standard output using .TP .B -p Run -.IM proof (1) +.MR proof (1) on the specified man pages. .TP .B -P Run -.IM page (1) +.MR page (1) on the specified man pages. .TP .B -t Run -.IM troff (1) +.MR troff (1) and send its output to standard output. .TP @@ -106,8 +106,8 @@ index for .br .B \*9/bin/lookman .SH "SEE ALSO" -.IM page (1) , -.IM proof (1) +.MR page (1) , +.MR proof (1) .SH BUGS The manual was intended to be typeset; some detail is sacrificed on text terminals. .PP diff --git a/man/man1/map.1 b/man/man1/map.1 index e5c253041..d526aa484 100644 --- a/man/man1/map.1 +++ b/man/man1/map.1 @@ -305,7 +305,7 @@ tracks appear as dot-dashed lines if the plotting filter supports them.) The .I file contains -.IM plot (7) -style +.MR plot (7) -style data for .L : or @@ -640,7 +640,7 @@ Map driver program .B \*9/src/cmd/map .SH "SEE ALSO" .IR map (7), -.IM plot (1) +.MR plot (1) .SH DIAGNOSTICS `Map seems to be empty'\(ema coarse survey found zero extent within the diff --git a/man/man1/mc.1 b/man/man1/mc.1 index 4727df5fb..627202be7 100644 --- a/man/man1/mc.1 +++ b/man/man1/mc.1 @@ -18,10 +18,10 @@ splits the input into as many columns as will fit in .I N print positions. If run in a -.IM 9term (1) , -.IM xterm (1) , +.MR 9term (1) , +.MR xterm (1) , or -.IM acme (1) +.MR acme (1) window, the default .I N is the number of blanks that will fit across the window; @@ -36,14 +36,14 @@ is printed separately. .SH SOURCE .B \*9/src/cmd/draw/mc.c .SH "SEE ALSO" -.IM 9term (1) , -.IM acme (1) , -.IM acme (4) , -.IM xterm (1) , -.IM pr (1) , +.MR 9term (1) , +.MR acme (1) , +.MR acme (4) , +.MR xterm (1) , +.MR pr (1) , .I lc in -.IM ls (1) +.MR ls (1) .SH BUGS On systems with high-DPI screens, .I 9term diff --git a/man/man1/mk.1 b/man/man1/mk.1 index 4b5e94d4c..4c3d2b701 100644 --- a/man/man1/mk.1 +++ b/man/man1/mk.1 @@ -29,7 +29,7 @@ contains a .I rule for each target that identifies the files and other targets upon which it depends and an -.IM sh (1) +.MR sh (1) script, a .IR recipe , to update the target. @@ -157,7 +157,7 @@ In the recipe of a meta-rule, the environment variable contains the string matched by the .BR % . For example, a meta-rule to compile a C program using -.IM 9c (1) +.MR 9c (1) might be: .IP .EX @@ -207,7 +207,7 @@ References to variables are replaced by the variables' values. Special characters may be quoted using single quotes .BR \&'' as in -.IM sh (1) . +.MR sh (1) . .PP Assignments and rules are distinguished by the first unquoted occurrence of @@ -246,7 +246,7 @@ A legal reference of the form or .B ${name} is expanded as in -.IM sh (1) . +.MR sh (1) . A reference of the form .BI ${name: A % B = C\fL%\fID\fL}\fR, where @@ -315,9 +315,9 @@ or .BR rcsh , .I mk uses -.IM rc (1) 's +.MR rc (1) 's quoting rules; otherwise it uses -.IM sh (1) 's. +.MR sh (1) 's. The .B MKSHELL variable is consulted when the mkfile is read, not when it is executed, @@ -523,7 +523,7 @@ of the aggregate Currently, the only aggregates supported are .I 9ar (see -.IM 9c (1) ) +.MR 9c (1) ) archives. .SS Attributes The colon separating the target from the prerequisites @@ -567,12 +567,12 @@ In the rule, .B % has no special meaning. The target is interpreted as a regular expression as defined in -.IM regexp (7) . +.MR regexp (7) . The prerequisites may contain references to subexpressions in form .BI \e n\f1, as in the substitute command of -.IM sed (1) . +.MR sed (1) . .TP .B U The targets are considered to have been updated @@ -625,7 +625,7 @@ Regular expression meta-rules: .EE .PP A correct way to deal with -.IM yacc (1) +.MR yacc (1) grammars. The file .B lex.c @@ -656,8 +656,8 @@ x.tab.h:Pcmp -s: y.tab.h .SH SOURCE .B \*9/src/cmd/mk .SH SEE ALSO -.IM sh (1) , -.IM regexp (7) +.MR sh (1) , +.MR regexp (7) .PP A. Hume, ``Mk: a Successor to Make'' diff --git a/man/man1/mk9660.1 b/man/man1/mk9660.1 index 34c21eb83..4f78bd273 100644 --- a/man/man1/mk9660.1 +++ b/man/man1/mk9660.1 @@ -71,7 +71,7 @@ the current directory). The .I proto file is formatted as described in -.IM proto (3) . +.MR proto (3) . .PP The created CD image will be in ISO-9660 format, but by default the file names will @@ -224,7 +224,7 @@ mk9660 -9cj -s /n/bootes -p srcproto cdimage .SH SOURCE \*9/src/cmd/9660 .SH "SEE ALSO -.IM proto (3) +.MR proto (3) .\" .SH "SEE ALSO" .\" .I 9660srv .\" (in diff --git a/man/man1/mkdir.1 b/man/man1/mkdir.1 index ece75f347..b91ba22ed 100644 --- a/man/man1/mkdir.1 +++ b/man/man1/mkdir.1 @@ -28,11 +28,11 @@ The flag sets the permissions to be used when creating the directory. The default is 0777. .SH "SEE ALSO" -.IM rm (1) +.MR rm (1) .br .IR cd in -.IM rc (1) +.MR rc (1) .SH SOURCE .B \*9/src/cmd/mkdir.c .SH DIAGNOSTICS diff --git a/man/man1/mount.1 b/man/man1/mount.1 index 51f1c785f..123a395ae 100644 --- a/man/man1/mount.1 +++ b/man/man1/mount.1 @@ -15,7 +15,7 @@ mounts a 9P server's files into the file system. is typically either the name of a Unix domain socket (see -.IM namespace (1) ) +.MR namespace (1) ) or the name or IP address of a machine serving 9P over TCP port 564. .PP @@ -29,7 +29,7 @@ On Linux, .I mount uses the native 9P kernel module when present. Otherwise it tries to use -.IM 9pfuse (4) +.MR 9pfuse (4) with the FUSE file system module. Using the 9P kernel module requires root access. FUSE can often be used by regular users. @@ -45,7 +45,7 @@ should be invoked as .BR mount . .SH EXAMPLES Mount -.IM acme (4) +.MR acme (4) onto .B /mnt/acme : .IP @@ -64,6 +64,6 @@ cat /mnt/plumb/rules .br .B \*9/bin/unmount .SH SEE ALSO -.IM intro (4) , +.MR intro (4) , .IR intro (9p), -.IM 9pfuse (4) +.MR 9pfuse (4) diff --git a/man/man1/namespace.1 b/man/man1/namespace.1 index 238877e1a..7015ca257 100644 --- a/man/man1/namespace.1 +++ b/man/man1/namespace.1 @@ -7,9 +7,9 @@ namespace \- print name space directory .I Namespace prints the directory representing the current name space. See -.IM intro (4) . +.MR intro (4) . .SH SOURCE .B \*9/src/cmd/namespace.c .SH SEE ALSO -.IM getns (3) , -.IM intro (4) +.MR getns (3) , +.MR intro (4) diff --git a/man/man1/ndb.1 b/man/man1/ndb.1 index a92b05b1a..4ce7616b3 100644 --- a/man/man1/ndb.1 +++ b/man/man1/ndb.1 @@ -24,9 +24,9 @@ ndbquery, ndbmkhash, ndbmkdb, ndbipquery, ndbmkhosts \- network database The network database holds administrative information used by .I authdial (see -.IM authsrv (3) ) +.MR authsrv (3) ) and -.IM secstored (1) . +.MR secstored (1) . .PP .I Ndbquery searches the database for an attribute of type @@ -46,7 +46,7 @@ of all the matched entries is returned. uses .I ndbipinfo (see -.IM ndb (3) ) +.MR ndb (3) ) to search for the values of the attributes .I rattr corresponding to the system @@ -382,7 +382,7 @@ and by the ndb library routines. .PP .I Ndbmkdb is used in concert with -.IM awk (1) +.MR awk (1) scripts to convert uucp systems files and IP host files into database files. @@ -395,7 +395,7 @@ it is necessary to run .I ndbmkhash whenever the files are modified. It may be profitable to control this by a frequent -.IM cron (8) +.MR cron (8) job. .PP .I Ndbmkhosts @@ -439,5 +439,5 @@ hash files for .SH SOURCE .B \*9/src/cmd/ndb .SH SEE ALSO -.IM ndb (3) , -.IM ndb (7) +.MR ndb (3) , +.MR ndb (7) diff --git a/man/man1/netfiles.1 b/man/man1/netfiles.1 index 11ab979dc..97f72c6ff 100644 --- a/man/man1/netfiles.1 +++ b/man/man1/netfiles.1 @@ -21,7 +21,7 @@ Netfiles, netfileget, netfileput, netfilestat \- network file access inside acme .SH DESCRIPTION .B Netfiles presents remote file systems in -.IM acme (4) +.MR acme (4) windows. Each window is named .BI /n/ system / path @@ -35,7 +35,7 @@ reads names of windows to create from the plumbing channel .B netfileedit (see -.IM plumber (4) +.MR plumber (4) and the example section below). In a .IR netfiles -controlled @@ -60,13 +60,13 @@ The three first check to see if .I system is a service in the current name space (see -.IM intro (4) ). +.MR intro (4) ). If so, they use -.IM 9p (1) +.MR 9p (1) to access it. Otherwise, they assume that the system is a network name and use -.IM ssh (1) 's +.MR ssh (1) 's .I sftp to access it. .PP @@ -100,7 +100,7 @@ or .SH EXAMPLES The following plumbing rule (see -.IM plumb (7) ) +.MR plumb (7) ) passes .B /n/ paths to @@ -118,17 +118,17 @@ plumb client Netfiles .SH SOURCE .B \*9/src/cmd/netfiles .SH SEE ALSO -.IM 9p (1) , -.IM ssh (1) , -.IM ssh-agent (1) , -.IM intro (4) , -.IM acme (4) , -.IM factotum (4) , +.MR 9p (1) , +.MR ssh (1) , +.MR ssh-agent (1) , +.MR intro (4) , +.MR acme (4) , +.MR factotum (4) , .HR http://v9fs.sf.net .SH BUGS .I Netfiles depends on -.IM sftpcache (1) , +.MR sftpcache (1) , which only works with OpenSSH versions 4.3 and earlier; later versions do not print the .B sftp> diff --git a/man/man1/page.1 b/man/man1/page.1 index 4284bda2c..8edefe260 100644 --- a/man/man1/page.1 +++ b/man/man1/page.1 @@ -25,7 +25,7 @@ of a PostScript, PDF, or -.IM troff (1) +.MR troff (1) or Unix's .IR tex (1) @@ -41,7 +41,7 @@ graphics files FAX page, a Plan 9 -.IM image (7) +.MR image (7) file, an Inferno bitmap file, or other common format). .I Page displays these @@ -108,7 +108,7 @@ it listens to the .B image plumbing channel (see -.IM plumber (4) ) +.MR plumber (4) ) for more images to display. The .B -i @@ -194,7 +194,7 @@ reverses the order in which pages are displayed. Typing a .B w will write the currently viewed page to a new file as a compressed -.IM image (7) +.MR image (7) file. When possible, the filename is of the form .IR basename . pagenum . bit . @@ -217,7 +217,7 @@ and PDF .IR files . It also calls a variety of conversion programs, such as those described in -.IM jpg (1) , +.MR jpg (1) , to convert the various raster graphics formats into Inferno bitmap files. Pages are converted ``on the fly,'' as needed. @@ -235,11 +235,11 @@ Browse the Inferno bitmap library. man -t page | page -w Preview this manual in a new window. .SH "SEE ALSO -.IM gs (1) , -.IM jpg (1) , -.IM proof (1) , -.IM tex (1) , -.IM troff (1) +.MR gs (1) , +.MR jpg (1) , +.MR proof (1) , +.MR tex (1) , +.MR troff (1) .SH SOURCE .B \*9/src/cmd/page .SH DIAGNOSTICS @@ -277,7 +277,7 @@ There are too many keyboard commands and menu items. Displaying a PostScript or PDF file depends both on having GhostScript (see -.IM gs (1) ) +.MR gs (1) ) installed and on the underlying operating system providing a file descriptor device tree at .BR /dev/fd . diff --git a/man/man1/paint.1 b/man/man1/paint.1 index fa37ceb74..838535c02 100644 --- a/man/man1/paint.1 +++ b/man/man1/paint.1 @@ -19,7 +19,7 @@ If the optional argument is specified, then it is read and used as the canvas. .I Paint only recognizes Plan 9 bitmap format (see -.IM image (6) ). +.MR image (6) ). .PP A number of immediate keyboard commands are recognized: .TP @@ -74,12 +74,12 @@ Quits the program. .SH SOURCE .B /sys/src/cmd/paint.c .SH "SEE ALSO" -.IM resample (1) , -.IM rotate (1) , -.IM crop (1) , -.IM jpg (1) , -.IM page (1) , -.IM image (6) +.MR resample (1) , +.MR rotate (1) , +.MR crop (1) , +.MR jpg (1) , +.MR page (1) , +.MR image (6) .SH HISTORY .I Paint first appeared in 9front (October, 2011). diff --git a/man/man1/passwd.1 b/man/man1/passwd.1 index d31f3a8bc..9f32497f3 100644 --- a/man/man1/passwd.1 +++ b/man/man1/passwd.1 @@ -36,7 +36,7 @@ It is a substitute for a SecureNet box. .br .B \*9/src/cmd/auth/passwd.c .SH "SEE ALSO" -.IM encrypt (3) +.MR encrypt (3) .PP Robert Morris and Ken Thompson, ``UNIX Password Security,'' diff --git a/man/man1/pem.1 b/man/man1/pem.1 index b18ee2514..9911af95f 100644 --- a/man/man1/pem.1 +++ b/man/man1/pem.1 @@ -20,7 +20,7 @@ Privacy Enhanced Mail program but now commonly used for other applications, notably TLS. PEM encodes data in base 64 (see -.IM encode (3) ) +.MR encode (3) ) between lines of the form: .IP .EX @@ -33,7 +33,7 @@ where may be any string describing the encoded data. The most common use of PEM format on Plan 9 is for encoding X.509 certificates; see -.IM rsa (1) . +.MR rsa (1) . .PP .I Pemdecode extracts the named @@ -62,4 +62,4 @@ hello world .SH SOURCE .B \*9/src/cmd/auth .SH "SEE ALSO -.IM rsa (1) +.MR rsa (1) diff --git a/man/man1/pic.1 b/man/man1/pic.1 index bacc1dcb6..d122ff3b5 100644 --- a/man/man1/pic.1 +++ b/man/man1/pic.1 @@ -31,7 +31,7 @@ pic, tpic, svgpic \- troff and tex preprocessors for drawing pictures .SH DESCRIPTION .I Pic is a -.IM troff (1) +.MR troff (1) preprocessor for drawing figures on a typesetter. .I Pic code is contained between @@ -300,7 +300,7 @@ statement removes the definition of a macro. .PP .I Tpic is a -.IM tex (1) +.MR tex (1) preprocessor that accepts .IR pic language. @@ -345,8 +345,8 @@ A: ellipse .B \*9/src/cmd/pic .SH "SEE ALSO" .IR grap (1), -.IM doctype (1) , -.IM troff (1) +.MR doctype (1) , +.MR troff (1) .br B. W. Kernighan, ``PIC\(ema Graphics Language for Typesetting'', diff --git a/man/man1/plot.1 b/man/man1/plot.1 index 8485bcd5d..87d6936a8 100644 --- a/man/man1/plot.1 +++ b/man/man1/plot.1 @@ -14,7 +14,7 @@ from the .I files or standard input, drawing the results in a newly created -.IM rio (1) +.MR rio (1) window. Plot persists until a newline is typed in the window. Various options may be interspersed with the @@ -31,7 +31,7 @@ Erase the screen. .TP .BI -c " col" Set the foreground color (see -.IM plot (7) +.MR plot (7) for color names). .TP .BI -f " fill" @@ -57,5 +57,5 @@ middle of the screen. .SH SOURCE .B \*9/src/cmd/plot .SH "SEE ALSO" -.IM rio (1) , -.IM plot (7) +.MR rio (1) , +.MR plot (7) diff --git a/man/man1/plumb.1 b/man/man1/plumb.1 index a6295342f..39e4d6c53 100644 --- a/man/man1/plumb.1 +++ b/man/man1/plumb.1 @@ -83,6 +83,6 @@ default rules file .SH SOURCE .B \*9/src/cmd/plumb .SH "SEE ALSO" -.IM plumb (3) , -.IM plumber (4) , -.IM plumb (7) +.MR plumb (3) , +.MR plumber (4) , +.MR plumb (7) diff --git a/man/man1/pr.1 b/man/man1/pr.1 index f7069ac0a..624c25fb9 100644 --- a/man/man1/pr.1 +++ b/man/man1/pr.1 @@ -106,5 +106,5 @@ characters instead of the default 72. .SH SOURCE .B \*9/src/cmd/pr.c .SH "SEE ALSO" -.IM cat (1) , -.IM lp (1) +.MR cat (1) , +.MR lp (1) diff --git a/man/man1/proof.1 b/man/man1/proof.1 index fe5db6d3f..63b70a6bb 100644 --- a/man/man1/proof.1 +++ b/man/man1/proof.1 @@ -22,7 +22,7 @@ proof \- troff output interpreter .SH DESCRIPTION .I Proof reads -.IM troff (1) +.MR troff (1) intermediate language from .I file or standard input @@ -126,8 +126,8 @@ into screen fonts and character numbers .B \*9/src/cmd/proof .SH SEE ALSO .IR lp (1), -.IM gs (1) , -.IM page (1) +.MR gs (1) , +.MR page (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual'' diff --git a/man/man1/ps.1 b/man/man1/ps.1 index c597060ff..5904564ab 100644 --- a/man/man1/ps.1 +++ b/man/man1/ps.1 @@ -102,6 +102,6 @@ to print the arguments for the process. Newlines in arguments will be translate .br .B \*9/bin/psu .SH "SEE ALSO" -.IM acid (1) , -.IM db (1) , -.IM kill (1) +.MR acid (1) , +.MR db (1) , +.MR kill (1) diff --git a/man/man1/psfonts.1 b/man/man1/psfonts.1 index 223c74f52..2c4b05315 100644 --- a/man/man1/psfonts.1 +++ b/man/man1/psfonts.1 @@ -16,9 +16,9 @@ psfonts, psdownload \- add necessary fonts to PostScript document for printing ] .SH DESCRIPTION Plan 9's -.IM troff (1) +.MR troff (1) and -.IM tr2post (1) +.MR tr2post (1) use non-standard PostScript fonts (found in .BR \*9/postscript/font ). @@ -114,12 +114,12 @@ Continue running even after fatal errors occur. .PD .SH EXAMPLE See -.IM tr2post (1) +.MR tr2post (1) for an example. .SH SOURCE .B \*9/bin/psfonts .br .B \*9/src/cmd/postscript/download .SH SEE ALSO -.IM troff (1) , -.IM tr2post (1) +.MR troff (1) , +.MR tr2post (1) diff --git a/man/man1/pwd.1 b/man/man1/pwd.1 index 1464302df..e0a506fb7 100644 --- a/man/man1/pwd.1 +++ b/man/man1/pwd.1 @@ -18,8 +18,8 @@ such as constructing shell prompts. .SH SEE ALSO .I cd in -.IM rc (1) , -.IM getwd (3) +.MR rc (1) , +.MR getwd (3) .SH BUGS .I Pwd is not provided. diff --git a/man/man1/rc.1 b/man/man1/rc.1 index 1d6a008b2..38a867d76 100644 --- a/man/man1/rc.1 +++ b/man/man1/rc.1 @@ -50,7 +50,7 @@ exits or is terminated, the variable .B $status gets the process's wait message (see -.IM wait (3) ); +.MR wait (3) ); it will be the null string if the command was successful. .PP A long command line may be continued on subsequent lines by typing @@ -83,7 +83,7 @@ in a directory in .B $path is the program to be executed. To be executable, the user must have execute permission (see -.IM stat (3) ) +.MR stat (3) ) and the file must be either an executable binary for the current machine's CPU type, or a shell script. Shell scripts begin with a line containing the full path name of a shell @@ -350,7 +350,7 @@ or is a previously opened file descriptor and .I fd0 becomes a new copy (in the sense of -.IM dup (3) ) +.MR dup (3) ) of it. A file descriptor may be closed by writing .BI >[ fd0 =] @@ -543,7 +543,7 @@ function definition. A function with a special name will be called when .I rc receives a corresponding note; see -.IM notify (3) . +.MR notify (3) . The valid note names (and corresponding notes) are .B sighup .RB ( hangup ), @@ -662,7 +662,7 @@ is composed of the bitwise OR of the .B rfork flags specified by the option letters (see -.IM fork (2) ). +.MR fork (2) ). If no .I flags are given, they default to @@ -829,7 +829,7 @@ parsing the .B $PATH variable (as in -.IM sh (1) ) +.MR sh (1) ) or by .BR "path=(.\ /bin)" . The variables diff --git a/man/man1/readcons.1 b/man/man1/readcons.1 index d85452b7c..6fc56a662 100644 --- a/man/man1/readcons.1 +++ b/man/man1/readcons.1 @@ -27,4 +27,4 @@ is printed instead of an empty string. .SH SOURCE .B \*9/src/cmd/readcons.c .SH SEE ALSO -.IM readcons (3) +.MR readcons (3) diff --git a/man/man1/resample.1 b/man/man1/resample.1 index 4b41ca081..71c3b7472 100755 --- a/man/man1/resample.1 +++ b/man/man1/resample.1 @@ -40,19 +40,19 @@ and .PP The input should be a Plan 9 image as described in -.IM image (7) , +.MR image (7) , and the output will be a compressed 24-bit .B r8g8b8 image. To uncompress the image or change the pixel format, use .I iconv (see -.IM crop (1) ). +.MR crop (1) ). .PP .SH SOURCE .B \*9/src/cmd/resample.c .SH "SEE ALSO -.IM crop (1) , -.IM image (7) +.MR crop (1) , +.MR image (7) .SH BUGS Faster algorithms exist, but this implementation produces correct pictures. diff --git a/man/man1/rio.1 b/man/man1/rio.1 index d22ad3e41..fb4b5dfb9 100644 --- a/man/man1/rio.1 +++ b/man/man1/rio.1 @@ -68,15 +68,15 @@ specifies an alternative program to run when the .I New menu item is selected. The default is to try -.IM 9term (1) +.MR 9term (1) and then to fall back to -.IM xterm (1) . +.MR xterm (1) . The .B \-s option has no effect. It formerly set the scrolling mode for new windows and is recognized to avoid breaking scripts. See -.IM 9term (1) +.MR 9term (1) for a description of scrolling behavior. .PP The @@ -137,11 +137,11 @@ Very small windows may not be created. The new window is created running .IR termprog , by default -.IM 9term (1) +.MR 9term (1) or, if .I 9term is not available, -.IM xterm (1) . +.MR xterm (1) . .TP .B Resize Change the size and location of a window. @@ -165,7 +165,7 @@ Deleting a window causes a .L hangup note to be sent to all processes in the window's process group (see -.IM notify (3) ). +.MR notify (3) ). .TP .B Hide Hide a window. Click in the window to be hidden (gunsight cursor); @@ -241,8 +241,8 @@ starts a particular program.) .PP There is a currently a compiled-in limit of 128 hidden windows. .SH "SEE ALSO" -.IM 9term (1) , -.IM xterm (1) +.MR 9term (1) , +.MR xterm (1) .PP As mentioned above, .I rio diff --git a/man/man1/rm.1 b/man/man1/rm.1 index ce0ea1c13..104eda935 100644 --- a/man/man1/rm.1 +++ b/man/man1/rm.1 @@ -25,4 +25,4 @@ and the directory itself. .SH SOURCE .B \*9/src/cmd/rm.c .SH "SEE ALSO" -.IM remove (3) +.MR remove (3) diff --git a/man/man1/rsa.1 b/man/man1/rsa.1 index 2ba0d8b03..4d8f286b2 100644 --- a/man/man1/rsa.1 +++ b/man/man1/rsa.1 @@ -85,7 +85,7 @@ Plan 9 represents DSA and RSA keys as attribute-value pair lists prefixed with the string .BR key ; this is the generic key format used by -.IM factotum (4) . +.MR factotum (4) . A full DSA private key has the following attributes: .TP .B proto @@ -334,9 +334,9 @@ scp auth.keys unix:.ssh/authorized_keys .SH SOURCE .B \*9/src/cmd/auth .SH "SEE ALSO -.IM factotum (4) , -.IM pem (1) , -.IM ssh (1) +.MR factotum (4) , +.MR pem (1) , +.MR ssh (1) .SH BUGS There are too many key formats. .PP diff --git a/man/man1/sam.1 b/man/man1/sam.1 index c928b6679..ac9f6e820 100644 --- a/man/man1/sam.1 +++ b/man/man1/sam.1 @@ -51,7 +51,7 @@ copies leading white space on the current line to the new line. Do not `download' the terminal part of .IR sam . Editing will be done with the command language only, as in -.IM ed (1) . +.MR ed (1) . .TP .BI -r " machine Run the host part remotely @@ -69,7 +69,7 @@ for debugging. .PD .SS Regular expressions Regular expressions are as in -.IM regexp (7) +.MR regexp (7) with the addition of .BR \en to represent newlines. @@ -698,7 +698,7 @@ There is usually a `current window', marked with a dark border, to which typed text and editing commands apply. Text may be typed and edited as in -.IM rio (1) ; +.MR rio (1) ; also the escape key (ESC) selects (sets dot to) text typed since the last mouse button hit. .PP @@ -798,7 +798,7 @@ the white-space-delimited block of text is sent as a plumb message with a .B click attribute defining where the selection lies (see -.IM plumb (7) ). +.MR plumb (7) ). .TP .B look Search forward for the next occurrence of the literal text in dot. @@ -909,11 +909,11 @@ source for the separate terminal part .TP .B \*9/bin/E .SH SEE ALSO -.IM ed (1) , -.IM sed (1) , -.IM grep (1) , -.IM rio (1) , -.IM regexp (7) . +.MR ed (1) , +.MR sed (1) , +.MR grep (1) , +.MR rio (1) , +.MR regexp (7) . .PP Rob Pike, ``The text editor sam''. diff --git a/man/man1/scat.1 b/man/man1/scat.1 index 1fef52336..407b97ef5 100644 --- a/man/man1/scat.1 +++ b/man/man1/scat.1 @@ -10,7 +10,7 @@ outside the solar system and implements database-like manipulations on sets of such objects. It also provides an interface to -.IM astro (1) +.MR astro (1) to plot the locations of solar system objects. Finally, it displays images from the Space Telescope Science Institute's @@ -119,7 +119,7 @@ The names and .B comet refer to the earth's penumbra at lunar distance and the comet installed in the current -.IM astro (1) . +.MR astro (1) . The output is the planet's name, right ascension and declination, azimuth and altitude, and phase for the moon and sun, as shown by .BR astro . @@ -182,7 +182,7 @@ collects all objects in the patches that cover the current set. .TP .BI astro " option" Run -.IM astro (1) +.MR astro (1) with the specified .I options (to which will be appended @@ -324,7 +324,7 @@ Draw a map of the Pleiades. .SH SOURCE .B \*9/src/cmd/scat .SH SEE ALSO -.IM astro (1) +.MR astro (1) .br .B \*9/sky/constelnames\ \ the three-letter abbreviations of the constellation names. diff --git a/man/man1/secstore.1 b/man/man1/secstore.1 index 6c25c7303..9374e3902 100644 --- a/man/man1/secstore.1 +++ b/man/man1/secstore.1 @@ -97,7 +97,7 @@ Option .B -n says that the password should be read from NVRAM (see -.IM authsrv (3) ) +.MR authsrv (3) ) instead of from .BR /dev/tty . .PP @@ -107,7 +107,7 @@ or the server specified by option .BR -s . .PP For example, to add a secret to the file read by -.IM factotum (4) , +.MR factotum (4) , run .sp .EX @@ -192,8 +192,8 @@ block chaining (CBC) mode. .br .B \*9/src/cmd/auth/secstore .SH SEE ALSO -.IM factotum (4) , -.IM secstored (1) +.MR factotum (4) , +.MR secstored (1) .SH BUGS There is deliberately no backup of files on the secstore, so .B -r diff --git a/man/man1/secstored.1 b/man/man1/secstored.1 index d21ff5e59..82eaee3cf 100644 --- a/man/man1/secstored.1 +++ b/man/man1/secstored.1 @@ -18,7 +18,7 @@ username .PP .I Secstored serves requests from -.IM secstore (1) . +.MR secstore (1) . The .B -R option supplements the password check with a @@ -61,4 +61,4 @@ for mapping local userid to RADIUS userid .SH SOURCE .B \*9/src/cmd/auth/secstore .SH SEE ALSO -.IM secstore (1) +.MR secstore (1) diff --git a/man/man1/sed.1 b/man/man1/sed.1 index 8df5285e1..8a892da1e 100644 --- a/man/man1/sed.1 +++ b/man/man1/sed.1 @@ -78,7 +78,7 @@ that addresses the last line of input, or a context address, .BI / regular-expression / \f1, in the style of -.IM regexp (7) , +.MR regexp (7) , with the added convention that .L \en matches a @@ -235,7 +235,7 @@ in the pattern space. Any character may be used instead of .LR / . For a fuller description see -.IM regexp (7) . +.MR regexp (7) . .I Flags is zero or more of .RS @@ -374,8 +374,8 @@ formatted manuscript. .IR grep (1), .IR awk (1), .IR lex (1), -.IM sam (1) , -.IM regexp (7) +.MR sam (1) , +.MR regexp (7) .br L. E. McMahon, `SED \(em A Non-interactive Text Editor', diff --git a/man/man1/seq.1 b/man/man1/seq.1 index eea10dfaf..e181f5bef 100644 --- a/man/man1/seq.1 +++ b/man/man1/seq.1 @@ -38,7 +38,7 @@ The options are .TP "\w'\fL-f \fIformat\fLXX'u" .BI -f format Use the -.IM print (3) -style +.MR print (3) -style .I format .IR print for printing each (floating point) number. diff --git a/man/man1/sftpcache.1 b/man/man1/sftpcache.1 index aec061f4b..8c0a0ad8a 100644 --- a/man/man1/sftpcache.1 +++ b/man/man1/sftpcache.1 @@ -7,7 +7,7 @@ sftpcache \- cache sftp connections .SH DESCRIPTION .I Sftpcache multiplexes clients onto persistent -.IM sftp (1) +.MR sftp (1) connections. It runs .I sftp @@ -16,7 +16,7 @@ and posts a socket named .IB system .sftp in the name space directory (see -.IM intro (4) ). +.MR intro (4) ). Clients can connect to the socket, one at a time, to interact with the .I sftp @@ -24,13 +24,13 @@ session. .PP .I Sftpcache is used by -.IM netfiles (1) . +.MR netfiles (1) . .SH SOURCE .B \*9/src/cmd/sftpcache.c .SH SEE ALSO -.IM ssh (1) , -.IM sftp (1) , -.IM netfiles (1) +.MR ssh (1) , +.MR sftp (1) , +.MR netfiles (1) .SH BUGS .I Sftpcache only works with OpenSSH versions 4.3 and earlier; diff --git a/man/man1/sleep.1 b/man/man1/sleep.1 index a6a19a381..f5f7c4cff 100644 --- a/man/man1/sleep.1 +++ b/man/man1/sleep.1 @@ -28,4 +28,4 @@ while (){ .SH SOURCE .B \*9/src/cmd/sleep.c .SH "SEE ALSO" -.IM sleep (3) +.MR sleep (3) diff --git a/man/man1/snarfer.1 b/man/man1/snarfer.1 index db8ce1987..ef77c9511 100644 --- a/man/man1/snarfer.1 +++ b/man/man1/snarfer.1 @@ -30,14 +30,14 @@ running keeps the X11 snarf buffer in sync with the Carbon snarf buffer, working around a bug in the OS X X11 server. See -.IM getsnarf (3) +.MR getsnarf (3) for more details. .SH SOURCE .B \*9/src/cmd/snarfer .SH SEE ALSO Unix's .IR xclipboard (1), -.IM getsnarf (3) +.MR getsnarf (3) .SH BUGS Both .I xclipboard diff --git a/man/man1/soelim.1 b/man/man1/soelim.1 index 6b8f46527..c7324035d 100755 --- a/man/man1/soelim.1 +++ b/man/man1/soelim.1 @@ -11,19 +11,19 @@ soelim \- preprocess so inclusion commands in troff input .I Soelim reads the specified files or the standard input and performs the textual inclusion implied by -.IM troff (1) +.MR troff (1) directives of the form .TP .B "\&.so some_file .PP when they appear at the beginning of input lines. This is useful when using programs such as -.IM tbl (1) +.MR tbl (1) that do not normally do this, allowing placement of individual tables or other text objects in separate files to be run as a part of a large document. .SH SOURCE .B \*9/bin/soelim .SH "SEE ALSO" -.IM deroff (1) , -.IM troff (1) +.MR deroff (1) , +.MR troff (1) diff --git a/man/man1/sort.1 b/man/man1/sort.1 index d732374c7..6922114b0 100644 --- a/man/man1/sort.1 +++ b/man/man1/sort.1 @@ -242,8 +242,8 @@ come out in their original order. .SH SOURCE .B \*9/src/cmd/sort.c .SH SEE ALSO -.IM uniq (1) , -.IM look (1) +.MR uniq (1) , +.MR look (1) .SH DIAGNOSTICS .I Sort comments and exits with non-null status for various trouble diff --git a/man/man1/spell.1 b/man/man1/spell.1 index 3e7388eb3..27ae68039 100644 --- a/man/man1/spell.1 +++ b/man/man1/spell.1 @@ -31,7 +31,7 @@ not sanctioned there\(emon the standard output. .PP .I Spell ignores constructs of -.IM troff (1) +.MR troff (1) and its standard preprocessors. It understands these options: .TP @@ -82,10 +82,10 @@ the script source for .I sprog .SH SEE ALSO -.IM deroff (1) +.MR deroff (1) .SH BUGS The heuristics of -.IM deroff (1) +.MR deroff (1) used to excise formatting information are imperfect. .PP The spelling list's coverage is uneven; diff --git a/man/man1/split.1 b/man/man1/split.1 index 440cf7eb7..b61ef1855 100644 --- a/man/man1/split.1 +++ b/man/man1/split.1 @@ -41,7 +41,7 @@ File divisions occur at each line that matches a regular .IR expression ; see -.IM regexp (7) . +.MR regexp (7) . Multiple .B -e options may appear. @@ -77,6 +77,6 @@ to lower case. .B \*9/src/cmd/split.c .SH SEE ALSO .IR sed (1), -.IM awk (1) , -.IM grep (1) , -.IM regexp (7) +.MR awk (1) , +.MR grep (1) , +.MR regexp (7) diff --git a/man/man1/src.1 b/man/man1/src.1 index 94f69b4f3..7648602b3 100644 --- a/man/man1/src.1 +++ b/man/man1/src.1 @@ -19,11 +19,11 @@ examines the named to find the corresponding source code, which is then sent to the editor using .B B (see -.IM sam (1) ). +.MR sam (1) ). If .I file is an -.IM rc (1) +.MR rc (1) script, the source is the file itself. If .I file @@ -35,7 +35,7 @@ and will point the editor at the line that begins the definition. .I Src uses -.IM db (1) +.MR db (1) to extract the symbol table information that identifies the source. .PP .I Src @@ -78,6 +78,6 @@ src -s strcmp rc .SH SOURCE .B \*9/bin/src .SH "SEE ALSO" -.IM db (1) , -.IM plumb (1) , -.IM sam (1) . +.MR db (1) , +.MR plumb (1) , +.MR sam (1) . diff --git a/man/man1/ssam.1 b/man/man1/ssam.1 index 17a105aa5..aa9fc647a 100755 --- a/man/man1/ssam.1 +++ b/man/man1/ssam.1 @@ -63,8 +63,8 @@ Count frequency of words read from standard input. .B \*9/bin/ssam .SH SEE ALSO .IR sed (1), -.IM sam (1) , -.IM regexp (7) +.MR sam (1) , +.MR regexp (7) .PP Rob Pike, ``The text editor sam''. diff --git a/man/man1/ssh-agent.1 b/man/man1/ssh-agent.1 index 2300ab9df..70ecec647 100644 --- a/man/man1/ssh-agent.1 +++ b/man/man1/ssh-agent.1 @@ -10,9 +10,9 @@ ssh-agent \- SSH authentication agent .SH DESCRIPTION .I Ssh-agent presents -.IM factotum (4) +.MR factotum (4) using the interface that -.IM ssh (1) +.MR ssh (1) requires. .PP Once @@ -33,7 +33,7 @@ via a Unix socket named .B ssh-agent.socket in the name space directory (see -.IM intro (4) ). +.MR intro (4) ). Note that although the socket is posted in the name space directory, it is not for 9P conversations. .I Ssh @@ -81,10 +81,10 @@ Invoke this one with .B 9 .BR ssh-agent ; see -.IM 9 (1) . +.MR 9 (1) . .SH EXAMPLES Assume -.IM factotum (4) +.MR factotum (4) is already running and initialized with keys. .PP Start a new agent, copying the commands by hand: @@ -103,7 +103,7 @@ $ .EE .PP Start the agent from -.IM sh (1) : +.MR sh (1) : .IP .EX $ eval `9 ssh-agent -e` @@ -111,7 +111,7 @@ $ .EE .PP Start the agent from -.IM rc (1) : +.MR rc (1) : .IP .EX % eval `{9 ssh-agent} @@ -128,9 +128,9 @@ tux% ^D .SH SOURCE .B \*9/src/cmd/auth/ssh-agent.c .SH SEE ALSO -.IM ssh (1) , -.IM rsa (1) , -.IM factotum (4) +.MR ssh (1) , +.MR rsa (1) , +.MR factotum (4) .SH BUGS A surprise rather than a bug: .I ssh-agent diff --git a/man/man1/strings.1 b/man/man1/strings.1 index c4d950ed6..b4070f0fe 100644 --- a/man/man1/strings.1 +++ b/man/man1/strings.1 @@ -25,4 +25,4 @@ line with the offset of the continuation line. .SH SOURCE .B \*9/src/cmd/strings.c .SH SEE ALSO -.IM nm (1) +.MR nm (1) diff --git a/man/man1/sum.1 b/man/man1/sum.1 index 3d674cb31..727f273fe 100644 --- a/man/man1/sum.1 +++ b/man/man1/sum.1 @@ -73,5 +73,5 @@ summed. .br .B \*9/src/cmd/sha1sum.c .SH "SEE ALSO" -.IM cmp (1) , -.IM wc (1) +.MR cmp (1) , +.MR wc (1) diff --git a/man/man1/tar.1 b/man/man1/tar.1 index a7455fbe1..dc4d666c3 100644 --- a/man/man1/tar.1 +++ b/man/man1/tar.1 @@ -112,14 +112,14 @@ archive entries. .B z Operate on compressed tar archives. The type of compression is inferred from the file name extension: -.IM gzip (1) +.MR gzip (1) for .B .tar.gz and .BR .tgz ; .I bzip2 (see -.IM gzip (1) ) +.MR gzip (1) ) for .BR .tar.bz , .BR .tbz , @@ -153,8 +153,8 @@ can be used to copy hierarchies thus: .SH SEE ALSO .I 9ar in -.IM 9c (1) , -.IM bundle (1) +.MR 9c (1) , +.MR bundle (1) .SH BUGS There is no way to ask for any but the last occurrence of a file. diff --git a/man/man1/tbl.1 b/man/man1/tbl.1 index c727fb2bd..c241a0ab2 100644 --- a/man/man1/tbl.1 +++ b/man/man1/tbl.1 @@ -11,7 +11,7 @@ tbl \- format tables for nroff or troff is a preprocessor for formatting tables for .I nroff or -.IM troff (1) . +.MR troff (1) . The input .I files are copied to the standard output, @@ -74,7 +74,7 @@ recognize and .I y as -.IM eqn (1) +.MR eqn (1) delimiters .PD .RE @@ -275,8 +275,8 @@ Bernardsville 2018 3.30 .B \*9/src/cmd/tbl .SH SEE ALSO .IR troff (1), -.IM eqn (1) , -.IM doctype (1) +.MR eqn (1) , +.MR doctype (1) .br M. E. Lesk and L. L. Cherry, ``TBL\(ema Program to Format Tables'', diff --git a/man/man1/tcs.1 b/man/man1/tcs.1 index 6e32b5f1d..ef871fa4c 100644 --- a/man/man1/tcs.1 +++ b/man/man1/tcs.1 @@ -36,7 +36,7 @@ is the .SM UTF encoding described in -.IM utf (7) . +.MR utf (7) . The .B -l option lists the character sets known to @@ -164,4 +164,4 @@ Print an up to date list of the supported character sets. .SH SEE ALSO .IR ascii (1), .IR rune (3), -.IM utf (7) . +.MR utf (7) . diff --git a/man/man1/test.1 b/man/man1/test.1 index 3553804fd..0a8499138 100644 --- a/man/man1/test.1 +++ b/man/man1/test.1 @@ -182,7 +182,7 @@ and must be enclosed in quotes. .I Test is a dubious way to check for specific character strings: it uses a process to do what an -.IM rc (1) +.MR rc (1) match or switch statement can do. The first example is not only inefficient but wrong, because .I test diff --git a/man/man1/time.1 b/man/man1/time.1 index 91e338319..25d3dbf21 100644 --- a/man/man1/time.1 +++ b/man/man1/time.1 @@ -18,4 +18,4 @@ followed by the command line. .SH SOURCE .B \*9/src/cmd/time.c .SH "SEE ALSO" -.IM prof (1) +.MR prof (1) diff --git a/man/man1/touch.1 b/man/man1/touch.1 index 086d4a828..2a48c3c2d 100644 --- a/man/man1/touch.1 +++ b/man/man1/touch.1 @@ -27,9 +27,9 @@ is present. .SH SOURCE .B \*9/src/cmd/touch.c .SH SEE ALSO -.IM ls (1) , -.IM stat (3) , -.IM chmod (1) +.MR ls (1) , +.MR stat (3) , +.MR chmod (1) .SH BUGS .I Touch will not touch directories. diff --git a/man/man1/tr.1 b/man/man1/tr.1 index 3746e48eb..74c512fb2 100644 --- a/man/man1/tr.1 +++ b/man/man1/tr.1 @@ -94,4 +94,4 @@ tr -cs A-Za-z ' .SH SOURCE .B \*9/src/cmd/tr.c .SH "SEE ALSO" -.IM sed (1) +.MR sed (1) diff --git a/man/man1/tr2post.1 b/man/man1/tr2post.1 index 4d047f4ff..29d3e85cb 100644 --- a/man/man1/tr2post.1 +++ b/man/man1/tr2post.1 @@ -15,7 +15,7 @@ converts .I files (or standard input), which should be the device-independent output of -.IM troff (1) , +.MR troff (1) , into the PostScript printer language. .PP The options are: @@ -47,11 +47,11 @@ logical pages per physical page Using this option emits PostScript with invalid document structuring comments. It will print fine but will not view correctly in -.IM gv (1) +.MR gv (1) or .I psv (see -.IM page (1) ). +.MR page (1) ). .TP .BI -o " pagelist Print only the pages in the @@ -110,5 +110,5 @@ psv /tmp/a.ps .SH SOURCE .B \*9/src/cmd/postscript/tr2post .SH SEE ALSO -.IM troff (1) , -.IM psfonts (1) +.MR troff (1) , +.MR psfonts (1) diff --git a/man/man1/troff.1 b/man/man1/troff.1 index acce30a73..032e8c70f 100644 --- a/man/man1/troff.1 +++ b/man/man1/troff.1 @@ -176,18 +176,18 @@ font width tables for .SH SOURCE .B \*9/src/cmd/troff .SH "SEE ALSO" -.IM lpr (1) , -.IM proof (1) , -.IM tr2post (1) , +.MR lpr (1) , +.MR proof (1) , +.MR tr2post (1) , .IR eqn (1), .IR tbl (1), .IR pic (1), -.IM grap (1) , +.MR grap (1) , .IR doctype (1), -.IM ms (7) , -.IM image (7) , -.IM tex (1) , -.IM deroff (1) +.MR ms (7) , +.MR image (7) , +.MR tex (1) , +.MR deroff (1) .br J. F. Ossanna and B. W. Kernighan, ``Troff User's Manual'' diff --git a/man/man1/troff2html.1 b/man/man1/troff2html.1 index 98ea62a8f..06465e9b9 100644 --- a/man/man1/troff2html.1 +++ b/man/man1/troff2html.1 @@ -13,7 +13,7 @@ troff2html \- convert troff output into HTML .SH DESCRIPTION .I Troff2html reads the -.IM troff (1) +.MR troff (1) output in the named .IR files , default standard input, @@ -28,10 +28,10 @@ Its main use is for (see Plan 9's .IR httpd (8)), which converts -.IM man (1) +.MR man (1) pages into HTML and depends on a specially annotated set of -.IM man (7) +.MR man (7) macros, invoked by .B troff .BR -manhtml . @@ -58,7 +58,7 @@ x X html manref end cp 1 .EE .PP which are used to create HTML hyperlinks around text of the form -.IM cp (1) +.MR cp (1) pointing to .BR /magic/man2html/1/cp . .PP @@ -69,14 +69,14 @@ Plan 9's On the one hand, because it uses the input, .B ms2html can handle -.IM pic (1) , -.IM eqn (1) , +.MR pic (1) , +.MR eqn (1) , etc., which .I troff2html does not handle at all; on the other hand, .B ms2html understands only -.IM ms (7) +.MR ms (7) documents and is easily confused by complex .B troff constructions. @@ -84,7 +84,7 @@ constructions. has the reverse properties: it does not handle the preprocessors but its output is reliable and (modulo helper annotations) is independent of macro package. .SH SEE ALSO -.IM troff (1) , +.MR troff (1) , Plan 9's .IR ms2html (1), .I man2html diff --git a/man/man1/tweak.1 b/man/man1/tweak.1 index 09b96af37..773ec325e 100644 --- a/man/man1/tweak.1 +++ b/man/man1/tweak.1 @@ -35,14 +35,14 @@ If the file is a subfont, a second line presents a hexadecimal 16-bit .B offset to be applied to character values from the subfont (typically as stored in a font file; see -.IM font (7) ); +.MR font (7) ); and the subfont's .BR n , .BR height , and .B ascent as defined in -.IM cachechars (3) . +.MR cachechars (3) . .PP By means described below, magnified views of portions of the images may be displayed. @@ -61,7 +61,7 @@ default font; the character's and .BR width as defined in -.IM cachechars (3) ; +.MR cachechars (3) ; and .BR iwidth , the physical width of the image in the subfont's image. @@ -158,9 +158,9 @@ The program will complain once about modified but unwritten files. .SH SOURCE .B \*9/src/cmd/draw/tweak.c .SH "SEE ALSO" -.IM cachechars (3) , -.IM image (7) , -.IM font (7) +.MR cachechars (3) , +.MR image (7) , +.MR font (7) .SH BUGS For a program written to adjust width tables in fonts, .I tweak diff --git a/man/man1/uniq.1 b/man/man1/uniq.1 index 98e2cc7bb..07629ea4e 100644 --- a/man/man1/uniq.1 +++ b/man/man1/uniq.1 @@ -56,4 +56,4 @@ Fields are skipped before characters. .IR sort (1) .SH BUGS Field selection and comparison should be compatible with -.IM sort (1) . +.MR sort (1) . diff --git a/man/man1/vac.1 b/man/man1/vac.1 index 489e677f2..53f89b2ae 100644 --- a/man/man1/vac.1 +++ b/man/man1/vac.1 @@ -115,7 +115,7 @@ Do not include the file or directory specified by This option may be repeated multiple times. .I Exclude can be a shell pattern as accepted by -.IM rc (1) , +.MR rc (1) , with one extension: .B \&... matches any sequence of characters including slashes. @@ -225,5 +225,5 @@ If listing files, print metadata in addition to the names. .SH SOURCE .B \*9/src/cmd/vac .SH "SEE ALSO" -.IM vacfs (4) , -.IM venti (8) +.MR vacfs (4) , +.MR venti (8) diff --git a/man/man1/venti.1 b/man/man1/venti.1 index 6231e40ba..b35b2ac17 100644 --- a/man/man1/venti.1 +++ b/man/man1/venti.1 @@ -40,7 +40,7 @@ read, write, copy \- simple Venti clients .SH DESCRIPTION Venti is a SHA1-addressed block storage server. See -.IM venti (7) +.MR venti (7) for a full introduction. .PP .I Read @@ -167,13 +167,13 @@ messages send/received. .SH SOURCE .B \*9/src/cmd/venti .SH SEE ALSO -.IM vac (1) , -.IM venti (3) , -.IM vacfs (4) , -.IM venti (7) , -.IM vbackup (8) , -.IM venti (8) , -.IM venti-fmt (8) +.MR vac (1) , +.MR venti (3) , +.MR vacfs (4) , +.MR venti (7) , +.MR vbackup (8) , +.MR venti (8) , +.MR venti-fmt (8) .SH BUGS There should be programs to read and write venti files and directories. diff --git a/man/man1/web.1 b/man/man1/web.1 index 1abdcc009..0d57ad9f5 100644 --- a/man/man1/web.1 +++ b/man/man1/web.1 @@ -81,7 +81,7 @@ URL passed to and .I wmail are invoked as start commands in the -.IM plumber (4) 's +.MR plumber (4) 's rules for opening web pages and writing mail messages. .SH FILES .TP @@ -93,4 +93,4 @@ and .SH SOURCE .B \*9/bin .SH SEE ALSO -.IM plumber (4) +.MR plumber (4) diff --git a/man/man1/wintext.1 b/man/man1/wintext.1 index 269db2e0e..b7108e462 100644 --- a/man/man1/wintext.1 +++ b/man/man1/wintext.1 @@ -22,11 +22,11 @@ wintext, ", "" \- access text in current window prints the text of the current .I win (see -.IM acme (1) ), -.IM 9term (1) , +.MR acme (1) ), +.MR 9term (1) , or (Unix's) -.IM tmux (1) +.MR tmux (1) window to standard output. .PP .I \*y @@ -43,7 +43,7 @@ prints the last command executed. prints the last command that .I \*y would print and then executes it by piping it into -.IM rc (1) . +.MR rc (1) . .PP Both .I \*y @@ -61,7 +61,7 @@ or .BR # . .SH EXAMPLES Print the -.IM ls (1) +.MR ls (1) and .I lc commands executed in this window: @@ -87,8 +87,8 @@ ramfs rc read rio rm % .EE .SH SEE ALSO -.IM 9term (1) , -.IM acme (1) +.MR 9term (1) , +.MR acme (1) .SH SOURCE .B \*9/bin .SH BUGS @@ -96,5 +96,5 @@ ramfs rc read rio rm and .I \*(yy are hard to type in shells other than -.IM rc (1) . +.MR rc (1) . .\" and in troff! diff --git a/man/man1/winwatch.1 b/man/man1/winwatch.1 index fc4afbacf..98031fbc0 100644 --- a/man/man1/winwatch.1 +++ b/man/man1/winwatch.1 @@ -17,7 +17,7 @@ winwatch \- monitor rio windows .SH DESCRIPTION .I Winwatch displays the labels of all current -.IM rio (1) +.MR rio (1) windows, refreshing the display every second. Right clicking a window's label unhides, raises and gives focus to that window. Typing @@ -53,5 +53,5 @@ Excluding winwatch and stats from being shown. .SH SOURCE .B \*9/src/cmd/winwatch.c .SH SEE ALSO -.IM rio (1) , -.IM regexp (7) . +.MR rio (1) , +.MR regexp (7) . diff --git a/man/man1/xd.1 b/man/man1/xd.1 index d291210b4..3a98d9365 100644 --- a/man/man1/xd.1 +++ b/man/man1/xd.1 @@ -91,7 +91,7 @@ followed by an asterisk. .SH SOURCE .B \*9/src/cmd/xd.c .SH "SEE ALSO" -.IM db (1) +.MR db (1) .SH BUGS The various output formats don't line up properly in the output of .IR xd . diff --git a/man/man1/yacc.1 b/man/man1/yacc.1 index 3fbd47c2d..b291473f5 100644 --- a/man/man1/yacc.1 +++ b/man/man1/yacc.1 @@ -23,7 +23,7 @@ to produce a program This program must be loaded with a lexical analyzer function, .B yylex(void) (often generated by -.IM lex (1) ), +.MR lex (1) ), with a .B main(int argc, char *argv[]) program, and with an error handling routine, @@ -115,7 +115,7 @@ option reverses this. The parser accepts .SM UTF input text (see -.IM utf (7) ), +.MR utf (7) ), which has a couple of effects. First, the return value of .B yylex() @@ -156,7 +156,7 @@ parser prototype using stdio .SH SOURCE .B \*9/src/cmd/yacc.c .SH "SEE ALSO" -.IM lex (1) +.MR lex (1) .br S. C. Johnson and R. Sethi, ``Yacc: A parser generator'', diff --git a/man/man1/yesterday.1 b/man/man1/yesterday.1 index f18cf3756..eae046e03 100644 --- a/man/man1/yesterday.1 +++ b/man/man1/yesterday.1 @@ -91,8 +91,8 @@ by convention, root of the dump file system .SH SOURCE .B \*9/bin/yesterday .SH SEE ALSO -.IM diff (1) , -.IM hist (1) , -.IM vbackup (8) +.MR diff (1) , +.MR hist (1) , +.MR vbackup (8) .SH BUGS It's hard to use this command without singing. diff --git a/man/man3/0intro.3 b/man/man3/0intro.3 index 0fe209c68..fe75e7980 100644 --- a/man/man3/0intro.3 +++ b/man/man3/0intro.3 @@ -49,7 +49,7 @@ automatically, so it is rarely necessary to tell the loader which libraries a program needs; see -.IM 9c (1) . +.MR 9c (1) . .PP The library to which a function belongs is defined by the header file that defines its interface. @@ -121,7 +121,7 @@ and plus macros that define the layout of .IR jmp_buf (see -.IM setjmp (3) ); +.MR setjmp (3) ); .\" definitions of the bits in the floating-point control register .\" as used by .\" .IR getfcr (2); @@ -198,27 +198,27 @@ by or .I create (see -.IM open (3) ). +.MR open (3) ). These calls return an integer called a .IR "file descriptor" which identifies the file to subsequent I/O calls, notably -.IM read (3) +.MR read (3) and .IR write . The system allocates the numbers by selecting the lowest unused descriptor. They are allocated dynamically; there is no visible limit to the number of file descriptors a process may have open. They may be reassigned using -.IM dup (3) . +.MR dup (3) . File descriptors are indices into a kernel resident .IR "file descriptor table" . Each process has an associated file descriptor table. In threaded programs (see -.IM thread (3) ), +.MR thread (3) ), the file descriptor table is shared by all the procs. .PP By convention, @@ -236,22 +236,22 @@ Files are normally read or written in sequential order. The I/O position in the file is called the .IR "file offset" and may be set arbitrarily using the -.IM seek (3) +.MR seek (3) system call. .PP Directories may be opened like regular files. Instead of reading them with -.IM read (3) , +.MR read (3) , use the .B Dir structure-based routines described in -.IM dirread (3) . +.MR dirread (3) . The entry corresponding to an arbitrary file can be retrieved by .IR dirstat (see -.IM stat (3) ) +.MR stat (3) ) or .IR dirfstat ; .I dirwstat @@ -262,9 +262,9 @@ write back entries, thus changing the properties of a file. New files are made with .I create (see -.IM open (3) ) +.MR open (3) ) and deleted with -.IM remove (3) . +.MR remove (3) . Directories may not directly be written; .IR create , .IR remove , @@ -273,27 +273,27 @@ and .I fwstat alter them. .PP -.IM Pipe (3) +.MR Pipe (3) creates a connected pair of file descriptors, useful for bidirectional local communication. .SS "Process execution and control" A new process is created when an existing one calls -.IM fork (2) . +.MR fork (2) . The new (child) process starts out with copies of the address space and most other attributes of the old (parent) process. In particular, the child starts out running the same program as the parent; -.IM exec (3) +.MR exec (3) will bring in a different one. .PP Each process has a unique integer process id; a set of open files, indexed by file descriptor; and a current working directory (changed by -.IM chdir (2) ). +.MR chdir (2) ). .PP Each process has a set of attributes \(em memory, open files, name space, etc. \(em that may be shared or unique. @@ -302,9 +302,9 @@ Flags to control the sharing of these attributes. .PP A process terminates by calling -.IM exits (3) . +.MR exits (3) . A parent process may call -.IM wait (3) +.MR wait (3) to wait for some child to terminate. A bit of status information may be passed from @@ -317,14 +317,14 @@ The Plan 9 interface persists here, although the functionality does not. Instead, empty strings are converted to exit status 0 and non-empty strings to 1. .PP A process can go to sleep for a specified time by calling -.IM sleep (3) . +.MR sleep (3) . .PP There is a .I notification mechanism for telling a process about events such as address faults, floating point faults, and messages from other processes. A process uses -.IM notify (3) +.MR notify (3) to register the function to be called (the .IR "notification handler" ) when such events occur. @@ -334,12 +334,12 @@ the main C library works properly in multiprocess programs; .IR malloc , .IR print , and the other routines use locks (see -.IM lock (3) ) +.MR lock (3) ) to synchronize access to their data structures. The graphics library defined in .B is also multi-process capable; details are in -.IM graphics (3) . +.MR graphics (3) . In general, though, multiprocess programs should use some form of synchronization to protect shared data. .PP @@ -365,12 +365,12 @@ Therefore, a program that shouldn't block unexpectedly will use a process to serve the I/O request, passing the result to the main processes over a channel when the request completes. For examples of this design, see -.IM ioproc (3) +.MR ioproc (3) or -.IM mouse (3) . +.MR mouse (3) . .SH SEE ALSO .IR nm (1), -.IM 9c (1) +.MR 9c (1) .SH DIAGNOSTICS Math functions in .I libc @@ -378,14 +378,14 @@ return special values when the function is undefined for the given arguments or when the value is not representable (see -.IM nan (3) ). +.MR nan (3) ). .PP Some of the functions in .I libc are system calls and many others employ system calls in their implementation. All system calls return integers, with \-1 indicating that an error occurred; -.IM errstr (3) +.MR errstr (3) recovers a string describing the error. Some user-level library functions also use the .I errstr diff --git a/man/man3/9p-cmdbuf.3 b/man/man3/9p-cmdbuf.3 index 804f6332c..4ba3b6c81 100644 --- a/man/man3/9p-cmdbuf.3 +++ b/man/man3/9p-cmdbuf.3 @@ -44,7 +44,7 @@ bytes at using .I tokenize (see -.IM getfields (3) ). +.MR getfields (3) ). It returns a .B Cmdbuf structure holding pointers to each field in the message. @@ -116,4 +116,4 @@ is a good example. .SH SOURCE .B \*9/src/lib9p/parse.c .SH SEE ALSO -.IM 9p (3) +.MR 9p (3) diff --git a/man/man3/9p-fid.3 b/man/man3/9p-fid.3 index b87ea2538..239f58ce0 100644 --- a/man/man3/9p-fid.3 +++ b/man/man3/9p-fid.3 @@ -73,7 +73,7 @@ and .BR Reqpool s. They are primarily used by the 9P server loop described in -.IM 9p (3) . +.MR 9p (3) . .PP .B Fid structures are intended to represent @@ -115,7 +115,7 @@ element points at a .B File structure (see -.IM 9p-file (3) ) +.MR 9p-file (3) ) corresponding to the fid. The .B aux @@ -200,5 +200,5 @@ structures. .SH SOURCE .B \*9/src/lib9p .SH SEE ALSO -.IM 9p (3) , -.IM 9p-file (3) +.MR 9p (3) , +.MR 9p-file (3) diff --git a/man/man3/9p-file.3 b/man/man3/9p-file.3 index 52c19bfdf..e849f7134 100644 --- a/man/man3/9p-file.3 +++ b/man/man3/9p-file.3 @@ -144,7 +144,7 @@ When creating new file references by copying pointers, call .I incref (see -.IM lock (3) ) +.MR lock (3) ) to update the reference count. To note the removal of a reference to a file, call .IR closefile . @@ -218,6 +218,6 @@ return nf; .SH SOURCE .B \*9/src/lib9p/file.c .SH SEE ALSO -.IM 9p (3) +.MR 9p (3) .SH BUGS The reference counting is cumbersome. diff --git a/man/man3/9p-intmap.3 b/man/man3/9p-intmap.3 index 7e7db303f..486e18260 100644 --- a/man/man3/9p-intmap.3 +++ b/man/man3/9p-intmap.3 @@ -122,5 +122,5 @@ and .SH SOURCE .B \*9/src/lib9p/intmap.c .SH SEE ALSO -.IM 9p (3) , -.IM 9p-fid (3) +.MR 9p (3) , +.MR 9p-fid (3) diff --git a/man/man3/9p.3 b/man/man3/9p.3 index eac5a3d60..adf102691 100644 --- a/man/man3/9p.3 +++ b/man/man3/9p.3 @@ -110,13 +110,13 @@ and .B Fid structures are allocated one-to-one with uncompleted requests and active fids, and are described in -.IM 9p-fid (3) . +.MR 9p-fid (3) . .PP The behavior of .I srv depends on whether there is a file tree (see -.IM 9p-file (3) ) +.MR 9p-file (3) ) associated with the server, that is, whether the .B tree @@ -178,11 +178,11 @@ as .BI /srv/ name . .IP Fork a child process via -.IM rfork (3) +.MR rfork (3) or .I procrfork (see -.IM thread (3) ), +.MR thread (3) ), using the .BR RFFDG , .RR RFNOTEG , @@ -214,7 +214,7 @@ The parent returns to the caller. .LP If any error occurs during this process, the entire process is terminated by calling -.IM sysfatal (3) . +.MR sysfatal (3) . .SS Service functions The functions in a .B Srv @@ -332,7 +332,7 @@ where is the program name variable as set by .I ARGBEGIN (see -.IM arg (3) ). +.MR arg (3) ). .TP .I Attach The @@ -707,7 +707,7 @@ the service loop (which runs in a separate process from its caller) terminates using .I _exits (see -.IM exits (3) ). +.MR exits (3) ). .PD .PP If the @@ -752,6 +752,6 @@ or is maintained elsewhere. .SH SOURCE .B \*9/src/lib9p .SH SEE ALSO -.IM 9p-fid (3) , -.IM 9p-file (3) , +.MR 9p-fid (3) , +.MR 9p-file (3) , .IR intro (9p) diff --git a/man/man3/9pclient.3 b/man/man3/9pclient.3 index a4c80d8be..74537ab40 100644 --- a/man/man3/9pclient.3 +++ b/man/man3/9pclient.3 @@ -149,7 +149,7 @@ connects to a service named .I name in the current name space directory (see -.IM intro (4) ). +.MR intro (4) ). Both attach to the root of the file system using the attach name .IR aname . @@ -228,7 +228,7 @@ the allocated structures will be freed and the file descriptor corresponding to the connection will be closed (see -.IM close (2) ). +.MR close (2) ). Fids are not reference counted: when .I fsclose is called, the clunk transaction and freeing of storage @@ -308,7 +308,7 @@ sets the offset; the and .I type arguments are used as in -.IM seek (3) . +.MR seek (3) . Calling .I fspread or @@ -340,7 +340,7 @@ for the given fid. .PP .I Fsaccess behaves like Unix's -.IM access (2) . +.MR access (2) . .I Fsremove removes the named path. .I Fsfremove @@ -358,7 +358,7 @@ are like and .I vfprint (see -.IM print (3) ) +.MR print (3) ) but write to .BR CFid* s. .PP @@ -376,7 +376,7 @@ is similar but reads the entire directory. The returned pointer should be freed with .I free (see -.IM malloc (3) ) +.MR malloc (3) ) when no longer needed. .PP .I Fsdirfstat @@ -396,7 +396,7 @@ structure returned by should be freed with .I free (see -.IM malloc (3) ) +.MR malloc (3) ) when no longer needed. .PP .I Fsdirstat @@ -418,7 +418,7 @@ opens a file on the 9P server for reading or writing but returns a Unix file descriptor instead of a fid structure. The file descriptor is actually one end of a -.IM pipe (2) . +.MR pipe (2) . A proxy process on the other end is ferrying data between the pipe and the 9P fid. Because of the implementation as a pipe, @@ -443,18 +443,18 @@ If the flag is set, the library calls .I threadexitsall (see -.IM thread (3) ) +.MR thread (3) ) when it detects EOF on a 9P connection. .SH SOURCE .B \*9/src/lib9pclient .SH SEE ALSO -.IM intro (4) , +.MR intro (4) , .IR intro (9p), .I fsaopen and .I nsaopen in -.IM auth (3) +.MR auth (3) .SH BUGS The implementation should use a special version string to distinguish between diff --git a/man/man3/acme.3 b/man/man3/acme.3 index d2f116ae6..7c4ac67a7 100644 --- a/man/man3/acme.3 +++ b/man/man3/acme.3 @@ -141,7 +141,7 @@ char* evsmprint(char *fmt, va_list arg) .SH DESCRIPTION .I Libacme provides a simple C interface for interacting with -.IM acme (1) +.MR acme (1) windows. .PP A @@ -168,7 +168,7 @@ Most of the library routines access files in the window's .I acme directory. See -.IM acme (4) +.MR acme (4) for details. Many library routines take a format string .I fmt @@ -179,11 +179,11 @@ denotes the result of formatting the string and arguments using .I smprint (see -.IM print (3) ). +.MR print (3) ). .PP .I Pipetowin runs the -.IM rc (1) +.MR rc (1) command line .I fmt\fR, \fP... with @@ -199,7 +199,7 @@ Otherwise the command inherits the caller's standard error. .PP .I Pipewinto runs the -.IM rc (1) +.MR rc (1) command line .I fmt\fR, \fP... with the window's @@ -300,7 +300,7 @@ to position relative to .I type (see -.IM seek (3) ). +.MR seek (3) ). .PP .I Winwrite writes the @@ -317,7 +317,7 @@ The fields correspond to the fields in .IR acme 's event messages. See -.IM acme (4) +.MR acme (4) for detailed explanations. The fields are: .TP @@ -384,7 +384,7 @@ that it should be handled internally. returns a pointer to a .B Channel (see -.IM thread (3) ) +.MR thread (3) ) on which event structures (not pointers) can be read. The first call to .I wineventchan @@ -404,20 +404,20 @@ after calling and .I evsmprint are like -.IM malloc (3) , +.MR malloc (3) , .IR realloc , .IR strdup (see -.IM strcat (3) ), +.MR strcat (3) ), and .IR vsmprint (see -.IM print (3) ), +.MR print (3) ), but they call -.IM sysfatal (3) +.MR sysfatal (3) on error rather than returning nil. .SH SOURCE .B \*9/src/libacme .SH SEE ALSO -.IM acme (1) , -.IM acme (4) +.MR acme (1) , +.MR acme (4) diff --git a/man/man3/addpt.3 b/man/man3/addpt.3 index 5a22abeb3..74d19634b 100644 --- a/man/man3/addpt.3 +++ b/man/man3/addpt.3 @@ -185,4 +185,4 @@ They are implemented as macros. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) +.MR graphics (3) diff --git a/man/man3/aes.3 b/man/man3/aes.3 index c9c74155b..94ff54a70 100644 --- a/man/man3/aes.3 +++ b/man/man3/aes.3 @@ -39,13 +39,13 @@ cryptographically strongly unpredictable. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM blowfish (3) , -.IM des (3) , -.IM dsa (3) , -.IM elgamal (3) , -.IM rc4 (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR blowfish (3) , +.MR des (3) , +.MR dsa (3) , +.MR elgamal (3) , +.MR rc4 (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/allocimage.3 b/man/man3/allocimage.3 index 72ee805e6..518d6b327 100644 --- a/man/man3/allocimage.3 +++ b/man/man3/allocimage.3 @@ -135,7 +135,7 @@ The field will have been set to the identifying number used by .B /dev/draw (see -.IM draw (3) ), +.MR draw (3) ), and the .I cache field will be zero. @@ -148,7 +148,7 @@ The field will be set to the number of bits per pixel specified by the channel descriptor (see -.IM image (7) ). +.MR image (7) ). .I Allocimage returns 0 if the server has run out of image memory. .PP @@ -191,7 +191,7 @@ These routines permit unrelated applications sharing a display to share an image for example they provide the mechanism behind .B getwindow (see -.IM graphics (3) ). +.MR graphics (3) ). .PP The RGB values in a color are .I premultiplied @@ -214,7 +214,7 @@ values between image and user space or external files. There is a fixed format for the exchange and storage of image data (see -.IM image (7) ). +.MR image (7) ). .PP .I Unloadimage reads a rectangle of pixels from image @@ -271,7 +271,7 @@ but for bytes of compressed image .I data (see -.IM image (7) ). +.MR image (7) ). On each call to .IR cloadimage, the @@ -289,7 +289,7 @@ return the number of bytes copied. .PP .I Readimage creates an image from data contained in an external file (see -.IM image (7) +.MR image (7) for the file format); .I fd is a file descriptor obtained by opening such a file for reading. @@ -333,10 +333,10 @@ To allocate a single-pixel replicated image that may be used to paint a region r .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IM graphics (3) , -.IM draw (3) , -.IM draw (3) , -.IM image (7) +.MR graphics (3) , +.MR draw (3) , +.MR draw (3) , +.MR image (7) .SH DIAGNOSTICS These functions return pointer 0 or integer \-1 on failure, usually due to insufficient memory. diff --git a/man/man3/arg.3 b/man/man3/arg.3 index 1d6dbab15..d9aa812ff 100644 --- a/man/man3/arg.3 +++ b/man/man3/arg.3 @@ -20,7 +20,7 @@ These macros assume the names and .I argv are in scope; see -.IM exec (3) . +.MR exec (3) . .I ARGBEGIN and .I ARGEND @@ -58,7 +58,7 @@ but instead of returning zero runs .I code and, if that returns, calls -.IM abort (3) . +.MR abort (3) . A typical value for .I code is diff --git a/man/man3/arith3.3 b/man/man3/arith3.3 index 198cce35f..039df33ec 100644 --- a/man/man3/arith3.3 +++ b/man/man3/arith3.3 @@ -266,4 +266,4 @@ Subtract the coordinates of two points. .SH SOURCE .B \*9/src/libgeometry .SH "SEE ALSO -.IM matrix (3) +.MR matrix (3) diff --git a/man/man3/atof.3 b/man/man3/atof.3 index ce2ca723e..8b462aa9d 100644 --- a/man/man3/atof.3 +++ b/man/man3/atof.3 @@ -129,7 +129,7 @@ after calling .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IM fscanf (3) +.MR fscanf (3) .SH DIAGNOSTICS Zero is returned if the beginning of the input string is not interpretable as a number; even in this case, @@ -175,4 +175,4 @@ are preprocessor macros defined as and .IR p9atoll ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/auth.3 b/man/man3/auth.3 index 747b9555d..9fda7de35 100644 --- a/man/man3/auth.3 +++ b/man/man3/auth.3 @@ -95,7 +95,7 @@ CFsys* nsamount(char *name, char *aname); .SH DESCRIPTION .PP This library, in concert with -.IM factotum (4) , +.MR factotum (4) , is used to authenticate users. It provides the primary interface to .IR factotum . @@ -168,7 +168,7 @@ It provides the primary interface to The following routines use the .B AuthInfo structure returned after a successful authentication by -.IM factotum (4) . +.MR factotum (4) . .PP .ne 8 .EX @@ -212,11 +212,11 @@ file, as opened by An .B sprint (see -.IM print (3) ) +.MR print (3) ) of .I fmt and the variable arg list yields a key template (see -.IM factotum (4) ) +.MR factotum (4) ) specifying the key to use. The template must specify at least the protocol ( .BI proto= xxx ) @@ -258,7 +258,7 @@ arranges a connection to either by opening .B /mnt/factotum/rpc or by using -.IM 9pclient (3) +.MR 9pclient (3) to connect to a .B factotum service posted in the current name space. @@ -266,7 +266,7 @@ The returned connection is freed using .IR auth_freerpc . Individual commands can be sent to -.IM factotum (4) +.MR factotum (4) by invoking .IR auth_rpc . .PP @@ -418,7 +418,7 @@ and but execute the protocol on a .B CFid* (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) instead of a file descriptor. .PP .I Fsamount @@ -429,15 +429,15 @@ are like and .I nsmount (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) but use .I factotum to authenticate to the file servers. .SH SOURCE .B \*9/src/libauth .SH SEE ALSO -.IM factotum (4) , -.IM authsrv (3) +.MR factotum (4) , +.MR authsrv (3) .SH DIAGNOSTICS These routines set .IR errstr . diff --git a/man/man3/authsrv.3 b/man/man3/authsrv.3 index 2b2113bc2..e1ace0c4c 100644 --- a/man/man3/authsrv.3 +++ b/man/man3/authsrv.3 @@ -68,7 +68,7 @@ If is non-nil, the network database (see -.IM ndb (1) ) +.MR ndb (1) ) is queried for an entry which contains .B authdom=\fIad\fP or @@ -212,8 +212,8 @@ to recieve an answer. .SH SOURCE .B \*9/src/libauthsrv .SH SEE ALSO -.IM passwd (1) , -.IM dial (3) , +.MR passwd (1) , +.MR dial (3) , Plan 9's .IR authsrv (6). .SH DIAGNOSTICS diff --git a/man/man3/bin.3 b/man/man3/bin.3 index 3ab9ba90c..e86854943 100644 --- a/man/man3/bin.3 +++ b/man/man3/bin.3 @@ -82,7 +82,7 @@ are ignored, and the result is the same as calling and .I bingrow allocate large chunks of memory using -.IM malloc (3) +.MR malloc (3) and return pieces of these chunks. The chunks are .IR free 'd @@ -91,7 +91,7 @@ upon a call to .SH SOURCE .B \*9/src/libbin .SH SEE ALSO -.IM malloc (3) +.MR malloc (3) .SH DIAGNOSTICS .I binalloc and diff --git a/man/man3/bio.3 b/man/man3/bio.3 index 1f7b82212..05721f8b3 100644 --- a/man/man3/bio.3 +++ b/man/man3/bio.3 @@ -93,7 +93,7 @@ for mode or creates for mode .BR OWRITE . It calls -.IM malloc (3) +.MR malloc (3) to allocate a buffer. .PP .I Bfdopen @@ -104,7 +104,7 @@ for mode or .BR OWRITE . It calls -.IM malloc (3) +.MR malloc (3) to allocate a buffer. .PP .I Binit @@ -173,7 +173,7 @@ of the most recent string returned by .PP .I Brdstr returns a -.IM malloc (3) -allocated +.MR malloc (3) -allocated buffer containing the next line of input delimited by .IR delim , terminated by a NUL (0) byte. @@ -225,7 +225,7 @@ may back up a maximum of five bytes. uses .I charstod (see -.IM atof (3) ) +.MR atof (3) ) and .I Bgetc to read the formatted @@ -246,7 +246,7 @@ and a negative value is returned if a read error occurred. .PP .I Bseek applies -.IM seek (3) +.MR seek (3) to .IR bp . It returns the new file offset. @@ -278,7 +278,7 @@ on the output stream. .PP .I Bprint is a buffered interface to -.IM print (3) . +.MR print (3) . If this causes a .IR write to occur and there is an error, @@ -325,10 +325,10 @@ written. .SH SOURCE .B \*9/src/libbio .SH SEE ALSO -.IM open (3) , -.IM print (3) , -.IM exits (3) , -.IM utf (7) , +.MR open (3) , +.MR print (3) , +.MR exits (3) , +.MR utf (7) , .SH DIAGNOSTICS .I Bio routines that return integers yield diff --git a/man/man3/blowfish.3 b/man/man3/blowfish.3 index 2ae83f4d3..95d775072 100644 --- a/man/man3/blowfish.3 +++ b/man/man3/blowfish.3 @@ -40,13 +40,13 @@ must be a multiple of eight bytes as padding is currently unsupported. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM des (3) , -.IM dsa (3) , -.IM elgamal (3) , -.IM rc4 (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR des (3) , +.MR dsa (3) , +.MR elgamal (3) , +.MR rc4 (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/cachechars.3 b/man/man3/cachechars.3 index 95b172e92..1b2cc5b06 100644 --- a/man/man3/cachechars.3 +++ b/man/man3/cachechars.3 @@ -30,7 +30,7 @@ A may contain too many characters to hold in memory simultaneously. The graphics library and draw device (see -.IM draw (3) ) +.MR draw (3) ) cooperate to solve this problem by maintaining a cache of recently used character images. The details of this cooperation need not be known by most programs: @@ -127,7 +127,7 @@ A .B Font consists of an overall height and ascent and a collection of subfonts together with the ranges of runes (see -.IM utf (7) ) +.MR utf (7) ) they represent. Fonts are described by the following structures. .IP @@ -181,7 +181,7 @@ The and .LR ascent fields of Font are described in -.IM graphics (3) . +.MR graphics (3) . .L Sub contains .L nsub @@ -302,12 +302,12 @@ for replacement when the cache is full. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM allocimage (3) , -.IM draw (3) , -.IM subfont (3) , -.IM image (7) , -.IM font (7) +.MR graphics (3) , +.MR allocimage (3) , +.MR draw (3) , +.MR subfont (3) , +.MR image (7) , +.MR font (7) .SH DIAGNOSTICS All of the functions use the graphics error function (see -.IM graphics (3) ). +.MR graphics (3) ). diff --git a/man/man3/cleanname.3 b/man/man3/cleanname.3 index 8486cd90f..75fdd8058 100644 --- a/man/man3/cleanname.3 +++ b/man/man3/cleanname.3 @@ -31,4 +31,4 @@ must contain room for at least two bytes. .SH SOURCE .B \*9/src/lib9/cleanname.c .SH SEE ALSO -.IM cleanname (1) +.MR cleanname (1) diff --git a/man/man3/color.3 b/man/man3/color.3 index 0c1b88213..e08d91949 100644 --- a/man/man3/color.3 +++ b/man/man3/color.3 @@ -19,7 +19,7 @@ int cmap2rgba(int col) .SH DESCRIPTION These routines convert between `true color' red/green/blue triples and the Plan 9 color map. See -.IM color (7) +.MR color (7) for a description of RGBV, the standard color map. .PP .I Rgb2cmap @@ -41,16 +41,16 @@ and the next 8 representing blue, then green, then red, as for .I cmap2rgba shifted up 8 bits. This 32-bit representation is the format used by -.IM draw (3) +.MR draw (3) and -.IM memdraw (3) +.MR memdraw (3) library routines that take colors as arguments. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM allocimage (3) , -.IM draw (3) , -.IM image (7) , -.IM color (7) +.MR graphics (3) , +.MR allocimage (3) , +.MR draw (3) , +.MR image (7) , +.MR color (7) diff --git a/man/man3/complete.3 b/man/man3/complete.3 index b0f9fcea8..f1d0c2803 100644 --- a/man/man3/complete.3 +++ b/man/man3/complete.3 @@ -86,15 +86,15 @@ function frees a structure and its contents. .PP In -.IM rio (1) +.MR rio (1) and -.IM acme (1) , +.MR acme (1) , file name completion is triggered by a control-F character or an Insert character. .SH SOURCE .B \*9/src/libcomplete .SH SEE ALSO -.IM rio (1) , -.IM acme (1) +.MR rio (1) , +.MR acme (1) .SH DIAGNOSTICS The .I complete diff --git a/man/man3/ctime.3 b/man/man3/ctime.3 index db6591343..5d80d4118 100644 --- a/man/man3/ctime.3 +++ b/man/man3/ctime.3 @@ -26,7 +26,7 @@ long tm2sec(Tm *tm) converts a time .I clock such as returned by -.IM time (3) +.MR time (3) into .SM ASCII (sic) @@ -85,8 +85,8 @@ is not .br .B \*9/src/lib9/tm2sec.c .SH "SEE ALSO" -.IM date (1) , -.IM time (3) +.MR date (1) , +.MR time (3) .SH BUGS The return values point to static data whose content is overwritten by each call. @@ -112,4 +112,4 @@ are preprocessor macros defined as and .IR p9tm2sec ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/des.3 b/man/man3/des.3 index 5381f2e37..686fc4c9e 100644 --- a/man/man3/des.3 +++ b/man/man3/des.3 @@ -132,13 +132,13 @@ using .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM blowfish (3) , -.IM dsa (3) , -.IM elgamal (3) , -.IM rc4 (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR blowfish (3) , +.MR dsa (3) , +.MR elgamal (3) , +.MR rc4 (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/dial.3 b/man/man3/dial.3 index f34b1c54d..24efc7023 100644 --- a/man/man3/dial.3 +++ b/man/man3/dial.3 @@ -264,7 +264,7 @@ int callkremvax(void) .EE .PP Connect to a Unix socket served by -.IM acme (4) : +.MR acme (4) : .IP .EX int dialacme(void) @@ -346,4 +346,4 @@ are preprocessor macros defined as .IR p9announce , and so on; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/dirread.3 b/man/man3/dirread.3 index b0386a23a..cce8d9785 100644 --- a/man/man3/dirread.3 +++ b/man/man3/dirread.3 @@ -19,11 +19,11 @@ long dirreadall(int fd, Dir **buf) #define DIRMAX (sizeof(Dir)+STATMAX) .SH DESCRIPTION The data returned by a -.IM read (3) +.MR read (3) on a directory is a set of complete directory entries in a machine-independent format, exactly equivalent to the result of a -.IM stat (3) +.MR stat (3) on each file or subdirectory in the directory. .I Dirread decodes the directory entries into a machine-dependent form. @@ -35,11 +35,11 @@ structures whose address is returned in .B *buf (see -.IM stat (3) +.MR stat (3) for the layout of a .BR Dir ). The array is allocated with -.IM malloc (3) +.MR malloc (3) each time .I dirread is called. @@ -50,7 +50,7 @@ is like but reads in the entire directory; by contrast, .I dirread steps through a directory one -.IM read (3) +.MR read (3) at a time. .PP Directory entries have variable length. @@ -85,9 +85,9 @@ The file offset is advanced by the number of bytes actually read. .SH SOURCE .B \*9/src/lib9/dirread.c .SH SEE ALSO -.IM intro (3) , -.IM open (3) , -.IM read (3) +.MR intro (3) , +.MR open (3) , +.MR read (3) .SH DIAGNOSTICS .I Dirread and diff --git a/man/man3/draw.3 b/man/man3/draw.3 index c91ab541f..4ad680b33 100644 --- a/man/man3/draw.3 +++ b/man/man3/draw.3 @@ -259,7 +259,7 @@ The clipping region may be modified dynamically using .TP .B chan The pixel channel format descriptor, as described in -.IM image (7) . +.MR image (7) . The value should not be modified after the image is created. .TP .B depth @@ -268,7 +268,7 @@ number of bits per pixel in the picture; it is identically .B chantodepth(chan) (see -.IM graphics (3) ) +.MR graphics (3) ) and is provided as a convenience. The value should not be modified after the image is created. .TP @@ -712,7 +712,7 @@ what is to .B atan (see -.IM sin (3) ). +.MR sin (3) ). .TP .BI border( dst\fP,\fP\ r\fP,\fP\ i\fP,\fP\ color\fP,\fP\ sp\fP) .I Border @@ -810,11 +810,11 @@ is non-zero. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM stringsize (3) , -.IM color (7) , -.IM utf (7) , -.IM addpt (3) +.MR graphics (3) , +.MR stringsize (3) , +.MR color (7) , +.MR utf (7) , +.MR addpt (3) .PP T. Porter, T. Duff. ``Compositing Digital Images'', diff --git a/man/man3/drawfcall.3 b/man/man3/drawfcall.3 index ecdc272ae..1ee37cd8c 100644 --- a/man/man3/drawfcall.3 +++ b/man/man3/drawfcall.3 @@ -30,15 +30,15 @@ int readwsysmsg(int fd, uchar *buf, uint nbuf) uint sizeW2M(Wsysmsg *w) .SH DESCRIPTION These routines are analogues of the routines described in -.IM fcall (3) . +.MR fcall (3) . They manipulate graphics device protocol messages rather than 9P protocol messages. The graphics device protocol is used for internal communication between the -.IM devdraw (1) +.MR devdraw (1) graphics server and the -.IM draw (3) +.MR draw (3) library. A .B Wsysmsg @@ -48,6 +48,6 @@ The protocol is intentionally undocumented and may change. .SH SOURCE .B \*9/src/libdraw/drawfcall.c .SH SEE ALSO -.IM devdraw (1) , -.IM draw (3) , -.IM graphics (3) +.MR devdraw (1) , +.MR draw (3) , +.MR graphics (3) diff --git a/man/man3/dsa.3 b/man/man3/dsa.3 index 0a3c34a12..787140101 100644 --- a/man/man3/dsa.3 +++ b/man/man3/dsa.3 @@ -84,7 +84,7 @@ and generated by .IR DSAprimes (see -.IM prime (3) ). +.MR prime (3) ). Otherwise, .B p and @@ -128,17 +128,17 @@ are provided to manage signature storage. converts an ASN1 formatted DSA private key into the corresponding .B DSApriv structure; see -.IM rsa (3) +.MR rsa (3) for other ASN1 routines. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM blowfish (3) , -.IM des (3) , -.IM rc4 (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR blowfish (3) , +.MR des (3) , +.MR rc4 (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/dup.3 b/man/man3/dup.3 index e313c0682..268873630 100644 --- a/man/man3/dup.3 +++ b/man/man3/dup.3 @@ -36,4 +36,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9dup ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/elgamal.3 b/man/man3/elgamal.3 index 9fe4e6987..af4bc03b6 100644 --- a/man/man3/elgamal.3 +++ b/man/man3/elgamal.3 @@ -113,13 +113,13 @@ are provided to manage signature storage. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM blowfish (3) , -.IM des (3) , -.IM dsa (3) , -.IM rc4 (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR blowfish (3) , +.MR des (3) , +.MR dsa (3) , +.MR rc4 (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/encode.3 b/man/man3/encode.3 index e3a94860d..57b5cd081 100644 --- a/man/man3/encode.3 +++ b/man/man3/encode.3 @@ -49,9 +49,9 @@ of 8. .PP .I Encodefmt can be used with -.IM fmtinstall (3) +.MR fmtinstall (3) and -.IM print (3) +.MR print (3) to print encoded representations of byte arrays. The verbs are .TP diff --git a/man/man3/encrypt.3 b/man/man3/encrypt.3 index 70ff003ed..894020d87 100644 --- a/man/man3/encrypt.3 +++ b/man/man3/encrypt.3 @@ -84,4 +84,4 @@ are preprocessor macros defined as and .IR p9decrypt ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/errstr.3 b/man/man3/errstr.3 index 5bc7bf091..703f2ee08 100644 --- a/man/man3/errstr.3 +++ b/man/man3/errstr.3 @@ -53,7 +53,7 @@ the result is an empty string. The verb .B r in -.IM print (3) +.MR print (3) calls .I errstr and outputs the error string. @@ -92,8 +92,8 @@ will reset .I Errstr always returns 0. .SH SEE ALSO -.IM intro (3) , -.IM perror (3) +.MR intro (3) , +.MR perror (3) .SH BUGS The implementation sets .I errno @@ -104,4 +104,4 @@ When .I errno is set to other values, the error string is synthesized using -.IM strerror (3) . +.MR strerror (3) . diff --git a/man/man3/event.3 b/man/man3/event.3 index 56ddeb346..f76e5ea27 100644 --- a/man/man3/event.3 +++ b/man/man3/event.3 @@ -93,12 +93,12 @@ enum{ These routines provide an interface to multiple sources of input for unthreaded programs. Threaded programs (see -.IM thread (3) ) +.MR thread (3) ) should instead use the threaded mouse and keyboard interface described in -.IM mouse (3) +.MR mouse (3) and -.IM keyboard (3) . +.MR keyboard (3) . .PP .I Einit must be called first. @@ -113,7 +113,7 @@ the mouse and keyboard events will be enabled; in this case, .IR initdraw (see -.IM graphics (3) ) +.MR graphics (3) ) must have already been called. The user must provide a function called .IR eresized @@ -123,7 +123,7 @@ is running has been resized; the argument is a flag specifying whether the program must call .I getwindow (see -.IM graphics (3) ) +.MR graphics (3) ) to re-establish a connection to its window. After resizing (and perhaps calling .IR getwindow ), @@ -266,7 +266,7 @@ The return is the same as for .IR eread . .PP As described in -.IM graphics (3) , +.MR graphics (3) , the graphics functions are buffered. .IR Event , .IR eread , @@ -370,15 +370,15 @@ changes the cursor image to that described by the .B Cursor .I c (see -.IM mouse (3) ). +.MR mouse (3) ). If .B c is nil, it restores the image to the default arrow. .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IM rio (1) , -.IM graphics (3) , -.IM plumb (3) , +.MR rio (1) , +.MR graphics (3) , +.MR plumb (3) , .\" .IR cons (3), -.IM draw (3) +.MR draw (3) diff --git a/man/man3/exec.3 b/man/man3/exec.3 index cc921dbdd..51096cc91 100644 --- a/man/man3/exec.3 +++ b/man/man3/exec.3 @@ -25,11 +25,11 @@ points to the name of the file to be executed; it must not be a directory, and the permissions must allow the current user to execute it (see -.IM stat (3) ). +.MR stat (3) ). It should also be a valid binary image, as defined by the local operating system, or a shell script (see -.IM rc (1) ). +.MR rc (1) ). The first line of a shell script must begin with .L #! @@ -92,24 +92,24 @@ files remain open across .B OCEXEC OR'd into the open mode; see -.IM open (3) ); +.MR open (3) ); and the working directory and environment (see -.IM getenv (3) ) +.MR getenv (3) ) remain the same. However, a newly .I exec'ed process has no notification handlers (see -.IM notify (3) ). +.MR notify (3) ). .SH SOURCE .B \*9/src/lib9/exec.c .br .B \*9/src/lib9/execl.c .SH SEE ALSO -.IM prof (1) , -.IM intro (3) , -.IM stat (3) +.MR prof (1) , +.MR intro (3) , +.MR stat (3) .SH DIAGNOSTICS If these functions fail, they return and set .IR errstr . @@ -138,4 +138,4 @@ are preprocessor macros defined as and .IR p9execl ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/exits.3 b/man/man3/exits.3 index c1d47ea87..2f4b1f4fc 100644 --- a/man/man3/exits.3 +++ b/man/man3/exits.3 @@ -39,7 +39,7 @@ explanation of the reason for exiting, or a null pointer or empty string to indicate normal termination. The string is passed to the parent process, prefixed by the name and process id of the exiting process, when the parent does a -.IM wait (3) . +.MR wait (3) . .PP Before calling .I _exits @@ -85,8 +85,8 @@ cancels a previous registration of an exit function. .br .B \*9/src/lib9/_exits.c .SH "SEE ALSO" -.IM fork (2) , -.IM wait (3) +.MR fork (2) , +.MR wait (3) .SH BUGS Because of limitations of Unix, the exit status of a process can only be an 8-bit integer. @@ -117,4 +117,4 @@ are preprocessor macros defined as and .IR p9atexitdont ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/fcall.3 b/man/man3/fcall.3 index 6dc4bf5cc..5e9bd1958 100644 --- a/man/man3/fcall.3 +++ b/man/man3/fcall.3 @@ -225,7 +225,7 @@ by a successful call to Another structure is .BR Dir , used by the routines described in -.IM stat (3) . +.MR stat (3) . .I ConvM2D converts the machine-independent form starting at .I ap @@ -293,7 +293,7 @@ contain a validly formatted machine-independent entry suitable as an argument, for example, for the .B wstat (see -.IM stat (3) ) +.MR stat (3) ) system call. It checks that the sizes of all the elements of the the entry sum to exactly .IR nbuf , @@ -321,7 +321,7 @@ for an incorrectly formatted entry. and .I dirmodefmt are formatting routines, suitable for -.IM fmtinstall (3) . +.MR fmtinstall (3) . They convert .BR Dir* , .BR Fcall* , @@ -343,7 +343,7 @@ with format letter .PP .I Read9pmsg calls -.IM read (3) +.MR read (3) multiple times, if necessary, to read an entire 9P message into .BR buf . The return value is 0 for end of file, or -1 for error; it does not return @@ -351,7 +351,7 @@ partial messages. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IM intro (3) , -.IM 9p (3) , -.IM stat (3) , +.MR intro (3) , +.MR 9p (3) , +.MR stat (3) , .IR intro (9p) diff --git a/man/man3/flate.3 b/man/man3/flate.3 index cd90c1f2a..81f82dcf3 100644 --- a/man/man3/flate.3 +++ b/man/man3/flate.3 @@ -173,7 +173,7 @@ The block functions return the number of bytes produced when they succeed. .I Mkcrctab allocates (using -.IM malloc (3) ), +.MR malloc (3) ), initializes, and returns a table for rapid computation of 32 bit CRC values using the polynomial .IR poly . .I Blockcrc diff --git a/man/man3/fmtinstall.3 b/man/man3/fmtinstall.3 index 93bded761..b68cd008c 100644 --- a/man/man3/fmtinstall.3 +++ b/man/man3/fmtinstall.3 @@ -94,16 +94,16 @@ int fmtrunestrcpy(Fmt *f, Rune *s); int errfmt(Fmt *f); .SH DESCRIPTION The interface described here allows the construction of custom -.IM print (3) +.MR print (3) verbs and output routines. In essence, they provide access to the workings of the formatted print code. .PP The -.IM print (3) +.MR print (3) suite maintains its state with a data structure called .BR Fmt . A typical call to -.IM print (3) +.MR print (3) or its relatives initializes a .B Fmt structure, passes it to subsidiary routines to process the output, @@ -154,7 +154,7 @@ to generate the output. These behave like .B fprint (see -.IM print (3) ) +.MR print (3) ) or .B vfprint except that the characters are buffered until @@ -207,7 +207,7 @@ In are the width and precision, and .IB fp ->flags the decoded flags for the verb (see -.IM print (3) +.MR print (3) for a description of these items). The standard flag values are: .B FmtSign @@ -282,7 +282,7 @@ produced. .PP Some internal functions may be useful to format primitive types. They honor the width, precision and flags as described in -.IM print (3) . +.MR print (3) . .I Fmtrune formats a single character .BR r . @@ -307,7 +307,7 @@ regardless of whether the output is bytes or runes. This function prints an error message with a variable number of arguments and then quits. Compared to the corresponding example in -.IM print (3) , +.MR print (3) , this version uses a smaller buffer, will never truncate the output message, but might generate multiple .B write @@ -364,9 +364,9 @@ main(...) .SH SOURCE .B \*9/src/lib9/fmt .SH SEE ALSO -.IM print (3) , -.IM utf (7) , -.IM errstr (3) +.MR print (3) , +.MR utf (7) , +.MR errstr (3) .SH DIAGNOSTICS These routines return negative numbers or nil for errors and set .IR errstr . diff --git a/man/man3/frame.3 b/man/man3/frame.3 index 4fb2f8b69..4b027acb3 100644 --- a/man/man3/frame.3 +++ b/man/man3/frame.3 @@ -73,9 +73,9 @@ enum{ This library supports .I frames of editable text in a single font on raster displays, such as in -.IM sam (1) +.MR sam (1) and -.IM 9term (1) . +.MR 9term (1) . Frames may hold any character except NUL (0). Long lines are folded and tabs are at fixed intervals. .PP @@ -239,7 +239,7 @@ If a .B Frame is being moved but not resized, that is, if the shape of its containing rectangle is unchanged, it is sufficient to use -.IM draw (3) +.MR draw (3) to copy the containing rectangle from the old to the new location and then call .I frsetrects to establish the new geometry. @@ -357,6 +357,6 @@ and .SH SOURCE .B \*9/src/libframe .SH SEE ALSO -.IM graphics (3) , -.IM draw (3) , -.IM cachechars (3) . +.MR graphics (3) , +.MR draw (3) , +.MR cachechars (3) . diff --git a/man/man3/genrandom.3 b/man/man3/genrandom.3 index 320ecd14f..b58756353 100644 --- a/man/man3/genrandom.3 +++ b/man/man3/genrandom.3 @@ -25,11 +25,11 @@ number generator. The X9.17 generator is seeded by 24 truly random bytes read via .I truerand (see -.IM rand (3) ). +.MR rand (3) ). .PP .I Prng uses the native -.IM rand (3) +.MR rand (3) pseudo-random number generator to fill the buffer. Used with .IR srand , this function can produce a reproducible stream of pseudo random @@ -38,8 +38,8 @@ numbers useful in testing. Both functions may be passed to .I mprand (see -.IM mp (3) ). +.MR mp (3) ). .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) +.MR mp (3) diff --git a/man/man3/get9root.3 b/man/man3/get9root.3 index 343ad9d6d..a6bdd02f8 100644 --- a/man/man3/get9root.3 +++ b/man/man3/get9root.3 @@ -49,7 +49,7 @@ if different from should be freed with .I free (see -.IM malloc (3) ) +.MR malloc (3) ) when no longer needed. .PP As a convention, programs should never @@ -57,7 +57,7 @@ As a convention, programs should never paths obtained from user input. .SH EXAMPLE The -.IM plumber (4) +.MR plumber (4) uses this code to find unrooted file names included by plumb rules. .IP .EX @@ -69,7 +69,7 @@ fd = open(unsharp(buf), OREAD); .br .B \*9/src/lib9/unsharp.c .SH SEE ALSO -.IM intro (4) +.MR intro (4) .SH BUGS .I Get9root could be smarter about finding the tree when diff --git a/man/man3/getenv.3 b/man/man3/getenv.3 index 3ce0a316b..a37cb6595 100644 --- a/man/man3/getenv.3 +++ b/man/man3/getenv.3 @@ -18,7 +18,7 @@ int putenv(char *name, char *val) fetches the environment value associated with .I name into memory allocated with -.IM malloc (3) , +.MR malloc (3) , 0-terminates it, and returns a pointer to that area. If no file exists, 0 @@ -44,4 +44,4 @@ are preprocessor macros defined as and .IR p9putenv ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/getfields.3 b/man/man3/getfields.3 index 19741b855..79a1ed786 100644 --- a/man/man3/getfields.3 +++ b/man/man3/getfields.3 @@ -75,9 +75,9 @@ with non-zero, except that fields may be quoted using single quotes, in the manner of -.IM rc (1) . +.MR rc (1) . See -.IM quote (3) +.MR quote (3) for related quote-handling software. .PP .I Tokenize @@ -91,5 +91,5 @@ set to \f5"\et\er\en "\fP. .SH SEE ALSO .I strtok in -.IM strcat (3) , -.IM quote (3) . +.MR strcat (3) , +.MR quote (3) . diff --git a/man/man3/getns.3 b/man/man3/getns.3 index a23a856b1..6d0a5a9c2 100644 --- a/man/man3/getns.3 +++ b/man/man3/getns.3 @@ -14,9 +14,9 @@ returns a pointer to a malloced string that contains the path to the name space directory for the current process. The name space directory is a clumsy substitute for Plan 9's per-process name spaces; see -.IM intro (4) +.MR intro (4) for details. .SH SOURCE .B \*9/src/lib9/getns.c .SH SEE ALSO -.IM intro (4) +.MR intro (4) diff --git a/man/man3/getsnarf.3 b/man/man3/getsnarf.3 index 323b6ab54..30d220828 100644 --- a/man/man3/getsnarf.3 +++ b/man/man3/getsnarf.3 @@ -20,7 +20,7 @@ returns a copy of the current buffer; the returned pointer should be freed with .I free (see -.IM malloc (3) ) +.MR malloc (3) ) when no longer needed. .PP .I Putsnarf @@ -36,4 +36,4 @@ will convert as necessary. .SH SOURCE .B \*9/src/libdraw/snarf.c .SH SEE ALSO -.IM snarfer (1) +.MR snarfer (1) diff --git a/man/man3/getuser.3 b/man/man3/getuser.3 index dae84a230..45531b4c1 100644 --- a/man/man3/getuser.3 +++ b/man/man3/getuser.3 @@ -19,7 +19,7 @@ name of the user who owns the current process. .I Getuser calls -.IM getuid (2) +.MR getuid (2) and then reads .B /etc/passwd to find the corresponding name. @@ -33,7 +33,7 @@ looks first for an environment variable If there is no such variable, .I sysname calls -.IM gethostname (2) +.MR gethostname (2) and truncates the returned name at the first dot. If .I gethostname diff --git a/man/man3/getwd.3 b/man/man3/getwd.3 index 9bb36d309..f9ef1949b 100644 --- a/man/man3/getwd.3 +++ b/man/man3/getwd.3 @@ -23,10 +23,10 @@ bytes in the buffer provided. .SH SOURCE .B \*9/src/lib9/getwd.c .SH "SEE ALSO" -.IM pwd (1) +.MR pwd (1) .SH DIAGNOSTICS On error, zero is returned. -.IM Errstr (3) +.MR Errstr (3) may be consulted for more information. .SH BUGS To avoid name conflicts with the underlying system, @@ -34,4 +34,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9getwd ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/graphics.3 b/man/man3/graphics.3 index 42b797f44..da0b61cfd 100644 --- a/man/man3/graphics.3 +++ b/man/man3/graphics.3 @@ -107,7 +107,7 @@ extern Font *font A .B Display structure represents a connection to the graphics device, -.IM draw (3) , +.MR draw (3) , holding all graphics resources associated with the connection, including in particular raster image data in use by the client program. The structure is defined (in part) as: @@ -135,7 +135,7 @@ A .B Point is a location in an Image (see below and -.IM draw (3) ), +.MR draw (3) ), such as the display, and is defined as: .IP .EX @@ -184,18 +184,18 @@ contains the coordinates of the first point beyond the rectangle. The .B Image data structure is defined in -.IM draw (3) . +.MR draw (3) . .PP A .B Font is a set of character images, indexed by runes (see -.IM utf (7) ). +.MR utf (7) ). The images are organized into .BR Subfonts , each containing the images for a small, contiguous set of runes. The detailed format of these data structures, which are described in detail in -.IM cachechars (3) , +.MR cachechars (3) , is immaterial for most applications. .B Font and @@ -210,7 +210,7 @@ and the distance from the top of the highest character to the bottom of the lowest character (and hence, the interline spacing). See -.IM cachechars (3) +.MR cachechars (3) for more details. .PP .I Buildfont @@ -221,7 +221,7 @@ returning a pointer that can be used by .B string (see -.IM draw (3) ) +.MR draw (3) ) to draw characters from the font. .I Openfont does the same, but reads the description @@ -231,7 +231,7 @@ frees a font. In contrast to Plan 9, font names in Plan 9 from User Space are a small language describing the desired font. See -.IM font (7) +.MR font (7) for details. .PP A @@ -274,7 +274,7 @@ structure representing the connection), (an .B Image representing the display memory itself or, if -.IM rio (1) +.MR rio (1) is running, the client's window), and .B font @@ -287,7 +287,7 @@ which is written to .B /dev/label if non-nil so that it can be used to identify the window when hidden (see -.IM rio (1) ). +.MR rio (1) ). The font is created by reading the named .I font file. If @@ -301,7 +301,7 @@ if is not set, it imports the default (usually minimal) font from the operating system. (See -.IM font (7) +.MR font (7) for a full discussion of font syntaxes.) The global .I font @@ -322,7 +322,7 @@ is nil, the library provides a default, called Another effect of .I initdraw is that it installs -.IM print (3) +.MR print (3) formats .I Pfmt and @@ -360,9 +360,9 @@ and files; and .I ref specifies the refresh function to be used to create the window, if running under -.IM rio (1) +.MR rio (1) (see -.IM window (3) ). +.MR window (3) ). .\" .PP .\" The function .\" .I newwindow @@ -435,11 +435,11 @@ by looking in to find the name of the window and opening it using .B namedimage (see -.IM allocimage (3) ). +.MR allocimage (3) ). The resulting window will be created using the refresh method .I ref (see -.IM window (3) ); +.MR window (3) ); this should almost always be .B Refnone because @@ -456,7 +456,7 @@ defining the window (or the overall display, if no window system is running); an a pointer to the .B Screen representing the root of the window's hierarchy. (See -.IM window (3) . +.MR window (3) . The overloading of the .B screen word is an unfortunate historical accident.) @@ -528,15 +528,15 @@ the window boundaries; otherwise is a no-op. .PP The graphics functions described in -.IM draw (3) , -.IM allocimage (3) , -.IM cachechars (3) , +.MR draw (3) , +.MR allocimage (3) , +.MR cachechars (3) , and -.IM subfont (3) +.MR subfont (3) are implemented by writing commands to files under .B /dev/draw (see -.IM draw (3) ); +.MR draw (3) ); the writes are buffered, so the functions may not take effect immediately. .I Flushimage flushes the buffer, doing all pending graphics operations. @@ -546,7 +546,7 @@ is non-zero, any changes are also copied from the `soft screen' (if any) in the driver to the visible frame buffer. The various allocation routines in the library flush automatically, as does the event package (see -.IM event (3) ); +.MR event (3) ); most programs do not need to call .IR flushimage . It returns \-1 on error. @@ -563,13 +563,13 @@ and .I chantostr convert between the channel descriptor strings used by -.IM image (7) +.MR image (7) and the internal .B ulong representation used by the graphics protocol (see -.IM draw (3) 's +.MR draw (3) 's .B b message). .B Chantostr @@ -599,7 +599,7 @@ if(getwindow(display, Refnone) < 0) .EE .PP To create and set up a new -.IM rio (1) +.MR rio (1) window, .IP .EX @@ -630,23 +630,23 @@ if(gengetwindow(display, "/tmp/winname", .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IM rio (1) , -.IM addpt (3) , -.IM allocimage (3) , -.IM cachechars (3) , -.IM subfont (3) , -.IM draw (3) , -.IM event (3) , -.IM frame (3) , -.IM print (3) , -.IM window (3) , -.IM draw (3) , +.MR rio (1) , +.MR addpt (3) , +.MR allocimage (3) , +.MR cachechars (3) , +.MR subfont (3) , +.MR draw (3) , +.MR event (3) , +.MR frame (3) , +.MR print (3) , +.MR window (3) , +.MR draw (3) , .\" .IR rio (4), -.IM image (7) , -.IM font (7) +.MR image (7) , +.MR font (7) .SH DIAGNOSTICS An error function may call -.IM errstr (3) +.MR errstr (3) for further diagnostics. .SH BUGS The names diff --git a/man/man3/html.3 b/man/man3/html.3 index f99fda1b4..b77fda919 100644 --- a/man/man3/html.3 +++ b/man/man3/html.3 @@ -1411,7 +1411,7 @@ would not otherwise fit), and .SH SOURCE .B \*9/src/libhtml .SH SEE ALSO -.IM fmt (1) +.MR fmt (1) .PP W3C World Wide Web Consortium, ``HTML 4.01 Specification''. diff --git a/man/man3/ioproc.3 b/man/man3/ioproc.3 index 2645a228f..38609d7b6 100644 --- a/man/man3/ioproc.3 +++ b/man/man3/ioproc.3 @@ -80,14 +80,14 @@ and execute the similarly named library or system calls (see -.IM close (2) , -.IM dial (3) , -.IM open (3) , -.IM read (3) , -.IM fcall (3) , -.IM sendfd (3) , +.MR close (2) , +.MR dial (3) , +.MR open (3) , +.MR read (3) , +.MR fcall (3) , +.MR sendfd (3) , and -.IM sleep (3) ) +.MR sleep (3) ) in the slave process associated with .IR io . It is an error to execute more than one call @@ -187,10 +187,10 @@ ioread(Ioproc *io, int fd, void *a, long n) .SH SOURCE .B \*9/src/libthread .SH SEE ALSO -.IM dial (3) , -.IM open (3) , -.IM read (3) , -.IM thread (3) +.MR dial (3) , +.MR open (3) , +.MR read (3) , +.MR thread (3) .SH BUGS .I Iointerrupt is currently unimplemented. diff --git a/man/man3/ip.3 b/man/man3/ip.3 index c8305dea4..da3855ed8 100644 --- a/man/man3/ip.3 +++ b/man/man3/ip.3 @@ -126,7 +126,7 @@ The string representation of Ethernet addresses is exactly .PP .I Eipfmt is a -.IM print (3) +.MR print (3) formatter for Ethernet (verb .BR E ) addresses, @@ -340,4 +340,4 @@ point to point. .SH SOURCE .B \*9/src/libip .SH SEE ALSO -.IM print (3) +.MR print (3) diff --git a/man/man3/isalpharune.3 b/man/man3/isalpharune.3 index eeaf3ebcb..f9b20a0c9 100644 --- a/man/man3/isalpharune.3 +++ b/man/man3/isalpharune.3 @@ -35,7 +35,7 @@ in particular a subset of their properties as defined in the Unicode standard. Unicode defines some characters as alphabetic and specifies three cases: upper, lower, and title. Analogously to -.IM isalpha (3) +.MR isalpha (3) for .SM ASCII\c , diff --git a/man/man3/keyboard.3 b/man/man3/keyboard.3 index 6c1bf026e..feedfd2e9 100644 --- a/man/man3/keyboard.3 +++ b/man/man3/keyboard.3 @@ -23,14 +23,14 @@ void closekeyboard(Keyboard *kc) .SH DESCRIPTION These functions access and control a keyboard interface for character-at-a-time I/O in a multi-threaded environment, usually in combination with -.IM mouse (3) . +.MR mouse (3) . They use the message-passing .B Channel interface in the threads library (see -.IM thread (3) ); +.MR thread (3) ); programs that wish a more event-driven, single-threaded approach should use -.IM event (3) . +.MR event (3) . .PP .I Initkeyboard opens a connection to the keyboard and returns a @@ -86,10 +86,10 @@ structure. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM draw (3) , -.IM event (3) , -.IM thread (3) . +.MR graphics (3) , +.MR draw (3) , +.MR event (3) , +.MR thread (3) . .SH BUGS Because the interface delivers complete runes, there is no way to report lesser actions such as diff --git a/man/man3/lock.3 b/man/man3/lock.3 index 31882bb0c..2dea7467c 100644 --- a/man/man3/lock.3 +++ b/man/man3/lock.3 @@ -80,7 +80,7 @@ are rendezvous points. Locks and rendezvous points have trivial implementations in programs not using the thread library (see -.IM thread (3) ), +.MR thread (3) ), since such programs have no concurrency. .PP Used carelessly, spin locks can be expensive and can easily generate deadlocks. diff --git a/man/man3/mach-cmd.3 b/man/man3/mach-cmd.3 index 08563eb75..a2b4462d5 100644 --- a/man/man3/mach-cmd.3 +++ b/man/man3/mach-cmd.3 @@ -64,7 +64,7 @@ fields) of all currently open headers (see .I symopen in -.IM mach-symbol (3) ). +.MR mach-symbol (3) ). When dynamically linked objects have been attached, they are present in this linked list, and therefore included in searches by @@ -73,7 +73,7 @@ and therefore included in searches by and .I findsym (see -.IM mach-symbol (3) ). +.MR mach-symbol (3) ). .TP .I corhdr The file header for the core dump, if any. @@ -118,9 +118,9 @@ loaded. uses all of these functions while parsing an argument vector as would be passed to a debugger like -.IM db (1) +.MR db (1) or -.IM acid (1) . +.MR acid (1) . It expects a list of executable files, core dump files, or process ids, given in any order. If extra arguments are given (for example, more than one executable, or both @@ -133,9 +133,9 @@ fills them in as best it can. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO -.IM mach (3) , -.IM mach-file (3) , -.IM mach-map (3) +.MR mach (3) , +.MR mach-file (3) , +.MR mach-map (3) .SH BUGS The interface needs to be changed to support multiple threads, each with its own register set. diff --git a/man/man3/mach-file.3 b/man/man3/mach-file.3 index 22a61aa0d..cd275c5e8 100644 --- a/man/man3/mach-file.3 +++ b/man/man3/mach-file.3 @@ -161,10 +161,10 @@ The memory at should be freed via .I free (see -.IM malloc (3) ) +.MR malloc (3) ) when no longer needed. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IM mach (3) , -.IM mach-map (3) +.MR mach (3) , +.MR mach-map (3) diff --git a/man/man3/mach-map.3 b/man/man3/mach-map.3 index 94e73a223..a0e274023 100644 --- a/man/man3/mach-map.3 +++ b/man/man3/mach-map.3 @@ -133,10 +133,10 @@ via data structures that provides access to an address space and register set. The functions described in -.IM mach-file (3) +.MR mach-file (3) are typically used to construct these maps. Related library functions described in -.IM mach-symbol (3) +.MR mach-symbol (3) provide similar access to symbol tables. .PP Each @@ -178,7 +178,7 @@ The .B rw function is most commonly used to provide access to executing processes via -.IM ptrace (2) +.MR ptrace (2) and to zeroed segments. .PP .I Allocmap @@ -346,7 +346,7 @@ such locations are useful for passing specific constants to functions expect locations, such as .I unwind (see -.IM mach-stack (3) ). +.MR mach-stack (3) ). .PP .I Loccmp compares two locations, returning negative, zero, or positive @@ -360,7 +360,7 @@ which are ordered before indirections. .PP .I Locfmt is a -.IM print (3) -verb +.MR print (3) -verb that formats a .B Loc structure @@ -371,7 +371,7 @@ Indirection locations are needed in some contexts (e.g., when using .I findlsym (see -.IM mach-symbol (3) )), +.MR mach-symbol (3) )), but bothersome in most. .I Locsimplify rewrites indirections as absolute memory addresses, by evaluating @@ -397,8 +397,8 @@ function families as necessary. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IM mach (3) , -.IM mach-file (3) +.MR mach (3) , +.MR mach-file (3) .SH DIAGNOSTICS These routines set .IR errstr . diff --git a/man/man3/mach-stack.3 b/man/man3/mach-stack.3 index abf413943..4c34abb15 100644 --- a/man/man3/mach-stack.3 +++ b/man/man3/mach-stack.3 @@ -68,7 +68,7 @@ a new .I rget function, and a symbol (see -.IM mach-symbol (3) ) +.MR mach-symbol (3) ) describing the current function (nil if no symbol is known). The value returned by the tracer @@ -180,6 +180,6 @@ trace(Map *map, ulong pc, ulong callerpc, .SH SOURCE .B \*9/src/libmach .SH SEE ALSO -.IM mach (3) +.MR mach (3) .SH BUGS Need to talk about Regs diff --git a/man/man3/mach-swap.3 b/man/man3/mach-swap.3 index 39b18ef9d..eda669117 100644 --- a/man/man3/mach-swap.3 +++ b/man/man3/mach-swap.3 @@ -114,4 +114,4 @@ and low 32-bits are in .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IM mach (3) +.MR mach (3) diff --git a/man/man3/mach-symbol.3 b/man/man3/mach-symbol.3 index fc7bbd281..a761a12b4 100644 --- a/man/man3/mach-symbol.3 +++ b/man/man3/mach-symbol.3 @@ -61,10 +61,10 @@ int fnbound(ulong pc, ulong bounds[2]) .SH DESCRIPTION These functions provide machine-independent access to the symbol table of an executable file or executing process. -.IM Mach (3) , -.IM mach-file (3) , +.MR Mach (3) , +.MR mach-file (3) , and -.IM mach-map (3) +.MR mach-map (3) describe additional library functions for accessing executable files and executing processes. .PP @@ -74,7 +74,7 @@ uses the data in the structure filled by .I crackhdr (see -.IM mach-file (3) ) +.MR mach-file (3) ) to initialize in-memory structures used to access the symbol tables contained in the file. .IR Symclose @@ -371,6 +371,6 @@ in the system error buffer where it is available via .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO" -.IM mach (3) , -.IM mach-file (3) , -.IM mach-map (3) +.MR mach (3) , +.MR mach-file (3) , +.MR mach-map (3) diff --git a/man/man3/mach.3 b/man/man3/mach.3 index 71742155c..bf260d581 100644 --- a/man/man3/mach.3 +++ b/man/man3/mach.3 @@ -40,7 +40,7 @@ points at the structure for the architecture being debugged. It is set implicitly by .I crackhdr (see -.IM mach-file (3) ) +.MR mach-file (3) ) and can be set explicitly by calling .I machbyname or @@ -66,31 +66,31 @@ Mac OS X). Other manual pages describe the library functions in detail. .PP -.IM Mach-cmd (3) +.MR Mach-cmd (3) describes some convenience routines for attaching to processes and core files. .PP -.IM Mach-file (3) +.MR Mach-file (3) describes the manipulation of binary files. .PP -.IM Mach-map (3) +.MR Mach-map (3) describes the interface to address spaces and register sets in executable files and executing programs. .PP -.IM Mach-stack (3) +.MR Mach-stack (3) describes support for unwinding the stack. .PP -.IM Mach-swap (3) +.MR Mach-swap (3) describes helper functions for accessing data in a particular byte order. .PP -.IM Mach-symbol (3) +.MR Mach-symbol (3) describes the interface to debugging symbol information. .SH SOURCE .B \*9/src/libmach .SH "SEE ALSO -.IM mach-file (3) , -.IM mach-map (3) , -.IM mach-stack (3) , -.IM mach-swap (3) , -.IM mach-symbol (3) +.MR mach-file (3) , +.MR mach-map (3) , +.MR mach-stack (3) , +.MR mach-swap (3) , +.MR mach-symbol (3) diff --git a/man/man3/malloc.3 b/man/man3/malloc.3 index 300b9c5b0..02498ab9b 100644 --- a/man/man3/malloc.3 +++ b/man/man3/malloc.3 @@ -132,8 +132,8 @@ the source of allocation. .SH SEE ALSO .I trump (in -.IM acid (1) ), -.IM getcallerpc (3) +.MR acid (1) ), +.MR getcallerpc (3) .SH DIAGNOSTICS .I Malloc, realloc and @@ -153,7 +153,7 @@ The library for .I acid can be used to obtain traces of malloc execution; see -.IM acid (1) . +.MR acid (1) . .SH BUGS The different specification of .I calloc @@ -182,4 +182,4 @@ are preprocessor macros defined as and .IR p9free ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/matrix.3 b/man/man3/matrix.3 index b66170efd..7d6c9e6b2 100644 --- a/man/man3/matrix.3 +++ b/man/man3/matrix.3 @@ -347,4 +347,4 @@ coordinates. .SH SOURCE .B \*9/src/libgeometry/matrix.c .SH "SEE ALSO -.IM arith3 (3) +.MR arith3 (3) diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3 index 89e073b92..8dad89d0b 100644 --- a/man/man3/memdraw.3 +++ b/man/man3/memdraw.3 @@ -168,7 +168,7 @@ type defines memory-resident rectangular pictures and the methods to draw upon t differ from .BR Image s (see -.IM draw (3) ) +.MR draw (3) ) in that they are manipulated directly in user memory rather than by RPCs to the .B /dev/draw @@ -176,7 +176,7 @@ hierarchy. The .Bmemdraw library is the basis for the kernel -.IM draw (3) +.MR draw (3) driver and also used by a number of programs that must manipulate images without a display. .PP @@ -273,7 +273,7 @@ images with a given rectangle and channel descriptor (see .B strtochan in -.IM graphics (3) ), +.MR graphics (3) ), creating a fresh .B Memdata structure and associated storage. @@ -294,7 +294,7 @@ writes a compressed representation of to file descriptor .IR fd . For more on bitmap formats, see -.IM image (7) . +.MR image (7) . .I Freememimage frees images returned by any of these routines. The @@ -326,7 +326,7 @@ and \-1 in case of an error. .I Memfillcolor fills an image with the given color, a 32-bit number as described in -.IM color (3) . +.MR color (3) . .PP .IR Memarc , .IR mempoly , @@ -344,7 +344,7 @@ are identical to the and .IR gendraw , routines described in -.IM draw (3) , +.MR draw (3) , except that they operate on .BR Memimage s rather than @@ -366,9 +366,9 @@ analogues of and .B string (see -.IM subfont (3) +.MR subfont (3) and -.IM graphics (3) ), +.MR graphics (3) ), except that they operate only on .BR Memsubfont s @@ -433,15 +433,15 @@ prints to a serial line rather than the screen, for obvious reasons. .SH SOURCE .B \*9/src/libmemdraw .SH SEE ALSO -.IM addpt (3) , -.IM color (3) , -.IM draw (3) , -.IM graphics (3) , -.IM memlayer (3) , -.IM stringsize (3) , -.IM subfont (3) , -.IM color (7) , -.IM utf (7) +.MR addpt (3) , +.MR color (3) , +.MR draw (3) , +.MR graphics (3) , +.MR memlayer (3) , +.MR stringsize (3) , +.MR subfont (3) , +.MR color (7) , +.MR utf (7) .SH BUGS .I Memimagestring is unusual in using a subfont rather than a font, diff --git a/man/man3/memlayer.3 b/man/man3/memlayer.3 index c13a72a45..d7f065100 100644 --- a/man/man3/memlayer.3 +++ b/man/man3/memlayer.3 @@ -97,18 +97,18 @@ int memunload(Memimage *i, Rectangle r, .PP .SH DESCRIPTION These functions build upon the -.IM memdraw (3) +.MR memdraw (3) interface to maintain overlapping graphical windows on in-memory images. They are used by the kernel to implement the windows interface presented by -.IM draw (3) +.MR draw (3) and -.IM window (3) +.MR window (3) and probably have little use outside of the kernel. .PP The basic function is to extend the definition of a .B Memimage (see -.IM memdraw (3) ) +.MR memdraw (3) ) to include overlapping windows defined by the .B Memlayer type. @@ -270,7 +270,7 @@ They have the signatures of and .I memimageline (see -.IM memdraw (3) ) +.MR memdraw (3) ) but accept .B Memlayer or @@ -294,12 +294,12 @@ bytes of data in .I buf are in compressed image format (see -.IM image (7) ). +.MR image (7) ). .SH SOURCE .B \*9/src/libmemlayer .SH SEE ALSO -.IM graphics (3) , -.IM memdraw (3) , -.IM stringsize (3) , -.IM window (3) , -.IM draw (3) +.MR graphics (3) , +.MR memdraw (3) , +.MR stringsize (3) , +.MR window (3) , +.MR draw (3) diff --git a/man/man3/memory.3 b/man/man3/memory.3 index fefb9ba3a..5f191dd4e 100644 --- a/man/man3/memory.3 +++ b/man/man3/memory.3 @@ -109,7 +109,7 @@ All these routines have portable C implementations in .\" Most also have machine-dependent assembly language implementations in .\" .BR \*9/lib9/$objtype . .SH SEE ALSO -.IM strcat (3) +.MR strcat (3) .SH BUGS ANSI C does not require .I memcpy diff --git a/man/man3/mouse.3 b/man/man3/mouse.3 index 6974dfa63..9b835891b 100644 --- a/man/man3/mouse.3 +++ b/man/man3/mouse.3 @@ -49,9 +49,9 @@ They use the message-passing .B Channel interface in the threads library (see -.IM thread (3) ); +.MR thread (3) ); programs that wish a more event-driven, single-threaded approach should use -.IM event (3) . +.MR event (3) . .PP The state of the mouse is recorded in a structure, .BR Mouse , @@ -107,7 +107,7 @@ are a naming the device file connected to the mouse and an .I Image (see -.IM draw (3) ) +.MR draw (3) ) on which the mouse will be visible. Typically the file is nil, @@ -136,7 +136,7 @@ The actual value sent may be discarded; the receipt of the message tells the program that it should call .B getwindow (see -.IM graphics (3) ) +.MR graphics (3) ) to reconnect to the window. .PP .I Readmouse @@ -152,7 +152,7 @@ or message sent on the channel. It calls .B flushimage (see -.IM graphics (3) ) +.MR graphics (3) ) before blocking, so any buffered graphics requests are displayed. .PP .I Closemouse @@ -174,14 +174,14 @@ is nil, the cursor is set to the default. The format of the cursor data is spelled out in .B and described in -.IM graphics (3) . +.MR graphics (3) . .PP .I Getrect returns the dimensions of a rectangle swept by the user, using the mouse, in the manner -.IM rio (1) +.MR rio (1) or -.IM sam (1) +.MR sam (1) uses to create a new window. The .I but @@ -220,7 +220,7 @@ struct Menu behaves the same as its namesake .I emenuhit described in -.IM event (3) , +.MR event (3) , with two exceptions. First, it uses a .B Mousectl @@ -230,7 +230,7 @@ it creates the menu as a true window on the .B Screen .I scr (see -.IM window (3) ), +.MR window (3) ), permitting the menu to be displayed in parallel with other activities on the display. If .I scr @@ -244,8 +244,8 @@ restoring the display when the menu is removed. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM draw (3) , -.IM event (3) , -.IM keyboard (3) , -.IM thread (3) . +.MR graphics (3) , +.MR draw (3) , +.MR event (3) , +.MR keyboard (3) , +.MR thread (3) . diff --git a/man/man3/mousescrollsize.3 b/man/man3/mousescrollsize.3 index 4595a68d5..c4c24b10b 100644 --- a/man/man3/mousescrollsize.3 +++ b/man/man3/mousescrollsize.3 @@ -28,15 +28,15 @@ causes a half-window scroll increment. .PP .I Mousescrollsize is used by -.IM 9term (1) +.MR 9term (1) and -.IM acme (1) +.MR acme (1) to set their scrolling behavior. .SH SOURCE .B \*9/src/libdraw/scroll.c .SH SEE ALSO -.IM 9term (1) , -.IM acme (1) +.MR 9term (1) , +.MR acme (1) .SH BUGS .I Libdraw expects up and down scroll wheel events to be expressed as clicks of mouse buttons 4 and 5, diff --git a/man/man3/mp.3 b/man/man3/mp.3 index ad61ed904..8ea365dc2 100644 --- a/man/man3/mp.3 +++ b/man/man3/mp.3 @@ -315,9 +315,9 @@ is the buffer is allocated. .I Mpfmt can be used with -.IM fmtinstall (3) +.MR fmtinstall (3) and -.IM print (3) +.MR print (3) to print hexadecimal representations of .BR mpint s. .PP diff --git a/man/man3/mux.3 b/man/man3/mux.3 index 180528b9e..ed8229403 100644 --- a/man/man3/mux.3 +++ b/man/man3/mux.3 @@ -123,7 +123,7 @@ nil if an error occurred. .I Muxprocs allocates new procs (see -.IM thread (3) ) +.MR thread (3) ) in which to run .I send and @@ -146,7 +146,7 @@ that need to remain active. .I Libmux also provides a non-blocking interface, useful for programs forced to use a -.IM select (3) -based +.MR select (3) -based main loop. .I Muxrpcstart runs the first half of @@ -176,7 +176,7 @@ with .SH SOURCE .B \*9/src/libmux .SH SEE ALSO -.IM thread (3) , +.MR thread (3) , .IR intro (9p) .SH BUGS .I Libmux diff --git a/man/man3/ndb.3 b/man/man3/ndb.3 index 2392f3ff5..413c11d62 100644 --- a/man/man3/ndb.3 +++ b/man/man3/ndb.3 @@ -88,13 +88,13 @@ Ndbtuple* ndbsubstitute(Ndbtuple *t, Ndbtuple *from, Ndbtuple *to); These routines are used by network administrative programs to search the network database. They operate on the database files described in -.IM ndb (7) . +.MR ndb (7) . .PP .I Ndbopen opens the database .I file and calls -.IM malloc (3) +.MR malloc (3) to allocate a buffer for it. If .I file @@ -128,7 +128,7 @@ is used to find each successive match. On a successful search both return a linked list of .I Ndbtuple structures acquired by -.IM malloc (3) +.MR malloc (3) that represent the attribute/value pairs in the entry. On failure they return zero. @@ -450,8 +450,8 @@ directory of network database files .SH SOURCE .B \*9/src/libndb .SH SEE ALSO -.IM ndb (1) -.IM ndb (7) +.MR ndb (1) +.MR ndb (7) .SH DIAGNOSTICS .IR Ndbgetvalue and diff --git a/man/man3/needstack.3 b/man/man3/needstack.3 index c19d15534..52fa8785a 100644 --- a/man/man3/needstack.3 +++ b/man/man3/needstack.3 @@ -45,7 +45,7 @@ is a no-op. .I Needstack should be thought of as a comment checked at run time, like -.IM assert (3) . +.MR assert (3) . .SH EXAMPLE The X Window library implementation of .I XLookupString @@ -57,7 +57,7 @@ before making calls to .IR XLookupString . If a thread (in this case, the keyboard-reading thread used inside the -.IM draw (3) +.MR draw (3) library) does not allocate a large enough stack, the problem is diagnosed immediately rather than left to corrupt memory. @@ -66,4 +66,4 @@ immediately rather than left to corrupt memory. .br .B \*9/src/libthread .SH SEE ALSO -.IM thread (3) +.MR thread (3) diff --git a/man/man3/notify.3 b/man/man3/notify.3 index 269fe4b07..9f2efb6db 100644 --- a/man/man3/notify.3 +++ b/man/man3/notify.3 @@ -33,12 +33,12 @@ or writing on a closed pipe, a is posted to communicate the exception. A note may also be posted by another process via -.IM postnote (3) . +.MR postnote (3) . On Unix, notes are implemented as signals. .PP When a note is received, the action taken depends on the note. See -.IM signal (7) +.MR signal (7) for the full description of the defaults. .PP The default actions may be overridden. @@ -53,10 +53,10 @@ replaces the previous handler, if any. An argument of zero cancels a previous handler, restoring the default action. A -.IM fork (2) +.MR fork (2) system call leaves the handler registered in both the parent and the child; -.IM exec (3) +.MR exec (3) restores the default behavior. Handlers may not perform floating point operations. .PP @@ -112,17 +112,17 @@ set up with using the .I notejmp function (see -.IM setjmp (3) ). +.MR setjmp (3) ). .PP Unix provides a fixed set of notes (typically there are 32) called .IR signals . It also allows a process to block certain notes from being delivered (see -.IM sigprocmask (2) ) +.MR sigprocmask (2) ) and to ignore certain notes by setting the signal hander to the special value .B SIG_IGN (see -.IM signal (2) ). +.MR signal (2) ). .I Noteenable and .I notedisable @@ -137,7 +137,7 @@ is called upon receipt of the note; if the handler is not called, the note is di Regardless of the origin of the note or the presence of a handler, if the process is being debugged (see -.IM ptrace (2) ) +.MR ptrace (2) ) the arrival of a note puts the process in the .B Stopped state and awakens the debugger. @@ -252,7 +252,7 @@ are usually generated by the operating system. .br .B \*9/src/lib9/atnotify.c .SH SEE ALSO -.IM intro (3) , +.MR intro (3) , .I notejmp in -.IM setjmp (3) +.MR setjmp (3) diff --git a/man/man3/open.3 b/man/man3/open.3 index adc38feb1..d4b2e2725 100644 --- a/man/man3/open.3 +++ b/man/man3/open.3 @@ -34,7 +34,7 @@ says to truncate the file to zero length before opening it; .B OCEXEC says to close the file when an -.IM exec (3) +.MR exec (3) or .I execl system call is made; @@ -48,7 +48,7 @@ are always appended to the end of the file. fails if the file does not exist or the user does not have permission to open it for the requested purpose (see -.IM stat (3) +.MR stat (3) for a description of permissions). The user must have write permission on the .I file @@ -61,7 +61,7 @@ system call (unlike the implicit .I open in -.IM exec (3) ), +.MR exec (3) ), .B OEXEC is actually identical to .BR OREAD . @@ -143,8 +143,8 @@ allows the file descriptor to be reused. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IM intro (3) , -.IM stat (3) +.MR intro (3) , +.MR stat (3) .SH DIAGNOSTICS These functions set .IR errstr . @@ -169,4 +169,4 @@ are preprocessor macros defined as and .IR p9create ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/opentemp.3 b/man/man3/opentemp.3 index 33c0b060a..f105a57fd 100644 --- a/man/man3/opentemp.3 +++ b/man/man3/opentemp.3 @@ -25,7 +25,7 @@ to .L z are tried until the name of a file that does not yet exist (see -.IM access (2) ) +.MR access (2) ) is generated. .I Opentemp then opens the file for the given @@ -49,4 +49,4 @@ will never return the same name. .SH "SEE ALSO .I create in -.IM open (3) +.MR open (3) diff --git a/man/man3/pipe.3 b/man/man3/pipe.3 index c134eaa27..ef4de3132 100644 --- a/man/man3/pipe.3 +++ b/man/man3/pipe.3 @@ -25,7 +25,7 @@ is available for reading from After the pipe has been established, cooperating processes created by subsequent -.IM fork (2) +.MR fork (2) calls may pass data through the pipe with .I read @@ -53,14 +53,14 @@ calls. .\" .IR stat (3)). .PP When all the data has been read from a pipe and the writer has closed the pipe or exited, -.IM read (3) +.MR read (3) will return 0 bytes. Writes to a pipe with no reader will generate a note .BR "sys: write on closed pipe" . .SH SOURCE .B \*9/src/lib9/pipe.c .SH SEE ALSO -.IM intro (3) , -.IM read (3) +.MR intro (3) , +.MR read (3) .SH DIAGNOSTICS Sets .IR errstr . @@ -79,7 +79,7 @@ Unix pipes are not guaranteed to be bidirectional. In order to ensure a bidirectional channel, .I p9pipe creates Unix domain sockets via the -.IM socketpair (2) +.MR socketpair (2) instead of Unix pipes. .PP The implementation of pipes as Unix domain sockets @@ -89,11 +89,11 @@ Unix's dup device. If a Unix domain socket is open as file descriptor 0, some implementations disallow the opening of .BR /dev/fd/0 ; instead one must -.IM connect (2) +.MR connect (2) to it. If this functionality is important (as it is for -.IM rc (1) ), +.MR rc (1) ), one must .B #undef .B pipe diff --git a/man/man3/plumb.3 b/man/man3/plumb.3 index 28185a882..409c40bc2 100644 --- a/man/man3/plumb.3 +++ b/man/man3/plumb.3 @@ -68,7 +68,7 @@ Plumbmsg* plumbrecvfid(CFid *fid) int plumbsendtofid(CFid *fid, Plumbmsg *m) .SH DESCRIPTION These routines manipulate -.IM plumb (7) +.MR plumb (7) messages, transmitting them, receiving them, and converting them between text and these data structures: .IP @@ -99,7 +99,7 @@ struct Plumbattr opens the named plumb .IR port , using -.IM open (3) +.MR open (3) mode .IR omode . If @@ -108,11 +108,11 @@ begins with a slash, it is taken as a literal file name; otherwise .I plumbopen searches for the location of the -.IM plumber (4) +.MR plumber (4) service and opens the port there. .PP For programs using the -.IM event (3) +.MR event (3) interface, .I eplumb registers, using the given @@ -121,9 +121,9 @@ receipt of messages from the named .IR port . .PP The library mounts the -.IM plumber (4) +.MR plumber (4) service on demand (using the -.IM 9pclient (3) ) +.MR 9pclient (3) ) library and reuses the mount instance for future calls to .IR plumbopen . @@ -157,7 +157,7 @@ to frees all the data associated with the message .IR m , all the components of which must therefore have been allocated with -.IM malloc (3) . +.MR malloc (3) . .PP .I Plumbrecv returns the next message available on the file descriptor @@ -259,7 +259,7 @@ The file descriptor returned by is created with .I fsopenfd (see -.IM 9pclient (3) ), +.MR 9pclient (3) ), which masks information about read and write errors. This is acceptable for use in .I plumbrecv @@ -276,10 +276,10 @@ that preserves the exact error details. .SH SOURCE .B \*9/src/libplumb .SH SEE ALSO -.IM plumb (1) , -.IM event (3) , -.IM plumber (4) , -.IM plumb (7) +.MR plumb (1) , +.MR event (3) , +.MR plumber (4) , +.MR plumb (7) .SH DIAGNOSTICS When appropriate, including when a .I plumbsend diff --git a/man/man3/post9pservice.3 b/man/man3/post9pservice.3 index 4bf1a68b1..5eeae234f 100644 --- a/man/man3/post9pservice.3 +++ b/man/man3/post9pservice.3 @@ -11,11 +11,11 @@ int post9pservice(int fd, char *name, char *mtpt) .SH DESCRIPTION .I Post9pservice invokes -.IM 9pserve (4) +.MR 9pserve (4) to post a new 9P service in the current ``name space'' (see -.IM intro (4) ) +.MR intro (4) ) named .IR name . Clients connecting to the posted service @@ -30,10 +30,10 @@ is non-nil, mounts the service on .IR mtpt , using -.IM 9pfuse (4) . +.MR 9pfuse (4) . .SH "SEE ALSO -.IM intro (4) , -.IM 9pfuse (4) , -.IM 9pserve (4) +.MR intro (4) , +.MR 9pfuse (4) , +.MR 9pserve (4) .SH SOURCE .B \*9/src/lib9/post9p.c diff --git a/man/man3/postnote.3 b/man/man3/postnote.3 index 3dd7796d0..907710a1f 100644 --- a/man/man3/postnote.3 +++ b/man/man3/postnote.3 @@ -38,8 +38,8 @@ Returns zero if the write succeeds, otherwise \-1. .SH SOURCE .B \*9/src/lib9/postnote.c .SH "SEE ALSO" -.IM notify (3) , -.IM intro (3) +.MR notify (3) , +.MR intro (3) .SH DIAGNOSTICS Sets .IR errstr . diff --git a/man/man3/prime.3 b/man/man3/prime.3 index 4e4987d3f..d364b30cb 100644 --- a/man/man3/prime.3 +++ b/man/man3/prime.3 @@ -93,8 +93,8 @@ slow algorithm. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM aes (3) -.IM blowfish (3) , -.IM des (3) , -.IM elgamal (3) , -.IM rsa (3) , +.MR aes (3) +.MR blowfish (3) , +.MR des (3) , +.MR elgamal (3) , +.MR rsa (3) , diff --git a/man/man3/print.3 b/man/man3/print.3 index 997b5cb3a..452ed7c81 100644 --- a/man/man3/print.3 +++ b/man/man3/print.3 @@ -67,7 +67,7 @@ writes to the named output file descriptor: a buffered form is described in -.IM bio (3) . +.MR bio (3) . .I Sprint places text followed by the NUL character @@ -104,7 +104,7 @@ is like .IR sprint , except that it prints into and returns a string of the required length, which is allocated by -.IM malloc (3) . +.MR malloc (3) . .PP The routines .IR runesprint , @@ -361,7 +361,7 @@ The .B S verb is similar, but it interprets its pointer as an array of runes (see -.IM utf (7) ); +.MR utf (7) ); the runes are converted to .SM UTF before output. @@ -389,10 +389,10 @@ but that will change if pointers and integers are different sizes. The .B r verb takes no arguments; it copies the error string returned by a call to -.IM errstr (3) . +.MR errstr (3) . .PP Custom verbs may be installed using -.IM fmtinstall (3) . +.MR fmtinstall (3) . .SH EXAMPLE This function prints an error message with a variable number of arguments and then quits. @@ -415,9 +415,9 @@ void fatal(char *msg, ...) .SH SOURCE .B \*9/src/lib9/fmt .SH SEE ALSO -.IM fmtinstall (3) , -.IM fprintf (3) , -.IM utf (7) +.MR fmtinstall (3) , +.MR fprintf (3) , +.MR utf (7) .SH DIAGNOSTICS Routines that write to a file descriptor or call .IR malloc @@ -425,7 +425,7 @@ set .IR errstr . .SH BUGS The formatting is close to that specified for ANSI -.IM fprintf (3) ; +.MR fprintf (3) ; the main difference is that .B b and diff --git a/man/man3/proto.3 b/man/man3/proto.3 index eceb63813..571b932e6 100644 --- a/man/man3/proto.3 +++ b/man/man3/proto.3 @@ -127,6 +127,6 @@ generic prototype file. .SH SOURCE .B \*9/src/libdisk/proto.c .SH SEE ALSO -.IM mk9660 (1) , +.MR mk9660 (1) , Plan 9's .IR mkfs (8) diff --git a/man/man3/pushtls.3 b/man/man3/pushtls.3 index 21730d337..7a086f00e 100644 --- a/man/man3/pushtls.3 +++ b/man/man3/pushtls.3 @@ -108,7 +108,7 @@ used by a client to resume a previously negotiated security association. On output, the connection directory is set, as with .B listen (see -.IM dial (3) ). +.MR dial (3) ). The input .I cert is freed and a freshly allocated copy of the remote's certificate @@ -149,7 +149,7 @@ The private key corresponding to .I cert.pem should have been previously loaded into factotum. (See -.IM rsa (3) +.MR rsa (3) .\" XXX should be rsa(8) for more about key generation.) By setting @@ -175,8 +175,8 @@ PEM certificate files .\" .br .B \*9/src/libsec/port .SH "SEE ALSO" -.IM dial (3) , -.IM thumbprint (7) ; +.MR dial (3) , +.MR thumbprint (7) ; Plan 9's .IR factotum (4) and diff --git a/man/man3/qball.3 b/man/man3/qball.3 index 785158c69..a5a67a790 100644 --- a/man/man3/qball.3 +++ b/man/man3/qball.3 @@ -68,7 +68,7 @@ and normal to the axis. .SH SOURCE .B \*9/src/libgeometry/qball.c .SH SEE ALSO -.IM quaternion (3) +.MR quaternion (3) .br Ken Shoemake, ``Animating Rotation with Quaternion Curves'', diff --git a/man/man3/quaternion.3 b/man/man3/quaternion.3 index f51a1e7f2..31b59b90f 100644 --- a/man/man3/quaternion.3 +++ b/man/man3/quaternion.3 @@ -121,7 +121,7 @@ The following routines operate on rotations or orientations represented as unit .TP .B mtoq Convert a rotation matrix (see -.IM matrix (3) ) +.MR matrix (3) ) to a unit quaternion. .TP .B qtom @@ -148,12 +148,12 @@ This is just a rotation about the same axis by half the angle. .SH SOURCE .B \*9/src/libgeometry/quaternion.c .SH SEE ALSO -.IM matrix (3) , -.IM qball (3) +.MR matrix (3) , +.MR qball (3) .SH BUGS To avoid name conflicts with NetBSD, .I qdiv is a preprocessor macro defined as .IR p9qdiv ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/quote.3 b/man/man3/quote.3 index d34e4893d..30e85bdf5 100644 --- a/man/man3/quote.3 +++ b/man/man3/quote.3 @@ -58,10 +58,10 @@ The empty string is represented by two quotes, The first four functions act as variants of .B strdup (see -.IM strcat (3) ). +.MR strcat (3) ). Each returns a freshly allocated copy of the string, created using -.IM malloc (3) . +.MR malloc (3) . .I Quotestrdup returns a quoted copy of .IR s , @@ -75,7 +75,7 @@ The versions of these functions do the same for .CW Rune strings (see -.IM runestrcat (3) ). +.MR runestrcat (3) ). .PP The string returned by .I quotestrdup @@ -124,13 +124,13 @@ blanks, control characters, and quotes are always quoted. is provided as a .I doquote function that flags any character special to -.IM rc (1) . +.MR rc (1) . .PP .I Quotestrfmt and .I quoterunestrfmt are -.IM print (3) +.MR print (3) formatting routines that produce quoted strings as output. They may be installed by hand, but .I quotefmtinstall @@ -154,21 +154,21 @@ statements so the compiler can type-check uses of and .B %Q in -.IM print (3) +.MR print (3) format strings. .SH SOURCE .B \*9/src/lib9/quote.c .br .B \*9/src/lib9/fmt/fmtquote.c .SH "SEE ALSO -.IM rc (1) , -.IM malloc (3) , -.IM print (3) , -.IM strcat (3) +.MR rc (1) , +.MR malloc (3) , +.MR print (3) , +.MR strcat (3) .SH BUGS Because it is provided by the format library, .I doquote is a preprocessor macro defined as .IR fmtdoquote ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/rand.3 b/man/man3/rand.3 index 8d35e444b..ba7ef97f8 100644 --- a/man/man3/rand.3 +++ b/man/man3/rand.3 @@ -125,7 +125,7 @@ truly random bytes read from .PP .I Prng uses the native -.IM rand (3) +.MR rand (3) pseudo-random number generator to fill the buffer. Used with .IR srand , this function can produce a reproducible stream of pseudo random @@ -138,7 +138,7 @@ and may be passed to .I mprand (see -.IM mp (3) ). +.MR mp (3) ). .PP .I Fastrand uses @@ -161,7 +161,7 @@ to return a uniform .B \*9/src/libsec/port .SH "SEE ALSO .\" .IR cons (3), -.IM mp (3) +.MR mp (3) .SH BUGS .I Truerand and @@ -181,7 +181,7 @@ are preprocessor macros defined as .IR p9lrand , and so on; see -.IM intro (3) . +.MR intro (3) . .ie \n(HT .ds HT " .el .ds HT " (see HTML-formatted man page for link) .PP diff --git a/man/man3/rc4.3 b/man/man3/rc4.3 index 1b7888d9d..60849150f 100644 --- a/man/man3/rc4.3 +++ b/man/man3/rc4.3 @@ -43,13 +43,13 @@ structure keeps track of the algorithm. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM blowfish (3) , -.IM des (3) , -.IM dsa (3) , -.IM elgamal (3) , -.IM rsa (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR blowfish (3) , +.MR des (3) , +.MR dsa (3) , +.MR elgamal (3) , +.MR rsa (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) diff --git a/man/man3/read.3 b/man/man3/read.3 index a176ad6d9..6fd9feb02 100644 --- a/man/man3/read.3 +++ b/man/man3/read.3 @@ -65,7 +65,7 @@ if this is not the same as requested. and .I Pwrite equivalent to a -.IM seek (3) +.MR seek (3) to .I offset followed by a @@ -83,10 +83,10 @@ without interference. .SH SOURCE .B \*9/src/lib9/readn.c .SH SEE ALSO -.IM intro (3) , +.MR intro (3) , .IR open (3), -.IM dup (3) , -.IM pipe (3) +.MR dup (3) , +.MR pipe (3) .SH DIAGNOSTICS These functions set .IR errstr . diff --git a/man/man3/readcolmap.3 b/man/man3/readcolmap.3 index d559cdabe..f0c048653 100644 --- a/man/man3/readcolmap.3 +++ b/man/man3/readcolmap.3 @@ -63,14 +63,14 @@ Both return 0 on success, or \-1 on error, setting .PP Changing the hardware color map does not change the color map used by the -.IM draw (3) +.MR draw (3) operator to convert between mapped and true color or greyscale images, which is described in -.IM color (7) . +.MR color (7) . .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IM graphics (3) , -.IM draw (3) , -.IM color (7) +.MR graphics (3) , +.MR draw (3) , +.MR color (7) diff --git a/man/man3/readcons.3 b/man/man3/readcons.3 index cf2df9bad..9deaa44ef 100644 --- a/man/man3/readcons.3 +++ b/man/man3/readcons.3 @@ -31,7 +31,7 @@ is non-zero, the input is not echoed to the screen. A stripped-down version of .I netkey (see -.IM passwd (1) ): +.MR passwd (1) ): .IP .EX pass = readcons("password", nil, 1); diff --git a/man/man3/regexp.3 b/man/man3/regexp.3 index a7a5ac8b1..854ad9967 100644 --- a/man/man3/regexp.3 +++ b/man/man3/regexp.3 @@ -42,11 +42,11 @@ compiles a regular expression and returns a pointer to the generated description. The space is allocated by -.IM malloc (3) +.MR malloc (3) and may be released by .IR free . Regular expressions are exactly as in -.IM regexp (7) . +.MR regexp (7) . .PP .I Regcomplit is like @@ -196,7 +196,7 @@ array elements should be used. .SH SOURCE .B \*9/src/libregexp .SH "SEE ALSO" -.IM grep (1) +.MR grep (1) .SH DIAGNOSTICS .I Regcomp returns diff --git a/man/man3/rfork.3 b/man/man3/rfork.3 index df5048f77..102ec3b34 100644 --- a/man/man3/rfork.3 +++ b/man/man3/rfork.3 @@ -15,14 +15,14 @@ int rfork(int flags) is a partial implementation of the Plan 9 system call. It can be used to manipulate some process state and to create new processes a la -.IM fork (2) . +.MR fork (2) . It cannot be used to create shared-memory processes (Plan 9's .B RFMEM flag); for that functionality use .I proccreate (see -.IM thread (3) ). +.MR thread (3) ). .PP The .I flags @@ -45,7 +45,7 @@ If set, the child process will be dissociated from the parent. Upon exit the child will leave no .B Waitmsg (see -.IM wait (3) ) +.MR wait (3) ) for the parent to collect. .\" .TP .\" .B RFNAMEG @@ -81,9 +81,9 @@ for the parent to collect. Each process is a member of a group of processes that all receive notes when a note is sent to the group (see -.IM postnote (3) +.MR postnote (3) and -.IM signal (2) ). +.MR signal (2) ). The group of a new process is by default the same as its parent, but if .B RFNOTEG is set (regardless of @@ -154,7 +154,7 @@ will sleep, if necessary, until required process resources are available. Calling .B rfork(RFFDG|RFPROC) is equivalent to calling -.IM fork (2) . +.MR fork (2) . .SH SOURCE .B \*9/src/lib9/rfork.c .SH DIAGNOSTICS diff --git a/man/man3/rsa.3 b/man/man3/rsa.3 index 8bea1aab4..35145bda0 100644 --- a/man/man3/rsa.3 +++ b/man/man3/rsa.3 @@ -197,7 +197,7 @@ The subject line is conventionally of the form using the quoting conventions of .I tokenize (see -.IM getfields (3) ). +.MR getfields (3) ). .PP .I X509req creates an X.509 certification request. @@ -241,14 +241,14 @@ struct PEMChain .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM mp (3) , -.IM aes (3) , -.IM blowfish (3) , -.IM des (3) , -.IM dsa (3) , -.IM elgamal (3) , -.IM rc4 (3) , -.IM sechash (3) , -.IM prime (3) , -.IM rand (3) +.MR mp (3) , +.MR aes (3) , +.MR blowfish (3) , +.MR des (3) , +.MR dsa (3) , +.MR elgamal (3) , +.MR rc4 (3) , +.MR sechash (3) , +.MR prime (3) , +.MR rand (3) .\" .IR pem (8) diff --git a/man/man3/rune.3 b/man/man3/rune.3 index d4fcf89d1..2cff02e37 100644 --- a/man/man3/rune.3 +++ b/man/man3/rune.3 @@ -189,5 +189,5 @@ returns .br .B \*9/src/lib9/utf/utfrune.c .SH SEE ALSO -.IM utf (7) , -.IM tcs (1) +.MR utf (7) , +.MR tcs (1) diff --git a/man/man3/runestrcat.3 b/man/man3/runestrcat.3 index eff637e41..42686f10f 100644 --- a/man/man3/runestrcat.3 +++ b/man/man3/runestrcat.3 @@ -56,12 +56,12 @@ Rune* runestrstr(Rune *s1, Rune *s2) .SH DESCRIPTION These functions are rune string analogues of the corresponding functions in -.IM strcat (3) . +.MR strcat (3) . .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IM memory (3) , -.IM rune (3) , -.IM strcat (3) +.MR memory (3) , +.MR rune (3) , +.MR strcat (3) .SH BUGS The outcome of overlapping moves varies among implementations. diff --git a/man/man3/searchpath.3 b/man/man3/searchpath.3 index 77c91f94c..10b741ebb 100644 --- a/man/man3/searchpath.3 +++ b/man/man3/searchpath.3 @@ -13,9 +13,9 @@ char* searchpath(char *name) searches for the executable .I name in the same way that -.IM sh (1) +.MR sh (1) and -.IM rc (1) +.MR rc (1) do. .PP The environment variable @@ -32,9 +32,9 @@ returns a pointer to a malloced string containing a path or simply .IR name ) suitable for use in -.IM open (3) +.MR open (3) or -.IM exec (3) . +.MR exec (3) . .PP If .I name diff --git a/man/man3/sechash.3 b/man/man3/sechash.3 index a7c6970d4..cabfbce33 100644 --- a/man/man3/sechash.3 +++ b/man/man3/sechash.3 @@ -138,14 +138,14 @@ and .I sha1unpickle unmarshal a pickled digest. All four routines return a pointer to a newly -.IM malloc (3) 'd +.MR malloc (3) 'd object. .SH SOURCE .B \*9/src/libsec .SH SEE ALSO -.IM aes (3) , -.IM blowfish (3) , -.IM des (3) , -.IM elgamal (3) , -.IM rc4 (3) , -.IM rsa (3) +.MR aes (3) , +.MR blowfish (3) , +.MR des (3) , +.MR elgamal (3) , +.MR rc4 (3) , +.MR rsa (3) diff --git a/man/man3/seek.3 b/man/man3/seek.3 index a95f37ff4..7282c3663 100644 --- a/man/man3/seek.3 +++ b/man/man3/seek.3 @@ -39,8 +39,8 @@ Seeking in a pipe is a no-op. .SH SOURCE .B \*9/src/lib9/seek.c .SH SEE ALSO -.IM intro (3) , -.IM open (3) +.MR intro (3) , +.MR open (3) .SH DIAGNOSTICS Sets .IR errstr . @@ -50,4 +50,4 @@ To avoid name conflicts with the underlying system, is a preprocessor macro defined as .IR p9seek ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/sendfd.3 b/man/man3/sendfd.3 index 82fd8a499..fe6391c2d 100644 --- a/man/man3/sendfd.3 +++ b/man/man3/sendfd.3 @@ -20,14 +20,14 @@ and can be used to pass an open file descriptor over a Unix domain socket from one process to another. Since -.IM pipe (3) +.MR pipe (3) is implemented with -.IM socketpair (2) +.MR socketpair (2) instead of -.IM pipe (2) , +.MR pipe (2) , .I socket can be a file descriptor obtained from -.IM pipe (3) . +.MR pipe (3) . .PP .I Sendfd sends the file descriptor @@ -51,7 +51,7 @@ will not. .SH SOURCE .B \*9/src/lib9/sendfd.c .SH SEE ALSO -.IM socketpair (2) , +.MR socketpair (2) , .I sendmsg in -.IM send (2) +.MR send (2) diff --git a/man/man3/setjmp.3 b/man/man3/setjmp.3 index 16fb0387e..33573ba88 100644 --- a/man/man3/setjmp.3 +++ b/man/man3/setjmp.3 @@ -46,7 +46,7 @@ was called. is the same as .I longjmp except that it is to be called from within a note handler (see -.IM notify (3) ). +.MR notify (3) ). The .I uregs argument should be the first argument passed to the note handler. @@ -58,7 +58,7 @@ can also be used to switch stacks. .SH SOURCE .B \*9/src/lib9/jmp.c .SH SEE ALSO -.IM notify (3) +.MR notify (3) .SH BUGS .PP .I Notejmp @@ -78,7 +78,7 @@ are preprocessor macros defined as and .IR p9jmp_buf ; see -.IM intro (3) . +.MR intro (3) . .PP .I P9setjmp is implemented as a preprocessor macro that calls diff --git a/man/man3/sleep.3 b/man/man3/sleep.3 index 0bccc15f8..fabd2b4b9 100644 --- a/man/man3/sleep.3 +++ b/man/man3/sleep.3 @@ -27,7 +27,7 @@ Sleep returns \-1 if interrupted, 0 otherwise. causes an .B alarm note (see -.IM notify (3) ) +.MR notify (3) ) to be sent to the invoking process after the number of milliseconds given by the argument. Successive calls to @@ -39,7 +39,7 @@ the alarm clock. .SH SOURCE .B \*9/src/lib9/sleep.c .SH SEE ALSO -.IM intro (3) +.MR intro (3) .SH DIAGNOSTICS These functions set .IR errstr . @@ -53,4 +53,4 @@ are preprocessor macros defined as and .IR p9alarm ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/stat.3 b/man/man3/stat.3 index 253833f64..3a652d108 100644 --- a/man/man3/stat.3 +++ b/man/man3/stat.3 @@ -105,7 +105,7 @@ struct Dir { .EE .PP The returned structure is allocated by -.IM malloc (3) ; +.MR malloc (3) ; freeing it also frees the associated strings. .PP This structure and @@ -283,9 +283,9 @@ to retrieve the initial values first. .SH SOURCE .B \*9/src/lib9/dirstat.c .SH SEE ALSO -.IM intro (3) , -.IM fcall (3) , -.IM dirread (3) , +.MR intro (3) , +.MR fcall (3) , +.MR dirread (3) , .IR stat (9p) .SH DIAGNOSTICS The @@ -305,7 +305,7 @@ or is too short for the returned data, the return value will be .B BIT16SZ (see -.IM fcall (3) ) +.MR fcall (3) ) and the two bytes returned will contain the initial count field of the returned data; diff --git a/man/man3/strcat.3 b/man/man3/strcat.3 index 3cf294778..7dcf51f70 100644 --- a/man/man3/strcat.3 +++ b/man/man3/strcat.3 @@ -222,7 +222,7 @@ is returned. returns a pointer to a distinct copy of the null-terminated string .I s in space obtained from -.IM malloc (3) +.MR malloc (3) or .L 0 if no space can be obtained. @@ -244,14 +244,14 @@ operates analogously, but ignores ASCII case differences when comparing strings. .SH SOURCE .B \*9/src/lib9 .SH SEE ALSO -.IM memory (3) , -.IM rune (3) , -.IM runestrcat (3) +.MR memory (3) , +.MR rune (3) , +.MR runestrcat (3) .SH BUGS These routines know nothing about .SM UTF. Use the routines in -.IM rune (3) +.MR rune (3) as appropriate. Note, however, that the definition of .SM UTF diff --git a/man/man3/string.3 b/man/man3/string.3 index 7862bb280..301185f75 100644 --- a/man/man3/string.3 +++ b/man/man3/string.3 @@ -268,4 +268,4 @@ The input stack has a maximum depth of 32 nested include files. .SH SOURCE .B \*9/src/libString .SH SEE ALSO -.IM bio (3) +.MR bio (3) diff --git a/man/man3/stringsize.3 b/man/man3/stringsize.3 index 3ad0054cf..c0639ab34 100644 --- a/man/man3/stringsize.3 +++ b/man/man3/stringsize.3 @@ -57,13 +57,13 @@ are analogous, but accept an array of runes rather than .SH SOURCE .B \*9/src/libdraw .SH "SEE ALSO" -.IM addpt (3) , -.IM cachechars (3) , -.IM subfont (3) , -.IM draw (3) , -.IM draw (3) , -.IM image (7) , -.IM font (7) +.MR addpt (3) , +.MR cachechars (3) , +.MR subfont (3) , +.MR draw (3) , +.MR draw (3) , +.MR image (7) , +.MR font (7) .SH DIAGNOSTICS Because strings are loaded dynamically, these routines may generate I/O to the server and produce calls to the graphics error function. diff --git a/man/man3/subfont.3 b/man/man3/subfont.3 index e321b7da5..1de30246e 100644 --- a/man/man3/subfont.3 +++ b/man/man3/subfont.3 @@ -53,13 +53,13 @@ Font* mkfont(Subfont *f, Rune min) .SH DESCRIPTION Subfonts are the components of fonts that hold the character images. A font comprises an array of subfonts; see -.IM cachechars (3) . +.MR cachechars (3) . A new .B Subfont is allocated and initialized with .IR allocsubfont . See -.IM cachechars (3) +.MR cachechars (3) for the meaning of .IR n , .IR height , @@ -81,7 +81,7 @@ The appropriate fields of the returned structure are set to the passed arguments, and the image is registered as a subfont with the graphics device -.IM draw (3) . +.MR draw (3) . .I Allocsubfont returns 0 on failure. .PP @@ -97,7 +97,7 @@ on if .B f->info was not allocated by -.IM malloc (3) +.MR malloc (3) it should be zeroed before calling .IR subffree . .PP @@ -150,7 +150,7 @@ Although it is principally a routine internal to the library, may be substituted by the application to provide a less file-oriented subfont naming scheme. .PP The format of a subfont file is described in -.IM font (7) . +.MR font (7) . Briefly, it contains a image with all the characters in it, followed by a subfont header, followed by character information. .I Readsubfont @@ -181,13 +181,13 @@ the part of a subfont file that comes after the image. It should be preceded by a call to .IR writeimage (see -.IM allocimage (3) ). +.MR allocimage (3) ). .PP .I Stringsubfont is analogous to .B string (see -.IM draw (3) ) +.MR draw (3) ) for subfonts. Rather than use the underlying font caching primitives, it calls .B draw @@ -224,12 +224,12 @@ bitmap font file tree .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM allocimage (3) , -.IM draw (3) , -.IM cachechars (3) , -.IM image (7) , -.IM font (7) +.MR graphics (3) , +.MR allocimage (3) , +.MR draw (3) , +.MR cachechars (3) , +.MR image (7) , +.MR font (7) .SH DIAGNOSTICS All of the functions use the graphics error function (see -.IM graphics (3) ). +.MR graphics (3) ). diff --git a/man/man3/sysfatal.3 b/man/man3/sysfatal.3 index 8684ea127..210136a97 100644 --- a/man/man3/sysfatal.3 +++ b/man/man3/sysfatal.3 @@ -16,17 +16,17 @@ void sysfatal(char *fmt, ...) prints to standard error the name of the running program, a colon and a space, the message described by the -.IM print (3) +.MR print (3) format string .I fmt and subsequent arguments, and a newline. It then calls -.IM exits (3) +.MR exits (3) with the formatted message as argument. The program's name is the value of .BR argv0 , which will be set if the program uses the -.IM arg (3) +.MR arg (3) interface to process its arguments. If .B argv0 @@ -44,7 +44,7 @@ The message is a line with several fields: the name of the machine writing the message; the date and time; the message specified by the -.IM print (3) +.MR print (3) format .I fmt and any following arguments; @@ -60,9 +60,9 @@ can be used safely in multi-threaded programs. .br .B \*9/src/lib9/syslog.c .SH "SEE ALSO" -.IM intro (3) , -.IM errstr (3) , +.MR intro (3) , +.MR errstr (3) , the .B %r format in -.IM print (3) +.MR print (3) diff --git a/man/man3/thread.3 b/man/man3/thread.3 index 41ac565f3..6c6b46022 100644 --- a/man/man3/thread.3 +++ b/man/man3/thread.3 @@ -267,10 +267,10 @@ in arbitrary ways and should synchronize their actions using .B qlocks (see -.IM lock (3) ) +.MR lock (3) ) or channel communication. System calls such as -.IM read (3) +.MR read (3) block the entire proc; all threads in a proc block until the system call finishes. .PP @@ -364,7 +364,7 @@ are threaded analogues of and .I execl (see -.IM exec (3) ); +.MR exec (3) ); on success, they replace the calling thread and invoke the external program, never returning. @@ -400,7 +400,7 @@ and .I threadexec will duplicate (see -.IM dup (3) ) +.MR dup (3) ) the three file descriptors in .I fd onto standard input, output, and error for the external program @@ -443,14 +443,14 @@ stop the running of the program. returns a channel of pointers to .B Waitmsg structures (see -.IM wait (3) ). +.MR wait (3) ). When an exec'ed process exits, a pointer to a .B Waitmsg is sent to this channel. These .B Waitmsg structures have been allocated with -.IM malloc (3) +.MR malloc (3) and should be freed after use. .PP A @@ -611,13 +611,13 @@ calls. .PP .I Chanprint formats its arguments in the manner of -.IM print (3) +.MR print (3) and sends the result to the channel .IR c. The string delivered by .I chanprint is allocated with -.IM malloc (3) +.MR malloc (3) and should be freed upon receipt. .PP Thread library functions do not return on failure; @@ -628,10 +628,10 @@ Threaded programs should use in place of .I atnotify (see -.IM notify (3) ). +.MR notify (3) ). .PP It is safe to use -.IM sysfatal (3) +.MR sysfatal (3) in threaded programs. .I Sysfatal will print the error string and call @@ -673,7 +673,7 @@ To create new processes, use .SH FILES .B \*9/acid/thread contains useful -.IM acid (1) +.MR acid (1) functions for debugging threaded programs. .PP .B \*9/src/libthread/test @@ -681,8 +681,8 @@ contains some example programs. .SH SOURCE .B \*9/src/libthread .SH SEE ALSO -.IM intro (3) , -.IM ioproc (3) +.MR intro (3) , +.MR ioproc (3) .SH BUGS To avoid name conflicts, .IR alt , @@ -707,7 +707,7 @@ and so on. is defined as a macro that expands to .IR threadyield . See -.IM intro (3) . +.MR intro (3) . .PP Threadint, threadintgrp, diff --git a/man/man3/time.3 b/man/man3/time.3 index 583a2d7fd..6095c3291 100644 --- a/man/man3/time.3 +++ b/man/man3/time.3 @@ -41,4 +41,4 @@ are preprocessor macros defined as and .IR p9nsec ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/udpread.3 b/man/man3/udpread.3 index 80142526e..ebf0b9975 100644 --- a/man/man3/udpread.3 +++ b/man/man3/udpread.3 @@ -65,4 +65,4 @@ to send a response back to the sender of the original packet. .SH SOURCE .B \*9/src/lib9/udp.c .SH SEE ALSO -.IM ip (3) +.MR ip (3) diff --git a/man/man3/venti-cache.3 b/man/man3/venti-cache.3 index 8c2bd33d8..15d141ead 100644 --- a/man/man3/venti-cache.3 +++ b/man/man3/venti-cache.3 @@ -112,9 +112,9 @@ the block's cache address. allocates a new cache using the client connection .I z (see -.IM venti-conn (3) +.MR venti-conn (3) and -.IM venti-client (3) ), +.MR venti-client (3) ), with .I maxmem bytes of memory. @@ -195,7 +195,7 @@ The default function is .I vtwrite (see -.IM venti-client (3) ); +.MR venti-client (3) ); .I vtsetcachewrite sets it. .I Vtsetcachewrite @@ -230,8 +230,8 @@ or, more commonly, that cache blocks are being leaked. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) , -.IM venti-client (3) , -.IM venti-conn (3) , -.IM venti-file (3) , -.IM venti (7) +.MR venti (3) , +.MR venti-client (3) , +.MR venti-conn (3) , +.MR venti-file (3) , +.MR venti (7) diff --git a/man/man3/venti-client.3 b/man/man3/venti-client.3 index e475ef300..1f81acaf4 100644 --- a/man/man3/venti-client.3 +++ b/man/man3/venti-client.3 @@ -53,7 +53,7 @@ int vtping(VtConn *z) extern int ventidoublechecksha1; /* default 1 */ .SH DESCRIPTION These routines execute the client side of the -.IM venti (7) +.MR venti (7) protocol. .PP .I Vtrpc @@ -84,7 +84,7 @@ is typically called only indirectly, via calls .I vtversion (see -.IM venti-conn (3) ) +.MR venti-conn (3) ) and .IR vthello , in that order, returning success only @@ -171,14 +171,14 @@ in the same proc should start separate procs running and .I vtrecvproc as described in -.IM venti-conn (3) . +.MR venti-conn (3) . .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) , -.IM venti-conn (3) , -.IM venti-packet (3) , -.IM venti (7) +.MR venti (3) , +.MR venti-conn (3) , +.MR venti-packet (3) , +.MR venti (7) .SH DIAGNOSTICS .I Vtrpc and diff --git a/man/man3/venti-conn.3 b/man/man3/venti-conn.3 index 0c1b95d54..ba40ff6ec 100644 --- a/man/man3/venti-conn.3 +++ b/man/man3/venti-conn.3 @@ -90,21 +90,21 @@ for reading and writing. .I Vtdial dials the given network address (see -.IM dial (3) ) +.MR dial (3) ) and returns a corresponding connection. It returns nil if the connection cannot be established. .PP .I Vtversion exchanges version information with the remote side as described in -.IM venti (7) . +.MR venti (7) . The negotiated version is stored in .IB z ->version \fR. .PP .I Vtsend writes a packet (see -.IM venti-packet (3) ) +.MR venti-packet (3) ) on the connection .IR z . The packet @@ -115,7 +115,7 @@ be returned by .I vtsend will add the two-byte length field (see -.IM venti (7) ) +.MR venti (7) ) at the begnning. .I Vtsend frees @@ -137,7 +137,7 @@ and block until the packet can be written or read from the network. In a threaded program (see -.IM thread (3) ), +.MR thread (3) ), this may not be desirable. If the caller arranges for .IR vtsendproc @@ -192,12 +192,12 @@ as they are sent or received. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (1) , -.IM venti (3) , -.IM venti-client (3) , -.IM venti-packet (3) , -.IM venti-server (3) , -.IM venti (7) +.MR venti (1) , +.MR venti (3) , +.MR venti-client (3) , +.MR venti-packet (3) , +.MR venti-server (3) , +.MR venti (7) .SH DIAGNOSTICS Routines that return pointers return nil on error. Routines returning integers return 0 on success, \-1 on error. diff --git a/man/man3/venti-fcall.3 b/man/man3/venti-fcall.3 index e463c141f..f721669ec 100644 --- a/man/man3/venti-fcall.3 +++ b/man/man3/venti-fcall.3 @@ -109,7 +109,7 @@ converts a .B VtEntry structure describing a Venti file (see -.IM venti (7) ) +.MR venti (7) ) into a 40-byte .RB ( VtEntrySize ) structure at @@ -122,7 +122,7 @@ converts a .B VtFcall structure describing a Venti protocol message (see -.IM venti (7) ) +.MR venti (7) ) into a packet. .I Vtfcallunpack does the reverse conversion. @@ -130,7 +130,7 @@ does the reverse conversion. The fields in a .B VtFcall are named after the protocol fields described in -.IM venti (7) , +.MR venti (7) , except that the .B type field is renamed @@ -158,7 +158,7 @@ and the packet The block type enumeration defined in .B (presented in -.IM venti (7) ) +.MR venti (7) ) differs from the one used on disk and in the network protocol. The disk and network representation uses different @@ -232,7 +232,7 @@ is nil, the label is ignored. and .I vtscorefmt are -.IM print (3) +.MR print (3) formatters to print .B VtFcall structures and scores. @@ -244,9 +244,9 @@ is installed as .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (1) , -.IM venti (3) , -.IM venti (7) +.MR venti (1) , +.MR venti (3) , +.MR venti (7) .SH DIAGNOSTICS .IR Vtentrypack , .IR vtfcallpack , diff --git a/man/man3/venti-file.3 b/man/man3/venti-file.3 index 01003f783..9f3698c95 100644 --- a/man/man3/venti-file.3 +++ b/man/man3/venti-file.3 @@ -99,7 +99,7 @@ void vtfileunlock(VtFile *f); .SH DESCRIPTION These routines provide a simple interface to create and manipulate Venti file trees (see -.IM venti (7) ). +.MR venti (7) ). .PP .I Vtfilecreateroot creates a new Venti file. @@ -226,7 +226,7 @@ if an error is encountered. .I Vtfilewrite writes to an in-memory copy of the data blocks (see -.IM venti-cache (3) ) +.MR venti-cache (3) ) instead of writing directly to Venti. .I Vtfileflush writes all copied blocks associated with @@ -319,7 +319,7 @@ in the same directory block. .SH SOURCE .B \*9/src/libventi/file.c .SH SEE ALSO -.IM venti-cache (3) , -.IM venti-conn (3) , -.IM venti-client (3) , -.IM venti (7) +.MR venti-cache (3) , +.MR venti-conn (3) , +.MR venti-client (3) , +.MR venti (7) diff --git a/man/man3/venti-log.3 b/man/man3/venti-log.3 index 0d05af2ef..b0a99062b 100644 --- a/man/man3/venti-log.3 +++ b/man/man3/venti-log.3 @@ -122,9 +122,9 @@ passed nil log structures. .PP The server library (see -.IM venti-conn (3) +.MR venti-conn (3) and -.IM venti-server (3) ) +.MR venti-server (3) ) writes debugging information to the log named .IR VtServerLog , which defaults to the string @@ -132,5 +132,5 @@ which defaults to the string .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) , -.IM venti (8) +.MR venti (3) , +.MR venti (8) diff --git a/man/man3/venti-mem.3 b/man/man3/venti-mem.3 index 6877f0b68..f9f83fb64 100644 --- a/man/man3/venti-mem.3 +++ b/man/man3/venti-mem.3 @@ -35,7 +35,7 @@ void vtfree(void *ptr) .SH DESCRIPTION These routines allocate and free memory. On failure, they print an error message and call -.IM sysfatal (3) . +.MR sysfatal (3) . They do not return. .PP .I Vtbrk @@ -63,4 +63,4 @@ when no longer needed. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) +.MR venti (3) diff --git a/man/man3/venti-packet.3 b/man/man3/venti-packet.3 index 0f7386904..faea58c2c 100644 --- a/man/man3/venti-packet.3 +++ b/man/man3/venti-packet.3 @@ -129,7 +129,7 @@ because fragments may not be filled completely. compares the data sections of two packets as .I memcmp (see -.IM memory (3) ) +.MR memory (3) ) would. .PP .I Packetconcat @@ -260,7 +260,7 @@ bytes at offset .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) +.MR venti (3) .SH DIAGNOSTICS These functions return errors only when passed invalid inputs, diff --git a/man/man3/venti-server.3 b/man/man3/venti-server.3 index 54b8cb4ac..0265781aa 100644 --- a/man/man3/venti-server.3 +++ b/man/man3/venti-server.3 @@ -33,7 +33,7 @@ VtReq* vtgetreq(VtSrv *srv) void vtrespond(VtReq *req) .SH DESCRIPTION These routines execute the server side of the -.IM venti (7) +.MR venti (7) protocol. .PP .I Vtsrvhello @@ -115,8 +115,8 @@ blocks written to it and returns error on all reads. .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (3) , -.IM venti-conn (3) , -.IM venti-packet (3) , -.IM venti (7) , -.IM venti (8) +.MR venti (3) , +.MR venti-conn (3) , +.MR venti-packet (3) , +.MR venti (7) , +.MR venti (8) diff --git a/man/man3/venti-zero.3 b/man/man3/venti-zero.3 index 4ee8f9401..26bc3fe74 100644 --- a/man/man3/venti-zero.3 +++ b/man/man3/venti-zero.3 @@ -52,5 +52,5 @@ is the score of the zero-length block. .br .B \*9/src/libventi/zeroscore.c .SH SEE ALSO -.IM venti (3) , -.IM venti (7) +.MR venti (3) , +.MR venti (7) diff --git a/man/man3/venti.3 b/man/man3/venti.3 index 368b70ebf..f5222fad0 100644 --- a/man/man3/venti.3 +++ b/man/man3/venti.3 @@ -15,61 +15,61 @@ This manual page describes general utility functions. .PP Other manual pages describe the library functions in detail. .PP -.IM Venti-cache (3) +.MR Venti-cache (3) describes a simple in-memory block cache to help clients. .PP -.IM Venti-conn (3) +.MR Venti-conn (3) describes routines for manipulating network connections between Venti clients and servers. -.IM Venti-client (3) +.MR Venti-client (3) and -.IM venti-server (3) +.MR venti-server (3) describe routines for writing clients and servers on top of these. .PP -.IM Venti-fcall (3) +.MR Venti-fcall (3) describes the C representation of Venti protocol messages and data structures. It also describes routines that convert between the C representation and the network and disk representations. .PP -.IM Venti-file (3) +.MR Venti-file (3) describes routines for writing clients that manipulate Venti file trees (see -.IM venti (7) ). +.MR venti (7) ). .PP -.IM Venti-log (3) +.MR Venti-log (3) describes routines to access in-memory log buffers as well as the logging that is done automatically by the library. .PP -.IM Venti-mem (3) +.MR Venti-mem (3) describes wrappers around the canonical -.IM malloc (3) +.MR malloc (3) routines that abort on error. .PP -.IM Venti-packet (3) +.MR Venti-packet (3) describes routines for manipulating zero-copy chains of data buffers. .PP -.IM Venti-zero (3) +.MR Venti-zero (3) describes routines to zero truncate and zero extend blocks (see -.IM venti (7) ). +.MR venti (7) ). .SH SOURCE .B \*9/src/libventi .SH SEE ALSO -.IM venti (1) , -.IM venti-cache (3) , -.IM venti-client (3) , -.IM venti-fcall (3) , -.IM venti-file (3) -.IM venti-log (3) , -.IM venti-mem (3) , -.IM venti-packet (3) , -.IM venti-server (3) , -.IM venti-zero (3) , -.IM venti (7) , -.IM venti (8) +.MR venti (1) , +.MR venti-cache (3) , +.MR venti-client (3) , +.MR venti-fcall (3) , +.MR venti-file (3) +.MR venti-log (3) , +.MR venti-mem (3) , +.MR venti-packet (3) , +.MR venti-server (3) , +.MR venti-zero (3) , +.MR venti (7) , +.MR venti (8) diff --git a/man/man3/wait.3 b/man/man3/wait.3 index c51df3c36..889ccd1fa 100644 --- a/man/man3/wait.3 +++ b/man/man3/wait.3 @@ -29,9 +29,9 @@ int awaitfor(int pid, char *s, int n) .SH DESCRIPTION .I Wait causes a process to wait for any child process (see -.IM fork (2) +.MR fork (2) and -.IM rfork (3) ) +.MR rfork (3) ) to exit. It returns a .B Waitmsg @@ -62,7 +62,7 @@ the time spent in system calls, and the child's elapsed real time, all in units of milliseconds. .B Msg contains the message that the child specified in -.IM exits (3) . +.MR exits (3) . For a normal exit, .B msg[0] is zero, @@ -78,7 +78,7 @@ returns immediately, with return value nil. The .B Waitmsg structure is allocated by -.IM malloc (3) +.MR malloc (3) and should be freed after use. For programs that only need the pid of the exiting program, .I waitpid @@ -114,7 +114,7 @@ The filled-in buffer may be parsed (after appending a NUL) using .IR tokenize (see -.IM getfields (3) ); +.MR getfields (3) ); the resulting fields are, in order, pid, the three times, and the exit string, which will be .B '' @@ -139,8 +139,8 @@ returns .PP .B \*9/src/lib9/await.c .SH "SEE ALSO" -.IM rfork (3) , -.IM exits (3) , +.MR rfork (3) , +.MR exits (3) , .SH DIAGNOSTICS These routines set .IR errstr . @@ -156,4 +156,4 @@ are preprocessor macros defined as and .IR p9waitfor ; see -.IM intro (3) . +.MR intro (3) . diff --git a/man/man3/window.3 b/man/man3/window.3 index 2663171f5..b8a6db180 100644 --- a/man/man3/window.3 +++ b/man/man3/window.3 @@ -121,7 +121,7 @@ to color the window initially, and a refresh method The refresh methods are .BR Refbackup , which provides backing store and is the method used by -.IM rio (1) +.MR rio (1) for its clients; .BR Refnone , which provides no refresh and is designed for temporary uses @@ -142,7 +142,7 @@ pointer that may be treated like any other image. In particular, it is freed by calling .B freeimage (see -.IM allocimage (3) ). +.MR allocimage (3) ). The following functions, however, apply only to windows, not regular images. .PP .B Bottomwindow @@ -199,13 +199,13 @@ and screen position .RI ( scr ). Their usage is shown in the Examples section. .PP -.IM Rio (1) +.MR Rio (1) creates its client windows with backing store, .BR Refbackup . The graphics initialization routine, .B initdraw (see -.IM graphics (3) ), +.MR graphics (3) ), builds a .B Screen upon this, and then allocates upon that another window indented @@ -234,10 +234,10 @@ actual screen position of the window unless it is recorded separately. .SH SOURCE .B \*9/src/libdraw .SH SEE ALSO -.IM graphics (3) , -.IM draw (3) , -.IM cachechars (3) , -.IM draw (3) +.MR graphics (3) , +.MR draw (3) , +.MR cachechars (3) , +.MR draw (3) .SH BUGS The refresh method .B Refmesg diff --git a/man/man4/0intro.4 b/man/man4/0intro.4 index 598a03fbd..c80db2080 100644 --- a/man/man4/0intro.4 +++ b/man/man4/0intro.4 @@ -15,7 +15,7 @@ In Plan 9, the kernel mount device \fImnt\fR(3) acts as a client to the 9P servers mounted in the current name space, translating system calls such as -.IM open (2) +.MR open (2) into 9P transactions such as .IR open (9p). The kernel also multiplexes the potentially many processes onto a single 9P conversation @@ -30,17 +30,17 @@ On Unix, 9P clients do not access servers via the traditional file system call interface. Only the Unix name space can be accessed that way. Instead, 9P clients use the -.IM 9pclient (3) +.MR 9pclient (3) library to connect and interact directly with particular 9P servers. The -.IM 9p (1) +.MR 9p (1) command-line client is useful for interactive use and in shell scripts. .PP To preserve the façade of a single 9P conversation with each server, 9P servers invoke -.IM 9pserve (4) , +.MR 9pserve (4) , typically via -.IM post9pservice (3) . +.MR post9pservice (3) . .I 9pserve announces a 9P service at a particular network address and multiplexes the clients that connect to @@ -58,7 +58,7 @@ Setting the .B $NAMESPACE environment variable overrides this default. The -.IM namespace (1) +.MR namespace (1) command prints the current name space directory. .PP Occasionally it is useful to be able to connect the input or output @@ -73,7 +73,7 @@ implementation of (see also .I fsopenfd in -.IM 9pclient (3) ) +.MR 9pclient (3) ) returns the read or write end of a pipe; a helper process transfers data between the other end of the pipe and the 9P server. diff --git a/man/man4/9import.4 b/man/man4/9import.4 index 5bcafe52a..6ddff346c 100644 --- a/man/man4/9import.4 +++ b/man/man4/9import.4 @@ -19,7 +19,7 @@ tool allows an arbitrary on a remote .I system, with the capability of running the Plan 9 -.IM exportfs (4) +.MR exportfs (4) service, to be imported into the local name space. Usually @@ -31,7 +31,7 @@ A process is started on the remote machine, with authority of the user of .IR 9import , to perform work for the local machine using the -.IM exportfs (4) +.MR exportfs (4) service. The default port used is TCP 17007. If @@ -55,11 +55,11 @@ Use .I keypattern to select a key to authenticate to the remote side (see -.IM auth (2) ). +.MR auth (2) ). .TP .B -p Push the -.IM aan (8) +.MR aan (8) filter onto the connection to protect against temporary network outages. .TP @@ -69,11 +69,11 @@ Post the connection's mountable file descriptor as .SH SOURCE .B \*9/src/cmd/9import.c .SH SEE ALSO -.IM srv (4) , -.IM aan (8) , -.IM listen1 (8) , +.MR srv (4) , +.MR aan (8) , +.MR listen1 (8) , .B cs in -.IM ndb (7) +.MR ndb (7) .SH BUGS Encryption is not implemented. diff --git a/man/man4/9pserve.4 b/man/man4/9pserve.4 index 7eaa975f0..7f691b588 100644 --- a/man/man4/9pserve.4 +++ b/man/man4/9pserve.4 @@ -50,7 +50,7 @@ and clunks any outstanding fids belonging to the client. .PP .I 9pserve is typically not invoked directly; use -.IM post9pservice (3) +.MR post9pservice (3) instead. .PP The options are: @@ -73,7 +73,7 @@ rewrite all attach messages to use and .IR afid ; used to implement -.IM srv (4) 's +.MR srv (4) 's .B -a option .TP @@ -90,8 +90,8 @@ instead assume 9P2000 and a maximum message size of .IR msize .PD .SH "SEE ALSO -.IM intro (4) , +.MR intro (4) , .IR intro (9p), -.IM 9pfuse (4) +.MR 9pfuse (4) .SH SOURCE .B \*9/src/cmd/9pserve.c diff --git a/man/man4/acme.4 b/man/man4/acme.4 index 1ed287fb3..a285b3b89 100644 --- a/man/man4/acme.4 +++ b/man/man4/acme.4 @@ -15,7 +15,7 @@ acme \- control files for text windows \&... ] .SH DESCRIPTION The text window system -.IM acme (1) +.MR acme (1) serves a variety of files for reading, writing, and controlling windows. Some of them are virtual versions of system files for dealing @@ -28,7 +28,7 @@ When a command is run under a directory holding these files is posted as the 9P service .B acme (using -.IM 9pserve (4) ). +.MR 9pserve (4) ). .PP Some of these files supply virtual versions of services available from the underlying environment, in particular the character terminal files in Plan 9's @@ -47,7 +47,7 @@ Other files are unique to is a subdirectory used by .B win (see -.IM acme (1) ) +.MR acme (1) ) as a mount point for the .I acme files associated with the window in which @@ -436,5 +436,5 @@ except that reads stop at the end address. .SH SOURCE .B \*9/src/cmd/acme .SH SEE ALSO -.IM rio (1) , -.IM acme (1) +.MR rio (1) , +.MR acme (1) diff --git a/man/man4/factotum.4 b/man/man4/factotum.4 index 453965df9..02466fcfb 100644 --- a/man/man4/factotum.4 +++ b/man/man4/factotum.4 @@ -127,7 +127,7 @@ RSA encryption and signatures, used by SSH and TLS. passwords in the clear. .TP .B vnc -.IM vnc (1) 's +.MR vnc (1) 's challenge/response. .TP .B wep @@ -186,7 +186,7 @@ cpu server. On starting, it will attempt to get a key from NVRAM using .B readnvram (see -.IM authsrv (3) ), +.MR authsrv (3) ), prompting for anything it needs. It will never subsequently prompt for a key that it doesn't have. @@ -245,7 +245,7 @@ specific to each supported protocol. .PP All keys can have additional attibutes that act either as comments or as selectors to distinguish them in the -.IM auth (3) +.MR auth (3) library calls. .PP The factotum owner can use any key stored by factotum. @@ -305,7 +305,7 @@ such as and .B auth_challenge (see -.IM auth (3) ) +.MR auth (3) ) to specify which key and protocol to use for an authentication. Like a key tuple, a key template is also a list of .IB attribute = value @@ -367,7 +367,7 @@ turned on by the option. .PP By default when factotum starts it looks for a -.IM secstore (1) +.MR secstore (1) account on $auth for the user and, if one exists, prompts for a secstore password in order to fetch the file @@ -385,7 +385,7 @@ sets a public/private keypair for ssh authentication, generated by .B ssh_genkey (see -.IM ssh (1) ). +.MR ssh (1) ). .PD .SS "Confirming key use .PP @@ -481,11 +481,11 @@ RPC's) until done if successful, reading back an .I AuthInfo structure (see -.IM authsrv (3) ). +.MR authsrv (3) ). .PP The RPC protocol is normally embodied by one of the routines in -.IM auth (3) . +.MR auth (3) . We describe it here should anyone want to extend the library. .PP @@ -545,7 +545,7 @@ necessary authentication has succeeded, an .B AuthInfo structure (see -.IM auth (3) ) +.MR auth (3) ) can be retrieved with an .B authinfo RPC @@ -703,7 +703,7 @@ and are intended to be proxied via .I auth_proxy (see -.IM auth (3) ). +.MR auth (3) ). .\" The protocols follow .\" .IR p9any (7) .\" and @@ -736,7 +736,7 @@ before being sent over the network. .PP .I Vnc is the challenge-response protocol used by -.IM vnc (1) ; +.MR vnc (1) ; valid roles are .B client and @@ -840,7 +840,7 @@ a string: a space-separated quoted user name and password that can be parsed with .I tokenize (see -.IM getfields (3) ). +.MR getfields (3) ). Conventionally, client keys have distinguishing attributes like .B service @@ -905,7 +905,7 @@ and .BR !dk specifying the private half of the key; see -.IM rsa (3) . +.MR rsa (3) . Conventionally, .I rsa keys also have @@ -972,7 +972,7 @@ attributes. If the key is to be used for signing, it must also have a .B !secret attribute; see -.IM dsa (3) . +.MR dsa (3) . Conventionally, .I dsa keys @@ -1019,4 +1019,4 @@ The response is a hexadecimal string of length 32. .SH SOURCE .B \*9/src/cmd/auth/factotum .SH SEE ALSO -.IM ssh-agent (1) +.MR ssh-agent (1) diff --git a/man/man4/fontsrv.4 b/man/man4/fontsrv.4 index a270b2f10..6cc0d0a7d 100644 --- a/man/man4/fontsrv.4 +++ b/man/man4/fontsrv.4 @@ -20,7 +20,7 @@ fontsrv \- file system access to host fonts presents the host window system's fonts in the standard Plan 9 format (see -.IM font (7) ). +.MR font (7) ). It serves a virtual directory tree mounted at .I mtpt (if the @@ -72,14 +72,14 @@ representing 32-character Unicode ranges. .PP .I Openfont (see -.IM graphics (3) ) +.MR graphics (3) ) recognizes font paths beginning with .B /mnt/font and implements them by invoking .IR fontsrv ; it need not be running already. See -.IM font (7) +.MR font (7) for a full discussion of font name syntaxes. .SH EXAMPLES List the fonts on the system: @@ -96,7 +96,7 @@ or: .EE .LP Run -.IM acme (1) +.MR acme (1) using the operating system's Monaco as the fixed-width font: .IP .EX @@ -104,7 +104,7 @@ using the operating system's Monaco as the fixed-width font: .EE .LP Run -.IM sam (1) +.MR sam (1) using the same font: .IP .EX @@ -113,7 +113,7 @@ using the same font: .SH SOURCE .B \*9/src/cmd/fontsrv .SH SEE ALSO -.IM font (7) +.MR font (7) .SH BUGS .PP Due to OS X restrictions, diff --git a/man/man4/fossil.4 b/man/man4/fossil.4 index 6072a39a1..fd6dd0a9a 100644 --- a/man/man4/fossil.4 +++ b/man/man4/fossil.4 @@ -148,10 +148,10 @@ will be named The attach name used in .I mount (see -.IM bind (1) , -.IM bind (2) +.MR bind (1) , +.MR bind (2) and -.IM attach (5) ) +.MR attach (5) ) selects a file system to be served and optionally a subtree, in the format @@ -163,7 +163,7 @@ An empty attach name selects normally requires all users except .L none to provide authentication tickets on each -.IM attach (5) . +.MR attach (5) . To keep just anyone from connecting, .L none is only allowed to attach after another user @@ -179,7 +179,7 @@ flag to or .B srv (see -.IM fossilcons (8) ). +.MR fossilcons (8) ). .PP The groups called .B noworld @@ -207,7 +207,7 @@ readable by the world but writable only to the developers. starts a new instance of the fossil file server. It is configured mainly through console commands, documented in -.IM fossilcons (8) . +.MR fossilcons (8) . .PP The options are: .TF "-c\fI cmd @@ -239,7 +239,7 @@ and which starts a file server console on .BI /srv/ cons \fR. See -.IM fossilcons (8) +.MR fossilcons (8) for more information. .TP .BI -f " file @@ -269,7 +269,7 @@ for inconsistencies. is deprecated in favor of the console .B check command (see -.IM fossilcons (8) ). +.MR fossilcons (8) ). .I Flchk prints .I fossil @@ -375,7 +375,7 @@ system stored on Venti at The score should have been generated by .I fossil rather than by -.IM vac (1) , +.MR vac (1) , so that the appropriate snapshot metadata is present. .PD .PP @@ -450,7 +450,7 @@ See the discussion of the and .B uname commands in -.IM fossilcons (8) +.MR fossilcons (8) for more about the user table. .ne 3 .PP @@ -488,13 +488,13 @@ command to prepare the script. .SH SOURCE .B \*9/src/cmd/fossil .SH SEE ALSO -.IM yesterday (1) , -.IM fs (3) , -.IM fs (4) , -.IM srv (4) , -.IM fossilcons (8) , -.IM loadfossil (8) , -.IM venti (8) +.MR yesterday (1) , +.MR fs (3) , +.MR fs (4) , +.MR srv (4) , +.MR fossilcons (8) , +.MR loadfossil (8) , +.MR venti (8) .SH BUGS It is possible that the disk format (but not the Venti format) will change in the future, to make the disk a full cache diff --git a/man/man4/import.4 b/man/man4/import.4 index 7d67a4493..434a23bd0 100644 --- a/man/man4/import.4 +++ b/man/man4/import.4 @@ -48,7 +48,7 @@ the path have different meanings on the two systems.) connects to .I system using -.IM ssh (1) . +.MR ssh (1) . It invokes .I import on the remote system to carry out the remote @@ -109,5 +109,5 @@ sam & .SH SOURCE .B \*9/src/cmd/import.c .SH SEE ALSO -.IM 9pserve (4) , -.IM intro (4) +.MR 9pserve (4) , +.MR intro (4) diff --git a/man/man4/plumber.4 b/man/man4/plumber.4 index a86f032a0..c309a39c2 100644 --- a/man/man4/plumber.4 +++ b/man/man4/plumber.4 @@ -14,17 +14,17 @@ plumber \- file system for interprocess messaging The .I plumber is a user-level file server that receives, examines, rewrites, and dispatches -.IM plumb (7) +.MR plumb (7) messages between programs. Its behavior is programmed by a .I plumbing file (default .BR $HOME/lib/plumbing ) in the format of -.IM plumb (7) . +.MR plumb (7) . .PP Its services are posted via -.IM 9pserve (4) +.MR 9pserve (4) as .BR plumb , and consist of two @@ -39,14 +39,14 @@ for dispatching messages to applications. Programs use .B fswrite (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) to deliver messages to the .B send file, and .I fsread to receive them from the corresponding port. For example, -.IM sam (1) 's +.MR sam (1) 's .B plumb menu item or the .B B @@ -115,13 +115,13 @@ statements .TP .B plumb mount name for -.IM plumber (4) . +.MR plumber (4) . .SH SOURCE .B \*9/src/cmd/plumb .SH "SEE ALSO" -.IM plumb (1) , -.IM plumb (3) , -.IM plumb (7) +.MR plumb (1) , +.MR plumb (3) , +.MR plumb (7) .\" .SH BUGS .\" .IR Plumber 's .\" file name space is fixed, so it is difficult to plumb diff --git a/man/man4/ramfs.4 b/man/man4/ramfs.4 index 20e72b385..794519810 100644 --- a/man/man4/ramfs.4 +++ b/man/man4/ramfs.4 @@ -21,7 +21,7 @@ By default posts its service as .B ramfs using -.IM 9pserve (4) . +.MR 9pserve (4) . .PP The .B -S @@ -46,5 +46,5 @@ It can also be used to provide high-performance temporary files. .SH SOURCE .B \*9/src/cmd/ramfs.c .SH "SEE ALSO" -.IM 9p (3) , -.IM 9pserve (4) +.MR 9p (3) , +.MR 9pserve (4) diff --git a/man/man4/smugfs.4 b/man/man4/smugfs.4 index fdea4e470..be3404b1b 100644 --- a/man/man4/smugfs.4 +++ b/man/man4/smugfs.4 @@ -24,7 +24,7 @@ is a user-level file system that provides access to images stored on the SmugMug photo sharing service. It logs in after obtaining a password from -.IM factotum (4) +.MR factotum (4) using .B server=smugmug.com and @@ -32,7 +32,7 @@ and (if any) as key criteria (see -.IM auth (3) ). +.MR auth (3) ). Then .I smugfs serves a virtual directory tree mounted at @@ -265,7 +265,7 @@ SmugMug, If multiple categories or albums have the same name, only one will be accessible via the file system interface. Renaming the accessible one via Unix's -.IM mv (1) +.MR mv (1) will resolve the problem. .PP Boolean values appear as diff --git a/man/man4/srv.4 b/man/man4/srv.4 index 469b2b4ca..ae6a76349 100644 --- a/man/man4/srv.4 +++ b/man/man4/srv.4 @@ -22,7 +22,7 @@ srv, 9fs \- start network file service dials the given address and initializes the connection to serve the 9P protocol. It then posts the resulting connection in the current name space (see -.IM intro (4) ) +.MR intro (4) ) as .I srvname (default @@ -70,7 +70,7 @@ available as service .IR sources . .I 9fs is an -.IM rc (1) +.MR rc (1) script; examine it to see what local conventions apply. .SH EXAMPLES List the root directory on @@ -98,6 +98,6 @@ sudo mount -t 9p -o trans=unix,uname=$USER,dfltuid=`id -u`,dfltgid=`id -g` .br .B \*9/bin/9fs .SH "SEE ALSO -.IM dial (3) , -.IM intro (4) , -.IM netfiles (1) +.MR dial (3) , +.MR intro (4) , +.MR netfiles (1) diff --git a/man/man4/tapefs.4 b/man/man4/tapefs.4 index b8843173a..669cc819b 100644 --- a/man/man4/tapefs.4 +++ b/man/man4/tapefs.4 @@ -91,7 +91,7 @@ Tenth Edition research Unix systems (4KB block size). .PP .I Zipfs interprets zip archives (see -.IM gzip (1) ). +.MR gzip (1) ). .SH SOURCE .PP These commands are constructed in a highly stereotyped @@ -103,7 +103,7 @@ in .BR \*9/src/cmd/tapefs , which in turn derive substantially from -.IM ramfs (4) . +.MR ramfs (4) . .SH "SEE ALSO -.IM intro (7) , -.IM ramfs (4) . +.MR intro (7) , +.MR ramfs (4) . diff --git a/man/man4/vacfs.4 b/man/man4/vacfs.4 index 0c92ff60c..f3287e359 100644 --- a/man/man4/vacfs.4 +++ b/man/man4/vacfs.4 @@ -26,7 +26,7 @@ vacfs \- a Venti-based file system .SH DESCRIPTION .I Vacfs interprets the file system created by -.IM vac (1) +.MR vac (1) so that it can be mounted into a Plan 9 file hierarchy. The data for the file system is stored on a Venti server with a root fingerprint specified in @@ -81,6 +81,6 @@ The amount of memory, in bytes, allocated to the block cache. The default is 16M .SH SOURCE .B \*9/src/cmd/vac .SH "SEE ALSO" -.IM vac (1) , +.MR vac (1) , Plan 9's .IR venti (8) diff --git a/man/man7/color.7 b/man/man7/color.7 index 7e9a39b77..917c25217 100644 --- a/man/man7/color.7 +++ b/man/man7/color.7 @@ -121,11 +121,11 @@ which is scaled so 0 represents fully transparent and 255 represents opaque colo The alpha is .I premultiplied into the other channels, as described in the paper by Porter and Duff cited in -.IM draw (3) . +.MR draw (3) . The function .B setalpha (see -.IM allocimage (3) ) +.MR allocimage (3) ) aids the initialization of color values with non-trivial alpha. .PP The packing of pixels into bytes and words is odd. @@ -138,13 +138,13 @@ the byte ordering is blue, green, red. .PP To maintain a constant external representation, the -.IM draw (3) +.MR draw (3) interface as well as the various graphics libraries represent colors by 32-bit numbers, as described in -.IM color (3) . +.MR color (3) . .SH "SEE ALSO" -.IM color (3) , -.IM graphics (3) , -.IM draw (3) +.MR color (3) , +.MR graphics (3) , +.MR draw (3) diff --git a/man/man7/face.7 b/man/man7/face.7 index a69aac989..8cd378257 100644 --- a/man/man7/face.7 +++ b/man/man7/face.7 @@ -25,7 +25,7 @@ per color)). The large files serve no special purpose; they are stored as images (see -.IM image (7) ). +.MR image (7) ). The small files are the `icons' displayed by .B faces and @@ -110,6 +110,6 @@ which then appears as a domain name in the .B .dict files. .SH "SEE ALSO" -.IM mail (1) , -.IM tweak (1) , -.IM image (7) +.MR mail (1) , +.MR tweak (1) , +.MR image (7) diff --git a/man/man7/font.7 b/man/man7/font.7 index a11ca53c8..c9ebb9197 100644 --- a/man/man7/font.7 +++ b/man/man7/font.7 @@ -5,7 +5,7 @@ font, subfont \- external format for fonts and subfonts .B #include .SH DESCRIPTION Fonts and subfonts are described in -.IM cachechars (3) . +.MR cachechars (3) . .PP External bitmap fonts are described by a plain text file that can be read using .IR openfont . @@ -21,7 +21,7 @@ with an optional starting position within the subfont, and the file name names an external file suitable for .I readsubfont (see -.IM graphics (3) ). +.MR graphics (3) ). The minimum number of a covered range is mapped to the specified starting position (default zero) of the corresponding subfont. @@ -36,11 +36,11 @@ that can be read and written using and .I writesubfont (see -.IM subfont (3) ). +.MR subfont (3) ). The format for subfont files is: an image containing character glyphs, followed by a subfont header, followed by character information. The image has the format for external image files described in -.IM image (7) . +.MR image (7) . The subfont header has 3 decimal strings: .BR n , @@ -72,7 +72,7 @@ are irrelevant. .PP Note that the convention of using the character with value zero (NUL) to represent characters of zero width (see -.IM draw (3) ) +.MR draw (3) ) means that fonts should have, as their zeroth character, one with non-zero width. .SS "Font Names @@ -121,7 +121,7 @@ The command .B . lists the available fonts. See -.IM fontsrv (4) +.MR fontsrv (4) for more. .PP If the font name has the form @@ -136,7 +136,7 @@ The Plan 9 bitmap fonts were designed for screens with pixel density around 100 When used on screens with pixel density above 200 DPI, the bitmap fonts are automatically pixel doubled. Similarly, fonts loaded from -.IM fontsrv (4) +.MR fontsrv (4) are automatically doubled in size by varying the effective .I size path element. @@ -184,7 +184,7 @@ a system-installed vector font on high-density displays: .B \*9/font/* font directories .SH "SEE ALSO" -.IM graphics (3) , -.IM draw (3) , -.IM cachechars (3) , -.IM subfont (3) +.MR graphics (3) , +.MR draw (3) , +.MR cachechars (3) , +.MR subfont (3) diff --git a/man/man7/htmlroff.7 b/man/man7/htmlroff.7 index 56874b1bb..34f2cc5bd 100644 --- a/man/man7/htmlroff.7 +++ b/man/man7/htmlroff.7 @@ -2,7 +2,7 @@ .SH NAME htmlroff \- HTML formatting and typesetting .SH DESCRIPTION -.IM Htmlroff (1) +.MR Htmlroff (1) accepts .I troff input with a few extensions and changes. @@ -200,7 +200,7 @@ inside .B tags. This heuristic handles simple equations formatted by -.IM eqn (1) . +.MR eqn (1) . .SS Conditional input .PP To make it easier to write input files that can be formatted by both @@ -315,7 +315,7 @@ For example, redefines the .B PS macro that marks the beginning of a -.IM pic (1) +.MR pic (1) picture: .IP .EX diff --git a/man/man7/image.7 b/man/man7/image.7 index b412742fc..bfb299bd3 100644 --- a/man/man7/image.7 +++ b/man/man7/image.7 @@ -5,9 +5,9 @@ image \- external format for images .B #include .SH DESCRIPTION Images are described in -.IM graphics (3) , +.MR graphics (3) , and the definition of pixel values is in -.IM color (7) . +.MR color (7) . Fonts and images are stored in external files in machine-independent formats. .PP @@ -21,7 +21,7 @@ and and .B writememimage (see -.IM memdraw (3) ). +.MR memdraw (3) ). An uncompressed image file starts with 5 strings: .BR chan , @@ -37,7 +37,7 @@ value is a textual string describing the pixel format (see .B strtochan in -.IM graphics (3) +.MR graphics (3) and the discussion of channel descriptors below), and the rectangle coordinates are decimal strings. The rest of the file contains the @@ -73,7 +73,7 @@ The and .B unloadimage functions described in -.IM allocimage (3) +.MR allocimage (3) also deal with rows in this format, stored in user memory. .PP The channel format string is a sequence of two-character channel descriptions, @@ -110,7 +110,7 @@ In particular .B 'r8g8b8' pixels have byte ordering blue, green, and red within the file. See -.IM color (7) +.MR color (7) for more details of the pixel format. .PP A venerable yet deprecated format replaces the channel string @@ -179,7 +179,7 @@ as used by (see Plan 9's .IR faces (1) and -.IM face (7) ) +.MR face (7) ) and 16\(mu16 cursors, can be stored textually, suitable for inclusion in C source. Each line of text represents one scan line as a @@ -188,18 +188,18 @@ bytes, shorts, or words in C format. For cursors, each line defines a pair of bytes. (It takes two images to define a cursor; each must be stored separately to be processed by programs such as -.IM tweak (1) .) +.MR tweak (1) .) Face files of one bit per pixel are stored as a sequence of shorts, those of larger pixel sizes as a sequence of longs. Software that reads these files must deduce the image size from the input; there is no header. These formats reflect history rather than design. .SH "SEE ALSO" -.IM jpg (1) , -.IM tweak (1) , -.IM graphics (3) , -.IM draw (3) , -.IM allocimage (3) , -.IM color (7) , -.IM face (7) , -.IM font (7) +.MR jpg (1) , +.MR tweak (1) , +.MR graphics (3) , +.MR draw (3) , +.MR allocimage (3) , +.MR color (7) , +.MR face (7) , +.MR font (7) diff --git a/man/man7/keyboard.7 b/man/man7/keyboard.7 index 56c0d3aee..69094a221 100644 --- a/man/man7/keyboard.7 +++ b/man/man7/keyboard.7 @@ -49,15 +49,15 @@ in particular, control-J is a line feed and control-M a carriage return. .PP The down arrow, used by -.IM 9term (1) , -.IM acme (1) , +.MR 9term (1) , +.MR acme (1) , and -.IM sam (1) , +.MR sam (1) , causes windows to scroll forward. The up arrow scrolls backward. .PP Characters in Plan 9 are runes (see -.IM utf (7) ). +.MR utf (7) ). Any rune can be typed using a compose key followed by several other keys. The compose key is also generally near the lower right of the main key area: @@ -92,11 +92,11 @@ the compose key followed by a two- or three-character sequence. The full list is too long to repeat here, but is contained in the file .L \*9/lib/keyboard in a format suitable for -.IM grep (1) +.MR grep (1) or -.IM look (1) . +.MR look (1) . To add a sequence, edit that file and then rebuild -.IM devdraw (1) . +.MR devdraw (1) . .PP There are several rules guiding the design of the sequences, as illustrated by the following examples. @@ -235,10 +235,10 @@ to run them automatically at startup. sorted table of characters and keyboard sequences .PD .SH "SEE ALSO" -.IM intro (1) , -.IM ascii (1) , -.IM tcs (1) , -.IM 9term (1) , -.IM acme (1) , -.IM sam (1) , -.IM utf (7) +.MR intro (1) , +.MR ascii (1) , +.MR tcs (1) , +.MR 9term (1) , +.MR acme (1) , +.MR sam (1) , +.MR utf (7) diff --git a/man/man7/man.7 b/man/man7/man.7 index 98fae1c3e..f82a1bc7c 100644 --- a/man/man7/man.7 +++ b/man/man7/man.7 @@ -82,9 +82,9 @@ font- or size-setting macros. The .B -man macros admit equations and tables in the style of -.IM eqn (1) +.MR eqn (1) and -.IM tbl (1) , +.MR tbl (1) , but do not support arguments on .B .EQ and @@ -113,7 +113,7 @@ The root directory of the Plan 9 installation. .B \*9/tmac/tmac.antimes .SH SEE ALSO .IR troff (1), -.IM man (1) +.MR man (1) .SH REQUESTS .ta \w'.TH n c x 'u +\w'Cause 'u +\w'Argument\ 'u .di xx diff --git a/man/man7/map.7 b/man/man7/map.7 index 72925e414..ced8db491 100644 --- a/man/man7/map.7 +++ b/man/man7/map.7 @@ -80,7 +80,7 @@ in the map file. Both the map file and the index file are ordered by patch latitude and longitude. .SH "SEE ALSO" -.IM map (7) +.MR map (7) .br The data comes from the World Data Bank I and II and U.S. Government sources: the Census Bureau, Geological diff --git a/man/man7/mhtml.7 b/man/man7/mhtml.7 index 95439641f..f561fb43a 100644 --- a/man/man7/mhtml.7 +++ b/man/man7/mhtml.7 @@ -19,14 +19,14 @@ mhtml \- macros for formatting HTML \&... .SH DESCRIPTION This package of -.IM htmlroff (1) +.MR htmlroff (1) macro definitions provides convenient macros for formatting HTML. It is usually used along with -.IM troff (1) +.MR troff (1) macro packages such as -.IM man (7) +.MR man (7) and -.IM ms (7) . +.MR ms (7) . .I Mhtml replaces some macros defined in the other packages, so it should be listed after them on the @@ -64,7 +64,7 @@ before invoking Accumulate footnotes and print them at the end of the document under a \fBNotes\fP heading. These replace the macros in -.IM ms (7) . +.MR ms (7) . To emit the notes accumulated so far, invoke .BR .NOTES . .TP @@ -75,7 +75,7 @@ and .B .PE with a PNG image corresponding to the output of running -.IM troff (1) +.MR troff (1) on the input. .TP .B .TS\fR, \fP.TE @@ -100,6 +100,6 @@ percent of the current output width. .SH FILES .B \*9/tmac/tmac.html .SH SEE ALSO -.IM htmlroff (1) , -.IM htmlroff (7) , -.IM ms (7) +.MR htmlroff (1) , +.MR htmlroff (7) , +.MR ms (7) diff --git a/man/man7/mpictures.7 b/man/man7/mpictures.7 index c6eaf555c..5da1d547a 100644 --- a/man/man7/mpictures.7 +++ b/man/man7/mpictures.7 @@ -10,7 +10,7 @@ mpictures \- picture inclusion macros .SH DESCRIPTION .I Mpictures macros insert PostScript pictures into -.IM troff (1) +.MR troff (1) documents. The macros are: .TP @@ -129,7 +129,7 @@ comment is present, the picture is assumed to fill an 8.5\(mu11-inch page. Nothing prevents the picture from being placed off the page. .SH SEE ALSO -.IM troff (1) +.MR troff (1) .SH DIAGNOSTICS A picture file that can't be read by the PostScript postprocessor is replaced by white space. diff --git a/man/man7/ms.7 b/man/man7/ms.7 index 7d50c89ac..5886a7e19 100644 --- a/man/man7/ms.7 +++ b/man/man7/ms.7 @@ -18,7 +18,7 @@ ms \- macros for formatting manuscripts This package of .I nroff and -.IM troff (1) +.MR troff (1) macro definitions provides a canned formatting facility for tech%nical papers in various formats. .PP @@ -38,11 +38,11 @@ impunity after the first .LR .na . .PP Output of the -.IM eqn (1) , -.IM tbl (1) , -.IM pic (1) +.MR eqn (1) , +.MR tbl (1) , +.MR pic (1) and -.IM grap (1) +.MR grap (1) preprocessors for equations, tables, pictures, and graphs is acceptable as input. .SH FILES @@ -57,8 +57,8 @@ Tenth Edition, Volume 2. .br .IR eqn (1), .IR troff (1), -.IM tbl (1) , -.IM pic (1) +.MR tbl (1) , +.MR pic (1) .SH REQUESTS .ta \w'..ND \fIdate\fR 'u +\w'Initial 'u +\w'Cause 'u .br @@ -153,7 +153,7 @@ Implies produced by .I neqn or -.IM eqn (1) . +.MR eqn (1) . .ti0 \fL\&.EQ\fP \fIx y\fR - yes Display equation. Equation number is @@ -234,7 +234,7 @@ is subsection level (default 1). \fL\&.P2\fP - yes End program display. .ti0 \fL\&.PE\fP - yes End picture; see -.IM pic (1) . +.MR pic (1) . .ti0 \fL\&.PF\fP - yes End picture; restore vertical position. @@ -280,7 +280,7 @@ font automatically bold. Default is 5 10 15 ... .ti0 \fL\&.TE\fP - yes End table; see -.IM tbl (1) . +.MR tbl (1) . .ti0 \fL\&.TH\fP - yes End heading section of table. .ti0 diff --git a/man/man7/ndb.7 b/man/man7/ndb.7 index 9ab448fe5..bb59d8aab 100644 --- a/man/man7/ndb.7 +++ b/man/man7/ndb.7 @@ -59,7 +59,7 @@ Within tuples, pairs on the same line bind tighter than pairs on different lines. .PP Programs search the database directly using the routines in -.IM ndb (3) . +.MR ndb (3) . .\" or indirectly using .\" .B ndb/cs .\" and @@ -292,8 +292,8 @@ tcp=9fs port=564 first database file searched .SH "SEE ALSO" .\" .IR dial (2), -.IM ndb (1) , -.IM ndb (3) +.MR ndb (1) , +.MR ndb (3) .\" .IR dhcpd (8), .\" .IR ipconfig (8), .\" .IR con (1) diff --git a/man/man7/plot.7 b/man/man7/plot.7 index 31cb41a00..87308b3f2 100644 --- a/man/man7/plot.7 +++ b/man/man7/plot.7 @@ -340,4 +340,4 @@ Restore previous environment. .PD .SH "SEE ALSO" .IR plot (1), -.IM graph (1) +.MR graph (1) diff --git a/man/man7/plumb.7 b/man/man7/plumb.7 index 446b4340a..37b2385b5 100644 --- a/man/man7/plumb.7 +++ b/man/man7/plumb.7 @@ -6,7 +6,7 @@ plumb \- format of plumb messages and rules .SH DESCRIPTION .SS "Message format The messages formed by the -.IM plumb (3) +.MR plumb (3) library are formatted for transmission between processes into textual form, using newlines to separate the fields. @@ -61,7 +61,7 @@ A missing field is represented by an empty line. The .B plumber (see -.IM plumb (1) ) +.MR plumb (1) ) receives messages on its .B send port (applications @@ -271,7 +271,7 @@ rule should be specified in a rule set. .RE .PP The arguments to all rules may contain quoted strings, exactly as in -.IM rc (1) . +.MR rc (1) . They may also contain simple string variables, identified by a leading dollar sign .BR $ . Variables may be set, between rule sets, by assignment statements in the style of @@ -341,7 +341,7 @@ field of the message. .B $plan9 The root directory of the Plan 9 tree (see -.IM get9root (3) ). +.MR get9root (3) ). .RE .SH EXAMPLE The following is a modest, representative file of plumbing rules. @@ -403,7 +403,7 @@ default rules file. .TP .B plumb service name for -.IM plumber (4) . +.MR plumber (4) . .TP .B \*9/plumb directory for @@ -416,7 +416,7 @@ public macro definitions. .B \*9/plumb/basic basic rule set. .SH "SEE ALSO" -.IM plumb (1) , -.IM plumb (3) , -.IM plumber (4) , -.IM regexp (7) +.MR plumb (1) , +.MR plumb (3) , +.MR plumber (4) , +.MR regexp (7) diff --git a/man/man7/regexp.7 b/man/man7/regexp.7 index dbc5a9a16..73fd4dded 100644 --- a/man/man7/regexp.7 +++ b/man/man7/regexp.7 @@ -4,9 +4,9 @@ regexp \- Plan 9 regular expression notation .SH DESCRIPTION This manual page describes the regular expression syntax used by the Plan 9 regular expression library -.IM regexp (3) . +.MR regexp (3) . It is the form used by -.IM egrep (1) +.MR egrep (1) before .I egrep got complicated. @@ -130,4 +130,4 @@ A match to any part of a regular expression extends as far as possible without preventing a match to the remainder of the regular expression. .SH "SEE ALSO" -.IM regexp (3) +.MR regexp (3) diff --git a/man/man7/thumbprint.7 b/man/man7/thumbprint.7 index 4d90f4377..5a4b933ba 100644 --- a/man/man7/thumbprint.7 +++ b/man/man7/thumbprint.7 @@ -9,7 +9,7 @@ for example by calling and .B okThumbprint (see -.IM pushtls (3) ), +.MR pushtls (3) ), check the remote side's public key by comparing against thumbprints from a trusted list. The list is maintained by people who set local policies @@ -38,4 +38,4 @@ For example, a web server might have thumbprint x509 sha1=8fe472d31b360a8303cd29f92bd734813cbd923c cn=*.cs.bell-labs.com .EE .SH "SEE ALSO" -.IM pushtls (3) +.MR pushtls (3) diff --git a/man/man7/utf.7 b/man/man7/utf.7 index 0a963c8cd..5ad61764a 100644 --- a/man/man7/utf.7 +++ b/man/man7/utf.7 @@ -57,7 +57,7 @@ in order to work properly with non-\c .SM ASCII input. See -.IM rune (3) . +.MR rune (3) . .PP Letting numbers be binary, a rune x is converted to a multibyte @@ -85,7 +85,7 @@ In the inverse mapping, any sequence except those described above is incorrect and is converted to rune hexadecimal 0080. .SH "SEE ALSO" -.IM ascii (1) , -.IM tcs (1) , -.IM rune (3) , +.MR ascii (1) , +.MR tcs (1) , +.MR rune (3) , .IR "The Unicode Standard" . diff --git a/man/man7/venti.7 b/man/man7/venti.7 index 960920fcd..800c85f3b 100644 --- a/man/man7/venti.7 +++ b/man/man7/venti.7 @@ -14,19 +14,19 @@ of clients. This manual page documents the basic concepts of block storage using Venti as well as the Venti network protocol. .PP -.IM Venti (1) +.MR Venti (1) documents some simple clients. -.IM Vac (1) , -.IM vacfs (4) , +.MR Vac (1) , +.MR vacfs (4) , and -.IM vbackup (8) +.MR vbackup (8) are more complex clients. .PP -.IM Venti (3) +.MR Venti (3) describes a C library interface for accessing Venti servers and manipulating Venti data structures. .PP -.IM Venti (8) +.MR Venti (8) describes the programs used to run a Venti server. .PP .SS "Scores @@ -40,11 +40,11 @@ Scores may have an optional prefix, typically used to describe the format of the data. For example, -.IM vac (1) +.MR vac (1) uses a .B vac: prefix, while -.IM vbackup (8) +.MR vbackup (8) uses prefixes corresponding to the file system types: .BR ext2: , @@ -93,7 +93,7 @@ Keeping this parallel representation is a minor annoyance but makes it possible for general programs like .I venti/copy (see -.IM venti (1) ) +.MR venti (1) ) to traverse the block tree without knowing the specific details of any particular program's data. .SS "Block Types @@ -202,7 +202,7 @@ Text strings are represented similarly, using a two-byte count with the text itself stored as a UTF-encoded sequence of Unicode characters (see -.IM utf (7) ). +.MR utf (7) ). Text strings are not .SM NUL\c -terminated: @@ -395,7 +395,7 @@ Use and .I vtfromdisktype (see -.IM venti (3) ) +.MR venti (3) ) to convert a block type enumeration value .RB ( VtDataType , etc.) @@ -457,9 +457,9 @@ in the packet may be either 2 or 4 bytes; the total packet length distinguishes the two cases. .SH SEE ALSO -.IM venti (1) , -.IM venti (3) , -.IM venti (8) +.MR venti (1) , +.MR venti (3) , +.MR venti (8) .br Sean Quinlan and Sean Dorward, ``Venti: a new approach to archival storage'', diff --git a/man/man8/fossilcons.8 b/man/man8/fossilcons.8 index 49a42e094..8ad9d4beb 100644 --- a/man/man8/fossilcons.8 +++ b/man/man8/fossilcons.8 @@ -340,7 +340,7 @@ con /srv/fscons .SH DESCRIPTION These are configuration and maintenance commands executed at the console of a -.IM fossil (4) +.MR fossil (4) file server. The commands are split into three groups above: file server configuration, @@ -372,11 +372,11 @@ a file in any file system served by .I 9p executes a 9P transaction; the arguments are in the same format used by -.IM 9pcon (8) . +.MR 9pcon (8) . .PP .I Bind behaves similarly to -.IM bind (1) . +.MR bind (1) . It is useful when fossil is started without devices it needs configured into its namespace. @@ -389,7 +389,7 @@ standard error. .PP .I Echo behaves identically to -.IM echo (1) , +.MR echo (1) , writing to the console. .PP .I Listen @@ -492,7 +492,7 @@ the string used to represent this user in the 9P protocol .TP .I leader the group's leader (see Plan 9's -.IM stat (5) +.MR stat (5) for a description of the special privileges held by a group leader) .TP .I members @@ -821,7 +821,7 @@ removing a non-empty directory. A subsequent .I flchk (see -.IM fossil (4) ) +.MR fossil (4) ) will identify the abandoned storage so it can be reclaimed with .I bfree commands. @@ -1013,7 +1013,7 @@ takes a temporary snapshot of the current file system, recording it in .BI /snapshot/ yyyy / mmdd / hhmm \fR, as described in -.IM fossil (4) . +.MR fossil (4) . The .B -a flag causes @@ -1021,7 +1021,7 @@ flag causes to take an archival snapshot, recording it in .BI /archive/ yyyy / mmdd \fR, also described in -.IM fossil (4) . +.MR fossil (4) . By default the snapshot is taken of .BR /active , the root of the active file system. @@ -1132,7 +1132,7 @@ writes dirty blocks in memory to the disk. .PP .I Vac prints the Venti score for a -.IM vac (1) +.MR vac (1) archive containing the tree rooted at .IR dir , diff --git a/man/man8/getflags.8 b/man/man8/getflags.8 index 02c774f57..776a17aa2 100644 --- a/man/man8/getflags.8 +++ b/man/man8/getflags.8 @@ -16,7 +16,7 @@ not take arguments, or a letter followed by the space-separated names of its arguments. .I Getflags prints an -.IM rc (1) +.MR rc (1) script on standard output which initializes the environment variable .BI $flag x @@ -51,15 +51,15 @@ and .BR $0 , the program name (see -.IM rc (1) ). +.MR rc (1) ). If run under -.IM sh (1) , +.MR sh (1) , which does not set .BR $0 , the program name must be given explicitly on the command line. .SH EXAMPLE Parse the arguments for Plan 9's -.IM leak (1) : +.MR leak (1) : .IP .EX flagfmt='b,s,f binary,r res,x width' @@ -74,4 +74,4 @@ if(! ifs=() eval `{getflags $*} || ~ $#* 0){ .br .B \*9/src/cmd/usage.c .SH SEE ALSO -.IM arg (3) +.MR arg (3) diff --git a/man/man8/listen1.8 b/man/man8/listen1.8 index 2de33f1fc..98f560f32 100644 --- a/man/man8/listen1.8 +++ b/man/man8/listen1.8 @@ -34,4 +34,4 @@ flag causes verbose logging on standard output. .SH SOURCE .B \*9/src/cmd/listen1.c .SH "SEE ALSO" -.IM dial (3) +.MR dial (3) diff --git a/man/man8/mkfs.8 b/man/man8/mkfs.8 index fb4fa2e60..073e55b2f 100644 --- a/man/man8/mkfs.8 +++ b/man/man8/mkfs.8 @@ -34,7 +34,7 @@ copies files from the file tree to a .B kfs file system (see -.IM kfs (4) ). +.MR kfs (4) ). The kfs service is mounted on .I root (default @@ -47,7 +47,7 @@ The .I proto files are read (see -.IM proto (2) +.MR proto (2) for their format) and any files specified in them that are out of date are copied to .BR /n/kfs . @@ -183,5 +183,5 @@ disk/mkext -u -d /n/newfs < arch .br .B \*9/src/cmd/disk/mkext.c .SH "SEE ALSO" -.IM prep (8) , -.IM tar (1) +.MR prep (8) , +.MR tar (1) diff --git a/man/man8/vbackup.8 b/man/man8/vbackup.8 index e212435ed..fa201f400 100644 --- a/man/man8/vbackup.8 +++ b/man/man8/vbackup.8 @@ -70,7 +70,7 @@ back up Unix file systems to Venti .SH DESCRIPTION These programs back up and restore standard Unix file system images stored in -.IM venti (8) . +.MR venti (8) . Images stored in .I venti are named by @@ -102,7 +102,7 @@ The argument .I disk should be a disk or disk partition device that would be appropriate to pass to -.IM mount (8) . +.MR mount (8) . .PP The optional argument .I score @@ -135,7 +135,7 @@ The default is the name returned by .I sysname (see -.IM getuser (3) ). +.MR getuser (3) ). The default .I mtpt is the place where @@ -149,7 +149,7 @@ command. The default is the name returned by .I sysname (see -.IM getuser (3) ). +.MR getuser (3) ). .TP .B -n No-op mode: do not write any blocks to the server @@ -207,7 +207,7 @@ to zero unused blocks instead. .PP .I Vftp presents an -.IM ftp (1) -like +.MR ftp (1) -like interface to a physical or backed-up disk image. It is used mainly for debugging. Type @@ -228,7 +228,7 @@ must be run by the user Because .I address is passed to the host OS kernel rather than interpreted by -.IM dial (3) , +.MR dial (3) , it must be only an IP address, not a full dial address. .PP .I Vnfs diff --git a/man/man8/venti-backup.8 b/man/man8/venti-backup.8 index 88bad8f33..131514c65 100644 --- a/man/man8/venti-backup.8 +++ b/man/man8/venti-backup.8 @@ -104,8 +104,8 @@ for a version that does this. .SH SOURCE .B \*9/src/cmd/venti/srv .SH SEE ALSO -.IM venti (7) , -.IM venti (8) +.MR venti (7) , +.MR venti (8) .SH BUGS .I Wrarena can't read a pipe or network connection containing an arena; diff --git a/man/man8/venti-fmt.8 b/man/man8/venti-fmt.8 index 19679ca0e..399068621 100644 --- a/man/man8/venti-fmt.8 +++ b/man/man8/venti-fmt.8 @@ -99,9 +99,9 @@ syncindex \- prepare and maintain a venti server These commands aid in the setup, maintenance, and debugging of venti servers. See -.IM venti (7) +.MR venti (7) for an overview of the venti system and -.IM venti (8) +.MR venti (8) for an overview of the data structures used by the venti server. .PP Note that the units for the various sizes in the following @@ -195,7 +195,7 @@ formats the given .I file as a Bloom filter (see -.IM venti (7) ). +.MR venti (7) ). The options are: .TF "\fL-s\fI size" .PD @@ -264,7 +264,7 @@ overflow. The total size of the index should be about 2% to 10% of the total size of the arenas, but the exact percentage depends both on the index block size and the compressed size of blocks stored. See the discussion in -.IM venti (8) +.MR venti (8) for more. .PP .I Fmtindex @@ -401,8 +401,8 @@ Increase the verbosity of output. .SH SOURCE .B \*9/src/cmd/venti/srv .SH SEE ALSO -.IM venti (7) , -.IM venti (8) +.MR venti (7) , +.MR venti (8) .SH BUGS .I Buildindex should allow an individual index section to be rebuilt. diff --git a/man/man8/venti.8 b/man/man8/venti.8 index d6c26903f..6a6d53e0d 100644 --- a/man/man8/venti.8 +++ b/man/man8/venti.8 @@ -40,7 +40,7 @@ venti \- archival storage server .I Venti is a SHA1-addressed archival storage server. See -.IM venti (7) +.MR venti (7) for a full introduction to the system. This page documents the structure and operation of the server. .PP @@ -138,7 +138,7 @@ less than 10 are not very useful; greater than 24 are probably a waste of memory. .I Fmtbloom (see -.IM venti-fmt (8) ) +.MR venti-fmt (8) ) can be given either .I nhash or @@ -220,7 +220,7 @@ The venti server announces two network services, one .BR venti , 17034) serving the venti protocol as described in -.IM venti (7) , +.MR venti (7) , and one serving HTTP (conventionally TCP port .BR http , @@ -333,7 +333,7 @@ with or .I fmtisect (see -.IM venti-fmt (8) ). +.MR venti-fmt (8) ). In particular, only the configuration needs to be changed if a component is moved to a different file. .PP @@ -506,11 +506,11 @@ Start the server and check the storage statistics: .SH SOURCE .B \*9/src/cmd/venti/srv .SH "SEE ALSO" -.IM venti (1) , -.IM venti (3) , -.IM venti (7) , -.IM venti-backup (8) -.IM venti-fmt (8) +.MR venti (1) , +.MR venti (3) , +.MR venti (7) , +.MR venti-backup (8) +.MR venti-fmt (8) .br Sean Quinlan and Sean Dorward, ``Venti: a new approach to archival storage'', @@ -523,7 +523,7 @@ Venti should not require the user to decide how to partition its memory usage. .PP Users of shells other than -.IM rc (1) +.MR rc (1) will not be able to use the program names shown. One solution is to define .B "V=$PLAN9/bin/venti" diff --git a/tmac/tmac.an b/tmac/tmac.an index c759a59ee..02b31bbfa 100644 --- a/tmac/tmac.an +++ b/tmac/tmac.an @@ -209,7 +209,10 @@ .HY .}f .. -.de IM +.\" MR - manual reference, as in .MR cat (1) , +.\" $3 is the punctuation after the reference ends, if any. +.de MR +.nh .}S 2 1 \& "\Xhtml manref start \\$1 \\$2\\$1" "\\$2\Xhtml manref end \\$1 \\$2\\$3" .HY .}f From 1f098efb7370a0b28306d10681e21883fb1c1507 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Aug 2020 20:46:23 -0400 Subject: [PATCH 265/323] all: a few more #define tricks for AIX This should make the AIX build finally work. Fixes #400. --- src/cmd/sam/sam.h | 3 +++ src/libdiskfs/hfs.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index c11163ef0..aae39b4a4 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/libdiskfs/hfs.h b/src/libdiskfs/hfs.h index bf5ebc9fe..dc30aeedd 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, From 291f7411783bf6871b253f3b15ce691eea7a257e Mon Sep 17 00:00:00 2001 From: Anthony Sorace Date: Sat, 26 Sep 2020 16:18:00 -0700 Subject: [PATCH 266/323] 9c, 9l: updates for macOS arm64. --- bin/9c | 4 ++++ bin/9l | 3 +++ 2 files changed, 7 insertions(+) diff --git a/bin/9c b/bin/9c index a22a0a087..59adda7f4 100755 --- a/bin/9c +++ b/bin/9c @@ -119,6 +119,10 @@ case "$tag" in useclang cflags="$cflags -g3 -m64" ;; +*Darwin-arm64*) + useclang + cflags="$cflags -g3 -m64" + ;; *Darwin*clang*) useclang cflags="$cflags -g3 -m32" diff --git a/bin/9l b/bin/9l index b4f915840..f6eb0ba1b 100755 --- a/bin/9l +++ b/bin/9l @@ -30,6 +30,9 @@ case "$tag" in *Darwin*x86_64*) ld="${CC9:-gcc} -m64 $CC9FLAGS" ;; +*Darwin-arm64*) + ld="${CC9:-gcc} -m64 $CC9FLAGS" + ;; *Darwin*) ld="${CC9:-gcc} -m32 $CC9FLAGS" ;; From a012d174336358f997ddcb0099c0b01499b053e4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 15 Dec 2020 00:01:26 -0500 Subject: [PATCH 267/323] time: print 1s of milliseconds --- src/cmd/time.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/time.c b/src/cmd/time.c index 3b52216b9..16379a89d 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 Date: Tue, 15 Dec 2020 00:05:17 -0500 Subject: [PATCH 268/323] libthread: fix use after free of first thread in each proc This was causing sporadic but frequent crashes at startup in 9pserve on the new M1 Macs, correctly diagnosing a use-after-free. --- src/libthread/thread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 902942d9a..65e651949 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -411,7 +411,14 @@ procscheduler(Proc *p) 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 @@ procscheduler(Proc *p) unlock(&threadnproclock); unlock(&p->lock); _threadsetproc(nil); + free(p->thread0); free(p); _threadpexit(); } From 69439fae6705a125047246c889384ed3aeb4d104 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 00:06:35 -0500 Subject: [PATCH 269/323] 9c: use -fcommon for clang Fixes #469. --- bin/9c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/9c b/bin/9c index 59adda7f4..9dfc082e5 100755 --- a/bin/9c +++ b/bin/9c @@ -83,6 +83,7 @@ useclang() -Wno-unneeded-internal-declaration \ -fsigned-char \ -fno-caret-diagnostics \ + -fcommon \ " cflags="$cflags -g" cflags="$cflags $CC9FLAGS" From 5b37d9126474864b5299426e27b2af37fcc96dd0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 00:06:35 -0500 Subject: [PATCH 270/323] libthread: delete NetBSD special case I added a direct call from thread.c to pthread.c's _threadpthreadstart in May, and no one has complained about NetBSD being broken. So probably no one is using this on NetBSD at all. Make pthread the only option. --- src/libthread/NetBSD-386-asm.s | 7 - src/libthread/NetBSD-power-asm.s | 16 -- src/libthread/NetBSD.c | 437 ------------------------------- src/libthread/sysofiles.sh | 9 +- 4 files changed, 4 insertions(+), 465 deletions(-) delete mode 100644 src/libthread/NetBSD-386-asm.s delete mode 100644 src/libthread/NetBSD-power-asm.s delete mode 100644 src/libthread/NetBSD.c diff --git a/src/libthread/NetBSD-386-asm.s b/src/libthread/NetBSD-386-asm.s deleted file mode 100644 index 197f12b54..000000000 --- a/src/libthread/NetBSD-386-asm.s +++ /dev/null @@ -1,7 +0,0 @@ -.globl _tas -_tas: - movl $0xCAFEBABE, %eax - movl 4(%esp), %ecx - xchgl %eax, 0(%ecx) - ret - diff --git a/src/libthread/NetBSD-power-asm.s b/src/libthread/NetBSD-power-asm.s deleted file mode 100644 index d6e21c157..000000000 --- a/src/libthread/NetBSD-power-asm.s +++ /dev/null @@ -1,16 +0,0 @@ - .globl _tas -_tas: - li %r0, 0 - mr %r4, %r3 - lis %r5, 0xcafe - ori %r5, %r5, 0xbabe -1: - lwarx %r3, %r0, %r4 - cmpwi %r3, 0 - bne 2f - stwcx. %r5, %r0, %r4 - bne- 1b -2: - sync - blr - diff --git a/src/libthread/NetBSD.c b/src/libthread/NetBSD.c deleted file mode 100644 index 2b14146b8..000000000 --- a/src/libthread/NetBSD.c +++ /dev/null @@ -1,437 +0,0 @@ -#include "threadimpl.h" - -#undef exits -#undef _exits - -static int -timefmt(Fmt *fmt) -{ - static char *mon[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - vlong ns; - Tm tm; - ns = nsec(); - tm = *localtime(time(0)); - return fmtprint(fmt, "%s %2d %02d:%02d:%02d.%03d", - mon[tm.mon], tm.mday, tm.hour, tm.min, tm.sec, - (int)(ns%1000000000)/1000000); -} - -/* - * spin locks - */ -extern int _tas(int*); - -void -_threadunlock(Lock *l, ulong pc) -{ - USED(pc); - - l->held = 0; -} - -int -_threadlock(Lock *l, int block, ulong pc) -{ - int i; -static int first=1; -if(first) {first=0; fmtinstall('\001', timefmt);} - - USED(pc); - - /* once fast */ - if(!_tas(&l->held)) - return 1; - if(!block) - return 0; - - /* a thousand times pretty fast */ - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - sched_yield(); - } - /* now increasingly slow */ - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1); - } -fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10); - } -fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100); - } -fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(1000); - } -fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc); - for(i=0; i<10; i++){ - if(!_tas(&l->held)) - return 1; - usleep(10*1000); - } -fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc); - for(i=0; i<1000; i++){ - if(!_tas(&l->held)) - return 1; - usleep(100*1000); - } -fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc); - /* take your time */ - while(_tas(&l->held)) - usleep(1000*1000); - return 1; -} - -/* - * sleep and wakeup - */ -static void -ign(int x) -{ - USED(x); -} - -static void /*__attribute__((constructor))*/ -ignusr1(int restart) -{ - struct sigaction sa; - - memset(&sa, 0, sizeof sa); - sa.sa_handler = ign; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGUSR1); - if(restart) - sa.sa_flags = SA_RESTART; - sigaction(SIGUSR1, &sa, nil); -} - -void -_procsleep(_Procrendez *r) -{ - sigset_t mask; - - /* - * Go to sleep. - * - * Block USR1, set the handler to interrupt system calls, - * unlock the vouslock so our waker can wake us, - * and then suspend. - */ -again: - r->asleep = 1; - r->pid = getpid(); - - sigprocmask(SIG_SETMASK, nil, &mask); - sigaddset(&mask, SIGUSR1); - sigprocmask(SIG_SETMASK, &mask, nil); - ignusr1(0); - unlock(r->l); - sigdelset(&mask, SIGUSR1); - sigsuspend(&mask); - - /* - * We're awake. Make USR1 not interrupt system calls. - */ - lock(r->l); - ignusr1(1); - if(r->asleep && r->pid == getpid()){ - /* Didn't really wake up - signal from something else */ - goto again; - } -} - -void -_procwakeupandunlock(_Procrendez *r) -{ - int pid; - - pid = 0; - if(r->asleep){ - r->asleep = 0; - assert(r->pid >= 1); - pid = r->pid; - } - assert(r->l); - unlock(r->l); - if(pid) - kill(pid, SIGUSR1); -} - -/* - * process creation and exit - */ -typedef struct Stackfree Stackfree; -struct Stackfree -{ - Stackfree *next; - int pid; - int pid1; -}; -static Lock stacklock; -static Stackfree *stackfree; - -static void -delayfreestack(uchar *stk, int pid, int pid1) -{ - Stackfree *sf; - - sf = (Stackfree*)stk; - sf->pid = pid; - sf->pid1 = pid1; - lock(&stacklock); - sf->next = stackfree; - stackfree = sf; - unlock(&stacklock); -} - -static void -dofreestacks(void) -{ - Stackfree *sf, *last, *next; - - if(stackfree==nil || !canlock(&stacklock)) - return; - - for(last=nil,sf=stackfree; sf; last=sf,sf=next){ - next = sf->next; - if(sf->pid >= 1 && kill(sf->pid, 0) < 0 && errno == ESRCH) - if(sf->pid1 >= 1 && kill(sf->pid1, 0) < 0 && errno == ESRCH){ - free(sf); - if(last) - last->next = next; - else - stackfree = next; - sf = last; - } - } - unlock(&stacklock); -} - -static int -startprocfn(void *v) -{ - void **a; - uchar *stk; - void (*fn)(void*); - Proc *p; - int pid0, pid1; - - a = (void**)v; - fn = a[0]; - p = a[1]; - stk = a[2]; - pid0 = (int)a[4]; - pid1 = getpid(); - free(a); - p->osprocid = pid1; - - (*fn)(p); - - delayfreestack(stk, pid0, pid1); - _exit(0); - return 0; -} - -/* - * indirect through here so that parent need not wait for child zombie - * - * slight race - if child exits and then another process starts before we - * manage to exit, we'll be running on a freed stack. - */ -static int -trampnowait(void *v) -{ - void **a; - int *kidpid; - - a = (void*)v; - kidpid = a[3]; - a[4] = (void*)getpid(); - *kidpid = clone(startprocfn, a[2]+65536-512, CLONE_VM|CLONE_FILES, a); - _exit(0); - return 0; -} - -void -_procstart(Proc *p, void (*fn)(Proc*)) -{ - void **a; - uchar *stk; - int pid, kidpid, status; - - dofreestacks(); - a = malloc(5*sizeof a[0]); - if(a == nil) - sysfatal("_procstart malloc: %r"); - stk = malloc(65536); - if(stk == nil) - sysfatal("_procstart malloc stack: %r"); - - a[0] = fn; - a[1] = p; - a[2] = stk; - a[3] = &kidpid; - kidpid = -1; - - pid = clone(trampnowait, stk+65536-16, CLONE_VM|CLONE_FILES, a); - if(pid > 0) - if(wait4(pid, &status, __WALL, 0) < 0) - fprint(2, "ffork wait4: %r\n"); - if(pid < 0 || kidpid < 0){ - fprint(2, "_procstart clone: %r\n"); - abort(); - } -} - -static char *threadexitsmsg; -void -sigusr2handler(int s) -{ -/* fprint(2, "%d usr2 %d\n", time(0), getpid()); */ - if(threadexitsmsg) - _exits(threadexitsmsg); -} - -void -threadexitsall(char *msg) -{ - static int pid[1024]; - int i, npid, mypid; - Proc *p; - - if(msg == nil) - msg = ""; - - /* - * Only one guy, ever, gets to run this. - * If two guys do it, inevitably they end up - * tripping over each other in the underlying - * C library exit() implementation, which is - * trying to run the atexit handlers and apparently - * not thread safe. This has been observed on - * both Linux and OpenBSD. Sigh. - */ - { - static Lock onelock; - if(!canlock(&onelock)) - _exits(threadexitsmsg); - threadexitsmsg = msg; - } - - mypid = getpid(); - lock(&_threadprocslock); - npid = 0; - for(p=_threadprocs; p; p=p->next) - if(p->osprocid != mypid && p->osprocid >= 1) - pid[npid++] = p->osprocid; - for(i=0; ipid == pid) - return p; - if(p->pid == 0){ - print("found 0 at %d (h=%d)\n", (i+h)%nelem(perproc), h); - break; - } - } - fprint(2, "myperproc %d (%s): cannot find self\n", pid, argv0); - abort(); - return nil; -} - -static Perproc* -newperproc(void) -{ - int i, pid, h; - Perproc *p; - - lock(&perlock); - pid = getpid(); - h = pid%nelem(perproc); - for(i=0; ipid == pid || p->pid == -1 || p->pid == 0){ - p->pid = pid; - unlock(&perlock); - return p; - } - } - fprint(2, "newperproc %d: out of procs\n", pid); - abort(); - return nil; -} - -Proc* -_threadproc(void) -{ - return myperproc()->proc; -} - -void -_threadsetproc(Proc *p) -{ - Perproc *pp; - - if(p) - p->osprocid = getpid(); - pp = newperproc(); - pp->proc = p; - if(p == nil) - pp->pid = -1; -} - -void -_pthreadinit(void) -{ - signal(SIGUSR2, sigusr2handler); -} - -void -_threadpexit(void) -{ - _exit(0); -} diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh index 833afbe02..cf9e02347 100644 --- a/src/libthread/sysofiles.sh +++ b/src/libthread/sysofiles.sh @@ -2,15 +2,14 @@ test -f $PLAN9/config && . $PLAN9/config +echo pthread.o + case "$SYSNAME" in -NetBSD) - echo ${SYSNAME}-${OBJTYPE}-asm.o $SYSNAME.o stkmalloc.o - ;; OpenBSD) - echo pthread.o stkmmap.o + echo stkmmap.o ;; *) - echo pthread.o stkmalloc.o + echo stkmalloc.o esac # Various libc don't supply swapcontext, makecontext, so we do. From b3a20a96eb2b91a5b0b8a8fb506e20a2fb50ebe8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 00:10:11 -0500 Subject: [PATCH 271/323] libthread: add threadmaybackground Programs that want to background themselves now need to define threadmaybackground returning 1. This avoids a confusing (to people and debuggers) extra parent process for all the threaded programs that will never want to background themselves. --- include/thread.h | 7 +++++-- man/man3/thread.3 | 34 ++++++++++++++++++++++------------ src/cmd/9pfuse/main.c | 6 ++++++ src/cmd/9pserve.c | 6 ++++++ src/cmd/auth/factotum/main.c | 6 ++++++ src/cmd/auth/ssh-agent.c | 6 ++++++ src/cmd/fossil/fossil.c | 6 ++++++ src/cmd/import.c | 6 ++++++ src/cmd/ndb/dns.c | 6 ++++++ src/cmd/plumb/plumber.c | 6 ++++++ src/cmd/smugfs/main.c | 6 ++++++ src/cmd/upas/fs/fs.c | 6 ++++++ src/cmd/upas/nfs/main.c | 6 ++++++ src/cmd/venti/srv/venti.c | 6 ++++++ src/lib9p/ramfs.c | 6 ++++++ src/libthread/bg.c | 7 +++++++ src/libthread/daemonize.c | 12 ++++++------ src/libthread/mkfile | 1 + src/libthread/thread.c | 2 +- 19 files changed, 120 insertions(+), 21 deletions(-) create mode 100644 src/libthread/bg.c diff --git a/include/thread.h b/include/thread.h index c01cd5166..8c8008292 100644 --- a/include/thread.h +++ b/include/thread.h @@ -1,7 +1,7 @@ #ifndef _THREAD_H_ #define _THREAD_H_ 1 #if defined(__cplusplus) -extern "C" { +extern "C" { #endif AUTOLIB(thread) @@ -15,6 +15,7 @@ void threadexits(char *); void threadexitsall(char *); void threadsetname(char*, ...); void threadsetstate(char*, ...); +void threadneedbackground(void); char *threadgetname(void); int threadyield(void); int threadidle(void); @@ -60,6 +61,8 @@ void **threaddata(void); void threadmain(int argc, char *argv[]); extern int mainstacksize; +int threadmaybackground(void); + /* * channel communication */ @@ -180,7 +183,7 @@ int threadspawnl(int[3], char*, ...); Channel* threadwaitchan(void); /* - * alternate interface to threadwaitchan - don't use both! + * alternate interface to threadwaitchan - don't use both! */ Waitmsg* procwait(int pid); diff --git a/man/man3/thread.3 b/man/man3/thread.3 index 6c6b46022..02e4c8686 100644 --- a/man/man3/thread.3 +++ b/man/man3/thread.3 @@ -33,6 +33,7 @@ threadintgrp, threadkill, threadkillgrp, threadmain, +threadmaybackground, threadnotify, threadid, threadpid, @@ -80,6 +81,7 @@ struct Alt { .ft L .ta \w'\fLChannel* 'u +4n +4n +4n +4n void threadmain(int argc, char *argv[]) +int threadmaybackground(void) int mainstacksize int proccreate(void (*fn)(void*), void *arg, uint stacksize) int threadcreate(void (*fn)(void*), void *arg, uint stacksize) @@ -171,7 +173,7 @@ initialized to the desired value .BR 1024 ). When using the .I pthread -library, +library, .B mainstacksize is ignored, as is the stack size argument to .BR proccreate : @@ -185,7 +187,7 @@ executes .I fn(arg) on a stack of size .IR stacksize . -Thread stacks are allocated in shared memory, making it valid to pass +Thread stacks are allocated in shared memory, making it valid to pass pointers to stack variables between threads and procs. .I Proccreate creates a new proc, and inside that proc creates @@ -207,7 +209,7 @@ returning the id of the created thread. .\" in .\" .IR rforkflag .) .\" .I Proccreate -.\" is identical to +.\" is identical to .\" .I procrfork .\" with .\" .I rforkflag @@ -238,6 +240,14 @@ When the last thread in .IR threadmain 's proc exits, the program will appear to its parent to have exited. The remaining procs will still run together, but as a background program. +This functionality can only be relied upon if the program defines a function +.I threadmaybackground +returning a non-zero result. +Programs that do not define such a +.I threadmaybackground +will crash instead should the last thread in +.IR threadmain 's +proc exit leaving behind other running procs. .PP The threads in a proc are coroutines, scheduled nonpreemptively in a round-robin fashion. @@ -341,18 +351,18 @@ Also for debugging, threads have a string state associated with them. .I Threadsetstate sets the state string. -There is no +There is no .IR threadgetstate ; since the thread scheduler resets the state to .B Running -every time it runs the thread, +every time it runs the thread, it is only useful for debuggers to inspect the state. .PP .I Threaddata returns a pointer to a per-thread pointer that may be modified by threaded programs for per-thread storage. -Similarly, +Similarly, .I procdata returns a pointer to a per-proc pointer. .PP @@ -398,11 +408,11 @@ response. .I Threadexecl and .I threadexec -will duplicate +will duplicate (see .MR dup (3) ) the three file descriptors in -.I fd +.I fd onto standard input, output, and error for the external program and then close them in the calling thread. Beware of code that sets @@ -467,9 +477,9 @@ operation blocks until the corresponding operation occurs and .IR "vice versa" . .IR Chancreate -allocates a new channel +allocates a new channel for messages of size -.I elsize +.I elsize and with a buffer holding .I nel messages. @@ -645,7 +655,7 @@ from the main proc before any other procs have been created. To create new processes, use .IR proccreate . .\" .PP -.\" It is safe to use +.\" It is safe to use .\" .IR rfork .\" (see .\" .IR fork (3)) @@ -663,7 +673,7 @@ To create new processes, use .\" .BR RFCENVG. .\" (To create new processes, use .\" .I proccreate -.\" and +.\" and .\" .IR procrfork .) .\" As mentioned above, .\" the thread library depends on all procs being in the diff --git a/src/cmd/9pfuse/main.c b/src/cmd/9pfuse/main.c index 69d1ad75d..4fa330a08 100644 --- a/src/cmd/9pfuse/main.c +++ b/src/cmd/9pfuse/main.c @@ -98,6 +98,12 @@ usage(void) void fusereader(void*); void watchfd(void*); +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char **argv) { diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c index 255bcbb25..e26eef146 100644 --- a/src/cmd/9pserve.c +++ b/src/cmd/9pserve.c @@ -137,6 +137,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + uchar vbuf[128]; extern int _threaddebuglevel; void diff --git a/src/cmd/auth/factotum/main.c b/src/cmd/auth/factotum/main.c index b3ace12c4..6dfc2a400 100644 --- a/src/cmd/auth/factotum/main.c +++ b/src/cmd/auth/factotum/main.c @@ -20,6 +20,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/auth/ssh-agent.c b/src/cmd/auth/ssh-agent.c index c3b0c7ef3..e944e3901 100644 --- a/src/cmd/auth/ssh-agent.c +++ b/src/cmd/auth/ssh-agent.c @@ -90,6 +90,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char **argv) { diff --git a/src/cmd/fossil/fossil.c b/src/cmd/fossil/fossil.c index 002e85103..c5672c869 100644 --- a/src/cmd/fossil/fossil.c +++ b/src/cmd/fossil/fossil.c @@ -59,6 +59,12 @@ readCmdPart(char *file, char ***pcmd, int *pncmd) *pncmd = ncmd; } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char* argv[]) { diff --git a/src/cmd/import.c b/src/cmd/import.c index 0be2f5b6f..7da70966e 100644 --- a/src/cmd/import.c +++ b/src/cmd/import.c @@ -51,6 +51,12 @@ fatal(char *fmt, ...) threadexitsall("fatal"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/ndb/dns.c b/src/cmd/ndb/dns.c index cb3170529..723989b96 100644 --- a/src/cmd/ndb/dns.c +++ b/src/cmd/ndb/dns.c @@ -121,6 +121,12 @@ checkaddress(void) fprint(2, "warning: announce mismatch %s %s\n", udpaddr, tcpaddr); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c index c99282f02..5ead2e931 100644 --- a/src/cmd/plumb/plumber.c +++ b/src/cmd/plumb/plumber.c @@ -26,6 +26,12 @@ makeports(Ruleset *rules[]) addport(rules[i]->port); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/smugfs/main.c b/src/cmd/smugfs/main.c index e1c2745f6..31c9a752b 100644 --- a/src/cmd/smugfs/main.c +++ b/src/cmd/smugfs/main.c @@ -51,6 +51,12 @@ smuglogin(void) printerrors = 0; } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char **argv) { diff --git a/src/cmd/upas/fs/fs.c b/src/cmd/upas/fs/fs.c index dc6ff3ba6..32968e67e 100644 --- a/src/cmd/upas/fs/fs.c +++ b/src/cmd/upas/fs/fs.c @@ -155,6 +155,12 @@ notifyf(void *a, char *s) noted(NDFLT); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/upas/nfs/main.c b/src/cmd/upas/nfs/main.c index c72a48494..68ae141b5 100644 --- a/src/cmd/upas/nfs/main.c +++ b/src/cmd/upas/nfs/main.c @@ -26,6 +26,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char **argv) { diff --git a/src/cmd/venti/srv/venti.c b/src/cmd/venti/srv/venti.c index 1725537a2..67fda91e1 100644 --- a/src/cmd/venti/srv/venti.c +++ b/src/cmd/venti/srv/venti.c @@ -23,6 +23,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/lib9p/ramfs.c b/src/lib9p/ramfs.c index b7a07c7d0..7cf6489d5 100644 --- a/src/lib9p/ramfs.c +++ b/src/lib9p/ramfs.c @@ -125,6 +125,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char **argv) { diff --git a/src/libthread/bg.c b/src/libthread/bg.c new file mode 100644 index 000000000..2edbc0e48 --- /dev/null +++ b/src/libthread/bg.c @@ -0,0 +1,7 @@ +#include "threadimpl.h" + +int +threadmaybackground(void) +{ + return 0; +} diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c index 387d15272..f994ffe15 100644 --- a/src/libthread/daemonize.c +++ b/src/libthread/daemonize.c @@ -8,7 +8,7 @@ #undef wait static int sigpid; -static int threadpassfd; +static int threadpassfd = -1; static int gotsigchld; static void @@ -163,9 +163,9 @@ _threadsetupdaemonize(void) void _threaddaemonize(void) { - if(threadpassfd >= 0){ - write(threadpassfd, "0", 1); - close(threadpassfd); - threadpassfd = -1; - } + if(threadpassfd < 0) + sysfatal("threads in main proc exited w/o threadmaybackground"); + write(threadpassfd, "0", 1); + close(threadpassfd); + threadpassfd = -1; } diff --git a/src/libthread/mkfile b/src/libthread/mkfile index 8a77a3161..eca4f4df4 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -4,6 +4,7 @@ SYSOFILES=`{sh ./sysofiles.sh} LIB=libthread.a OFILES=\ $SYSOFILES\ + bg.$O\ channel.$O\ daemonize.$O\ exec.$O\ diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 65e651949..7151e8756 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -844,7 +844,7 @@ main(int argc, char **argv) // Easier to just run in pthread-per-thread mode. pthreadperthread = 1; #endif - if(strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) + if(threadmaybackground() && strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) _threadsetupdaemonize(); threadargc = argc; From b73633b1b4e9d3dbd680edf900b2b53befbf5a9a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 00:15:37 -0500 Subject: [PATCH 272/323] libthread: fix pthreadperthread bugs --- src/libthread/thread.c | 293 +++++++++++++++++++++++-------------- src/libthread/threadimpl.h | 1 + 2 files changed, 187 insertions(+), 107 deletions(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 7151e8756..94173ebc6 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -1,6 +1,6 @@ #include "threadimpl.h" -int _threaddebuglevel; +int _threaddebuglevel = 0; static uint threadnproc; static uint threadnsysproc; @@ -20,13 +20,16 @@ static void contextswitch(Context *from, Context *to); static void procmain(Proc*); static void procscheduler(Proc*); static int threadinfo(void*, char*); +static void pthreadscheduler(Proc *p); +static void pthreadsleepschedlocked(Proc *p, _Thread *t); +static void pthreadwakeupschedlocked(Proc *p, _Thread *self, _Thread *t); +static _Thread* procnext(Proc*, _Thread*); static void -_threaddebug(char *fmt, ...) +_threaddebug(_Thread *t, char *fmt, ...) { va_list arg; char buf[128]; - _Thread *t; char *p; static int fd = -1; @@ -52,7 +55,8 @@ _threaddebug(char *fmt, ...) va_start(arg, fmt); vsnprint(buf, sizeof buf, fmt, arg); va_end(arg); - t = proc()->thread; + if(t == nil) + t = proc()->thread; if(t) fprint(fd, "%p %d.%d: %s\n", proc(), getpid(), t->id, buf); else @@ -181,10 +185,15 @@ _threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) stack = 0; // not using it t = threadalloc(fn, arg, stack); t->proc = p; - if(p->nthread == 0) - p->thread0 = t; - else if(pthreadperthread) - _threadpthreadstart(p, t); + if(pthreadperthread) { + if(p->nthread != 0) + _threadpthreadstart(p, t); + else + t->mainthread = 1; + } else { + if(p->nthread == 0) + p->thread0 = t; + } p->nthread++; addthreadinproc(p, t); _threadready(t); @@ -197,6 +206,7 @@ threadcreate(void (*fn)(void*), void *arg, uint stack) _Thread *t; t = _threadcreate(proc(), fn, arg, stack); + _threaddebug(nil, "threadcreate %d", t->id); return t->id; } @@ -210,41 +220,11 @@ proccreate(void (*fn)(void*), void *arg, uint stack) p = procalloc(); t = _threadcreate(p, fn, arg, stack); id = t->id; /* t might be freed after _procstart */ + _threaddebug(t, "proccreate %p", p); _procstart(p, procmain); return id; } -// For pthreadperthread mode, procswitch flips -// between the threads. -static void -procswitch(Proc *p, _Thread *from, _Thread *to) -{ - _threaddebug("procswitch %p %d %d", p, from?from->id:-1, to?to->id:-1); - lock(&p->schedlock); - from->schedrend.l = &p->schedlock; - if(to) { - p->schedthread = to; - to->schedrend.l = &p->schedlock; - _threaddebug("procswitch wakeup %p %d", p, to->id); - _procwakeup(&to->schedrend); - } - if(p->schedthread != from) { - if(from->exiting) { - unlock(&p->schedlock); - _threadpexit(); - _threaddebug("procswitch exit wakeup!!!\n"); - } - while(p->schedthread != from) { - _threaddebug("procswitch sleep %p %d", p, from->id); - _procsleep(&from->schedrend); - _threaddebug("procswitch awake %p %d", p, from->id); - } - if(p->schedthread != from) - sysfatal("_procswitch %p %p oops", p->schedthread, from); - } - unlock(&p->schedlock); -} - void _threadswitch(void) { @@ -255,10 +235,10 @@ _threadswitch(void) /*print("threadswtch %p\n", p); */ - if(p->thread == p->thread0) + if(pthreadperthread) + pthreadscheduler(p); + else if(p->thread == p->thread0) procscheduler(p); - else if(pthreadperthread) - procswitch(p, p->thread, p->thread0); else contextswitch(&p->thread->context, &p->schedcontext); } @@ -390,7 +370,10 @@ void _threadpthreadmain(Proc *p, _Thread *t) { _threadsetproc(p); - procswitch(p, t, nil); + lock(&p->lock); + pthreadsleepschedlocked(p, t); + unlock(&p->lock); + _threaddebug(nil, "startfn"); t->startfn(t->startarg); threadexits(nil); } @@ -400,76 +383,47 @@ procscheduler(Proc *p) { _Thread *t; - _threaddebug("scheduler enter"); + _threaddebug(nil, "scheduler enter"); //print("s %p\n", p); -Top: - lock(&p->lock); - t = p->thread; - p->thread = nil; - if(t->exiting){ - delthreadinproc(p, t); - p->nthread--; -/*print("nthread %d\n", p->nthread); */ - _threadstkfree(t->stk, t->stksize); - /* - * 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(;;){ - if((t = p->pinthread) != nil){ - while(!onlist(&p->runqueue, t)){ - p->runrend.l = &p->lock; - _threaddebug("scheduler sleep (pin)"); - _procsleep(&p->runrend); - _threaddebug("scheduler wake (pin)"); - } - }else - while((t = p->runqueue.head) == nil){ - if(p->nthread == 0) - goto Out; - if((t = p->idlequeue.head) != nil){ - /* - * Run all the idling threads once. - */ - while((t = p->idlequeue.head) != nil){ - delthread(&p->idlequeue, t); - addthread(&p->runqueue, t); - } - continue; - } - p->runrend.l = &p->lock; - _threaddebug("scheduler sleep"); - _procsleep(&p->runrend); - _threaddebug("scheduler wake"); + for(;;) { + /* Finish running current thread. */ + lock(&p->lock); + t = p->thread; + p->thread = nil; + if(t->exiting){ + delthreadinproc(p, t); + p->nthread--; + /*print("nthread %d\n", p->nthread); */ + _threadstkfree(t->stk, t->stksize); + /* + * 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); } - if(p->pinthread && p->pinthread != t) - fprint(2, "p->pinthread %p t %p\n", p->pinthread, t); - assert(p->pinthread == nil || p->pinthread == t); - delthread(&p->runqueue, t); + + /* Pick next thread. */ + t = procnext(p, nil); + if(t == nil) + break; + _threaddebug(nil, "run %d (%s)", t->id, t->name); + //print("run %p %p %p %p\n", t, *(uintptr*)(t->context.uc.mc.sp), t->context.uc.mc.di, t->context.uc.mc.si); unlock(&p->lock); - p->thread = t; - p->nswitch++; - _threaddebug("run %d (%s)", t->id, t->name); -//print("run %p %p %p %p\n", t, *(uintptr*)(t->context.uc.mc.sp), t->context.uc.mc.di, t->context.uc.mc.si); + + /* Switch to next thread. */ if(t == p->thread0) return; - if(pthreadperthread) - procswitch(p, p->thread0, t); - else - contextswitch(&p->schedcontext, &t->context); - _threaddebug("back in scheduler"); -/*print("back in scheduler\n"); */ - goto Top; + contextswitch(&p->schedcontext, &t->context); + + _threaddebug(nil, "back in scheduler"); + /*print("back in scheduler\n"); */ } -Out: - _threaddebug("scheduler exit"); + /* No more threads in proc. Clean up. */ + _threaddebug(nil, "scheduler exit"); if(p->mainproc){ /* * Stupid bug - on Linux 2.6 and maybe elsewhere, @@ -502,6 +456,125 @@ procscheduler(Proc *p) _threadpexit(); } +static void +pthreadsleepschedlocked(Proc *p, _Thread *t) +{ + _threaddebug(t, "pthreadsleepsched %p %d", p, t->id);; + t->schedrend.l = &p->lock; + while(p->schedthread != t) + _procsleep(&t->schedrend); +} + +static void +pthreadwakeupschedlocked(Proc *p, _Thread *self, _Thread *t) +{ + _threaddebug(self, "pthreadwakeupschedlocked %p %d", p, t->id);; + t->schedrend.l = &p->schedlock; + p->schedthread = t; + _procwakeup(&t->schedrend); +} + +static void +pthreadscheduler(Proc *p) +{ + _Thread *self, *t; + + _threaddebug(nil, "scheduler"); + lock(&p->lock); + self = p->thread; + p->thread = nil; + _threaddebug(self, "pausing"); + + if(self->exiting) { + _threaddebug(self, "exiting"); + delthreadinproc(p, self); + p->nthread--; + } + + t = procnext(p, self); + if(t != nil) { + pthreadwakeupschedlocked(p, self, t); + if(!self->exiting) { + pthreadsleepschedlocked(p, self); + _threaddebug(nil, "resume %d", self->id); + unlock(&p->lock); + return; + } + } + + if(t == nil) { + /* Tear down proc bookkeeping. Wait to free p. */ + delproc(p); + lock(&threadnproclock); + if(p->sysproc) + --threadnsysproc; + if(--threadnproc == threadnsysproc) + threadexitsall(p->msg); + unlock(&threadnproclock); + } + + /* Tear down pthread. */ + if(self->mainthread && p->mainproc) { + _threaddaemonize(); + _threaddebug(self, "sleeper"); + unlock(&p->lock); + /* + * Avoid bugs with main pthread exiting. + * When all procs are gone, threadexitsall above will happen. + */ + for(;;) + sleep(60*60*1000); + } + _threadsetproc(nil); + free(self); + unlock(&p->lock); + if(t == nil) + free(p); + _threadpexit(); +} + +static _Thread* +procnext(Proc *p, _Thread *self) +{ + _Thread *t; + + if((t = p->pinthread) != nil){ + while(!onlist(&p->runqueue, t)){ + p->runrend.l = &p->lock; + _threaddebug(self, "scheduler sleep (pin)"); + _procsleep(&p->runrend); + _threaddebug(self, "scheduler wake (pin)"); + } + } else + while((t = p->runqueue.head) == nil){ + if(p->nthread == 0) + return nil; + if((t = p->idlequeue.head) != nil){ + /* + * Run all the idling threads once. + */ + while((t = p->idlequeue.head) != nil){ + delthread(&p->idlequeue, t); + addthread(&p->runqueue, t); + } + continue; + } + p->runrend.l = &p->lock; + _threaddebug(self, "scheduler sleep"); + _procsleep(&p->runrend); + _threaddebug(self, "scheduler wake"); + } + + if(p->pinthread && p->pinthread != t) + fprint(2, "p->pinthread %p t %p\n", p->pinthread, t); + assert(p->pinthread == nil || p->pinthread == t); + delthread(&p->runqueue, t); + + p->thread = t; + p->nswitch++; + return t; +} + void _threadsetsysproc(void) { @@ -784,14 +857,18 @@ threadrwakeup(Rendez *r, int all, ulong pc) int i; _Thread *t; + _threaddebug(nil, "rwakeup %p %d", r, all); for(i=0;; i++){ if(i==1 && !all) break; if((t = r->waiting.head) == nil) break; + _threaddebug(nil, "rwakeup %p %d -> wake %d", r, all, t->id); delthread(&r->waiting, t); _threadready(t); + _threaddebug(nil, "rwakeup %p %d -> loop", r, all); } + _threaddebug(nil, "rwakeup %p %d -> total %d", r, all, i); return i; } @@ -827,6 +904,7 @@ int main(int argc, char **argv) { Proc *p; + _Thread *t; char *opts; argv0 = argv[0]; @@ -875,7 +953,8 @@ main(int argc, char **argv) if(mainstacksize == 0) mainstacksize = 256*1024; atnotify(threadinfo, 1); - _threadcreate(p, threadmainstart, nil, mainstacksize); + t = _threadcreate(p, threadmainstart, nil, mainstacksize); + t->mainthread = 1; procmain(p); sysfatal("procscheduler returned in threadmain!"); /* does not return */ diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 8d22a161c..14646031d 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -97,6 +97,7 @@ struct _Thread uchar *stk; uint stksize; int exiting; + int mainthread; Proc *proc; char name[256]; char state[256]; From e68f07d46f5f168dc2076286627279540bf1f99e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 00:16:10 -0500 Subject: [PATCH 273/323] libthread: make pthreadperthread the default --- man/man3/thread.3 | 34 ++++++++++++++-------------------- src/libthread/thread.c | 2 +- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/man/man3/thread.3 b/man/man3/thread.3 index 02e4c8686..c0a59091b 100644 --- a/man/man3/thread.3 +++ b/man/man3/thread.3 @@ -158,27 +158,21 @@ by The thread library provides a .I main function that sets up a proc with a single thread executing -.I threadmain -on a stack of size -.I mainstacksize -(default eight kilobytes). -To set -.IR mainstacksize , -declare a global variable -initialized to the desired value -.RI ( e.g. , -.B int -.B mainstacksize -.B = -.BR 1024 ). -When using the +.IR threadmain . +.PP +Every thread is backed by an operating system-provided .I pthread -library, -.B mainstacksize -is ignored, as is the stack size argument to -.BR proccreate : -the first thread in each proc -runs on the native system stack. +and runs on its system-provided stack; +.I mainstacksize +and the the stack size arguments to +.I proccreate +and +.I threadcreate +are ignored. +Although each thread is backed by a separate +.IR pthread , +the threads in a proc are still scheduled non-preemptively +as on Plan 9 and as described below. .PP .I Threadcreate creates a new thread in the calling proc, returning a unique integer diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 94173ebc6..0c7640001 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -7,7 +7,7 @@ static uint threadnsysproc; static Lock threadnproclock; static Ref threadidref; static Proc *threadmainproc; -static int pthreadperthread; +static int pthreadperthread = 1; static void addproc(Proc*); static void delproc(Proc*); From 18571208068d5fe2f0bf7b4e980525a7f577c503 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 07:18:30 -0500 Subject: [PATCH 274/323] libthread: simplify Now that everything uses pthreads and pthreadperthread, can delete various conditionals, all the custom context code, and so on. Also update documents. Fixes #355. --- include/libc.h | 2 - include/u.h | 7 +- src/libthread/386-ucontext.c | 22 -- src/libthread/386-ucontext.h | 119 ------- src/libthread/COPYING.SPARC64-CONTEXT | 458 -------------------------- src/libthread/COPYRIGHT | 9 - src/libthread/Linux-arm-asm.s | 41 --- src/libthread/Linux-sparc64-context.S | 135 -------- src/libthread/OpenBSD-386-asm.s | 45 --- src/libthread/OpenBSD-power-asm.S | 73 ---- src/libthread/OpenBSD-x86_64-asm.S | 44 --- src/libthread/arm-ucontext.c | 24 -- src/libthread/mkfile | 3 +- src/libthread/power-ucontext.c | 26 -- src/libthread/power-ucontext.h | 36 -- src/libthread/sparc64-ucontext.c | 49 --- src/libthread/stkmalloc.c | 13 - src/libthread/stkmmap.c | 25 -- src/libthread/sysofiles.sh | 27 -- src/libthread/thread.c | 217 +----------- src/libthread/threadimpl.h | 44 --- src/libthread/x86_64-ucontext.c | 28 -- src/libthread/x86_64-ucontext.h | 42 --- 23 files changed, 12 insertions(+), 1477 deletions(-) delete mode 100644 src/libthread/386-ucontext.c delete mode 100644 src/libthread/386-ucontext.h delete mode 100644 src/libthread/COPYING.SPARC64-CONTEXT delete mode 100644 src/libthread/Linux-arm-asm.s delete mode 100644 src/libthread/Linux-sparc64-context.S delete mode 100644 src/libthread/OpenBSD-386-asm.s delete mode 100644 src/libthread/OpenBSD-power-asm.S delete mode 100644 src/libthread/OpenBSD-x86_64-asm.S delete mode 100644 src/libthread/arm-ucontext.c delete mode 100644 src/libthread/power-ucontext.c delete mode 100644 src/libthread/power-ucontext.h delete mode 100644 src/libthread/sparc64-ucontext.c delete mode 100644 src/libthread/stkmalloc.c delete mode 100644 src/libthread/stkmmap.c delete mode 100644 src/libthread/sysofiles.sh delete mode 100644 src/libthread/x86_64-ucontext.c delete mode 100644 src/libthread/x86_64-ucontext.h diff --git a/include/libc.h b/include/libc.h index 4bb537d67..1e24f0bb3 100644 --- a/include/libc.h +++ b/include/libc.h @@ -473,10 +473,8 @@ extern _Thread *(*threadnow)(void); typedef struct Lock Lock; struct Lock { -#ifdef PLAN9PORT_USING_PTHREADS int init; pthread_mutex_t mutex; -#endif int held; }; diff --git a/include/u.h b/include/u.h index f84e348a6..856e10f4c 100644 --- a/include/u.h +++ b/include/u.h @@ -67,7 +67,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #if defined(__linux__) # include # include -# define PLAN9PORT_USING_PTHREADS 1 # if defined(__USE_MISC) # undef _NEEDUSHORT # undef _NEEDUINT @@ -76,7 +75,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #elif defined(__sun__) # include # include -# define PLAN9PORT_USING_PTHREADS 1 # undef _NEEDUSHORT # undef _NEEDUINT # undef _NEEDULONG @@ -84,7 +82,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #elif defined(__FreeBSD__) # include # include -# define PLAN9PORT_USING_PTHREADS 1 # include # if !defined(_POSIX_SOURCE) # undef _NEEDUSHORT @@ -93,7 +90,6 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #elif defined(__APPLE__) # include # include -# define PLAN9PORT_USING_PTHREADS 1 # if __GNUC__ < 4 # undef _NEEDUSHORT # undef _NEEDUINT @@ -108,20 +104,19 @@ typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; #elif defined(__NetBSD__) # include # include +# include # undef _NEEDUSHORT # undef _NEEDUINT # undef _NEEDULONG #elif defined(__OpenBSD__) # include # include -# define PLAN9PORT_USING_PTHREADS 1 # undef _NEEDUSHORT # undef _NEEDUINT # undef _NEEDULONG #else /* No idea what system this is -- try some defaults */ # include -# define PLAN9PORT_USING_PTHREADS 1 #endif #ifndef O_DIRECT diff --git a/src/libthread/386-ucontext.c b/src/libthread/386-ucontext.c deleted file mode 100644 index 3afa9513d..000000000 --- a/src/libthread/386-ucontext.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - int *sp; - - sp = USPALIGN(ucp, 4); - sp -= argc; - memmove(sp, &argc+1, argc*sizeof(int)); - *--sp = 0; /* return address */ - ucp->uc_mcontext.mc_eip = (long)func; - ucp->uc_mcontext.mc_esp = (int)sp; -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/386-ucontext.h b/src/libthread/386-ucontext.h deleted file mode 100644 index b1ee81b30..000000000 --- a/src/libthread/386-ucontext.h +++ /dev/null @@ -1,119 +0,0 @@ -#define setcontext(u) setmcontext(&(u)->uc_mcontext) -#define getcontext(u) getmcontext(&(u)->uc_mcontext) -typedef struct mcontext mcontext_t; -typedef struct ucontext ucontext_t; - -extern int swapcontext(ucontext_t*, ucontext_t*); -extern void makecontext(ucontext_t*, void(*)(), int, ...); -extern int getmcontext(mcontext_t*); -extern void setmcontext(mcontext_t*); - -/*- - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/sys/ucontext.h,v 1.4 1999/10/11 20:33:17 luoqi Exp $ - */ - -/* #include */ - -/*- - * Copyright (c) 1999 Marcel Moolenaar - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer - * in this position and unchanged. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.4 1999/10/11 20:33:09 luoqi Exp $ - */ - -struct mcontext { - /* - * The first 20 fields must match the definition of - * sigcontext. So that we can support sigcontext - * and ucontext_t at the same time. - */ - int mc_onstack; /* XXX - sigcontext compat. */ - int mc_gs; - int mc_fs; - int mc_es; - int mc_ds; - int mc_edi; - int mc_esi; - int mc_ebp; - int mc_isp; - int mc_ebx; - int mc_edx; - int mc_ecx; - int mc_eax; - int mc_trapno; - int mc_err; - int mc_eip; - int mc_cs; - int mc_eflags; - int mc_esp; /* machine state */ - int mc_ss; - - int mc_fpregs[28]; /* env87 + fpacc87 + u_long */ - int __spare__[17]; -}; - -struct ucontext { - /* - * Keep the order of the first two fields. Also, - * keep them the first two fields in the structure. - * This way we can have a union with struct - * sigcontext and ucontext_t. This allows us to - * support them both at the same time. - * note: the union is not defined, though. - */ - sigset_t uc_sigmask; - mcontext_t uc_mcontext; - - struct __ucontext *uc_link; - stack_t uc_stack; - int __spare__[8]; -}; diff --git a/src/libthread/COPYING.SPARC64-CONTEXT b/src/libthread/COPYING.SPARC64-CONTEXT deleted file mode 100644 index 3b204400c..000000000 --- a/src/libthread/COPYING.SPARC64-CONTEXT +++ /dev/null @@ -1,458 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/src/libthread/COPYRIGHT b/src/libthread/COPYRIGHT index d08209658..212b96bc2 100644 --- a/src/libthread/COPYRIGHT +++ b/src/libthread/COPYRIGHT @@ -42,12 +42,3 @@ Contains parts of an earlier library that has: * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ - -=== - -The above notices do *NOT* apply to Linux-sparc64-context.S -or to sparc64-ucontext.c. Those are functions from -the GNU C library and are provided for systems that use the GNU C -library but somehow are missing those functions. They are -distributed under the Lesser GPL; see COPYING.SPARC64-CONTEXT. - diff --git a/src/libthread/Linux-arm-asm.s b/src/libthread/Linux-arm-asm.s deleted file mode 100644 index 9bd54f8af..000000000 --- a/src/libthread/Linux-arm-asm.s +++ /dev/null @@ -1,41 +0,0 @@ -.globl mygetmcontext -mygetmcontext: - str r1, [r0,#4] - str r2, [r0,#8] - str r3, [r0,#12] - str r4, [r0,#16] - str r5, [r0,#20] - str r6, [r0,#24] - str r7, [r0,#28] - str r8, [r0,#32] - str r9, [r0,#36] - str r10, [r0,#40] - str r11, [r0,#44] - str r12, [r0,#48] - str r13, [r0,#52] - str r14, [r0,#56] - /* store 1 as r0-to-restore */ - mov r1, #1 - str r1, [r0] - /* return 0 */ - mov r0, #0 - mov pc, lr - -.globl mysetmcontext -mysetmcontext: - ldr r1, [r0,#4] - ldr r2, [r0,#8] - ldr r3, [r0,#12] - ldr r4, [r0,#16] - ldr r5, [r0,#20] - ldr r6, [r0,#24] - ldr r7, [r0,#28] - ldr r8, [r0,#32] - ldr r9, [r0,#36] - ldr r10, [r0,#40] - ldr r11, [r0,#44] - ldr r12, [r0,#48] - ldr r13, [r0,#52] - ldr r14, [r0,#56] - ldr r0, [r0] - mov pc, lr diff --git a/src/libthread/Linux-sparc64-context.S b/src/libthread/Linux-sparc64-context.S deleted file mode 100644 index 1cc383913..000000000 --- a/src/libthread/Linux-sparc64-context.S +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* Constants shared between setcontext() and getcontext(). Don't - install this header file. */ - - -#define UC_LINK 0 -#define __UC_SIGMASK 16 -#define UC_M_PC 40 -#define UC_M_NPC 48 -#define UC_SIGMASK 536 -#define SIGMASK_WORDS 16 - -/* Copyright (C) 1997, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Richard Henderson (rth@tamu.edu). - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#define ENTRY(x) x: -#define END(x) - -/*#include "ucontext_i.h" (up above) */ - -/* int getcontext(ucontext_t *); */ - -ENTRY(getcontext) - - ldx [%o0 + UC_LINK], %o1 /* Preserve uc_link field, the - trap clears it. */ - ta 0x6e -1: - ldx [%o0 + UC_M_PC], %o2 - ldx [%o0 + UC_M_NPC], %o3 - ldx [%o0 + __UC_SIGMASK], %o4 - stx %o1, [%o0 + UC_LINK] - add %o2, 2f - 1b, %o2 - stx %o2, [%o0 + UC_M_PC] - add %o3, 2f - 1b, %o3 - stx %o3, [%o0 + UC_M_NPC] -#if SIGMASK_WORDS == 16 - stx %o4, [%o0 + UC_SIGMASK] - stx %g0, [%o0 + UC_SIGMASK + 8] - stx %g0, [%o0 + UC_SIGMASK + 16] - stx %g0, [%o0 + UC_SIGMASK + 24] - stx %g0, [%o0 + UC_SIGMASK + 32] - stx %g0, [%o0 + UC_SIGMASK + 40] - stx %g0, [%o0 + UC_SIGMASK + 48] - stx %g0, [%o0 + UC_SIGMASK + 56] - stx %g0, [%o0 + UC_SIGMASK + 64] - stx %g0, [%o0 + UC_SIGMASK + 72] - stx %g0, [%o0 + UC_SIGMASK + 80] - stx %g0, [%o0 + UC_SIGMASK + 88] - stx %g0, [%o0 + UC_SIGMASK + 96] - stx %g0, [%o0 + UC_SIGMASK + 104] - stx %g0, [%o0 + UC_SIGMASK + 112] - stx %g0, [%o0 + UC_SIGMASK + 120] -#else -# error Adjust getcontext -#endif -2: - retl - clr %o0 - -END(getcontext) - -/* Copyright (C) 1997, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Richard Henderson (rth@tamu.edu). - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -/* -#include -#include "ucontext_i.h" -*/ - -/* int setcontext(ucontext_t *ctx); */ -.weak setcontext -ENTRY(setcontext) - - mov 1, %o1 - -/* int __setcontext(ucontext_t *ctx, int restoremask); */ -ENTRY(__setcontext) - - ldx [%o0 + UC_SIGMASK], %o2 - stx %o2, [%o0 + __UC_SIGMASK] - ta 0x6f - -END(__setcontext) - diff --git a/src/libthread/OpenBSD-386-asm.s b/src/libthread/OpenBSD-386-asm.s deleted file mode 100644 index ed18d2f0b..000000000 --- a/src/libthread/OpenBSD-386-asm.s +++ /dev/null @@ -1,45 +0,0 @@ -.globl getmcontext -getmcontext: - movl 4(%esp), %eax - - movl %fs, 8(%eax) - movl %es, 12(%eax) - movl %ds, 16(%eax) - movl %ss, 76(%eax) - movl %edi, 20(%eax) - movl %esi, 24(%eax) - movl %ebp, 28(%eax) - movl %ebx, 36(%eax) - movl %edx, 40(%eax) - movl %ecx, 44(%eax) - - movl $1, 48(%eax) /* %eax */ - movl (%esp), %ecx /* %eip */ - movl %ecx, 60(%eax) - leal 4(%esp), %ecx /* %esp */ - movl %ecx, 72(%eax) - - movl 44(%eax), %ecx /* restore %ecx */ - movl $0, %eax - ret - -.globl setmcontext -setmcontext: - movl 4(%esp), %eax - - movl 8(%eax), %fs - movl 12(%eax), %es - movl 16(%eax), %ds - movl 76(%eax), %ss - movl 20(%eax), %edi - movl 24(%eax), %esi - movl 28(%eax), %ebp - movl 36(%eax), %ebx - movl 40(%eax), %edx - movl 44(%eax), %ecx - - movl 72(%eax), %esp - pushl 60(%eax) /* new %eip */ - movl 48(%eax), %eax - ret - diff --git a/src/libthread/OpenBSD-power-asm.S b/src/libthread/OpenBSD-power-asm.S deleted file mode 100644 index 36035eb56..000000000 --- a/src/libthread/OpenBSD-power-asm.S +++ /dev/null @@ -1,73 +0,0 @@ -ENTRY(_getmcontext) /* xxx: instruction scheduling */ - mflr %r0 - mfcr %r5 - mfctr %r6 - mfxer %r7 - stw %r0, 0*4(%r3) - stw %r5, 1*4(%r3) - stw %r6, 2*4(%r3) - stw %r7, 3*4(%r3) - - stw %r1, 4*4(%r3) - stw %r2, 5*4(%r3) - li %r5, 1 /* return value for setmcontext */ - stw %r5, 6*4(%r3) - - stw %r13, (0+7)*4(%r3) /* callee-save GPRs */ - stw %r14, (1+7)*4(%r3) /* xxx: block move */ - stw %r15, (2+7)*4(%r3) - stw %r16, (3+7)*4(%r3) - stw %r17, (4+7)*4(%r3) - stw %r18, (5+7)*4(%r3) - stw %r19, (6+7)*4(%r3) - stw %r20, (7+7)*4(%r3) - stw %r21, (8+7)*4(%r3) - stw %r22, (9+7)*4(%r3) - stw %r23, (10+7)*4(%r3) - stw %r24, (11+7)*4(%r3) - stw %r25, (12+7)*4(%r3) - stw %r26, (13+7)*4(%r3) - stw %r27, (14+7)*4(%r3) - stw %r28, (15+7)*4(%r3) - stw %r29, (16+7)*4(%r3) - stw %r30, (17+7)*4(%r3) - stw %r31, (18+7)*4(%r3) - - li %r3, 0 /* return */ - blr - -ENTRY(_setmcontext) - lwz %r13, (0+7)*4(%r3) /* callee-save GPRs */ - lwz %r14, (1+7)*4(%r3) /* xxx: block move */ - lwz %r15, (2+7)*4(%r3) - lwz %r16, (3+7)*4(%r3) - lwz %r17, (4+7)*4(%r3) - lwz %r18, (5+7)*4(%r3) - lwz %r19, (6+7)*4(%r3) - lwz %r20, (7+7)*4(%r3) - lwz %r21, (8+7)*4(%r3) - lwz %r22, (9+7)*4(%r3) - lwz %r23, (10+7)*4(%r3) - lwz %r24, (11+7)*4(%r3) - lwz %r25, (12+7)*4(%r3) - lwz %r26, (13+7)*4(%r3) - lwz %r27, (14+7)*4(%r3) - lwz %r28, (15+7)*4(%r3) - lwz %r29, (16+7)*4(%r3) - lwz %r30, (17+7)*4(%r3) - lwz %r31, (18+7)*4(%r3) - - lwz %r1, 4*4(%r3) - lwz %r2, 5*4(%r3) - - lwz %r0, 0*4(%r3) - mtlr %r0 - lwz %r0, 1*4(%r3) - mtcr %r0 /* mtcrf 0xFF, %r0 */ - lwz %r0, 2*4(%r3) - mtctr %r0 - lwz %r0, 3*4(%r3) - mtxer %r0 - - lwz %r3, 6*4(%r3) - blr diff --git a/src/libthread/OpenBSD-x86_64-asm.S b/src/libthread/OpenBSD-x86_64-asm.S deleted file mode 100644 index e982cdef8..000000000 --- a/src/libthread/OpenBSD-x86_64-asm.S +++ /dev/null @@ -1,44 +0,0 @@ -.text -.align 8 - -.globl libthread_getmcontext -libthread_getmcontext: - movq $1, 0*8(%rdi) // rax - movq %rbx, 1*8(%rdi) - movq %rcx, 2*8(%rdi) - movq %rdx, 3*8(%rdi) - movq %rsi, 4*8(%rdi) - movq %rdi, 5*8(%rdi) - movq %rbp, 6*8(%rdi) - movq %rsp, 7*8(%rdi) - movq %r8, 8*8(%rdi) - movq %r9, 9*8(%rdi) - movq %r10, 10*8(%rdi) - movq %r11, 11*8(%rdi) - movq %r12, 12*8(%rdi) - movq %r13, 13*8(%rdi) - movq %r14, 14*8(%rdi) - movq %r15, 15*8(%rdi) - movq $0, %rax - ret - -.globl libthread_setmcontext -libthread_setmcontext: - movq 0*8(%rdi), %rax - movq 1*8(%rdi), %rbx - movq 2*8(%rdi), %rcx - movq 3*8(%rdi), %rdx - movq 4*8(%rdi), %rsi - // %rdi later - movq 6*8(%rdi), %rbp - movq 7*8(%rdi), %rsp - movq 8*8(%rdi), %r8 - movq 9*8(%rdi), %r9 - movq 10*8(%rdi), %r10 - movq 11*8(%rdi), %r11 - movq 12*8(%rdi), %r12 - movq 13*8(%rdi), %r13 - movq 14*8(%rdi), %r14 - movq 15*8(%rdi), %r15 - movq 5*8(%rdi), %rdi - ret diff --git a/src/libthread/arm-ucontext.c b/src/libthread/arm-ucontext.c deleted file mode 100644 index 512ca973d..000000000 --- a/src/libthread/arm-ucontext.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) -{ - int i, *sp; - va_list arg; - - sp = USPALIGN(uc, 4); - va_start(arg, argc); - for(i=0; i<4 && iuc_mcontext.arm_r0)[i] = va_arg(arg, uint); - va_end(arg); - uc->uc_mcontext.arm_sp = (uint)sp; - uc->uc_mcontext.arm_lr = (uint)fn; -} - -int -swapcontext(ucontext_t *oucp, const ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/mkfile b/src/libthread/mkfile index eca4f4df4..40941f439 100644 --- a/src/libthread/mkfile +++ b/src/libthread/mkfile @@ -1,15 +1,14 @@ <$PLAN9/src/mkhdr -SYSOFILES=`{sh ./sysofiles.sh} LIB=libthread.a OFILES=\ - $SYSOFILES\ bg.$O\ channel.$O\ daemonize.$O\ exec.$O\ ioproc.$O\ iorw.$O\ + pthread.$O\ ref.$O\ thread.$O\ wait.$O\ diff --git a/src/libthread/power-ucontext.c b/src/libthread/power-ucontext.c deleted file mode 100644 index 32a8e931f..000000000 --- a/src/libthread/power-ucontext.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - ulong *sp, *tos; - va_list arg; - - if(argc != 2) - sysfatal("libthread: makecontext misused"); - sp = USPALIGN(ucp, 16); - ucp->mc.pc = (long)func; - ucp->mc.sp = (long)sp; - va_start(arg, argc); - ucp->mc.r3 = va_arg(arg, long); - ucp->mc.r4 = va_arg(arg, long); - va_end(arg); -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/power-ucontext.h b/src/libthread/power-ucontext.h deleted file mode 100644 index 1985d98d2..000000000 --- a/src/libthread/power-ucontext.h +++ /dev/null @@ -1,36 +0,0 @@ -#define setcontext(u) _setmcontext(&(u)->mc) -#define getcontext(u) _getmcontext(&(u)->mc) -typedef struct mcontext mcontext_t; -typedef struct ucontext ucontext_t; -struct mcontext -{ - ulong pc; /* lr */ - ulong cr; /* mfcr */ - ulong ctr; /* mfcr */ - ulong xer; /* mfcr */ - ulong sp; /* callee saved: r1 */ - ulong toc; /* callee saved: r2 */ - ulong r3; /* first arg to function, return register: r3 */ - ulong gpr[19]; /* callee saved: r13-r31 */ -/* -// XXX: currently do not save vector registers or floating-point state -// ulong pad; -// uvlong fpr[18]; / * callee saved: f14-f31 * / -// ulong vr[4*12]; / * callee saved: v20-v31, 256-bits each * / -*/ -}; - -struct ucontext -{ - struct { - void *ss_sp; - uint ss_size; - } uc_stack; - sigset_t uc_sigmask; - mcontext_t mc; -}; - -void makecontext(ucontext_t*, void(*)(void), int, ...); -int swapcontext(ucontext_t*, ucontext_t*); -int _getmcontext(mcontext_t*); -void _setmcontext(mcontext_t*); diff --git a/src/libthread/sparc64-ucontext.c b/src/libthread/sparc64-ucontext.c deleted file mode 100644 index e4800c19c..000000000 --- a/src/libthread/sparc64-ucontext.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -#define UC_M_PC 40 -#define UC_M_NPC 48 - -extern int __getcontext (ucontext_t *ucp); -extern int __setcontext (const ucontext_t *ucp, int restoremask); - -int -swapcontext (ucontext_t *oucp, const ucontext_t *ucp) -{ - extern void __swapcontext_ret (void); - /* Save the current machine context to oucp. */ - __getcontext (oucp); - /* Modify oucp to skip the __setcontext call on reactivation. */ - *(long*)((char*)oucp+UC_M_PC) = (long)__swapcontext_ret; - *(long*)((char*)oucp+UC_M_NPC) = (long)__swapcontext_ret + 4; - /* Restore the machine context in ucp. */ - __setcontext (ucp, 1); - return 0; -} - -asm (" \n\ - .text \n\ - .type __swapcontext_ret, #function \n\ -__swapcontext_ret: \n\ - return %i7 + 8 \n\ - clr %o0 \n\ - .size __swapcontext_ret, .-__swapcontext_ret \n\ - "); diff --git a/src/libthread/stkmalloc.c b/src/libthread/stkmalloc.c deleted file mode 100644 index 083aea1b9..000000000 --- a/src/libthread/stkmalloc.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "threadimpl.h" - -void* -_threadstkalloc(int n) -{ - return malloc(n); -} - -void -_threadstkfree(void *v, int n) -{ - free(v); -} diff --git a/src/libthread/stkmmap.c b/src/libthread/stkmmap.c deleted file mode 100644 index f4a246308..000000000 --- a/src/libthread/stkmmap.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include "threadimpl.h" - -#ifndef MAP_STACK -#define MAP_STACK 0 -#endif - -void* -_threadstkalloc(int n) -{ - void *p; - - p = mmap(nil, n, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON|MAP_STACK, -1, 0); - if(p == (void*)-1) - return nil; - return p; -} - -void -_threadstkfree(void *v, int n) -{ - if(n > 0) - munmap(v, n); -} diff --git a/src/libthread/sysofiles.sh b/src/libthread/sysofiles.sh deleted file mode 100644 index cf9e02347..000000000 --- a/src/libthread/sysofiles.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -test -f $PLAN9/config && . $PLAN9/config - -echo pthread.o - -case "$SYSNAME" in -OpenBSD) - echo stkmmap.o - ;; -*) - echo stkmalloc.o -esac - -# Various libc don't supply swapcontext, makecontext, so we do. -case "$SYSNAME-$OBJTYPE" in -Linux-arm | Linux-sparc64 | NetBSD-arm | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) - echo $OBJTYPE-ucontext.o - ;; -esac - -# A few libc don't supply setcontext, getcontext, so we do. -case "$SYSNAME-$OBJTYPE" in -Linux-arm | Linux-sparc64 | OpenBSD-386 | OpenBSD-power | OpenBSD-x86_64) - echo $SYSNAME-$OBJTYPE-asm.o - ;; -esac diff --git a/src/libthread/thread.c b/src/libthread/thread.c index 0c7640001..d72bf896d 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -7,7 +7,6 @@ static uint threadnsysproc; static Lock threadnproclock; static Ref threadidref; static Proc *threadmainproc; -static int pthreadperthread = 1; static void addproc(Proc*); static void delproc(Proc*); @@ -16,9 +15,7 @@ static void delthread(_Threadlist*, _Thread*); static int onlist(_Threadlist*, _Thread*); static void addthreadinproc(Proc*, _Thread*); static void delthreadinproc(Proc*, _Thread*); -static void contextswitch(Context *from, Context *to); static void procmain(Proc*); -static void procscheduler(Proc*); static int threadinfo(void*, char*); static void pthreadscheduler(Proc *p); static void pthreadsleepschedlocked(Proc *p, _Thread *t); @@ -86,114 +83,24 @@ procalloc(void) return p; } -static void -threadstart(uint y, uint x) -{ - _Thread *t; - ulong z; - -//print("threadstart\n"); - z = (ulong)x << 16; /* hide undefined 32-bit shift from 32-bit compilers */ - z <<= 16; - z |= y; - t = (_Thread*)z; - -//print("threadstart sp=%p arg=%p startfn=%p t=%p\n", &t, t, t->startfn, t->startarg); - t->startfn(t->startarg); -/*print("threadexits %p\n", v); */ - threadexits(nil); -/*print("not reacehd\n"); */ -} - -static _Thread* -threadalloc(void (*fn)(void*), void *arg, uint stack) +_Thread* +_threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) { _Thread *t; - sigset_t zero; - uint x, y; - ulong z; - /* allocate the task and stack together */ + USED(stack); t = malloc(sizeof *t); if(t == nil) - sysfatal("threadalloc malloc: %r"); + sysfatal("threadcreate malloc: %r"); memset(t, 0, sizeof *t); t->id = incref(&threadidref); -//print("fn=%p arg=%p\n", fn, arg); t->startfn = fn; t->startarg = arg; -//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); - - /* do a reasonable initialization */ - if(stack == 0) - return t; - t->stk = _threadstkalloc(stack); - if(t->stk == nil) - sysfatal("threadalloc malloc stack: %r"); - t->stksize = stack; - memset(&t->context.uc, 0, sizeof t->context.uc); - sigemptyset(&zero); - sigprocmask(SIG_BLOCK, &zero, &t->context.uc.uc_sigmask); -//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); - - /* must initialize with current context */ - if(getcontext(&t->context.uc) < 0) - sysfatal("threadalloc getcontext: %r"); -//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); - - /* - * Call makecontext to do the real work. - * To avoid various mistakes on other system software, - * debuggers, and so on, don't get too close to both - * ends of the stack. Just staying away is much easier - * than debugging everything (outside our control) - * that has off-by-one errors. - */ - t->context.uc.uc_stack.ss_sp = (void*)(t->stk+64); - t->context.uc.uc_stack.ss_size = t->stksize-2*64; -#if defined(__sun__) && !defined(__MAKECONTEXT_V2_SOURCE) /* sigh */ - /* can avoid this with __MAKECONTEXT_V2_SOURCE but only on SunOS 5.9 */ - t->context.uc.uc_stack.ss_sp = - (char*)t->context.uc.uc_stack.ss_sp - +t->context.uc.uc_stack.ss_size; -#endif - /* - * All this magic is because you have to pass makecontext a - * function that takes some number of word-sized variables, - * and on 64-bit machines pointers are bigger than words. - */ -//print("makecontext sp=%p t=%p startfn=%p\n", (char*)t->stk+t->stksize, t, t->startfn); - z = (ulong)t; - y = z; - z >>= 16; /* hide undefined 32-bit shift from 32-bit compilers */ - x = z>>16; - makecontext(&t->context.uc, (void(*)(void))threadstart, 2, y, x); - - return t; -} - -_Thread* -_threadcreate(Proc *p, void (*fn)(void*), void *arg, uint stack) -{ - _Thread *t; - - /* defend against bad C libraries */ - if(stack < (256<<10)) - stack = 256<<10; - - if(p->nthread == 0 || pthreadperthread) - stack = 0; // not using it - t = threadalloc(fn, arg, stack); t->proc = p; - if(pthreadperthread) { - if(p->nthread != 0) - _threadpthreadstart(p, t); - else - t->mainthread = 1; - } else { - if(p->nthread == 0) - p->thread0 = t; - } + if(p->nthread != 0) + _threadpthreadstart(p, t); + else + t->mainthread = 1; p->nthread++; addthreadinproc(p, t); _threadready(t); @@ -232,15 +139,8 @@ _threadswitch(void) needstack(0); p = proc(); - /*print("threadswtch %p\n", p); */ - - if(pthreadperthread) - pthreadscheduler(p); - else if(p->thread == p->thread0) - procscheduler(p); - else - contextswitch(&p->thread->context, &p->schedcontext); + pthreadscheduler(p); } void @@ -338,15 +238,6 @@ threadsysfatal(char *fmt, va_list arg) threadexitsall(buf); } -static void -contextswitch(Context *from, Context *to) -{ - if(swapcontext(&from->uc, &to->uc) < 0){ - fprint(2, "swapcontext failed: %r\n"); - assert(0); - } -} - static void procmain(Proc *p) { @@ -357,7 +248,6 @@ procmain(Proc *p) /* take out first thread to run on system stack */ t = p->runqueue.head; delthread(&p->runqueue, t); - memset(&t->context.uc, 0, sizeof t->context.uc); /* run it */ p->thread = t; @@ -378,84 +268,6 @@ _threadpthreadmain(Proc *p, _Thread *t) threadexits(nil); } -static void -procscheduler(Proc *p) -{ - _Thread *t; - - _threaddebug(nil, "scheduler enter"); -//print("s %p\n", p); - for(;;) { - /* Finish running current thread. */ - lock(&p->lock); - t = p->thread; - p->thread = nil; - if(t->exiting){ - delthreadinproc(p, t); - p->nthread--; - /*print("nthread %d\n", p->nthread); */ - _threadstkfree(t->stk, t->stksize); - /* - * 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); - } - - /* Pick next thread. */ - t = procnext(p, nil); - if(t == nil) - break; - _threaddebug(nil, "run %d (%s)", t->id, t->name); - //print("run %p %p %p %p\n", t, *(uintptr*)(t->context.uc.mc.sp), t->context.uc.mc.di, t->context.uc.mc.si); - unlock(&p->lock); - - /* Switch to next thread. */ - if(t == p->thread0) - return; - contextswitch(&p->schedcontext, &t->context); - - _threaddebug(nil, "back in scheduler"); - /*print("back in scheduler\n"); */ - } - - /* No more threads in proc. Clean up. */ - _threaddebug(nil, "scheduler exit"); - if(p->mainproc){ - /* - * Stupid bug - on Linux 2.6 and maybe elsewhere, - * if the main thread exits then the others keep running - * but the process shows up as a zombie in ps and is not - * attachable with ptrace. We'll just sit around pretending - * to be a system proc instead of exiting. - */ - _threaddaemonize(); - lock(&threadnproclock); - if(++threadnsysproc == threadnproc) - threadexitsall(p->msg); - p->sysproc = 1; - unlock(&threadnproclock); - for(;;) - sleep(1000); - } - - delproc(p); - lock(&threadnproclock); - if(p->sysproc) - --threadnsysproc; - if(--threadnproc == threadnsysproc) - threadexitsall(p->msg); - unlock(&threadnproclock); - unlock(&p->lock); - _threadsetproc(nil); - free(p->thread0); - free(p); - _threadpexit(); -} - static void pthreadsleepschedlocked(Proc *p, _Thread *t) { @@ -913,15 +725,6 @@ main(int argc, char **argv) if(opts == nil) opts = ""; - pthreadperthread = (strstr(opts, "pthreadperthread") != nil); -#ifdef PLAN9PORT_ASAN - // ASAN can't deal with the coroutine stack switches. - // In theory it has support for informing it about stack switches, - // but even with those calls added it can't deal with things - // like fork or exit from a coroutine stack. - // Easier to just run in pthread-per-thread mode. - pthreadperthread = 1; -#endif if(threadmaybackground() && strstr(opts, "nodaemon") == nil && getenv("NOLIBTHREADDAEMONIZE") == nil) _threadsetupdaemonize(); @@ -956,7 +759,7 @@ main(int argc, char **argv) t = _threadcreate(p, threadmainstart, nil, mainstacksize); t->mainthread = 1; procmain(p); - sysfatal("procscheduler returned in threadmain!"); + sysfatal("procmain returned in libthread"); /* does not return */ return 0; } diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 14646031d..9eddba21f 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -9,36 +9,11 @@ # if defined(__APPLE__) # define _XOPEN_SOURCE /* for Snow Leopard */ # endif -# include #endif #include #include "libc.h" #include "thread.h" -#if defined(__OpenBSD__) -# define mcontext libthread_mcontext -# define mcontext_t libthread_mcontext_t -# define ucontext libthread_ucontext -# define ucontext_t libthread_ucontext_t -# if defined __i386__ -# include "386-ucontext.h" -# elif defined __amd64__ -# include "x86_64-ucontext.h" -# else -# include "power-ucontext.h" -# endif -extern pid_t rfork_thread(int, void*, int(*)(void*), void*); -#endif - -#if defined(__arm__) -int mygetmcontext(ulong*); -void mysetmcontext(const ulong*); -#define setcontext(u) mysetmcontext(&(u)->uc_mcontext.arm_r0) -#define getcontext(u) mygetmcontext(&(u)->uc_mcontext.arm_r0) -#endif - - -typedef struct Context Context; typedef struct Execjob Execjob; typedef struct Proc Proc; typedef struct _Procrendez _Procrendez; @@ -54,11 +29,6 @@ enum STACK = 8192 }; -struct Context -{ - ucontext_t uc; -}; - struct Execjob { int *fd; @@ -72,11 +42,7 @@ struct _Procrendez { Lock *l; int asleep; -#ifdef PLAN9PORT_USING_PTHREADS pthread_cond_t cond; -#else - int pid; -#endif }; struct _Thread @@ -85,15 +51,10 @@ struct _Thread _Thread *prev; _Thread *allnext; _Thread *allprev; - Context context; void (*startfn)(void*); void *startarg; uint id; -#ifdef PLAN9PORT_USING_PTHREADS pthread_t osprocid; -#else - int osprocid; -#endif uchar *stk; uint stksize; int exiting; @@ -115,11 +76,7 @@ struct Proc Proc *next; Proc *prev; char msg[128]; -#ifdef PLAN9PORT_USING_PTHREADS pthread_t osprocid; -#else - int osprocid; -#endif Lock lock; int nswitch; _Thread *thread0; @@ -133,7 +90,6 @@ struct Proc _Procrendez runrend; Lock schedlock; _Thread *schedthread; - Context schedcontext; void *udata; Jmp sigjmp; int mainproc; diff --git a/src/libthread/x86_64-ucontext.c b/src/libthread/x86_64-ucontext.c deleted file mode 100644 index 5d1aaefc1..000000000 --- a/src/libthread/x86_64-ucontext.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "threadimpl.h" - -void -makecontext(ucontext_t *uc, void (*fn)(void), int argc, ...) -{ - uintptr *sp; - va_list arg; - - if(argc != 2) - sysfatal("libthread: makecontext misused"); - va_start(arg, argc); - uc->mc.di = va_arg(arg, uint); - uc->mc.si = va_arg(arg, uint); - va_end(arg); - - sp = USPALIGN(uc, 16); - *--sp = 0; // fn's return address - *--sp = (uintptr)fn; // return address of setcontext - uc->mc.sp = (uintptr)sp; -} - -int -swapcontext(ucontext_t *oucp, ucontext_t *ucp) -{ - if(getcontext(oucp) == 0) - setcontext(ucp); - return 0; -} diff --git a/src/libthread/x86_64-ucontext.h b/src/libthread/x86_64-ucontext.h deleted file mode 100644 index e0640761c..000000000 --- a/src/libthread/x86_64-ucontext.h +++ /dev/null @@ -1,42 +0,0 @@ -#define setcontext(u) libthread_setmcontext(&(u)->mc) -#define getcontext(u) libthread_getmcontext(&(u)->mc) -typedef struct mcontext mcontext_t; -typedef struct ucontext ucontext_t; - -struct mcontext -{ - uintptr ax; - uintptr bx; - uintptr cx; - uintptr dx; - uintptr si; - uintptr di; - uintptr bp; - uintptr sp; - uintptr r8; - uintptr r9; - uintptr r10; - uintptr r11; - uintptr r12; - uintptr r13; - uintptr r14; - uintptr r15; -/* -// XXX: currently do not save vector registers or floating-point state -*/ -}; - -struct ucontext -{ - struct { - void *ss_sp; - uint ss_size; - } uc_stack; - sigset_t uc_sigmask; - mcontext_t mc; -}; - -void makecontext(ucontext_t*, void(*)(void), int, ...); -int swapcontext(ucontext_t*, ucontext_t*); -int libthread_getmcontext(mcontext_t*); -void libthread_setmcontext(mcontext_t*); From 8b9aaf2e3f7f6e2733e52db4dd1dcb46a91e4972 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 07:18:30 -0500 Subject: [PATCH 275/323] devdraw: add /usr/X11R7 for NetBSD Fixes #362. --- src/cmd/devdraw/mkwsysrules.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh index 122e9123d..56dff55a3 100644 --- a/src/cmd/devdraw/mkwsysrules.sh +++ b/src/cmd/devdraw/mkwsysrules.sh @@ -7,6 +7,8 @@ if [ "x$X11" = "x" ]; then X11=/usr/X11R6 elif [ -d /usr/local/X11R6 ]; then X11=/usr/local/X11R6 + elif [ -d /usr/X11R7 ]; then + X11=/usr/X11R7 elif [ -d /usr/X ]; then X11=/usr/X elif [ -d /usr/openwin ]; then # for Sun From 0a7fe606818a7906cdc57ea14cb57b416be6c1de Mon Sep 17 00:00:00 2001 From: Nicola Girardi Date: Fri, 20 Mar 2020 18:52:41 +0000 Subject: [PATCH 276/323] 9term: use openpty on NetBSD Fixes #376. --- src/cmd/9term/NetBSD.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmd/9term/NetBSD.c b/src/cmd/9term/NetBSD.c index eec79c286..182948033 100644 --- a/src/cmd/9term/NetBSD.c +++ b/src/cmd/9term/NetBSD.c @@ -1 +1,17 @@ +#define getpts not_using_this_getpts #include "bsdpty.c" +#undef getpts + +#include + +int +getpts(int fd[], char *slave) +{ + if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){ + fchmod(fd[1], 0620); + strcpy(slave, ttyname(fd[0])); + return 0; + } + sysfatal("no ptys: %r"); + return 0; +} From 0bd14783426d137428ffae7cd89cfc06b88d1b11 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 07:21:44 -0500 Subject: [PATCH 277/323] wintext: use rc not bash --- bin/wintext | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/bin/wintext b/bin/wintext index 80a899576..1f36a05c5 100755 --- a/bin/wintext +++ b/bin/wintext @@ -1,22 +1,17 @@ -#!/bin/bash +#!/usr/local/plan9/bin/rc -case "$winid" in -[0-9]*) +if(~ $winid [0-9]*) { 9p read acme/$winid/body exit 0 -esac - -case "$text9term" in -unix!*) - dial -e $text9term &1 +echo 'no running window found' >[2=1] exit 1 From 99dee78c2d44641ba56e5bb640d732f993b3dfa1 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 07:39:16 -0500 Subject: [PATCH 278/323] all: remove $OBJTYPE from build Now that we assume pthreads, the only assembly left is in libmp and libsec. We only ever added assembly for 386. The portable C code is fine for plan9port. --- INSTALL | 30 +-- bin/9a | 21 -- bin/9c | 14 +- bin/9l | 12 +- dist/buildmk | 2 +- src/libmp/386/mkfile | 15 -- src/libmp/386/mpdigdiv-Darwin.s | 33 --- src/libmp/386/mpdigdiv.s | 33 --- src/libmp/386/mpvecadd-Darwin.s | 70 ----- src/libmp/386/mpvecadd.s | 70 ----- src/libmp/386/mpvecdigmuladd-Darwin.s | 68 ----- src/libmp/386/mpvecdigmuladd.s | 69 ----- src/libmp/386/mpvecdigmulsub-Darwin.s | 69 ----- src/libmp/386/mpvecdigmulsub.s | 70 ----- src/libmp/386/mpvecsub-Darwin.s | 60 ----- src/libmp/386/mpvecsub.s | 60 ----- src/libmp/PowerMacintosh/mkfile | 4 - src/libmp/arm/mkfile | 4 - src/libmp/arm64/mkfile | 4 - src/libmp/mips/mkfile | 4 - src/libmp/mkfile | 2 +- src/libmp/port/mkfile | 5 +- src/libmp/power/mkfile | 4 - src/libmp/sparc64/mkfile | 4 - src/libmp/sun4u/mkfile | 4 - src/libmp/x86_64/mkfile | 4 - src/libsec/386/md5block.spp | 248 ------------------ src/libsec/386/mkfile | 26 -- src/libsec/386/sha1block.spp | 221 ---------------- src/libsec/PowerMacintosh/mkfile | 4 - src/libsec/arm/mkfile | 4 - src/libsec/arm64/mkfile | 4 - src/libsec/mips/mkfile | 4 - src/libsec/mkfile | 2 +- src/libsec/port/mkfile | 3 +- src/libsec/power/mkfile | 4 - src/libsec/sparc64/mkfile | 4 - src/libsec/sun4u/mkfile | 4 - src/libsec/x86_64/mkfile | 4 - src/mkenv | 36 +-- src/mkfile | 2 - unix/make/{Make.Darwin-386 => Make.Darwin} | 0 unix/make/Make.Darwin-PowerMacintosh | 7 - unix/make/{Make.FreeBSD-386 => Make.FreeBSD} | 0 unix/make/{Make.HP-UX-9000 => Make.HP-UX} | 0 unix/make/{Make.Linux-x86_64 => Make.Linux} | 0 unix/make/Make.Linux-386 | 6 - unix/make/Make.Linux-power | 6 - unix/make/{Make.NetBSD-386 => Make.NetBSD} | 0 unix/make/{Make.OSF1-alpha => Make.OSF1} | 0 unix/make/{Make.OpenBSD-386 => Make.OpenBSD} | 0 unix/make/Make.SunOS | 2 + .../{Make.SunOS-sun4u-cc => Make.SunOS-cc} | 0 .../{Make.SunOS-sun4u-gcc => Make.SunOS-gcc} | 0 unix/make/Make.SunOS-sun4u | 2 - unix/make/Makefile.TOP | 4 +- 56 files changed, 41 insertions(+), 1291 deletions(-) delete mode 100755 bin/9a delete mode 100644 src/libmp/386/mkfile delete mode 100644 src/libmp/386/mpdigdiv-Darwin.s delete mode 100644 src/libmp/386/mpdigdiv.s delete mode 100644 src/libmp/386/mpvecadd-Darwin.s delete mode 100644 src/libmp/386/mpvecadd.s delete mode 100644 src/libmp/386/mpvecdigmuladd-Darwin.s delete mode 100644 src/libmp/386/mpvecdigmuladd.s delete mode 100644 src/libmp/386/mpvecdigmulsub-Darwin.s delete mode 100644 src/libmp/386/mpvecdigmulsub.s delete mode 100644 src/libmp/386/mpvecsub-Darwin.s delete mode 100644 src/libmp/386/mpvecsub.s delete mode 100644 src/libmp/PowerMacintosh/mkfile delete mode 100644 src/libmp/arm/mkfile delete mode 100644 src/libmp/arm64/mkfile delete mode 100644 src/libmp/mips/mkfile delete mode 100644 src/libmp/power/mkfile delete mode 100644 src/libmp/sparc64/mkfile delete mode 100644 src/libmp/sun4u/mkfile delete mode 100644 src/libmp/x86_64/mkfile delete mode 100644 src/libsec/386/md5block.spp delete mode 100644 src/libsec/386/mkfile delete mode 100644 src/libsec/386/sha1block.spp delete mode 100644 src/libsec/PowerMacintosh/mkfile delete mode 100644 src/libsec/arm/mkfile delete mode 100644 src/libsec/arm64/mkfile delete mode 100644 src/libsec/mips/mkfile delete mode 100644 src/libsec/power/mkfile delete mode 100644 src/libsec/sparc64/mkfile delete mode 100644 src/libsec/sun4u/mkfile delete mode 100644 src/libsec/x86_64/mkfile rename unix/make/{Make.Darwin-386 => Make.Darwin} (100%) delete mode 100644 unix/make/Make.Darwin-PowerMacintosh rename unix/make/{Make.FreeBSD-386 => Make.FreeBSD} (100%) rename unix/make/{Make.HP-UX-9000 => Make.HP-UX} (100%) rename unix/make/{Make.Linux-x86_64 => Make.Linux} (100%) delete mode 100644 unix/make/Make.Linux-386 delete mode 100644 unix/make/Make.Linux-power rename unix/make/{Make.NetBSD-386 => Make.NetBSD} (100%) rename unix/make/{Make.OSF1-alpha => Make.OSF1} (100%) rename unix/make/{Make.OpenBSD-386 => Make.OpenBSD} (100%) create mode 100644 unix/make/Make.SunOS rename unix/make/{Make.SunOS-sun4u-cc => Make.SunOS-cc} (100%) rename unix/make/{Make.SunOS-sun4u-gcc => Make.SunOS-gcc} (100%) delete mode 100644 unix/make/Make.SunOS-sun4u diff --git a/INSTALL b/INSTALL index 49a4d9a40..79c0745fa 100755 --- a/INSTALL +++ b/INSTALL @@ -71,18 +71,15 @@ if [ `uname` = SunOS ]; then echo "* Running on Solaris: checking architecture..." case "$(isainfo -n)" in *amd64*) - echo " x86-64 found." - echo "OBJTYPE=x86_64" >>$PLAN9/config + echo " x86-64 found; using gcc." echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/amd64 ;; *i386*) - echo " i386 found." - echo "OBJTYPE=386" >>$PLAN9/config + echo " i386 found; using gcc." echo "CC9=gcc" >>$PLAN9/config # defaults to gcc on Solaris/i386 ;; *sparc*) echo " Sparc found." - echo "OBJTYPE=sparc" >>$PLAN9/config ;; esac fi @@ -90,28 +87,15 @@ fi if [ `uname` = Darwin ]; then export NPROC=$(sysctl hw.ncpu | sed 's/hw.ncpu: //') # On Darwin, uname -m -p cannot be trusted. - echo "* Running on Darwin: checking architecture..." + echo "* Running on Darwin..." rm -f ./a.out - if ! gcc lib/darwin-main.c >/dev/null 2>&1; then - echo "Cannot find gcc. You may need to install the command-line tools using Xcode." >&2 + if ! xcrun --sdk macosx clang lib/darwin-main.c >/dev/null 2>&1; then + echo "Cannot find 'xcrun --sdk macosx clang'." >&2 + echo "You may need to install the command-line tools using Xcode." >&2 echo "See http://swtch.com/go/xcodegcc for details." >&2 exit 1 fi - case "$(file ./a.out 2>/dev/null)" in - *x86_64*) - echo " x86-64 found." - echo "OBJTYPE=x86_64" >>$PLAN9/config - echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config - ;; - *i386*) - echo " i386 found." - echo "OBJTYPE=386" >>$PLAN9/config - ;; - *ppc*) - echo " power found." - echo "OBJTYPE=power" >>$PLAN9/config - ;; - esac + echo "CC9='xcrun --sdk macosx clang'" >>$PLAN9/config rm -f ./a.out fi diff --git a/bin/9a b/bin/9a deleted file mode 100755 index 753797c8f..000000000 --- a/bin/9a +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -if [ $# != 1 ]; then - echo 'usage: 9a file.s' 1>&2 - exit 1 -fi - -test -f $PLAN9/config && . $PLAN9/config - -aflags="" -case "`uname`-${OBJTYPE:-`uname -m`}" in -Darwin-*386*) - aflags="-arch i386" - ;; -Darwin-*x86_64*) - aflags="-arch x86_64" - ;; -esac - -out=`echo $1 | sed 's/\.s$//;s/$/.o/'` -exec as $aflags -o $out $1 diff --git a/bin/9c b/bin/9c index 9dfc082e5..4d4881792 100755 --- a/bin/9c +++ b/bin/9c @@ -112,24 +112,14 @@ usexlc() cflags="$cflags $CC9FLAGS" } -tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}-${CC9:-cc}" +tag="${SYSNAME:-`uname`}-${CC9:-cc}" case "$tag" in *DragonFly*gcc*|*BSD*gcc*) usegcc ;; *DragonFly*clang|*BSD*clang*) useclang ;; -*Darwin-x86_64*) +*Darwin*) useclang cflags="$cflags -g3 -m64" ;; -*Darwin-arm64*) - useclang - cflags="$cflags -g3 -m64" - ;; -*Darwin*clang*) - useclang - cflags="$cflags -g3 -m32" - ;; -*Darwin*) usegcc - cflags="$cflags -g3 -no-cpp-precomp -m32" ;; *HP-UX*) cc=${CC9:-cc}; cflags="-g -O -c -Ae" ;; *Linux*) usegcc case "${CC9:-gcc}" in diff --git a/bin/9l b/bin/9l index f6eb0ba1b..abca55fcc 100755 --- a/bin/9l +++ b/bin/9l @@ -9,7 +9,7 @@ verbose=false nmflags="" extralibs="-lm" -tag="${SYSNAME:-`uname`}-${OBJTYPE:-`uname -m`}" +tag="${SYSNAME:-`uname`}" case "$tag" in *DragonFly*|*BSD*) ld="${CC9:-gcc} $CC9FLAGS" @@ -27,14 +27,8 @@ case "$tag" in userpath=true extralibs="$extralibs -lutil -lresolv -lpthread" ;; -*Darwin*x86_64*) - ld="${CC9:-gcc} -m64 $CC9FLAGS" - ;; -*Darwin-arm64*) - ld="${CC9:-gcc} -m64 $CC9FLAGS" - ;; *Darwin*) - ld="${CC9:-gcc} -m32 $CC9FLAGS" + ld="${CC9:-gcc} -m64 $CC9FLAGS" ;; *SunOS*) ld="${CC9:-cc} -g $CC9FLAGS" @@ -255,7 +249,7 @@ then fi # Don't say -L with a non-existent directory: Xcode complains. # x86_64 seems to put its 64-bit libraries in lib64. - if [ "${OBJTYPE:-`uname -m`}" = "x86_64" -a -d "$X11/lib64" ] + if [ "`uname -m`" = "x86_64" -a -d "$X11/lib64" ] then libsl="$libsl -L$X11/lib64" fi diff --git a/dist/buildmk b/dist/buildmk index cd11417c0..ba21ae023 100755 --- a/dist/buildmk +++ b/dist/buildmk @@ -2,5 +2,5 @@ # run this in the src directory . ../src/mkenv -export SYSNAME OBJTYPE INSTALL +export SYSNAME INSTALL sh -x mkmk.sh diff --git a/src/libmp/386/mkfile b/src/libmp/386/mkfile deleted file mode 100644 index c63daf427..000000000 --- a/src/libmp/386/mkfile +++ /dev/null @@ -1,15 +0,0 @@ -<$PLAN9/src/mkhdr - -LIB=libmp.a -UNAME=`uname` -A=`[ $UNAME = Darwin ] && echo -Darwin` -OFILES=\ - mpdigdiv$A.$O\ - mpvecadd$A.$O\ - mpvecdigmuladd$A.$O\ - mpvecdigmulsub$A.$O\ - mpvecsub$A.$O\ - -HFILES=$PLAN9/include/mp.h ../port/dat.h - -<$PLAN9/src/mksyslib diff --git a/src/libmp/386/mpdigdiv-Darwin.s b/src/libmp/386/mpdigdiv-Darwin.s deleted file mode 100644 index 038214bf6..000000000 --- a/src/libmp/386/mpdigdiv-Darwin.s +++ /dev/null @@ -1,33 +0,0 @@ -.text - -.globl _mpdigdiv -_mpdigdiv: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - - leal 12(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %ebx /* dividend */ - movl 0(%ebx), %eax - movl 4(%ebx), %edx - movl 4(%ebp), %ebx /* divisor */ - movl 8(%ebp), %ebp /* quotient */ - - xorl %ecx, %ecx - cmpl %ebx, %edx /* dividend >= 2^32 * divisor */ - jae 2f - cmpl %ecx, %ebx /* divisor == 1 */ - je 2f - divl %ebx /* AX = DX:AX/BX */ - movl %eax, (%ebp) -1: - /* Postlude */ - popl %ebx - popl %ebp - ret - - /* return all 1's */ -2: - notl %ecx - movl %ecx, (%ebp) - jmp 1b diff --git a/src/libmp/386/mpdigdiv.s b/src/libmp/386/mpdigdiv.s deleted file mode 100644 index 48d37c0d2..000000000 --- a/src/libmp/386/mpdigdiv.s +++ /dev/null @@ -1,33 +0,0 @@ -.text -.p2align 2,0x90 -.globl mpdigdiv -mpdigdiv: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - - leal 12(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %ebx /* dividend */ - movl 0(%ebx), %eax - movl 4(%ebx), %edx - movl 4(%ebp), %ebx /* divisor */ - movl 8(%ebp), %ebp /* quotient */ - - xorl %ecx, %ecx - cmpl %ebx, %edx /* dividend >= 2^32 * divisor */ - jae divovfl - cmpl %ecx, %ebx /* divisor == 1 */ - je divovfl - divl %ebx /* AX = DX:AX/BX */ - movl %eax, (%ebp) -done: - /* Postlude */ - popl %ebx - popl %ebp - ret - - /* return all 1's */ -divovfl: - notl %ecx - movl %ecx, (%ebp) - jmp done diff --git a/src/libmp/386/mpvecadd-Darwin.s b/src/libmp/386/mpvecadd-Darwin.s deleted file mode 100644 index 2f68dbda1..000000000 --- a/src/libmp/386/mpvecadd-Darwin.s +++ /dev/null @@ -1,70 +0,0 @@ -/* mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum) */ -/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */ -/* prereq: alen >= blen, sum has room for alen+1 digits */ -/* (very old gnu assembler doesn't allow multiline comments) */ - -.text - -.p2align 2,0x90 -.globl _mpvecadd -_mpvecadd: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - - movl 4(%ebp), %edx /* alen */ - movl 12(%ebp), %ecx /* blen */ - movl 0(%ebp), %esi /* a */ - movl 8(%ebp), %ebx /* b */ - subl %ecx, %edx - movl 16(%ebp), %edi /* sum */ - xorl %ebp, %ebp /* this also sets carry to 0 */ - - /* skip addition if b is zero */ - testl %ecx,%ecx - je 2f - - /* sum[0:blen-1],carry = a[0:blen-1] + b[0:blen-1] */ -1: - movl (%esi, %ebp, 4), %eax - adcl (%ebx, %ebp, 4), %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop 1b - -2: - /* jump if alen > blen */ - incl %edx - movl %edx, %ecx - loop 5f - - /* sum[alen] = carry */ -3: - jb 4f - movl $0, (%edi, %ebp, 4) - jmp 6f - -4: - movl $1, (%edi, %ebp, 4) - jmp 6f - - /* sum[blen:alen-1],carry = a[blen:alen-1] + 0 */ -5: - movl (%esi, %ebp, 4),%eax - adcl $0, %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop 5b - jmp 3b - -6: - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret diff --git a/src/libmp/386/mpvecadd.s b/src/libmp/386/mpvecadd.s deleted file mode 100644 index 41d83c3f1..000000000 --- a/src/libmp/386/mpvecadd.s +++ /dev/null @@ -1,70 +0,0 @@ -/* mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum) */ -/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */ -/* prereq: alen >= blen, sum has room for alen+1 digits */ -/* (very old gnu assembler doesn't allow multiline comments) */ - -.text - -.p2align 2,0x90 -.globl mpvecadd -mpvecadd: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - - movl 4(%ebp), %edx /* alen */ - movl 12(%ebp), %ecx /* blen */ - movl 0(%ebp), %esi /* a */ - movl 8(%ebp), %ebx /* b */ - subl %ecx, %edx - movl 16(%ebp), %edi /* sum */ - xorl %ebp, %ebp /* this also sets carry to 0 */ - - /* skip addition if b is zero */ - testl %ecx,%ecx - je _add1 - - /* sum[0:blen-1],carry = a[0:blen-1] + b[0:blen-1] */ -_addloop1: - movl (%esi, %ebp, 4), %eax - adcl (%ebx, %ebp, 4), %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop _addloop1 - -_add1: - /* jump if alen > blen */ - incl %edx - movl %edx, %ecx - loop _addloop2 - - /* sum[alen] = carry */ -_addend: - jb _addcarry - movl $0, (%edi, %ebp, 4) - jmp done - -_addcarry: - movl $1, (%edi, %ebp, 4) - jmp done - - /* sum[blen:alen-1],carry = a[blen:alen-1] + 0 */ -_addloop2: - movl (%esi, %ebp, 4),%eax - adcl $0, %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop _addloop2 - jmp _addend - -done: - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret diff --git a/src/libmp/386/mpvecdigmuladd-Darwin.s b/src/libmp/386/mpvecdigmuladd-Darwin.s deleted file mode 100644 index f6d28ac38..000000000 --- a/src/libmp/386/mpvecdigmuladd-Darwin.s +++ /dev/null @@ -1,68 +0,0 @@ -/* - * mpvecdigmul(mpdigit *b, int n, mpdigit m, mpdigit *p) - * - * p += b*m - * - * each step look like: - * hi,lo = m*b[i] - * lo += oldhi + carry - * hi += carry - * p[i] += lo - * oldhi = hi - * - * the registers are: - * hi = DX - constrained by hardware - * lo = AX - constrained by hardware - * b+n = SI - can't be BP - * p+n = DI - can't be BP - * i-n = BP - * m = BX - * oldhi = CX - * - */ -.text - -.globl _mpvecdigmuladd -_mpvecdigmuladd: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %esi /* b */ - movl 4(%ebp), %ecx /* n */ - movl 8(%ebp), %ebx /* m */ - movl 12(%ebp), %edi /* p */ - movl %ecx, %ebp - negl %ebp /* BP = -n */ - shll $2, %ecx - addl %ecx, %esi /* SI = b + n */ - addl %ecx, %edi /* DI = p + n */ - xorl %ecx, %ecx -1: - movl (%esi, %ebp, 4), %eax /* lo = b[i] */ - mull %ebx /* hi, lo = b[i] * m */ - addl %ecx,%eax /* lo += oldhi */ - jae 2f - incl %edx /* hi += carry */ -2: - addl %eax, (%edi, %ebp, 4) /* p[i] += lo */ - jae 3f - incl %edx /* hi += carry */ -3: - movl %edx, %ecx /* oldhi = hi */ - incl %ebp /* i++ */ - jnz 1b - xorl %eax, %eax - addl %ecx, (%edi, %ebp, 4) /* p[n] + oldhi */ - adcl %eax, %eax /* return carry out of p[n] */ - - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/386/mpvecdigmuladd.s b/src/libmp/386/mpvecdigmuladd.s deleted file mode 100644 index 8c92f61f4..000000000 --- a/src/libmp/386/mpvecdigmuladd.s +++ /dev/null @@ -1,69 +0,0 @@ -# -# mpvecdigmul(mpdigit *b, int n, mpdigit m, mpdigit *p) -# -# p += b*m -# -# each step look like: -# hi,lo = m*b[i] -# lo += oldhi + carry -# hi += carry -# p[i] += lo -# oldhi = hi -# -# the registers are: -# hi = DX - constrained by hardware -# lo = AX - constrained by hardware -# b+n = SI - can't be BP -# p+n = DI - can't be BP -# i-n = BP -# m = BX -# oldhi = CX -# - -.text - -.p2align 2,0x90 -.globl mpvecdigmuladd -mpvecdigmuladd: - # Prelude - pushl %ebp # save on stack - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp # %ebp = FP for now - movl 0(%ebp), %esi # b - movl 4(%ebp), %ecx # n - movl 8(%ebp), %ebx # m - movl 12(%ebp), %edi # p - movl %ecx, %ebp - negl %ebp # BP = -n - shll $2, %ecx - addl %ecx, %esi # SI = b + n - addl %ecx, %edi # DI = p + n - xorl %ecx, %ecx -_muladdloop: - movl (%esi, %ebp, 4), %eax # lo = b[i] - mull %ebx # hi, lo = b[i] * m - addl %ecx,%eax # lo += oldhi - jae _muladdnocarry1 - incl %edx # hi += carry -_muladdnocarry1: - addl %eax, (%edi, %ebp, 4) # p[i] += lo - jae _muladdnocarry2 - incl %edx # hi += carry -_muladdnocarry2: - movl %edx, %ecx # oldhi = hi - incl %ebp # i++ - jnz _muladdloop - xorl %eax, %eax - addl %ecx, (%edi, %ebp, 4) # p[n] + oldhi - adcl %eax, %eax # return carry out of p[n] - - # Postlude - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/386/mpvecdigmulsub-Darwin.s b/src/libmp/386/mpvecdigmulsub-Darwin.s deleted file mode 100644 index 8f7f4d685..000000000 --- a/src/libmp/386/mpvecdigmulsub-Darwin.s +++ /dev/null @@ -1,69 +0,0 @@ -/* - * mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p) - * - * p -= b*m - * - * each step look like: - * hi,lo = m*b[i] - * lo += oldhi + carry - * hi += carry - * p[i] += lo - * oldhi = hi - * - * the registers are: - * hi = DX - constrained by hardware - * lo = AX - constrained by hardware - * b = SI - can't be BP - * p = DI - can't be BP - * i = BP - * n = CX - constrained by LOOP instr - * m = BX - * oldhi = EX - * - */ -.text - -.globl _mpvecdigmulsub -_mpvecdigmulsub: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %esi /* b */ - movl 4(%ebp), %ecx /* n */ - movl 8(%ebp), %ebx /* m */ - movl 12(%ebp), %edi /* p */ - xorl %ebp, %ebp - pushl %ebp -1: - movl (%esi, %ebp, 4),%eax /* lo = b[i] */ - mull %ebx /* hi, lo = b[i] * m */ - addl 0(%esp), %eax /* lo += oldhi */ - jae 2f - incl %edx /* hi += carry */ -2: - subl %eax, (%edi, %ebp, 4) - jae 3f - incl %edx /* hi += carry */ -3: - movl %edx, 0(%esp) - incl %ebp - loop 1b - popl %eax - subl %eax, (%edi, %ebp, 4) - jae 4f - movl $-1, %eax - jmp 5f -4: - movl $1, %eax -5: - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/386/mpvecdigmulsub.s b/src/libmp/386/mpvecdigmulsub.s deleted file mode 100644 index 017e86c9c..000000000 --- a/src/libmp/386/mpvecdigmulsub.s +++ /dev/null @@ -1,70 +0,0 @@ -# -# mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p) -# -# p -= b*m -# -# each step look like: -# hi,lo = m*b[i] -# lo += oldhi + carry -# hi += carry -# p[i] += lo -# oldhi = hi -# -# the registers are: -# hi = DX - constrained by hardware -# lo = AX - constrained by hardware -# b = SI - can't be BP -# p = DI - can't be BP -# i = BP -# n = CX - constrained by LOOP instr -# m = BX -# oldhi = EX -# - -.text - -.p2align 2,0x90 -.globl mpvecdigmulsub -mpvecdigmulsub: - # Prelude - pushl %ebp # save on stack - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp # %ebp = FP for now - movl 0(%ebp), %esi # b - movl 4(%ebp), %ecx # n - movl 8(%ebp), %ebx # m - movl 12(%ebp), %edi # p - xorl %ebp, %ebp - pushl %ebp -_mulsubloop: - movl (%esi, %ebp, 4),%eax # lo = b[i] - mull %ebx # hi, lo = b[i] * m - addl 0(%esp), %eax # lo += oldhi - jae _mulsubnocarry1 - incl %edx # hi += carry -_mulsubnocarry1: - subl %eax, (%edi, %ebp, 4) - jae _mulsubnocarry2 - incl %edx # hi += carry -_mulsubnocarry2: - movl %edx, 0(%esp) - incl %ebp - loop _mulsubloop - popl %eax - subl %eax, (%edi, %ebp, 4) - jae _mulsubnocarry3 - movl $-1, %eax - jmp done -_mulsubnocarry3: - movl $1, %eax -done: - # Postlude - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/386/mpvecsub-Darwin.s b/src/libmp/386/mpvecsub-Darwin.s deleted file mode 100644 index 0155e3ec7..000000000 --- a/src/libmp/386/mpvecsub-Darwin.s +++ /dev/null @@ -1,60 +0,0 @@ -/* mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff) */ -/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */ -/* prereq: alen >= blen, diff has room for alen digits */ -/* (very old gnu assembler doesn't allow multiline comments) */ - -.text - -.p2align 2,0x90 -.globl _mpvecsub -_mpvecsub: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %esi /* a */ - movl 8(%ebp), %ebx /* b */ - movl 4(%ebp), %edx /* alen */ - movl 12(%ebp), %ecx /* blen */ - movl 16(%ebp), %edi /* diff */ - - subl %ecx,%edx - xorl %ebp,%ebp /* this also sets carry to 0 */ - - /* skip subraction if b is zero */ - testl %ecx,%ecx - jz 2f - - /* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */ -1: - movl (%esi, %ebp, 4), %eax - sbbl (%ebx, %ebp, 4), %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop 1b - -2: - incl %edx - movl %edx,%ecx - loop 3f - jmp 4f - - /* diff[blen:alen-1] = a[blen:alen-1] - 0 */ -3: - movl (%esi, %ebp, 4), %eax - sbbl $0, %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop 3b - -4: - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/386/mpvecsub.s b/src/libmp/386/mpvecsub.s deleted file mode 100644 index d68424cf4..000000000 --- a/src/libmp/386/mpvecsub.s +++ /dev/null @@ -1,60 +0,0 @@ -/* mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff) */ -/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */ -/* prereq: alen >= blen, diff has room for alen digits */ -/* (very old gnu assembler doesn't allow multiline comments) */ - -.text - -.p2align 2,0x90 -.globl mpvecsub -mpvecsub: - /* Prelude */ - pushl %ebp /* save on stack */ - pushl %ebx - pushl %esi - pushl %edi - - leal 20(%esp), %ebp /* %ebp = FP for now */ - movl 0(%ebp), %esi /* a */ - movl 8(%ebp), %ebx /* b */ - movl 4(%ebp), %edx /* alen */ - movl 12(%ebp), %ecx /* blen */ - movl 16(%ebp), %edi /* diff */ - - subl %ecx,%edx - xorl %ebp,%ebp /* this also sets carry to 0 */ - - /* skip subraction if b is zero */ - testl %ecx,%ecx - jz _sub1 - - /* diff[0:blen-1],borrow = a[0:blen-1] - b[0:blen-1] */ -_subloop1: - movl (%esi, %ebp, 4), %eax - sbbl (%ebx, %ebp, 4), %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop _subloop1 - -_sub1: - incl %edx - movl %edx,%ecx - loop _subloop2 - jmp done - - /* diff[blen:alen-1] = a[blen:alen-1] - 0 */ -_subloop2: - movl (%esi, %ebp, 4), %eax - sbbl $0, %eax - movl %eax, (%edi, %ebp, 4) - incl %ebp - loop _subloop2 - -done: - /* Postlude */ - popl %edi - popl %esi - popl %ebx - popl %ebp - ret - diff --git a/src/libmp/PowerMacintosh/mkfile b/src/libmp/PowerMacintosh/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/PowerMacintosh/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/arm/mkfile b/src/libmp/arm/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/arm/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/arm64/mkfile b/src/libmp/arm64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/arm64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/mips/mkfile b/src/libmp/mips/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/mips/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/mkfile b/src/libmp/mkfile index e3f1aa696..81f237c43 100644 --- a/src/libmp/mkfile +++ b/src/libmp/mkfile @@ -2,6 +2,6 @@ DIRS=\ port\ - $OBJTYPE\ +# $OBJTYPE\ <$PLAN9/src/mkdirs diff --git a/src/libmp/port/mkfile b/src/libmp/port/mkfile index b0cf77cd1..15612aa75 100644 --- a/src/libmp/port/mkfile +++ b/src/libmp/port/mkfile @@ -34,8 +34,9 @@ FILES=\ mptouv\ ALLOFILES=${FILES:%=%.$O} -# cull things in the per-machine directories from this list -OFILES= `{sh ./reduce $O $OBJTYPE $ALLOFILES} +# # cull things in the per-machine directories from this list +# OFILES= `{sh ./reduce $O $ALLOFILES} +OFILES=$ALLOFILES HFILES=\ $PLAN9/include/lib9.h\ diff --git a/src/libmp/power/mkfile b/src/libmp/power/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/power/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/sparc64/mkfile b/src/libmp/sparc64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/sparc64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/sun4u/mkfile b/src/libmp/sun4u/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/sun4u/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libmp/x86_64/mkfile b/src/libmp/x86_64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libmp/x86_64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/386/md5block.spp b/src/libsec/386/md5block.spp deleted file mode 100644 index feebf615e..000000000 --- a/src/libsec/386/md5block.spp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * rfc1321 requires that I include this. The code is new. The constants - * all come from the rfc (hence the copyright). We trade a table for the - * macros in rfc. The total size is a lot less. -- presotto - * - * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All - * rights reserved. - * - * License to copy and use this software is granted provided that it - * is identified as the "RSA Data Security, Inc. MD5 Message-Digest - * Algorithm" in all material mentioning or referencing this software - * or this function. - * - * License is also granted to make and use derivative works provided - * that such works are identified as "derived from the RSA Data - * Security, Inc. MD5 Message-Digest Algorithm" in all material - * mentioning or referencing the derived work. - * - * RSA Data Security, Inc. makes no representations concerning either - * the merchantability of this software or the suitability of this - * software forany particular purpose. It is provided "as is" - * without express or implied warranty of any kind. - * These notices must be retained in any copies of any part of this - * documentation and/or software. - */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 - -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 - -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 - -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -#define PAYME(x) $##x - -/* - * SI is data - * a += FN(B,C,D); - * a += x[sh] + t[sh]; - * a = (a << S11) | (a >> (32 - S11)); - * a += b; - */ - -#define BODY1(off,V,FN,SH,A,B,C,D)\ - FN(B,C,D)\ - leal V(A, %edi, 1), A;\ - addl off(%ebp), A;\ - roll PAYME(SH), A;\ - addl B, A;\ - -#define BODY(off,V,FN,SH,A,B,C,D)\ - FN(B,C,D)\ - leal V(A, %edi, 1), A;\ - addl (off)(%ebp), A;\ - roll PAYME(SH), A;\ - addl B,A;\ - -/* - * fn1 = ((c ^ d) & b) ^ d - */ -#define FN1(B,C,D)\ - movl C, %edi;\ - xorl D, %edi;\ - andl B, %edi;\ - xorl D, %edi;\ - -/* - * fn2 = ((b ^ c) & d) ^ c; - */ -#define FN2(B,C,D)\ - movl B, %edi;\ - xorl C, %edi;\ - andl D, %edi;\ - xorl C, %edi;\ - -/* - * fn3 = b ^ c ^ d; - */ -#define FN3(B,C,D)\ - movl B, %edi;\ - xorl C, %edi;\ - xorl D, %edi;\ - -/* - * fn4 = c ^ (b | ~d); - */ -#define FN4(B,C,D)\ - movl D, %edi;\ - xorl $-1, %edi;\ - orl B, %edi;\ - xorl C, %edi;\ - -#define STACKSIZE 20 - -#define DATA (STACKSIZE+8) -#define LEN (STACKSIZE+12) -#define STATE (STACKSIZE+16) - -#define EDATA (STACKSIZE-4) -#define OLDEBX (STACKSIZE-8) -#define OLDESI (STACKSIZE-12) -#define OLDEDI (STACKSIZE-16) - - .text - - .p2align 2,0x90 -#ifdef __Darwin__ - .globl __md5block - __md5block: -#else - .globl _md5block - _md5block: -#endif - - /* Prelude */ - pushl %ebp - subl $(STACKSIZE), %esp - movl %ebx, OLDEBX(%esp) - movl %esi, OLDESI(%esp) - movl %edi, OLDEDI(%esp) - - movl DATA(%esp), %eax - addl LEN(%esp), %eax - movl %eax, EDATA(%esp) - - movl DATA(%esp), %ebp - -0: - movl STATE(%esp), %esi - movl (%esi), %eax - movl 4(%esi), %ebx - movl 8(%esi), %ecx - movl 12(%esi), %edx - - BODY1( 0*4,0xd76aa478,FN1,S11,%eax,%ebx,%ecx,%edx) - BODY1( 1*4,0xe8c7b756,FN1,S12,%edx,%eax,%ebx,%ecx) - BODY1( 2*4,0x242070db,FN1,S13,%ecx,%edx,%eax,%ebx) - BODY1( 3*4,0xc1bdceee,FN1,S14,%ebx,%ecx,%edx,%eax) - - BODY1( 4*4,0xf57c0faf,FN1,S11,%eax,%ebx,%ecx,%edx) - BODY1( 5*4,0x4787c62a,FN1,S12,%edx,%eax,%ebx,%ecx) - BODY1( 6*4,0xa8304613,FN1,S13,%ecx,%edx,%eax,%ebx) - BODY1( 7*4,0xfd469501,FN1,S14,%ebx,%ecx,%edx,%eax) - - BODY1( 8*4,0x698098d8,FN1,S11,%eax,%ebx,%ecx,%edx) - BODY1( 9*4,0x8b44f7af,FN1,S12,%edx,%eax,%ebx,%ecx) - BODY1(10*4,0xffff5bb1,FN1,S13,%ecx,%edx,%eax,%ebx) - BODY1(11*4,0x895cd7be,FN1,S14,%ebx,%ecx,%edx,%eax) - - BODY1(12*4,0x6b901122,FN1,S11,%eax,%ebx,%ecx,%edx) - BODY1(13*4,0xfd987193,FN1,S12,%edx,%eax,%ebx,%ecx) - BODY1(14*4,0xa679438e,FN1,S13,%ecx,%edx,%eax,%ebx) - BODY1(15*4,0x49b40821,FN1,S14,%ebx,%ecx,%edx,%eax) - - - BODY( 1*4,0xf61e2562,FN2,S21,%eax,%ebx,%ecx,%edx) - BODY( 6*4,0xc040b340,FN2,S22,%edx,%eax,%ebx,%ecx) - BODY(11*4,0x265e5a51,FN2,S23,%ecx,%edx,%eax,%ebx) - BODY( 0*4,0xe9b6c7aa,FN2,S24,%ebx,%ecx,%edx,%eax) - - BODY( 5*4,0xd62f105d,FN2,S21,%eax,%ebx,%ecx,%edx) - BODY(10*4,0x02441453,FN2,S22,%edx,%eax,%ebx,%ecx) - BODY(15*4,0xd8a1e681,FN2,S23,%ecx,%edx,%eax,%ebx) - BODY( 4*4,0xe7d3fbc8,FN2,S24,%ebx,%ecx,%edx,%eax) - - BODY( 9*4,0x21e1cde6,FN2,S21,%eax,%ebx,%ecx,%edx) - BODY(14*4,0xc33707d6,FN2,S22,%edx,%eax,%ebx,%ecx) - BODY( 3*4,0xf4d50d87,FN2,S23,%ecx,%edx,%eax,%ebx) - BODY( 8*4,0x455a14ed,FN2,S24,%ebx,%ecx,%edx,%eax) - - BODY(13*4,0xa9e3e905,FN2,S21,%eax,%ebx,%ecx,%edx) - BODY( 2*4,0xfcefa3f8,FN2,S22,%edx,%eax,%ebx,%ecx) - BODY( 7*4,0x676f02d9,FN2,S23,%ecx,%edx,%eax,%ebx) - BODY(12*4,0x8d2a4c8a,FN2,S24,%ebx,%ecx,%edx,%eax) - - - BODY( 5*4,0xfffa3942,FN3,S31,%eax,%ebx,%ecx,%edx) - BODY( 8*4,0x8771f681,FN3,S32,%edx,%eax,%ebx,%ecx) - BODY(11*4,0x6d9d6122,FN3,S33,%ecx,%edx,%eax,%ebx) - BODY(14*4,0xfde5380c,FN3,S34,%ebx,%ecx,%edx,%eax) - - BODY( 1*4,0xa4beea44,FN3,S31,%eax,%ebx,%ecx,%edx) - BODY( 4*4,0x4bdecfa9,FN3,S32,%edx,%eax,%ebx,%ecx) - BODY( 7*4,0xf6bb4b60,FN3,S33,%ecx,%edx,%eax,%ebx) - BODY(10*4,0xbebfbc70,FN3,S34,%ebx,%ecx,%edx,%eax) - - BODY(13*4,0x289b7ec6,FN3,S31,%eax,%ebx,%ecx,%edx) - BODY( 0*4,0xeaa127fa,FN3,S32,%edx,%eax,%ebx,%ecx) - BODY( 3*4,0xd4ef3085,FN3,S33,%ecx,%edx,%eax,%ebx) - BODY( 6*4,0x04881d05,FN3,S34,%ebx,%ecx,%edx,%eax) - - BODY( 9*4,0xd9d4d039,FN3,S31,%eax,%ebx,%ecx,%edx) - BODY(12*4,0xe6db99e5,FN3,S32,%edx,%eax,%ebx,%ecx) - BODY(15*4,0x1fa27cf8,FN3,S33,%ecx,%edx,%eax,%ebx) - BODY( 2*4,0xc4ac5665,FN3,S34,%ebx,%ecx,%edx,%eax) - - - BODY( 0*4,0xf4292244,FN4,S41,%eax,%ebx,%ecx,%edx) - BODY( 7*4,0x432aff97,FN4,S42,%edx,%eax,%ebx,%ecx) - BODY(14*4,0xab9423a7,FN4,S43,%ecx,%edx,%eax,%ebx) - BODY( 5*4,0xfc93a039,FN4,S44,%ebx,%ecx,%edx,%eax) - - BODY(12*4,0x655b59c3,FN4,S41,%eax,%ebx,%ecx,%edx) - BODY( 3*4,0x8f0ccc92,FN4,S42,%edx,%eax,%ebx,%ecx) - BODY(10*4,0xffeff47d,FN4,S43,%ecx,%edx,%eax,%ebx) - BODY( 1*4,0x85845dd1,FN4,S44,%ebx,%ecx,%edx,%eax) - - BODY( 8*4,0x6fa87e4f,FN4,S41,%eax,%ebx,%ecx,%edx) - BODY(15*4,0xfe2ce6e0,FN4,S42,%edx,%eax,%ebx,%ecx) - BODY( 6*4,0xa3014314,FN4,S43,%ecx,%edx,%eax,%ebx) - BODY(13*4,0x4e0811a1,FN4,S44,%ebx,%ecx,%edx,%eax) - - BODY( 4*4,0xf7537e82,FN4,S41,%eax,%ebx,%ecx,%edx) - BODY(11*4,0xbd3af235,FN4,S42,%edx,%eax,%ebx,%ecx) - BODY( 2*4,0x2ad7d2bb,FN4,S43,%ecx,%edx,%eax,%ebx) - BODY( 9*4,0xeb86d391,FN4,S44,%ebx,%ecx,%edx,%eax) - - addl $(16*4), %ebp - movl STATE(%esp), %edi - addl %eax,0(%edi) - addl %ebx,4(%edi) - addl %ecx,8(%edi) - addl %edx,12(%edi) - - movl EDATA(%esp), %edi - cmpl %edi, %ebp - jb 0b - - /* Postlude */ - movl OLDEBX(%esp), %ebx - movl OLDESI(%esp), %esi - movl OLDEDI(%esp), %edi - addl $(STACKSIZE), %esp - popl %ebp - ret - diff --git a/src/libsec/386/mkfile b/src/libsec/386/mkfile deleted file mode 100644 index 6f970600f..000000000 --- a/src/libsec/386/mkfile +++ /dev/null @@ -1,26 +0,0 @@ -<$PLAN9/src/mkhdr - -LIB=libsec.a -SFILES=\ - md5block.s\ - sha1block.s\ - -HFILES=$PLAN9/include/libsec.h - -OFILES=${SFILES:%.s=%.$O} - -UPDATE=mkfile\ - $HFILES\ - $SFILES\ - -<$PLAN9/src/mksyslib - -%.s: %.spp - if [ `uname` = OpenBSD ] || [ `uname` = Darwin ] - then - gcc -xc -D__`uname`__ -E $stem.spp >$stem.s - else - cpp $stem.spp >$stem.s - fi - -CLEANFILES=md5block.s sha1block.s diff --git a/src/libsec/386/sha1block.spp b/src/libsec/386/sha1block.spp deleted file mode 100644 index 386b2e6c3..000000000 --- a/src/libsec/386/sha1block.spp +++ /dev/null @@ -1,221 +0,0 @@ -.text - -.p2align 2,0x90 -#ifdef __Darwin__ -.globl __sha1block -__sha1block: -#else -.globl _sha1block -_sha1block: -#endif - -/* x = (wp[off-f] ^ wp[off-8] ^ wp[off-14] ^ wp[off-16]) <<< 1; - * wp[off] = x; - * x += A <<< 5; - * E += 0xca62c1d6 + x; - * x = FN(B,C,D); - * E += x; - * B >>> 2 - */ -#define BSWAPDI BYTE $0x0f; BYTE $0xcf; - -#define BODY(off,FN,V,A,B,C,D,E)\ - movl (off-64)(%ebp), %edi;\ - xorl (off-56)(%ebp), %edi;\ - xorl (off-32)(%ebp), %edi;\ - xorl (off-12)(%ebp), %edi;\ - roll $1, %edi;\ - movl %edi, off(%ebp);\ - leal V(%edi, E, 1), E;\ - movl A, %edi;\ - roll $5, %edi;\ - addl %edi, E;\ - FN(B,C,D)\ - addl %edi, E;\ - rorl $2, B;\ - -#define BODY0(off,FN,V,A,B,C,D,E)\ - movl off(%ebx), %edi;\ - bswap %edi;\ - movl %edi, off(%ebp);\ - leal V(%edi,E,1), E;\ - movl A, %edi;\ - roll $5,%edi;\ - addl %edi,E;\ - FN(B,C,D)\ - addl %edi,E;\ - rorl $2,B;\ - -/* - * fn1 = (((C^D)&B)^D); - */ -#define FN1(B,C,D)\ - movl C, %edi;\ - xorl D, %edi;\ - andl B, %edi;\ - xorl D, %edi;\ - -/* - * fn24 = B ^ C ^ D - */ -#define FN24(B,C,D)\ - movl B, %edi;\ - xorl C, %edi;\ - xorl D, %edi;\ - -/* - * fn3 = ((B ^ C) & (D ^= B)) ^ B - * D ^= B to restore D - */ -#define FN3(B,C,D)\ - movl B, %edi;\ - xorl C, %edi;\ - xorl B, D;\ - andl D, %edi;\ - xorl B, %edi;\ - xorl B, D;\ - -/* - * stack offsets - * void sha1block(uchar *DATA, int LEN, ulong *STATE) - */ -#define STACKSIZE (48+80*4) -#define DATA (STACKSIZE+8) -#define LEN (STACKSIZE+12) -#define STATE (STACKSIZE+16) - -/* - * stack offsets for locals - * ulong w[80]; - * uchar *edata; - * ulong *w15, *w40, *w60, *w80; - * register local - * ulong *wp = %ebp - * ulong a = eax, b = ebx, c = ecx, d = edx, e = esi - * ulong tmp = edi - */ -#define WARRAY (STACKSIZE-4-(80*4)) -#define TMP1 (STACKSIZE-8-(80*4)) -#define TMP2 (STACKSIZE-12-(80*4)) -#define W15 (STACKSIZE-16-(80*4)) -#define W40 (STACKSIZE-20-(80*4)) -#define W60 (STACKSIZE-24-(80*4)) -#define W80 (STACKSIZE-28-(80*4)) -#define EDATA (STACKSIZE-32-(80*4)) -#define OLDEBX (STACKSIZE-36-(80*4)) -#define OLDESI (STACKSIZE-40-(80*4)) -#define OLDEDI (STACKSIZE-44-(80*4)) - - /* Prelude */ - pushl %ebp - subl $(STACKSIZE), %esp - - mov %ebx, OLDEBX(%esp) - mov %esi, OLDESI(%esp) - mov %edi, OLDEDI(%esp) - - movl DATA(%esp), %eax - addl LEN(%esp), %eax - movl %eax, EDATA(%esp) - - leal (WARRAY+15*4)(%esp), %edi /* aw15 */ - movl %edi, W15(%esp) - leal (WARRAY+40*4)(%esp), %edx /* aw40 */ - movl %edx, W40(%esp) - leal (WARRAY+60*4)(%esp), %ecx /* aw60 */ - movl %ecx, W60(%esp) - leal (WARRAY+80*4)(%esp), %edi /* aw80 */ - movl %edi, W80(%esp) - -0: - leal WARRAY(%esp), %ebp /* warray */ - - movl STATE(%esp), %edi /* state */ - movl (%edi),%eax - movl 4(%edi),%ebx - movl %ebx, TMP1(%esp) /* tmp1 */ - movl 8(%edi), %ecx - movl 12(%edi), %edx - movl 16(%edi), %esi - - movl DATA(%esp), %ebx /* data */ - -1: - BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) - movl %esi,TMP2(%esp) - BODY0(4,FN1,0x5a827999,%esi,%eax,TMP1(%esp),%ecx,%edx) - movl TMP1(%esp),%esi - BODY0(8,FN1,0x5a827999,%edx,TMP2(%esp),%eax,%esi,%ecx) - BODY0(12,FN1,0x5a827999,%ecx,%edx,TMP2(%esp),%eax,%esi) - movl %esi,TMP1(%esp) - BODY0(16,FN1,0x5a827999,%esi,%ecx,%edx,TMP2(%esp),%eax) - movl TMP2(%esp),%esi - - addl $20, %ebx - addl $20, %ebp - cmpl W15(%esp), %ebp /* w15 */ - jb 1b - - BODY0(0,FN1,0x5a827999,%eax,TMP1(%esp),%ecx,%edx,%esi) - addl $4, %ebx - movl %ebx, DATA(%esp) /* data */ - movl TMP1(%esp),%ebx - - BODY(4,FN1,0x5a827999,%esi,%eax,%ebx,%ecx,%edx) - BODY(8,FN1,0x5a827999,%edx,%esi,%eax,%ebx,%ecx) - BODY(12,FN1,0x5a827999,%ecx,%edx,%esi,%eax,%ebx) - BODY(16,FN1,0x5a827999,%ebx,%ecx,%edx,%esi,%eax) - - addl $20, %ebp - -2: - BODY(0,FN24,0x6ed9eba1,%eax,%ebx,%ecx,%edx,%esi) - BODY(4,FN24,0x6ed9eba1,%esi,%eax,%ebx,%ecx,%edx) - BODY(8,FN24,0x6ed9eba1,%edx,%esi,%eax,%ebx,%ecx) - BODY(12,FN24,0x6ed9eba1,%ecx,%edx,%esi,%eax,%ebx) - BODY(16,FN24,0x6ed9eba1,%ebx,%ecx,%edx,%esi,%eax) - - addl $20,%ebp - cmpl W40(%esp), %ebp - jb 2b - -3: - BODY(0,FN3,0x8f1bbcdc,%eax,%ebx,%ecx,%edx,%esi) - BODY(4,FN3,0x8f1bbcdc,%esi,%eax,%ebx,%ecx,%edx) - BODY(8,FN3,0x8f1bbcdc,%edx,%esi,%eax,%ebx,%ecx) - BODY(12,FN3,0x8f1bbcdc,%ecx,%edx,%esi,%eax,%ebx) - BODY(16,FN3,0x8f1bbcdc,%ebx,%ecx,%edx,%esi,%eax) - - addl $20, %ebp - cmpl W60(%esp), %ebp /* w60 */ - jb 3b - -4: - BODY(0,FN24,0xca62c1d6,%eax,%ebx,%ecx,%edx,%esi) - BODY(4,FN24,0xca62c1d6,%esi,%eax,%ebx,%ecx,%edx) - BODY(8,FN24,0xca62c1d6,%edx,%esi,%eax,%ebx,%ecx) - BODY(12,FN24,0xca62c1d6,%ecx,%edx,%esi,%eax,%ebx) - BODY(16,FN24,0xca62c1d6,%ebx,%ecx,%edx,%esi,%eax) - - addl $20, %ebp - cmpl W80(%esp), %ebp /* w80 */ - jb 4b - - movl STATE(%esp), %edi /* state */ - addl %eax, 0(%edi) - addl %ebx, 4(%edi) - addl %ecx, 8(%edi) - addl %edx, 12(%edi) - addl %esi, 16(%edi) - - movl EDATA(%esp), %edi /* edata */ - cmpl %edi, DATA(%esp) /* data */ - jb 0b - - /* Postlude */ - mov OLDEBX(%esp), %ebx - mov OLDESI(%esp), %esi - mov OLDEDI(%esp), %edi - addl $(STACKSIZE), %esp - popl %ebp - ret diff --git a/src/libsec/PowerMacintosh/mkfile b/src/libsec/PowerMacintosh/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/PowerMacintosh/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/arm/mkfile b/src/libsec/arm/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/arm/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/arm64/mkfile b/src/libsec/arm64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/arm64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/mips/mkfile b/src/libsec/mips/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/mips/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/mkfile b/src/libsec/mkfile index e3f1aa696..81f237c43 100644 --- a/src/libsec/mkfile +++ b/src/libsec/mkfile @@ -2,6 +2,6 @@ DIRS=\ port\ - $OBJTYPE\ +# $OBJTYPE\ <$PLAN9/src/mkdirs diff --git a/src/libsec/port/mkfile b/src/libsec/port/mkfile index 60baf2a3a..7db34a979 100644 --- a/src/libsec/port/mkfile +++ b/src/libsec/port/mkfile @@ -54,7 +54,8 @@ ALLOFILES=\ tlshand.$O\ x509.$O\ -OFILES=`{sh ./reduce $O $OBJTYPE $ALLOFILES} +# OFILES=`{sh ./reduce $O $OBJTYPE $ALLOFILES} +OFILES=$ALLOFILES HFILES=$PLAN9/include/libsec.h <$PLAN9/src/mksyslib diff --git a/src/libsec/power/mkfile b/src/libsec/power/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/power/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/sparc64/mkfile b/src/libsec/sparc64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/sparc64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/sun4u/mkfile b/src/libsec/sun4u/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/sun4u/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/libsec/x86_64/mkfile b/src/libsec/x86_64/mkfile deleted file mode 100644 index 43a4662b3..000000000 --- a/src/libsec/x86_64/mkfile +++ /dev/null @@ -1,4 +0,0 @@ -all: - -%:V: - # nothing to see here diff --git a/src/mkenv b/src/mkenv index 6c89f141b..5feca4835 100644 --- a/src/mkenv +++ b/src/mkenv @@ -2,22 +2,22 @@ # and also valid shell input for ../dist/buildmk SYSNAME=`uname` -OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' - s;.*i[3-6]86.*;386;; - s;.*i86pc.*;386;; - s;.*amd64.*;x86_64;; - s;.*x86_64.*;x86_64;; - s;.*armv.*;arm;g; - s;.*powerpc.*;power;g; - s;.*PowerMacintosh.*;power;g; - s;.*Power.Macintosh.*;power;g; - s;.*macppc.*;power;g; - s;.*mips.*;mips;g; - s;.*ppc64.*;power;g; - s;.*ppc.*;power;g; - s;.*alpha.*;alpha;g; - s;.*sun4u.*;sun4u;g; - s;.*aarch64.*;arm64; - s;.*arm64.*;arm64; -'` +# OBJTYPE=`(uname -m -p 2>/dev/null || uname -m) | sed ' +# s;.*i[3-6]86.*;386;; +# s;.*i86pc.*;386;; +# s;.*amd64.*;x86_64;; +# s;.*x86_64.*;x86_64;; +# s;.*armv.*;arm;g; +# s;.*powerpc.*;power;g; +# s;.*PowerMacintosh.*;power;g; +# s;.*Power.Macintosh.*;power;g; +# s;.*macppc.*;power;g; +# s;.*mips.*;mips;g; +# s;.*ppc64.*;power;g; +# s;.*ppc.*;power;g; +# s;.*alpha.*;alpha;g; +# s;.*sun4u.*;sun4u;g; +# s;.*aarch64.*;arm64; +# s;.*arm64.*;arm64; +# '` INSTALL=`[ $(uname) = AIX ] && echo installbsd || echo install` diff --git a/src/mkfile b/src/mkfile index 4740780db..d17ca6b6e 100644 --- a/src/mkfile +++ b/src/mkfile @@ -37,9 +37,7 @@ mkmk.sh:VD: ) | sed ' s/'$INSTALL'/$INSTALL/g s/'$SYSNAME'/$SYSNAME/g - s/'$OBJTYPE'/$OBJTYPE/g s;'$PLAN9';$PLAN9;g - s/^9[ac] *tas-.*/9a tas-$OBJTYPE.s || 9c tas-$OBJTYPE.c/ ' >$target testmkmk:V: diff --git a/unix/make/Make.Darwin-386 b/unix/make/Make.Darwin similarity index 100% rename from unix/make/Make.Darwin-386 rename to unix/make/Make.Darwin diff --git a/unix/make/Make.Darwin-PowerMacintosh b/unix/make/Make.Darwin-PowerMacintosh deleted file mode 100644 index 21ede6f29..000000000 --- a/unix/make/Make.Darwin-PowerMacintosh +++ /dev/null @@ -1,7 +0,0 @@ -CC=gcc -CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -I${PREFIX}/include -O=o -AR=ar -ARFLAGS=rvc -NAN=nan64.$O -RANLIB=ranlib diff --git a/unix/make/Make.FreeBSD-386 b/unix/make/Make.FreeBSD similarity index 100% rename from unix/make/Make.FreeBSD-386 rename to unix/make/Make.FreeBSD diff --git a/unix/make/Make.HP-UX-9000 b/unix/make/Make.HP-UX similarity index 100% rename from unix/make/Make.HP-UX-9000 rename to unix/make/Make.HP-UX diff --git a/unix/make/Make.Linux-x86_64 b/unix/make/Make.Linux similarity index 100% rename from unix/make/Make.Linux-x86_64 rename to unix/make/Make.Linux diff --git a/unix/make/Make.Linux-386 b/unix/make/Make.Linux-386 deleted file mode 100644 index c1dc41095..000000000 --- a/unix/make/Make.Linux-386 +++ /dev/null @@ -1,6 +0,0 @@ -CC=gcc -CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -O=o -AR=ar -ARFLAGS=rvc -NAN=nan64.$O diff --git a/unix/make/Make.Linux-power b/unix/make/Make.Linux-power deleted file mode 100644 index c1dc41095..000000000 --- a/unix/make/Make.Linux-power +++ /dev/null @@ -1,6 +0,0 @@ -CC=gcc -CFLAGS+=-Wall -Wno-missing-braces -Wno-parentheses -Wno-switch -O2 -g -c -I. -O=o -AR=ar -ARFLAGS=rvc -NAN=nan64.$O diff --git a/unix/make/Make.NetBSD-386 b/unix/make/Make.NetBSD similarity index 100% rename from unix/make/Make.NetBSD-386 rename to unix/make/Make.NetBSD diff --git a/unix/make/Make.OSF1-alpha b/unix/make/Make.OSF1 similarity index 100% rename from unix/make/Make.OSF1-alpha rename to unix/make/Make.OSF1 diff --git a/unix/make/Make.OpenBSD-386 b/unix/make/Make.OpenBSD similarity index 100% rename from unix/make/Make.OpenBSD-386 rename to unix/make/Make.OpenBSD diff --git a/unix/make/Make.SunOS b/unix/make/Make.SunOS new file mode 100644 index 000000000..a306597b0 --- /dev/null +++ b/unix/make/Make.SunOS @@ -0,0 +1,2 @@ +include Make.SunOS-$(CC) +NAN=nan64.$O diff --git a/unix/make/Make.SunOS-sun4u-cc b/unix/make/Make.SunOS-cc similarity index 100% rename from unix/make/Make.SunOS-sun4u-cc rename to unix/make/Make.SunOS-cc diff --git a/unix/make/Make.SunOS-sun4u-gcc b/unix/make/Make.SunOS-gcc similarity index 100% rename from unix/make/Make.SunOS-sun4u-gcc rename to unix/make/Make.SunOS-gcc diff --git a/unix/make/Make.SunOS-sun4u b/unix/make/Make.SunOS-sun4u deleted file mode 100644 index c5fe67b82..000000000 --- a/unix/make/Make.SunOS-sun4u +++ /dev/null @@ -1,2 +0,0 @@ -include Make.SunOS-sun4u-$(CC) -NAN=nan64.$O diff --git a/unix/make/Makefile.TOP b/unix/make/Makefile.TOP index 516937e08..5feb1d471 100644 --- a/unix/make/Makefile.TOP +++ b/unix/make/Makefile.TOP @@ -1,18 +1,16 @@ # this works in gnu make SYSNAME:=${shell uname} -OBJTYPE:=${shell uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'} # this works in bsd make SYSNAME!=uname -OBJTYPE!=uname -m | sed 's;i.86;386;; s;amd64;x864_64;; s;/.*;;; s; ;;g' # the gnu rules will mess up bsd but not vice versa, # hence the gnu rules come first. RANLIB=true -include Make.$(SYSNAME)-$(OBJTYPE) +include Make.$(SYSNAME) PREFIX=/usr/local From ebbeff0ac69f8fa25fed3f85d2e7b2261e4fa2aa Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 07:59:26 -0500 Subject: [PATCH 279/323] .gitignore: enumerate ignored parts of bin/ --- .gitignore | 235 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 218 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index f590cf28d..61deffc6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,226 @@ -plan9.log -plan9-reverse.log -state -state.old -state.journal -*.o *.a -man/man?/*.html -src/**/o.* -y.tab.[ch] -src/cmd/rc/x.tab.h -unix/*.tgz -bin/ -log/ -dict/ -postscript/font/ -sky/here -sky/*.scat +*.o *.orig +bin/9660srv +bin/9import +bin/9p +bin/9pfuse +bin/9pserve +bin/9term +bin/Mail +bin/Netfiles +bin/acid +bin/acidtypes +bin/acme +bin/acmeevent +bin/aescbc +bin/ascii +bin/asn12dsa +bin/asn12rsa +bin/astro +bin/auxclog +bin/auxstats +bin/awk +bin/basename +bin/bc +bin/bmp +bin/bunzip2 +bin/bzip2 +bin/cal +bin/calendar +bin/cat +bin/cb +bin/cleanname +bin/clock +bin/cmapcube +bin/cmp +bin/col +bin/colors +bin/comm +bin/compress +bin/core +bin/crop +bin/date +bin/db +bin/dc +bin/dd +bin/delatex +bin/deroff +bin/devdraw +bin/dial +bin/dict +bin/diff +bin/disknfs +bin/dns +bin/dnsdebug +bin/dnsquery +bin/dnstcp +bin/dsa2pub +bin/dsa2ssh +bin/dsagen +bin/dsasign +bin/du +bin/dump9660 +bin/echo +bin/ed +bin/eqn +bin/factor +bin/factotum +bin/file +bin/fmt +bin/fontsrv +bin/fortune +bin/freq +bin/fsize +bin/getflags +bin/gif +bin/grap +bin/graph +bin/grep +bin/gunzip +bin/gview +bin/gzip +bin/hget +bin/hist +bin/hoc +bin/htmlfmt +bin/htmlroff +bin/ico +bin/iconv +bin/idiff +bin/img +bin/import +bin/join +bin/jpg +bin/lex +bin/listen1 +bin/look +bin/ls +bin/macargv +bin/mapd +bin/mc +bin/md5sum +bin/mk +bin/mkdir +bin/mklatinkbd +bin/mtime +bin/namespace +bin/ndbipquery +bin/ndbmkdb +bin/ndbmkhash +bin/ndbmkhosts +bin/ndbquery +bin/netkey +bin/news +bin/p +bin/page +bin/paint +bin/passwd +bin/pbd +bin/pemdecode +bin/pemencode +bin/pic +bin/plot +bin/plumb +bin/plumber +bin/png +bin/ppm +bin/pr +bin/primes +bin/proof +bin/psdownload +bin/ramfs +bin/rc +bin/read +bin/readcons +bin/resample +bin/rm +bin/rsa2csr +bin/rsa2pub +bin/rsa2ssh +bin/rsa2x509 +bin/rsafill +bin/rsagen +bin/sam +bin/samterm +bin/scat +bin/secstore +bin/secstored +bin/secuser +bin/sed +bin/seq +bin/sftpcache +bin/sha1sum +bin/sleep +bin/sort +bin/split +bin/sprog +bin/srv +bin/ssh-agent +bin/stats +bin/statusbar +bin/strings +bin/sum +bin/svgpic +bin/tail +bin/tar +bin/tbl +bin/tcolors +bin/tcs +bin/tee +bin/test +bin/time +bin/togif +bin/toico +bin/topng +bin/toppm +bin/touch +bin/tpic +bin/tr +bin/tr2post +bin/troff +bin/troff2html +bin/tweak +bin/uncompress +bin/unicode +bin/uniq +bin/units +bin/unutf +bin/unvac +bin/unzip +bin/usage +bin/vac +bin/vacfs +bin/vbackup +bin/vcat +bin/vmount0 +bin/vnfs +bin/wc +bin/win +bin/xd +bin/yacc +bin/yuv +bin/zcat +bin/zerotrunc +bin/zip config +dict/ install.log install.sum last-change +log/ +man/man?/*.html +plan9-reverse.log +plan9.log +postscript/font/ +sky/*.scat +sky/here +src/**/o.* src/cmd/awk/y.output src/cmd/devdraw/latin1.h +src/cmd/rc/x.tab.h +state +state.journal +state.old +unix/*.tgz +y.tab.[ch] From 0ed5e9f828757a17995e0550f285a11c1ff27026 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:07:24 -0500 Subject: [PATCH 280/323] 9a: remove a few mentions --- man/man1/9c.1 | 16 +--------------- src/mkhdr | 2 +- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/man/man1/9c.1 b/man/man1/9c.1 index dd15926d7..943df6fbe 100644 --- a/man/man1/9c.1 +++ b/man/man1/9c.1 @@ -1,6 +1,6 @@ .TH 9C 1 .SH NAME -9c, 9a, 9l, 9ar \- C compiler, assembler, linker, archiver +9c, 9l, 9ar \- C compiler, assembler, linker, archiver .SH SYNOPSIS .B 9c [ @@ -14,10 +14,6 @@ .I file \&... .PP -.B 9a -.I file -\&... -.PP .B 9l [ .I -o @@ -81,12 +77,6 @@ also defines .B __sun__ on SunOS systems. .PP -.I 9a -assembles the named files into object files for the current system. -Unlike some system assemblers, it does -.I not -promise to run the C preprocessor on the source files. -.PP .I 9l links the named object files and libraries to create the target executable. Each @@ -203,10 +193,6 @@ rebuilt whenever the archive is modified. Compile three C source files. .TP .L -9a file4.s -Assemble one assembler source file. -.TP -.L 9ar rvc lib.a file[12].o Archive the first two object files into a library. .TP diff --git a/src/mkhdr b/src/mkhdr index 35a2ccc54..77cf85593 100644 --- a/src/mkhdr +++ b/src/mkhdr @@ -9,7 +9,7 @@ OS=$O CC=9c #CC=9r LD=9l -AS=9a +AS=no-9a AR=9ar CFLAGS= LDFLAGS= From 74577741c856c145811061a438d5a52ea7055f39 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:12:04 -0500 Subject: [PATCH 281/323] tcolors: add threadmaybackground --- src/cmd/draw/tcolors.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/draw/tcolors.c b/src/cmd/draw/tcolors.c index 9aa4de798..056749470 100644 --- a/src/cmd/draw/tcolors.c +++ b/src/cmd/draw/tcolors.c @@ -44,6 +44,12 @@ dither[16] = { extern int chattydrawclient; +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { From 4692dd4786f8847494d3f020bc3c05ba210adc0d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:38:55 -0500 Subject: [PATCH 282/323] 9c: drop PLAN9PORT_ASAN It is no longer special. --- bin/9c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/bin/9c b/bin/9c index 4d4881792..63840b198 100755 --- a/bin/9c +++ b/bin/9c @@ -26,10 +26,6 @@ usegcc() # that option only works with gcc3+ it seems cflags="$cflags -ggdb" cflags="$cflags $CC9FLAGS" - case "$cflags" in - *sanitize=address*) - cflags="$cflags -DPLAN9PORT_ASAN" - esac } quiet() @@ -87,11 +83,6 @@ useclang() " cflags="$cflags -g" cflags="$cflags $CC9FLAGS" - - case "$cflags" in - *sanitize=address*) - cflags="$cflags -DPLAN9PORT_ASAN" - esac } usexlc() From 91ececc99741b3111c69d455bc928e871b15d766 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:41:01 -0500 Subject: [PATCH 283/323] libthread: drop schedlock Having two locks in the proc was causing deadlocks. --- src/libthread/thread.c | 2 +- src/libthread/threadimpl.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libthread/thread.c b/src/libthread/thread.c index d72bf896d..79e0ec71f 100644 --- a/src/libthread/thread.c +++ b/src/libthread/thread.c @@ -281,7 +281,7 @@ static void pthreadwakeupschedlocked(Proc *p, _Thread *self, _Thread *t) { _threaddebug(self, "pthreadwakeupschedlocked %p %d", p, t->id);; - t->schedrend.l = &p->schedlock; + t->schedrend.l = &p->lock; p->schedthread = t; _procwakeup(&t->schedrend); } diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h index 9eddba21f..fd40f2528 100644 --- a/src/libthread/threadimpl.h +++ b/src/libthread/threadimpl.h @@ -88,7 +88,6 @@ struct Proc uint nthread; uint sysproc; _Procrendez runrend; - Lock schedlock; _Thread *schedthread; void *udata; Jmp sigjmp; From ee9b2a22996e29d55b97f7717163989173c71747 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:44:15 -0500 Subject: [PATCH 284/323] .gitignore: more binaries --- .gitignore | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.gitignore b/.gitignore index 61deffc6d..bb7c160db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ *.a *.o *.orig +bin/" +bin/"" bin/9660srv bin/9import bin/9p @@ -50,6 +52,8 @@ bin/devdraw bin/dial bin/dict bin/diff +bin/disk/mkext +bin/disk/mkfs bin/disknfs bin/dns bin/dnsdebug @@ -70,7 +74,21 @@ bin/file bin/fmt bin/fontsrv bin/fortune +bin/fossil/conf +bin/fossil/flchk +bin/fossil/flfmt +bin/fossil/fossil +bin/fossil/last +bin/fossil/view bin/freq +bin/fs/32vfs +bin/fs/cpiofs +bin/fs/tapfs +bin/fs/tarfs +bin/fs/tpfs +bin/fs/v10fs +bin/fs/v6fs +bin/fs/zipfs bin/fsize bin/getflags bin/gif @@ -101,6 +119,7 @@ bin/mapd bin/mc bin/md5sum bin/mk +bin/mk9660 bin/mkdir bin/mklatinkbd bin/mtime @@ -110,6 +129,10 @@ bin/ndbmkdb bin/ndbmkhash bin/ndbmkhosts bin/ndbquery +bin/netfileget +bin/netfilelib.rc +bin/netfileput +bin/netfilestat bin/netkey bin/news bin/p @@ -193,6 +216,31 @@ bin/vac bin/vacfs bin/vbackup bin/vcat +bin/venti/buildindex +bin/venti/checkarenas +bin/venti/checkindex +bin/venti/clumpstats +bin/venti/conf +bin/venti/copy +bin/venti/dump +bin/venti/findscore +bin/venti/fixarenas +bin/venti/fmtarenas +bin/venti/fmtbloom +bin/venti/fmtindex +bin/venti/fmtisect +bin/venti/mirrorarenas +bin/venti/printarena +bin/venti/printarenapart +bin/venti/rdarena +bin/venti/read +bin/venti/ro +bin/venti/sync +bin/venti/syncindex +bin/venti/venti +bin/venti/verifyarena +bin/venti/wrarena +bin/venti/write bin/vmount0 bin/vnfs bin/wc From f23783cbb197f71f867bd9d44abfa8787a65448b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 08:46:47 -0500 Subject: [PATCH 285/323] .gitignore: add LOCAL.config and lib/fortunes.index --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bb7c160db..ad8a20dee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.a *.o *.orig +LOCAL.config bin/" bin/"" bin/9660srv @@ -256,6 +257,7 @@ dict/ install.log install.sum last-change +lib/fortunes.index log/ man/man?/*.html plan9-reverse.log From dbc153f51e2af8fabe43b0c408d27f2dd6b09925 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 10:40:25 -0500 Subject: [PATCH 286/323] 9term: add threadmaybackground --- src/cmd/9term/9term.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index b28f44faf..d7391cf52 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -47,6 +47,12 @@ usage(void) threadexitsall("usage"); } +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { From 6c8e44dd2e3b346ad5e313830ef22ee7b0a9df04 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 30 Dec 2020 20:36:09 +0100 Subject: [PATCH 287/323] wintext: add to moveplan9.files (#470) --- lib/moveplan9.files | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/moveplan9.files b/lib/moveplan9.files index 165351033..fe47d4ab0 100644 --- a/lib/moveplan9.files +++ b/lib/moveplan9.files @@ -34,6 +34,7 @@ bin/upas/unspambox bin/venti/conf bin/vmount bin/vwhois +bin/wintext bin/yesterday dist/debian/mkpkg dist/debian/mkrep From ac487c754e009b0f3c01c2a8ad5bda2143da4a6b Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 30 Dec 2020 14:42:47 -0500 Subject: [PATCH 288/323] acme: allow @ in file names For upspin and other tools that put email addresses in names. --- src/cmd/acme/look.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 35667c6c3..a7172b505 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -378,7 +378,7 @@ search(Text *ct, Rune *r, uint n) int isfilec(Rune r) { - static Rune Lx[] = { '.', '-', '+', '/', ':', 0 }; + static Rune Lx[] = { '.', '-', '+', '/', ':', '@', 0 }; if(isalnum(r)) return TRUE; if(runestrchr(Lx, r)) From 7f6458b045e04b97dd06b3171ac67e9ecde32429 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 5 Jan 2021 23:35:33 -0500 Subject: [PATCH 289/323] stats: add threadmaybackground --- src/cmd/devdraw/mac-screen.m | 5 ++- src/cmd/draw/stats.c | 6 ++++ src/cmd/sam/cmd.c | 70 ++++++++++++++++++------------------ src/cmd/sam/parse.h | 6 ++-- src/cmd/sam/sam.h | 2 -- 5 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index ad9c029e7..9e51eec6e 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -238,11 +238,14 @@ - (id)attach:(Client*)client winsize:(char*)winsize label:(char*)label { char *s; NSArray *allDevices; - const NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled + NSWindowStyleMask Winstyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; + if(label == nil || *label == '\0') + Winstyle &= ~NSWindowStyleMaskTitled; + s = winsize; sr = [[NSScreen mainScreen] frame]; r = [[NSScreen mainScreen] visibleFrame]; diff --git a/src/cmd/draw/stats.c b/src/cmd/draw/stats.c index 3b6471b79..d74b95e33 100644 --- a/src/cmd/draw/stats.c +++ b/src/cmd/draw/stats.c @@ -675,6 +675,12 @@ keyboardthread(void *v) void machproc(void*); void updateproc(void*); +int +threadmaybackground(void) +{ + return 1; +} + void threadmain(int argc, char *argv[]) { diff --git a/src/cmd/sam/cmd.c b/src/cmd/sam/cmd.c index 386fe8d47..7176a8271 100644 --- a/src/cmd/sam/cmd.c +++ b/src/cmd/sam/cmd.c @@ -3,41 +3,41 @@ static char linex[]="\n"; static char wordx[]=" \t\n"; -struct cmdtab cmdtab[]={ +struct Cmdtab cmdtab[]={ /* cmdc text regexp addr defcmd defaddr count token fn */ - '\n', 0, 0, 0, 0, aDot, 0, 0, nl_cmd, - 'a', 1, 0, 0, 0, aDot, 0, 0, a_cmd, - 'b', 0, 0, 0, 0, aNo, 0, linex, b_cmd, - 'B', 0, 0, 0, 0, aNo, 0, linex, b_cmd, - 'c', 1, 0, 0, 0, aDot, 0, 0, c_cmd, - 'd', 0, 0, 0, 0, aDot, 0, 0, d_cmd, - 'D', 0, 0, 0, 0, aNo, 0, linex, D_cmd, - 'e', 0, 0, 0, 0, aNo, 0, wordx, e_cmd, - 'f', 0, 0, 0, 0, aNo, 0, wordx, f_cmd, - 'g', 0, 1, 0, 'p', aDot, 0, 0, g_cmd, - 'i', 1, 0, 0, 0, aDot, 0, 0, i_cmd, - 'k', 0, 0, 0, 0, aDot, 0, 0, k_cmd, - 'm', 0, 0, 1, 0, aDot, 0, 0, m_cmd, - 'n', 0, 0, 0, 0, aNo, 0, 0, n_cmd, - 'p', 0, 0, 0, 0, aDot, 0, 0, p_cmd, - 'q', 0, 0, 0, 0, aNo, 0, 0, q_cmd, - 'r', 0, 0, 0, 0, aDot, 0, wordx, e_cmd, - 's', 0, 1, 0, 0, aDot, 1, 0, s_cmd, - 't', 0, 0, 1, 0, aDot, 0, 0, m_cmd, - 'u', 0, 0, 0, 0, aNo, 2, 0, u_cmd, - 'v', 0, 1, 0, 'p', aDot, 0, 0, g_cmd, - 'w', 0, 0, 0, 0, aAll, 0, wordx, w_cmd, - 'x', 0, 1, 0, 'p', aDot, 0, 0, x_cmd, - 'y', 0, 1, 0, 'p', aDot, 0, 0, x_cmd, - 'X', 0, 1, 0, 'f', aNo, 0, 0, X_cmd, - 'Y', 0, 1, 0, 'f', aNo, 0, 0, X_cmd, - '!', 0, 0, 0, 0, aNo, 0, linex, plan9_cmd, - '>', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd, - '<', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd, - '|', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd, - '=', 0, 0, 0, 0, aDot, 0, linex, eq_cmd, - 'c'|0x100,0, 0, 0, 0, aNo, 0, wordx, cd_cmd, - 0, 0, 0, 0, 0, 0, 0, 0 + {'\n', 0, 0, 0, 0, aDot, 0, 0, nl_cmd}, + {'a', 1, 0, 0, 0, aDot, 0, 0, a_cmd}, + {'b', 0, 0, 0, 0, aNo, 0, linex, b_cmd}, + {'B', 0, 0, 0, 0, aNo, 0, linex, b_cmd}, + {'c', 1, 0, 0, 0, aDot, 0, 0, c_cmd}, + {'d', 0, 0, 0, 0, aDot, 0, 0, d_cmd}, + {'D', 0, 0, 0, 0, aNo, 0, linex, D_cmd}, + {'e', 0, 0, 0, 0, aNo, 0, wordx, e_cmd}, + {'f', 0, 0, 0, 0, aNo, 0, wordx, f_cmd}, + {'g', 0, 1, 0, 'p', aDot, 0, 0, g_cmd}, + {'i', 1, 0, 0, 0, aDot, 0, 0, i_cmd}, + {'k', 0, 0, 0, 0, aDot, 0, 0, k_cmd}, + {'m', 0, 0, 1, 0, aDot, 0, 0, m_cmd}, + {'n', 0, 0, 0, 0, aNo, 0, 0, n_cmd}, + {'p', 0, 0, 0, 0, aDot, 0, 0, p_cmd}, + {'q', 0, 0, 0, 0, aNo, 0, 0, q_cmd}, + {'r', 0, 0, 0, 0, aDot, 0, wordx, e_cmd}, + {'s', 0, 1, 0, 0, aDot, 1, 0, s_cmd}, + {'t', 0, 0, 1, 0, aDot, 0, 0, m_cmd}, + {'u', 0, 0, 0, 0, aNo, 2, 0, u_cmd}, + {'v', 0, 1, 0, 'p', aDot, 0, 0, g_cmd}, + {'w', 0, 0, 0, 0, aAll, 0, wordx, w_cmd}, + {'x', 0, 1, 0, 'p', aDot, 0, 0, x_cmd}, + {'y', 0, 1, 0, 'p', aDot, 0, 0, x_cmd}, + {'X', 0, 1, 0, 'f', aNo, 0, 0, X_cmd}, + {'Y', 0, 1, 0, 'f', aNo, 0, 0, X_cmd}, + {'!', 0, 0, 0, 0, aNo, 0, linex, plan9_cmd}, + {'>', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd}, + {'<', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd}, + {'|', 0, 0, 0, 0, aDot, 0, linex, plan9_cmd}, + {'=', 0, 0, 0, 0, aDot, 0, linex, eq_cmd}, + {'c'|0x100,0, 0, 0, 0, aNo, 0, wordx, cd_cmd}, + {0, 0, 0, 0, 0, 0, 0, 0}, }; Cmd *parsecmd(int); Addr *compoundaddr(void); @@ -402,7 +402,7 @@ Cmd * parsecmd(int nest) { int i, c; - struct cmdtab *ct; + Cmdtab *ct; Cmd *cp, *ncp; Cmd cmd; diff --git a/src/cmd/sam/parse.h b/src/cmd/sam/parse.h index d5fabf14e..dd837a48c 100644 --- a/src/cmd/sam/parse.h +++ b/src/cmd/sam/parse.h @@ -33,7 +33,8 @@ struct Cmd #define ctext g.text #define caddr g.addr -extern struct cmdtab{ +typedef struct Cmdtab Cmdtab; +struct Cmdtab { ushort cmdc; /* command character */ uchar text; /* takes a textual argument? */ uchar regexp; /* takes a regular expression? */ @@ -43,7 +44,8 @@ extern struct cmdtab{ uchar count; /* takes a count e.g. s2/// */ char *token; /* takes text terminated by one of these */ int (*fn)(File*, Cmd*); /* function to call with parse tree */ -}cmdtab[]; +}; +extern Cmdtab cmdtab[]; enum Defaddr{ /* default addresses */ aNo, diff --git a/src/cmd/sam/sam.h b/src/cmd/sam/sam.h index aae39b4a4..6e018156f 100644 --- a/src/cmd/sam/sam.h +++ b/src/cmd/sam/sam.h @@ -37,7 +37,6 @@ typedef struct Address Address; typedef struct Block Block; typedef struct Buffer Buffer; typedef struct Disk Disk; -typedef struct Discdesc Discdesc; typedef struct File File; typedef struct List List; typedef struct Range Range; @@ -342,7 +341,6 @@ void warn_S(Warn, String*); int whichmenu(File*); void writef(File*); Posn writeio(File*); -Discdesc *Dstart(void); extern Rune samname[]; /* compiler dependent */ extern Rune *left[]; From 0a513e65607223d11ba94003256b13ef5779e7e8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 3 Jan 2021 00:54:20 -0500 Subject: [PATCH 290/323] sam: rm dregs --- src/cmd/sam/README | 29 ------- src/cmd/sam/_libc.h | 40 ---------- src/cmd/sam/err | 39 ---------- src/cmd/sam/plan9.c | 185 -------------------------------------------- 4 files changed, 293 deletions(-) delete mode 100644 src/cmd/sam/README delete mode 100644 src/cmd/sam/_libc.h delete mode 100644 src/cmd/sam/err delete mode 100644 src/cmd/sam/plan9.c diff --git a/src/cmd/sam/README b/src/cmd/sam/README deleted file mode 100644 index b78a89daa..000000000 --- a/src/cmd/sam/README +++ /dev/null @@ -1,29 +0,0 @@ -This is sam (not including samterm) from the 4th edition of Plan 9, -with changes so that it can be compiled under unix. -(Tested on Solaris 7 and Debian 3.0r1.) - -Some extra libraries are needed. First, fetch libutf-2.0 and libfmt-2.0 -from - http://pdos.lcs.mit.edu/~rsc/software/ - -(Beware that in libfmt/fmt.c there is a line that says: - 'u', __ifmt, /* in Plan 9, __flagfmt */ -Thus, sam will have to fmtinstall the other thing. Other ported programs -may have to do the same. The fmt library should probably print messages -about bad format characters to stderr, since no one seems to check the -return codes.) - -Compile and install those two libraries. -Set PREFIX in the Makefile to match, then compile sam. - -Your C compiler will emit many complaints of the form: - sam.c:496: warning: passing arg 1 of `bufread' from incompatible pointer type - -This is because the Plan 9 compiler has a slightly different (better, -ala Oberon) type system than ISO C. Popular compilers generate the right -code, so in an act of civil disobediance I changed just enough to get -it to compile, but left the type errors in. Now the next C standard can -adopt this extension, because at least one important C program uses it! - --- Scott Schwartz, 4 July 2003 - diff --git a/src/cmd/sam/_libc.h b/src/cmd/sam/_libc.h deleted file mode 100644 index 656189182..000000000 --- a/src/cmd/sam/_libc.h +++ /dev/null @@ -1,40 +0,0 @@ -#define __USE_UNIX98 // for pread/pwrite, supposedly -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utf.h" -#include "fmt.h" - -#define nil 0 -#define dup dup2 -#define exec execv -#define seek lseek -#define getwd getcwd -#define USED(a) -#define SET(a) - -enum { - OREAD = 0, - OWRITE = 1, - ORDWR = 2, - OCEXEC = 4, - ORCLOSE = 8 -}; - -enum { - ERRMAX = 255 -}; - -void exits(const char *); -void _exits(const char *); -int notify (void(*f)(void *, char *)); -int create(char *, int, int); -int errstr(char *, int); diff --git a/src/cmd/sam/err b/src/cmd/sam/err deleted file mode 100644 index 2a36c23b2..000000000 --- a/src/cmd/sam/err +++ /dev/null @@ -1,39 +0,0 @@ -address.c: In function `filematch': -address.c:159: warning: passing arg 1 of `bufreset' from incompatible pointer type -address.c:160: warning: passing arg 1 of `bufinsert' from incompatible pointer type -file.c: In function `mergeextend': -file.c:117: warning: passing arg 1 of `bufread' from incompatible pointer type -file.c: In function `fileinsert': -file.c:275: warning: passing arg 1 of `bufinsert' from incompatible pointer type -file.c: In function `filedelete': -file.c:301: warning: passing arg 1 of `bufdelete' from incompatible pointer type -file.c: In function `fileundelete': -file.c:324: warning: passing arg 1 of `bufread' from incompatible pointer type -file.c: In function `filereadc': -file.c:339: warning: passing arg 1 of `bufread' from incompatible pointer type -file.c: In function `fileload': -file.c:405: warning: passing arg 1 of `bufload' from incompatible pointer type -file.c: In function `fileundo': -file.c:528: warning: passing arg 1 of `bufdelete' from incompatible pointer type -file.c:546: warning: passing arg 1 of `bufinsert' from incompatible pointer type -file.c: In function `fileclose': -file.c:604: warning: passing arg 1 of `bufclose' from incompatible pointer type -io.c: In function `readio': -io.c:90: warning: passing arg 1 of `bufload' from incompatible pointer type -io.c: In function `writeio': -io.c:152: warning: passing arg 1 of `bufread' from incompatible pointer type -mesg.c: In function `inmesg': -mesg.c:248: warning: passing arg 1 of `bufread' from incompatible pointer type -mesg.c: In function `snarf': -mesg.c:568: warning: passing arg 1 of `bufread' from incompatible pointer type -mesg.c: In function `setgenstr': -mesg.c:612: warning: passing arg 1 of `bufread' from incompatible pointer type -sam.c: In function `readcmd': -sam.c:496: warning: passing arg 1 of `bufread' from incompatible pointer type -sam.c: In function `copy': -sam.c:676: warning: passing arg 1 of `bufread' from incompatible pointer type -xec.c: In function `s_cmd': -xec.c:234: warning: passing arg 1 of `bufread' from incompatible pointer type -xec.c:243: warning: passing arg 1 of `bufread' from incompatible pointer type -xec.c: In function `display': -xec.c:401: warning: passing arg 1 of `bufread' from incompatible pointer type diff --git a/src/cmd/sam/plan9.c b/src/cmd/sam/plan9.c deleted file mode 100644 index 0a3fe0709..000000000 --- a/src/cmd/sam/plan9.c +++ /dev/null @@ -1,185 +0,0 @@ -#include "sam.h" - -Rune samname[] = L"~~sam~~"; - -Rune *left[]= { - L"{[(<«", - L"\n", - L"'\"`", - 0 -}; -Rune *right[]= { - L"}])>»", - L"\n", - L"'\"`", - 0 -}; - -char RSAM[] = "sam"; -char SAMTERM[] = "/bin/aux/samterm"; -char HOME[] = "HOME"; -char TMPDIR[] = "/tmp"; -char SH[] = "rc"; -char SHPATH[] = "/bin/rc"; -char RX[] = "rx"; -char RXPATH[] = "/bin/rx"; -char SAMSAVECMD[] = "/bin/rc\n/sys/lib/samsave"; - -void -dprint(char *z, ...) -{ - char buf[BLOCKSIZE]; - va_list arg; - - va_start(arg, z); - vseprint(buf, &buf[BLOCKSIZE], z, arg); - va_end(arg); - termwrite(buf); -} - -void -print_ss(char *s, String *a, String *b) -{ - dprint("?warning: %s: `%.*S' and `%.*S'\n", s, a->n, a->s, b->n, b->s); -} - -void -print_s(char *s, String *a) -{ - dprint("?warning: %s `%.*S'\n", s, a->n, a->s); -} - -char* -getuser(void) -{ - static char user[64]; - int fd; - - if(user[0] == 0){ - fd = open("/dev/user", 0); - if(fd<0 || read(fd, user, sizeof user-1)<=0) - strcpy(user, "none"); - close(fd); - } - return user; -} - -int -statfile(char *name, ulong *dev, uvlong *id, long *time, long *length, long *appendonly) -{ - Dir *dirb; - - dirb = dirstat(name); - if(dirb == nil) - return -1; - if(dev) - *dev = dirb->type|(dirb->dev<<16); - if(id) - *id = dirb->qid.path; - if(time) - *time = dirb->mtime; - if(length) - *length = dirb->length; - if(appendonly) - *appendonly = dirb->mode & DMAPPEND; - free(dirb); - return 1; -} - -int -statfd(int fd, ulong *dev, uvlong *id, long *time, long *length, long *appendonly) -{ - Dir *dirb; - - dirb = dirfstat(fd); - if(dirb == nil) - return -1; - if(dev) - *dev = dirb->type|(dirb->dev<<16); - if(id) - *id = dirb->qid.path; - if(time) - *time = dirb->mtime; - if(length) - *length = dirb->length; - if(appendonly) - *appendonly = dirb->mode & DMAPPEND; - free(dirb); - return 1; -} - -void -notifyf(void *a, char *s) -{ - USED(a); - if(bpipeok && strcmp(s, "sys: write on closed pipe") == 0) - noted(NCONT); - if(strcmp(s, "interrupt") == 0) - noted(NCONT); - panicking = 1; - rescue(); - noted(NDFLT); -} - -int -newtmp(int num) -{ - int i, fd; - static char tempnam[30]; - - i = getpid(); - do - snprint(tempnam, sizeof tempnam, "%s/%d%.4s%dsam", TMPDIR, num, getuser(), i++); - while(access(tempnam, 0) == 0); - fd = create(tempnam, ORDWR|OCEXEC|ORCLOSE, 0000); - if(fd < 0){ - remove(tempnam); - fd = create(tempnam, ORDWR|OCEXEC|ORCLOSE, 0000); - } - return fd; -} - -int -waitfor(int pid) -{ - int msg; - Waitmsg *w; - - while((w = wait()) != nil){ - if(w->pid != pid){ - free(w); - continue; - } - msg = (w->msg[0] != '\0'); - free(w); - return msg; - } - return -1; -} - -void -samerr(char *buf) -{ - sprint(buf, "%s/sam.err", TMPDIR); -} - -void* -emalloc(ulong n) -{ - void *p; - - p = malloc(n); - if(p == 0) - panic("malloc fails"); - memset(p, 0, n); - return p; -} - -void* -erealloc(void *p, ulong n) -{ - p = realloc(p, n); - if(p == 0) - panic("realloc fails"); - return p; -} From 1c845e0bd5ff897dc5e90f2c24db4ecd81a8f60c Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 5 Jan 2021 23:38:09 -0500 Subject: [PATCH 291/323] acme, sam, samterm: remove weird switch usage For whatever reason all three of these programs contain switches like: switch(x) { case 1: if(cond) case 2: f(); } Like Duff's device, this is legal C but more obscure than it really needs to be. This commit assumes those are intended as written and simply writes them more clearly. I did consider that maybe they are mistakes, but in the case of sam/regexp.c, my rewrite in this commit matches the acme/regx.c that has been in plan9port since I added acme in 2003. (I didn't bother to dig up the old Plan 9 releases.) Assuming acme/regx.c has been correct for the past two decades, this commit should be correct too. --- src/cmd/acme/edit.c | 6 ++++-- src/cmd/sam/cmd.c | 6 ++++-- src/cmd/sam/regexp.c | 2 +- src/cmd/samterm/flayer.c | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cmd/acme/edit.c b/src/cmd/acme/edit.c index 81f80300d..82a19b0d5 100644 --- a/src/cmd/acme/edit.c +++ b/src/cmd/acme/edit.c @@ -635,9 +635,11 @@ simpleaddr(void) case '.': case '$': case '\'': - if(addr.type!='"') + if(addr.type=='"') + break; + /* fall through */ case '"': - editerror("bad address syntax"); + editerror("bad address syntax"); break; case 'l': case '#': diff --git a/src/cmd/sam/cmd.c b/src/cmd/sam/cmd.c index 7176a8271..13bd17e0d 100644 --- a/src/cmd/sam/cmd.c +++ b/src/cmd/sam/cmd.c @@ -559,9 +559,11 @@ simpleaddr(void) case '.': case '$': case '\'': - if(addr.type!='"') + if(addr.type=='"') + break; + /* fall through */ case '"': - error(Eaddress); + error(Eaddress); break; case 'l': case '#': diff --git a/src/cmd/sam/regexp.c b/src/cmd/sam/regexp.c index 2e369fe16..57c639d9c 100644 --- a/src/cmd/sam/regexp.c +++ b/src/cmd/sam/regexp.c @@ -700,11 +700,11 @@ bexecute(File *f, Posn startp) break; case 1: /* expired; wrap to end */ if(sel.p[0].p1>=0) - case 3: goto Return; list[0][0].inst = list[1][0].inst = 0; p = f->b.nc; goto doloop; + case 3: default: goto Return; } diff --git a/src/cmd/samterm/flayer.c b/src/cmd/samterm/flayer.c index e9fde31c0..a8e70d0c0 100644 --- a/src/cmd/samterm/flayer.c +++ b/src/cmd/samterm/flayer.c @@ -169,8 +169,8 @@ newvisibilities(int redraw) break; case V(Some, Some): - if(l->f.b==0 && redraw) case V(None, Some): + if(ov == None || (l->f.b==0 && redraw)) flprepare(l); if(l->f.b && redraw){ flrefresh(l, l->entire, 0); From fdcf3d70c24886dddb5fd7052dfada67d33d5c75 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 09:58:44 -0500 Subject: [PATCH 292/323] auxstats: do not postnote 0 --- src/cmd/auxstats/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/auxstats/main.c b/src/cmd/auxstats/main.c index 3fd77ac4c..a37c9723e 100644 --- a/src/cmd/auxstats/main.c +++ b/src/cmd/auxstats/main.c @@ -21,7 +21,8 @@ notifyf(void *v, char *msg) if(strstr(msg, "child")) noted(NCONT); - postnote(PNPROC, pid, msg); + if(pid) + postnote(PNPROC, pid, msg); exits(nil); } From 0cc1faf015a253ef64b97a8453b6fc959c0ee512 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 09:59:03 -0500 Subject: [PATCH 293/323] lib9: reject postnote with special pids --- src/lib9/postnote.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib9/postnote.c b/src/lib9/postnote.c index 68e6d2f66..d750c69dc 100644 --- a/src/lib9/postnote.c +++ b/src/lib9/postnote.c @@ -18,6 +18,11 @@ postnote(int who, int pid, char *msg) return -1; } + if(pid <= 0){ + werrstr("bad pid in postnote"); + return -1; + } + switch(who){ default: werrstr("bad who in postnote"); From c3ae85a004c8714fc653629a983327d9a15b36da Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 09:59:54 -0500 Subject: [PATCH 294/323] rc: do not exit on EINTR from read This happens if lldb attaches to rc. --- src/cmd/rc/io.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd/rc/io.c b/src/cmd/rc/io.c index c2e9d7b46..907ba86fb 100644 --- a/src/cmd/rc/io.c +++ b/src/cmd/rc/io.c @@ -1,4 +1,5 @@ #include +#include #include "rc.h" #include "exec.h" #include "io.h" @@ -257,7 +258,15 @@ int emptybuf(io *f) { int n; - if(f->fd==-1 || (n = Read(f->fd, f->buf, NBUF))<=0) return EOF; + if(f->fd==-1) + return EOF; +Loop: + errno = 0; + n = Read(f->fd, f->buf, NBUF); + if(n < 0 && errno == EINTR) + goto Loop; + if(n <= 0) + return EOF; f->bufp = f->buf; f->ebuf = f->buf+n; return *f->bufp++&0xff; From 6a80119eb509bd948d87ad1b84b0a82855a3c691 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 10:01:25 -0500 Subject: [PATCH 295/323] sam: remove backward ?: The exit code here is ignored anyway. --- src/cmd/sam/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/sam/shell.c b/src/cmd/sam/shell.c index c6efdd572..92bd5277b 100644 --- a/src/cmd/sam/shell.c +++ b/src/cmd/sam/shell.c @@ -90,7 +90,7 @@ plan9(File *f, int type, String *s, int nest) free(c); } } - exits(retcode? "error" : 0); + exits(0); } if(pid==-1){ fprint(2, "Can't fork?!\n"); From 3ccd61629b641613bcccbc51125330efab9c89a7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 10:05:50 -0500 Subject: [PATCH 296/323] sam: avoid out-of-bounds read in rterm Usually r->nused < r->nalloc and the read is in bounds. But it could in theory be right on the line and reading past the end of the allocation. Make it safe but preserve as much of the old semantics as possible. This use of rterm appears to be only for optimization purposes so the result does not matter for correctness. --- src/cmd/sam/rasp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/sam/rasp.c b/src/cmd/sam/rasp.c index c96101df6..55d16cfb0 100644 --- a/src/cmd/sam/rasp.c +++ b/src/cmd/sam/rasp.c @@ -283,8 +283,8 @@ rterm(List *r, Posn p1) for(p = 0,i = 0; inused && p+L(i)<=p1; p+=L(i++)) ; - if(i==r->nused && (i==0 || !T(i-1))) - return 0; + if(i==r->nused) + return i > 0 && T(i-1); return T(i); } From 52b599a63c488d3a80bb9f5dd97bad0b10103c54 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 14 Jan 2021 10:30:24 -0500 Subject: [PATCH 297/323] libthread: call setpgrp in programs that will background This fixes the 'run stats from rc; exit rc; stats dies' problem. It's unclear whether this is the right fix or whether rc should be starting all its interactive commands in their own process groups. But at least it does fix stats dying. --- src/libthread/daemonize.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c index f994ffe15..299290688 100644 --- a/src/libthread/daemonize.c +++ b/src/libthread/daemonize.c @@ -101,6 +101,13 @@ _threadsetupdaemonize(void) sigpid = 1; + /* + * We've been told this program is likely to background itself. + * Put it in its own process group so that we don't get a SIGHUP + * when the parent exits. + */ + setpgrp(); + if(pipe(p) < 0) sysfatal("passer pipe: %r"); From 4056d6be4d0fca6fc5e6ccfd24ff4785db9fec15 Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Fri, 29 Jan 2021 05:12:42 +0000 Subject: [PATCH 298/323] libhtml: fix array bounds in lex --- src/libhtml/lex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libhtml/lex.c b/src/libhtml/lex.c index 49c5f502e..82324ba55 100644 --- a/src/libhtml/lex.c +++ b/src/libhtml/lex.c @@ -586,7 +586,7 @@ getplaindata(TokenSource* ts, Token* a, int* pai) } if(c != 0){ buf[j++] = c; - if(j == sizeof(buf)-1){ + if(j == BIGBUFSIZE-1){ s = buftostr(s, buf, j); j = 0; } From 20c14efad6487b0a09ecd661680321afa240bc0b Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Fri, 29 Jan 2021 05:30:08 +0000 Subject: [PATCH 299/323] xd: fix swizz8 loop counting --- src/cmd/xd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/xd.c b/src/cmd/xd.c index 9f83e1cf9..2cfbcfd13 100644 --- a/src/cmd/xd.c +++ b/src/cmd/xd.c @@ -327,7 +327,7 @@ swizz8(void) *q++ = *p++; p = data; q = swdata; - for(i=0; i<8; i++){ + for(i=0; i<2; i++){ p[0] = q[7]; p[1] = q[6]; p[2] = q[5]; From 4e6bb208eb96baae65fd6b1bf99aaa1115b9a9ba Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Fri, 29 Jan 2021 05:35:40 +0000 Subject: [PATCH 300/323] eqn: enlarge errbuf to account for large tokens --- src/cmd/eqn/e.h | 2 +- src/cmd/eqn/input.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/eqn/e.h b/src/cmd/eqn/e.h index 07dc4df66..f2a718494 100644 --- a/src/cmd/eqn/e.h +++ b/src/cmd/eqn/e.h @@ -20,7 +20,7 @@ extern int class[LAST][LAST]; #undef sprintf /* Snow Leopard */ -extern char errbuf[200]; +extern char errbuf[2000]; extern char *cmdname; #define ERROR sprintf(errbuf, #define FATAL ), error(1, errbuf) diff --git a/src/cmd/eqn/input.c b/src/cmd/eqn/input.c index a0c0c34e4..b146171b0 100644 --- a/src/cmd/eqn/input.c +++ b/src/cmd/eqn/input.c @@ -255,7 +255,7 @@ void yyerror(char *s) error(0, s); /* temporary */ } -char errbuf[200]; +char errbuf[2000]; void eprint(void) /* try to print context around error */ { From 0144f87dc6c7f2f6becbd55519e433a9b36a466f Mon Sep 17 00:00:00 2001 From: Xiao-Yong Jin Date: Fri, 29 Jan 2021 05:38:41 +0000 Subject: [PATCH 301/323] htmlroff: fix array bounds --- src/cmd/htmlroff/roff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/htmlroff/roff.c b/src/cmd/htmlroff/roff.c index 34b794be7..f52e07343 100644 --- a/src/cmd/htmlroff/roff.c +++ b/src/cmd/htmlroff/roff.c @@ -257,7 +257,7 @@ copyarg(void) int c; Rune *r; - if(_readx(buf, sizeof buf, ArgMode, 0) < 0) + if(_readx(buf, MaxLine, ArgMode, 0) < 0) return nil; r = runestrstr(buf, L("\\\"")); if(r){ @@ -280,7 +280,7 @@ readline(int m) static Rune buf[MaxLine]; Rune *r; - if(_readx(buf, sizeof buf, m, 1) < 0) + if(_readx(buf, MaxLine, m, 1) < 0) return nil; r = erunestrdup(buf); return r; From 36cd4c58c1346375b98f517fb8568be5bb47618d Mon Sep 17 00:00:00 2001 From: Fazlul Shahriar Date: Fri, 29 Jan 2021 18:55:29 -0500 Subject: [PATCH 302/323] man9: rename IM to MR Commit d32deab17bfffa5bffc5fab3e6577558e40888c5 renamed IM to MR but these man pages were missed. --- man/man9/0intro.9p | 18 +++++++++--------- man/man9/attach.9p | 4 ++-- man/man9/clunk.9p | 2 +- man/man9/flush.9p | 4 ++-- man/man9/open.9p | 4 ++-- man/man9/openfd.9p | 8 ++++---- man/man9/read.9p | 2 +- man/man9/remove.9p | 2 +- man/man9/stat.9p | 4 ++-- man/man9/version.9p | 2 +- man/man9/walk.9p | 4 ++-- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/man/man9/0intro.9p b/man/man9/0intro.9p index f432cf519..30e153a1d 100644 --- a/man/man9/0intro.9p +++ b/man/man9/0intro.9p @@ -21,7 +21,7 @@ such a machine is called, somewhat confusingly, a Another possibility for a server is to synthesize files on demand, perhaps based on information on data structures maintained in memory; the -.IM plumber (4) +.MR plumber (4) server is an example of such a server. .PP A @@ -63,7 +63,7 @@ bytes of data. Text strings are represented this way, with the text itself stored as a UTF-8 encoded sequence of Unicode characters (see -.IM utf (7) ). +.MR utf (7) ). Text strings in 9P messages are not .SM NUL\c -terminated: @@ -114,7 +114,7 @@ Plan 9 names may contain any printable character (that is, any character outside hexadecimal 00-1F and 80-9F) except slash.) Messages are transported in byte form to allow for machine independence; -.IM fcall (3) +.MR fcall (3) describes routines that convert to and from this form into a machine-dependent C structure. .SH MESSAGES @@ -348,7 +348,7 @@ a ``current file'' on the server. Fids are somewhat like file descriptors in a user process, but they are not restricted to files open for I/O: directories being examined, files being accessed by -.IM stat (3) +.MR stat (3) calls, and so on \(em all files being manipulated by the operating system \(em are identified by fids. Fids are chosen by the client. @@ -461,7 +461,7 @@ to have their input or output attached to fids on 9P servers. See .IR openfd (9p) and -.IM 9pclient (3) +.MR 9pclient (3) for details. .PP The @@ -475,7 +475,7 @@ access permissions (read, write and execute for owner, group and public), access and modification times, and owner and group identifications (see -.IM stat (3) ). +.MR stat (3) ). The owner and group identifications are textual names. The .B wstat @@ -523,12 +523,12 @@ into 9P messages. .SS Unix On Unix, 9P services are posted as Unix domain sockets in a well-known directory (see -.IM getns (3) +.MR getns (3) and -.IM 9pserve (4) ). +.MR 9pserve (4) ). Clients connect to these servers using a 9P client library (see -.IM 9pclient (3) ). +.MR 9pclient (3) ). .SH DIRECTORIES Directories are created by .B create diff --git a/man/man9/attach.9p b/man/man9/attach.9p index 3a5104d5d..4160f30d6 100644 --- a/man/man9/attach.9p +++ b/man/man9/attach.9p @@ -122,7 +122,7 @@ and and .I fsauth (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generate .B attach and @@ -163,6 +163,6 @@ transactions. .\" .B mount .\" system call on an uninitialized connection. .SH SEE ALSO -.IM 9pclient (3) , +.MR 9pclient (3) , .IR version (9P), Plan 9's \fIauthsrv\fR(6) diff --git a/man/man9/clunk.9p b/man/man9/clunk.9p index 3277c4b05..f014ac426 100644 --- a/man/man9/clunk.9p +++ b/man/man9/clunk.9p @@ -41,7 +41,7 @@ generated by and .I fsunmount (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) and indirectly by other actions such as failed .I fsopen calls. diff --git a/man/man9/flush.9p b/man/man9/flush.9p index d0987cac4..862ab9a4a 100644 --- a/man/man9/flush.9p +++ b/man/man9/flush.9p @@ -99,11 +99,11 @@ flushing a and flushing an invalid tag. .SH ENTRY POINTS The -.IM 9pclient (3) +.MR 9pclient (3) library does not generate .B flush transactions.. -.IM 9pserve (4) +.MR 9pserve (4) generates .B flush transactions to cancel transactions pending when a client hangs up. diff --git a/man/man9/open.9p b/man/man9/open.9p index 1f74eb07d..8a54f72c0 100644 --- a/man/man9/open.9p +++ b/man/man9/open.9p @@ -160,7 +160,7 @@ in this case, the .I fscreate call (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) uses .B open with truncation. @@ -209,7 +209,7 @@ again. and .I fscreate (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) both generate .B open messages; only diff --git a/man/man9/openfd.9p b/man/man9/openfd.9p index 56fb392a2..620b1991a 100644 --- a/man/man9/openfd.9p +++ b/man/man9/openfd.9p @@ -43,18 +43,18 @@ it cannot be .PP .I Openfd is implemented by -.IM 9pserve (4) . +.MR 9pserve (4) . 9P servers that post their services using -.IM 9pserve (4) +.MR 9pserve (4) (or indirectly via -.IM post9pservice (3) ) +.MR post9pservice (3) ) will never see a .B Topenfd message. .SH ENTRY POINTS .I Fsopenfd (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generates an .B openfd message. diff --git a/man/man9/read.9p b/man/man9/read.9p index 515f85c31..675bb7738 100644 --- a/man/man9/read.9p +++ b/man/man9/read.9p @@ -114,7 +114,7 @@ to be transferred atomically. and .I fswrite (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generate the corresponding messages. Because they take an offset parameter, the .I fspread diff --git a/man/man9/remove.9p b/man/man9/remove.9p index 79a646a10..232c88f6b 100644 --- a/man/man9/remove.9p +++ b/man/man9/remove.9p @@ -45,7 +45,7 @@ so other fids typically remain usable. .SH ENTRY POINTS .I Fsremove (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generates .B remove messages. diff --git a/man/man9/stat.9p b/man/man9/stat.9p index b92f2d69f..7706d3eb1 100644 --- a/man/man9/stat.9p +++ b/man/man9/stat.9p @@ -88,7 +88,7 @@ The and .I convD2M routines (see -.IM fcall (3) ) +.MR fcall (3) ) convert between directory entries and a C structure called a .BR Dir . .PP @@ -263,7 +263,7 @@ messages are generated by and .IR fsdirstat (see -.IM 9pclient (3) ). +.MR 9pclient (3) ). .PP .B Wstat messages are generated by diff --git a/man/man9/version.9p b/man/man9/version.9p index 99f30239b..c71ee5566 100644 --- a/man/man9/version.9p +++ b/man/man9/version.9p @@ -91,7 +91,7 @@ requests is called a .SH ENTRY POINTS .I Fsversion (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generates .B version messages; diff --git a/man/man9/walk.9p b/man/man9/walk.9p index b48b947bb..735b7dcb9 100644 --- a/man/man9/walk.9p +++ b/man/man9/walk.9p @@ -149,13 +149,13 @@ may be packed in a single message. This constant is called .B MAXWELEM in -.IM fcall (3) . +.MR fcall (3) . Despite this restriction, the system imposes no limit on the number of elements in a file name, only the number that may be transmitted in a single message. .SH ENTRY POINTS .I Fswalk (see -.IM 9pclient (3) ) +.MR 9pclient (3) ) generates walk messages. One or more walk messages may be generated by any call that evaluates file names: From a72478870ae66b7ac1e73b1d22b578cd31852f33 Mon Sep 17 00:00:00 2001 From: David Arroyo Date: Sun, 31 Jan 2021 00:51:32 -0500 Subject: [PATCH 303/323] 9p: parse lines in rdwr command Use bio(3) to read at most one line of input per iteration, even if there is more than one line available in the input buffer. This makes it easier to interact with line-oriented ctl files like that of factotum(4) from shell scripts, without the need to control when and how much data is flushed to a pipe. --- src/cmd/9p.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cmd/9p.c b/src/cmd/9p.c index 75511a194..a5b97f85f 100644 --- a/src/cmd/9p.c +++ b/src/cmd/9p.c @@ -302,8 +302,10 @@ void xrdwr(int argc, char **argv) { char buf[4096]; + char *p; int n; CFid *fid; + Biobuf *b; ARGBEGIN{ default: @@ -313,6 +315,8 @@ xrdwr(int argc, char **argv) if(argc != 1) usage(); + if((b = Bfdopen(0, OREAD)) == nil) + sysfatal("out of memory"); fid = xopen(argv[0], ORDWR); for(;;){ fsseek(fid, 0, 0); @@ -322,15 +326,15 @@ xrdwr(int argc, char **argv) if(write(1, buf, n) < 0 || write(1, "\n", 1) < 0) sysfatal("write error: %r"); } - n = read(0, buf, sizeof buf); - if(n <= 0) + if((p = Brdstr(b, '\n', 1)) == nil) break; - if(buf[n-1] == '\n') - n--; - if(fswrite(fid, buf, n) != n) + n = strlen(p); + if(fswrite(fid, p, n) != n) fprint(2, "write: %r\n"); + free(p); } fsclose(fid); + Bterm(b); threadexitsall(0); } From f62d4c4143c9a21e488fca658590e1546700586f Mon Sep 17 00:00:00 2001 From: Connor Taffe Date: Tue, 26 Jan 2021 15:14:18 -0600 Subject: [PATCH 304/323] 9pfuse: support MacFUSE >=4 MacFUSE 4 removes support for passing device fd to the mount command. Adds support for the receiving the fd over a socket instead, and updates command paths and filesystem name. --- src/cmd/9pfuse/fuse.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/cmd/9pfuse/fuse.c b/src/cmd/9pfuse/fuse.c index 4c9aac9bf..ea8e3bbf3 100644 --- a/src/cmd/9pfuse/fuse.c +++ b/src/cmd/9pfuse/fuse.c @@ -798,16 +798,19 @@ mountfuse(char *mtpt) } return fd; #elif defined(__APPLE__) - int i, pid, fd, r; + int i, pid, fd, r, p[2]; char buf[20]; struct vfsconf vfs; char *f, *v; if(getvfsbyname(v="osxfusefs", &vfs) < 0 && + getvfsbyname(v="macfuse", &vfs) < 0 && getvfsbyname(v="osxfuse", &vfs) < 0 && getvfsbyname(v="fusefs", &vfs) < 0){ if(access((v="osxfusefs", f="/Library/Filesystems/osxfusefs.fs" "/Support/load_osxfusefs"), 0) < 0 && + access((v="macfuse", f="/Library/Filesystems/macfuse.fs" + "/Contents/Resources/load_macfuse"), 0) < 0 && access((v="osxfuse", f="/Library/Filesystems/osxfuse.fs" "/Contents/Resources/load_osxfuse"), 0) < 0 && access((v="osxfuse", f="/opt/local/Library/Filesystems/osxfuse.fs" @@ -837,6 +840,32 @@ mountfuse(char *mtpt) } } + /* MacFUSE >=4 dropped support for passing fd */ + if (strcmp(v, "macfuse") == 0) { + if(socketpair(AF_UNIX, SOCK_STREAM, 0, p) < 0) + return -1; + pid = fork(); + if(pid < 0) + return -1; + if(pid == 0){ + close(p[1]); + snprint(buf, sizeof buf, "%d", p[0]); + putenv("_FUSE_COMMFD", buf); + putenv("_FUSE_COMMVERS", "2"); + putenv("_FUSE_CALL_BY_LIB", "1"); + putenv("_FUSE_DAEMON_PATH", + "/Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfus"); + execl("/Library/Filesystems/macfuse.fs/Contents/Resources/mount_macfuse", + "mount_macfuse", mtpt, nil); + fprint(2, "exec mount_macfuse: %r\n"); + _exit(1); + } + close(p[0]); + fd = recvfd(p[1]); + close(p[1]); + return fd; + } + /* Look for available FUSE device. */ /* * We need to truncate `fs` from the end of the vfs name if From 90971376a5e8620fc62579aa1b3be26245ec8c06 Mon Sep 17 00:00:00 2001 From: Connor Taffe Date: Sun, 31 Jan 2021 19:33:14 -0600 Subject: [PATCH 305/323] mount: find kext with MacFUSE >=4 and macOS >=11 --- bin/mount | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/mount b/bin/mount index 0fbb1bfd5..e29cc201e 100755 --- a/bin/mount +++ b/bin/mount @@ -20,11 +20,14 @@ case FreeBSD echo 'don''t know how to mount (no fuse)' >[1=2] case Darwin version=`{sw_vers -productVersion|cut -d. -f1,2} + major_version = `{echo $version|cut -d. -f1} if(sysctl fuse.version >[2]/dev/null |9 grep -si 'fuse.version' || sysctl macfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' || sysctl osxfuse.version.number >[2]/dev/null |9 grep -si 'fuse.version' || test -d /System/Library/Extensions/fusefs.kext || test -d /Library/Filesystems/osxfuse.fs/Contents/Extensions/$version/osxfuse.kext || + test -d /Library/Filesystems/macfuse.fs/Contents/Extensions/$version/macfuse.kext || + test -d /Library/Filesystems/macfuse.fs/Contents/Extensions/$major_version/macfuse.kext || test -d /Library/Filesystems/osxfusefs.fs/Support/osxfusefs.kext || test -d /opt/local/Library/Filesystems/osxfuse.fs || test -d /Library/Filesystems/fusefs.fs/Support/fusefs.kext) From 73661401ea00ef6a862d0a4b292e091b319c25bc Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 Jan 2021 14:30:40 -0500 Subject: [PATCH 306/323] acme: fix double-free in acmeerrorproc The receiver of cerr takes ownership of s. --- src/cmd/acme/acme.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index e5658a4ef..d001a2a84 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -383,7 +383,7 @@ int erroutfd; void acmeerrorproc(void *v) { - char *buf, *s; + char *buf; int n; USED(v); @@ -391,9 +391,7 @@ acmeerrorproc(void *v) buf = emalloc(8192+1); while((n=read(errorfd, buf, 8192)) >= 0){ buf[n] = '\0'; - s = estrdup(buf); - sendp(cerr, s); - free(s); + sendp(cerr, estrdup(buf)); } free(buf); } From a8bd9e9d8cd029a220ad4b9dad752d26c55bf4c2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 23 Mar 2021 17:24:58 -0400 Subject: [PATCH 307/323] mk: fix for Unix build --- src/cmd/mk/symtab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/mk/symtab.c b/src/cmd/mk/symtab.c index 2bb28ba8d..da02f8972 100644 --- a/src/cmd/mk/symtab.c +++ b/src/cmd/mk/symtab.c @@ -21,7 +21,7 @@ syminit(void) Symtab * symlook(char *sym, int space, void *install) { - ulong h; + unsigned long h; char *p; Symtab *s; @@ -45,7 +45,7 @@ symlook(char *sym, int space, void *install) void symdel(char *sym, int space) { - ulong h; + unsigned long h; char *p; Symtab *s, *ls; From 88a87fadae6629932d9c160f53ad5d79775f8f94 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 23 Mar 2021 17:24:35 -0400 Subject: [PATCH 308/323] all: update for new MIT license On March 23, 2021, Nokia transferred the copyrights in the Plan 9 software to the Plan 9 Foundation, which relicensed them under the MIT license. This commit updates the Plan 9 from User Space license to reflect the new base license. The vast majority of the contributions beyond the base Plan 9 set were by me, many of them explicitly under an MIT license. Those are all under the new MIT license now as well. The port of mk to Unix was taken from Inferno via Vita Nuova and had been made available under GPL, but Vita Nuova has relicensed Inferno under the MIT license as well, to match the new Plan 9 license. Michael Teichgraber contributed src/lib9/zoneinfo.c explicitly under the Lucent Public License but has agreed to change the contribution to the MIT license now used in the rest of the distribution. There remain a few exceptions, most notably fonts. See the root LICENSE file for full details. The only mention of the Lucent Public License in the whole tree now is in the LICENSE file, explaining the history. --- LICENSE | 284 ++++++-------------------------------------- dist/unix.html | 125 +++++++++---------- font/LICENSE | 5 +- src/cmd/awk/README | 13 -- src/cmd/mk/NOTICE | 42 +++---- src/lib9/LICENSE | 11 +- src/lib9/fmt/NOTICE | 19 --- src/lib9/utf/NOTICE | 13 -- src/lib9/zoneinfo.c | 2 +- unix/NOTICE.bio | 19 +-- unix/NOTICE.fmt | 39 +++--- unix/NOTICE.mk | 20 +--- unix/NOTICE.regexp | 39 +++--- unix/NOTICE.utf | 39 +++--- unix/README.dot | 3 + unix/mkfile | 14 ++- 16 files changed, 196 insertions(+), 491 deletions(-) delete mode 100644 src/cmd/awk/README delete mode 100644 src/lib9/fmt/NOTICE delete mode 100644 src/lib9/utf/NOTICE diff --git a/LICENSE b/LICENSE index 6110e313d..52d0f5ff5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,257 +1,49 @@ -Copyright © 2000-2009 Lucent Technologies. All Rights Reserved. +Copyright © 2021 Plan 9 Foundation Portions Copyright © 2001-2008 Russ Cox Portions Copyright © 2008-2009 Google Inc. -=================================================================== - -The bulk of this software is derived from Plan 9 and is thus distributed -under the Lucent Public License, Version 1.02, reproduced below. - -There are a few exceptions: libutf, libfmt, and libregexp are distributed -under simpler BSD-like boilerplates. See the LICENSE files in those -directories. There are other exceptions, also marked with LICENSE files -in their directories or marked at the top of the file. - -The bitmap fonts in the font/luc, font/lucm, font/lucsans, and font/pelm -directory are copyright B&H Inc. and distributed under more restricted -terms under agreement with B&H. See the NOTICE file in those directories. +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =================================================================== -Lucent Public License Version 1.02 - -THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE -PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. - -1. DEFINITIONS - -"Contribution" means: - - a. in the case of Lucent Technologies Inc. ("LUCENT"), the Original - Program, and - b. in the case of each Contributor, - - i. changes to the Program, and - ii. additions to the Program; - - where such changes and/or additions to the Program were added to the - Program by such Contributor itself or anyone acting on such - Contributor's behalf, and the Contributor explicitly consents, in - accordance with Section 3C, to characterization of the changes and/or - additions as Contributions. - -"Contributor" means LUCENT and any other entity that has Contributed a -Contribution to the Program. - -"Distributor" means a Recipient that distributes the Program, -modifications to the Program, or any part thereof. - -"Licensed Patents" mean patent claims licensable by a Contributor -which are necessarily infringed by the use or sale of its Contribution -alone or when combined with the Program. - -"Original Program" means the original version of the software -accompanying this Agreement as released by LUCENT, including source -code, object code and documentation, if any. - -"Program" means the Original Program and Contributions or any part -thereof - -"Recipient" means anyone who receives the Program under this -Agreement, including all Contributors. - -2. GRANT OF RIGHTS - - a. Subject to the terms of this Agreement, each Contributor hereby - grants Recipient a non-exclusive, worldwide, royalty-free copyright - license to reproduce, prepare derivative works of, publicly display, - publicly perform, distribute and sublicense the Contribution of such - Contributor, if any, and such derivative works, in source code and - object code form. - - b. Subject to the terms of this Agreement, each Contributor hereby - grants Recipient a non-exclusive, worldwide, royalty-free patent - license under Licensed Patents to make, use, sell, offer to sell, - import and otherwise transfer the Contribution of such Contributor, if - any, in source code and object code form. The patent license granted - by a Contributor shall also apply to the combination of the - Contribution of that Contributor and the Program if, at the time the - Contribution is added by the Contributor, such addition of the - Contribution causes such combination to be covered by the Licensed - Patents. The patent license granted by a Contributor shall not apply - to (i) any other combinations which include the Contribution, nor to - (ii) Contributions of other Contributors. No hardware per se is - licensed hereunder. - - c. Recipient understands that although each Contributor grants the - licenses to its Contributions set forth herein, no assurances are - provided by any Contributor that the Program does not infringe the - patent or other intellectual property rights of any other entity. Each - Contributor disclaims any liability to Recipient for claims brought by - any other entity based on infringement of intellectual property rights - or otherwise. As a condition to exercising the rights and licenses - granted hereunder, each Recipient hereby assumes sole responsibility - to secure any other intellectual property rights needed, if any. For - example, if a third party patent license is required to allow - Recipient to distribute the Program, it is Recipient's responsibility - to acquire that license before distributing the Program. - - d. Each Contributor represents that to its knowledge it has sufficient - copyright rights in its Contribution, if any, to grant the copyright - license set forth in this Agreement. - -3. REQUIREMENTS - -A. Distributor may choose to distribute the Program in any form under -this Agreement or under its own license agreement, provided that: - - a. it complies with the terms and conditions of this Agreement; - - b. if the Program is distributed in source code or other tangible - form, a copy of this Agreement or Distributor's own license agreement - is included with each copy of the Program; and - - c. if distributed under Distributor's own license agreement, such - license agreement: - - i. effectively disclaims on behalf of all Contributors all warranties - and conditions, express and implied, including warranties or - conditions of title and non-infringement, and implied warranties or - conditions of merchantability and fitness for a particular purpose; - ii. effectively excludes on behalf of all Contributors all liability - for damages, including direct, indirect, special, incidental and - consequential damages, such as lost profits; and - iii. states that any provisions which differ from this Agreement are - offered by that Contributor alone and not by any other party. - -B. Each Distributor must include the following in a conspicuous - location in the Program: - - Copyright (C) 2003, Lucent Technologies Inc. and others. All Rights - Reserved. - -C. In addition, each Contributor must identify itself as the -originator of its Contribution in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution. -Also, each Contributor must agree that the additions and/or changes -are intended to be a Contribution. Once a Contribution is contributed, -it may not thereafter be revoked. - -4. COMMERCIAL DISTRIBUTION - -Commercial distributors of software may accept certain -responsibilities with respect to end users, business partners and the -like. While this license is intended to facilitate the commercial use -of the Program, the Distributor who includes the Program in a -commercial product offering should do so in a manner which does not -create potential liability for Contributors. Therefore, if a -Distributor includes the Program in a commercial product offering, -such Distributor ("Commercial Distributor") hereby agrees to defend -and indemnify every Contributor ("Indemnified Contributor") against -any losses, damages and costs (collectively"Losses") arising from -claims, lawsuits and other legal actions brought by a third party -against the Indemnified Contributor to the extent caused by the acts -or omissions of such Commercial Distributor in connection with its -distribution of the Program in a commercial product offering. The -obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. -In order to qualify, an Indemnified Contributor must: a) promptly -notify the Commercial Distributor in writing of such claim, and b) -allow the Commercial Distributor to control, and cooperate with the -Commercial Distributor in, the defense and any related settlement -negotiations. The Indemnified Contributor may participate in any such -claim at its own expense. - -For example, a Distributor might include the Program in a commercial -product offering, Product X. That Distributor is then a Commercial -Distributor. If that Commercial Distributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Distributor's responsibility -alone. Under this section, the Commercial Distributor would have to -defend claims against the Contributors related to those performance -claims and warranties, and if a court requires any Contributor to pay -any damages as a result, the Commercial Distributor must pay those -damages. - -5. NO WARRANTY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS -PROVIDED ON AN"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY -OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its -exercise of rights under this Agreement, including but not limited to -the risks and costs of program errors, compliance with applicable -laws, damage to or loss of data, programs or equipment, and -unavailability or interruption of operations. - -6. DISCLAIMER OF LIABILITY - -EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR -ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING -WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR -DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED -HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. EXPORT CONTROL - -Recipient agrees that Recipient alone is responsible for compliance -with the United States export administration regulations (and the -export control laws and regulation of any other countries). - -8. GENERAL - -If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of -the remainder of the terms of this Agreement, and without further -action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable. +This software is derived from Plan 9, originally copyright Lucent Technologies +and distributed under the Lucent Public License, Version 1.02. +Lucent was bought by Alcatel, which was bought by Nokia. +On March 23, 2021, Nokia announced the transfer of the Plan 9 copyrights to the +Plan 9 Foundation, which in turn relicensed Plan 9 under the the MIT license, +reproduced above. -If Recipient institutes patent litigation against a Contributor with -respect to a patent applicable to software (including a cross-claim or -counterclaim in a lawsuit), then any patent licenses granted by that -Contributor to such Recipient under this Agreement shall terminate as -of the date such litigation is filed. In addition, if Recipient -institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program -itself (excluding combinations of the Program with other software or -hardware) infringes such Recipient's patent(s), then such Recipient's -rights granted under Section 2(b) shall terminate as of the date such -litigation is filed. +There are a few exceptions, noted with LICENSE files in their own directories: -All Recipient's rights under this Agreement shall terminate if it -fails to comply with any of the material terms or conditions of this -Agreement and does not cure such failure in a reasonable period of -time after becoming aware of such noncompliance. If all Recipient's -rights under this Agreement terminate, Recipient agrees to cease use -and distribution of the Program as soon as reasonably practicable. -However, Recipient's obligations under this Agreement and any licenses -granted by Recipient relating to the Program shall continue and -survive. +The bzip2 program uses the bzip2 license; see src/cmd/bzip2/LICENSE. -LUCENT may publish new versions (including revisions) of this -Agreement from time to time. Each new version of the Agreement will be -given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the -Agreement under which it was received. In addition, after a new -version of the Agreement is published, Contributor may elect to -distribute the Program (including its Contributions) under the new -version. No one other than LUCENT has the right to modify this -Agreement. Except as expressly stated in Sections 2(a) and 2(b) above, -Recipient receives no rights or licenses to the intellectual property -of any Contributor under this Agreement, whether expressly, by -implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved. +The fonts from Bigelow and Holmes were licensed only for Plan 9 itself, +not for derivatives like Plan 9 from User Space. -This Agreement is governed by the laws of the State of New York and -the intellectual property laws of the United States of America. No -party to this Agreement will bring a legal action under this Agreement -more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation. +Plan 9 from User Space arranged a separate agreement with B&H to include +the bitmap fonts in the font/luc, font/lucm, font/lucsans, and font/pelm +directories. Other bitmap fonts have other licenses. See font/LICENSE. +The Lucida Sans Unicode PostScript fonts were licensed from B&H only for Plan 9 +itself, not derivatives like Plan 9 from User Space. In their place, Plan 9 from +User Space provides Luxi Sans, also by B&H but available under a more liberal +license, and Deja Vu, a Unicode extension of the Bitstream Vera family of fonts. +Luxi Sans is similar to Lucida Sans, but it has no Unicode support. +Deja Vu does have good Unicode support. diff --git a/dist/unix.html b/dist/unix.html index 9948da2f4..33f428a66 100644 --- a/dist/unix.html +++ b/dist/unix.html @@ -23,7 +23,7 @@ UTF-8, formatted print, buffered I/O, and regular expression libraries, along with mk, a simple replacement for make.

- +
supported systems @@ -49,7 +49,7 @@ make PREFIX=/usr/elsewhere install.
- + On unsupported systems, you will need to create Make.YourOS-YourArch. See the existing ones for examples. If you write one for a new system, @@ -62,27 +62,25 @@
- + Libutf is a port of Plan 9's support library for UTF-8 and Unicode. - +
- - manual: + + manual: isalpharune(3), rune(3), runestrcat(3), utf(7) - +
- - download: libutf.tgz (checksums) - + download: libutf.tgz +
- - license: original Bell Labs MIT-like - or Lucent Public License + + license: MIT
@@ -91,7 +89,7 @@
- + Libfmt is a port of Plan 9's formatted print library. As a base it provides all the syntax of ANSI C's printf but adds the ability for client programs to install new print verbs. @@ -99,108 +97,104 @@ the system error string. Instead of perror("foo"), you can write fprint(2, "foo: %r\n");. - This is especially nice when you write verbs to format the + This is especially nice when you write verbs to format the data structures used by your particular programs. Needs libutf. - +
- - manual: + + manual: print(3), fmtinstall(3), quote(3), fmtstrtod(3) - +
- - download: libfmt.tgz (checksums) - + + download: libfmt.tgz +
- - License: original Bell Labs MIT-like - or Lucent Public License + + license: MIT
- +
libbio
- + Libbio is a port of Plan 9's buffered I/O library. It provides most of the same functionality as stdio or sfio, but with a simpler interface and smaller footprint. Needs libutf and libfmt. - +
- - manual: + + manual: bio(3) - +
- - download: libbio.tgz (checksums) - + + download: libbio.tgz +
- - License: Vita Nuova MIT-like - or Lucent Public License + + license: MIT
- +
libregexp9
- + Libregexp9 is a port of Plan 9's Unicode-capable regular expression library. It is small and simple and provides the traditional extended regular - expressions (without modern complications like + expressions (without modern complications like {} and various \x character classes). It supports Unicode via wide character or UTF-8 encoding. Needs libutf and libfmt. - +
- - manual: + + manual: regexp9(3), regexp9(7) - +
- - download: libregexp9.tgz (checksums) - + + download: libregexp9.tgz +
- - License: original Bell Labs MIT-like - or Lucent Public License + + license: MIT
- +
mk
- + Mk is a simple replacement for make. Needs libutf, libfmt, libbio, and libregexp9. - +
- - manual: + + manual: mk(1) - +
- - download: mk.tgz (checksums) - + + download: mk.tgz +
- - License: Vita Nuova MIT-like - or Lucent Public License + + license: MIT
@@ -208,12 +202,11 @@
- + Includes mk and all the libraries. - +
- - download: mk-with-libs.tgz (checksums) + download: mk-with-libs.tgz
diff --git a/font/LICENSE b/font/LICENSE index 6ca96ce60..19b048acc 100644 --- a/font/LICENSE +++ b/font/LICENSE @@ -1,5 +1,6 @@ Many of the fonts in this directory come from other sources -and are distributed under licenses other than the Lucent Public License. +and are distributed under licenses other than the MIT-style license +that governs the main distribution. In particular, see: @@ -13,4 +14,4 @@ In particular, see: naga10/README pelm/NOTICE shinonome/README - + diff --git a/src/cmd/awk/README b/src/cmd/awk/README deleted file mode 100644 index e3efb50d9..000000000 --- a/src/cmd/awk/README +++ /dev/null @@ -1,13 +0,0 @@ -This 'awk' source is directly downloaded from the Plan 9 source - -http://cm.bell-labs.com/sources/plan9/sys/src/cmd/awk/ - -as such, it's copyright is held by Lucent Technologies and distributed under the -Lucent Public License version 1.02 [http://www.opensource.org/licenses/lucent1.02.php]. - -Modifications were made by Jeff Sickel in order to build using Plan 9 from User -Space [https://9fans.github.io/plan9port/] to the following files: - - mkfile - re.c - diff --git a/src/cmd/mk/NOTICE b/src/cmd/mk/NOTICE index 9911f992a..f9fa9e36f 100644 --- a/src/cmd/mk/NOTICE +++ b/src/cmd/mk/NOTICE @@ -1,27 +1,21 @@ -Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. -Portions Copyright © 1995-1997 C H Forsyth (forsyth@caldo.demon.co.uk). All rights reserved. -Portions Copyright © 1997-1999 Vita Nuova Limited. All rights reserved. -Portions Copyright © 2000-2002 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. +Copyright © 2021 Plan 9 Foundation +Portions Copyright © 1997-1999 Vita Nuova Limited +Portions Copyright © 2000-2015 Vita Nuova Holdings Limited -Under a licence agreement with Lucent Technologies Inc. effective 1st March 2000, -Vita Nuova Holdings Limited has the right to determine (within a specified scope) -the form and content of sublicences for this software. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Vita Nuova Holdings Limited now makes this software available as Free -Software under the terms of the `GNU General Public LIcense, Version 2' -(see the file LICENCE or http://www.fsf.org/copyleft/gpl.html for -the full terms and conditions). One of the conditions of that licence -is that you must keep intact all notices that refer to that licence and to the absence of -of any warranty: for this software, note that includes this NOTICE file in particular. - -This suite of programs is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -`GNU General Public License' for more details. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -This copyright NOTICE applies to all files in this directory and -subdirectories, unless another copyright notice appears in a given -file or subdirectory. If you take code from this software to use in -other programs, you must somehow include with it an appropriate -copyright notice that includes the copyright notice and the other -notices above. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/lib9/LICENSE b/src/lib9/LICENSE index 12e3eba5f..c6665b2be 100644 --- a/src/lib9/LICENSE +++ b/src/lib9/LICENSE @@ -1,8 +1,7 @@ -The files listed below may be redistributed either under the -terms of the Lucent Public License version 1.02 or under the -terms of the simpler MIT-style license at the bottom of this file. The files listed below were written from scrach for plan9port and do not derive from the Plan 9 from Bell Labs distribution. +They are made available under an MIT-style license, using the +same terms as the main distribution. ../../include/u.h non-Plan 9 code in ../../include/libc.h @@ -70,11 +69,7 @@ and do not derive from the Plan 9 from Bell Labs distribution. time.c truerand.c udp.c - unsharp.c - -The other source files in this directory do derive from Plan 9 and -are distributed only under the terms of the Lucent Public License -version 1.02, as detailed in ../../LICENSE. + unsharp.c Copyright 2001-2007 Russ Cox. All Rights Reserved. diff --git a/src/lib9/fmt/NOTICE b/src/lib9/fmt/NOTICE deleted file mode 100644 index 5dc21cb5f..000000000 --- a/src/lib9/fmt/NOTICE +++ /dev/null @@ -1,19 +0,0 @@ -/* - * The authors of this software are Rob Pike and Ken Thompson. - * Copyright (c) 2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. -*/ - -This is a Unix port of the Plan 9 formatted I/O package. - -Please send comments about the packaging -to Russ Cox . - diff --git a/src/lib9/utf/NOTICE b/src/lib9/utf/NOTICE deleted file mode 100644 index ad76cd52b..000000000 --- a/src/lib9/utf/NOTICE +++ /dev/null @@ -1,13 +0,0 @@ -/* - * The authors of this software are Rob Pike and Ken Thompson. - * Copyright (c) 1998-2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - */ diff --git a/src/lib9/zoneinfo.c b/src/lib9/zoneinfo.c index f8ae442dd..36b4b6ef1 100644 --- a/src/lib9/zoneinfo.c +++ b/src/lib9/zoneinfo.c @@ -6,7 +6,7 @@ * Formats 0 and 2 are supported, and 4-byte timestamps * * Copyright © 2008 M. Teichgräber - * Contributed under the terms of the Lucent Public License 1.02. + * Contributed under the MIT license used in the rest of the distribution. */ #include "zoneinfo.h" diff --git a/unix/NOTICE.bio b/unix/NOTICE.bio index 24bef790d..3e5dcdbaf 100644 --- a/unix/NOTICE.bio +++ b/unix/NOTICE.bio @@ -1,13 +1,8 @@ -This copyright NOTICE applies to all files in this directory and -subdirectories, unless another copyright notice appears in a given -file or subdirectory. If you take substantial code from this software to use in -other programs, you must somehow include with it an appropriate -copyright notice that includes the copyright notice and the other -notices below. It is fine (and often tidier) to do that in a separate -file such as NOTICE, LICENCE or COPYING. +This is a Unix port of the Plan 9 buffered I/O library. +Please send comments about the packaging to Russ Cox . - Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. - Revisions Copyright © 2000-2005 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. +Copyright © 2021 Plan 9 Foundation +Revisions Copyright © 2000-2005 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,9 +21,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ----- - -This software is also made available under the Lucent Public License -version 1.02; see http://9p.io/plan9/license.html - diff --git a/unix/NOTICE.fmt b/unix/NOTICE.fmt index e40240709..3c66bac32 100644 --- a/unix/NOTICE.fmt +++ b/unix/NOTICE.fmt @@ -1,25 +1,22 @@ -/* - * The authors of this software are Rob Pike and Ken Thompson. - * Copyright (c) 2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. -*/ +This is a Unix port of the Plan 9 formatted I/O library, by Rob Pike and Ken Thompson. +Please send comments about the packaging to Russ Cox . -This is a Unix port of the Plan 9 formatted I/O package. +Copyright © 2021 Plan 9 Foundation -Please send comments about the packaging -to Russ Cox . +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. ----- - -This software is also made available under the Lucent Public License -version 1.02; see http://9p.io/plan9/license.html - +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/unix/NOTICE.mk b/unix/NOTICE.mk index 4fb98fb76..9b7350ef2 100644 --- a/unix/NOTICE.mk +++ b/unix/NOTICE.mk @@ -1,13 +1,9 @@ -This copyright NOTICE applies to all files in this directory and -subdirectories, unless another copyright notice appears in a given -file or subdirectory. If you take substantial code from this software to use in -other programs, you must somehow include with it an appropriate -copyright notice that includes the copyright notice and the other -notices below. It is fine (and often tidier) to do that in a separate -file such as NOTICE, LICENCE or COPYING. +This is a Unix port of the Plan 9 build tool mk, by Andrew Hume. +Please send comments about the packaging to Russ Cox . - Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. - Revisions Copyright © 2000-2003 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. +Copyright © 2021 Plan 9 Foundation +Portions Copyright © 1997-1999 Vita Nuova Limited +Portions Copyright © 2000-2015 Vita Nuova Holdings Limited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -26,9 +22,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ----- - -This software is also made available under the Lucent Public License -version 1.02; see http://9p.io/plan9/license.html - diff --git a/unix/NOTICE.regexp b/unix/NOTICE.regexp index 686891c1d..076a901ba 100644 --- a/unix/NOTICE.regexp +++ b/unix/NOTICE.regexp @@ -1,25 +1,22 @@ -/* - * The authors of this software is Rob Pike. - * Copyright (c) 2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. -*/ +This is a Unix port of the Plan 9 regular expression library, by Rob Pike. +Please send comments about the packaging to Russ Cox . -This is a Unix port of the Plan 9 regular expression library. +Copyright © 2021 Plan 9 Foundation -Please send comments about the packaging -to Russ Cox . +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. ----- - -This software is also made available under the Lucent Public License -version 1.02; see http://9p.io/plan9/license.html - +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/unix/NOTICE.utf b/unix/NOTICE.utf index e40240709..b39ee1ecc 100644 --- a/unix/NOTICE.utf +++ b/unix/NOTICE.utf @@ -1,25 +1,22 @@ -/* - * The authors of this software are Rob Pike and Ken Thompson. - * Copyright (c) 2002 by Lucent Technologies. - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. -*/ +This is a Unix port of the Plan 9 UTF-8 library, by Rob Pike and Ken Thompson. +Please send comments about the packaging to Russ Cox . -This is a Unix port of the Plan 9 formatted I/O package. +Copyright © 2021 Plan 9 Foundation -Please send comments about the packaging -to Russ Cox . +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. ----- - -This software is also made available under the Lucent Public License -version 1.02; see http://9p.io/plan9/license.html - +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/unix/README.dot b/unix/README.dot index 9479bbb5c..819d7569e 100644 --- a/unix/README.dot +++ b/unix/README.dot @@ -13,6 +13,9 @@ mk new-utf new-fmt new-bio new-regexp new-mk mk test-utf test-fmt test-bio test-regexp test-mk create the directory, populate it, and run a test build +mk test + run the above tests and then clean up + mk libutf.tgz libfmt.tgz libbio.tgz libregexp9.tgz mk.tgz create the directory, populate it, and build a tar file diff --git a/unix/mkfile b/unix/mkfile index 1c4319c6b..ba641bc6b 100644 --- a/unix/mkfile +++ b/unix/mkfile @@ -34,7 +34,12 @@ test-%:V: if(! test -f `{echo $i | sed 's/.c$/.o/'}) echo XXX not building $i cd .. - rm -r $td + +test:V: test-utf test-fmt test-bio test-regexp test-mk + mk test-clean + +test-clean:V: + rm -rf libutf libfmt libbio libregexp mk lib%.tgz:V: mk new-$stem @@ -49,7 +54,7 @@ mk.tgz:V: tar cf /dev/stdout mk | gzip > $target mk-with-libs.tgz:V: - mk new-utf + mk new-utf mk new-fmt mk new-bio mk new-regexp @@ -64,9 +69,6 @@ mk-with-libs.tgz:V: tgz:V: libutf.tgz libfmt.tgz libregexp9.tgz libbio.tgz mk.tgz mk-with-libs.tgz +# run from 'mk push' in ../dist, which sets 9fansweb push:V: - rm -f *.sha1 *.md5 *.sha256 - for (i in *.tgz) - sha1sum $i >$i.sha1 cp *.tgz $9fansweb/plan9port/unix - cp *.tgz.sha1 $9fansweb/plan9port/unix From 878b30c0bc1446ba933dc4539438512766183500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Noack?= Date: Mon, 17 Aug 2020 21:11:56 +0200 Subject: [PATCH 309/323] fspread: fix buffer overflow Without this fix, fspread is trusting the server to return as much data as requested, or less. If a server responds with more data though, fspread writes beyond the bounds of the buffer to fill, which is passed in by the caller. It depends on the caller of fspread() where that buffer is, so there are various possible attack vectors. In the Plan9 kernel, I found this implemented in devmnt.c, where overly large responses are truncated to the size requested before copying, so I assume that this strategy works here too. This also affects fsread() and fsreadn(), which are based on fspread(). --- src/lib9pclient/read.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib9pclient/read.c b/src/lib9pclient/read.c index ea94e9aa4..aaf843262 100644 --- a/src/lib9pclient/read.c +++ b/src/lib9pclient/read.c @@ -13,6 +13,7 @@ fspread(CFid *fid, void *buf, long n, vlong offset) Fcall tx, rx; void *freep; uint msize; + long nr; msize = fid->fs->msize - IOHDRSZ; if(n > msize) @@ -34,17 +35,21 @@ fspread(CFid *fid, void *buf, long n, vlong offset) free(freep); return -1; } - if(rx.count){ - memmove(buf, rx.data, rx.count); + nr = rx.count; + if(nr > n) + nr = n; + + if(nr){ + memmove(buf, rx.data, nr); if(offset == -1){ qlock(&fid->lk); - fid->offset += rx.count; + fid->offset += nr; qunlock(&fid->lk); } } free(freep); - return rx.count; + return nr; } long From 93a25a0f974e659e24767a13790ea4e87aabef22 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 9 Apr 2021 15:22:52 -0400 Subject: [PATCH 310/323] install(1): mention libfontconfig1-dev for Debian Also update install.txt, which mistakenly contained intro(1). Pointed out by Nicholas Schwartz. --- install.txt | 287 ++++++++++++++------------------------------- man/man1/install.1 | 2 +- 2 files changed, 86 insertions(+), 203 deletions(-) diff --git a/install.txt b/install.txt index 6e0e9d3e4..e7dd3c65b 100644 --- a/install.txt +++ b/install.txt @@ -1,219 +1,102 @@ - INTRO(1) INTRO(1) + INSTALL(1) INSTALL(1) NAME - intro - introduction to Plan 9 from User Space + install - notes about Plan 9 from User Space installation - DESCRIPTION - Plan 9 is a distributed computing environment built at Bell - Labs starting in the late 1980s. The system can be obtained - from Bell Labs at http://9p.io/plan9 and runs - on PCs and a variety of other platforms. Plan 9 became a - convenient platform for experimenting with new ideas, appli- - cations, and services. - - Plan 9 from User Space provides many of the ideas, applica- - tions, and services from Plan 9 on Unix-like systems. It - runs on FreeBSD (x86, x86-64), Linux (x86, x86-64, PowerPC - and ARM), Mac OS X (x86, x86-64, and PowerPC), NetBSD (x86 - and PowerPC), OpenBSD (x86 and PowerPC), Dragonfly BSD - (x86-64), and SunOS (x86-64 and Sparc). - - Commands - Plan 9 from User Space expects its own directory tree, con- - ventionally /usr/local/plan9. When programs need to access - files in the tree, they expect the $PLAN9 environment vari- - able to contain the name of the root of the tree. See - install(1) for details about installation. - - Many of the familiar Unix commands, for example cat(1), - ls(1), and wc(1), are present, but in their Plan 9 forms: - cat takes no options, ls does not columnate its output when - printing to a terminal, and wc counts UTF characters. In - some cases, the differences are quite noticeable: grep(1) - and sed(1) expect Plan 9 regular expressions (see - regexp(7)), which are closest to what Unix calls extended - regular expressions. Because of these differences, it is - not recommended to put $PLAN9/bin before the usual system - bin directories in your search path. Instead, put it at the - end of your path and use the 9(1) script when you want to - invoke the Plan 9 version of a traditional Unix command. - - Occasionally the Plan 9 programs have been changed to adapt - to Unix. Mk(1) now allows mkfiles to choose their own - shell, and rc(1) has a ulimit builtin and manages $PATH. - - Many of the graphical programs from Plan 9 are present, - including sam(1) and acme(1). An X11 window manager rio(1) - mimics Plan 9's window system, with command windows imple- - mented by the external program 9term(1). Following the style - of X Windows, these programs run in new windows rather than - the one in which they are invoked. They all take a -W - option to specify the size and placement of the new window. - The argument is one of widthxheight, widthxheight@xmin,xmax, - - Page 1 Plan 9 (printed 12/1/14) - - INTRO(1) INTRO(1) - - or xmin,ymin,xmax,ymax. - - The plumber(4) helps to connect the various Plan 9 programs - together, and fittings like web(1) connect it to external - programs such as web browsers; one can click on a URL in - acme and see the page load in Firefox. - - User-level file servers - In Plan 9, user-level file servers present file trees via - the Plan 9 file protocol, 9P. Processes can mount arbitrary - file servers and customize their own name spaces. These - facilities are used to connect programs. Clients interact - with file servers by reading and writing files. - - This cannot be done directly on Unix. Instead the servers - listen for 9P connections on Unix domain sockets; clients - connect to these sockets and speak 9P directly using the - 9pclient(3) library. Intro(4) tells more of the story. The - effect is not as clean as on Plan 9, but it gets the job - done and still provides a uniform and easy-to-understand - mechanism. The 9p(1) client can be used in shell scripts or - by hand to carry out simple interactions with servers. - Netfiles(1) is an experimental client for acme. - - External databases - Some programs rely on large databases that would be cumber- - some to include in every release. Scripts are provided that - download these databases separately. These databases can be - downloaded separately. See $PLAN9/dict/README and - $PLAN9/sky/README. - - Programming - The shell scripts 9c and 9l (see 9c(1)) provide a simple - interface to the underlying system compiler and linker, sim- - ilar to the 2c and 2l families on Plan 9. 9c compiles - source files, and 9l links object files into executables. - When using Plan 9 libraries, 9l infers the correct set of - libraries from the object files, so that no -l options are - needed. - - The only way to write multithreaded programs is to use the - thread(3) library. Rfork(3) exists but is not as capable as - on Plan 9. There are many unfortunate by necessary prepro- - cessor diversions to make Plan 9 and Unix libraries coexist. - See intro(3) for details. - - The debuggers acid(1) and db(1) and the debugging library - mach(3) are works in progress. They are platform- - independent, so that x86 Linux core dumps can be inspected - on PowerPC Mac OS X machines, but they are also fairly - incomplete. The x86 target is the most mature; initial Pow- - erPC support exists; and other targets are unimplemented. - - Page 2 Plan 9 (printed 12/1/14) - - INTRO(1) INTRO(1) - - The debuggers can only inspect, not manipulate, target pro- - cesses. Support for operating system threads and for 64-bit - architectures needs to be rethought. On x86 Linux systems, - acid and db can be relied upon to produce reasonable stack - traces (often in cases when GNU gdb cannot) and dump data - structures, but that it is the extent to which they have - been developed and exercised. - - Porting programs - The vast majority of the familiar Plan 9 programs have been - ported, including the Unicode-aware troff(1). - - Of the more recent additions to Plan 9, factotum(4), - secstore(1), and secstored(1), vac(1), vacfs(4), and - venti(8) are all ported. - - A backup system providing a dump file system built atop - Venti is in progress; see vbackup(8). - - Porting to new systems - Porting the tree to new operating systems or architectures - should be straightforward, as system-specific code has been - kept to a minimum. The largest pieces of system-specific - code are , which must include the right system files - and set up the right integer type definitions, and - libthread, which must implement spin locks, operating system - thread creation, and context switching routines. Portable - implementations of these using and - already exist. If your system supports them, you may not - need to write any system specific code at all. - - There are other smaller system dependencies, such as the - terminal handling code in 9term(1) and the implementation of - getcallerpc(3), but these are usually simple and are not on - the critical path for getting the system up and running. + SYNOPSIS + cd /usr/local/plan9; ./INSTALL [ -b | -c ] [ -r path ] - SEE ALSO - The rest of this manual describes Plan 9 from User Space. - Many of the man pages have been brought from Plan 9, but - they have been updated, and others have been written from + DESCRIPTION + To obtain the Plan 9 tree, use Git (see git(1)) or download + a tar file from https://9fans.github.io/plan9port. + + The tree can be unpacked anywhere, but the usual place is + /usr/local/plan9. In the root of the tree, run ./INSTALL. + This script builds the Plan 9 build program mk(1) if neces- + sary, cleans all previously built object files and libraries + out of the tree, rebuilds and installs everything, and then + cleans up. + + There are a few files in tree which have the root hard-coded + in them. After the build, INSTALL edits these files to + replace the string /usr/local/plan9 with the name of the + root of the current tree. + + Finally, INSTALL builds an HTML version of the manual and + installs it in /usr/local/plan9/man. + + The installation can be thought of as two steps: build all + the binaries, and then edit files as necessary to fix the + references to the installation root. If necessary, these + can be run separately. Given the -b flag, INSTALL performs + only the first step. Given the -c flag, INSTALL performs + only the second step. The first step can be done with the + tree in a temporary work directory, but the second step must + be done once the tree is in its final location. If you want + to build the project in one location and then install into + another location, use -r path to specify the final location + of Plan9 tree. These flags are only necessary when trying + to conform to the expectations of certain package management + systems. + + At the end of the installation, INSTALL prints suggested + settings for the environment variables $PLAN9 and $PATH. + + INSTALL writes various autodetected settings to + /usr/local/plan9/config. The file + /usr/local/plan9/LOCAL.config is appended to config after + this auto-detection and can be used to override the choices. + If LOCAL.config contains a line WSYSTYPE=nowsys then the + system is built without using X11. LOCAL.config may also + list settings for CC9 (the host C compiler) and CC9FLAGS + (any additional flags to pass to the compiler). Values more + + Page 1 Plan 9 (printed 4/9/21) + + INSTALL(1) INSTALL(1) + + complex than single words should be quoted with single + quotes. + + On most Linux systems, the X11 header packages need to be + installed to build using X11. On Debian. the required pack- + ages are libfontconfig1-dev, libx11-dev, libxext-dev, and + libxt-dev. On Ubuntu, it suffices to install xorg-dev. + + INSTALL can safely be repeated to rebuild the system from scratch. - The manual pages are in a Unix style tree, with names like - $PLAN9/man/man1/cat.1 instead of Plan 9's simpler - $PLAN9/man/1/cat, so that the Unix man(1) utility can handle - it. Some systems, for example Debian Linux, deduce the man - page locations from the search path, so that adding - $PLAN9/bin to your path is sufficient to cause $PLAN9/man to - be consulted for manual pages using the system man. On other - systems, or to look at manual pages with the same name as a - system page, invoke the Plan 9 man directly, as in 9 man - cat. - - Page 3 Plan 9 (printed 12/1/14) - - INTRO(1) INTRO(1) - - The manual sections follow the Unix numbering conventions, - not the Plan 9 ones. + Once the system is built for the first time, it can be main- + tained and rebuilt using mk(1). To rebuild individual com- + mands or libraries, run mk install and mk clean in the + appropriate source directory (see src(1)). - Section (1) describes general publicly accessible commands. + FILES + /usr/local/plan9/lib/moveplan9.files + the list of files that need to have /usr/local/plan9 + edited out of them - Section (3) describes C library functions. + /usr/local/plan9/lib/moveplan9.sh + the script that edits the files - Section (4) describes user-level file servers. + /usr/local/plan9/src/mkmk.sh + the shell script used to build mk(1) - Section (7) describes file formats and protocols. (On Unix, - section (5) is technically for file formats but seems now to - be used for describing specific files.) + /usr/local/plan9/dist/manweb + the shell script that builds the HTML manual - Section (8) describes commands used for system administra- - tion. + /usr/local/plan9/man/index.html + the top-level page in the HTML version of the manual - Section (9p) describes the Plan 9 file protocol 9P. + /usr/local/plan9/install.log + logged output from the last run of INSTALL - These pages describe parts of the system that are new or - different from Plan 9 from Bell Labs: + /usr/local/plan9/install.sum + a summary of install.log - 9(1), 9c(1), 9p(1), 9term(1), acidtypes in acid(1), - dial(1), git(1), label(1), the MKSHELL variable in - mk(1), namespace(1), netfiles(1), page(1), psfonts(1), - rio(1), web(1), wintext(1) - - intro(3), 9pclient(3), the unix network in dial(3), - exits(3), get9root(3), getns(3), notify(3), - post9pservice(3), rfork(3), searchpath(3), sendfd(3), - udpread(3), venti(3), wait(3), wctl(3) - - intro(4), 9pserve(4), import(4), - - vbackup(8) - - openfd(9p) - - DIAGNOSTICS - In Plan 9, a program's exit status is an arbitrary text - string, while on Unix it is an integer. Section (1) of this - manual describes commands as though they exit with string - statuses. In fact, exiting with an empty status corresponds - to exiting with status 0, and exiting with any non-empty - string corresponds to exiting with status 1. See exits(3). + SEE ALSO + intro(1), git(1) - Page 4 Plan 9 (printed 12/1/14) + Page 2 Plan 9 (printed 4/9/21) diff --git a/man/man1/install.1 b/man/man1/install.1 index 4b173d181..66f780c72 100644 --- a/man/man1/install.1 +++ b/man/man1/install.1 @@ -101,7 +101,7 @@ with single quotes. .PP On most Linux systems, the X11 header packages need to be installed to build using X11. On Debian. the required packages are -libx11-dev, libxext-dev, and libxt-dev. +libfontconfig1-dev, libx11-dev, libxext-dev, and libxt-dev. On Ubuntu, it suffices to install xorg-dev. .PP .I INSTALL From 70cc6e5ba7798b315c3fb3aae19620a01604a459 Mon Sep 17 00:00:00 2001 From: Anthony Sorace Date: Thu, 22 Apr 2021 00:16:10 -0700 Subject: [PATCH 311/323] libthread: use setpgid instead of setpgrp --- src/libthread/daemonize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c index 299290688..89efaf5da 100644 --- a/src/libthread/daemonize.c +++ b/src/libthread/daemonize.c @@ -106,7 +106,7 @@ _threadsetupdaemonize(void) * Put it in its own process group so that we don't get a SIGHUP * when the parent exits. */ - setpgrp(); + setpgid(0, 0); if(pipe(p) < 0) sysfatal("passer pipe: %r"); From 6c4260fc670a71ae13587ff7da64518e5295777b Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Sun, 29 Aug 2021 13:36:30 -0700 Subject: [PATCH 312/323] bin/9c, bin/9l: Re-enable optimization on AIX. --- bin/9c | 4 ++-- bin/9l | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/9c b/bin/9c index 63840b198..de8f81e98 100755 --- a/bin/9c +++ b/bin/9c @@ -90,7 +90,7 @@ usexlc() cc=${CC9:-xlc_r} cflags=" \ -c \ - -O0 \ + -O2 \ -qmaxmem=-1 \ -qsuppress=1506-236 \ -qsuppress=1506-358 \ @@ -99,7 +99,7 @@ usexlc() -qsuppress=1506-1300 \ -qsuppress=1506-342 \ " - cflags="$cflags -g -qfullpath" + cflags="$cflags -g -qdbxextra -qfullpath" cflags="$cflags $CC9FLAGS" } diff --git a/bin/9l b/bin/9l index abca55fcc..d7c9e2ddc 100755 --- a/bin/9l +++ b/bin/9l @@ -58,7 +58,7 @@ case "$tag" in esac ;; *AIX*) - ld="${CC9:-xlc_r} -g -O0 $CC9FLAGS" + ld="${CC9:-xlc_r} $CC9FLAGS" nmflags="-A -B" ;; *) From e9d8c4516847e3d8b36f384fb662b1a490f76f4e Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Sun, 29 Aug 2021 13:38:35 -0700 Subject: [PATCH 313/323] libdraw: Fix GUI programs on AIX (#398) --- src/libdraw/string.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libdraw/string.c b/src/libdraw/string.c index 5ba5016a4..4f08b1b8d 100644 --- a/src/libdraw/string.c +++ b/src/libdraw/string.c @@ -81,7 +81,11 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i }else rptr = &r; sf = nil; +#if defined(__AIX__) + while((*s || *rptr) && len){ +#else while((*s || *r) && len){ +#endif max = Max; if(len < max) max = len; From d356d2a8b2436266d7b2fceabc3d281bc3e360a7 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 30 Aug 2021 08:41:21 -0700 Subject: [PATCH 314/323] 9term: Skip unnecessary ioctl call on AIX. --- src/cmd/9term/AIX.c | 1 - src/cmd/9term/bsdpty.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/9term/AIX.c b/src/cmd/9term/AIX.c index b7ccbf0f4..eec79c286 100644 --- a/src/cmd/9term/AIX.c +++ b/src/cmd/9term/AIX.c @@ -1,2 +1 @@ -#define TIOCSCTTY 0x540E #include "bsdpty.c" diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c index 3710a18d6..e7e047e35 100644 --- a/src/cmd/9term/bsdpty.c +++ b/src/cmd/9term/bsdpty.c @@ -63,8 +63,10 @@ childpty(int fd[], char *slave) sfd = open(slave, ORDWR); if(sfd < 0) sysfatal("child open %s: %r\n", slave); +#if !defined (__AIX__) if(ioctl(sfd, TIOCSCTTY, 0) < 0) fprint(2, "ioctl TIOCSCTTY: %r\n"); +#endif return sfd; } From aa01c23be63787550e64bc1a0f3a8d267cad1fa4 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Fri, 30 Jul 2021 00:19:09 -0700 Subject: [PATCH 315/323] .gitignore: Ignore some more things that get created during compile. --- .gitignore | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index ad8a20dee..98370cdbe 100644 --- a/.gitignore +++ b/.gitignore @@ -158,6 +158,7 @@ bin/rc bin/read bin/readcons bin/resample +bin/rio bin/rm bin/rsa2csr bin/rsa2pub @@ -246,7 +247,9 @@ bin/vmount0 bin/vnfs bin/wc bin/win +bin/winwatch bin/xd +bin/xshove bin/yacc bin/yuv bin/zcat @@ -266,9 +269,26 @@ postscript/font/ sky/*.scat sky/here src/**/o.* +src/cmd/awk/proctab.c src/cmd/awk/y.output +src/cmd/bc.tab.c +src/cmd/bc.tab.h +src/cmd/delatex.c src/cmd/devdraw/latin1.h +src/cmd/eqn/eqn.c +src/cmd/eqn/prevy.tab.h +src/cmd/grap/grap.c +src/cmd/grap/grapl.c +src/cmd/jpg/rgbv.h +src/cmd/jpg/ycbcr.h +src/cmd/pic/picl.c +src/cmd/pic/picy.c src/cmd/rc/x.tab.h +src/cmd/svgpic/picl.c +src/cmd/svgpic/picy.c +src/cmd/tpic/picy.c +src/cmd/units.tab.c +src/cmd/units.tab.h state state.journal state.old From 385a6d5877258cee0cac6151e6359c9206006b01 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Sun, 8 Aug 2021 11:03:02 -0700 Subject: [PATCH 316/323] lib9p: Remove postmountsrv (#505) --- include/9p.h | 1 - man/lookman.index | 1 - man/man3/9p.3 | 14 ++------- man/man3/INDEX | 1 - src/lib9p/_post.c | 77 ----------------------------------------------- src/lib9p/post.c | 23 -------------- src/lib9p/post.h | 13 -------- 7 files changed, 3 insertions(+), 127 deletions(-) delete mode 100644 src/lib9p/_post.c delete mode 100644 src/lib9p/post.c delete mode 100644 src/lib9p/post.h diff --git a/include/9p.h b/include/9p.h index 57caac28f..586c59ccb 100644 --- a/include/9p.h +++ b/include/9p.h @@ -219,7 +219,6 @@ struct Srv { }; void srv(Srv*); -void postmountsrv(Srv*, char*, char*, int); int postfd(char*, int); extern int chatty9p; void respond(Req*, char*); diff --git a/man/lookman.index b/man/lookman.index index 56aabc53c..56f12227b 100644 --- a/man/lookman.index +++ b/man/lookman.index @@ -19153,7 +19153,6 @@ posted /usr/local/plan9/man/man4/plumber.4 posted /usr/local/plan9/man/man9/0intro.9p postfd /usr/local/plan9/man/man3/9p.3 postmark /usr/local/plan9/man/man1/bundle.1 -postmountsrv /usr/local/plan9/man/man3/9p.3 postnote /usr/local/plan9/man/man3/notify.3 postnote /usr/local/plan9/man/man3/postnote.3 postnote /usr/local/plan9/man/man3/rfork.3 diff --git a/man/man3/9p.3 b/man/man3/9p.3 index adf102691..86b37fafe 100644 --- a/man/man3/9p.3 +++ b/man/man3/9p.3 @@ -6,7 +6,6 @@ emalloc9p, erealloc9p, estrdup9p, postfd, -postmountsrv, readbuf, readstr, respond, @@ -61,7 +60,6 @@ typedef struct Srv { .ft L .ta \w'\fLvoid* 'u int srv(Srv *s) -void postmountsrv(Srv *s, char *name, char *mtpt, int flag) void threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag) int postfd(char *srvname, int fd) void respond(Req *r, char *error) @@ -96,8 +94,6 @@ and writing the responses to .BR s->outfd . (Typically, -.I postmountsrv -or .I threadpostmountsrv initializes the .B infd @@ -148,12 +144,10 @@ but abort the program if they run out of memory. If alternate behavior is desired, clients can link against alternate implementations of these functions. .PP -.I Postmountsrv -and .I threadpostmountsrv -are wrappers that create a separate process in which to run +is a wrapper that creates a separate process in which to run .IR srv . -They do the following: +It does the following: .IP If .IB s -> nopipe @@ -296,9 +290,7 @@ the service functions. The service loop provided by .I srv (and indirectly by -.I postmountsrv -and -.IR threadpostmountsrv ) +.I threadpostmountsrv ) is single-threaded. If it is expected that some requests might block, arranging for alternate processes diff --git a/man/man3/INDEX b/man/man3/INDEX index 6654ea7c2..39e10b41a 100644 --- a/man/man3/INDEX +++ b/man/man3/INDEX @@ -50,7 +50,6 @@ emalloc9p 9p.3 erealloc9p 9p.3 estrdup9p 9p.3 postfd 9p.3 -postmountsrv 9p.3 readbuf 9p.3 readstr 9p.3 respond 9p.3 diff --git a/src/lib9p/_post.c b/src/lib9p/_post.c deleted file mode 100644 index 56f614fe6..000000000 --- a/src/lib9p/_post.c +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include -#include -#include <9p.h> -#include "post.h" - -Postcrud* -_post1(Srv *s, char *name, char *mtpt, int flag) -{ - Postcrud *p; - - p = emalloc9p(sizeof *p); - if(!s->nopipe){ - if(pipe(p->fd) < 0) - sysfatal("pipe: %r"); - s->infd = s->outfd = p->fd[1]; - s->srvfd = p->fd[0]; - } - if(name) - if(postfd(name, s->srvfd) < 0) - sysfatal("postfd %s: %r", name); - p->s = s; - p->mtpt = mtpt; - p->flag = flag; - return p; -} - -void -_post2(void *v) -{ - Srv *s; - - s = v; - if(!s->leavefdsopen){ - rfork(RFNOTEG); - rendezvous((ulong)s, 0); - close(s->srvfd); - } - srv(s); -} - -void -_post3(Postcrud *p) -{ - /* - * Normally the server is posting as the last thing it does - * before exiting, so the correct thing to do is drop into - * a different fd space and close the 9P server half of the - * pipe before trying to mount the kernel half. This way, - * if the file server dies, we don't have a ref to the 9P server - * half of the pipe. Then killing the other procs will drop - * all the refs on the 9P server half, and the mount will fail. - * Otherwise the mount hangs forever. - * - * Libthread in general and acme win in particular make - * it hard to make this fd bookkeeping work out properly, - * so leaveinfdopen is a flag that win sets to opt out of this - * safety net. - */ - if(!p->s->leavefdsopen){ - rfork(RFFDG); - rendezvous((ulong)p->s, 0); - close(p->s->infd); - if(p->s->infd != p->s->outfd) - close(p->s->outfd); - } - -#if 0 - if(p->mtpt){ - if(amount(p->s->srvfd, p->mtpt, p->flag, "") == -1) - sysfatal("mount %s: %r", p->mtpt); - }else -#endif - close(p->s->srvfd); - free(p); -} diff --git a/src/lib9p/post.c b/src/lib9p/post.c deleted file mode 100644 index 4ee99bc8d..000000000 --- a/src/lib9p/post.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include -#include <9p.h> -#include "post.h" - -void -postmountsrv(Srv *s, char *name, char *mtpt, int flag) -{ - Postcrud *p; - - p = _post1(s, name, mtpt, flag); - switch(rfork(RFPROC|RFNOTEG|RFNAMEG|RFMEM)){ - case -1: - sysfatal("rfork: %r"); - case 0: - _post2(s); - exits(nil); - default: - _post3(p); - } -} diff --git a/src/lib9p/post.h b/src/lib9p/post.h deleted file mode 100644 index 069a7ce7b..000000000 --- a/src/lib9p/post.h +++ /dev/null @@ -1,13 +0,0 @@ -typedef struct Postcrud Postcrud; -struct Postcrud -{ - int fd[2]; - Srv *s; - char *name; - char *mtpt; - int flag; -}; - -Postcrud *_post1(Srv*, char*, char*, int); -void _post2(void*); -void _post3(Postcrud*); From ceb1ab90ff65d3c2ac3fc46546dc2eed206a37c3 Mon Sep 17 00:00:00 2001 From: Alexander Kapshuk Date: Tue, 31 Aug 2021 10:10:59 +0300 Subject: [PATCH 317/323] lib9p: Fix compile error commit 385a6d5877258cee0cac6151e6359c9206006b01 removed src/lib9p/_post.c from the code base, but overlooked removing a reference to the _post.o object file from the src/lib9p/mkfile. This results in lib9p failing to compile: * Running on Darwin... * Compiler version: Apple clang version 12.0.5 (clang-1205.0.22.11) * Building mk... * Building everything (be patient)... >>> mk: don't know how to make '/Users/sasha/plan9port_fork/lib/lib9p.a(_post.o)' in /Users/sasha/plan9port_fork/src/lib9p mk: for i in ... : exit status=exit(1) Remove _post.o from the list of dependent object files from src/lib9p/mkfile to have lib9p compile. Fixes: 385a6d587725 ("lib9p: Remove postmountsrv (#505)") --- src/lib9p/mkfile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib9p/mkfile b/src/lib9p/mkfile index 3c6225f69..3d7fa0331 100644 --- a/src/lib9p/mkfile +++ b/src/lib9p/mkfile @@ -2,7 +2,6 @@ LIB=lib9p.a OFILES=\ - _post.$O\ dirread.$O\ fid.$O\ file.$O\ From 8cf52696bed986f8914f214768690d6ca47bae76 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 28 Sep 2021 13:07:25 -0400 Subject: [PATCH 318/323] acme: fix extra print args --- src/cmd/acme/exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c index be7936ae0..1dd022889 100644 --- a/src/cmd/acme/exec.c +++ b/src/cmd/acme/exec.c @@ -209,14 +209,14 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt) if(n <= EVENTSIZE) winevent(t->w, "%c%d %d %d %d %.*S\n", c, aq0, aq1, f, n, n, r); else - winevent(t->w, "%c%d %d %d 0 \n", c, aq0, aq1, f, n); + winevent(t->w, "%c%d %d %d 0 \n", c, aq0, aq1, f); if(q0!=aq0 || q1!=aq1){ n = q1-q0; bufread(&t->file->b, q0, r, n); if(n <= EVENTSIZE) winevent(t->w, "%c%d %d 0 %d %.*S\n", c, q0, q1, n, n, r); else - winevent(t->w, "%c%d %d 0 0 \n", c, q0, q1, n); + winevent(t->w, "%c%d %d 0 0 \n", c, q0, q1); } if(a){ winevent(t->w, "%c0 0 0 %d %s\n", c, utflen(a), a); From d3ee9f70e4ee00bd12557910c9e3dcc1fabd53c7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 30 Sep 2021 08:44:00 -0400 Subject: [PATCH 319/323] sam: fix spurious overwrite message Fixes: % sam -d -. w foo foo: (new file) #0 w foo ?warning: write might change good version of `foo' --- src/cmd/sam/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/sam/io.c b/src/cmd/sam/io.c index c112c0a1a..c3dc9778c 100644 --- a/src/cmd/sam/io.c +++ b/src/cmd/sam/io.c @@ -63,7 +63,7 @@ writef(File *f) warn(Wnotnewline); closeio(n); if(f->name.s[0]==0 || samename){ - if(statfile(name, &dev, &qid, &mtime, 0, 0) > 0){ + if(statfile(genc, &dev, &qid, &mtime, 0, 0) > 0){ f->dev = dev; f->qidpath = qid; f->mtime = mtime; From e683bdfa76a5c2c54422a6bd2934b133d77ba610 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Sun, 3 Oct 2021 19:19:51 +0000 Subject: [PATCH 320/323] mk: provide a mechanism to default to `rc` For cross-compiling plan9 from Unix, provide a way to force `mk` to use `rc` instead of `sh` without setting `MKSHELL` in individual `mkfile`s. If the environment variable `FORCERCFORMK` is set, `mk` will default to using `rc`, not `sh`. Signed-off-by: Dan Cross --- src/cmd/mk/shell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/mk/shell.c b/src/cmd/mk/shell.c index 8c15ec218..3e10146f6 100644 --- a/src/cmd/mk/shell.c +++ b/src/cmd/mk/shell.c @@ -41,6 +41,8 @@ setshell(Word *w) void initshell(void) { + if(getenv("FORCERCFORMK") != nil) + shelldefault = &rcshell; shellcmd = stow(shelldefault->name); shellt = shelldefault; setvar("MKSHELL", shellcmd); From 0ac2a105ae58e86a8d224020f0a3c43358312e66 Mon Sep 17 00:00:00 2001 From: Nic Date: Sun, 17 Oct 2021 14:18:29 +0100 Subject: [PATCH 321/323] cmd/auxstats: improve wireless interface name matcher in Linux --- src/cmd/auxstats/Linux.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index 7bc4b7206..e40265511 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "dat.h" void xapm(int); @@ -235,10 +236,12 @@ void xwireless(int first) { static int fd = -1; + static Reprog *wlan = nil; int i; if(first){ fd = open("/proc/net/wireless", OREAD); + wlan = regcomp("^(wlan[0-9]+|wlp[0-9]+s[0-9]+):$"); return; } @@ -247,7 +250,7 @@ xwireless(int first) tokens(i); if(ntok < 3) continue; - if(strcmp(tok[0], "wlan0:") == 0) + if(regexec(wlan, tok[0], nil, 0) == 1) Bprint(&bout, "802.11 =%lld 100\n", atoll(tok[2])); } } From 7b0b2065faf449f820b092afb74cf0af2dae79a3 Mon Sep 17 00:00:00 2001 From: Nicola Girardi Date: Sun, 17 Oct 2021 19:46:13 +0100 Subject: [PATCH 322/323] cmd/auxstats: improve network device name matcher in Linux --- src/cmd/auxstats/Linux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index e40265511..74491ac29 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -120,9 +120,11 @@ xnet(int first) vlong totb, totp, tote, totin, totou, totinb, totoub, b, p, e, in, ou, inb, oub; char *q; static int fd = -1; + static Reprog *netdev = nil; if(first){ fd = open("/proc/net/dev", OREAD); + netdev = regcomp("^(eth[0-9]+|wlan[0-9]+|enp[0-9]+s[0-9]+f[0-9]+|wlp[0-9]+s[0-9]+)$"); return; } @@ -141,7 +143,7 @@ xnet(int first) tokens(i); if(ntok < 8+8) continue; - if(strncmp(tok[0], "eth", 3) != 0 && strncmp(tok[0], "wlan", 4) != 0) + if(regexec(netdev, tok[0], nil, 0) != 1) continue; inb = atoll(tok[1]); oub = atoll(tok[9]); From d0d440860f2000a1560abb3f593cdc325fcead4c Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Tue, 19 Oct 2021 17:08:45 +0100 Subject: [PATCH 323/323] src/cmd/acme: provide info on presense or absence of undo history (#528) It's sometimes useful to know whether there's been editing activity in a window. This PR adds that information to the ctl file. Change-Id: I21a342ac636dd5c7701b3ed560e3526867329c2c --- man/man4/acme.4 | 7 ++++--- src/cmd/acme/fns.h | 2 ++ src/cmd/acme/wind.c | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/man/man4/acme.4 b/man/man4/acme.4 index a285b3b89..f55a85b75 100644 --- a/man/man4/acme.4 +++ b/man/man4/acme.4 @@ -184,9 +184,10 @@ is always appended; the file offset is ignored. .B ctl may be read to recover the five numbers as held in the .B index -file, described above, plus three more fields: the width of the -window in pixels, the name of the font used in the window, -and the width of a tab character in pixels. +file, described above, plus five more fields: the width of the +window in pixels; the name of the font used in the window; +the width of a tab character in pixels; a 1 if there is undo history, 0 otherwise; +a 1 if there is redo history, 0 otherwise. Text messages may be written to .B ctl to affect the window. diff --git a/src/cmd/acme/fns.h b/src/cmd/acme/fns.h index c0339c230..969db417f 100644 --- a/src/cmd/acme/fns.h +++ b/src/cmd/acme/fns.h @@ -25,6 +25,8 @@ void savemouse(Window*); int restoremouse(Window*); void clearmouse(void); void allwindows(void(*)(Window*, void*), void*); +uint seqof(Window*, int); + uint loadfile(int, uint, int*, int(*)(void*, uint, Rune*, int), void*, DigestState*); void movetodel(Window*); diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c index 0cba59205..98c97368c 100644 --- a/src/cmd/acme/wind.c +++ b/src/cmd/acme/wind.c @@ -689,8 +689,8 @@ 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), - w->body.reffont->f->name, w->body.fr.maxtab); + return smprint("%s%11d %q %11d %11d %11d ", buf, Dx(w->body.fr.r), + w->body.reffont->f->name, w->body.fr.maxtab, seqof(w, 1) != 0, seqof(w, 0) != 0); return buf; }