summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-12-27 03:19:04 +0000
committerian <ian@FreeBSD.org>2014-12-27 03:19:04 +0000
commit6c9b54c869088edab9c4bed15049c9e3aa3f99ae (patch)
tree495574a24c55afa738544ccc6490c75e428103b1 /usr.sbin/config
parentd082e488cb5d0ab8f76c2694943f4b1688869f8b (diff)
downloadFreeBSD-src-6c9b54c869088edab9c4bed15049c9e3aa3f99ae.zip
FreeBSD-src-6c9b54c869088edab9c4bed15049c9e3aa3f99ae.tar.gz
MFC r274924, r274936:
Consider the negation operator (!) to be a word even if it is not followed by whitespace. This allows "optional !foo" which is what most programmers are naturally going to tend to do as opposed to "optional ! foo". Fix the negation (!) operator so that it binds only to the word that immediately follows it.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/main.c5
-rw-r--r--usr.sbin/config/mkmakefile.c24
2 files changed, 17 insertions, 12 deletions
diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c
index 86ecfa6..ff18d3c 100644
--- a/usr.sbin/config/main.c
+++ b/usr.sbin/config/main.c
@@ -314,6 +314,11 @@ begin:
}
cp = line;
*cp++ = ch;
+ /* Negation operator is a word by itself. */
+ if (ch == '!') {
+ *cp = 0;
+ return (line);
+ }
while ((ch = getc(fp)) != EOF) {
if (isspace(ch))
break;
diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c
index cae2efc..0f873c4 100644
--- a/usr.sbin/config/mkmakefile.c
+++ b/usr.sbin/config/mkmakefile.c
@@ -386,13 +386,9 @@ next:
if (nreqs == 0)
errout("%s: syntax error describing %s\n",
fname, this);
- if (not)
- compile += !match;
- else
- compile += match;
+ compile += match;
match = 1;
nreqs = 0;
- not = 0;
continue;
}
if (eq(wd, "no-obj")) {
@@ -474,19 +470,23 @@ next:
this, wd);
STAILQ_FOREACH(dp, &dtab, d_next)
if (eq(dp->d_name, wd)) {
- dp->d_done |= DEVDONE;
+ if (not)
+ match = 0;
+ else
+ dp->d_done |= DEVDONE;
goto nextparam;
}
SLIST_FOREACH(op, &opt, op_next)
- if (op->op_value == 0 && opteq(op->op_name, wd))
+ if (op->op_value == 0 && opteq(op->op_name, wd)) {
+ if (not)
+ match = 0;
goto nextparam;
- match = 0;
+ }
+ match &= not;
nextparam:;
+ not = 0;
}
- if (not)
- compile += !match;
- else
- compile += match;
+ compile += match;
if (compile && tp == NULL) {
if (std == 0 && nreqs == 0)
errout("%s: what is %s optional on?\n",
OpenPOWER on IntegriCloud