summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/var.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-05-12 14:31:42 +0000
committerharti <harti@FreeBSD.org>2005-05-12 14:31:42 +0000
commit8a832592ce11ab5f5c94757893e5f7353808bee1 (patch)
tree4063d4c37b93bccf895ea505b1cd72847fc1b684 /usr.bin/make/var.c
parente7ab78380c4d30d28dbf699ac0bffeb881f56c83 (diff)
downloadFreeBSD-src-8a832592ce11ab5f5c94757893e5f7353808bee1.zip
FreeBSD-src-8a832592ce11ab5f5c94757893e5f7353808bee1.tar.gz
Move variable printing from main.c to var.c
Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.233)
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r--usr.bin/make/var.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index eb83c52..a70acae 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -96,6 +96,7 @@ __FBSDID("$FreeBSD$");
#include "globals.h"
#include "GNode.h"
#include "job.h"
+#include "lst.h"
#include "make.h"
#include "parse.h"
#include "str.h"
@@ -2530,3 +2531,36 @@ Var_Dump(void)
}
}
+/**
+ * Print the values of any variables requested by
+ * the user.
+ */
+void
+Var_Print(Lst *vlist, Boolean expandVars)
+{
+ LstNode *n;
+ const char *name;
+ char *v;
+ char *value;
+
+ LST_FOREACH(n, vlist) {
+ name = Lst_Datum(n);
+ if (expandVars) {
+ v = emalloc(strlen(name) + 1 + 3);
+ sprintf(v, "${%s}", name);
+
+ value = Buf_Peel(Var_Subst(v,
+ VAR_GLOBAL, FALSE));
+ printf("%s\n", value);
+
+ free(v);
+ free(value);
+ } else {
+ value = Var_Value(name, VAR_GLOBAL, &v);
+ printf("%s\n", value != NULL ? value : "");
+ if (v != NULL)
+ free(v);
+ }
+ }
+}
+
OpenPOWER on IntegriCloud