Module Name:    src
Committed By:   rillig
Date:           Tue Oct 27 08:00:20 UTC 2020

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

Log Message:
make(1): extract CleanUp from main

This makes it a bit easier to spot the main task of the main function,
which is the runTargets call.


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/usr.bin/make/main.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.401 src/usr.bin/make/main.c:1.402
--- src/usr.bin/make/main.c:1.401	Tue Oct 27 07:51:43 2020
+++ src/usr.bin/make/main.c	Tue Oct 27 08:00:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.401 2020/10/27 07:51:43 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.402 2020/10/27 08:00:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.401 2020/10/27 07:51:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.402 2020/10/27 08:00:20 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -1172,6 +1172,39 @@ InitVpath(void)
 	free(vpath);
 }
 
+static void
+CleanUp(void)
+{
+#ifdef CLEANUP
+	Lst_Destroy(opts.variables, free);
+	Lst_Free(opts.makefiles);	/* don't free, may be used in GNodes */
+	Lst_Destroy(opts.create, free);
+#endif
+
+	/* print the graph now it's been processed if the user requested it */
+	if (DEBUG(GRAPH2))
+		Targ_PrintGraph(2);
+
+	Trace_Log(MAKEEND, 0);
+
+	if (enterFlagObj)
+		printf("%s: Leaving directory `%s'\n", progname, objdir);
+	if (opts.enterFlag)
+		printf("%s: Leaving directory `%s'\n", progname, curdir);
+
+#ifdef USE_META
+	meta_finish();
+#endif
+	Suff_End();
+	Targ_End();
+	Arch_End();
+	Var_End();
+	Parse_End();
+	Dir_End();
+	Job_End();
+	Trace_End();
+}
+
 /*-
  * main --
  *	The main function, for obvious reasons. Initializes variables
@@ -1527,34 +1560,7 @@ main(int argc, char **argv)
 		outOfDate = runTargets();
 	}
 
-#ifdef CLEANUP
-	Lst_Destroy(opts.variables, free);
-	Lst_Free(opts.makefiles);	/* don't free, may be used in GNodes */
-	Lst_Destroy(opts.create, free);
-#endif
-
-	/* print the graph now it's been processed if the user requested it */
-	if (DEBUG(GRAPH2))
-		Targ_PrintGraph(2);
-
-	Trace_Log(MAKEEND, 0);
-
-	if (enterFlagObj)
-		printf("%s: Leaving directory `%s'\n", progname, objdir);
-	if (opts.enterFlag)
-		printf("%s: Leaving directory `%s'\n", progname, curdir);
-
-#ifdef USE_META
-	meta_finish();
-#endif
-	Suff_End();
-	Targ_End();
-	Arch_End();
-	Var_End();
-	Parse_End();
-	Dir_End();
-	Job_End();
-	Trace_End();
+	CleanUp();
 
 	return outOfDate ? 1 : 0;
 }

Reply via email to