From 65a2faf0b602709f5ee7d3bbb61506252941e023 Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 4 Dec 2020 14:39:56 +0000 Subject: [PATCH] make(1): use consistent variable names for list nodes --- usr.bin/make/arch.c | 22 +++++++++------------- usr.bin/make/dir.c | 11 ++++++----- usr.bin/make/job.c | 10 +++++----- usr.bin/make/lst.c | 16 ++++++++-------- usr.bin/make/targ.c | 22 +++++++++++++--------- 5 files changed, 41 insertions(+), 40 deletions(-) diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 13592cff43a9..b594a9b88333 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.182 2020/11/29 01:40:26 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.183 2020/12/04 14:39:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -125,7 +125,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.182 2020/11/29 01:40:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.183 2020/12/04 14:39:56 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -169,21 +169,20 @@ ArchFree(void *ap) /* * Parse an archive specification such as "archive.a(member1 member2.${EXT})", - * adding nodes for the expanded members to nodeLst. Nodes are created as + * adding nodes for the expanded members to gns. Nodes are created as * necessary. * * Input: * pp The start of the specification. - * nodeLst The list on which to place the nodes. + * gns The list on which to place the nodes. * ctxt The context in which to expand variables. * * Output: * return TRUE if it was a valid specification. * *pp Points to the first non-space after the archive spec. - * *nodeLst Nodes for the members have been added. */ Boolean -Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) +Arch_ParseArchive(char **pp, GNodeList *gns, GNode *ctxt) { char *cp; /* Pointer into line */ GNode *gn; /* New node */ @@ -317,8 +316,6 @@ Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) /* * Now form an archive spec and recurse to deal with * nested variables and multi-word variable values. - * The results are just placed at the end of the - * nodeLst we're returning. */ sacrifice = str_concat4(libName, "(", memName, ")"); buf = sacrifice; @@ -333,10 +330,9 @@ Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) */ gn = Targ_GetNode(buf); gn->type |= OP_ARCHV; - Lst_Append(nodeLst, gn); + Lst_Append(gns, gn); - } else if (!Arch_ParseArchive(&sacrifice, nodeLst, - ctxt)) { + } else if (!Arch_ParseArchive(&sacrifice, gns, ctxt)) { /* Error in nested call. */ free(buf); return FALSE; @@ -357,7 +353,7 @@ Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) free(fullname); gn->type |= OP_ARCHV; - Lst_Append(nodeLst, gn); + Lst_Append(gns, gn); } Lst_Done(&members); @@ -375,7 +371,7 @@ Arch_ParseArchive(char **pp, GNodeList *nodeLst, GNode *ctxt) * we place it on the end of the provided list. */ gn->type |= OP_ARCHV; - Lst_Append(nodeLst, gn); + Lst_Append(gns, gn); } if (doSubst) free(memName); diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index b2ee9cc43103..d4d906c22cb3 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.248 2020/12/04 14:28:50 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,7 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.248 2020/12/04 14:28:50 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $"); #define DIR_DEBUG0(text) DEBUG0(DIR, text) #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) @@ -1667,9 +1667,10 @@ Dir_PrintDirectories(void) void SearchPath_Print(SearchPath *path) { - SearchPathNode *node; - for (node = path->first; node != NULL; node = node->next) { - const CachedDir *dir = node->datum; + SearchPathNode *ln; + + for (ln = path->first; ln != NULL; ln = ln->next) { + const CachedDir *dir = ln->datum; debug_printf("%s ", dir->name); } } diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c index 92aba4e18ebf..feda373610c7 100644 --- a/usr.bin/make/job.c +++ b/usr.bin/make/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.334 2020/11/29 09:27:40 rillig Exp $ */ +/* $NetBSD: job.c,v 1.335 2020/12/04 14:39:56 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.334 2020/11/29 09:27:40 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.335 2020/12/04 14:39:56 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 @@ -919,10 +919,10 @@ JobPrintCommands(Job *job) static void JobSaveCommands(Job *job) { - StringListNode *node; + StringListNode *ln; - for (node = job->tailCmds; node != NULL; node = node->next) { - const char *cmd = node->datum; + for (ln = job->tailCmds; ln != NULL; ln = ln->next) { + const char *cmd = ln->datum; char *expanded_cmd; /* XXX: This Var_Subst is only intended to expand the dynamic * variables such as .TARGET, .IMPSRC. It is not intended to diff --git a/usr.bin/make/lst.c b/usr.bin/make/lst.c index f87b26c17ccf..919b4cd3d6c3 100644 --- a/usr.bin/make/lst.c +++ b/usr.bin/make/lst.c @@ -1,4 +1,4 @@ -/* $NetBSD: lst.c,v 1.97 2020/11/29 00:54:43 rillig Exp $ */ +/* $NetBSD: lst.c,v 1.98 2020/12/04 14:39:56 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -34,7 +34,7 @@ #include "make.h" -MAKE_RCSID("$NetBSD: lst.c,v 1.97 2020/11/29 00:54:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: lst.c,v 1.98 2020/12/04 14:39:56 rillig Exp $"); static ListNode * LstNodeNew(ListNode *prev, ListNode *next, void *datum) @@ -226,20 +226,20 @@ Lst_MoveAll(List *dst, List *src) void Lst_PrependAll(List *dst, List *src) { - ListNode *node; + ListNode *ln; - for (node = src->last; node != NULL; node = node->prev) - Lst_Prepend(dst, node->datum); + for (ln = src->last; ln != NULL; ln = ln->prev) + Lst_Prepend(dst, ln->datum); } /* Copy the element data from src to the end of dst. */ void Lst_AppendAll(List *dst, List *src) { - ListNode *node; + ListNode *ln; - for (node = src->first; node != NULL; node = node->next) - Lst_Append(dst, node->datum); + for (ln = src->first; ln != NULL; ln = ln->next) + Lst_Append(dst, ln->datum); } /* diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c index 785a325642f5..e732cffb7c22 100644 --- a/usr.bin/make/targ.c +++ b/usr.bin/make/targ.c @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.148 2020/11/29 01:05:08 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.149 2020/12/04 14:39:56 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.148 2020/11/29 01:05:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.149 2020/12/04 14:39:56 rillig Exp $"); /* * All target nodes that appeared on the left-hand side of one of the @@ -306,19 +306,23 @@ GNode *Targ_GetEndNode(void) return endNode; } -/* Return the named nodes, creating them as necessary. */ +/* Add the named nodes to the list, creating them as necessary. */ void -Targ_FindList(GNodeList *nodes, StringList *names) +Targ_FindList(GNodeList *gns, StringList *names) { StringListNode *ln; + for (ln = names->first; ln != NULL; ln = ln->next) { const char *name = ln->datum; GNode *gn = Targ_GetNode(name); - Lst_Append(nodes, gn); + Lst_Append(gns, gn); } } -/* Return true if should ignore errors when creating gn. */ +/* + * Return true if errors from shell commands should be ignored when + * creating gn. + */ Boolean Targ_Ignore(const GNode *gn) { @@ -356,10 +360,10 @@ Targ_SetMain(GNode *gn) static void PrintNodeNames(GNodeList *gnodes) { - GNodeListNode *node; + GNodeListNode *ln; - for (node = gnodes->first; node != NULL; node = node->next) { - GNode *gn = node->datum; + for (ln = gnodes->first; ln != NULL; ln = ln->next) { + GNode *gn = ln->datum; debug_printf(" %s%s", gn->name, gn->cohort_num); } }