Browse Source

Plan 9 from Bell Labs 2005-05-20

David du Colombier 19 years ago
parent
commit
399f5dd355
5 changed files with 105 additions and 56 deletions
  1. 4 3
      dist/replica/_plan9.db
  2. 3 3
      dist/replica/plan9.db
  3. 4 0
      dist/replica/plan9.log
  4. 13 1
      sys/man/1/mlmgr
  5. 81 49
      sys/src/cmd/aux/msexceltables.c

+ 4 - 3
dist/replica/_plan9.db

@@ -118,7 +118,7 @@
 386/bin/aux/mnihongo - 775 sys sys 1115950044 139321
 386/bin/aux/mouse - 775 sys sys 1115950044 44026
 386/bin/aux/ms2 - 775 sys sys 1115950044 84166
-386/bin/aux/msexceltables - 775 sys sys 1115950044 80995
+386/bin/aux/msexceltables - 775 sys sys 1116557402 81233
 386/bin/aux/mswordstrings - 775 sys sys 1115950044 65317
 386/bin/aux/na - 775 sys sys 1115950045 154186
 386/bin/aux/nfsmount - 775 sys sys 1115950045 234092
@@ -7149,7 +7149,7 @@ sys/man/1/marshal - 664 sys sys 1079970326 3150
 sys/man/1/mc - 664 sys sys 1113743326 552
 sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
-sys/man/1/mlmgr - 664 sys sys 1045501403 2427
+sys/man/1/mlmgr - 664 sys sys 1116513886 2542
 sys/man/1/ms2html - 664 sys sys 960001562 856
 sys/man/1/nedmail - 664 sys sys 1114697978 6820
 sys/man/1/netstat - 664 sys sys 953344523 827
@@ -9485,7 +9485,7 @@ sys/src/cmd/aux/mnihongo/mnihongo.c - 664 sys sys 946759402 6406
 sys/src/cmd/aux/mnihongo/tmac.nihongo - 664 sys sys 944960789 22
 sys/src/cmd/aux/mouse.c - 664 sys sys 1063855425 7049
 sys/src/cmd/aux/ms2.c - 664 sys sys 1015008685 3129
-sys/src/cmd/aux/msexceltables.c - 664 sys sys 1106410108 13282
+sys/src/cmd/aux/msexceltables.c - 664 sys sys 1116513714 13568
 sys/src/cmd/aux/mswordstrings.c - 664 sys sys 952201344 5767
 sys/src/cmd/aux/na - 20000000775 sys sys 955036627 0
 sys/src/cmd/aux/na/mkfile - 664 sys sys 955036627 121
@@ -14884,3 +14884,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
+sys/src/cmd/aux/msexceltables.c - 664 sys sys 1116559800 13722

+ 3 - 3
dist/replica/plan9.db

@@ -118,7 +118,7 @@
 386/bin/aux/mnihongo - 775 sys sys 1115950044 139321
 386/bin/aux/mouse - 775 sys sys 1115950044 44026
 386/bin/aux/ms2 - 775 sys sys 1115950044 84166
-386/bin/aux/msexceltables - 775 sys sys 1115950044 80995
+386/bin/aux/msexceltables - 775 sys sys 1116557402 81233
 386/bin/aux/mswordstrings - 775 sys sys 1115950044 65317
 386/bin/aux/na - 775 sys sys 1115950045 154186
 386/bin/aux/nfsmount - 775 sys sys 1115950045 234092
@@ -7149,7 +7149,7 @@ sys/man/1/marshal - 664 sys sys 1079970326 3150
 sys/man/1/mc - 664 sys sys 1113743326 552
 sys/man/1/mk - 664 sys sys 1113743328 13198
 sys/man/1/mkdir - 664 sys sys 1082593141 717
-sys/man/1/mlmgr - 664 sys sys 1045501403 2427
+sys/man/1/mlmgr - 664 sys sys 1116513886 2542
 sys/man/1/ms2html - 664 sys sys 960001562 856
 sys/man/1/nedmail - 664 sys sys 1114697978 6820
 sys/man/1/netstat - 664 sys sys 953344523 827
@@ -9485,7 +9485,7 @@ sys/src/cmd/aux/mnihongo/mnihongo.c - 664 sys sys 946759402 6406
 sys/src/cmd/aux/mnihongo/tmac.nihongo - 664 sys sys 944960789 22
 sys/src/cmd/aux/mouse.c - 664 sys sys 1063855425 7049
 sys/src/cmd/aux/ms2.c - 664 sys sys 1015008685 3129
-sys/src/cmd/aux/msexceltables.c - 664 sys sys 1106410108 13282
+sys/src/cmd/aux/msexceltables.c - 664 sys sys 1116559800 13722
 sys/src/cmd/aux/mswordstrings.c - 664 sys sys 952201344 5767
 sys/src/cmd/aux/na - 20000000775 sys sys 955036627 0
 sys/src/cmd/aux/na/mkfile - 664 sys sys 955036627 121

