1*b5514887Smuffin /* 2*b5514887Smuffin * Copyright 1990 Sun Microsystems, Inc. All rights reserved. 3*b5514887Smuffin * Use is subject to license terms. 4*b5514887Smuffin */ 5*b5514887Smuffin 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 15*b5514887Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate /* ti.c: classify line intersections */ 187c478bd9Sstevel@tonic-gate # include "t..c" 197c478bd9Sstevel@tonic-gate /* determine local environment for intersections */ 20*b5514887Smuffin 21*b5514887Smuffin int 22*b5514887Smuffin interv(int i, int c) 237c478bd9Sstevel@tonic-gate { 247c478bd9Sstevel@tonic-gate int ku, kl; 257c478bd9Sstevel@tonic-gate if (c>=ncol || c == 0) 267c478bd9Sstevel@tonic-gate { 277c478bd9Sstevel@tonic-gate if (dboxflg) 287c478bd9Sstevel@tonic-gate { 297c478bd9Sstevel@tonic-gate if (i==0) return(BOT); 307c478bd9Sstevel@tonic-gate if (i>=nlin) return(TOP); 317c478bd9Sstevel@tonic-gate return(THRU); 327c478bd9Sstevel@tonic-gate } 337c478bd9Sstevel@tonic-gate if (c>=ncol) 347c478bd9Sstevel@tonic-gate return(0); 357c478bd9Sstevel@tonic-gate } 367c478bd9Sstevel@tonic-gate ku = i>0 ? lefdata(i-1,c) : 0; 377c478bd9Sstevel@tonic-gate if (i+1 >= nlin) 387c478bd9Sstevel@tonic-gate kl=0; 397c478bd9Sstevel@tonic-gate else 407c478bd9Sstevel@tonic-gate kl = lefdata(allh(i) ? i+1 : i, c); 417c478bd9Sstevel@tonic-gate if (ku==2 && kl==2) return(THRU); 427c478bd9Sstevel@tonic-gate if (ku ==2) return(TOP); 437c478bd9Sstevel@tonic-gate if (kl==BOT) return(2); 447c478bd9Sstevel@tonic-gate return(0); 457c478bd9Sstevel@tonic-gate } 46*b5514887Smuffin 47*b5514887Smuffin int 48*b5514887Smuffin interh(int i, int c) 497c478bd9Sstevel@tonic-gate { 507c478bd9Sstevel@tonic-gate int kl, kr; 517c478bd9Sstevel@tonic-gate if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1))) 527c478bd9Sstevel@tonic-gate { 537c478bd9Sstevel@tonic-gate if (c==ncol) 547c478bd9Sstevel@tonic-gate return(LEFT); 557c478bd9Sstevel@tonic-gate if (c==0) 567c478bd9Sstevel@tonic-gate return(RIGHT); 577c478bd9Sstevel@tonic-gate return(THRU); 587c478bd9Sstevel@tonic-gate } 597c478bd9Sstevel@tonic-gate if (i>=nlin) return(0); 607c478bd9Sstevel@tonic-gate kl = c>0 ? thish (i,c-1) : 0; 617c478bd9Sstevel@tonic-gate if (kl<=1 && i>0 && allh(up1(i))) 627c478bd9Sstevel@tonic-gate kl = c>0 ? thish(up1(i),c-1) : 0; 637c478bd9Sstevel@tonic-gate kr = thish(i,c); 647c478bd9Sstevel@tonic-gate if (kr<=1 && i>0 && allh(up1(i))) 657c478bd9Sstevel@tonic-gate kr = c>0 ? thish(up1(i), c) : 0; 667c478bd9Sstevel@tonic-gate if (kl== '=' && kr == '=') return(THRU); 677c478bd9Sstevel@tonic-gate if (kl== '=') return(LEFT); 687c478bd9Sstevel@tonic-gate if (kr== '=') return(RIGHT); 697c478bd9Sstevel@tonic-gate return(0); 707c478bd9Sstevel@tonic-gate } 71*b5514887Smuffin 72*b5514887Smuffin int 73*b5514887Smuffin up1(int i) 747c478bd9Sstevel@tonic-gate { 757c478bd9Sstevel@tonic-gate i--; 767c478bd9Sstevel@tonic-gate while (instead[i] && i>0) i--; 777c478bd9Sstevel@tonic-gate return(i); 787c478bd9Sstevel@tonic-gate } 79