date and time created 89/05/23 10:06:08 by bostic
[unix-history] / usr / src / old / tbl / tt.c
CommitLineData
476fcd16
SL
1#ifndef lint
2static char sccsid[] = "@(#)tt.c 4.2 %G%";
3#endif
caa88614
BS
4
5 /* tt.c: subroutines for drawing horizontal lines */
6# include "t..c"
7ctype(il, ic)
8{
9if (instead[il])
10 return(0);
11if (fullbot[il])
12 return(0);
13il = stynum[il];
14return(style[il][ic]);
15}
16min(a,b)
17{
18return(a<b ? a : b);
19}
20fspan(i,c)
21{
22c++;
23return(c<ncol && ctype(i,c)=='s');
24}
25lspan(i,c)
26{
27int k;
28if (ctype(i,c) != 's') return(0);
29c++;
30if (c < ncol && ctype(i,c)== 's')
31 return(0);
32for(k=0; ctype(i,--c) == 's'; k++);
33return(k);
34}
35ctspan(i,c)
36{
37int k;
38c++;
39for(k=1; c<ncol && ctype(i,c)=='s'; k++)
40 c++;
41return(k);
42}
43tohcol(ic)
44{
45 if (ic==0)
46 fprintf(tabout, "\\h'|0'");
47 else
48 fprintf(tabout, "\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
49}
50allh(i)
51{
52/* return true if every element in line i is horizontal */
53/* also at least one must be horizontl */
54int c, one, k;
55if (fullbot[i]) return(1);
56for(one=c=0; c<ncol; c++)
57 {
58 k = thish(i,c);
59 if (k==0) return(0);
60 if (k==1) continue;
61 one=1;
62 }
63return(one);
64}
65thish(i,c)
66{
67 int t;
68 char *s;
69 struct colstr *pc;
70 if (c<0)return(0);
71 if (i<0) return(0);
72 t = ctype(i,c);
73 if (t=='_' || t == '-')
74 return('-');
75 if (t=='=')return('=');
76 if (t=='^') return(1);
77 if (fullbot[i] )
78 return(fullbot[i]);
79 if (t=='s') return(thish(i,c-1));
80 if (t==0) return(1);
81 pc = &table[i][c];
82 s = (t=='a' ? pc->rcol : pc->col);
83 if (s==0 || (point(s) && *s==0))
84 return(1);
85 if (vspen(s)) return(1);
86 if (t=barent( s))
87 return(t);
88 return(0);
89}