8672 proc_t changes broke genunix dmods and walker
[unleashed.git] / usr / src / cmd / tbl / tv.c
blob77fa9c5881214c0344b53eea0612ace4269021d1
1 /*
2 * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* tv.c: draw vertical lines */
18 # include "t..c"
20 void
21 drawvert(int start, int end, int c, int lwid)
23 char *exb=0, *ext=0;
24 int tp=0, sl, ln, pos, epb, ept, vm;
25 end++;
26 vm='v';
27 /* note: nr 35 has value of 1m outside of linesize */
28 while (instead[end]) end++;
29 for(ln=0; ln<lwid; ln++)
31 epb=ept=0;
32 pos = 2*ln-lwid+1;
33 if (pos!=tp) fprintf(tabout, "\\h'%dp'", pos-tp);
34 tp = pos;
35 if (end<nlin)
37 if (fullbot[end]|| (!instead[end] && allh(end)))
38 epb=2;
39 else
40 switch (midbar(end,c))
42 case '-':
43 exb = "1v-.5m"; break;
44 case '=':
45 exb = "1v-.5m";
46 epb = 1; break;
49 if (lwid>1)
50 switch(interh(end, c))
52 case THRU: epb -= 1; break;
53 case RIGHT: epb += (ln==0 ? 1 : -1); break;
54 case LEFT: epb += (ln==1 ? 1 : -1); break;
56 if (lwid==1)
57 switch(interh(end,c))
59 case THRU: epb -= 1; break;
60 case RIGHT: case LEFT: epb += 1; break;
62 if (start>0)
64 sl = start-1;
65 while (sl>=0 && instead[sl]) sl--;
66 if (sl>=0 && (fullbot[sl] || allh(sl)))
67 ept=0;
68 else
69 if (sl>=0)
70 switch(midbar(sl,c))
72 case '-':
73 ext = ".5m"; break;
74 case '=':
75 ext= ".5m"; ept = -1; break;
76 default:
77 vm = 'm'; break;
79 else
80 ept = -4;
82 else if (start==0 && allh(0))
84 ept=0;
85 vm = 'm';
87 if (lwid>1)
88 switch(interh(start,c))
90 case THRU: ept += 1; break;
91 case LEFT: ept += (ln==0 ? 1 : -1); break;
92 case RIGHT: ept += (ln==1 ? 1 : -1); break;
94 else if (lwid==1)
95 switch(interh(start,c))
97 case THRU: ept += 1; break;
98 case LEFT: case RIGHT: ept -= 1; break;
100 if (exb)
101 fprintf(tabout, "\\v'%s'", exb);
102 if (epb)
103 fprintf(tabout, "\\v'%dp'", epb);
104 fprintf(tabout, "\\s\\n(%d",LSIZE);
105 if (linsize)
106 fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
107 fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */
108 fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u");
109 if (ext)
110 fprintf(tabout, "-(%s)",ext);
111 if (exb)
112 fprintf(tabout, "-(%s)", exb);
113 pos = ept-epb;
114 if (pos)
115 fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos);
116 /* the string #d is either "nl" or ".d" depending
117 on diversions; on GCOS not the same */
118 fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u");
119 if (ext)
120 fprintf(tabout, "+%s",ext);
121 if (ept)
122 fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept));
123 fprintf(tabout, "'");
124 if (linsize)
125 fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
130 midbar(int i, int c)
132 int k;
133 k = midbcol(i,c);
134 if (k==0 && c>0)
135 k = midbcol(i, c-1);
136 return(k);
140 midbcol(int i, int c)
142 int ct;
143 while ( (ct=ctype(i,c)) == 's')
144 c--;
145 if (ct=='-' || ct == '=')
146 return(ct);
147 if (ct=barent(table[i][c].col))
148 return(ct);
149 return(0);
153 barent(char *s)
155 if (s==0) return (1);
156 if (!point(s)) return(1);
157 if (s[0]== '\\') s++;
158 if (s[1]!= 0)
159 return(0);
160 switch(s[0])
162 case '_':
163 return('-');
164 case '=':
165 return('=');
167 return(0);