Skip to content

Commit 6c9b54c

Browse files
ianian
ian
authored and
ian
committed
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.
1 parent d082e48 commit 6c9b54c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

usr.sbin/config/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,11 @@ get_word(FILE *fp)
314314
}
315315
cp = line;
316316
*cp++ = ch;
317+
/* Negation operator is a word by itself. */
318+
if (ch == '!') {
319+
*cp = 0;
320+
return (line);
321+
}
317322
while ((ch = getc(fp)) != EOF) {
318323
if (isspace(ch))
319324
break;

usr.sbin/config/mkmakefile.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,9 @@ read_file(char *fname)
386386
if (nreqs == 0)
387387
errout("%s: syntax error describing %s\n",
388388
fname, this);
389-
if (not)
390-
compile += !match;
391-
else
392-
compile += match;
389+
compile += match;
393390
match = 1;
394391
nreqs = 0;
395-
not = 0;
396392
continue;
397393
}
398394
if (eq(wd, "no-obj")) {
@@ -474,19 +470,23 @@ read_file(char *fname)
474470
this, wd);
475471
STAILQ_FOREACH(dp, &dtab, d_next)
476472
if (eq(dp->d_name, wd)) {
477-
dp->d_done |= DEVDONE;
473+
if (not)
474+
match = 0;
475+
else
476+
dp->d_done |= DEVDONE;
478477
goto nextparam;
479478
}
480479
SLIST_FOREACH(op, &opt, op_next)
481-
if (op->op_value == 0 && opteq(op->op_name, wd))
480+
if (op->op_value == 0 && opteq(op->op_name, wd)) {
481+
if (not)
482+
match = 0;
482483
goto nextparam;
483-
match = 0;
484+
}
485+
match &= not;
484486
nextparam:;
487+
not = 0;
485488
}
486-
if (not)
487-
compile += !match;
488-
else
489-
compile += match;
489+
compile += match;
490490
if (compile && tp == NULL) {
491491
if (std == 0 && nreqs == 0)
492492
errout("%s: what is %s optional on?\n",

0 commit comments

Comments
 (0)