MCPcopy Create free account
hub / github.com/Entware/Entware / expand_dollar_with_args

Function expand_dollar_with_args

scripts/config/preprocess.c:456–491  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

454 * $(BAR)
455 */
456static 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
493char *expand_dollar(const char **str)
494{

Callers 2

expand_dollarFunction · 0.85
__expand_stringFunction · 0.85

Calls 3

xstrdupFunction · 0.85
pperrorFunction · 0.85
eval_clauseFunction · 0.85

Tested by

no test coverage detected