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 3.28 1994/06/24 12:05:32 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"
14 #include "nobitfield.h"
23 #include "noRoption.h"
27 extern char **inctable;
31 int do_dependencies = 0;
36 char options[128]; /* one for every char */
38 char loptions[128]; /* one for every char */
51 next_option: /* to allow combined one-char options */
52 switch (opt = *text++) {
54 case 0: /* to end the goto next_option loop */
59 fatal("illegal option: %c", opt);
61 warning("illegal option: %c", opt);
66 options[*text++] = 1; /* flags, debug options etc. */
73 case 'p': /* procentry/procexit */
74 case 'L' : /* no fil/lin */
75 case 'n': /* use no registers */
76 case 'w': /* no warnings will be given */
82 case 'h': /* heuristic tests */
83 case 'v': /* no complaints about unused arguments */
84 case 'a': /* check long->int int->long conversions */
85 case 'b': /* don't report unreachable break-statements */
86 case 'x': /* complain about unused extern declared variables */
87 case 'u': /* no "used but not defined"; for pass 2 */
88 case 'L': /* lintlibrary */
95 case 'A' : /* Amake dependency generation */
108 case 'g': /* symbol table for debugger */
112 #endif /* DBSYMTAB */
114 case 'R': /* strict version */
117 #else /* NOROPTION */
118 warning("-R option not implemented");
119 #endif /* NOROPTION */
123 deleted, is now a debug-flag
124 case 'C' : /* E option + comment output */
127 warning("-C: comment is not output");
129 warning("-C option ignored");
132 #endif /* ___XXX___ */
134 case 'D' : { /* -Dname : predefine name */
136 register char *cp = text, *name, *mactext;
138 if (class(*cp) != STIDF) {
139 error("identifier missing in -D%s", text);
145 while (*cp && in_idf(*cp)) {
149 if (!*cp) { /* -Dname */
153 if (*cp == '=') { /* -Dname=text */
154 *cp++ = '\0'; /* end of name */
157 else { /* -Dname?? */
158 error("malformed option -D%s", text);
162 macro_def(str2idf(name), mactext, -1, strlen(mactext),
165 warning("-D option ignored");
171 deleted, is now a debug-flag
172 case 'E' : /* run preprocessor only, with #<int> */
176 warning("-E option ignored");
179 #endif /* ___XXX___ */
181 case 'I' : /* -Ipath : insert "path" into include list */
185 register char *new = text;
187 if (++inc_total > inc_max) {
189 Realloc((char *) inctable,(inc_max+=10)*sizeof(char *));
192 for (i = inc_pos++; i < inc_total; i++) {
193 char *tmp = inctable[i];
199 else inctable[inc_pos] = 0;
201 warning("-I option ignored");
205 case 'M': /* maximum identifier length */
206 idfsize = txt2int(&text);
207 if (*text || idfsize <= 0)
208 fatal("malformed -M option");
209 if (idfsize > IDFSIZE)
210 fatal("maximum identifier length is %d", IDFSIZE);
214 deleted, is now a debug-flag
215 case 'P' : /* run preprocessor stand-alone, without #'s */
220 warning("-P option ignored");
223 #endif /* ___XXX___ */
226 case 'S' : { /* -Sint : static scope number for lint */
227 extern int stat_number;
228 stat_number = txt2int(&text);
235 extern char *C_tmpdir;
241 warning("-T option ignored");
246 case 'U' : { /* -Uname : undefine predefined */
248 register struct idf *idef;
251 if ((idef = str2idf(text))->id_macro) {
252 free_macro(idef->id_macro);
253 idef->id_macro = (struct macro *) 0;
257 warning("-U option ignored");
263 case 'V' : /* set object sizes and alignment requirements */
265 warning("-V option ignored");
269 register arith sz, algn;
272 while (c = *text++) {
277 algn = txt2int(&text);
280 case 's': /* short */
288 dword_size = (word_size = sz) << 1;
304 case 'f': /* float */
312 case 'd': /* double */
320 case 'p': /* pointer */
324 pointer_align = algn;
326 case 'r': /* adjust bitfields right */
329 #else /* NOBITFIELD */
330 warning("bitfields are not implemented");
331 #endif /* NOBITFIELD */
333 case 'S': /* initial struct alignment */
337 case 'U': /* initial union alignment */
342 error("-V: bad type indicator %c\n", c);
349 density = txt2int(&text);
359 /* the integer pointed to by *tp is read, while increasing
360 *tp; the resulting value is yielded.
362 register int val = 0, ch;
364 while (ch = **tp, ch >= '0' && ch <= '9') {
365 val = val * 10 + ch - '0';