Skip to content

Commit

Permalink
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/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
  • Loading branch information
torvalds committed Feb 27, 2013
2 parents ad60a93 + e3900e7 commit 309667e
Show file tree
Hide file tree
Showing 21 changed files with 391 additions and 283 deletions.
23 changes: 0 additions & 23 deletions Documentation/kbuild/kconfig-language.txt
Original file line number Diff line number Diff line change
Expand Up @@ -388,26 +388,3 @@ config FOO
depends on BAR && m

limits FOO to module (=m) or disabled (=n).

Kconfig symbol existence
~~~~~~~~~~~~~~~~~~~~~~~~
The following two methods produce the same kconfig symbol dependencies
but differ greatly in kconfig symbol existence (production) in the
generated config file.

case 1:

config FOO
tristate "about foo"
depends on BAR

vs. case 2:

if BAR
config FOO
tristate "about foo"
endif

In case 1, the symbol FOO will always exist in the config file (given
no other dependencies). In case 2, the symbol FOO will only exist in
the config file if BAR is enabled.
6 changes: 6 additions & 0 deletions Documentation/kbuild/kconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ KCONFIG_OVERWRITECONFIG
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
break symlinks when .config is a symlink to somewhere else.

CONFIG_
--------------------------------------------------
If you set CONFIG_ in the environment, Kconfig will prefix all symbols
with its value when saving the configuration, instead of using the default,
"CONFIG_".

______________________________________________________________________
Environment variables for '{allyes/allmod/allno/rand}config'

Expand Down
3 changes: 3 additions & 0 deletions scripts/kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ else
Kconfig := Kconfig
endif

# We need this, in case the user has it in its environment
unexport CONFIG_

xconfig: $(obj)/qconf
$< $(Kconfig)

Expand Down
7 changes: 6 additions & 1 deletion scripts/kconfig/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum input_mode {
} input_mode = oldaskconfig;

static int indent = 1;
static int tty_stdio;
static int valid_stdin = 1;
static int sync_kconfig;
static int conf_cnt;
Expand Down Expand Up @@ -108,6 +109,8 @@ static int conf_askvalue(struct symbol *sym, const char *def)
case oldaskconfig:
fflush(stdout);
xfgets(line, 128, stdin);
if (!tty_stdio)
printf("\n");
return 1;
default:
break;
Expand Down Expand Up @@ -495,6 +498,8 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

tty_stdio = isatty(0) && isatty(1) && isatty(2);

while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
input_mode = (enum input_mode)opt;
switch (opt) {
Expand Down Expand Up @@ -621,7 +626,7 @@ int main(int ac, char **av)
return 1;
}
}
valid_stdin = isatty(0) && isatty(1) && isatty(2);
valid_stdin = tty_stdio;
}

switch (input_mode) {
Expand Down
10 changes: 5 additions & 5 deletions scripts/kconfig/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

struct expr *expr_alloc_symbol(struct symbol *sym)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = E_SYMBOL;
e->left.sym = sym;
return e;
}

struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = ce;
return e;
}

struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.expr = e1;
e->right.expr = e2;
Expand All @@ -38,7 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e

struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
{
struct expr *e = calloc(1, sizeof(*e));
struct expr *e = xcalloc(1, sizeof(*e));
e->type = type;
e->left.sym = s1;
e->right.sym = s2;
Expand Down Expand Up @@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org)
if (!org)
return NULL;

