8322 nl: misleading-indentation
[unleashed.git] / usr / src / cmd / tbl / t3.c
blob7b9cdb2e857fa43ce17b06ce20d1b4c5d1fee549
1 /*
2 * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* t3.c: interpret commands affecting whole table */
18 # include "t..c"
19 #include <string.h>
21 struct optstr {char *optnam; int *optadd;} options [] = {
22 "expand", &expflg,
23 "EXPAND", &expflg,
24 "center", &ctrflg,
25 "CENTER", &ctrflg,
26 "box", &boxflg,
27 "BOX", &boxflg,
28 "allbox", &allflg,
29 "ALLBOX", &allflg,
30 "doublebox", &dboxflg,
31 "DOUBLEBOX", &dboxflg,
32 "frame", &boxflg,
33 "FRAME", &boxflg,
34 "doubleframe", &dboxflg,
35 "DOUBLEFRAME", &dboxflg,
36 "tab", &tab,
37 "TAB", &tab,
38 "linesize", &linsize,
39 "LINESIZE", &linsize,
40 "delim", &delim1,
41 "DELIM", &delim1,
42 0,0};
44 void backrest(char *);
46 void
47 getcomm(void)
49 char line[200], *cp, nb[25], *t;
50 struct optstr *lp;
51 int c, ci, found;
52 for(lp= options; lp->optnam; lp++)
53 *(lp->optadd) = 0;
54 texname = texstr[texct=0];
55 tab = '\t';
56 printf(".nr %d \\n(.s\n", LSIZE);
57 gets1(line, sizeof line);
58 /* see if this is a command line */
59 if (strchr(line,';') == NULL)
61 backrest(line);
62 return;
64 for(cp=line; (c = *cp) != ';'; cp++)
66 if (!letter(c)) continue;
67 found=0;
68 for(lp= options; lp->optadd; lp++)
70 if (prefix(lp->optnam, cp))
72 *(lp->optadd) = 1;
73 cp += strlen(lp->optnam);
74 if (letter(*cp))
75 error(gettext("Misspelled global option"));
76 while (*cp==' ')cp++;
77 t=nb;
78 if ( *cp == '(')
79 while ((ci= *++cp) != ')')
80 *t++ = ci;
81 else cp--;
82 *t++ = 0; *t=0;
83 if (lp->optadd == &tab)
85 if (nb[0])
86 *(lp->optadd) = nb[0];
88 if (lp->optadd == &linsize)
89 printf(".nr %d %s\n", LSIZE, nb);
90 if (lp->optadd == &delim1)
92 delim1 = nb[0];
93 delim2 = nb[1];
95 found=1;
96 break;
99 if (!found)
100 error(gettext("Illegal option"));
102 cp++;
103 backrest(cp);
104 return;
107 void
108 backrest(char *cp)
110 char *s;
111 for(s=cp; *s; s++);
112 un1getc('\n');
113 while (s>cp)
114 un1getc(*--s);
115 return;