xref: /onnv-gate/usr/src/cmd/tbl/ti.c (revision 381:1a7f0e46092a)
1*381Smuffin /*
2*381Smuffin  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
3*381Smuffin  * Use is subject to license terms.
4*381Smuffin  */
5*381Smuffin 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
14*381Smuffin 
15*381Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
170Sstevel@tonic-gate  /* ti.c: classify line intersections */
180Sstevel@tonic-gate # include "t..c"
190Sstevel@tonic-gate /* determine local environment for intersections */
20*381Smuffin 
21*381Smuffin int
interv(int i,int c)22*381Smuffin interv(int i, int c)
230Sstevel@tonic-gate {
240Sstevel@tonic-gate int ku, kl;
250Sstevel@tonic-gate if (c>=ncol || c == 0)
260Sstevel@tonic-gate 	{
270Sstevel@tonic-gate 	if (dboxflg)
280Sstevel@tonic-gate 		{
290Sstevel@tonic-gate 		if (i==0) return(BOT);
300Sstevel@tonic-gate 		if (i>=nlin) return(TOP);
310Sstevel@tonic-gate 		return(THRU);
320Sstevel@tonic-gate 		}
330Sstevel@tonic-gate 	if (c>=ncol)
340Sstevel@tonic-gate 		return(0);
350Sstevel@tonic-gate 	}
360Sstevel@tonic-gate ku = i>0 ? lefdata(i-1,c) : 0;
370Sstevel@tonic-gate if (i+1 >= nlin)
380Sstevel@tonic-gate 	kl=0;
390Sstevel@tonic-gate else
400Sstevel@tonic-gate kl = lefdata(allh(i) ? i+1 : i, c);
410Sstevel@tonic-gate if (ku==2 && kl==2) return(THRU);
420Sstevel@tonic-gate if (ku ==2) return(TOP);
430Sstevel@tonic-gate if (kl==BOT) return(2);
440Sstevel@tonic-gate return(0);
450Sstevel@tonic-gate }
46*381Smuffin 
47*381Smuffin int
interh(int i,int c)48*381Smuffin interh(int i, int c)
490Sstevel@tonic-gate {
500Sstevel@tonic-gate int kl, kr;
510Sstevel@tonic-gate if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1)))
520Sstevel@tonic-gate 	{
530Sstevel@tonic-gate 	if (c==ncol)
540Sstevel@tonic-gate 		return(LEFT);
550Sstevel@tonic-gate 	if (c==0)
560Sstevel@tonic-gate 		return(RIGHT);
570Sstevel@tonic-gate 	return(THRU);
580Sstevel@tonic-gate 	}
590Sstevel@tonic-gate if (i>=nlin) return(0);
600Sstevel@tonic-gate kl = c>0 ? thish (i,c-1) : 0;
610Sstevel@tonic-gate if (kl<=1 && i>0 && allh(up1(i)))
620Sstevel@tonic-gate 	kl = c>0 ? thish(up1(i),c-1) : 0;
630Sstevel@tonic-gate kr = thish(i,c);
640Sstevel@tonic-gate if (kr<=1 && i>0 && allh(up1(i)))
650Sstevel@tonic-gate 	kr = c>0 ? thish(up1(i), c) : 0;
660Sstevel@tonic-gate if (kl== '=' && kr ==  '=') return(THRU);
670Sstevel@tonic-gate if (kl== '=') return(LEFT);
680Sstevel@tonic-gate if (kr== '=') return(RIGHT);
690Sstevel@tonic-gate return(0);
700Sstevel@tonic-gate }
71*381Smuffin 
72*381Smuffin int
up1(int i)73*381Smuffin up1(int i)
740Sstevel@tonic-gate {
750Sstevel@tonic-gate i--;
760Sstevel@tonic-gate while (instead[i] && i>0) i--;
770Sstevel@tonic-gate return(i);
780Sstevel@tonic-gate }
79