Browse Source

Plan 9 from Bell Labs 2007-02-21

David du Colombier 15 years ago
parent
commit
dc3d1f5669
7 changed files with 395 additions and 22 deletions
  1. 9 6
      dist/replica/_plan9.db
  2. 9 6
      dist/replica/plan9.db
  3. 9 0
      dist/replica/plan9.log
  4. 17 10
      rc/bin/man
  5. 55 0
      sys/man/1/col
  6. 1 0
      sys/src/9/boot/bootcache.c
  7. 295 0
      sys/src/cmd/col.c

+ 9 - 6
dist/replica/_plan9.db

@@ -1,7 +1,7 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1161230065 220860
+386/9load - 775 sys sys 1171784718 220040
 386/9loaddebug - 775 sys sys 1171917619 316230
-386/9loadlite - 775 sys sys 1161230067 137112
+386/9loadlite - 775 sys sys 1171784720 137116
 386/9loadlitedebug - 775 sys sys 1171917620 202506
 386/9pc - 775 sys sys 1161230890 1924142
 386/9pc.gz - 664 sys sys 1161232307 821176
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1161232323 903701
 386/9pcf - 775 sys sys 1161231061 2460368
 386/9pcf.gz - 664 sys sys 1161232332 1060367
-386/9pxeload - 775 sys sys 1169491686 220036
+386/9pxeload - 775 sys sys 1171784719 220040
 386/_9pcdisk.gz - 664 sys sys 1039764191 695837
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
@@ -183,6 +183,7 @@
 386/bin/cleanname - 775 sys sys 1168402295 58541
 386/bin/clock - 775 sys sys 1168402296 158688
 386/bin/cmp - 775 sys sys 1157597609 40658
+386/bin/col - 775 sys sys 1172029864 64995
 386/bin/colors - 775 sys sys 1168402296 150967
 386/bin/comm - 775 sys sys 1168402296 61586
 386/bin/compress - 775 sys sys 1159212097 166928
@@ -529,7 +530,7 @@
 386/include/u.h - 664 sys sys 1168306831 1510
 386/include/ureg.h - 664 sys sys 944946012 523
 386/init - 775 sys sys 1168402360 101418
-386/ld.com - 775 sys sys 1161230065 73464
+386/ld.com - 775 sys sys 1171784723 73464
 386/lib - 20000000775 sys sys 1016826328 0
 386/lib/ape - 20000000775 sys sys 1070519112 0
 386/lib/ape/lib9.a - 664 sys sys 1135531447 6906
@@ -5463,7 +5464,7 @@ rc/bin/leak - 775 sys sys 1139744263 1052
 rc/bin/lookman - 775 sys sys 1017679344 686
 rc/bin/lp - 775 sys sys 1162105982 5201
 rc/bin/mail - 775 sys sys 1045504003 138
-rc/bin/man - 775 sys sys 1168305408 2538
+rc/bin/man - 775 sys sys 1172005212 2494
 rc/bin/map - 775 sys sys 945617207 1576
 rc/bin/mapdemo - 775 sys sys 945617207 4075
 rc/bin/membername - 775 sys sys 945617207 89
@@ -7287,6 +7288,7 @@ sys/man/1/chgrp - 664 sys sys 944959673 710
 sys/man/1/chmod - 664 sys sys 1079372922 1299
 sys/man/1/cleanname - 664 sys sys 944959674 580
 sys/man/1/cmp - 664 sys sys 1134330626 1069
+sys/man/1/col - 664 sys sys 1172005089 962
 sys/man/1/colors - 664 sys sys 1134330626 1438
 sys/man/1/comm - 664 sys sys 944959675 665
 sys/man/1/con - 664 sys sys 1155994747 4310
@@ -7877,7 +7879,7 @@ sys/src/9/boot/aux.c - 664 sys sys 1168305725 2586
 sys/src/9/boot/boot.c - 664 sys sys 1146746630 6013
 sys/src/9/boot/boot.h - 664 sys sys 1063857659 1785
 sys/src/9/boot/bootauth.c - 664 sys sys 1131289783 1160
-sys/src/9/boot/bootcache.c - 664 sys sys 1063857645 1579
+sys/src/9/boot/bootcache.c - 664 sys sys 1171955975 1608
 sys/src/9/boot/bootip.c - 664 sys sys 1072972133 3418
 sys/src/9/boot/bootmkfile - 664 sys sys 1091732792 404
 sys/src/9/boot/doauthenticate.c - 664 sys sys 1015012529 2300
