From 5dd110f70b3a960a1be7fc6070584d764ec7ca60 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sun, 13 Nov 2022 10:43:45 +0200 Subject: win32: native make menuconfig: support search Previously, pressing slash to search at the menu aborted the menu program ('mconf'), because regexp is not available with native mingw. Now it works, but the search is of plain string rather than regexp. --- scripts/kconfig/symbol.c | 26 +++++++++++++++++++++----- 1 file 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) return symbol; } +#if !defined HAVE_RE && !defined __MINGW32__ +#define HAVE_RE 1 +#endif + struct symbol **sym_re_search(const char *pattern) { -#ifdef __MINGW32__ - fprintf(stderr, "NOTIMPL: sym_re_search\n"); - exit(1); -#else struct symbol *sym, **sym_arr = NULL; int i, cnt, size; +#if HAVE_RE regex_t re; +#else + /* without re support use: strstr(sym->name, upper(pattern)) */ + /* sym->name is a config, e.g. "SHELL_ASH" or "FEATURE_UTMP" */ + char upat[256] = {0}; + for (i = 0; i < 255 && pattern[i]; ++i) + upat[i] = toupper(pattern[i]); +#endif cnt = size = 0; /* Skip if empty */ if (strlen(pattern) == 0) return NULL; +#if HAVE_RE if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) return NULL; +#endif for_all_symbols(i, sym) { if (sym->flags & SYMBOL_CONST || !sym->name) continue; +#if HAVE_RE if (regexec(&re, sym->name, 0, NULL, 0)) continue; +#else + if (!strstr(sym->name, upat)) + continue; +#endif if (cnt + 1 >= size) { void *tmp = sym_arr; size += 16; @@ -763,10 +778,11 @@ struct symbol **sym_re_search(const char *pattern) } if (sym_arr) sym_arr[cnt] = NULL; +#if HAVE_RE regfree(&re); +#endif return sym_arr; -#endif } -- cgit v1.2.3-55-g6feb