aboutsummaryrefslogtreecommitdiff
path: root/busybox/scripts/config/symbol.c
diff options
context:
space:
mode:
Diffstat (limited to 'busybox/scripts/config/symbol.c')
-rw-r--r--busybox/scripts/config/symbol.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/busybox/scripts/config/symbol.c b/busybox/scripts/config/symbol.c
index a9fae9c13..ea629728a 100644
--- a/busybox/scripts/config/symbol.c
+++ b/busybox/scripts/config/symbol.c
@@ -6,6 +6,7 @@
6#include <ctype.h> 6#include <ctype.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h> 8#include <string.h>
9#include <regex.h>
9#include <sys/utsname.h> 10#include <sys/utsname.h>
10 11
11#define LKC_DIRECT_LINK 12#define LKC_DIRECT_LINK
@@ -414,7 +415,7 @@ tristate sym_toggle_tristate_value(struct symbol *sym)
414 415
415bool sym_string_valid(struct symbol *sym, const char *str) 416bool sym_string_valid(struct symbol *sym, const char *str)
416{ 417{
417 char ch; 418 signed char ch;
418 419
419 switch (sym->type) { 420 switch (sym->type) {
420 case S_STRING: 421 case S_STRING:
@@ -649,6 +650,43 @@ struct symbol *sym_find(const char *name)
649 return symbol; 650 return symbol;
650} 651}
651 652
653struct symbol **sym_re_search(const char *pattern)
654{
655 struct symbol *sym, **sym_arr = NULL;
656 int i, cnt, size;
657 regex_t re;
658
659 cnt = size = 0;
660 /* Skip if empty */
661 if (strlen(pattern) == 0)
662 return NULL;
663 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
664 return NULL;
665
666 for_all_symbols(i, sym) {
667 if (sym->flags & SYMBOL_CONST || !sym->name)
668 continue;
669 if (regexec(&re, sym->name, 0, NULL, 0))
670 continue;
671 if (cnt + 1 >= size) {
672 void *tmp = sym_arr;
673 size += 16;
674 sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
675 if (!sym_arr) {
676 free(tmp);
677 return NULL;
678 }
679 }
680 sym_arr[cnt++] = sym;
681 }
682 if (sym_arr)
683 sym_arr[cnt] = NULL;
684 regfree(&re);
685
686 return sym_arr;
687}
688
689
652struct symbol *sym_check_deps(struct symbol *sym); 690struct symbol *sym_check_deps(struct symbol *sym);
653 691
654static struct symbol *sym_check_expr_deps(struct expr *e) 692static struct symbol *sym_check_expr_deps(struct expr *e)