Module Name: src Committed By: uebayasi Date: Thu Oct 9 10:29:36 UTC 2014
Modified Files: src/usr.bin/config: defs.h files.c sem.c Log Message: If a file is marked by an atom expression, like "file a.c foo", and if the specified expression is an attribute, mark the file as belonging to the attribute. At this moment this information is not used for any purpose, but can be traced by config -ddd. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/config/defs.h cvs rdiff -u -r1.13 -r1.14 src/usr.bin/config/files.c cvs rdiff -u -r1.44 -r1.45 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.48 src/usr.bin/config/defs.h:1.49 --- src/usr.bin/config/defs.h:1.48 Thu Oct 9 07:43:55 2014 +++ src/usr.bin/config/defs.h Thu Oct 9 10:29:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.48 2014/10/09 07:43:55 martin Exp $ */ +/* $NetBSD: defs.h,v 1.49 2014/10/09 10:29:36 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -174,6 +174,7 @@ struct attr { 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 */ }; /* @@ -319,6 +320,8 @@ struct filetype char fit_lastc; /* last char from path */ const char *fit_path; /* full file path */ const char *fit_prefix; /* any file prefix */ + struct attr *fit_attr; /* owner attr */ + TAILQ_ENTRY(files) fit_anext; /* next file in attr */ }; /* Anything less than 0x10 is sub-type specific */ #define FIT_NOPROLOGUE 0x10 /* Don't prepend $S/ */ @@ -350,6 +353,8 @@ struct files { #define fi_lastc fi_fit.fit_lastc #define fi_path fi_fit.fit_path #define fi_prefix fi_fit.fit_prefix +#define fi_attr fi_fit.fit_attr +#define fi_anext fi_fit.fit_anext /* flags */ #define FI_SEL 0x01 /* selected */ Index: src/usr.bin/config/files.c diff -u src/usr.bin/config/files.c:1.13 src/usr.bin/config/files.c:1.14 --- src/usr.bin/config/files.c:1.13 Thu Oct 9 06:49:53 2014 +++ src/usr.bin/config/files.c Thu Oct 9 10:29:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: files.c,v 1.13 2014/10/09 06:49:53 uebayasi Exp $ */ +/* $NetBSD: files.c,v 1.14 2014/10/09 10:29:36 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -65,6 +65,7 @@ static struct hashtab *pathtab; /* full static struct files **unchecked; +static void addfiletoattr(const char *, struct files *); static int checkaux(const char *, void *); static int fixcount(const char *, void *); static int fixfsel(const char *, void *); @@ -157,6 +158,7 @@ addfile(const char *path, struct condexp fi->fi_optx = optx; fi->fi_optf = NULL; fi->fi_mkrule = rule; + fi->fi_attr = NULL; TAILQ_INSERT_TAIL(&allfiles, fi, fi_next); return; bad: @@ -195,6 +197,18 @@ addobject(const char *path, struct conde return; } +static void +addfiletoattr(const char *name, struct files *fi) +{ + struct attr *a; + + a = ht_lookup(attrtab, name); + if (a != NULL) { + TAILQ_INSERT_TAIL(&a->a_files, fi, fi_anext); + fi->fi_attr = a; + } +} + /* * We have finished reading some "files" file, either ../../conf/files * or ./files.$machine. Make sure that everything that is flagged as @@ -260,6 +274,9 @@ fixfiles(void) /* include it */ ; } else if (fi->fi_optx != NULL) { + if (fi->fi_optx->cx_type == CX_ATOM) { + addfiletoattr(fi->fi_optx->cx_u.atom, fi); + } flathead = NULL; flatp = &flathead; sel = expr_eval(fi->fi_optx, @@ -298,6 +315,9 @@ fixfiles(void) } fi->fi_flags |= FI_SEL; CFGDBG(3, "file slected `%s'", fi->fi_path); + if (fi->fi_attr != NULL) + CFGDBG(3, "file `%s' belongs to attr `%s'", fi->fi_path, + fi->fi_attr->a_name); } return (err); } Index: src/usr.bin/config/sem.c diff -u src/usr.bin/config/sem.c:1.44 src/usr.bin/config/sem.c:1.45 --- src/usr.bin/config/sem.c:1.44 Thu Oct 9 06:49:53 2014 +++ src/usr.bin/config/sem.c Thu Oct 9 10:29:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.44 2014/10/09 06:49:53 uebayasi Exp $ */ +/* $NetBSD: sem.c,v 1.45 2014/10/09 10:29:36 uebayasi Exp $ */ /* * Copyright (c) 1992, 1993 @@ -269,6 +269,7 @@ defattr(const char *name, struct loclist 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);