* Expand a string that follows '$' * * For example, if the input string is * ($(FOO)$($(BAR)))$(BAZ) * this helper evaluates * $($(FOO)$($(BAR))) * and returns a new string containing the expansion (note that the string is * recursively expanded), also advancing 'str' to point to the next character * after the corresponding closing parenthesis, in this case, *str will be * $(B
| 454 | * $(BAR) |
| 455 | */ |
| 456 | static char *expand_dollar_with_args(const char **str, int argc, char *argv[]) |
| 457 | { |
| 458 | const char *p = *str; |
| 459 | const char *q; |
| 460 | int nest = 0; |
| 461 | |
| 462 | /* |
| 463 | * In Kconfig, variable/function references always start with "$(". |
| 464 | * Neither single-letter variables as in $A nor curly braces as in ${CC} |
| 465 | * are supported. '$' not followed by '(' loses its special meaning. |
| 466 | */ |
| 467 | if (*p != '(') { |
| 468 | *str = p; |
| 469 | return xstrdup("$"); |
| 470 | } |
| 471 | |
| 472 | p++; |
| 473 | q = p; |
| 474 | while (*q) { |
| 475 | if (*q == '(') { |
| 476 | nest++; |
| 477 | } else if (*q == ')') { |
| 478 | if (nest-- == 0) |
| 479 | break; |
| 480 | } |
| 481 | q++; |
| 482 | } |
| 483 | |
| 484 | if (!*q) |
| 485 | pperror("unterminated reference to '%s': missing ')'", p); |
| 486 | |
| 487 | /* Advance 'str' to after the expanded initial portion of the string */ |
| 488 | *str = q + 1; |
| 489 | |
| 490 | return eval_clause(p, q - p, argc, argv); |
| 491 | } |
| 492 | |
| 493 | char *expand_dollar(const char **str) |
| 494 | { |
no test coverage detected