Changeset 1985 in kBuild
- Timestamp:
- Oct 28, 2008 1:58:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/expand.c
r1980 r1985 208 208 } 209 209 210 #ifdef CONFIG_WITH_VALUE_LENGTH 211 /* Static worker for reference_variable() that expands the recursive 212 variable V. The main difference between this and 213 recursively_expand[_for_file] is that this worker avoids the temporary 214 buffer and outputs directly into the current variable buffer (O). */ 215 static char * 216 reference_recursive_variable (char *o, struct variable *v) 217 { 218 const struct floc *this_var; 219 const struct floc **saved_varp; 220 int set_reading = 0; 221 222 /* Don't install a new location if this location is empty. 223 This can happen for command-line variables, builtin variables, etc. */ 224 saved_varp = expanding_var; 225 if (v->fileinfo.filenm) 226 { 227 this_var = &v->fileinfo; 228 expanding_var = &this_var; 229 } 230 231 /* If we have no other file-reading context, use the variable's context. */ 232 if (!reading_file) 233 { 234 set_reading = 1; 235 reading_file = &v->fileinfo; 236 } 237 238 if (v->expanding) 239 { 240 if (!v->exp_count) 241 /* Expanding V causes infinite recursion. Lose. */ 242 fatal (*expanding_var, 243 _("Recursive variable `%s' references itself (eventually)"), 244 v->name); 245 --v->exp_count; 246 } 247 248 v->expanding = 1; 249 if (!v->append) 250 /* Expand directly into the variable buffer. */ 251 variable_expand_string_2 (o, v->value, v->value_length, &o); 252 else 253 { 254 /* XXX: Feel free to optimize appending target variables as well. */ 255 char *value = allocated_variable_append (v); 256 unsigned int value_len = strlen (value); 257 o = variable_buffer_output (o, value, value_len); 258 free (value); 259 } 260 v->expanding = 0; 261 262 if (set_reading) 263 reading_file = 0; 264 265 expanding_var = saved_varp; 266 267 return o; 268 } 269 #endif /* CONFIG_WITH_VALUE_LENGTH */ 270 210 271 /* Expand a simple reference to variable NAME, which is LENGTH chars long. */ 211 272 … … 219 280 { 220 281 struct variable *v; 282 #ifndef CONFIG_WITH_VALUE_LENGTH 221 283 char *value; 284 #endif 222 285 223 286 v = lookup_variable (name, length); … … 235 298 o = variable_buffer_output (o, v->value, v->value_length); 236 299 else 237 { 238 unsigned int value_len; 239 240 /* XXX: Inline recursively_expand_for_file() here and what it calls, try 241 make use of O directly instead wasting time on an intermediate buffer. */ 242 value = recursively_expand_for_file (v, NULL, &value_len); 243 o = variable_buffer_output (o, value, value_len); 244 free (value); 245 } 300 o = reference_recursive_variable (o, v); 246 301 #else /* !CONFIG_WITH_VALUE_LENGTH */ 247 302 value = (v->recursive ? recursively_expand (v) : v->value);
Note:
See TracChangeset
for help on using the changeset viewer.