tMany small edits. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c8b6342d3c2a167dec16931815926e9e4387e7ef
 (DIR) parent 741f510ce758f77ed5193256fb693a09a7daecce
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 13 Jan 2005 04:49:19 +0000
       
       Many small edits.
       
       Diffstat:
         M bin/9l                              |      13 +++++++++++--
         M bin/doctype                         |       2 +-
         M bin/g                               |       2 +-
         M bin/lc                              |       2 +-
         M bin/man                             |      12 ++++++------
         M dict/README                         |       6 ++++++
         M dist/checkman.awk                   |     153 ++++++++++++++++++-------------
         M include/libc.h                      |      14 +++++---------
         M include/thread.h                    |       5 -----
         M lib/fortunes                        |      38 +++++++++++++++++++++++++++++++
         M lib/moveplan9.files                 |       1 +
         A man/fonts                           |      10 ++++++++++
         A man/man1/0intro.1                   |     300 +++++++++++++++++++++++++++++++
         M man/man1/9c.1                       |      59 +++++++++++++++++++++++++++----
         M man/man1/9p.1                       |       4 +---
         M man/man1/9term.1                    |      38 ++++++++++++++++++-------------
         M man/man1/INDEX                      |       9 +++++----
         M man/man1/acid.1                     |      10 +++++-----
         M man/man1/acme.1                     |      25 +++++++++++++++----------
         M man/man1/acmeevent.1                |      86 ++++++++++++++++++++++++++-----
         M man/man1/ascii.1                    |      11 +++++------
         M man/man1/astro.1                    |       7 +++----
         M man/man1/bc.1                       |       6 +++---
         M man/man1/bundle.1                   |       4 ++--
         M man/man1/cal.1                      |       2 +-
         M man/man1/calendar.1                 |       6 +++---
         M man/man1/cat.1                      |       2 +-
         M man/man1/colors.1                   |      55 +++++++++++--------------------
         M man/man1/core.1                     |       3 +++
         M man/man1/date.1                     |       2 +-
         M man/man1/db.1                       |       8 --------
         M man/man1/dc.1                       |       8 ++++----
         M man/man1/deroff.1                   |       2 +-
         M man/man1/dict.1                     |      10 ++++------
         M man/man1/diff.1                     |       2 +-
         M man/man1/doctype.1                  |      13 ++++++++++---
         M man/man1/ed.1                       |       2 +-
         M man/man1/fortune.1                  |       6 +++---
         M man/man1/grap.1                     |       6 +++---
         M man/man1/grep.1                     |       1 +
         M man/man1/idiff.1                    |      15 ++++++++-------
         M man/man1/join.1                     |       2 +-
         M man/man1/kill.1                     |      10 +++++-----
         M man/man1/lex.1                      |       2 +-
         M man/man1/look.1                     |       5 ++---
         M man/man1/ls.1                       |       3 +--
         M man/man1/man.1                      |       9 ++++++---
         M man/man1/map.1                      |       2 +-
         M man/man1/mk.1                       |      69 +++++++++++++++++++++-----------
         M man/man1/namespace.1                |       3 ++-
         M man/man1/news.1                     |      21 ++++++++++-----------
         M man/man1/page.1                     |      10 +++++++++-
         M man/man1/plumb.1                    |       8 ++------
         M man/man1/proof.1                    |       5 ++---
         M man/man1/ps.1                       |       2 +-
         M man/man1/rc.1                       |       3 +--
         M man/man1/sam.1                      |      17 +++++++++++------
         M man/man1/scat.1                     |      18 +++++++++---------
         M man/man1/secstore.1                 |     138 +++++++++++++++---------------
         M man/man1/sed.1                      |       6 +++---
         M man/man1/sort.1                     |       6 ++++--
         M man/man1/spell.1                    |       4 ++--
         M man/man1/stats.1                    |      20 ++++++++++++++------
         M man/man1/tail.1                     |       4 ++--
         M man/man1/troff.1                    |       8 ++++----
         M man/man1/units.1                    |      11 +++++------
         M man/man1/vac.1                      |       1 -
         M man/man1/wc.1                       |       2 +-
         M man/man1/web.1                      |      22 +++++++++++++++++++++-
         M man/man1/wintext.1                  |      32 ++++++++++++++++----------------
         M man/man1/yacc.1                     |       2 +-
         A man/man3/0intro.3                   |     395 ++++++++++++++++++++++++++++++
         M man/man3/9p.3                       |      12 ++++++------
         M man/man3/9pclient.3                 |       4 ++--
         M man/man3/INDEX                      |     110 +++++++++++++------------------
         M man/man3/atof.3                     |      32 +++++++++++++++++++++++++++++++
         M man/man3/bin.3                      |       2 +-
         M man/man3/bio.3                      |       2 +-
         M man/man3/complete.3                 |      12 ++++++------
         M man/man3/ctime.3                    |      21 +++++++++++++++++++--
         M man/man3/dial.3                     |      21 +++++++++++++++++++--
         M man/man3/dup.3                      |       9 +++++----
         M man/man3/event.3                    |       5 +++++
         M man/man3/exec.3                     |      11 +++++++++++
         M man/man3/exits.3                    |      11 +++++++++++
         M man/man3/flate.3                    |      26 +++++++++++++-------------
         M man/man3/fmtinstall.3               |       1 -
         M man/man3/frame.3                    |       2 +-
         M man/man3/genrandom.3                |       6 ++++--
         M man/man3/getenv.3                   |      11 ++++++++---
         M man/man3/getwd.3                    |       9 ++++++++-
         M man/man3/graphics.3                 |       6 +++++-
         M man/man3/malloc.3                   |      15 +++++++++++++++
         M man/man3/memdraw.3                  |       5 ++---
         M man/man3/memlayer.3                 |       4 ++--
         M man/man3/mp.3                       |      16 ++++++++--------
         M man/man3/muldiv.3                   |       2 +-
         M man/man3/mux.3                      |       1 +
         M man/man3/notify.3                   |       4 +++-
         M man/man3/print.3                    |      59 +++++++++++++------------------
         M man/man3/pushtls.3                  |       2 +-
         M man/man3/quote.3                    |       7 +++++++
         M man/man3/rand.3                     |      19 +++++++++++++++++--
         M man/man3/regexp.3                   |       8 ++++----
         M man/man3/sechash.3                  |      21 +++++++++++----------
         M man/man3/seek.3                     |       7 +++++++
         M man/man3/setjmp.3                   |      51 +++++++++++++------------------
         M man/man3/sleep.3                    |      11 +++++++++++
         M man/man3/string.3                   |       2 +-
         M man/man3/subfont.3                  |       6 +++---
         M man/man3/thread.3                   |      31 ++++---------------------------
         M man/man3/time.3                     |      11 +++++++++++
         M man/man3/wait.3                     |      13 +++++++++++++
         M man/man4/INDEX                      |       1 +
         M man/man4/acme.4                     |      12 ++++--------
         A man/man4/import.4                   |     106 ++++++++++++++++++++++++++++++
         M man/man4/plumber.4                  |       6 +++---
         M man/man7/INDEX                      |       1 -
         M man/man7/font.7                     |       4 ++--
         M man/man7/man.7                      |       6 ++++--
         M man/man7/ms.7                       |       2 +-
         M man/man7/plumb.7                    |      14 +++++++-------
         M man/man7/regexp.7                   |      17 -----------------
         M man/man8/mk9660.8                   |       9 ++++-----
         M man/secindex                        |       4 ++--
         M rcmain                              |       1 +
         M src/cmd/9660/dump9660.c             |       6 +++---
         M src/cmd/acid/main.c                 |       2 +-
         M src/cmd/acme/acme.c                 |       4 +---
         M src/cmd/bc.y                        |       2 +-
         M src/cmd/calendar.c                  |       2 +-
         M src/cmd/dict/dict.h                 |       3 +++
         M src/cmd/dict/mkfile                 |       2 +-
         A src/cmd/dict/roget.c                |     147 +++++++++++++++++++++++++++++++
         M src/cmd/dict/utils.c                |       3 +++
         A src/cmd/draw/iconv.c                |     102 +++++++++++++++++++++++++++++++
         M src/cmd/ed.c                        |       2 +-
         M src/cmd/grep/main.c                 |       3 +++
         M src/cmd/import.c                    |       2 +-
         M src/cmd/map/map.c                   |       3 ++-
         M src/cmd/map/mapdemo.rc              |       2 +-
         M src/cmd/mk/mkfile.test              |       4 ++--
         M src/cmd/mk/parse.c                  |      37 +++++++++++++------------------
         M src/cmd/mk/shell.c                  |       2 ++
         M src/cmd/mkfile                      |       2 +-
         M src/cmd/news.c                      |       2 +-
         M src/cmd/plumb/plumber.c             |       4 +---
         M src/cmd/rc/exec.c                   |       1 +
         M src/cmd/rm.c                        |      10 +++++++++-
         M src/cmd/sam/plan9.c                 |       2 +-
         M src/cmd/sort.c                      |       2 +-
         M src/libdraw/mkfile                  |       2 --
         D src/libdraw/readcolmap.c            |      49 -------------------------------
         D src/libdraw/writecolmap.c           |      35 -------------------------------
         M src/libdraw/x11-init.c              |       4 +---
         M src/libthread/channel.c             |       1 +
         M src/libthread/daemonize.c           |       4 ++--
         M src/libthread/thread.c              |      20 +++++++++++++++-----
         M tmac/tmac.anhtml                    |       7 +++++--
         M tmac/tmac.antimes                   |       4 +++-
       
       160 files changed, 2204 insertions(+), 864 deletions(-)
       ---
 (DIR) diff --git a/bin/9l b/bin/9l
       t@@ -91,6 +91,7 @@ then
                do
                        eval "have$i() { false; }"
                done
       +        havethread() { false; }
        
                # now find correct order
                libsl=""
       t@@ -129,6 +130,12 @@ then
                fi
                libsl="$libsl -l9"
        
       +        # cycle: lib9 expects p9main, which is defined in libthread.  oops.
       +        if $havethread
       +        then
       +                libsl="$libsl -lthread"
       +        fi
       +
                if [ "x$needdraw" = xtrue ]
                then
                        if [ "x$X11" = "x" ]
       t@@ -194,9 +201,11 @@ if $verbose
        then
                echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
        fi
       -if ! $ld -L$PLAN9/lib "$@" $libsl $extralibs
       +if $ld -L$PLAN9/lib "$@" $libsl $extralibs
        then
       +        exit 0
       +else
                rm -f $target
                exit 1
        fi
       -exit 0
       +
 (DIR) diff --git a/bin/doctype b/bin/doctype
       t@@ -24,7 +24,7 @@ ifs='
        '{
                files=`{echo $*}
        }
       -9grep -h '\$LIST|\|reference|^\.(EQ|TS|\[|PS|IS|GS|G1|GD|PP|BM|LP|BP|PI|cstart|begin|TH...)|^\.P$' $* |
       +9 grep -h '\$LIST|\|reference|^\.(EQ|TS|\[|PS|IS|GS|G1|GD|PP|BM|LP|BP|PI|cstart|begin|TH...)|^\.P$' $* |
        sort -u |
        awk '
        BEGIN        { files = "'$files'" }
 (DIR) diff --git a/bin/g b/bin/g
       t@@ -34,4 +34,4 @@ case $# in
                files="$@"
        esac
        
       -exec grep -n $flags -- "$pattern" $files /dev/null
       +exec 9 grep -n $flags -- "$pattern" $files /dev/null
 (DIR) diff --git a/bin/lc b/bin/lc
       t@@ -1,3 +1,3 @@
        #!/bin/sh
        
       -ls "$@" | mc
       +9 ls "$@" | mc
 (DIR) diff --git a/bin/man b/bin/man
       t@@ -60,11 +60,11 @@ if(~ $#sec 0) {
        }
        ix=$S/man$sec/INDEX
        if(~ $#* 1) pat='^'^$1^' '
       -if not pat='^('^`{echo $* | 9sed 's/ /|/g'}^') '
       +if not pat='^('^`{echo $* | 9 sed 's/ /|/g'}^') '
        fils=()
        for(i in $S/man$sec){
       -        if(/bin/test -f $i/INDEX){
       -                try=`{grep $pat $i/INDEX | 9sed 's/^[^ ]* //'}
       +        if(test -f $i/INDEX){
       +                try=`{grep $pat $i/INDEX | 9 sed 's/^[^ ]* //'}
                        if(! ~ $#try 0)
                                fils=($fils $i/$try)
                }
       t@@ -75,7 +75,7 @@ if(~ $#fils 0) {
                for(i) {
                        for(n in $sec) {
                                try=$S/man$n/$i.$n*
       -                        if (/bin/test -f $try)
       +                        if (test -f $try)
                                        fils=($fils $try)
                        }
                }
       t@@ -85,7 +85,7 @@ if(~ $#fils 0) {
                }
        }
        for(i in $fils) {
       -        if(! /bin/test -f $i)
       +        if(! test -f $i)
                        echo need $i >[1=2]
                if not {
                        switch($cmd) {
       t@@ -99,7 +99,7 @@ for(i in $fils) {
                                roff t $i |tr2post |psfonts |page
        
                        case n
       -                        roff n $i | 9sed '
       +                        roff n $i | 9 sed '
                                        ${
                                               /^$/p
                                        }
 (DIR) diff --git a/dict/README b/dict/README
       t@@ -5,3 +5,9 @@
        wget -O- http://pdos.lcs.mit.edu/~rsc/software/plan9/pgw.tar.bz2|
                bunzip2|
                tar xf -
       +
       +# This is the Project Gutenberg original Roget's thesaurus
       +
       +wget -O- http://pdos.lcs.mit.edu/~rsc/software/plan9/roget.tar.bz2|
       +        bunzip2|
       +        tar xf -
 (DIR) diff --git a/dist/checkman.awk b/dist/checkman.awk
       t@@ -41,8 +41,10 @@ BEGIN {
                Omitman["nm(1)"] = 1
                Omitman["prof(1)"] = 1
                Omitman["pwd(1)"] = 1
       +        Omitman["qiv(1)"] = 1
                Omitman["sh(1)"] = 1
                Omitman["ssh(1)"] = 1
       +        Omitman["stty(1)"] = 1
                Omitman["tar(1)"] = 1
                Omitman["tex(1)"] = 1
                Omitman["unutf(1)"] = 1
       t@@ -50,6 +52,7 @@ BEGIN {
        
                Omitman["access(2)"] = 1
                Omitman["brk(2)"] = 1
       +        Omitman["chdir(2)"] = 1
                Omitman["close(2)"] = 1
                Omitman["connect(2)"] = 1
                Omitman["fork(2)"] = 1
       t@@ -90,10 +93,10 @@ BEGIN {
                # don't need documentation for these in bin
                Omitted[".cvsignore"] = 1
                Omitted["Getdir"] = 1
       -        Omitted["9grep"] = 1        # is in grep(1)
       -        Omitted["9sed"] = 1        # is in sed(1)
       -        Omitted["9lex"] = 1                # is in lex(1)
       -        Omitted["9yacc"] = 1        # is in yacc(1)
       +        Omitted["tcolors"] = 1
       +        Omitted["tref"] = 1
       +        Omitted["unutf"] = 1
       +        Omitted["vtdump"] = 1
        
                # not for users
                Omittedlib["creadimage"] = 1
       t@@ -198,56 +201,66 @@ BEGIN {
                Renamelib["regsub9"] = "regsub"
                Renamelib["rregexec9"] = "rregexec"
                Renamelib["rregsub9"] = "rregsub"
       +
       +        lastline = "XXX";
       +        lastfile = FILENAME;
        }
        
        FNR==1        {
       -                n = length(FILENAME)
       -                nam = FILENAME
       -                if(nam ~ /\.html$/)
       -                        next
       -                if(nam !~ /^man\/man(.*)\/(.*)\.(.*)$/){
       -                        print "nam", nam, "not of form [0-9][0-9]?/*"
       -                        next
       -                }
       -                nam = substr(nam, 8)
       -                gsub("[/.]", " ", nam);
       -                n = split(nam, a)
       -                sec = a[1]
       -                name = a[2]
       -                section = a[3]
       -                if($1 != ".TH" || NF != 3)
       -                        print "First line of", FILENAME, "not a proper .TH"
       -                else if(($2 != toupper(name) || substr($3, 1, length(sec)) != sec || $3 != toupper(section)) \
       -                                && ($2!="INTRO" || name!="0intro") \
       -                                && (name !~ /^9/ || $2!=toupper(substr(name, 2)))){
       -                        print ".TH of", FILENAME, "doesn't match filename"
       -                }else
       -                        Pages[tolower($2) "(" tolower($3) ")"] = 1
       -                Sh = 0
       +        if(lastline == ""){
       +                # screws up troff headers
       +                print lastfile ":$ is a blank line"
       +        }
       +
       +        n = length(FILENAME)
       +        nam = FILENAME
       +        if(nam ~ /\.html$/)
       +                next
       +        if(nam !~ /^man\/man(.*)\/(.*)\.(.*)$/){
       +                print "nam", nam, "not of form [0-9][0-9]?/*"
       +                next
       +        }
       +        nam = substr(nam, 8)
       +        gsub("[/.]", " ", nam);
       +        n = split(nam, a)
       +        sec = a[1]
       +        name = a[2]
       +        section = a[3]
       +        if($1 != ".TH" || NF != 3)
       +                print "First line of", FILENAME, "not a proper .TH"
       +        else if(($2 != toupper(name) || substr($3, 1, length(sec)) != sec || $3 != toupper(section)) \
       +                        && ($2!="INTRO" || name!="0intro") \
       +                        && (name !~ /^9/ || $2!=toupper(substr(name, 2)))){
       +                print ".TH of", FILENAME, "doesn't match filename"
       +        }else
       +                Pages[tolower($2) "(" tolower($3) ")"] = 1
       +        Sh = 0
        }
        
       +{ lastline=$0; lastfile=FILENAME; }
       +
        $1 == ".SH" {
       -                if(inex)
       -                        print "Unterminated .EX in", FILENAME, ":", $0
       -                inex = 0;
       -                if (substr($2, 1, 1) == "\"") {
       -                        if (NF == 2) {
       -                                print "Unneeded quote in", FILENAME, ":", $0
       -                                $2 = substr($2, 2, length($2)-2)
       -                        } else if (NF == 3) {
       -                                $2 = substr($2, 2) substr($3, 1, length($3)-1)
       -                                NF = 2
       -                        }
       +        if(inex)
       +                print "Unterminated .EX in", FILENAME, ":", $0
       +        inex = 0;
       +        if (substr($2, 1, 1) == "\"") {
       +                if (NF == 2) {
       +                        print "Unneeded quote in", FILENAME, ":", $0
       +                        $2 = substr($2, 2, length($2)-2)
       +                } else if (NF == 3) {
       +                        $2 = substr($2, 2) substr($3, 1, length($3)-1)
       +                        NF = 2
                        }
       -                if(Sh == 0 && $2 != "NAME")
       -                        print FILENAME, "has no .SH NAME"
       -                w = Weight[$2]
       -                if (w) {
       -                        if (w < Sh)
       -                                print "Heading", $2, "out of order in", FILENAME
       -                        Sh += w
       -                }
       -                sh = $2
       +        }
       +        if(Sh == 0 && $2 != "NAME")
       +                print FILENAME, "has no .SH NAME"
       +        w = Weight[$2]
       +        if (w) {
       +                if (w < Sh)
       +                        print "Heading", $2, "out of order in", FILENAME
       +                Sh += w
       +        }
       +        sh = $2
        }
        
        $1 == ".EX" {
       t@@ -257,45 +270,55 @@ $1 == ".EX" {
        }
        
        $1 == ".EE" {
       -                if(!inex)
       -                        print "Bad .EE in", FILENAME ":" FNR ":", $0
       -                inex = 0;
       +        if(!inex)
       +                print "Bad .EE in", FILENAME ":" FNR ":", $0
       +        inex = 0;
        }
        
        $1 == ".TF" {
       -                smallspace = 1
       +        smallspace = 1
        }
        
        $1 == ".PD" || $1 == ".SH" || $1 == ".SS" || $1 == ".TH" {
       -                smallspace = 0
       +        smallspace = 0
        }
        
        $1 == ".RE" {
       -                lastre = 1
       +        lastre = 1
        }
        
        $1 == ".PP" {
       -                if(smallspace && !lastre)
       -                        print "Possible missing .PD at " FILENAME ":" FNR
       -                smallspace = 0
       +        if(smallspace && !lastre)
       +                print "Possible missing .PD at " FILENAME ":" FNR
       +        smallspace = 0
        }
        
        $1 != ".RE" {
       -                lastre = 0
       +        lastre = 0
        }
        
       -sh == "SOURCE" && $1 ~ /^\// {
       -        s = $1
       -        sub("\\\*9", ENVIRON["PLAN9"], s)
       +sh == "BUGS" && $1 == ".br" {
       +        print FILENAME ":" FNR ": .br in BUGS"
       +}
       +
       +sh == "SOURCE" && $1 ~ /^\\\*9\// {
       +        s = ENVIRON["PLAN9"] substr($1, 4)
                Sources[s] = 1
        }
        
       -sh == "SOURCE" && $2 ~ /^\// {
       -        s = $2
       -        sub("\\\*9", ENVIRON["PLAN9"], s)
       +sh == "SOURCE" && $2 ~ /^\\\*9\// {
       +        s = ENVIRON["PLAN9"] substr($2, 4)
                Sources[s] = 1
        }
        
       +sh == "SOURCE" && $1 ~ /^\// {
       +        Sources[$1] = 1
       +}
       +
       +sh == "SOURCE" && $2 ~ /^\// {
       +        Sources[$2] = 1
       +}
       +
        $0 ~ /^\.[A-Z].*\([1-9]\)/ {
                        if ($1 == ".IR" && $3 ~ /\([0-9]\)/) {
                                name = $2
       t@@ -319,6 +342,10 @@ $0 ~ /^\.[A-Z].*\([1-9]\)/ {
        }
        
        END {
       +        if(lastline == ""){
       +                print lastfile ":$ is a blank line"
       +        }
       +
                print "Checking Source References"
                cmd = "xargs -n 100 ls -d 2>&1 >/dev/null | sed 's/^ls: /        /; s/: .*//'"
                for (i in Sources) {
 (DIR) diff --git a/include/libc.h b/include/libc.h
       t@@ -358,10 +358,8 @@ extern        double        atof(char*); <stdlib.h>
        extern        int        p9atoi(char*);
        extern        long        p9atol(char*);
        extern        vlong        p9atoll(char*);
       -extern        double        charstod(int(*)(void*), void*);
       +extern        double        fmtcharstod(int(*)(void*), void*);
        extern        char*        cleanname(char*);
       -extern        int        p9decrypt(void*, void*, int);
       -extern        int        p9encrypt(void*, void*, int);
        extern        int        dec64(uchar*, int, char*, int);
        extern        int        enc64(char*, int, uchar*, int);
        extern        int        dec32(uchar*, int, char*, int);
       t@@ -386,7 +384,6 @@ extern        void        p9longjmp(p9jmp_buf, int);
        extern        char*        mktemp(char*);
        extern        int                opentemp(char*);
        /* extern        double        modf(double, double*); <math.h> */
       -extern        int        netcrypt(void*, void*);
        extern        void        p9notejmp(void*, p9jmp_buf, int);
        extern        void        perror(const char*);
        extern        int        postnote(int, int, char *);
       t@@ -397,14 +394,12 @@ extern        double        p9pow10(int);
        #define p9setjmp(b)        sigsetjmp((void*)(b), 1)
        /*
         * <stdlib.h>
       -extern        double        strtod(char*, char**);
        extern        long        strtol(char*, char**, int);
        extern        ulong        strtoul(char*, char**, int);
        extern        vlong        strtoll(char*, char**, int);
        extern        uvlong        strtoull(char*, char**, int);
         */
        extern        void        sysfatal(char*, ...);
       -extern        void        p9syslog(int, char*, char*, ...);
        extern        long        p9time(long*);
        /* extern        int        tolower(int); <ctype.h> */
        /* extern        int        toupper(int); <ctype.h> */
       t@@ -426,9 +421,10 @@ extern        void        needstack(int);
        #define putenv                p9putenv
        #define notejmp                p9notejmp
        #define jmp_buf                p9jmp_buf
       -#define syslog                p9syslog
        #define time                p9time
        #define pow10                p9pow10
       +#define strtod                fmtstrtod
       +#define charstod        fmtcharstod
        #endif
        
        /*
       t@@ -527,7 +523,6 @@ extern        int        p9announce(char*, char*);
        extern        int        p9dial(char*, char*, char*, int*);
        extern        int        p9dialparse(char *ds, char **net, char **unixa, u32int *ip, int *port);
        extern        void        p9setnetmtpt(char*, int, char*);
       -extern        int        p9hangup(int);
        extern        int        p9listen(char*, char*);
        extern        char*        p9netmkaddr(char*, char*, char*);
        extern        int        p9reject(int, char*, char*);
       t@@ -537,7 +532,6 @@ extern        int        p9reject(int, char*, char*);
        #define        announce        p9announce
        #define        dial                p9dial
        #define        setnetmtpt        p9setnetmtpt
       -#define        hangup                p9hangup
        #define        listen                p9listen
        #define        netmkaddr        p9netmkaddr
        #define        reject                p9reject
       t@@ -614,6 +608,7 @@ extern        void                freenetconninfo(NetConnInfo*);
        #define QTEXCL                0x20                /* type bit for exclusive use files */
        #define QTMOUNT                0x10                /* type bit for mounted channel */
        #define QTAUTH                0x08                /* type bit for authentication file */
       +#define QTLINK                0x04                /* symbolic link */
        #define QTFILE                0x00                /* plain file */
        
        /* bits in Dir.mode */
       t@@ -622,6 +617,7 @@ extern        void                freenetconninfo(NetConnInfo*);
        #define DMEXCL                0x20000000        /* mode bit for exclusive use files */
        #define DMMOUNT                0x10000000        /* mode bit for mounted channel */
        #define DMAUTH                0x08000000        /* mode bit for authentication file */
       +#define DMLINK                0x04000000        /* mode bit for symbolic link */
        #define DMREAD                0x4                /* mode bit for read permission */
        #define DMWRITE                0x2                /* mode bit for write permission */
        #define DMEXEC                0x1                /* mode bit for execute permission */
 (DIR) diff --git a/include/thread.h b/include/thread.h
       t@@ -35,11 +35,6 @@ void        threaddaemonize(void);
         */
        
        /*
       - * clumsy linker hack
       - */
       -void        threadlinklibrary(void);
       -
       -/*
         * per proc and thread data
         */
        void                **procdata(void);
 (DIR) diff --git a/lib/fortunes b/lib/fortunes
       t@@ -4005,3 +4005,41 @@ object-oriented design is the roman numerals of computing.  - rob
        Java is the f*cking COBOL of the 90s, and future generations of geeks are going to fly back from Mars to piss on our graves for inflicting it on them.  - rasputnik@hellooperator.net
        httpd_server* httpd_initialize(char* hostname, httpd_sockaddr* sa4P, httpd_sockaddr* sa6P, unsigned short port, char* cgi_pattern, int cgi_limit, char* charset, char* p3p, int max_age, char* cwd, int no_log, FILE* logfp, int no_symlink_check, int vhost, int global_passwd, char* url_pattern, char* local_pattern, int no_empty_referers )
        it's easier to post to 9fans than to think. - boyd
       +We assume familiarity with Rubik's Cube, the delights of which cannot be presented adequately in a textual description!  - an algorithms textbook
       +If you are idle for more than 1000 hours, the system will log you out.  Please save reviews frequently.
       +We lead by following standards. - sape
       +-bash: /home/r/.bash_logout: Permission denied
       +I am he as you are he as you are me and we are all together. - forsyth after Lennon on authentication
       +Network services at the Murray Hill, NJ, location (100001) will be unavailable due to UPS (Uninterrupted Power Supply) maintenance from 8:00 p.m. EDT on Saturday, June 26, to 4:00 a.m. EDT on Sunday, June 27.
       +Don't show this message again.
       +Service error -27.
       +Beauty is more important in computing than anywhere else in technology because software is so complicated. Beauty is the ultimate defence against complexity. - David Gelernter
       +Zatoichi: in theaters December 31, 1969.
       +recordio.h:992: type `__true_type' is not a base type for type `__false_type'
       +Telephone number has to be 10 numbers.  For example, enter '8002158482'.  Please contact us at 1-800-215-8482 for any assitance.
       +No one but a theorist believes his theory; everyone puts faith in a laboratory result but the experimenter himself.  - Einstein
       +(Okay, Plan 9 isn't Linux, but it's a close relative).
       +Tux is not cute.  Tux has the expression of someone right after knitting needles have been used to scramble the front side of their cerebral cortex.  Tux scares me.  - Ron Minnich
       +Setting up your SIP account will allow you to call both other SIP users as well as pstn phones. - Wim Sweldens
       +ntifs.c(202) : error C2064: term does not evaluate to a function taking 25732904 arguments
       +There's no "I" in team, but there's both a "me" and an "I" in media.
       +Oh, I'm sorry, sir, go ahead.  I didn't realize you were root.
       +C++ is to C as lung cancer is to lung.
       +Warning: bad syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
       +Those days [of "one tool doing one job well"] are dead and gone and the eulogy was delivered by Perl.  - rob
       +We have found that the Real Player plugin, which is used by the BBC Radio Player, may or may not function fully depending on a combination of what flavour of unix/linux you are using, which browser you are using, which version of browser you are using, and which version of GCC built the plugin during installation.
       +Sheer [program] size is often an illusion, reflecting only a need for improvement.  - Kernighan and Plauger
       +bootsplash: silent mode.
       +Trusting every aspect of our lives to a giant computer was the smartest thing we ever did!  - Homer
       +Courts are not equipped to execute the law. - John Ashcroft
       +The Ken Thompson school of thought on expert systems: there's table lookup, fraud, and grand fraud. - Andrew Hume, quoted in ;login:
       +I am Davros, my Daleks are my servers and plan9 is my control board mwahahaha - Matt
       +What's grey?  A melted penguin.
       +Why don't cannibals eat clowns?  Because they taste funny.
       +Two goldfish are in a tank.  One turns to the other and says, "Do you know how to drive one of these things?"
       +What do software pirates say?  CD-Arrrrrrr!
       +Select only drivers expected to compile cleanly. - Linux kernel configuration option
       +usage: tar [-][{ruxXtcC}acdefhlm{o|S}pqvwLUBDRV{O|K}fb] [dir] [tapefile] [blocksize] file ...
       +/opt/exp/lib/firefox/bin/run-mozilla.sh: line 451: 16207 Segmentation fault      "$prog" ${1+"$@"}
       +LoadPlugin: failed to initialize shared library /opt/net/exp/lib/mozilla/bin/plugins/j2re1.4.2/plugin/i386/ns610-gcc32/libjavaplugin_oji.so [/opt/net/exp/lib/mozilla/bin/plugins/j2re1.4.2/plugin/i386/ns610-gcc32/libjavaplugin_oji.so: undefined symbol: _ZdlPv]
       +This 43 minute video FEATURES the 22 year-old, 6'6" (6'11" in heels) 300+ pound, size 14 shoe size Blythe
 (DIR) diff --git a/lib/moveplan9.files b/lib/moveplan9.files
       t@@ -5,5 +5,6 @@ bin/Getdir
        bin/adict
        bin/doctype
        bin/lookman
       +bin/sig
        bin/spell
        bin/src
 (DIR) diff --git a/man/fonts b/man/fonts
       t@@ -0,0 +1,10 @@
       +# mkfile rules to get fonts in Lucida Sans.
       +# if you want to use Times, change these next lines to
       +# MAN=mantimes
       +# FONTS=''
       +MAN=man
       +FONTS='.fp 1 R LucidaSans
       +.fp 2 I LucidaSansI
       +.fp 3 B LucidaSansB
       +.fp 5 L LucidaCW
       +'
 (DIR) diff --git a/man/man1/0intro.1 b/man/man1/0intro.1
       t@@ -0,0 +1,300 @@
       +.TH INTRO 1
       +.SH NAME
       +intro \- introduction to Plan 9 from User Space
       +.SH 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
       +.B http://plan9.bell-labs.com/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.
       +.PP
       +Plan 9 from User Space provides many of the ideas,
       +applications, and services from Plan 9
       +on Unix-like systems.
       +It runs on
       +FreeBSD (x86),
       +Linux (x86 and PowerPC),
       +Mac OS X (PowerPC),
       +OpenBSD (x86),
       +and
       +SunOS (Sparc).
       +.SS Commands
       +Plan 9 from User Space expects its own directory tree,
       +conventionally
       +.BR /usr/local/plan9 .
       +When programs need to access files in the tree,
       +they expect the
       +.B $PLAN9
       +environment variable 
       +to contain the name of the root of the tree.
       +See
       +.IR install (8)
       +for details about installation.
       +.PP
       +Many of the familiar Unix commands,
       +for example
       +.IR cat (1),
       +.IR ls (1),
       +and
       +.IR wc (1),
       +are present, but in their Plan 9 forms:
       +.I cat
       +takes no arguments,
       +.I ls
       +does not columnate its output when printing to a terminal,
       +and
       +.I wc
       +counts UTF characters.
       +In some cases, the differences are quite noticeable:
       +.IR grep (1)
       +and
       +.IR sed (1)
       +expect Plan 9 regular expressions
       +(see
       +.IR 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
       +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)
       +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)
       +now allows mkfiles to choose their own shell,
       +and
       +.IR rc (1)
       +has a
       +.I ulimit
       +builtin and manages
       +.BR $PATH .
       +.PP
       +Many of the graphical programs from Plan 9 are present,
       +including
       +.IR sam (1)
       +and
       +.IR acme (1).
       +An X11 window manager
       +.IR rio (1)
       +mimics Plan 9's window system, with command windows
       +implemented by the external program
       +.IR 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
       +.B -W
       +option to specify the size and placement of the new window.
       +The argument is one of
       +\fIwidth\^\^\fLx\fI\^\^height\fR,
       +\fIwidth\^\^\fLx\fI\^\^height\^\^\fL@\fI\^\^xmin\fL,\fIxmax\fR,
       +\fL'\fIxmin ymin xmax ymax\fL'\fR,
       +\fRor
       +\fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR.
       +.PP
       +The
       +.IR plumber (4)
       +helps to connect the various Plan 9 programs together,
       +and fittings like
       +.IR web (1)
       +connect it to external programs such as web browsers;
       +one can click on a URL in
       +.I acme
       +and see the page load in
       +.IR Firefox .
       +.SS 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.
       +.PP
       +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)
       +library.
       +.IR 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)
       +client can be used in shell scripts or by hand to carry out
       +simple interactions with servers.
       +.SS Programming
       +The shell scripts
       +.I 9c
       +and
       +.I 9l
       +(see
       +.IR 9c (1))
       +provide a simple interface to the underlying system compiler and linker,
       +similar to the 
       +.I 2c
       +and
       +.I 2l
       +families on Plan 9.
       +.I 9c
       +compiles source files, and
       +.I 9l
       +links object files into executables.
       +When using Plan 9 libraries,
       +.I 9l
       +infers the correct set of libraries from the object files,
       +so that no
       +.B -l
       +options are needed.
       +.PP
       +The only way to write multithreaded programs is to use the
       +.IR thread (3)
       +library.
       +.IR 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)
       +for details.
       +.PP
       +The debuggers
       +.IR acid (1)
       +and
       +.IR db (1)
       +and the debugging library
       +.IR 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 PowerPC support
       +exists; and other targets are unimplemented.
       +The debuggers can only inspect, not manipulate, target processes.
       +Support for operating system threads and for 64-bit architectures
       +needs to be rethought.
       +On x86 Linux systems,
       +.I acid
       +and
       +.I db
       +can be relied upon to produce reasonable stack traces
       +(often in cases when GNU
       +.I gdb
       +cannot)
       +and dump data structures,
       +but that it is the extent to which they have been developed and exercised.
       +.SS External databases
       +Some programs rely on large databases that would be
       +cumbersome to include in every release.
       +Scripts are provided that download these databases separately.
       +These databases can be downloaded separately.  
       +See
       +.B $PLAN9/dict/README
       +and
       +.BR $PLAN9/sky/README .
       +.SS Porting programs
       +The vast majority of the familiar Plan 9 programs 
       +have been ported, including the Unicode-aware
       +.IR troff (1).
       +.PP
       +Of the more recent additions to Plan 9,
       +the
       +.IR secstore (1)
       +client has been ported, though
       +.I secstored
       +has not.
       +.IR Vac (1)
       +has been ported, though
       +.I vacfs
       +has not.
       +.IR Factotum
       +and
       +.IR venti
       +are in progress.
       +.PP
       +A backup system providing a dump file system built atop Venti
       +is also in progress.
       +.SS 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
       +.BR <u.h> ,
       +which must include the right system files and
       +set up the right integer type definitions,
       +and
       +.IR libthread ,
       +which must implement spin locks, operating system thread
       +creation, and context switching routines.
       +Portable implementations of these using 
       +.B <pthread.h>
       +and
       +.B <ucontext.h>
       +already exist.  If your system supports them, you may not
       +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)
       +and the implementation of
       +.IR getcallerpc (3),
       +but these are usually simple and are not on the critical
       +path for getting the system up and running.
       +.SS SEE ALSO
       +The system's documentation is these manual pages.
       +Many of the man pages have been brought from Plan 9,
       +but they have been updated, and others have been written from scratch.
       +.PP
       +The manual pages are in a Unix style tree, with names like
       +.B $PLAN9/man/man1/cat.1
       +instead of Plan 9's simpler
       +.BR  $PLAN9/man/1/cat ,
       +so that the Unix
       +.IR man (1)
       +utility can handle it.
       +Some systems, for example Debian Linux,
       +deduce the man page locations from the search path, so that
       +adding 
       +.B $PLAN9/bin
       +to your path is sufficient to cause
       +.B $PLAN9/man
       +to be consulted for manual pages using the system
       +.IR man .
       +On other systems, or to look at manual pages with the
       +same name as a system page,
       +invoke the Plan 9
       +.I man
       +directly, as in
       +.B 9
       +.B man
       +.BR cat .
       +.PP
       +The manual sections follow the Unix numbering conventions,
       +not the Plan 9 ones.
       +.PP
       +Section (1) describes general publicly accessible commands.
       +.PP
       +Section (3) describes C library functions.
       +.PP
       +Section (4) describes user-level file servers.
       +.PP
       +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.)
       +.PP
       +Section (8) describes commands used for system administration.
       +.PP
       +Section (9p) describes the Plan 9 file protocol 9P.
       +.SH 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
       +.IR exits (3).
 (DIR) diff --git a/man/man1/9c.1 b/man/man1/9c.1
       t@@ -3,6 +3,14 @@
        9c, 9a, 9l, 9ar \- C compiler, assembler, linker, archiver
        .SH SYNOPSIS
        .B 9c
       +[
       +.B -I
       +.I path
       +]
       +[
       +.B -D
       +.I name
       +]
        .I file
        \&...
        .PP
       t@@ -26,7 +34,7 @@
        \&...
        ]
        [
       -.BI -l library
       +.BI -l name
        \&...
        ]
        .PP
       t@@ -49,12 +57,24 @@ One can use them to write portable recipes for mkfiles.
        compiles the named C
        .I files
        into object files for the current system.
       -The system C compiler is invoked with warnings enabled,
       -with the symbol
       +The system C compiler is invoked with warnings enabled.
       +The
       +.B -I
       +option adds
       +.I path
       +to the include path,
       +and the
       +.B -D
       +option defines
       +.I name
       +in the C preprocessor.
       +.I 9c
       +always
       +defines the symbol
        .B PLAN9PORT
       -is defined in the C preprocessor, and with
       +defined in the C preprocessor and adds
        .B $PLAN9/include
       -on the include path.
       +to the include path.
        .PP
        .I 9c
        also defines
       t@@ -74,7 +94,7 @@ links the named object files and libraries to create the target executable.
        Each
        .B -l
        option specifies that a library named
       -.BI lib library .a
       +.BI lib name .a
        be found and linked.
        The
        .B -L
       t@@ -84,6 +104,30 @@ invokes the system linker with
        .B $PLAN9/lib
        already on the library search path.
        .PP
       +.I 9l
       +searches the named objects and libraries for symbols of the form
       +.BI __p9l_autolib_ name \fR,
       +which it takes as indication that it should link
       +.BI $PLAN9/lib/lib name .a
       +as well.
       +It also examines such libraries to find their own dependencies.
       +A single
       +.B -l
       +option at the beginning of the command line disables this behavior.
       +The symbol
       +.BI __p9l_autolib_ name
       +is added to an object file by the macro
       +.B AUTOLIB( name )\fR,
       +defined in
       +.B <u.h>.
       +Header files associated with libraries contain
       +.B AUTOLIB
       +annotations; ordinary programs need not use them.
       +Due to shortcomings in the implementation, a source file may not
       +contain the same
       +.B AUTOLIB
       +statement multiple times.
       +.PP
        .I 9ar
        maintains object file archives called libraries.
        The exact set of valid command keys varies from system to system,
       t@@ -154,7 +198,7 @@ inserts a table of contents, required by the linker, at
        the front of the library.
        The table of contents is
        rebuilt whenever the archive is modified.
       -.SH EXAMPLE
       +.SH EXAMPLES
        .TP
        .L
        9c file1.c file2.c file3.c
       t@@ -167,6 +211,7 @@ Assemble one assembler source file.
        .L
        9ar rvc lib.a file[12].o
        Archive the first two object files into a library.
       +.TP
        .L
        9l -o prog file3.o file4.o lib.a
        Link the final two object files and any necessary objects from the library
 (DIR) diff --git a/man/man1/9p.1 b/man/man1/9p.1
       t@@ -110,9 +110,7 @@ cat $HOME/lib/plumbing | 9p write plumb/rules
        .PP
        To display the contents of the current
        .IR acme (4)
       -window (specified by the environment variable
       -.BR $winid )
       -on standard output:
       +window:
        .IP
        .EX
        9p read acme/$winid/body
 (DIR) diff --git a/man/man1/9term.1 b/man/man1/9term.1
       t@@ -1,6 +1,6 @@
        .TH 9TERM 1
        .SH NAME
       -9term, label \- terminal windows
       +9term \- terminal windows
        .SH SYNOPSIS
        .B 9term
        [
       t@@ -14,14 +14,11 @@
        .I cmd
        \&...
        ]
       -.PP
       -.B label
       -.I name
        .SH DESCRIPTION
        .I 9term
        is a terminal window program for the X Window System,
        providing an interface similar to that used on Plan 9.
       -.SS Commands
       +.SS Command
        The
        .I 9term
        command starts a new window.
       t@@ -59,15 +56,6 @@ if set; otherwise it uses the graphics system default.
        runs the given command in the window, or 
        .B $SHELL
        if no command is given.
       -.PP
       -The
       -.I label
       -command changes a window's identifying name by
       -echoing a special control code that both
       -.I 9term
       -and
       -.IR xterm (1)
       -understand.
        .SS Text windows
        Characters typed on the keyboard
        collect in the window to form
       t@@ -152,7 +140,7 @@ An EOT character (control-D) behaves exactly like newline except
        that it is not delivered to a program when read.
        Thus on an empty line an EOT serves to deliver an end-of-file indication:
        the read will return zero characters.
       -Like newlines, unread EOTs may be successfully edited out of the text.
       +.\" Like newlines, unread EOTs may be successfully edited out of the text.
        The BS character (control-H) erases the character before the selected text.
        The ETB character (control-W) erases any nonalphanumeric characters, then
        the alphanumeric word just before the selected text.
       t@@ -202,6 +190,10 @@ before (after) the current selection.
        relies on the kernel's terminal processing to handle
        EOT and DEL, so the terminal must be set up with EOT
        as the ``eof'' character and DEL as the ``intr'' character.
       +.I 9term
       +runs
       +.IR stty (1)
       +to establish this when the terminal is created.
        .PP
        Normally, written output to a window blocks when
        the text reaches the end of the screen and the terminal
       t@@ -214,7 +206,7 @@ the terminal settings of the running programs.
        Most programs run with echo enabled.
        In this mode,
        .I 9term
       -display and allows editing of the input.
       +displays and allows editing of the input.
        Some programs, typically those reading passwords,
        run with echo disabled.
        In this mode,
       t@@ -279,9 +271,23 @@ 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
        by plumbing the file and line information in a compiler's diagnostic.
       +.PP
       +Each
       +.I 9term
       +listens for connections on a Unix socket.
       +When a client connects, the 
       +.I 9term
       +writes the window contents to the client and then hangs up.
       +.I 9term
       +installs the name of this socket in the environment as
       +.B $text9term
       +before running
       +.IR cmd .
        .SH SOURCE
        .B \*9/src/cmd/9term
        .SH BUGS
        There should be a program to toggle the current window's hold mode.
        .PP
        Unix makes everything harder.
       +.SH SEE ALSO
       +.IR wintext (1)
 (DIR) diff --git a/man/man1/INDEX b/man/man1/INDEX
       t@@ -1,10 +1,12 @@
       +0intro 0intro.1
       +intro 0intro.1
       +9 9.1
        9a 9c.1
        9ar 9c.1
        9c 9c.1
        9l 9c.1
        9p 9p.1
        9term 9term.1
       -label 9term.1
        acid acid.1
        acidtypes acid.1
        acme acme.1
       t@@ -27,13 +29,12 @@ cleanname cleanname.1
        auxclog clog.1
        clog clog.1
        cmp cmp.1
       +cmapcube colors.1
        colors colors.1
       -getmap colors.1
        comm comm.1
        core core.1
        crop crop.1
        iconv crop.1
       -clock date.1
        date date.1
        db db.1
        dc dc.1
       t@@ -93,6 +94,7 @@ lc ls.1
        ls ls.1
        lookman man.1
        man man.1
       +sig man.1
        map map.1
        mapd map.1
        mapdemo map.1
       t@@ -142,7 +144,6 @@ scat scat.1
        aescbc secstore.1
        ipso secstore.1
        secstore secstore.1
       -9sed sed.1
        sed sed.1
        seq seq.1
        sleep sleep.1
 (DIR) diff --git a/man/man1/acid.1 b/man/man1/acid.1
       t@@ -4,7 +4,7 @@ acid, acidtypes \- debugger
        .SH SYNOPSIS
        .B acid
        [
       -.BI -l " libfile
       +.BI -l " library
        ]
        [
        .B -wq
       t@@ -49,7 +49,7 @@ 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 
       -.RB ( 8.out
       +.RB ( a.out
        by default).
        At the prompt,
        .I acid
       t@@ -514,13 +514,13 @@ for processes that are still active.
        .SH BUGS
        There is no way to redirect the standard input and standard output
        of a new process.
       -.br
       +.PP
        Source line selection near the beginning of a file may pick
        an adjacent file.
       -.br
       +.PP
        With the extant stepping commands, one cannot step through instructions
        outside the text segment and it is hard to debug across process forks.
       -.br
       +.PP
        Breakpoints do not work yet.
        Therefore, commands such as
        .BR step ,
 (DIR) diff --git a/man/man1/acme.1 b/man/man1/acme.1
       t@@ -71,7 +71,7 @@ The
        .RB ( -F )
        option sets the main font, usually variable-pitch (alternate, usually fixed-pitch);
        the default is
       -.B /lib/font/bit/lucidasans/euro.8.font
       +.B /usr/local/plan9/font/lucidasans/euro.8.font
        .RB ( \&.../lucm/unicode.9.font ).
        Tab intervals are set to the width of 4 (or the value of
        .BR $tabstop )
       t@@ -140,7 +140,7 @@ temporarily hiding other windows in the column.
        if any of them needs attention.)
        The layout box in a window is normally white; when it is black in the center,
        it records that the file is `dirty':
       -.I Acme
       +.I acme
        believes it is modified from its original
        contents.
        .PP
       t@@ -455,26 +455,31 @@ 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
        necessary.
        For example, in a window
       -.B /adm/users
       +.B /etc/passwd
        executing
        .B pwd
        will produce the output
       -.B /adm
       +.B /etc
        in a (possibly newly-created) window labeled
       -.BR /adm/+Errors ;
       +.BR /etc/+Errors ;
        in a window containing
       -.B \*9/src/cmd/sam/sam.c
       +.B /home/rob/sam/sam.c
        executing
        .B mk
        will run
        .IR mk (1)
        in
       -.BR \*9/src/cmd/sam ,
       +.BR /home/rob/sam ,
        producing output in a window labeled
       -.BR \*9/src/cmd/sam/+Errors .
       +.BR /home/rob/sam/+Errors .
        The environment of such commands contains the variable
        .B $%
       -with value set to the filename of the window in which the command is run.
       +with value set to the filename of the window in which the command is run,
       +and
       +.B $winid
       +set to the window's id number
       +(see
       +.IR acme (4)).
        .SS "Mouse button 3
        Pointing at text with button 3 instructs
        .I acme
       t@@ -586,7 +591,7 @@ creates a new
        window and runs a
        .I command
        (default
       -.BR /bin/rc )
       +.BR $SHELL )
        in it, turning the window into something analogous to an
        .IR rio (1)
        window.
 (DIR) diff --git a/man/man1/acmeevent.1 b/man/man1/acmeevent.1
       t@@ -132,32 +132,92 @@ and
        a button 2 action in the tag
        .RB ( x ).
        .TP
       -.I q0
       -
       +.I q0\fR, \fPq1
       +The character addresses of the action.
        .TP
       +.I eq0\fR, \fPq1
       +The expanded character addresses of the action.
       +If the text indicated by
       +.IR q0 ,
        .I q1
       -
       -.TP
       -.I eq0
       -
       -.TP
       +is a null string that has a non-null expansion,
       +.IR eq0 ,
        .I eq1
       -
       +are the addresses of the expansion.
       +Otherwise they are the same as
       +.IR q0 ,
       +.IR q1 .
        .TP
        .I flag
       -
       +.I Flag
       +is a bitwise OR (reported decimally) of the following:
       +1 if the text indicated is recognized as an
       +.I acme
       +built-in command;
       +2 if the text indicated is a null string that has a non-null expansion
       +(see
       +.IR eq0 ,
       +.I eq1
       +above);
       +8 if the command has an extra (chorded) argument
       +(see
       +.I chordarg
       +below).
       +.I Flag
       +remains from the
       +.IR acme (4)
       +event format.
       +Because
       +.IR eq0 ,
       +.IR eq1 ,
       +and
       +.I chordarg
       +are explicit in each event
       +(unlike in
       +.IR acme (4)
       +events),
       +.I flag
       +can usually be ignored.
        .TP
        .I textlen
       -
       +The length of the action text (or its expansion) for button 2 and button 3 events in characters.
        .TP
        .I text
       -
       +If
       +.I textlen
       +is less than 256 chracters,
       +.I text
       +is the action text itself.
       +Otherwise it is an empty string and must be read from the
       +.B data
       +file.
        .TP
        .I chordarg
       -
       +The chorded argument for an action.
        .TP
        .I chordorigin
       -
       +If the chord argument is in the body of a named window,
       +.I chordorigin
       +specifies the full address of the argument,
       +as in
       +.BR /etc/group:#123,#234 .
       +.PD
       +.PP
       +To experiment with
       +.IR acmeevent ,
       +create an empty window in
       +.I acme
       +(using
       +.IR New ), type
       +.IP
       +.EX
       +9p read acme/$winid/event | acmeevent
       +.EE
       +.LP
       +inside it, and execute it.
       +Actions performed on the window will be printed as events in the
       +.B +Errors
       +window.
        .PP
        .I Acme.rc
        is a library of
 (DIR) diff --git a/man/man1/ascii.1 b/man/man1/ascii.1
       t@@ -39,7 +39,7 @@ ascii, unicode \- interpret ASCII, Unicode characters
        .PP
        .B look
        .I hex
       -.B /lib/unicode
       +.B \*9/lib/unicode
        .SH DESCRIPTION
        .I Ascii
        prints the
       t@@ -122,7 +122,7 @@ and
        may be unhelpful if the characters printed are not available in the current font.
        .PP
        The file
       -.B /lib/unicode
       +.B \*9/lib/unicode
        contains a
        table of characters and descriptions, sorted in hexadecimal order,
        suitable for
       t@@ -143,19 +143,18 @@ Print the hex value of `p'.
        .B "unicode 2200-22f1"
        Print a table of miscellaneous mathematical symbols.
        .TP
       -.B "look 039 /lib/unicode"
       +.B "look 039 \*9/lib/unicode"
        See the start of the Greek alphabet's encoding in the Unicode Standard.
        .SH FILES
       -.TF /lib/unicode
        .TP
       -.B /lib/unicode
       +.B \*9/lib/unicode
        table of characters and descriptions.
        .SH SOURCE
        .B \*9/src/cmd/ascii.c
        .br
        .B \*9/src/cmd/unicode.c
        .SH "SEE ALSO"
       -.IR look (1)
       +.IR look (1),
        .IR tcs (1),
        .IR utf (7),
        .IR font (7)
 (DIR) diff --git a/man/man1/astro.1 b/man/man1/astro.1
       t@@ -35,7 +35,7 @@ A prompt gives the input format.
        If
        .B l
        is missing, the initial position is read from the file
       -.BR /lib/sky/here .
       +.BR \*9/sky/here .
        .TP
        .B c
        Report for
       t@@ -105,12 +105,11 @@ This is modified (in the source) to refer to an approaching comet
        but in steady state
        usually refers to the last interesting comet (currently Hale-Bopp, C/1995 O1).
        .SH FILES
       -.TF /lib/sky/estartab
        .TP
       -.B /lib/sky/estartab
       +.B \*9/sky/estartab
        ecliptic star data
        .TP
       -.B /lib/sky/here
       +.B \*9/sky/here
        default latitude (N), longitude (W), and elevation (meters)
        .SH SOURCE
        .B \*9/src/cmd/astro
 (DIR) diff --git a/man/man1/bc.1 b/man/man1/bc.1
       t@@ -267,7 +267,7 @@ define e(x) {
        for(i=1; i<=10; i++) print e(i)
        .EE
        .SH FILES
       -.B /sys/lib/bclib
       +.B \*9/lib/bclib
        mathematical library
        .SH SOURCE
        .B \*9/src/cmd/bc.y
       t@@ -281,12 +281,12 @@ No
        or
        .L !
        operators.
       -.br
       +.PP
        A
        .L for
        statement must have all three
        .LR E s.
       -.br
       +.PP
        A
        .L quit
        is interpreted when read, not when executed.
 (DIR) diff --git a/man/man1/bundle.1 b/man/man1/bundle.1
       t@@ -41,7 +41,7 @@ say in
        then do
        .TP
        .L
       -cd gift; rc horse; mk
       +cd gift; sh horse; mk
        .SH SOURCE
        .B \*9/bin/bundle
        .SH SEE ALSO
       t@@ -53,5 +53,5 @@ cd gift; rc horse; mk
        .SH BUGS
        .I Bundle
        will not create directories and is unsatisfactory for non-text files.
       -.br
       +.PP
        Beware of gift horses.
 (DIR) diff --git a/man/man1/cal.1 b/man/man1/cal.1
       t@@ -39,7 +39,7 @@ Try
        .SH BUGS
        The year is always considered to start in January even though this
        is historically naive.
       -.br
       +.PP
        Beware that
        .L "cal 90"
        refers to the early Christian era,
 (DIR) diff --git a/man/man1/calendar.1 b/man/man1/calendar.1
       t@@ -15,7 +15,7 @@ calendar \- print upcoming events
        .SH DESCRIPTION
        .I Calendar
        reads the named files, default
       -.BR /usr/$user/lib/calendar ,
       +.BR $HOME/lib/calendar ,
        and writes to standard output any lines
        containing today's or tomorrow's date.
        Examples of recognized date formats are 
       t@@ -45,9 +45,9 @@ On Friday and Saturday, events through Monday are printed.
        To have your calendar mailed to you every day, use
        .IR cron (8).
        .SH FILES
       -.TF /usr/$user/lib/calendar
       +.TF $HOME/lib/calendar
        .TP
       -.B /usr/$user/lib/calendar
       +.B $HOME/lib/calendar
        personal calendar
        .SH SOURCE
        .B \*9/src/cmd/calendar.c
 (DIR) diff --git a/man/man1/cat.1 b/man/man1/cat.1
       t@@ -17,7 +17,7 @@ cat, read, nobs \- catenate files
        .I file ...
        ]
        .br
       -nobs
       +.B nobs
        [
        .I file ...
        ]
 (DIR) diff --git a/man/man1/colors.1 b/man/man1/colors.1
       t@@ -1,6 +1,6 @@
        .TH COLORS 1
        .SH NAME
       -getmap, colors \- display color map
       +colors, cmapcube \- display color map
        .SH SYNOPSIS
        .PP
        .B colors
       t@@ -9,16 +9,13 @@ getmap, colors \- display color map
        .B -x
        ]
        .PP
       -.B getmap
       +.B cmapcube
        [
       -.I colormap
       +.B -nbw
        ]
        .SH DESCRIPTION
        .I Colors
       -presents a grid showing the colors in the current color map.
       -If the display is true color,
       -.I colors
       -shows a grid of the RGBV color map
       +presents a grid showing the colors in the RGBV color map
        (see
        .IR color (7)).
        .PP
       t@@ -37,36 +34,22 @@ option instead shows, in the same form, a grey-scale ramp.
        .PP
        A menu on mouse button 3 contains a single entry, to exit the program.
        .PP
       -On 8-bit color-mapped displays,
       -.I getmap
       -loads the display's color map (default
       -.BR rgbv ).
       -The named
       -.I colormap
       -can be a file in the current directory or in the standard repository
       -.BR /lib/cmap .
       -It can also be a string of the form
       -.B gamma
       -or
       -.BI gamma N\f1 ,
       -where
       -.I N
       -is a floating point value for the gamma, defining the contrast for a monochrome map.
       -Similarly,
       -.B rgamma
       +.I Cmapcube
       +presents the same colors but in a 3-dimensional cube.
       +Dragging with button 1 rotates the cube.
       +Clicking on a color with button 2
       +displays the map index for that color.
       +Clicking button 3 exits.
       +.PP
       +The
       +.B -n
       +option disables drawing of the color squares.
       +The
       +.B -b
        and
       -.BI rgamma N
       -define a reverse-video monochrome map.
       -Finally, the names
       -.B screen
       -or
       -.B display
       -or
       -.B vga
       -are taken as synonyms for the current color map stored in the display hardware.
       -.SH FILES
       -.B /lib/cmap
       -directory of color map files
       +.B -w
       +options set the background (default grey)
       +to black or white.
        .SH SOURCE
        .B \*9/src/cmd/draw/colors.c
        .SH SEE ALSO
 (DIR) diff --git a/man/man1/core.1 b/man/man1/core.1
       t@@ -44,3 +44,6 @@ searches the current directory.
        .IR acid (1),
        .IR db (1),
        .IR core (5)
       +.SH BUGS
       +.I Core
       +has not been written.
 (DIR) diff --git a/man/man1/date.1 b/man/man1/date.1
       t@@ -1,6 +1,6 @@
        .TH DATE 1
        .SH NAME
       -date, clock \- date and time
       +date \- date and time
        .SH SYNOPSIS
        .B date
        [
 (DIR) diff --git a/man/man1/db.1 b/man/man1/db.1
       t@@ -912,14 +912,6 @@ To set a breakpoint at the beginning of
        .B write()
        in extant process 27:
        .IP
       -.de EX
       -.RS
       -.ft B
       -.nf
       -..
       -.de EE
       -.RE
       -..
        .EX
        % db 27
        :h
 (DIR) diff --git a/man/man1/dc.1 b/man/man1/dc.1
       t@@ -223,15 +223,15 @@ results are truncated to the following scales.
        \fLv\fR        max(\fIs,sa\fR)
        .fi
        .SH EXAMPLES
       +.LP
       +Print the first ten values of
       +.IR n !
       +.IP
        .EX
        [la1+dsa*pla10>y]sy
        0sa1
        lyx
        .EE
       -.ns
       -.IP
       -Print the first ten values of
       -.IR n !
        .SH SOURCE
        .B \*9/src/cmd/dc.c
        .SH "SEE ALSO"
 (DIR) diff --git a/man/man1/deroff.1 b/man/man1/deroff.1
       t@@ -112,6 +112,6 @@ when the popular
        delimiters for
        .I eqn
        are in effect. 
       -.br
       +.PP
        Text inside macros is emitted at place of
        definition, not place of call.
 (DIR) diff --git a/man/man1/dict.1 b/man/man1/dict.1
       t@@ -182,12 +182,10 @@ it starts with the
        .BI /adict/ dict /
        window.
        .SH FILES
       -.B /lib/dict/oed2
       -.br
       -.B /lib/dict/oed2index
       -.br
       -Other files in
       -.BR /lib .
       +.TP
       +.B \*9/dict
       +dictionaries
       +.PD
        .SH "SEE ALSO"
        .IR regexp (7)
        .SH SOURCE
 (DIR) diff --git a/man/man1/diff.1 b/man/man1/diff.1
       t@@ -148,7 +148,7 @@ Editing scripts produced under the
        .BR -e " or"
        .BR -f " option are naive about"
        creating lines consisting of a single `\fB.\fR'.
       -.br
       +.PP
        When running
        .I diff
        on directories, the notion of what is a text
 (DIR) diff --git a/man/man1/doctype.1 b/man/man1/doctype.1
       t@@ -4,8 +4,13 @@ doctype \- intuit command line for formatting a document
        .SH SYNOPSIS
        .B doctype
        [
       -.I option ...
       -] [
       +.B -n
       +]
       +[
       +.B -T
       +.I dev
       +]
       +[
        .I file
        ]
        \&...
       t@@ -32,7 +37,9 @@ invokes
        .I nroff
        instead of
        .IR troff .
       -Other options are passed to
       +The
       +.B -T
       +option is passed to
        .IR troff .
        .SH EXAMPLES
        .TP
 (DIR) diff --git a/man/man1/ed.1 b/man/man1/ed.1
       t@@ -49,7 +49,7 @@ commands.
        If no 
        .I file
        is given, make
       -.B /fd/1
       +.B /dev/stdout
        the remembered file; see the
        .L e
        command below.
 (DIR) diff --git a/man/man1/fortune.1 b/man/man1/fortune.1
       t@@ -13,11 +13,11 @@ If a
        .I file
        is specified, the saying is taken from that file;
        otherwise it is selected from
       -.BR /sys/games/lib/fortunes .
       +.BR \*9/lib/fortunes .
        .SH FILES
       -.B /sys/games/lib/fortunes
       +.B \*9/lib/fortunes
        .br
       -.B /sys/games/lib/fortunes.index
       +.B \*9/lib/fortunes.index
        \ \ fast lookup table, maintained automatically
        .SH SOURCE
        .B \*9/src/cmd/fortune.c
 (DIR) diff --git a/man/man1/grap.1 b/man/man1/grap.1
       t@@ -254,7 +254,7 @@ symbols like
        .BR star ,
        .BR plus ,
        etc., in
       -.BR /sys/lib/grap.defines ,
       +.BR \*9/lib/grap.defines ,
        which is included if it exists.
        .PP
        .I var
       t@@ -399,9 +399,9 @@ copy thru / circle at $1,$2 /
        .vs
        .EE
        .SH FILES
       -.TF /sys/lib/grap.defines
       +.TF \*9/lib/grap.defines
        .TP
       -.B /sys/lib/grap.defines
       +.B \*9/lib/grap.defines
        definitions of standard plotting characters, e.g., bullet
        .SH SOURCE
        .B \*9/src/cmd/grap
 (DIR) diff --git a/man/man1/grep.1 b/man/man1/grep.1
       t@@ -10,6 +10,7 @@ grep, g \- search a file for a pattern
        [
        .I file ...
        ]
       +.PP
        .B g
        [
        .I option ...
 (DIR) diff --git a/man/man1/idiff.1 b/man/man1/idiff.1
       t@@ -14,7 +14,8 @@ interactively
        merges 
        .I file1
        and 
       -.IR file2 .
       +.I file2
       +onto standard output.
        Wherever
        .I file1
        and
       t@@ -23,7 +24,8 @@ differ,
        .I idiff
        displays the differences in the style of
        .RB `` diff
       -.RB -n ''
       +.BR -n ''
       +on standard error
        and prompts the user to select a chunk.
        Valid responses are:
        .TP
       t@@ -54,9 +56,10 @@ The
        .B -b
        and
        .B -w
       -flags
       -are simply
       -passed through to
       +flags,
       +if passed,
       +are
       +passed to
        .IR diff .
        .SH FILES
        .B /tmp/idiff.*
       t@@ -68,5 +71,3 @@ passed through to
        Kernighan and Pike,
        .IR "The Unix Programming Environment" ,
        Prentice-Hall, 1984.
       -.SH BUGS
       -This is a poorly-written manual page.
 (DIR) diff --git a/man/man1/join.1 b/man/man1/join.1
       t@@ -143,5 +143,5 @@ with
        the sequence is that of
        .BI "sort -t" x
        .BI -k y , y\f1.
       -.br
       +.PP
        One of the files must be randomly accessible.
 (DIR) diff --git a/man/man1/kill.1 b/man/man1/kill.1
       t@@ -13,11 +13,6 @@ kill, slay, start, stop \- print commands to manipulate processes
        .PP
        .B stop
        .I name ...
       -.PP
       -.B broke
       -[
       -.I user
       -]
        .SH DESCRIPTION
        .I Kill
        prints commands that will cause all processes with 
       t@@ -67,3 +62,8 @@ signal.
        .SH "SEE ALSO"
        .IR ps (1),
        .IR notify (3)
       +.SH BUGS
       +.I Stop
       +and
       +.I start
       +should limit themselves to currently running or stopped processes.
 (DIR) diff --git a/man/man1/lex.1 b/man/man1/lex.1
       t@@ -77,5 +77,5 @@ Tenth Edition, Volume 2.
        .SH BUGS
        Cannot handle
        .SM UTF.
       -.br
       +.PP
        The asteroid to kill this dinosaur is still in orbit.
 (DIR) diff --git a/man/man1/look.1 b/man/man1/look.1
       t@@ -77,10 +77,9 @@ is assumed, with collating sequence
        .IR grep (1)
        .SH DIAGNOSTICS
        The exit status is
       -.B \&"not found"
       +.RB `` "not found" ''
        if no match is found, and
       -.B \&"no dictionary"
       +.RB `` "no dictionary" ''
        if
        .I file
        or the default dictionary cannot be opened.
       -
 (DIR) diff --git a/man/man1/ls.1 b/man/man1/ls.1
       t@@ -157,6 +157,5 @@ if none of the above permissions is granted.
        .br
        .B \*9/bin/lc
        .SH SEE ALSO
       -.IR stat (3)
       +.IR stat (3),
        .IR mc (1)
       -
 (DIR) diff --git a/man/man1/man.1 b/man/man1/man.1
       t@@ -1,6 +1,6 @@
        .TH MAN 1
        .SH NAME
       -man, lookman \- print or find pages of this manual
       +man, lookman, sig \- print or find pages of this manual
        .SH SYNOPSIS
        .B man
        [
       t@@ -88,17 +88,20 @@ command to make an index for a given section
        index for
        .I lookman
        .SH SOURCE
       -.B \*9/bin/9man
       +.B \*9/bin/man
        .br
        .B \*9/bin/lookman
        .SH "SEE ALSO"
       +.IR page (1),
        .IR proof (1)
        .SH BUGS
        The manual was intended to be typeset; some detail is sacrificed on text terminals.
        .PP
        There is no automatic mechanism to keep the indices up to date.
        .PP
       -Except for special cases, it doesn't recognize things that should be run through
       +Except for special cases,
       +.I man
       +doesn't recognize things that should be run through
        .I tbl
        and/or
        .IR eqn .
 (DIR) diff --git a/man/man1/map.1 b/man/man1/map.1
       t@@ -634,7 +634,7 @@ maps for
        .B /lib/map/*.x
        map indexes
        .TP
       -.B /bin/aux/mapd
       +.B mapd
        Map driver program
        .SH SOURCE
        .B \*9/src/cmd/map
 (DIR) diff --git a/man/man1/mk.1 b/man/man1/mk.1
       t@@ -1,21 +1,4 @@
        .TH MK 1
       -.de EX
       -.nf
       -.ft B
       -..
       -.de EE
       -.fi
       -.ft R
       -..
       -.de LR
       -.if t .BR \\$1 \\$2
       -.if n .RB ` \\$1 '\\$2
       -..
       -.de L
       -.nh
       -.if t .B \\$1
       -.if n .RB ` \\$1 '
       -..
        .SH NAME
        mk, membername \- maintain (make) related files
        .SH SYNOPSIS
       t@@ -313,6 +296,7 @@ and any command line assignment as an argument to
        .IR mk .
        A variable assignment argument overrides the first (but not any subsequent)
        assignment to that variable.
       +.PP
        The variable
        .B MKFLAGS
        contains all the option arguments (arguments starting with
       t@@ -324,6 +308,45 @@ and
        contains all the targets in the call to
        .IR mk .
        .PP
       +The variable
       +.B MKSHELL
       +contains the shell command line
       +.I mk
       +uses to run recipes.
       +If the first word of the command ends in
       +.B rc
       +or
       +.BR rcsh ,
       +.I mk
       +uses
       +.IR rc (1)'s
       +quoting rules; otherwise it uses
       +.IR sh (1)'s.
       +The
       +.B MKSHELL
       +variable is consulted when the mkfile is read, not when it is executed,
       +so that different shells can be used within a single mkfile:
       +.IP
       +.EX
       +MKSHELL=$PLAN9/bin/rc
       +use-rc:V:
       +        for(i in a b c) echo $i
       +
       +MKSHELL=sh
       +use-sh:V:
       +        for i in a b c; do echo $i; done
       +.EE
       +.LP
       +Mkfiles included via
       +.B <
       +or
       +.B <|
       +.RI ( q.v. )
       +see their own private copy of
       +.BR MKSHELL ,
       +which always starts set to
       +.B sh .
       +.PP
        Dynamic information may be included in the mkfile by using a line of the form
        .IP
        \fR<|\fIcommand\fR \fIargs\fR
       t@@ -510,6 +533,7 @@ archives.
        .I Membername
        echoes just the member names of a list of aggregate names.
        It is useful in recipes like:
       +.IP
        .EX
        OFILES=a.o b.o
        libc.a(%):N: %
       t@@ -647,7 +671,7 @@ x.tab.h:Pcmp -s:        y.tab.h
        .EE
        .SH SEE ALSO
        .IR sh (1),
       -.IR regexp9 (7)
       +.IR regexp (7)
        .PP
        A. Hume,
        ``Mk: a Successor to Make''
       t@@ -664,19 +688,18 @@ It was later ported to Plan 9.
        This software is a port of the Plan 9 version back to Unix.
        .SH BUGS
        Identical recipes for regular expression meta-rules only have one target.
       -.br
       +.PP
        Seemingly appropriate input like
        .B CFLAGS=-DHZ=60
        is parsed as an erroneous attribute; correct it by inserting
        a space after the first 
        .LR = .
       -.br
       +.PP
        The recipes printed by
        .I mk
        before being passed to
       -.I sh
       +the shell
        for execution are sometimes erroneously expanded
        for printing.  Don't trust what's printed; rely
       -on what
       -.I sh
       +on what the shell
        does.
 (DIR) diff --git a/man/man1/namespace.1 b/man/man1/namespace.1
       t@@ -11,4 +11,5 @@ See
        .SH SOURCE
        .B \*9/src/cmd/namespace.c
        .SH SEE ALSO
       -.IR getns (3)
       +.IR getns (3),
       +.IR intro (4)
 (DIR) diff --git a/man/man1/news.1 b/man/man1/news.1
       t@@ -35,13 +35,13 @@ Other arguments
        select particular news items.
        .PP
        To post a news item, create a file in
       -.BR  /lib/news .
       -.PP
       -You may arrange to receive news automatically by 
       -registering your mail address in
       -.BR /sys/lib/subscribers .
       -A daemon mails recent news
       -to all addresses on the list.
       +.BR  \*9/news .
       +.\" .PP
       +.\" You may arrange to receive news automatically by 
       +.\" registering your mail address in
       +.\" .BR /sys/lib/subscribers .
       +.\" A daemon mails recent news
       +.\" to all addresses on the list.
        .PP
        Empty news items, and news items named
        .B core
       t@@ -49,15 +49,14 @@ or
        .B dead.letter
        are ignored.
        .SH FILES
       -.TF /sys/lib/subscribers
        .TP
       -.B /lib/news/*
       +.B \*9/news/*
        articles
        .TP
        .B $HOME/lib/newstime
        modify time is time news was last read
       -.TP
       -.B /sys/lib/subscribers
       +.\" .TP
       +.\" .B /sys/lib/subscribers
        who gets news mailed to them
        .SH SOURCE
        .B \*9/src/cmd/news.c
 (DIR) diff --git a/man/man1/page.1 b/man/man1/page.1
       t@@ -49,7 +49,7 @@ To view troff output, use
        .IR proof (1).
        .SH "SEE ALSO
        .IR gs (1),
       -.IR gv (1)
       +.IR gv (1),
        .IR jpg (1),
        .IR proof (1),
        .IR tex (1),
       t@@ -64,3 +64,11 @@ When using Preview on Mac OS X,
        leaves temporary files in
        .BR /var/tmp ,
        since it has no way to know when the viewer has exited.
       +.PP
       +.I Page
       +does not handle
       +Plan 9 
       +.IR image (7)
       +files; use
       +.I img
       +explicitly.
 (DIR) diff --git a/man/man1/plumb.1 b/man/man1/plumb.1
       t@@ -76,14 +76,10 @@ will add an
        .B action=showdata
        attribute to the message.
        .SH FILES
       -.TF /usr/$user/lib/plumbing
       +.TF $HOME/lib/plumbing
        .TP
       -.B /usr/$user/lib/plumbing
       +.B $HOME/lib/plumbing
        default rules file
       -.TP
       -.B /mnt/plumb
       -mount point for
       -.IR plumber (4).
        .SH SOURCE
        .B \*9/src/cmd/plumb
        .SH "SEE ALSO"
 (DIR) diff --git a/man/man1/proof.1 b/man/man1/proof.1
       t@@ -115,12 +115,11 @@ and
        .B d
        commands are also available as command line options.
        .SH FILES
       -.TF /lib/font/bit/MAP
        .TP
       -.B /lib/font/bit/*
       +.B \*9/font/*
        fonts
        .TP
       -.B /lib/font/bit/MAP
       +.B \*9/font/MAP
        how to convert troff output fonts and character names
        into screen fonts and character numbers
        .SH SOURCE
 (DIR) diff --git a/man/man1/ps.1 b/man/man1/ps.1
       t@@ -81,7 +81,7 @@ performing the named system call.
        waiting for more of a critical
        .IR resource .
        .TP
       -.BI wchan
       +.I wchan
        waiting on the named wait channel
        (on a Unix kernel).
        .PD
 (DIR) diff --git a/man/man1/rc.1 b/man/man1/rc.1
       t@@ -765,8 +765,7 @@ The string for a variable entry has the variable's name followed by
        .B =
        and its value.
        If the value has more than one component, these
       -are separated by SOH
       -.RB ( '\e001' )
       +are separated by SOH (001)
        characters.
        The string for a function is just the
        .I rc
 (DIR) diff --git a/man/man1/sam.1 b/man/man1/sam.1
       t@@ -19,6 +19,9 @@ sam, B, E, sam.save, samterm, samsave \- screen editor with structural regular e
        .B B
        .IB file \fR[\fP: line \fR]
        \&...
       +.PP
       +.B E
       +.I file
        .SH DESCRIPTION
        .I Sam
        is a multi-file editor.
       t@@ -845,7 +848,7 @@ It runs
        .I B
        on
        .I file
       -and then waits to exit until
       +and then does not exit until
        .I file
        is changed, which is taken as a signal that
        .I file
       t@@ -858,22 +861,22 @@ terminates other than by a
        command (by hangup, deleting its window, etc.), modified
        files are saved in an
        executable file,
       -.BR $home/sam.save .
       +.BR $HOME/sam.save .
        This program, when executed, asks whether to write
        each file back to a external file.
        The answer
        .L y
        causes writing; anything else skips the file.
        .SH FILES
       -.TF \*9/src/cmd/samterm
       +.TF $HOME/sam.save
        .TP
       -.B $home/sam.save
       +.B $HOME/sam.save
        .TP
       -.B $home/sam.err
       +.B $HOME/sam.err
        .TP
        .B \*9/bin/samsave
        the program called to unpack
       -.BR $home/sam.save .
       +.BR $HOME/sam.save .
        .SH SOURCE
        .TF \*9/src/cmd/samterm
        .TP
       t@@ -886,6 +889,8 @@ itself
        source for the separate terminal part
        .TP
        .B \*9/bin/B
       +.TP
       +.B \*9/bin/E
        .SH SEE ALSO
        .IR ed (1),
        .IR sed (1),
 (DIR) diff --git a/man/man1/scat.1 b/man/man1/scat.1
       t@@ -124,7 +124,7 @@ The output is the planet's name, right ascension and declination, azimuth and al
        for the moon and sun, as shown by
        .BR astro .
        The positions are current at the start of
       -.I scat 's
       +.IR scat 's
        execution; see the
        .B astro
        command in the next section for more information.
       t@@ -313,20 +313,20 @@ Draw a map of the Pleiades.
                expand 1
                plot
        .EE
       -.PP
       -Show a pretty galaxy.
       -.EX
       -        ngc1300
       -        plate 10'
       -.EE
       +.\" .PP
       +.\" Show a pretty galaxy.
       +.\" .EX
       +.\"         ngc1300
       +.\"         plate 10'
       +.\" .EE
        .SH FILES
       -.B /lib/sky/*.scat
       +.B \*9/sky/*.scat
        .SH SOURCE
        .B \*9/src/cmd/scat
        .SH SEE ALSO
        .IR astro (1)
        .br
       -.B /lib/sky/constelnames\ \ 
       +.B \*9/sky/constelnames\ \ 
        the three-letter abbreviations of the constellation names.
        .PP
        The data was provided by the Astronomical Data Center at the NASA Goddard
 (DIR) diff --git a/man/man1/secstore.1 b/man/man1/secstore.1
       t@@ -127,70 +127,70 @@ The next three commands fetch the persistent copy of the secrets,
        append a new secret,
        and save the updated file back to secstore.
        The final command loads the new secret into the running factotum.
       -.PP
       -The
       -.I ipso
       -command packages this sequence into a convenient script to simplify editing of
       -.I files
       -stored on a secure store.
       -It copies the named
       -.I files
       -into a local
       -.IR ramfs (4)
       -and invokes
       -.IR acme (1)
       -on them.  When the editor exits,
       -.I ipso
       -prompts the user to confirm copying modifed or newly created files back to
       -.I secstore.
       -If no
       -.I file
       -is mentioned,
       -.I ipso
       -grabs all the user's files from
       -.I secstore
       -for editing.
       -.PP
       -By default, ipso will edit the
       -.I secstore
       -files and, if
       -one of them is named
       -.BR factotum ,
       -flush your current keys from factotum and load
       -the new ones from the file.
       -If you supply any of the
       -.BR -e ,
       -.BR -f ,
       -or
       -.BR -l
       -options,
       -.I ipso
       -will just perform the operations you requested, i.e.,
       -edit, flush, and/or load.
       -.PP
       -The
       -.B -s
       -option of
       -.I ipso
       -invokes
       -.IR sam (1)
       -as the editor insted of
       -.BR acme ;
       -the
       -.B -a
       -option provides a similar service for files encrypted by
       -.I aescbc
       -.RI ( q.v. ).
       -With the
       -.B -a
       -option, the full rooted pathname of the
       -.I file
       -must be specified and all
       -.I files
       -must be encrypted with the same key.
       -Also with
       -.BR -a ,
       -newly created files are ignored.
       +.\" .PP
       +.\" The
       +.\" .I ipso
       +.\" command packages this sequence into a convenient script to simplify editing of
       +.\" .I files
       +.\" stored on a secure store.
       +.\" It copies the named
       +.\" .I files
       +.\" into a local
       +.\" .IR ramfs (4)
       +.\" and invokes
       +.\" .IR acme (1)
       +.\" on them.  When the editor exits,
       +.\" .I ipso
       +.\" prompts the user to confirm copying modifed or newly created files back to
       +.\" .I secstore.
       +.\" If no
       +.\" .I file
       +.\" is mentioned,
       +.\" .I ipso
       +.\" grabs all the user's files from
       +.\" .I secstore
       +.\" for editing.
       +.\" .PP
       +.\" By default, ipso will edit the
       +.\" .I secstore
       +.\" files and, if
       +.\" one of them is named
       +.\" .BR factotum ,
       +.\" flush your current keys from factotum and load
       +.\" the new ones from the file.
       +.\" If you supply any of the
       +.\" .BR -e ,
       +.\" .BR -f ,
       +.\" or
       +.\" .BR -l
       +.\" options,
       +.\" .I ipso
       +.\" will just perform the operations you requested, i.e.,
       +.\" edit, flush, and/or load.
       +.\" .PP
       +.\" The
       +.\" .B -s
       +.\" option of
       +.\" .I ipso
       +.\" invokes
       +.\" .IR sam (1)
       +.\" as the editor insted of
       +.\" .BR acme ;
       +.\" the
       +.\" .B -a
       +.\" option provides a similar service for files encrypted by
       +.\" .I aescbc
       +.\" .RI ( q.v. ).
       +.\" With the
       +.\" .B -a
       +.\" option, the full rooted pathname of the
       +.\" .I file
       +.\" must be specified and all
       +.\" .I files
       +.\" must be encrypted with the same key.
       +.\" Also with
       +.\" .BR -a ,
       +.\" newly created files are ignored.
        .PP
        .I Aescbc
        encrypts and decrypts using AES (Rijndael) in cipher
       t@@ -205,8 +205,8 @@ There is deliberately no backup of files on the secstore, so
        .B -r
        (or a disk crash) is irrevocable.  You are advised to store
        important secrets in a second location.
       -.PP
       -When using
       -.IR ipso ,
       -secrets will appear as plain text in the editor window,
       -so use the command in private.
       +.\" .PP
       +.\" When using
       +.\" .IR ipso ,
       +.\" secrets will appear as plain text in the editor window,
       +.\" so use the command in private.
 (DIR) diff --git a/man/man1/sed.1 b/man/man1/sed.1
       t@@ -1,8 +1,8 @@
        .TH SED 1
        .SH NAME
       -9sed \- stream editor
       +sed \- stream editor
        .SH SYNOPSIS
       -.B 9sed
       +.B sed
        [
        .B -n
        ]
       t@@ -366,7 +366,7 @@ ${
        Delete all but one of each group of empty lines from a
        formatted manuscript.
        .SH SOURCE
       -.B \*9/src/cmd/9sed.c
       +.B \*9/src/cmd/sed.c
        .SH SEE ALSO
        .IR ed (1), 
        .IR grep (1), 
 (DIR) diff --git a/man/man1/sort.1 b/man/man1/sort.1
       t@@ -19,6 +19,8 @@ sort \- sort and/or merge files
        .I ,pos2
        ]
        ] ...
       +.br
       +\h'0.5in'
        [
        .B -o
        .I output
       t@@ -210,7 +212,7 @@ This file may be the same as one of the inputs.
        Put temporary files in
        .I dir
        rather than in
       -.BR /tmp .
       +.BR /var/tmp .
        .ne 4
        .SH EXAMPLES
        .TP
       t@@ -236,7 +238,7 @@ grep -n '^' input | sort -t: +1f +0n | sed 's/[0-9]*://'
        A stable sort: input lines that compare equal will 
        come out in their original order.
        .SH FILES
       -.BI /tmp/sort. <pid>.<ordinal>
       +.BI /var/tmp/sort. <pid>.<ordinal>
        .SH SOURCE
        .B \*9/src/cmd/sort.c
        .SH SEE ALSO
 (DIR) diff --git a/man/man1/spell.1 b/man/man1/spell.1
       t@@ -67,7 +67,7 @@ American spelling list
        .B \*9/lib/brspell
        British spelling list
        .TP
       -.B /bin/aux/sprog
       +.B \*9/bin/sprog
        The actual spelling checker.
        It expects one word per line on standard input,
        and takes the same arguments as
       t@@ -87,7 +87,7 @@ source for
        The heuristics of
        .IR deroff (1)
        used to excise formatting information are imperfect.
       -.br
       +.PP
        The spelling list's coverage is uneven;
        in particular biology, medicine, and chemistry, and
        perforce proper names,
 (DIR) diff --git a/man/man1/stats.1 b/man/man1/stats.1
       t@@ -167,13 +167,21 @@ to exit.
        .PD
        .SH EXAMPLE
        Show the load, memory, interrupts, system calls, context switches,
       -and ethernet packets for the local machine, a remote Linux machine 
       -.BR tux ,
       -and a remote BSD machine
       -.BR daemon .
       +and ethernet packets for the local machine,
       +a remote BSD machine
       +.IR daemon ,
       +and
       +a remote Linux machine 
       +.IR tux .
       +.I Auxstats
       +is not in
       +.IR tux 's
       +path, so the full path must be given.
        .IP
       -.B
       -stats -lmisce `hostname` tux:\*9/bin/auxstats daemon
       +.EX
       +stats -lmisce `hostname` daemon \e
       +    tux:\*9/bin/auxstats
       +.EE
        .SH SOURCE
        .B \*9/src/cmd/draw/stats.c
        .PP
 (DIR) diff --git a/man/man1/tail.1 b/man/man1/tail.1
       t@@ -77,11 +77,11 @@ Print the first 10 lines of a file.
        Tails relative to the end of the file
        are treasured up in a buffer, and thus
        are limited in length.
       -.br
       +.PP
        According to custom, option
        .BI + number
        counts lines from 1, and counts
        blocks and bytes from 0.
       -.br
       +.PP
        .I Tail
        is ignorant of UTF.
 (DIR) diff --git a/man/man1/troff.1 b/man/man1/troff.1
       t@@ -158,19 +158,19 @@ to speed output and reduce output character count.
        Tab settings are assumed to be every
        8 nominal character widths.
        .SH FILES
       -.TF /sys/lib/troff/term/*
       +.TF \*9/troff/term/*
        .TP
        .B /tmp/trtmp*
        temporary file
        .TP
       -.B /sys/lib/tmac/tmac.*
       +.B \*9/tmac/tmac.*
        standard macro files
        .TP
       -.B /sys/lib/troff/term/*
       +.B \*9/troff/term/*
        terminal driving tables for
        .I nroff
        .TP
       -.B /sys/lib/troff/font/*
       +.B \*9/troff/font/*
        font width tables for
        .I troff
        .SH SOURCE
 (DIR) diff --git a/man/man1/units.1 b/man/man1/units.1
       t@@ -73,13 +73,13 @@ Currency is denoted
        etc.
        .PP
        The complete list of units can be found in
       -.BR /lib/units .
       +.BR \*9/lib/units .
        A
        .I file
        argument to
        .I units
        specifies a file to be used instead of
       -.BR /lib/units.
       +.BR \*9/lib/units.
        The
        .B -v
        flag causes
       t@@ -93,7 +93,7 @@ you want: atm
            / .97973
        .EE
        .SH FILES
       -.B /lib/units
       +.B \*9/lib/units
        .SH SOURCE
        .B \*9/src/cmd/units.y
        .SH BUGS
       t@@ -102,7 +102,6 @@ Since
        does only multiplicative scale changes,
        it can convert Kelvin to Rankine but not Centigrade to
        Fahrenheit.
       -.br
       +.PP
        Currency conversions are only as accurate as the last time someone
       -updated
       -.BR /lib/units .
       +updated the database.
 (DIR) diff --git a/man/man1/vac.1 b/man/man1/vac.1
       t@@ -127,4 +127,3 @@ and the vac archives that are expanded and merged.
        .B \*9/src/cmd/vac
        .SH "SEE ALSO"
        Plan 9's \fIvacfs\fR(4) and \fIventi\fR(8)
       -
 (DIR) diff --git a/man/man1/wc.1 b/man/man1/wc.1
       t@@ -43,7 +43,7 @@ but
        looks for only
        .SM ASCII
        space, tab and newline.
       -.br
       +.PP
        .I Wc
        should have options to count suboptimal
        .SM UTF
 (DIR) diff --git a/man/man1/web.1 b/man/man1/web.1
       t@@ -31,6 +31,8 @@ The choice of browser is determined by the
        .B $BROWSER
        environment variable, which should be the name of
        the executable for your choice of web browser.
       +The default is
       +.BR firefox .
        Since the various browsers all use different syntaxes
        in their
        .B -remote
       t@@ -41,6 +43,23 @@ When possible,
        .I web
        opens each URL in a new tab rather than a new window.
        .PP
       +When run under Mac OS X,
       +.B $BROWSER
       +should be set to the string
       +.B safari
       +or
       +.BR firefox .
       +.I Web
       +uses AppleScript to talk to the browser.
       +If 
       +.B $BROWSER
       +is not set,
       +.I web
       +looks for Firefox in
       +.BR /Applications/Firefox.app
       +and uses it if found;
       +otherwise it uses Safari.
       +.PP
        .I Wmail
        starts the composition of a new mail message to
        .IR address .
       t@@ -49,7 +68,8 @@ The choice of mailer is determined by the
        .B $MAILER
        environment variable.
        The supported mailers are:
       -.TP browser
       +.TP
       +.B browser
        invoke the mailer via a
        .B mailto://
        URL passed to
 (DIR) diff --git a/man/man1/wintext.1 b/man/man1/wintext.1
       t@@ -1,15 +1,19 @@
        .TH WINTEXT 1
        .SH NAME
        wintext, ", "" \- access text in current window
       +.ds x \C'"'
       +.ds xx \C'"'\^\^\^\^\C'"'
       +.ds y \*x\ 
       +.ds yy \*(xx\ 
        .SH SYNOPSIS
        .B wintext
        .br
       -.B \C'"'\ 
       +.B \*x\ 
        [
        .I prefix
        ]
        .br
       -.B \C'"'\C'"'\ 
       +.B \*(xx\ 
        [
        .I prefix
        ]
       t@@ -23,7 +27,7 @@ or
        .IR 9term (1)
        window to standard output.
        .PP
       -.I \C'"'
       +.I \*y
        searches the window text for commands typed with a particular prefix
        and prints them, indented, to standard output.
        .I Prefix
       t@@ -31,18 +35,18 @@ is a regular expression that is matched against the beginning of the command-lin
        If
        .I prefix
        is omitted,
       -.I \C'"'
       +.I \*y
        prints the last command executed.
       -.I \C'"'\C'"'
       +.I \*(yy
        prints the last command that
       -.I \C'"'
       +.I \*y
        would print and then executes it by piping it into 
        .IR rc (1).
        .PP
        Both
       -.I \C'"'
       +.I \*y
        and
       -.I \C'"'\C'"'
       +.I \*(yy
        identify commands in the window text by looking for lines
        beginning with a shell prompt.
        Prompts are assumed to be an unindented sequence of
       t@@ -62,7 +66,7 @@ commands executed in this window:
        .IP
        .EX
        .ta +4n
       -% \C'"' 'l[sc]'
       +% \*x 'l[sc]'
                % ls -l /tmp/qq*
                # ls -lrt /etc
                % lc r*
       t@@ -75,7 +79,7 @@ command again:
        .IP
        .EX
        .ta +4n
       -% \C'"'\C'"' lc
       +% \*(xx lc
                % lc r*
        ramfs   rc      read    rio     rm
        % 
       t@@ -86,13 +90,9 @@ ramfs   rc      read    rio     rm
        .SH SOURCE
        .B \*9/bin
        .SH BUGS
       -.I \C'"'
       +.I \*y
        and
       -.I \C'"'\C'"'
       +.I \*(yy
        are hard to type in shells other than
        .IR rc (1).
        .\" and in troff!
       -.PP
       -Don't run
       -.I \C'"'\C'"'
       -twice in a row.
 (DIR) diff --git a/man/man1/yacc.1 b/man/man1/yacc.1
       t@@ -145,7 +145,7 @@ parser prototype
        .B \*9/lib/yaccpars
        parser prototype using stdio
        .SH SOURCE
       -.B \*9/src/cmd/9yacc.c
       +.B \*9/src/cmd/yacc.c
        .SH "SEE ALSO"
        .IR lex (1)
        .br
 (DIR) diff --git a/man/man3/0intro.3 b/man/man3/0intro.3
       t@@ -0,0 +1,395 @@
       +.TH INTRO 3
       +.SH NAME
       +intro \- introduction to library functions
       +.SH SYNOPSIS
       +.nf
       +.B #include <u.h>
       +.PP
       +.B #include \fIany Unix headers\fR
       +.PP
       +.B #include <libc.h>
       +.PP
       +.B #include <auth.h>
       +.PP
       +.B #include <bio.h>
       +.PP
       +.B #include <draw.h>
       +.PP
       +.B #include <fcall.h>
       +.PP
       +.B #include <frame.h>
       +.PP
       +.B #include <mach.h>
       +.PP
       +.B #include <regexp.h>
       +.PP
       +.B #include <thread.h>
       +.fi
       +.SH DESCRIPTION
       +This section describes functions
       +in various libraries.
       +For the most part, each library is defined by a single C include
       +file, such as those listed above, and a single archive file containing
       +the library proper.  The name of the archive is
       +.BI \*9/lib/lib x .a \f1,
       +where
       +.I x
       +is the base of the include file name, stripped of a leading
       +.B lib
       +if present.
       +For example,
       +.B <draw.h>
       +defines the contents of library
       +.BR \*9/lib/libdraw.a ,
       +which may be abbreviated when named to the loader as
       +.BR -ldraw .
       +In practice, each include file contains a magic pragma
       +that directs the loader to pick up the associated archive
       +automatically, so it is rarely necessary to tell the loader
       +which
       +libraries a program needs;
       +see
       +.IR 9c (1).
       +.PP
       +The library to which a function belongs is defined by the
       +header file that defines its interface.
       +The `C library',
       +.IR libc ,
       +contains most of the basic subroutines such
       +as
       +.IR strlen .
       +Declarations for all of these functions are
       +in
       +.BR <libc.h> ,
       +which must be preceded by
       +.RI ( needs )
       +an include of
       +.BR <u.h> .
       +The graphics library,
       +.IR draw ,
       +is defined by
       +.BR <draw.h> ,
       +which needs
       +.B <libc.h>
       +and
       +.BR <u.h> .
       +The Buffered I/O library,
       +.IR libbio ,
       +is defined by
       +.BR <bio.h> ,
       +which needs
       +.B <libc.h>
       +and
       +.BR <u.h> .
       +The ANSI C Standard I/O library,
       +.IR libstdio ,
       +is defined by
       +.BR <stdio.h> ,
       +which needs
       +.BR <u.h> .
       +There are a few other, less commonly used libraries defined on
       +individual pages of this section.
       +.PP
       +The include file
       +.BR <u.h> ,
       +a prerequisite of several other include files,
       +declares the architecture-dependent and -independent types, including:
       +.IR uchar ,
       +.IR ushort ,
       +and
       +.IR ulong ,
       +the unsigned integer types;
       +.IR schar ,
       +the signed char type;
       +.I vlong
       +and
       +.IR uvlong ,
       +the signed and unsigned very long integral types;
       +.IR Rune ,
       +the Unicode character type;
       +.IR u8int ,
       +.IR u16int ,
       +.IR u32int ,
       +and
       +.IR u64int ,
       +the unsigned integral types with specific widths;
       +.IR jmp_buf ,
       +the type of the argument to
       +.I setjmp
       +and 
       +.IR longjmp ,
       +plus macros that define the layout of
       +.IR jmp_buf
       +(see
       +.IR setjmp (3));
       +.\" definitions of the bits in the floating-point control register
       +.\" as used by
       +.\" .IR getfcr (2);
       +and
       +the macros
       +.B va_arg
       +and friends for accessing arguments of variadic functions (identical to the
       +macros defined in
       +.B <stdarg.h>
       +in ANSI C).
       +.PP
       +Plan 9 and Unix use many similarly-named functions for different purposes:
       +for example, Plan 9's
       +.I dup
       +is closer to (but not exactly) Unix's
       +.IR dup2 .
       +To avoid name conflicts,
       +.B <libc.h>
       +defines many of these names as preprocessor macros to add a
       +.I p9
       +prefix,
       +so that
       +.I dup
       +becomes
       +.IR p9dup .
       +To disable this renaming,
       +.B #define
       +.B NOPLAN9DEFINES
       +before including
       +.BR <libc.h> .
       +If Unix headers must be included in a program,
       +they should be included after
       +.BR <u.h> ,
       +which sets important preprocessor directives
       +(for example, to enable 64-bit file offsets),
       +but before
       +.BR <libc.h> ,
       +to avoid renaming problems.
       +.SS "Name space
       +Files are collected into a hierarchical organization called a
       +.I "file tree
       +starting in a
       +.I directory
       +called the
       +.IR root .
       +File names, also called
       +.IR paths ,
       +consist of a number of
       +.BR / -separated
       +.I "path elements"
       +with the slashes corresponding to directories.
       +A path element must contain only printable
       +characters (those outside the control spaces of
       +.SM ASCII
       +and Latin-1).
       +A path element cannot contain a slash.
       +.PP
       +When a process presents a file name to Plan 9, it is
       +.I evaluated
       +by the following algorithm.
       +Start with a directory that depends on the first
       +character of the path:
       +.L /
       +means the root of the main hierarchy,
       +and anything else means the process's current working directory.
       +Then for each path element, look up the element
       +in the directory, advance to that directory,
       +do a possible translation (see below), and repeat.
       +The last step may yield a directory or regular file.
       +.SS "File I/O"
       +Files are opened for input or output
       +by
       +.I open
       +or
       +.I create
       +(see
       +.IR 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)
       +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).
       +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)),
       +the file descriptor table is shared by all the procs.
       +.PP
       +By convention,
       +file descriptor 0 is the standard input,
       +1 is the standard output,
       +and 2 is the standard error output.
       +With one exception, the operating system is unaware of these conventions;
       +it is permissible to close file 0,
       +or even to replace it by a file open only for writing,
       +but many programs will be confused by such chicanery.
       +The exception is that the system prints messages about broken processes
       +to file descriptor 2.
       +.PP
       +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)
       +system call.
       +.PP
       +Directories may be opened like regular files.
       +Instead of reading them with
       +.IR read (3),
       +use the
       +.B Dir
       +structure-based
       +routines described in
       +.IR dirread (3).
       +The entry
       +corresponding to an arbitrary file can be retrieved by
       +.IR dirstat
       +(see
       +.IR stat (3))
       +or
       +.IR dirfstat ;
       +.I dirwstat
       +and
       +.I dirfwstat
       +write back entries, thus changing the properties of a file.
       +.PP
       +New files are made with
       +.I create
       +(see
       +.IR open (3))
       +and deleted with
       +.IR remove (3).
       +Directories may not directly be written;
       +.IR create ,
       +.IR remove ,
       +.IR wstat ,
       +and
       +.I fwstat
       +alter them.
       +.PP
       +.IR 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).
       +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)
       +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)).
       +.PP
       +Each process has a set of attributes \(em memory, open files,
       +name space, etc. \(em that may be shared or unique.
       +Flags to
       +.IR rfork
       +control the sharing of these attributes.
       +.PP
       +A process terminates by calling
       +.IR exits (3).
       +A parent process may call
       +.IR wait (3)
       +to wait for some child to terminate.
       +A bit of status information
       +may be passed from
       +.I exits
       +to
       +.IR wait .
       +On Plan 9, the status information is an arbitrary text string,
       +but on Unix it is a single integer.
       +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).
       +.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)
       +to register the function to be called (the
       +.IR "notification handler" )
       +when such events occur.
       +.SS Multithreading
       +Where possible according to the ANSI C standard,
       +the main C library works properly in multiprocess programs;
       +.IR malloc ,
       +.IR print ,
       +and the other routines use locks (see
       +.IR lock (3))
       +to synchronize access to their data structures.
       +The graphics library defined in
       +.B <draw.h>
       +is also multi-process capable; details are in
       +.IR graphics (3).
       +In general, though, multiprocess programs should use some form of synchronization
       +to protect shared data.
       +.PP
       +The thread library, defined in
       +.BR <thread.h> ,
       +provides support for multiprocess programs.
       +It includes a data structure called a
       +.B Channel
       +that can be used to send messages between processes,
       +and coroutine-like
       +.IR threads ,
       +which enable multiple threads of control within a single process.
       +The threads within a process are scheduled by the library, but there is
       +no pre-emptive scheduling within a process; thread switching occurs
       +only at communication or synchronization points.
       +.PP
       +Most programs using the thread library
       +comprise multiple processes
       +communicating over channels, and within some processes,
       +multiple threads.  Since I/O calls may block, a system
       +call may block all the threads in a process.
       +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)
       +or
       +.IR mouse (3).
       +.SH SEE ALSO
       +.IR nm (1), 
       +.IR 9c (1)
       +.SH DIAGNOSTICS
       +Math functions in
       +.I libc
       +return
       +special values when the function is undefined for the
       +given arguments or when the value is not representable
       +(see
       +.IR 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)
       +recovers a string describing the error.
       +Some user-level library functions also use the
       +.I errstr
       +mechanism to report errors.
       +Functions that may affect the value of the error string are said to ``set
       +.IR errstr '';
       +it is understood that the error string is altered only if an error occurs.
 (DIR) diff --git a/man/man3/9p.3 b/man/man3/9p.3
       t@@ -109,13 +109,13 @@ and
        .B Fid
        structures are allocated one-to-one with uncompleted
        requests and active fids, and are described in
       -.IR 9pfid (3).
       +.IR 9p-fid (3).
        .PP
        The behavior of
        .I srv
        depends on whether there is a file tree
        (see
       -.IR 9pfile (3))
       +.IR 9p-file (3))
        associated with the server, that is,
        whether the
        .B tree
       t@@ -717,8 +717,8 @@ accept the
        option to increment
        .BR chatty9p .
        .SH EXAMPLES
       -\*9/src/lib9p/ramfs.c
       -is an example of simple single-threaded file servers.
       +.B \*9/src/lib9p/ramfs.c
       +is an example of a simple single-threaded file server.
        On Plan 9, see
        .IR archfs ,
        .IR cdfs ,
       t@@ -744,6 +744,6 @@ or is maintained elsewhere.
        .SH SOURCE
        .B \*9/src/lib9p
        .SH SEE ALSO
       -.IR 9pfid (3),
       -.IR 9pfile (3),
       +.IR 9p-fid (3),
       +.IR 9p-file (3),
        .IR intro (9p)
 (DIR) diff --git a/man/man3/9pclient.3 b/man/man3/9pclient.3
       t@@ -9,8 +9,8 @@ CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsmount, fsversion, 
        .B #include <fcall.h>
        .PP
        .B #include <9pclient.h>
       +.ta +\w'\fLCFsys* 'u
        .PP
       -.ta +'\fLCFsys* 'u
        .B
        CFsys*        fsmount(int fd, char *aname)
        .PP
       t@@ -214,7 +214,7 @@ The path is parsed as a slash-separated sequence of path elements,
        as on Unix and Plan 9.
        Elements that are empty or
        dot
       -.B ( . )
       +.RB ( . )
        are ignored.
        .PP
        Once opened, these fids can be read and written using
 (DIR) diff --git a/man/man3/INDEX b/man/man3/INDEX
       t@@ -1,3 +1,48 @@
       +0intro 0intro.3
       +intro 0intro.3
       +9p-cmdbuf 9p-cmdbuf.3
       +Cmdbuf 9p-cmdbuf.3
       +lookupcmd 9p-cmdbuf.3
       +parsecmd 9p-cmdbuf.3
       +respondcmderror 9p-cmdbuf.3
       +9p-fid 9p-fid.3
       +Fid 9p-fid.3
       +Fidpool 9p-fid.3
       +Req 9p-fid.3
       +Reqpool 9p-fid.3
       +allocfid 9p-fid.3
       +allocfidpool 9p-fid.3
       +allocreq 9p-fid.3
       +allocreqpool 9p-fid.3
       +closefid 9p-fid.3
       +closereq 9p-fid.3
       +freefidpool 9p-fid.3
       +freereqpool 9p-fid.3
       +lookupfid 9p-fid.3
       +lookupreq 9p-fid.3
       +removefid 9p-fid.3
       +removereq 9p-fid.3
       +9p-file 9p-file.3
       +File 9p-file.3
       +Tree 9p-file.3
       +alloctree 9p-file.3
       +closedirfile 9p-file.3
       +closefile 9p-file.3
       +createfile 9p-file.3
       +freetree 9p-file.3
       +hasperm 9p-file.3
       +opendirfile 9p-file.3
       +readdirfile 9p-file.3
       +removefile 9p-file.3
       +walkfile 9p-file.3
       +9p-intmap 9p-intmap.3
       +Intmap 9p-intmap.3
       +allocmap 9p-intmap.3
       +caninsertkey 9p-intmap.3
       +deletekey 9p-intmap.3
       +freemap 9p-intmap.3
       +insertkey 9p-intmap.3
       +lookupkey 9p-intmap.3
        9p 9p.3
        Srv 9p.3
        dirread9p 9p.3
       t@@ -39,41 +84,6 @@ fsunmount 9pclient.3
        fsversion 9pclient.3
        fswrite 9pclient.3
        nsmount 9pclient.3
       -9pcmdbuf 9pcmdbuf.3
       -Cmdbuf 9pcmdbuf.3
       -lookupcmd 9pcmdbuf.3
       -parsecmd 9pcmdbuf.3
       -respondcmderror 9pcmdbuf.3
       -9pfid 9pfid.3
       -Fid 9pfid.3
       -Fidpool 9pfid.3
       -Req 9pfid.3
       -Reqpool 9pfid.3
       -allocfid 9pfid.3
       -allocfidpool 9pfid.3
       -allocreq 9pfid.3
       -allocreqpool 9pfid.3
       -closefid 9pfid.3
       -closereq 9pfid.3
       -freefidpool 9pfid.3
       -freereqpool 9pfid.3
       -lookupfid 9pfid.3
       -lookupreq 9pfid.3
       -removefid 9pfid.3
       -removereq 9pfid.3
       -9pfile 9pfile.3
       -File 9pfile.3
       -Tree 9pfile.3
       -alloctree 9pfile.3
       -closedirfile 9pfile.3
       -closefile 9pfile.3
       -createfile 9pfile.3
       -freetree 9pfile.3
       -hasperm 9pfile.3
       -opendirfile 9pfile.3
       -readdirfile 9pfile.3
       -removefile 9pfile.3
       -walkfile 9pfile.3
        Dx addpt.3
        Dy addpt.3
        Pt addpt.3
       t@@ -233,15 +243,11 @@ accept dial.3
        announce dial.3
        dial dial.3
        dialparse dial.3
       -hangup dial.3
        listen dial.3
        netmkaddr dial.3
        reject dial.3
        dirread dirread.3
        dirreadall dirread.3
       -Disk disk.3
       -disk disk.3
       -opendisk disk.3
        ARROW draw.3
        Image draw.3
        _string draw.3
       t@@ -473,14 +479,6 @@ targetid html.3
        targetname html.3
        toStr html.3
        validitems html.3
       -Intmap intmap.3
       -allocmap intmap.3
       -caninsertkey intmap.3
       -deletekey intmap.3
       -freemap intmap.3
       -insertkey intmap.3
       -intmap intmap.3
       -lookupkey intmap.3
        closeioproc ioproc.3
        iocall ioproc.3
        ioclose ioproc.3
       t@@ -927,9 +925,6 @@ pwrite read.3
        read read.3
        readn read.3
        write read.3
       -RGB readcolmap.3
       -readcolmap readcolmap.3
       -writecolmap readcolmap.3
        regcomp regexp.3
        regcomplit regexp.3
        regcompnl regexp.3
       t@@ -939,15 +934,6 @@ regexp regexp.3
        regsub regexp.3
        rregexec regexp.3
        rregsub regexp.3
       -regcomp regexp9.3
       -regcomplit regexp9.3
       -regcompnl regexp9.3
       -regerror regexp9.3
       -regexec regexp9.3
       -regexp9 regexp9.3
       -regsub regexp9.3
       -rregexec regexp9.3
       -rregsub regexp9.3
        rfork rfork.3
        
        X509dump rsa.3
       t@@ -993,11 +979,6 @@ runestrncmp runestrcat.3
        runestrncpy runestrcat.3
        runestrrchr runestrcat.3
        runestrstr runestrcat.3
       -openscsi scsi.3
       -scsi scsi.3
       -scsicmd scsi.3
       -scsierror scsi.3
       -scsiready scsi.3
        hmac_md5 sechash.3
        hmac_sha1 sechash.3
        md4 sechash.3
       t@@ -1125,7 +1106,6 @@ threadint thread.3
        threadintgrp thread.3
        threadkill thread.3
        threadkillgrp thread.3
       -threadlinklibrary thread.3
        threadmain thread.3
        threadnotify thread.3
        threadpid thread.3
 (DIR) diff --git a/man/man3/atof.3 b/man/man3/atof.3
       t@@ -144,3 +144,35 @@ and
        .I atol
        accept octal and hexadecimal numbers in the style of C,
        contrary to the ANSI specification.
       +.PP
       +.IR Atof ,
       +.IR strtod ,
       +.IR strtol ,
       +.IR strtoul ,
       +.IR strtoll ,
       +and
       +.IR strtoull
       +are not provided:
       +they are expected to be provided by the underlying system.
       +.PP
       +Because they are implemented in the fmt library,
       +.I charstod
       +and
       +.I strtod
       +are preprocessor macros defined as
       +.I fmtcharstod
       +and
       +.IR fmtstrtod .
       +.PP
       +To avoid name conflicts with the underlying system,
       +.IR atoi ,
       +.IR atol ,
       +and
       +.I atoll
       +are preprocessor macros defined as
       +.IR p9atoi ,
       +.IR p9atol ,
       +and
       +.IR p9atoll ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/bin.3 b/man/man3/bin.3
       t@@ -20,7 +20,7 @@ void        *binalloc(Bin **bp, ulong size, int clr);
        void        *bingrow(Bin **bp, void *op, ulong osize,
        .br
        .B
       -        ulong size, int clr);
       +            ulong size, int clr);
        .PP
        .B
        void        binfree(Bin **bp);
 (DIR) diff --git a/man/man3/bio.3 b/man/man3/bio.3
       t@@ -2,7 +2,7 @@
        .SH NAME
        Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered \- buffered input/output
        .SH SYNOPSIS
       -.ta \w'Biobuf* 'u
       +.ta \w'\fLBiobuf* 'u
        .B #include <u.h>
        .br
        .B #include <libc.h>
 (DIR) diff --git a/man/man3/complete.3 b/man/man3/complete.3
       t@@ -13,12 +13,12 @@ complete, freecompletion \- file name completion
        .ta \w'    'u +\w'    'u +\w'    'u +\w'    'u +\w'    'u
        typedef struct Completion        Completion;
        struct Completion{
       -        uchar advance;                /* whether forward progress has been made */
       -        uchar complete;        /* whether the completion now represents a file or directory */
       -        char *string;                /* the string to advance, suffixed " " or "/" for file or directory */
       -        int nmatch;                /* number of files that matched */
       -        int nfile;                        /* number of files returned */
       -        char **filename;        /* their names */
       +        uchar advance;
       +        uchar complete;
       +        char *string;
       +        int nmatch;
       +        int nfile;
       +        char **filename;
        };
        
        .fi
 (DIR) diff --git a/man/man3/ctime.3 b/man/man3/ctime.3
       t@@ -90,9 +90,26 @@ is not
        .SH BUGS
        The return values point to static data
        whose content is overwritten by each call.
       -.br
       +.PP
        Daylight Savings Time is ``normal'' in the Southern hemisphere.
       -.br
       +.PP
        These routines are not equipped to handle non-\c
        .SM ASCII
        text, and are provincial anyway.
       +.PP
       +To avoid name conflicts with the underlying system,
       +.IR ctime ,
       +.IR localtime ,
       +.IR gmtime ,
       +.IR asctime ,
       +and
       +.I tm2sec
       +are preprocessor macros defined as
       +.IR p9ctime ,
       +.IR p9localtime ,
       +.IR p9gmtime ,
       +.IR p9asctime ,
       +and
       +.IR p9tm2sec ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/dial.3 b/man/man3/dial.3
       t@@ -1,6 +1,6 @@
        .TH DIAL 3
        .SH NAME
       -dial, hangup, announce, listen, accept, reject, netmkaddr, dialparse \- make and break network connections
       +dial, announce, listen, accept, reject, netmkaddr, dialparse \- make and break network connections
        .SH SYNOPSIS
        .B #include <u.h>
        .br
       t@@ -34,7 +34,10 @@ char* netmkaddr(char *addr, char *defnet, char *defservice)
        .\" void freenetconninfo(NetConnINfo*)
        .PP
        .B
       -int        dialparse(char *addr, char **net, char **unix, u32int *host, int *port)
       +int   dialparse(char *addr, char **net, char **unix,
       +.br
       +.B
       +          u32int *host, int *port)
        .SH DESCRIPTION
        For these routines,
        .I addr
       t@@ -310,3 +313,17 @@ bekremvax(void)
        and
        .I listen
        return \-1 if they fail.
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.IR dial ,
       +.IR announce ,
       +.IR listen ,
       +.IR netmkaddr ,
       +and
       +.I reject
       +are preprocessor macros defined as
       +.IR p9dial ,
       +.IR p9announce ,
       +and so on;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/dup.3 b/man/man3/dup.3
       t@@ -31,8 +31,9 @@ for the new file descriptor
        Sets
        .IR errstr .
        .SH BUGS
       -.I Dup
       -is a macro for
       -.I p9dup
       -to avoid name conflicts with the Unix function; see
       +To avoid name conflicts with the underlying system,
       +.I dup
       +is a preprocessor macro defined as
       +.IR p9dup ;
       +see
        .IR intro (3).
 (DIR) diff --git a/man/man3/event.3 b/man/man3/event.3
       t@@ -382,3 +382,8 @@ is nil, it restores the image to the default arrow.
        .IR plumb (3),
        .\" .IR cons (3),
        .IR draw (3)
       +.SH BUGS
       +.I Etimer
       +and
       +.I estart
       +are unimplemented.
 (DIR) diff --git a/man/man3/exec.3 b/man/man3/exec.3
       t@@ -128,3 +128,14 @@ use the user's current path to locate
        This is a clumsy way to deal with Unix's lack of
        a union directory for
        .BR /bin .
       +.PP
       +To avoid name conflicts with the underlying system,
       +.I exec
       +and
       +.I execl
       +are preprocessor macros defined as
       +.I p9exec
       +and
       +.IR p9execl ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/exits.3 b/man/man3/exits.3
       t@@ -93,3 +93,14 @@ non-empty messages.
        Exit codes 97 through 99 are used by the thread library to signal
        internal synchronization errors between the main program
        and a proxy process that implements backgrounding.
       +.PP
       +To avoid name conflicts with the underlying system,
       +.I atexit
       +and
       +.I atexitdont
       +are preprocessor macros defined as
       +.I p9atexit
       +and
       +.IR p9atexitdont ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/flate.3 b/man/man3/flate.3
       t@@ -8,7 +8,7 @@ deflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock, inflateinit, 
        .br
        .B #include <flate.h>
        .PP
       -.ta \w'ulongmm'u
       +.ta \w'\fLulongmm'u +\w'\fL  'u
        .PP
        .B
        int        deflateinit(void)
       t@@ -17,37 +17,37 @@ int        deflateinit(void)
        int        deflate(void *wr, int (*w)(void*,void*,int),
        .br
        .B
       -        void *rr, int (*r)(void*,void*,int),
       +                void *rr, int (*r)(void*,void*,int),
        .br
        .B
       -        int level, int debug)
       +                int level, int debug)
        .PP
        .B
        int        deflatezlib(void *wr, int (*w)(void*,void*,int),
        .br
        .B
       -        void *rr, int (*r)(void*,void*,int),
       +                void *rr, int (*r)(void*,void*,int),
        .br
        .B
       -        int level, int debug)
       +                int level, int debug)
        .PP
        .B
        int        deflateblock(uchar *dst, int dsize,
        .br
        .B
       -        uchar *src, int ssize,
       +                uchar *src, int ssize,
        .br
        .B
       -        int level, int debug)
       +                int level, int debug)
        .PP
        .B
        int        deflatezlibblock(uchar *dst, int dsize,
        .br
        .B
       -        uchar *src, int ssize,
       +                uchar *src, int ssize,
        .br
        .B
       -        int level, int debug)
       +                int level, int debug)
        .PP
        .B
        int        inflateinit(void)
       t@@ -56,25 +56,25 @@ int        inflateinit(void)
        int        inflate(void *wr, int (*w)(void*, void*, int),
        .br
        .B
       -        void *getr, int (*get)(void*))
       +                void *getr, int (*get)(void*))
        .PP
        .B
        int        inflatezlib(void *wr, int (*w)(void*, void*, int),
        .br
        .B
       -        void *getr, int (*get)(void*))
       +                void *getr, int (*get)(void*))
        .PP
        .B
        int        inflateblock(uchar *dst, int dsize,
        .br
        .B
       -        uchar *src, int ssize)
       +                uchar *src, int ssize)
        .PP
        .B
        int        inflatezlibblock(uchar *dst, int dsize,
        .br
        .B
       -        uchar *src, int ssize)
       +                uchar *src, int ssize)
        .PP
        .B
        char        *flateerr(int error)
 (DIR) diff --git a/man/man3/fmtinstall.3 b/man/man3/fmtinstall.3
       t@@ -370,4 +370,3 @@ main(...)
        .SH DIAGNOSTICS
        These routines return negative numbers or nil for errors and set
        .IR errstr .
       -.SH BUGS
 (DIR) diff --git a/man/man3/frame.3 b/man/man3/frame.3
       t@@ -75,7 +75,7 @@ This library supports
        of editable text in a single font on raster displays, such as in
        .IR sam (1)
        and
       -.IR rio (1).
       +.IR 9term (1).
        Frames may hold any character except NUL (0).
        Long lines are folded and tabs are at fixed intervals.
        .PP
 (DIR) diff --git a/man/man3/genrandom.3 b/man/man3/genrandom.3
       t@@ -22,8 +22,10 @@ very least, unguessable numbers.
        .I Genrandom
        fills a buffer with bytes from the X9.17 pseudo-random
        number generator.  The X9.17 generator is seeded by 24
       -truly random bytes read from
       -.BR /dev/random .
       +truly random bytes read via
       +.I truerand
       +(see
       +.IR rand (3)).
        .PP
        .I Prng
        uses the native
 (DIR) diff --git a/man/man3/getenv.3 b/man/man3/getenv.3
       t@@ -35,8 +35,13 @@ to
        Sets
        .IR errstr .
        .SH BUGS
       -Defined as macros for
       +To avoid name conflicts with the underlying system,
       +.I getenv
       +and
       +.I putenv
       +are preprocessor macros defined as
        .I p9getenv
        and
       -.I p9putenv
       -to avoid name conflicts with Unix library calls.
       +.IR p9putenv ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/getwd.3 b/man/man3/getwd.3
       t@@ -23,8 +23,15 @@ bytes in the buffer provided.
        .SH SOURCE
        .B \*9/src/lib9/getwd.c
        .SH "SEE ALSO"
       -.IR pwd (1),
       +.IR pwd (1)
        .SH DIAGNOSTICS
        On error, zero is returned.
        .IR Errstr (3)
        may be consulted for more information.
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.I getwd
       +is a preprocessor macro defined as
       +.IR p9getwd ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/graphics.3 b/man/man3/graphics.3
       t@@ -615,7 +615,7 @@ if(gengetwindow(display, "/tmp/winname",
        \&...
        .EE
        .SH FILES
       -.BR /lib/font/bit "    directory of fonts
       +.BR \*9/font/bit "    directory of fonts
        .SH SOURCE
        .B \*9/src/libdraw
        .SH "SEE ALSO"
       t@@ -649,3 +649,7 @@ and might be more appropriately called
        .B white
        and
        .BR black .
       +.PP
       +These manual pages contain many references to
       +the now-fictitious
       +.BR /dev/draw .
 (DIR) diff --git a/man/man3/malloc.3 b/man/man3/malloc.3
       t@@ -168,3 +168,18 @@ When
        and
        .I free
        detect such corruption, they abort.
       +.PP
       +To avoid name conflicts with the system versions of these functions,
       +.IR malloc ,
       +.IR realloc ,
       +.IR calloc ,
       +and
       +.I free
       +are preprocessor macros defined as
       +.IR p9malloc ,
       +.IR p9realloc ,
       +.IR p9calloc ,
       +and
       +.IR p9free ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/memdraw.3 b/man/man3/memdraw.3
       t@@ -449,7 +449,6 @@ prints to a serial line rather than the screen, for obvious reasons.
        is unusual in using a subfont rather than a font,
        and in having no parameter to align the source.
        .PP
       -.I Libmemdraw
       -is archived into
       +These functions are 
       +archived into
        .IR libdraw .
       -
 (DIR) diff --git a/man/man3/memlayer.3 b/man/man3/memlayer.3
       t@@ -304,6 +304,6 @@ are in compressed image format
        .IR window (3),
        .IR draw (3)
        .SH BUGS
       -.I Libmemlayer
       -is archived into
       +These functions
       +are archived into
        .IR libdraw .
 (DIR) diff --git a/man/man3/mp.3 b/man/man3/mp.3
       t@@ -1,6 +1,6 @@
        .TH MP 3
        .SH NAME
       -mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpcmp, mpextendedgcd, mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, crtpre, crtin, crtout, crtprefree, crtresfree, mpfactorial \- extended precision arithmetic
       +mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpfactorial, mpcmp, mpextendedgcd, mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, crtpre, crtin, crtout, crtprefree, crtresfree \- extended precision arithmetic
        .SH SYNOPSIS
        .B #include <u.h>
        .br
       t@@ -108,6 +108,9 @@ void        mpmod(mpint *b, mpint *m, mpint *remainder)
        void        mpdiv(mpint *dividend, mpint *divisor,  mpint *quotient, mpint *remainder)
        .PP
        .B
       +mpint*        mpfactorial(ulong n)
       +.PP
       +.B
        int        mpcmp(mpint *b1, mpint *b2)
        .PP
        .B
       t@@ -162,9 +165,6 @@ void        crtprefree(CRTpre *cre)
        void        crtresfree(CRTres *res)
        .PP
        .B
       -mpint*        mpfactorial(ulong n)
       -.PP
       -.B
        mpint        *mpzero, *mpone, *mptwo
        .SH DESCRIPTION
        .PP
       t@@ -441,6 +441,10 @@ Otherwise,
        .BR "quotient = dividend/divisor" .
        .BR "remainder = dividend % divisor" .
        .TP
       +.I mpfactorial
       +returns factorial of
       +.IR n .
       +.TP
        .I mpcmp
        returns -1, 0, or +1 as
        .I b1
       t@@ -575,9 +579,5 @@ free
        and
        .I CRTres
        structures respectively.
       -.PP
       -.I Mpfactorial
       -returns the factorial of
       -.IR n .
        .SH SOURCE
        .B \*9/src/libmp
 (DIR) diff --git a/man/man3/muldiv.3 b/man/man3/muldiv.3
       t@@ -7,7 +7,7 @@ muldiv, umuldiv \- high-precision multiplication and division
        .B #include <libc.h>
        .PP
        .B
       -long muldiv(long a, long b, long c)
       +long  muldiv(long a, long b, long c)
        .PP
        .B
        ulong umuldiv(ulong a, ulong b, ulong c)
 (DIR) diff --git a/man/man3/mux.3 b/man/man3/mux.3
       t@@ -7,6 +7,7 @@ Mux, muxinit, muxrpc, muxthreads \- protocol multiplexor
        .nf
        .B
        .ta +4n
       +.ft B
        struct Mux
        {
                uint mintag;
 (DIR) diff --git a/man/man3/notify.3 b/man/man3/notify.3
       t@@ -207,7 +207,7 @@ is a common set that includes:
        .PP
        .RS 3n
        .nf
       -.ta \w'\fLsys: write on closed pipe  \fP'u \w'system call address argument out of range   'u
       +.ta \w'\fLsys: segmentation violation  \fP'u +\w'process requested to exit     'u
        \fINote\fP        \fIMeaning\fP        \fIUnix signal\fP
        \fLinterrupt\fP        user interrupt (DEL key)        SIGINTR
        \fLhangup\fP        I/O connection closed        SIGHUP
       t@@ -217,6 +217,8 @@ is a common set that includes:
        \fLsys: kill\fP        process forced to exit        SIGKILL
        \fLsys: bus error\fP        bus error        SIGBUS
        \fLsys: segmentation violation\fP        segmentation violation        SIGSEGV
       +\fLsys: write on closed pipe\fP        write on closed pipe        SIGPIPE
       +\fLsys: child\fP        child wait status change        SIGCHLD
        .fi
        .RE
        .PP
 (DIR) diff --git a/man/man3/print.3 b/man/man3/print.3
       t@@ -1,18 +1,10 @@
        .TH PRINT 3
       -.de EX
       -.nf
       -.ft B
       -..
       -.de EE
       -.fi
       -.ft R
       -..
        .SH NAME
        print, fprint, sprint, snprint, seprint, smprint, runesprint, runesnprint, runeseprint, runesmprint, vfprint, vsnprint, vseprint, vsmprint, runevsnprint, runevseprint, runevsmprint \- print formatted output
        .SH SYNOPSIS
       -.B #include <utf.h>
       +.B #include <u.h>
        .PP
       -.B #include <fmt.h>
       +.B #include <libc.h>
        .PP
        .ta \w'\fLchar* 'u
        .B
       t@@ -72,7 +64,10 @@ Rune*        runevsmprint(Rune *format, va_list v)
        writes text to the standard output.
        .I Fprint
        writes to the named output
       -file descriptor.
       +file descriptor:
       +a buffered form
       +is described in
       +.IR bio (3).
        .I Sprint
        places text
        followed by the NUL character
       t@@ -96,7 +91,7 @@ but will not place more than
        bytes in
        .IR s .
        Its result is always NUL-terminated and holds the maximal
       -number of characters that can fit.
       +number of complete UTF-8 characters that can fit.
        .I Seprint
        is like
        .IR snprint ,
       t@@ -191,27 +186,26 @@ described below.
        .PP
        The numeric verbs
        .BR d ,
       -.BR i ,
       -.BR u ,
        .BR o ,
        .BR b ,
        .BR x ,
        and
        .B X
       -format their arguments in decimal, decimal,
       -unsigned decimal, octal, binary, hexadecimal, and upper case hexadecimal.
       +format their arguments in decimal,
       +octal, binary, hexadecimal, and upper case hexadecimal.
        Each interprets the flags
        .BR 0 ,
        .BR h ,
        .BR hh ,
        .BR l ,
       +.BR u ,
        .BR + ,
        .BR - ,
        .BR , ,
        and
        .B #
        to mean pad with zeros,
       -short, byte, long, always print a sign, left justified, commas every three digits,
       +short, byte, long, unsigned, always print a sign, left justified, commas every three digits,
        and alternate format.
        Also, a space character in the flag
        position is like
       t@@ -221,12 +215,9 @@ If neither
        short nor long is specified,
        then the argument is an
        .BR int .
       -If an unsigned verb is specified,
       +If unsigned is specified,
        then the argument is interpreted as a
       -positive number and no sign is output;
       -space and
       -.B +
       -flags are ignored for unsigned verbs.
       +positive number and no sign is output.
        If two
        .B l
        flags are given,
       t@@ -249,8 +240,8 @@ for
        .B o
        conversion, the number is preceded by a
        .B 0
       -if it doesn't already begin with one.
       -For non-zero numbers and
       +if it doesn't already begin with one;
       +for
        .B x
        conversion, the number is preceded by
        .BR 0x ;
       t@@ -345,7 +336,7 @@ conversions, trailing zeros are not removed.
        .PP
        The
        .B s
       -verb copies a string
       +verb copies a NUL-terminated string
        (pointer to
        .BR char )
        to the output.
       t@@ -397,9 +388,7 @@ 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 strerror (3)
       -with an argument of
       -.IR errno.
       +.IR errstr (3).
        .PP
        Custom verbs may be installed using
        .IR fmtinstall (3).
       t@@ -414,12 +403,12 @@ void fatal(char *msg, ...)
                char buf[1024], *out;
                va_list arg;
        
       -        out = vseprint(buf, buf+sizeof buf, "Fatal error: ");
       +        out = seprint(buf, buf+sizeof buf, "Fatal error: ");
                va_start(arg, msg);
                out = vseprint(out, buf+sizeof buf, msg, arg);
                va_end(arg);
                write(2, buf, out-buf);
       -        exit(1);
       +        exits("fatal error");
        }
        .EE
        .SH SEE ALSO
       t@@ -438,9 +427,9 @@ the main difference is that
        .B b
        and
        .B r
       -are not in ANSI and some
       -.B C9X
       -verbs are missing.
       +are not in ANSI and
       +.B u
       +is a flag here instead of a verb.
        Also, and distinctly not a bug,
        .I print
        and friends generate
       t@@ -449,8 +438,8 @@ rather than
        .SM ASCII.
        .PP
        There is no
       -.BR runeprint ,
       -.BR runefprint ,
       +.IR runeprint ,
       +.IR runefprint ,
        etc. because runes are byte-order dependent and should not be written directly to a file; use the
        UTF output of
        .I print
 (DIR) diff --git a/man/man3/pushtls.3 b/man/man3/pushtls.3
       t@@ -26,7 +26,7 @@ int                        tlsServer(int fd, TLSconn *conn)
        uchar                *readcert(char *filename, int *pcertlen)
        .PP
        .B
       -PEMchain        *readcertchain(char *filename)
       +PEMchain                *readcertchain(char *filename)
        .PP
        .B
        Thumbprint*        initThumbprints(char *ok, char *crl)
 (DIR) diff --git a/man/man3/quote.3 b/man/man3/quote.3
       t@@ -165,3 +165,10 @@ format strings.
        .IR malloc (3),
        .IR print (3),
        .IR 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).
 (DIR) diff --git a/man/man3/rand.3 b/man/man3/rand.3
       t@@ -156,9 +156,9 @@ to return a uniform
        .IR x ,
        .RI 0≤ x < val ≤ 2\u\s732\s10\d-1.
        .SH SOURCE
       -.B \*9/src/lib9/
       +.B \*9/src/lib9
        .br
       -.B \*9/src/libsec/port/
       +.B \*9/src/libsec/port
        .SH "SEE ALSO
        .\" .IR cons (3),
        .IR mp (3)
       t@@ -167,3 +167,18 @@ to return a uniform
        and
        .I ntruerand
        maintain a static file descriptor.
       +.PP
       +To avoid name conflicts with the underlying system,
       +.IR rand ,
       +.IR lrand ,
       +.IR frand ,
       +.IR nrand ,
       +.IR lnrand ,
       +and
       +.I srand
       +are preprocessor macros defined as
       +.IR p9rand ,
       +.IR p9lrand ,
       +and so on;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/regexp.3 b/man/man3/regexp.3
       t@@ -113,22 +113,22 @@ typedef struct {
                union {
                   char *sp;
                   Rune *rsp;
       -        };
       +        } s;
                union {
                   char *ep;
                   Rune *rep;
       -        };
       +        } e;
        } Resub;
        .EE
        .LP
        If
       -.B match[0].sp
       +.B match[0].s.sp
        is nonzero on entry,
        .I regexec
        starts matching at that point within
        .IR string .
        If
       -.B match[0].ep
       +.B match[0].e.ep
        is nonzero on entry,
        the last character matched is the one
        preceding that point.
 (DIR) diff --git a/man/man3/sechash.3 b/man/man3/sechash.3
       t@@ -13,50 +13,51 @@ md4, md5, sha1, hmac_md5, hmac_sha1, md5pickle, md5unpickle, sha1pickle, sha1unp
        .B
        DigestState*        md4(uchar *data, ulong dlen, uchar *digest,
        .B
       -                         DigestState *state)
       +                            DigestState *state)
        .PP
        .B
        DigestState*        md5(uchar *data, ulong dlen, uchar *digest,
        .B
       -                         DigestState *state)
       +                            DigestState *state)
        .PP
        .B
        char*                md5pickle(MD5state *state)
        .PP
        .B
       -MD5state*        md5unpickle(char *p);
       +MD5state*                md5unpickle(char *p);
        .PP
        .B
        DigestState*        sha1(uchar *data, ulong dlen, uchar *digest,
        .B
       -                         DigestState *state)
       +                            DigestState *state)
        .PP
        .B
        char*                sha1pickle(MD5state *state)
        .PP
        .B
       -MD5state*        sha1unpickle(char *p);
       +MD5state*                sha1unpickle(char *p);
        .PP
        .B
        DigestState*        hmac_md5(uchar *data, ulong dlen,
        .br
        .B
       -                         uchar *key, ulong klen,
       +                            uchar *key, ulong klen,
        .br
        .B
       -                         uchar *digest, DigestState *state)
       +                            uchar *digest, DigestState *state)
        .PP
        .B
        DigestState*        hmac_sha1(uchar *data, ulong dlen,
        .br
        .B
       -                         uchar *key, ulong klen,
       +                            uchar *key, ulong klen,
        .br
        .B
       -                         uchar *digest, DigestState *state)
       +                            uchar *digest, DigestState *state)
        .SH DESCRIPTION
        .PP
       -We support several secure hash functions.  The output of the
       +These functions implement
       +the cryptographic hash functions MD4, MD5, and SHA1.  The output of the
        hash is called a
        .IR digest .
        A hash is secure if, given the hashed data and the digest,
 (DIR) diff --git a/man/man3/seek.3 b/man/man3/seek.3
       t@@ -44,3 +44,10 @@ Seeking in a pipe is a no-op.
        .SH DIAGNOSTICS
        Sets
        .IR errstr .
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.I seek
       +is a preprocessor macro defined as
       +.IR p9seek ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/setjmp.3 b/man/man3/setjmp.3
       t@@ -55,36 +55,6 @@ argument should be the first argument passed to the note handler.
        and
        .I longjmp
        can also be used to switch stacks.
       -Defined in
       -.B </$objtype/u.h>
       -are several macros that can be used to build
       -.B jmp_bufs
       -by hand.  The following code establishes a
       -.B jmp_buf
       -.i label
       -that may be called by
       -.I longjmp
       -to begin execution in a function
       -.BR f
       -with 1024 bytes of stack:
       -.IP
       -.EX
       -#include <u.h>
       -#include <libc.h>
       -
       -jmp_buf label;
       -#define NSTACK 1024
       -char stack[NSTACK];
       -
       -void
       -setlabel(void)
       -{
       -        label[JMPBUFPC] = ((ulong)f+JMPBUFDPC);
       -        /* -2 leaves room for old pc and new pc in frame */
       -        label[JMPBUFSP =
       -                (ulong)(&stack[NSTACK-2*sizeof(ulong*)]);
       -}
       -.EE
        .SH SOURCE
        .B \*9/src/lib9/jmp.c
        .SH SEE ALSO
       t@@ -94,3 +64,24 @@ setlabel(void)
        .I Notejmp
        cannot recover from an address trap or bus error (page fault) on the 680x0
        architectures.
       +.PP
       +To avoid name conflicts with the underlying system,
       +.IR setjmp ,
       +.IR longjmp ,
       +.IR notejmp ,
       +and
       +.I jmp_buf
       +are preprocessor macros defined as
       +.IR p9setjmp ,
       +.IR p9longjmp ,
       +.IR p9notejmp ,
       +and
       +.IR p9jmp_buf ;
       +see
       +.IR intro (3).
       +.PP
       +.I P9setjmp
       +is implemented as a preprocessor macro that calls
       +.I sigsetjmp
       +(see
       +Unix's \fIsetjmp\fR(3)).
 (DIR) diff --git a/man/man3/sleep.3 b/man/man3/sleep.3
       t@@ -43,3 +43,14 @@ the alarm clock.
        .SH DIAGNOSTICS
        These functions set
        .IR errstr .
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.I sleep
       +and
       +.I alarm
       +are preprocessor macros defined as
       +.I p9sleep
       +and
       +.IR p9alarm ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/string.3 b/man/man3/string.3
       t@@ -117,7 +117,7 @@ is used when code needs a reference to the character array.
        Using
        .B s->base
        directly is frowned upon since it exposes too much of the implementation.
       -.SS "allocation and freeing
       +.SS "Allocation and freeing
        .PP
        A string must be allocated before it can be used.
        One normally does this using
 (DIR) diff --git a/man/man3/subfont.3 b/man/man3/subfont.3
       t@@ -104,7 +104,7 @@ it should be zeroed before calling
        A number of subfonts are kept in external files.
        The convention for naming subfont files is:
        .IP
       -.B /lib/font/bit/\fIname\fP/\fIclass\fP.\fIsize\fP.\fIdepth
       +.B \*9/font/\fIname\fP/\fIclass\fP.\fIsize\fP.\fIdepth
        .PD
        .PP
        where
       t@@ -217,9 +217,9 @@ into the
        to
        .IB min + s ->n-1\f1.
        .SH FILES
       -.TF /lib/font/bit
       +.TF \*9/font
        .TP
       -.B /lib/font/bit
       +.B \*9/font
        bitmap font file tree
        .SH SOURCE
        .B \*9/src/libdraw
 (DIR) diff --git a/man/man3/thread.3 b/man/man3/thread.3
       t@@ -33,7 +33,6 @@ threadint,
        threadintgrp,
        threadkill,
        threadkillgrp,
       -threadlinklibrary,
        threadmain,
        threadnotify,
        threadid,
       t@@ -46,14 +45,6 @@ threadwaitchan,
        yield \- thread and proc management
        .SH SYNOPSIS
        .PP
       -.de EX
       -.nf
       -.ft B
       -..
       -.de EE
       -.fi
       -.ft R
       -..
        .EX
        .ta 4n +4n +4n +4n +4n +4n +4n
        #include <u.h>
       t@@ -88,8 +79,6 @@ struct Alt {
        void        threadmain(int argc, char *argv[])
        int        mainstacksize
        int        proccreate(void (*fn)(void*), void *arg, uint stacksize)
       -int        procrfork(void (*fn)(void*), void *arg, uint stacksize,
       -                int rforkflag)
        int        threadcreate(void (*fn)(void*), void *arg, uint stacksize)
        void        threadexits(char *status)
        void        threadexitsall(char *status)
       t@@ -393,6 +382,7 @@ fd[0] = 0;
        fd[1] = 1;
        fd[2] = 2;
        .EE
       +.LP
        to use the current standard files.  The correct code is
        .IP
        .EX
       t@@ -656,20 +646,6 @@ contains some example programs.
        .IR intro (3),
        .IR ioproc (3)
        .SH BUGS
       -A program that intends to use the thread library
       -but does not call any of its functions will not cause Unix linkers
       -to link the thread library, resulting in the unintelligible error:
       -.IP
       -.EX
       -\*9/lib/lib9.a(main.o)(.text+0x17): In function `main':
       -\*9/src/lib9/main.c:10: undefined reference to `p9main'
       -.EE
       -.LP
       -or similar.  To force the thread library to be linked properly in such cases,
       -insert a call to the no-op function
       -.I threadlinklibrary
       -somewhere in your program.
       -.PP
        To avoid name conflicts,
        .IR alt ,
        .IR nbrecv ,
       t@@ -689,10 +665,11 @@ are defined as macros that expand to
        .IR chanalt ,
        .IR channbrecv ,
        and so on.
       -Similarly,
       -.I yield
       +.I Yield
        is defined as a macro that expands to
        .IR threadyield .
       +See
       +.IR intro (3).
        .PP
        The implementation of
        .I threadnotify
 (DIR) diff --git a/man/man3/time.3 b/man/man3/time.3
       t@@ -31,3 +31,14 @@ is also set to the answer.
        .SH DIAGNOSTICS
        These functions set
        .IR errstr .
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.I time
       +and
       +.I nsec
       +are preprocessor macros defined as
       +.I p9time
       +and
       +.IR p9nsec ;
       +see
       +.IR intro (3).
 (DIR) diff --git a/man/man3/wait.3 b/man/man3/wait.3
       t@@ -144,3 +144,16 @@ returns
        .SH DIAGNOSTICS
        These routines set
        .IR errstr .
       +.SH BUGS
       +To avoid name conflicts with the underlying system,
       +.IR wait ,
       +.IR waitpid ,
       +and
       +.I waitfor
       +are preprocessor macros defined as
       +.IR p9wait ,
       +.IR p9waitpid ,
       +and
       +.IR p9waitfor ;
       +see 
       +.IR intro (3).
 (DIR) diff --git a/man/man4/INDEX b/man/man4/INDEX
       t@@ -2,5 +2,6 @@
        intro 0intro.4
        9pserve 9pserve.4
        acme acme.4
       +import import.4
        plumber plumber.4
        ramfs ramfs.4
 (DIR) diff --git a/man/man4/acme.4 b/man/man4/acme.4
       t@@ -25,14 +25,10 @@ of
        itself.
        When a command is run under
        .IR acme ,
       -a directory holding these files is mounted on
       -.B /mnt/acme
       -(also bound to
       -.BR /mnt/wsys )
       -and also
       -.BR /dev ;
       -the files mentioned here
       -appear in both those directories.
       +a directory holding these files is posted as the 9P service
       +.B acme
       +(using
       +.IR 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
 (DIR) diff --git a/man/man4/import.4 b/man/man4/import.4
       t@@ -0,0 +1,106 @@
       +.TH IMPORT 4
       +.SH NAME
       +import \- import 9P resources from another system
       +.SH SYNOPSIS
       +.B import
       +[
       +.B -df
       +]
       +[
       +.B -n
       +.I ns
       +]
       +[
       +.B -p
       +.I prog
       +]
       +[
       +.B -s
       +.I service
       +]
       +.I system
       +.SH DESCRIPTION
       +.I Import
       +presents the 9P service
       +.I service
       +(default
       +.BR plumb )
       +running on
       +.I system
       +as a service on the local system,
       +in the current name space.
       +.PP
       +The
       +.B -n
       +option sets the remote name space directory
       +where
       +.I import
       +should expect to find
       +.IR service .
       +If it is not specified,
       +.I import
       +uses name of the local system's name space directory.
       +(Since name space directories are conventionally inside
       +.BR /tmp ,
       +the path have different meanings on the two systems.)
       +.PP
       +.I Import
       +connects to
       +.I system
       +using
       +.IR ssh (1).
       +It invokes
       +.I import
       +on the remote system to carry out the remote
       +side of the protocol.
       +The
       +.B -p
       +option specifies the path to
       +.I import
       +on the remote system, in case it is not in the system search path.
       +.PP
       +The
       +.B -d
       +option turns on debugging.
       +The
       +.B -f
       +option keeps
       +.I import
       +from forking itself into the background, also useful for debugging.
       +.SH EXAMPLE
       +Suppose you run
       +.B sam
       +.B -r
       +to the CPU server
       +.IR anna .
       +.I Sam
       +wants to talk to a plumber on the local terminal,
       +but the file names will refer to files on
       +.IR anna .
       +.PP
       +To fix this problem, create a new name space directory
       +and start a new plumber on
       +.IR anna :
       +.IP
       +.EX
       +remotens=/tmp/ns.`whoami`.on.`hostname`
       +ssh anna mkdir $remotens
       +ssh anna NAMESPACE=$remotens plumber
       +.EE
       +Now import that plumber to the local name space before starting
       +.I sam
       +and
       +.IR 9term :
       +.IP
       +.EX
       +NAMESPACE=/tmp/ns.anna
       +mkdir $NAMESPACE
       +import -n $remotens -s plumb anna
       +sam &
       +9term ssh anna &
       +.EE
       +.SH SOURCE
       +.B \*9/src/cmd/import.c
       +.SH SEE ALSO
       +.IR 9pserve (4),
       +.IR intro (4)
 (DIR) diff --git a/man/man4/plumber.4 b/man/man4/plumber.4
       t@@ -16,7 +16,7 @@ messages between programs.
        Its behavior is programmed by a
        .I plumbing
        file (default
       -.BR /usr/$user/lib/plumbing )
       +.BR $HOME/lib/plumbing )
        in the format of
        .IR plumb (7).
        .PP
       t@@ -96,9 +96,9 @@ 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).
        .SH FILES
       -.TF /usr/$user/lib/plumbing
       +.TF $HOME/lib/plumbing
        .TP
       -.B /usr/$user/lib/plumbing
       +.B $HOME/lib/plumbing
        default rules file
        .TP
        .B \*9/plumb
 (DIR) diff --git a/man/man7/INDEX b/man/man7/INDEX
       t@@ -9,7 +9,6 @@ ms ms.7
        plot plot.7
        plumb plumb.7
        regexp regexp.7
       -regexp9 regexp9.7
        thumbprint thumbprint.7
        ASCII utf.7
        UTF utf.7
 (DIR) diff --git a/man/man7/font.7 b/man/man7/font.7
       t@@ -76,9 +76,9 @@ characters of zero width (see
        means that fonts should have, as their zeroth character,
        one with non-zero width.
        .SH FILES
       -.TF /lib/font/bit/*
       +.TF \*9/font/*
        .TP
       -.B /lib/font/bit/*
       +.B \*9/font/*
        font directories
        .SH "SEE ALSO"
        .IR graphics (3),
 (DIR) diff --git a/man/man7/man.7 b/man/man7/man.7
       t@@ -108,7 +108,9 @@ Change to default type size.
        .B \e*9
        The root directory of the Plan 9 installation.
        .SH FILES
       -.B /sys/lib/tmac/tmac.an
       +.B \*9/tmac/tmac.an
       +.PP
       +.B \*9/tmac/tmac.antimes
        .SH SEE ALSO
        .IR troff (1), 
        .IR man (1)
       t@@ -244,7 +246,7 @@ into handling literal double quote marks
        .B \&"
        in font-alternation macros, such as
        .LR .BI .
       -.br
       +.PP
        There is no direct way to suppress column widows in 2-column
        output; the column lengths may be adjusted by inserting
        .L .sp
 (DIR) diff --git a/man/man7/ms.7 b/man/man7/ms.7
       t@@ -46,7 +46,7 @@ and
        preprocessors
        for equations, tables, pictures, and graphs is acceptable as input.
        .SH FILES
       -.B /sys/lib/tmac/tmac.s
       +.B \*9/tmac/tmac.s
        .SH "SEE ALSO"
        .br
        M. E. Lesk,
 (DIR) diff --git a/man/man7/plumb.7 b/man/man7/plumb.7
       t@@ -396,24 +396,24 @@ editor = acme
        include basic
        .EE
        .SH FILES
       -.TF /usr/$user/lib/plumbing
       +.TF $HOME/lib/plumbing
        .TP
       -.B /usr/$user/lib/plumbing
       +.B $HOME/lib/plumbing
        default rules file.
        .TP
       -.B /mnt/plumb
       -mount point for
       +.B plumb
       +service name for
        .IR plumber (4).
        .TP
       -.B /sys/lib/plumb
       +.B \*9/plumb
        directory for
        .B include
        files.
        .TP
       -.B /sys/lib/plumb/fileaddr
       +.B \*9/plumb/fileaddr
        public macro definitions.
        .TP
       -.B /sys/lib/plumb/basic
       +.B \*9/plumb/basic
        basic rule set.
        .SH "SEE ALSO"
        .IR plumb (1),
 (DIR) diff --git a/man/man7/regexp.7 b/man/man7/regexp.7
       t@@ -1,21 +1,4 @@
        .TH REGEXP 7
       -.de EX
       -.nf
       -.ft B
       -..
       -.de EE
       -.fi
       -.ft R
       -..
       -.de LR
       -.if t .BR \\$1 \\$2
       -.if n .RB ` \\$1 '\\$2
       -..
       -.de L
       -.nh
       -.if t .B \\$1
       -.if n .RB ` \\$1 '
       -..
        .SH NAME
        regexp \- Plan 9 regular expression notation
        .SH DESCRIPTION
 (DIR) diff --git a/man/man8/mk9660.8 b/man/man8/mk9660.8
       t@@ -2,7 +2,7 @@
        .SH NAME
        dump9660, mk9660 \- create an ISO-9660 CD image
        .SH SYNOPSIS
       -.B disk/mk9660
       +.B mk9660
        [
        .B -:D
        ]
       t@@ -27,7 +27,7 @@ volume
        ]
        .I image
        .PP
       -.B disk/dump9660
       +.B dump9660
        [
        .B -:D
        ]
       t@@ -63,7 +63,7 @@ an ISO-9660 CD image containing the
        files named in
        .I proto
        (by default,
       -.BR /sys/lib/sysconfig/proto/allproto )
       +.BR \*9/proto/allproto )
        from the file tree
        .I src
        (by default,
       t@@ -218,8 +218,7 @@ Plan 9 extensions in the system use fields, and
        a Joliet directory tree.
        .IP
        .EX
       -disk/mk9660 -9cj -s /n/bootes \e
       -        -p /sys/lib/sysconfig/srcproto cdimage
       +mk9660 -9cj -s /n/bootes -p srcproto cdimage
        .EE
        .SH SOURCE
        \*9/src/cmd/9660
 (DIR) diff --git a/man/secindex b/man/secindex
       t@@ -2,7 +2,7 @@
        builtin cd $1
        for (i in [a-z0-9:]*) {
                b=`{echo $i | sed 's/\..*//'}
       -        9sed -n '
       +        9 sed -n '
                /SH *NAM/,/SH/{
                        /SH/d
                        s/, *$//
       t@@ -34,4 +34,4 @@ for (i in [a-z0-9:]*) {
                q
        ' $i
        echo $b $i
       -} |sort -u
       +} |9 sort -u
 (DIR) diff --git a/rcmain b/rcmain
       t@@ -13,6 +13,7 @@ if(~ $rcname ?.out ?.rc */?.rc */?.out) prompt=('broken! ' '        ')
        if(flag p) path=(/bin /usr/bin)
        if not{
                finit
       +        # should be taken care of by rc now, but leave just in case
                if(~ $#path 0) {
                        path=(/bin /usr/bin)
                        eval `{sh -c 'echo $PATH |
 (DIR) diff --git a/src/cmd/9660/dump9660.c b/src/cmd/9660/dump9660.c
       t@@ -21,9 +21,9 @@ void
        usage(void)
        {
                if(mk9660)
       -                fprint(2, "usage: disk/mk9660 [-D:] [-9cjr] [-b bootfile] [-p proto] [-s src] cdimage\n");
       +                fprint(2, "usage: mk9660 [-D:] [-9cjr] [-b bootfile] [-p proto] [-s src] cdimage\n");
                else
       -                fprint(2, "usage: disk/dump9660 [-D:] [-9cjr] [-m maxsize] [-n now] [-p proto] [-s src] cdimage\n");
       +                fprint(2, "usage: dump9660 [-D:] [-9cjr] [-m maxsize] [-n now] [-p proto] [-s src] cdimage\n");
                exits("usage");
        }
        
       t@@ -42,7 +42,7 @@ main(int argc, char **argv)
                fix = 0;
                status = nil;
                memset(&info, 0, sizeof info);
       -        proto = "/sys/lib/sysconfig/proto/allproto";
       +        proto = unsharp("#9/proto/allproto");
                src = "./";
        
                info.volumename = atom("9CD");
 (DIR) diff --git a/src/cmd/acid/main.c b/src/cmd/acid/main.c
       t@@ -357,7 +357,7 @@ userinit(void)
        
                sprint(buf, "#9/acid/%s", mach->name);
                loadmodule(unsharp(buf));
       -        p = getenv("home");
       +        p = getenv("HOME");
                if(p != 0) {
                        sprint(buf, "%s/lib/acid", p);
                        silent = 1;
 (DIR) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
       t@@ -123,9 +123,7 @@ threadmain(int argc, char *argv[])
                quotefmtinstall();
                cputype = getenv("cputype");
                objtype = getenv("objtype");
       -        home = getenv("home");
       -        if(home == nil)
       -                home = getenv("HOME");
       +        home = getenv("HOME");
                p = getenv("tabstop");
                if(p != nil){
                        maxtab = strtoul(p, nil, 0);
 (DIR) diff --git a/src/cmd/bc.y b/src/cmd/bc.y
       t@@ -961,7 +961,7 @@ main(int argc, char **argv)
                if(lflag) {
                        argv--;
                        argc++;
       -                argv[1] = "/sys/lib/bclib";
       +                argv[1] = unsharp("#9/lib/bclib");
                }
                if(cflag) {
                        yyinit(argc, argv);
 (DIR) diff --git a/src/cmd/calendar.c b/src/cmd/calendar.c
       t@@ -75,7 +75,7 @@ main(int argc, char *argv[])
                for(i=0; i<argc || (i==0 && argc==0); i++){
                        if(i==0 && argc==0)
                                snprint(buf, sizeof(buf),
       -                                "/usr/%s/lib/calendar", getuser());
       +                                "%s/lib/calendar", getenv("HOME"));
                        else
                                strcpy(buf, argv[i]);
                        fd = open(buf, OREAD);
 (DIR) diff --git a/src/cmd/dict/dict.h b/src/cmd/dict/dict.h
       t@@ -134,6 +134,9 @@ void        movieprintkey(void);
        long        pgwnextoff(long);
        void        pgwprintentry(Entry,int);
        void        pgwprintkey(void);
       +void        rogetprintentry(Entry, int);
       +long        rogetnextoff(long);
       +void        rogetprintkey(void);
        long        slangnextoff(long);
        void        slangprintentry(Entry, int);
        void        slangprintkey(void);
 (DIR) diff --git a/src/cmd/dict/mkfile b/src/cmd/dict/mkfile
       t@@ -2,7 +2,7 @@
        
        TARG=dict
        LFILES=oed.$O ahd.$O pcollins.$O pcollinsg.$O movie.$O slang.$O robert.$O\
       -        world.$O jis208.$O gb2312.$O thesaurus.$O simple.$O pgw.$O
       +        world.$O jis208.$O gb2312.$O thesaurus.$O simple.$O pgw.$O roget.$O\
        
        OFILES=dict.$O\
                $LFILES\
 (DIR) diff --git a/src/cmd/dict/roget.c b/src/cmd/dict/roget.c
       t@@ -0,0 +1,147 @@
       +#include <u.h>
       +#include <libc.h>
       +#include <bio.h>
       +#include <ctype.h>
       +#include "dict.h"
       +
       +/* Roget's Thesaurus from project Gutenberg */
       +
       +/* static long Last = 0; */
       +
       +void
       +rogetprintentry(Entry e, int cmd)
       +{
       +        int spc;
       +        char c, *p;
       +
       +        spc = 0;
       +        p = e.start;
       +
       +        if(cmd == 'h'){
       +                while(!isspace(*p) && p < e.end)
       +                        p++;
       +                while(strncmp(p, " -- ", 4) != 0 && p < e.end){
       +                        while(isspace(*p) && p < e.end)
       +                                p++;
       +                        if (*p == '[' || *p == '{'){        
       +                                c = (*p == '[')? ']': '}';
       +                                while(*p != c && p < e.end)
       +                                        p++;
       +                                p++;
       +                                continue;
       +                        }
       +                        if (isdigit(*p) || ispunct(*p)){
       +                                while(!isspace(*p) && p < e.end)
       +                                        p++;
       +                                continue;
       +                        }
       +
       +
       +                        if (isspace(*p))
       +                                spc = 1;
       +                        else
       +                        if (spc){
       +                                outchar(' ');
       +                                spc = 0;
       +                        }
       +
       +                        while(!isspace(*p) && p < e.end)
       +                                outchar(*p++);
       +                }
       +                return;
       +        }        
       +
       +        while(p < e.end && !isspace(*p))
       +                p++;
       +        while(p < e.end && isspace(*p))
       +                p++;
       +
       +        while (p < e.end){
       +                if (p < e.end -4 && strncmp(p, " -- ", 4) == 0){        /* first line */
       +                        outnl(2);
       +                        p += 4;
       +                        spc = 0;
       +                }
       +                        
       +                if (p < e.end -2 && strncmp(p, "[ ", 4) == 0){                /* twiddle layout */
       +                        outchars(" [");
       +                        continue;
       +                }
       +
       +                if (p < e.end -4 && strncmp(p, "&c (", 4) == 0){        /* usefull xref */
       +                        if (spc)
       +                                outchar(' ');
       +                        outchar('/');
       +                        while(p < e.end && *p != '(')
       +                                p++;
       +                        p++;
       +                        while(p < e.end && *p != ')')
       +                                outchar(*p++);
       +                        p++;
       +                        while(p < e.end && isspace(*p))
       +                                p++;
       +                        while(p < e.end && isdigit(*p))
       +                                p++;
       +                        outchar('/');
       +                        continue;
       +                }
       +
       +                if (p < e.end -3 && strncmp(p, "&c ", 3) == 0){                /* less usefull xref */
       +                        while(p < e.end && !isdigit(*p))
       +                                p++;
       +                        while(p < e.end && isdigit(*p))
       +                                p++;
       +                        continue;
       +                }
       +
       +                if (*p == '\n' && p < (e.end -1)){                        /* their newlines */
       +                        spc = 0;
       +                        p++;
       +                        if (isspace(*p)){                                /* their continuation line */
       +                                while (isspace(*p))
       +                                        p++;
       +                                p--;
       +                        }
       +                        else{
       +                                outnl(2);
       +                        }
       +                }
       +                if (spc && *p != ';' && *p != '.' &&
       +                    *p != ',' && !isspace(*p)){                                /* drop spaces before punct */
       +                        spc = 0;
       +                        outchar(' ');
       +                }
       +                if (isspace(*p))
       +                        spc = 1;
       +                else
       +                        outchar(*p);
       +                p++;
       +        }
       +        outnl(0);
       +}
       +
       +long
       +rogetnextoff(long fromoff)
       +{
       +        int i;
       +        vlong l;
       +        char *p;
       +
       +        Bseek(bdict, fromoff, 0);
       +        Brdline(bdict, '\n');
       +        while ((p = Brdline(bdict, '\n')) != nil){
       +                l = Blinelen(bdict);
       +                if (!isdigit(*p))
       +                        continue;
       +                for (i = 0; i < l-4; i++)
       +                        if (strncmp(p+i, " -- ", 4) == 0)
       +                                return Boffset(bdict)-l;
       +        }
       +        return Boffset(bdict);
       +}
       +
       +void
       +rogetprintkey(void)
       +{
       +        Bprint(bout, "No pronunciation key.\n");
       +}
 (DIR) diff --git a/src/cmd/dict/utils.c b/src/cmd/dict/utils.c
       t@@ -16,6 +16,9 @@ Dict dicts[] = {
                {"thesaurus",        "Collins Thesaurus",
                 "#9/dict/thesaurus",        "#9/dict/thesindex",
                 thesnextoff,        thesprintentry,        thesprintkey},
       +        {"roget",                "Project Gutenberg Roget's Thesaurus",
       +         "#9/dict/roget", "#9/dict/rogetindex",
       +         rogetnextoff,        rogetprintentry,        rogetprintkey},
        
                {"ce",                "Gendai Chinese->English",
                 "#9/dict/world/sansdata/sandic24.dat",
 (DIR) diff --git a/src/cmd/draw/iconv.c b/src/cmd/draw/iconv.c
       t@@ -0,0 +1,102 @@
       +#include <u.h>
       +#include <libc.h>
       +#include <draw.h>
       +#include <memdraw.h>
       +
       +void
       +usage(void)
       +{
       +        fprint(2, "usage: iconv [-u] [-c chanstr] [file]\n");
       +        exits("usage");
       +}
       +
       +void
       +writeuncompressed(int fd, Memimage *m)
       +{
       +        char chanstr[32];
       +        int bpl, y, j;
       +        uchar *buf;
       +
       +        if(chantostr(chanstr, m->chan) == nil)
       +                sysfatal("can't convert channel descriptor: %r");
       +        fprint(fd, "%11s %11d %11d %11d %11d ",
       +                chanstr, m->r.min.x, m->r.min.y, m->r.max.x, m->r.max.y);
       +
       +        bpl = bytesperline(m->r, m->depth);
       +        buf = malloc(bpl);
       +        if(buf == nil)
       +                sysfatal("malloc failed: %r");
       +        for(y=m->r.min.y; y<m->r.max.y; y++){
       +                j = unloadmemimage(m, Rect(m->r.min.x, y, m->r.max.x, y+1), buf, bpl);
       +                if(j != bpl)
       +                        sysfatal("image unload failed: %r");
       +                if(write(fd, buf, bpl) != bpl)
       +                        sysfatal("write failed: %r");
       +        }
       +        free(buf);
       +}
       +
       +void
       +main(int argc, char *argv[])
       +{
       +        char *tostr, *file;
       +        int fd, uncompressed;
       +        ulong tochan;
       +        Memimage *m, *n;
       +
       +        tostr = nil;
       +        uncompressed = 0;
       +        ARGBEGIN{
       +        case 'c':
       +                tostr = EARGF(usage());
       +                break;
       +        case 'u':
       +                uncompressed = 1;
       +                break;
       +        default:
       +                usage();
       +        }ARGEND
       +
       +        memimageinit();
       +
       +        file = "<stdin>";
       +        m = nil;
       +
       +        switch(argc){
       +        case 0:
       +                m = readmemimage(0);
       +                break;
       +        case 1:
       +                file = argv[0];
       +                fd = open(file, OREAD);
       +                if(fd < 0)
       +                        sysfatal("can't open %s: %r", file);
       +                m = readmemimage(fd);
       +                close(fd);
       +                break;
       +        default:
       +                usage();
       +        }
       +
       +        if(m == nil)
       +                sysfatal("can't read %s: %r", file);
       +
       +        if(tostr == nil)
       +                tochan = m->chan;
       +        else{
       +                tochan = strtochan(tostr);
       +                if(tochan == 0)
       +                        sysfatal("bad channel descriptor '%s'", tostr);
       +        }
       +
       +        n = allocmemimage(m->r, tochan);
       +        if(n == nil)
       +                sysfatal("can't allocate new image: %r");
       +
       +        memimagedraw(n, n->r, m, m->r.min, nil, ZP, S);
       +        if(uncompressed)
       +                writeuncompressed(1, n);
       +        else
       +                writememimage(1, n);
       +        exits(nil);
       +}
 (DIR) diff --git a/src/cmd/ed.c b/src/cmd/ed.c
       t@@ -146,7 +146,7 @@ main(int argc, char *argv[])
                        vflag = 0;
                }
                if(oflag) {
       -                p1 = "/fd/1";
       +                p1 = "/dev/stdout";
                        p2 = savedfile;
                        while(*p2++ = *p1++)
                                ;
 (DIR) diff --git a/src/cmd/grep/main.c b/src/cmd/grep/main.c
       t@@ -21,6 +21,9 @@ main(int argc, char *argv[])
                        flags[ARGC()]++;
                        break;
        
       +        case 'E':        /* ignore, turns gnu grep into egrep */
       +                break;
       +
                case 'e':
                        flags['e']++;
                        lineno = 0;
 (DIR) diff --git a/src/cmd/import.c b/src/cmd/import.c
       t@@ -32,7 +32,7 @@ enum
        void
        usage(void)
        {
       -        fprint(2, "usage: %s [-s service] [-n remote-ns] [-fd] [-p remote-prog] remote-system\n", argv0);
       +        fprint(2, "usage: %s [-df] [-s service] [-n remote-ns] [-p remote-prog] remote-system\n", argv0);
                exits("usage");
        }
        
 (DIR) diff --git a/src/cmd/map/map.c b/src/cmd/map/map.c
       t@@ -21,7 +21,7 @@ char *mapindex(char *);
        proj projection;
        
        
       -static char *mapdir = "/lib/map";        /* default map directory */
       +static char *mapdir = "#9/map";        /* default map directory */
        struct file {
                char *name;
                char *color;
       t@@ -150,6 +150,7 @@ main(int argc, char *argv[])
                double dd;
                if(sizeof(short)!=2)
                        abort();        /* getshort() won't work */
       +        mapdir = unsharp(mapdir);
                s = getenv("MAP");
                if(s)
                        file[0].name = s;
 (DIR) diff --git a/src/cmd/map/mapdemo.rc b/src/cmd/map/mapdemo.rc
       t@@ -9,7 +9,7 @@ fn demo {proj=$1;        shift;
                        echo t $type
                        echo 'm -8192 -8192'
                        echo t $proj - $label
       -                MAP=world MAPDIR=/lib/map map $proj $* -s -d 5
       +                MAP=world MAPDIR=$PLAN9/map map $proj $* -s -d 5
                } 
                sleep 5
        }
 (DIR) diff --git a/src/cmd/mk/mkfile.test b/src/cmd/mk/mkfile.test
       t@@ -1,9 +1,9 @@
       -|$PLAN9/bin/rc
       +MKSHELL=$PLAN9/bin/rc
        use-rc:V:
                for(i in a b c)
                        echo $i
        
       -|/bin/sh
       +MKSHELL=/bin/sh
        use-sh:V:
                for i in a b c
                do
 (DIR) diff --git a/src/cmd/mk/parse.c b/src/cmd/mk/parse.c
       t@@ -91,18 +91,18 @@ cp = wtos(tail, ' '); print("assign %s to %s\n", head->s, cp); free(cp);
        */
                                        setvar(head->s, (void *) tail);
                                        symlook(head->s, S_WESET, (void *)"");
       +                                if(strcmp(head->s, "MKSHELL") == 0){
       +                                        if((err = setshell(tail)) != nil){
       +                                                SYNERR(hline);
       +                                                fprint(2, "%s\n", err);
       +                                                Exit();
       +                                                break;
       +                                        }
       +                                }
                                }
                                if(attr)
                                        symlook(head->s, S_NOEXPORT, (void *)"");
                                break;
       -                case 'S':
       -                        if((err = setshell(tail)) != nil){
       -                                SYNERR(hline);
       -                                fprint(2, "%s\n", err);
       -                                Exit();
       -                                break;
       -                        }
       -                        break;
                        default:
                                SYNERR(hline);
                                fprint(2, "expected one of :<=\n");
       t@@ -144,19 +144,14 @@ rhead(char *line, Word **h, Word **t, int *attr, char **prog)
                int n;
                Word *w;
        
       -        if(*line == '|'){
       -                sep = 'S';        /* shell */
       -                p = line+1;
       -        }else{
       -                p = shellt->charin(line,":=<");
       -                if(p == 0)
       -                        return('?');
       -                sep = *p;
       -                *p++ = 0;
       -                if(sep == '<' && *p == '|'){
       -                        sep = '|';
       -                        p++;
       -                }
       +        p = shellt->charin(line,":=<");
       +        if(p == 0)
       +                return('?');
       +        sep = *p;
       +        *p++ = 0;
       +        if(sep == '<' && *p == '|'){
       +                sep = '|';
       +                p++;
                }
                *attr = 0;
                *prog = 0;
 (DIR) diff --git a/src/cmd/mk/shell.c b/src/cmd/mk/shell.c
       t@@ -41,6 +41,7 @@ initshell(void)
        {
                shellcmd = stow(shells[0]->name);
                shellt = shells[0];
       +        setvar("MKSHELL", shellcmd);
        }
        
        void
       t@@ -72,5 +73,6 @@ popshell(void)
                shellstack = s->next;
                shellt = s->t;
                shellcmd = s->w;
       +        setvar("MKSHELL", shellcmd);
                free(s);
        }
 (DIR) diff --git a/src/cmd/mkfile b/src/cmd/mkfile
       t@@ -1,6 +1,6 @@
        <$PLAN9/src/mkhdr
        
       -TARG=`ls *.[cy] | grep -v "\.tab\.c$" | sed 's/\.[cy]//'`
       +TARG=`ls *.[cy] | egrep -v "\.tab\.c$" | sed 's/\.[cy]//'`
        
        <$PLAN9/src/mkmany
        
 (DIR) diff --git a/src/cmd/news.c b/src/cmd/news.c
       t@@ -101,7 +101,7 @@ read_dir(int update)
                n_count = 0;
                n_list = malloc(NINC*sizeof(File));
                na = NINC;
       -        home = getenv("home");
       +        home = getenv("HOME");
                if(home) {
                        sprint(newstime, TFILE, home);
                        d = dirstat(newstime);
 (DIR) diff --git a/src/cmd/plumb/plumber.c b/src/cmd/plumb/plumber.c
       t@@ -43,9 +43,7 @@ threadmain(int argc, char *argv[])
                }ARGEND
        
                user = getuser();
       -        home = getenv("home");
       -        if(home == nil)
       -                home = getenv("HOME");
       +        home = getenv("HOME");
                if(user==nil || home==nil)
                        error("can't initialize $user or $home: %r");
                if(plumbfile == nil){
 (DIR) diff --git a/src/cmd/rc/exec.c b/src/cmd/rc/exec.c
       t@@ -90,6 +90,7 @@ var *newvar(char *name, var *next)
                v->changed=0;
                v->fnchanged=0;
                v->next=next;
       +        v->changefn = 0;
                return v;
        }
        /*
 (DIR) diff --git a/src/cmd/rm.c b/src/cmd/rm.c
       t@@ -1,4 +1,5 @@
        #include <u.h>
       +#include <sys/stat.h>
        #include <libc.h>
        
        #define rmdir p9rmdir
       t@@ -16,6 +17,13 @@ err(char *f)
                }
        }
        
       +int
       +issymlink(char *name)
       +{
       +        struct stat s;
       +        return lstat(name, &s) >= 0 && S_ISLNK(s.st_mode);
       +}
       +
        /*
         * f is a non-empty directory. Remove its contents and then it.
         */
       t@@ -48,7 +56,7 @@ rmdir(char *f)
                ndir = 0;
                for(i=0; i<n; i++){
                        snprint(name, nname, "%s/%s", f, dirbuf[i].name);
       -                if(remove(name) != -1)
       +                if(remove(name) != -1 || issymlink(name))
                                dirbuf[i].qid.type = QTFILE;        /* so we won't recurse */
                        else{
                                if(dirbuf[i].qid.type & QTDIR)
 (DIR) diff --git a/src/cmd/sam/plan9.c b/src/cmd/sam/plan9.c
       t@@ -17,7 +17,7 @@ Rune *right[]= {
        
        char        RSAM[] = "sam";
        char        SAMTERM[] = "/bin/aux/samterm";
       -char        HOME[] = "home";
       +char        HOME[] = "HOME";
        char        TMPDIR[] = "/tmp";
        char        SH[] = "rc";
        char        SHPATH[] = "/bin/rc";
 (DIR) diff --git a/src/cmd/sort.c b/src/cmd/sort.c
       t@@ -356,7 +356,7 @@ tempfile(int n)
                static uint pid;
                char *dir;
        
       -        dir = "/tmp";
       +        dir = "/var/tmp";
                if(args.tname)
                        dir = args.tname;
                if(strlen(dir) >= nelem(file)-20) {
 (DIR) diff --git a/src/libdraw/mkfile b/src/libdraw/mkfile
       t@@ -36,7 +36,6 @@ OFILES=\
                mkfont.$O\
                openfont.$O\
                poly.$O\
       -        readcolmap.$O\
                readimage.$O\
                readsubfont.$O\
                rectclip.$O\
       t@@ -52,7 +51,6 @@ OFILES=\
                subfontname.$O\
                unloadimage.$O\
                window.$O\
       -        writecolmap.$O\
                writeimage.$O\
                writesubfont.$O\
                md-alloc.$O\
 (DIR) diff --git a/src/libdraw/readcolmap.c b/src/libdraw/readcolmap.c
       t@@ -1,49 +0,0 @@
       -#include <u.h>
       -#include <libc.h>
       -#include <draw.h>
       -#include <bio.h>
       -
       -static ulong
       -getval(char **p)
       -{
       -        ulong v;
       -        char *q;
       -
       -        v = strtoul(*p, &q, 0);
       -        v |= v<<8;
       -        v |= v<<16;
       -        *p = q;
       -        return v;
       -}
       -
       -void
       -readcolmap(Display *d, RGB *colmap)
       -{
       -        int i;
       -        char *p, *q;
       -        Biobuf *b;
       -        char buf[128];
       -
       -        USED(screen);
       -
       -        sprint(buf, "/dev/draw/%d/colormap", d->dirno);
       -        b = Bopen(buf, OREAD);
       -        if(b == 0)
       -                drawerror(d, "rdcolmap: can't open colormap device");
       -
       -        for(;;) {
       -                p = Brdline(b, '\n');
       -                if(p == 0)
       -                        break;
       -                i = strtoul(p, &q, 0);
       -                if(i < 0 || i > 255) {
       -                        fprint(2, "rdcolmap: bad index\n");
       -                        exits("bad");
       -                }
       -                p = q;
       -                colmap[255-i].red = getval(&p);
       -                colmap[255-i].green = getval(&p);
       -                colmap[255-i].blue = getval(&p);
       -        }
       -        Bterm(b);
       -}
 (DIR) diff --git a/src/libdraw/writecolmap.c b/src/libdraw/writecolmap.c
       t@@ -1,35 +0,0 @@
       -#include <u.h>
       -#include <libc.h>
       -#include <draw.h>
       -
       -/*
       - * This code (and the devdraw interface) will have to change
       - * if we ever get bitmaps with ldepth > 3, because the
       - * colormap will have to be written in chunks
       - */
       -
       -void
       -writecolmap(Display *d, RGB *m)
       -{
       -        int i, n, fd;
       -        char buf[64], *t;
       -        ulong r, g, b;
       -
       -        sprint(buf, "/dev/draw/%d/colormap", d->dirno);
       -        fd = open(buf, OWRITE);
       -        if(fd < 0)
       -                drawerror(d, "wrcolmap: open colormap failed");
       -        t = malloc(8192);
       -        n = 0;
       -        for(i = 0; i < 256; i++) {
       -                r = m[i].red>>24;
       -                g = m[i].green>>24;
       -                b = m[i].blue>>24;
       -                n += sprint(t+n, "%d %lud %lud %lud\n", 255-i, r, g, b);
       -        }
       -        i = write(fd, t, n);
       -        free(t);
       -        close(fd);
       -        if(i != n)
       -                drawerror(d, "wrcolmap: bad write");
       -}
 (DIR) diff --git a/src/libdraw/x11-init.c b/src/libdraw/x11-init.c
       t@@ -346,9 +346,7 @@ xattach(char *label)
        
                        display_resources = XResourceManagerString(_x.display);
                        if(display_resources == nil){
       -                        home = getenv("home");
       -                        if(home == nil)
       -                                home = getenv("HOME");
       +                        home = getenv("HOME");
                                if(home!=nil && (file=smprint("%s/.Xdefaults", home)) != nil){
                                        XrmCombineFileDatabase(file, &database, False);
                                        free(file);
 (DIR) diff --git a/src/libthread/channel.c b/src/libthread/channel.c
       t@@ -249,6 +249,7 @@ chanalt(Alt *a)
                Channel *c;
                _Thread *t;
        
       +        needstack(512);
                for(i=0; a[i].op != CHANEND && a[i].op != CHANNOBLK; i++)
                        ;
                n = i;
 (DIR) diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c
       t@@ -42,10 +42,12 @@ child(void)
                        fprint(2, "%s: wait pid %d stopped\n", argv0, pid);
                        return;
                }
       +#ifdef WIFCONTINUED
                if(WIFCONTINUED(status)){
                        fprint(2, "%s: wait pid %d continued\n", argv0, pid);
                        return;
                }
       +#endif
                fprint(2, "%s: wait pid %d status 0x%ux\n", argv0, pid, status);
                _exit(99);
        }
       t@@ -84,8 +86,6 @@ _threadsetupdaemonize(void)
        
                sigpid = 1;
        
       -        threadlinklibrary();
       -
                if(pipe(p) < 0)
                        sysfatal("passer pipe: %r");
        
 (DIR) diff --git a/src/libthread/thread.c b/src/libthread/thread.c
       t@@ -169,6 +169,7 @@ _threadswitch(void)
        {
                Proc *p;
        
       +        needstack(0);
                p = proc();
        //print("threadswtch %p\n", p);
                contextswitch(&p->thread->context, &p->schedcontext);
       t@@ -324,6 +325,20 @@ threadsetstate(char *fmt, ...)
                va_end(arg);
        }
        
       +void
       +needstack(int n)
       +{
       +        _Thread *t;
       +
       +        t = proc()->thread;
       +
       +        if((char*)&t <= (char*)t->stk
       +        || (char*)&t - (char*)t->stk < 256+n){
       +                fprint(2, "thread stack overflow\n");
       +                abort();
       +        }
       +}
       +
        /*
         * locking
         */
       t@@ -499,11 +514,6 @@ threadmainstart(void *v)
                threadmain(threadargc, threadargv);
        }
        
       -void
       -threadlinklibrary(void)
       -{
       -}
       -
        int
        main(int argc, char **argv)
        {
 (DIR) diff --git a/tmac/tmac.anhtml b/tmac/tmac.anhtml
       t@@ -1,4 +1,4 @@
       -.so #9/tmac/tmac.an
       +.so /usr/local/plan9/tmac/tmac.an
        .de }H
        ..
        .de }F
       t@@ -9,6 +9,9 @@
        ..
        .nr LL 20i
        .dePP
       -\Xhtml <P>
       +\Xhtml manPP
        .}p
        ..
       +.am TH
       +\Xhtml manhead \\$1 \\$2
       +..
 (DIR) diff --git a/tmac/tmac.antimes b/tmac/tmac.antimes
       t@@ -484,8 +484,10 @@
        .if\nm10 .ds ]m November
        .if\nm11 .ds ]m December
        .ifn \{.nr m \nm+1
       +.nr yD (\n(yr%100
       +.af yD 01
        .ie\nd .ds ]W (last mod. \nm/\nd/\ny)
       -.el.ds ]W (printed \n(mo/\n(dy/\n(yr)
       +.el.ds ]W (printed \n(mo/\n(dy/\n(yD)
        ..\}
        .if\n()s .ds ]W
        .if\n()t \{.ie \nd .ds ]W \*(]m \nd, 20\ny