Browse Source

Plan 9 from Bell Labs 2009-03-14

David du Colombier 15 years ago
parent
commit
a6f3979b4b
5 changed files with 118 additions and 62 deletions
  1. 1 0
      sys/games/lib/fortunes
  2. 24 9
      sys/man/1/doc2txt
  3. 2 2
      sys/src/9/pc/devether.c
  4. 16 9
      sys/src/boot/pc/ether82563.c
  5. 75 42
      sys/src/cmd/aux/msexceltables.c

+ 1 - 0
sys/games/lib/fortunes

@@ -4253,3 +4253,4 @@ There is no organization (dept/cost center) in Lucent Technologies whose name ma
 	buf[0] = '\0';		/* make sure it's empty (silly 3b2) */
   #ifndef bool /* Linux 2.6.19 C++ nightmare */
 slashdot: the consensus of the ill-informed  - brucee
+"People aren't wearing enough hats" - Truism from brucee

+ 24 - 9
sys/man/1/doc2txt

@@ -35,11 +35,14 @@ doc2txt, doc2ps, wdoc2txt, xls2txt, olefs, mswordstrings, msexceltables
 .br
 .B aux/msexceltables
 [
-.B -aDnt
+.B -qaDnt
 ] [
 .B -d
 .I delim
 ] [
+.B -c
+.I column-range
+] [
 .B -w
 .I worksheet-range
 ]
@@ -95,26 +98,38 @@ by default a single space.
 .B -D
 Enables debugging output.
 .TP
+.BI -c " range
+.I Range
+is a comma-separated list of column numbers and ranges.
+Ranges are separated by dashes.
+Limit processing to just those columns named;
+by default all columns are output.
+.TP
 .B -n
-Disables field padding to column width.
+Disables field padding to column width. 
+.TP
+.B -q
+Disable quoting of textural fields (see 
+.IR quote (2).)
 .TP
 .B -t
 Truncate fields to the column width.
 .TP
-.BI -w " pages
-.I Pages
-is a comma-separated list of page numbers and ranges.
-Ranges are separated by dashes.
-Limit processing to just those pages named;
-by default all tabular sheets are output.
+.BI -w " range
+.I Range
+is a comma-separated list of worksheet numbers and ranges, this
+limits the sheets output using the same syntax as the
+.B -c
+option above.
 Suppressed chart pages are always included in the sheet count.
 .SH EXAMPLE
 Extract pieces of an MS Excel spreadsheet.
 .PD 0
 .IP
 .EX
+.SM
 aux/olefs report.xls
-msexceltables -w 1,7,9-14,3-4 -n -d '@' /mnt/doc/Workbook
+msexceltables -q -w 1,7,9-14 -c 3-5 -n -d '@' /mnt/doc/Workbook > rpt.txt
 unmount /mnt/doc
 .EE
 .PD

+ 2 - 2
sys/src/9/pc/devether.c

@@ -441,11 +441,11 @@ etherprobe(int cardno, int ctlrno)
 		lg = 14;
 	/* allocate larger output queues for higher-speed interfaces */
 	bsz = 1UL << (lg + 17);		/* 2ⁱ⁷ = 128K, bsz = 2ⁿ × 128K */
-	while (bsz > mainmem->maxsize && bsz >= 128*1024)
+	while (bsz > mainmem->maxsize / 8 && bsz > 128*1024)
 		bsz /= 2;
 
 	netifinit(ether, name, Ntypes, bsz);
-	while (ether->oq == nil && bsz >= 128*1024) {
+	while (ether->oq == nil && bsz > 128*1024) {
 		bsz /= 2;
 		ether->oq = qopen(bsz, Qmsg, 0, 0);
 		ether->limit = bsz;

+ 16 - 9
sys/src/boot/pc/ether82563.c

@@ -430,8 +430,6 @@ static char *tname[] = {
 	"i82575",
 };
 
-#define Type	tname[ctlr->type]
-
 typedef struct Ctlr Ctlr;
 struct Ctlr {
 	int	port;
@@ -640,6 +638,8 @@ toringbuf(Ether *ether, Block *bp)
 			ether->ctlrno, ether->ri);
 }
 
+int	interesting(Block *bp);
+
 static void
 i82563interrupt(Ureg*, void* arg)
 {
@@ -674,11 +674,12 @@ i82563interrupt(Ureg*, void* arg)
 						bp->rp+6, rdesc->length);
 				ctlr->rb[rdh] = nil;
 				bp->wp += rdesc->length;
-				toringbuf(edev, bp);
+//				if (interesting(bp))
+					toringbuf(edev, bp);
 				freeb(bp);
 			} else if (rdesc->status & Reop && rdesc->errors)
