diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-09-17 22:31:26 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-09-17 22:31:26 +0000 |
commit | 7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b (patch) | |
tree | e9bbc739d9ad215c67355ae9b0a1a298016a17b9 /usr.bin/make/dir.c | |
parent | 086f36bd966184831309cca6a2187aa38f6b0393 (diff) | |
download | FreeBSD-src-7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b.zip FreeBSD-src-7fd8427cf78ed3d6ed80aafb4dd8b2ae5c85715b.tar.gz |
Move common use of if (DEBUG(FOO)) printf... to DEBUGF(FOO, ...), using
variable length arguments to a macro. Bump version as this makes DEBUG
statements *always* go to stderr rather than sometimes stdout. There are
a few stragglers, which I will take care of as soon as I can. Mostly these
relate to the need-for-death-of some of the remote job code.
Nearby stylistic nits and XXX added/fixed where appropriate.
Diffstat (limited to 'usr.bin/make/dir.c')
-rw-r--r-- | usr.bin/make/dir.c | 104 |
1 files changed, 27 insertions, 77 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index 9bb6d6f..e8eb297 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -541,7 +541,7 @@ DirPrintWord(word, dummy) void * word; void * dummy; { - printf("%s ", (char *) word); + DEBUGF(DIR, "%s ", (char *) word); return(dummy ? 0 : 0); } @@ -569,9 +569,7 @@ Dir_Expand (word, path, expansions) { char *cp; - if (DEBUG(DIR)) { - printf("expanding \"%s\"...", word); - } + DEBUGF(DIR, "expanding \"%s\"...", word); cp = strchr(word, '{'); if (cp) { @@ -655,7 +653,7 @@ Dir_Expand (word, path, expansions) } if (DEBUG(DIR)) { Lst_ForEach(expansions, DirPrintWord, (void *) 0); - fputc('\n', stdout); + DEBUGF(DIR, "\n"); } } @@ -705,9 +703,7 @@ Dir_FindFile (name, path) cp = name; } - if (DEBUG(DIR)) { - printf("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. @@ -716,18 +712,14 @@ Dir_FindFile (name, path) */ if ((!hasSlash || (cp - name == 2 && *name == '.')) && (Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL)) { - if (DEBUG(DIR)) { - printf("in '.'\n"); - } + DEBUGF(DIR, "in '.'\n"); hits += 1; dot->hits += 1; return (estrdup (name)); } if (Lst_Open (path) == FAILURE) { - if (DEBUG(DIR)) { - printf("couldn't open path, file not found\n"); - } + DEBUGF(DIR, "couldn't open path, file not found\n"); misses += 1; return ((char *) NULL); } @@ -742,13 +734,9 @@ Dir_FindFile (name, path) */ while ((ln = Lst_Next (path)) != NULL) { p = (Path *) Lst_Datum (ln); - if (DEBUG(DIR)) { - printf("%s...", p->name); - } + DEBUGF(DIR, "%s...", p->name); if (Hash_FindEntry (&p->files, cp) != (Hash_Entry *)NULL) { - if (DEBUG(DIR)) { - printf("here..."); - } + DEBUGF(DIR, "here..."); if (hasSlash) { /* * If the name had a slash, its initial components and p's @@ -764,16 +752,12 @@ Dir_FindFile (name, path) p1 -= 1; p2 -= 1; } if (p2 >= name || (p1 >= p->name && *p1 != '/')) { - if (DEBUG(DIR)) { - printf("component mismatch -- continuing..."); - } + DEBUGF(DIR, "component mismatch -- continuing..."); continue; } } file = str_concat (p->name, cp, STR_ADDSLASH); - if (DEBUG(DIR)) { - printf("returning %s\n", file); - } + DEBUGF(DIR, "returning %s\n", file); Lst_Close (path); p->hits += 1; hits += 1; @@ -788,9 +772,7 @@ Dir_FindFile (name, path) continue; } if (*p1 == '\0' && p2 == cp - 1) { - if (DEBUG(DIR)) { - printf("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); } @@ -810,9 +792,7 @@ Dir_FindFile (name, path) * end). This phase is only performed if the file is *not* absolute. */ if (!hasSlash) { - if (DEBUG(DIR)) { - printf("failed.\n"); - } + DEBUGF(DIR, "failed.\n"); misses += 1; return ((char *) NULL); } @@ -820,9 +800,7 @@ Dir_FindFile (name, path) if (*name != '/') { Boolean checkedDot = FALSE; - if (DEBUG(DIR)) { - printf("failed. Trying subdirectories..."); - } + DEBUGF(DIR, "failed. Trying subdirectories..."); (void) Lst_Open (path); while ((ln = Lst_Next (path)) != NULL) { p = (Path *) Lst_Datum (ln); @@ -835,15 +813,10 @@ Dir_FindFile (name, path) file = estrdup(name); checkedDot = TRUE; } - if (DEBUG(DIR)) { - printf("checking %s...", file); - } - + DEBUGF(DIR, "checking %s...", file); if (stat (file, &stb) == 0) { - if (DEBUG(DIR)) { - printf("got it.\n"); - } + DEBUGF(DIR, "got it.\n"); Lst_Close (path); @@ -866,10 +839,7 @@ Dir_FindFile (name, path) * Save the modification time so if it's needed, we don't have * to fetch it again. */ - if (DEBUG(DIR)) { - printf("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); @@ -880,9 +850,7 @@ Dir_FindFile (name, path) } } - if (DEBUG(DIR)) { - printf("failed. "); - } + DEBUGF(DIR, "failed. "); Lst_Close (path); if (checkedDot) { @@ -890,9 +858,7 @@ Dir_FindFile (name, path) * Already checked by the given name, since . was in the path, * so no point in proceeding... */ - if (DEBUG(DIR)) { - printf("Checked . already, returning NULL\n"); - } + DEBUGF(DIR, "Checked . already, returning NULL\n"); return(NULL); } } @@ -933,29 +899,20 @@ Dir_FindFile (name, path) return ((char *) NULL); } #else /* !notdef */ - if (DEBUG(DIR)) { - printf("Looking for \"%s\"...", name); - } + DEBUGF(DIR, "Looking for \"%s\"...", name); bigmisses += 1; entry = Hash_FindEntry(&mtimes, name); if (entry != (Hash_Entry *)NULL) { - if (DEBUG(DIR)) { - printf("got it (in mtime cache)\n"); - } - return(estrdup(name)); + DEBUGF(DIR, "got it (in mtime cache)\n"); + return (estrdup(name)); } else if (stat (name, &stb) == 0) { entry = Hash_CreateEntry(&mtimes, name, (Boolean *)NULL); - if (DEBUG(DIR)) { - printf("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 { - if (DEBUG(DIR)) { - printf("failed. Returning NULL\n"); - } + DEBUGF(DIR, "failed. Returning NULL\n"); return ((char *)NULL); } #endif /* notdef */ @@ -1004,10 +961,8 @@ Dir_MTime (gn) * see if the file was actually updated, so we need to actually go * to the filesystem. */ - if (DEBUG(DIR)) { - printf("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) { @@ -1061,10 +1016,7 @@ Dir_AddDir (path, name) (void)Lst_AtEnd (path, (void *)p); } } else { - if (DEBUG(DIR)) { - printf("Caching %s...", name); - fflush(stdout); - } + DEBUGF(DIR, "Caching %s...", name); if ((d = opendir (name)) != (DIR *) NULL) { p = (Path *) emalloc (sizeof (Path)); @@ -1101,9 +1053,7 @@ Dir_AddDir (path, name) (void)Lst_AtEnd (openDirectories, (void *)p); (void)Lst_AtEnd (path, (void *)p); } - if (DEBUG(DIR)) { - printf("done\n"); - } + DEBUGF(DIR, "done\n"); } } |