Deleted Added
full compact
var.c (146134) var.c (146141)
1/*-
2 * Copyright (c) 2002 Juli Mallett.
3 * Copyright (c) 1988, 1989, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1989 by Berkeley Softworks
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 26 unchanged lines hidden (view full) ---

35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)var.c 8.3 (Berkeley) 3/19/94
40 */
41
42#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002 Juli Mallett.
3 * Copyright (c) 1988, 1989, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1989 by Berkeley Softworks
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 26 unchanged lines hidden (view full) ---

35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)var.c 8.3 (Berkeley) 3/19/94
40 */
41
42#include <sys/cdefs.h>
43__FBSDID("$FreeBSD: head/usr.bin/make/var.c 146134 2005-05-12 11:58:39Z harti $");
43__FBSDID("$FreeBSD: head/usr.bin/make/var.c 146141 2005-05-12 14:31:42Z harti $");
44
45/**
46 * var.c --
47 * Variable-handling functions
48 *
49 * Interface:
50 * Var_Set Set the value of a variable in the given
51 * context. The variable is created if it doesn't

--- 39 unchanged lines hidden (view full) ---

91#include <sys/types.h>
92#include <regex.h>
93
94#include "buf.h"
95#include "config.h"
96#include "globals.h"
97#include "GNode.h"
98#include "job.h"
44
45/**
46 * var.c --
47 * Variable-handling functions
48 *
49 * Interface:
50 * Var_Set Set the value of a variable in the given
51 * context. The variable is created if it doesn't

--- 39 unchanged lines hidden (view full) ---

91#include <sys/types.h>
92#include <regex.h>
93
94#include "buf.h"
95#include "config.h"
96#include "globals.h"
97#include "GNode.h"
98#include "job.h"
99#include "lst.h"
99#include "make.h"
100#include "parse.h"
101#include "str.h"
102#include "targ.h"
103#include "util.h"
104#include "var.h"
105
106/**

--- 2418 unchanged lines hidden (view full) ---

2525
2526 printf("#*** Command-line Variables:\n");
2527 LST_FOREACH(ln, &VAR_CMD->context) {
2528 v = Lst_Datum(ln);
2529 printf("%-16s = %s\n", v->name, Buf_Data(v->val));
2530 }
2531}
2532
100#include "make.h"
101#include "parse.h"
102#include "str.h"
103#include "targ.h"
104#include "util.h"
105#include "var.h"
106
107/**

--- 2418 unchanged lines hidden (view full) ---

2526
2527 printf("#*** Command-line Variables:\n");
2528 LST_FOREACH(ln, &VAR_CMD->context) {
2529 v = Lst_Datum(ln);
2530 printf("%-16s = %s\n", v->name, Buf_Data(v->val));
2531 }
2532}
2533
2534/**
2535 * Print the values of any variables requested by
2536 * the user.
2537 */
2538void
2539Var_Print(Lst *vlist, Boolean expandVars)
2540{
2541 LstNode *n;
2542 const char *name;
2543 char *v;
2544 char *value;
2545
2546 LST_FOREACH(n, vlist) {
2547 name = Lst_Datum(n);
2548 if (expandVars) {
2549 v = emalloc(strlen(name) + 1 + 3);
2550 sprintf(v, "${%s}", name);
2551
2552 value = Buf_Peel(Var_Subst(v,
2553 VAR_GLOBAL, FALSE));
2554 printf("%s\n", value);
2555
2556 free(v);
2557 free(value);
2558 } else {
2559 value = Var_Value(name, VAR_GLOBAL, &v);
2560 printf("%s\n", value != NULL ? value : "");
2561 if (v != NULL)
2562 free(v);
2563 }
2564 }
2565}
2566