diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/symbol.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 63199cd93..31d5fbbfc 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
| @@ -728,28 +728,43 @@ struct symbol *sym_find(const char *name) | |||
| 728 | return symbol; | 728 | return symbol; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | #if !defined HAVE_RE && !defined __MINGW32__ | ||
| 732 | #define HAVE_RE 1 | ||
| 733 | #endif | ||
| 734 | |||
| 731 | struct symbol **sym_re_search(const char *pattern) | 735 | struct symbol **sym_re_search(const char *pattern) |
| 732 | { | 736 | { |
| 733 | #ifdef __MINGW32__ | ||
| 734 | fprintf(stderr, "NOTIMPL: sym_re_search\n"); | ||
| 735 | exit(1); | ||
| 736 | #else | ||
| 737 | struct symbol *sym, **sym_arr = NULL; | 737 | struct symbol *sym, **sym_arr = NULL; |
| 738 | int i, cnt, size; | 738 | int i, cnt, size; |
| 739 | #if HAVE_RE | ||
| 739 | regex_t re; | 740 | regex_t re; |
| 741 | #else | ||
| 742 | /* without re support use: strstr(sym->name, upper(pattern)) */ | ||
| 743 | /* sym->name is a config, e.g. "SHELL_ASH" or "FEATURE_UTMP" */ | ||
| 744 | char upat[256] = {0}; | ||
| 745 | for (i = 0; i < 255 && pattern[i]; ++i) | ||
| 746 | upat[i] = toupper(pattern[i]); | ||
| 747 | #endif | ||
| 740 | 748 | ||
| 741 | cnt = size = 0; | 749 | cnt = size = 0; |
| 742 | /* Skip if empty */ | 750 | /* Skip if empty */ |
| 743 | if (strlen(pattern) == 0) | 751 | if (strlen(pattern) == 0) |
| 744 | return NULL; | 752 | return NULL; |
| 753 | #if HAVE_RE | ||
| 745 | if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) | 754 | if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) |
| 746 | return NULL; | 755 | return NULL; |
| 756 | #endif | ||
| 747 | 757 | ||
| 748 | for_all_symbols(i, sym) { | 758 | for_all_symbols(i, sym) { |
| 749 | if (sym->flags & SYMBOL_CONST || !sym->name) | 759 | if (sym->flags & SYMBOL_CONST || !sym->name) |
| 750 | continue; | 760 | continue; |
| 761 | #if HAVE_RE | ||
| 751 | if (regexec(&re, sym->name, 0, NULL, 0)) | 762 | if (regexec(&re, sym->name, 0, NULL, 0)) |
| 752 | continue; | 763 | continue; |
| 764 | #else | ||
| 765 | if (!strstr(sym->name, upat)) | ||
| 766 | continue; | ||
| 767 | #endif | ||
| 753 | if (cnt + 1 >= size) { | 768 | if (cnt + 1 >= size) { |
| 754 | void *tmp = sym_arr; | 769 | void *tmp = sym_arr; |
| 755 | size += 16; | 770 | size += 16; |
| @@ -763,10 +778,11 @@ struct symbol **sym_re_search(const char *pattern) | |||
| 763 | } | 778 | } |
| 764 | if (sym_arr) | 779 | if (sym_arr) |
| 765 | sym_arr[cnt] = NULL; | 780 | sym_arr[cnt] = NULL; |
| 781 | #if HAVE_RE | ||
| 766 | regfree(&re); | 782 | regfree(&re); |
| 783 | #endif | ||
| 767 | 784 | ||
| 768 | return sym_arr; | 785 | return sym_arr; |
| 769 | #endif | ||
| 770 | } | 786 | } |
| 771 | 787 | ||
| 772 | 788 | ||
