xref: /titanic_44/usr/src/cmd/tbl/t9.c (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*
2  * Copyright 1983-2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 
10 /*
11  * Copyright (c) 1980 Regents of the University of California.
12  * All rights reserved. The Berkeley software License Agreement
13  * specifies the terms and conditions for redistribution.
14  */
15 
16 #pragma ident	"%Z%%M%	%I%	%E% SMI"
17 
18  /* t9.c: write lines for tables over 200 lines */
19 # include "t..c"
20 static useln;
21 yetmore()
22 {
23 for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
24 if (useln>=MAXLIN)
25 	error(gettext("Weird.  No data in table."));
26 table[0]=table[useln];
27 for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
28 if (useln<0)
29 	error(gettext("Weird.  No real lines in table."));
30 domore(leftover);
31 while (gets1(cstore=cspace, MAXSTR) && domore(cstore))
32 	;
33 last =cstore;
34 return;
35 }
36 domore(dataln)
37 	char *dataln;
38 {
39 	int icol, ch;
40 if (prefix(".TE", dataln))
41 	return(0);
42 if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1]))
43 	{
44 	puts(dataln);
45 	return(1);
46 	}
47 instead[0]=0;
48 fullbot[0]=0;
49 if (dataln[1]==0)
50 switch(dataln[0])
51 	{
52 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
53 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
54 	}
55 for (icol = 0; icol <ncol; icol++)
56 	{
57 	table[0][icol].col = dataln;
58 	table[0][icol].rcol=0;
59 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
60 			;
61 	*dataln++ = '\0';
62 	switch(ctype(useln,icol))
63 		{
64 		case 'n':
65 			table[0][icol].rcol = maknew(table[0][icol].col);
66 			break;
67 		case 'a':
68 			table[0][icol].rcol = table[0][icol].col;
69 			table[0][icol].col= "";
70 			break;
71 		}
72 	while (ctype(useln,icol+1)== 's') /* spanning */
73 		table[0][++icol].col = "";
74 	if (ch == '\0') break;
75 	}
76 while (++icol <ncol)
77 	table[0][icol].col = "";
78 putline(useln,0);
79 return(1);
80 }
81