@@ -9898,6 +9900,7 @@ sys/src/cmd/chmod.c - 664 sys sys 1079372923 1904
 sys/src/cmd/cleanname.c - 664 sys sys 944960760 715
 sys/src/cmd/clock.c - 664 sys sys 1014925410 1881
 sys/src/cmd/cmp.c - 664 sys sys 1157581072 2491
+sys/src/cmd/col.c - 664 sys sys 1172005084 3850
 sys/src/cmd/colors.c - 664 sys sys 951763912 3186
 sys/src/cmd/comm.c - 664 sys sys 1093979717 2140
 sys/src/cmd/compress - 20000000775 sys sys 1157679448 0

+ 9 - 6
dist/replica/plan9.db

@@ -1,7 +1,7 @@
 386 - 20000000775 sys sys 1010957353 0
-386/9load - 775 sys sys 1161230065 220860
+386/9load - 775 sys sys 1171784718 220040
 386/9loaddebug - 775 sys sys 1171917619 316230
-386/9loadlite - 775 sys sys 1161230067 137112
+386/9loadlite - 775 sys sys 1171784720 137116
 386/9loadlitedebug - 775 sys sys 1171917620 202506
 386/9pc - 775 sys sys 1161230890 1924142
 386/9pc.gz - 664 sys sys 1161232307 821176
@@ -11,7 +11,7 @@
 386/9pcdisk.gz - 664 sys sys 1161232323 903701
 386/9pcf - 775 sys sys 1161231061 2460368
 386/9pcf.gz - 664 sys sys 1161232332 1060367
-386/9pxeload - 775 sys sys 1169491686 220036
+386/9pxeload - 775 sys sys 1171784719 220040
 386/_9pcdisk.gz - 664 sys sys 1039764191 695837
 386/bin - 20000000775 sys sys 1018897690 0
 386/bin/8a - 775 sys sys 1168402260 116604
@@ -183,6 +183,7 @@
 386/bin/cleanname - 775 sys sys 1168402295 58541
 386/bin/clock - 775 sys sys 1168402296 158688
 386/bin/cmp - 775 sys sys 1157597609 40658
+386/bin/col - 775 sys sys 1172029864 64995
 386/bin/colors - 775 sys sys 1168402296 150967
 386/bin/comm - 775 sys sys 1168402296 61586
 386/bin/compress - 775 sys sys 1159212097 166928
@@ -529,7 +530,7 @@
 386/include/u.h - 664 sys sys 1168306831 1510
 386/include/ureg.h - 664 sys sys 944946012 523
 386/init - 775 sys sys 1168402360 101418
-386/ld.com - 775 sys sys 1161230065 73464
+386/ld.com - 775 sys sys 1171784723 73464
 386/lib - 20000000775 sys sys 1016826328 0
 386/lib/ape - 20000000775 sys sys 1070519112 0
 386/lib/ape/lib9.a - 664 sys sys 1135531447 6906
@@ -5463,7 +5464,7 @@ rc/bin/leak - 775 sys sys 1139744263 1052
 rc/bin/lookman - 775 sys sys 1017679344 686
 rc/bin/lp - 775 sys sys 1162105982 5201
 rc/bin/mail - 775 sys sys 1045504003 138
-rc/bin/man - 775 sys sys 1168305408 2538
+rc/bin/man - 775 sys sys 1172005212 2494
 rc/bin/map - 775 sys sys 945617207 1576
 rc/bin/mapdemo - 775 sys sys 945617207 4075
 rc/bin/membername - 775 sys sys 945617207 89
@@ -7287,6 +7288,7 @@ sys/man/1/chgrp - 664 sys sys 944959673 710
 sys/man/1/chmod - 664 sys sys 1079372922 1299
 sys/man/1/cleanname - 664 sys sys 944959674 580
 sys/man/1/cmp - 664 sys sys 1134330626 1069
+sys/man/1/col - 664 sys sys 1172005089 962
 sys/man/1/colors - 664 sys sys 1134330626 1438
 sys/man/1/comm - 664 sys sys 944959675 665
 sys/man/1/con - 664 sys sys 1155994747 4310
