Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: in irrelevant function calls in condition...



details:   https://anonhg.NetBSD.org/src/rev/fc2ba45f68cd
branches:  trunk
changeset: 1029277:fc2ba45f68cd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 29 08:23:40 2021 +0000

description:
make: in irrelevant function calls in conditions, return false

When a condition contains an irrelevant function call, it doesn't matter
whether the function call evaluates to true or to false, it will be
discarded anyway by either CondParser_And or CondParser_Or.

Returning false instead of true makes the code simpler, plus it is more
common to return false for irrelevant results.

No functional change.

diffstat:

 usr.bin/make/cond.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 98dd446ad4dd -r fc2ba45f68cd usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Wed Dec 29 08:15:45 2021 +0000
+++ b/usr.bin/make/cond.c       Wed Dec 29 08:23:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.315 2021/12/29 08:15:45 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.316 2021/12/29 08:23:40 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.315 2021/12/29 08:15:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.316 2021/12/29 08:23:40 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -762,7 +762,7 @@
                return false;
 
        ok = ParseWord(par, &p, doEval, fn_name, &arg);
-       *out_token = ToToken(ok && (!doEval || fn(arg)));
+       *out_token = ToToken(ok && doEval && fn(arg));
 
        free(arg);
        par->p = p;



Home | Main Index | Thread Index | Old Index