From da559dbfd0be23fc669acb52510c335ffdb62372 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Thu, 10 Mar 2005 15:38:01 +0000 Subject: [PATCH] Constify Var_Dump and simplify it by inlining VarPrintVar. --- usr.bin/make/var.c | 22 ++++++++-------------- usr.bin/make/var.h | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 7014c5a3a5cc..2e82e9252f9c 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -142,8 +142,6 @@ GNode *VAR_CMD; /* variables defined on the command-line */ #define OPEN_BRACE '{' #define CLOSE_BRACE '}' -static int VarPrintVar(void *, void *); - /* * Create a Var object. * @@ -2098,16 +2096,6 @@ Var_Init(void) VAR_CMD = Targ_NewGN("Command"); } -/****************** PRINT DEBUGGING INFO *****************/ -static int -VarPrintVar(void *vp, void *dummy __unused) -{ - Var *v = (Var *) vp; - - printf("%-16s = %s\n", v->name, (char *)Buf_GetAll(v->val, (size_t *)NULL)); - return (0); -} - /*- *----------------------------------------------------------------------- * Var_Dump -- @@ -2115,8 +2103,14 @@ VarPrintVar(void *vp, void *dummy __unused) *----------------------------------------------------------------------- */ void -Var_Dump(GNode *ctxt) +Var_Dump(const GNode *ctxt) { + const LstNode *ln; + const Var *v; - Lst_ForEach(&ctxt->context, VarPrintVar, (void *)NULL); + LST_FOREACH(ln, &ctxt->context) { + v = Lst_Datum(ln); + printf("%-16s = %s\n", v->name, + (const char *)Buf_GetAll(v->val, NULL)); + } } diff --git a/usr.bin/make/var.h b/usr.bin/make/var.h index fe59e9cc0acf..c1a0fb6b6d0c 100644 --- a/usr.bin/make/var.h +++ b/usr.bin/make/var.h @@ -122,6 +122,6 @@ struct Buffer *Var_Subst(const char *, const char *, struct GNode *, Boolean); char *Var_GetTail(char *); char *Var_GetHead(char *); void Var_Init(void); -void Var_Dump(struct GNode *); +void Var_Dump(const struct GNode *); #endif /* var_h_9cccafce */