@@ -7877,7 +7879,7 @@ sys/src/9/boot/aux.c - 664 sys sys 1168305725 2586
 sys/src/9/boot/boot.c - 664 sys sys 1146746630 6013
 sys/src/9/boot/boot.h - 664 sys sys 1063857659 1785
 sys/src/9/boot/bootauth.c - 664 sys sys 1131289783 1160
-sys/src/9/boot/bootcache.c - 664 sys sys 1063857645 1579
+sys/src/9/boot/bootcache.c - 664 sys sys 1171955975 1608
 sys/src/9/boot/bootip.c - 664 sys sys 1072972133 3418
 sys/src/9/boot/bootmkfile - 664 sys sys 1091732792 404
 sys/src/9/boot/doauthenticate.c - 664 sys sys 1015012529 2300
@@ -9898,6 +9900,7 @@ sys/src/cmd/chmod.c - 664 sys sys 1079372923 1904
 sys/src/cmd/cleanname.c - 664 sys sys 944960760 715
 sys/src/cmd/clock.c - 664 sys sys 1014925410 1881
 sys/src/cmd/cmp.c - 664 sys sys 1157581072 2491
+sys/src/cmd/col.c - 664 sys sys 1172005084 3850
 sys/src/cmd/colors.c - 664 sys sys 951763912 3186
 sys/src/cmd/comm.c - 664 sys sys 1093979717 2140
 sys/src/cmd/compress - 20000000775 sys sys 1157679448 0

+ 9 - 0
dist/replica/plan9.log

@@ -47516,3 +47516,12 @@
 1171830606 9 c 386/lib/libauthsrv.a - 664 sys sys 1171830301 35838
 1171918807 0 c 386/9loaddebug - 775 sys sys 1171917619 316230
 1171918807 1 c 386/9loadlitedebug - 775 sys sys 1171917620 202506
+1171956606 0 c 386/9load - 775 sys sys 1171784718 220040
+1171956606 1 c 386/9loadlite - 775 sys sys 1171784720 137116
+1171956606 2 c 386/9pxeload - 775 sys sys 1171784719 220040
+1171956606 3 c 386/ld.com - 775 sys sys 1171784723 73464
+1171956606 4 c sys/src/9/boot/bootcache.c - 664 sys sys 1171955975 1608
+1172005206 0 c rc/bin/man - 775 sys sys 1172005212 2494
+1172005206 1 a sys/man/1/col - 664 sys sys 1172005089 962
+1172005206 2 a sys/src/cmd/col.c - 664 sys sys 1172005084 3850
+1172030406 0 a 386/bin/col - 775 sys sys 1172029864 64995

+ 17 - 10
rc/bin/man

@@ -1,5 +1,5 @@
 #!/bin/rc
-
+# man - print manual pages
 rfork e
 
 . /sys/man/fonts
