Module Name:    src
Committed By:   rillig
Date:           Mon Sep 28 22:23:35 UTC 2020

Modified Files:
        src/usr.bin/make: arch.c compat.c dir.c job.c make.c make.h meta.c
            parse.c suff.c targ.c var.c

Log Message:
make(1): make debug logging simpler

This avoids referring to the debug_file variable in many places where
this implementation detail is not necessary.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.bin/make/arch.c
cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/compat.c
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/make/dir.c
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/job.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/make/make.c
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/make.h
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/make/meta.c
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/parse.c
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/suff.c
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/targ.c
cvs rdiff -u -r1.549 -r1.550 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/arch.c
diff -u src/usr.bin/make/arch.c:1.125 src/usr.bin/make/arch.c:1.126
--- src/usr.bin/make/arch.c:1.125	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/arch.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.125 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.126 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -134,7 +134,7 @@
 #include    "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.125 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.126 2020/09/28 22:23:35 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -612,7 +612,7 @@ ArchStatMember(const char *archive, cons
 		if (fseek(arch, -elen, SEEK_CUR) != 0)
 			goto badarch;
 		if (DEBUG(ARCH) || DEBUG(MAKE)) {
-		    fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
+		    debug_printf("ArchStat: Extended format entry for %s\n", memName);
 		}
 	    }
 #endif
