Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Implicitly define attribute for options.
details: https://anonhg.NetBSD.org/src/rev/771359ba62a7
branches: trunk
changeset: 802954:771359ba62a7
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Fri Oct 10 07:48:50 2014 +0000
description:
Implicitly define attribute for options.
diffstat:
usr.bin/config/main.c | 9 ++++++++-
usr.bin/config/sem.c | 29 ++++++++++++++++++++++++++---
usr.bin/config/sem.h | 3 ++-
3 files changed, 36 insertions(+), 5 deletions(-)
diffs (94 lines):
diff -r 2bb85c5fb6a8 -r 771359ba62a7 usr.bin/config/main.c
--- a/usr.bin/config/main.c Fri Oct 10 07:37:50 2014 +0000
+++ b/usr.bin/config/main.c Fri Oct 10 07:48:50 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.59 2014/10/10 07:08:26 uebayasi Exp $ */
+/* $NetBSD: main.c,v 1.60 2014/10/10 07:48:50 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -875,6 +875,13 @@
olddl = olddl->dl_next;
olddl->dl_next = dl;
}
+
+ /*
+ * Implicit attribute definition for option.
+ */
+ const char *n;
+ n = strtolower(dl->dl_name);
+ refattr(n);
}
}
diff -r 2bb85c5fb6a8 -r 771359ba62a7 usr.bin/config/sem.c
--- a/usr.bin/config/sem.c Fri Oct 10 07:37:50 2014 +0000
+++ b/usr.bin/config/sem.c Fri Oct 10 07:48:50 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.51 2014/10/10 07:08:26 uebayasi Exp $ */
+/* $NetBSD: sem.c,v 1.52 2014/10/10 07:48:50 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -236,12 +236,13 @@
}
}
- a = mkattr(name);
- if (a == NULL) {
+ if (getrefattr(name, &a)) {
cfgerror("attribute `%s' already defined", name);
loclist_destroy(locs);
return (1);
}
+ if (a == NULL)
+ a = mkattr(name);
a->a_deps = deps;
expandattr(a, NULL);
@@ -674,6 +675,28 @@
(void)mkattr(name);
}
+int
+getrefattr(const char *name, struct attr **ra)
+{
+ struct attr *a;
+
+ a = ht_lookup(attrtab, name);
+ if (a == NULL) {
+ *ra = NULL;
+ return (0);
+ }
+ /*
+ * Check if the existing attr is only referenced, not really defined.
+ */
+ if (a->a_deps == NULL &&
+ a->a_iattr == 0 &&
+ a->a_devclass == 0) {
+ *ra = a;
+ return (0);
+ }
+ return (1);
+}
+
/*
* Recursively expand an attribute and its dependencies, checking for
* cycles, and invoking a callback for each attribute found.
diff -r 2bb85c5fb6a8 -r 771359ba62a7 usr.bin/config/sem.h
--- a/usr.bin/config/sem.h Fri Oct 10 07:37:50 2014 +0000
+++ b/usr.bin/config/sem.h Fri Oct 10 07:48:50 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.h,v 1.12 2014/10/10 06:59:38 uebayasi Exp $ */
+/* $NetBSD: sem.h,v 1.13 2014/10/10 07:48:50 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -58,6 +58,7 @@
struct attr *mkattr(const char *);
struct attr *getattr(const char *);
void refattr(const char *);
+int getrefattr(const char *, struct attr **);
void expandattr(struct attr *, void (*)(struct attr *));
void selectattr(struct attr *);
void setmajor(struct devbase *, int);
Home |
Main Index |
Thread Index |
Old Index