2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: options.c,v 1.16 1994/06/27 08:01:46 ceriel Exp $ */
6 /* U S E R O P T I O N - H A N D L I N G */
9 #include "botch_free.h"
13 #include "nobitfield.h"
25 extern char **inctable;
29 int do_dependencies = 0;
34 char options[128]; /* one for every char */
36 char loptions[128]; /* one for every char */
49 next_option: /* to allow combined one-char options */
50 switch (opt = *text++) {
52 case 0: /* to end the goto next_option loop */
57 fatal("illegal option: %c", opt);
59 warning("illegal option: %c", opt);
64 options[*text++] = 1; /* flags, debug options etc. */
69 case 'A' : /* Amake dependency generation */
82 case 'g': /* symbol table for debugger */
92 case 'p': /* procentry/procexit */
93 case 'L' : /* no fil/lin */
94 case 'n': /* use no registers */
95 case 'w': /* no warnings will be given */
96 case 's': /* no stricts will be given */
97 case 'o': /* no complaints about old-style */
100 case 'a': /* suppress all but errors diagnostics */
101 options['w'] = 1; /* implies -a */
107 case 'h': /* heuristic tests */
108 case 'v': /* no complaints about unused arguments */
109 case 'a': /* check long->int int->long conversions */
110 case 'b': /* don't report unreachable break-statements */
111 case 'x': /* complain about unused extern declared variables */
112 case 'u': /* no "used but not defined"; for pass 2 */
113 case 'L': /* lintlibrary */
119 case 'D' : { /* -Dname : predefine name */
120 register char *cp = text, *name, *mactext;
123 if (class(*cp) != STIDF && class(*cp) != STELL) {
124 error("identifier missing in -D%s", text);
130 while (*cp && in_idf(*cp)) {
134 if (!*cp) { /* -Dname */
136 mactext = Salloc("1", 2);
139 if (*cp == '=') { /* -Dname=text */
140 *cp++ = '\0'; /* end of name */
141 maclen = (unsigned) strlen(cp);
142 mactext = Salloc(cp, maclen + 1);
144 else { /* -Dname?? */
145 error("malformed option -D%s", text);
149 macro_def(str2idf(name, 0), mactext, -1, (int)maclen, NOFLAG);
153 case 'I' : /* -Ipath : insert "path" into include list */
156 register char *new = text;
158 if (inc_total >= inc_max) {
160 Realloc((char *)inctable,
161 (unsigned)((inc_max+=10)*sizeof(char *)));
164 for (i = inc_pos++; i < inc_total ; i++) {
165 char *tmp = inctable[i];
172 else inctable[inc_pos] = 0;
176 case 'M': /* maximum identifier length */
177 idfsize = txt2int(&text);
178 if (*text || idfsize <= 0)
179 fatal("malformed -M option");
180 if (idfsize > IDFSIZE)
181 fatal("maximum identifier length is %d", IDFSIZE);
185 case 'S' : { /* -Sint : static scope number for lint */
186 extern int stat_number;
187 stat_number = txt2int(&text);
194 extern char *C_tmpdir;
200 warning("-T option ignored");
206 case 'U' : /* -Uname : undefine predefined */
207 if (*text) do_undef(str2idf(text, 0));
213 case 'V' : /* set object sizes and alignment requirements */
215 register arith sz, algn;
218 while (c = *text++) {
223 algn = txt2int(&text);
226 case 's': /* short */
234 dword_size = (word_size = sz) << 1;
250 case 'f': /* float */
256 case 'd': /* double */
262 case 'x': /* long double */
268 case 'p': /* pointer */
272 pointer_align = algn;
274 case 'r': /* adjust bitfields right */
277 #else /* NOBITFIELD */
278 warning("bitfields are not implemented");
279 #endif /* NOBITFIELD */
281 case 'S': /* initial struct alignment */
285 case 'U': /* initial union alignment */
290 error("-V: bad type indicator %c\n", c);
296 density = txt2int(&text);
307 /* the integer pointed to by *tp is read, while increasing
308 *tp; the resulting value is yielded.
310 register int val = 0, ch;
312 while (ch = **tp, ch >= '0' && ch <= '9') {
313 val = val * 10 + ch - '0';