diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile index 6f995908e82c..4c1a52b48602 100644 --- a/usr.bin/make/unit-tests/Makefile +++ b/usr.bin/make/unit-tests/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.30 2010/12/10 00:37:23 sjg Exp $ +# $NetBSD: Makefile,v 1.31 2011/03/06 00:02:14 sjg Exp $ # # Unit tests for make(1) # The main targets are: @@ -27,6 +27,7 @@ SUBFILES= \ doterror \ dotwait \ forsubst \ + misc \ moderrs \ modmatch \ modmisc \ @@ -35,6 +36,7 @@ SUBFILES= \ modword \ posix \ qequals \ + sysv \ ternary \ unexport \ unexport-env \ diff --git a/usr.bin/make/unit-tests/cond1 b/usr.bin/make/unit-tests/cond1 index cf51b5c526f0..7d3df40dc31d 100644 --- a/usr.bin/make/unit-tests/cond1 +++ b/usr.bin/make/unit-tests/cond1 @@ -1,4 +1,4 @@ -# $Id: cond1,v 1.4 2008/10/29 15:37:08 sjg Exp $ +# $Id: cond1,v 1.5 2011/03/06 00:02:14 sjg Exp $ # hard code these! TEST_UNAME_S= NetBSD @@ -95,6 +95,11 @@ C=clever C=dim .endif +.if defined(nosuch) && ${nosuch:Mx} != "" +# this should not happen +.info nosuch is x +.endif + all: @echo "$n is $X prime" @echo "A='$A' B='$B' C='$C' o='$o,${o2}'" diff --git a/usr.bin/make/unit-tests/misc b/usr.bin/make/unit-tests/misc new file mode 100644 index 000000000000..bb54df488f1f --- /dev/null +++ b/usr.bin/make/unit-tests/misc @@ -0,0 +1,16 @@ +# $Id: misc,v 1.1 2011/03/06 00:02:14 sjg Exp $ + +.if !exists(${.CURDIR}/) +.warning ${.CURDIR}/ doesn't exist ? +.endif + +.if !exists(${.CURDIR}/.) +.warning ${.CURDIR}/. doesn't exist ? +.endif + +.if !exists(${.CURDIR}/..) +.warning ${.CURDIR}/.. doesn't exist ? +.endif + +all: + @: all is well diff --git a/usr.bin/make/unit-tests/sysv b/usr.bin/make/unit-tests/sysv new file mode 100644 index 000000000000..ab8ce0ba11f6 --- /dev/null +++ b/usr.bin/make/unit-tests/sysv @@ -0,0 +1,13 @@ +# $Id: sysv,v 1.1 2011/03/06 00:02:14 sjg Exp $ + +FOO ?= +FOOBAR = $(FOO:=bar) + +_this := ${.PARSEDIR}/${.PARSEFILE} + +# we expect nothing when FOO is empty +all: + @echo FOOBAR = $(FOOBAR) +.if empty(FOO) + @FOO="foo fu" ${.MAKE} -f ${_this} +.endif diff --git a/usr.bin/make/unit-tests/test.exp b/usr.bin/make/unit-tests/test.exp index 347bb9f2409b..2c54d1f051ec 100644 --- a/usr.bin/make/unit-tests/test.exp +++ b/usr.bin/make/unit-tests/test.exp @@ -306,6 +306,8 @@ Now we expect an error... *** Error code 1 (continuing) `all' not remade because of errors. V.i386 ?= OK +FOOBAR = +FOOBAR = foobar fubar The answer is unknown The answer is unknown The answer is empty diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index b78219ab56f9..61a433dbbe32 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $ */ +/* $NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $"); +__RCSID("$NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -3346,9 +3346,13 @@ ApplyModifiers(char *nstr, const char *tstr, */ termc = *--cp; delim = '\0'; - newStr = VarModify(ctxt, &parsestate, nstr, - VarSYSVMatch, - &pattern); + if (pattern.leftLen == 0 && *nstr == '\0') { + newStr = nstr; /* special case */ + } else { + newStr = VarModify(ctxt, &parsestate, nstr, + VarSYSVMatch, + &pattern); + } free(UNCONST(pattern.lhs)); free(UNCONST(pattern.rhs)); } else @@ -3746,7 +3750,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, nstr = bmake_strndup(start, *lengthPtr); *freePtr = nstr; } else { - nstr = var_Error; + nstr = errnum ? var_Error : varNoError; } } if (nstr != Buf_GetAll(&v->val, NULL))