+ 4 - 0
dist/replica/plan9.log

@@ -19175,3 +19175,7 @@
 1116385233 0 c sys/man/8/ipconfig - 664 sys sys 1116383710 6170
 1116424839 0 c sys/lib/dist/pc/inst/halt - 775 sys sys 1116424549 325
 1116424839 1 c sys/man/3/usb - 664 sys sys 1116424546 6826
+1116514858 0 c sys/man/1/mlmgr - 664 sys sys 1116513886 2542
+1116514858 1 c sys/src/cmd/aux/msexceltables.c - 664 sys sys 1116513714 13568
+1116558007 0 c 386/bin/aux/msexceltables - 775 sys sys 1116557402 81233
+1116559806 0 c sys/src/cmd/aux/msexceltables.c - 664 sys sys 1116559800 13722

+ 13 - 1
sys/man/1/mlmgr

@@ -10,6 +10,10 @@ ml, mlmgr, mlowner \-  unmoderated mailing lists
 .I address
 .PP
 .B upas/ml
+[
+.B -r 
+.I replyto-address
+]
 .I addressfile
 .I listname
 .PP
@@ -20,7 +24,7 @@ ml, mlmgr, mlowner \-  unmoderated mailing lists
 .I Mlmgr
 creates and updates unmoderated mailing lists.
 The
-.B \-c
+.B -c
 option creates mail directories for both
 .I listname
 and
@@ -98,6 +102,14 @@ Appropriate calls to them are inserted in the
 .B pipeto
 files created by
 .IR mlmgr .
+.PP
+.IR Ml 's
+.B -r
+option
+sets the
+.B Reply-to:
+field in the mail sent out by
+.I ml.
 .SH FILES
 .TF /mail/box/\fI<listname>\fP/address-list
 .TP

+ 81 - 49
sys/src/cmd/aux/msexceltables.c

@@ -13,6 +13,8 @@ enum {
 	Terror,
 
 	Ver8 = 0x600,		// only BIFF8 and BIFF8x files support unicode
+
+	Nwidths = 4096,
 };
 	
 	
@@ -64,8 +66,7 @@ static int Nxf = 0;		// # of above
 static Biobuf *bo;		// stdout (sic)
 
 // table scope
-static int *Width = nil;	// array of colum widths
-static int Nwidths = 0;		// # of above
+static int Width[Nwidths];	// array of colum widths
 static int Ncols = -1;		// max colums in table used
 static int Content = 0;		// type code for contents of sheet
 static Row *Root = nil;		// one worksheet's worth of cells
@@ -150,22 +151,29 @@ cell(int r, int c, int f, int type, void *val)
 	sysfatal("cannot happen error\n");
 }
 
-void
-numfmt(int fmt, int min, int max, double num)
+struct Tm *
+bifftime(double num)
 {
-	long t;
-	char buf[1024];
-	struct Tm *tm;
+	long long t = num;
 
 	/* Beware - These epochs are wrong, this
 	 * is to remain compatible with Lotus-123
 	 * which believed 1900 was a leap year
 	 */
 	if (Datemode)
-		t = (num-24107)*60*60*24;	// epoch = 1/1/1904
+		t -= 24107;		// epoch = 1/1/1904
 	else
-		t = (num-25569)*60*60*24;	// epoch = 31/12/1899
-	tm = localtime(t);
+		t -= 25569;		// epoch = 31/12/1899
+	t *= 60*60*24;
+
+	return localtime((long)t);
+}
+
+void
+numfmt(int fmt, int min, int max, double num)
+{
+	char buf[1024];
+	struct Tm *tm;
 
 	if (fmt == 9)
 		snprint(buf, sizeof(buf),"%.0f%%", num);
@@ -176,19 +184,29 @@ numfmt(int fmt, int min, int max, double num)
 	if (fmt == 11 || fmt == 48)
 		snprint(buf, sizeof(buf),"%e", num);
 	else
-	if (fmt >= 14 && fmt <= 17)
+	if (fmt >= 14 && fmt <= 17){
+		tm = bifftime(num);
 		snprint(buf, sizeof(buf),"%d-%s-%d",
 			tm->mday, Months[tm->mon], tm->year+1900);
+	}
 	else
-	if ((fmt >= 18 && fmt <= 21) || (fmt >= 45 && fmt <= 47))
+	if ((fmt >= 18 && fmt <= 21) || (fmt >= 45 && fmt <= 47)){
+
+		tm = bifftime(num);
 		snprint(buf, sizeof(buf),"%02d:%02d:%02d", tm->hour, tm->min, tm->sec);
+
+	}
 	else
-	if (fmt == 22)
+	if (fmt == 22){
+
+		tm = bifftime(num);
 		snprint(buf, sizeof(buf),"%02d:%02d:%02d %d-%s-%d",
 			tm->hour, tm->min, tm->sec,
 			tm->mday, Months[tm->mon], tm->year+1900);
-	else
+
+	}else
 		snprint(buf, sizeof(buf),"%g", num);
+
 	Bprint(bo, "%-*.*q", min, max, buf);
 }
 
