Browse Source

Plan 9 from Bell Labs 2008-03-04

David du Colombier 13 years ago
parent
commit
5a9b20f8e4

+ 5 - 4
dist/replica/_plan9.db

@@ -12543,7 +12543,7 @@ sys/src/cmd/ip/ipconfig - 20000000775 sys sys 1176933436 0
 sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1198189129 5311
 sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1198189135 20619
 sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1204178443 40237
-sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1184880750 233
+sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1204591120 575
 sys/src/cmd/ip/ipconfig/ppp.c - 664 sys sys 1184880751 1046
 sys/src/cmd/ip/linklocal.c - 664 sys sys 1197673397 1751
 sys/src/cmd/ip/measure.c - 664 sys sys 944961011 3733
@@ -13196,12 +13196,12 @@ sys/src/cmd/pr.c - 664 sys sys 1168307016 11172
 sys/src/cmd/primes.c - 664 sys sys 1172257895 2471
 sys/src/cmd/prof.c - 664 sys sys 1124305301 5547
 sys/src/cmd/proof - 20000000775 sys sys 1039727677 0
-sys/src/cmd/proof/font.c - 664 sys sys 944961621 8525
+sys/src/cmd/proof/font.c - 664 sys sys 1204590145 8836
 sys/src/cmd/proof/htroff.c - 664 sys sys 955223407 10496
-sys/src/cmd/proof/main.c - 664 sys sys 955242172 3268
+sys/src/cmd/proof/main.c - 664 sys sys 1204590214 3199
 sys/src/cmd/proof/mkfile - 664 sys sys 944961622 180
 sys/src/cmd/proof/proof.h - 664 sys sys 955223407 919
-sys/src/cmd/proof/screen.c - 664 sys sys 1143759342 6646
+sys/src/cmd/proof/screen.c - 664 sys sys 1204590226 6673
 sys/src/cmd/ps.c - 664 sys sys 1144686672 2783
 sys/src/cmd/pwd.c - 664 sys sys 1067722792 287
 sys/src/cmd/qa - 20000000775 sys sys 1039727573 0
@@ -15869,3 +15869,4 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+386/bin/proof - 775 sys sys 1204604985 179949

+ 5 - 5
dist/replica/plan9.db

@@ -376,7 +376,7 @@
 386/bin/pr - 775 sys sys 1178568298 76251
 386/bin/primes - 775 sys sys 1172289653 63329
 386/bin/prof - 775 sys sys 1188530184 111994
-386/bin/proof - 775 sys sys 1197732806 179174
+386/bin/proof - 775 sys sys 1204604985 179949
 386/bin/ps - 775 sys sys 1168402346 68812
 386/bin/pwd - 775 sys sys 1148500685 36932
 386/bin/ramfs - 775 sys sys 1178568298 88610
@@ -12543,7 +12543,7 @@ sys/src/cmd/ip/ipconfig - 20000000775 sys sys 1176933436 0
 sys/src/cmd/ip/ipconfig/ipconfig.h - 664 sys sys 1198189129 5311
 sys/src/cmd/ip/ipconfig/ipv6.c - 664 sys sys 1198189135 20619
 sys/src/cmd/ip/ipconfig/main.c - 664 sys sys 1204178443 40237
-sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1184880750 233
+sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1204591120 575
 sys/src/cmd/ip/ipconfig/ppp.c - 664 sys sys 1184880751 1046
 sys/src/cmd/ip/linklocal.c - 664 sys sys 1197673397 1751
 sys/src/cmd/ip/measure.c - 664 sys sys 944961011 3733
@@ -13196,12 +13196,12 @@ sys/src/cmd/pr.c - 664 sys sys 1168307016 11172
 sys/src/cmd/primes.c - 664 sys sys 1172257895 2471
 sys/src/cmd/prof.c - 664 sys sys 1124305301 5547
 sys/src/cmd/proof - 20000000775 sys sys 1039727677 0
