Skip to content

Commit 309667e

Browse files
committed
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kconfig changes from Michal Marek: "I forgot to send a pull request in time for the v3.8-rc1 merge window, so the list is a bit longer this time: - menuconfig enables extended colors in ncurses if the wide-character version is used. - CONFIG_ prefix can be specified in the environment to make life easier for people using kconfig multiple times in a single tree (no functional change in the kernel kconfig usage). - kconfig aborts on OOM. - inputboxes in menuconfig allow to move the cursor. - menuconfig has Save/Load buttons now. - xconfig build fix with new g++ and Qt3. - nconfig color scheme fix and help text update. - make oldconfig prints newlines when output is redirected. - some other minor fixes." * 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild: Fix missing '\n' for NEW symbols in yes "" | make oldconfig >conf.new kconfig: nconf: rewrite labels of function keys line kconfig: nconf: rewrite help texts kconfig: fix a compiliation error when using make xconfig nconf: function keys line, change background color for better readability menuconfig: Get rid of the top-level entries for "Load an Alternate/Save an Alternate" menuconfig: Add Save/Load buttons kconfig:lxdialog: remove duplicate code menuconfig:inputbox: support navigate input position kconfig: document use of CONFIG_ environment variable scripts/kconfig: ensure we use proper CONFIG_ prefix merge_config.sh: Add option to specify output dir Revert "kconfig-language: add to hints" kconfig: Regenerate lexer kconfig: Fix malloc handling in conf tools kconfig: get CONFIG_ prefix from the environment kconfig: add a function to get the CONFIG_ prefix kconfig: remove CONFIG_ from string constants menuconfig: fix extended colors ncurses support
2 parents ad60a93 + e3900e7 commit 309667e

21 files changed

+391
-283
lines changed

Documentation/kbuild/kconfig-language.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -388,26 +388,3 @@ config FOO
388388
depends on BAR && m
389389

390390
limits FOO to module (=m) or disabled (=n).
391-
392-
Kconfig symbol existence
393-
~~~~~~~~~~~~~~~~~~~~~~~~
394-
The following two methods produce the same kconfig symbol dependencies
395-
but differ greatly in kconfig symbol existence (production) in the
396-
generated config file.
397-
398-
case 1:
399-
400-
config FOO
401-
tristate "about foo"
402-
depends on BAR
403-
404-
vs. case 2:
405-
406-
if BAR
407-
config FOO
408-
tristate "about foo"
409-
endif
410-
411-
In case 1, the symbol FOO will always exist in the config file (given
412-
no other dependencies). In case 2, the symbol FOO will only exist in
413-
the config file if BAR is enabled.

Documentation/kbuild/kconfig.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ KCONFIG_OVERWRITECONFIG
4646
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
4747
break symlinks when .config is a symlink to somewhere else.
4848

49+
CONFIG_
50+
--------------------------------------------------
51+
If you set CONFIG_ in the environment, Kconfig will prefix all symbols
52+
with its value when saving the configuration, instead of using the default,
53+
"CONFIG_".
54+
4955
______________________________________________________________________
5056
Environment variables for '{allyes/allmod/allno/rand}config'
5157

scripts/kconfig/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ else
1111
Kconfig := Kconfig
1212
endif
1313

14+
# We need this, in case the user has it in its environment
15+
unexport CONFIG_
16+
1417
xconfig: $(obj)/qconf
1518
$< $(Kconfig)
1619

scripts/kconfig/conf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum input_mode {
3636
} input_mode = oldaskconfig;
3737

3838
static int indent = 1;
39+
static int tty_stdio;
3940
static int valid_stdin = 1;
4041
static int sync_kconfig;
4142
static int conf_cnt;
@@ -108,6 +109,8 @@ static int conf_askvalue(struct symbol *sym, const char *def)
108109
case oldaskconfig:
109110
fflush(stdout);
110111
xfgets(line, 128, stdin);
112+
if (!tty_stdio)
113+
printf("\n");
111114
return 1;
112115
default:
113116
break;
@@ -495,6 +498,8 @@ int main(int ac, char **av)
495498
bindtextdomain(PACKAGE, LOCALEDIR);
496499
textdomain(PACKAGE);
497500

501+
tty_stdio = isatty(0) && isatty(1) && isatty(2);
502+
498503
while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
499504
input_mode = (enum input_mode)opt;
500505
switch (opt) {
@@ -621,7 +626,7 @@ int main(int ac, char **av)
621626
return 1;
622627
}
623628
}
624-
valid_stdin = isatty(0) && isatty(1) && isatty(2);
629+
valid_stdin = tty_stdio;
625630
}
626631

