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