diff -ur src.o/usr.sbin/config/config.h src/usr.sbin/config/config.h --- src.o/usr.sbin/config/config.h Mon Apr 30 10:55:43 2007 +++ src/usr.sbin/config/config.h Mon May 14 01:25:11 2007 @@ -177,7 +177,7 @@ void cfgfile_add(const char *); void cfgfile_removeall(void); -extern STAILQ_HEAD(device_head, device) dtab, rmdtab; +extern STAILQ_HEAD(device_head, device) dtab; extern char errbuf[80]; extern int yyline; diff -ur src.o/usr.sbin/config/config.y src/usr.sbin/config/config.y --- src.o/usr.sbin/config/config.y Sat May 12 21:38:18 2007 +++ src/usr.sbin/config/config.y Mon May 14 01:33:13 2007 @@ -78,7 +78,7 @@ #include "config.h" -struct device_head dtab, rmdtab; +struct device_head dtab; char *ident; char *env; int envmode; @@ -105,9 +105,6 @@ return ret; } -static void rmoptall(struct opt_head *list, struct opt_head *torem); -static void rmdevall(struct device_head *dh, struct device_head *torem); - %} %% Configuration: @@ -177,7 +174,7 @@ OPTIONS Opt_list | NOOPTION Save_id - = { rmopt_schedule(&rmopts, $2); } | + = { rmopt_schedule(&opt, $2); } | MAKEOPTIONS Mkopt_list | NOMAKEOPTION Save_id @@ -305,10 +302,10 @@ = { char *s = devopt($1); - rmopt_schedule(&rmopts, s); + rmopt_schedule(&opt, s); free(s); /* and the device part */ - rmdev_schedule(&rmdtab, $1); + rmdev_schedule(&dtab, $1); } ; %% @@ -323,17 +320,14 @@ int yywrap(void) { - - if (found_defaults == 0 && incignore == 0) { - if (freopen("DEFAULTS", "r", stdin) == NULL) - return 1; - yyfile = "DEFAULTS"; + if (found_defaults) { + if (freopen(PREFIX, "r", stdin) == NULL) + err(2, "%s", PREFIX); + yyfile = PREFIX; yyline = 0; - found_defaults = 1; + found_defaults = 0; return 0; } - rmoptall(&opt, &rmopts); - rmdevall(&dtab, &rmdtab); return 1; } @@ -391,29 +385,10 @@ { struct device *dp; - dp = calloc(1, sizeof(struct device)); - dp->d_name = strdup(name); - assert(dp->d_name != NULL); - STAILQ_INSERT_HEAD(dh, dp, d_next); -} - -/* - * Take care a devices previously scheduled for removal. - */ -static void -rmdevall(struct device_head *dh, struct device_head *torem) -{ - struct device *dp, *rdp; - - while (!STAILQ_EMPTY(torem)) { - dp = STAILQ_FIRST(torem); - STAILQ_REMOVE_HEAD(torem, d_next); - rdp = finddev(dh, dp->d_name); - if (rdp != NULL) { - STAILQ_REMOVE(dh, rdp, device, d_next); - free(rdp->d_name); - free(rdp); - } + dp = finddev(dh, name); + if (dp != NULL) { + STAILQ_REMOVE(dh, dp, device, d_next); + free(dp->d_name); free(dp); } } @@ -469,31 +444,10 @@ { struct opt *op; - op = calloc(1, sizeof(*op)); - op->op_name = ns(name); - SLIST_INSERT_HEAD(list, op, op_next); -} - -/* - * Remove all options that were scheduled for removal. - */ -static void -rmoptall(struct opt_head *list, struct opt_head *torem) -{ - struct opt *op, *rop; - - op = rop = NULL; - while (!SLIST_EMPTY(torem)) { - op = SLIST_FIRST(torem); - SLIST_REMOVE_HEAD(torem, op_next); - rop = findopt(list, op->op_name); - if (rop != NULL) { - SLIST_REMOVE(list, rop, opt, op_next); - free(rop->op_name); - if (rop->op_value != NULL) - free(rop->op_value); - free(rop); - } + op = findopt(list, name); + if (op != NULL) { + SLIST_REMOVE(list, op, opt, op_next); + free(op->op_name); free(op); } } diff -ur src.o/usr.sbin/config/main.c src/usr.sbin/config/main.c --- src.o/usr.sbin/config/main.c Sun May 13 00:37:52 2007 +++ src/usr.sbin/config/main.c Mon May 14 01:43:45 2007 @@ -150,14 +150,14 @@ usage(); PREFIX = *argv; - /* - * We mark lack of DEFAULTS here. Once we hit EOF in PREFIX, yywrap() - * will try to bring DEFAULTS to the playground, if this exists. - */ - found_defaults = 0; - if (freopen(PREFIX, "r", stdin) == NULL) - err(2, "%s", PREFIX); - yyfile = PREFIX; + if (freopen("DEFAULTS", "r", stdin) != NULL) { + found_defaults = 1; + yyfile = "DEFAULTS"; + } else { + if (freopen(PREFIX, "r", stdin) == NULL) + err(2, "%s", PREFIX); + yyfile = PREFIX; + } if (*destdir != '\0') { len = strlen(destdir); while (len > 1 && destdir[len - 1] == '/') @@ -184,7 +184,6 @@ STAILQ_INIT(&fntab); STAILQ_INIT(&ftab); STAILQ_INIT(&hints); - STAILQ_INIT(&rmdtab); if (yyparse()) exit(3);