-				print("%s: input packet error 0x%ux\n",
-					Type, rdesc->errors);
+				print("%s: input packet error %#ux\n",
+					tname[ctlr->type], rdesc->errors);
 			rdesc->status = 0;
 			rdh = NEXT(rdh, Nrdesc);
 		}
@@ -717,7 +718,6 @@ i82563init(Ether* edev)
 		csr32w(ctlr, Rxdctl, r);
 	}
 	csr32w(ctlr, Rctl, rctl);
-
 	ctlr->rdba = mallocalign(Nrdesc*sizeof(Rdesc), 128, 0, 0);
 	csr32w(ctlr, Rdbal, PCIWADDR(ctlr->rdba));
 	csr32w(ctlr, Rdbah, 0);
@@ -759,7 +759,12 @@ i82563init(Ether* edev)
 		r |= Qenable;
 	csr32w(ctlr, Txdctl, r);
 
-	csr32w(ctlr, Rxcsum, Tuofl | Ipofl | ETHERHDRSIZE<<PcssSHIFT);
+	/*
+	 * Don't enable checksum offload.  In practice, it interferes with
+	 * tftp booting on at least the 82575.
+	 */
+//	csr32w(ctlr, Rxcsum, Tuofl | Ipofl | ETHERHDRSIZE<<PcssSHIFT);
+	csr32w(ctlr, Rxcsum, 0);
 	r = csr32r(ctlr, Tctl);
 	r |= Ten;
 	csr32w(ctlr, Tctl, r);
@@ -934,7 +939,8 @@ i82563reset(Ctlr* ctlr)
 	else
 		r = eeload(ctlr);
 	if (r != 0 && r != 0xBABA){
-		print("%s: bad EEPROM checksum - 0x%4.4ux\n", Type, r);
+		print("%s: bad EEPROM checksum - 0x%4.4ux\n",
+			tname[ctlr->type], r);
 		return -1;
 	}
 
@@ -1123,7 +1129,8 @@ i82563pnp(Ether* edev)
 	 * currently either we can skip the interface or note it is down,
 	 * but not both.
 	if((csr32r(ctlr, Status)&Lu) == 0){
-		print("ether#%d: 82563 (%s): link down\n", edev->ctlrno, Type);
+		print("ether#%d: 82563 (%s): link down\n",
+			edev->ctlrno, tname[ctlr->type]);
 		return -1;
 	}
 	 */

+ 75 - 42
sys/src/cmd/aux/msexceltables.c

@@ -54,6 +54,7 @@ static int Trunc = 0;		// truncate cells to colum width
 static int All = 0;		// dump all sheet types, Worksheets only by default
 static char *Delim = " ";	// field delimiter
 static char *Sheetrange = nil;	// range of sheets wanted
+static char *Columnrange = nil;	// range of collums wanted
 static int Debug = 0;
 
 // file scope
@@ -65,6 +66,7 @@ static int Nstrtab = 0;		// # of above
 static int *Xf;			// array of extended format indices
 static int Nxf = 0;		// # of above
 static Biobuf *bo;		// stdout (sic)
+static int Doquote = 1;		// quote text fields if they are rc(1) unfriendly
 
 // table scope
 static int Width[Nwidths];	// array of colum widths
@@ -85,6 +87,47 @@ static char *Errmsgs[] = {
 	[0x2a]	"#N/A!",	// argument of function not available
 };
 
+int
+wanted(char *range, int here)
+{
+	int n, s;
+	char *p;
+
+	if (! range)
+		return 1;
+
+	s = -1;
+	p = range;
+	while(1){
+		n = strtol(p, &p, 10);
+		switch(*p){
+		case 0:
+			if(n == here)
+				return 1;
+			if(s != -1 && here > s && here < n)
+				return 1;
+			return 0;
+		case ',':
+			if(n == here)
+				return 1;
+			if(s != -1 && here > s && here < n)
+				return 1;
+			s = -1;
+			p++;
+			break;
+		case '-':
+			if(n == here)
+				return 1;
+			s = n;
+			p++;
+			break;
+		default:
+			sysfatal("%s malformed range spec", range);
+			break;
+		}
+	}
+}
+
 	
 void
 cell(int r, int c, int f, int type, void *val)
