From 690731a46540e4647b3613204e5fc3d4cdf83b65 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 27 Dec 2014 03:19:04 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.freebsd.org/base/stable/10@276280 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/config/main.c | 5 +++++ usr.sbin/config/mkmakefile.c | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 86ecfa6cd..ff18d3c86 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -314,6 +314,11 @@ get_word(FILE *fp) } 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 cae2efc09..0f873c445 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -386,13 +386,9 @@ read_file(char *fname) 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 @@ read_file(char *fname) 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", -- 2.45.0