Bell 32V development
[unix-history] / usr / src / cmd / tbl / t3.c
CommitLineData
6554f91c
TL
1 /* t3.c: interpret commands affecting whole table */
2# include "t..c"
3struct optstr {char *optnam; int *optadd;} options [] = {
4 "expand", &expflg,
5 "EXPAND", &expflg,
6 "center", &ctrflg,
7 "CENTER", &ctrflg,
8 "box", &boxflg,
9 "BOX", &boxflg,
10 "allbox", &allflg,
11 "ALLBOX", &allflg,
12 "doublebox", &dboxflg,
13 "DOUBLEBOX", &dboxflg,
14 "frame", &boxflg,
15 "FRAME", &boxflg,
16 "doubleframe", &dboxflg,
17 "DOUBLEFRAME", &dboxflg,
18 "tab", &tab,
19 "TAB", &tab,
20 "linesize", &linsize,
21 "LINESIZE", &linsize,
22 "delim", &delim1,
23 "DELIM", &delim1,
24 0,0};
25getcomm()
26{
27char line[200], *cp, nb[25], *t;
28struct optstr *lp;
29int c, ci, found;
30for(lp= options; lp->optnam; lp++)
31 *(lp->optadd) = 0;
32texname = texstr[texct=0];
33tab = '\t';
34printf(".nr %d \\n(.s\n", LSIZE);
35gets1(line);
36/* see if this is a command line */
37if (index(line,';') == NULL)
38 {
39 backrest(line);
40 return;
41 }
42for(cp=line; (c = *cp) != ';'; cp++)
43 {
44 if (!letter(c)) continue;
45 found=0;
46 for(lp= options; lp->optadd; lp++)
47 {
48 if (prefix(lp->optnam, cp))
49 {
50 *(lp->optadd) = 1;
51 cp += strlen(lp->optnam);
52 if (letter(*cp))
53 error("Misspelled global option");
54 while (*cp==' ')cp++;
55 t=nb;
56 if ( *cp == '(')
57 while ((ci= *++cp) != ')')
58 *t++ = ci;
59 else cp--;
60 *t++ = 0; *t=0;
61 if (lp->optadd == &tab)
62 {
63 if (nb[0])
64 *(lp->optadd) = nb[0];
65 }
66 if (lp->optadd == &linsize)
67 printf(".nr %d %s\n", LSIZE, nb);
68 if (lp->optadd == &delim1)
69 {
70 delim1 = nb[0];
71 delim2 = nb[1];
72 }
73 found=1;
74 break;
75 }
76 }
77 if (!found)
78 error("Illegal option");
79 }
80cp++;
81backrest(cp);
82return;
83}
84backrest(cp)
85 char *cp;
86{
87char *s;
88for(s=cp; *s; s++);
89un1getc('\n');
90while (s>cp)
91 un1getc(*--s);
92return;
93}