2 * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
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 /* t8.c: write out one line of output table */
20 # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
26 void puttext(char *, char *, char *);
27 void funnies(int, int);
34 * i: line number for deciding format
35 * nl: line number for finding data usually identical
38 putline(int i
, int nl
)
40 int c
, lf
, ct
, form
, lwid
, vspf
, ip
= -1, cmidx
, exvspen
, vforml
;
43 watchout
=vspf
=exvspen
=0;
45 if (i
==0 && ( allflg
|| boxflg
|| dboxflg
))
46 fullwide(0, dboxflg
? '=' : '-');
47 if (instead
[nl
]==0 && fullbot
[nl
] ==0)
54 for(ip
=nl
; ip
<nlin
; ip
=next(ip
))
55 if (!vspen(s
=table
[ip
][c
].col
)) break;
56 if (s
>(char *)0 && s
<(char *)128)
57 fprintf(tabout
, ".ne \\n(%c|u+\\n(.Vu\n",s
);
60 if (point(s
)) continue;
61 fprintf(tabout
, ".ne \\n(%c|u+\\n(.Vu\n",s
);
65 fprintf(tabout
, ".mk #%c\n", linestop
[nl
]+'a'-1);
74 switch (ct
=fullbot
[nl
])
84 if (instead
[nl
]==0 && fullbot
[nl
]==0)
85 if (vspen(table
[nl
][c
].col
)) vspf
=1;
87 if (vspen(table
[lf
][c
].col
)) vspf
=1;
91 fprintf(tabout
, ".nr #^ \\n(\\*(#du\n");
92 fprintf(tabout
, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
100 chfont
|= (int)(font
[stynum
[nl
]][c
]);
101 if (point(s
) ) continue;
103 if (lf
>=0 && vspen(table
[lf
][c
].col
))
104 fprintf(tabout
, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s
,'a'+c
,s
,'a'+c
);
106 fprintf(tabout
, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s
,s
);
108 if (allflg
&& once
>0 )
112 if (allh(nl
) && !pr1403
)
114 fprintf(tabout
, ".nr %d \\n(.v\n", SVS
);
115 fprintf(tabout
, ".vs \\n(.vu-\\n(.sp\n");
118 fprintf(tabout
, ".nr %2d \\n(.f\n", S1
);
119 fprintf(tabout
, ".nr 35 1m\n");
120 fprintf(tabout
, "\\&");
122 for(c
=0; c
<ncol
; c
++)
124 if (watchout
==0 && i
+1<nlin
&& (lf
=left(i
,c
, &lwid
))>=0)
127 drawvert(lf
, i
, c
, lwid
);
130 if (rightl
&& c
+1==ncol
) continue;
132 for(lf
=prev(nl
); lf
>=0 && vspen(table
[lf
][c
].col
); lf
=prev(lf
))
134 form
= ctype(vforml
,c
);
138 if (form
=='a') ct
= c
+CMID
;
139 if (form
=='n' && table
[nl
][c
].rcol
&& lused
[c
]==0) ct
= c
+CMID
;
140 fprintf(tabout
, "\\h'|\\n(%du'", ct
);
143 fn
= font
[stynum
[vforml
]][c
];
144 size
= csize
[stynum
[vforml
]][c
];
146 switch(ct
=ctype(vforml
, c
))
150 if (table
[nl
][c
].rcol
)
152 if (lused
[c
]) /*Zero field width*/
156 if (vspen(table
[ip
][c
].col
))
160 fprintf(tabout
, "\\v'-(\\n(\\*(#du-\\n(^%cu", c
+'a');
162 fprintf(tabout
, "-((\\n(#-u-\\n(^%cu)/2u)", c
+'a');
164 fprintf(tabout
, "'");
168 fprintf(tabout
, "%c%c",F1
,F2
);
170 fprintf(tabout
, "%c",F1
);
172 s
= table
[nl
][c
].rcol
;
184 if (real(table
[nl
][c
].col
))
185 fprintf(stderr
,gettext("%s: line %d: Data ignored on table line %d\n"), ifile
, iline
-1, i
+1);
191 if (realsplit
? rused
[c
]: used
[c
]) /*Zero field width*/
193 /* form: 1 left, 2 right, 3 center adjust */
196 makeline(i
,c
,ifline(s
));
201 printf("\\l'|\\n(%du\\&%s'", c
+CRIGHT
, s
+2);
205 cmidx
= ctop
[stynum
[nl
]][c
]==0;
207 if (vspen(table
[ip
][c
].col
))
211 fprintf(tabout
, "\\v'-(\\n(\\*(#du-\\n(^%cu", c
+'a');
213 fprintf(tabout
, "-((\\n(#-u-\\n(^%cu)/2u)", c
+'a');
215 fprintf(tabout
, "'");
218 fprintf(tabout
, "%c", F1
);
220 fprintf(tabout
, "%c", F2
);
224 puttext(s
, fn
, size
);
226 fprintf(tabout
, "%c", F2
);
227 fprintf(tabout
, "%c", F1
);
230 if (vspen(table
[ip
][c
].col
))
232 exvspen
= (c
+1 < ncol
) && vspen(table
[ip
][c
+1].col
) &&
233 (topat
[c
] == topat
[c
+1]) &&
234 (cmidx
== (ctop
[stynum
[nl
]][c
+1]==0)) && (left(i
,c
+1,&lwid
)<0);
237 fprintf(tabout
, "\\v'(\\n(\\*(#du-\\n(^%cu", c
+'a');
239 fprintf(tabout
, "-((\\n(#-u-\\n(^%cu)/2u)", c
+'a');
241 fprintf(tabout
, "'");
246 /* if lines need to be split for gcos here is the place for a backslash */
247 if (vct
> 7 && c
< ncol
)
249 fprintf(tabout
, "\n.sp-1\n\\&");
253 fprintf(tabout
, "\n");
254 if (allh(nl
) && !pr1403
) fprintf(tabout
, ".vs \\n(%du\n", SVS
);
259 for(c
=0; c
<ncol
; c
++)
260 if (vspen(table
[nl
][c
].col
) && (nl
==0 || (lf
=prev(nl
))<0 || !vspen(table
[lf
][c
].col
)))
262 fprintf(tabout
, ".nr ^%c \\n(#^u\n", 'a'+c
);
269 puttext(char *s
, char *fn
, char *size
)
275 fprintf(tabout
, "%s",s
);
276 if (*fn
>0) fprintf(tabout
, "\\f\\n(%2d", S1
);
277 if (size
!=0) putsize("0");
282 funnies(int stl
, int lin
)
284 /* write out funny diverted things */
285 int c
, s
, pl
, lwid
, dv
, lf
, ct
;
287 fprintf(tabout
, ".mk ##\n"); /* rmember current vertical position */
288 fprintf(tabout
, ".nr %d \\n(##\n", S1
); /* bottom position */
289 for(c
=0; c
<ncol
; c
++)
291 s
= (int)table
[lin
][c
].col
;
292 if (point(s
)) continue;
294 fprintf(tabout
, ".sp |\\n(##u-1v\n");
295 fprintf(tabout
, ".nr %d ", SIND
);
296 for(pl
=stl
; pl
>=0 && !isalpha(ct
=ctype(pl
,c
)); pl
=prev(pl
))
302 fprintf(tabout
, "(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c
+CLEFT
,c
-1+ctspan(lin
,c
)+CRIGHT
, s
);
305 fprintf(tabout
, "\\n(%du\n",c
+CLEFT
);
308 fprintf(tabout
, "\\n(%du\n",c
+CMID
);
311 fprintf(tabout
, "\\n(%du-\\n(%c-u\n", c
+CRIGHT
, s
);
314 fprintf(tabout
, ".in +\\n(%du\n", SIND
);
315 fn
=font
[stynum
[stl
]][c
];
318 if (stl
>0 && pl
>=0 && vspen(table
[pl
][c
].col
))
320 fprintf(tabout
, ".sp |\\n(^%cu\n", 'a'+c
);
321 if (ctop
[stynum
[stl
]][c
]==0)
323 fprintf(tabout
, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP
, 'a'+c
, s
);
324 fprintf(tabout
, ".if \\n(%d>0 .sp \\n(%du/2u\n", TMP
, TMP
);
327 fprintf(tabout
, ".%c+\n",s
);
328 fprintf(tabout
, ".in -\\n(%du\n", SIND
);
329 if (*fn
>0) putfont("P");
330 fprintf(tabout
, ".mk %d\n", S2
);
331 fprintf(tabout
, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2
, S1
, S1
, S2
);
333 fprintf(tabout
, ".sp |\\n(%du\n", S1
);
334 for(c
=dv
=0; c
<ncol
; c
++)
336 if (stl
+1< nlin
&& (lf
=left(stl
,c
,&lwid
))>=0)
339 fprintf(tabout
, ".sp -1\n");
342 drawvert(lf
, stl
, c
, lwid
);
346 fprintf(tabout
,"\n");
353 fprintf(tabout
, fn
[1] ? "\\f(%.2s" : "\\f%.2s", fn
);
360 fprintf(tabout
, "\\s%s",s
);