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): add GNode_Path to access the path of a...
details: https://anonhg.NetBSD.org/src/rev/41bb532f6c3f
branches: trunk
changeset: 941659:41bb532f6c3f
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 25 21:51:48 2020 +0000
description:
make(1): add GNode_Path to access the path of a GNode
diffstat:
usr.bin/make/dir.c | 7 +++----
usr.bin/make/job.c | 16 ++++++++--------
usr.bin/make/make.c | 11 +++++------
usr.bin/make/make.h | 10 ++++++++--
usr.bin/make/meta.c | 4 ++--
usr.bin/make/suff.c | 8 ++++----
usr.bin/make/targ.c | 7 +++----
usr.bin/make/var.c | 6 +++---
8 files changed, 36 insertions(+), 33 deletions(-)
diffs (264 lines):
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/dir.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
}
}
- if (fullName && gn->path == NULL) {
+ if (fullName != NULL && gn->path == NULL)
gn->path = fullName;
- }
gn->mtime = mst.mst_mtime;
return gn->mtime;
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/job.c
--- a/usr.bin/make/job.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/job.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
static void
JobDeleteTarget(GNode *gn)
{
+ const char *file;
+
if (gn->type & OP_JOIN)
return;
if (gn->type & OP_PHONY)
@@ -452,11 +454,9 @@
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 @@
} 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){
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/make.c
--- a/usr.bin/make/make.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/make.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
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 @@
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 @@
}
(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);
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/make.h
--- a/usr.bin/make/make.h Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/make.h Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
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 { \
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/meta.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
"(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);
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/suff.c
--- a/usr.bin/make/suff.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/suff.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
}
}
- 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 @@
/*
* 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);
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/targ.c
--- a/usr.bin/make/targ.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/targ.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
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");
}
diff -r bcb8fd8298b6 -r 41bb532f6c3f usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Oct 25 21:34:52 2020 +0000
+++ b/usr.bin/make/var.c Sun Oct 25 21:51:48 2020 +0000
@@ -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 @@
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);
Home |
Main Index |
Thread Index |
Old Index