diff --git a/usr.bin/config/main.c b/usr.bin/config/main.c index fa409b84e64c..a1aad388ef21 100644 --- a/usr.bin/config/main.c +++ b/usr.bin/config/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.59 2014/10/10 07:08:26 uebayasi Exp $ */ +/* $NetBSD: main.c,v 1.60 2014/10/10 07:48:50 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -875,6 +875,13 @@ defopt(struct dlhash *ht, const char *fname, struct defoptlist *opts, olddl = olddl->dl_next; olddl->dl_next = dl; } + + /* + * Implicit attribute definition for option. + */ + const char *n; + n = strtolower(dl->dl_name); + refattr(n); } } diff --git a/usr.bin/config/sem.c b/usr.bin/config/sem.c index 1daabecd657b..43599f4fcf47 100644 --- a/usr.bin/config/sem.c +++ b/usr.bin/config/sem.c @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.51 2014/10/10 07:08:26 uebayasi Exp $ */ +/* $NetBSD: sem.c,v 1.52 2014/10/10 07:48:50 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -236,12 +236,13 @@ defattr(const char *name, struct loclist *locs, struct attrlist *deps, } } - a = mkattr(name); - if (a == NULL) { + if (getrefattr(name, &a)) { cfgerror("attribute `%s' already defined", name); loclist_destroy(locs); return (1); } + if (a == NULL) + a = mkattr(name); a->a_deps = deps; expandattr(a, NULL); @@ -674,6 +675,28 @@ refattr(const char *name) (void)mkattr(name); } +int +getrefattr(const char *name, struct attr **ra) +{ + struct attr *a; + + a = ht_lookup(attrtab, name); + if (a == NULL) { + *ra = NULL; + return (0); + } + /* + * Check if the existing attr is only referenced, not really defined. + */ + if (a->a_deps == NULL && + a->a_iattr == 0 && + a->a_devclass == 0) { + *ra = a; + return (0); + } + return (1); +} + /* * Recursively expand an attribute and its dependencies, checking for * cycles, and invoking a callback for each attribute found. diff --git a/usr.bin/config/sem.h b/usr.bin/config/sem.h index ab8aa734de78..eb49d44d9b42 100644 --- a/usr.bin/config/sem.h +++ b/usr.bin/config/sem.h @@ -1,4 +1,4 @@ -/* $NetBSD: sem.h,v 1.12 2014/10/10 06:59:38 uebayasi Exp $ */ +/* $NetBSD: sem.h,v 1.13 2014/10/10 07:48:50 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -58,6 +58,7 @@ struct deva *getdevattach(const char *); struct attr *mkattr(const char *); struct attr *getattr(const char *); void refattr(const char *); +int getrefattr(const char *, struct attr **); void expandattr(struct attr *, void (*)(struct attr *)); void selectattr(struct attr *); void setmajor(struct devbase *, int);