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