Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 359247
b: refs/heads/master
c: e3900e7
h: refs/heads/master
i:
  359245: ada551b
  359243: 21d2c36
  359239: 1a7142c
  359231: 963d80a
v: v3
  • Loading branch information
Michal Marek committed Feb 25, 2013
1 parent 8a3c149 commit 00b2ac8
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 283 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02f3e53a131c8aa3fe3c954058f1add5beeae621
refs/heads/master: e3900e74f26fc924c8e9e2a922bd40369b0bb517
23 changes: 0 additions & 23 deletions trunk/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 trunk/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 trunk/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 trunk/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 trunk/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 trunk/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 trunk/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 trunk/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
121 changes: 92 additions & 29 deletions trunk/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
20 changes: 11 additions & 9 deletions trunk/scripts/kconfig/lxdialog/menubox.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* *) A bugfix for the Page-Down problem
*
* *) Formerly when I used Page Down and Page Up, the cursor would be set
* *) Formerly when I used Page Down and Page Up, the cursor would be set
* to the first position in the menu box. Now lxdialog is a bit
* smarter and works more like other menu systems (just have a look at
* it).
Expand Down Expand Up @@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x,
*/
static void print_buttons(WINDOW * win, int height, int width, int selected)
{
int x = width / 2 - 16;
int x = width / 2 - 28;
int y = height - 2;

print_button(win, gettext("Select"), y, x, selected == 0);
print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
print_button(win, gettext(" Save "), y, x + 36, selected == 3);
print_button(win, gettext(" Load "), y, x + 48, selected == 4);

wmove(win, y, x + 1 + 12 * selected);
wrefresh(win);
Expand Down Expand Up @@ -372,7 +374,7 @@ int dialog_menu(const char *title, const char *prompt,
case TAB:
case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 2 : (button > 2 ? 0 : button);
? 4 : (button > 4 ? 0 : button);

print_buttons(dialog, height, width, button);
wrefresh(menu);
Expand All @@ -399,17 +401,17 @@ int dialog_menu(const char *title, const char *prompt,
return 2;
case 's':
case 'y':
return 3;
return 5;
case 'n':
return 4;
return 6;
case 'm':
return 5;
return 7;
case ' ':
return 6;
return 8;
case '/':
return 7;
return 9;
case 'z':
return 8;
return 10;
case '\n':
return button;
}
Expand Down
Loading

0 comments on commit 00b2ac8

Please sign in to comment.