1*381Smuffin /*
2*381Smuffin * Copyright 1991 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 /* t3.c: interpret commands affecting whole table */
180Sstevel@tonic-gate # include "t..c"
19*381Smuffin #include <string.h>
20*381Smuffin
210Sstevel@tonic-gate struct optstr {char *optnam; int *optadd;} options [] = {
220Sstevel@tonic-gate "expand", &expflg,
230Sstevel@tonic-gate "EXPAND", &expflg,
240Sstevel@tonic-gate "center", &ctrflg,
250Sstevel@tonic-gate "CENTER", &ctrflg,
260Sstevel@tonic-gate "box", &boxflg,
270Sstevel@tonic-gate "BOX", &boxflg,
280Sstevel@tonic-gate "allbox", &allflg,
290Sstevel@tonic-gate "ALLBOX", &allflg,
300Sstevel@tonic-gate "doublebox", &dboxflg,
310Sstevel@tonic-gate "DOUBLEBOX", &dboxflg,
320Sstevel@tonic-gate "frame", &boxflg,
330Sstevel@tonic-gate "FRAME", &boxflg,
340Sstevel@tonic-gate "doubleframe", &dboxflg,
350Sstevel@tonic-gate "DOUBLEFRAME", &dboxflg,
360Sstevel@tonic-gate "tab", &tab,
370Sstevel@tonic-gate "TAB", &tab,
380Sstevel@tonic-gate "linesize", &linsize,
390Sstevel@tonic-gate "LINESIZE", &linsize,
400Sstevel@tonic-gate "delim", &delim1,
410Sstevel@tonic-gate "DELIM", &delim1,
420Sstevel@tonic-gate 0,0};
43*381Smuffin
44*381Smuffin void backrest(char *);
45*381Smuffin
46*381Smuffin void
getcomm(void)47*381Smuffin getcomm(void)
480Sstevel@tonic-gate {
490Sstevel@tonic-gate char line[200], *cp, nb[25], *t;
500Sstevel@tonic-gate struct optstr *lp;
510Sstevel@tonic-gate int c, ci, found;
520Sstevel@tonic-gate for(lp= options; lp->optnam; lp++)
530Sstevel@tonic-gate *(lp->optadd) = 0;
540Sstevel@tonic-gate texname = texstr[texct=0];
550Sstevel@tonic-gate tab = '\t';
560Sstevel@tonic-gate printf(".nr %d \\n(.s\n", LSIZE);
570Sstevel@tonic-gate gets1(line, sizeof line);
580Sstevel@tonic-gate /* see if this is a command line */
590Sstevel@tonic-gate if (strchr(line,';') == NULL)
600Sstevel@tonic-gate {
610Sstevel@tonic-gate backrest(line);
620Sstevel@tonic-gate return;
630Sstevel@tonic-gate }
640Sstevel@tonic-gate for(cp=line; (c = *cp) != ';'; cp++)
650Sstevel@tonic-gate {
660Sstevel@tonic-gate if (!letter(c)) continue;
670Sstevel@tonic-gate found=0;
680Sstevel@tonic-gate for(lp= options; lp->optadd; lp++)
690Sstevel@tonic-gate {
700Sstevel@tonic-gate if (prefix(lp->optnam, cp))
710Sstevel@tonic-gate {
720Sstevel@tonic-gate *(lp->optadd) = 1;
730Sstevel@tonic-gate cp += strlen(lp->optnam);
740Sstevel@tonic-gate if (letter(*cp))
750Sstevel@tonic-gate error(gettext("Misspelled global option"));
760Sstevel@tonic-gate while (*cp==' ')cp++;
770Sstevel@tonic-gate t=nb;
780Sstevel@tonic-gate if ( *cp == '(')
790Sstevel@tonic-gate while ((ci= *++cp) != ')')
800Sstevel@tonic-gate *t++ = ci;
810Sstevel@tonic-gate else cp--;
820Sstevel@tonic-gate *t++ = 0; *t=0;
830Sstevel@tonic-gate if (lp->optadd == &tab)
840Sstevel@tonic-gate {
850Sstevel@tonic-gate if (nb[0])
860Sstevel@tonic-gate *(lp->optadd) = nb[0];
870Sstevel@tonic-gate }
880Sstevel@tonic-gate if (lp->optadd == &linsize)
890Sstevel@tonic-gate printf(".nr %d %s\n", LSIZE, nb);
900Sstevel@tonic-gate if (lp->optadd == &delim1)
910Sstevel@tonic-gate {
920Sstevel@tonic-gate delim1 = nb[0];
930Sstevel@tonic-gate delim2 = nb[1];
940Sstevel@tonic-gate }
950Sstevel@tonic-gate found=1;
960Sstevel@tonic-gate break;
970Sstevel@tonic-gate }
980Sstevel@tonic-gate }
990Sstevel@tonic-gate if (!found)
1000Sstevel@tonic-gate error(gettext("Illegal option"));
1010Sstevel@tonic-gate }
1020Sstevel@tonic-gate cp++;
1030Sstevel@tonic-gate backrest(cp);
1040Sstevel@tonic-gate return;
1050Sstevel@tonic-gate }
106*381Smuffin
107*381Smuffin void
backrest(char * cp)108*381Smuffin backrest(char *cp)
1090Sstevel@tonic-gate {
1100Sstevel@tonic-gate char *s;
1110Sstevel@tonic-gate for(s=cp; *s; s++);
1120Sstevel@tonic-gate un1getc('\n');
1130Sstevel@tonic-gate while (s>cp)
1140Sstevel@tonic-gate un1getc(*--s);
1150Sstevel@tonic-gate return;
1160Sstevel@tonic-gate }
117