Print this page
make: remove SCCS ident stuff
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/bin/make/common/macro.cc
+++ new/usr/src/cmd/make/bin/make/common/macro.cc
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 -/*
26 - * @(#)macro.cc 1.28 06/12/12
27 - */
28 -
29 -#pragma ident "@(#)macro.cc 1.28 06/12/12"
30 25
31 26 /*
32 27 * macro.cc
33 28 *
34 29 * Handle expansion of make macros
35 30 */
36 31
37 32 /*
38 33 * Included files
39 34 */
40 35 #ifdef DISTRIBUTED
41 36 #include <avo/strings.h> /* AVO_STRDUP() */
42 37 #include <dm/Avo_DoJobMsg.h>
43 38 #endif
44 39 #include <mk/defs.h>
45 40 #include <mksh/macro.h> /* getvar(), expand_value() */
46 41 #include <mksh/misc.h> /* getmem() */
47 42
48 43 /*
49 44 * Defined macros
50 45 */
51 46
52 47 /*
53 48 * typedefs & structs
54 49 */
55 50
56 51 /*
57 52 * Static variables
58 53 */
59 54
60 55 /*
61 56 * File table of contents
62 57 */
63 58
64 59 void
65 60 setvar_append(register Name name, register Name value)
66 61 {
67 62 register Property macro_apx = get_prop(name->prop, macro_append_prop);
68 63 register Property macro = get_prop(name->prop, macro_prop);
69 64 int length;
70 65 String_rec destination;
71 66 wchar_t buffer[STRING_BUFFER_LENGTH];
72 67 register Chain chain;
73 68 Name val = NULL;
74 69
75 70 if(macro_apx == NULL) {
76 71 macro_apx = append_prop(name, macro_append_prop);
77 72 if(macro != NULL) {
78 73 macro_apx->body.macro_appendix.value = macro->body.macro.value;
79 74 }
80 75 }
81 76
82 77 val = macro_apx->body.macro_appendix.value_to_append;
83 78
84 79 INIT_STRING_FROM_STACK(destination, buffer);
85 80 buffer[0] = 0;
86 81 if (val != NULL) {
87 82 APPEND_NAME(val,
88 83 &destination,
89 84 (int) val->hash.length);
90 85 if (value != NULL) {
91 86 MBTOWC(wcs_buffer, " ");
92 87 append_char(wcs_buffer[0], &destination);
93 88 }
94 89 }
95 90 if (value != NULL) {
96 91 APPEND_NAME(value,
97 92 &destination,
98 93 (int) value->hash.length);
99 94 }
100 95 value = GETNAME(destination.buffer.start, FIND_LENGTH);
101 96 if (destination.free_after_use) {
102 97 retmem(destination.buffer.start);
103 98 }
104 99 macro_apx->body.macro_appendix.value_to_append = value;
105 100
106 101 SETVAR(name, empty_name, true);
107 102 }
108 103
109 104 /*
110 105 * setvar_envvar()
111 106 *
112 107 * This function scans the list of environment variables that have
113 108 * dynamic values and sets them.
114 109 *
115 110 * Parameters:
116 111 *
117 112 * Global variables used:
118 113 * envvar A list of environment vars with $ in value
119 114 */
120 115 void
121 116 #ifdef DISTRIBUTED
122 117 setvar_envvar(Avo_DoJobMsg *dmake_job_msg)
123 118 #else
124 119 setvar_envvar(void)
125 120 #endif
126 121 {
127 122 wchar_t buffer[STRING_BUFFER_LENGTH];
128 123 int length;
129 124 #ifdef DISTRIBUTED
130 125 Property macro;
131 126 #endif
132 127 register char *mbs, *tmp_mbs_buffer = NULL;
133 128 register char *env, *tmp_mbs_buffer2 = NULL;
134 129 Envvar p;
135 130 String_rec value;
136 131
137 132 for (p = envvar; p != NULL; p = p->next) {
138 133 if (p->already_put
139 134 #ifdef DISTRIBUTED
140 135 && !dmake_job_msg
141 136 #endif
142 137 ) {
143 138 continue;
144 139 }
145 140 INIT_STRING_FROM_STACK(value, buffer);
146 141 expand_value(p->value, &value, false);
147 142 if ((length = wslen(value.buffer.start)) >= MAXPATHLEN) {
148 143 mbs = tmp_mbs_buffer = getmem((length + 1) * MB_LEN_MAX);
149 144 (void) wcstombs(mbs,
150 145 value.buffer.start,
151 146 (length + 1) * MB_LEN_MAX);
152 147 } else {
153 148 mbs = mbs_buffer;
154 149 WCSTOMBS(mbs, value.buffer.start);
155 150 }
156 151 length = 2 + strlen(p->name->string_mb) + strlen(mbs);
157 152 if (!p->already_put || length > (MAXPATHLEN * MB_LEN_MAX)) {
158 153 env = tmp_mbs_buffer2 = getmem(length);
159 154 } else {
160 155 env = mbs_buffer2;
161 156 }
162 157 (void) sprintf(env,
163 158 "%s=%s",
164 159 p->name->string_mb,
165 160 mbs);
166 161 if (!p->already_put) {
167 162 (void) putenv(env);
168 163 p->already_put = true;
169 164 if (p->env_string) {
170 165 retmem_mb(p->env_string);
171 166 }
172 167 p->env_string = env;
173 168 tmp_mbs_buffer2 = NULL; // We should not return this memory now
174 169 }
175 170 #ifdef DISTRIBUTED
176 171 if (dmake_job_msg) {
177 172 dmake_job_msg->appendVar(env);
178 173 }
179 174 #endif
180 175 if (tmp_mbs_buffer2) {
181 176 retmem_mb(tmp_mbs_buffer2);
182 177 tmp_mbs_buffer2 = NULL;
183 178 }
184 179 if (tmp_mbs_buffer) {
185 180 retmem_mb(tmp_mbs_buffer);
186 181 tmp_mbs_buffer = NULL;
187 182 }
188 183 }
189 184 #ifdef DISTRIBUTED
190 185 /* Append SUNPRO_DEPENDENCIES to the dmake_job_msg. */
191 186 if (keep_state && dmake_job_msg) {
192 187 macro = get_prop(sunpro_dependencies->prop, macro_prop);
193 188 length = 2 +
194 189 strlen(sunpro_dependencies->string_mb) +
195 190 strlen(macro->body.macro.value->string_mb);
196 191 if (length > (MAXPATHLEN * MB_LEN_MAX)) {
197 192 env = tmp_mbs_buffer2 = getmem(length);
198 193 } else {
199 194 env = mbs_buffer2;
200 195 }
201 196 (void) sprintf(env,
202 197 "%s=%s",
203 198 sunpro_dependencies->string_mb,
204 199 macro->body.macro.value->string_mb);
205 200 dmake_job_msg->appendVar(env);
206 201 if (tmp_mbs_buffer2) {
207 202 retmem_mb(tmp_mbs_buffer2);
208 203 tmp_mbs_buffer2 = NULL;
209 204 }
210 205 }
211 206 #endif
212 207 }
213 208
214 209
↓ open down ↓ |
175 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX