1*381Smuffin /*
2*381Smuffin * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
3*381Smuffin * Use is subject to license terms.
4*381Smuffin */
5*381Smuffin
60Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
70Sstevel@tonic-gate /* All Rights Reserved */
80Sstevel@tonic-gate
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate */
140Sstevel@tonic-gate
15*381Smuffin #pragma ident "%Z%%M% %I% %E% SMI"
160Sstevel@tonic-gate
170Sstevel@tonic-gate /* tg.c: process included text blocks */
180Sstevel@tonic-gate # include "t..c"
190Sstevel@tonic-gate /* get_text was originally gettext and was renamed */
20*381Smuffin
21*381Smuffin int
get_text(char * sp,int ilin,int icol,char * fn,char * sz)22*381Smuffin get_text(char *sp, int ilin, int icol, char *fn, char *sz)
230Sstevel@tonic-gate {
240Sstevel@tonic-gate /* get a section of text */
250Sstevel@tonic-gate char line[BIGBUF];
260Sstevel@tonic-gate int oname;
270Sstevel@tonic-gate char *vs;
280Sstevel@tonic-gate if (texname==0) error(gettext("Too many text block diversions"));
290Sstevel@tonic-gate if (textflg==0)
300Sstevel@tonic-gate {
310Sstevel@tonic-gate fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
320Sstevel@tonic-gate textflg=1;
330Sstevel@tonic-gate }
340Sstevel@tonic-gate fprintf(tabout, ".eo\n");
350Sstevel@tonic-gate fprintf(tabout, ".am %02d\n", icol+80);
360Sstevel@tonic-gate fprintf(tabout, ".br\n");
370Sstevel@tonic-gate fprintf(tabout, ".di %c+\n", texname);
380Sstevel@tonic-gate rstofill();
390Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
400Sstevel@tonic-gate fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
410Sstevel@tonic-gate vs = vsize[stynum[ilin]][icol];
420Sstevel@tonic-gate if ((sz && *sz) || (vs && *vs))
430Sstevel@tonic-gate {
440Sstevel@tonic-gate fprintf(tabout, ".nr %d \\n(.v\n", S2);
450Sstevel@tonic-gate if (vs==0 || *vs==0) vs= "\\n(.s+2";
460Sstevel@tonic-gate if (sz && *sz)
470Sstevel@tonic-gate fprintf(tabout, ".ps %s\n",sz);
480Sstevel@tonic-gate fprintf(tabout, ".vs %s\n",vs);
490Sstevel@tonic-gate fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
500Sstevel@tonic-gate }
510Sstevel@tonic-gate if (cll[icol][0])
520Sstevel@tonic-gate fprintf(tabout, ".ll %sn\n", cll[icol]);
530Sstevel@tonic-gate else
540Sstevel@tonic-gate fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
550Sstevel@tonic-gate fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
560Sstevel@tonic-gate if (ctype(ilin,icol)=='a')
570Sstevel@tonic-gate fprintf(tabout, ".ll -2n\n");
580Sstevel@tonic-gate fprintf(tabout, ".in 0\n");
590Sstevel@tonic-gate while (gets1(line, sizeof line))
600Sstevel@tonic-gate {
610Sstevel@tonic-gate if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
620Sstevel@tonic-gate if (match("T}", line)) break;
630Sstevel@tonic-gate fprintf(tabout, "%s\n", line);
640Sstevel@tonic-gate }
650Sstevel@tonic-gate if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
660Sstevel@tonic-gate if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
670Sstevel@tonic-gate fprintf(tabout, ".br\n");
680Sstevel@tonic-gate fprintf(tabout, ".di\n");
690Sstevel@tonic-gate fprintf(tabout, ".nr %c| \\n(dn\n", texname);
700Sstevel@tonic-gate fprintf(tabout, ".nr %c- \\n(dl\n", texname);
710Sstevel@tonic-gate fprintf(tabout, "..\n");
720Sstevel@tonic-gate fprintf(tabout, ".ec \\\n");
730Sstevel@tonic-gate /* copy remainder of line */
740Sstevel@tonic-gate if (line[2])
750Sstevel@tonic-gate tcopy (sp, line+3);
760Sstevel@tonic-gate else
770Sstevel@tonic-gate *sp=0;
780Sstevel@tonic-gate oname=texname;
790Sstevel@tonic-gate texname = texstr[++texct];
800Sstevel@tonic-gate return(oname);
810Sstevel@tonic-gate }
82*381Smuffin
83*381Smuffin void
untext(void)84*381Smuffin untext(void)
850Sstevel@tonic-gate {
860Sstevel@tonic-gate rstofill();
870Sstevel@tonic-gate fprintf(tabout, ".nf\n");
880Sstevel@tonic-gate fprintf(tabout, ".ll \\n(%du\n", SL);
890Sstevel@tonic-gate }
90