xref: /illumos-gate/usr/src/cmd/tbl/t9.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1 /*
2  * Copyright 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 
21 static int useln;
22 
23 void
24 yetmore(void)
25 {
26 for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
27 if (useln>=MAXLIN)
28 	error(gettext("Weird.  No data in table."));
29 table[0]=table[useln];
30 for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
31 if (useln<0)
32 	error(gettext("Weird.  No real lines in table."));
33 domore(leftover);
34 while (gets1(cstore=cspace, MAXSTR) && domore(cstore))
35 	;
36 last =cstore;
37 return;
38 }
39 
40 int
41 domore(char *dataln)
42 {
43 	int icol, ch;
44 if (prefix(".TE", dataln))
45 	return(0);
46 if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1]))
47 	{
48 	puts(dataln);
49 	return(1);
50 	}
51 instead[0]=0;
52 fullbot[0]=0;
53 if (dataln[1]==0)
54 switch(dataln[0])
55 	{
56 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
57 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
58 	}
59 for (icol = 0; icol <ncol; icol++)
60 	{
61 	table[0][icol].col = dataln;
62 	table[0][icol].rcol=0;
63 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
64 			;
65 	*dataln++ = '\0';
66 	switch(ctype(useln,icol))
67 		{
68 		case 'n':
69 			table[0][icol].rcol = maknew(table[0][icol].col);
70 			break;
71 		case 'a':
72 			table[0][icol].rcol = table[0][icol].col;
73 			table[0][icol].col= "";
74 			break;
75 		}
76 	while (ctype(useln,icol+1)== 's') /* spanning */
77 		table[0][++icol].col = "";
78 	if (ch == '\0') break;
79 	}
80 while (++icol <ncol)
81 	table[0][icol].col = "";
82 putline(useln,0);
83 return(1);
84 }
85