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