aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/make/cond.c
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1995-01-23 21:03:17 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1995-01-23 21:03:17 +0000
commit9f574f9a908a903efc4a514a61bde333d960573c (patch)
tree4fe60a8bd60f90f8461d826b8a6c0cd471c798d3 /usr.bin/make/cond.c
parent8d81c1222778f5f4e7f1640dda9ac9c1fe47fcdd (diff)
downloadsrc-9f574f9a908a903efc4a514a61bde333d960573c.tar.gz
src-9f574f9a908a903efc4a514a61bde333d960573c.zip
Bring in a number of changes from NetBSD's make, fixing quite a few
problems in the process: 1. Quoting should work properly now. In particular, Chet's reported bash make problem has gone away. 2. A lot of memory that just wasn't being free'd after use is now freed. This should cause make to take up a LOT less memory when dealing with archive targets. 3. Give proper credit to Adam de Boor in a number of files. Obtained from: NetBSD (and Adam de Boor)
Notes
Notes: svn path=/head/; revision=5814
Diffstat (limited to 'usr.bin/make/cond.c')
-rw-r--r--usr.bin/make/cond.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index cec9e1e1379e..c99010d8d6aa 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1988, 1989, 1990, 1993
- * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
* Copyright (c) 1989 by Berkeley Softworks
* All rights reserved.
*
@@ -96,7 +96,7 @@ typedef enum {
*/
static int CondGetArg __P((char **, char **, char *, Boolean));
static Boolean CondDoDefined __P((int, char *));
-static int CondStrMatch __P((char *, char *));
+static int CondStrMatch __P((ClientData, ClientData));
static Boolean CondDoMake __P((int, char *));
static Boolean CondDoExists __P((int, char *));
static Boolean CondDoTarget __P((int, char *));
@@ -277,14 +277,17 @@ CondDoDefined (argLen, arg)
char *arg;
{
char savec = arg[argLen];
+ char *p1;
Boolean result;
arg[argLen] = '\0';
- if (Var_Value (arg, VAR_CMD) != (char *)NULL) {
+ if (Var_Value (arg, VAR_CMD, &p1) != (char *)NULL) {
result = TRUE;
} else {
result = FALSE;
}
+ if (p1)
+ free(p1);
arg[argLen] = savec;
return (result);
}
@@ -305,10 +308,10 @@ CondDoDefined (argLen, arg)
*/
static int
CondStrMatch(string, pattern)
- char *string;
- char *pattern;
+ ClientData string;
+ ClientData pattern;
{
- return(!Str_Match(string,pattern));
+ return(!Str_Match((char *) string,(char *) pattern));
}
/*-
@@ -532,7 +535,8 @@ CondToken(doEval)
}
condExpr += varSpecLen;
- if (!isspace(*condExpr) && strchr("!=><", *condExpr) == NULL) {
+ if (!isspace((unsigned char) *condExpr) &&
+ strchr("!=><", *condExpr) == NULL) {
Buffer buf;
char *cp;
@@ -544,7 +548,8 @@ CondToken(doEval)
if (doFree)
free(lhs);
- for (;*condExpr && !isspace(*condExpr); condExpr++)
+ for (;*condExpr && !isspace((unsigned char) *condExpr);
+ condExpr++)
Buf_AddByte(buf, (Byte)*condExpr);
Buf_AddByte(buf, (Byte)'\0');
@@ -557,7 +562,7 @@ CondToken(doEval)
/*
* Skip whitespace to get to the operator
*/
- while (isspace(*condExpr))
+ while (isspace((unsigned char) *condExpr))
condExpr++;
/*
@@ -583,7 +588,7 @@ CondToken(doEval)
goto do_compare;
}
- while (isspace(*condExpr)) {
+ while (isspace((unsigned char) *condExpr)) {
condExpr++;
}
if (*condExpr == '\0') {
@@ -703,7 +708,8 @@ do_string_compare:
/*
* Skip over the right-hand side
*/
- while(!isspace(*condExpr) && (*condExpr != '\0')) {
+ while(!isspace((unsigned char) *condExpr) &&
+ (*condExpr != '\0')) {
condExpr++;
}
}
@@ -810,9 +816,8 @@ error:
for (arglen = 0;
condExpr[arglen] != '(' && condExpr[arglen] != '\0';
arglen += 1)
- {
- /* void */ ;
- }
+ continue;
+
if (condExpr[arglen] != '\0') {
val = Var_Parse(&condExpr[arglen - 1], VAR_CMD,
doEval, &length, &doFree);
@@ -824,7 +829,7 @@ error:
* spaces... 4/15/92, christos
*/
char *p;
- for (p = val; *p && isspace(*p); p++)
+ for (p = val; *p && isspace((unsigned char)*p); p++)
continue;
t = (*p == '\0') ? True : False;
}