summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2020-11-23 22:31:04 +0000
committerrillig <rillig@NetBSD.org>2020-11-23 22:31:04 +0000
commitd54fbb6419ced5d6915ea430e0a1e66bb2fd3389 (patch)
treec1fdfcfd1a9fcaed764920f917d7c570f8ba436e /usr.bin/make
parent707f07705aab6ccb29d325032b50360877c3d3b7 (diff)
make(1): extract ResolveFullName from Dir_UpdateMTime
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/dir.c51
1 files changed, 32 insertions, 19 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index 568aa7dff6e..1a6ede6a4e6 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.218 2020/11/23 22:14:54 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.219 2020/11/23 22:31:04 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.218 2020/11/23 22:14:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.219 2020/11/23 22:31:04 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1291,25 +1291,10 @@ Dir_FindHereOrAbove(const char *here, const char *search_path)
return NULL;
}
-/* Search gn along dirSearchPath and store its modification time in gn->mtime.
- * If no file is found, store 0 instead.
- *
- * The found file is stored in gn->path, unless the node already had a path. */
-void
-Dir_UpdateMTime(GNode *gn, Boolean recheck)
+static char *
+ResolveFullName(GNode *gn)
{
char *fullName;
- struct cached_stat cst;
-
- if (gn->type & OP_ARCHV) {
- Arch_UpdateMTime(gn);
- return;
- }
-
- if (gn->type & OP_PHONY) {
- gn->mtime = 0;
- return;
- }
if (gn->path == NULL) {
if (gn->type & OP_NOPATH)
@@ -1354,6 +1339,33 @@ Dir_UpdateMTime(GNode *gn, Boolean recheck)
if (fullName == NULL)
fullName = bmake_strdup(gn->name);
+ /* XXX: Is every piece of memory freed as it should? */
+
+ return fullName;
+}
+
+/* Search gn along dirSearchPath and store its modification time in gn->mtime.
+ * If no file is found, store 0 instead.
+ *
+ * The found file is stored in gn->path, unless the node already had a path. */
+void
+Dir_UpdateMTime(GNode *gn, Boolean recheck)
+{
+ char *fullName;
+ struct cached_stat cst;
+
+ if (gn->type & OP_ARCHV) {
+ Arch_UpdateMTime(gn);
+ return;
+ }
+
+ if (gn->type & OP_PHONY) {
+ gn->mtime = 0;
+ return;
+ }
+
+ fullName = ResolveFullName(gn);
+
if (cached_stats(fullName, &cst, recheck ? CST_UPDATE : CST_NONE) < 0) {
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
@@ -1367,6 +1379,7 @@ Dir_UpdateMTime(GNode *gn, Boolean recheck)
if (fullName != NULL && gn->path == NULL)
gn->path = fullName;
+ /* XXX: else free(fullName)? */
gn->mtime = cst.cst_mtime;
}