aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-10 19:06:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-10 19:06:46 -0400
commitb202c0d5205662fd96f7151afa83f891f2f4d542 (patch)
tree1e44a453662d0a8b26b3d7799f280f6ddbd67403
parentcb63fc26623ee38fd84d71ea5a98189240ec2e1b (diff)
parentb57caaaed2bd127fe656e6c145970ed6a05c0125 (diff)
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kconfig updates from Michal Marek: - dependency solver fix for make defconfig - randconfig fixes, one of which had to be reverted again - more user-friendly sorting of search results - hex and range keywords support longs - fix for [mn]conf not to rely on particular behavior of the LINES and COLS variables - cleanup of magic constants in kconfig/lxdialog - [mn]conf formatting fixes - fix for scripts/config's help text in out-of-tree usage (under a different name) * 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kconfig: allow "hex" and "range" to support longs Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG" kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG kconfig: loop as long as we changed some symbols in randconfig kconfig/[mn]conf: make it explicit in the search box that a regexp is possible kconfig: sort found symbols by relevance kconfig/conf: print the seed used to initialise the RNG for randconfig kconfig/conf: accept a base-16 seed for randconfig kconfig/conf: fix randconfig setting multiple symbols in a choice scripts/config: replace hard-coded script name by a dynamic value mconf/nconf: mark empty menus/menuconfigs different from non-empty ones nconf: use function calls instead of ncurses' variables LINES and COLS mconf: use function calls instead of ncurses' variables LINES and COLS kconfig/lxdialog: handle newline characters in print_autowrap() kconfig/lxdialog: Use new mininimum resize definitions in conf_choice() kconfig/lxdialog: Add definitions for mininimum (re)size values kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on
-rw-r--r--Documentation/kbuild/kconfig.txt13
-rwxr-xr-xscripts/config12
-rw-r--r--scripts/kconfig/conf.c6
-rw-r--r--scripts/kconfig/confdata.c33
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/lkc.h3
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rw-r--r--scripts/kconfig/lxdialog/checklist.c8
-rw-r--r--scripts/kconfig/lxdialog/dialog.h14
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c8
-rw-r--r--scripts/kconfig/lxdialog/menubox.c6
-rw-r--r--scripts/kconfig/lxdialog/textbox.c6
-rw-r--r--scripts/kconfig/lxdialog/util.c46
-rw-r--r--scripts/kconfig/lxdialog/yesno.c8
-rw-r--r--scripts/kconfig/mconf.c21
-rw-r--r--scripts/kconfig/menu.c16
-rw-r--r--scripts/kconfig/nconf.c39
-rw-r--r--scripts/kconfig/nconf.gui.c20
-rw-r--r--scripts/kconfig/symbol.c99
19 files changed, 262 insertions, 100 deletions
diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt
index 213859e69e88..e349f293cc98 100644
--- a/Documentation/kbuild/kconfig.txt
+++ b/Documentation/kbuild/kconfig.txt
@@ -174,6 +174,19 @@ Searching in menuconfig:
174 174
175 /^hotplug 175 /^hotplug
176 176
177 When searching, symbols are sorted thus:
178 - exact match first: an exact match is when the search matches
179 the complete symbol name;
180 - alphabetical order: when two symbols do not match exactly,
181 they are sorted in alphabetical order (in the user's current
182 locale).
183 For example: ^ATH.K matches:
184 ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG
185 [...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...]
186 of which only ATH5K and ATH9K match exactly and so are sorted
187 first (and in alphabetical order), then come all other symbols,
188 sorted in alphabetical order.
189
177______________________________________________________________________ 190______________________________________________________________________
178User interface options for 'menuconfig' 191User interface options for 'menuconfig'
179 192
diff --git a/scripts/config b/scripts/config
index a65ecbbdd32a..567120a87c39 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,6 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2# Manipulate options in a .config file from the command line 2# Manipulate options in a .config file from the command line
3 3
4myname=${0##*/}
5
4# If no prefix forced, use the default CONFIG_ 6# If no prefix forced, use the default CONFIG_
5CONFIG_="${CONFIG_-CONFIG_}" 7CONFIG_="${CONFIG_-CONFIG_}"
6 8
@@ -8,7 +10,7 @@ usage() {
8 cat >&2 <<EOL 10 cat >&2 <<EOL
9Manipulate options in a .config file from the command line. 11Manipulate options in a .config file from the command line.
10Usage: 12Usage:
11config options command ... 13$myname options command ...
12commands: 14commands:
13 --enable|-e option Enable option 15 --enable|-e option Enable option
14 --disable|-d option Disable option 16 --disable|-d option Disable option
@@ -33,14 +35,14 @@ options:
33 --file config-file .config file to change (default .config) 35 --file config-file .config file to change (default .config)
34 --keep-case|-k Keep next symbols' case (dont' upper-case it) 36 --keep-case|-k Keep next symbols' case (dont' upper-case it)
35 37
36config doesn't check the validity of the .config file. This is done at next 38$myname doesn't check the validity of the .config file. This is done at next
37make time. 39make time.
38 40
39By default, config will upper-case the given symbol. Use --keep-case to keep 41By default, $myname will upper-case the given symbol. Use --keep-case to keep
40the case of all following symbols unchanged. 42the case of all following symbols unchanged.
41 43
42config uses 'CONFIG_' as the default symbol prefix. Set the environment 44$myname uses 'CONFIG_' as the default symbol prefix. Set the environment
43variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ... 45variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
44EOL 46EOL
45 exit 1 47 exit 1
46} 48}
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index bde5b95c8c19..d19944f9c3ac 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -527,11 +527,12 @@ int main(int ac, char **av)
527 seed_env = getenv("KCONFIG_SEED"); 527 seed_env = getenv("KCONFIG_SEED");
528 if( seed_env && *seed_env ) { 528 if( seed_env && *seed_env ) {
529 char *endp; 529 char *endp;
530 int tmp = (int)strtol(seed_env, &endp, 10); 530 int tmp = (int)strtol(seed_env, &endp, 0);
531 if (*endp == '\0') { 531 if (*endp == '\0') {
532 seed = tmp; 532 seed = tmp;
533 } 533 }
534 } 534 }
535 fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
535 srand(seed); 536 srand(seed);
536 break; 537 break;
537 } 538 }
@@ -653,7 +654,8 @@ int main(int ac, char **av)
653 conf_set_all_new_symbols(def_default); 654 conf_set_all_new_symbols(def_default);
654 break; 655 break;
655 case randconfig: 656 case randconfig:
656 conf_set_all_new_symbols(def_random); 657 /* Really nothing to do in this loop */
658 while (conf_set_all_new_symbols(def_random)) ;
657 break; 659 break;
658 case defconfig: 660 case defconfig:
659 conf_set_all_new_symbols(def_default); 661 conf_set_all_new_symbols(def_default);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 43eda40c3838..c55c227af463 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1040,7 +1040,7 @@ void conf_set_changed_callback(void (*fn)(void))
1040 conf_changed_callback = fn; 1040 conf_changed_callback = fn;
1041} 1041}
1042 1042
1043static void randomize_choice_values(struct symbol *csym) 1043static bool randomize_choice_values(struct symbol *csym)
1044{ 1044{
1045 struct property *prop; 1045 struct property *prop;
1046 struct symbol *sym; 1046 struct symbol *sym;
@@ -1053,7 +1053,7 @@ static void randomize_choice_values(struct symbol *csym)
1053 * In both cases stop. 1053 * In both cases stop.
1054 */ 1054 */
1055 if (csym->curr.tri != yes) 1055 if (csym->curr.tri != yes)
1056 return; 1056 return false;
1057 1057
1058 prop = sym_get_choice_prop(csym); 1058 prop = sym_get_choice_prop(csym);
1059 1059
@@ -1077,13 +1077,18 @@ static void randomize_choice_values(struct symbol *csym)
1077 else { 1077 else {
1078 sym->def[S_DEF_USER].tri = no; 1078 sym->def[S_DEF_USER].tri = no;
1079 } 1079 }
1080 sym->flags |= SYMBOL_DEF_USER;
1081 /* clear VALID to get value calculated */
1082 sym->flags &= ~SYMBOL_VALID;
1080 } 1083 }
1081 csym->flags |= SYMBOL_DEF_USER; 1084 csym->flags |= SYMBOL_DEF_USER;
1082 /* clear VALID to get value calculated */ 1085 /* clear VALID to get value calculated */
1083 csym->flags &= ~(SYMBOL_VALID); 1086 csym->flags &= ~(SYMBOL_VALID);
1087
1088 return true;
1084} 1089}
1085 1090
1086static void set_all_choice_values(struct symbol *csym) 1091void set_all_choice_values(struct symbol *csym)
1087{ 1092{
1088 struct property *prop; 1093 struct property *prop;
1089 struct symbol *sym; 1094 struct symbol *sym;
@@ -1100,10 +1105,10 @@ static void set_all_choice_values(struct symbol *csym)
1100 } 1105 }
1101 csym->flags |= SYMBOL_DEF_USER; 1106 csym->flags |= SYMBOL_DEF_USER;
1102 /* clear VALID to get value calculated */ 1107 /* clear VALID to get value calculated */
1103 csym->flags &= ~(SYMBOL_VALID); 1108 csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
1104} 1109}
1105 1110
1106void conf_set_all_new_symbols(enum conf_def_mode mode) 1111bool conf_set_all_new_symbols(enum conf_def_mode mode)
1107{ 1112{
1108 struct symbol *sym, *csym; 1113 struct symbol *sym, *csym;
1109 int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y 1114 int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
@@ -1151,6 +1156,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1151 exit( 1 ); 1156 exit( 1 );
1152 } 1157 }
1153 } 1158 }
1159 bool has_changed = false;
1154 1160
1155 for_all_symbols(i, sym) { 1161 for_all_symbols(i, sym) {
1156 if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) 1162 if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
@@ -1158,6 +1164,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1158 switch (sym_get_type(sym)) { 1164 switch (sym_get_type(sym)) {
1159 case S_BOOLEAN: 1165 case S_BOOLEAN:
1160 case S_TRISTATE: 1166 case S_TRISTATE:
1167 has_changed = true;
1161 switch (mode) { 1168 switch (mode) {
1162 case def_yes: 1169 case def_yes:
1163 sym->def[S_DEF_USER].tri = yes; 1170 sym->def[S_DEF_USER].tri = yes;
@@ -1202,14 +1209,26 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1202 * selected in a choice block and we set it to yes, 1209 * selected in a choice block and we set it to yes,
1203 * and the rest to no. 1210 * and the rest to no.
1204 */ 1211 */
1212 if (mode != def_random) {
1213 for_all_symbols(i, csym) {
1214 if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
1215 sym_is_choice_value(csym))
1216 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
1217 }
1218 }
1219
1205 for_all_symbols(i, csym) { 1220 for_all_symbols(i, csym) {
1206 if (sym_has_value(csym) || !sym_is_choice(csym)) 1221 if (sym_has_value(csym) || !sym_is_choice(csym))
1207 continue; 1222 continue;
1208 1223
1209 sym_calc_value(csym); 1224 sym_calc_value(csym);
1210 if (mode == def_random) 1225 if (mode == def_random)
1211 randomize_choice_values(csym); 1226 has_changed = randomize_choice_values(csym);
1212 else 1227 else {
1213 set_all_choice_values(csym); 1228 set_all_choice_values(csym);
1229 has_changed = true;
1230 }
1214 } 1231 }
1232
1233 return has_changed;
1215} 1234}
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index cdd48600e02a..df198a5f4822 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -106,6 +106,9 @@ struct symbol {
106#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ 106#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
107#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ 107#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
108 108
109/* choice values need to be set before calculating this symbol value */
110#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
111
109#define SYMBOL_MAXLENGTH 256 112#define SYMBOL_MAXLENGTH 256
110#define SYMBOL_HASHSIZE 9973 113#define SYMBOL_HASHSIZE 9973
111 114
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index f8aee5fc6d5e..09f4edfdc911 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -86,7 +86,8 @@ const char *conf_get_autoconfig_name(void);
86char *conf_get_default_confname(void); 86char *conf_get_default_confname(void);
87void sym_set_change_count(int count); 87void sym_set_change_count(int count);
88void sym_add_change_count(int count); 88void sym_add_change_count(int count);
89void conf_set_all_new_symbols(enum conf_def_mode mode); 89bool conf_set_all_new_symbols(enum conf_def_mode mode);
90void set_all_choice_values(struct symbol *csym);
90 91
91struct conf_printer { 92struct conf_printer {
92 void (*print_symbol)(FILE *, struct symbol *, const char *, void *); 93 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index ef1a7381f956..ecdb9659b67d 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
14/* menu.c */ 14/* menu.c */
15P(rootmenu,struct menu,); 15P(rootmenu,struct menu,);
16 16
17P(menu_is_empty, bool, (struct menu *menu));
17P(menu_is_visible, bool, (struct menu *menu)); 18P(menu_is_visible, bool, (struct menu *menu));
18P(menu_has_prompt, bool, (struct menu *menu)); 19P(menu_has_prompt, bool, (struct menu *menu));
19P(menu_get_prompt,const char *,(struct menu *menu)); 20P(menu_get_prompt,const char *,(struct menu *menu));
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index a2eb80fbc896..3b15c08ec1fa 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
132 } 132 }
133 133
134do_resize: 134do_resize:
135 if (getmaxy(stdscr) < (height + 6)) 135 if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
136 return -ERRDISPLAYTOOSMALL; 136 return -ERRDISPLAYTOOSMALL;
137 if (getmaxx(stdscr) < (width + 6)) 137 if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
138 return -ERRDISPLAYTOOSMALL; 138 return -ERRDISPLAYTOOSMALL;
139 139
140 max_choice = MIN(list_height, item_count()); 140 max_choice = MIN(list_height, item_count());
141 141
142 /* center dialog box on screen */ 142 /* center dialog box on screen */
143 x = (COLS - width) / 2; 143 x = (getmaxx(stdscr) - width) / 2;
144 y = (LINES - height) / 2; 144 y = (getmaxy(stdscr) - height) / 2;
145 145
146 draw_shadow(stdscr, y, x, height, width); 146 draw_shadow(stdscr, y, x, height, width);
147 147
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 1099337079b6..b4343d384926 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -200,6 +200,20 @@ int item_is_tag(char tag);
200int on_key_esc(WINDOW *win); 200int on_key_esc(WINDOW *win);
201int on_key_resize(void); 201int on_key_resize(void);
202 202
203/* minimum (re)size values */
204#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
205#define CHECKLIST_WIDTH_MIN 6
206#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
207#define INPUTBOX_WIDTH_MIN 2
208#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
209#define MENUBOX_WIDTH_MIN 65
210#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
211#define TEXTBOX_WIDTH_MIN 8
212#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
213#define YESNO_WIDTH_MIN 4
214#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
215#define WINDOW_WIDTH_MIN 80
216
203int init_dialog(const char *backtitle); 217int init_dialog(const char *backtitle);
204void set_dialog_backtitle(const char *backtitle); 218void set_dialog_backtitle(const char *backtitle);
205void set_dialog_subtitles(struct subtitle_list *subtitles); 219void set_dialog_subtitles(struct subtitle_list *subtitles);
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 21404a04d7c3..447a582198c9 100644
--- a/scripts/kconfig/lxdialog/inputbox.c
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -56,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
56 strcpy(instr, init); 56 strcpy(instr, init);
57 57
58do_resize: 58do_resize:
59 if (getmaxy(stdscr) <= (height - 2)) 59 if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
60 return -ERRDISPLAYTOOSMALL; 60 return -ERRDISPLAYTOOSMALL;
61 if (getmaxx(stdscr) <= (width - 2)) 61 if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
62 return -ERRDISPLAYTOOSMALL; 62 return -ERRDISPLAYTOOSMALL;
63 63
64 /* center dialog box on screen */ 64 /* center dialog box on screen */
65 x = (COLS - width) / 2; 65 x = (getmaxx(stdscr) - width) / 2;
66 y = (LINES - height) / 2; 66 y = (getmaxy(stdscr) - height) / 2;
67 67
68 draw_shadow(stdscr, y, x, height, width); 68 draw_shadow(stdscr, y, x, height, width);
69 69
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 38cd69c5660e..c93de0b2faca 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
193do_resize: 193do_resize:
194 height = getmaxy(stdscr); 194 height = getmaxy(stdscr);
195 width = getmaxx(stdscr); 195 width = getmaxx(stdscr);
196 if (height < 15 || width < 65) 196 if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
197 return -ERRDISPLAYTOOSMALL; 197 return -ERRDISPLAYTOOSMALL;
198 198
199 height -= 4; 199 height -= 4;
@@ -203,8 +203,8 @@ do_resize:
203 max_choice = MIN(menu_height, item_count()); 203 max_choice = MIN(menu_height, item_count());
204 204
205 /* center dialog box on screen */ 205 /* center dialog box on screen */
206 x = (COLS - width) / 2; 206 x = (getmaxx(stdscr) - width) / 2;
207 y = (LINES - height) / 2; 207 y = (getmaxy(stdscr) - height) / 2;
208 208
209 draw_shadow(stdscr, y, x, height, width); 209 draw_shadow(stdscr, y, x, height, width);
210 210
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index a48bb93e0907..1773319b95e7 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -80,7 +80,7 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height,
80 80
81do_resize: 81do_resize:
82 getmaxyx(stdscr, height, width); 82 getmaxyx(stdscr, height, width);
83 if (height < 8 || width < 8) 83 if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
84 return -ERRDISPLAYTOOSMALL; 84 return -ERRDISPLAYTOOSMALL;
85 if (initial_height != 0) 85 if (initial_height != 0)
86 height = initial_height; 86 height = initial_height;
@@ -98,8 +98,8 @@ do_resize:
98 width = 0; 98 width = 0;
99 99
100 /* center dialog box on screen */ 100 /* center dialog box on screen */
101 x = (COLS - width) / 2; 101 x = (getmaxx(stdscr) - width) / 2;
102 y = (LINES - height) / 2; 102 y = (getmaxy(stdscr) - height) / 2;
103 103
104 draw_shadow(stdscr, y, x, height, width); 104 draw_shadow(stdscr, y, x, height, width);
105 105
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a0e97c299410..58a8289dd650 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
254 254
255void dialog_clear(void) 255void dialog_clear(void)
256{ 256{
257 attr_clear(stdscr, LINES, COLS, dlg.screen.atr); 257 int lines, columns;
258
259 lines = getmaxy(stdscr);
260 columns = getmaxx(stdscr);
261
262 attr_clear(stdscr, lines, columns, dlg.screen.atr);
258 /* Display background title if it exists ... - SLH */ 263 /* Display background title if it exists ... - SLH */
259 if (dlg.backtitle != NULL) { 264 if (dlg.backtitle != NULL) {
260 int i, len = 0, skip = 0; 265 int i, len = 0, skip = 0;
@@ -269,10 +274,10 @@ void dialog_clear(void)
269 } 274 }
270 275
271 wmove(stdscr, 1, 1); 276 wmove(stdscr, 1, 1);
272 if (len > COLS - 2) { 277 if (len > columns - 2) {
273 const char *ellipsis = "[...] "; 278 const char *ellipsis = "[...] ";
274 waddstr(stdscr, ellipsis); 279 waddstr(stdscr, ellipsis);
275 skip = len - (COLS - 2 - strlen(ellipsis)); 280 skip = len - (columns - 2 - strlen(ellipsis));
276 } 281 }
277 282
278 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { 283 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void)
298 skip--; 303 skip--;
299 } 304 }
300 305
301 for (i = len + 1; i < COLS - 1; i++) 306 for (i = len + 1; i < columns - 1; i++)
302 waddch(stdscr, ACS_HLINE); 307 waddch(stdscr, ACS_HLINE);
303 } 308 }
304 wnoutrefresh(stdscr); 309 wnoutrefresh(stdscr);
@@ -317,7 +322,7 @@ int init_dialog(const char *backtitle)
317 getyx(stdscr, saved_y, saved_x); 322 getyx(stdscr, saved_y, saved_x);
318 323
319 getmaxyx(stdscr, height, width); 324 getmaxyx(stdscr, height, width);
320 if (height < 19 || width < 80) { 325 if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
321 endwin(); 326 endwin();
322 return -ERRDISPLAYTOOSMALL; 327 return -ERRDISPLAYTOOSMALL;
323 } 328 }
@@ -371,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
371/* 376/*
372 * Print a string of text in a window, automatically wrap around to the 377 * Print a string of text in a window, automatically wrap around to the
373 * next line if the string is too long to fit on one line. Newline 378 * next line if the string is too long to fit on one line. Newline
374 * characters '\n' are replaced by spaces. We start on a new line 379 * characters '\n' are propperly processed. We start on a new line
375 * if there is no room for at least 4 nonblanks following a double-space. 380 * if there is no room for at least 4 nonblanks following a double-space.
376 */ 381 */
377void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) 382void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
378{ 383{
379 int newl, cur_x, cur_y; 384 int newl, cur_x, cur_y;
380 int i, prompt_len, room, wlen; 385 int prompt_len, room, wlen;
381 char tempstr[MAX_LEN + 1], *word, *sp, *sp2; 386 char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
382 387
383 strcpy(tempstr, prompt); 388 strcpy(tempstr, prompt);
384 389
385 prompt_len = strlen(tempstr); 390 prompt_len = strlen(tempstr);
386 391
387 /*
388 * Remove newlines
389 */
390 for (i = 0; i < prompt_len; i++) {
391 if (tempstr[i] == '\n')
392 tempstr[i] = ' ';
393 }
394
395 if (prompt_len <= width - x * 2) { /* If prompt is short */ 392 if (prompt_len <= width - x * 2) { /* If prompt is short */
396 wmove(win, y, (width - prompt_len) / 2); 393 wmove(win, y, (width - prompt_len) / 2);
397 waddstr(win, tempstr); 394 waddstr(win, tempstr);
@@ -401,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
401 newl = 1; 398 newl = 1;
402 word = tempstr; 399 word = tempstr;
403 while (word && *word) { 400 while (word && *word) {
404 sp = strchr(word, ' '); 401 sp = strpbrk(word, "\n ");
402 if (sp && *sp == '\n')
403 newline_separator = sp;
404
405 if (sp) 405 if (sp)
406 *sp++ = 0; 406 *sp++ = 0;
407 407
@@ -413,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
413 if (wlen > room || 413 if (wlen > room ||
414 (newl && wlen < 4 && sp 414 (newl && wlen < 4 && sp
415 && wlen + 1 + strlen(sp) > room 415 && wlen + 1 + strlen(sp) > room
416 && (!(sp2 = strchr(sp, ' ')) 416 && (!(sp2 = strpbrk(sp, "\n "))
417 || wlen + 1 + (sp2 - sp) > room))) { 417 || wlen + 1 + (sp2 - sp) > room))) {
418 cur_y++; 418 cur_y++;
419 cur_x = x; 419 cur_x = x;
@@ -421,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
421 wmove(win, cur_y, cur_x); 421 wmove(win, cur_y, cur_x);
422 waddstr(win, word); 422 waddstr(win, word);
423 getyx(win, cur_y, cur_x); 423 getyx(win, cur_y, cur_x);
424 cur_x++; 424
425 /* Move to the next line if the word separator was a newline */
426 if (newline_separator) {
427 cur_y++;
428 cur_x = x;
429 newline_separator = 0;
430 } else
431 cur_x++;
432
425 if (sp && *sp == ' ') { 433 if (sp && *sp == ' ') {
426 cur_x++; /* double space */ 434 cur_x++; /* double space */
427 while (*++sp == ' ') ; 435 while (*++sp == ' ') ;
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c
index 4e6e8090c20b..676fb2f824a3 100644
--- a/scripts/kconfig/lxdialog/yesno.c
+++ b/scripts/kconfig/lxdialog/yesno.c
@@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
45 WINDOW *dialog; 45 WINDOW *dialog;
46 46
47do_resize: 47do_resize:
48 if (getmaxy(stdscr) < (height + 4)) 48 if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
49 return -ERRDISPLAYTOOSMALL; 49 return -ERRDISPLAYTOOSMALL;
50 if (getmaxx(stdscr) < (width + 4)) 50 if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
51 return -ERRDISPLAYTOOSMALL; 51 return -ERRDISPLAYTOOSMALL;
52 52
53 /* center dialog box on screen */ 53 /* center dialog box on screen */
54 x = (COLS - width) / 2; 54 x = (getmaxx(stdscr) - width) / 2;
55 y = (LINES - height) / 2; 55 y = (getmaxy(stdscr) - height) / 2;
56 56
57 draw_shadow(stdscr, y, x, height, width); 57 draw_shadow(stdscr, y, x, height, width);
58 58
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index a69cbd78fb38..6c9c45f9fbba 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -48,7 +48,7 @@ static const char mconf_readme[] = N_(
48"----------\n" 48"----------\n"
49"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" 49"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
50" you wish to change or submenu wish to select and press <Enter>.\n" 50" you wish to change or submenu wish to select and press <Enter>.\n"
51" Submenus are designated by \"--->\".\n" 51" Submenus are designated by \"--->\", empty ones by \"----\".\n"
52"\n" 52"\n"
53" Shortcut: Press the option's highlighted letter (hotkey).\n" 53" Shortcut: Press the option's highlighted letter (hotkey).\n"
54" Pressing a hotkey more than once will sequence\n" 54" Pressing a hotkey more than once will sequence\n"
@@ -176,7 +176,7 @@ static const char mconf_readme[] = N_(
176"\n"), 176"\n"),
177menu_instructions[] = N_( 177menu_instructions[] = N_(
178 "Arrow keys navigate the menu. " 178 "Arrow keys navigate the menu. "
179 "<Enter> selects submenus --->. " 179 "<Enter> selects submenus ---> (or empty submenus ----). "
180 "Highlighted letters are hotkeys. " 180 "Highlighted letters are hotkeys. "
181 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 181 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
182 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " 182 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
@@ -401,7 +401,7 @@ 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 to search for " 404 str_printf( &title, _("Enter %s (sub)string or regexp to search for "
405 "(with or without \"%s\")"), CONFIG_, CONFIG_); 405 "(with or without \"%s\")"), CONFIG_, CONFIG_);
406 406
407again: 407again:
@@ -498,8 +498,9 @@ static void build_conf(struct menu *menu)
498 menu->data ? "-->" : "++>", 498 menu->data ? "-->" : "++>",
499 indent + 1, ' ', prompt); 499 indent + 1, ' ', prompt);
500 } else 500 } else
501 item_make(" %*c%s --->", indent + 1, ' ', prompt); 501 item_make(" %*c%s %s",
502 502 indent + 1, ' ', prompt,
503 menu_is_empty(menu) ? "----" : "--->");
503 item_set_tag('m'); 504 item_set_tag('m');
504 item_set_data(menu); 505 item_set_data(menu);
505 if (single_menu_mode && menu->data) 506 if (single_menu_mode && menu->data)
@@ -630,7 +631,7 @@ static void build_conf(struct menu *menu)
630 (sym_has_value(sym) || !sym_is_changable(sym)) ? 631 (sym_has_value(sym) || !sym_is_changable(sym)) ?
631 "" : _(" (NEW)")); 632 "" : _(" (NEW)"));
632 if (menu->prompt->type == P_MENU) { 633 if (menu->prompt->type == P_MENU) {
633 item_add_str(" --->"); 634 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
634 return; 635 return;
635 } 636 }
636 } 637 }
@@ -826,7 +827,9 @@ static void conf_choice(struct menu *menu)
826 dialog_clear(); 827 dialog_clear();
827 res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), 828 res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
828 _(radiolist_instructions), 829 _(radiolist_instructions),
829 15, 70, 6); 830 MENUBOX_HEIGTH_MIN,
831 MENUBOX_WIDTH_MIN,
832 CHECKLIST_HEIGTH_MIN);
830 selected = item_activate_selected(); 833 selected = item_activate_selected();
831 switch (res) { 834 switch (res) {
832 case 0: 835 case 0:
@@ -957,8 +960,8 @@ static int handle_exit(void)
957 dialog_clear(); 960 dialog_clear();
958 if (conf_get_changed()) 961 if (conf_get_changed())
959 res = dialog_yesno(NULL, 962 res = dialog_yesno(NULL,
960 _("Do you wish to save your new configuration ?\n" 963 _("Do you wish to save your new configuration?\n"
961 "<ESC><ESC> to continue."), 964 "(Press <ESC><ESC> to continue kernel configuration.)"),
962 6, 60); 965 6, 60);
963 else 966 else
964 res = -1; 967 res = -1;
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index fd3f0180e08f..7e233a6ca64e 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -443,6 +443,22 @@ bool menu_has_prompt(struct menu *menu)
443 return true; 443 return true;
444} 444}
445 445
446/*
447 * Determine if a menu is empty.
448 * A menu is considered empty if it contains no or only
449 * invisible entries.
450 */
451bool menu_is_empty(struct menu *menu)
452{
453 struct menu *child;
454
455 for (child = menu->list; child; child = child->next) {
456 if (menu_is_visible(child))
457 return(false);
458 }
459 return(true);
460}
461
446bool menu_is_visible(struct menu *menu) 462bool menu_is_visible(struct menu *menu)
447{ 463{
448 struct menu *child; 464 struct menu *child;
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index dbf31edd22b2..7975d8d258c3 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -45,8 +45,8 @@ static const char nconf_global_help[] = N_(
45"<n> to remove it. You may press the <Space> key to cycle through the\n" 45"<n> to remove it. You may press the <Space> key to cycle through the\n"
46"available options.\n" 46"available options.\n"
47"\n" 47"\n"
48"A trailing \"--->\" designates a submenu.\n" 48"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n"
49"\n" 49"empty submenu.\n"
50"\n" 50"\n"
51"Menu navigation keys\n" 51"Menu navigation keys\n"
52"----------------------------------------------------------------------\n" 52"----------------------------------------------------------------------\n"
@@ -131,7 +131,7 @@ static const char nconf_global_help[] = N_(
131"\n"), 131"\n"),
132menu_no_f_instructions[] = N_( 132menu_no_f_instructions[] = N_(
133"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 133"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
134"Submenus are designated by a trailing \"--->\".\n" 134"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
135"\n" 135"\n"
136"Use the following keys to navigate the menus:\n" 136"Use the following keys to navigate the menus:\n"
137"Move up or down with <Up> and <Down>.\n" 137"Move up or down with <Up> and <Down>.\n"
@@ -148,7 +148,7 @@ menu_no_f_instructions[] = N_(
148"For help related to the current menu entry press <?> or <h>.\n"), 148"For help related to the current menu entry press <?> or <h>.\n"),
149menu_instructions[] = N_( 149menu_instructions[] = N_(
150"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 150"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
151"Submenus are designated by a trailing \"--->\".\n" 151"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
152"\n" 152"\n"
153"Use the following keys to navigate the menus:\n" 153"Use the following keys to navigate the menus:\n"
154"Move up or down with <Up> or <Down>.\n" 154"Move up or down with <Up> or <Down>.\n"
@@ -365,15 +365,16 @@ static void print_function_line(void)
365 int i; 365 int i;
366 int offset = 1; 366 int offset = 1;
367 const int skip = 1; 367 const int skip = 1;
368 int lines = getmaxy(stdscr);
368 369
369 for (i = 0; i < function_keys_num; i++) { 370 for (i = 0; i < function_keys_num; i++) {
370 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); 371 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
371 mvwprintw(main_window, LINES-3, offset, 372 mvwprintw(main_window, lines-3, offset,
372 "%s", 373 "%s",
373 function_keys[i].key_str); 374 function_keys[i].key_str);
374 (void) wattrset(main_window, attributes[FUNCTION_TEXT]); 375 (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
375 offset += strlen(function_keys[i].key_str); 376 offset += strlen(function_keys[i].key_str);
376 mvwprintw(main_window, LINES-3, 377 mvwprintw(main_window, lines-3,
377 offset, "%s", 378 offset, "%s",
378 function_keys[i].func); 379 function_keys[i].func);
379 offset += strlen(function_keys[i].func) + skip; 380 offset += strlen(function_keys[i].func) + skip;
@@ -694,7 +695,7 @@ static void search_conf(void)
694 int dres; 695 int dres;
695 696
696 title = str_new(); 697 title = str_new();
697 str_printf( &title, _("Enter %s (sub)string to search for " 698 str_printf( &title, _("Enter %s (sub)string or regexp to search for "
698 "(with or without \"%s\")"), CONFIG_, CONFIG_); 699 "(with or without \"%s\")"), CONFIG_, CONFIG_);
699 700
700again: 701again:
@@ -759,9 +760,9 @@ static void build_conf(struct menu *menu)
759 indent + 1, ' ', prompt); 760 indent + 1, ' ', prompt);
760 } else 761 } else
761 item_make(menu, 'm', 762 item_make(menu, 'm',
762 " %*c%s --->", 763 " %*c%s %s",
763 indent + 1, 764 indent + 1, ' ', prompt,
764 ' ', prompt); 765 menu_is_empty(menu) ? "----" : "--->");
765 766
766 if (single_menu_mode && menu->data) 767 if (single_menu_mode && menu->data)
767 goto conf_childs; 768 goto conf_childs;
@@ -903,7 +904,7 @@ static void build_conf(struct menu *menu)
903 (sym_has_value(sym) || !sym_is_changable(sym)) ? 904 (sym_has_value(sym) || !sym_is_changable(sym)) ?
904 "" : _(" (NEW)")); 905 "" : _(" (NEW)"));
905 if (menu->prompt && menu->prompt->type == P_MENU) { 906 if (menu->prompt && menu->prompt->type == P_MENU) {
906 item_add_str(" --->"); 907 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
907 return; 908 return;
908 } 909 }
909 } 910 }
@@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions,
954 955
955 clear(); 956 clear();
956 (void) wattrset(main_window, attributes[NORMAL]); 957 (void) wattrset(main_window, attributes[NORMAL]);
957 print_in_middle(stdscr, 1, 0, COLS, 958 print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
958 menu_backtitle, 959 menu_backtitle,
959 attributes[MAIN_HEADING]); 960 attributes[MAIN_HEADING]);
960 961
@@ -1455,14 +1456,18 @@ static void conf_save(void)
1455 1456
1456void setup_windows(void) 1457void setup_windows(void)
1457{ 1458{
1459 int lines, columns;
1460
1461 getmaxyx(stdscr, lines, columns);
1462
1458 if (main_window != NULL) 1463 if (main_window != NULL)
1459 delwin(main_window); 1464 delwin(main_window);
1460 1465
1461 /* set up the menu and menu window */ 1466 /* set up the menu and menu window */
1462 main_window = newwin(LINES-2, COLS-2, 2, 1); 1467 main_window = newwin(lines-2, columns-2, 2, 1);
1463 keypad(main_window, TRUE); 1468 keypad(main_window, TRUE);
1464 mwin_max_lines = LINES-7; 1469 mwin_max_lines = lines-7;
1465 mwin_max_cols = COLS-6; 1470 mwin_max_cols = columns-6;
1466 1471
1467 /* panels order is from bottom to top */ 1472 /* panels order is from bottom to top */
1468 new_panel(main_window); 1473 new_panel(main_window);
@@ -1470,6 +1475,7 @@ void setup_windows(void)
1470 1475
1471int main(int ac, char **av) 1476int main(int ac, char **av)
1472{ 1477{
1478 int lines, columns;
1473 char *mode; 1479 char *mode;
1474 1480
1475 setlocale(LC_ALL, ""); 1481 setlocale(LC_ALL, "");
@@ -1495,7 +1501,8 @@ int main(int ac, char **av)
1495 keypad(stdscr, TRUE); 1501 keypad(stdscr, TRUE);
1496 curs_set(0); 1502 curs_set(0);
1497 1503
1498 if (COLS < 75 || LINES < 20) { 1504 getmaxyx(stdscr, lines, columns);
1505 if (columns < 75 || lines < 20) {
1499 endwin(); 1506 endwin();
1500 printf("Your terminal should have at " 1507 printf("Your terminal should have at "
1501 "least 20 lines and 75 columns\n"); 1508 "least 20 lines and 75 columns\n");
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 9f8c44ecc703..8275f0e55106 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
276 276
277 total_width = max(msg_width, btns_width); 277 total_width = max(msg_width, btns_width);
278 /* place dialog in middle of screen */ 278 /* place dialog in middle of screen */
279 y = (LINES-(msg_lines+4))/2; 279 y = (getmaxy(stdscr)-(msg_lines+4))/2;
280 x = (COLS-(total_width+4))/2; 280 x = (getmaxx(stdscr)-(total_width+4))/2;
281 281
282 282
283 /* create the windows */ 283 /* create the windows */
@@ -387,8 +387,8 @@ int dialog_inputbox(WINDOW *main_window,
387 prompt_width = max(prompt_width, strlen(title)); 387 prompt_width = max(prompt_width, strlen(title));
388 388
389 /* place dialog in middle of screen */ 389 /* place dialog in middle of screen */
390 y = (LINES-(prompt_lines+4))/2; 390 y = (getmaxy(stdscr)-(prompt_lines+4))/2;
391 x = (COLS-(prompt_width+4))/2; 391 x = (getmaxx(stdscr)-(prompt_width+4))/2;
392 392
393 strncpy(result, init, *result_len); 393 strncpy(result, init, *result_len);
394 394
@@ -545,7 +545,7 @@ void show_scroll_win(WINDOW *main_window,
545{ 545{
546 int res; 546 int res;
547 int total_lines = get_line_no(text); 547 int total_lines = get_line_no(text);
548 int x, y; 548 int x, y, lines, columns;
549 int start_x = 0, start_y = 0; 549 int start_x = 0, start_y = 0;
550 int text_lines = 0, text_cols = 0; 550 int text_lines = 0, text_cols = 0;
551 int total_cols = 0; 551 int total_cols = 0;
@@ -556,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,
556 WINDOW *pad; 556 WINDOW *pad;
557 PANEL *panel; 557 PANEL *panel;
558 558
559 getmaxyx(stdscr, lines, columns);
560
559 /* find the widest line of msg: */ 561 /* find the widest line of msg: */
560 total_lines = get_line_no(text); 562 total_lines = get_line_no(text);
561 for (i = 0; i < total_lines; i++) { 563 for (i = 0; i < total_lines; i++) {
@@ -569,14 +571,14 @@ void show_scroll_win(WINDOW *main_window,
569 (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); 571 (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
570 fill_window(pad, text); 572 fill_window(pad, text);
571 573
572 win_lines = min(total_lines+4, LINES-2); 574 win_lines = min(total_lines+4, lines-2);
573 win_cols = min(total_cols+2, COLS-2); 575 win_cols = min(total_cols+2, columns-2);
574 text_lines = max(win_lines-4, 0); 576 text_lines = max(win_lines-4, 0);
575 text_cols = max(win_cols-2, 0); 577 text_cols = max(win_cols-2, 0);
576 578
577 /* place window in middle of screen */ 579 /* place window in middle of screen */
578 y = (LINES-win_lines)/2; 580 y = (lines-win_lines)/2;
579 x = (COLS-win_cols)/2; 581 x = (columns-win_cols)/2;
580 582
581 win = newwin(win_lines, win_cols, y, x); 583 win = newwin(win_lines, win_cols, y, x);
582 keypad(win, TRUE); 584 keypad(win, TRUE);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index ecc5aa5f865d..d550300ec00c 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
136 return NULL; 136 return NULL;
137} 137}
138 138
139static int sym_get_range_val(struct symbol *sym, int base) 139static long sym_get_range_val(struct symbol *sym, int base)
140{ 140{
141 sym_calc_value(sym); 141 sym_calc_value(sym);
142 switch (sym->type) { 142 switch (sym->type) {
@@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
155static void sym_validate_range(struct symbol *sym) 155static void sym_validate_range(struct symbol *sym)
156{ 156{
157 struct property *prop; 157 struct property *prop;
158 int base, val, val2; 158 long base, val, val2;
159 char str[64]; 159 char str[64];
160 160
161 switch (sym->type) { 161 switch (sym->type) {
@@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
179 return; 179 return;
180 } 180 }
181 if (sym->type == S_INT) 181 if (sym->type == S_INT)
182 sprintf(str, "%d", val2); 182 sprintf(str, "%ld", val2);
183 else 183 else
184 sprintf(str, "0x%x", val2); 184 sprintf(str, "0x%lx", val2);
185 sym->curr.val = strdup(str); 185 sym->curr.val = strdup(str);
186} 186}
187 187
@@ -300,6 +300,14 @@ void sym_calc_value(struct symbol *sym)
300 300
301 if (sym->flags & SYMBOL_VALID) 301 if (sym->flags & SYMBOL_VALID)
302 return; 302 return;
303
304 if (sym_is_choice_value(sym) &&
305 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
306 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
307 prop = sym_get_choice_prop(sym);
308 sym_calc_value(prop_get_symbol(prop));
309 }
310
303 sym->flags |= SYMBOL_VALID; 311 sym->flags |= SYMBOL_VALID;
304 312
305 oldval = sym->curr; 313 oldval = sym->curr;
@@ -425,6 +433,9 @@ void sym_calc_value(struct symbol *sym)
425 433
426 if (sym->flags & SYMBOL_AUTO) 434 if (sym->flags & SYMBOL_AUTO)
427 sym->flags &= ~SYMBOL_WRITE; 435 sym->flags &= ~SYMBOL_WRITE;
436
437 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
438 set_all_choice_values(sym);
428} 439}
429 440
430void sym_clear_all_valid(void) 441void sym_clear_all_valid(void)
@@ -583,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
583bool sym_string_within_range(struct symbol *sym, const char *str) 594bool sym_string_within_range(struct symbol *sym, const char *str)
584{ 595{
585 struct property *prop; 596 struct property *prop;
586 int val; 597 long val;
587 598
588 switch (sym->type) { 599 switch (sym->type) {
589 case S_STRING: 600 case S_STRING:
@@ -943,38 +954,98 @@ const char *sym_escape_string_value(const char *in)
943 return res; 954 return res;
944} 955}
945 956
957struct sym_match {
958 struct symbol *sym;
959 off_t so, eo;
960};
961
962/* Compare matched symbols as thus:
963 * - first, symbols that match exactly
964 * - then, alphabetical sort
965 */
966static int sym_rel_comp( const void *sym1, const void *sym2 )
967{
968 struct sym_match *s1 = *(struct sym_match **)sym1;
969 struct sym_match *s2 = *(struct sym_match **)sym2;
970 int l1, l2;
971
972 /* Exact match:
973 * - if matched length on symbol s1 is the length of that symbol,
974 * then this symbol should come first;
975 * - if matched length on symbol s2 is the length of that symbol,
976 * then this symbol should come first.
977 * Note: since the search can be a regexp, both symbols may match
978 * exactly; if this is the case, we can't decide which comes first,
979 * and we fallback to sorting alphabetically.
980 */
981 l1 = s1->eo - s1->so;
982 l2 = s2->eo - s2->so;
983 if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name))
984 return -1;
985 if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name))
986 return 1;
987
988 /* As a fallback, sort symbols alphabetically */
989 return strcmp(s1->sym->name, s2->sym->name);
990}
991
946struct symbol **sym_re_search(const char *pattern) 992struct symbol **sym_re_search(const char *pattern)
947{ 993{
948 struct symbol *sym, **sym_arr = NULL; 994 struct symbol *sym, **sym_arr = NULL;
995 struct sym_match **sym_match_arr = NULL;
949 int i, cnt, size; 996 int i, cnt, size;
950 regex_t re; 997 regex_t re;
998 regmatch_t match[1];
951 999
952 cnt = size = 0; 1000 cnt = size = 0;
953 /* Skip if empty */ 1001 /* Skip if empty */
954 if (strlen(pattern) == 0) 1002 if (strlen(pattern) == 0)
955 return NULL; 1003 return NULL;
956 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) 1004 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
957 return NULL; 1005 return NULL;
958 1006
959 for_all_symbols(i, sym) { 1007 for_all_symbols(i, sym) {
1008 struct sym_match *tmp_sym_match;
960 if (sym->flags & SYMBOL_CONST || !sym->name) 1009 if (sym->flags & SYMBOL_CONST || !sym->name)
961 continue; 1010 continue;
962 if (regexec(&re, sym->name, 0, NULL, 0)) 1011 if (regexec(&re, sym->name, 1, match, 0))
963 continue; 1012 continue;
964 if (cnt + 1 >= size) { 1013 if (cnt + 1 >= size) {
965 void *tmp = sym_arr; 1014 void *tmp;
966 size += 16; 1015 size += 16;
967 sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); 1016 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *));
968 if (!sym_arr) { 1017 if (!tmp) {
969 free(tmp); 1018 goto sym_re_search_free;
970 return NULL;
971 } 1019 }
1020 sym_match_arr = tmp;
972 } 1021 }
973 sym_calc_value(sym); 1022 sym_calc_value(sym);
974 sym_arr[cnt++] = sym; 1023 tmp_sym_match = (struct sym_match*)malloc(sizeof(struct sym_match));
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
1029 */
1030 tmp_sym_match->so = match[0].rm_so;
1031 tmp_sym_match->eo = match[0].rm_eo;
1032 sym_match_arr[cnt++] = tmp_sym_match;
975 } 1033 }
976 if (sym_arr) 1034 if (sym_match_arr) {
1035 qsort(sym_match_arr, cnt, sizeof(struct sym_match*), sym_rel_comp);
1036 sym_arr = malloc((cnt+1) * sizeof(struct symbol));
1037 if (!sym_arr)
1038 goto sym_re_search_free;
1039 for (i = 0; i < cnt; i++)
1040 sym_arr[i] = sym_match_arr[i]->sym;
977 sym_arr[cnt] = NULL; 1041 sym_arr[cnt] = NULL;
1042 }
1043sym_re_search_free:
1044 if (sym_match_arr) {
1045 for (i = 0; i < cnt; i++)
1046 free(sym_match_arr[i]);
1047 free(sym_match_arr);
1048 }
978 regfree(&re); 1049 regfree(&re);
979 1050
980 return sym_arr; 1051 return sym_arr;