summaryrefslogtreecommitdiffstats
path: root/contrib/bmake/main.c
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2014-07-08 22:27:50 +0000
committersjg <sjg@FreeBSD.org>2014-07-08 22:27:50 +0000
commit8a8bdedf3516cfc13d63e3d424375679d4fe2a5c (patch)
tree4c5229352cca8f44795e8423807a3ec5d9f482ed /contrib/bmake/main.c
parent26d6f0488543168ab53e731b626612a7d1028552 (diff)
downloadFreeBSD-src-8a8bdedf3516cfc13d63e3d424375679d4fe2a5c.zip
FreeBSD-src-8a8bdedf3516cfc13d63e3d424375679d4fe2a5c.tar.gz
Update to bmake-20140620
Main change is detection of malformed variable references. Reviewed by: obrien
Diffstat (limited to 'contrib/bmake/main.c')
-rw-r--r--contrib/bmake/main.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 78fbf41..f86184c 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $ */
+/* $NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.225 2013/09/14 15:09:34 matt Exp $");
+__RCSID("$NetBSD: main.c,v 1.226 2014/02/07 17:23:35 pooka Exp $");
#endif
#endif /* not lint */
#endif
@@ -1102,11 +1102,12 @@ main(int argc, char **argv)
*/
#ifndef NO_PWD_OVERRIDE
if (!ignorePWD) {
- char *pwd;
+ char *pwd, *ptmp1 = NULL, *ptmp2 = NULL;
if ((pwd = getenv("PWD")) != NULL &&
- getenv("MAKEOBJDIRPREFIX") == NULL) {
- const char *makeobjdir = getenv("MAKEOBJDIR");
+ Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &ptmp1) == NULL) {
+ const char *makeobjdir = Var_Value("MAKEOBJDIR",
+ VAR_CMD, &ptmp2);
if (makeobjdir == NULL || !strchr(makeobjdir, '$')) {
if (stat(pwd, &sb) == 0 &&
@@ -1115,6 +1116,8 @@ main(int argc, char **argv)
(void)strncpy(curdir, pwd, MAXPATHLEN);
}
}
+ free(ptmp1);
+ free(ptmp2);
}
#endif
Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
@@ -1131,11 +1134,13 @@ main(int argc, char **argv)
Dir_Init(curdir);
(void)Main_SetObjdir(curdir);
- if ((path = getenv("MAKEOBJDIRPREFIX")) != NULL) {
+ if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) {
(void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir);
(void)Main_SetObjdir(mdpath);
- } else if ((path = getenv("MAKEOBJDIR")) != NULL) {
+ free(p1);
+ } else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) {
(void)Main_SetObjdir(path);
+ free(p1);
} else {
(void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine);
if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) {
OpenPOWER on IntegriCloud