627632
switch (input_mode) {

scripts/kconfig/expr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@
1313

1414
struct expr *expr_alloc_symbol(struct symbol *sym)
1515
{
16-
struct expr *e = calloc(1, sizeof(*e));
16+
struct expr *e = xcalloc(1, sizeof(*e));
1717
e->type = E_SYMBOL;
1818
e->left.sym = sym;
1919
return e;
2020
}
2121

2222
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
2323
{
24-
struct expr *e = calloc(1, sizeof(*e));
24+
struct expr *e = xcalloc(1, sizeof(*e));
2525
e->type = type;
2626
e->left.expr = ce;
2727
return e;
2828
}
2929

3030
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
3131
{
32-
struct expr *e = calloc(1, sizeof(*e));
32+
struct expr *e = xcalloc(1, sizeof(*e));
3333
e->type = type;
3434
e->left.expr = e1;
3535
e->right.expr = e2;
@@ -38,7 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
3838

3939
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
4040
{
41-
struct expr *e = calloc(1, sizeof(*e));
41+
struct expr *e = xcalloc(1, sizeof(*e));
4242
e->type = type;
4343
e->left.sym = s1;
4444
e->right.sym = s2;
@@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org)
6666
if (!org)
6767
return NULL;
6868

69-
e = malloc(sizeof(*org));
69+
e = xmalloc(sizeof(*org));
7070
memcpy(e, org, sizeof(*org));
7171
switch (org->type) {
7272
case E_SYMBOL:

scripts/kconfig/gconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# include <config.h>
1111
#endif
1212

13+
#include <stdlib.h>
1314
#include "lkc.h"
1415
#include "images.c"
1516

@@ -22,7 +23,6 @@
2223
#include <string.h>
2324
#include <unistd.h>
2425
#include <time.h>
25-
#include <stdlib.h>
2626

2727
//#define DEBUG
2828

scripts/kconfig/lkc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ extern "C" {
3939
#ifndef CONFIG_
4040
#define CONFIG_ "CONFIG_"
4141
#endif
42+
static inline const char *CONFIG_prefix(void)
43+
{
44+
return getenv( "CONFIG_" ) ?: CONFIG_;
45+
}
46+
#undef CONFIG_
47+
#define CONFIG_ CONFIG_prefix()
4248

4349
#define TF_COMMAND 0x0001
4450
#define TF_PARAM 0x0002
@@ -116,6 +122,8 @@ void menu_set_type(int type);
116122
/* util.c */
117123
struct file *file_lookup(const char *name);
118124
int file_write_dep(const char *name);
125+
void *xmalloc(size_t size);
126+
void *xcalloc(size_t nmemb, size_t size);
119127

120128
struct gstr {
121129
size_t len;

scripts/kconfig/lxdialog/check-lxdialog.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ccflags()
2121
{
2222
if [ -f /usr/include/ncursesw/curses.h ]; then
2323
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
24+
echo ' -DNCURSES_WIDECHAR=1'
2425
elif [ -f /usr/include/ncurses/ncurses.h ]; then
2526
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
2627
elif [ -f /usr/include/ncurses/curses.h ]; then

scripts/kconfig/lxdialog/dialog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ int dialog_menu(const char *title, const char *prompt,
221221
const void *selected, int *s_scroll);
222222
int dialog_checklist(const char *title, const char *prompt, int height,
223223
int width, int list_height);
224-
extern char dialog_input_result[];
225224
int dialog_inputbox(const char *title, const char *prompt, int height,
226225
int width, const char *init);
227226

scripts/kconfig/lxdialog/inputbox.c

Lines changed: 92 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
4545
const char *init)
4646
{
4747
int i, x, y, box_y, box_x, box_width;
48-
int input_x = 0, scroll = 0, key = 0, button = -1;
48+
int input_x = 0, key = 0, button = -1;
49+
int show_x, len, pos;
4950
char *instr = dialog_input_result;
5051
WINDOW *dialog;
5152

@@ -97,14 +98,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
9798
wmove(dialog, box_y, box_x);
9899
wattrset(dialog, dlg.inputbox.atr);
99100

100-
input_x = strlen(instr);
101+
len = strlen(instr);
102+
pos = len;
101103

102-
if (input_x >= box_width) {
103-
scroll = input_x - box_width + 1;
104+
if (len >= box_width) {
105+
show_x = len - box_width + 1;
104106
input_x = box_width - 1;
105107
for (i = 0; i < box_width - 1; i++)
106-
waddch(dialog, instr[scroll + i]);
108+
waddch(dialog, instr[show_x + i]);
107109
} else {
110+
show_x = 0;
111+
input_x = len;
108112
waddstr(dialog, instr);
109113
}
110114

@@ -121,45 +125,104 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
121125
case KEY_UP:
122126
case KEY_DOWN:
123127
break;
124-
case KEY_LEFT:
125-
continue;
126-
case KEY_RIGHT:
127-
continue;
128128
case KEY_BACKSPACE:
129129
case 127:
130-
if (input_x || scroll) {
130+
if (pos) {
131131
wattrset(dialog, dlg.inputbox.atr);
132-
if (!input_x) {
133-
scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
134-
wmove(dialog, box_y, box_x);
135-
for (i = 0; i < box_width; i++)
136-
waddch(dialog,
137-
instr[scroll + input_x + i] ?
138-
instr[scroll + input_x + i] : ' ');
139-
input_x = strlen(instr) - scroll;
132+
if (input_x == 0) {
133+
show_x--;
140134
} else
141135
input_x--;
142-
instr[scroll + input_x] = '\0';
143-
mvwaddch(dialog, box_y, input_x + box_x, ' ');
136+
137+
if (pos < len) {
138+
for (i = pos - 1; i < len; i++) {
139+
instr[i] = instr[i+1];
140+
}
141+
}
142+
143+
pos--;
144+
len--;
145+
instr[len] = '\0';
146+
wmove(dialog, box_y, box_x);
147+
for (i = 0; i < box_width; i++) {
148+
if (!instr[show_x + i]) {
149+
waddch(dialog, ' ');
150+
break;
151+
}
152+
waddch(dialog, instr[show_x + i]);
153+
}
144154
wmove(dialog, box_y, input_x + box_x);
145155
wrefresh(dialog);
146156
}
147157
continue;
158+
case KEY_LEFT:
159+
if (pos > 0) {
160+
if (input_x > 0) {
161+
wmove(dialog, box_y, --input_x + box_x);
162+
} else if (input_x == 0) {
163+
show_x--;
164+
wmove(dialog, box_y, box_x);
165+
for (i = 0; i < box_width; i++) {
166+
if (!instr[show_x + i]) {
167+
waddch(dialog, ' ');
168+
break;
169+
}
170+
waddch(dialog, instr[show_x + i]);
171+
}
172+
wmove(dialog, box_y, box_x);
173+
}
174+
pos--;
175+
}
176+
continue;
177+
case KEY_RIGHT:
178+
if (pos < len) {
179+
if (input_x < box_width - 1) {
180+
wmove(dialog, box_y, ++input_x + box_x);
181+
} else if (input_x == box_width - 1) {
182+
show_x++;
183+
wmove(dialog, box_y, box_x);
184+
for (i = 0; i < box_width; i++) {
185+
if (!instr[show_x + i]) {
186+
waddch(dialog, ' ');
187+
break;
188+
}
189+
waddch(dialog, instr[show_x + i]);
190+
}
191+
wmove(dialog, box_y, input_x + box_x);
192+
}
193+
pos++;
194+
}
195+
continue;
148196
default:
149197
if (key < 0x100 && isprint(key)) {
150-
if (scroll + input_x < MAX_LEN) {
198+
if (len < MAX_LEN) {
151199
wattrset(dialog, dlg.inputbox.atr);
152-
instr[scroll + input_x] = key;
153-
instr[scroll + input_x + 1] = '\0';
200+
if (pos < len) {
201+
for (i = len; i > pos; i--)
202+
instr[i] = instr[i-1];
203+
instr[pos] = key;
204+
} else {
205+
instr[len] = key;
206+
}
207+
pos++;
208+
len++;
209+
instr[len] = '\0';
210+
154211
if (input_x == box_width - 1) {
155-
scroll++;
156-
wmove(dialog, box_y, box_x);
157-
for (i = 0; i < box_width - 1; i++)
158-
waddch(dialog, instr [scroll + i]);
212+
show_x++;
159213
} else {
160-
wmove(dialog, box_y, input_x++ + box_x);
161-
waddch(dialog, key);
214+
input_x++;
215+
}
216+
217+
wmove(dialog, box_y, box_x);
218+
for (i = 0; i < box_width; i++) {
219+
if (!instr[show_x + i]) {
220+
waddch(dialog, ' ');
221+
break;
222+
}
223+
waddch(dialog, instr[show_x + i]);
162224
}
225+
wmove(dialog, box_y, input_x + box_x);
163226
wrefresh(dialog);
164227
} else
165228
flash(); /* Alarm user about overflow */

0 commit comments

Comments
 (0)