1 #ifndef lint
2 static char sccsid[] = "@(#)options.c 1.2 (CWI) 85/10/02";
3 #endif lint
4
5 /*
6 * Threat the option part of the table
7 */
8
9 #include "defs.h"
10 #include "ext.h"
11
12 struct optstr {
13 char *optnam;
14 int *optadd;
15 }options[] = {
16 "expand", &expflg,
17 "EXPAND", &expflg,
18 "center", &ctrflg,
19 "CENTER", &ctrflg,
20 "centre", &ctrflg, /* proper English added by jaap */
21 "CENTRE", &ctrflg, /* proper English added by jaap */
22 "box", &boxflg,
23 "BOX", &boxflg,
24 "allbox", &allflg,
25 "ALLBOX", &allflg,
26 "doublebox", &dboxflg,
27 "DOUBLEBOX", &dboxflg,
28 "frame", &boxflg,
29 "FRAME", &boxflg,
30 "doubleframe", &dboxflg,
31 "DOUBLEFRAME", &dboxflg,
32 "tab", &tab,
33 "TAB", &tab,
34 "linesize", &linsize,
35 "LINESIZ", &linsize,
36 "delim", &delim1,
37 "DELIM", &delim1,
38 0, 0
39 };
40
41 #define NBSIZ 25
42
getcomm()43 getcomm(){
44 char line[BUFSIZ], *cp, nb[NBSIZ], *t;
45 register struct optstr *lp;
46 register int c, ci;
47 int found;
48
49 for(lp = options; lp -> optnam; lp++)
50
51 *(lp -> optadd) = 0;
52 texname = texstr[texct = 0];
53 tab = '\t';
54 printf(".nr %d \\n(.s\n", LSIZE);
55 gets1(line);
56 /*
57 * see if this is a command line
58 */
59 if(index(line, ';') == NULL){
60 backrest(line);
61 return;
62 }
63 for(cp = line; (c = *cp) != ';'; cp++){
64 if(!isalpha(c))
65 continue;
66 found = 0;
67 for(lp = options; lp -> optadd; lp++){
68 if(prefix(lp -> optnam, cp)){
69 *(lp -> optadd) = 1;
70 cp += strlen(lp -> optnam);
71 if(isalpha(*cp))
72 error("Misspelled global option");
73 while(*cp == ' ')
74 cp++;
75 t = nb;
76 if(*cp == '(')
77 while((ci = *++cp) != ')'){
78 *t++ = ci;
79 if(t >= &nb[NBSIZ-3])
80 error("buffer overflow");
81 }
82 else
83 cp--;
84 *t++ = 0;
85 *t = 0;
86 if(lp -> optadd == &tab){
87 if(nb[0])
88 *(lp -> optadd) = nb[0];
89 }
90 if(lp -> optadd == &linsize)
91 printf(".nr %d %s\n", LSIZE, nb);
92 if(lp -> optadd == &delim1){
93 delim1 = nb[0];
94 delim2 = nb[1];
95 }
96 found = 1;
97 break;
98 }
99 }
100 if(!found)
101 error("Illegal option");
102 }
103 cp++;
104 backrest(cp);
105 return;
106 }
107