Module Name: src
Committed By: rillig
Date: Sun Oct 25 21:51:49 UTC 2020
Modified Files:
src/usr.bin/make: dir.c job.c make.c make.h meta.c suff.c targ.c var.c
Log Message:
make(1): add GNode_Path to access the path of a GNode
To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/make/dir.c
cvs rdiff -u -r1.286 -r1.287 src/usr.bin/make/job.c
cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/make.c
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/make.h
cvs rdiff -u -r1.130 -r1.131 src/usr.bin/make/meta.c
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/make/suff.c
cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/targ.c
cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/var.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/dir.c
diff -u src/usr.bin/make/dir.c:1.188 src/usr.bin/make/dir.c:1.189
--- src/usr.bin/make/dir.c:1.188 Sun Oct 25 19:19:07 2020
+++ src/usr.bin/make/dir.c Sun Oct 25 21:51:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -135,7 +135,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.188 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.189 2020/10/25 21:51:48 rillig Exp $");
#define DIR_DEBUG0(text) DEBUG0(DIR, text)
#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -1367,9 +1367,8 @@ Dir_MTime(GNode *gn, Boolean recheck)
}
}
- if (fullName && gn->path == NULL) {
+ if (fullName != NULL && gn->path == NULL)
gn->path = fullName;
- }
gn->mtime = mst.mst_mtime;
return gn->mtime;
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.286 src/usr.bin/make/job.c:1.287
--- src/usr.bin/make/job.c:1.286 Sun Oct 25 21:34:52 2020
+++ src/usr.bin/make/job.c Sun Oct 25 21:51:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $ */
+/* $NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.286 2020/10/25 21:34:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.287 2020/10/25 21:51:48 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -443,6 +443,8 @@ job_table_dump(const char *where)
static void
JobDeleteTarget(GNode *gn)
{
+ const char *file;
+
if (gn->type & OP_JOIN)
return;
if (gn->type & OP_PHONY)
@@ -452,11 +454,9 @@ JobDeleteTarget(GNode *gn)
if (noExecute)
return;
- {
- char *file = (gn->path == NULL ? gn->name : gn->path);
- if (eunlink(file) != -1)
- Error("*** %s removed", file);
- }
+ file = GNode_Path(gn);
+ if (eunlink(file) != -1)
+ Error("*** %s removed", file);
}
/*
@@ -1138,7 +1138,7 @@ Job_Touch(GNode *gn, Boolean silent)
} else if (gn->type & OP_LIB) {
Arch_TouchLib(gn);
} else {
- char *file = gn->path ? gn->path : gn->name;
+ const char *file = GNode_Path(gn);
times.actime = times.modtime = now;
if (utime(file, ×) < 0){
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.179 src/usr.bin/make/make.c:1.180
--- src/usr.bin/make/make.c:1.179 Sun Oct 25 10:07:23 2020
+++ src/usr.bin/make/make.c Sun Oct 25 21:51:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.179 2020/10/25 10:07:23 rillig Exp $ */
+/* $NetBSD: make.c,v 1.180 2020/10/25 21:51:48 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.179 2020/10/25 10:07:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.180 2020/10/25 21:51:48 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked = 1;
@@ -294,8 +294,7 @@ Make_OODate(GNode *gn)
if (gn->youngestChild != NULL &&
gn->mtime < gn->youngestChild->mtime) {
debug_printf("modified before source %s...",
- gn->youngestChild->path ? gn->youngestChild->path
- : gn->youngestChild->name);
+ GNode_Path(gn->youngestChild));
} else if (gn->mtime == 0) {
debug_printf("non-existent and no sources...");
} else {
@@ -785,7 +784,7 @@ MakeAddAllSrc(GNode *cgn, GNode *pgn)
if (cgn->type & OP_ARCHV)
child = Var_Value(MEMBER, cgn, &p1);
else
- child = cgn->path ? cgn->path : cgn->name;
+ child = GNode_Path(cgn);
if (cgn->type & OP_JOIN) {
allsrc = Var_Value(ALLSRC, cgn, &p2);
} else {
@@ -1178,7 +1177,7 @@ Make_ExpandUse(GNodeList *targs)
}
(void)Dir_MTime(gn, 0);
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
+ Var_Set(TARGET, GNode_Path(gn), gn);
UnmarkChildren(gn);
HandleUseNodes(gn);
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.171 src/usr.bin/make/make.h:1.172
--- src/usr.bin/make/make.h:1.171 Sat Oct 24 20:51:49 2020
+++ src/usr.bin/make/make.h Sun Oct 25 21:51:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.171 2020/10/24 20:51:49 rillig Exp $ */
+/* $NetBSD: make.h,v 1.172 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -587,12 +587,18 @@ void GNode_FprintDetails(FILE *, const c
Boolean NoExecute(GNode *gn);
/* See if the node was seen on the left-hand side of a dependency operator. */
-static Boolean MAKE_ATTR_UNUSED
+static MAKE_ATTR_UNUSED Boolean
GNode_IsTarget(const GNode *gn)
{
return (gn->type & OP_OPMASK) != 0;
}
+static MAKE_ATTR_UNUSED const char *
+GNode_Path(const GNode *gn)
+{
+ return gn->path != NULL ? gn->path : gn->name;
+}
+
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
union __unconst { \
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.130 src/usr.bin/make/meta.c:1.131
--- src/usr.bin/make/meta.c:1.130 Sat Oct 24 10:32:25 2020
+++ src/usr.bin/make/meta.c Sun Oct 25 21:51:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.130 2020/10/24 10:32:25 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.131 2020/10/25 21:51:49 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -794,7 +794,7 @@ meta_job_error(Job *job, GNode *gn, int
"(ignored)" : "");
}
if (gn) {
- Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL);
+ Var_Set(".ERROR_TARGET", GNode_Path(gn), VAR_GLOBAL);
}
getcwd(cwd, sizeof(cwd));
Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.224 src/usr.bin/make/suff.c:1.225
--- src/usr.bin/make/suff.c:1.224 Sun Oct 25 17:12:51 2020
+++ src/usr.bin/make/suff.c Sun Oct 25 21:51:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.224 2020/10/25 17:12:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.225 2020/10/25 21:51:49 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -1788,7 +1788,7 @@ SuffFindNormalDeps(GNode *gn, SrcList *s
}
}
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
+ Var_Set(TARGET, GNode_Path(gn), gn);
pref = (targ != NULL) ? targ->pref : gn->name;
Var_Set(PREFIX, pref, gn);
@@ -1953,7 +1953,7 @@ SuffFindDeps(GNode *gn, SrcList *slst)
/*
* Make sure we have these set, may get revised below.
*/
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
+ Var_Set(TARGET, GNode_Path(gn), gn);
Var_Set(PREFIX, gn->name, gn);
SUFF_DEBUG1("SuffFindDeps (%s)\n", gn->name);
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.123 src/usr.bin/make/targ.c:1.124
--- src/usr.bin/make/targ.c:1.123 Sun Oct 25 19:19:07 2020
+++ src/usr.bin/make/targ.c Sun Oct 25 21:51:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.123 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.124 2020/10/25 21:51:49 rillig Exp $");
static GNodeList *allTargets; /* the list of all targets found so far */
#ifdef CLEANUP
@@ -516,8 +516,7 @@ PrintOnlySources(void)
if (GNode_IsTarget(gn))
continue;
- debug_printf("#\t%s [%s]",
- gn->name, gn->path ? gn->path : gn->name);
+ debug_printf("#\t%s [%s]", gn->name, GNode_Path(gn));
Targ_PrintType(gn->type);
debug_printf("\n");
}
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.588 src/usr.bin/make/var.c:1.589
--- src/usr.bin/make/var.c:1.588 Sun Oct 25 19:19:07 2020
+++ src/usr.bin/make/var.c Sun Oct 25 21:51:49 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $ */
+/* $NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.588 2020/10/25 19:19:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.589 2020/10/25 21:51:49 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2172,7 +2172,7 @@ ApplyModifier_Path(const char **pp, Appl
gn = Targ_FindNode(st->v->name);
if (gn == NULL || gn->type & OP_NOPATH) {
path = NULL;
- } else if (gn->path) {
+ } else if (gn->path != NULL) {
path = bmake_strdup(gn->path);
} else {
SearchPath *searchPath = Suff_FindPath(gn);