-sys/src/cmd/proof/font.c - 664 sys sys 944961621 8525
+sys/src/cmd/proof/font.c - 664 sys sys 1204590145 8836
 sys/src/cmd/proof/htroff.c - 664 sys sys 955223407 10496
-sys/src/cmd/proof/main.c - 664 sys sys 955242172 3268
+sys/src/cmd/proof/main.c - 664 sys sys 1204590214 3199
 sys/src/cmd/proof/mkfile - 664 sys sys 944961622 180
 sys/src/cmd/proof/proof.h - 664 sys sys 955223407 919
-sys/src/cmd/proof/screen.c - 664 sys sys 1143759342 6646
+sys/src/cmd/proof/screen.c - 664 sys sys 1204590226 6673
 sys/src/cmd/ps.c - 664 sys sys 1144686672 2783
 sys/src/cmd/pwd.c - 664 sys sys 1067722792 287
 sys/src/cmd/qa - 20000000775 sys sys 1039727573 0

+ 5 - 0
dist/replica/plan9.log

@@ -18700,3 +18700,8 @@
 1204326003 0 c sys/src/boot/pc/ether8169.c - 664 sys sys 1204324647 21870
 1204326003 1 c sys/src/boot/pc/sdaoe.c - 664 sys sys 1204324647 11381
 1204424261 0 c sys/man/8/ipconfig - 664 sys sys 1204424262 8203
+1204590603 0 c sys/src/cmd/proof/font.c - 664 sys sys 1204590145 8836
+1204590603 1 c sys/src/cmd/proof/main.c - 664 sys sys 1204590214 3199
+1204590603 2 c sys/src/cmd/proof/screen.c - 664 sys sys 1204590226 6673
+1204592404 0 c sys/src/cmd/ip/ipconfig/mkfile - 664 sys sys 1204591120 575
+1204605003 0 c 386/bin/proof - 775 sys sys 1204604985 179949

+ 14 - 0
sys/src/cmd/ip/ipconfig/mkfile

@@ -21,3 +21,17 @@ UPDATE=\
 	${OFILES:%.$O=%.c}\
 
 </sys/src/cmd/mkone
+
+safeinstall:V: $O.out
+	if(test -e $BIN/___ipconfig)
+		mv $BIN/___ipconfig $BIN/____ipconfig
+	if(test -e $BIN/__ipconfig)
+		mv $BIN/__ipconfig $BIN/___ipconfig
+	if(test -e $BIN/_ipconfig)
+		mv $BIN/_ipconfig $BIN/__ipconfig
+	mv $BIN/ipconfig $BIN/_ipconfig
+	cp $O.out $BIN/ipconfig
+
+safeinstallall:V:
+	for (objtype in $CPUS)
+		mk safeinstall

+ 28 - 13
sys/src/cmd/proof/font.c

@@ -5,7 +5,7 @@
 #include <bio.h>
 #include "proof.h"
 
-char	fname[NFONT][20];		/* font names */
+char	fname[NFONT][20];	/* font names */
 char lastload[NFONT][20];	/* last file name prefix loaded for this font */
 Font	*fonttab[NFONT][NSIZE];	/* pointers to fonts */
 int	fmap[NFONT];		/* what map to use with this font */
@@ -67,7 +67,7 @@ dochar(Rune r[])
 	Font *f;
 	Point p;
 	int fontno, fm, i;
-	char buf[10];
+	char buf[32];
 
 	fontno = curfont;
 	if((s = map(r, curfont)) == 0){		/* not on current font */
@@ -94,7 +94,7 @@ dochar(Rune r[])
 			p.x = hpos/DIV + xyoffset.x + offset.x;
 			p.y = vpos/DIV + xyoffset.y + offset.y;
 			p.y -= font->ascent;
-			sprint(buf, "%S", r);
+			snprint(buf, sizeof buf, "%S", r);
 			string(screen, p, display->black, ZP, font, buf);
 			return;
 		}
