make(1): indent targ.c with tabs instead of spaces
Explain the tricky details of GNode_Free. Invert a condition in Targ_PrintNode to reduce the overall indentation.
This commit is contained in:
parent
026824484e
commit
5737b54186
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: targ.c,v 1.149 2020/12/04 14:39:56 rillig Exp $ */
|
||||
/* $NetBSD: targ.c,v 1.150 2020/12/05 15:35:34 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -119,7 +119,7 @@
|
|||
#include "dir.h"
|
||||
|
||||
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.149 2020/12/04 14:39:56 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: targ.c,v 1.150 2020/12/05 15:35:34 rillig Exp $");
|
||||
|
||||
/*
|
||||
* All target nodes that appeared on the left-hand side of one of the
|
||||
|
@ -168,7 +168,8 @@ Targ_List(void)
|
|||
return &allTargets;
|
||||
}
|
||||
|
||||
/* Create a new graph node, but don't register it anywhere.
|
||||
/*
|
||||
* Create a new graph node, but don't register it anywhere.
|
||||
*
|
||||
* Graph nodes that appear on the left-hand side of a dependency line such
|
||||
* as "target: source" are called targets. XXX: In some cases (like the
|
||||
|
@ -229,22 +230,49 @@ GNode_Free(void *gnp)
|
|||
free(gn->name);
|
||||
free(gn->uname);
|
||||
free(gn->path);
|
||||
/* gn->youngestChild is not owned by this node. */
|
||||
Lst_Done(&gn->implicitParents); /* Do not free the nodes themselves, */
|
||||
Lst_Done(&gn->parents); /* as they are not owned by this node. */
|
||||
Lst_Done(&gn->children); /* likewise */
|
||||
Lst_Done(&gn->order_pred); /* likewise */
|
||||
Lst_Done(&gn->order_succ); /* likewise */
|
||||
Lst_Done(&gn->cohorts); /* likewise */
|
||||
HashTable_Done(&gn->vars); /* Do not free the variables themselves,
|
||||
* even though they are owned by this node.
|
||||
* XXX: they should probably be freed. */
|
||||
Lst_Done(&gn->commands); /* Do not free the commands themselves,
|
||||
* as they may be shared with other nodes. */
|
||||
/* gn->suffix is not owned by this node. */
|
||||
/* XXX: gn->suffix should be unreferenced here. This requires a thorough
|
||||
* check that the reference counting is done correctly in all places,
|
||||
* otherwise a suffix might be freed too early. */
|
||||
|
||||
/* Don't free gn->youngestChild since it is not owned by this node. */
|
||||
|
||||
/*
|
||||
* In the following lists, only free the list nodes, but not the
|
||||
* GNodes in them since these are not owned by this node.
|
||||
*/
|
||||
Lst_Done(&gn->implicitParents);
|
||||
Lst_Done(&gn->parents);
|
||||
Lst_Done(&gn->children);
|
||||
Lst_Done(&gn->order_pred);
|
||||
Lst_Done(&gn->order_succ);
|
||||
Lst_Done(&gn->cohorts);
|
||||
|
||||
/*
|
||||
* Do not free the variables themselves, even though they are owned
|
||||
* by this node.
|
||||
*
|
||||
* XXX: For the nodes that represent targets or sources (and not
|
||||
* VAR_GLOBAL), it should be safe to free the variables as well,
|
||||
* since each node manages the memory for all its variables itself.
|
||||
*
|
||||
* XXX: The GNodes that are only used as variable contexts (VAR_CMD,
|
||||
* VAR_GLOBAL, VAR_INTERNAL) are not freed at all (see Var_End, where
|
||||
* they are not mentioned). These might be freed at all, if their
|
||||
* variable values are indeed not used anywhere else (see Trace_Init
|
||||
* for the only suspicious use).
|
||||
*/
|
||||
HashTable_Done(&gn->vars);
|
||||
|
||||
/*
|
||||
* Do not free the commands themselves, as they may be shared with
|
||||
* other nodes.
|
||||
*/
|
||||
Lst_Done(&gn->commands);
|
||||
|
||||
/*
|
||||
* gn->suffix is not owned by this node.
|
||||
*
|
||||
* XXX: gn->suffix should be unreferenced here. This requires a
|
||||
* thorough check that the reference counting is done correctly in
|
||||
* all places, otherwise a suffix might be freed too early.
|
||||
*/
|
||||
|
||||
free(gn);
|
||||
}
|
||||
|
@ -297,8 +325,12 @@ Targ_NewInternalNode(const char *name)
|
|||
*/
|
||||
GNode *Targ_GetEndNode(void)
|
||||
{
|
||||
/* Save the node locally to avoid having to search for it all the time. */
|
||||
/*
|
||||
* Save the node locally to avoid having to search for it all
|
||||
* the time.
|
||||
*/
|
||||
static GNode *endNode = NULL;
|
||||
|
||||
if (endNode == NULL) {
|
||||
endNode = Targ_GetNode(".END");
|
||||
endNode->type = OP_SPECIAL;
|
||||
|
@ -382,14 +414,17 @@ void
|
|||
Targ_PrintCmds(GNode *gn)
|
||||
{
|
||||
StringListNode *ln;
|
||||
|
||||
for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
|
||||
const char *cmd = ln->datum;
|
||||
debug_printf("\t%s\n", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Format a modification time in some reasonable way and return it.
|
||||
* The time is placed in a static area, so it is overwritten with each call. */
|
||||
/*
|
||||
* Format a modification time in some reasonable way and return it.
|
||||
* The time is placed in a static area, so it is overwritten with each call.
|
||||
*/
|
||||
char *
|
||||
Targ_FmtTime(time_t tm)
|
||||
{
|
||||
|
@ -478,17 +513,18 @@ Targ_PrintNode(GNode *gn, int pass)
|
|||
if (gn->flags == 0)
|
||||
return;
|
||||
|
||||
if (GNode_IsTarget(gn)) {
|
||||
if (!GNode_IsTarget(gn))
|
||||
return;
|
||||
|
||||
debug_printf("#\n");
|
||||
if (gn == mainTarg) {
|
||||
if (gn == mainTarg)
|
||||
debug_printf("# *** MAIN TARGET ***\n");
|
||||
}
|
||||
|
||||
if (pass >= 2) {
|
||||
if (gn->unmade > 0) {
|
||||
if (gn->unmade > 0)
|
||||
debug_printf("# %d unmade children\n", gn->unmade);
|
||||
} else {
|
||||
else
|
||||
debug_printf("# No unmade children\n");
|
||||
}
|
||||
if (!(gn->type & (OP_JOIN | OP_USE | OP_USEBEFORE | OP_EXEC))) {
|
||||
if (gn->mtime != 0) {
|
||||
debug_printf("# last modified %s: %s\n",
|
||||
|
@ -497,15 +533,15 @@ Targ_PrintNode(GNode *gn, int pass)
|
|||
} else if (gn->made != UNMADE) {
|
||||
debug_printf("# non-existent (maybe): %s\n",
|
||||
made_name(gn->made));
|
||||
} else {
|
||||
} else
|
||||
debug_printf("# unmade\n");
|
||||
}
|
||||
}
|
||||
PrintNodeNamesLine("implicit parents", &gn->implicitParents);
|
||||
} else {
|
||||
if (gn->unmade)
|
||||
debug_printf("# %d unmade children\n", gn->unmade);
|
||||
}
|
||||
|
||||
PrintNodeNamesLine("parents", &gn->parents);
|
||||
PrintNodeNamesLine("order_pred", &gn->order_pred);
|
||||
PrintNodeNamesLine("order_succ", &gn->order_succ);
|
||||
|
@ -516,16 +552,15 @@ Targ_PrintNode(GNode *gn, int pass)
|
|||
debug_printf("\n");
|
||||
Targ_PrintCmds(gn);
|
||||
debug_printf("\n\n");
|
||||
if (gn->type & OP_DOUBLEDEP) {
|
||||
if (gn->type & OP_DOUBLEDEP)
|
||||
Targ_PrintNodes(&gn->cohorts, pass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Targ_PrintNodes(GNodeList *gnodes, int pass)
|
||||
{
|
||||
GNodeListNode *ln;
|
||||
|
||||
for (ln = gnodes->first; ln != NULL; ln = ln->next)
|
||||
Targ_PrintNode(ln->datum, pass);
|
||||
}
|
||||
|
@ -547,7 +582,8 @@ PrintOnlySources(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Input:
|
||||
/*
|
||||
* Input:
|
||||
* pass 1 => before processing
|
||||
* 2 => after processing
|
||||
* 3 => after processing, an error occurred
|
||||
|
@ -577,11 +613,13 @@ Targ_PrintGraph(int pass)
|
|||
Suff_PrintAll();
|
||||
}
|
||||
|
||||
/* Propagate some type information to cohort nodes (those from the '::'
|
||||
/*
|
||||
* Propagate some type information to cohort nodes (those from the '::'
|
||||
* dependency operator).
|
||||
*
|
||||
* Should be called after the makefiles are parsed but before any action is
|
||||
* taken. */
|
||||
* taken.
|
||||
*/
|
||||
void
|
||||
Targ_Propagate(void)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue