1 #ifndef lint 2 static char sccsid[] = "@(#)troffgen.c 1.1 (CWI) 85/07/19"; 3 #endif lint 4 5 #include <stdio.h> 6 #include "pic.h" 7 #include "y.tab.h" 8 9 struct obj *troffgen(s) /* save away a string of troff commands */ 10 YYSTYPE s; 11 { 12 struct obj *p; 13 14 if (strncmp(s.p, ".PS", 3) == 0) 15 yyerror(".PS found inside .PS/.PE"); 16 savetext(CENTER, s.p); /* use the existing text mechanism */ 17 p = makenode(TROFF, 0); 18 return(p); 19 } 20 21 savetext(t, s) /* record text elements for current object */ 22 int t; 23 char *s; 24 { 25 switch (t) { 26 case CENTER: t = 'C'; break; 27 case LJUST: t = 'L'; break; 28 case RJUST: t = 'R'; break; 29 case SPREAD: t = 'S'; break; 30 case FILL: t = 'F'; break; 31 case ABOVE: t = 'A'; break; 32 case BELOW: t = 'B'; break; 33 } 34 if (ntext >= MAXTEXT) { 35 yyerror("too many text strings (%d)\n", ntext); 36 exit(1); 37 } 38 text[ntext].t_type = t; 39 text[ntext].t_val = s; 40 dprintf("saving %c text %s at %d\n", t, s, ntext); 41 ntext++; 42 } 43