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 /* tu.c: draws horizontal lines */ 19*7c478bd9Sstevel@tonic-gate # include "t..c" 20*7c478bd9Sstevel@tonic-gate makeline(i,c,lintype) 21*7c478bd9Sstevel@tonic-gate { 22*7c478bd9Sstevel@tonic-gate int cr, type, shortl; 23*7c478bd9Sstevel@tonic-gate type = thish(i,c); 24*7c478bd9Sstevel@tonic-gate if (type==0) return; 25*7c478bd9Sstevel@tonic-gate cr=c; 26*7c478bd9Sstevel@tonic-gate shortl = (table[i][c].col[0]=='\\'); 27*7c478bd9Sstevel@tonic-gate if (c>0 && !shortl && thish(i,c-1) == type)return; 28*7c478bd9Sstevel@tonic-gate if (shortl==0) 29*7c478bd9Sstevel@tonic-gate for(cr=c; cr < ncol && (ctype(i,cr)=='s'||type==thish(i,cr)); cr++); 30*7c478bd9Sstevel@tonic-gate else 31*7c478bd9Sstevel@tonic-gate for(cr=c+1; cr<ncol && ctype(i,cr)=='s'; cr++); 32*7c478bd9Sstevel@tonic-gate drawline(i, c, cr-1, lintype, 0, shortl); 33*7c478bd9Sstevel@tonic-gate } 34*7c478bd9Sstevel@tonic-gate fullwide(i, lintype) 35*7c478bd9Sstevel@tonic-gate { 36*7c478bd9Sstevel@tonic-gate int cr, cl; 37*7c478bd9Sstevel@tonic-gate if (!pr1403) 38*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".nr %d \\n(.v\n.vs \\n(.vu-\\n(.sp\n", SVS); 39*7c478bd9Sstevel@tonic-gate cr= 0; 40*7c478bd9Sstevel@tonic-gate while (cr<ncol) 41*7c478bd9Sstevel@tonic-gate { 42*7c478bd9Sstevel@tonic-gate cl=cr; 43*7c478bd9Sstevel@tonic-gate while (i>0 && vspand(prev(i),cl,1)) 44*7c478bd9Sstevel@tonic-gate cl++; 45*7c478bd9Sstevel@tonic-gate for(cr=cl; cr<ncol; cr++) 46*7c478bd9Sstevel@tonic-gate if (i>0 && vspand(prev(i),cr,1)) 47*7c478bd9Sstevel@tonic-gate break; 48*7c478bd9Sstevel@tonic-gate if (cl<ncol) 49*7c478bd9Sstevel@tonic-gate drawline(i,cl,(cr<ncol?cr-1:cr),lintype,1,0); 50*7c478bd9Sstevel@tonic-gate } 51*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\n"); 52*7c478bd9Sstevel@tonic-gate if (!pr1403) 53*7c478bd9Sstevel@tonic-gate fprintf(tabout, ".vs \\n(%du\n", SVS); 54*7c478bd9Sstevel@tonic-gate } 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate drawline(i, cl, cr, lintype, noheight, shortl) 57*7c478bd9Sstevel@tonic-gate { 58*7c478bd9Sstevel@tonic-gate char *exhr, *exhl, *lnch; 59*7c478bd9Sstevel@tonic-gate int lcount, ln, linpos, oldpos, nodata; 60*7c478bd9Sstevel@tonic-gate lcount=0; 61*7c478bd9Sstevel@tonic-gate exhr=exhl= ""; 62*7c478bd9Sstevel@tonic-gate switch(lintype) 63*7c478bd9Sstevel@tonic-gate { 64*7c478bd9Sstevel@tonic-gate case '-': lcount=1;break; 65*7c478bd9Sstevel@tonic-gate case '=': lcount = pr1403? 1 : 2; break; 66*7c478bd9Sstevel@tonic-gate case SHORTLINE: lcount=1; break; 67*7c478bd9Sstevel@tonic-gate } 68*7c478bd9Sstevel@tonic-gate if (lcount<=0) return; 69*7c478bd9Sstevel@tonic-gate nodata = cr-cl>=ncol || noheight || allh(i); 70*7c478bd9Sstevel@tonic-gate if (!nodata) 71*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'-.5m'"); 72*7c478bd9Sstevel@tonic-gate for(ln=oldpos=0; ln<lcount; ln++) 73*7c478bd9Sstevel@tonic-gate { 74*7c478bd9Sstevel@tonic-gate linpos = 2*ln - lcount +1; 75*7c478bd9Sstevel@tonic-gate if (linpos != oldpos) 76*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%dp'", linpos-oldpos); 77*7c478bd9Sstevel@tonic-gate oldpos=linpos; 78*7c478bd9Sstevel@tonic-gate if (shortl==0) 79*7c478bd9Sstevel@tonic-gate { 80*7c478bd9Sstevel@tonic-gate tohcol(cl); 81*7c478bd9Sstevel@tonic-gate if (lcount>1) 82*7c478bd9Sstevel@tonic-gate { 83*7c478bd9Sstevel@tonic-gate switch(interv(i,cl)) 84*7c478bd9Sstevel@tonic-gate { 85*7c478bd9Sstevel@tonic-gate case TOP: exhl = ln==0 ? "1p" : "-1p"; break; 86*7c478bd9Sstevel@tonic-gate case BOT: exhl = ln==1 ? "1p" : "-1p"; break; 87*7c478bd9Sstevel@tonic-gate case THRU: exhl = "1p"; break; 88*7c478bd9Sstevel@tonic-gate } 89*7c478bd9Sstevel@tonic-gate if (exhl[0]) 90*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\h'%s'", exhl); 91*7c478bd9Sstevel@tonic-gate } 92*7c478bd9Sstevel@tonic-gate else if (lcount==1) 93*7c478bd9Sstevel@tonic-gate { 94*7c478bd9Sstevel@tonic-gate switch(interv(i,cl)) 95*7c478bd9Sstevel@tonic-gate { 96*7c478bd9Sstevel@tonic-gate case TOP: case BOT: exhl = "-1p"; break; 97*7c478bd9Sstevel@tonic-gate case THRU: exhl = "1p"; break; 98*7c478bd9Sstevel@tonic-gate } 99*7c478bd9Sstevel@tonic-gate if (exhl[0]) 100*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\h'%s'", exhl); 101*7c478bd9Sstevel@tonic-gate } 102*7c478bd9Sstevel@tonic-gate if (lcount>1) 103*7c478bd9Sstevel@tonic-gate { 104*7c478bd9Sstevel@tonic-gate switch(interv(i,cr+1)) 105*7c478bd9Sstevel@tonic-gate { 106*7c478bd9Sstevel@tonic-gate case TOP: exhr = ln==0 ? "-1p" : "+1p"; break; 107*7c478bd9Sstevel@tonic-gate case BOT: exhr = ln==1 ? "-1p" : "+1p"; break; 108*7c478bd9Sstevel@tonic-gate case THRU: exhr = "-1p"; break; 109*7c478bd9Sstevel@tonic-gate } 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate else if (lcount==1) 112*7c478bd9Sstevel@tonic-gate { 113*7c478bd9Sstevel@tonic-gate switch(interv(i,cr+1)) 114*7c478bd9Sstevel@tonic-gate { 115*7c478bd9Sstevel@tonic-gate case TOP: case BOT: exhr = "+1p"; break; 116*7c478bd9Sstevel@tonic-gate case THRU: exhr = "-1p"; break; 117*7c478bd9Sstevel@tonic-gate } 118*7c478bd9Sstevel@tonic-gate } 119*7c478bd9Sstevel@tonic-gate } 120*7c478bd9Sstevel@tonic-gate else 121*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\h'|\\n(%du'", cl+CLEFT); 122*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\s\\n(%d",LSIZE); 123*7c478bd9Sstevel@tonic-gate if (linsize) 124*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); 125*7c478bd9Sstevel@tonic-gate if (shortl) 126*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\l'|\\n(%du'", cr+CRIGHT); 127*7c478bd9Sstevel@tonic-gate else 128*7c478bd9Sstevel@tonic-gate { 129*7c478bd9Sstevel@tonic-gate lnch = "\\(ul"; 130*7c478bd9Sstevel@tonic-gate if (pr1403) 131*7c478bd9Sstevel@tonic-gate lnch = lintype==2 ? "=" : "\\(ru"; 132*7c478bd9Sstevel@tonic-gate if (cr+1>=ncol) 133*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch); 134*7c478bd9Sstevel@tonic-gate else 135*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr+CRIGHT, 136*7c478bd9Sstevel@tonic-gate cr+1+CLEFT, exhr, lnch); 137*7c478bd9Sstevel@tonic-gate } 138*7c478bd9Sstevel@tonic-gate if (linsize) 139*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); 140*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\s0"); 141*7c478bd9Sstevel@tonic-gate } 142*7c478bd9Sstevel@tonic-gate if (oldpos!=0) 143*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%dp'", -oldpos); 144*7c478bd9Sstevel@tonic-gate if (!nodata) 145*7c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'+.5m'"); 146*7c478bd9Sstevel@tonic-gate } 147*7c478bd9Sstevel@tonic-gate getstop() 148*7c478bd9Sstevel@tonic-gate { 149*7c478bd9Sstevel@tonic-gate int i,c,k,junk, stopp; 150*7c478bd9Sstevel@tonic-gate stopp=1; 151*7c478bd9Sstevel@tonic-gate for(i=0; i<MAXLIN; i++) 152*7c478bd9Sstevel@tonic-gate linestop[i]=0; 153*7c478bd9Sstevel@tonic-gate for(i=0; i<nlin; i++) 154*7c478bd9Sstevel@tonic-gate for(c=0; c<ncol; c++) 155*7c478bd9Sstevel@tonic-gate { 156*7c478bd9Sstevel@tonic-gate k = left(i,c,&junk); 157*7c478bd9Sstevel@tonic-gate if (k>=0 && linestop[k]==0) 158*7c478bd9Sstevel@tonic-gate linestop[k]= ++stopp; 159*7c478bd9Sstevel@tonic-gate } 160*7c478bd9Sstevel@tonic-gate if (boxflg || allflg || dboxflg) 161*7c478bd9Sstevel@tonic-gate linestop[0]=1; 162*7c478bd9Sstevel@tonic-gate } 163*7c478bd9Sstevel@tonic-gate left(i,c, lwidp) 164*7c478bd9Sstevel@tonic-gate int *lwidp; 165*7c478bd9Sstevel@tonic-gate { 166*7c478bd9Sstevel@tonic-gate int kind, li, lj; 167*7c478bd9Sstevel@tonic-gate /* returns -1 if no line to left */ 168*7c478bd9Sstevel@tonic-gate /* returns number of line where it starts */ 169*7c478bd9Sstevel@tonic-gate /* stores into lwid the kind of line */ 170*7c478bd9Sstevel@tonic-gate *lwidp=0; 171*7c478bd9Sstevel@tonic-gate kind = lefdata(i,c); 172*7c478bd9Sstevel@tonic-gate if (kind==0) return(-1); 173*7c478bd9Sstevel@tonic-gate if (i+1<nlin) 174*7c478bd9Sstevel@tonic-gate if (lefdata(next(i),c)== kind) return(-1); 175*7c478bd9Sstevel@tonic-gate while (i>=0 && lefdata(i,c)==kind) 176*7c478bd9Sstevel@tonic-gate i=prev(li=i); 177*7c478bd9Sstevel@tonic-gate if (prev(li)== -1) li=0; 178*7c478bd9Sstevel@tonic-gate *lwidp=kind; 179*7c478bd9Sstevel@tonic-gate for(lj= i+1; lj<li; lj++) 180*7c478bd9Sstevel@tonic-gate if (instead[lj] && strcmp(instead[lj], ".TH")==0) 181*7c478bd9Sstevel@tonic-gate return(li); 182*7c478bd9Sstevel@tonic-gate for(i= i+1; i<li; i++) 183*7c478bd9Sstevel@tonic-gate if (fullbot[i]) 184*7c478bd9Sstevel@tonic-gate li=i; 185*7c478bd9Sstevel@tonic-gate return(li); 186*7c478bd9Sstevel@tonic-gate } 187*7c478bd9Sstevel@tonic-gate lefdata(i,c) 188*7c478bd9Sstevel@tonic-gate { 189*7c478bd9Sstevel@tonic-gate int ck; 190*7c478bd9Sstevel@tonic-gate if (i>=nlin) i=nlin-1; 191*7c478bd9Sstevel@tonic-gate if (ctype(i,c) == 's') 192*7c478bd9Sstevel@tonic-gate { 193*7c478bd9Sstevel@tonic-gate for(ck=c; ctype(i,ck)=='s'; ck--); 194*7c478bd9Sstevel@tonic-gate if (thish(i,ck)==0) 195*7c478bd9Sstevel@tonic-gate return(0); 196*7c478bd9Sstevel@tonic-gate } 197*7c478bd9Sstevel@tonic-gate i =stynum[i]; 198*7c478bd9Sstevel@tonic-gate i = lefline[i][c]; 199*7c478bd9Sstevel@tonic-gate if (i>0) return(i); 200*7c478bd9Sstevel@tonic-gate if (dboxflg && c==0) return(2); 201*7c478bd9Sstevel@tonic-gate if (allflg)return(1); 202*7c478bd9Sstevel@tonic-gate if (boxflg && c==0) return(1); 203*7c478bd9Sstevel@tonic-gate return(0); 204*7c478bd9Sstevel@tonic-gate } 205*7c478bd9Sstevel@tonic-gate next(i) 206*7c478bd9Sstevel@tonic-gate { 207*7c478bd9Sstevel@tonic-gate while (i+1 <nlin) 208*7c478bd9Sstevel@tonic-gate { 209*7c478bd9Sstevel@tonic-gate i++; 210*7c478bd9Sstevel@tonic-gate if (!fullbot[i] && !instead[i]) break; 211*7c478bd9Sstevel@tonic-gate } 212*7c478bd9Sstevel@tonic-gate return(i); 213*7c478bd9Sstevel@tonic-gate } 214*7c478bd9Sstevel@tonic-gate prev(i) 215*7c478bd9Sstevel@tonic-gate { 216*7c478bd9Sstevel@tonic-gate while (--i >=0 && (fullbot[i] || instead[i])) 217*7c478bd9Sstevel@tonic-gate ; 218*7c478bd9Sstevel@tonic-gate return(i); 219*7c478bd9Sstevel@tonic-gate } 220