summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2002-09-18 16:13:03 +0000
committerjmallett <jmallett@FreeBSD.org>2002-09-18 16:13:03 +0000
commitb1a7ec95a8c436a372ffbd98f7bc0dd1ac347451 (patch)
treea7eadfee50e5871652c0862c86c068d7542d59b1 /usr.bin
parent9d78d39578a32950b1e4b145c514518052390c70 (diff)
downloadFreeBSD-src-b1a7ec95a8c436a372ffbd98f7bc0dd1ac347451.zip
FreeBSD-src-b1a7ec95a8c436a372ffbd98f7bc0dd1ac347451.tar.gz
Make the DEBUGF() macro portable by (ugh) adding a Debug() function, which
is merely printf() but to stderr. This takes care of the caveat which lead to the use of a vararg macro -- getting everything to stderr.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/arch.c14
-rw-r--r--usr.bin/make/compat.c8
-rw-r--r--usr.bin/make/cond.c8
-rw-r--r--usr.bin/make/dir.c52
-rw-r--r--usr.bin/make/for.c8
-rw-r--r--usr.bin/make/job.c74
-rw-r--r--usr.bin/make/main.c22
-rw-r--r--usr.bin/make/make.c34
-rw-r--r--usr.bin/make/make.h5
-rw-r--r--usr.bin/make/nonints.h1
-rw-r--r--usr.bin/make/parse.c2
-rw-r--r--usr.bin/make/suff.c58
-rw-r--r--usr.bin/make/targ.c4
-rw-r--r--usr.bin/make/var.c14
14 files changed, 163 insertions, 141 deletions
diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c
index 9eb9bb7..983dc42 100644
--- a/usr.bin/make/arch.c
+++ b/usr.bin/make/arch.c
@@ -699,7 +699,7 @@ ArchSVR4Entry(ar, name, size, arch)
strncmp(name, ARLONGNAMES2, sizeof(ARLONGNAMES2) - 1) == 0) {
if (ar->fnametab != NULL) {
- DEBUGF(ARCH, "Attempted to redefine an SVR4 name table\n");
+ DEBUGF(ARCH, ("Attempted to redefine an SVR4 name table\n"));
return -1;
}
@@ -711,7 +711,7 @@ ArchSVR4Entry(ar, name, size, arch)
ar->fnamesize = size;
if (fread(ar->fnametab, size, 1, arch) != 1) {
- DEBUGF(ARCH, "Reading an SVR4 name table failed\n");
+ DEBUGF(ARCH, ("Reading an SVR4 name table failed\n"));
return -1;
}
eptr = ar->fnametab + size;
@@ -728,7 +728,7 @@ ArchSVR4Entry(ar, name, size, arch)
default:
break;
}
- DEBUGF(ARCH, "Found svr4 archive name table with %zu entries\n", entry);
+ DEBUGF(ARCH, ("Found svr4 archive name table with %zu entries\n", entry));
return 0;
}
@@ -737,16 +737,16 @@ ArchSVR4Entry(ar, name, size, arch)
entry = (size_t) strtol(&name[1], &eptr, 0);
if ((*eptr != ' ' && *eptr != '\0') || eptr == &name[1]) {
- DEBUGF(ARCH, "Could not parse SVR4 name %s\n", name);
+ DEBUGF(ARCH, ("Could not parse SVR4 name %s\n", name));
return 2;
}
if (entry >= ar->fnamesize) {
- DEBUGF(ARCH, "SVR4 entry offset %s is greater than %zu\n",
- name, ar->fnamesize);
+ DEBUGF(ARCH, ("SVR4 entry offset %s is greater than %zu\n",
+ name, ar->fnamesize));
return 2;
}
- DEBUGF(ARCH, "Replaced %s with %s\n", name, &ar->fnametab[entry]);
+ DEBUGF(ARCH, ("Replaced %s with %s\n", name, &ar->fnametab[entry]));
(void) strncpy(name, &ar->fnametab[entry], MAXPATHLEN);
name[MAXPATHLEN] = '\0';
diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c
index 1ff3e53..92c59cd 100644
--- a/usr.bin/make/compat.c
+++ b/usr.bin/make/compat.c
@@ -457,13 +457,13 @@ CompatMake (gnp, pgnp)
* we were modified last. The criteria for datedness are defined by the
* Make_OODate function.
*/
- DEBUGF(MAKE, "Examining %s...", gn->name);
+ DEBUGF(MAKE, ("Examining %s...", gn->name));
if (! Make_OODate(gn)) {
gn->made = UPTODATE;
- DEBUGF(MAKE, "up-to-date.\n");
+ DEBUGF(MAKE, ("up-to-date.\n"));
return (0);
} else {
- DEBUGF(MAKE, "out-of-date.\n");
+ DEBUGF(MAKE, ("out-of-date.\n"));
}
/*
@@ -570,7 +570,7 @@ CompatMake (gnp, pgnp)
}
if (gn->cmtime > gn->mtime)
gn->mtime = gn->cmtime;
- DEBUGF(MAKE, "update time: %s\n", Targ_FmtTime(gn->mtime));
+ DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(gn->mtime)));
#endif
if (!(gn->type & OP_EXEC)) {
pgn->childMade = TRUE;
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index cfdde15..dcf7b55 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -657,8 +657,8 @@ do_string_compare:
string = (char *)Buf_GetAll(buf, (int *)0);
Buf_Destroy(buf, FALSE);
- DEBUGF(COND, "lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
- lhs, string, op);
+ DEBUGF(COND, ("lhs = \"%s\", rhs = \"%s\", op = %.2s\n",
+ lhs, string, op));
/*
* Null-terminate rhs and perform the comparison.
* t is set to the result.
@@ -718,8 +718,8 @@ do_string_compare:
}
}
- DEBUGF(COND, "left = %f, right = %f, op = %.2s\n", left,
- right, op);
+ DEBUGF(COND, ("left = %f, right = %f, op = %.2s\n", left,
+ right, op));
switch(op[0]) {
case '!':
if (op[1] != '=') {
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c
index e8eb297..e97cdeb 100644
--- a/usr.bin/make/dir.c
+++ b/usr.bin/make/dir.c
@@ -541,7 +541,7 @@ DirPrintWord(word, dummy)
void * word;
void * dummy;
{
- DEBUGF(DIR, "%s ", (char *) word);
+ DEBUGF(DIR, ("%s ", (char *) word));
return(dummy ? 0 : 0);
}
@@ -569,7 +569,7 @@ Dir_Expand (word, path, expansions)
{
char *cp;
- DEBUGF(DIR, "expanding \"%s\"...", word);
+ DEBUGF(DIR, ("expanding \"%s\"...", word));
cp = strchr(word, '{');
if (cp) {
@@ -653,7 +653,7 @@ Dir_Expand (word, path, expansions)
}
if (DEBUG(DIR)) {
Lst_ForEach(expansions, DirPrintWord, (void *) 0);
- DEBUGF(DIR, "\n");
+ DEBUGF(DIR, ("\n"));
}
}
@@ -703,7 +703,7 @@ Dir_FindFile (name, path)
cp = name;
}
- DEBUGF(DIR, "Searching for %s...", name);
+ DEBUGF(DIR, ("Searching for %s...", name));
/*
* No matter what, we always look for the file in the current directory
* before anywhere else and we *do not* add the ./ to it if it exists.
@@ -712,14 +712,14 @@ Dir_FindFile (name, path)
*/
if ((!hasSlash || (cp - name == 2 && *name == '.')) &&
(Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL)) {
- DEBUGF(DIR, "in '.'\n");
+ DEBUGF(DIR, ("in '.'\n"));
hits += 1;
dot->hits += 1;
return (estrdup (name));
}
if (Lst_Open (path) == FAILURE) {
- DEBUGF(DIR, "couldn't open path, file not found\n");
+ DEBUGF(DIR, ("couldn't open path, file not found\n"));
misses += 1;
return ((char *) NULL);
}
@@ -734,9 +734,9 @@ Dir_FindFile (name, path)
*/
while ((ln = Lst_Next (path)) != NULL) {
p = (Path *) Lst_Datum (ln);
- DEBUGF(DIR, "%s...", p->name);
+ DEBUGF(DIR, ("%s...", p->name));
if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) {
- DEBUGF(DIR, "here...");
+ DEBUGF(DIR, ("here..."));
if (hasSlash) {
/*
* If the name had a slash, its initial components and p's
@@ -752,12 +752,12 @@ Dir_FindFile (name, path)
p1 -= 1; p2 -= 1;
}
if (p2 >= name || (p1 >= p->name && *p1 != '/')) {
- DEBUGF(DIR, "component mismatch -- continuing...");
+ DEBUGF(DIR, ("component mismatch -- continuing..."));
continue;
}
}
file = str_concat (p->name, cp, STR_ADDSLASH);
- DEBUGF(DIR, "returning %s\n", file);
+ DEBUGF(DIR, ("returning %s\n", file));
Lst_Close (path);
p->hits += 1;
hits += 1;
@@ -772,7 +772,7 @@ Dir_FindFile (name, path)
continue;
}
if (*p1 == '\0' && p2 == cp - 1) {
- DEBUGF(DIR, "must be here but isn't -- returing NULL\n");
+ DEBUGF(DIR, ("must be here but isn't -- returing NULL\n"));
Lst_Close (path);
return ((char *) NULL);
}
@@ -792,7 +792,7 @@ Dir_FindFile (name, path)
* end). This phase is only performed if the file is *not* absolute.
*/
if (!hasSlash) {
- DEBUGF(DIR, "failed.\n");
+ DEBUGF(DIR, ("failed.\n"));
misses += 1;
return ((char *) NULL);
}
@@ -800,7 +800,7 @@ Dir_FindFile (name, path)
if (*name != '/') {
Boolean checkedDot = FALSE;
- DEBUGF(DIR, "failed. Trying subdirectories...");
+ DEBUGF(DIR, ("failed. Trying subdirectories..."));
(void) Lst_Open (path);
while ((ln = Lst_Next (path)) != NULL) {
p = (Path *) Lst_Datum (ln);
@@ -813,10 +813,10 @@ Dir_FindFile (name, path)
file = estrdup(name);
checkedDot = TRUE;
}
- DEBUGF(DIR, "checking %s...", file);
+ DEBUGF(DIR, ("checking %s...", file));
if (stat (file, &stb) == 0) {
- DEBUGF(DIR, "got it.\n");
+ DEBUGF(DIR, ("got it.\n"));
Lst_Close (path);
@@ -839,7 +839,7 @@ Dir_FindFile (name, path)
* Save the modification time so if it's needed, we don't have
* to fetch it again.
*/
- DEBUGF(DIR, "Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file);
+ DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), file));
entry = Hash_CreateEntry(&mtimes, (char *) file,
(Boolean *)NULL);
Hash_SetValue(entry, (long)stb.st_mtime);
@@ -850,7 +850,7 @@ Dir_FindFile (name, path)
}
}
- DEBUGF(DIR, "failed. ");
+ DEBUGF(DIR, ("failed. "));
Lst_Close (path);
if (checkedDot) {
@@ -858,7 +858,7 @@ Dir_FindFile (name, path)
* Already checked by the given name, since . was in the path,
* so no point in proceeding...
*/
- DEBUGF(DIR, "Checked . already, returning NULL\n");
+ DEBUGF(DIR, ("Checked . already, returning NULL\n"));
return(NULL);
}
}
@@ -899,20 +899,20 @@ Dir_FindFile (name, path)
return ((char *) NULL);
}
#else /* !notdef */
- DEBUGF(DIR, "Looking for \"%s\"...", name);
+ DEBUGF(DIR, ("Looking for \"%s\"...", name));
bigmisses += 1;
entry = Hash_FindEntry(&mtimes, name);
if (entry != (Hash_Entry *)NULL) {
- DEBUGF(DIR, "got it (in mtime cache)\n");
+ DEBUGF(DIR, ("got it (in mtime cache)\n"));
return (estrdup(name));
} else if (stat (name, &stb) == 0) {
entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL);
- DEBUGF(DIR, "Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name);
+ DEBUGF(DIR, ("Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), name));
Hash_SetValue(entry, (long)stb.st_mtime);
return (estrdup (name));
} else {
- DEBUGF(DIR, "failed. Returning NULL\n");
+ DEBUGF(DIR, ("failed. Returning NULL\n"));
return ((char *)NULL);
}
#endif /* notdef */
@@ -961,8 +961,8 @@ Dir_MTime (gn)
* see if the file was actually updated, so we need to actually go
* to the filesystem.
*/
- DEBUGF(DIR, "Using cached time %s for %s\n",
- Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName);
+ DEBUGF(DIR, ("Using cached time %s for %s\n",
+ Targ_FmtTime((time_t)(long)Hash_GetValue(entry)), fullName));
stb.st_mtime = (time_t)(long)Hash_GetValue(entry);
Hash_DeleteEntry(&mtimes, entry);
} else if (stat (fullName, &stb) < 0) {
@@ -1016,7 +1016,7 @@ Dir_AddDir (path, name)
(void)Lst_AtEnd (path, (void *)p);
}
} else {
- DEBUGF(DIR, "Caching %s...", name);
+ DEBUGF(DIR, ("Caching %s...", name));
if ((d = opendir (name)) != (DIR *) NULL) {
p = (Path *) emalloc (sizeof (Path));
@@ -1053,7 +1053,7 @@ Dir_AddDir (path, name)
(void)Lst_AtEnd (openDirectories, (void *)p);
(void)Lst_AtEnd (path, (void *)p);
}
- DEBUGF(DIR, "done\n");
+ DEBUGF(DIR, ("done\n"));
}
}
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c
index d5aa54d..c152008 100644
--- a/usr.bin/make/for.c
+++ b/usr.bin/make/for.c
@@ -192,7 +192,7 @@ For_Eval (line)
ptr++;
wrd = ptr--;
}
- DEBUGF(FOR, "For: Iterator %s List %s\n", forVar, sub);
+ DEBUGF(FOR, ("For: Iterator %s List %s\n", forVar, sub));
if (ptr - wrd > 0)
ADDWORD();
else
@@ -210,7 +210,7 @@ For_Eval (line)
if (strncmp(ptr, "endfor", 6) == 0 &&
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
- DEBUGF(FOR, "For: end for %d\n", forLevel);
+ DEBUGF(FOR, ("For: end for %d\n", forLevel));
if (--forLevel < 0) {
Parse_Error (level, "for-less endfor");
return 0;
@@ -219,7 +219,7 @@ For_Eval (line)
else if (strncmp(ptr, "for", 3) == 0 &&
isspace((unsigned char) ptr[3])) {
forLevel++;
- DEBUGF(FOR, "For: new loop %d\n", forLevel);
+ DEBUGF(FOR, ("For: new loop %d\n", forLevel));
}
}
@@ -255,7 +255,7 @@ ForExec(namep, argp)
For *arg = (For *) argp;
int len;
Var_Set(arg->var, name, VAR_GLOBAL);
- DEBUGF(FOR, "--- %s = %s\n", arg->var, name);
+ DEBUGF(FOR, ("--- %s = %s\n", arg->var, name));
Parse_FromString(Var_Subst(arg->var, (char *) Buf_GetAll(arg->buf, &len),
VAR_GLOBAL, FALSE));
Var_Delete(arg->var, VAR_GLOBAL);
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 4eae54c..bb1e092 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -354,7 +354,7 @@ JobCondPassSig(jobp, signop)
* Assume that sending the signal to job->pid will signal any remote
* job as well.
*/
- DEBUGF(JOB, "JobCondPassSig passing signal %d to child %d.\n", signo, job->pid);
+ DEBUGF(JOB, ("JobCondPassSig passing signal %d to child %d.\n", signo, job->pid));
KILL(job->pid, signo);
#endif
return 0;
@@ -381,7 +381,7 @@ JobPassSig(signo)
sigset_t nmask, omask;
struct sigaction act;
- DEBUGF(JOB, "JobPassSig(%d) called.\n", signo);
+ DEBUGF(JOB, ("JobPassSig(%d) called.\n", signo));
Lst_ForEach(jobs, JobCondPassSig, (void *) &signo);
/*
@@ -416,7 +416,7 @@ JobPassSig(signo)
act.sa_flags = 0;
sigaction(signo, &act, NULL);
- DEBUGF(JOB, "JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1)));
+ DEBUGF(JOB, ("JobPassSig passing signal to self, mask = %x.\n", ~0 & ~(1 << (signo-1))));
(void) signal(signo, SIG_DFL);
(void) KILL(getpid(), signo);
@@ -535,7 +535,7 @@ JobPrintCommand(cmdp, jobp)
}
#define DBPRINTF(fmt, arg) \
- DEBUGF(JOB, fmt, arg); \
+ DEBUGF(JOB, (fmt, arg)); \
(void) fprintf(job->cmdFILE, fmt, arg); \
(void) fflush(job->cmdFILE);
@@ -809,7 +809,7 @@ JobFinish(job, status)
}
if (WIFEXITED(*status)) {
- DEBUGF(JOB, "Process %d exited.\n", job->pid);
+ DEBUGF(JOB, ("Process %d exited.\n", job->pid));
if (WEXITSTATUS(*status) != 0) {
if (usePipes && job->node != lastNode) {
MESSAGE(out, job->node);
@@ -830,7 +830,7 @@ JobFinish(job, status)
(void) fprintf(out, "*** Completed successfully\n");
}
} else if (WIFSTOPPED(*status)) {
- DEBUGF(JOB, "Process %d stopped.\n", job->pid);
+ DEBUGF(JOB, ("Process %d stopped.\n", job->pid));
if (usePipes && job->node != lastNode) {
MESSAGE(out, job->node);
lastNode = job->node;
@@ -861,7 +861,7 @@ JobFinish(job, status)
(void) fprintf(out, "*** Continued\n");
}
if (!(job->flags & JOB_CONTINUING)) {
- DEBUGF(JOB, "Warning: process %d was not continuing.\n", job->pid);
+ DEBUGF(JOB, ("Warning: process %d was not continuing.\n", job->pid));
#ifdef notdef
/*
* We don't really want to restart a job from scratch just
@@ -876,12 +876,12 @@ JobFinish(job, status)
Lst_AtEnd(jobs, (void *)job);
nJobs += 1;
if (!(job->flags & JOB_REMOTE)) {
- DEBUGF(JOB, "Process %d is continuing locally.\n", job->pid);
+ DEBUGF(JOB, ("Process %d is continuing locally.\n", job->pid));
nLocal += 1;
}
if (nJobs == maxJobs) {
jobFull = TRUE;
- DEBUGF(JOB, "Job queue is full.\n");
+ DEBUGF(JOB, ("Job queue is full.\n"));
}
(void) fflush(out);
return;
@@ -1163,13 +1163,13 @@ JobExec(job, argv)
if (DEBUG(JOB)) {
int i;
- DEBUGF(JOB, "Running %s %sly\n", job->node->name,
- job->flags&JOB_REMOTE?"remote":"local");
- DEBUGF(JOB, "\tCommand: ");
+ DEBUGF(JOB, ("Running %s %sly\n", job->node->name,
+ job->flags&JOB_REMOTE?"remote":"local"));
+ DEBUGF(JOB, ("\tCommand: "));
for (i = 0; argv[i] != NULL; i++) {
- DEBUGF(JOB, "%s ", argv[i]);
+ DEBUGF(JOB, ("%s ", argv[i]));
}
- DEBUGF(JOB, "\n");
+ DEBUGF(JOB, ("\n"));
}
/*
@@ -1439,7 +1439,7 @@ JobRestart(job)
}
(void)Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- DEBUGF(JOB, "Job queue is full.\n");
+ DEBUGF(JOB, ("Job queue is full.\n"));
return;
}
#ifdef REMOTE
@@ -1459,7 +1459,7 @@ JobRestart(job)
nJobs += 1;
if (nJobs == maxJobs) {
jobFull = TRUE;
- DEBUGF(JOB, "Job queue is full.\n");
+ DEBUGF(JOB, ("Job queue is full.\n"));
}
} else if (job->flags & JOB_RESTART) {
/*
@@ -1474,7 +1474,7 @@ JobRestart(job)
JobMakeArgv(job, argv);
- DEBUGF(JOB, "Restarting %s...", job->node->name);
+ DEBUGF(JOB, ("Restarting %s...", job->node->name));
#ifdef REMOTE
if ((job->node->type&OP_NOEXPORT) ||
(nLocal < maxLocal && runLocalFirst)
@@ -1490,16 +1490,16 @@ JobRestart(job)
* Can't be exported and not allowed to run locally -- put it
* back on the hold queue and mark the table full
*/
- DEBUGF(JOB, "holding\n");
+ DEBUGF(JOB, ("holding\n"));
(void)Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- DEBUGF(JOB, "Job queue is full.\n");
+ DEBUGF(JOB, ("Job queue is full.\n"));
return;
} else {
/*
* Job may be run locally.
*/
- DEBUGF(JOB, "running locally\n");
+ DEBUGF(JOB, ("running locally\n"));
job->flags &= ~JOB_REMOTE;
}
}
@@ -1508,7 +1508,7 @@ JobRestart(job)
/*
* Can be exported. Hooray!
*/
- DEBUGF(JOB, "exporting\n");
+ DEBUGF(JOB, ("exporting\n"));
job->flags |= JOB_REMOTE;
}
#endif
@@ -1518,7 +1518,7 @@ JobRestart(job)
* The job has stopped and needs to be restarted. Why it stopped,
* we don't know...
*/
- DEBUGF(JOB, "Resuming %s...", job->node->name);
+ DEBUGF(JOB, ("Resuming %s...", job->node->name));
if (((job->flags & JOB_REMOTE) ||
(nLocal < maxLocal) ||
#ifdef REMOTE
@@ -1558,7 +1558,7 @@ JobRestart(job)
JobFinish(job, &status);
job->flags &= ~(JOB_RESUME|JOB_CONTINUING);
- DEBUGF(JOB, "done\n");
+ DEBUGF(JOB, ("done\n"));
} else {
Error("couldn't resume %s: %s",
job->node->name, strerror(errno));
@@ -1571,10 +1571,10 @@ JobRestart(job)
* Job cannot be restarted. Mark the table as full and
* place the job back on the list of stopped jobs.
*/
- DEBUGF(JOB, "table full\n");
+ DEBUGF(JOB, ("table full\n"));
(void) Lst_AtFront(stoppedJobs, (void *)job);
jobFull = TRUE;
- DEBUGF(JOB, "Job queue is full.\n");
+ DEBUGF(JOB, ("Job queue is full.\n"));
}
}
}
@@ -1867,7 +1867,7 @@ JobStart(gn, flags, previous)
*/
jobFull = TRUE;
- DEBUGF(JOB, "Can only run job locally.\n");
+ DEBUGF(JOB, ("Can only run job locally.\n"));
job->flags |= JOB_RESTART;
(void) Lst_AtEnd(stoppedJobs, (void *)job);
} else {
@@ -1877,7 +1877,7 @@ JobStart(gn, flags, previous)
* at least say the table is full.
*/
jobFull = TRUE;
- DEBUGF(JOB, "Local job queue is full.\n");
+ DEBUGF(JOB, ("Local job queue is full.\n"));
}
JobExec(job, argv);
}
@@ -1985,7 +1985,7 @@ end_loop:
nRead = read(job->inPipe, &job->outBuf[job->curPos],
JOB_BUFSIZE - job->curPos);
if (nRead < 0) {
- DEBUGF(JOB, "JobDoOutput(piperead)");
+ DEBUGF(JOB, ("JobDoOutput(piperead)"));
nr = 0;
} else {
nr = nRead;
@@ -2170,7 +2170,7 @@ Job_CatchChildren(block)
while ((pid = waitpid((pid_t) -1, &status,
(block?0:WNOHANG)|WUNTRACED)) > 0)
{
- DEBUGF(JOB, "Process %d exited or stopped.\n", pid);
+ DEBUGF(JOB, ("Process %d exited or stopped.\n", pid));
jnode = Lst_Find(jobs, (void *)&pid, JobCmpPid);
@@ -2191,11 +2191,11 @@ Job_CatchChildren(block)
job = (Job *) Lst_Datum(jnode);
(void) Lst_Remove(jobs, jnode);
nJobs -= 1;
- DEBUGF(JOB, "Job queue is no longer full.\n");
+ DEBUGF(JOB, ("Job queue is no longer full.\n"));
jobFull = FALSE;
#ifdef REMOTE
if (!(job->flags & JOB_REMOTE)) {
- DEBUGF(JOB, "Job queue has one fewer local process.\n");
+ DEBUGF(JOB, ("Job queue has one fewer local process.\n"));
nLocal -= 1;
}
#else
@@ -2738,8 +2738,8 @@ JobInterrupt(runINTERRUPT, signo)
}
#else
if (job->pid) {
- DEBUGF(JOB, "JobInterrupt passing signal to child %d.\n",
- job->pid);
+ DEBUGF(JOB, ("JobInterrupt passing signal to child %d.\n",
+ job->pid));
KILL(job->pid, signo);
}
#endif /* RMT_WANTS_SIGNALS */
@@ -2766,7 +2766,7 @@ JobInterrupt(runINTERRUPT, signo)
/*
* Resume the thing so it will take the signal.
*/
- DEBUGF(JOB, "JobInterrupt passing CONT to stopped child %d.\n", job->pid);
+ DEBUGF(JOB, ("JobInterrupt passing CONT to stopped child %d.\n", job->pid));
KILL(job->pid, SIGCONT);
#ifdef RMT_WANTS_SIGNALS
if (job->flags & JOB_REMOTE) {
@@ -2943,7 +2943,7 @@ JobFlagForMigration(hostID)
Job *job; /* job descriptor for dead child */
LstNode jnode; /* list element for finding job */
- DEBUGF(JOB, "JobFlagForMigration(%d) called.\n", hostID);
+ DEBUGF(JOB, ("JobFlagForMigration(%d) called.\n", hostID));
jnode = Lst_Find(jobs, (void *)hostID, JobCmpRmtID);
if (jnode == NULL) {
@@ -2957,7 +2957,7 @@ JobFlagForMigration(hostID)
}
job = (Job *) Lst_Datum(jnode);
- DEBUGF(JOB, "JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name);
+ DEBUGF(JOB, ("JobFlagForMigration(%d) found job '%s'.\n", hostID, job->node->name));
KILL(job->pid, SIGSTOP);
@@ -2985,7 +2985,7 @@ static void
JobRestartJobs()
{
while (!jobFull && !Lst_IsEmpty(stoppedJobs)) {
- DEBUGF(JOB, "Job queue is not full. Restarting a stopped job.\n");
+ DEBUGF(JOB, ("Job queue is not full. Restarting a stopped job.\n"));
JobRestart((Job *)Lst_DeQueue(stoppedJobs));
}
}
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index f143975..df8778e 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -1126,6 +1126,28 @@ bad:
*res = '\0';
return res;
}
+
+/*-
+ * Debug --
+ * Print a debugging message given its format.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The message is printed.
+ */
+/* VARARGS */
+void
+Debug(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ (void)vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ (void)fflush(stderr);
+}
/*-
* Error --
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index b8773f9..50d48a7 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -157,9 +157,9 @@ Make_OODate (gn)
if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
(void) Dir_MTime (gn);
if (gn->mtime != 0) {
- DEBUGF(MAKE, "modified %s...", Targ_FmtTime(gn->mtime));
+ DEBUGF(MAKE, ("modified %s...", Targ_FmtTime(gn->mtime)));
} else {
- DEBUGF(MAKE, "non-existent...");
+ DEBUGF(MAKE, ("non-existent..."));
}
}
@@ -182,10 +182,10 @@ Make_OODate (gn)
* If the node is a USE node it is *never* out of date
* no matter *what*.
*/
- DEBUGF(MAKE, ".USE node...");
+ DEBUGF(MAKE, (".USE node..."));
oodate = FALSE;
} else if (gn->type & OP_LIB) {
- DEBUGF(MAKE, "library...");
+ DEBUGF(MAKE, ("library..."));
/*
* always out of date if no children and :: target
@@ -198,7 +198,7 @@ Make_OODate (gn)
* A target with the .JOIN attribute is only considered
* out-of-date if any of its children was out-of-date.
*/
- DEBUGF(MAKE, ".JOIN node...");
+ DEBUGF(MAKE, (".JOIN node..."));
oodate = gn->childMade;
} else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) {
/*
@@ -206,11 +206,11 @@ Make_OODate (gn)
* the .EXEC attribute is always considered out-of-date.
*/
if (gn->type & OP_FORCE) {
- DEBUGF(MAKE, "! operator...");
+ DEBUGF(MAKE, ("! operator..."));
} else if (gn->type & OP_PHONY) {
- DEBUGF(MAKE, ".PHONY node...");
+ DEBUGF(MAKE, (".PHONY node..."));
} else {
- DEBUGF(MAKE, ".EXEC node...");
+ DEBUGF(MAKE, (".EXEC node..."));
}
oodate = TRUE;
} else if ((gn->mtime < gn->cmtime) ||
@@ -225,17 +225,17 @@ Make_OODate (gn)
* it.
*/
if (gn->mtime < gn->cmtime) {
- DEBUGF(MAKE, "modified before source...");
+ DEBUGF(MAKE, ("modified before source..."));
} else if (gn->mtime == 0) {
- DEBUGF(MAKE, "non-existent and no sources...");
+ DEBUGF(MAKE, ("non-existent and no sources..."));
} else {
- DEBUGF(MAKE, ":: operator and no sources...");
+ DEBUGF(MAKE, (":: operator and no sources..."));
}
oodate = TRUE;
} else {
#if 0
/* WHY? */
- DEBUGF(MAKE, "source %smade...", gn->childMade ? "" : "not ");
+ DEBUGF(MAKE, ("source %smade...", gn->childMade ? "" : "not "));
oodate = gn->childMade;
#else
oodate = FALSE;
@@ -457,7 +457,7 @@ Make_Update (cgn)
if (noExecute || (cgn->type & OP_SAVE_CMDS) || Dir_MTime(cgn) == 0) {
cgn->mtime = now;
}
- DEBUGF(MAKE, "update time: %s\n", Targ_FmtTime(cgn->mtime));
+ DEBUGF(MAKE, ("update time: %s\n", Targ_FmtTime(cgn->mtime)));
#endif
}
@@ -662,7 +662,7 @@ MakeStartJobs ()
while (!Job_Full() && !Lst_IsEmpty (toBeMade)) {
gn = (GNode *) Lst_DeQueue (toBeMade);
- DEBUGF(MAKE, "Examining %s...", gn->name);
+ DEBUGF(MAKE, ("Examining %s...", gn->name));
/*
* Make sure any and all predecessors that are going to be made,
* have been.
@@ -674,7 +674,7 @@ MakeStartJobs ()
GNode *pgn = (GNode *)Lst_Datum(ln);
if (pgn->make && pgn->made == UNMADE) {
- DEBUGF(MAKE, "predecessor %s not made yet.\n", pgn->name);
+ DEBUGF(MAKE, ("predecessor %s not made yet.\n", pgn->name));
break;
}
}
@@ -691,14 +691,14 @@ MakeStartJobs ()
numNodes--;
if (Make_OODate (gn)) {
- DEBUGF(MAKE, "out-of-date\n");
+ DEBUGF(MAKE, ("out-of-date\n"));
if (queryFlag) {
return (TRUE);
}
Make_DoAllVar (gn);
Job_Make (gn);
} else {
- DEBUGF(MAKE, "up-to-date\n");
+ DEBUGF(MAKE, ("up-to-date\n"));
gn->made = UPTODATE;
if (gn->type & OP_JOIN) {
/*
diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h
index 6976a89..ee0b34e 100644
--- a/usr.bin/make/make.h
+++ b/usr.bin/make/make.h
@@ -338,11 +338,10 @@ extern int debug;
#define CONCAT(a,b) a##b
#define DEBUG(module) (debug & CONCAT(DEBUG_,module))
-#define DEBUGF(module,fmt,args...) \
+#define DEBUGF(module,args) \
do { \
if (DEBUG(module)) { \
- fprintf(stderr, fmt, ##args); \
- fflush(stderr); \
+ Debug args ; \
} \
} while (0)
#define ISDOT(c) ((c)[0] == '.' && (((c)[1] == '\0') || ((c)[1] == '/')))
diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h
index eb4d442..0b08e16 100644
--- a/usr.bin/make/nonints.h
+++ b/usr.bin/make/nonints.h
@@ -64,6 +64,7 @@ void For_Run(void);
/* main.c */
void Main_ParseArgLine(char *);
char *Cmd_Exec(char *, char **);
+void Debug(const char *, ...);
void Error(const char *, ...);
void Fatal(const char *, ...);
void Punt(const char *, ...);
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 8a8b91a..b52fe47 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1813,7 +1813,7 @@ Parse_FromString(str)
{
IFile *oldFile; /* state associated with this file */
- DEBUGF(FOR, "%s\n----\n", str);
+ DEBUGF(FOR, ("%s\n----\n", str));
oldFile = (IFile *) emalloc (sizeof (IFile));
oldFile->lineno = lineno;
diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c
index e6665da..ccf137e 100644
--- a/usr.bin/make/suff.c
+++ b/usr.bin/make/suff.c
@@ -414,19 +414,19 @@ SuffInsert (l, s)
}
Lst_Close (l);
- DEBUGF(SUFF, "inserting %s(%d)...", s->name, s->sNum);
+ DEBUGF(SUFF, ("inserting %s(%d)...", s->name, s->sNum));
if (ln == NULL) {
- DEBUGF(SUFF, "at end of list\n");
+ DEBUGF(SUFF, ("at end of list\n"));
(void)Lst_AtEnd (l, (void *)s);
s->refCount++;
(void)Lst_AtEnd(s->ref, (void *) l);
} else if (s2->sNum != s->sNum) {
- DEBUGF(SUFF, "before %s(%d)\n", s2->name, s2->sNum);
+ DEBUGF(SUFF, ("before %s(%d)\n", s2->name, s2->sNum));
(void)Lst_Insert (l, ln, (void *)s);
s->refCount++;
(void)Lst_AtEnd(s->ref, (void *) l);
} else {
- DEBUGF(SUFF, "already there\n");
+ DEBUGF(SUFF, ("already there\n"));
}
}
@@ -619,8 +619,8 @@ Suff_AddTransform (line)
/*
* link the two together in the proper relationship and order
*/
- DEBUGF(SUFF, "defining transformation from `%s' to `%s'\n",
- s->name, t->name);
+ DEBUGF(SUFF, ("defining transformation from `%s' to `%s'\n",
+ s->name, t->name));
SuffInsert (t->children, s);
SuffInsert (s->parents, t);
@@ -658,8 +658,8 @@ Suff_EndTransform(gnp, dummy)
(void)SuffParseTransform(gn->name, &s, &t);
- DEBUGF(SUFF, "deleting transformation from `%s' to `%s'\n",
- s->name, t->name);
+ DEBUGF(SUFF, ("deleting transformation from `%s' to `%s'\n",
+ s->name, t->name));
/*
* Remove the source from the target's children list. We check for a
@@ -676,7 +676,7 @@ Suff_EndTransform(gnp, dummy)
*/
SuffRemove(s->parents, t);
} else if (gn->type & OP_TRANSFORM) {
- DEBUGF(SUFF, "transformation %s complete\n", gn->name);
+ DEBUGF(SUFF, ("transformation %s complete\n", gn->name));
}
return(dummy ? 0 : 0);
@@ -1150,7 +1150,7 @@ SuffFindThem (srcs, slst)
while (!Lst_IsEmpty (srcs)) {
s = (Src *) Lst_DeQueue (srcs);
- DEBUGF(SUFF, "\ttrying %s...", s->file);
+ DEBUGF(SUFF, ("\ttrying %s...", s->file));
/*
* A file is considered to exist if either a node exists in the
@@ -1173,14 +1173,14 @@ SuffFindThem (srcs, slst)
break;
}
- DEBUGF(SUFF, "not there\n");
+ DEBUGF(SUFF, ("not there\n"));
SuffAddLevel (srcs, s);
Lst_AtEnd(slst, (void *) s);
}
if (rs) {
- DEBUGF(SUFF, "got it\n");
+ DEBUGF(SUFF, ("got it\n"));
}
return (rs);
}
@@ -1266,7 +1266,7 @@ SuffFindCmds (targ, slst)
Lst_AtEnd(targ->cp, (void *) ret);
#endif
Lst_AtEnd(slst, (void *) ret);
- DEBUGF(SUFF, "\tusing existing source %s\n", s->name);
+ DEBUGF(SUFF, ("\tusing existing source %s\n", s->name));
return (ret);
}
}
@@ -1317,7 +1317,7 @@ SuffExpandChildren(cgnp, pgnp)
* the children list.
*/
if (strchr(cgn->name, '$') != (char *)NULL) {
- DEBUGF(SUFF, "Expanding \"%s\"...", cgn->name);
+ DEBUGF(SUFF, ("Expanding \"%s\"...", cgn->name));
cp = Var_Subst(NULL, cgn->name, pgn, TRUE);
if (cp != (char *)NULL) {
@@ -1406,7 +1406,7 @@ SuffExpandChildren(cgnp, pgnp)
while(!Lst_IsEmpty(members)) {
gn = (GNode *)Lst_DeQueue(members);
- DEBUGF(SUFF, "%s...", gn->name);
+ DEBUGF(SUFF, ("%s...", gn->name));
if (Lst_Member(pgn->children, (void *)gn) == NULL) {
(void)Lst_Append(pgn->children, prevLN, (void *)gn);
prevLN = Lst_Succ(prevLN);
@@ -1427,7 +1427,7 @@ SuffExpandChildren(cgnp, pgnp)
ln = Lst_Member(pgn->children, (void *)cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
- DEBUGF(SUFF, "\n");
+ DEBUGF(SUFF, ("\n"));
} else if (Dir_HasWildcards(cgn->name)) {
Lst exp; /* List of expansions */
Lst path; /* Search path along which to expand */
@@ -1443,12 +1443,12 @@ SuffExpandChildren(cgnp, pgnp)
cp = cgn->name + strlen(cgn->name);
ln = Lst_Find(sufflist, (void *)cp, SuffSuffIsSuffixP);
- DEBUGF(SUFF, "Wildcard expanding \"%s\"...", cgn->name);
+ DEBUGF(SUFF, ("Wildcard expanding \"%s\"...", cgn->name));
if (ln != NULL) {
Suff *s = (Suff *)Lst_Datum(ln);
- DEBUGF(SUFF, "suffix is \"%s\"...", s->name);
+ DEBUGF(SUFF, ("suffix is \"%s\"...", s->name));
path = s->searchPath;
} else {
/*
@@ -1469,7 +1469,7 @@ SuffExpandChildren(cgnp, pgnp)
*/
cp = (char *)Lst_DeQueue(exp);
- DEBUGF(SUFF, "%s...", cp);
+ DEBUGF(SUFF, ("%s...", cp));
gn = Targ_FindNode(cp, TARG_CREATE);
/*
@@ -1496,7 +1496,7 @@ SuffExpandChildren(cgnp, pgnp)
ln = Lst_Member(pgn->children, (void *)cgn);
pgn->unmade--;
Lst_Remove(pgn->children, ln);
- DEBUGF(SUFF, "\n");
+ DEBUGF(SUFF, ("\n"));
}
return(0);
@@ -1580,7 +1580,7 @@ SuffApplyTransform(tGn, sGn, t, s)
gn = (GNode *)Lst_Datum(ln);
- DEBUGF(SUFF, "\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name);
+ DEBUGF(SUFF, ("\tapplying %s -> %s to \"%s\"\n", s->name, t->name, tGn->name));
/*
* Record last child for expansion purposes
@@ -1686,7 +1686,7 @@ SuffFindArchiveDeps(gn, slst)
/*
* Didn't know what it was -- use .NULL suffix if not in make mode
*/
- DEBUGF(SUFF, "using null suffix\n");
+ DEBUGF(SUFF, ("using null suffix\n"));
ms = suffNull;
}
@@ -1716,8 +1716,8 @@ SuffFindArchiveDeps(gn, slst)
* Got one -- apply it
*/
if (!SuffApplyTransform(gn, mem, (Suff *)Lst_Datum(ln), ms)) {
- DEBUGF(SUFF, "\tNo transformation from %s -> %s\n",
- ms->name, ((Suff *)Lst_Datum(ln))->name);
+ DEBUGF(SUFF, ("\tNo transformation from %s -> %s\n",
+ ms->name, ((Suff *)Lst_Datum(ln))->name));
}
}
}
@@ -1859,7 +1859,7 @@ SuffFindNormalDeps(gn, slst)
* Handle target of unknown suffix...
*/
if (Lst_IsEmpty(targs) && suffNull != NULL) {
- DEBUGF(SUFF, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name);
+ DEBUGF(SUFF, ("\tNo known suffix on %s. Using .NULL suffix\n", gn->name));
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
@@ -1880,10 +1880,10 @@ SuffFindNormalDeps(gn, slst)
if (Lst_IsEmpty(gn->commands) && Lst_IsEmpty(gn->children))
SuffAddLevel(srcs, targ);
else {
- DEBUGF(SUFF, "not ");
+ DEBUGF(SUFF, ("not "));
}
- DEBUGF(SUFF, "adding suffix rules\n");
+ DEBUGF(SUFF, ("adding suffix rules\n"));
(void)Lst_AtEnd(targs, (void *)targ);
}
@@ -1931,7 +1931,7 @@ SuffFindNormalDeps(gn, slst)
Lst_ForEach(gn->children, SuffExpandChildren, (void *)gn);
if (targ == NULL) {
- DEBUGF(SUFF, "\tNo valid suffix on %s\n", gn->name);
+ DEBUGF(SUFF, ("\tNo valid suffix on %s\n", gn->name));
sfnd_abort:
/*
@@ -2174,7 +2174,7 @@ SuffFindDeps (gn, slst)
gn->type |= OP_DEPS_FOUND;
}
- DEBUGF(SUFF, "SuffFindDeps (%s)\n", gn->name);
+ DEBUGF(SUFF, ("SuffFindDeps (%s)\n", gn->name));
if (gn->type & OP_ARCHV) {
SuffFindArchiveDeps(gn, slst);
diff --git a/usr.bin/make/targ.c b/usr.bin/make/targ.c
index 86bd080..04611e0 100644
--- a/usr.bin/make/targ.c
+++ b/usr.bin/make/targ.c
@@ -488,7 +488,7 @@ Targ_PrintType (type)
int tbit;
#define PRINTBIT(attr) case CONCAT(OP_,attr): printf("." #attr " "); break
-#define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, "." #attr " "); break
+#define PRINTDBIT(attr) case CONCAT(OP_,attr): DEBUGF(TARG, ("." #attr " ")); break
type &= ~OP_OPMASK;
@@ -509,7 +509,7 @@ Targ_PrintType (type)
PRINTBIT(NOTMAIN);
PRINTDBIT(LIB);
/*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
- case OP_MEMBER: DEBUGF(TARG, ".MEMBER "); break;
+ case OP_MEMBER: DEBUGF(TARG, (".MEMBER ")); break;
PRINTDBIT(ARCHV);
}
}
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 472e737..d6f09c8 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -396,7 +396,7 @@ VarAdd (name, val, ctxt)
(void) Lst_AtFront (ctxt->context, (void *)v);
(void) Lst_AtEnd (allVars, (void *) v);
- DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name, val);
+ DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
}
@@ -444,7 +444,7 @@ Var_Delete(name, ctxt)
{
LstNode ln;
- DEBUGF(VAR, "%s:delete %s\n", ctxt->name, name);
+ DEBUGF(VAR, ("%s:delete %s\n", ctxt->name, name));
ln = Lst_Find(ctxt->context, (void *)name, VarCmp);
if (ln != NULL) {
Var *v;
@@ -499,7 +499,7 @@ Var_Set (name, val, ctxt)
Buf_Discard(v->val, Buf_Size(v->val));
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
- DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name, val);
+ DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name, val));
}
/*
* Any variables given on the command line are automatically exported
@@ -550,8 +550,8 @@ Var_Append (name, val, ctxt)
Buf_AddByte(v->val, (Byte)' ');
Buf_AddBytes(v->val, strlen(val), (Byte *)val);
- DEBUGF(VAR, "%s:%s = %s\n", ctxt->name, name,
- (char *) Buf_GetAll(v->val, (int *)NULL));
+ DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, name,
+ (char *) Buf_GetAll(v->val, (int *)NULL)));
if (v->flags & VAR_FROM_ENV) {
/*
@@ -1772,7 +1772,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
char *newStr; /* New value to return */
char termc; /* Character which terminated scan */
- DEBUGF(VAR, "Applying :%c to \"%s\"\n", *tstr, str);
+ DEBUGF(VAR, ("Applying :%c to \"%s\"\n", *tstr, str));
switch (*tstr) {
case 'U':
if (tstr[1] == endc || tstr[1] == ':') {
@@ -2241,7 +2241,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
}
}
}
- DEBUGF(VAR, "Result is \"%s\"\n", newStr);
+ DEBUGF(VAR, ("Result is \"%s\"\n", newStr));
if (*freePtr) {
free (str);
OpenPOWER on IntegriCloud