summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/var.c
diff options
context:
space:
mode:
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