Commit 309667e5 authored by Linus Torvalds's avatar Linus Torvalds

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
parents ad60a933 e3900e74
...@@ -388,26 +388,3 @@ config FOO ...@@ -388,26 +388,3 @@ config FOO
depends on BAR && m depends on BAR && m
limits FOO to module (=m) or disabled (=n). 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.
...@@ -46,6 +46,12 @@ KCONFIG_OVERWRITECONFIG ...@@ -46,6 +46,12 @@ KCONFIG_OVERWRITECONFIG
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
break symlinks when .config is a symlink to somewhere else. 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' Environment variables for '{allyes/allmod/allno/rand}config'
......
...@@ -11,6 +11,9 @@ else ...@@ -11,6 +11,9 @@ else
Kconfig := Kconfig Kconfig := Kconfig
endif endif
# We need this, in case the user has it in its environment
unexport CONFIG_
xconfig: $(obj)/qconf xconfig: $(obj)/qconf
$< $(Kconfig) $< $(Kconfig)
......
...@@ -36,6 +36,7 @@ enum input_mode { ...@@ -36,6 +36,7 @@ enum input_mode {
} input_mode = oldaskconfig; } input_mode = oldaskconfig;
static int indent = 1; static int indent = 1;
static int tty_stdio;
static int valid_stdin = 1; static int valid_stdin = 1;
static int sync_kconfig; static int sync_kconfig;
static int conf_cnt; static int conf_cnt;
...@@ -108,6 +109,8 @@ static int conf_askvalue(struct symbol *sym, const char *def) ...@@ -108,6 +109,8 @@ static int conf_askvalue(struct symbol *sym, const char *def)
case oldaskconfig: case oldaskconfig:
fflush(stdout); fflush(stdout);
xfgets(line, 128, stdin); xfgets(line, 128, stdin);
if (!tty_stdio)
printf("\n");
return 1; return 1;
default: default:
break; break;
...@@ -495,6 +498,8 @@ int main(int ac, char **av) ...@@ -495,6 +498,8 @@ int main(int ac, char **av)
bindtextdomain(PACKAGE, LOCALEDIR); bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); textdomain(PACKAGE);
tty_stdio = isatty(0) && isatty(1) && isatty(2);
while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) { while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
input_mode = (enum input_mode)opt; input_mode = (enum input_mode)opt;
switch (opt) { switch (opt) {
...@@ -621,7 +626,7 @@ int main(int ac, char **av) ...@@ -621,7 +626,7 @@ int main(int ac, char **av)
return 1; return 1;
} }
} }
valid_stdin = isatty(0) && isatty(1) && isatty(2); valid_stdin = tty_stdio;
} }
switch (input_mode) { switch (input_mode) {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
struct expr *expr_alloc_symbol(struct symbol *sym) 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->type = E_SYMBOL;
e->left.sym = sym; e->left.sym = sym;
return e; return e;
...@@ -21,7 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym) ...@@ -21,7 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym)
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) 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->type = type;
e->left.expr = ce; e->left.expr = ce;
return e; return e;
...@@ -29,7 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) ...@@ -29,7 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) 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->type = type;
e->left.expr = e1; e->left.expr = e1;
e->right.expr = e2; e->right.expr = e2;
...@@ -38,7 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e ...@@ -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 *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->type = type;
e->left.sym = s1; e->left.sym = s1;
e->right.sym = s2; e->right.sym = s2;
...@@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org) ...@@ -66,7 +66,7 @@ struct expr *expr_copy(const struct expr *org)
if (!org) if (!org)
return NULL; return NULL;
e = malloc(sizeof(*org)); e = xmalloc(sizeof(*org));
memcpy(e, org, sizeof(*org)); memcpy(e, org, sizeof(*org));
switch (org->type) { switch (org->type) {
case E_SYMBOL: case E_SYMBOL:
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
# include <config.h> # include <config.h>
#endif #endif
#include <stdlib.h>
#include "lkc.h" #include "lkc.h"
#include "images.c" #include "images.c"
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <time.h> #include <time.h>
#include <stdlib.h>
//#define DEBUG //#define DEBUG
......
...@@ -39,6 +39,12 @@ extern "C" { ...@@ -39,6 +39,12 @@ extern "C" {
#ifndef CONFIG_ #ifndef CONFIG_
#define CONFIG_ "CONFIG_" #define CONFIG_ "CONFIG_"
#endif #endif
static inline const char *CONFIG_prefix(void)
{
return getenv( "CONFIG_" ) ?: CONFIG_;
}
#undef CONFIG_
#define CONFIG_ CONFIG_prefix()
#define TF_COMMAND 0x0001 #define TF_COMMAND 0x0001
#define TF_PARAM 0x0002 #define TF_PARAM 0x0002
...@@ -116,6 +122,8 @@ void menu_set_type(int type); ...@@ -116,6 +122,8 @@ void menu_set_type(int type);
/* util.c */ /* util.c */
struct file *file_lookup(const char *name); struct file *file_lookup(const char *name);
int file_write_dep(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 { struct gstr {
size_t len; size_t len;
......
...@@ -21,6 +21,7 @@ ccflags() ...@@ -21,6 +21,7 @@ ccflags()
{ {
if [ -f /usr/include/ncursesw/curses.h ]; then if [ -f /usr/include/ncursesw/curses.h ]; then
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"' echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
echo ' -DNCURSES_WIDECHAR=1'
elif [ -f /usr/include/ncurses/ncurses.h ]; then elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"' echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then elif [ -f /usr/include/ncurses/curses.h ]; then
......
...@@ -221,7 +221,6 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -221,7 +221,6 @@ int dialog_menu(const char *title, const char *prompt,
const void *selected, int *s_scroll); const void *selected, int *s_scroll);
int dialog_checklist(const char *title, const char *prompt, int height, int dialog_checklist(const char *title, const char *prompt, int height,
int width, int list_height); int width, int list_height);
extern char dialog_input_result[];
int dialog_inputbox(const char *title, const char *prompt, int height, int dialog_inputbox(const char *title, const char *prompt, int height,
int width, const char *init); int width, const char *init);
......
...@@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -45,7 +45,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
const char *init) const char *init)
{ {
int i, x, y, box_y, box_x, box_width; 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; char *instr = dialog_input_result;
WINDOW *dialog; WINDOW *dialog;
...@@ -97,14 +98,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -97,14 +98,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
wmove(dialog, box_y, box_x); wmove(dialog, box_y, box_x);
wattrset(dialog, dlg.inputbox.atr); wattrset(dialog, dlg.inputbox.atr);
input_x = strlen(instr); len = strlen(instr);
pos = len;
if (input_x >= box_width) { if (len >= box_width) {
scroll = input_x - box_width + 1; show_x = len - box_width + 1;
input_x = box_width - 1; input_x = box_width - 1;
for (i = 0; i < box_width - 1; i++) for (i = 0; i < box_width - 1; i++)
waddch(dialog, instr[scroll + i]); waddch(dialog, instr[show_x + i]);
} else { } else {
show_x = 0;
input_x = len;
waddstr(dialog, instr); waddstr(dialog, instr);
} }
...@@ -121,45 +125,104 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -121,45 +125,104 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
case KEY_UP: case KEY_UP:
case KEY_DOWN: case KEY_DOWN:
break; break;
case KEY_LEFT:
continue;
case KEY_RIGHT:
continue;
case KEY_BACKSPACE: case KEY_BACKSPACE:
case 127: case 127:
if (input_x || scroll) { if (pos) {
wattrset(dialog, dlg.inputbox.atr); wattrset(dialog, dlg.inputbox.atr);
if (!input_x) { if (input_x == 0) {
scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); show_x--;
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;
} else } else
input_x--; 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); wmove(dialog, box_y, input_x + box_x);
wrefresh(dialog); wrefresh(dialog);
} }
continue; 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: default:
if (key < 0x100 && isprint(key)) { if (key < 0x100 && isprint(key)) {
if (scroll + input_x < MAX_LEN) { if (len < MAX_LEN) {
wattrset(dialog, dlg.inputbox.atr); wattrset(dialog, dlg.inputbox.atr);
instr[scroll + input_x] = key; if (pos < len) {
instr[scroll + input_x + 1] = '\0'; 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) { if (input_x == box_width - 1) {
scroll++; show_x++;
wmove(dialog, box_y, box_x);
for (i = 0; i < box_width - 1; i++)
waddch(dialog, instr [scroll + i]);
} else { } else {
wmove(dialog, box_y, input_x++ + box_x); input_x++;
waddch(dialog, key); }
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); wrefresh(dialog);
} else } else
flash(); /* Alarm user about overflow */ flash(); /* Alarm user about overflow */
......
...@@ -154,12 +154,14 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, ...@@ -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) 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; int y = height - 2;
print_button(win, gettext("Select"), y, x, selected == 0); print_button(win, gettext("Select"), y, x, selected == 0);
print_button(win, gettext(" Exit "), y, x + 12, selected == 1); print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
print_button(win, gettext(" Help "), y, x + 24, selected == 2); 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); wmove(win, y, x + 1 + 12 * selected);
wrefresh(win); wrefresh(win);
...@@ -372,7 +374,7 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -372,7 +374,7 @@ int dialog_menu(const char *title, const char *prompt,
case TAB: case TAB:
case KEY_RIGHT: case KEY_RIGHT:
button = ((key == KEY_LEFT ? --button : ++button) < 0) button = ((key == KEY_LEFT ? --button : ++button) < 0)
? 2 : (button > 2 ? 0 : button); ? 4 : (button > 4 ? 0 : button);
print_buttons(dialog, height, width, button); print_buttons(dialog, height, width, button);
wrefresh(menu); wrefresh(menu);
...@@ -399,17 +401,17 @@ int dialog_menu(const char *title, const char *prompt, ...@@ -399,17 +401,17 @@ int dialog_menu(const char *title, const char *prompt,
return 2; return 2;
case 's': case 's':
case 'y': case 'y':
return 3; return 5;
case 'n': case 'n':
return 4; return 6;
case 'm': case 'm':
return 5; return 7;
case ' ': case ' ':
return 6; return 8;
case '/': case '/':
return 7; return 9;
case 'z': case 'z':
return 8; return 10;
case '\n': case '\n':
return button; return button;
} }
......
...@@ -280,6 +280,7 @@ static struct menu *current_menu; ...@@ -280,6 +280,7 @@ static struct menu *current_menu;
static int child_count; static int child_count;
static int single_menu_mode; static int single_menu_mode;
static int show_all_options; static int show_all_options;
static int save_and_exit;
static void conf(struct menu *menu, struct menu *active_menu); static void conf(struct menu *menu, struct menu *active_menu);
static void conf_choice(struct menu *menu); static void conf_choice(struct menu *menu);
...@@ -348,15 +349,19 @@ static void search_conf(void) ...@@ -348,15 +349,19 @@ static void search_conf(void)
{ {
struct symbol **sym_arr; struct symbol **sym_arr;
struct gstr res; struct gstr res;
struct gstr title;
char *dialog_input; char *dialog_input;
int dres, vscroll = 0, hscroll = 0; int dres, vscroll = 0, hscroll = 0;
bool again; bool again;
title = str_new();
str_printf( &title, _("Enter %s (sub)string to search for "
"(with or without \"%s\")"), CONFIG_, CONFIG_);
again: again:
dialog_clear(); dialog_clear();
dres = dialog_inputbox(_("Search Configuration Parameter"), dres = dialog_inputbox(_("Search Configuration Parameter"),
_("Enter " CONFIG_ " (sub)string to search for " str_get(&title),
"(with or without \"" CONFIG_ "\")"),
10, 75, ""); 10, 75, "");
switch (dres) { switch (dres) {
case 0: case 0:
...@@ -365,6 +370,7 @@ static void search_conf(void) ...@@ -365,6 +370,7 @@ static void search_conf(void)
show_helptext(_("Search Configuration"), search_help); show_helptext(_("Search Configuration"), search_help);
goto again; goto again;
default: default:
str_free(&title);
return; return;
} }
...@@ -398,6 +404,7 @@ static void search_conf(void) ...@@ -398,6 +404,7 @@ static void search_conf(void)
str_free(&res); str_free(&res);
} while (again); } while (again);
free(sym_arr); free(sym_arr);
str_free(&title);
} }
static void build_conf(struct menu *menu) static void build_conf(struct menu *menu)
...@@ -592,14 +599,6 @@ static void conf(struct menu *menu, struct menu *active_menu) ...@@ -592,14 +599,6 @@ static void conf(struct menu *menu, struct menu *active_menu)
build_conf(menu); build_conf(menu);
if (!child_count) if (!child_count)
break; break;
if (menu == &rootmenu) {
item_make("--- ");
item_set_tag(':');
item_make(_(" Load an Alternate Configuration File"));
item_set_tag('L');
item_make(_(" Save an Alternate Configuration File"));
item_set_tag('S');
}
dialog_clear(); dialog_clear();
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions), _(menu_instructions),
...@@ -636,12 +635,6 @@ static void conf(struct menu *menu, struct menu *active_menu) ...@@ -636,12 +635,6 @@ static void conf(struct menu *menu, struct menu *active_menu)
case 's': case 's':
conf_string(submenu); conf_string(submenu);
break; break;
case 'L':
conf_load();
break;
case 'S':
conf_save();
break;
} }
break; break;
case 2: case 2:
...@@ -651,6 +644,12 @@ static void conf(struct menu *menu, struct menu *active_menu) ...@@ -651,6 +644,12 @@ static void conf(struct menu *menu, struct menu *active_menu)
show_helptext(_("README"), _(mconf_readme)); show_helptext(_("README"), _(mconf_readme));
break; break;
case 3: case 3:
conf_save();
break;
case 4:
conf_load();
break;
case 5:
if (item_is_tag('t')) { if (item_is_tag('t')) {
if (sym_set_tristate_value(sym, yes)) if (sym_set_tristate_value(sym, yes))
break; break;
...@@ -658,24 +657,24 @@ static void conf(struct menu *menu, struct menu *active_menu) ...@@ -658,24 +657,24 @@ static void conf(struct menu *menu, struct menu *active_menu)
show_textbox(NULL, setmod_text, 6, 74); show_textbox(NULL, setmod_text, 6, 74);
} }
break; break;
case 4: case 6:
if (item_is_tag('t')) if (item_is_tag('t'))
sym_set_tristate_value(sym, no); sym_set_tristate_value(sym, no);
break; break;
case 5: case 7:
if (item_is_tag('t')) if (item_is_tag('t'))
sym_set_tristate_value(sym, mod); sym_set_tristate_value(sym, mod);
break; break;
case 6: case 8:
if (item_is_tag('t')) if (item_is_tag('t'))
sym_toggle_tristate_value(sym); sym_toggle_tristate_value(sym);
else if (item_is_tag('m')) else if (item_is_tag('m'))
conf(submenu, NULL); conf(submenu, NULL);
break; break;
case 7: case 9:
search_conf(); search_conf();
break; break;
case 8: case 10:
show_all_options = !show_all_options; show_all_options = !show_all_options;
break; break;
} }
...@@ -702,6 +701,17 @@ static void show_helptext(const char *title, const char *text) ...@@ -702,6 +701,17 @@ static void show_helptext(const char *title, const char *text)
show_textbox(title, text, 0, 0); show_textbox(title, text, 0, 0);
} }
static void conf_message_callback(const char *fmt, va_list ap)
{
char buf[PATH_MAX+1];
vsnprintf(buf, sizeof(buf), fmt, ap);
if (save_and_exit)
printf("%s", buf);
else
show_textbox(NULL, buf, 6, 60);
}
static void show_help(struct menu *menu) static void show_help(struct menu *menu)
{ {
struct gstr help = str_new(); struct gstr help = str_new();
...@@ -870,6 +880,7 @@ static int handle_exit(void) ...@@ -870,6 +880,7 @@ static int handle_exit(void)
{ {
int res; int res;
save_and_exit = 1;
dialog_clear(); dialog_clear();
if (conf_get_changed()) if (conf_get_changed())
res = dialog_yesno(NULL, res = dialog_yesno(NULL,
...@@ -941,6 +952,7 @@ int main(int ac, char **av) ...@@ -941,6 +952,7 @@ int main(int ac, char **av)
} }
set_config_filename(conf_get_configname()); set_config_filename(conf_get_configname());
conf_set_message_callback(conf_message_callback);
do { do {
conf(&rootmenu, NULL); conf(&rootmenu, NULL);
res = handle_exit(); res = handle_exit();
......
...@@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym) ...@@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
{ {
struct menu *menu; struct menu *menu;
menu = malloc(sizeof(*menu)); menu = xmalloc(sizeof(*menu));
memset(menu, 0, sizeof(*menu)); memset(menu, 0, sizeof(*menu));
menu->sym = sym; menu->sym = sym;
menu->parent = current_menu; menu->parent = current_menu;
...@@ -531,7 +531,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, ...@@ -531,7 +531,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
location = menu; location = menu;
} }
if (head && location) { if (head && location) {
jump = malloc(sizeof(struct jump_key)); jump = xmalloc(sizeof(struct jump_key));
if (menu_is_visible(prop->menu)) { if (menu_is_visible(prop->menu)) {
/* /*
......
...@@ -32,11 +32,13 @@ usage() { ...@@ -32,11 +32,13 @@ usage() {
echo " -m only merge the fragments, do not execute the make command" echo " -m only merge the fragments, do not execute the make command"
echo " -n use allnoconfig instead of alldefconfig" echo " -n use allnoconfig instead of alldefconfig"
echo " -r list redundant entries when merging fragments" echo " -r list redundant entries when merging fragments"
echo " -O dir to put generated output files"
} }
MAKE=true MAKE=true
ALLTARGET=alldefconfig ALLTARGET=alldefconfig
WARNREDUN=false WARNREDUN=false
OUTPUT=.
while true; do while true; do
case $1 in case $1 in
...@@ -59,6 +61,16 @@ while true; do ...@@ -59,6 +61,16 @@ while true; do
shift shift
continue continue
;; ;;
"-O")
if [ -d $2 ];then
OUTPUT=$(echo $2 | sed 's/\/*$//')
else
echo "output directory $2 does not exist" 1>&2
exit 1
fi
shift 2
continue
;;
*) *)
break break
;; ;;
...@@ -100,9 +112,9 @@ for MERGE_FILE in $MERGE_LIST ; do ...@@ -100,9 +112,9 @@ for MERGE_FILE in $MERGE_LIST ; do
done done
if [ "$MAKE" = "false" ]; then if [ "$MAKE" = "false" ]; then
cp $TMP_FILE .config cp $TMP_FILE $OUTPUT/.config
echo "#" echo "#"
echo "# merged configuration written to .config (needs make)" echo "# merged configuration written to $OUTPUT/.config (needs make)"
echo "#" echo "#"
clean_up clean_up
exit exit
...@@ -111,14 +123,14 @@ fi ...@@ -111,14 +123,14 @@ fi
# Use the merged file as the starting point for: # Use the merged file as the starting point for:
# alldefconfig: Fills in any missing symbols with Kconfig default # alldefconfig: Fills in any missing symbols with Kconfig default
# allnoconfig: Fills in any missing symbols with # CONFIG_* is not set # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
make KCONFIG_ALLCONFIG=$TMP_FILE $ALLTARGET make KCONFIG_ALLCONFIG=$TMP_FILE O=$OUTPUT $ALLTARGET
# Check all specified config values took (might have missed-dependency issues) # Check all specified config values took (might have missed-dependency issues)
for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
ACTUAL_VAL=$(grep -w -e "$CFG" .config) ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config)
if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
echo "Value requested for $CFG not in final .config" echo "Value requested for $CFG not in final .config"
echo "Requested value: $REQUESTED_VAL" echo "Requested value: $REQUESTED_VAL"
......
This diff is collapsed.
...@@ -48,7 +48,7 @@ static void set_normal_colors(void) ...@@ -48,7 +48,7 @@ static void set_normal_colors(void)
init_pair(INPUT_FIELD, -1, -1); init_pair(INPUT_FIELD, -1, -1);
init_pair(FUNCTION_HIGHLIGHT, -1, -1); init_pair(FUNCTION_HIGHLIGHT, -1, -1);
init_pair(FUNCTION_TEXT, COLOR_BLUE, -1); init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
} }
/* available attributes: /* available attributes:
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <qglobal.h> #include <qglobal.h>
#if QT_VERSION < 0x040000 #if QT_VERSION < 0x040000
#include <stddef.h>
#include <qmainwindow.h> #include <qmainwindow.h>
#include <qvbox.h> #include <qvbox.h>
#include <qvaluelist.h> #include <qvaluelist.h>
......
...@@ -656,11 +656,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) ...@@ -656,11 +656,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
size = strlen(newval) + 1; size = strlen(newval) + 1;
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
size += 2; size += 2;
sym->def[S_DEF_USER].val = val = malloc(size); sym->def[S_DEF_USER].val = val = xmalloc(size);
*val++ = '0'; *val++ = '0';
*val++ = 'x'; *val++ = 'x';
} else if (!oldval || strcmp(oldval, newval)) } else if (!oldval || strcmp(oldval, newval))
sym->def[S_DEF_USER].val = val = malloc(size); sym->def[S_DEF_USER].val = val = xmalloc(size);
else else
return true; return true;
...@@ -812,7 +812,7 @@ struct symbol *sym_lookup(const char *name, int flags) ...@@ -812,7 +812,7 @@ struct symbol *sym_lookup(const char *name, int flags)
hash = 0; hash = 0;
} }
symbol = malloc(sizeof(*symbol)); symbol = xmalloc(sizeof(*symbol));
memset(symbol, 0, sizeof(*symbol)); memset(symbol, 0, sizeof(*symbol));
symbol->name = new_name; symbol->name = new_name;
symbol->type = S_UNKNOWN; symbol->type = S_UNKNOWN;
...@@ -863,7 +863,7 @@ const char *sym_expand_string_value(const char *in) ...@@ -863,7 +863,7 @@ const char *sym_expand_string_value(const char *in)
size_t reslen; size_t reslen;
reslen = strlen(in) + 1; reslen = strlen(in) + 1;
res = malloc(reslen); res = xmalloc(reslen);
res[0] = '\0'; res[0] = '\0';
while ((src = strchr(in, '$'))) { while ((src = strchr(in, '$'))) {
...@@ -921,7 +921,7 @@ const char *sym_escape_string_value(const char *in) ...@@ -921,7 +921,7 @@ const char *sym_escape_string_value(const char *in)
p++; p++;
} }
res = malloc(reslen); res = xmalloc(reslen);
res[0] = '\0'; res[0] = '\0';
strcat(res, "\""); strcat(res, "\"");
...@@ -1228,7 +1228,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym) ...@@ -1228,7 +1228,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
struct property *prop; struct property *prop;
struct property **propp; struct property **propp;
prop = malloc(sizeof(*prop)); prop = xmalloc(sizeof(*prop));
memset(prop, 0, sizeof(*prop)); memset(prop, 0, sizeof(*prop));
prop->type = type; prop->type = type;
prop->sym = sym; prop->sym = sym;
......
...@@ -23,7 +23,7 @@ struct file *file_lookup(const char *name) ...@@ -23,7 +23,7 @@ struct file *file_lookup(const char *name)
} }
} }
file = malloc(sizeof(*file)); file = xmalloc(sizeof(*file));
memset(file, 0, sizeof(*file)); memset(file, 0, sizeof(*file));
file->name = file_name; file->name = file_name;
file->next = file_list; file->next = file_list;
...@@ -81,7 +81,7 @@ int file_write_dep(const char *name) ...@@ -81,7 +81,7 @@ int file_write_dep(const char *name)
struct gstr str_new(void) struct gstr str_new(void)
{ {
struct gstr gs; struct gstr gs;
gs.s = malloc(sizeof(char) * 64); gs.s = xmalloc(sizeof(char) * 64);
gs.len = 64; gs.len = 64;
gs.max_width = 0; gs.max_width = 0;
strcpy(gs.s, "\0"); strcpy(gs.s, "\0");
...@@ -138,3 +138,22 @@ const char *str_get(struct gstr *gs) ...@@ -138,3 +138,22 @@ const char *str_get(struct gstr *gs)
return gs->s; return gs->s;
} }
void *xmalloc(size_t size)
{
void *p = malloc(size);
if (p)
return p;
fprintf(stderr, "Out of memory.\n");
exit(1);
}
void *xcalloc(size_t nmemb, size_t size)
{
void *p = calloc(nmemb, size);
if (p)
return p;
fprintf(stderr, "Out of memory.\n");
exit(1);
}
...@@ -40,7 +40,7 @@ static void zconf_endfile(void); ...@@ -40,7 +40,7 @@ static void zconf_endfile(void);
static void new_string(void) static void new_string(void)
{ {
text = malloc(START_STRSIZE); text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE; text_asize = START_STRSIZE;
text_size = 0; text_size = 0;
*text = 0; *text = 0;
...@@ -62,7 +62,7 @@ static void append_string(const char *str, int size) ...@@ -62,7 +62,7 @@ static void append_string(const char *str, int size)
static void alloc_string(const char *str, int size) static void alloc_string(const char *str, int size)
{ {
text = malloc(size + 1); text = xmalloc(size + 1);
memcpy(text, str, size); memcpy(text, str, size);
text[size] = 0; text[size] = 0;
} }
...@@ -288,7 +288,7 @@ void zconf_initscan(const char *name) ...@@ -288,7 +288,7 @@ void zconf_initscan(const char *name)
exit(1); exit(1);
} }
current_buf = malloc(sizeof(*current_buf)); current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf)); memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name); current_file = file_lookup(name);
...@@ -299,7 +299,7 @@ void zconf_nextfile(const char *name) ...@@ -299,7 +299,7 @@ void zconf_nextfile(const char *name)
{ {
struct file *iter; struct file *iter;
struct file *file = file_lookup(name); struct file *file = file_lookup(name);
struct buffer *buf = malloc(sizeof(*buf)); struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf)); memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER; current_buf->state = YY_CURRENT_BUFFER;
......
...@@ -802,7 +802,7 @@ static void zconf_endfile(void); ...@@ -802,7 +802,7 @@ static void zconf_endfile(void);
static void new_string(void) static void new_string(void)
{ {
text = malloc(START_STRSIZE); text = xmalloc(START_STRSIZE);
text_asize = START_STRSIZE; text_asize = START_STRSIZE;
text_size = 0; text_size = 0;
*text = 0; *text = 0;
...@@ -824,7 +824,7 @@ static void append_string(const char *str, int size) ...@@ -824,7 +824,7 @@ static void append_string(const char *str, int size)
static void alloc_string(const char *str, int size) static void alloc_string(const char *str, int size)
{ {
text = malloc(size + 1); text = xmalloc(size + 1);
memcpy(text, str, size); memcpy(text, str, size);
text[size] = 0; text[size] = 0;
} }
...@@ -2343,7 +2343,7 @@ void zconf_initscan(const char *name) ...@@ -2343,7 +2343,7 @@ void zconf_initscan(const char *name)
exit(1); exit(1);
} }
current_buf = malloc(sizeof(*current_buf)); current_buf = xmalloc(sizeof(*current_buf));
memset(current_buf, 0, sizeof(*current_buf)); memset(current_buf, 0, sizeof(*current_buf));
current_file = file_lookup(name); current_file = file_lookup(name);
...@@ -2354,7 +2354,7 @@ void zconf_nextfile(const char *name) ...@@ -2354,7 +2354,7 @@ void zconf_nextfile(const char *name)
{ {
struct file *iter; struct file *iter;
struct file *file = file_lookup(name); struct file *file = file_lookup(name);
struct buffer *buf = malloc(sizeof(*buf)); struct buffer *buf = xmalloc(sizeof(*buf));
memset(buf, 0, sizeof(*buf)); memset(buf, 0, sizeof(*buf));
current_buf->state = YY_CURRENT_BUFFER; current_buf->state = YY_CURRENT_BUFFER;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment