Module Name: src Committed By: rillig Date: Sun Dec 6 10:49:02 UTC 2020
Modified Files: src/usr.bin/make: dir.c suff.c targ.c var.c Log Message: make(1): inline macros for debug logging No changes to the resulting binary, except for the line numbers in assertions. To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/dir.c cvs rdiff -u -r1.326 -r1.327 src/usr.bin/make/suff.c cvs rdiff -u -r1.152 -r1.153 src/usr.bin/make/targ.c cvs rdiff -u -r1.707 -r1.708 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/dir.c diff -u src/usr.bin/make/dir.c:1.249 src/usr.bin/make/dir.c:1.250 --- src/usr.bin/make/dir.c:1.249 Fri Dec 4 14:39:56 2020 +++ src/usr.bin/make/dir.c Sun Dec 6 10:49:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -136,11 +136,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.249 2020/12/04 14:39:56 rillig Exp $"); - -#define DIR_DEBUG0(text) DEBUG0(DIR, text) -#define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1) -#define DIR_DEBUG2(fmt, arg1, arg2) DEBUG2(DIR, fmt, arg1, arg2) +MAKE_RCSID("$NetBSD: dir.c,v 1.250 2020/12/06 10:49:02 rillig Exp $"); /* A search path is a list of CachedDir structures. A CachedDir has in it the * name of the directory and the names of all the files in the directory. @@ -369,12 +365,12 @@ static void OpenDirs_Done(OpenDirs *odirs) { CachedDirListNode *ln = odirs->list.first; - DIR_DEBUG1("OpenDirs_Done: %u entries to remove\n", + DEBUG1(DIR, "OpenDirs_Done: %u entries to remove\n", odirs->table.numEntries); while (ln != NULL) { CachedDirListNode *next = ln->next; CachedDir *dir = ln->datum; - DIR_DEBUG2("OpenDirs_Done: refCount %d for \"%s\"\n", + DEBUG2(DIR, "OpenDirs_Done: refCount %d for \"%s\"\n", dir->refCount, dir->name); CachedDir_Unref(dir); /* removes the dir from odirs->list */ ln = next; @@ -429,8 +425,8 @@ cached_stats(const char *pathname, struc cst = HashTable_FindValue(tbl, pathname); if (cst != NULL && !(flags & CST_UPDATE)) { *out_cst = *cst; - DIR_DEBUG2("Using cached time %s for %s\n", - Targ_FmtTime(cst->cst_mtime), pathname); + DEBUG2(DIR, "Using cached time %s for %s\n", + Targ_FmtTime(cst->cst_mtime), pathname); return 0; } @@ -450,8 +446,8 @@ cached_stats(const char *pathname, struc cst->cst_mode = sys_st.st_mode; *out_cst = *cst; - DIR_DEBUG2(" Caching %s for %s\n", - Targ_FmtTime(sys_st.st_mtime), pathname); + DEBUG2(DIR, " Caching %s for %s\n", + Targ_FmtTime(sys_st.st_mtime), pathname); return 0; } @@ -838,7 +834,7 @@ Dir_Expand(const char *word, SearchPath assert(path != NULL); assert(expansions != NULL); - DIR_DEBUG1("Expanding \"%s\"... ", word); + DEBUG1(DIR, "Expanding \"%s\"... ", word); cp = strchr(word, '{'); if (cp != NULL) { @@ -942,13 +938,13 @@ DirLookup(CachedDir *dir, const char *ba { char *file; /* the current filename to check */ - DIR_DEBUG1(" %s ...\n", dir->name); + DEBUG1(DIR, " %s ...\n", dir->name); if (!HashSet_Contains(&dir->files, base)) return NULL; file = str_concat3(dir->name, "/", base); - DIR_DEBUG1(" returning %s\n", file); + DEBUG1(DIR, " returning %s\n", file); dir->hits++; hits++; return file; @@ -964,7 +960,7 @@ DirLookupSubdir(CachedDir *dir, const ch char *file = dir == dot ? bmake_strdup(name) : str_concat3(dir->name, "/", name); - DIR_DEBUG1("checking %s ...\n", file); + DEBUG1(DIR, "checking %s ...\n", file); if (cached_stat(file, &cst) == 0) { nearmisses++; @@ -984,7 +980,7 @@ DirLookupAbs(CachedDir *dir, const char const char *dnp; /* pointer into dir->name */ const char *np; /* pointer into name */ - DIR_DEBUG1(" %s ...\n", dir->name); + DEBUG1(DIR, " %s ...\n", dir->name); /* * If the file has a leading path component and that component @@ -999,13 +995,13 @@ DirLookupAbs(CachedDir *dir, const char return NULL; if (!HashSet_Contains(&dir->files, cp)) { - DIR_DEBUG0(" must be here but isn't -- returning\n"); + DEBUG0(DIR, " must be here but isn't -- returning\n"); return bmake_strdup(""); /* to terminate the search */ } dir->hits++; hits++; - DIR_DEBUG1(" returning %s\n", name); + DEBUG1(DIR, " returning %s\n", name); return bmake_strdup(name); } @@ -1016,14 +1012,14 @@ DirFindDot(const char *name, const char { if (HashSet_Contains(&dot->files, base)) { - DIR_DEBUG0(" in '.'\n"); + DEBUG0(DIR, " in '.'\n"); hits++; dot->hits++; return bmake_strdup(name); } if (cur != NULL && HashSet_Contains(&cur->files, base)) { - DIR_DEBUG1(" in ${.CURDIR} = %s\n", cur->name); + DEBUG1(DIR, " in ${.CURDIR} = %s\n", cur->name); hits++; cur->hits++; return str_concat3(cur->name, "/", base); @@ -1061,10 +1057,10 @@ Dir_FindFile(const char *name, SearchPat lastSlash = strrchr(name, '/'); base = lastSlash != NULL ? lastSlash + 1 : name; - DIR_DEBUG1("Searching for %s ...", name); + DEBUG1(DIR, "Searching for %s ...", name); if (path == NULL) { - DIR_DEBUG0("couldn't open path, file not found\n"); + DEBUG0(DIR, "couldn't open path, file not found\n"); misses++; return NULL; } @@ -1073,10 +1069,10 @@ Dir_FindFile(const char *name, SearchPat CachedDir *dir = path->first->datum; if (dir == dotLast) { seenDotLast = TRUE; - DIR_DEBUG0("[dot last]..."); + DEBUG0(DIR, "[dot last]..."); } } - DIR_DEBUG0("\n"); + DEBUG0(DIR, "\n"); /* * If there's no leading directory components or if the leading @@ -1130,7 +1126,7 @@ Dir_FindFile(const char *name, SearchPat * This phase is only performed if the file is *not* absolute. */ if (lastSlash == NULL) { - DIR_DEBUG0(" failed.\n"); + DEBUG0(DIR, " failed.\n"); misses++; return NULL; } @@ -1144,7 +1140,7 @@ Dir_FindFile(const char *name, SearchPat SearchPathNode *ln; Boolean checkedDot = FALSE; - DIR_DEBUG0(" Trying subdirectories...\n"); + DEBUG0(DIR, " Trying subdirectories...\n"); if (!seenDotLast) { if (dot != NULL) { @@ -1184,7 +1180,7 @@ Dir_FindFile(const char *name, SearchPat * Already checked by the given name, since . was in * the path, so no point in proceeding. */ - DIR_DEBUG0(" Checked . already, returning NULL\n"); + DEBUG0(DIR, " Checked . already, returning NULL\n"); return NULL; } @@ -1201,7 +1197,7 @@ Dir_FindFile(const char *name, SearchPat * This is signified by DirLookupAbs() returning an empty * string. */ - DIR_DEBUG0(" Trying exact path matches...\n"); + DEBUG0(DIR, " Trying exact path matches...\n"); if (!seenDotLast && cur && ((file = DirLookupAbs(cur, name, base)) != NULL)) { @@ -1276,14 +1272,14 @@ Dir_FindFile(const char *name, SearchPat return NULL; } #else - DIR_DEBUG1(" Looking for \"%s\" ...\n", name); + DEBUG1(DIR, " Looking for \"%s\" ...\n", name); bigmisses++; if (cached_stat(name, &cst) == 0) { return bmake_strdup(name); } - DIR_DEBUG0(" failed. Returning NULL\n"); + DEBUG0(DIR, " failed. Returning NULL\n"); return NULL; #endif } @@ -1401,7 +1397,7 @@ ResolveFullName(GNode *gn) !Lst_IsEmpty(&gn->implicitParents)) fullName = ResolveMovedDepends(gn); - DIR_DEBUG2("Found '%s' as '%s'\n", + DEBUG2(DIR, "Found '%s' as '%s'\n", gn->name, fullName ? fullName : "(not found)"); } @@ -1465,11 +1461,11 @@ CacheNewDir(const char *name, SearchPath struct dirent *dp; if ((d = opendir(name)) == NULL) { - DIR_DEBUG1("Caching %s ... not found\n", name); + DEBUG1(DIR, "Caching %s ... not found\n", name); return dir; } - DIR_DEBUG1("Caching %s ...\n", name); + DEBUG1(DIR, "Caching %s ...\n", name); dir = CachedDir_New(name); @@ -1493,7 +1489,7 @@ CacheNewDir(const char *name, SearchPath if (path != NULL) Lst_Append(path, CachedDir_Ref(dir)); - DIR_DEBUG1("Caching %s done\n", name); + DEBUG1(DIR, "Caching %s done\n", name); return dir; } Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.326 src/usr.bin/make/suff.c:1.327 --- src/usr.bin/make/suff.c:1.326 Sat Dec 5 18:38:02 2020 +++ src/usr.bin/make/suff.c Sun Dec 6 10:49:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.327 2020/12/06 10:49:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -114,11 +114,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $"); - -#define SUFF_DEBUG0(text) DEBUG0(SUFF, text) -#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) -#define SUFF_DEBUG2(fmt, arg1, arg2) DEBUG2(SUFF, fmt, arg1, arg2) +MAKE_RCSID("$NetBSD: suff.c,v 1.327 2020/12/06 10:49:02 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -442,7 +438,7 @@ SuffixList_Insert(SuffixList *list, Suff } if (ln == NULL) { - SUFF_DEBUG2("inserting \"%s\" (%d) at end of list\n", + DEBUG2(SUFF, "inserting \"%s\" (%d) at end of list\n", suff->name, suff->sNum); Lst_Append(list, Suffix_Ref(suff)); Lst_Append(&suff->ref, list); @@ -452,7 +448,7 @@ SuffixList_Insert(SuffixList *list, Suff Lst_InsertBefore(list, ln, Suffix_Ref(suff)); Lst_Append(&suff->ref, list); } else { - SUFF_DEBUG2("\"%s\" (%d) is already there\n", + DEBUG2(SUFF, "\"%s\" (%d) is already there\n", suff->name, suff->sNum); } } @@ -622,7 +618,7 @@ Suff_AddTransform(const char *name) } /* Link the two together in the proper relationship and order. */ - SUFF_DEBUG2("defining transformation from `%s' to `%s'\n", + DEBUG2(SUFF, "defining transformation from `%s' to `%s'\n", srcSuff->name, targSuff->name); Relate(srcSuff, targSuff); @@ -652,7 +648,7 @@ Suff_EndTransform(GNode *gn) return; if (!Lst_IsEmpty(&gn->commands) || !Lst_IsEmpty(&gn->children)) { - SUFF_DEBUG1("transformation %s complete\n", gn->name); + DEBUG1(SUFF, "transformation %s complete\n", gn->name); return; } @@ -663,7 +659,7 @@ Suff_EndTransform(GNode *gn) if (!ParseTransform(gn->name, &srcSuff, &targSuff)) return; - SUFF_DEBUG2("deleting incomplete transformation from `%s' to `%s'\n", + DEBUG2(SUFF, "deleting incomplete transformation from `%s' to `%s'\n", srcSuff->name, targSuff->name); /* @@ -790,7 +786,7 @@ UpdateTarget(GNode *target, GNode **inou /* * Link the two together in the proper relationship and order. */ - SUFF_DEBUG2("defining transformation from `%s' to `%s'\n", + DEBUG2(SUFF, "defining transformation from `%s' to `%s'\n", srcSuff->name, targSuff->name); Relate(srcSuff, targSuff); } @@ -1123,7 +1119,7 @@ FindThem(CandidateList *srcs, CandidateS debug_printf("remove from list %p src %p:%s\n", srcs, src, src->file); #endif - SUFF_DEBUG1("\ttrying %s...", src->file); + DEBUG1(SUFF, "\ttrying %s...", src->file); /* * A file is considered to exist if either a node exists in the @@ -1132,7 +1128,7 @@ FindThem(CandidateList *srcs, CandidateS if (Targ_FindNode(src->file) != NULL) { found: HashSet_Done(&seen); - SUFF_DEBUG0("got it\n"); + DEBUG0(SUFF, "got it\n"); return src; } @@ -1145,12 +1141,12 @@ FindThem(CandidateList *srcs, CandidateS } } - SUFF_DEBUG0("not there\n"); + DEBUG0(SUFF, "not there\n"); if (HashSet_Add(&seen, src->file)) CandidateList_AddCandidatesFor(srcs, src); else { - SUFF_DEBUG1("FindThem: skipping duplicate \"%s\"\n", + DEBUG1(SUFF, "FindThem: skipping duplicate \"%s\"\n", src->file); } @@ -1230,7 +1226,7 @@ FindCmds(Candidate *targ, CandidateSearc Lst_Append(&targ->childrenList, ret); #endif CandidateSearcher_Add(cs, ret); - SUFF_DEBUG1("\tusing existing source %s\n", sgn->name); + DEBUG1(SUFF, "\tusing existing source %s\n", sgn->name); return ret; } @@ -1256,7 +1252,7 @@ ExpandWildcards(GNodeListNode *cln, GNod */ char *cp = Lst_Dequeue(&expansions); - SUFF_DEBUG1("%s...", cp); + DEBUG1(SUFF, "%s...", cp); gn = Targ_GetNode(cp); /* Add gn to the parents child list before the original child */ @@ -1267,7 +1263,7 @@ ExpandWildcards(GNodeListNode *cln, GNod Lst_Done(&expansions); - SUFF_DEBUG0("\n"); + DEBUG0(SUFF, "\n"); /* * Now the source is expanded, remove it from the list of children to @@ -1382,7 +1378,7 @@ ExpandChildren(GNodeListNode *cln, GNode return; } - SUFF_DEBUG1("Expanding \"%s\"...", cgn->name); + DEBUG1(SUFF, "Expanding \"%s\"...", cgn->name); (void)Var_Subst(cgn->name, pgn, VARE_WANTRES | VARE_UNDEFERR, &cp); /* TODO: handle errors */ @@ -1407,7 +1403,7 @@ ExpandChildren(GNodeListNode *cln, GNode while (!Lst_IsEmpty(&members)) { GNode *gn = Lst_Dequeue(&members); - SUFF_DEBUG1("%s...", gn->name); + DEBUG1(SUFF, "%s...", gn->name); /* * Add gn to the parents child list before the * original child. @@ -1423,7 +1419,7 @@ ExpandChildren(GNodeListNode *cln, GNode free(cp); } - SUFF_DEBUG0("\n"); + DEBUG0(SUFF, "\n"); /* * Now the source is expanded, remove it from the list of children to @@ -1470,7 +1466,7 @@ Suff_FindPath(GNode *gn) if (Suffix_IsSuffix(ln->datum, nameLen, name + nameLen)) break; - SUFF_DEBUG1("Wildcard expanding \"%s\"...", gn->name); + DEBUG1(SUFF, "Wildcard expanding \"%s\"...", gn->name); if (ln != NULL) suff = ln->datum; /* @@ -1480,10 +1476,10 @@ Suff_FindPath(GNode *gn) } if (suff != NULL) { - SUFF_DEBUG1("suffix is \"%s\"...\n", suff->name); + DEBUG1(SUFF, "suffix is \"%s\"...\n", suff->name); return suff->searchPath; } else { - SUFF_DEBUG0("\n"); + DEBUG0(SUFF, "\n"); return &dirSearchPath; /* Use default search path */ } } @@ -1567,7 +1563,7 @@ ExpandMember(GNode *gn, const char *eoar /* Got one -- apply it */ Suffix *suff = ln->datum; if (!ApplyTransform(gn, mem, suff, memSuff)) { - SUFF_DEBUG2("\tNo transformation from %s -> %s\n", + DEBUG2(SUFF, "\tNo transformation from %s -> %s\n", memSuff->name, suff->name); } } @@ -1632,7 +1628,7 @@ FindDepsArchive(GNode *gn, CandidateSear memSuff = mem->suffix; if (memSuff == NULL) { /* Didn't know what it was. */ - SUFF_DEBUG0("using null suffix\n"); + DEBUG0(SUFF, "using null suffix\n"); memSuff = nullSuff; } @@ -1736,7 +1732,7 @@ FindDepsRegularUnknown(GNode *gn, const if (!Lst_IsEmpty(targs) || nullSuff == NULL) return; - SUFF_DEBUG1("\tNo known suffix on %s. Using .NULL suffix\n", gn->name); + DEBUG1(SUFF, "\tNo known suffix on %s. Using .NULL suffix\n", gn->name); targ = Candidate_New(bmake_strdup(gn->name), bmake_strdup(sopref), nullSuff, NULL, gn); @@ -1750,10 +1746,10 @@ FindDepsRegularUnknown(GNode *gn, const if (Lst_IsEmpty(&gn->commands)) CandidateList_AddCandidatesFor(srcs, targ); else { - SUFF_DEBUG0("not "); + DEBUG0(SUFF, "not "); } - SUFF_DEBUG0("adding suffix rules\n"); + DEBUG0(SUFF, "adding suffix rules\n"); Lst_Append(targs, targ); } @@ -1921,7 +1917,7 @@ FindDepsRegular(GNode *gn, CandidateSear } if (targ == NULL) { - SUFF_DEBUG1("\tNo valid suffix on %s\n", gn->name); + DEBUG1(SUFF, "\tNo valid suffix on %s\n", gn->name); sfnd_abort: FindDepsRegularPath(gn, targ); @@ -2065,7 +2061,7 @@ FindDeps(GNode *gn, CandidateSearcher *c Var_Set(TARGET, GNode_Path(gn), gn); Var_Set(PREFIX, gn->name, gn); - SUFF_DEBUG1("SuffFindDeps \"%s\"\n", gn->name); + DEBUG1(SUFF, "SuffFindDeps \"%s\"\n", gn->name); if (gn->type & OP_ARCHV) FindDepsArchive(gn, cs); Index: src/usr.bin/make/targ.c diff -u src/usr.bin/make/targ.c:1.152 src/usr.bin/make/targ.c:1.153 --- src/usr.bin/make/targ.c:1.152 Sat Dec 5 18:38:02 2020 +++ src/usr.bin/make/targ.c Sun Dec 6 10:49:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.152 2020/12/05 18:38:02 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.153 2020/12/06 10:49:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -119,7 +119,7 @@ #include "dir.h" /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: targ.c,v 1.152 2020/12/05 18:38:02 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.153 2020/12/06 10:49:02 rillig Exp $"); /* * All target nodes that appeared on the left-hand side of one of the @@ -451,7 +451,7 @@ Targ_PrintType(int type) type &= ~tbit; switch (tbit) { -#define PRINTBIT(bit, name) case bit: debug_printf(" " name); break +#define PRINTBIT(bit, attr) case bit: debug_printf(" " attr); break #define PRINTDBIT(bit, attr) case bit: if (DEBUG(TARG)) debug_printf(" " attr); break PRINTBIT(OP_OPTIONAL, ".OPTIONAL"); PRINTBIT(OP_USE, ".USE"); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.707 src/usr.bin/make/var.c:1.708 --- src/usr.bin/make/var.c:1.707 Sat Dec 5 18:38:02 2020 +++ src/usr.bin/make/var.c Sun Dec 6 10:49:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.707 2020/12/05 18:38:02 rillig Exp $ */ +/* $NetBSD: var.c,v 1.708 2020/12/06 10:49:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -130,12 +130,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.707 2020/12/05 18:38:02 rillig Exp $"); - -#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) -#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) -#define VAR_DEBUG3(fmt, arg1, arg2, arg3) DEBUG3(VAR, fmt, arg1, arg2, arg3) -#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4) +MAKE_RCSID("$NetBSD: var.c,v 1.708 2020/12/06 10:49:02 rillig Exp $"); ENUM_FLAGS_RTTI_3(VarEvalFlags, VARE_UNDEFERR, VARE_WANTRES, VARE_KEEP_DOLLAR); @@ -465,9 +460,8 @@ VarAdd(const char *name, const char *val Var *v = VarNew(he->key /* aliased */, NULL, val, flags & VAR_SET_READONLY ? VAR_READONLY : VAR_NONE); HashEntry_Set(he, v); - if (!(ctxt->flags & INTERNAL)) { - VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val); - } + if (!(ctxt->flags & INTERNAL)) + DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, val); } /* Remove a variable from a context, freeing all related memory as well. @@ -484,7 +478,7 @@ Var_Delete(const char *name, GNode *ctxt name = name_freeIt; } he = HashTable_FindEntry(&ctxt->vars, name); - VAR_DEBUG3("%s:delete %s%s\n", + DEBUG3(VAR, "%s:delete %s%s\n", ctxt->name, name, he != NULL ? "" : " (not found)"); free(name_freeIt); @@ -725,11 +719,11 @@ UnexportVar(const char *varname, Boolean { Var *v = VarFind(varname, VAR_GLOBAL, FALSE); if (v == NULL) { - VAR_DEBUG1("Not unexporting \"%s\" (not found)\n", varname); + DEBUG1(VAR, "Not unexporting \"%s\" (not found)\n", varname); return; } - VAR_DEBUG1("Unexporting \"%s\"\n", varname); + DEBUG1(VAR, "Unexporting \"%s\"\n", varname); if (!unexport_env && (v->flags & VAR_EXPORTED) && !(v->flags & VAR_REEXPORT)) unsetenv(v->name); @@ -815,8 +809,8 @@ Var_SetWithFlags(const char *name, const } if (name[0] == '\0') { - VAR_DEBUG2("Var_Set(\"%s\", \"%s\", ...) " - "name expands to empty string - ignored\n", + DEBUG2(VAR, "Var_Set(\"%s\", \"%s\", ...) " + "name expands to empty string - ignored\n", unexpanded_name, val); free(name_freeIt); return; @@ -826,7 +820,7 @@ Var_SetWithFlags(const char *name, const v = VarFind(name, VAR_CMDLINE, FALSE); if (v != NULL) { if (v->flags & VAR_FROM_CMD) { - VAR_DEBUG3("%s:%s = %s ignored!\n", + DEBUG3(VAR, "%s:%s = %s ignored!\n", ctxt->name, name, val); goto out; } @@ -853,14 +847,14 @@ Var_SetWithFlags(const char *name, const VarAdd(name, val, ctxt, flags); } else { if ((v->flags & VAR_READONLY) && !(flags & VAR_SET_READONLY)) { - VAR_DEBUG3("%s:%s = %s ignored (read-only)\n", + DEBUG3(VAR, "%s:%s = %s ignored (read-only)\n", ctxt->name, name, val); goto out; } Buf_Empty(&v->val); Buf_AddStr(&v->val, val); - VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val); + DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, val); if (v->flags & VAR_EXPORTED) Var_Export1(name, VAR_EXPORT_PARENT); } @@ -962,8 +956,8 @@ Var_Append(const char *name, const char /* TODO: handle errors */ name = name_freeIt; if (name[0] == '\0') { - VAR_DEBUG2("Var_Append(\"%s\", \"%s\", ...) " - "name expands to empty string - ignored\n", + DEBUG2(VAR, "Var_Append(\"%s\", \"%s\", ...) " + "name expands to empty string - ignored\n", unexpanded_name, val); free(name_freeIt); return; @@ -976,13 +970,13 @@ Var_Append(const char *name, const char /* XXX: name is expanded for the second time */ Var_Set(name, val, ctxt); } else if (v->flags & VAR_READONLY) { - VAR_DEBUG1("Ignoring append to %s since it is read-only\n", + DEBUG1(VAR, "Ignoring append to %s since it is read-only\n", name); } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) { Buf_AddByte(&v->val, ' '); Buf_AddStr(&v->val, val); - VAR_DEBUG3("%s:%s = %s\n", + DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, Buf_GetAll(&v->val, NULL)); if (v->flags & VAR_FROM_ENV) { @@ -1184,7 +1178,7 @@ static void ModifyWord_Match(const char *word, SepBuf *buf, void *data) { const char *pattern = data; - VAR_DEBUG2("VarMatch [%s] [%s]\n", word, pattern); + DEBUG2(VAR, "VarMatch [%s] [%s]\n", word, pattern); if (Str_Match(word, pattern)) SepBuf_AddStr(buf, word); } @@ -1504,8 +1498,8 @@ ModifyWord_Loop(const char *word, SepBuf (void)Var_Subst(args->str, args->ctx, args->eflags, &s); /* TODO: handle errors */ - VAR_DEBUG4("ModifyWord_Loop: " - "in \"%s\", replace \"%s\" with \"%s\" to \"%s\"\n", + DEBUG4(VAR, "ModifyWord_Loop: " + "in \"%s\", replace \"%s\" with \"%s\" to \"%s\"\n", word, args->tvar, args->str, s); if (s[0] == '\n' || Buf_EndsWith(&buf->buf, '\n')) @@ -1618,7 +1612,7 @@ ModifyWords(const char *str, words = Str_Words(str, FALSE); - VAR_DEBUG2("ModifyWords: split \"%s\" into %zu words\n", + DEBUG2(VAR, "ModifyWords: split \"%s\" into %zu words\n", str, words.len); for (i = 0; i < words.len; i++) { @@ -2061,7 +2055,7 @@ ParseModifierPart( *out_length = Buf_Len(&buf); *out_part = Buf_Destroy(&buf, FALSE); - VAR_DEBUG1("Modifier part: \"%s\"\n", *out_part); + DEBUG1(VAR, "Modifier part: \"%s\"\n", *out_part); return VPR_OK; } @@ -2506,7 +2500,7 @@ ApplyModifier_Match(const char **pp, App free(old_pattern); } - VAR_DEBUG3("Pattern[%s] for [%s] is [%s]\n", + DEBUG3(VAR, "Pattern[%s] for [%s] is [%s]\n", st->var->name, st->val, pattern); callback = mod[0] == 'M' ? ModifyWord_Match : ModifyWord_NoMatch; @@ -3389,7 +3383,7 @@ ApplyModifiersIndirect( return AMIR_APPLY_MODS; } - VAR_DEBUG3("Indirect modifier \"%s\" from \"%.*s\"\n", + DEBUG3(VAR, "Indirect modifier \"%s\" from \"%.*s\"\n", mods, (int)(p - *inout_p), *inout_p); if (mods[0] != '\0') { @@ -3951,7 +3945,7 @@ Var_Parse(const char **pp, GNode *ctxt, char eflags_str[VarEvalFlags_ToStringSize]; VarExprFlags exprFlags = VEF_NONE; - VAR_DEBUG2("Var_Parse: %s with %s\n", start, + DEBUG2(VAR, "Var_Parse: %s with %s\n", start, Enum_FlagsToString(eflags_str, sizeof eflags_str, eflags, VarEvalFlags_ToStringSpecs));