Module Name: src Committed By: rillig Date: Tue Dec 28 16:59:09 UTC 2021
Modified Files: src/usr.bin/make: parse.c Log Message: make: reduce scope of the list of wildcard target names The list is only used when a single target name is parsed, in case the name contains wildcards. There is no need to keep it any longer or reuse it. Clean up outdated and redundant comments. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.594 -r1.595 src/usr.bin/make/parse.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/parse.c diff -u src/usr.bin/make/parse.c:1.594 src/usr.bin/make/parse.c:1.595 --- src/usr.bin/make/parse.c:1.594 Tue Dec 28 16:35:43 2021 +++ src/usr.bin/make/parse.c Tue Dec 28 16:59:09 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $"); /* types and constants */ @@ -1177,32 +1177,19 @@ ParseDependencyTarget(const char *target } static void -ParseDependencyTargetMundane(char *targetName, StringList *targetNames) +ParseDependencyTargetMundane(char *targetName) { + StringList targetNames = LST_INIT; + if (Dir_HasWildcards(targetName)) { - /* - * Targets are to be sought only in the current directory, - * so create an empty path for the thing. Note we need to - * use Dir_Destroy in the destruction of the path as the - * Dir module could have added a directory to the path... - */ SearchPath *emptyPath = SearchPath_New(); - - SearchPath_Expand(emptyPath, targetName, targetNames); - + SearchPath_Expand(emptyPath, targetName, &targetNames); SearchPath_Free(emptyPath); - } else { - /* - * No wildcards, but we want to avoid code duplication, - * so create a list with the word on it. - */ - Lst_Append(targetNames, targetName); - } - - /* Apply the targets. */ + } else + Lst_Append(&targetNames, targetName); - while (!Lst_IsEmpty(targetNames)) { - char *targName = Lst_Dequeue(targetNames); + while (!Lst_IsEmpty(&targetNames)) { + char *targName = Lst_Dequeue(&targetNames); GNode *gn = Suff_IsTransform(targName) ? Suff_AddTransform(targName) : Targ_GetNode(targName); @@ -1395,8 +1382,7 @@ ParseDependencyTargets(char **inout_cp, const char *lstart, ParseSpecial *inout_special, GNodeType *inout_targetAttr, - SearchPathList **inout_paths, - StringList *targetNames) + SearchPathList **inout_paths) { char *cp; char *tgt = *inout_line; @@ -1462,7 +1448,7 @@ ParseDependencyTargets(char **inout_cp, * the end of the targets list */ if (*inout_special == SP_NOT && *tgt != '\0') - ParseDependencyTargetMundane(tgt, targetNames); + ParseDependencyTargetMundane(tgt); else if (*inout_special == SP_PATH && *tgt != '.' && *tgt != '\0') Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", @@ -1650,9 +1636,7 @@ ParseDependency(char *line) SearchPathList *paths; /* search paths to alter when parsing a list * of .PATH targets */ GNodeType targetAttr; /* from special sources */ - /* target names to be found and added to the targets list */ - StringList targetNames = LST_INIT; - char *lstart = line; + const char *lstart = line; /* * In special targets, the children are linked as children of the @@ -1667,16 +1651,9 @@ ParseDependency(char *line) /* XXX: don't use 'line' as an iterator variable */ if (!ParseDependencyTargets(&cp, &line, lstart, &special, - &targetAttr, &paths, &targetNames)) + &targetAttr, &paths)) goto out; - /* - * Don't need the list of target names anymore. - * The targets themselves are now in the global variable 'targets'. - */ - Lst_Done(&targetNames); - Lst_Init(&targetNames); - if (!Lst_IsEmpty(targets)) ParseDependencyCheckSpecial(special); @@ -1691,7 +1668,6 @@ ParseDependency(char *line) out: if (paths != NULL) Lst_Free(paths); - Lst_Done(&targetNames); } typedef struct VarAssignParsed {