Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Fix evaluation of defined(FOO) and ${FOO} > 0



details:   https://anonhg.NetBSD.org/src/rev/338070d77341
branches:  trunk
changeset: 341994:338070d77341
user:      sjg <sjg%NetBSD.org@localhost>
date:      Wed Dec 02 00:28:24 2015 +0000

description:
Fix evaluation of defined(FOO) and ${FOO} > 0
add a unit-test to catch it.

diffstat:

 usr.bin/make/cond.c              |  12 ++++++------
 usr.bin/make/unit-tests/cond2.mk |   6 +++++-
 2 files changed, 11 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r 9ab492c7e0d6 -r 338070d77341 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Wed Dec 02 00:07:35 2015 +0000
+++ b/usr.bin/make/cond.c       Wed Dec 02 00:28:24 2015 +0000
@@ -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 @@
     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) {
diff -r 9ab492c7e0d6 -r 338070d77341 usr.bin/make/unit-tests/cond2.mk
--- a/usr.bin/make/unit-tests/cond2.mk  Wed Dec 02 00:07:35 2015 +0000
+++ b/usr.bin/make/unit-tests/cond2.mk  Wed Dec 02 00:28:24 2015 +0000
@@ -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= oops
 .endif
 
+.if defined(.NDEF) && ${.NDEF} > 0
+Z= yes
+.endif
+
 all:
        @echo $@



Home | Main Index | Thread Index | Old Index