Module Name: src Committed By: sjg Date: Wed Dec 2 00:28:24 UTC 2015
Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond2.mk Log Message: Fix evaluation of defined(FOO) and ${FOO} > 0 add a unit-test to catch it. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/usr.bin/make/cond.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond2.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.70 src/usr.bin/make/cond.c:1.71 --- src/usr.bin/make/cond.c:1.70 Mon Nov 30 23:15:43 2015 +++ src/usr.bin/make/cond.c Wed Dec 2 00:28:24 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.70 2015/11/30 23:15:43 sjg Exp $ */ +/* $NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.70 2015/11/30 23:15:43 sjg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.70 2015/11/30 23:15:43 sjg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -489,11 +489,11 @@ CondCvtArg(char *str, double *value) unsigned long l_val; double d_val; + errno = 0; if (!*str) { - errno = EINVAL; - return FALSE; + *value = (double)0; + return TRUE; } - errno = 0; l_val = strtoul(str, &eptr, str[1] == 'x' ? 16 : 10); ech = *eptr; if (ech == 0 && errno != ERANGE) { Index: src/usr.bin/make/unit-tests/cond2.mk diff -u src/usr.bin/make/unit-tests/cond2.mk:1.1 src/usr.bin/make/unit-tests/cond2.mk:1.2 --- src/usr.bin/make/unit-tests/cond2.mk:1.1 Tue May 5 21:51:09 2015 +++ src/usr.bin/make/unit-tests/cond2.mk Wed Dec 2 00:28:24 2015 @@ -1,4 +1,4 @@ -# $Id: cond2.mk,v 1.1 2015/05/05 21:51:09 sjg Exp $ +# $Id: cond2.mk,v 1.2 2015/12/02 00:28:24 sjg Exp $ TEST_UNAME_S= NetBSD @@ -21,5 +21,9 @@ Y!= echo TEST_NOT_SET is empty or not de Y= oops .endif +.if defined(.NDEF) && ${.NDEF} > 0 +Z= yes +.endif + all: @echo $@