Module Name: src Committed By: uebayasi Date: Fri Oct 10 05:27:29 UTC 2014
Modified Files: src/usr.bin/config: defs.h sem.c Log Message: Refactor attr definition and initialization a little. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/usr.bin/config/defs.h cvs rdiff -u -r1.47 -r1.48 src/usr.bin/config/sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.53 src/usr.bin/config/defs.h:1.54 --- src/usr.bin/config/defs.h:1.53 Thu Oct 9 19:27:04 2014 +++ src/usr.bin/config/defs.h Fri Oct 10 05:27:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.53 2014/10/09 19:27:04 uebayasi Exp $ */ +/* $NetBSD: defs.h,v 1.54 2014/10/10 05:27:28 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -166,15 +166,19 @@ struct defoptlist { */ struct attr { const char *a_name; /* name of this attribute */ + struct attrlist *a_deps; /* we depend on these other attrs */ + int a_expanding; /* to detect cycles in attr graph */ + TAILQ_HEAD(, files) a_files; /* files in this attr */ + + /* "interface attribute" */ int a_iattr; /* true => allows children */ - const char *a_devclass; /* device class described */ struct loclist *a_locs; /* locators required */ int a_loclen; /* length of above list */ struct nvlist *a_devs; /* children */ struct nvlist *a_refs; /* parents */ - struct attrlist *a_deps; /* we depend on these other attrs */ - int a_expanding; /* to detect cycles in attr graph */ - TAILQ_HEAD(, files) a_files; /* files in this attr */ + + /* "device class" */ + const char *a_devclass; /* device class described */ }; /* Index: src/usr.bin/config/sem.c diff -u src/usr.bin/config/sem.c:1.47 src/usr.bin/config/sem.c:1.48 --- src/usr.bin/config/sem.c:1.47 Thu Oct 9 16:08:36 2014 +++ src/usr.bin/config/sem.c Fri Oct 10 05:27:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.47 2014/10/09 16:08:36 uebayasi Exp $ */ +/* $NetBSD: sem.c,v 1.48 2014/10/10 05:27:28 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -240,16 +240,24 @@ defattr(const char *name, struct loclist } a->a_name = name; + a->a_deps = deps; + a->a_expanding = 0; + TAILQ_INIT(&a->a_files); + + /* "interface attribute" initialization */ if (locs != NULL) { a->a_iattr = 1; /* unwrap */ a->a_locs = locs->ll_next; locs->ll_next = NULL; loclist_destroy(locs); - } else { - a->a_iattr = 0; - a->a_locs = NULL; + len = 0; + for (ll = a->a_locs; ll != NULL; ll = ll->ll_next) + len++; + a->a_loclen = len; } + + /* "device class" initialization */ if (devclass) { char classenum[256], *cp; int errored = 0; @@ -266,17 +274,7 @@ defattr(const char *name, struct loclist *cp = toupper((unsigned char)*cp); } a->a_devclass = intern(classenum); - } else - a->a_devclass = NULL; - len = 0; - for (ll = a->a_locs; ll != NULL; ll = ll->ll_next) - len++; - a->a_loclen = len; - a->a_devs = NULL; - a->a_refs = NULL; - a->a_deps = deps; - a->a_expanding = 0; - TAILQ_INIT(&a->a_files); + } /* Expand the attribute to check for cycles in the graph. */ expandattr(a, NULL);