calculate connectivity of gateways to find multi-hop gateways;
[unix-history] / usr / src / old / tbl / t5.c
CommitLineData
476fcd16
SL
1#ifndef lint
2static char sccsid[] = "@(#)t5.c 4.2 %G%";
3#endif
485ece2d
BS
4
5 /* t5.c: read data for table */
6# include "t..c"
7gettbl()
8{
9int icol, ch;
10cstore=cspace= chspace();
11textflg=0;
12for (nlin=nslin=0; gets1(cstore); nlin++)
13 {
14 stynum[nlin]=nslin;
15 if (prefix(".TE", cstore))
16 {
17 leftover=0;
18 break;
19 }
20 if (prefix(".TC", cstore) || prefix(".T&", cstore))
21 {
22 readspec();
23 nslin++;
24 }
25 if (nlin>=MAXLIN)
26 {
27 leftover=cstore;
28 break;
29 }
30 fullbot[nlin]=0;
31 if (cstore[0] == '.' && !isdigit(cstore[1]))
32 {
33 instead[nlin] = cstore;
34 while (*cstore++);
35 continue;
36 }
37 else instead[nlin] = 0;
38 if (nodata(nlin))
39 {
40 if (ch = oneh(nlin))
41 fullbot[nlin]= ch;
42 nlin++;
43 nslin++;
44 instead[nlin]=fullbot[nlin]=0;
45 }
46 table[nlin] = alocv((ncol+2)*sizeof(table[0][0]));
47 if (cstore[1]==0)
48 switch(cstore[0])
49 {
50 case '_': fullbot[nlin]= '-'; continue;
51 case '=': fullbot[nlin]= '='; continue;
52 }
53 stynum[nlin] = nslin;
54 nslin = min(nslin+1, nclin-1);
55 for (icol = 0; icol <ncol; icol++)
56 {
57 table[nlin][icol].col = cstore;
58 table[nlin][icol].rcol=0;
59 ch=1;
60 if (match(cstore, "T{")) /* text follows */
61 table[nlin][icol].col =
62 gettext(cstore, nlin, icol,
63 font[stynum[nlin]][icol],
64 csize[stynum[nlin]][icol]);
65 else
66 {
67 for(; (ch= *cstore) != '\0' && ch != tab; cstore++)
68 ;
69 *cstore++ = '\0';
70 switch(ctype(nlin,icol)) /* numerical or alpha, subcol */
71 {
72 case 'n':
73 table[nlin][icol].rcol = maknew(table[nlin][icol].col);
74 break;
75 case 'a':
76 table[nlin][icol].rcol = table[nlin][icol].col;
77 table[nlin][icol].col = "";
78 break;
79 }
80 }
81 while (ctype(nlin,icol+1)== 's') /* spanning */
82 table[nlin][++icol].col = "";
83 if (ch == '\0') break;
84 }
85 while (++icol <ncol+2)
86 {
87 table[nlin][icol].col = "";
88 table [nlin][icol].rcol=0;
89 }
90 while (*cstore != '\0')
91 cstore++;
92 if (cstore-cspace > MAXCHS)
93 cstore = cspace = chspace();
94 }
95last = cstore;
96permute();
97if (textflg) untext();
98return;
99}
100nodata(il)
101{
102int c;
103for (c=0; c<ncol;c++)
104 {
105 switch(ctype(il,c))
106 {
107 case 'c': case 'n': case 'r': case 'l': case 's': case 'a':
108 return(0);
109 }
110 }
111return(1);
112}
113oneh(lin)
114{
115int k, icol;
116k = ctype(lin,0);
117for(icol=1; icol<ncol; icol++)
118 {
119 if (k != ctype(lin,icol))
120 return(0);
121 }
122return(k);
123}
124# define SPAN "\\^"
125permute()
126{
127int irow, jcol, is;
128char *start, *strig;
129for(jcol=0; jcol<ncol; jcol++)
130 {
131 for(irow=1; irow<nlin; irow++)
132 {
133 if (vspand(irow,jcol,0))
134 {
135 is = prev(irow);
136 if (is<0)
137 error("Vertical spanning in first row not allowed");
138 start = table[is][jcol].col;
139 strig = table[is][jcol].rcol;
140 while (irow<nlin &&vspand(irow,jcol,0))
141 irow++;
142 table[--irow][jcol].col = start;
143 table[irow][jcol].rcol = strig;
144 while (is<irow)
145 {
146 table[is][jcol].rcol =0;
147 table[is][jcol].col= SPAN;
148 is = next(is);
149 }
150 }
151 }
152 }
153}
154vspand(ir,ij,ifform)
155{
156if (ir<0) return(0);
157if (ir>=nlin)return(0);
158if (instead[ir]) return(0);
159if (ifform==0 && ctype(ir,ij)=='^') return(1);
160if (table[ir][ij].rcol!=0) return(0);
161if (fullbot[ir]) return(0);
162return(vspen(table[ir][ij].col));
163}
164vspen(s)
165 char *s;
166{
167if (s==0) return(0);
168if (!point(s)) return(0);
169return(match(s, SPAN));
170}