@@ -214,11 +257,22 @@ void
 dump(void)
 {
 	Row *r;
-	Col *c;
-	int i, min, max;
+	Col *c, *c1;
+	char *strfmt;
+	int i, n, last, min, max;
+
+	if(Doquote)
+		strfmt = "%-*.*q";
+	else
+		strfmt = "%-*.*s";
 
 	for(r = Root; r; r = r->next){
+		n = 1;
 		for(c = r->col; c; c = c->next){
+			n++;
+			if(! wanted(Columnrange, n))
+				continue;
+
 			if(c->c < 0 || c->c >= Nwidths || (min = Width[c->c]) == 0)
 				min = Defwidth;
 			if((c->next && c->c == c->next->c) || Nopad)
@@ -235,28 +289,35 @@ dump(void)
 					numfmt(Xf[c->f], min, max, c->number);
 				break;
 			case Tlabel:
-				Bprint(bo, "%-*.*q", min, max, c->label);
+				Bprint(bo, strfmt, min, max, c->label);
 				break;
 			case Tbool:
-				Bprint(bo, "%-*.*s", min, max, (c->bool)? "True": "False");
+				Bprint(bo, strfmt, min, max, (c->bool)? "True": "False");
 				break;
 			case Tindex:
 				if(c->index < 0 || c->index >= Nstrtab)
 					sysfatal("SST string out of range - corrupt file?");
-				Bprint(bo, "%-*.*q", min, max, Strtab[c->index]);
+				Bprint(bo, strfmt, min, max, Strtab[c->index]);
 				break;
 			case Terror:
 				if(c->error < 0 || c->error >= nelem(Errmsgs) || !Errmsgs[c->error])
 					Bprint(bo, "#ERR=%d", c->index);
 				else
-					Bprint(bo, "%-*.*q", min, max, Errmsgs[c->error]);
+					Bprint(bo, strfmt, min, max, Errmsgs[c->error]);
 				break;
 			default:
 				sysfatal("cannot happen error");
 				break;
 			}
 
-			if(c->next){
+			last = 1;
+			for(i = n+1, c1 = c->next; c1; c1 = c1->next, i++)
+				if(wanted(Columnrange, i)){
+					last = 0;
+					break;
+				}
+
+			if(! last){
 				if(c->next->c == c->c)		// bar charts
 					Bprint(bo, "=");
 				else{
@@ -587,40 +648,6 @@ datemode(Biff *b)
 	Datemode = gint(b, 2);
 }
 
-int
-wanted(char *range, int sheet)
-{
-	int i, j;
-	char *p;
-
-	if (! range)
-		return 1;
-
-	p = range;
-	while(*p){
-		i = strtol(p, &p, 10);
-		switch(*p){
-		case '\0':
-		case ',':
-			if (i == sheet)
-				return 1;
-			break;
-		case '-':
-			j = strtol(p+1, &p, 10);
-			if(sheet >= i && sheet <= j)
-				return 1;
-
-			break;
-		default:
-			sysfatal(" %s malformed range spec", range);
-			break;
-		}
-		if (*p == ',')
-			p++;
-	}
-	return 0;
-}
-
 void
 eof(Biff *b)
 {
@@ -751,7 +778,7 @@ xls2csv(Biobuf *bp)
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-Dant] [-w worksheets] [-d delim] /mnt/doc/Workbook\n", argv0);
+	fprint(2, "usage: %s [-Danqt] [-w worksheets] [-c columns] [-d delim] /mnt/doc/Workbook\n", argv0);
 	exits("usage");
 }
 
@@ -768,6 +795,9 @@ main(int argc, char *argv[])
 	case 'a':
 		All = 1;
 		break;
+	case 'q':
+		Doquote = 0;
+		break;
 	case 'd':
 		Delim = EARGF(usage());
 		break;
@@ -777,6 +807,9 @@ main(int argc, char *argv[])
 	case 't':
 		Trunc = 1;
 		break;
+	case 'c':
+		Columnrange = EARGF(usage());
+		break;
 	case 'w':
 		Sheetrange = EARGF(usage());
 		break;