tt.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
1/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2/*	  All Rights Reserved  	*/
3
4
5/*
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
11/*
12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13 * All Rights Reserved.
14 */
15
16#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
17
18 /* tt.c: subroutines for drawing horizontal lines */
19# include "t..c"
20ctype(il, ic)
21{
22if (instead[il])
23	return(0);
24if (fullbot[il])
25	return(0);
26il = stynum[il];
27return(style[il][ic]);
28}
29min(a,b)
30{
31return(a<b ? a : b);
32}
33fspan(i,c)
34{
35c++;
36return(c<ncol && ctype(i,c)=='s');
37}
38lspan(i,c)
39{
40int k;
41if (ctype(i,c) != 's') return(0);
42c++;
43if (c < ncol && ctype(i,c)== 's')
44	return(0);
45for(k=0; ctype(i,--c) == 's'; k++);
46return(k);
47}
48ctspan(i,c)
49{
50int k;
51c++;
52for(k=1; c<ncol && ctype(i,c)=='s'; k++)
53	c++;
54return(k);
55}
56tohcol(ic)
57{
58			if (ic==0)
59				fprintf(tabout, "\\h'|0'");
60			else
61				fprintf(tabout, "\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
62}
63allh(i)
64{
65/* return true if every element in line i is horizontal */
66/* also at least one must be horizontl */
67int c, one, k;
68if (fullbot[i]) return(1);
69for(one=c=0; c<ncol; c++)
70	{
71	k = thish(i,c);
72	if (k==0) return(0);
73	if (k==1) continue;
74	one=1;
75	}
76return(one);
77}
78thish(i,c)
79{
80	int t;
81	char *s;
82	struct colstr *pc;
83	if (c<0)return(0);
84	if (i<0) return(0);
85	t = ctype(i,c);
86	if (t=='_' || t == '-')
87		return('-');
88	if (t=='=')return('=');
89	if (t=='^') return(1);
90	if (fullbot[i] )
91		return(fullbot[i]);
92	if (t=='s') return(thish(i,c-1));
93	if (t==0) return(1);
94	pc = &table[i][c];
95	s = (t=='a' ? pc->rcol : pc->col);
96	if (s==0 || (point(s) && *s==0))
97		return(1);
98	if (vspen(s)) return(1);
99	if (t=barent( s))
100		return(t);
101	return(0);
102}
103