plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

t9.c (1578B)


      1 /* t9.c: write lines for tables over 200 lines */
      2 # include "t.h"
      3 static int useln;
      4 
      5 void
      6 yetmore(void)
      7 {
      8 	for (useln = 0; useln < MAXLIN && table[useln] == 0; useln++)
      9 		;
     10 	if (useln >= MAXLIN)
     11 		error("Wierd.  No data in table.");
     12 	table[0] = table[useln];
     13 	for (useln = nlin - 1; useln >= 0 && (fullbot[useln] || instead[useln]); useln--)
     14 		;
     15 	if (useln < 0)
     16 		error("Wierd.  No real lines in table.");
     17 	domore(leftover);
     18 	while (gets1(cstore = cspace, MAXCHS) && domore(cstore))
     19 		;
     20 	last = cstore;
     21 	return;
     22 }
     23 
     24 
     25 int
     26 domore(char *dataln)
     27 {
     28 	int	icol, ch;
     29 
     30 	if (prefix(".TE", dataln))
     31 		return(0);
     32 	if (dataln[0] == '.' && !isdigit((uchar)dataln[1])) {
     33 		Bprint(&tabout, "%s\n", dataln);
     34 		return(1);
     35 	}
     36 	fullbot[0] = 0;
     37 	instead[0] = (char *)0;
     38 	if (dataln[1] == 0)
     39 		switch (dataln[0]) {
     40 		case '_':
     41 			fullbot[0] = '-';
     42 			putline(useln, 0);
     43 			return(1);
     44 		case '=':
     45 			fullbot[0] = '=';
     46 			putline(useln, 0);
     47 			return(1);
     48 		}
     49 	for (icol = 0; icol < ncol; icol++) {
     50 		table[0][icol].col = dataln;
     51 		table[0][icol].rcol = 0;
     52 		for (; (ch = *dataln) != '\0' && ch != tab; dataln++)
     53 			;
     54 		*dataln++ = '\0';
     55 		switch (ctype(useln, icol)) {
     56 		case 'n':
     57 			table[0][icol].rcol = maknew(table[0][icol].col);
     58 			break;
     59 		case 'a':
     60 			table[0][icol].rcol = table[0][icol].col;
     61 			table[0][icol].col = "";
     62 			break;
     63 		}
     64 		while (ctype(useln, icol + 1) == 's') /* spanning */
     65 			table[0][++icol].col = "";
     66 		if (ch == '\0')
     67 			break;
     68 	}
     69 	while (++icol < ncol)
     70 		table[0][icol].col = "";
     71 	putline(useln, 0);
     72 	exstore = exspace;		 /* reuse space for numerical items */
     73 	return(1);
     74 }