Implicitly define attribute for options.

This commit is contained in:
uebayasi 2014-10-10 07:48:50 +00:00
parent 16dc4dca31
commit 6903e7639b
3 changed files with 36 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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);