Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make If we do .export (all) and have any variables t...
details: https://anonhg.NetBSD.org/src/rev/c27b97f2d914
branches: trunk
changeset: 754119:c27b97f2d914
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Apr 21 04:25:27 2010 +0000
description:
If we do .export (all) and have any variables that involve :sh
we will hit an error (var is recursive) while trying to evaluate that.
Fix, and add a unit test for this.
diffstat:
usr.bin/make/unit-tests/export-all | 14 +++++++++++++-
usr.bin/make/unit-tests/test.exp | 2 ++
usr.bin/make/var.c | 13 ++++++++++---
3 files changed, 25 insertions(+), 4 deletions(-)
diffs (83 lines):
diff -r d1e2408cc0b2 -r c27b97f2d914 usr.bin/make/unit-tests/export-all
--- a/usr.bin/make/unit-tests/export-all Wed Apr 21 02:59:29 2010 +0000
+++ b/usr.bin/make/unit-tests/export-all Wed Apr 21 04:25:27 2010 +0000
@@ -1,8 +1,20 @@
-# $Id: export-all,v 1.1 2007/10/05 15:27:46 sjg Exp $
+# $Id: export-all,v 1.2 2010/04/21 04:25:28 sjg Exp $
UT_OK=good
UT_F=fine
+# the old way to do :tA
+M_tAbad = C,.*,cd & \&\& 'pwd',:sh
+# the new
+M_tA = tA
+
+here := ${.PARSEDIR}
+
+# this will cause trouble (recursing if we let it)
+UT_BADDIR = ${${here}/../${here:T}:L:${M_tAbad}:T}
+# this will be ok
+UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T}
+
.export
.include "export"
diff -r d1e2408cc0b2 -r c27b97f2d914 usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp Wed Apr 21 02:59:29 2010 +0000
+++ b/usr.bin/make/unit-tests/test.exp Wed Apr 21 04:25:27 2010 +0000
@@ -33,12 +33,14 @@
UT_TEST=export
UT_ZOO=hoopie
UT_ALL=even this gets exported
+UT_BADDIR=unit-tests
UT_DOLLAR=This is $UT_FU
UT_F=fine
UT_FOO=foobar is fubar
UT_FU=fubar
UT_NO=all
UT_OK=good
+UT_OKDIR=unit-tests
UT_TEST=export-all
UT_ZOO=hoopie
At first, I am
diff -r d1e2408cc0b2 -r c27b97f2d914 usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Apr 21 02:59:29 2010 +0000
+++ b/usr.bin/make/var.c Wed Apr 21 04:25:27 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $ */
+/* $NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -591,6 +591,13 @@
v->flags |= (VAR_EXPORTED|VAR_REEXPORT);
return 1;
}
+ if (v->flags & VAR_IN_USE) {
+ /*
+ * We recursed while exporting in a child.
+ * This isn't going to end well, just skip it.
+ */
+ return 0;
+ }
n = snprintf(tmp, sizeof(tmp), "${%s}", name);
if (n < (int)sizeof(tmp)) {
val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0);
Home |
Main Index |
Thread Index |
Old Index