Module Name: src
Committed By: rillig
Date: Wed Nov 11 07:13:42 UTC 2020
Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: directive-ifmake.exp directive-ifmake.mk
Log Message:
make(1): add test to cover the If_Eval call in EvalNotEmpty
To generate a diff of this commit:
cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/cond.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-ifmake.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-ifmake.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.203 src/usr.bin/make/cond.c:1.204
--- src/usr.bin/make/cond.c:1.203 Tue Nov 10 22:25:38 2020
+++ src/usr.bin/make/cond.c Wed Nov 11 07:13:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.203 2020/11/10 22:25:38 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.204 2020/11/11 07:13:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.203 2020/11/10 22:25:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.204 2020/11/11 07:13:42 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -536,11 +536,11 @@ EvalNotEmpty(CondParser *par, const char
if (TryParseNumber(value, &num))
return num != 0.0;
- /* For .if ${...}, check for non-empty string (defProc is ifdef). */
+ /* For .if ${...}, check for non-empty string. */
if (par->if_info->form[0] == '\0')
return value[0] != '\0';
- /* Otherwise action default test ... */
+ /* For the other variants of .ifxxx ${...}, use its default function. */
return If_Eval(par->if_info, value, strlen(value));
}
Index: src/usr.bin/make/unit-tests/directive-ifmake.exp
diff -u src/usr.bin/make/unit-tests/directive-ifmake.exp:1.3 src/usr.bin/make/unit-tests/directive-ifmake.exp:1.4
--- src/usr.bin/make/unit-tests/directive-ifmake.exp:1.3 Sun Aug 30 14:25:45 2020
+++ src/usr.bin/make/unit-tests/directive-ifmake.exp Wed Nov 11 07:13:42 2020
@@ -1,9 +1,10 @@
-make: "directive-ifmake.mk" line 8: ok: positive condition works
-make: "directive-ifmake.mk" line 19: ok: negation works
-make: "directive-ifmake.mk" line 25: ok: double negation works
-make: "directive-ifmake.mk" line 32: ok: both mentioned
-make: "directive-ifmake.mk" line 39: ok: only those mentioned
-make: "directive-ifmake.mk" line 49: Targets can even be added at parse time.
+make: "directive-ifmake.mk" line 10: ok: positive condition works
+make: "directive-ifmake.mk" line 21: ok: negation works
+make: "directive-ifmake.mk" line 27: ok: double negation works
+make: "directive-ifmake.mk" line 34: ok: both mentioned
+make: "directive-ifmake.mk" line 41: ok: only those mentioned
+make: "directive-ifmake.mk" line 51: Targets can even be added at parse time.
+make: "directive-ifmake.mk" line 69: ok
: first
: second
: late-target
Index: src/usr.bin/make/unit-tests/directive-ifmake.mk
diff -u src/usr.bin/make/unit-tests/directive-ifmake.mk:1.6 src/usr.bin/make/unit-tests/directive-ifmake.mk:1.7
--- src/usr.bin/make/unit-tests/directive-ifmake.mk:1.6 Sun Nov 8 22:45:51 2020
+++ src/usr.bin/make/unit-tests/directive-ifmake.mk Wed Nov 11 07:13:42 2020
@@ -1,8 +1,10 @@
-# $NetBSD: directive-ifmake.mk,v 1.6 2020/11/08 22:45:51 rillig Exp $
+# $NetBSD: directive-ifmake.mk,v 1.7 2020/11/11 07:13:42 rillig Exp $
#
# Tests for the .ifmake directive, which provides a shortcut for asking
# whether a certain target is requested to be made from the command line.
+# The targets 'first' and 'second' are passed in on the command line.
+
# This is the most basic form.
.ifmake first
. info ok: positive condition works
@@ -61,5 +63,14 @@
. error
.endif
+# A condition that consists of a variable expression only (without any
+# comparison operator) can be used with .if and the other .ifxxx directives.
+.ifmake ${:Ufirst}
+. info ok
+.else
+. error
+.endif
+
+
first second unmentioned late-target:
: $@