@@ -840,7 +840,7 @@ ArchFindMember(const char *archive, cons
 		}
 		ename[elen] = '\0';
 		if (DEBUG(ARCH) || DEBUG(MAKE)) {
-		    fprintf(debug_file, "ArchFind: Extended format entry for %s\n", ename);
+		    debug_printf("ArchFind: Extended format entry for %s\n", ename);
 		}
 		if (strncmp(ename, member, len) == 0) {
 			/* Found as extended name */
@@ -1114,7 +1114,7 @@ Arch_LibOODate(GNode *gn)
 	    modTimeTOC = (int)strtol(arhPtr->ar_date, NULL, 10);
 
 	    if (DEBUG(ARCH) || DEBUG(MAKE)) {
-		fprintf(debug_file, "%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
+		debug_printf("%s modified %s...", RANLIBMAG, Targ_FmtTime(modTimeTOC));
 	    }
 	    oodate = (gn->cmgn == NULL || gn->cmgn->mtime > modTimeTOC);
 	} else {
@@ -1122,7 +1122,7 @@ Arch_LibOODate(GNode *gn)
 	     * A library w/o a table of contents is out-of-date
 	     */
 	    if (DEBUG(ARCH) || DEBUG(MAKE)) {
-		fprintf(debug_file, "No t.o.c....");
+		debug_printf("No t.o.c....");
 	    }
 	    oodate = TRUE;
 	}

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.157 src/usr.bin/make/compat.c:1.158
--- src/usr.bin/make/compat.c:1.157	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/compat.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.157 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.158 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -99,7 +99,7 @@
 #include    "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.157 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.158 2020/09/28 22:23:35 rillig Exp $");
 
 static GNode	    *curTarg = NULL;
 static void CompatInterrupt(int);
@@ -403,19 +403,19 @@ Compat_RunCommand(const char *cmdp, stru
 	if (status != 0) {
 	    if (DEBUG(ERROR)) {
 		const char *cp;
-		fprintf(debug_file, "\n*** Failed target:  %s\n*** Failed command: ",
-		    gn->name);
+		debug_printf("\n*** Failed target:  %s\n*** Failed command: ",
+			     gn->name);
 		for (cp = cmd; *cp; ) {
 		    if (ch_isspace(*cp)) {
-			fprintf(debug_file, " ");
+			debug_printf(" ");
 			while (ch_isspace(*cp))
 			    cp++;
 		    } else {
-			fprintf(debug_file, "%c", *cp);
+			debug_printf("%c", *cp);
 			cp++;
 		    }
 		}
-		fprintf(debug_file, "\n");
+		debug_printf("\n");
 	    }
 	    printf("*** Error code %d", status);
 	}

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.151 src/usr.bin/make/dir.c:1.152
--- src/usr.bin/make/dir.c:1.151	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/dir.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.151 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.152 2020/09/28 22:23:35 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.151 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.152 2020/09/28 22:23:35 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -755,9 +755,9 @@ DirPrintExpansions(StringList *words)
     StringListNode *ln;
     for (ln = words->first; ln != NULL; ln = ln->next) {
 	const char *word = ln->datum;
-	fprintf(debug_file, "%s ", word);
+	debug_printf("%s ", word);
     }
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
 }
 
 /*-
@@ -1713,17 +1713,16 @@ Dir_PrintDirectories(void)
 {
     CachedDirListNode *ln;
 
-    fprintf(debug_file, "#*** Directory Cache:\n");
-    fprintf(debug_file,
-	    "# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
-	    hits, misses, nearmisses, bigmisses,
-	    percentage(hits, hits + bigmisses + nearmisses));
-    fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
+    debug_printf("#*** Directory Cache:\n");
+    debug_printf("# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
+		 hits, misses, nearmisses, bigmisses,
+		 percentage(hits, hits + bigmisses + nearmisses));
+    debug_printf("# %-20s referenced\thits\n", "directory");
 
     for (ln = openDirectories->first; ln != NULL; ln = ln->next) {
 	CachedDir *dir = ln->datum;
-	fprintf(debug_file, "# %-20s %10d\t%4d\n", dir->name, dir->refCount,
-		dir->hits);
+	debug_printf("# %-20s %10d\t%4d\n", dir->name, dir->refCount,
+		     dir->hits);
     }
 }
 
@@ -1733,6 +1732,6 @@ Dir_PrintPath(SearchPath *path)
     SearchPathNode *node;
     for (node = path->first; node != NULL; node = node->next) {
 	const CachedDir *dir = node->datum;
-	fprintf(debug_file, "%s ", dir->name);
+	debug_printf("%s ", dir->name);
     }
 }

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.250 src/usr.bin/make/job.c:1.251
--- src/usr.bin/make/job.c:1.250	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/job.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.250 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.251 2020/09/28 22:23:35 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.250 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.251 2020/09/28 22:23:35 rillig Exp $");
 
 # define STATIC static
 
@@ -356,9 +356,9 @@ job_table_dump(const char *where)
 {
     Job *job;
 
-    fprintf(debug_file, "job table @ %s\n", where);
+    debug_printf("job table @ %s\n", where);
     for (job = job_table; job < job_table_end; job++) {
-	fprintf(debug_file, "job %d, status %d, flags %d, pid %d\n",
+	debug_printf("job %d, status %d, flags %d, pid %d\n",
 	    (int)(job - job_table), job->job_state, job->flags, job->pid);
     }
 }
@@ -524,10 +524,8 @@ JobPassSig_suspend(int signo)
     act.sa_flags = 0;
     (void)sigaction(signo, &act, NULL);
 
-    if (DEBUG(JOB)) {
-	(void)fprintf(debug_file,
-		       "JobPassSig passing signal %d to self.\n", signo);
-    }
+    if (DEBUG(JOB))
+	debug_printf("JobPassSig passing signal %d to self.\n", signo);
 
     (void)kill(getpid(), signo);
 
@@ -631,7 +629,7 @@ JobPrintCommand(void *cmdp, void *jobp)
     }
 
 #define DBPRINTF(fmt, arg) if (DEBUG(JOB)) {	\
-	(void)fprintf(debug_file, fmt, arg);	\
+	debug_printf(fmt, arg);			\
     }						\
    (void)fprintf(job->cmdFILE, fmt, arg);	\
    (void)fflush(job->cmdFILE);
@@ -1176,12 +1174,12 @@ JobExec(Job *job, char **argv)
     if (DEBUG(JOB)) {
 	int i;
 
-	(void)fprintf(debug_file, "Running %s %sly\n", job->node->name, "local");
-	(void)fprintf(debug_file, "\tCommand: ");
+	debug_printf("Running %s %sly\n", job->node->name, "local");
+	debug_printf("\tCommand: ");
 	for (i = 0; argv[i] != NULL; i++) {
-	    (void)fprintf(debug_file, "%s ", argv[i]);
+	    debug_printf("%s ", argv[i]);
 	}
-	(void)fprintf(debug_file, "\n");
+	debug_printf("\n");
     }
 
     /*
@@ -1328,8 +1326,8 @@ JobExec(Job *job, char **argv)
      * Now the job is actually running, add it to the table.
      */
     if (DEBUG(JOB)) {
-	fprintf(debug_file, "JobExec(%s): pid %d added to jobs table\n",
-		job->node->name, job->pid);
+	debug_printf("JobExec(%s): pid %d added to jobs table\n",
+		     job->node->name, job->pid);
 	job_table_dump("job started");
     }
     JobSigUnlock(&mask);
@@ -2510,7 +2508,7 @@ JobRestartJobs(void)
 	    }
 	    job->job_suspended = 0;
 	    if (KILLPG(job->pid, SIGCONT) != 0 && DEBUG(JOB)) {
-		fprintf(debug_file, "Failed to send SIGCONT to %d\n", job->pid);
+		debug_printf("Failed to send SIGCONT to %d\n", job->pid);
 	    }
 	}
 	if (job->job_state == JOB_ST_FINISHED)

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.152 src/usr.bin/make/make.c:1.153
--- src/usr.bin/make/make.c:1.152	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/make.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.152 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.153 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
 #include    "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.152 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.153 2020/09/28 22:23:35 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;
@@ -128,7 +128,7 @@ static int MakeBuildParent(void *, void 
 MAKE_ATTR_DEAD static void
 make_abort(GNode *gn, int line)
 {
-    fprintf(debug_file, "make_abort from line %d\n", line);
+    debug_printf("make_abort from line %d\n", line);
     Targ_PrintNode(gn, 2);
     Targ_PrintNodes(toBeMade, 2);
     Targ_PrintGraph(3);
@@ -211,9 +211,9 @@ Make_OODate(GNode *gn)
 	(void)Dir_MTime(gn, 1);
 	if (DEBUG(MAKE)) {
 	    if (gn->mtime != 0) {
-		fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime));
+		debug_printf("modified %s...", Targ_FmtTime(gn->mtime));
 	    } else {
-		fprintf(debug_file, "non-existent...");
+		debug_printf("non-existent...");
 	    }
 	}
     }