e = malloc(sizeof(*org));
e = xmalloc(sizeof(*org));
memcpy(e, org, sizeof(*org));
switch (org->type) {
case E_SYMBOL:
Expand Down
2 changes: 1 addition & 1 deletion scripts/kconfig/gconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# include <config.h>
#endif

#include <stdlib.h>
#include "lkc.h"
#include "images.c"

Expand All @@ -22,7 +23,6 @@
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdlib.h>

//#define DEBUG

Expand Down
8 changes: 8 additions & 0 deletions scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ extern "C" {
#ifndef CONFIG_
#define CONFIG_ "CONFIG_"
#endif
static inline const char *CONFIG_prefix(void)
{
return getenv( "CONFIG_" ) ?: CONFIG_;
}
#undef CONFIG_
#define CONFIG_ CONFIG_prefix()

#define TF_COMMAND 0x0001
#define TF_PARAM 0x0002
Expand Down Expand Up @@ -116,6 +122,8 @@ void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
void *xmalloc(size_t size);
void *xcalloc(size_t nmemb, size_t size);

struct gstr {
size_t len;
Expand Down
1 change: 1 addition & 0 deletions scripts/kconfig/lxdialog/check-lxdialog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ccflags()
{
if [ -f /usr/include/ncursesw/curses.h ]; then
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
echo ' -DNCURSES_WIDECHAR=1'
elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then
Expand Down
1 change: 0 additions & 1 deletion scripts/kconfig/lxdialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ int dialog_menu(const char *title, const char *prompt,
const void *selected, int *s_scroll);
int dialog_checklist(const char *title, const char *prompt, int height,
int width, int list_height);
extern char dialog_input_result[];
int dialog_inputbox(const char *title, const char *prompt, int height,
int width, const char *init);

Expand Down
121 changes: 92 additions & 29 deletions scripts/kconfig/lxdialog/inputbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
const char *init)
{
int i, x, y, box_y, box_x, box_width;
int input_x = 0, scroll = 0, key = 0, button = -1;
int input_x = 0, key = 0, button = -1;
int show_x, len, pos;
char *instr = dialog_input_result;
WINDOW *dialog;

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

input_x = strlen(instr);
len = strlen(instr);
pos = len;

if (input_x >= box_width) {
scroll = input_x - box_width + 1;
if (len >= box_width) {
show_x = len - box_width + 1;
input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++)
waddch(dialog, instr[scroll + i]);
waddch(dialog, instr[show_x + i]);
} else {
show_x = 0;
input_x = len;
waddstr(dialog, instr);
}

Expand All @@ -121,45 +125,104 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
case KEY_UP:
case KEY_DOWN:
break;
case KEY_LEFT:
continue;
case KEY_RIGHT:
continue;
case KEY_BACKSPACE:
case 127:
if (input_x || scroll) {
if (pos) {
wattrset(dialog, dlg.inputbox.atr);
if (!input_x) {
scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++)
waddch(dialog,
instr[scroll + input_x + i] ?
instr[scroll + input_x + i] : ' ');
input_x = strlen(instr) - scroll;
if (input_x == 0) {
show_x--;
} else
input_x--;
instr[scroll + input_x] = '\0';
mvwaddch(dialog, box_y, input_x + box_x, ' ');

if (pos < len) {
for (i = pos - 1; i < len; i++) {
instr[i] = instr[i+1];
}
}

pos--;
len--;
instr[len] = '\0';
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++) {
if (!instr[show_x + i]) {
waddch(dialog, ' ');
break;
}
waddch(dialog, instr[show_x + i]);
}
wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
}
continue;
case KEY_LEFT:
if (pos > 0) {
if (input_x > 0) {
wmove(dialog, box_y, --input_x + box_x);
} else if (input_x == 0) {
show_x--;
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++) {
if (!instr[show_x + i]) {
waddch(dialog, ' ');
break;
}
waddch(dialog, instr[show_x + i]);
}
wmove(dialog, box_y, box_x);
}
pos--;
}
continue;
case KEY_RIGHT:
if (pos < len) {
if (input_x < box_width - 1) {
wmove(dialog, box_y, ++input_x + box_x);
} else if (input_x == box_width - 1) {
show_x++;
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++) {
if (!instr[show_x + i]) {
waddch(dialog, ' ');
break;
}
waddch(dialog, instr[show_x + i]);
}
wmove(dialog, box_y, input_x + box_x);
}
pos++;
}
continue;
default:
if (key < 0x100 && isprint(key)) {
if (scroll + input_x < MAX_LEN) {
if (len < MAX_LEN) {
wattrset(dialog, dlg.inputbox.atr);
instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0';
if (pos < len) {
for (i = len; i > pos; i--)
instr[i] = instr[i-1];
instr[pos] = key;
} else {
instr[len] = key;
}
pos++;
len++;
instr[len] = '\0';

if (input_x == box_width - 1) {
scroll++;
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++)
waddch(dialog, instr [scroll + i]);
show_x++;
} else {
wmove(dialog, box_y, input_x++ + box_x);
waddch(dialog, key);
input_x++;
}

wmove(dialog, box_y, box_x);
for (i = 0; i < box_width; i++) {
if (!instr[show_x + i]) {
waddch(dialog, ' ');
break;
}
waddch(dialog, instr[show_x + i]);
}
wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog);
} else
flash(); /* Alarm user about overflow */
Expand Down
Loading

0 comments on commit 309667e

Please sign in to comment.