Module Name:    src
Committed By:   uebayasi
Date:           Thu Oct  9 15:25:26 UTC 2014

Modified Files:
        src/usr.bin/config: defs.h files.c sem.c

Log Message:
Define an implicit attribute "netbsd" internally to collect files that don't
belong to any specific attribute.

Eventually, all operations doing "foreach (files)" can be rewritten as "foreach
(attributes) foreach (files)".


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/config/defs.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/config/files.c
cvs rdiff -u -r1.45 -r1.46 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.49 src/usr.bin/config/defs.h:1.50
--- src/usr.bin/config/defs.h:1.49	Thu Oct  9 10:29:36 2014
+++ src/usr.bin/config/defs.h	Thu Oct  9 15:25:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.49 2014/10/09 10:29:36 uebayasi Exp $	*/
+/*	$NetBSD: defs.h,v 1.50 2014/10/09 15:25:26 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -507,6 +507,7 @@ SLIST_HEAD(, prefix)	prefixes,	/* prefix
 			allprefixes;	/* all prefixes used (after popped) */
 SLIST_HEAD(, prefix)	curdirs;	/* curdir stack */
 
+extern struct attr allattr;
 struct	devi **packed;		/* arrayified table for packed devi's */
 size_t	npacked;		/* size of packed table, <= ndevi */
 

Index: src/usr.bin/config/files.c
diff -u src/usr.bin/config/files.c:1.14 src/usr.bin/config/files.c:1.15
--- src/usr.bin/config/files.c:1.14	Thu Oct  9 10:29:36 2014
+++ src/usr.bin/config/files.c	Thu Oct  9 15:25:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: files.c,v 1.14 2014/10/09 10:29:36 uebayasi Exp $	*/
+/*	$NetBSD: files.c,v 1.15 2014/10/09 15:25:26 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -203,9 +203,11 @@ addfiletoattr(const char *name, struct f
 	struct attr *a;
 
 	a = ht_lookup(attrtab, name);
-	if (a != NULL) {
-		TAILQ_INSERT_TAIL(&a->a_files, fi, fi_anext);
+	if (a == NULL) {
+		CFGDBG(1, "attr `%s' not found", name);
+	} else {
 		fi->fi_attr = a;
+		TAILQ_INSERT_TAIL(&a->a_files, fi, fi_anext);
 	}
 }
 
@@ -314,10 +316,14 @@ 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);
+		CFGDBG(3, "file selected `%s'", fi->fi_path);
+
+		/* Add other files to the default "netbsd" attribute. */
+		if (fi->fi_attr == NULL) {
+			addfiletoattr(allattr.a_name, fi);
+		}
+		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.45 src/usr.bin/config/sem.c:1.46
--- src/usr.bin/config/sem.c:1.45	Thu Oct  9 10:29:36 2014
+++ src/usr.bin/config/sem.c	Thu Oct  9 15:25:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.45 2014/10/09 10:29:36 uebayasi Exp $	*/
+/*	$NetBSD: sem.c,v 1.46 2014/10/09 15:25:26 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -65,6 +65,7 @@ const char *s_none;
 
 static struct hashtab *cfhashtab;	/* for config lookup */
 struct hashtab *devitab;		/* etc */
+struct attr allattr;
 
 static struct attr errattr;
 static struct devbase errdev;
@@ -95,6 +96,11 @@ initsem(void)
 {
 
 	attrtab = ht_new();
+
+	allattr.a_name = "netbsd";
+	TAILQ_INIT(&allattr.a_files);
+	(void)ht_insert(attrtab, allattr.a_name, &allattr);
+
 	errattr.a_name = "<internal>";
 
 	TAILQ_INIT(&allbases);

Reply via email to