@@ -113,7 +113,7 @@ dochar(Rune r[])
 static void
 loadfont(int n, int s)
 {
-	char file[100];
+	char file[256];
 	int i, fd, t, deep;
 	static char *try[3] = {"", "times/R.", "pelm/"};
 	Subfont *f;
@@ -127,7 +127,8 @@ loadfont(int n, int s)
 		dprint(2, "size %d, i %d, mag %g\n", s, i, mag);
 		for(; i >= MINSIZE; i--){
 			/* if .font file exists, take that */
-			sprint(file, "%s/%s%d.font", libfont, try[t], i);
+			snprint(file, sizeof file, "%s/%s%d.font",
+				libfont, try[t], i);
 			ff = openfont(display, file);
 			if(ff != 0){
 				fonttab[n][s] = ff;
@@ -136,7 +137,8 @@ loadfont(int n, int s)
 			}
 			/* else look for a subfont file */
 			for (deep = log2[screen->depth]; deep >= 0; deep--){
-				sprint(file, "%s/%s%d.%d", libfont, try[t], i, deep);
+				snprint(file, sizeof file, "%s/%s%d.%d",
+					libfont, try[t], i, deep);
 				dprint(2, "trying %s for %d\n", file, i);
 				if ((fd = open(file, 0)) >= 0){
 					f = readsubfont(display, file, fd, 0);
@@ -300,7 +302,9 @@ buildtroff(char *buf)	/* map troff names into bitmap filenames */
 	fontmap[nfontmap].troffname = strdup(name);
 	fontmap[nfontmap].prefix = strdup(prefix);
 	fontmap[nfontmap].map = curmap;
-	dprint(2, "troff name %s is bitmap %s map %d in slot %d fallback %s\n", name, prefix, curmap, nfontmap, fontmap[nfontmap].fallback? fontmap[nfontmap].fallback : "<null>");
+	dprint(2, "troff name %s is bitmap %s map %d in slot %d fallback %s\n",
+		name, prefix, curmap, nfontmap, fontmap[nfontmap].fallback?
+		fontmap[nfontmap].fallback: "<null>");
 	nfontmap++;
 }
 
@@ -327,16 +331,27 @@ static char *
 map(Rune rp[], int font)	/* figure out mapping for char in this font */
 {
 	static char s[100];
-	char c[10];
+	unsigned m;
+	char c[32];
 	Link *p;
 	Rune r;
 
-	if(rp[1]==0 &&  rp[0]<QUICK)	/* fast lookup */
-		r = charmap[fmap[font]].quick[rp[0]];
-	else {	/* high-valued or compound character name */
-		sprint(c, "%S", rp);
+	if((unsigned)font >= NFONT) {
+		dprint(2, "map: font %ud >= NFONT (%d)\n", font, NFONT);
+		return 0;
+	}
+	m = fmap[font];
+	if(m >= nelem(charmap)) {
+		dprint(2, "map: fmap[font] %ud >= nelem(charmap) (%d)\n",
+			m, nelem(charmap));
+		return 0;
+	}
+	if(rp[1] == 0 && rp[0] < QUICK)		/* fast lookup */
+		r = charmap[m].quick[rp[0]];
+	else {			/* high-valued or compound character name */
+		snprint(c, sizeof c, "%S", rp);
 		r = 0;
-		for (p = charmap[fmap[font]].slow; p; p = p->next)
+		for (p = charmap[m].slow; p; p = p->next)
 			if(eq(c, p->name)){
 				r = p->val;
 				break;

+ 27 - 41
sys/src/cmd/proof/main.c

@@ -11,69 +11,54 @@ double mag = DEFMAG;
 int dbg = 0;
 char *track = 0;
 Biobuf bin;
-char libfont[100] = "/lib/font/bit";
-char mapfile[100] = "MAP";
+char libfont[256] = "/lib/font/bit";
+char mapfile[256] = "MAP";
 char *mapname = "MAP";
 
 void
 usage(void)
 {
-	fprint(2, "usage: proof [-m mag] [-/ nview] [-x xoff] [-y yoff] [-M mapfile] [-F fontdir] [-dt] file...\n");
+	fprint(2, "usage: proof [-m mag] [-/ nview] [-x xoff] [-y yoff] "
+		"[-M mapfile] [-F fontdir] [-dt] file...\n");
 	exits("usage");
 }
 
-double
-getnum(char *s)
-{
-	if(s == nil)
-		usage();
-	return atof(s);
-}
-
-char*
-getstr(char *s)
-{
-	if(s == nil)
-		usage();
-	return s;
-}
-
 void
 main(int argc, char *argv[])
 {
 	char c;
 	int dotrack = 0;
-	
+
 	ARGBEGIN{
+	case 'M':	/* change MAP file */
+		mapname = EARGF(usage());
+		break;
+	case 'F':	/* change /lib/font/bit directory */
+		strncpy(libfont, EARGF(usage()), sizeof libfont);
+		break;
+	case 'd':
+		dbg = 1;
+		break;
 	case 'm':	/* magnification */
-		mag = getnum(ARGF());
+		mag = atof(EARGF(usage()));
 		if (mag < 0.1 || mag > 10){
 			fprint(2, "ridiculous mag argument ignored\n");
 			mag = DEFMAG;
 		}
 		break;
-	case '/':
-		nview = getnum(ARGF());
-		if (nview < 1 || nview > MAXVIEW)
-			nview = 1;
+	case 't':
+		dotrack = 1;
 		break;
 	case 'x':
-		xyoffset.x += getnum(ARGF()) * 100;
+		xyoffset.x += atof(EARGF(usage())) * 100;
 		break;
 	case 'y':
-		xyoffset.y += getnum(ARGF()) * 100;
-		break;
-	case 'M':	/* change MAP file */
-		strcpy(mapname, getstr(ARGF()));
-		break;
-	case 'F':	/* change /lib/font/bit directory */
-		strcpy(libfont, getstr(ARGF()));
+		xyoffset.y += atof(EARGF(usage())) * 100;
 		break;
-	case 'd':
-		dbg = 1;
-		break;
-	case 't':
-		dotrack = 1;
+	case '/':
+		nview = atof(EARGF(usage()));
+		if (nview < 1 || nview > MAXVIEW)
+			nview = 1;
 		break;
 	default:
 		usage();
@@ -89,13 +74,14 @@ main(int argc, char *argv[])
 			track = argv[0];
 	}
 	Binit(&bin, 0, OREAD);
-	sprint(mapfile, "%s/%s", libfont, mapname);
+	snprint(mapfile, sizeof mapfile, "%s/%s", libfont, mapname);
 	readmapfile(mapfile);
 	for (c = 0; c < NFONT; c++)
 		loadfontname(c, "??");
 	mapscreen();
 	clearscreen();
-	readpage(); 
+	readpage();
+	exits(0);
 }
 
 /*
@@ -104,7 +90,7 @@ main(int argc, char *argv[])
 #define	SIZE	100000	/* 8-10 pages, typically */
 
 char	bufc[SIZE];
-char	*inc = bufc;		/* where next input character goes */
+char	*inc = bufc;	/* where next input character goes */
 char	*outc = bufc;	/* next character to be read from buffer */
 int	off;		/* position of outc in total input stream */
 

+ 5 - 4
sys/src/cmd/proof/screen.c

@@ -192,9 +192,10 @@ char *pan(void)
 	return "p";
 }
 
-static char *getmousestr(void)
+static char *
+getmousestr(void)
 {
-	static char buf[20];
+	static char buf[64];
 
 	checkmouse();
 	if (last_but == 1)
@@ -213,10 +214,10 @@ static char *getmousestr(void)
 		case Again:
 			return "p";
 		case Bigger:
-			sprint(buf, "m%g", mag * 1.1);
+			snprint(buf, sizeof buf, "m%g", mag * 1.1);
 			return buf;
 		case Smaller:
-			sprint(buf, "m%g", mag / 1.1);
+			snprint(buf, sizeof buf, "m%g", mag / 1.1);
 			return buf;
 		case Pan:
 			return pan();