Module Name:    src
Committed By:   rillig
Date:           Mon Dec 27 21:21:17 UTC 2021

Modified Files:
        src/usr.bin/make: cond.c main.c parse.c

Log Message:
make: rename local variables to be simpler

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/make/cond.c
cvs rdiff -u -r1.551 -r1.552 src/usr.bin/make/main.c
cvs rdiff -u -r1.586 -r1.587 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/cond.c
diff -u src/usr.bin/make/cond.c:1.307 src/usr.bin/make/cond.c:1.308
--- src/usr.bin/make/cond.c:1.307	Mon Dec 27 18:54:19 2021
+++ src/usr.bin/make/cond.c	Mon Dec 27 21:21:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.307 2021/12/27 18:54:19 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.308 2021/12/27 21:21:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.307 2021/12/27 18:54:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.308 2021/12/27 21:21:17 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -399,7 +399,7 @@ CondParser_StringExpr(CondParser *par, c
 		      Buffer *buf, FStr *inout_str)
 {
 	VarEvalMode emode;
-	const char *nested_p;
+	const char *p;
 	bool atStart;
 	VarParseResult parseResult;
 
@@ -407,9 +407,9 @@ CondParser_StringExpr(CondParser *par, c
 	    : doEval ? VARE_UNDEFERR
 	    : VARE_PARSE_ONLY;
 
-	nested_p = par->p;
-	atStart = nested_p == start;
-	parseResult = Var_Parse(&nested_p, SCOPE_CMDLINE, emode, inout_str);
+	p = par->p;
+	atStart = p == start;
+	parseResult = Var_Parse(&p, SCOPE_CMDLINE, emode, inout_str);
 	/* TODO: handle errors */
 	if (inout_str->str == var_Error) {
 		if (parseResult == VPR_ERR) {
@@ -433,7 +433,7 @@ CondParser_StringExpr(CondParser *par, c
 		*inout_str = FStr_InitRefer(NULL);
 		return false;
 	}
-	par->p = nested_p;
+	par->p = p;
 
 	/*
 	 * If the '$' started the string literal (which means no quotes), and

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.551 src/usr.bin/make/main.c:1.552
--- src/usr.bin/make/main.c:1.551	Mon Dec 27 20:59:59 2021
+++ src/usr.bin/make/main.c	Mon Dec 27 21:21:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.551 2021/12/27 20:59:59 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.552 2021/12/27 21:21:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.551 2021/12/27 20:59:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.552 2021/12/27 21:21:17 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -1429,21 +1429,21 @@ main_Init(int argc, char **argv)
 
 	/* Set some other useful variables. */
 	{
-		char tmp[64], *ep = getenv(MAKE_LEVEL_ENV);
+		char buf[64], *ep = getenv(MAKE_LEVEL_ENV);
 
 		makelevel = ep != NULL && ep[0] != '\0' ? atoi(ep) : 0;
 		if (makelevel < 0)
 			makelevel = 0;
-		snprintf(tmp, sizeof tmp, "%d", makelevel);
-		Global_Set(MAKE_LEVEL, tmp);
-		snprintf(tmp, sizeof tmp, "%u", myPid);
-		Global_Set(".MAKE.PID", tmp);
-		snprintf(tmp, sizeof tmp, "%u", getppid());
-		Global_Set(".MAKE.PPID", tmp);
-		snprintf(tmp, sizeof tmp, "%u", getuid());
-		Global_Set(".MAKE.UID", tmp);
-		snprintf(tmp, sizeof tmp, "%u", getgid());
-		Global_Set(".MAKE.GID", tmp);
+		snprintf(buf, sizeof buf, "%d", makelevel);
+		Global_Set(MAKE_LEVEL, buf);
+		snprintf(buf, sizeof buf, "%u", myPid);
+		Global_Set(".MAKE.PID", buf);
+		snprintf(buf, sizeof buf, "%u", getppid());
+		Global_Set(".MAKE.PPID", buf);
+		snprintf(buf, sizeof buf, "%u", getuid());
+		Global_Set(".MAKE.UID", buf);
+		snprintf(buf, sizeof buf, "%u", getgid());
+		Global_Set(".MAKE.GID", buf);
 	}
 	if (makelevel > 0) {
 		char pn[1024];

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.586 src/usr.bin/make/parse.c:1.587
--- src/usr.bin/make/parse.c:1.586	Mon Dec 27 19:06:07 2021
+++ src/usr.bin/make/parse.c	Mon Dec 27 21:21:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.586 2021/12/27 19:06:07 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.587 2021/12/27 21:21:17 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.586 2021/12/27 19:06:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.587 2021/12/27 21:21:17 rillig Exp $");
 
 /* types and constants */
 
@@ -842,7 +842,7 @@ ParseDependencySourceWait(bool isSpecial
 }
 
 static bool
-ParseDependencySourceKeyword(const char *src, ParseSpecial specType)
+ParseDependencySourceKeyword(const char *src, ParseSpecial special)
 {
 	int keywd;
 	GNodeType op;
@@ -860,7 +860,7 @@ ParseDependencySourceKeyword(const char 
 		return true;
 	}
 	if (parseKeywords[keywd].spec == SP_WAIT) {
-		ParseDependencySourceWait(specType != SP_NOT);
+		ParseDependencySourceWait(special != SP_NOT);
 		return true;
 	}
 	return false;
@@ -916,7 +916,7 @@ ParseDependencySourceOrder(const char *s
 
 static void
 ParseDependencySourceOther(const char *src, GNodeType tOp,
-			   ParseSpecial specType)
+			   ParseSpecial special)
 {
 	GNode *gn;
 
@@ -938,7 +938,7 @@ ParseDependencySourceOther(const char *s
 	if (tOp != OP_NONE)
 		gn->type |= tOp;
 	else
-		LinkToTargets(gn, specType != SP_NOT);
+		LinkToTargets(gn, special != SP_NOT);
 }
 
 /*
@@ -953,17 +953,17 @@ ParseDependencySourceOther(const char *s
  *	src		name of the source to handle
  */
 static void
-ParseDependencySource(GNodeType tOp, const char *src, ParseSpecial specType)
+ParseDependencySource(GNodeType tOp, const char *src, ParseSpecial special)
 {
-	if (ParseDependencySourceKeyword(src, specType))
+	if (ParseDependencySourceKeyword(src, special))
 		return;
 
-	if (specType == SP_MAIN)
+	if (special == SP_MAIN)
 		ParseDependencySourceMain(src);
-	else if (specType == SP_ORDER)
+	else if (special == SP_ORDER)
 		ParseDependencySourceOrder(src);
 	else
-		ParseDependencySourceOther(src, tOp, specType);
+		ParseDependencySourceOther(src, tOp, special);
 }
 
 /*
@@ -1060,11 +1060,11 @@ ParseDependencyTargetWord(const char **p
  * See the tests deptgt-*.mk.
  */
 static void
-ParseDependencyTargetSpecial(ParseSpecial *inout_specType,
+ParseDependencyTargetSpecial(ParseSpecial *inout_special,
 			     const char *targetName,
 			     SearchPathList **inout_paths)
 {
-	switch (*inout_specType) {
+	switch (*inout_special) {
 	case SP_PATH:
 		if (*inout_paths == NULL)
 			*inout_paths = Lst_New();
@@ -1076,7 +1076,7 @@ ParseDependencyTargetSpecial(ParseSpecia
 		 * .MAIN node.
 		 */
 		if (!Lst_IsEmpty(&opts.create))
-			*inout_specType = SP_NOT;
+			*inout_special = SP_NOT;
 		break;
 	case SP_BEGIN:
 	case SP_END:
@@ -1146,11 +1146,11 @@ ParseDependencyTargetPath(const char *su
 }
 
 /*
- * See if it's a special target and if so set specType to match it.
+ * See if it's a special target and if so set inout_special to match it.
  */
 static bool
 ParseDependencyTarget(const char *targetName,
-		      ParseSpecial *inout_specType,
+		      ParseSpecial *inout_special,
 		      GNodeType *out_tOp, SearchPathList **inout_paths)
 {
 	int keywd;
@@ -1164,20 +1164,20 @@ ParseDependencyTarget(const char *target
 	 */
 	keywd = ParseFindKeyword(targetName);
 	if (keywd != -1) {
-		if (*inout_specType == SP_PATH &&
+		if (*inout_special == SP_PATH &&
 		    parseKeywords[keywd].spec != SP_PATH) {
 			Parse_Error(PARSE_FATAL, "Mismatched special targets");
 			return false;
 		}
 
-		*inout_specType = parseKeywords[keywd].spec;
+		*inout_special = parseKeywords[keywd].spec;
 		*out_tOp = parseKeywords[keywd].op;
 
-		ParseDependencyTargetSpecial(inout_specType, targetName,
+		ParseDependencyTargetSpecial(inout_special, targetName,
 		    inout_paths);
 
 	} else if (strncmp(targetName, ".PATH", 5) == 0) {
-		*inout_specType = SP_PATH;
+		*inout_special = SP_PATH;
 		if (!ParseDependencyTargetPath(targetName + 5, inout_paths))
 			return false;
 	}
@@ -1185,7 +1185,7 @@ ParseDependencyTarget(const char *target
 }
 
 static void
-ParseDependencyTargetMundane(char *targetName, StringList *curTargs)
+ParseDependencyTargetMundane(char *targetName, StringList *targetNames)
 {
 	if (Dir_HasWildcards(targetName)) {
 		/*
@@ -1196,7 +1196,7 @@ ParseDependencyTargetMundane(char *targe
 		 */
 		SearchPath *emptyPath = SearchPath_New();
 
-		SearchPath_Expand(emptyPath, targetName, curTargs);
+		SearchPath_Expand(emptyPath, targetName, targetNames);
 
 		SearchPath_Free(emptyPath);
 	} else {
@@ -1204,13 +1204,13 @@ ParseDependencyTargetMundane(char *targe
 		 * No wildcards, but we want to avoid code duplication,
 		 * so create a list with the word on it.
 		 */
-		Lst_Append(curTargs, targetName);
+		Lst_Append(targetNames, targetName);
 	}
 
 	/* Apply the targets. */
 
-	while (!Lst_IsEmpty(curTargs)) {
-		char *targName = Lst_Dequeue(curTargs);
+	while (!Lst_IsEmpty(targetNames)) {
+		char *targName = Lst_Dequeue(targetNames);
 		GNode *gn = Suff_IsTransform(targName)
 		    ? Suff_AddTransform(targName)
 		    : Targ_GetNode(targName);
@@ -1241,9 +1241,9 @@ ParseDependencyTargetExtraWarn(char **pp
 }
 
 static void
-ParseDependencyCheckSpec(ParseSpecial specType)
+ParseDependencyCheckSpecial(ParseSpecial special)
 {
-	switch (specType) {
+	switch (special) {
 	case SP_DEFAULT:
 	case SP_STALE:
 	case SP_BEGIN:
@@ -1304,9 +1304,9 @@ ClearPaths(SearchPathList *paths)
  *	a .PATH removes all directories from the search path(s).
  */
 static void
-ParseDependencySourcesEmpty(ParseSpecial specType, SearchPathList *paths)
+ParseDependencySourcesEmpty(ParseSpecial special, SearchPathList *paths)
 {
-	switch (specType) {
+	switch (special) {
 	case SP_SUFFIXES:
 		Suff_ClearSuffixes();
 		break;
@@ -1370,10 +1370,10 @@ AddToPaths(const char *dir, SearchPathLi
  * and will cause make to do a new chdir to that path.
  */
 static void
-ParseDependencySourceSpecial(ParseSpecial specType, char *word,
+ParseDependencySourceSpecial(ParseSpecial special, char *word,
 			     SearchPathList *paths)
 {
-	switch (specType) {
+	switch (special) {
 	case SP_SUFFIXES:
 		Suff_AddSuffix(word, &mainNode);
 		break;
@@ -1401,10 +1401,10 @@ static bool
 ParseDependencyTargets(char **inout_cp,
 		       char **inout_line,
 		       const char *lstart,
-		       ParseSpecial *inout_specType,
+		       ParseSpecial *inout_special,
 		       GNodeType *inout_tOp,
 		       SearchPathList **inout_paths,
-		       StringList *curTargs)
+		       StringList *targetNames)
 {
 	char *cp;
 	char *tgt = *inout_line;
@@ -1461,7 +1461,7 @@ ParseDependencyTargets(char **inout_cp,
 		savec = *cp;
 		*cp = '\0';
 
-		if (!ParseDependencyTarget(tgt, inout_specType, inout_tOp,
+		if (!ParseDependencyTarget(tgt, inout_special, inout_tOp,
 		    inout_paths))
 			return false;
 
@@ -1469,9 +1469,9 @@ ParseDependencyTargets(char **inout_cp,
 		 * Have word in line. Get or create its node and stick it at
 		 * the end of the targets list
 		 */
-		if (*inout_specType == SP_NOT && *tgt != '\0')
-			ParseDependencyTargetMundane(tgt, curTargs);
-		else if (*inout_specType == SP_PATH && *tgt != '.' &&
+		if (*inout_special == SP_NOT && *tgt != '\0')
+			ParseDependencyTargetMundane(tgt, targetNames);
+		else if (*inout_special == SP_PATH && *tgt != '.' &&
 			 *tgt != '\0')
 			Parse_Error(PARSE_WARNING, "Extra target (%s) ignored",
 			    tgt);
@@ -1483,7 +1483,7 @@ ParseDependencyTargets(char **inout_cp,
 		 * If it is a special type and not .PATH, it's the only target
 		 * we allow on this line.
 		 */
-		if (*inout_specType != SP_NOT && *inout_specType != SP_PATH)
+		if (*inout_special != SP_NOT && *inout_special != SP_PATH)
 			ParseDependencyTargetExtraWarn(&cp, lstart);
 		else
 			pp_skip_whitespace(&cp);
@@ -1503,7 +1503,7 @@ ParseDependencyTargets(char **inout_cp,
 
 static void
 ParseDependencySourcesSpecial(char *start, char *end,
-			      ParseSpecial specType, SearchPathList *paths)
+			      ParseSpecial special, SearchPathList *paths)
 {
 	char savec;
 
@@ -1512,7 +1512,7 @@ ParseDependencySourcesSpecial(char *star
 			end++;
 		savec = *end;
 		*end = '\0';
-		ParseDependencySourceSpecial(specType, start, paths);
+		ParseDependencySourceSpecial(special, start, paths);
 		*end = savec;
 		if (savec != '\0')
 			end++;
@@ -1523,7 +1523,7 @@ ParseDependencySourcesSpecial(char *star
 
 static bool
 ParseDependencySourcesMundane(char *start, char *end,
-			      ParseSpecial specType, GNodeType tOp)
+			      ParseSpecial special, GNodeType tOp)
 {
 	while (*start != '\0') {
 		/*
@@ -1556,7 +1556,7 @@ ParseDependencySourcesMundane(char *star
 
 			while (!Lst_IsEmpty(&sources)) {
 				GNode *gn = Lst_Dequeue(&sources);
-				ParseDependencySource(tOp, gn->name, specType);
+				ParseDependencySource(tOp, gn->name, special);
 			}
 			Lst_Done(&sources);
 			end = start;
@@ -1566,7 +1566,7 @@ ParseDependencySourcesMundane(char *star
 				end++;
 			}
 
-			ParseDependencySource(tOp, start, specType);
+			ParseDependencySource(tOp, start, special);
 		}
 		pp_skip_whitespace(&end);
 		start = end;
@@ -1581,44 +1581,44 @@ ParseDependencySourcesMundane(char *star
  */
 static void
 ParseDependencySources(char *line, char *cp, GNodeType tOp,
-		       ParseSpecial specType, SearchPathList **inout_paths)
+		       ParseSpecial special, SearchPathList **inout_paths)
 {
 	if (line[0] == '\0') {
-		ParseDependencySourcesEmpty(specType, *inout_paths);
-	} else if (specType == SP_MFLAGS) {
+		ParseDependencySourcesEmpty(special, *inout_paths);
+	} else if (special == SP_MFLAGS) {
 		Main_ParseArgLine(line);
 		/*
 		 * Set the initial character to a null-character so the loop
 		 * to get sources won't get anything.
 		 */
 		*line = '\0';
-	} else if (specType == SP_SHELL) {
+	} else if (special == SP_SHELL) {
 		if (!Job_ParseShell(line)) {
 			Parse_Error(PARSE_FATAL,
 			    "improper shell specification");
 			return;
 		}
 		*line = '\0';
-	} else if (specType == SP_NOTPARALLEL || specType == SP_SINGLESHELL ||
-		   specType == SP_DELETE_ON_ERROR) {
+	} else if (special == SP_NOTPARALLEL || special == SP_SINGLESHELL ||
+		   special == SP_DELETE_ON_ERROR) {
 		*line = '\0';
 	}
 
 	/* Now go for the sources. */
-	if (specType == SP_SUFFIXES || specType == SP_PATH ||
-	    specType == SP_INCLUDES || specType == SP_LIBS ||
-	    specType == SP_NULL || specType == SP_OBJDIR) {
-		ParseDependencySourcesSpecial(line, cp, specType,
+	if (special == SP_SUFFIXES || special == SP_PATH ||
+	    special == SP_INCLUDES || special == SP_LIBS ||
+	    special == SP_NULL || special == SP_OBJDIR) {
+		ParseDependencySourcesSpecial(line, cp, special,
 		    *inout_paths);
 		if (*inout_paths != NULL) {
 			Lst_Free(*inout_paths);
 			*inout_paths = NULL;
 		}
-		if (specType == SP_PATH)
+		if (special == SP_PATH)
 			Dir_SetPATH();
 	} else {
 		assert(*inout_paths == NULL);
-		if (!ParseDependencySourcesMundane(line, cp, specType, tOp))
+		if (!ParseDependencySourcesMundane(line, cp, special, tOp))
 			return;
 	}
 
@@ -1657,14 +1657,14 @@ ParseDependency(char *line)
 				 * of .PATH targets */
 	GNodeType tOp;		/* operator from special target */
 	/* target names to be found and added to the targets list */
-	StringList curTargs = LST_INIT;
+	StringList targetNames = LST_INIT;
 	char *lstart = line;
 
 	/*
 	 * In special targets, the children are linked as children of the
 	 * parent but not vice versa.
 	 */
-	ParseSpecial specType = SP_NOT;
+	ParseSpecial special = SP_NOT;
 
 	DEBUG1(PARSE, "ParseDependency(%s)\n", line);
 	tOp = OP_NONE;
@@ -1672,19 +1672,19 @@ ParseDependency(char *line)
 	paths = NULL;
 
 	/* XXX: don't use 'line' as an iterator variable */
-	if (!ParseDependencyTargets(&cp, &line, lstart, &specType, &tOp,
-	    &paths, &curTargs))
+	if (!ParseDependencyTargets(&cp, &line, lstart, &special, &tOp,
+	    &paths, &targetNames))
 		goto out;
 
 	/*
 	 * Don't need the list of target names anymore.
 	 * The targets themselves are now in the global variable 'targets'.
 	 */
-	Lst_Done(&curTargs);
-	Lst_Init(&curTargs);
+	Lst_Done(&targetNames);
+	Lst_Init(&targetNames);
 
 	if (!Lst_IsEmpty(targets))
-		ParseDependencyCheckSpec(specType);
+		ParseDependencyCheckSpecial(special);
 
 	op = ParseDependencyOp(&cp);
 	ApplyDependencyOperator(op);
@@ -1692,12 +1692,12 @@ ParseDependency(char *line)
 	pp_skip_whitespace(&cp);
 	line = cp;		/* XXX: 'line' is an inappropriate name */
 
-	ParseDependencySources(line, cp, tOp, specType, &paths);
+	ParseDependencySources(line, cp, tOp, special, &paths);
 
 out:
 	if (paths != NULL)
 		Lst_Free(paths);
-	Lst_Done(&curTargs);
+	Lst_Done(&targetNames);
 }
 
 typedef struct VarAssignParsed {

Reply via email to