Detect and remove defunct or unknown options from opt_*.h files. This

can happen when options are removed from the options files.
This commit is contained in:
Peter Wemm 1999-07-01 16:17:13 +00:00
parent 5cda71067d
commit 02e7144a4e

View File

@ -37,7 +37,7 @@
static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93"; static char sccsid[] = "@(#)mkheaders.c 8.1 (Berkeley) 6/6/93";
#endif #endif
static const char rcsid[] = static const char rcsid[] =
"$Id: mkoptions.c,v 1.10 1999/04/18 13:36:29 peter Exp $"; "$Id: mkoptions.c,v 1.11 1999/04/24 18:59:19 peter Exp $";
#endif /* not lint */ #endif /* not lint */
/* /*
@ -125,11 +125,13 @@ do_option(name)
char *name; char *name;
{ {
char *file, *inw; char *file, *inw;
struct opt_list *ol;
struct opt *op, *op_head, *topp; struct opt *op, *op_head, *topp;
FILE *inf, *outf; FILE *inf, *outf;
char *value; char *value;
char *oldvalue; char *oldvalue;
int seen; int seen;
int tidy;
file = tooption(name); file = tooption(name);
@ -169,6 +171,7 @@ do_option(name)
oldvalue = NULL; oldvalue = NULL;
op_head = NULL; op_head = NULL;
seen = 0; seen = 0;
tidy = 0;
for (;;) { for (;;) {
char *cp; char *cp;
char *invalue; char *invalue;
@ -180,8 +183,8 @@ do_option(name)
if ((inw = get_word(inf)) == 0 || inw == (char *)EOF) if ((inw = get_word(inf)) == 0 || inw == (char *)EOF)
break; break;
inw = ns(inw); inw = ns(inw);
cp = get_word(inf); /* get the option value */
if (cp == 0 || cp == (char *)EOF) if ((cp = get_word(inf)) == 0 || cp == (char *)EOF)
break; break;
/* option value */ /* option value */
invalue = ns(cp); /* malloced */ invalue = ns(cp); /* malloced */
@ -190,12 +193,21 @@ do_option(name)
invalue = value; invalue = value;
seen++; seen++;
} }
op = (struct opt *) malloc(sizeof *op); for (ol = otab; ol != 0; ol = ol->o_next)
bzero(op, sizeof(*op)); if (eq(inw, ol->o_name))
op->op_name = inw; break;
op->op_value = invalue; if (!seen && !ol) {
op->op_next = op_head; printf("WARNING: unknown option `%s' removed from %s\n",
op_head = op; inw, file);
tidy++;
} else {
op = (struct opt *) malloc(sizeof *op);
bzero(op, sizeof(*op));
op->op_name = inw;
op->op_value = invalue;
op->op_next = op_head;
op_head = op;
}
/* EOL? */ /* EOL? */
cp = get_word(inf); cp = get_word(inf);
@ -203,8 +215,8 @@ do_option(name)
break; break;
} }
(void) fclose(inf); (void) fclose(inf);
if ((value == NULL && oldvalue == NULL) || if (!tidy && ((value == NULL && oldvalue == NULL) ||
(value && oldvalue && eq(value,oldvalue))) { (value && oldvalue && eq(value, oldvalue)))) {
for (op = op_head; op != NULL; op = topp) { for (op = op_head; op != NULL; op = topp) {
topp = op->op_next; topp = op->op_next;
free(op->op_name); free(op->op_name);