Blob


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