@@ -11,6 +11,7 @@ d=0
 
 fn roff {
 	preproc=()
+	postproc=cat
 	x=`{doctype $2}
 	if (~ $1 t) {
 		if(~ $x *grap*)
@@ -21,23 +22,28 @@ fn roff {
 	}
 	if not {
 		Nflag=-N
+		if (grep -s '^\.2C' $2)
+			postproc=col
 	}
 	if(~ $x *eqn*)
 		preproc=($preproc eqn)
 	if(~ $x *tbl*)
 		preproc=($preproc tbl)
-	switch($#preproc) {
+	{echo -n $FONTS; cat $2 </dev/null} |
+		switch($#preproc) {
 		case 0
-			{echo -n $FONTS; cat $2< /dev/null} | troff $Nflag -$MAN 
+			troff $Nflag -$MAN 
 		case 1
-			{echo -n $FONTS; cat $2< /dev/null} | $preproc | troff $Nflag -$MAN
+			$preproc | troff $Nflag -$MAN
 		case 2
-			{echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | troff $Nflag -$MAN
+			$preproc(1) | $preproc(2) | troff $Nflag -$MAN
 		case 3
-			{echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | $preproc(3) | troff $Nflag -$MAN
+			$preproc(1) | $preproc(2) | $preproc(3) |
+				troff $Nflag -$MAN
 		case *
-			{echo -n $FONTS; cat $2< /dev/null} | $preproc(1) | $preproc(2) | $preproc(3) | $preproc(4) | troff $Nflag -$MAN
-	}
+			$preproc(1) | $preproc(2) | $preproc(3) |
+				$preproc(4) | troff $Nflag -$MAN
+		} | $postproc
 }
 
 fn page {
@@ -58,7 +64,8 @@ while(~ $d 0) {
 		sec=($sec $1)
 		shift
 	}
-	if not switch($1) {
+	if not
+		switch($1) {
 		case -t ; cmd=t ; shift
 		case -n ; cmd=n ; shift
 		case -p ; cmd=p ; shift
@@ -67,7 +74,7 @@ while(~ $d 0) {
 		case -b ; cmd=b ; shift
 		case -S ; search=no ; shift
 		case * ; d=1
-	}
+		}
 }
 if(~ $#sec 0) {
 	sec=`{ls -pd $S/[0-9]* }

+ 55 - 0
sys/man/1/col

@@ -0,0 +1,55 @@
+.TH COL 1
+.SH NAME
+col \- column alignment
+.SH SYNOPSIS
+.B col
+[
+.B -bfx 
+]
+.SH DESCRIPTION
+.I Col
+overlays lines to expunge reverse line feeds
+(ESC-7)
+and half line feeds (ESC-9 and ESC-8)
+as produced by
+.I nroff
+for .2C in
+.IR ms (6)
+or
+.IR man (6)
+and for 
+.IR tbl (1).
+.I Col
+is a pure filter.
+It normally emits only full line feeds;
+option 
+.B -f
+(fine) allows half line feeds too.
+Option 
+.B -b
+removes backspaces, printing just one of each pile of overstruck
+characters.
+.I Col
+normally converts white space to tabs;
+option
+.B -x
+overrides this feature.
+Other escaped characters and non-printing characters are ignored.
+.SH EXAMPLES
+.TP
+.L
+tbl file | nroff -ms | col | p
+Format some tables for printing on typewriters;
+use
+.I col
+to remove reverse line feeds, and 
+paginate the output.
+.SH SEE ALSO
+.IR pr (1)
+.SH BUGS
+.I Col
+can't back up more than 128 lines or
+handle more than 800 characters per line,
+and understands
+.L VT
+(013) as reverse line feed.

+ 1 - 0
sys/src/9/boot/bootcache.c

@@ -15,6 +15,7 @@ cache(int fd)
 
 	*partition = 0;
 
+	bind("#S", "/dev", MAFTER);
 	readfile("#e/cfs", buf, sizeof(buf));
 	if(*buf){
 		argc = tokenize(buf, argv, 4);

+ 295 - 0
sys/src/cmd/col.c

@@ -0,0 +1,295 @@
+/* col - eliminate reverse line feeds */
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+#include <bio.h>
+
+enum {
+	ESC	= '\033',
+	RLF	= '\013',
+
+	PL	= 256,
+	LINELN	= 800,
+
+	Tabstop	= 8,		/* must be power of 2 */
+};
+
+static int bflag, xflag, fflag;
+static int cp, lp;
+static int half;
+static int ll, llh, mustwr;
+static int pcp = 0;
+
+static char *page[PL];
+static char *line;
+static char lbuff[LINELN];
+static Biobuf bin, bout;
+
+void	emit(char *s, int lineno);
+void	incr(void), decr(void);
+void	outc(Rune);
+
+static void
+usage(void)
+{
+	fprint(2, "usage: %s [-bfx]\n", argv0);
+	exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+	int i, lno;
+	long ch;
+	Rune c;
+
+	ARGBEGIN{
+	case 'b':
+		bflag++;
+		break;
+	case 'f':
+		fflag++;
+		break;
+	case 'x':
+		xflag++;
+		break;
+	default:
+		usage();
+	}ARGEND;
+
+	for (ll=0; ll < PL; ll++)
+		page[ll] = nil;
+
+	cp = 0;
+	ll = 0;
+	mustwr = PL;
+	line = lbuff;
+
+	Binit(&bin, 0, OREAD);
+	Binit(&bout, 1, OWRITE);
+	while ((ch = Bgetrune(&bin)) != Beof) {
+		c = ch;
+		switch (c) {
+		case '\n':
+			incr();
+			incr();
+			cp = 0;
+			break;
+
+		case '\0':
+			break;
+
+		case ESC:
+			c = Bgetrune(&bin);
+			switch (c) {
+			case '7':	/* reverse full line feed */
+				decr();
+				decr();
+				break;
+
+			case '8':	/* reverse half line feed */
+				if (fflag)
+					decr();
+				else
+					if (--half < -1) {
+						decr();
+						decr();
+						half += 2;
+					}
+				break;
+
+			case '9':	/* forward half line feed */
+				if (fflag)
+					incr();
+				else
+					if (++half > 0) {
+						incr();
+						incr();
+						half -= 2;
+					}
+				break;
+			}
+			break;
+
+		case RLF:
+			decr();
+			decr();
+			break;
+
+		case '\r':
+			cp = 0;
+			break;
+
+		case '\t':
+			cp = (cp + Tabstop) & -Tabstop;
+			break;
+
+		case '\b':
+			if (cp > 0)
+				cp--;
+			break;
+
+		case ' ':
+			cp++;
+			break;
+
+		default:
+			if (!isascii(c) || isprint(c)) {
+				outc(c);
+				cp++;
+			}
+			break;
+		}
+	}
+
+	for (i=0; i < PL; i++) {
+		lno = (mustwr+i) % PL;
+		if (page[lno] != 0)
+			emit(page[lno], mustwr+i-PL);
+	}
+	emit(" ", (llh + 1) & -2);
+	exits(0);
+}
+
+void
+outc(Rune c)
+{
+	if (lp > cp) {
+		line = lbuff;
+		lp = 0;
+	}
+
+	while (lp < cp) {
+		switch (*line) {
+		case '\0':
+			*line = ' ';
+			lp++;
+			break;
+		case '\b':
+			lp--;
+			break;
+		default:
+			lp++;
+			break;
+		}
+		line++;
+	}
+	while (*line == '\b')
+		line += 2;
+	if (bflag || *line == '\0' || *line == ' ')
+		*line = c;
+	else {
+		char c1, c2, c3;
+
+		c1 = *++line;
+		*line++ = '\b';
+		c2 = *line;
+		*line++ = c;
+		while (c1) {
+			c3 = *line;
+			*line++ = c1;
+			c1 = c2;
+			c2 = c3;
+		}
+		lp = 0;
+		line = lbuff;
+	}
+}
+
+void
+store(int lno)
+{
+	lno %= PL;
+	if (page[lno] != nil)
+		free(page[lno]);
+	page[lno] = malloc((unsigned)strlen(lbuff) + 2);
+	if (page[lno] == nil)
+		sysfatal("out of memory");
+	strcpy(page[lno], lbuff);
+}
+
+void
+fetch(int lno)
+{
+	char *p;
+
+	lno %= PL;
+	p = lbuff;
+	while (*p)
+		*p++ = '\0';
+	line = lbuff;
+	lp = 0;
+	if (page[lno])
+		strcpy(line, page[lno]);
+}
+
+void
+emit(char *s, int lineno)
+{
+	int ncp;
+	char *p;
+	static int cline = 0;
+
+	if (*s) {
+		while (cline < lineno - 1) {
+			Bputrune(&bout, '\n');
+			pcp = 0;
+			cline += 2;
+		}
+		if (cline != lineno) {
+			Bputrune(&bout, ESC);
+			Bputrune(&bout, '9');
+			cline++;
+		}
+		if (pcp)
+			Bputrune(&bout, '\r');
+		pcp = 0;
+		p = s;
+		while (*p) {
+			ncp = pcp;
+			while (*p++ == ' ')
+				if ((++ncp & 7) == 0 && !xflag) {
+					pcp = ncp;
+					Bputrune(&bout, '\t');
+				}
+			if (!*--p)
+				break;
+			while (pcp < ncp) {
+				Bputrune(&bout, ' ');
+				pcp++;
+			}
+			Bputrune(&bout, *p);
+			if (*p++ == '\b')
+				pcp--;
+			else
+				pcp++;
+		}
+	}
+}
+
+void
+incr(void)
+{
+	int lno;
+
+	store(ll++);
+	if (ll > llh)
+		llh = ll;
+	lno = ll % PL;
+	if (ll >= mustwr && page[lno]) {
+		emit(page[lno], ll - PL);
+		mustwr++;
+		free(page[lno]);
+		page[lno] = nil;
+	}
+	fetch(ll);
+}
+
+void
+decr(void)
+{
+	if (ll > mustwr - PL) {
+		store(ll--);
+		fetch(ll);
+	}
+}