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