Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Define an implicit attribute "netbsd" interna...



details:   https://anonhg.NetBSD.org/src/rev/6afe3788f271
branches:  trunk
changeset: 802931:6afe3788f271
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Thu Oct 09 15:25:26 2014 +0000

description:
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)".

diffstat:

 usr.bin/config/defs.h  |   3 ++-
 usr.bin/config/files.c |  20 +++++++++++++-------
 usr.bin/config/sem.c   |   8 +++++++-
 3 files changed, 22 insertions(+), 9 deletions(-)

diffs (88 lines):

diff -r 3575f23230f4 -r 6afe3788f271 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Thu Oct 09 10:29:36 2014 +0000
+++ b/usr.bin/config/defs.h     Thu Oct 09 15:25:26 2014 +0000
@@ -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 @@
                        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 */
 
diff -r 3575f23230f4 -r 6afe3788f271 usr.bin/config/files.c
--- a/usr.bin/config/files.c    Thu Oct 09 10:29:36 2014 +0000
+++ b/usr.bin/config/files.c    Thu Oct 09 15:25:26 2014 +0000
@@ -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 @@
        struct attr *a;
 
        a = ht_lookup(attrtab, name);
-       if (a != NULL) {
+       if (a == NULL) {
+               CFGDBG(1, "attr `%s' not found", name);
+       } else {
+               fi->fi_attr = a;
                TAILQ_INSERT_TAIL(&a->a_files, fi, fi_anext);
-               fi->fi_attr = a;
        }
 }
 
@@ -314,10 +316,14 @@
                        }
                }
                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);
 }
diff -r 3575f23230f4 -r 6afe3788f271 usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Thu Oct 09 10:29:36 2014 +0000
+++ b/usr.bin/config/sem.c      Thu Oct 09 15:25:26 2014 +0000
@@ -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 @@
 
 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 @@
 {
 
        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);



Home | Main Index | Thread Index | Old Index