Module Name:    src
Committed By:   rillig
Date:           Sun Jul  7 09:54:13 UTC 2024

Modified Files:
        src/usr.bin/make: main.c make.h targ.c var.c

Log Message:
make: move initialization of variable scopes to targ.c

The variable scopes are freed by Targ_End, so initialize them there as
well.  Separate printing statistics and freeing memory, which makes
Var_End unnecessary.


To generate a diff of this commit:
cvs rdiff -u -r1.629 -r1.630 src/usr.bin/make/main.c
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/make.h
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/targ.c
cvs rdiff -u -r1.1133 -r1.1134 src/usr.bin/make/var.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/main.c
diff -u src/usr.bin/make/main.c:1.629 src/usr.bin/make/main.c:1.630
--- src/usr.bin/make/main.c:1.629	Sun Jul  7 07:50:57 2024
+++ src/usr.bin/make/main.c	Sun Jul  7 09:54:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.629 2024/07/07 07:50:57 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.630 2024/07/07 09:54:12 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.629 2024/07/07 07:50:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -1342,7 +1342,6 @@ main_Init(int argc, char **argv)
 
 	/* Just in case MAKEOBJDIR wants us to do something tricky. */
 	Targ_Init();
-	Var_Init();
 	Global_Set_ReadOnly(".MAKE.OS", utsname.sysname);
 	Global_Set("MACHINE", machine);
 	Global_Set("MACHINE_ARCH", machine_arch);
@@ -1581,15 +1580,15 @@ main_CleanUp(void)
 	if (opts.enterFlag)
 		printf("%s: Leaving directory `%s'\n", progname, curdir);
 
+	Var_Stats();
+	Targ_Stats();
+
 #ifdef USE_META
 	meta_finish();
 #endif
 #ifdef CLEANUP
 	Suff_End();
-#endif
-	Var_End();
 	Targ_End();
-#ifdef CLEANUP
 	Arch_End();
 	Parse_End();
 	Dir_End();

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.341 src/usr.bin/make/make.h:1.342
--- src/usr.bin/make/make.h:1.341	Sun Jul  7 07:50:57 2024
+++ src/usr.bin/make/make.h	Sun Jul  7 09:54:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.341 2024/07/07 07:50:57 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.342 2024/07/07 09:54:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -931,8 +931,6 @@ void Parse_RegisterCommand(char *cmd MAK
 #endif
 
 /* var.c */
-void Var_Init(void);
-void Var_End(void);
 
 typedef enum VarEvalMode {
 

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.183 src/usr.bin/make/targ.c:1.184
--- src/usr.bin/make/targ.c:1.183	Sat May 25 21:07:48 2024
+++ src/usr.bin/make/targ.c	Sun Jul  7 09:54:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.184 2024/07/07 09:54:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.184 2024/07/07 09:54:12 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -126,23 +126,24 @@ void
 Targ_Init(void)
 {
 	HashTable_Init(&allTargetsByName);
+	SCOPE_INTERNAL = GNode_New("Internal");
+	SCOPE_GLOBAL = GNode_New("Global");
+	SCOPE_CMDLINE = GNode_New("Command");
 }
 
+#ifdef CLEANUP
 void
 Targ_End(void)
 {
-#ifdef CLEANUP
 	GNodeListNode *ln;
-#endif
-	Targ_Stats();
-#ifdef CLEANUP
+
 	Lst_Done(&allTargets);
 	HashTable_Done(&allTargetsByName);
 	for (ln = allNodes.first; ln != NULL; ln = ln->next)
 		GNode_Free(ln->datum);
 	Lst_Done(&allNodes);
-#endif
 }
+#endif
 
 void
 Targ_Stats(void)

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1133 src/usr.bin/make/var.c:1.1134
--- src/usr.bin/make/var.c:1.1133	Fri Jul  5 20:01:52 2024
+++ src/usr.bin/make/var.c	Sun Jul  7 09:54:12 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1133 2024/07/05 20:01:52 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -76,10 +76,6 @@
  * expressions like ${VAR}, ${VAR:Modifiers}, ${${VARNAME}} or ${VAR:${MODS}}.
  *
  * Interface:
- *	Var_Init	Initialize this module.
- *
- *	Var_End		Clean up the module.
- *
  *	Var_Set
  *	Var_SetExpand	Set the value of the variable, creating it if
  *			necessary.
@@ -132,7 +128,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1133 2024/07/05 20:01:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4809,22 +4805,6 @@ Var_Expand(FStr *str, GNode *scope, VarE
 	*str = FStr_InitOwn(expanded);
 }
 
-/* Initialize the variables module. */
-void
-Var_Init(void)
-{
-	SCOPE_INTERNAL = GNode_New("Internal");
-	SCOPE_GLOBAL = GNode_New("Global");
-	SCOPE_CMDLINE = GNode_New("Command");
-}
-
-/* Clean up the variables module. */
-void
-Var_End(void)
-{
-	Var_Stats();
-}
-
 void
 Var_Stats(void)
 {

Reply via email to