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