1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate /* ti.c: classify line intersections */ 19*7c478bd9Sstevel@tonic-gate # include "t..c" 20*7c478bd9Sstevel@tonic-gate /* determine local environment for intersections */ 21*7c478bd9Sstevel@tonic-gate interv(i,c) 22*7c478bd9Sstevel@tonic-gate { 23*7c478bd9Sstevel@tonic-gate int ku, kl; 24*7c478bd9Sstevel@tonic-gate if (c>=ncol || c == 0) 25*7c478bd9Sstevel@tonic-gate { 26*7c478bd9Sstevel@tonic-gate if (dboxflg) 27*7c478bd9Sstevel@tonic-gate { 28*7c478bd9Sstevel@tonic-gate if (i==0) return(BOT); 29*7c478bd9Sstevel@tonic-gate if (i>=nlin) return(TOP); 30*7c478bd9Sstevel@tonic-gate return(THRU); 31*7c478bd9Sstevel@tonic-gate } 32*7c478bd9Sstevel@tonic-gate if (c>=ncol) 33*7c478bd9Sstevel@tonic-gate return(0); 34*7c478bd9Sstevel@tonic-gate } 35*7c478bd9Sstevel@tonic-gate ku = i>0 ? lefdata(i-1,c) : 0; 36*7c478bd9Sstevel@tonic-gate if (i+1 >= nlin) 37*7c478bd9Sstevel@tonic-gate kl=0; 38*7c478bd9Sstevel@tonic-gate else 39*7c478bd9Sstevel@tonic-gate kl = lefdata(allh(i) ? i+1 : i, c); 40*7c478bd9Sstevel@tonic-gate if (ku==2 && kl==2) return(THRU); 41*7c478bd9Sstevel@tonic-gate if (ku ==2) return(TOP); 42*7c478bd9Sstevel@tonic-gate if (kl==BOT) return(2); 43*7c478bd9Sstevel@tonic-gate return(0); 44*7c478bd9Sstevel@tonic-gate } 45*7c478bd9Sstevel@tonic-gate interh(i,c) 46*7c478bd9Sstevel@tonic-gate { 47*7c478bd9Sstevel@tonic-gate int kl, kr; 48*7c478bd9Sstevel@tonic-gate if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1))) 49*7c478bd9Sstevel@tonic-gate { 50*7c478bd9Sstevel@tonic-gate if (c==ncol) 51*7c478bd9Sstevel@tonic-gate return(LEFT); 52*7c478bd9Sstevel@tonic-gate if (c==0) 53*7c478bd9Sstevel@tonic-gate return(RIGHT); 54*7c478bd9Sstevel@tonic-gate return(THRU); 55*7c478bd9Sstevel@tonic-gate } 56*7c478bd9Sstevel@tonic-gate if (i>=nlin) return(0); 57*7c478bd9Sstevel@tonic-gate kl = c>0 ? thish (i,c-1) : 0; 58*7c478bd9Sstevel@tonic-gate if (kl<=1 && i>0 && allh(up1(i))) 59*7c478bd9Sstevel@tonic-gate kl = c>0 ? thish(up1(i),c-1) : 0; 60*7c478bd9Sstevel@tonic-gate kr = thish(i,c); 61*7c478bd9Sstevel@tonic-gate if (kr<=1 && i>0 && allh(up1(i))) 62*7c478bd9Sstevel@tonic-gate kr = c>0 ? thish(up1(i), c) : 0; 63*7c478bd9Sstevel@tonic-gate if (kl== '=' && kr == '=') return(THRU); 64*7c478bd9Sstevel@tonic-gate if (kl== '=') return(LEFT); 65*7c478bd9Sstevel@tonic-gate if (kr== '=') return(RIGHT); 66*7c478bd9Sstevel@tonic-gate return(0); 67*7c478bd9Sstevel@tonic-gate } 68*7c478bd9Sstevel@tonic-gate up1(i) 69*7c478bd9Sstevel@tonic-gate { 70*7c478bd9Sstevel@tonic-gate i--; 71*7c478bd9Sstevel@tonic-gate while (instead[i] && i>0) i--; 72*7c478bd9Sstevel@tonic-gate return(i); 73*7c478bd9Sstevel@tonic-gate } 74