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(1): flip conditions in ParseDoDependency



details:   https://anonhg.NetBSD.org/src/rev/e305a2087a3a
branches:  trunk
changeset: 1014244:e305a2087a3a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 14 16:12:41 2020 +0000

description:
make(1): flip conditions in ParseDoDependency

In the usual case where the character is a letter or another ordinary
character, each of the terminal conditions has to be evaluated,
therefore from the compiler's view the order doesn't matter.  For
humans, "a unless b" is easier to grasp and more common than "not b but
a", therefore switch to the common pattern.

diffstat:

 usr.bin/make/parse.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r f09fc4d54bc2 -r e305a2087a3a usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Mon Sep 14 16:11:32 2020 +0000
+++ b/usr.bin/make/parse.c      Mon Sep 14 16:12:41 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.308 2020/09/14 16:05:09 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.309 2020/09/14 16:12:41 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.308 2020/09/14 16:05:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.309 2020/09/14 16:12:41 rillig Exp $");
 
 /* types and constants */
 
@@ -1141,11 +1141,12 @@
 
        /* Find the end of the next word. */
        for (cp = line; *cp != '\0';) {
-           if (!ParseIsEscaped(lstart, cp) &&
-               (ch_isspace(*cp) || *cp == '!' || *cp == ':' || *cp == LPAREN))
+           char ch = *cp;
+           if ((ch_isspace(ch) || ch == '!' || ch == ':' || ch == LPAREN) &&
+               !ParseIsEscaped(lstart, cp))
                break;
 
-           if (*cp == '$') {
+           if (ch == '$') {
                /*
                 * Must be a dynamic source (would have been expanded
                 * otherwise), so call the Var module to parse the puppy



Home | Main Index | Thread Index | Old Index