| 249 | } |
| 250 | |
| 251 | static char *variable_expand(const char *name, int argc, char *argv[]) |
| 252 | { |
| 253 | struct variable *v; |
| 254 | char *res; |
| 255 | |
| 256 | v = variable_lookup(name); |
| 257 | if (!v) |
| 258 | return NULL; |
| 259 | |
| 260 | if (argc == 0 && v->exp_count) |
| 261 | pperror("Recursive variable '%s' references itself (eventually)", |
| 262 | name); |
| 263 | |
| 264 | if (v->exp_count > 1000) |
| 265 | pperror("Too deep recursive expansion"); |
| 266 | |
| 267 | v->exp_count++; |
| 268 | |
| 269 | if (v->flavor == VAR_RECURSIVE) |
| 270 | res = expand_string_with_args(v->value, argc, argv); |
| 271 | else |
| 272 | res = xstrdup(v->value); |
| 273 | |
| 274 | v->exp_count--; |
| 275 | |
| 276 | return res; |
| 277 | } |
| 278 | |
| 279 | void variable_add(const char *name, const char *value, |
| 280 | enum variable_flavor flavor) |
no test coverage detected