@@ -264,11 +264,11 @@ Make_OODate(GNode *gn)
 	 */
 	if (DEBUG(MAKE)) {
 	    if (gn->type & OP_FORCE) {
-		fprintf(debug_file, "! operator...");
+		debug_printf("! operator...");
 	    } else if (gn->type & OP_PHONY) {
-		fprintf(debug_file, ".PHONY node...");
+		debug_printf(".PHONY node...");
 	    } else {
-		fprintf(debug_file, ".EXEC node...");
+		debug_printf(".EXEC node...");
 	    }
 	}
 	oodate = TRUE;
@@ -286,12 +286,12 @@ Make_OODate(GNode *gn)
 	 */
 	if (DEBUG(MAKE)) {
 	    if (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) {
-		fprintf(debug_file, "modified before source %s...",
-		    gn->cmgn->path ? gn->cmgn->path : gn->cmgn->name);
+		debug_printf("modified before source %s...",
+			     gn->cmgn->path ? gn->cmgn->path : gn->cmgn->name);
 	    } else if (gn->mtime == 0) {
-		fprintf(debug_file, "non-existent and no sources...");
+		debug_printf("non-existent and no sources...");
 	    } else {
-		fprintf(debug_file, ":: operator and no sources...");
+		debug_printf(":: operator and no sources...");
 	    }
 	}
 	oodate = TRUE;
@@ -305,7 +305,7 @@ Make_OODate(GNode *gn)
 	 */
 	if (DEBUG(MAKE)) {
 	    if (gn->flags & FORCE)
-		fprintf(debug_file, "non existing child...");
+		debug_printf("non existing child...");
 	}
 	oodate = (gn->flags & FORCE) ? TRUE : FALSE;
     }
@@ -385,7 +385,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
 
 #ifdef DEBUG_SRC
     if ((cgn->type & (OP_USE|OP_USEBEFORE|OP_TRANSFORM)) == 0) {
-	fprintf(debug_file, "Make_HandleUse: called for plain node %s\n", cgn->name);
+	debug_printf("Make_HandleUse: called for plain node %s\n", cgn->name);
 	return;
     }
 #endif
