diff options
author | Michal Marek <mmarek@suse.cz> | 2013-07-23 09:57:17 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2013-07-23 09:57:17 -0400 |
commit | c3286ee337b0586a8ae2b4f13c33e3de5d71139e (patch) | |
tree | 0bb5c494c1d88daba153eae98bb62ee42a00b3bd /scripts | |
parent | ad81f0545ef01ea651886dddac4bef6cec930092 (diff) | |
parent | 508382a0428f2b2f49da0e0e89c921f07c9306aa (diff) |
Merge branch 'yem-kconfig-rc-fixes' of git://gitorious.org/linux-kconfig/linux-kconfig into kbuild/kconfig
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/mconf.c | 4 | ||||
-rw-r--r-- | scripts/kconfig/nconf.c | 4 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 49 |
3 files changed, 24 insertions, 33 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 6c9c45f9fbba..2c3963165a0d 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -401,8 +401,8 @@ static void search_conf(void) | |||
401 | struct subtitle_part stpart; | 401 | struct subtitle_part stpart; |
402 | 402 | ||
403 | title = str_new(); | 403 | title = str_new(); |
404 | str_printf( &title, _("Enter %s (sub)string or regexp to search for " | 404 | str_printf( &title, _("Enter (sub)string or regexp to search for " |
405 | "(with or without \"%s\")"), CONFIG_, CONFIG_); | 405 | "(with or without \"%s\")"), CONFIG_); |
406 | 406 | ||
407 | again: | 407 | again: |
408 | dialog_clear(); | 408 | dialog_clear(); |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 7975d8d258c3..4fbecd2473bc 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -695,8 +695,8 @@ static void search_conf(void) | |||
695 | int dres; | 695 | int dres; |
696 | 696 | ||
697 | title = str_new(); | 697 | title = str_new(); |
698 | str_printf( &title, _("Enter %s (sub)string or regexp to search for " | 698 | str_printf( &title, _("Enter (sub)string or regexp to search for " |
699 | "(with or without \"%s\")"), CONFIG_, CONFIG_); | 699 | "(with or without \"%s\")"), CONFIG_); |
700 | 700 | ||
701 | again: | 701 | again: |
702 | dres = dialog_inputbox(main_window, | 702 | dres = dialog_inputbox(main_window, |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index d550300ec00c..a76b8fd1db4f 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -963,11 +963,11 @@ struct sym_match { | |||
963 | * - first, symbols that match exactly | 963 | * - first, symbols that match exactly |
964 | * - then, alphabetical sort | 964 | * - then, alphabetical sort |
965 | */ | 965 | */ |
966 | static int sym_rel_comp( const void *sym1, const void *sym2 ) | 966 | static int sym_rel_comp(const void *sym1, const void *sym2) |
967 | { | 967 | { |
968 | struct sym_match *s1 = *(struct sym_match **)sym1; | 968 | const struct sym_match *s1 = sym1; |
969 | struct sym_match *s2 = *(struct sym_match **)sym2; | 969 | const struct sym_match *s2 = sym2; |
970 | int l1, l2; | 970 | int exact1, exact2; |
971 | 971 | ||
972 | /* Exact match: | 972 | /* Exact match: |
973 | * - if matched length on symbol s1 is the length of that symbol, | 973 | * - if matched length on symbol s1 is the length of that symbol, |
@@ -978,11 +978,11 @@ static int sym_rel_comp( const void *sym1, const void *sym2 ) | |||
978 | * exactly; if this is the case, we can't decide which comes first, | 978 | * exactly; if this is the case, we can't decide which comes first, |
979 | * and we fallback to sorting alphabetically. | 979 | * and we fallback to sorting alphabetically. |
980 | */ | 980 | */ |
981 | l1 = s1->eo - s1->so; | 981 | exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); |
982 | l2 = s2->eo - s2->so; | 982 | exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); |
983 | if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name)) | 983 | if (exact1 && !exact2) |
984 | return -1; | 984 | return -1; |
985 | if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name)) | 985 | if (!exact1 && exact2) |
986 | return 1; | 986 | return 1; |
987 | 987 | ||
988 | /* As a fallback, sort symbols alphabetically */ | 988 | /* As a fallback, sort symbols alphabetically */ |
@@ -992,7 +992,7 @@ static int sym_rel_comp( const void *sym1, const void *sym2 ) | |||
992 | struct symbol **sym_re_search(const char *pattern) | 992 | struct symbol **sym_re_search(const char *pattern) |
993 | { | 993 | { |
994 | struct symbol *sym, **sym_arr = NULL; | 994 | struct symbol *sym, **sym_arr = NULL; |
995 | struct sym_match **sym_match_arr = NULL; | 995 | struct sym_match *sym_match_arr = NULL; |
996 | int i, cnt, size; | 996 | int i, cnt, size; |
997 | regex_t re; | 997 | regex_t re; |
998 | regmatch_t match[1]; | 998 | regmatch_t match[1]; |
@@ -1005,47 +1005,38 @@ struct symbol **sym_re_search(const char *pattern) | |||
1005 | return NULL; | 1005 | return NULL; |
1006 | 1006 | ||
1007 | for_all_symbols(i, sym) { | 1007 | for_all_symbols(i, sym) { |
1008 | struct sym_match *tmp_sym_match; | ||
1009 | if (sym->flags & SYMBOL_CONST || !sym->name) | 1008 | if (sym->flags & SYMBOL_CONST || !sym->name) |
1010 | continue; | 1009 | continue; |
1011 | if (regexec(&re, sym->name, 1, match, 0)) | 1010 | if (regexec(&re, sym->name, 1, match, 0)) |
1012 | continue; | 1011 | continue; |
1013 | if (cnt + 1 >= size) { | 1012 | if (cnt >= size) { |
1014 | void *tmp; | 1013 | void *tmp; |
1015 | size += 16; | 1014 | size += 16; |
1016 | tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *)); | 1015 | tmp = realloc(sym_match_arr, size * sizeof(struct sym_match)); |
1017 | if (!tmp) { | 1016 | if (!tmp) |
1018 | goto sym_re_search_free; | 1017 | goto sym_re_search_free; |
1019 | } | ||
1020 | sym_match_arr = tmp; | 1018 | sym_match_arr = tmp; |
1021 | } | 1019 | } |
1022 | sym_calc_value(sym); | 1020 | sym_calc_value(sym); |
1023 | tmp_sym_match = (struct sym_match*)malloc(sizeof(struct sym_match)); | 1021 | /* As regexec returned 0, we know we have a match, so |
1024 | if (!tmp_sym_match) | ||
1025 | goto sym_re_search_free; | ||
1026 | tmp_sym_match->sym = sym; | ||
1027 | /* As regexec return 0, we know we have a match, so | ||
1028 | * we can use match[0].rm_[se]o without further checks | 1022 | * we can use match[0].rm_[se]o without further checks |
1029 | */ | 1023 | */ |
1030 | tmp_sym_match->so = match[0].rm_so; | 1024 | sym_match_arr[cnt].so = match[0].rm_so; |
1031 | tmp_sym_match->eo = match[0].rm_eo; | 1025 | sym_match_arr[cnt].eo = match[0].rm_eo; |
1032 | sym_match_arr[cnt++] = tmp_sym_match; | 1026 | sym_match_arr[cnt++].sym = sym; |
1033 | } | 1027 | } |
1034 | if (sym_match_arr) { | 1028 | if (sym_match_arr) { |
1035 | qsort(sym_match_arr, cnt, sizeof(struct sym_match*), sym_rel_comp); | 1029 | qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp); |
1036 | sym_arr = malloc((cnt+1) * sizeof(struct symbol)); | 1030 | sym_arr = malloc((cnt+1) * sizeof(struct symbol)); |
1037 | if (!sym_arr) | 1031 | if (!sym_arr) |
1038 | goto sym_re_search_free; | 1032 | goto sym_re_search_free; |
1039 | for (i = 0; i < cnt; i++) | 1033 | for (i = 0; i < cnt; i++) |
1040 | sym_arr[i] = sym_match_arr[i]->sym; | 1034 | sym_arr[i] = sym_match_arr[i].sym; |
1041 | sym_arr[cnt] = NULL; | 1035 | sym_arr[cnt] = NULL; |
1042 | } | 1036 | } |
1043 | sym_re_search_free: | 1037 | sym_re_search_free: |
1044 | if (sym_match_arr) { | 1038 | /* sym_match_arr can be NULL if no match, but free(NULL) is OK */ |
1045 | for (i = 0; i < cnt; i++) | 1039 | free(sym_match_arr); |
1046 | free(sym_match_arr[i]); | ||
1047 | free(sym_match_arr); | ||
1048 | } | ||
1049 | regfree(&re); | 1040 | regfree(&re); |
1050 | 1041 | ||
1051 | return sym_arr; | 1042 | return sym_arr; |