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): split confusing condition in ParseDoDe...



details:   https://anonhg.NetBSD.org/src/rev/9ffb3713f410
branches:  trunk
changeset: 976204:9ffb3713f410
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 14 15:11:13 2020 +0000

description:
make(1): split confusing condition in ParseDoDependency

A while loop is easier to understand than a do-while loop.

An if statement of the form if-something-then-do-something is easier to
understand than if-complicated-condition-then-continue-doing-something.

diffstat:

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

diffs (41 lines):

diff -r 5b35dccfd73a -r 9ffb3713f410 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Mon Sep 14 15:09:57 2020 +0000
+++ b/usr.bin/make/parse.c      Mon Sep 14 15:11:13 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.306 2020/09/14 14:58:27 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.307 2020/09/14 15:11:13 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.306 2020/09/14 14:58:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.307 2020/09/14 15:11:13 rillig Exp $");
 
 /* types and constants */
 
@@ -1133,7 +1133,7 @@
      * First, grind through the targets.
      */
 
-    do {
+    while (TRUE) {
        /*
         * Here LINE points to the beginning of the next word, and
         * LSTART points to the actual beginning of the line.
@@ -1413,8 +1413,11 @@
            }
        }
        line = cp;
-    } while (*line && (ParseIsEscaped(lstart, line) ||
-       (*line != '!' && *line != ':')));
+       if (*line == '\0')
+           break;
+       if ((*line == '!' || *line == ':') && !ParseIsEscaped(lstart, line))
+           break;
+    }
 
     /*
      * Don't need the list of target names anymore...



Home | Main Index | Thread Index | Old Index