@@ -623,10 +623,10 @@ Make_Update(GNode *cgn)
     while ((ln = Lst_Next(parents)) != NULL) {
 	pgn = LstNode_Datum(ln);
 	if (DEBUG(MAKE))
-	    fprintf(debug_file, "inspect parent %s%s: flags %x, "
-			"type %x, made %d, unmade %d ",
-		    pgn->name, pgn->cohort_num, pgn->flags,
-		    pgn->type, pgn->made, pgn->unmade-1);
+	    debug_printf("inspect parent %s%s: flags %x, "
+			 "type %x, made %d, unmade %d ",
+			 pgn->name, pgn->cohort_num, pgn->flags,
+			 pgn->type, pgn->made, pgn->unmade - 1);
 
 	if (!(pgn->flags & REMAKE)) {
 	    /* This parent isn't needed */
@@ -669,8 +669,8 @@ Make_Update(GNode *cgn)
 	pgn->unmade -= 1;
 	if (pgn->unmade < 0) {
 	    if (DEBUG(MAKE)) {
-		fprintf(debug_file, "Graph cycles through %s%s\n",
-		    pgn->name, pgn->cohort_num);
+		debug_printf("Graph cycles through %s%s\n",
+			     pgn->name, pgn->cohort_num);
 		Targ_PrintGraph(2);
 	    }
 	    Error("Graph cycles through %s%s", pgn->name, pgn->cohort_num);
@@ -697,9 +697,9 @@ Make_Update(GNode *cgn)
 	    continue;
 	}
 	if (DEBUG(MAKE)) {
-	    fprintf(debug_file, "- %s%s made, schedule %s%s (made %d)\n",
-		    cgn->name, cgn->cohort_num,
-		    pgn->name, pgn->cohort_num, pgn->made);
+	    debug_printf("- %s%s made, schedule %s%s (made %d)\n",
+			 cgn->name, cgn->cohort_num,
+			 pgn->name, pgn->cohort_num, pgn->made);
 	    Targ_PrintNode(pgn, 2);
 	}
 	/* Ok, we can schedule the parent again */
@@ -1007,8 +1007,8 @@ MakePrintStatusOrder(void *ognp, void *g
     GNode_FprintDetails(stdout, "(", ogn, ")\n");
 
     if (DEBUG(MAKE) && debug_file != stdout) {
-	fprintf(debug_file, "    `%s%s' has .ORDER dependency against %s%s ",
-		gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
+	debug_printf("    `%s%s' has .ORDER dependency against %s%s ",
+		     gn->name, gn->cohort_num, ogn->name, ogn->cohort_num);
 	GNode_FprintDetails(debug_file, "(", ogn, ")\n");
     }
     return 0;
@@ -1044,8 +1044,7 @@ MakePrintStatus(void *gnp, void *v_error
 	    printf("`%s%s' was not built", gn->name, gn->cohort_num);
 	    GNode_FprintDetails(stdout, " (", gn, ")!\n");
 	    if (DEBUG(MAKE) && debug_file != stdout) {
-		fprintf(debug_file, "`%s%s' was not built",
-			gn->name, gn->cohort_num);
+		debug_printf("`%s%s' was not built", gn->name, gn->cohort_num);
 		GNode_FprintDetails(debug_file, " (", gn, ")!\n");
 	    }
 	    /* Most likely problem is actually caused by .ORDER */
@@ -1056,8 +1055,8 @@ MakePrintStatus(void *gnp, void *v_error
 	    printf("`%s%s' not remade because of errors.\n",
 		    gn->name, gn->cohort_num);
 	    if (DEBUG(MAKE) && debug_file != stdout)
-		fprintf(debug_file, "`%s%s' not remade because of errors.\n",
-			gn->name, gn->cohort_num);
+		debug_printf("`%s%s' not remade because of errors.\n",
+			     gn->name, gn->cohort_num);
 	    break;
 	}
 	return 0;
@@ -1291,7 +1290,7 @@ Make_Run(GNodeList *targs)
     Make_ProcessWait(targs);
 
     if (DEBUG(MAKE)) {
-	 fprintf(debug_file, "#***# full graph\n");
+	 debug_printf("#***# full graph\n");
 	 Targ_PrintGraph(1);
     }
 
@@ -1337,7 +1336,7 @@ Make_Run(GNodeList *targs)
     if (errors == 0) {
 	Lst_ForEachUntil(targs, MakePrintStatus, &errors);
 	if (DEBUG(MAKE)) {
-	    fprintf(debug_file, "done: errors %d\n", errors);
+	    debug_printf("done: errors %d\n", errors);
 	    if (errors)
 		Targ_PrintGraph(4);
 	}

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.149 src/usr.bin/make/make.h:1.150
--- src/usr.bin/make/make.h:1.149	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/make.h	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.149 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.150 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -87,6 +87,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <fcntl.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -523,29 +524,39 @@ extern int debug;
 
 #define	DEBUG(module)	(debug & CONCAT(DEBUG_,module))
 
+static inline MAKE_ATTR_UNUSED void MAKE_ATTR_PRINTFLIKE(1, 2)
+debug_printf(const char *fmt, ...)
+{
+    va_list args;
+
+    va_start(args, fmt);
+    vfprintf(debug_file, fmt, args);
+    va_end(args);
+}
+
 #define DEBUG0(module, text) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, "%s", text)
+    else debug_printf("%s", text)
 
 #define DEBUG1(module, fmt, arg1) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, fmt, arg1)
+    else debug_printf(fmt, arg1)
 
 #define DEBUG2(module, fmt, arg1, arg2) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, fmt, arg1, arg2)
+    else debug_printf(fmt, arg1, arg2)
 
 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, fmt, arg1, arg2, arg3)
+    else debug_printf(fmt, arg1, arg2, arg3)
 
 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, fmt, arg1, arg2, arg3, arg4)
+    else debug_printf(fmt, arg1, arg2, arg3, arg4)
 
 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
     if (!DEBUG(module)) (void)0; \
-    else fprintf(debug_file, fmt, arg1, arg2, arg3, arg4, arg5)
+    else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
 
 #include "nonints.h"
 

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.121 src/usr.bin/make/meta.c:1.122
--- src/usr.bin/make/meta.c:1.121	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/meta.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.121 2020/09/28 20:46:11 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.122 2020/09/28 22:23:35 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -385,10 +385,10 @@ printCMD(void *cmdp, void *mfpp)
  * Certain node types never get a .meta file
  */
 #define SKIP_META_TYPE(_type) do { \
-    if ((gn->type & __CONCAT(OP_, _type))) {	\
+    if ((gn->type & __CONCAT(OP_, _type))) { \
 	if (verbose) { \
-	    fprintf(debug_file, "Skipping meta for %s: .%s\n", \
-		    gn->name, __STRING(_type));		       \
+	    debug_printf("Skipping meta for %s: .%s\n", \
+		    gn->name, __STRING(_type)); \
 	} \
 	return FALSE; \
     } \
@@ -421,8 +421,7 @@ meta_needed(GNode *gn, const char *dname
     /* Check if there are no commands to execute. */
     if (Lst_IsEmpty(gn->commands)) {
 	if (verbose)
-	    fprintf(debug_file, "Skipping meta for %s: no commands\n",
-		    gn->name);
+	    debug_printf("Skipping meta for %s: no commands\n", gn->name);
 	return FALSE;
     }
     if ((gn->type & (OP_META|OP_SUBMAKE)) == OP_SUBMAKE) {
@@ -436,8 +435,7 @@ meta_needed(GNode *gn, const char *dname
     /* The object directory may not exist. Check it.. */
     if (cached_stat(dname, &mst) != 0) {
 	if (verbose)
-	    fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n",
-		    gn->name);
+	    debug_printf("Skipping meta for %s: no .OBJDIR\n", gn->name);
 	return FALSE;
     }
 
@@ -448,8 +446,8 @@ meta_needed(GNode *gn, const char *dname
     /* If we aren't in the object directory, don't create a meta file. */
     if (!metaCurdirOk && strcmp(curdir, dname) == 0) {
 	if (verbose)
-	    fprintf(debug_file, "Skipping meta for %s: .OBJDIR == .CURDIR\n",
-		    gn->name);
+	    debug_printf("Skipping meta for %s: .OBJDIR == .CURDIR\n",
+			 gn->name);
 	return FALSE;
     }
     return TRUE;
@@ -1240,9 +1238,9 @@ meta_oodate(GNode *gn, Boolean oodate)
 			continue;
 #ifdef DEBUG_META_MODE
 		    if (DEBUG(META))
-			    fprintf(debug_file, "%s: %d: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
-				    fname, lineno,
-				    pid, buf[0], cwd, lcwd, latestdir);
+			debug_printf("%s: %d: %d: %c: cwd=%s lcwd=%s ldir=%s\n",
+				     fname, lineno,
+				     pid, buf[0], cwd, lcwd, latestdir);
 #endif
 		    break;
 		}
@@ -1270,9 +1268,10 @@ meta_oodate(GNode *gn, Boolean oodate)
 			    Var_Set(cldir, latestdir, VAR_GLOBAL);
 #ifdef DEBUG_META_MODE
 			    if (DEBUG(META))
-				    fprintf(debug_file, "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
-					    fname, lineno,
-					    child, cwd, lcwd, latestdir);
+				debug_printf(
+					"%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
+					fname, lineno,
+					child, cwd, lcwd, latestdir);
 #endif
 			}
 		    }

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.341 src/usr.bin/make/parse.c:1.342
--- src/usr.bin/make/parse.c:1.341	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/parse.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.341 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.342 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -132,7 +132,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.341 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.342 2020/09/28 22:23:35 rillig Exp $");
 
 /* types and constants */
 
@@ -814,8 +814,8 @@ ParseLinkSrc(void *pgnp, void *data)
 	Lst_Append(cgn->parents, pgn);
 
     if (DEBUG(PARSE)) {
-	fprintf(debug_file, "# %s: added child %s - %s\n",
-		__func__, pgn->name, cgn->name);
+	debug_printf("# %s: added child %s - %s\n",
+		     __func__, pgn->name, cgn->name);
 	Targ_PrintNode(pgn, 0);
 	Targ_PrintNode(cgn, 0);
     }
@@ -979,8 +979,8 @@ ParseDoSrc(int tOp, const char *src, Par
 	    Lst_Append(predecessor->order_succ, gn);
 	    Lst_Append(gn->order_pred, predecessor);
 	    if (DEBUG(PARSE)) {
-		fprintf(debug_file, "# %s: added Order dependency %s - %s\n",
-		    __func__, predecessor->name, gn->name);
+		debug_printf("# %s: added Order dependency %s - %s\n",
+			     __func__, predecessor->name, gn->name);
 		Targ_PrintNode(predecessor, 0);
 		Targ_PrintNode(gn, 0);
 	    }
@@ -2307,9 +2307,10 @@ Parse_SetInput(const char *name, int lin
 	ParseTrackInput(name);
 
     if (DEBUG(PARSE))
-	fprintf(debug_file, "%s: file %s, line %d, fd %d, nextbuf %s, arg %p\n",
-		__func__, name, line, fd,
-		nextbuf == loadedfile_nextbuf ? "loadedfile" : "other", arg);
+	debug_printf("%s: file %s, line %d, fd %d, nextbuf %s, arg %p\n",
+		     __func__, name, line, fd,
+		     nextbuf == loadedfile_nextbuf ? "loadedfile" : "other",
+		     arg);
 
     if (fd == -1 && nextbuf == NULL)
 	/* sanity */

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.171 src/usr.bin/make/suff.c:1.172
--- src/usr.bin/make/suff.c:1.171	Mon Sep 28 20:46:11 2020
+++ src/usr.bin/make/suff.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.171 2020/09/28 20:46:11 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.172 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include	  "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.171 2020/09/28 20:46:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.172 2020/09/28 22:23:35 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -936,9 +936,9 @@ SuffAddSrc(void *sp, void *lsp)
 #ifdef DEBUG_SRC
 	s2->cp = Lst_Init();
 	Lst_Append(targ->cp, s2);
-	fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l);
+	debug_printf("1 add %p %p to %p:", targ, s2, ls->l);
 	Lst_ForEach(ls->l, PrintAddr, NULL);
-	fprintf(debug_file, "\n");
+	debug_printf("\n");
 #endif
     }
     s2 = bmake_malloc(sizeof(Src));
@@ -954,9 +954,9 @@ SuffAddSrc(void *sp, void *lsp)
 #ifdef DEBUG_SRC
     s2->cp = Lst_Init();
     Lst_Append(targ->cp, s2);
-    fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l);
+    debug_printf("2 add %p %p to %p:", targ, s2, ls->l);
     Lst_ForEach(ls->l, PrintAddr, NULL);
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
 #endif
 }
 
@@ -988,9 +988,9 @@ SuffRemoveSrc(SrcList *l)
     Lst_Open(l);
 
 #ifdef DEBUG_SRC
-    fprintf(debug_file, "cleaning %lx: ", (unsigned long) l);
+    debug_printf("cleaning %lx: ", (unsigned long) l);
     Lst_ForEach(l, PrintAddr, NULL);
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
 #endif
 
     while ((ln = Lst_Next(l)) != NULL) {
@@ -1008,7 +1008,7 @@ SuffRemoveSrc(SrcList *l)
 		--s->parent->children;
 	    }
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "free: [l=%p] p=%p %d\n", l, s, s->children);
+	    debug_printf("free: [l=%p] p=%p %d\n", l, s, s->children);
 	    Lst_Free(s->cp);
 #endif
 	    Lst_Remove(l, ln);
@@ -1018,9 +1018,9 @@ SuffRemoveSrc(SrcList *l)
 	}
 #ifdef DEBUG_SRC
 	else {
-	    fprintf(debug_file, "keep: [l=%p] p=%p %d: ", l, s, s->children);
+	    debug_printf("keep: [l=%p] p=%p %d: ", l, s, s->children);
 	    Lst_ForEach(s->cp, PrintAddr, NULL);
-	    fprintf(debug_file, "\n");
+	    debug_printf("\n");
 	}
 #endif
     }
