diff options
| author | rillig <rillig@NetBSD.org> | 2020-09-14 17:44:57 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2020-09-14 17:44:57 +0000 |
| commit | 64ad9918f4fe826232c445f7f018de4ad968ec02 (patch) | |
| tree | 811446fed273dfe02612d758f67a278762580480 /usr.bin/make/parse.c | |
| parent | 8de3199f6a5d33a4b862cdeaa6083793844d70f2 (diff) | |
make(1): clean up documentation and code of ParseLinkSrc
The previous documentation was focused on the implementation details,
which are already clear from the code. Add some high-level
documentation to help readers understand how this function fits into the
overall picture.
Diffstat (limited to 'usr.bin/make/parse.c')
| -rw-r--r-- | usr.bin/make/parse.c | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index eac156679ac..aa66c504226 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.315 2020/09/14 16:59:41 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.316 2020/09/14 17:44:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -131,7 +131,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.315 2020/09/14 16:59:41 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.316 2020/09/14 17:44:57 rillig Exp $"); /* types and constants */ @@ -745,48 +745,40 @@ ParseMessage(char *line) struct ParseLinkSrcArgs { GNode *cgn; + + /* The special target of the current dependency line. */ + /* Example: for ".SUFFIXES: .c.o", it is 'Suffixes'. */ ParseSpecial specType; }; -/*- - *--------------------------------------------------------------------- - * ParseLinkSrc -- - * Link the parent node to its new child. Used in a Lst_ForEach by - * ParseDoDependency. If the specType isn't 'Not', the parent - * isn't linked as a parent of the child. - * - * Input: - * pgnp The parent node - * cgpn The child node - * - * Results: - * Always = 0 +/* Add the child to the parent's children. * - * Side Effects: - * New elements are added to the parents list of cgn and the - * children list of cgn. the unmade field of pgn is updated - * to reflect the additional child. - *--------------------------------------------------------------------- - */ + * Add the parent to the child's parents, but only if the target is not + * special. An example for such a special target is .END, which does not + * need to be informed once the child target has been made. */ static int ParseLinkSrc(void *pgnp, void *data) { const struct ParseLinkSrcArgs *args = data; - GNode *pgn = (GNode *)pgnp; - GNode *cgn = args->cgn; + GNode *pgn = pgnp; + GNode *cgn = args->cgn; if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty(pgn->cohorts)) pgn = LstNode_Datum(Lst_Last(pgn->cohorts)); + Lst_Append(pgn->children, cgn); + pgn->unmade += 1; + if (args->specType == Not) Lst_Append(cgn->parents, pgn); - pgn->unmade += 1; + if (DEBUG(PARSE)) { - fprintf(debug_file, "# %s: added child %s - %s\n", __func__, - pgn->name, cgn->name); + fprintf(debug_file, "# %s: added child %s - %s\n", + __func__, pgn->name, cgn->name); Targ_PrintNode(pgn, 0); Targ_PrintNode(cgn, 0); } + return 0; } |
