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)".
This commit is contained in:
uebayasi 2014-10-09 15:25:26 +00:00
parent fa3d850434
commit adf6a4556b
3 changed files with 22 additions and 9 deletions

View File

@ -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 stack */
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 */

View File

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

View File

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