@@ -1058,7 +1058,7 @@ SuffFindThem(SrcList *srcs, SrcList *sls
 	 */
 	if (Targ_FindNode(s->file) != NULL) {
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "remove %p from %p\n", s, srcs);
+	    debug_printf("remove %p from %p\n", s, srcs);
 #endif
 	    rs = s;
 	    break;
@@ -1067,7 +1067,7 @@ SuffFindThem(SrcList *srcs, SrcList *sls
 	if ((ptr = Dir_FindFile(s->file, s->suff->searchPath)) != NULL) {
 	    rs = s;
 #ifdef DEBUG_SRC
-	    fprintf(debug_file, "remove %p from %p\n", s, srcs);
+	    debug_printf("remove %p from %p\n", s, srcs);
 #endif
 	    free(ptr);
 	    break;
@@ -1175,7 +1175,7 @@ SuffFindCmds(Src *targ, SrcList *slst)
     targ->children += 1;
 #ifdef DEBUG_SRC
     ret->cp = Lst_Init();
-    fprintf(debug_file, "3 add %p %p\n", targ, ret);
+    debug_printf("3 add %p %p\n", targ, ret);
     Lst_Append(targ->cp, ret);
 #endif
     Lst_Append(slst, ret);
@@ -2148,7 +2148,7 @@ Suff_End(void)
 static void
 SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
 {
-    fprintf(debug_file, "%s ", ((Suff *)s)->name);
+    debug_printf("%s ", ((Suff *)s)->name);
 }
 
 static void
@@ -2156,23 +2156,23 @@ SuffPrintSuff(void *sp, void *dummy MAKE
 {
     Suff    *s = (Suff *)sp;
 
-    fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
+    debug_printf("# `%s' [%d] ", s->name, s->refCount);
 
     if (s->flags != 0) {
 	char flags_buf[SuffFlags_ToStringSize];
 
-	fprintf(debug_file, " (%s)",
-		Enum_FlagsToString(flags_buf, sizeof flags_buf,
-				   s->flags, SuffFlags_ToStringSpecs));
+	debug_printf(" (%s)",
+		     Enum_FlagsToString(flags_buf, sizeof flags_buf,
+					s->flags, SuffFlags_ToStringSpecs));
     }
     fputc('\n', debug_file);
-    fprintf(debug_file, "#\tTo: ");
+    debug_printf("#\tTo: ");
     Lst_ForEach(s->parents, SuffPrintName, NULL);
     fputc('\n', debug_file);
-    fprintf(debug_file, "#\tFrom: ");
+    debug_printf("#\tFrom: ");
     Lst_ForEach(s->children, SuffPrintName, NULL);
     fputc('\n', debug_file);
-    fprintf(debug_file, "#\tSearch Path: ");
+    debug_printf("#\tSearch Path: ");
     Dir_PrintPath(s->searchPath);
     fputc('\n', debug_file);
 }
@@ -2182,7 +2182,7 @@ SuffPrintTrans(void *tp, void *dummy MAK
 {
     GNode   *t = (GNode *)tp;
 
-    fprintf(debug_file, "%-16s:", t->name);
+    debug_printf("%-16s:", t->name);
     Targ_PrintType(t->type);
     fputc('\n', debug_file);
     Targ_PrintCmds(t);
@@ -2192,9 +2192,9 @@ SuffPrintTrans(void *tp, void *dummy MAK
 void
 Suff_PrintAll(void)
 {
-    fprintf(debug_file, "#*** Suffixes:\n");
+    debug_printf("#*** Suffixes:\n");
     Lst_ForEach(sufflist, SuffPrintSuff, NULL);
 
-    fprintf(debug_file, "#*** Transformations:\n");
+    debug_printf("#*** Transformations:\n");
     Lst_ForEach(transforms, SuffPrintTrans, NULL);
 }

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.106 src/usr.bin/make/targ.c:1.107
--- src/usr.bin/make/targ.c:1.106	Sun Sep 27 21:35:16 2020
+++ src/usr.bin/make/targ.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.106 2020/09/27 21:35:16 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.107 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -122,7 +122,7 @@
 #include	  "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.106 2020/09/27 21:35:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.107 2020/09/28 22:23:35 rillig Exp $");
 
 static GNodeList *allTargets;	/* the list of all targets found so far */
 #ifdef CLEANUP
@@ -347,7 +347,7 @@ PrintNodeNames(GNodeList *gnodes)
 
     for (node = gnodes->first; node != NULL; node = node->next) {
 	GNode *gn = node->datum;
-	fprintf(debug_file, " %s%s", gn->name, gn->cohort_num);
+	debug_printf(" %s%s", gn->name, gn->cohort_num);
     }
 }
 
@@ -356,9 +356,9 @@ PrintNodeNamesLine(const char *label, GN
 {
     if (Lst_IsEmpty(gnodes))
 	return;
-    fprintf(debug_file, "# %s:", label);
+    debug_printf("# %s:", label);
     PrintNodeNames(gnodes);
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
 }
 
 void
@@ -367,7 +367,7 @@ Targ_PrintCmds(GNode *gn)
     StringListNode *node = gn->commands->first;
     for (; node != NULL; node = node->next) {
 	const char *cmd = LstNode_Datum(node);
-	fprintf(debug_file, "\t%s\n", cmd);
+	debug_printf("\t%s\n", cmd);
     }
 }
 
@@ -390,8 +390,8 @@ Targ_PrintType(int type)
 {
     int    tbit;
 
-#define PRINTBIT(attr)	case CONCAT(OP_,attr): fprintf(debug_file, " ." #attr); break
-#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))fprintf(debug_file, " ." #attr); break
+#define PRINTBIT(attr)	case CONCAT(OP_,attr): debug_printf(" ." #attr); break
+#define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))debug_printf(" ." #attr); break
 
     type &= ~OP_OPMASK;
 
@@ -412,7 +412,7 @@ Targ_PrintType(int type)
 	PRINTBIT(NOTMAIN);
 	PRINTDBIT(LIB);
 	    /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
-	case OP_MEMBER: if (DEBUG(TARG))fprintf(debug_file, " .MEMBER"); break;
+	case OP_MEMBER: if (DEBUG(TARG))debug_printf(" .MEMBER"); break;
 	PRINTDBIT(ARCHV);
 	PRINTDBIT(MADE);
 	PRINTDBIT(PHONY);
@@ -440,57 +440,57 @@ made_name(GNodeMade made)
 void
 Targ_PrintNode(GNode *gn, int pass)
 {
-    fprintf(debug_file, "# %s%s", gn->name, gn->cohort_num);
+    debug_printf("# %s%s", gn->name, gn->cohort_num);
     GNode_FprintDetails(debug_file, ", ", gn, "\n");
     if (gn->flags == 0)
 	return;
 
     if (!OP_NOP(gn->type)) {
-	fprintf(debug_file, "#\n");
+	debug_printf("#\n");
 	if (gn == mainTarg) {
-	    fprintf(debug_file, "# *** MAIN TARGET ***\n");
+	    debug_printf("# *** MAIN TARGET ***\n");
 	}
 	if (pass >= 2) {
 	    if (gn->unmade) {
-		fprintf(debug_file, "# %d unmade children\n", gn->unmade);
+		debug_printf("# %d unmade children\n", gn->unmade);
 	    } else {
-		fprintf(debug_file, "# No unmade children\n");
+		debug_printf("# No unmade children\n");
 	    }
 	    if (! (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
 		if (gn->mtime != 0) {
-		    fprintf(debug_file, "# last modified %s: %s\n",
+		    debug_printf("# last modified %s: %s\n",
 			    Targ_FmtTime(gn->mtime),
 			    made_name(gn->made));
 		} else if (gn->made != UNMADE) {
-		    fprintf(debug_file, "# non-existent (maybe): %s\n",
+		    debug_printf("# non-existent (maybe): %s\n",
 			    made_name(gn->made));
 		} else {
-		    fprintf(debug_file, "# unmade\n");
+		    debug_printf("# unmade\n");
 		}
 	    }
 	    PrintNodeNamesLine("implicit parents", gn->implicitParents);
 	} else {
 	    if (gn->unmade)
-		fprintf(debug_file, "# %d unmade children\n", gn->unmade);
+		debug_printf("# %d unmade children\n", gn->unmade);
 	}
 	PrintNodeNamesLine("parents", gn->parents);
 	PrintNodeNamesLine("order_pred", gn->order_pred);
 	PrintNodeNamesLine("order_succ", gn->order_succ);
 
-	fprintf(debug_file, "%-16s", gn->name);
+	debug_printf("%-16s", gn->name);
 	switch (gn->type & OP_OPMASK) {
 	case OP_DEPENDS:
-	    fprintf(debug_file, ":"); break;
+	    debug_printf(":"); break;
 	case OP_FORCE:
-	    fprintf(debug_file, "!"); break;
+	    debug_printf("!"); break;
 	case OP_DOUBLEDEP:
-	    fprintf(debug_file, "::"); break;
+	    debug_printf("::"); break;
 	}
 	Targ_PrintType(gn->type);
 	PrintNodeNames(gn->children);
-	fprintf(debug_file, "\n");
+	debug_printf("\n");
 	Targ_PrintCmds(gn);
-	fprintf(debug_file, "\n\n");
+	debug_printf("\n\n");
 	if (gn->type & OP_DOUBLEDEP) {
 	    Targ_PrintNodes(gn->cohorts, pass);
 	}
@@ -516,10 +516,10 @@ PrintOnlySources(void)
 	if (!OP_NOP(gn->type))
 	    continue;
 
-	fprintf(debug_file, "#\t%s [%s]",
+	debug_printf("#\t%s [%s]",
 		gn->name, gn->path ? gn->path : gn->name);
 	Targ_PrintType(gn->type);
-	fprintf(debug_file, "\n");
+	debug_printf("\n");
     }
 }
 
@@ -531,18 +531,18 @@ PrintOnlySources(void)
 void
 Targ_PrintGraph(int pass)
 {
-    fprintf(debug_file, "#*** Input graph:\n");
+    debug_printf("#*** Input graph:\n");
     Targ_PrintNodes(allTargets, pass);
-    fprintf(debug_file, "\n\n");
-    fprintf(debug_file, "#\n#   Files that are only sources:\n");
+    debug_printf("\n\n");
+    debug_printf("#\n#   Files that are only sources:\n");
     PrintOnlySources();
-    fprintf(debug_file, "#*** Global Variables:\n");
+    debug_printf("#*** Global Variables:\n");
     Var_Dump(VAR_GLOBAL);
-    fprintf(debug_file, "#*** Command-line Variables:\n");
+    debug_printf("#*** Command-line Variables:\n");
     Var_Dump(VAR_CMD);
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
     Dir_PrintDirectories();
-    fprintf(debug_file, "\n");
+    debug_printf("\n");
     Suff_PrintAll();
 }
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.549 src/usr.bin/make/var.c:1.550
--- src/usr.bin/make/var.c:1.549	Mon Sep 28 21:11:05 2020
+++ src/usr.bin/make/var.c	Mon Sep 28 22:23:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.549 2020/09/28 21:11:05 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.550 2020/09/28 22:23:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.549 2020/09/28 21:11:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.550 2020/09/28 22:23:35 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2998,16 +2998,15 @@ LogBeforeApply(const ApplyModifiersState
 
     /* At this point, only the first character of the modifier can
      * be used since the end of the modifier is not yet known. */
-    fprintf(debug_file,
-	    "Applying ${%s:%c%s} to \"%s\" (%s, %s, %s)\n",
-	    st->v->name, mod[0], is_single_char ? "" : "...", st->val,
-	    Enum_FlagsToString(eflags_str, sizeof eflags_str,
-			       st->eflags, VarEvalFlags_ToStringSpecs),
-	    Enum_FlagsToString(vflags_str, sizeof vflags_str,
-			       st->v->flags, VarFlags_ToStringSpecs),
-	    Enum_FlagsToString(exprflags_str, sizeof exprflags_str,
-			       st->exprFlags,
-			       VarExprFlags_ToStringSpecs));
+    debug_printf("Applying ${%s:%c%s} to \"%s\" (%s, %s, %s)\n",
+		 st->v->name, mod[0], is_single_char ? "" : "...", st->val,
+		 Enum_FlagsToString(eflags_str, sizeof eflags_str,
+				    st->eflags, VarEvalFlags_ToStringSpecs),
+		 Enum_FlagsToString(vflags_str, sizeof vflags_str,
+				    st->v->flags, VarFlags_ToStringSpecs),
+		 Enum_FlagsToString(exprflags_str, sizeof exprflags_str,
+				    st->exprFlags,
+				    VarExprFlags_ToStringSpecs));
 }
 
 static void
@@ -3019,16 +3018,15 @@ LogAfterApply(ApplyModifiersState *st, c
     const char *quot = st->newVal == var_Error ? "" : "\"";
     const char *newVal = st->newVal == var_Error ? "error" : st->newVal;
 
-    fprintf(debug_file,
-	    "Result of ${%s:%.*s} is %s%s%s (%s, %s, %s)\n",
-	    st->v->name, (int)(p - mod), mod, quot, newVal, quot,
-	    Enum_FlagsToString(eflags_str, sizeof eflags_str,
-			       st->eflags, VarEvalFlags_ToStringSpecs),
-	    Enum_FlagsToString(vflags_str, sizeof vflags_str,
-			       st->v->flags, VarFlags_ToStringSpecs),
-	    Enum_FlagsToString(exprflags_str, sizeof exprflags_str,
-			       st->exprFlags,
-			       VarExprFlags_ToStringSpecs));
+    debug_printf("Result of ${%s:%.*s} is %s%s%s (%s, %s, %s)\n",
+		 st->v->name, (int)(p - mod), mod, quot, newVal, quot,
+		 Enum_FlagsToString(eflags_str, sizeof eflags_str,
+				    st->eflags, VarEvalFlags_ToStringSpecs),
+		 Enum_FlagsToString(vflags_str, sizeof vflags_str,
+				    st->v->flags, VarFlags_ToStringSpecs),
+		 Enum_FlagsToString(exprflags_str, sizeof exprflags_str,
+				    st->exprFlags,
+				    VarExprFlags_ToStringSpecs));
 }
 
 /* Apply any modifiers (such as :Mpattern or :@var@loop@ or :Q or ::=value). */
@@ -3842,7 +3840,7 @@ static void
 VarPrintVar(void *vp, void *data MAKE_ATTR_UNUSED)
 {
     Var *v = (Var *)vp;
-    fprintf(debug_file, "%-16s = %s\n", v->name, Buf_GetAll(&v->val, NULL));
+    debug_printf("%-16s = %s\n", v->name, Buf_GetAll(&v->val, NULL));
 }
 
 /* Print all variables in a context, unordered. */

Reply via email to