Module Name:    src
Committed By:   rillig
Date:           Sun Nov  8 09:48:52 UTC 2020

Modified Files:
        src/usr.bin/make: make.c

Log Message:
make(1): extract condition from GNode_IsOODate into separate function


To generate a diff of this commit:
cvs rdiff -u -r1.194 -r1.195 src/usr.bin/make/make.c

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/make.c
diff -u src/usr.bin/make/make.c:1.194 src/usr.bin/make/make.c:1.195
--- src/usr.bin/make/make.c:1.194	Sun Nov  8 09:34:55 2020
+++ src/usr.bin/make/make.c	Sun Nov  8 09:48:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.194 2020/11/08 09:34:55 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.195 2020/11/08 09:48:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -108,7 +108,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.194 2020/11/08 09:34:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.195 2020/11/08 09:48:52 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -192,6 +192,23 @@ GNode_UpdateYoungestChild(GNode *gn, GNo
 	gn->youngestChild = cgn;
 }
 
+/*
+ * A node whose modification time is less than that of its
+ * youngest child or that has no children (youngestChild == NULL) and
+ * either doesn't exist (mtime == 0) and it isn't optional
+ * or was the object of a * :: operator is out-of-date.
+ * Why? Because that's the way Make does it.
+ */
+static Boolean
+IsOlderThanYoungestChild(GNode *gn)
+{
+    return (gn->youngestChild != NULL &&
+	    gn->mtime < gn->youngestChild->mtime) ||
+	   (gn->youngestChild == NULL &&
+	    ((gn->mtime == 0 && !(gn->type & OP_OPTIONAL))
+	     || gn->type & OP_DOUBLEDEP));
+}
+
 /* See if the node is out of date with respect to its sources.
  *
  * Used by Make_Run when deciding which nodes to place on the
@@ -275,19 +292,7 @@ GNode_IsOODate(GNode *gn)
 	    }
 	}
 	oodate = TRUE;
-    } else if ((gn->youngestChild != NULL &&
-		gn->mtime < gn->youngestChild->mtime) ||
-	       (gn->youngestChild == NULL &&
-		((gn->mtime == 0 && !(gn->type & OP_OPTIONAL))
-		 || gn->type & OP_DOUBLEDEP)))
-    {
-	/*
-	 * A node whose modification time is less than that of its
-	 * youngest child or that has no children (youngestChild == NULL) and
-	 * either doesn't exist (mtime == 0) and it isn't optional
-	 * or was the object of a * :: operator is out-of-date.
-	 * Why? Because that's the way Make does it.
-	 */
+    } else if (IsOlderThanYoungestChild(gn)) {
 	if (DEBUG(MAKE)) {
 	    if (gn->youngestChild != NULL &&
 		gn->mtime < gn->youngestChild->mtime) {

Reply via email to