diff options
Diffstat (limited to 'scripts/kconfig/symbol.c')
-rw-r--r-- | scripts/kconfig/symbol.c | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 1f8b305449db..a796c95fe8a0 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -350,16 +350,18 @@ 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) { |
354 | struct expr *e; | ||
355 | e = expr_simplify_unmet_dep(sym->rev_dep.expr, | ||
356 | sym->dir_dep.expr); | ||
355 | fprintf(stderr, "warning: ("); | 357 | fprintf(stderr, "warning: ("); |
356 | expr_fprint(sym->rev_dep.expr, stderr); | 358 | expr_fprint(e, stderr); |
357 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", | 359 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", |
358 | sym->name); | 360 | sym->name); |
359 | expr_fprint(sym->dir_dep.expr, stderr); | 361 | expr_fprint(sym->dir_dep.expr, stderr); |
360 | fprintf(stderr, ")\n"); | 362 | fprintf(stderr, ")\n"); |
363 | expr_free(e); | ||
361 | } | 364 | } |
362 | #endif | ||
363 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 365 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); |
364 | } | 366 | } |
365 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) | 367 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) |
@@ -688,7 +690,7 @@ const char *sym_get_string_default(struct symbol *sym) | |||
688 | switch (sym->type) { | 690 | switch (sym->type) { |
689 | case S_BOOLEAN: | 691 | case S_BOOLEAN: |
690 | case S_TRISTATE: | 692 | case S_TRISTATE: |
691 | /* The visibility imay limit the value from yes => mod */ | 693 | /* The visibility may limit the value from yes => mod */ |
692 | val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); | 694 | val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); |
693 | break; | 695 | break; |
694 | default: | 696 | default: |
@@ -842,6 +844,55 @@ struct symbol *sym_find(const char *name) | |||
842 | return symbol; | 844 | return symbol; |
843 | } | 845 | } |
844 | 846 | ||
847 | /* | ||
848 | * Expand symbol's names embedded in the string given in argument. Symbols' | ||
849 | * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to | ||
850 | * the empty string. | ||
851 | */ | ||
852 | const char *sym_expand_string_value(const char *in) | ||
853 | { | ||
854 | const char *src; | ||
855 | char *res; | ||
856 | size_t reslen; | ||
857 | |||
858 | reslen = strlen(in) + 1; | ||
859 | res = malloc(reslen); | ||
860 | res[0] = '\0'; | ||
861 | |||
862 | while ((src = strchr(in, '$'))) { | ||
863 | char *p, name[SYMBOL_MAXLENGTH]; | ||
864 | const char *symval = ""; | ||
865 | struct symbol *sym; | ||
866 | size_t newlen; | ||
867 | |||
868 | strncat(res, in, src - in); | ||
869 | src++; | ||
870 | |||
871 | p = name; | ||
872 | while (isalnum(*src) || *src == '_') | ||
873 | *p++ = *src++; | ||
874 | *p = '\0'; | ||
875 | |||
876 | sym = sym_find(name); | ||
877 | if (sym != NULL) { | ||
878 | sym_calc_value(sym); | ||
879 | symval = sym_get_string_value(sym); | ||
880 | } | ||
881 | |||
882 | newlen = strlen(res) + strlen(symval) + strlen(src) + 1; | ||
883 | if (newlen > reslen) { | ||
884 | reslen = newlen; | ||
885 | res = realloc(res, reslen); | ||
886 | } | ||
887 | |||
888 | strcat(res, symval); | ||
889 | in = src; | ||
890 | } | ||
891 | strcat(res, in); | ||
892 | |||
893 | return res; | ||
894 | } | ||
895 | |||
845 | struct symbol **sym_re_search(const char *pattern) | 896 | struct symbol **sym_re_search(const char *pattern) |
846 | { | 897 | { |
847 | struct symbol *sym, **sym_arr = NULL; | 898 | struct symbol *sym, **sym_arr = NULL; |