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): extract UpdateImplicitParentsVars from...



details:   https://anonhg.NetBSD.org/src/rev/7e90b0459f91
branches:  trunk
changeset: 945144:7e90b0459f91
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 22 17:29:32 2020 +0000

description:
make(1): extract UpdateImplicitParentsVars from Make_Update

diffstat:

 usr.bin/make/make.c |  55 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 32 insertions(+), 23 deletions(-)

diffs (97 lines):

diff -r 31d919adcc56 -r 7e90b0459f91 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Thu Oct 22 17:20:35 2020 +0000
+++ b/usr.bin/make/make.c       Thu Oct 22 17:29:32 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.168 2020/10/22 17:20:35 rillig Exp $        */
+/*     $NetBSD: make.c,v 1.169 2020/10/22 17:29:32 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include    "job.h"
 
 /*     "@(#)make.c     8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: make.c,v 1.168 2020/10/22 17:20:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.169 2020/10/22 17:29:32 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -559,6 +559,28 @@
     return mtime;
 }
 
+/*
+ * Set the .PREFIX and .IMPSRC variables for all the implied parents
+ * of this node.
+ */
+static void
+UpdateImplicitParentsVars(GNode *cgn, const char *cname)
+{
+    GNodeListNode *ln;
+    char *cpref_freeIt;
+    const char *cpref = Var_Value(PREFIX, cgn, &cpref_freeIt);
+
+    for (ln = cgn->implicitParents->first; ln != NULL; ln = ln->next) {
+       GNode *pgn = ln->datum;
+       if (pgn->flags & REMAKE) {
+           Var_Set(IMPSRC, cname, pgn);
+           if (cpref != NULL)
+               Var_Set(PREFIX, cpref, pgn);
+       }
+    }
+    bmake_free(cpref_freeIt);
+}
+
 /* Perform update on the parents of a node. Used by JobFinish once
  * a node has been dealt with and by MakeStartJobs if it finds an
  * up-to-date node.
@@ -582,7 +604,6 @@
 Make_Update(GNode *cgn)
 {
     const char *cname;         /* the child's name */
-    GNodeListNode *ln;
     time_t     mtime = -1;
     GNodeList *parents;
     GNode      *centurion;
@@ -627,8 +648,13 @@
 
     /* Now mark all the parents as having one less unmade child */
     Lst_Open(parents);
-    while ((ln = Lst_Next(parents)) != NULL) {
-       GNode *pgn = ln->datum;
+    for (;;) {
+       GNodeListNode *ln = Lst_Next(parents);
+       GNode *pgn;
+       if (ln == NULL)
+           break;
+       pgn = ln->datum;
+
        if (DEBUG(MAKE))
            debug_printf("inspect parent %s%s: flags %x, "
                         "type %x, made %d, unmade %d ",
@@ -715,24 +741,7 @@
     }
     Lst_Close(parents);
 
-    /*
-     * Set the .PREFIX and .IMPSRC variables for all the implied parents
-     * of this node.
-     */
-    {
-        char *cpref_freeIt;
-       const char *cpref = Var_Value(PREFIX, cgn, &cpref_freeIt);
-
-       for (ln = cgn->implicitParents->first; ln != NULL; ln = ln->next) {
-           GNode *pgn = ln->datum;
-           if (pgn->flags & REMAKE) {
-               Var_Set(IMPSRC, cname, pgn);
-               if (cpref != NULL)
-                   Var_Set(PREFIX, cpref, pgn);
-           }
-       }
-       bmake_free(cpref_freeIt);
-    }
+    UpdateImplicitParentsVars(cgn, cname);
 }
 
 static void



Home | Main Index | Thread Index | Old Index