Commit | Line | Data |
---|---|---|
94bed826 KB |
1 | /*- |
2 | * %sccs.include.proprietary.c% | |
3 | */ | |
4 | ||
476fcd16 | 5 | #ifndef lint |
94bed826 KB |
6 | static 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" | |
11 | struct 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}; | |
33 | getcomm() | |
34 | { | |
35 | char line[200], *cp, nb[25], *t; | |
36 | struct optstr *lp; | |
37 | int c, ci, found; | |
38 | for(lp= options; lp->optnam; lp++) | |
39 | *(lp->optadd) = 0; | |
40 | texname = texstr[texct=0]; | |
41 | tab = '\t'; | |
42 | printf(".nr %d \\n(.s\n", LSIZE); | |
43 | gets1(line); | |
44 | /* see if this is a command line */ | |
45 | if (index(line,';') == NULL) | |
46 | { | |
47 | backrest(line); | |
48 | return; | |
49 | } | |
50 | for(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 | } | |
88 | cp++; | |
89 | backrest(cp); | |
90 | return; | |
91 | } | |
92 | backrest(cp) | |
93 | char *cp; | |
94 | { | |
95 | char *s; | |
96 | for(s=cp; *s; s++); | |
97 | un1getc('\n'); | |
98 | while (s>cp) | |
99 | un1getc(*--s); | |
100 | return; | |
101 | } |