diff options
Diffstat (limited to 'scripts/kconfig/symbol.c')
| -rw-r--r-- | scripts/kconfig/symbol.c | 51 | 
1 files changed, 49 insertions, 2 deletions
| diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 1f8b305449db..af6e9f3de950 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
| @@ -350,7 +350,6 @@ void sym_calc_value(struct symbol *sym) | |||
| 350 | } | 350 | } | 
| 351 | } | 351 | } | 
| 352 | calc_newval: | 352 | calc_newval: | 
| 353 | #if 0 | ||
| 354 | if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { | 353 | if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { | 
| 355 | fprintf(stderr, "warning: ("); | 354 | fprintf(stderr, "warning: ("); | 
| 356 | expr_fprint(sym->rev_dep.expr, stderr); | 355 | expr_fprint(sym->rev_dep.expr, stderr); | 
| @@ -359,7 +358,6 @@ void sym_calc_value(struct symbol *sym) | |||
| 359 | expr_fprint(sym->dir_dep.expr, stderr); | 358 | expr_fprint(sym->dir_dep.expr, stderr); | 
| 360 | fprintf(stderr, ")\n"); | 359 | fprintf(stderr, ")\n"); | 
| 361 | } | 360 | } | 
| 362 | #endif | ||
| 363 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 361 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 
| 364 | } | 362 | } | 
| 365 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) | 363 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) | 
| @@ -842,6 +840,55 @@ struct symbol *sym_find(const char *name) | |||
| 842 | return symbol; | 840 | return symbol; | 
| 843 | } | 841 | } | 
| 844 | 842 | ||
| 843 | /* | ||
| 844 | * Expand symbol's names embedded in the string given in argument. Symbols' | ||
| 845 | * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to | ||
| 846 | * the empty string. | ||
| 847 | */ | ||
| 848 | const char *sym_expand_string_value(const char *in) | ||
| 849 | { | ||
| 850 | const char *src; | ||
| 851 | char *res; | ||
| 852 | size_t reslen; | ||
| 853 | |||
| 854 | reslen = strlen(in) + 1; | ||
| 855 | res = malloc(reslen); | ||
| 856 | res[0] = '\0'; | ||
| 857 | |||
| 858 | while ((src = strchr(in, '$'))) { | ||
| 859 | char *p, name[SYMBOL_MAXLENGTH]; | ||
| 860 | const char *symval = ""; | ||
| 861 | struct symbol *sym; | ||
| 862 | size_t newlen; | ||
| 863 | |||
| 864 | strncat(res, in, src - in); | ||
| 865 | src++; | ||
| 866 | |||
| 867 | p = name; | ||
| 868 | while (isalnum(*src) || *src == '_') | ||
| 869 | *p++ = *src++; | ||
| 870 | *p = '\0'; | ||
| 871 | |||
| 872 | sym = sym_find(name); | ||
| 873 | if (sym != NULL) { | ||
| 874 | sym_calc_value(sym); | ||
| 875 | symval = sym_get_string_value(sym); | ||
| 876 | } | ||
| 877 | |||
| 878 | newlen = strlen(res) + strlen(symval) + strlen(src) + 1; | ||
| 879 | if (newlen > reslen) { | ||
| 880 | reslen = newlen; | ||
| 881 | res = realloc(res, reslen); | ||
| 882 | } | ||
| 883 | |||
| 884 | strcat(res, symval); | ||
| 885 | in = src; | ||
| 886 | } | ||
| 887 | strcat(res, in); | ||
| 888 | |||
| 889 | return res; | ||
| 890 | } | ||
| 891 | |||
| 845 | struct symbol **sym_re_search(const char *pattern) | 892 | struct symbol **sym_re_search(const char *pattern) | 
| 846 | { | 893 | { | 
| 847 | struct symbol *sym, **sym_arr = NULL; | 894 | struct symbol *sym, **sym_arr = NULL; | 
