summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-11-24 11:04:56 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-11-24 11:04:56 +0000
commit0cd32023b11d1e6c79b2adc3ee67ef2546928426 (patch)
treebc5136a623b6f5578a2f60c22252b0ad35231457 /usr.bin
parent3c6f968cfaa21a5541afbf00dde6632b3781103d (diff)
be more strict in recognizing .if keyword() constructs, don't ignore
unknown keywords. uniform white space handling. okay beck@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/cond.c48
1 files changed, 25 insertions, 23 deletions
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index cfd72b2fae1..2cd5004291e 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cond.c,v 1.47 2012/10/18 17:54:43 espie Exp $ */
+/* $OpenBSD: cond.c,v 1.48 2012/11/24 11:04:55 espie Exp $ */
/* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */
/*
@@ -198,40 +198,42 @@ CondGetArg(const char **linePtr, struct Name *arg, const char *func,
const char *cp;
cp = *linePtr;
+ /* Set things up to return faster in case of problem */
+ arg->s = cp;
+ arg->e = cp;
+ arg->tofree = false;
+
+ /* make and defined are not really keywords, so if CondGetArg doesn't
+ * work...
+ */
if (parens) {
- while (*cp != '(' && *cp != '\0')
+ while (isspace(*cp))
cp++;
if (*cp == '(')
cp++;
+ else
+ return false;
}
- if (*cp == '\0') {
- /* No arguments whatsoever. Because 'make' and 'defined' aren't
- * really "reserved words", we don't print a message. I think
- * this is better than hitting the user with a warning message
- * every time s/he uses the word 'make' or 'defined' at the
- * beginning of a symbol... */
- arg->s = cp;
- arg->e = cp;
- arg->tofree = false;
+ if (*cp == '\0')
return false;
- }
- while (*cp == ' ' || *cp == '\t')
+ while (isspace(*cp))
cp++;
-
cp = VarName_Get(cp, arg, NULL, true, find_cond);
- while (*cp == ' ' || *cp == '\t')
- cp++;
- if (parens && *cp != ')') {
- Parse_Error(PARSE_WARNING,
- "Missing closing parenthesis for %s()", func);
- return false;
- } else if (parens)
- /* Advance pointer past close parenthesis. */
+ while (isspace(*cp))
cp++;
+ if (parens) {
+ if (*cp == ')')
+ cp++;
+ else {
+ Parse_Error(PARSE_WARNING,
+ "Missing closing parenthesis for %s()", func);
+ return false;
+ }
+ }
*linePtr = cp;
return true;
@@ -747,7 +749,7 @@ CondToken(bool doEval)
return t;
}
- while (*condExpr == ' ' || *condExpr == '\t')
+ while (isspace(*condExpr))
condExpr++;
switch (*condExpr) {
case '(':