@@ -210,6 +228,7 @@ dump(void)
 				max = min -2;		// FIXME: -2 because of bug %q format ?
 
 			switch(c->type){
+
 			case Tnumber:
 				if (Xf[c->f] == 0)
 					Bprint(bo, "%-*.*g", min, max, c->number);
@@ -278,9 +297,7 @@ release(void)
 	}
 	Root = nil;
 
-	free(Width);
-	Width = nil;
-	Nwidths = 0;
+	memset(Width, 0, sizeof(Width));
 	Ncols = -1;
 }
 
@@ -411,8 +428,8 @@ char *
 gstr(Biff *b, int len_width)
 {
 	Rune r;
-	int nch, sz, len, opt;
 	char *buf, *p;
+	int nch, w, sz, ln, rt, opt;
 
 	if (b->len < len_width){
 		if (getrec(b) == -1)
@@ -421,30 +438,47 @@ gstr(Biff *b, int len_width)
 			sysfatal("expected CONTINUE, got op=0x%x\n", b->op);
 	}
 
-	len = gint(b, len_width);
+	ln = gint(b, len_width);
 	if (Biffver != Ver8){
-		if ((buf = calloc(len+1, sizeof(char))) == nil)
+		if ((buf = calloc(ln+1, sizeof(char))) == nil)
 			sysfatal("no memory\n");
-		gmem(b, buf, len);
+		gmem(b, buf, ln);
 		return buf;
 	}
 
 
-	if ((buf = calloc(len+1, sizeof(char)*UTFmax)) == nil)
+	if ((buf = calloc(ln+1, sizeof(char)*UTFmax)) == nil)
 		sysfatal("no memory\n");
 	p = buf;
 
-	if (len == 0)
+	if (ln == 0)
 		return buf;
-
 	nch = 0;
+	*buf = 0;
 	while (1){
 		opt = gint(b, 1);
-		sz = (opt & 1)? sizeof(Rune): sizeof(char);
+		w = (opt & 1)? sizeof(Rune): sizeof(char);
+		/*
+		 * some people and compilers hate '?'
+		sz = (opt & 4)? gint(b, 4): 0;
+		rt = (opt & 8)? gint(b, 2): 0;
+		 */
+		if(opt & 4)
+			sz = gint(b,4);
+		else
+			sz = 0;
+		if(opt & 8)
+			rt = gint(b, 2);
+		else
+			rt = 0;
 		while(b->len > 0){
-			r = gint(b, sz);
+			r = gint(b, w);
 			p += runetochar(p, &r);
-			if (++nch >= len){
+			if (++nch >= ln){
+				if (opt & 4)
+					skip(b, sz);
+				if (opt & 8)
+					skip(b, rt*4);
 				return buf;
 			}
 		}
@@ -454,7 +488,7 @@ gstr(Biff *b, int len_width)
 			sysfatal("expected CONTINUE, got op=0x%x\n", b->op);
 	}
 	sysfatal("cannot ever happen error\n");
-	return buf;
+	return nil;  // shut up 8c
 }
 
 void
@@ -593,12 +627,10 @@ colinfo(Biff *b)
 	int c2 = gint(b, 2);
 	int w  = gint(b, 2);
 
-	if (c2 >= Nwidths){
-		Nwidths = c2+20;
-		if ((Width = realloc(Width, Nwidths*sizeof(int))) == nil)
-			sysfatal("no memory\n");
-	}
-
+	if (c1 < 0)
+		sysfatal("negitive collum number (%d)\n", c1);
+	if (c2 >= Nwidths)
+		sysfatal("too many collums (%d > %d)\n", c2, Nwidths);
 	w /= 256;
 
 	if (w > 100)
@@ -649,21 +681,21 @@ xls2csv(Biobuf *bp)
 		int op;
 		void (*func)(Biff *);
 	} dispatch[] = {
-		0x00a,	eof,
-		0x022,	datemode,
-		0x042,	codepage,
-		0x055,	defcolwidth,
-		0x05c,	writeaccess,
-		0x07d,	colinfo,
-		0x0bd,	mulrk,
-		0x0fc,	sst,
-		0x0fd,	labelsst,
-		0x203,	number,
-		0x204,	label,
-		0x205,	boolerr,
-		0x27e,	rk,
-		0x809,	bof,
-		0x0e0,	xf,
+		0x000a,	eof,
+		0x0022,	datemode,
+		0x0042,	codepage,
+		0x0055,	defcolwidth,
+		0x005c,	writeaccess,
+		0x007d,	colinfo,
+		0x00bd,	mulrk,
+		0x00fc,	sst,
+		0x00fd,	labelsst,
+		0x0203,	number,
+		0x0204,	label,
+		0x0205,	boolerr,
+		0x027e,	rk,
+		0x0809,	bof,
+		0x00e0,	xf,
 	};		
 	
 	b = &biff;