mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-01-31 16:36:14 +00:00
Merge pull request #161 from bhundven/kconfig_update
kconfig: Update kconfig. Sync with Linux-4.2
This commit is contained in:
commit
a66d84a69b
@ -8,6 +8,8 @@ config BACKEND
|
||||
bool
|
||||
default y if IS_A_BACKEND = "y" || IS_A_BACKEND = "Y"
|
||||
|
||||
if BACKEND
|
||||
|
||||
config BACKEND_ARCH
|
||||
string
|
||||
option env="CT_BACKEND_ARCH"
|
||||
@ -19,3 +21,5 @@ config BACKEND_KERNEL
|
||||
config BACKEND_LIBC
|
||||
string
|
||||
option env="CT_BACKEND_LIBC"
|
||||
|
||||
endif #if BACKEND
|
||||
|
@ -15,7 +15,7 @@ _ct_ng () {
|
||||
start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
|
||||
stop_steps=$(echo "${steps}" |sed -r -e 's/(^| )/+\1/;')
|
||||
|
||||
actions='help menuconfig oldconfig saveconfig extractconfig
|
||||
actions='help menuconfig nconfig oldconfig saveconfig extractconfig
|
||||
defconfig savedefconfig
|
||||
build build. build-all build-all.
|
||||
wiki-samples list-samples list-samples-short check-samples
|
||||
|
3
kconfig/.gitignore
vendored
3
kconfig/.gitignore
vendored
@ -2,7 +2,6 @@ conf
|
||||
?conf
|
||||
**.o
|
||||
**.dep
|
||||
lex.backup
|
||||
lex.zconf.c
|
||||
zconf.lex.c
|
||||
zconf.hash.c
|
||||
zconf.tab.c
|
||||
|
@ -11,7 +11,7 @@ LDFLAGS =
|
||||
|
||||
# Compiler flags to use gettext
|
||||
ifeq ($(gettext),)
|
||||
INTL_CFLAGS = -DKBUILD_NO_NLS
|
||||
INTL_CFLAGS = -Wno-format-security -DKBUILD_NO_NLS
|
||||
endif
|
||||
|
||||
# Compiler and linker flags to use ncurses
|
||||
@ -74,8 +74,8 @@ DEPS += $(nconf_DEP)
|
||||
@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
|
||||
|
||||
# Generate the grammar parser
|
||||
zconf.tab.o: zconf.tab.c zconf.hash.c lex.zconf.c
|
||||
zconf.tab.dep: zconf.tab.c zconf.hash.c lex.zconf.c
|
||||
zconf.tab.o: zconf.tab.c zconf.hash.c zconf.lex.c
|
||||
zconf.tab.dep: zconf.tab.c zconf.hash.c zconf.lex.c
|
||||
|
||||
.PRECIOUS: zconf.tab.c
|
||||
zconf.tab.c: zconf.y
|
||||
@ -84,9 +84,9 @@ zconf.tab.c: zconf.y
|
||||
|
||||
zconf.hash.c: zconf.gperf
|
||||
@echo " GPERF '$@'"
|
||||
@$(gperf) < $< > $@
|
||||
@$(gperf) -C < $< > $@
|
||||
|
||||
lex.zconf.c: zconf.l
|
||||
zconf.lex.c: zconf.l
|
||||
@echo " LEX '$@'"
|
||||
@flex -L -Pzconf -o$@ $<
|
||||
|
||||
@ -114,4 +114,4 @@ conf: $(COMMON_OBJ) $(conf_OBJ)
|
||||
clean:
|
||||
@echo " RM 'kconfig'"
|
||||
@rm -f conf mconf nconf $(ALL_OBJS) $(ALL_DEPS)
|
||||
@rm -f rm -f zconf.tab.c zconf.hash.c lex.zconf.c lex.backup
|
||||
@rm -f rm -f zconf.tab.c zconf.hash.c zconf.lex.c lex.backup
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Needed for systems without gettext
|
||||
$* -xc -o /dev/null - > /dev/null 2>&1 << EOF
|
||||
$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
|
||||
#include <libintl.h>
|
||||
int main()
|
||||
{
|
||||
@ -11,4 +11,3 @@ EOF
|
||||
if [ ! "$?" -eq "0" ]; then
|
||||
echo -DKBUILD_NO_NLS;
|
||||
fi
|
||||
|
||||
|
105
kconfig/conf.c
105
kconfig/conf.c
@ -13,12 +13,13 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
static void conf(struct menu *menu);
|
||||
static void check_conf(struct menu *menu);
|
||||
static void xfgets(char *str, int size, FILE *in);
|
||||
|
||||
enum input_mode {
|
||||
oldaskconfig,
|
||||
@ -32,12 +33,11 @@ enum input_mode {
|
||||
defconfig,
|
||||
savedefconfig,
|
||||
listnewconfig,
|
||||
oldnoconfig,
|
||||
olddefconfig,
|
||||
} input_mode = oldaskconfig;
|
||||
|
||||
char *defconfig_file;
|
||||
|
||||
static int indent = 1;
|
||||
static int tty_stdio;
|
||||
static int valid_stdin = 1;
|
||||
static int sync_kconfig;
|
||||
static int conf_cnt;
|
||||
@ -106,9 +106,12 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
||||
return 0;
|
||||
}
|
||||
check_stdin();
|
||||
/* fall through */
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
xfgets(line, 128, stdin);
|
||||
if (!tty_stdio)
|
||||
printf("\n");
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
@ -150,6 +153,7 @@ static int conf_string(struct menu *menu)
|
||||
def = NULL;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
line[strlen(line)-1] = 0;
|
||||
def = line;
|
||||
@ -304,6 +308,7 @@ static int conf_choice(struct menu *menu)
|
||||
break;
|
||||
}
|
||||
check_stdin();
|
||||
/* fall through */
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
xfgets(line, 128, stdin);
|
||||
@ -364,11 +369,12 @@ static void conf(struct menu *menu)
|
||||
case P_MENU:
|
||||
if ((input_mode == silentoldconfig ||
|
||||
input_mode == listnewconfig ||
|
||||
input_mode == oldnoconfig) &&
|
||||
input_mode == olddefconfig) &&
|
||||
rootEntry != menu) {
|
||||
check_conf(menu);
|
||||
return;
|
||||
}
|
||||
/* fall through */
|
||||
case P_COMMENT:
|
||||
prompt = menu_get_prompt(menu);
|
||||
if (prompt)
|
||||
@ -427,7 +433,7 @@ static void check_conf(struct menu *menu)
|
||||
if (sym->name && !sym_is_choice_value(sym)) {
|
||||
printf("%s%s\n", CONFIG_, sym->name);
|
||||
}
|
||||
} else if (input_mode != oldnoconfig) {
|
||||
} else if (input_mode != olddefconfig) {
|
||||
if (!conf_cnt++)
|
||||
printf(_("*\n* Restart config...\n*\n"));
|
||||
rootEntry = menu_get_parent_menu(menu);
|
||||
@ -452,21 +458,34 @@ static struct option long_opts[] = {
|
||||
{"alldefconfig", no_argument, NULL, alldefconfig},
|
||||
{"randconfig", no_argument, NULL, randconfig},
|
||||
{"listnewconfig", no_argument, NULL, listnewconfig},
|
||||
{"oldnoconfig", no_argument, NULL, oldnoconfig},
|
||||
{"olddefconfig", no_argument, NULL, olddefconfig},
|
||||
/*
|
||||
* oldnoconfig is an alias of olddefconfig, because people already
|
||||
* are dependent on its behavior(sets new symbols to their default
|
||||
* value but not 'n') with the counter-intuitive name.
|
||||
*/
|
||||
{"oldnoconfig", no_argument, NULL, olddefconfig},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
const char *progname = av[0];
|
||||
int opt;
|
||||
const char *name;
|
||||
const char *name, *defconfig_file = NULL /* gcc uninit */;
|
||||
struct stat tmpstat;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) {
|
||||
tty_stdio = isatty(0) && isatty(1) && isatty(2);
|
||||
|
||||
while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
|
||||
if (opt == 's') {
|
||||
conf_set_message_callback(NULL);
|
||||
continue;
|
||||
}
|
||||
input_mode = (enum input_mode)opt;
|
||||
switch (opt) {
|
||||
case silentoldconfig:
|
||||
@ -480,17 +499,36 @@ int main(int ac, char **av)
|
||||
{
|
||||
struct timeval now;
|
||||
unsigned int seed;
|
||||
char *seed_env;
|
||||
|
||||
/*
|
||||
* Use microseconds derived seed,
|
||||
* compensate for systems where it may be zero
|
||||
*/
|
||||
gettimeofday(&now, NULL);
|
||||
|
||||
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
|
||||
|
||||
seed_env = getenv("KCONFIG_SEED");
|
||||
if( seed_env && *seed_env ) {
|
||||
char *endp;
|
||||
int tmp = (int)strtol(seed_env, &endp, 0);
|
||||
if (*endp == '\0') {
|
||||
seed = tmp;
|
||||
}
|
||||
}
|
||||
fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
|
||||
srand(seed);
|
||||
break;
|
||||
}
|
||||
case oldaskconfig:
|
||||
case oldconfig:
|
||||
case allnoconfig:
|
||||
case allyesconfig:
|
||||
case allmodconfig:
|
||||
case alldefconfig:
|
||||
case listnewconfig:
|
||||
case olddefconfig:
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, _("See README for usage info\n"));
|
||||
exit(1);
|
||||
@ -533,7 +571,7 @@ int main(int ac, char **av)
|
||||
case oldaskconfig:
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
case oldnoconfig:
|
||||
case olddefconfig:
|
||||
conf_read(NULL);
|
||||
break;
|
||||
case allnoconfig:
|
||||
@ -542,8 +580,15 @@ int main(int ac, char **av)
|
||||
case alldefconfig:
|
||||
case randconfig:
|
||||
name = getenv("KCONFIG_ALLCONFIG");
|
||||
if (name && !stat(name, &tmpstat)) {
|
||||
conf_read_simple(name, S_DEF_USER);
|
||||
if (!name)
|
||||
break;
|
||||
if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) {
|
||||
if (conf_read_simple(name, S_DEF_USER)) {
|
||||
fprintf(stderr,
|
||||
_("*** Can't read seed configuration \"%s\"!\n"),
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (input_mode) {
|
||||
@ -554,10 +599,13 @@ int main(int ac, char **av)
|
||||
case randconfig: name = "allrandom.config"; break;
|
||||
default: break;
|
||||
}
|
||||
if (!stat(name, &tmpstat))
|
||||
conf_read_simple(name, S_DEF_USER);
|
||||
else if (!stat("all.config", &tmpstat))
|
||||
conf_read_simple("all.config", S_DEF_USER);
|
||||
if (conf_read_simple(name, S_DEF_USER) &&
|
||||
conf_read_simple("all.config", S_DEF_USER)) {
|
||||
fprintf(stderr,
|
||||
_("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
|
||||
name);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -572,7 +620,7 @@ int main(int ac, char **av)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
valid_stdin = isatty(0) && isatty(1) && isatty(2);
|
||||
valid_stdin = tty_stdio;
|
||||
}
|
||||
|
||||
switch (input_mode) {
|
||||
@ -589,7 +637,8 @@ int main(int ac, char **av)
|
||||
conf_set_all_new_symbols(def_default);
|
||||
break;
|
||||
case randconfig:
|
||||
conf_set_all_new_symbols(def_random);
|
||||
/* Really nothing to do in this loop */
|
||||
while (conf_set_all_new_symbols(def_random)) ;
|
||||
break;
|
||||
case defconfig:
|
||||
conf_set_all_new_symbols(def_default);
|
||||
@ -603,7 +652,7 @@ int main(int ac, char **av)
|
||||
/* fall through */
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
case oldnoconfig:
|
||||
case olddefconfig:
|
||||
case silentoldconfig:
|
||||
/* Update until a loop caused no more changes */
|
||||
do {
|
||||
@ -611,7 +660,7 @@ int main(int ac, char **av)
|
||||
check_conf(&rootmenu);
|
||||
} while (conf_cnt &&
|
||||
(input_mode != listnewconfig &&
|
||||
input_mode != oldnoconfig));
|
||||
input_mode != olddefconfig));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -623,11 +672,15 @@ int main(int ac, char **av)
|
||||
fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
|
||||
exit(1);
|
||||
}
|
||||
/* In crosstool-NG, we do not use the autoconf stuff */
|
||||
/* In crosstool-NG, we do not use the autoconf stuff
|
||||
if (conf_write_autoconf()) {
|
||||
fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
|
||||
return 1;
|
||||
} */
|
||||
} else if (input_mode == savedefconfig) {
|
||||
if (conf_write_defconfig(defconfig_file)) {
|
||||
fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
|
||||
defconfig_file);
|
||||
defconfig_file);
|
||||
return 1;
|
||||
}
|
||||
} else if (input_mode != listnewconfig) {
|
||||
@ -638,13 +691,11 @@ int main(int ac, char **av)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to facilitate fgets() by Jean Sacren.
|
||||
*/
|
||||
void xfgets(str, size, in)
|
||||
char *str;
|
||||
int size;
|
||||
FILE *in;
|
||||
void xfgets(char *str, int size, FILE *in)
|
||||
{
|
||||
if (fgets(str, size, in) == NULL)
|
||||
fprintf(stderr, "\nError in reading or end of file.\n");
|
||||
|
@ -7,15 +7,20 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
struct conf_printer {
|
||||
void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
|
||||
void (*print_comment)(FILE *, const char *, void *);
|
||||
};
|
||||
|
||||
static void conf_warning(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
@ -59,6 +64,7 @@ static void conf_message(const char *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
if (conf_message_callback)
|
||||
conf_message_callback(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
const char *conf_get_configname(void)
|
||||
@ -128,6 +134,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
sym->flags |= def_flags;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
case S_BOOLEAN:
|
||||
if (p[0] == 'y') {
|
||||
sym->def[def].tri = yes;
|
||||
@ -139,8 +146,10 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
sym->flags |= def_flags;
|
||||
break;
|
||||
}
|
||||
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
|
||||
break;
|
||||
if (def != S_DEF_AUTO)
|
||||
conf_warning("symbol value '%s' invalid for %s",
|
||||
p, sym->name);
|
||||
return 1;
|
||||
case S_OTHER:
|
||||
if (*p != '"') {
|
||||
for (p2 = p; *p2 && !isspace(*p2); p2++)
|
||||
@ -148,6 +157,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
sym->type = S_STRING;
|
||||
goto done;
|
||||
}
|
||||
/* fall through */
|
||||
case S_STRING:
|
||||
if (*p++ != '"')
|
||||
break;
|
||||
@ -159,9 +169,11 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
memmove(p2, p2 + 1, strlen(p2));
|
||||
}
|
||||
if (!p2) {
|
||||
conf_warning("invalid string found");
|
||||
if (def != S_DEF_AUTO)
|
||||
conf_warning("invalid string found");
|
||||
return 1;
|
||||
}
|
||||
/* fall through */
|
||||
case S_INT:
|
||||
case S_HEX:
|
||||
done:
|
||||
@ -169,7 +181,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
sym->def[def].val = strdup(p);
|
||||
sym->flags |= def_flags;
|
||||
} else {
|
||||
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
|
||||
if (def != S_DEF_AUTO)
|
||||
conf_warning("symbol value '%s' invalid for %s",
|
||||
p, sym->name);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -179,10 +193,66 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LINE_GROWTH 16
|
||||
static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
|
||||
{
|
||||
char *nline;
|
||||
size_t new_size = slen + 1;
|
||||
if (new_size > *n) {
|
||||
new_size += LINE_GROWTH - 1;
|
||||
new_size *= 2;
|
||||
nline = realloc(*lineptr, new_size);
|
||||
if (!nline)
|
||||
return -1;
|
||||
|
||||
*lineptr = nline;
|
||||
*n = new_size;
|
||||
}
|
||||
|
||||
(*lineptr)[slen] = c;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
|
||||
{
|
||||
char *line = *lineptr;
|
||||
size_t slen = 0;
|
||||
|
||||
for (;;) {
|
||||
int c = getc(stream);
|
||||
|
||||
switch (c) {
|
||||
case '\n':
|
||||
if (add_byte(c, &line, slen, n) < 0)
|
||||
goto e_out;
|
||||
slen++;
|
||||
/* fall through */
|
||||
case EOF:
|
||||
if (add_byte('\0', &line, slen, n) < 0)
|
||||
goto e_out;
|
||||
*lineptr = line;
|
||||
if (slen == 0)
|
||||
return -1;
|
||||
return slen;
|
||||
default:
|
||||
if (add_byte(c, &line, slen, n) < 0)
|
||||
goto e_out;
|
||||
slen++;
|
||||
}
|
||||
}
|
||||
|
||||
e_out:
|
||||
line[slen-1] = '\0';
|
||||
*lineptr = line;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int conf_read_simple(const char *name, int def)
|
||||
{
|
||||
FILE *in = NULL;
|
||||
char line[1024];
|
||||
char *line = NULL;
|
||||
size_t line_asize = 0;
|
||||
char *p, *p2;
|
||||
struct symbol *sym;
|
||||
int i, def_flags;
|
||||
@ -237,13 +307,14 @@ load:
|
||||
case S_STRING:
|
||||
if (sym->def[def].val)
|
||||
free(sym->def[def].val);
|
||||
/* fall through */
|
||||
default:
|
||||
sym->def[def].val = NULL;
|
||||
sym->def[def].tri = no;
|
||||
}
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), in)) {
|
||||
while (compat_getline(&line, &line_asize, in) != -1) {
|
||||
conf_lineno++;
|
||||
sym = NULL;
|
||||
if (line[0] == '#') {
|
||||
@ -331,6 +402,7 @@ setsym:
|
||||
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
|
||||
}
|
||||
}
|
||||
free(line);
|
||||
fclose(in);
|
||||
|
||||
if (modules_sym)
|
||||
@ -340,10 +412,8 @@ setsym:
|
||||
|
||||
int conf_read(const char *name)
|
||||
{
|
||||
struct symbol *sym, *choice_sym;
|
||||
struct property *prop;
|
||||
struct expr *e;
|
||||
int i, flags;
|
||||
struct symbol *sym;
|
||||
int i;
|
||||
|
||||
sym_set_change_count(0);
|
||||
|
||||
@ -353,7 +423,7 @@ int conf_read(const char *name)
|
||||
for_all_symbols(i, sym) {
|
||||
sym_calc_value(sym);
|
||||
if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
|
||||
goto sym_ok;
|
||||
continue;
|
||||
if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
|
||||
/* check that calculated value agrees with saved value */
|
||||
switch (sym->type) {
|
||||
@ -362,29 +432,18 @@ int conf_read(const char *name)
|
||||
if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
|
||||
break;
|
||||
if (!sym_is_choice(sym))
|
||||
goto sym_ok;
|
||||
continue;
|
||||
/* fall through */
|
||||
default:
|
||||
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
|
||||
goto sym_ok;
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
} else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
|
||||
/* no previous value and not saved */
|
||||
goto sym_ok;
|
||||
continue;
|
||||
conf_unsaved++;
|
||||
/* maybe print value in verbose mode... */
|
||||
sym_ok:
|
||||
if (!sym_is_choice(sym))
|
||||
continue;
|
||||
/* The choice symbol only has a set value (and thus is not new)
|
||||
* if all its visible childs have values.
|
||||
*/
|
||||
prop = sym_get_choice_prop(sym);
|
||||
flags = sym->flags;
|
||||
expr_list_for_each_sym(prop->expr, e, choice_sym)
|
||||
if (choice_sym->visible != no)
|
||||
flags &= choice_sym->flags;
|
||||
sym->flags &= flags | ~SYMBOL_DEF_USER;
|
||||
}
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
@ -417,64 +476,191 @@ int conf_read(const char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write a S_STRING */
|
||||
static void conf_write_string(bool headerfile, const char *name,
|
||||
const char *str, FILE *out)
|
||||
/*
|
||||
* Kconfig configuration printer
|
||||
*
|
||||
* This printer is used when generating the resulting configuration after
|
||||
* kconfig invocation and `defconfig' files. Unset symbol might be omitted by
|
||||
* passing a non-NULL argument to the printer.
|
||||
*
|
||||
*/
|
||||
static void
|
||||
kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
|
||||
{
|
||||
int l;
|
||||
if (headerfile)
|
||||
fprintf(out, "#define %s%s \"", CONFIG_, name);
|
||||
else
|
||||
fprintf(out, "%s%s=\"", CONFIG_, name);
|
||||
|
||||
while (1) {
|
||||
l = strcspn(str, "\"\\");
|
||||
if (l) {
|
||||
xfwrite(str, l, 1, out);
|
||||
str += l;
|
||||
}
|
||||
if (!*str)
|
||||
break;
|
||||
fprintf(out, "\\%c", *str++);
|
||||
}
|
||||
fputs("\"\n", out);
|
||||
}
|
||||
|
||||
static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
switch (sym_get_tristate_value(sym)) {
|
||||
case no:
|
||||
if (write_no)
|
||||
fprintf(out, "# %s%s is not set\n",
|
||||
if (*value == 'n') {
|
||||
bool skip_unset = (arg != NULL);
|
||||
|
||||
if (!skip_unset)
|
||||
fprintf(fp, "# %s%s is not set\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
case mod:
|
||||
fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
|
||||
break;
|
||||
case yes:
|
||||
fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
|
||||
}
|
||||
|
||||
static void
|
||||
kconfig_print_comment(FILE *fp, const char *value, void *arg)
|
||||
{
|
||||
const char *p = value;
|
||||
size_t l;
|
||||
|
||||
for (;;) {
|
||||
l = strcspn(p, "\n");
|
||||
fprintf(fp, "#");
|
||||
if (l) {
|
||||
fprintf(fp, " ");
|
||||
xfwrite(p, l, 1, fp);
|
||||
p += l;
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
if (*p++ == '\0')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static struct conf_printer kconfig_printer_cb =
|
||||
{
|
||||
.print_symbol = kconfig_print_symbol,
|
||||
.print_comment = kconfig_print_comment,
|
||||
};
|
||||
|
||||
/*
|
||||
* Header printer
|
||||
*
|
||||
* This printer is used when generating the `include/generated/autoconf.h' file.
|
||||
*/
|
||||
static void
|
||||
header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
|
||||
{
|
||||
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE: {
|
||||
const char *suffix = "";
|
||||
|
||||
switch (*value) {
|
||||
case 'n':
|
||||
break;
|
||||
case 'm':
|
||||
suffix = "_MODULE";
|
||||
/* fall through */
|
||||
default:
|
||||
fprintf(fp, "#define %s%s%s 1\n",
|
||||
CONFIG_, sym->name, suffix);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S_HEX: {
|
||||
const char *prefix = "";
|
||||
|
||||
if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
|
||||
prefix = "0x";
|
||||
fprintf(fp, "#define %s%s %s%s\n",
|
||||
CONFIG_, sym->name, prefix, value);
|
||||
break;
|
||||
}
|
||||
case S_STRING:
|
||||
conf_write_string(false, sym->name, sym_get_string_value(sym), out);
|
||||
break;
|
||||
case S_HEX:
|
||||
case S_INT:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
|
||||
fprintf(fp, "#define %s%s %s\n",
|
||||
CONFIG_, sym->name, value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
header_print_comment(FILE *fp, const char *value, void *arg)
|
||||
{
|
||||
const char *p = value;
|
||||
size_t l;
|
||||
|
||||
fprintf(fp, "/*\n");
|
||||
for (;;) {
|
||||
l = strcspn(p, "\n");
|
||||
fprintf(fp, " *");
|
||||
if (l) {
|
||||
fprintf(fp, " ");
|
||||
xfwrite(p, l, 1, fp);
|
||||
p += l;
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
if (*p++ == '\0')
|
||||
break;
|
||||
}
|
||||
fprintf(fp, " */\n");
|
||||
}
|
||||
|
||||
static struct conf_printer header_printer_cb =
|
||||
{
|
||||
.print_symbol = header_print_symbol,
|
||||
.print_comment = header_print_comment,
|
||||
};
|
||||
|
||||
/*
|
||||
* Tristate printer
|
||||
*
|
||||
* This printer is used when generating the `include/config/tristate.conf' file.
|
||||
*/
|
||||
static void
|
||||
tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
|
||||
{
|
||||
|
||||
if (sym->type == S_TRISTATE && *value != 'n')
|
||||
fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
|
||||
}
|
||||
|
||||
static struct conf_printer tristate_printer_cb =
|
||||
{
|
||||
.print_symbol = tristate_print_symbol,
|
||||
.print_comment = kconfig_print_comment,
|
||||
};
|
||||
|
||||
static void conf_write_symbol(FILE *fp, struct symbol *sym,
|
||||
struct conf_printer *printer, void *printer_arg)
|
||||
{
|
||||
const char *str;
|
||||
|
||||
switch (sym->type) {
|
||||
case S_OTHER:
|
||||
case S_UNKNOWN:
|
||||
break;
|
||||
case S_STRING:
|
||||
str = sym_get_string_value(sym);
|
||||
str = sym_escape_string_value(str);
|
||||
printer->print_symbol(fp, sym, str, printer_arg);
|
||||
free((void *)str);
|
||||
break;
|
||||
default:
|
||||
str = sym_get_string_value(sym);
|
||||
printer->print_symbol(fp, sym, str, printer_arg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"\n"
|
||||
"Automatically generated file; DO NOT EDIT.\n"
|
||||
"%s\n",
|
||||
rootmenu.prompt->text);
|
||||
|
||||
printer->print_comment(fp, buf, printer_arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out a minimal config.
|
||||
* All values that has default values are skipped as this is redundant.
|
||||
@ -531,7 +717,7 @@ int conf_write_defconfig(const char *filename)
|
||||
goto next_menu;
|
||||
}
|
||||
}
|
||||
conf_write_symbol(sym, out, true);
|
||||
conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
|
||||
}
|
||||
next_menu:
|
||||
if (menu->list != NULL) {
|
||||
@ -560,8 +746,6 @@ int conf_write(const char *name)
|
||||
const char *basename;
|
||||
const char *str;
|
||||
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
||||
time_t now;
|
||||
int use_timestamp = 1;
|
||||
char *env;
|
||||
|
||||
dirname[0] = 0;
|
||||
@ -598,19 +782,7 @@ int conf_write(const char *name)
|
||||
if (!out)
|
||||
return 1;
|
||||
|
||||
time(&now);
|
||||
env = getenv("KCONFIG_NOTIMESTAMP");
|
||||
if (env && *env)
|
||||
use_timestamp = 0;
|
||||
|
||||
fprintf(out, _("#\n"
|
||||
"# Automatically generated make config: don't edit\n"
|
||||
"# %s\n"
|
||||
"%s%s"
|
||||
"#\n"),
|
||||
rootmenu.prompt->text,
|
||||
use_timestamp ? "# " : "",
|
||||
use_timestamp ? ctime(&now) : "");
|
||||
conf_write_heading(out, &kconfig_printer_cb, NULL);
|
||||
|
||||
if (!conf_get_changed())
|
||||
sym_clear_all_valid();
|
||||
@ -631,8 +803,8 @@ int conf_write(const char *name)
|
||||
if (!(sym->flags & SYMBOL_WRITE))
|
||||
goto next;
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
/* Write config symbol to file */
|
||||
conf_write_symbol(sym, out, true);
|
||||
|
||||
conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
|
||||
}
|
||||
|
||||
next:
|
||||
@ -659,7 +831,7 @@ next:
|
||||
return 1;
|
||||
}
|
||||
|
||||
conf_message(_("configuration saved"));
|
||||
conf_message(_("configuration written to %s"), newname);
|
||||
|
||||
sym_set_change_count(0);
|
||||
|
||||
@ -781,7 +953,6 @@ out:
|
||||
int conf_write_autoconf(void)
|
||||
{
|
||||
struct symbol *sym;
|
||||
const char *str;
|
||||
const char *name;
|
||||
FILE *out, *tristate, *out_h;
|
||||
int i;
|
||||
@ -810,68 +981,23 @@ int conf_write_autoconf(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(out, "#\n"
|
||||
"# Automatically generated make config: don't edit\n"
|
||||
"# %s\n"
|
||||
"#\n",
|
||||
rootmenu.prompt->text);
|
||||
fprintf(tristate, "#\n"
|
||||
"# Automatically generated - do not edit\n"
|
||||
"\n");
|
||||
fprintf(out_h, "/*\n"
|
||||
" * Automatically generated C config: don't edit\n"
|
||||
" * %s\n"
|
||||
" */\n",
|
||||
rootmenu.prompt->text);
|
||||
conf_write_heading(out, &kconfig_printer_cb, NULL);
|
||||
|
||||
conf_write_heading(tristate, &tristate_printer_cb, NULL);
|
||||
|
||||
conf_write_heading(out_h, &header_printer_cb, NULL);
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
sym_calc_value(sym);
|
||||
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
|
||||
continue;
|
||||
|
||||
/* write symbol to config file */
|
||||
conf_write_symbol(sym, out, false);
|
||||
/* write symbol to auto.conf, tristate and header files */
|
||||
conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
|
||||
|
||||
/* update autoconf and tristate files */
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
switch (sym_get_tristate_value(sym)) {
|
||||
case no:
|
||||
break;
|
||||
case mod:
|
||||
fprintf(tristate, "%s%s=M\n",
|
||||
CONFIG_, sym->name);
|
||||
fprintf(out_h, "#define %s%s_MODULE 1\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
case yes:
|
||||
if (sym->type == S_TRISTATE)
|
||||
fprintf(tristate,"%s%s=Y\n",
|
||||
CONFIG_, sym->name);
|
||||
fprintf(out_h, "#define %s%s 1\n",
|
||||
CONFIG_, sym->name);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case S_STRING:
|
||||
conf_write_string(true, sym->name, sym_get_string_value(sym), out_h);
|
||||
break;
|
||||
case S_HEX:
|
||||
str = sym_get_string_value(sym);
|
||||
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
|
||||
fprintf(out_h, "#define %s%s 0x%s\n",
|
||||
CONFIG_, sym->name, str);
|
||||
break;
|
||||
}
|
||||
case S_INT:
|
||||
str = sym_get_string_value(sym);
|
||||
fprintf(out_h, "#define %s%s %s\n",
|
||||
CONFIG_, sym->name, str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
|
||||
|
||||
conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
|
||||
}
|
||||
fclose(out);
|
||||
fclose(tristate);
|
||||
@ -925,7 +1051,7 @@ void conf_set_changed_callback(void (*fn)(void))
|
||||
conf_changed_callback = fn;
|
||||
}
|
||||
|
||||
static void randomize_choice_values(struct symbol *csym)
|
||||
static bool randomize_choice_values(struct symbol *csym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *sym;
|
||||
@ -938,7 +1064,7 @@ static void randomize_choice_values(struct symbol *csym)
|
||||
* In both cases stop.
|
||||
*/
|
||||
if (csym->curr.tri != yes)
|
||||
return;
|
||||
return false;
|
||||
|
||||
prop = sym_get_choice_prop(csym);
|
||||
|
||||
@ -962,13 +1088,18 @@ static void randomize_choice_values(struct symbol *csym)
|
||||
else {
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
}
|
||||
sym->flags |= SYMBOL_DEF_USER;
|
||||
/* clear VALID to get value calculated */
|
||||
sym->flags &= ~SYMBOL_VALID;
|
||||
}
|
||||
csym->flags |= SYMBOL_DEF_USER;
|
||||
/* clear VALID to get value calculated */
|
||||
csym->flags &= ~(SYMBOL_VALID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_all_choice_values(struct symbol *csym)
|
||||
void set_all_choice_values(struct symbol *csym)
|
||||
{
|
||||
struct property *prop;
|
||||
struct symbol *sym;
|
||||
@ -985,20 +1116,66 @@ static void set_all_choice_values(struct symbol *csym)
|
||||
}
|
||||
csym->flags |= SYMBOL_DEF_USER;
|
||||
/* clear VALID to get value calculated */
|
||||
csym->flags &= ~(SYMBOL_VALID);
|
||||
csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
|
||||
}
|
||||
|
||||
void conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
bool conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
{
|
||||
struct symbol *sym, *csym;
|
||||
int i, cnt;
|
||||
int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
|
||||
* pty: probability of tristate = y
|
||||
* ptm: probability of tristate = m
|
||||
*/
|
||||
|
||||
pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
|
||||
* below, otherwise gcc whines about
|
||||
* -Wmaybe-uninitialized */
|
||||
if (mode == def_random) {
|
||||
int n, p[3];
|
||||
char *env = getenv("KCONFIG_PROBABILITY");
|
||||
n = 0;
|
||||
while( env && *env ) {
|
||||
char *endp;
|
||||
int tmp = strtol( env, &endp, 10 );
|
||||
if( tmp >= 0 && tmp <= 100 ) {
|
||||
p[n++] = tmp;
|
||||
} else {
|
||||
errno = ERANGE;
|
||||
perror( "KCONFIG_PROBABILITY" );
|
||||
exit( 1 );
|
||||
}
|
||||
env = (*endp == ':') ? endp+1 : endp;
|
||||
if( n >=3 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch( n ) {
|
||||
case 1:
|
||||
pby = p[0]; ptm = pby/2; pty = pby-ptm;
|
||||
break;
|
||||
case 2:
|
||||
pty = p[0]; ptm = p[1]; pby = pty + ptm;
|
||||
break;
|
||||
case 3:
|
||||
pby = p[0]; pty = p[1]; ptm = p[2];
|
||||
break;
|
||||
}
|
||||
|
||||
if( pty+ptm > 100 ) {
|
||||
errno = ERANGE;
|
||||
perror( "KCONFIG_PROBABILITY" );
|
||||
exit( 1 );
|
||||
}
|
||||
}
|
||||
bool has_changed = false;
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
if (sym_has_value(sym))
|
||||
if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
|
||||
continue;
|
||||
switch (sym_get_type(sym)) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
has_changed = true;
|
||||
switch (mode) {
|
||||
case def_yes:
|
||||
sym->def[S_DEF_USER].tri = yes;
|
||||
@ -1007,11 +1184,21 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
sym->def[S_DEF_USER].tri = mod;
|
||||
break;
|
||||
case def_no:
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
|
||||
sym->def[S_DEF_USER].tri = yes;
|
||||
else
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
break;
|
||||
case def_random:
|
||||
cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
|
||||
sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
|
||||
sym->def[S_DEF_USER].tri = no;
|
||||
cnt = rand() % 100;
|
||||
if (sym->type == S_TRISTATE) {
|
||||
if (cnt < pty)
|
||||
sym->def[S_DEF_USER].tri = yes;
|
||||
else if (cnt < (pty+ptm))
|
||||
sym->def[S_DEF_USER].tri = mod;
|
||||
} else if (cnt < pby)
|
||||
sym->def[S_DEF_USER].tri = yes;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
@ -1036,14 +1223,26 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
* selected in a choice block and we set it to yes,
|
||||
* and the rest to no.
|
||||
*/
|
||||
if (mode != def_random) {
|
||||
for_all_symbols(i, csym) {
|
||||
if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
|
||||
sym_is_choice_value(csym))
|
||||
csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
|
||||
}
|
||||
}
|
||||
|
||||
for_all_symbols(i, csym) {
|
||||
if (sym_has_value(csym) || !sym_is_choice(csym))
|
||||
continue;
|
||||
|
||||
sym_calc_value(csym);
|
||||
if (mode == def_random)
|
||||
randomize_choice_values(csym);
|
||||
else
|
||||
has_changed = randomize_choice_values(csym);
|
||||
else {
|
||||
set_all_choice_values(csym);
|
||||
has_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return has_changed;
|
||||
}
|
||||
|
303
kconfig/expr.c
303
kconfig/expr.c
@ -7,15 +7,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
#define DEBUG_EXPR 0
|
||||
|
||||
static int expr_eq(struct expr *e1, struct expr *e2);
|
||||
static struct expr *expr_eliminate_yn(struct expr *e);
|
||||
|
||||
struct expr *expr_alloc_symbol(struct symbol *sym)
|
||||
{
|
||||
struct expr *e = malloc(sizeof(*e));
|
||||
memset(e, 0, sizeof(*e));
|
||||
struct expr *e = xcalloc(1, sizeof(*e));
|
||||
e->type = E_SYMBOL;
|
||||
e->left.sym = sym;
|
||||
return e;
|
||||
@ -23,8 +24,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym)
|
||||
|
||||
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce)
|
||||
{
|
||||
struct expr *e = malloc(sizeof(*e));
|
||||
memset(e, 0, sizeof(*e));
|
||||
struct expr *e = xcalloc(1, sizeof(*e));
|
||||
e->type = type;
|
||||
e->left.expr = ce;
|
||||
return e;
|
||||
@ -32,8 +32,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 *e = malloc(sizeof(*e));
|
||||
memset(e, 0, sizeof(*e));
|
||||
struct expr *e = xcalloc(1, sizeof(*e));
|
||||
e->type = type;
|
||||
e->left.expr = e1;
|
||||
e->right.expr = e2;
|
||||
@ -42,8 +41,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 = malloc(sizeof(*e));
|
||||
memset(e, 0, sizeof(*e));
|
||||
struct expr *e = xcalloc(1, sizeof(*e));
|
||||
e->type = type;
|
||||
e->left.sym = s1;
|
||||
e->right.sym = s2;
|
||||
@ -71,7 +69,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:
|
||||
@ -81,6 +79,10 @@ struct expr *expr_copy(const struct expr *org)
|
||||
e->left.expr = expr_copy(org->left.expr);
|
||||
break;
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
e->left.sym = org->left.sym;
|
||||
e->right.sym = org->right.sym;
|
||||
@ -113,6 +115,10 @@ void expr_free(struct expr *e)
|
||||
expr_free(e->left.expr);
|
||||
return;
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
break;
|
||||
case E_OR:
|
||||
@ -191,7 +197,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
||||
#undef e1
|
||||
#undef e2
|
||||
|
||||
int expr_eq(struct expr *e1, struct expr *e2)
|
||||
static int expr_eq(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
int res, old_count;
|
||||
|
||||
@ -199,6 +205,10 @@ int expr_eq(struct expr *e1, struct expr *e2)
|
||||
return 0;
|
||||
switch (e1->type) {
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
|
||||
case E_SYMBOL:
|
||||
@ -233,7 +243,7 @@ int expr_eq(struct expr *e1, struct expr *e2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct expr *expr_eliminate_yn(struct expr *e)
|
||||
static struct expr *expr_eliminate_yn(struct expr *e)
|
||||
{
|
||||
struct expr *tmp;
|
||||
|
||||
@ -558,62 +568,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
|
||||
#undef e2
|
||||
}
|
||||
|
||||
static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
#define e1 (*ep1)
|
||||
#define e2 (*ep2)
|
||||
struct expr *tmp, *tmp1, *tmp2;
|
||||
|
||||
if (e1->type == type) {
|
||||
expr_eliminate_dups2(type, &e1->left.expr, &e2);
|
||||
expr_eliminate_dups2(type, &e1->right.expr, &e2);
|
||||
return;
|
||||
}
|
||||
if (e2->type == type) {
|
||||
expr_eliminate_dups2(type, &e1, &e2->left.expr);
|
||||
expr_eliminate_dups2(type, &e1, &e2->right.expr);
|
||||
}
|
||||
if (e1 == e2)
|
||||
return;
|
||||
|
||||
switch (e1->type) {
|
||||
case E_OR:
|
||||
expr_eliminate_dups2(e1->type, &e1, &e1);
|
||||
// (FOO || BAR) && (!FOO && !BAR) -> n
|
||||
tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
|
||||
tmp2 = expr_copy(e2);
|
||||
tmp = expr_extract_eq_and(&tmp1, &tmp2);
|
||||
if (expr_is_yes(tmp1)) {
|
||||
expr_free(e1);
|
||||
e1 = expr_alloc_symbol(&symbol_no);
|
||||
trans_count++;
|
||||
}
|
||||
expr_free(tmp2);
|
||||
expr_free(tmp1);
|
||||
expr_free(tmp);
|
||||
break;
|
||||
case E_AND:
|
||||
expr_eliminate_dups2(e1->type, &e1, &e1);
|
||||
// (FOO && BAR) || (!FOO || !BAR) -> y
|
||||
tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1)));
|
||||
tmp2 = expr_copy(e2);
|
||||
tmp = expr_extract_eq_or(&tmp1, &tmp2);
|
||||
if (expr_is_no(tmp1)) {
|
||||
expr_free(e1);
|
||||
e1 = expr_alloc_symbol(&symbol_yes);
|
||||
trans_count++;
|
||||
}
|
||||
expr_free(tmp2);
|
||||
expr_free(tmp1);
|
||||
expr_free(tmp);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
#undef e1
|
||||
#undef e2
|
||||
}
|
||||
|
||||
struct expr *expr_eliminate_dups(struct expr *e)
|
||||
{
|
||||
int oldcount;
|
||||
@ -626,7 +580,6 @@ struct expr *expr_eliminate_dups(struct expr *e)
|
||||
switch (e->type) {
|
||||
case E_OR: case E_AND:
|
||||
expr_eliminate_dups1(e->type, &e, &e);
|
||||
expr_eliminate_dups2(e->type, &e, &e);
|
||||
default:
|
||||
;
|
||||
}
|
||||
@ -646,6 +599,10 @@ struct expr *expr_transform(struct expr *e)
|
||||
return NULL;
|
||||
switch (e->type) {
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
case E_SYMBOL:
|
||||
case E_LIST:
|
||||
@ -718,6 +675,22 @@ struct expr *expr_transform(struct expr *e)
|
||||
e = tmp;
|
||||
e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
|
||||
break;
|
||||
case E_LEQ:
|
||||
case E_GEQ:
|
||||
// !a<='x' -> a>'x'
|
||||
tmp = e->left.expr;
|
||||
free(e);
|
||||
e = tmp;
|
||||
e->type = e->type == E_LEQ ? E_GTH : E_LTH;
|
||||
break;
|
||||
case E_LTH:
|
||||
case E_GTH:
|
||||
// !a<'x' -> a>='x'
|
||||
tmp = e->left.expr;
|
||||
free(e);
|
||||
e = tmp;
|
||||
e->type = e->type == E_LTH ? E_GEQ : E_LEQ;
|
||||
break;
|
||||
case E_OR:
|
||||
// !(a || b) -> !a && !b
|
||||
tmp = e->left.expr;
|
||||
@ -788,6 +761,10 @@ int expr_contains_symbol(struct expr *dep, struct symbol *sym)
|
||||
case E_SYMBOL:
|
||||
return dep->left.sym == sym;
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
return dep->left.sym == sym ||
|
||||
dep->right.sym == sym;
|
||||
@ -828,57 +805,6 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
struct expr *tmp = NULL;
|
||||
expr_extract_eq(E_AND, &tmp, ep1, ep2);
|
||||
if (tmp) {
|
||||
*ep1 = expr_eliminate_yn(*ep1);
|
||||
*ep2 = expr_eliminate_yn(*ep2);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
struct expr *tmp = NULL;
|
||||
expr_extract_eq(E_OR, &tmp, ep1, ep2);
|
||||
if (tmp) {
|
||||
*ep1 = expr_eliminate_yn(*ep1);
|
||||
*ep2 = expr_eliminate_yn(*ep2);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
#define e1 (*ep1)
|
||||
#define e2 (*ep2)
|
||||
if (e1->type == type) {
|
||||
expr_extract_eq(type, ep, &e1->left.expr, &e2);
|
||||
expr_extract_eq(type, ep, &e1->right.expr, &e2);
|
||||
return;
|
||||
}
|
||||
if (e2->type == type) {
|
||||
expr_extract_eq(type, ep, ep1, &e2->left.expr);
|
||||
expr_extract_eq(type, ep, ep1, &e2->right.expr);
|
||||
return;
|
||||
}
|
||||
if (expr_eq(e1, e2)) {
|
||||
*ep = *ep ? expr_alloc_two(type, *ep, e1) : e1;
|
||||
expr_free(e2);
|
||||
if (type == E_AND) {
|
||||
e1 = expr_alloc_symbol(&symbol_yes);
|
||||
e2 = expr_alloc_symbol(&symbol_yes);
|
||||
} else if (type == E_OR) {
|
||||
e1 = expr_alloc_symbol(&symbol_no);
|
||||
e2 = expr_alloc_symbol(&symbol_no);
|
||||
}
|
||||
}
|
||||
#undef e1
|
||||
#undef e2
|
||||
}
|
||||
|
||||
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
|
||||
{
|
||||
struct expr *e1, *e2;
|
||||
@ -913,6 +839,10 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
|
||||
case E_NOT:
|
||||
return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
|
||||
case E_UNEQUAL:
|
||||
case E_LTH:
|
||||
case E_LEQ:
|
||||
case E_GTH:
|
||||
case E_GEQ:
|
||||
case E_EQUAL:
|
||||
if (type == E_EQUAL) {
|
||||
if (sym == &symbol_yes)
|
||||
@ -940,10 +870,57 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum string_value_kind {
|
||||
k_string,
|
||||
k_signed,
|
||||
k_unsigned,
|
||||
k_invalid
|
||||
};
|
||||
|
||||
union string_value {
|
||||
unsigned long long u;
|
||||
signed long long s;
|
||||
};
|
||||
|
||||
static enum string_value_kind expr_parse_string(const char *str,
|
||||
enum symbol_type type,
|
||||
union string_value *val)
|
||||
{
|
||||
char *tail;
|
||||
enum string_value_kind kind;
|
||||
|
||||
errno = 0;
|
||||
switch (type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
return k_string;
|
||||
case S_INT:
|
||||
val->s = strtoll(str, &tail, 10);
|
||||
kind = k_signed;
|
||||
break;
|
||||
case S_HEX:
|
||||
val->u = strtoull(str, &tail, 16);
|
||||
kind = k_unsigned;
|
||||
break;
|
||||
case S_STRING:
|
||||
case S_UNKNOWN:
|
||||
val->s = strtoll(str, &tail, 0);
|
||||
kind = k_signed;
|
||||
break;
|
||||
default:
|
||||
return k_invalid;
|
||||
}
|
||||
return !errno && !*tail && tail > str && isxdigit(tail[-1])
|
||||
? kind : k_string;
|
||||
}
|
||||
|
||||
tristate expr_calc_value(struct expr *e)
|
||||
{
|
||||
tristate val1, val2;
|
||||
const char *str1, *str2;
|
||||
enum string_value_kind k1 = k_string, k2 = k_string;
|
||||
union string_value lval = {}, rval = {};
|
||||
int res;
|
||||
|
||||
if (!e)
|
||||
return yes;
|
||||
@ -964,31 +941,70 @@ tristate expr_calc_value(struct expr *e)
|
||||
val1 = expr_calc_value(e->left.expr);
|
||||
return EXPR_NOT(val1);
|
||||
case E_EQUAL:
|
||||
sym_calc_value(e->left.sym);
|
||||
sym_calc_value(e->right.sym);
|
||||
str1 = sym_get_string_value(e->left.sym);
|
||||
str2 = sym_get_string_value(e->right.sym);
|
||||
return !strcmp(str1, str2) ? yes : no;
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
sym_calc_value(e->left.sym);
|
||||
sym_calc_value(e->right.sym);
|
||||
str1 = sym_get_string_value(e->left.sym);
|
||||
str2 = sym_get_string_value(e->right.sym);
|
||||
return !strcmp(str1, str2) ? no : yes;
|
||||
break;
|
||||
default:
|
||||
printf("expr_calc_value: %d?\n", e->type);
|
||||
return no;
|
||||
}
|
||||
|
||||
sym_calc_value(e->left.sym);
|
||||
sym_calc_value(e->right.sym);
|
||||
str1 = sym_get_string_value(e->left.sym);
|
||||
str2 = sym_get_string_value(e->right.sym);
|
||||
|
||||
if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) {
|
||||
k1 = expr_parse_string(str1, e->left.sym->type, &lval);
|
||||
k2 = expr_parse_string(str2, e->right.sym->type, &rval);
|
||||
}
|
||||
|
||||
if (k1 == k_string || k2 == k_string)
|
||||
res = strcmp(str1, str2);
|
||||
else if (k1 == k_invalid || k2 == k_invalid) {
|
||||
if (e->type != E_EQUAL && e->type != E_UNEQUAL) {
|
||||
printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2);
|
||||
return no;
|
||||
}
|
||||
res = strcmp(str1, str2);
|
||||
} else if (k1 == k_unsigned || k2 == k_unsigned)
|
||||
res = (lval.u > rval.u) - (lval.u < rval.u);
|
||||
else /* if (k1 == k_signed && k2 == k_signed) */
|
||||
res = (lval.s > rval.s) - (lval.s < rval.s);
|
||||
|
||||
switch(e->type) {
|
||||
case E_EQUAL:
|
||||
return res ? no : yes;
|
||||
case E_GEQ:
|
||||
return res >= 0 ? yes : no;
|
||||
case E_GTH:
|
||||
return res > 0 ? yes : no;
|
||||
case E_LEQ:
|
||||
return res <= 0 ? yes : no;
|
||||
case E_LTH:
|
||||
return res < 0 ? yes : no;
|
||||
case E_UNEQUAL:
|
||||
return res ? yes : no;
|
||||
default:
|
||||
printf("expr_calc_value: relation %d?\n", e->type);
|
||||
return no;
|
||||
}
|
||||
}
|
||||
|
||||
int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
static int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
{
|
||||
#if 0
|
||||
return 1;
|
||||
#else
|
||||
if (t1 == t2)
|
||||
return 0;
|
||||
switch (t1) {
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
if (t2 == E_EQUAL || t2 == E_UNEQUAL)
|
||||
return 1;
|
||||
case E_EQUAL:
|
||||
case E_UNEQUAL:
|
||||
if (t2 == E_NOT)
|
||||
@ -1010,7 +1026,6 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
}
|
||||
printf("[%dgt%d?]", t1, t2);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline struct expr *
|
||||
@ -1083,6 +1098,24 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
|
||||
fn(data, NULL, "=");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
break;
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
else
|
||||
fn(data, NULL, "<choice>");
|
||||
fn(data, NULL, e->type == E_LEQ ? "<=" : "<");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
break;
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
else
|
||||
fn(data, NULL, "<choice>");
|
||||
fn(data, NULL, e->type == E_LEQ ? ">=" : ">");
|
||||
fn(data, e->right.sym, e->right.sym->name);
|
||||
break;
|
||||
case E_UNEQUAL:
|
||||
if (e->left.sym->name)
|
||||
fn(data, e->left.sym, e->left.sym->name);
|
||||
|
@ -10,7 +10,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "list.h"
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
@ -27,7 +29,9 @@ typedef enum tristate {
|
||||
} tristate;
|
||||
|
||||
enum expr_type {
|
||||
E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE
|
||||
E_NONE, E_OR, E_AND, E_NOT,
|
||||
E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ,
|
||||
E_LIST, E_SYMBOL, E_RANGE
|
||||
};
|
||||
|
||||
union expr_data {
|
||||
@ -91,7 +95,7 @@ struct symbol {
|
||||
#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
|
||||
#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
|
||||
#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
|
||||
#define SYMBOL_WRITE 0x0200 /* ? */
|
||||
#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
|
||||
#define SYMBOL_CHANGED 0x0400 /* ? */
|
||||
#define SYMBOL_AUTO 0x1000 /* value from environment variable */
|
||||
#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
|
||||
@ -104,6 +108,12 @@ struct symbol {
|
||||
#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
|
||||
#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
|
||||
|
||||
/* choice values need to be set before calculating this symbol value */
|
||||
#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
|
||||
|
||||
/* Set symbol to y if allnoconfig; used for symbols that hide others */
|
||||
#define SYMBOL_ALLNOCONFIG_Y 0x200000
|
||||
|
||||
#define SYMBOL_MAXLENGTH 256
|
||||
#define SYMBOL_HASHSIZE 9973
|
||||
|
||||
@ -172,7 +182,14 @@ struct menu {
|
||||
#define MENU_CHANGED 0x0001
|
||||
#define MENU_ROOT 0x0002
|
||||
|
||||
#ifndef SWIG
|
||||
struct jump_key {
|
||||
struct list_head entries;
|
||||
size_t offset;
|
||||
struct menu *target;
|
||||
int index;
|
||||
};
|
||||
|
||||
#define JUMP_NB 9
|
||||
|
||||
extern struct file *file_list;
|
||||
extern struct file *current_file;
|
||||
@ -190,18 +207,13 @@ struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
|
||||
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
|
||||
struct expr *expr_copy(const struct expr *org);
|
||||
void expr_free(struct expr *e);
|
||||
int expr_eq(struct expr *e1, struct expr *e2);
|
||||
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
|
||||
tristate expr_calc_value(struct expr *e);
|
||||
struct expr *expr_eliminate_yn(struct expr *e);
|
||||
struct expr *expr_trans_bool(struct expr *e);
|
||||
struct expr *expr_eliminate_dups(struct expr *e);
|
||||
struct expr *expr_transform(struct expr *e);
|
||||
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
|
||||
bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
|
||||
struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
|
||||
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
|
||||
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
|
||||
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
|
||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
|
||||
|
||||
@ -218,7 +230,6 @@ static inline int expr_is_no(struct expr *e)
|
||||
{
|
||||
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -10,6 +10,11 @@ PHONY += $(configurators)
|
||||
|
||||
$(configurators): config_files
|
||||
|
||||
export CT_IS_A_BACKEND:=$(CT_IS_A_BACKEND)
|
||||
export CT_BACKEND_ARCH:=$(CT_BACKEND_ARCH)
|
||||
export CT_BACKEND_KERNEL:=$(CT_BACKEND_KERNEL)
|
||||
export CT_BACKEND_LIBC:=$(CT_BACKEND_LIBC)
|
||||
|
||||
# We need CONF for savedefconfig in scripts/saveSample.sh
|
||||
export CONF := $(CT_LIB_DIR)/kconfig/conf
|
||||
MCONF := $(CT_LIB_DIR)/kconfig/mconf
|
||||
@ -55,6 +60,7 @@ extractconfig:
|
||||
|
||||
help-config::
|
||||
@echo ' menuconfig - Update current config using a menu based program'
|
||||
@echo ' nconfig - Update current config using a menu based program'
|
||||
@echo ' oldconfig - Update current config using a provided .config as base'
|
||||
@echo ' extractconfig - Extract to stdout the configuration items from a'
|
||||
@echo ' build.log file piped to stdin'
|
||||
|
131
kconfig/list.h
Normal file
131
kconfig/list.h
Normal file
@ -0,0 +1,131 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
/*
|
||||
* Copied from include/linux/...
|
||||
*/
|
||||
|
||||
#undef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
|
||||
/**
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_head within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(const struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *_new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = _new;
|
||||
_new->next = next;
|
||||
_new->prev = prev;
|
||||
prev->next = _new;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
|
||||
{
|
||||
__list_add(_new, head->prev, head);
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head *prev, struct list_head *next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
#define LIST_POISON1 ((void *) 0x00100100)
|
||||
#define LIST_POISON2 ((void *) 0x00200200)
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty() on entry does not return true after this, the entry is
|
||||
* in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = (struct list_head*)LIST_POISON1;
|
||||
entry->prev = (struct list_head*)LIST_POISON2;
|
||||
}
|
||||
#endif
|
@ -21,14 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef LKC_DIRECT_LINK
|
||||
#define P(name,type,arg) extern type name arg
|
||||
#else
|
||||
#include "lkc_defs.h"
|
||||
#define P(name,type,arg) extern type (*name ## _p) arg
|
||||
#endif
|
||||
#include "lkc_proto.h"
|
||||
#undef P
|
||||
|
||||
#define SRCTREE "srctree"
|
||||
|
||||
@ -44,6 +37,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
|
||||
@ -60,6 +59,7 @@ enum conf_def_mode {
|
||||
#define T_OPT_MODULES 1
|
||||
#define T_OPT_DEFCONFIG_LIST 2
|
||||
#define T_OPT_ENV 3
|
||||
#define T_OPT_ALLNOCONFIG_Y 4
|
||||
|
||||
struct kconf_id {
|
||||
int name;
|
||||
@ -68,11 +68,6 @@ struct kconf_id {
|
||||
enum symbol_type stype;
|
||||
};
|
||||
|
||||
#ifdef YYDEBUG
|
||||
extern int zconfdebug;
|
||||
#endif
|
||||
|
||||
int zconfparse(void);
|
||||
void zconfdump(FILE *out);
|
||||
void zconf_starthelp(void);
|
||||
FILE *zconf_fopen(const char *name);
|
||||
@ -81,26 +76,23 @@ void zconf_nextfile(const char *name);
|
||||
int zconf_lineno(void);
|
||||
const char *zconf_curname(void);
|
||||
|
||||
/* conf.c */
|
||||
void xfgets(char *str, int size, FILE *in);
|
||||
|
||||
/* confdata.c */
|
||||
const char *conf_get_configname(void);
|
||||
const char *conf_get_autoconfig_name(void);
|
||||
char *conf_get_default_confname(void);
|
||||
void sym_set_change_count(int count);
|
||||
void sym_add_change_count(int count);
|
||||
void conf_set_all_new_symbols(enum conf_def_mode mode);
|
||||
bool conf_set_all_new_symbols(enum conf_def_mode mode);
|
||||
void set_all_choice_values(struct symbol *csym);
|
||||
|
||||
/* confdata.c and expr.c */
|
||||
static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
|
||||
{
|
||||
if (fwrite(str, len, count, out) < count)
|
||||
fprintf(stderr, "\nError in writing or end of file.\n");
|
||||
}
|
||||
assert(len != 0);
|
||||
|
||||
/* kconfig_load.c */
|
||||
void kconfig_load(void);
|
||||
if (fwrite(str, len, count, out) != count)
|
||||
fprintf(stderr, "Error in writing or end of file.\n");
|
||||
}
|
||||
|
||||
/* menu.c */
|
||||
void _menu_init(void);
|
||||
@ -111,7 +103,6 @@ void menu_add_entry(struct symbol *sym);
|
||||
void menu_end_entry(void);
|
||||
void menu_add_dep(struct expr *dep);
|
||||
void menu_add_visibility(struct expr *dep);
|
||||
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
|
||||
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
|
||||
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
|
||||
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
|
||||
@ -122,6 +113,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;
|
||||
@ -133,7 +126,6 @@ struct gstr {
|
||||
int max_width;
|
||||
};
|
||||
struct gstr str_new(void);
|
||||
struct gstr str_assign(const char *s);
|
||||
void str_free(struct gstr *gs);
|
||||
void str_append(struct gstr *gs, const char *s);
|
||||
void str_printf(struct gstr *gs, const char *fmt, ...);
|
||||
@ -144,8 +136,6 @@ extern struct expr *sym_env_list;
|
||||
|
||||
void sym_init(void);
|
||||
void sym_clear_all_valid(void);
|
||||
void sym_set_all_changed(void);
|
||||
void sym_set_changed(struct symbol *sym);
|
||||
struct symbol *sym_choice_default(struct symbol *sym);
|
||||
const char *sym_get_string_default(struct symbol *sym);
|
||||
struct symbol *sym_check_deps(struct symbol *sym);
|
||||
|
@ -1,53 +1,52 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
/* confdata.c */
|
||||
P(conf_parse,void,(const char *name));
|
||||
P(conf_read,int,(const char *name));
|
||||
P(conf_read_simple,int,(const char *name, int));
|
||||
P(conf_write_defconfig,int,(const char *name));
|
||||
P(conf_write,int,(const char *name));
|
||||
P(conf_write_autoconf,int,(void));
|
||||
P(conf_get_changed,bool,(void));
|
||||
P(conf_set_changed_callback, void,(void (*fn)(void)));
|
||||
P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
|
||||
void conf_parse(const char *name);
|
||||
int conf_read(const char *name);
|
||||
int conf_read_simple(const char *name, int);
|
||||
int conf_write_defconfig(const char *name);
|
||||
int conf_write(const char *name);
|
||||
int conf_write_autoconf(void);
|
||||
bool conf_get_changed(void);
|
||||
void conf_set_changed_callback(void (*fn)(void));
|
||||
void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap));
|
||||
|
||||
/* menu.c */
|
||||
P(rootmenu,struct menu,);
|
||||
extern struct menu rootmenu;
|
||||
|
||||
P(menu_is_visible, bool, (struct menu *menu));
|
||||
P(menu_has_prompt, bool, (struct menu *menu));
|
||||
P(menu_get_prompt,const char *,(struct menu *menu));
|
||||
P(menu_get_root_menu,struct menu *,(struct menu *menu));
|
||||
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
|
||||
P(menu_has_help,bool,(struct menu *menu));
|
||||
P(menu_get_help,const char *,(struct menu *menu));
|
||||
P(get_symbol_str, void, (struct gstr *r, struct symbol *sym));
|
||||
P(get_relations_str, struct gstr, (struct symbol **sym_arr));
|
||||
P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
|
||||
bool menu_is_empty(struct menu *menu);
|
||||
bool menu_is_visible(struct menu *menu);
|
||||
bool menu_has_prompt(struct menu *menu);
|
||||
const char * menu_get_prompt(struct menu *menu);
|
||||
struct menu * menu_get_root_menu(struct menu *menu);
|
||||
struct menu * menu_get_parent_menu(struct menu *menu);
|
||||
bool menu_has_help(struct menu *menu);
|
||||
const char * menu_get_help(struct menu *menu);
|
||||
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
|
||||
void menu_get_ext_help(struct menu *menu, struct gstr *help);
|
||||
|
||||
/* symbol.c */
|
||||
P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
|
||||
extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
|
||||
|
||||
P(sym_lookup,struct symbol *,(const char *name, int flags));
|
||||
P(sym_find,struct symbol *,(const char *name));
|
||||
P(sym_expand_string_value,const char *,(const char *in));
|
||||
P(sym_re_search,struct symbol **,(const char *pattern));
|
||||
P(sym_type_name,const char *,(enum symbol_type type));
|
||||
P(sym_calc_value,void,(struct symbol *sym));
|
||||
P(sym_get_type,enum symbol_type,(struct symbol *sym));
|
||||
P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
|
||||
P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
|
||||
P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
|
||||
P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
|
||||
P(sym_string_within_range,bool,(struct symbol *sym, const char *str));
|
||||
P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
|
||||
P(sym_is_changable,bool,(struct symbol *sym));
|
||||
P(sym_get_choice_prop,struct property *,(struct symbol *sym));
|
||||
P(sym_get_default_prop,struct property *,(struct symbol *sym));
|
||||
P(sym_get_string_value,const char *,(struct symbol *sym));
|
||||
struct symbol * sym_lookup(const char *name, int flags);
|
||||
struct symbol * sym_find(const char *name);
|
||||
const char * sym_expand_string_value(const char *in);
|
||||
const char * sym_escape_string_value(const char *in);
|
||||
struct symbol ** sym_re_search(const char *pattern);
|
||||
const char * sym_type_name(enum symbol_type type);
|
||||
void sym_calc_value(struct symbol *sym);
|
||||
enum symbol_type sym_get_type(struct symbol *sym);
|
||||
bool sym_tristate_within_range(struct symbol *sym,tristate tri);
|
||||
bool sym_set_tristate_value(struct symbol *sym,tristate tri);
|
||||
tristate sym_toggle_tristate_value(struct symbol *sym);
|
||||
bool sym_string_valid(struct symbol *sym, const char *newval);
|
||||
bool sym_string_within_range(struct symbol *sym, const char *str);
|
||||
bool sym_set_string_value(struct symbol *sym, const char *newval);
|
||||
bool sym_is_changable(struct symbol *sym);
|
||||
struct property * sym_get_choice_prop(struct symbol *sym);
|
||||
const char * sym_get_string_value(struct symbol *sym);
|
||||
|
||||
P(prop_get_type_name,const char *,(enum prop_type type));
|
||||
const char * prop_get_type_name(enum prop_type type);
|
||||
|
||||
/* expr.c */
|
||||
P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
|
||||
P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken));
|
||||
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken);
|
||||
|
@ -4,7 +4,9 @@
|
||||
# What library to link
|
||||
ldflags()
|
||||
{
|
||||
for ext in so a dylib ; do
|
||||
pkg-config --libs ncursesw 2>/dev/null && exit
|
||||
pkg-config --libs ncurses 2>/dev/null && exit
|
||||
for ext in so a dll.a dylib ; do
|
||||
for lib in ncursesw ncurses curses ; do
|
||||
$cc -print-file-name=lib${lib}.${ext} | grep -q /
|
||||
if [ $? -eq 0 ]; then
|
||||
@ -19,12 +21,17 @@ ldflags()
|
||||
# Where is ncurses.h?
|
||||
ccflags()
|
||||
{
|
||||
if [ -f /usr/include/ncurses/ncurses.h ]; then
|
||||
if pkg-config --cflags ncursesw 2>/dev/null; then
|
||||
echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1'
|
||||
elif pkg-config --cflags ncurses 2>/dev/null; then
|
||||
echo '-DCURSES_LOC="<ncurses.h>"'
|
||||
elif [ -f /usr/include/ncursesw/curses.h ]; then
|
||||
echo '-I/usr/include/ncursesw -DCURSES_LOC="<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
|
||||
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
|
||||
elif [ -f /usr/include/ncursesw/curses.h ]; then
|
||||
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
|
||||
echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
|
||||
elif [ -f /usr/include/ncurses.h ]; then
|
||||
echo '-DCURSES_LOC="<ncurses.h>"'
|
||||
else
|
||||
@ -38,7 +45,7 @@ trap "rm -f $tmp" 0 1 2 3 15
|
||||
|
||||
# Check if we can link to ncurses
|
||||
check() {
|
||||
$cc -xc - -o $tmp 2>/dev/null <<'EOF'
|
||||
$cc -x c - -o $tmp 2>/dev/null <<'EOF'
|
||||
#include CURSES_LOC
|
||||
main() {}
|
||||
EOF
|
||||
|
@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
|
||||
}
|
||||
|
||||
do_resize:
|
||||
if (getmaxy(stdscr) < (height + 6))
|
||||
if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
if (getmaxx(stdscr) < (width + 6))
|
||||
if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
|
||||
max_choice = MIN(list_height, item_count());
|
||||
|
||||
/* center dialog box on screen */
|
||||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
x = (getmaxx(stdscr) - width) / 2;
|
||||
y = (getmaxy(stdscr) - height) / 2;
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
@ -168,13 +168,13 @@ do_resize:
|
||||
|
||||
/* create new window for the list */
|
||||
list = subwin(dialog, list_height, list_width, y + box_y + 1,
|
||||
x + box_x + 1);
|
||||
x + box_x + 1);
|
||||
|
||||
keypad(list, TRUE);
|
||||
|
||||
/* draw a box around the list items */
|
||||
draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
|
||||
dlg.menubox_border.atr, dlg.menubox.atr);
|
||||
dlg.menubox_border.atr, dlg.menubox.atr);
|
||||
|
||||
/* Find length of longest item in order to center checklist */
|
||||
check_x = 0;
|
||||
|
@ -106,8 +106,14 @@ struct dialog_color {
|
||||
int hl; /* highlight this item */
|
||||
};
|
||||
|
||||
struct subtitle_list {
|
||||
struct subtitle_list *next;
|
||||
const char *text;
|
||||
};
|
||||
|
||||
struct dialog_info {
|
||||
const char *backtitle;
|
||||
struct subtitle_list *subtitles;
|
||||
struct dialog_color screen;
|
||||
struct dialog_color shadow;
|
||||
struct dialog_color dialog;
|
||||
@ -144,6 +150,7 @@ struct dialog_info {
|
||||
*/
|
||||
extern struct dialog_info dlg;
|
||||
extern char dialog_input_result[];
|
||||
extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
@ -163,7 +170,7 @@ char item_tag(void);
|
||||
/* item list manipulation for lxdialog use */
|
||||
#define MAXITEMSTR 200
|
||||
struct dialog_item {
|
||||
char str[MAXITEMSTR]; /* promtp displayed */
|
||||
char str[MAXITEMSTR]; /* prompt displayed */
|
||||
char tag;
|
||||
void *data; /* pointer to menu item - used by menubox+checklist */
|
||||
int selected; /* Set to 1 by dialog_*() function if selected. */
|
||||
@ -193,8 +200,23 @@ int item_is_tag(char tag);
|
||||
int on_key_esc(WINDOW *win);
|
||||
int on_key_resize(void);
|
||||
|
||||
/* minimum (re)size values */
|
||||
#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
|
||||
#define CHECKLIST_WIDTH_MIN 6
|
||||
#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
|
||||
#define INPUTBOX_WIDTH_MIN 2
|
||||
#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
|
||||
#define MENUBOX_WIDTH_MIN 65
|
||||
#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
|
||||
#define TEXTBOX_WIDTH_MIN 8
|
||||
#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
|
||||
#define YESNO_WIDTH_MIN 4
|
||||
#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
|
||||
#define WINDOW_WIDTH_MIN 80
|
||||
|
||||
int init_dialog(const char *backtitle);
|
||||
void set_dialog_backtitle(const char *backtitle);
|
||||
void set_dialog_subtitles(struct subtitle_list *subtitles);
|
||||
void end_dialog(int x, int y);
|
||||
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
||||
void dialog_clear(void);
|
||||
@ -209,12 +231,17 @@ int first_alpha(const char *string, const char *exempt);
|
||||
int dialog_yesno(const char *title, const char *prompt, int height, int width);
|
||||
int dialog_msgbox(const char *title, const char *prompt, int height,
|
||||
int width, int pause);
|
||||
int dialog_textbox(const char *title, const char *file, int height, int width);
|
||||
|
||||
|
||||
typedef void (*update_text_fn)(char *buf, size_t start, size_t end, void
|
||||
*_data);
|
||||
int dialog_textbox(const char *title, char *tbuf, int initial_height,
|
||||
int initial_width, int *keys, int *_vscroll, int *_hscroll,
|
||||
update_text_fn update_text, void *data);
|
||||
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);
|
||||
|
||||
|
@ -42,10 +42,11 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
|
||||
* Display a dialog box for inputing a string
|
||||
*/
|
||||
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 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;
|
||||
|
||||
@ -55,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
|
||||
strcpy(instr, init);
|
||||
|
||||
do_resize:
|
||||
if (getmaxy(stdscr) <= (height - 2))
|
||||
if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
if (getmaxx(stdscr) <= (width - 2))
|
||||
if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
|
||||
/* center dialog box on screen */
|
||||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
x = (getmaxx(stdscr) - width) / 2;
|
||||
y = (getmaxy(stdscr) - height) / 2;
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
@ -97,14 +98,17 @@ do_resize:
|
||||
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);
|
||||
}
|
||||
|
||||
@ -121,45 +125,104 @@ do_resize:
|
||||
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 (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]);
|
||||
if (pos < len) {
|
||||
for (i = len; i > pos; i--)
|
||||
instr[i] = instr[i-1];
|
||||
instr[pos] = key;
|
||||
} else {
|
||||
wmove(dialog, box_y, input_x++ + box_x);
|
||||
waddch(dialog, key);
|
||||
instr[len] = key;
|
||||
}
|
||||
pos++;
|
||||
len++;
|
||||
instr[len] = '\0';
|
||||
|
||||
if (input_x == box_width - 1) {
|
||||
show_x++;
|
||||
} else {
|
||||
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 */
|
||||
|
@ -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).
|
||||
@ -64,7 +64,7 @@ static int menu_width, item_x;
|
||||
* Print menu item
|
||||
*/
|
||||
static void do_print_item(WINDOW * win, const char *item, int line_y,
|
||||
int selected, int hotkey)
|
||||
int selected, int hotkey)
|
||||
{
|
||||
int j;
|
||||
char *menu_item = malloc(menu_width + 1);
|
||||
@ -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);
|
||||
@ -180,7 +182,7 @@ static void do_scroll(WINDOW *win, int *scroll, int n)
|
||||
* Display a menu for choosing among a number of options
|
||||
*/
|
||||
int dialog_menu(const char *title, const char *prompt,
|
||||
const void *selected, int *s_scroll)
|
||||
const void *selected, int *s_scroll)
|
||||
{
|
||||
int i, j, x, y, box_x, box_y;
|
||||
int height, width, menu_height;
|
||||
@ -191,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
|
||||
do_resize:
|
||||
height = getmaxy(stdscr);
|
||||
width = getmaxx(stdscr);
|
||||
if (height < 15 || width < 65)
|
||||
if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
|
||||
height -= 4;
|
||||
@ -201,8 +203,8 @@ do_resize:
|
||||
max_choice = MIN(menu_height, item_count());
|
||||
|
||||
/* center dialog box on screen */
|
||||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
x = (getmaxx(stdscr) - width) / 2;
|
||||
y = (getmaxy(stdscr) - height) / 2;
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
@ -301,10 +303,11 @@ do_resize:
|
||||
}
|
||||
}
|
||||
|
||||
if (i < max_choice ||
|
||||
key == KEY_UP || key == KEY_DOWN ||
|
||||
key == '-' || key == '+' ||
|
||||
key == KEY_PPAGE || key == KEY_NPAGE) {
|
||||
if (item_count() != 0 &&
|
||||
(i < max_choice ||
|
||||
key == KEY_UP || key == KEY_DOWN ||
|
||||
key == '-' || key == '+' ||
|
||||
key == KEY_PPAGE || key == KEY_NPAGE)) {
|
||||
/* Remove highligt of current item */
|
||||
print_item(scroll + choice, choice, FALSE);
|
||||
|
||||
@ -372,7 +375,7 @@ do_resize:
|
||||
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);
|
||||
@ -399,17 +402,17 @@ do_resize:
|
||||
return 2;
|
||||
case 's':
|
||||
case 'y':
|
||||
return 3;
|
||||
case 'n':
|
||||
return 4;
|
||||
case 'm':
|
||||
return 5;
|
||||
case ' ':
|
||||
case 'n':
|
||||
return 6;
|
||||
case '/':
|
||||
case 'm':
|
||||
return 7;
|
||||
case 'z':
|
||||
case ' ':
|
||||
return 8;
|
||||
case '/':
|
||||
return 9;
|
||||
case 'z':
|
||||
return 10;
|
||||
case '\n':
|
||||
return button;
|
||||
}
|
||||
|
@ -22,23 +22,25 @@
|
||||
#include "dialog.h"
|
||||
|
||||
static void back_lines(int n);
|
||||
static void print_page(WINDOW * win, int height, int width);
|
||||
static void print_line(WINDOW * win, int row, int width);
|
||||
static void print_page(WINDOW *win, int height, int width, update_text_fn
|
||||
update_text, void *data);
|
||||
static void print_line(WINDOW *win, int row, int width);
|
||||
static char *get_line(void);
|
||||
static void print_position(WINDOW * win);
|
||||
|
||||
static int hscroll;
|
||||
static int begin_reached, end_reached, page_length;
|
||||
static const char *buf;
|
||||
static const char *page;
|
||||
static char *buf;
|
||||
static char *page;
|
||||
|
||||
/*
|
||||
* refresh window content
|
||||
*/
|
||||
static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
|
||||
int cur_y, int cur_x)
|
||||
int cur_y, int cur_x, update_text_fn update_text,
|
||||
void *data)
|
||||
{
|
||||
print_page(box, boxh, boxw);
|
||||
print_page(box, boxh, boxw, update_text, data);
|
||||
print_position(dialog);
|
||||
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
||||
wrefresh(dialog);
|
||||
@ -47,14 +49,18 @@ static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
|
||||
|
||||
/*
|
||||
* Display text from a file in a dialog box.
|
||||
*
|
||||
* keys is a null-terminated array
|
||||
* update_text() may not add or remove any '\n' or '\0' in tbuf
|
||||
*/
|
||||
int dialog_textbox(const char *title, const char *tbuf,
|
||||
int initial_height, int initial_width)
|
||||
int dialog_textbox(const char *title, char *tbuf, int initial_height,
|
||||
int initial_width, int *keys, int *_vscroll, int *_hscroll,
|
||||
update_text_fn update_text, void *data)
|
||||
{
|
||||
int i, x, y, cur_x, cur_y, key = 0;
|
||||
int height, width, boxh, boxw;
|
||||
int passed_end;
|
||||
WINDOW *dialog, *box;
|
||||
bool done = false;
|
||||
|
||||
begin_reached = 1;
|
||||
end_reached = 0;
|
||||
@ -63,9 +69,18 @@ int dialog_textbox(const char *title, const char *tbuf,
|
||||
buf = tbuf;
|
||||
page = buf; /* page is pointer to start of page to be displayed */
|
||||
|
||||
if (_vscroll && *_vscroll) {
|
||||
begin_reached = 0;
|
||||
|
||||
for (i = 0; i < *_vscroll; i++)
|
||||
get_line();
|
||||
}
|
||||
if (_hscroll)
|
||||
hscroll = *_hscroll;
|
||||
|
||||
do_resize:
|
||||
getmaxyx(stdscr, height, width);
|
||||
if (height < 8 || width < 8)
|
||||
if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
if (initial_height != 0)
|
||||
height = initial_height;
|
||||
@ -83,8 +98,8 @@ do_resize:
|
||||
width = 0;
|
||||
|
||||
/* center dialog box on screen */
|
||||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
x = (getmaxx(stdscr) - width) / 2;
|
||||
y = (getmaxy(stdscr) - height) / 2;
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
@ -120,25 +135,28 @@ do_resize:
|
||||
|
||||
/* Print first page of text */
|
||||
attr_clear(box, boxh, boxw, dlg.dialog.atr);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x, update_text,
|
||||
data);
|
||||
|
||||
while ((key != KEY_ESC) && (key != '\n')) {
|
||||
while (!done) {
|
||||
key = wgetch(dialog);
|
||||
switch (key) {
|
||||
case 'E': /* Exit */
|
||||
case 'e':
|
||||
case 'X':
|
||||
case 'x':
|
||||
delwin(box);
|
||||
delwin(dialog);
|
||||
return 0;
|
||||
case 'q':
|
||||
case '\n':
|
||||
done = true;
|
||||
break;
|
||||
case 'g': /* First page */
|
||||
case KEY_HOME:
|
||||
if (!begin_reached) {
|
||||
begin_reached = 1;
|
||||
page = buf;
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
cur_y, cur_x, update_text,
|
||||
data);
|
||||
}
|
||||
break;
|
||||
case 'G': /* Last page */
|
||||
@ -148,78 +166,48 @@ do_resize:
|
||||
/* point to last char in buf */
|
||||
page = buf + strlen(buf);
|
||||
back_lines(boxh);
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case 'K': /* Previous line */
|
||||
case 'k':
|
||||
case KEY_UP:
|
||||
if (!begin_reached) {
|
||||
back_lines(page_length + 1);
|
||||
if (begin_reached)
|
||||
break;
|
||||
|
||||
/* We don't call print_page() here but use
|
||||
* scrolling to ensure faster screen update.
|
||||
* However, 'end_reached' and 'page_length'
|
||||
* should still be updated, and 'page' should
|
||||
* point to start of next page. This is done
|
||||
* by calling get_line() in the following
|
||||
* 'for' loop. */
|
||||
scrollok(box, TRUE);
|
||||
wscrl(box, -1); /* Scroll box region down one line */
|
||||
scrollok(box, FALSE);
|
||||
page_length = 0;
|
||||
passed_end = 0;
|
||||
for (i = 0; i < boxh; i++) {
|
||||
if (!i) {
|
||||
/* print first line of page */
|
||||
print_line(box, 0, boxw);
|
||||
wnoutrefresh(box);
|
||||
} else
|
||||
/* Called to update 'end_reached' and 'page' */
|
||||
get_line();
|
||||
if (!passed_end)
|
||||
page_length++;
|
||||
if (end_reached && !passed_end)
|
||||
passed_end = 1;
|
||||
}
|
||||
|
||||
print_position(dialog);
|
||||
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
||||
wrefresh(dialog);
|
||||
}
|
||||
back_lines(page_length + 1);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case 'B': /* Previous page */
|
||||
case 'b':
|
||||
case 'u':
|
||||
case KEY_PPAGE:
|
||||
if (begin_reached)
|
||||
break;
|
||||
back_lines(page_length + boxh);
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case 'J': /* Next line */
|
||||
case 'j':
|
||||
case KEY_DOWN:
|
||||
if (!end_reached) {
|
||||
begin_reached = 0;
|
||||
scrollok(box, TRUE);
|
||||
scroll(box); /* Scroll box region up one line */
|
||||
scrollok(box, FALSE);
|
||||
print_line(box, boxh - 1, boxw);
|
||||
wnoutrefresh(box);
|
||||
print_position(dialog);
|
||||
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
||||
wrefresh(dialog);
|
||||
}
|
||||
if (end_reached)
|
||||
break;
|
||||
|
||||
back_lines(page_length - 1);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case KEY_NPAGE: /* Next page */
|
||||
case ' ':
|
||||
case 'd':
|
||||
if (end_reached)
|
||||
break;
|
||||
|
||||
begin_reached = 0;
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case '0': /* Beginning of line */
|
||||
case 'H': /* Scroll left */
|
||||
@ -234,8 +222,8 @@ do_resize:
|
||||
hscroll--;
|
||||
/* Reprint current page to scroll horizontally */
|
||||
back_lines(page_length);
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case 'L': /* Scroll right */
|
||||
case 'l':
|
||||
@ -245,11 +233,12 @@ do_resize:
|
||||
hscroll++;
|
||||
/* Reprint current page to scroll horizontally */
|
||||
back_lines(page_length);
|
||||
refresh_text_box(dialog, box, boxh, boxw,
|
||||
cur_y, cur_x);
|
||||
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||
cur_x, update_text, data);
|
||||
break;
|
||||
case KEY_ESC:
|
||||
key = on_key_esc(dialog);
|
||||
if (on_key_esc(dialog) == KEY_ESC)
|
||||
done = true;
|
||||
break;
|
||||
case KEY_RESIZE:
|
||||
back_lines(height);
|
||||
@ -257,11 +246,31 @@ do_resize:
|
||||
delwin(dialog);
|
||||
on_key_resize();
|
||||
goto do_resize;
|
||||
default:
|
||||
for (i = 0; keys[i]; i++) {
|
||||
if (key == keys[i]) {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delwin(box);
|
||||
delwin(dialog);
|
||||
return key; /* ESC pressed */
|
||||
if (_vscroll) {
|
||||
const char *s;
|
||||
|
||||
s = buf;
|
||||
*_vscroll = 0;
|
||||
back_lines(page_length);
|
||||
while (s < page && (s = strchr(s, '\n'))) {
|
||||
(*_vscroll)++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
if (_hscroll)
|
||||
*_hscroll = hscroll;
|
||||
return key;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -298,12 +307,23 @@ static void back_lines(int n)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a new page of text. Called by dialog_textbox().
|
||||
* Print a new page of text.
|
||||
*/
|
||||
static void print_page(WINDOW * win, int height, int width)
|
||||
static void print_page(WINDOW *win, int height, int width, update_text_fn
|
||||
update_text, void *data)
|
||||
{
|
||||
int i, passed_end = 0;
|
||||
|
||||
if (update_text) {
|
||||
char *end;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
get_line();
|
||||
end = page;
|
||||
back_lines(height);
|
||||
update_text(buf, page - buf, end - buf, data);
|
||||
}
|
||||
|
||||
page_length = 0;
|
||||
for (i = 0; i < height; i++) {
|
||||
print_line(win, i, width);
|
||||
@ -316,11 +336,10 @@ static void print_page(WINDOW * win, int height, int width)
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a new line of text. Called by dialog_textbox() and print_page().
|
||||
* Print a new line of text.
|
||||
*/
|
||||
static void print_line(WINDOW * win, int row, int width)
|
||||
{
|
||||
int y, x;
|
||||
char *line;
|
||||
|
||||
line = get_line();
|
||||
@ -329,10 +348,10 @@ static void print_line(WINDOW * win, int row, int width)
|
||||
waddch(win, ' ');
|
||||
waddnstr(win, line, MIN(strlen(line), width - 2));
|
||||
|
||||
getyx(win, y, x);
|
||||
/* Clear 'residue' of previous line */
|
||||
#if OLD_NCURSES
|
||||
{
|
||||
int x = getcurx(win);
|
||||
int i;
|
||||
for (i = 0; i < width - x; i++)
|
||||
waddch(win, ' ');
|
||||
@ -355,10 +374,8 @@ static char *get_line(void)
|
||||
end_reached = 0;
|
||||
while (*page != '\n') {
|
||||
if (*page == '\0') {
|
||||
if (!end_reached) {
|
||||
end_reached = 1;
|
||||
break;
|
||||
}
|
||||
end_reached = 1;
|
||||
break;
|
||||
} else if (i < MAX_LEN)
|
||||
line[i++] = *(page++);
|
||||
else {
|
||||
@ -371,7 +388,7 @@ static char *get_line(void)
|
||||
if (i <= MAX_LEN)
|
||||
line[i] = '\0';
|
||||
if (!end_reached)
|
||||
page++; /* move pass '\n' */
|
||||
page++; /* move past '\n' */
|
||||
|
||||
return line;
|
||||
}
|
||||
|
@ -23,6 +23,9 @@
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
/* Needed in signal handler in mconf.c */
|
||||
int saved_x, saved_y;
|
||||
|
||||
struct dialog_info dlg;
|
||||
|
||||
static void set_mono_theme(void)
|
||||
@ -251,15 +254,56 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
|
||||
|
||||
void dialog_clear(void)
|
||||
{
|
||||
attr_clear(stdscr, LINES, COLS, dlg.screen.atr);
|
||||
int lines, columns;
|
||||
|
||||
lines = getmaxy(stdscr);
|
||||
columns = getmaxx(stdscr);
|
||||
|
||||
attr_clear(stdscr, lines, columns, dlg.screen.atr);
|
||||
/* Display background title if it exists ... - SLH */
|
||||
if (dlg.backtitle != NULL) {
|
||||
int i;
|
||||
int i, len = 0, skip = 0;
|
||||
struct subtitle_list *pos;
|
||||
|
||||
wattrset(stdscr, dlg.screen.atr);
|
||||
mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
|
||||
|
||||
for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
|
||||
/* 3 is for the arrow and spaces */
|
||||
len += strlen(pos->text) + 3;
|
||||
}
|
||||
|
||||
wmove(stdscr, 1, 1);
|
||||
for (i = 1; i < COLS - 1; i++)
|
||||
if (len > columns - 2) {
|
||||
const char *ellipsis = "[...] ";
|
||||
waddstr(stdscr, ellipsis);
|
||||
skip = len - (columns - 2 - strlen(ellipsis));
|
||||
}
|
||||
|
||||
for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
|
||||
if (skip == 0)
|
||||
waddch(stdscr, ACS_RARROW);
|
||||
else
|
||||
skip--;
|
||||
|
||||
if (skip == 0)
|
||||
waddch(stdscr, ' ');
|
||||
else
|
||||
skip--;
|
||||
|
||||
if (skip < strlen(pos->text)) {
|
||||
waddstr(stdscr, pos->text + skip);
|
||||
skip = 0;
|
||||
} else
|
||||
skip -= strlen(pos->text);
|
||||
|
||||
if (skip == 0)
|
||||
waddch(stdscr, ' ');
|
||||
else
|
||||
skip--;
|
||||
}
|
||||
|
||||
for (i = len + 1; i < columns - 1; i++)
|
||||
waddch(stdscr, ACS_HLINE);
|
||||
}
|
||||
wnoutrefresh(stdscr);
|
||||
@ -273,8 +317,12 @@ int init_dialog(const char *backtitle)
|
||||
int height, width;
|
||||
|
||||
initscr(); /* Init curses */
|
||||
|
||||
/* Get current cursor position for signal handler in mconf.c */
|
||||
getyx(stdscr, saved_y, saved_x);
|
||||
|
||||
getmaxyx(stdscr, height, width);
|
||||
if (height < 19 || width < 80) {
|
||||
if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
|
||||
endwin();
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
}
|
||||
@ -295,6 +343,11 @@ void set_dialog_backtitle(const char *backtitle)
|
||||
dlg.backtitle = backtitle;
|
||||
}
|
||||
|
||||
void set_dialog_subtitles(struct subtitle_list *subtitles)
|
||||
{
|
||||
dlg.subtitles = subtitles;
|
||||
}
|
||||
|
||||
/*
|
||||
* End using dialog functions.
|
||||
*/
|
||||
@ -323,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
|
||||
/*
|
||||
* Print a string of text in a window, automatically wrap around to the
|
||||
* next line if the string is too long to fit on one line. Newline
|
||||
* characters '\n' are replaced by spaces. We start on a new line
|
||||
* characters '\n' are propperly processed. We start on a new line
|
||||
* if there is no room for at least 4 nonblanks following a double-space.
|
||||
*/
|
||||
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
{
|
||||
int newl, cur_x, cur_y;
|
||||
int i, prompt_len, room, wlen;
|
||||
char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
|
||||
int prompt_len, room, wlen;
|
||||
char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
|
||||
|
||||
strcpy(tempstr, prompt);
|
||||
|
||||
prompt_len = strlen(tempstr);
|
||||
|
||||
/*
|
||||
* Remove newlines
|
||||
*/
|
||||
for (i = 0; i < prompt_len; i++) {
|
||||
if (tempstr[i] == '\n')
|
||||
tempstr[i] = ' ';
|
||||
}
|
||||
|
||||
if (prompt_len <= width - x * 2) { /* If prompt is short */
|
||||
wmove(win, y, (width - prompt_len) / 2);
|
||||
waddstr(win, tempstr);
|
||||
@ -353,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
newl = 1;
|
||||
word = tempstr;
|
||||
while (word && *word) {
|
||||
sp = strchr(word, ' ');
|
||||
sp = strpbrk(word, "\n ");
|
||||
if (sp && *sp == '\n')
|
||||
newline_separator = sp;
|
||||
|
||||
if (sp)
|
||||
*sp++ = 0;
|
||||
|
||||
@ -365,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
if (wlen > room ||
|
||||
(newl && wlen < 4 && sp
|
||||
&& wlen + 1 + strlen(sp) > room
|
||||
&& (!(sp2 = strchr(sp, ' '))
|
||||
&& (!(sp2 = strpbrk(sp, "\n "))
|
||||
|| wlen + 1 + (sp2 - sp) > room))) {
|
||||
cur_y++;
|
||||
cur_x = x;
|
||||
@ -373,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||
wmove(win, cur_y, cur_x);
|
||||
waddstr(win, word);
|
||||
getyx(win, cur_y, cur_x);
|
||||
cur_x++;
|
||||
|
||||
/* Move to the next line if the word separator was a newline */
|
||||
if (newline_separator) {
|
||||
cur_y++;
|
||||
cur_x = x;
|
||||
newline_separator = 0;
|
||||
} else
|
||||
cur_x++;
|
||||
|
||||
if (sp && *sp == ' ') {
|
||||
cur_x++; /* double space */
|
||||
while (*++sp == ' ') ;
|
||||
@ -567,7 +623,7 @@ void item_make(const char *fmt, ...)
|
||||
void item_add_str(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
size_t avail;
|
||||
size_t avail;
|
||||
|
||||
avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str);
|
||||
|
||||
|
@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
|
||||
WINDOW *dialog;
|
||||
|
||||
do_resize:
|
||||
if (getmaxy(stdscr) < (height + 4))
|
||||
if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
if (getmaxx(stdscr) < (width + 4))
|
||||
if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
|
||||
return -ERRDISPLAYTOOSMALL;
|
||||
|
||||
/* center dialog box on screen */
|
||||
x = (COLS - width) / 2;
|
||||
y = (LINES - height) / 2;
|
||||
x = (getmaxx(stdscr) - width) / 2;
|
||||
y = (getmaxy(stdscr) - height) / 2;
|
||||
|
||||
draw_shadow(stdscr, y, x, height, width);
|
||||
|
||||
|
431
kconfig/mconf.c
431
kconfig/mconf.c
@ -15,17 +15,17 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
#include "lxdialog/dialog.h"
|
||||
|
||||
static const char mconf_readme[] = N_(
|
||||
"Overview\n"
|
||||
"--------\n"
|
||||
"This interface let you select features and parameters for the build.\n"
|
||||
"This interface lets you select features and parameters for the build.\n"
|
||||
"Features can either be built-in, modularized, or ignored. Parameters\n"
|
||||
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
||||
"\n"
|
||||
@ -39,16 +39,16 @@ static const char mconf_readme[] = N_(
|
||||
"\n"
|
||||
"To change any of these features, highlight it with the cursor\n"
|
||||
"keys and press <Y> to build it in, <M> to make it a module or\n"
|
||||
"<N> to removed it. You may also press the <Space Bar> to cycle\n"
|
||||
"through the available options (ie. Y->N->M->Y).\n"
|
||||
"<N> to remove it. You may also press the <Space Bar> to cycle\n"
|
||||
"through the available options (i.e. Y->N->M->Y).\n"
|
||||
"\n"
|
||||
"Some additional keyboard hints:\n"
|
||||
"\n"
|
||||
"Menus\n"
|
||||
"----------\n"
|
||||
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
|
||||
" you wish to change or submenu wish to select and press <Enter>.\n"
|
||||
" Submenus are designated by \"--->\".\n"
|
||||
"o Use the Up/Down arrow keys (cursor keys) to highlight the item you\n"
|
||||
" wish to change or the submenu you wish to select and press <Enter>.\n"
|
||||
" Submenus are designated by \"--->\", empty ones by \"----\".\n"
|
||||
"\n"
|
||||
" Shortcut: Press the option's highlighted letter (hotkey).\n"
|
||||
" Pressing a hotkey more than once will sequence\n"
|
||||
@ -65,7 +65,7 @@ static const char mconf_readme[] = N_(
|
||||
" there is a delayed response which you may find annoying.\n"
|
||||
"\n"
|
||||
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
|
||||
" <Exit> and <Help>.\n"
|
||||
" <Exit>, <Help>, <Save>, and <Load>.\n"
|
||||
"\n"
|
||||
"o To get help with an item, use the cursor keys to highlight <Help>\n"
|
||||
" and press <ENTER>.\n"
|
||||
@ -105,10 +105,10 @@ static const char mconf_readme[] = N_(
|
||||
"Text Box (Help Window)\n"
|
||||
"--------\n"
|
||||
"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
|
||||
" keys h,j,k,l function here as do <SPACE BAR> and <B> for those\n"
|
||||
" who are familiar with less and lynx.\n"
|
||||
" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n"
|
||||
" those who are familiar with less and lynx.\n"
|
||||
"\n"
|
||||
"o Press <E>, <X>, <Enter> or <Esc><Esc> to exit.\n"
|
||||
"o Press <E>, <X>, <q>, <Enter> or <Esc><Esc> to exit.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Alternate Configuration Files\n"
|
||||
@ -117,23 +117,21 @@ static const char mconf_readme[] = N_(
|
||||
"those who, for various reasons, find it necessary to switch\n"
|
||||
"between different configurations.\n"
|
||||
"\n"
|
||||
"At the end of the main menu you will find two options. One is\n"
|
||||
"for saving the current configuration to a file of your choosing.\n"
|
||||
"The other option is for loading a previously saved alternate\n"
|
||||
"configuration.\n"
|
||||
"The <Save> button will let you save the current configuration to\n"
|
||||
"a file of your choosing. Use the <Load> button to load a previously\n"
|
||||
"saved alternate configuration.\n"
|
||||
"\n"
|
||||
"Even if you don't use alternate configuration files, but you\n"
|
||||
"find during a Menuconfig session that you have completely messed\n"
|
||||
"up your settings, you may use the \"Load Alternate...\" option to\n"
|
||||
"restore your previously saved settings from \".config\" without\n"
|
||||
"restarting Menuconfig.\n"
|
||||
"Even if you don't use alternate configuration files, but you find\n"
|
||||
"during a Menuconfig session that you have completely messed up your\n"
|
||||
"settings, you may use the <Load> button to restore your previously\n"
|
||||
"saved settings from \".config\" without restarting Menuconfig.\n"
|
||||
"\n"
|
||||
"Other information\n"
|
||||
"-----------------\n"
|
||||
"If you use Menuconfig in an XTERM window make sure you have your\n"
|
||||
"$TERM variable set to point to a xterm definition which supports color.\n"
|
||||
"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n"
|
||||
"display correctly in a RXVT window because rxvt displays only one\n"
|
||||
"If you use Menuconfig in an XTERM window, make sure you have your\n"
|
||||
"$TERM variable set to point to an xterm definition which supports\n"
|
||||
"color. Otherwise, Menuconfig will look rather bad. Menuconfig will\n"
|
||||
"not display correctly in an RXVT window because rxvt displays only one\n"
|
||||
"intensity of color, bright.\n"
|
||||
"\n"
|
||||
"Menuconfig will display larger menus on screens or xterms which are\n"
|
||||
@ -148,8 +146,8 @@ static const char mconf_readme[] = N_(
|
||||
"\n"
|
||||
"Optional personality available\n"
|
||||
"------------------------------\n"
|
||||
"If you prefer to have all of the options listed in a single menu, rather\n"
|
||||
"than the default multimenu hierarchy, run the menuconfig with\n"
|
||||
"If you prefer to have all of the options listed in a single menu,\n"
|
||||
"rather than the default multimenu hierarchy, run the menuconfig with\n"
|
||||
"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||
"\n"
|
||||
"make MENUCONFIG_MODE=single_menu menuconfig\n"
|
||||
@ -172,11 +170,11 @@ static const char mconf_readme[] = N_(
|
||||
" mono => selects colors suitable for monochrome displays\n"
|
||||
" blackbg => selects a color scheme with black background\n"
|
||||
" classic => theme with blue background. The classic look\n"
|
||||
" bluetitle => a LCD friendly version of classic. (default)\n"
|
||||
" bluetitle => an LCD friendly version of classic. (default)\n"
|
||||
"\n"),
|
||||
menu_instructions[] = N_(
|
||||
"Arrow keys navigate the menu. "
|
||||
"<Enter> selects submenus --->. "
|
||||
"<Enter> selects submenus ---> (or empty submenus ----). "
|
||||
"Highlighted letters are hotkeys. "
|
||||
"Pressing <Y> includes, <N> excludes, <M> modularizes features. "
|
||||
"Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
|
||||
@ -236,29 +234,36 @@ search_help[] = N_(
|
||||
"Result:\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"Symbol: FOO [=m]\n"
|
||||
"Type : tristate\n"
|
||||
"Prompt: Foo bus is used to drive the bar HW\n"
|
||||
"Defined at drivers/pci/Kconfig:47\n"
|
||||
"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
||||
"Location:\n"
|
||||
" -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
|
||||
" -> PCI support (PCI [=y])\n"
|
||||
" -> PCI access mode (<choice> [=y])\n"
|
||||
"Selects: LIBCRC32\n"
|
||||
"Selected by: BAR\n"
|
||||
" Location:\n"
|
||||
" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
|
||||
" -> PCI support (PCI [=y])\n"
|
||||
"(1) -> PCI access mode (<choice> [=y])\n"
|
||||
" Defined at drivers/pci/Kconfig:47\n"
|
||||
" Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
||||
" Selects: LIBCRC32\n"
|
||||
" Selected by: BAR [=n]\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"o The line 'Type:' shows the type of the configuration option for\n"
|
||||
" this symbol (boolean, tristate, string, ...)\n"
|
||||
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
||||
" this symbol\n"
|
||||
"o The 'Defined at' line tell at what file / line number the symbol\n"
|
||||
"o The 'Defined at' line tells at what file / line number the symbol\n"
|
||||
" is defined\n"
|
||||
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
|
||||
"o The 'Depends on:' line tells what symbols need to be defined for\n"
|
||||
" this symbol to be visible in the menu (selectable)\n"
|
||||
"o The 'Location:' lines tell where in the menu structure this symbol\n"
|
||||
"o The 'Location:' lines tells where in the menu structure this symbol\n"
|
||||
" is located\n"
|
||||
" A location followed by a [=y] indicate that this is a selectable\n"
|
||||
" menu item - and current value is displayed inside brackets.\n"
|
||||
"o The 'Selects:' line tell what symbol will be automatically\n"
|
||||
" A location followed by a [=y] indicates that this is a\n"
|
||||
" selectable menu item - and the current value is displayed inside\n"
|
||||
" brackets.\n"
|
||||
" Press the key in the (#) prefix to jump directly to that\n"
|
||||
" location. You will be returned to the current search results\n"
|
||||
" after exiting this new menu.\n"
|
||||
"o The 'Selects:' line tells what symbols will be automatically\n"
|
||||
" selected if this symbol is selected (y or m)\n"
|
||||
"o The 'Selected by' line tell what symbol has selected this symbol\n"
|
||||
"o The 'Selected by' line tells what symbol has selected this symbol\n"
|
||||
"\n"
|
||||
"Only relevant lines are shown.\n"
|
||||
"\n\n"
|
||||
@ -273,12 +278,17 @@ static struct menu *current_menu;
|
||||
static int child_count;
|
||||
static int single_menu_mode;
|
||||
static int show_all_options;
|
||||
static int save_and_exit;
|
||||
static int silent;
|
||||
|
||||
static void conf(struct menu *menu);
|
||||
static void conf(struct menu *menu, struct menu *active_menu);
|
||||
static void conf_choice(struct menu *menu);
|
||||
static void conf_string(struct menu *menu);
|
||||
static void conf_load(void);
|
||||
static void conf_save(void);
|
||||
static int show_textbox_ext(const char *title, char *text, int r, int c,
|
||||
int *keys, int *vscroll, int *hscroll,
|
||||
update_text_fn update_text, void *data);
|
||||
static void show_textbox(const char *title, const char *text, int r, int c);
|
||||
static void show_helptext(const char *title, const char *text);
|
||||
static void show_help(struct menu *menu);
|
||||
@ -290,7 +300,7 @@ static void set_config_filename(const char *config_filename)
|
||||
int size;
|
||||
|
||||
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
|
||||
"%s - %s", config_filename, rootmenu.prompt->text);
|
||||
"%s - %s", config_filename, rootmenu.prompt->text);
|
||||
if (size >= sizeof(menu_backtitle))
|
||||
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
||||
set_dialog_backtitle(menu_backtitle);
|
||||
@ -300,18 +310,103 @@ static void set_config_filename(const char *config_filename)
|
||||
filename[sizeof(filename)-1] = '\0';
|
||||
}
|
||||
|
||||
struct subtitle_part {
|
||||
struct list_head entries;
|
||||
const char *text;
|
||||
};
|
||||
static LIST_HEAD(trail);
|
||||
|
||||
static struct subtitle_list *subtitles;
|
||||
static void set_subtitle(void)
|
||||
{
|
||||
struct subtitle_part *sp;
|
||||
struct subtitle_list *pos, *tmp;
|
||||
|
||||
for (pos = subtitles; pos != NULL; pos = tmp) {
|
||||
tmp = pos->next;
|
||||
free(pos);
|
||||
}
|
||||
|
||||
subtitles = NULL;
|
||||
list_for_each_entry(sp, &trail, entries) {
|
||||
if (sp->text) {
|
||||
if (pos) {
|
||||
pos->next = xcalloc(1, sizeof(*pos));
|
||||
pos = pos->next;
|
||||
} else {
|
||||
subtitles = pos = xcalloc(1, sizeof(*pos));
|
||||
}
|
||||
pos->text = sp->text;
|
||||
}
|
||||
}
|
||||
|
||||
set_dialog_subtitles(subtitles);
|
||||
}
|
||||
|
||||
static void reset_subtitle(void)
|
||||
{
|
||||
struct subtitle_list *pos, *tmp;
|
||||
|
||||
for (pos = subtitles; pos != NULL; pos = tmp) {
|
||||
tmp = pos->next;
|
||||
free(pos);
|
||||
}
|
||||
subtitles = NULL;
|
||||
set_dialog_subtitles(subtitles);
|
||||
}
|
||||
|
||||
struct search_data {
|
||||
struct list_head *head;
|
||||
struct menu **targets;
|
||||
int *keys;
|
||||
};
|
||||
|
||||
static void update_text(char *buf, size_t start, size_t end, void *_data)
|
||||
{
|
||||
struct search_data *data = _data;
|
||||
struct jump_key *pos;
|
||||
int k = 0;
|
||||
|
||||
list_for_each_entry(pos, data->head, entries) {
|
||||
if (pos->offset >= start && pos->offset < end) {
|
||||
char header[4];
|
||||
|
||||
if (k < JUMP_NB) {
|
||||
int key = '0' + (pos->index % JUMP_NB) + 1;
|
||||
|
||||
sprintf(header, "(%c)", key);
|
||||
data->keys[k] = key;
|
||||
data->targets[k] = pos->target;
|
||||
k++;
|
||||
} else {
|
||||
sprintf(header, " ");
|
||||
}
|
||||
|
||||
memcpy(buf + pos->offset, header, sizeof(header) - 1);
|
||||
}
|
||||
}
|
||||
data->keys[k] = 0;
|
||||
}
|
||||
|
||||
static void search_conf(void)
|
||||
{
|
||||
struct symbol **sym_arr;
|
||||
struct gstr res;
|
||||
struct gstr title;
|
||||
char *dialog_input;
|
||||
int dres;
|
||||
int dres, vscroll = 0, hscroll = 0;
|
||||
bool again;
|
||||
struct gstr sttext;
|
||||
struct subtitle_part stpart;
|
||||
|
||||
title = str_new();
|
||||
str_printf( &title, _("Enter (sub)string or regexp to search for "
|
||||
"(with or without \"%s\")"), CONFIG_);
|
||||
|
||||
again:
|
||||
dialog_clear();
|
||||
dres = dialog_inputbox(_("Search Configuration Parameter"),
|
||||
_("Enter " CONFIG_ " (sub)string to search for "
|
||||
"(with or without \"" CONFIG_ "\")"),
|
||||
str_get(&title),
|
||||
10, 75, "");
|
||||
switch (dres) {
|
||||
case 0:
|
||||
@ -320,6 +415,7 @@ again:
|
||||
show_helptext(_("Search Configuration"), search_help);
|
||||
goto again;
|
||||
default:
|
||||
str_free(&title);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -328,11 +424,43 @@ again:
|
||||
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
|
||||
dialog_input += strlen(CONFIG_);
|
||||
|
||||
sttext = str_new();
|
||||
str_printf(&sttext, "Search (%s)", dialog_input_result);
|
||||
stpart.text = str_get(&sttext);
|
||||
list_add_tail(&stpart.entries, &trail);
|
||||
|
||||
sym_arr = sym_re_search(dialog_input);
|
||||
res = get_relations_str(sym_arr);
|
||||
do {
|
||||
LIST_HEAD(head);
|
||||
struct menu *targets[JUMP_NB];
|
||||
int keys[JUMP_NB + 1], i;
|
||||
struct search_data data = {
|
||||
.head = &head,
|
||||
.targets = targets,
|
||||
.keys = keys,
|
||||
};
|
||||
struct jump_key *pos, *tmp;
|
||||
|
||||
res = get_relations_str(sym_arr, &head);
|
||||
set_subtitle();
|
||||
dres = show_textbox_ext(_("Search Results"), (char *)
|
||||
str_get(&res), 0, 0, keys, &vscroll,
|
||||
&hscroll, &update_text, (void *)
|
||||
&data);
|
||||
again = false;
|
||||
for (i = 0; i < JUMP_NB && keys[i]; i++)
|
||||
if (dres == keys[i]) {
|
||||
conf(targets[i]->parent, targets[i]);
|
||||
again = true;
|
||||
}
|
||||
str_free(&res);
|
||||
list_for_each_entry_safe(pos, tmp, &head, entries)
|
||||
free(pos);
|
||||
} while (again);
|
||||
free(sym_arr);
|
||||
show_textbox(_("Search Results"), str_get(&res), 0, 0);
|
||||
str_free(&res);
|
||||
str_free(&title);
|
||||
list_del(trail.prev);
|
||||
str_free(&sttext);
|
||||
}
|
||||
|
||||
static void build_conf(struct menu *menu)
|
||||
@ -369,8 +497,9 @@ static void build_conf(struct menu *menu)
|
||||
menu->data ? "-->" : "++>",
|
||||
indent + 1, ' ', prompt);
|
||||
} else
|
||||
item_make(" %*c%s --->", indent + 1, ' ', prompt);
|
||||
|
||||
item_make(" %*c%s %s",
|
||||
indent + 1, ' ', prompt,
|
||||
menu_is_empty(menu) ? "----" : "--->");
|
||||
item_set_tag('m');
|
||||
item_set_data(menu);
|
||||
if (single_menu_mode && menu->data)
|
||||
@ -501,7 +630,7 @@ static void build_conf(struct menu *menu)
|
||||
(sym_has_value(sym) || !sym_is_changable(sym)) ?
|
||||
"" : _(" (NEW)"));
|
||||
if (menu->prompt->type == P_MENU) {
|
||||
item_add_str(" --->");
|
||||
item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -513,40 +642,40 @@ conf_childs:
|
||||
indent -= doint;
|
||||
}
|
||||
|
||||
static void conf(struct menu *menu)
|
||||
static void conf(struct menu *menu, struct menu *active_menu)
|
||||
{
|
||||
struct menu *submenu;
|
||||
const char *prompt = menu_get_prompt(menu);
|
||||
struct subtitle_part stpart;
|
||||
struct symbol *sym;
|
||||
struct menu *active_menu = NULL;
|
||||
int res;
|
||||
int s_scroll = 0;
|
||||
|
||||
if (menu != &rootmenu)
|
||||
stpart.text = menu_get_prompt(menu);
|
||||
else
|
||||
stpart.text = NULL;
|
||||
list_add_tail(&stpart.entries, &trail);
|
||||
|
||||
while (1) {
|
||||
item_reset();
|
||||
current_menu = menu;
|
||||
build_conf(menu);
|
||||
if (!child_count)
|
||||
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');
|
||||
}
|
||||
set_subtitle();
|
||||
dialog_clear();
|
||||
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
|
||||
_(menu_instructions),
|
||||
active_menu, &s_scroll);
|
||||
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
|
||||
break;
|
||||
if (!item_activate_selected())
|
||||
continue;
|
||||
if (!item_tag())
|
||||
continue;
|
||||
|
||||
if (item_count() != 0) {
|
||||
if (!item_activate_selected())
|
||||
continue;
|
||||
if (!item_tag())
|
||||
continue;
|
||||
}
|
||||
submenu = item_data();
|
||||
active_menu = item_data();
|
||||
if (submenu)
|
||||
@ -561,32 +690,36 @@ static void conf(struct menu *menu)
|
||||
if (single_menu_mode)
|
||||
submenu->data = (void *) (long) !submenu->data;
|
||||
else
|
||||
conf(submenu);
|
||||
conf(submenu, NULL);
|
||||
break;
|
||||
case 't':
|
||||
if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
|
||||
conf_choice(submenu);
|
||||
else if (submenu->prompt->type == P_MENU)
|
||||
conf(submenu);
|
||||
conf(submenu, NULL);
|
||||
break;
|
||||
case 's':
|
||||
conf_string(submenu);
|
||||
break;
|
||||
case 'L':
|
||||
conf_load();
|
||||
break;
|
||||
case 'S':
|
||||
conf_save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (sym)
|
||||
show_help(submenu);
|
||||
else
|
||||
else {
|
||||
reset_subtitle();
|
||||
show_helptext(_("README"), _(mconf_readme));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
reset_subtitle();
|
||||
conf_save();
|
||||
break;
|
||||
case 4:
|
||||
reset_subtitle();
|
||||
conf_load();
|
||||
break;
|
||||
case 5:
|
||||
if (item_is_tag('t')) {
|
||||
if (sym_set_tristate_value(sym, yes))
|
||||
break;
|
||||
@ -594,34 +727,45 @@ static void conf(struct menu *menu)
|
||||
show_textbox(NULL, setmod_text, 6, 74);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 6:
|
||||
if (item_is_tag('t'))
|
||||
sym_set_tristate_value(sym, no);
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
if (item_is_tag('t'))
|
||||
sym_set_tristate_value(sym, mod);
|
||||
break;
|
||||
case 6:
|
||||
case 8:
|
||||
if (item_is_tag('t'))
|
||||
sym_toggle_tristate_value(sym);
|
||||
else if (item_is_tag('m'))
|
||||
conf(submenu);
|
||||
conf(submenu, NULL);
|
||||
break;
|
||||
case 7:
|
||||
case 9:
|
||||
search_conf();
|
||||
break;
|
||||
case 8:
|
||||
case 10:
|
||||
show_all_options = !show_all_options;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list_del(trail.prev);
|
||||
}
|
||||
|
||||
static int show_textbox_ext(const char *title, char *text, int r, int c, int
|
||||
*keys, int *vscroll, int *hscroll, update_text_fn
|
||||
update_text, void *data)
|
||||
{
|
||||
dialog_clear();
|
||||
return dialog_textbox(title, text, r, c, keys, vscroll, hscroll,
|
||||
update_text, data);
|
||||
}
|
||||
|
||||
static void show_textbox(const char *title, const char *text, int r, int c)
|
||||
{
|
||||
dialog_clear();
|
||||
dialog_textbox(title, text, r, c);
|
||||
show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void show_helptext(const char *title, const char *text)
|
||||
@ -629,6 +773,19 @@ static void show_helptext(const char *title, const char *text)
|
||||
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) {
|
||||
if (!silent)
|
||||
printf("%s", buf);
|
||||
} else {
|
||||
show_textbox(NULL, buf, 6, 60);
|
||||
}
|
||||
}
|
||||
|
||||
static void show_help(struct menu *menu)
|
||||
{
|
||||
struct gstr help = str_new();
|
||||
@ -671,7 +828,9 @@ static void conf_choice(struct menu *menu)
|
||||
dialog_clear();
|
||||
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
|
||||
_(radiolist_instructions),
|
||||
15, 70, 6);
|
||||
MENUBOX_HEIGTH_MIN,
|
||||
MENUBOX_WIDTH_MIN,
|
||||
CHECKLIST_HEIGTH_MIN);
|
||||
selected = item_activate_selected();
|
||||
switch (res) {
|
||||
case 0:
|
||||
@ -793,9 +952,60 @@ static void conf_save(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int handle_exit(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
save_and_exit = 1;
|
||||
reset_subtitle();
|
||||
dialog_clear();
|
||||
if (conf_get_changed())
|
||||
res = dialog_yesno(NULL,
|
||||
_("Do you wish to save your new configuration?\n"
|
||||
"(Press <ESC><ESC> to continue Crosstool-NG configuration.)"),
|
||||
6, 60);
|
||||
else
|
||||
res = -1;
|
||||
|
||||
end_dialog(saved_x, saved_y);
|
||||
|
||||
switch (res) {
|
||||
case 0:
|
||||
if (conf_write(filename)) {
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Error while writing of the configuration.\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
return 1;
|
||||
}
|
||||
/* fall through */
|
||||
case -1:
|
||||
if (!silent)
|
||||
printf(_("\n\n"
|
||||
"*** End of the configuration.\n"
|
||||
"*** Execute 'ct-ng build' to start the build or try 'ct-ng help'."
|
||||
"\n\n"));
|
||||
res = 0;
|
||||
break;
|
||||
default:
|
||||
if (!silent)
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
if (res != KEY_ESC)
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void sig_handler(int signo)
|
||||
{
|
||||
exit(handle_exit());
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int saved_x, saved_y;
|
||||
char *mode;
|
||||
int res;
|
||||
|
||||
@ -803,6 +1013,14 @@ int main(int ac, char **av)
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
if (ac > 1 && strcmp(av[1], "-s") == 0) {
|
||||
silent = 1;
|
||||
/* Silence conf_read() until the real callback is set up */
|
||||
conf_set_message_callback(NULL);
|
||||
av++;
|
||||
}
|
||||
conf_parse(av[1]);
|
||||
conf_read(NULL);
|
||||
|
||||
@ -812,9 +1030,6 @@ int main(int ac, char **av)
|
||||
single_menu_mode = 1;
|
||||
}
|
||||
|
||||
initscr();
|
||||
|
||||
getyx(stdscr, saved_y, saved_x);
|
||||
if (init_dialog(NULL)) {
|
||||
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
|
||||
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
|
||||
@ -822,37 +1037,11 @@ int main(int ac, char **av)
|
||||
}
|
||||
|
||||
set_config_filename(conf_get_configname());
|
||||
conf_set_message_callback(conf_message_callback);
|
||||
do {
|
||||
conf(&rootmenu);
|
||||
dialog_clear();
|
||||
if (conf_get_changed())
|
||||
res = dialog_yesno(NULL,
|
||||
_("Do you wish to save your "
|
||||
"new configuration?\n"
|
||||
"<ESC><ESC> to continue."),
|
||||
6, 60);
|
||||
else
|
||||
res = -1;
|
||||
conf(&rootmenu, NULL);
|
||||
res = handle_exit();
|
||||
} while (res == KEY_ESC);
|
||||
end_dialog(saved_x, saved_y);
|
||||
|
||||
switch (res) {
|
||||
case 0:
|
||||
if (conf_write(filename)) {
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Error while writing of the configuration.\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
return 1;
|
||||
}
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, _("\n\n"
|
||||
"Your configuration changes were NOT saved."
|
||||
"\n\n"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
169
kconfig/menu.c
169
kconfig/menu.c
@ -3,14 +3,14 @@
|
||||
* Released under the terms of the GNU GPL v2.0.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
static const char nohelp_text[] = N_(
|
||||
"There is no help available for this option.\n");
|
||||
static const char nohelp_text[] = "There is no help available for this option.";
|
||||
|
||||
struct menu rootmenu;
|
||||
static struct menu **last_entry_ptr;
|
||||
@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
|
||||
{
|
||||
struct menu *menu;
|
||||
|
||||
menu = malloc(sizeof(*menu));
|
||||
menu = xmalloc(sizeof(*menu));
|
||||
memset(menu, 0, sizeof(*menu));
|
||||
menu->sym = sym;
|
||||
menu->parent = current_menu;
|
||||
@ -119,12 +119,13 @@ void menu_set_type(int type)
|
||||
sym->type = type;
|
||||
return;
|
||||
}
|
||||
menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'",
|
||||
sym->name ? sym->name : "<choice>",
|
||||
sym_type_name(sym->type), sym_type_name(type));
|
||||
menu_warn(current_entry,
|
||||
"ignoring type redefinition of '%s' from '%s' to '%s'",
|
||||
sym->name ? sym->name : "<choice>",
|
||||
sym_type_name(sym->type), sym_type_name(type));
|
||||
}
|
||||
|
||||
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
|
||||
static struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
|
||||
{
|
||||
struct property *prop = prop_alloc(type, current_entry->sym);
|
||||
|
||||
@ -152,11 +153,24 @@ struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *e
|
||||
struct menu *menu = current_entry;
|
||||
|
||||
while ((menu = menu->parent) != NULL) {
|
||||
struct expr *dup_expr;
|
||||
|
||||
if (!menu->visibility)
|
||||
continue;
|
||||
/*
|
||||
* Do not add a reference to the
|
||||
* menu's visibility expression but
|
||||
* use a copy of it. Otherwise the
|
||||
* expression reduction functions
|
||||
* will modify expressions that have
|
||||
* multiple references which can
|
||||
* cause unwanted side effects.
|
||||
*/
|
||||
dup_expr = expr_copy(menu->visibility);
|
||||
|
||||
prop->visible.expr
|
||||
= expr_alloc_and(prop->visible.expr,
|
||||
menu->visibility);
|
||||
dup_expr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,12 +204,15 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
|
||||
|
||||
void menu_add_option(int token, char *arg)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
switch (token) {
|
||||
case T_OPT_MODULES:
|
||||
prop = prop_alloc(P_DEFAULT, modules_sym);
|
||||
prop->expr = expr_alloc_symbol(current_entry->sym);
|
||||
if (modules_sym)
|
||||
zconf_error("symbol '%s' redefines option 'modules'"
|
||||
" already defined by symbol '%s'",
|
||||
current_entry->sym->name,
|
||||
modules_sym->name
|
||||
);
|
||||
modules_sym = current_entry->sym;
|
||||
break;
|
||||
case T_OPT_DEFCONFIG_LIST:
|
||||
if (!sym_defconfig_list)
|
||||
@ -206,6 +223,9 @@ void menu_add_option(int token, char *arg)
|
||||
case T_OPT_ENV:
|
||||
prop_add_env(arg);
|
||||
break;
|
||||
case T_OPT_ALLNOCONFIG_Y:
|
||||
current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,8 +264,8 @@ static void sym_check_prop(struct symbol *sym)
|
||||
"config symbol '%s' uses select, but is "
|
||||
"not boolean or tristate", sym->name);
|
||||
else if (sym2->type != S_UNKNOWN &&
|
||||
sym2->type != S_BOOLEAN &&
|
||||
sym2->type != S_TRISTATE)
|
||||
sym2->type != S_BOOLEAN &&
|
||||
sym2->type != S_TRISTATE)
|
||||
prop_warn(prop,
|
||||
"'%s' has wrong type. 'select' only "
|
||||
"accept arguments of boolean and "
|
||||
@ -254,7 +274,7 @@ static void sym_check_prop(struct symbol *sym)
|
||||
case P_RANGE:
|
||||
if (sym->type != S_INT && sym->type != S_HEX)
|
||||
prop_warn(prop, "range is only allowed "
|
||||
"for int or hex symbols");
|
||||
"for int or hex symbols");
|
||||
if (!menu_validate_number(sym, prop->expr->left.sym) ||
|
||||
!menu_validate_number(sym, prop->expr->right.sym))
|
||||
prop_warn(prop, "range is invalid");
|
||||
@ -285,11 +305,6 @@ void menu_finalize(struct menu *parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parent->prompt &&
|
||||
!expr_is_yes(parent->prompt->visible.expr)) {
|
||||
parent->visibility = expr_alloc_and (parent->visibility,
|
||||
parent->prompt->visible.expr);
|
||||
}
|
||||
/* set the type of the remaining choice values */
|
||||
for (menu = parent->list; menu; menu = menu->next) {
|
||||
current_entry = menu;
|
||||
@ -441,6 +456,22 @@ bool menu_has_prompt(struct menu *menu)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine if a menu is empty.
|
||||
* A menu is considered empty if it contains no or only
|
||||
* invisible entries.
|
||||
*/
|
||||
bool menu_is_empty(struct menu *menu)
|
||||
{
|
||||
struct menu *child;
|
||||
|
||||
for (child = menu->list; child; child = child->next) {
|
||||
if (menu_is_visible(child))
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool menu_is_visible(struct menu *menu)
|
||||
{
|
||||
struct menu *child;
|
||||
@ -518,27 +549,53 @@ const char *menu_get_help(struct menu *menu)
|
||||
return "";
|
||||
}
|
||||
|
||||
static void get_prompt_str(struct gstr *r, struct property *prop)
|
||||
static void get_prompt_str(struct gstr *r, struct property *prop,
|
||||
struct list_head *head)
|
||||
{
|
||||
int i, j;
|
||||
struct menu *submenu[8], *menu;
|
||||
struct menu *submenu[8], *menu, *location = NULL;
|
||||
struct jump_key *jump = NULL;
|
||||
|
||||
str_printf(r, _("Prompt: %s\n"), _(prop->text));
|
||||
str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
|
||||
prop->menu->lineno);
|
||||
if (!expr_is_yes(prop->visible.expr)) {
|
||||
str_append(r, _(" Depends on: "));
|
||||
expr_gstr_print(prop->visible.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
menu = prop->menu->parent;
|
||||
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
|
||||
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
|
||||
bool accessible = menu_is_visible(menu);
|
||||
|
||||
submenu[i++] = menu;
|
||||
if (location == NULL && accessible)
|
||||
location = menu;
|
||||
}
|
||||
if (head && location) {
|
||||
jump = xmalloc(sizeof(struct jump_key));
|
||||
|
||||
if (menu_is_visible(prop->menu)) {
|
||||
/*
|
||||
* There is not enough room to put the hint at the
|
||||
* beginning of the "Prompt" line. Put the hint on the
|
||||
* last "Location" line even when it would belong on
|
||||
* the former.
|
||||
*/
|
||||
jump->target = prop->menu;
|
||||
} else
|
||||
jump->target = location;
|
||||
|
||||
if (list_empty(head))
|
||||
jump->index = 0;
|
||||
else
|
||||
jump->index = list_entry(head->prev, struct jump_key,
|
||||
entries)->index + 1;
|
||||
|
||||
list_add_tail(&jump->entries, head);
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
str_printf(r, _(" Location:\n"));
|
||||
for (j = 4; --i >= 0; j += 2) {
|
||||
menu = submenu[i];
|
||||
str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
|
||||
if (jump && menu == location)
|
||||
jump->offset = strlen(r->s);
|
||||
str_printf(r, "%*c-> %s", j, ' ',
|
||||
_(menu_get_prompt(menu)));
|
||||
if (menu->sym) {
|
||||
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
||||
menu->sym->name : _("<choice>"),
|
||||
@ -549,7 +606,23 @@ static void get_prompt_str(struct gstr *r, struct property *prop)
|
||||
}
|
||||
}
|
||||
|
||||
void get_symbol_str(struct gstr *r, struct symbol *sym)
|
||||
/*
|
||||
* get property of type P_SYMBOL
|
||||
*/
|
||||
static struct property *get_symbol_prop(struct symbol *sym)
|
||||
{
|
||||
struct property *prop = NULL;
|
||||
|
||||
for_all_properties(sym, prop, P_SYMBOL)
|
||||
break;
|
||||
return prop;
|
||||
}
|
||||
|
||||
/*
|
||||
* head is optional and may be NULL
|
||||
*/
|
||||
static void get_symbol_str(struct gstr *r, struct symbol *sym,
|
||||
struct list_head *head)
|
||||
{
|
||||
bool hit;
|
||||
struct property *prop;
|
||||
@ -568,7 +641,19 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
|
||||
}
|
||||
}
|
||||
for_all_prompts(sym, prop)
|
||||
get_prompt_str(r, prop);
|
||||
get_prompt_str(r, prop, head);
|
||||
|
||||
prop = get_symbol_prop(sym);
|
||||
if (prop) {
|
||||
str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
|
||||
prop->menu->lineno);
|
||||
if (!expr_is_yes(prop->visible.expr)) {
|
||||
str_append(r, _(" Depends on: "));
|
||||
expr_gstr_print(prop->visible.expr, r);
|
||||
str_append(r, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
hit = false;
|
||||
for_all_properties(sym, prop, P_SELECT) {
|
||||
if (!hit) {
|
||||
@ -588,14 +673,14 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
|
||||
str_append(r, "\n\n");
|
||||
}
|
||||
|
||||
struct gstr get_relations_str(struct symbol **sym_arr)
|
||||
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
|
||||
{
|
||||
struct symbol *sym;
|
||||
struct gstr res = str_new();
|
||||
int i;
|
||||
|
||||
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
|
||||
get_symbol_str(&res, sym);
|
||||
get_symbol_str(&res, sym, head);
|
||||
if (!i)
|
||||
str_append(&res, _("No matches found.\n"));
|
||||
return res;
|
||||
@ -605,16 +690,14 @@ struct gstr get_relations_str(struct symbol **sym_arr)
|
||||
void menu_get_ext_help(struct menu *menu, struct gstr *help)
|
||||
{
|
||||
struct symbol *sym = menu->sym;
|
||||
const char *help_text = nohelp_text;
|
||||
|
||||
if (menu_has_help(menu)) {
|
||||
if (sym->name) {
|
||||
if (sym->name)
|
||||
str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
|
||||
str_append(help, _(menu_get_help(menu)));
|
||||
str_append(help, "\n");
|
||||
}
|
||||
} else {
|
||||
str_append(help, nohelp_text);
|
||||
help_text = menu_get_help(menu);
|
||||
}
|
||||
str_printf(help, "%s\n", _(help_text));
|
||||
if (sym)
|
||||
get_symbol_str(help, sym);
|
||||
get_symbol_str(help, sym, NULL);
|
||||
}
|
||||
|
457
kconfig/nconf.c
457
kconfig/nconf.c
@ -7,217 +7,211 @@
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#define LKC_DIRECT_LINK
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lkc.h"
|
||||
#include "nconf.h"
|
||||
#include <ctype.h>
|
||||
|
||||
static const char nconf_readme[] = N_(
|
||||
"Overview\n"
|
||||
"--------\n"
|
||||
"This interface let you select features and parameters for the build.\n"
|
||||
"Features can either be built-in, modularized, or ignored. Parameters\n"
|
||||
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
||||
static const char nconf_global_help[] = N_(
|
||||
"Help windows\n"
|
||||
"------------\n"
|
||||
"o Global help: Unless in a data entry window, pressing <F1> will give \n"
|
||||
" you the global help window, which you are just reading.\n"
|
||||
"\n"
|
||||
"Menu items beginning with following braces represent features that\n"
|
||||
" [ ] can be built in or removed\n"
|
||||
" < > can be built in, modularized or removed\n"
|
||||
" { } can be built in or modularized (selected by other feature)\n"
|
||||
" - - are selected by other feature,\n"
|
||||
" XXX cannot be selected. Use Symbol Info to find out why,\n"
|
||||
"while *, M or whitespace inside braces means to build in, build as\n"
|
||||
"a module or to exclude the feature respectively.\n"
|
||||
"o A short version of the global help is available by pressing <F3>.\n"
|
||||
"\n"
|
||||
"To change any of these features, highlight it with the cursor\n"
|
||||
"keys and press <Y> to build it in, <M> to make it a module or\n"
|
||||
"<N> to removed it. You may also press the <Space Bar> to cycle\n"
|
||||
"through the available options (ie. Y->N->M->Y).\n"
|
||||
"o Local help: To get help related to the current menu entry, use any\n"
|
||||
" of <?> <h>, or if in a data entry window then press <F1>.\n"
|
||||
"\n"
|
||||
"Some additional keyboard hints:\n"
|
||||
"\n"
|
||||
"Menus\n"
|
||||
"Menu entries\n"
|
||||
"------------\n"
|
||||
"This interface lets you select features and parameters for Crosstool-NG\n"
|
||||
"build. Crosstool-NG features can either be built-in, modularized, or\n"
|
||||
"removed.\n"
|
||||
"Parameters must be entered as text or decimal or hexadecimal numbers.\n"
|
||||
"\n"
|
||||
"Menu entries beginning with following braces represent features that\n"
|
||||
" [ ] can be built in or removed\n"
|
||||
" < > can be built in, modularized or removed\n"
|
||||
" { } can be built in or modularized, are selected by another feature\n"
|
||||
" - - are selected by another feature\n"
|
||||
" XXX cannot be selected. Symbol Info <F2> tells you why.\n"
|
||||
"*, M or whitespace inside braces means to enable the option, let the build\n"
|
||||
"automatically decide what to choose or to exclude the feature respectively.\n"
|
||||
"The M (automatic decision) may have other meanings. It is suggested to\n"
|
||||
"read the help for the feature.\n"
|
||||
"\n"
|
||||
"To change any of these features, highlight it with the movement keys\n"
|
||||
"listed below and press <y> to enable it, <m> to let the component\n"
|
||||
"automatically decide what to do or <n> to disable it. You may press\n"
|
||||
"the <Space> key to cycle through the available options.\n"
|
||||
"\n"
|
||||
"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n"
|
||||
"empty submenu.\n"
|
||||
"\n"
|
||||
"Menu navigation keys\n"
|
||||
"----------------------------------------------------------------------\n"
|
||||
"Linewise up <Up>\n"
|
||||
"Linewise down <Down>\n"
|
||||
"Pagewise up <Page Up>\n"
|
||||
"Pagewise down <Page Down>\n"
|
||||
"First entry <Home>\n"
|
||||
"Last entry <End>\n"
|
||||
"Enter a submenu <Right> <Enter>\n"
|
||||
"Go back to parent menu <Left> <Esc> <F5>\n"
|
||||
"Close a help window <Enter> <Esc> <F5>\n"
|
||||
"Close entry window, apply <Enter>\n"
|
||||
"Close entry window, forget <Esc> <F5>\n"
|
||||
"Start incremental, case-insensitive search for STRING in menu entries,\n"
|
||||
" no regex support, STRING is displayed in upper left corner\n"
|
||||
" </>STRING\n"
|
||||
" Remove last character <Backspace>\n"
|
||||
" Jump to next hit <Down>\n"
|
||||
" Jump to previous hit <Up>\n"
|
||||
"Exit menu search mode </> <Esc>\n"
|
||||
"Search for configuration variables with or without leading CONFIG_\n"
|
||||
" <F8>RegExpr<Enter>\n"
|
||||
"Verbose search help <F8><F1>\n"
|
||||
"----------------------------------------------------------------------\n"
|
||||
"\n"
|
||||
"Unless in a data entry window, key <1> may be used instead of <F1>,\n"
|
||||
"<2> instead of <F2>, etc.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Radiolist (Choice list)\n"
|
||||
"-----------------------\n"
|
||||
"Use the movement keys listed above to select the option you wish to set\n"
|
||||
"and press <Space>.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Data entry\n"
|
||||
"----------\n"
|
||||
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
|
||||
" you wish to change use <Enter> or <Space>. Goto submenu by \n"
|
||||
" pressing <Enter> of <right-arrow>. Use <Esc> or <left-arrow> to go back.\n"
|
||||
" Submenus are designated by \"--->\".\n"
|
||||
"\n"
|
||||
" Searching: pressing '/' triggers interactive search mode.\n"
|
||||
" nconfig performs a case insensitive search for the string\n"
|
||||
" in the menu prompts (no regex support).\n"
|
||||
" Pressing the up/down keys highlights the previous/next\n"
|
||||
" matching item. Backspace removes one character from the\n"
|
||||
" match string. Pressing either '/' again or ESC exits\n"
|
||||
" search mode. All other keys behave normally.\n"
|
||||
"\n"
|
||||
" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
|
||||
" unseen options into view.\n"
|
||||
"\n"
|
||||
"o To exit a menu use the just press <ESC> <F5> <F8> or <left-arrow>.\n"
|
||||
"\n"
|
||||
"o To get help with an item, press <F1>\n"
|
||||
" Shortcut: Press <h> or <?>.\n"
|
||||
"Enter the requested information and press <Enter>. Hexadecimal values\n"
|
||||
"may be entered without the \"0x\" prefix.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Radiolists (Choice lists)\n"
|
||||
"-----------\n"
|
||||
"o Use the cursor keys to select the option you wish to set and press\n"
|
||||
" <S> or the <SPACE BAR>.\n"
|
||||
"Text Box (Help Window)\n"
|
||||
"----------------------\n"
|
||||
"Use movement keys as listed in table above.\n"
|
||||
"\n"
|
||||
" Shortcut: Press the first letter of the option you wish to set then\n"
|
||||
" press <S> or <SPACE BAR>.\n"
|
||||
"\n"
|
||||
"o To see available help for the item, press <F1>\n"
|
||||
" Shortcut: Press <H> or <?>.\n"
|
||||
"Press any of <Enter> <Esc> <q> <F5> <F9> to exit.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Data Entry\n"
|
||||
"-----------\n"
|
||||
"o Enter the requested information and press <ENTER>\n"
|
||||
" If you are entering hexadecimal values, it is not necessary to\n"
|
||||
" add the '0x' prefix to the entry.\n"
|
||||
"\n"
|
||||
"o For help, press <F1>.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Text Box (Help Window)\n"
|
||||
"--------\n"
|
||||
"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
|
||||
" keys h,j,k,l function here as do <SPACE BAR> for those\n"
|
||||
" who are familiar with less and lynx.\n"
|
||||
"\n"
|
||||
"o Press <Enter>, <F1>, <F5>, <F7> or <Esc> to exit.\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Alternate Configuration Files\n"
|
||||
"Alternate configuration files\n"
|
||||
"-----------------------------\n"
|
||||
"nconfig supports the use of alternate configuration files for\n"
|
||||
"those who, for various reasons, find it necessary to switch\n"
|
||||
"between different configurations.\n"
|
||||
"nconfig supports switching between different configurations.\n"
|
||||
"Press <F6> to save your current configuration. Press <F7> and enter\n"
|
||||
"a file name to load a previously saved configuration.\n"
|
||||
"\n"
|
||||
"At the end of the main menu you will find two options. One is\n"
|
||||
"for saving the current configuration to a file of your choosing.\n"
|
||||
"The other option is for loading a previously saved alternate\n"
|
||||
"configuration.\n"
|
||||
"\n"
|
||||
"Even if you don't use alternate configuration files, but you\n"
|
||||
"find during a nconfig session that you have completely messed\n"
|
||||
"up your settings, you may use the \"Load Alternate...\" option to\n"
|
||||
"restore your previously saved settings from \".config\" without\n"
|
||||
"restarting nconfig.\n"
|
||||
"Terminal configuration\n"
|
||||
"----------------------\n"
|
||||
"If you use nconfig in a xterm window, make sure your TERM environment\n"
|
||||
"variable specifies a terminal configuration which supports at least\n"
|
||||
"16 colors. Otherwise nconfig will look rather bad.\n"
|
||||
"\n"
|
||||
"Other information\n"
|
||||
"-----------------\n"
|
||||
"If you use nconfig in an XTERM window make sure you have your\n"
|
||||
"$TERM variable set to point to a xterm definition which supports color.\n"
|
||||
"Otherwise, nconfig will look rather bad. nconfig will not\n"
|
||||
"display correctly in a RXVT window because rxvt displays only one\n"
|
||||
"intensity of color, bright.\n"
|
||||
"If the \"stty size\" command reports the current terminalsize correctly,\n"
|
||||
"nconfig will adapt to sizes larger than the traditional 80x25 \"standard\"\n"
|
||||
"and display longer menus properly.\n"
|
||||
"\n"
|
||||
"nconfig will display larger menus on screens or xterms which are\n"
|
||||
"set to display more than the standard 25 row by 80 column geometry.\n"
|
||||
"In order for this to work, the \"stty size\" command must be able to\n"
|
||||
"display the screen's current row and column geometry. I STRONGLY\n"
|
||||
"RECOMMEND that you make sure you do NOT have the shell variables\n"
|
||||
"LINES and COLUMNS exported into your environment. Some distributions\n"
|
||||
"export those variables via /etc/profile. Some ncurses programs can\n"
|
||||
"become confused when those variables (LINES & COLUMNS) don't reflect\n"
|
||||
"the true screen size.\n"
|
||||
"\n"
|
||||
"Optional personality available\n"
|
||||
"------------------------------\n"
|
||||
"If you prefer to have all of the options listed in a single menu, rather\n"
|
||||
"than the default multimenu hierarchy, run the nconfig with NCONFIG_MODE\n"
|
||||
"environment variable set to single_menu. Example:\n"
|
||||
"Single menu mode\n"
|
||||
"----------------\n"
|
||||
"If you prefer to have all of the menu entries listed in a single menu,\n"
|
||||
"rather than the default multimenu hierarchy, run nconfig with\n"
|
||||
"NCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||
"\n"
|
||||
"make NCONFIG_MODE=single_menu nconfig\n"
|
||||
"ct-ng NCONFIG_MODE=single_menu nconfig\n"
|
||||
"\n"
|
||||
"<Enter> will then unroll the appropriate category, or enfold it if it\n"
|
||||
"is already unrolled.\n"
|
||||
"<Enter> will then unfold the appropriate category, or fold it if it\n"
|
||||
"is already unfolded. Folded menu entries will be designated by a\n"
|
||||
"leading \"++>\" and unfolded entries by a leading \"-->\".\n"
|
||||
"\n"
|
||||
"Note that this mode can eventually be a little more CPU expensive\n"
|
||||
"(especially with a larger number of unrolled categories) than the\n"
|
||||
"default mode.\n"
|
||||
"Note that this mode can eventually be a little more CPU expensive than\n"
|
||||
"the default mode, especially with a larger number of unfolded submenus.\n"
|
||||
"\n"),
|
||||
menu_no_f_instructions[] = N_(
|
||||
" You do not have function keys support. Please follow the\n"
|
||||
" following instructions:\n"
|
||||
" Arrow keys navigate the menu.\n"
|
||||
" <Enter> or <right-arrow> selects submenus --->.\n"
|
||||
" Capital Letters are hotkeys.\n"
|
||||
" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
|
||||
" Pressing SpaceBar toggles between the above options.\n"
|
||||
" Press <Esc> or <left-arrow> to go back one menu,\n"
|
||||
" <?> or <h> for Help, </> for Search.\n"
|
||||
" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
|
||||
" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
|
||||
" <Esc> always leaves the current window.\n"),
|
||||
"Legend: [*] built-in [ ] excluded <M> automatic < > automatic capable.\n"
|
||||
"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
|
||||
"\n"
|
||||
"Use the following keys to navigate the menus:\n"
|
||||
"Move up or down with <Up> and <Down>.\n"
|
||||
"Enter a submenu with <Enter> or <Right>.\n"
|
||||
"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
|
||||
"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
|
||||
"Pressing <Space> cycles through the available options.\n"
|
||||
"To search for menu entries press </>.\n"
|
||||
"<Esc> always leaves the current window.\n"
|
||||
"\n"
|
||||
"You do not have function keys support.\n"
|
||||
"Press <1> instead of <F1>, <2> instead of <F2>, etc.\n"
|
||||
"For verbose global help use key <1>.\n"
|
||||
"For help related to the current menu entry press <?> or <h>.\n"),
|
||||
menu_instructions[] = N_(
|
||||
" Arrow keys navigate the menu.\n"
|
||||
" <Enter> or <right-arrow> selects submenus --->.\n"
|
||||
" Capital Letters are hotkeys.\n"
|
||||
" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
|
||||
" Pressing SpaceBar toggles between the above options\n"
|
||||
" Press <Esc>, <F5> or <left-arrow> to go back one menu,\n"
|
||||
" <?>, <F1> or <h> for Help, </> for Search.\n"
|
||||
" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
|
||||
" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
|
||||
" <Esc> always leaves the current window\n"),
|
||||
"Legend: [*] built-in [ ] excluded <M> automatic < > automatic capable.\n"
|
||||
"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
|
||||
"\n"
|
||||
"Use the following keys to navigate the menus:\n"
|
||||
"Move up or down with <Up> or <Down>.\n"
|
||||
"Enter a submenu with <Enter> or <Right>.\n"
|
||||
"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
|
||||
"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
|
||||
"Pressing <Space> cycles through the available options.\n"
|
||||
"To search for menu entries press </>.\n"
|
||||
"<Esc> always leaves the current window.\n"
|
||||
"\n"
|
||||
"Pressing <1> may be used instead of <F1>, <2> instead of <F2>, etc.\n"
|
||||
"For verbose global help press <F1>.\n"
|
||||
"For help related to the current menu entry press <?> or <h>.\n"),
|
||||
radiolist_instructions[] = N_(
|
||||
" Use the arrow keys to navigate this window or\n"
|
||||
" press the hotkey of the item you wish to select\n"
|
||||
" followed by the <SPACE BAR>.\n"
|
||||
" Press <?>, <F1> or <h> for additional information about this option.\n"),
|
||||
"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n"
|
||||
"with <Space>.\n"
|
||||
"For help related to the current entry press <?> or <h>.\n"
|
||||
"For global help press <F1>.\n"),
|
||||
inputbox_instructions_int[] = N_(
|
||||
"Please enter a decimal value.\n"
|
||||
"Fractions will not be accepted.\n"
|
||||
"Press <RETURN> to accept, <ESC> to cancel."),
|
||||
"Press <Enter> to apply, <Esc> to cancel."),
|
||||
inputbox_instructions_hex[] = N_(
|
||||
"Please enter a hexadecimal value.\n"
|
||||
"Press <RETURN> to accept, <ESC> to cancel."),
|
||||
"Press <Enter> to apply, <Esc> to cancel."),
|
||||
inputbox_instructions_string[] = N_(
|
||||
"Please enter a string value.\n"
|
||||
"Press <RETURN> to accept, <ESC> to cancel."),
|
||||
"Press <Enter> to apply, <Esc> to cancel."),
|
||||
setmod_text[] = N_(
|
||||
"This feature depends on another which\n"
|
||||
"has been configured as a module.\n"
|
||||
"As a result, this feature will be built as a module."),
|
||||
nohelp_text[] = N_(
|
||||
"There is no help available for this option.\n"),
|
||||
"This feature depends on another feature which has been configured as\n"
|
||||
"automatic. As a result, the current feature will be built as automatic too."),
|
||||
load_config_text[] = N_(
|
||||
"Enter the name of the configuration file you wish to load.\n"
|
||||
"Accept the name shown to restore the configuration you\n"
|
||||
"last retrieved. Leave blank to abort."),
|
||||
"Accept the name shown to restore the configuration you last\n"
|
||||
"retrieved. Leave empty to abort."),
|
||||
load_config_help[] = N_(
|
||||
"\n"
|
||||
"For various reasons, one may wish to keep several different\n"
|
||||
"configurations available on a single machine.\n"
|
||||
"\n"
|
||||
"If you have saved a previous configuration in a file other than the\n"
|
||||
"default one, entering its name here will allow you to modify that\n"
|
||||
"configuration.\n"
|
||||
"default one, entering its name here will allow you to load and modify\n"
|
||||
"that configuration.\n"
|
||||
"\n"
|
||||
"If you are uncertain, then you have probably never used alternate\n"
|
||||
"configuration files. You should therefor leave this blank to abort.\n"),
|
||||
"Leave empty to abort.\n"),
|
||||
save_config_text[] = N_(
|
||||
"Enter a filename to which this configuration should be saved\n"
|
||||
"as an alternate. Leave blank to abort."),
|
||||
"as an alternate. Leave empty to abort."),
|
||||
save_config_help[] = N_(
|
||||
"\n"
|
||||
"For various reasons, one may wish to keep different configurations\n"
|
||||
"available on a single machine.\n"
|
||||
"For various reasons, one may wish to keep several different\n"
|
||||
"configurations available on a single machine.\n"
|
||||
"\n"
|
||||
"Entering a file name here will allow you to later retrieve, modify\n"
|
||||
"and use the current configuration as an alternate to whatever\n"
|
||||
"configuration options you have selected at that time.\n"
|
||||
"\n"
|
||||
"If you are uncertain what all this means then you should probably\n"
|
||||
"leave this blank.\n"),
|
||||
"Leave empty to abort.\n"),
|
||||
search_help[] = N_(
|
||||
"\n"
|
||||
"Search for symbols and display their relations. Regular expressions\n"
|
||||
"are allowed.\n"
|
||||
"Example: search for \"^FOO\"\n"
|
||||
"Search for symbols (configuration variable names CONFIG_*) and display\n"
|
||||
"their relations. Regular expressions are supported.\n"
|
||||
"Example: Search for \"^FOO\".\n"
|
||||
"Result:\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"Symbol: FOO [ = m]\n"
|
||||
@ -225,32 +219,32 @@ search_help[] = N_(
|
||||
"Defined at drivers/pci/Kconfig:47\n"
|
||||
"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
||||
"Location:\n"
|
||||
" -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
|
||||
" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
|
||||
" -> PCI support (PCI [ = y])\n"
|
||||
" -> PCI access mode (<choice> [ = y])\n"
|
||||
"Selects: LIBCRC32\n"
|
||||
"Selected by: BAR\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
||||
" this symbol\n"
|
||||
"o The 'Defined at' line tell at what file / line number the symbol\n"
|
||||
" is defined\n"
|
||||
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
|
||||
" this symbol to be visible in the menu (selectable)\n"
|
||||
"o The 'Location:' lines tell where in the menu structure this symbol\n"
|
||||
" is located\n"
|
||||
" A location followed by a [ = y] indicate that this is a selectable\n"
|
||||
" menu item - and current value is displayed inside brackets.\n"
|
||||
"o The 'Selects:' line tell what symbol will be automatically\n"
|
||||
" selected if this symbol is selected (y or m)\n"
|
||||
"o The 'Selected by' line tell what symbol has selected this symbol\n"
|
||||
"o The line 'Prompt:' shows the text displayed for this symbol in\n"
|
||||
" the menu hierarchy.\n"
|
||||
"o The 'Defined at' line tells at what file / line number the symbol is\n"
|
||||
" defined.\n"
|
||||
"o The 'Depends on:' line lists symbols that need to be defined for\n"
|
||||
" this symbol to be visible and selectable in the menu.\n"
|
||||
"o The 'Location:' lines tell, where in the menu structure this symbol\n"
|
||||
" is located. A location followed by a [ = y] indicates that this is\n"
|
||||
" a selectable menu item, and the current value is displayed inside\n"
|
||||
" brackets.\n"
|
||||
"o The 'Selects:' line tells, what symbol will be automatically selected\n"
|
||||
" if this symbol is selected (y or m).\n"
|
||||
"o The 'Selected by' line tells what symbol has selected this symbol.\n"
|
||||
"\n"
|
||||
"Only relevant lines are shown.\n"
|
||||
"\n\n"
|
||||
"Search examples:\n"
|
||||
"Examples: USB => find all symbols containing USB\n"
|
||||
" ^USB => find all symbols starting with USB\n"
|
||||
" USB$ => find all symbols ending with USB\n"
|
||||
"USB => find all symbols containing USB\n"
|
||||
"^USB => find all symbols starting with USB\n"
|
||||
"USB$ => find all symbols ending with USB\n"
|
||||
"\n");
|
||||
|
||||
struct mitem {
|
||||
@ -280,6 +274,9 @@ static int global_exit;
|
||||
/* the currently selected button */
|
||||
const char *current_instructions = menu_instructions;
|
||||
|
||||
static char *dialog_input_result;
|
||||
static int dialog_input_result_len;
|
||||
|
||||
static void conf(struct menu *menu);
|
||||
static void conf_choice(struct menu *menu);
|
||||
static void conf_string(struct menu *menu);
|
||||
@ -318,19 +315,19 @@ struct function_keys function_keys[] = {
|
||||
},
|
||||
{
|
||||
.key_str = "F2",
|
||||
.func = "Sym Info",
|
||||
.func = "SymInfo",
|
||||
.key = F_SYMBOL,
|
||||
.handler = handle_f2,
|
||||
},
|
||||
{
|
||||
.key_str = "F3",
|
||||
.func = "Insts",
|
||||
.func = "Help 2",
|
||||
.key = F_INSTS,
|
||||
.handler = handle_f3,
|
||||
},
|
||||
{
|
||||
.key_str = "F4",
|
||||
.func = "Config",
|
||||
.func = "ShowAll",
|
||||
.key = F_CONF,
|
||||
.handler = handle_f4,
|
||||
},
|
||||
@ -354,7 +351,7 @@ struct function_keys function_keys[] = {
|
||||
},
|
||||
{
|
||||
.key_str = "F8",
|
||||
.func = "Sym Search",
|
||||
.func = "SymSearch",
|
||||
.key = F_SEARCH,
|
||||
.handler = handle_f8,
|
||||
},
|
||||
@ -371,15 +368,16 @@ static void print_function_line(void)
|
||||
int i;
|
||||
int offset = 1;
|
||||
const int skip = 1;
|
||||
int lines = getmaxy(stdscr);
|
||||
|
||||
for (i = 0; i < function_keys_num; i++) {
|
||||
(void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
|
||||
mvwprintw(main_window, LINES-3, offset,
|
||||
mvwprintw(main_window, lines-3, offset,
|
||||
"%s",
|
||||
function_keys[i].key_str);
|
||||
(void) wattrset(main_window, attributes[FUNCTION_TEXT]);
|
||||
offset += strlen(function_keys[i].key_str);
|
||||
mvwprintw(main_window, LINES-3,
|
||||
mvwprintw(main_window, lines-3,
|
||||
offset, "%s",
|
||||
function_keys[i].func);
|
||||
offset += strlen(function_keys[i].func) + skip;
|
||||
@ -391,7 +389,7 @@ static void print_function_line(void)
|
||||
static void handle_f1(int *key, struct menu *current_item)
|
||||
{
|
||||
show_scroll_win(main_window,
|
||||
_("README"), _(nconf_readme));
|
||||
_("Global help"), _(nconf_global_help));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -406,7 +404,7 @@ static void handle_f2(int *key, struct menu *current_item)
|
||||
static void handle_f3(int *key, struct menu *current_item)
|
||||
{
|
||||
show_scroll_win(main_window,
|
||||
_("Instructions"),
|
||||
_("Short help"),
|
||||
_(current_instructions));
|
||||
return;
|
||||
}
|
||||
@ -695,15 +693,19 @@ static void search_conf(void)
|
||||
{
|
||||
struct symbol **sym_arr;
|
||||
struct gstr res;
|
||||
char dialog_input_result[100];
|
||||
struct gstr title;
|
||||
char *dialog_input;
|
||||
int dres;
|
||||
|
||||
title = str_new();
|
||||
str_printf( &title, _("Enter (sub)string or regexp to search for "
|
||||
"(with or without \"%s\")"), CONFIG_);
|
||||
|
||||
again:
|
||||
dres = dialog_inputbox(main_window,
|
||||
_("Search Configuration Parameter"),
|
||||
_("Enter " CONFIG_ " (sub)string to search for "
|
||||
"(with or without \"" CONFIG_ "\")"),
|
||||
"", dialog_input_result, 99);
|
||||
str_get(&title),
|
||||
"", &dialog_input_result, &dialog_input_result_len);
|
||||
switch (dres) {
|
||||
case 0:
|
||||
break;
|
||||
@ -712,6 +714,7 @@ again:
|
||||
_("Search Configuration"), search_help);
|
||||
goto again;
|
||||
default:
|
||||
str_free(&title);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -721,11 +724,12 @@ again:
|
||||
dialog_input += strlen(CONFIG_);
|
||||
|
||||
sym_arr = sym_re_search(dialog_input);
|
||||
res = get_relations_str(sym_arr);
|
||||
res = get_relations_str(sym_arr, NULL);
|
||||
free(sym_arr);
|
||||
show_scroll_win(main_window,
|
||||
_("Search Results"), str_get(&res));
|
||||
str_free(&res);
|
||||
str_free(&title);
|
||||
}
|
||||
|
||||
|
||||
@ -759,9 +763,9 @@ static void build_conf(struct menu *menu)
|
||||
indent + 1, ' ', prompt);
|
||||
} else
|
||||
item_make(menu, 'm',
|
||||
" %*c%s --->",
|
||||
indent + 1,
|
||||
' ', prompt);
|
||||
" %*c%s %s",
|
||||
indent + 1, ' ', prompt,
|
||||
menu_is_empty(menu) ? "----" : "--->");
|
||||
|
||||
if (single_menu_mode && menu->data)
|
||||
goto conf_childs;
|
||||
@ -903,7 +907,7 @@ static void build_conf(struct menu *menu)
|
||||
(sym_has_value(sym) || !sym_is_changable(sym)) ?
|
||||
"" : _(" (NEW)"));
|
||||
if (menu->prompt && menu->prompt->type == P_MENU) {
|
||||
item_add_str(" --->");
|
||||
item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -954,7 +958,7 @@ static void show_menu(const char *prompt, const char *instructions,
|
||||
|
||||
clear();
|
||||
(void) wattrset(main_window, attributes[NORMAL]);
|
||||
print_in_middle(stdscr, 1, 0, COLS,
|
||||
print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
|
||||
menu_backtitle,
|
||||
attributes[MAIN_HEADING]);
|
||||
|
||||
@ -1067,7 +1071,6 @@ static void conf(struct menu *menu)
|
||||
struct menu *submenu = 0;
|
||||
const char *prompt = menu_get_prompt(menu);
|
||||
struct symbol *sym;
|
||||
struct menu *active_menu = NULL;
|
||||
int res;
|
||||
int current_index = 0;
|
||||
int last_top_row = 0;
|
||||
@ -1152,13 +1155,9 @@ static void conf(struct menu *menu)
|
||||
continue;
|
||||
|
||||
submenu = (struct menu *) item_data();
|
||||
active_menu = (struct menu *)item_data();
|
||||
if (!submenu || !menu_is_visible(submenu))
|
||||
continue;
|
||||
if (submenu)
|
||||
sym = submenu->sym;
|
||||
else
|
||||
sym = NULL;
|
||||
sym = submenu->sym;
|
||||
|
||||
switch (res) {
|
||||
case ' ':
|
||||
@ -1222,20 +1221,13 @@ static void conf_message_callback(const char *fmt, va_list ap)
|
||||
|
||||
static void show_help(struct menu *menu)
|
||||
{
|
||||
struct gstr help = str_new();
|
||||
struct gstr help;
|
||||
|
||||
if (menu && menu->sym && menu_has_help(menu)) {
|
||||
if (menu->sym->name) {
|
||||
str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name);
|
||||
str_append(&help, _(menu_get_help(menu)));
|
||||
str_append(&help, "\n");
|
||||
get_symbol_str(&help, menu->sym);
|
||||
} else {
|
||||
str_append(&help, _(menu_get_help(menu)));
|
||||
}
|
||||
} else {
|
||||
str_append(&help, nohelp_text);
|
||||
}
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
help = str_new();
|
||||
menu_get_ext_help(menu, &help);
|
||||
show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
|
||||
str_free(&help);
|
||||
}
|
||||
@ -1360,7 +1352,6 @@ static void conf_choice(struct menu *menu)
|
||||
static void conf_string(struct menu *menu)
|
||||
{
|
||||
const char *prompt = menu_get_prompt(menu);
|
||||
char dialog_input_result[256];
|
||||
|
||||
while (1) {
|
||||
int res;
|
||||
@ -1383,8 +1374,8 @@ static void conf_string(struct menu *menu)
|
||||
prompt ? _(prompt) : _("Main Menu"),
|
||||
heading,
|
||||
sym_get_string_value(menu->sym),
|
||||
dialog_input_result,
|
||||
sizeof(dialog_input_result));
|
||||
&dialog_input_result,
|
||||
&dialog_input_result_len);
|
||||
switch (res) {
|
||||
case 0:
|
||||
if (sym_set_string_value(menu->sym,
|
||||
@ -1404,14 +1395,13 @@ static void conf_string(struct menu *menu)
|
||||
|
||||
static void conf_load(void)
|
||||
{
|
||||
char dialog_input_result[256];
|
||||
while (1) {
|
||||
int res;
|
||||
res = dialog_inputbox(main_window,
|
||||
NULL, load_config_text,
|
||||
filename,
|
||||
dialog_input_result,
|
||||
sizeof(dialog_input_result));
|
||||
&dialog_input_result,
|
||||
&dialog_input_result_len);
|
||||
switch (res) {
|
||||
case 0:
|
||||
if (!dialog_input_result[0])
|
||||
@ -1436,14 +1426,13 @@ static void conf_load(void)
|
||||
|
||||
static void conf_save(void)
|
||||
{
|
||||
char dialog_input_result[256];
|
||||
while (1) {
|
||||
int res;
|
||||
res = dialog_inputbox(main_window,
|
||||
NULL, save_config_text,
|
||||
filename,
|
||||
dialog_input_result,
|
||||
sizeof(dialog_input_result));
|
||||
&dialog_input_result,
|
||||
&dialog_input_result_len);
|
||||
switch (res) {
|
||||
case 0:
|
||||
if (!dialog_input_result[0])
|
||||
@ -1470,14 +1459,18 @@ static void conf_save(void)
|
||||
|
||||
void setup_windows(void)
|
||||
{
|
||||
int lines, columns;
|
||||
|
||||
getmaxyx(stdscr, lines, columns);
|
||||
|
||||
if (main_window != NULL)
|
||||
delwin(main_window);
|
||||
|
||||
/* set up the menu and menu window */
|
||||
main_window = newwin(LINES-2, COLS-2, 2, 1);
|
||||
main_window = newwin(lines-2, columns-2, 2, 1);
|
||||
keypad(main_window, TRUE);
|
||||
mwin_max_lines = LINES-7;
|
||||
mwin_max_cols = COLS-6;
|
||||
mwin_max_lines = lines-7;
|
||||
mwin_max_cols = columns-6;
|
||||
|
||||
/* panels order is from bottom to top */
|
||||
new_panel(main_window);
|
||||
@ -1485,12 +1478,18 @@ void setup_windows(void)
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int lines, columns;
|
||||
char *mode;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
if (ac > 1 && strcmp(av[1], "-s") == 0) {
|
||||
/* Silence conf_read() until the real callback is set up */
|
||||
conf_set_message_callback(NULL);
|
||||
av++;
|
||||
}
|
||||
conf_parse(av[1]);
|
||||
conf_read(NULL);
|
||||
|
||||
@ -1510,7 +1509,8 @@ int main(int ac, char **av)
|
||||
keypad(stdscr, TRUE);
|
||||
curs_set(0);
|
||||
|
||||
if (COLS < 75 || LINES < 20) {
|
||||
getmaxyx(stdscr, lines, columns);
|
||||
if (columns < 75 || lines < 20) {
|
||||
endwin();
|
||||
printf("Your terminal should have at "
|
||||
"least 20 lines and 75 columns\n");
|
||||
@ -1518,7 +1518,11 @@ int main(int ac, char **av)
|
||||
}
|
||||
|
||||
notimeout(stdscr, FALSE);
|
||||
#if NCURSES_REENTRANT
|
||||
set_escdelay(1);
|
||||
#else
|
||||
ESCDELAY = 1;
|
||||
#endif
|
||||
|
||||
/* set btns menu */
|
||||
curses_menu = new_menu(curses_menu_items);
|
||||
@ -1558,4 +1562,3 @@ int main(int ac, char **av)
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ static void set_normal_colors(void)
|
||||
init_pair(INPUT_FIELD, -1, -1);
|
||||
|
||||
init_pair(FUNCTION_HIGHLIGHT, -1, -1);
|
||||
init_pair(FUNCTION_TEXT, COLOR_BLUE, -1);
|
||||
init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
|
||||
}
|
||||
|
||||
/* available attributes:
|
||||
@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
|
||||
|
||||
total_width = max(msg_width, btns_width);
|
||||
/* place dialog in middle of screen */
|
||||
y = (LINES-(msg_lines+4))/2;
|
||||
x = (COLS-(total_width+4))/2;
|
||||
y = (getmaxy(stdscr)-(msg_lines+4))/2;
|
||||
x = (getmaxx(stdscr)-(total_width+4))/2;
|
||||
|
||||
|
||||
/* create the windows */
|
||||
@ -356,7 +356,7 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
|
||||
|
||||
int dialog_inputbox(WINDOW *main_window,
|
||||
const char *title, const char *prompt,
|
||||
const char *init, char *result, int result_len)
|
||||
const char *init, char **resultp, int *result_len)
|
||||
{
|
||||
int prompt_lines = 0;
|
||||
int prompt_width = 0;
|
||||
@ -367,7 +367,13 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
int i, x, y;
|
||||
int res = -1;
|
||||
int cursor_position = strlen(init);
|
||||
int cursor_form_win;
|
||||
char *result = *resultp;
|
||||
|
||||
if (strlen(init)+1 > *result_len) {
|
||||
*result_len = strlen(init)+1;
|
||||
*resultp = result = realloc(result, *result_len);
|
||||
}
|
||||
|
||||
/* find the widest line of msg: */
|
||||
prompt_lines = get_line_no(prompt);
|
||||
@ -381,10 +387,10 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
prompt_width = max(prompt_width, strlen(title));
|
||||
|
||||
/* place dialog in middle of screen */
|
||||
y = (LINES-(prompt_lines+4))/2;
|
||||
x = (COLS-(prompt_width+4))/2;
|
||||
y = (getmaxy(stdscr)-(prompt_lines+4))/2;
|
||||
x = (getmaxx(stdscr)-(prompt_width+4))/2;
|
||||
|
||||
strncpy(result, init, result_len);
|
||||
strncpy(result, init, *result_len);
|
||||
|
||||
/* create the windows */
|
||||
win = newwin(prompt_lines+6, prompt_width+7, y, x);
|
||||
@ -405,7 +411,9 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
fill_window(prompt_win, prompt);
|
||||
|
||||
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
||||
mvwprintw(form_win, 0, 0, "%s", result);
|
||||
cursor_form_win = min(cursor_position, prompt_width-1);
|
||||
mvwprintw(form_win, 0, 0, "%s",
|
||||
result + cursor_position-cursor_form_win);
|
||||
|
||||
/* create panels */
|
||||
panel = new_panel(win);
|
||||
@ -431,6 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
&result[cursor_position],
|
||||
len-cursor_position+1);
|
||||
cursor_position--;
|
||||
cursor_form_win--;
|
||||
len--;
|
||||
}
|
||||
break;
|
||||
case KEY_DC:
|
||||
@ -438,38 +448,63 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
memmove(&result[cursor_position],
|
||||
&result[cursor_position+1],
|
||||
len-cursor_position+1);
|
||||
len--;
|
||||
}
|
||||
break;
|
||||
case KEY_UP:
|
||||
case KEY_RIGHT:
|
||||
if (cursor_position < len &&
|
||||
cursor_position < min(result_len, prompt_width))
|
||||
if (cursor_position < len) {
|
||||
cursor_position++;
|
||||
cursor_form_win++;
|
||||
}
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
case KEY_LEFT:
|
||||
if (cursor_position > 0)
|
||||
if (cursor_position > 0) {
|
||||
cursor_position--;
|
||||
cursor_form_win--;
|
||||
}
|
||||
break;
|
||||
case KEY_HOME:
|
||||
cursor_position = 0;
|
||||
cursor_form_win = 0;
|
||||
break;
|
||||
case KEY_END:
|
||||
cursor_position = len;
|
||||
cursor_form_win = min(cursor_position, prompt_width-1);
|
||||
break;
|
||||
default:
|
||||
if ((isgraph(res) || isspace(res)) &&
|
||||
len-2 < result_len) {
|
||||
if ((isgraph(res) || isspace(res))) {
|
||||
/* one for new char, one for '\0' */
|
||||
if (len+2 > *result_len) {
|
||||
*result_len = len+2;
|
||||
*resultp = result = realloc(result,
|
||||
*result_len);
|
||||
}
|
||||
/* insert the char at the proper position */
|
||||
memmove(&result[cursor_position+1],
|
||||
&result[cursor_position],
|
||||
len+1);
|
||||
len-cursor_position+1);
|
||||
result[cursor_position] = res;
|
||||
cursor_position++;
|
||||
cursor_form_win++;
|
||||
len++;
|
||||
} else {
|
||||
mvprintw(0, 0, "unknow key: %d\n", res);
|
||||
mvprintw(0, 0, "unknown key: %d\n", res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cursor_form_win < 0)
|
||||
cursor_form_win = 0;
|
||||
else if (cursor_form_win > prompt_width-1)
|
||||
cursor_form_win = prompt_width-1;
|
||||
|
||||
wmove(form_win, 0, 0);
|
||||
wclrtoeol(form_win);
|
||||
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
||||
mvwprintw(form_win, 0, 0, "%s", result);
|
||||
wmove(form_win, 0, cursor_position);
|
||||
mvwprintw(form_win, 0, 0, "%s",
|
||||
result + cursor_position-cursor_form_win);
|
||||
wmove(form_win, 0, cursor_form_win);
|
||||
touchwin(win);
|
||||
refresh_all_windows(main_window);
|
||||
|
||||
@ -510,7 +545,7 @@ void show_scroll_win(WINDOW *main_window,
|
||||
{
|
||||
int res;
|
||||
int total_lines = get_line_no(text);
|
||||
int x, y;
|
||||
int x, y, lines, columns;
|
||||
int start_x = 0, start_y = 0;
|
||||
int text_lines = 0, text_cols = 0;
|
||||
int total_cols = 0;
|
||||
@ -521,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,
|
||||
WINDOW *pad;
|
||||
PANEL *panel;
|
||||
|
||||
getmaxyx(stdscr, lines, columns);
|
||||
|
||||
/* find the widest line of msg: */
|
||||
total_lines = get_line_no(text);
|
||||
for (i = 0; i < total_lines; i++) {
|
||||
@ -534,14 +571,14 @@ void show_scroll_win(WINDOW *main_window,
|
||||
(void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
|
||||
fill_window(pad, text);
|
||||
|
||||
win_lines = min(total_lines+4, LINES-2);
|
||||
win_cols = min(total_cols+2, COLS-2);
|
||||
win_lines = min(total_lines+4, lines-2);
|
||||
win_cols = min(total_cols+2, columns-2);
|
||||
text_lines = max(win_lines-4, 0);
|
||||
text_cols = max(win_cols-2, 0);
|
||||
|
||||
/* place window in middle of screen */
|
||||
y = (LINES-win_lines)/2;
|
||||
x = (COLS-win_cols)/2;
|
||||
y = (lines-win_lines)/2;
|
||||
x = (columns-win_cols)/2;
|
||||
|
||||
win = newwin(win_lines, win_cols, y, x);
|
||||
keypad(win, TRUE);
|
||||
@ -569,9 +606,11 @@ void show_scroll_win(WINDOW *main_window,
|
||||
switch (res) {
|
||||
case KEY_NPAGE:
|
||||
case ' ':
|
||||
case 'd':
|
||||
start_y += text_lines-2;
|
||||
break;
|
||||
case KEY_PPAGE:
|
||||
case 'u':
|
||||
start_y -= text_lines+2;
|
||||
break;
|
||||
case KEY_HOME:
|
||||
@ -597,10 +636,10 @@ void show_scroll_win(WINDOW *main_window,
|
||||
start_x++;
|
||||
break;
|
||||
}
|
||||
if (res == 10 || res == 27 || res == 'q'
|
||||
|| res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) {
|
||||
if (res == 10 || res == 27 || res == 'q' ||
|
||||
res == KEY_F(F_HELP) || res == KEY_F(F_BACK) ||
|
||||
res == KEY_F(F_EXIT))
|
||||
break;
|
||||
}
|
||||
if (start_y < 0)
|
||||
start_y = 0;
|
||||
if (start_y >= total_lines-text_lines)
|
||||
|
@ -89,7 +89,7 @@ void fill_window(WINDOW *win, const char *text);
|
||||
int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
|
||||
int dialog_inputbox(WINDOW *main_window,
|
||||
const char *title, const char *prompt,
|
||||
const char *init, char *result, int result_len);
|
||||
const char *init, char **resultp, int *result_len);
|
||||
void refresh_all_windows(WINDOW *main_window);
|
||||
void show_scroll_win(WINDOW *main_window,
|
||||
const char *title,
|
||||
|
219
kconfig/symbol.c
219
kconfig/symbol.c
@ -9,7 +9,6 @@
|
||||
#include <regex.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
struct symbol symbol_yes = {
|
||||
@ -113,7 +112,7 @@ struct property *sym_get_env_prop(struct symbol *sym)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct property *sym_get_default_prop(struct symbol *sym)
|
||||
static struct property *sym_get_default_prop(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
@ -137,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int sym_get_range_val(struct symbol *sym, int base)
|
||||
static long long sym_get_range_val(struct symbol *sym, int base)
|
||||
{
|
||||
sym_calc_value(sym);
|
||||
switch (sym->type) {
|
||||
@ -150,13 +149,14 @@ static int sym_get_range_val(struct symbol *sym, int base)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return strtol(sym->curr.val, NULL, base);
|
||||
return strtoll(sym->curr.val, NULL, base);
|
||||
}
|
||||
|
||||
static void sym_validate_range(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
int base, val, val2;
|
||||
int base;
|
||||
long long val, val2;
|
||||
char str[64];
|
||||
|
||||
switch (sym->type) {
|
||||
@ -172,7 +172,7 @@ static void sym_validate_range(struct symbol *sym)
|
||||
prop = sym_get_range_prop(sym);
|
||||
if (!prop)
|
||||
return;
|
||||
val = strtol(sym->curr.val, NULL, base);
|
||||
val = strtoll(sym->curr.val, NULL, base);
|
||||
val2 = sym_get_range_val(prop->expr->left.sym, base);
|
||||
if (val >= val2) {
|
||||
val2 = sym_get_range_val(prop->expr->right.sym, base);
|
||||
@ -180,12 +180,32 @@ static void sym_validate_range(struct symbol *sym)
|
||||
return;
|
||||
}
|
||||
if (sym->type == S_INT)
|
||||
sprintf(str, "%d", val2);
|
||||
sprintf(str, "%lld", val2);
|
||||
else
|
||||
sprintf(str, "0x%x", val2);
|
||||
sprintf(str, "0x%llx", val2);
|
||||
sym->curr.val = strdup(str);
|
||||
}
|
||||
|
||||
static void sym_set_changed(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
sym->flags |= SYMBOL_CHANGED;
|
||||
for (prop = sym->prop; prop; prop = prop->next) {
|
||||
if (prop->menu)
|
||||
prop->menu->flags |= MENU_CHANGED;
|
||||
}
|
||||
}
|
||||
|
||||
static void sym_set_all_changed(void)
|
||||
{
|
||||
struct symbol *sym;
|
||||
int i;
|
||||
|
||||
for_all_symbols(i, sym)
|
||||
sym_set_changed(sym);
|
||||
}
|
||||
|
||||
static void sym_calc_visibility(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
@ -263,11 +283,18 @@ static struct symbol *sym_calc_choice(struct symbol *sym)
|
||||
struct symbol *def_sym;
|
||||
struct property *prop;
|
||||
struct expr *e;
|
||||
int flags;
|
||||
|
||||
/* first calculate all choice values' visibilities */
|
||||
flags = sym->flags;
|
||||
prop = sym_get_choice_prop(sym);
|
||||
expr_list_for_each_sym(prop->expr, e, def_sym)
|
||||
expr_list_for_each_sym(prop->expr, e, def_sym) {
|
||||
sym_calc_visibility(def_sym);
|
||||
if (def_sym->visible != no)
|
||||
flags &= def_sym->flags;
|
||||
}
|
||||
|
||||
sym->flags &= flags | ~SYMBOL_DEF_USER;
|
||||
|
||||
/* is the user choice visible? */
|
||||
def_sym = sym->def[S_DEF_USER].val;
|
||||
@ -294,6 +321,14 @@ void sym_calc_value(struct symbol *sym)
|
||||
|
||||
if (sym->flags & SYMBOL_VALID)
|
||||
return;
|
||||
|
||||
if (sym_is_choice_value(sym) &&
|
||||
sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
|
||||
sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
|
||||
prop = sym_get_choice_prop(sym);
|
||||
sym_calc_value(prop_get_symbol(prop));
|
||||
}
|
||||
|
||||
sym->flags |= SYMBOL_VALID;
|
||||
|
||||
oldval = sym->curr;
|
||||
@ -419,6 +454,9 @@ void sym_calc_value(struct symbol *sym)
|
||||
|
||||
if (sym->flags & SYMBOL_AUTO)
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
|
||||
if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
|
||||
set_all_choice_values(sym);
|
||||
}
|
||||
|
||||
void sym_clear_all_valid(void)
|
||||
@ -433,26 +471,6 @@ void sym_clear_all_valid(void)
|
||||
sym_calc_value(modules_sym);
|
||||
}
|
||||
|
||||
void sym_set_changed(struct symbol *sym)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
sym->flags |= SYMBOL_CHANGED;
|
||||
for (prop = sym->prop; prop; prop = prop->next) {
|
||||
if (prop->menu)
|
||||
prop->menu->flags |= MENU_CHANGED;
|
||||
}
|
||||
}
|
||||
|
||||
void sym_set_all_changed(void)
|
||||
{
|
||||
struct symbol *sym;
|
||||
int i;
|
||||
|
||||
for_all_symbols(i, sym)
|
||||
sym_set_changed(sym);
|
||||
}
|
||||
|
||||
bool sym_tristate_within_range(struct symbol *sym, tristate val)
|
||||
{
|
||||
int type = sym_get_type(sym);
|
||||
@ -577,7 +595,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
|
||||
bool sym_string_within_range(struct symbol *sym, const char *str)
|
||||
{
|
||||
struct property *prop;
|
||||
int val;
|
||||
long long val;
|
||||
|
||||
switch (sym->type) {
|
||||
case S_STRING:
|
||||
@ -588,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
|
||||
prop = sym_get_range_prop(sym);
|
||||
if (!prop)
|
||||
return true;
|
||||
val = strtol(str, NULL, 10);
|
||||
val = strtoll(str, NULL, 10);
|
||||
return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
|
||||
val <= sym_get_range_val(prop->expr->right.sym, 10);
|
||||
case S_HEX:
|
||||
@ -597,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
|
||||
prop = sym_get_range_prop(sym);
|
||||
if (!prop)
|
||||
return true;
|
||||
val = strtol(str, NULL, 16);
|
||||
val = strtoll(str, NULL, 16);
|
||||
return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
|
||||
val <= sym_get_range_val(prop->expr->right.sym, 16);
|
||||
case S_BOOLEAN:
|
||||
@ -650,11 +668,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
|
||||
size = strlen(newval) + 1;
|
||||
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
|
||||
size += 2;
|
||||
sym->def[S_DEF_USER].val = val = malloc(size);
|
||||
sym->def[S_DEF_USER].val = val = xmalloc(size);
|
||||
*val++ = '0';
|
||||
*val++ = 'x';
|
||||
} 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
|
||||
return true;
|
||||
|
||||
@ -751,7 +769,8 @@ const char *sym_get_string_value(struct symbol *sym)
|
||||
case no:
|
||||
return "n";
|
||||
case mod:
|
||||
return "m";
|
||||
sym_calc_value(modules_sym);
|
||||
return (modules_sym->curr.tri == no) ? "n" : "m";
|
||||
case yes:
|
||||
return "y";
|
||||
}
|
||||
@ -805,7 +824,7 @@ struct symbol *sym_lookup(const char *name, int flags)
|
||||
hash = 0;
|
||||
}
|
||||
|
||||
symbol = malloc(sizeof(*symbol));
|
||||
symbol = xmalloc(sizeof(*symbol));
|
||||
memset(symbol, 0, sizeof(*symbol));
|
||||
symbol->name = new_name;
|
||||
symbol->type = S_UNKNOWN;
|
||||
@ -856,7 +875,7 @@ const char *sym_expand_string_value(const char *in)
|
||||
size_t reslen;
|
||||
|
||||
reslen = strlen(in) + 1;
|
||||
res = malloc(reslen);
|
||||
res = xmalloc(reslen);
|
||||
res[0] = '\0';
|
||||
|
||||
while ((src = strchr(in, '$'))) {
|
||||
@ -893,38 +912,132 @@ const char *sym_expand_string_value(const char *in)
|
||||
return res;
|
||||
}
|
||||
|
||||
const char *sym_escape_string_value(const char *in)
|
||||
{
|
||||
const char *p;
|
||||
size_t reslen;
|
||||
char *res;
|
||||
size_t l;
|
||||
|
||||
reslen = strlen(in) + strlen("\"\"") + 1;
|
||||
|
||||
p = in;
|
||||
for (;;) {
|
||||
l = strcspn(p, "\"\\");
|
||||
p += l;
|
||||
|
||||
if (p[0] == '\0')
|
||||
break;
|
||||
|
||||
reslen++;
|
||||
p++;
|
||||
}
|
||||
|
||||
res = xmalloc(reslen);
|
||||
res[0] = '\0';
|
||||
|
||||
strcat(res, "\"");
|
||||
|
||||
p = in;
|
||||
for (;;) {
|
||||
l = strcspn(p, "\"\\");
|
||||
strncat(res, p, l);
|
||||
p += l;
|
||||
|
||||
if (p[0] == '\0')
|
||||
break;
|
||||
|
||||
strcat(res, "\\");
|
||||
strncat(res, p++, 1);
|
||||
}
|
||||
|
||||
strcat(res, "\"");
|
||||
return res;
|
||||
}
|
||||
|
||||
struct sym_match {
|
||||
struct symbol *sym;
|
||||
off_t so, eo;
|
||||
};
|
||||
|
||||
/* Compare matched symbols as thus:
|
||||
* - first, symbols that match exactly
|
||||
* - then, alphabetical sort
|
||||
*/
|
||||
static int sym_rel_comp(const void *sym1, const void *sym2)
|
||||
{
|
||||
const struct sym_match *s1 = sym1;
|
||||
const struct sym_match *s2 = sym2;
|
||||
int exact1, exact2;
|
||||
|
||||
/* Exact match:
|
||||
* - if matched length on symbol s1 is the length of that symbol,
|
||||
* then this symbol should come first;
|
||||
* - if matched length on symbol s2 is the length of that symbol,
|
||||
* then this symbol should come first.
|
||||
* Note: since the search can be a regexp, both symbols may match
|
||||
* exactly; if this is the case, we can't decide which comes first,
|
||||
* and we fallback to sorting alphabetically.
|
||||
*/
|
||||
exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
|
||||
exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
|
||||
if (exact1 && !exact2)
|
||||
return -1;
|
||||
if (!exact1 && exact2)
|
||||
return 1;
|
||||
|
||||
/* As a fallback, sort symbols alphabetically */
|
||||
return strcmp(s1->sym->name, s2->sym->name);
|
||||
}
|
||||
|
||||
struct symbol **sym_re_search(const char *pattern)
|
||||
{
|
||||
struct symbol *sym, **sym_arr = NULL;
|
||||
struct sym_match *sym_match_arr = NULL;
|
||||
int i, cnt, size;
|
||||
regex_t re;
|
||||
regmatch_t match[1];
|
||||
|
||||
cnt = size = 0;
|
||||
/* Skip if empty */
|
||||
if (strlen(pattern) == 0)
|
||||
return NULL;
|
||||
if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
|
||||
if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
|
||||
return NULL;
|
||||
|
||||
for_all_symbols(i, sym) {
|
||||
if (sym->flags & SYMBOL_CONST || !sym->name)
|
||||
continue;
|
||||
if (regexec(&re, sym->name, 0, NULL, 0))
|
||||
if (regexec(&re, sym->name, 1, match, 0))
|
||||
continue;
|
||||
if (cnt + 1 >= size) {
|
||||
void *tmp = sym_arr;
|
||||
if (cnt >= size) {
|
||||
void *tmp;
|
||||
size += 16;
|
||||
sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
|
||||
if (!sym_arr) {
|
||||
free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
|
||||
if (!tmp)
|
||||
goto sym_re_search_free;
|
||||
sym_match_arr = tmp;
|
||||
}
|
||||
sym_calc_value(sym);
|
||||
sym_arr[cnt++] = sym;
|
||||
/* As regexec returned 0, we know we have a match, so
|
||||
* we can use match[0].rm_[se]o without further checks
|
||||
*/
|
||||
sym_match_arr[cnt].so = match[0].rm_so;
|
||||
sym_match_arr[cnt].eo = match[0].rm_eo;
|
||||
sym_match_arr[cnt++].sym = sym;
|
||||
}
|
||||
if (sym_arr)
|
||||
if (sym_match_arr) {
|
||||
qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
|
||||
sym_arr = malloc((cnt+1) * sizeof(struct symbol));
|
||||
if (!sym_arr)
|
||||
goto sym_re_search_free;
|
||||
for (i = 0; i < cnt; i++)
|
||||
sym_arr[i] = sym_match_arr[i].sym;
|
||||
sym_arr[cnt] = NULL;
|
||||
}
|
||||
sym_re_search_free:
|
||||
/* sym_match_arr can be NULL if no match, but free(NULL) is OK */
|
||||
free(sym_match_arr);
|
||||
regfree(&re);
|
||||
|
||||
return sym_arr;
|
||||
@ -934,7 +1047,7 @@ struct symbol **sym_re_search(const char *pattern)
|
||||
* When we check for recursive dependencies we use a stack to save
|
||||
* current state so we can print out relevant info to user.
|
||||
* The entries are located on the call stack so no need to free memory.
|
||||
* Note inser() remove() must always match to properly clear the stack.
|
||||
* Note insert() remove() must always match to properly clear the stack.
|
||||
*/
|
||||
static struct dep_stack {
|
||||
struct dep_stack *prev, *next;
|
||||
@ -1053,6 +1166,10 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
|
||||
case E_NOT:
|
||||
return sym_check_expr_deps(e->left.expr);
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
case E_LEQ:
|
||||
case E_LTH:
|
||||
case E_UNEQUAL:
|
||||
sym = sym_check_deps(e->left.sym);
|
||||
if (sym)
|
||||
@ -1178,7 +1295,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
|
||||
struct property *prop;
|
||||
struct property **propp;
|
||||
|
||||
prop = malloc(sizeof(*prop));
|
||||
prop = xmalloc(sizeof(*prop));
|
||||
memset(prop, 0, sizeof(*prop));
|
||||
prop->type = type;
|
||||
prop->sym = sym;
|
||||
@ -1255,4 +1372,6 @@ static void prop_add_env(const char *env)
|
||||
p = getenv(env);
|
||||
if (p)
|
||||
sym_add_default(sym, p);
|
||||
else
|
||||
menu_warn(current_entry, "environment variable %s undefined", env);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
* Released under the terms of the GNU GPL v2.0.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "lkc.h"
|
||||
|
||||
@ -21,7 +23,7 @@ struct file *file_lookup(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
file = malloc(sizeof(*file));
|
||||
file = xmalloc(sizeof(*file));
|
||||
memset(file, 0, sizeof(*file));
|
||||
file->name = file_name;
|
||||
file->next = file_list;
|
||||
@ -79,23 +81,13 @@ int file_write_dep(const char *name)
|
||||
struct gstr str_new(void)
|
||||
{
|
||||
struct gstr gs;
|
||||
gs.s = malloc(sizeof(char) * 64);
|
||||
gs.s = xmalloc(sizeof(char) * 64);
|
||||
gs.len = 64;
|
||||
gs.max_width = 0;
|
||||
strcpy(gs.s, "\0");
|
||||
return gs;
|
||||
}
|
||||
|
||||
/* Allocate and assign growable string */
|
||||
struct gstr str_assign(const char *s)
|
||||
{
|
||||
struct gstr gs;
|
||||
gs.s = strdup(s);
|
||||
gs.len = strlen(s) + 1;
|
||||
gs.max_width = 0;
|
||||
return gs;
|
||||
}
|
||||
|
||||
/* Free storage for growable string */
|
||||
void str_free(struct gstr *gs)
|
||||
{
|
||||
@ -136,3 +128,20 @@ const char *str_get(struct gstr *gs)
|
||||
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);
|
||||
}
|
||||
|
@ -7,18 +7,9 @@
|
||||
%pic
|
||||
%struct-type
|
||||
|
||||
%{
|
||||
# ifndef offsetof
|
||||
# include <stddef.h>
|
||||
# ifndef offsetof
|
||||
# define offsetof(st, m) ((size_t)(&((st *)0)->m))
|
||||
# endif
|
||||
# endif
|
||||
%}
|
||||
|
||||
struct kconf_id;
|
||||
|
||||
static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
|
||||
static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
|
||||
|
||||
%%
|
||||
mainmenu, T_MAINMENU, TF_COMMAND
|
||||
@ -53,4 +44,5 @@ on, T_ON, TF_PARAM
|
||||
modules, T_OPT_MODULES, TF_OPTION
|
||||
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
|
||||
env, T_OPT_ENV, TF_OPTION
|
||||
allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION
|
||||
%%
|
||||
|
@ -1,5 +1,5 @@
|
||||
%option backup nostdinit noyywrap never-interactive full ecs
|
||||
%option 8bit backup nodefault perf-report perf-report
|
||||
%option nostdinit noyywrap never-interactive full ecs
|
||||
%option 8bit nodefault perf-report perf-report
|
||||
%option noinput
|
||||
%x COMMAND HELP STRING PARAM
|
||||
%{
|
||||
@ -14,7 +14,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
#define START_STRSIZE 16
|
||||
@ -28,8 +27,8 @@ static char *text;
|
||||
static int text_size, text_asize;
|
||||
|
||||
struct buffer {
|
||||
struct buffer *parent;
|
||||
YY_BUFFER_STATE state;
|
||||
struct buffer *parent;
|
||||
YY_BUFFER_STATE state;
|
||||
};
|
||||
|
||||
struct buffer *current_buf;
|
||||
@ -41,7 +40,7 @@ static void zconf_endfile(void);
|
||||
|
||||
static void new_string(void)
|
||||
{
|
||||
text = malloc(START_STRSIZE);
|
||||
text = xmalloc(START_STRSIZE);
|
||||
text_asize = START_STRSIZE;
|
||||
text_size = 0;
|
||||
*text = 0;
|
||||
@ -63,13 +62,12 @@ static void append_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);
|
||||
text[size] = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
ws [ \n\t]
|
||||
n [A-Za-z0-9_]
|
||||
|
||||
%%
|
||||
@ -96,7 +94,7 @@ n [A-Za-z0-9_]
|
||||
|
||||
<COMMAND>{
|
||||
{n}+ {
|
||||
struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
BEGIN(PARAM);
|
||||
current_pos.file = current_file;
|
||||
current_pos.lineno = current_file->lineno;
|
||||
@ -124,6 +122,10 @@ n [A-Za-z0-9_]
|
||||
"!" return T_NOT;
|
||||
"=" return T_EQUAL;
|
||||
"!=" return T_UNEQUAL;
|
||||
"<=" return T_LESS_EQUAL;
|
||||
">=" return T_GREATER_EQUAL;
|
||||
"<" return T_LESS;
|
||||
">" return T_GREATER;
|
||||
\"|\' {
|
||||
str = yytext[0];
|
||||
new_string();
|
||||
@ -132,7 +134,7 @@ n [A-Za-z0-9_]
|
||||
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
|
||||
--- /* ignore */
|
||||
({n}|[-/.])+ {
|
||||
struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
if (id && id->flags & TF_PARAM) {
|
||||
zconflval.id = id;
|
||||
return id->token;
|
||||
@ -143,7 +145,12 @@ n [A-Za-z0-9_]
|
||||
}
|
||||
#.* /* comment */
|
||||
\\\n current_file->lineno++;
|
||||
.
|
||||
[[:blank:]]+
|
||||
. {
|
||||
fprintf(stderr,
|
||||
"%s:%d:warning: ignoring unsupported character '%c'\n",
|
||||
zconf_curname(), zconf_lineno(), *yytext);
|
||||
}
|
||||
<<EOF>> {
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
@ -289,7 +296,7 @@ void zconf_initscan(const char *name)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
current_buf = malloc(sizeof(*current_buf));
|
||||
current_buf = xmalloc(sizeof(*current_buf));
|
||||
memset(current_buf, 0, sizeof(*current_buf));
|
||||
|
||||
current_file = file_lookup(name);
|
||||
@ -300,7 +307,7 @@ void zconf_nextfile(const char *name)
|
||||
{
|
||||
struct file *iter;
|
||||
struct file *file = file_lookup(name);
|
||||
struct buffer *buf = malloc(sizeof(*buf));
|
||||
struct buffer *buf = xmalloc(sizeof(*buf));
|
||||
memset(buf, 0, sizeof(*buf));
|
||||
|
||||
current_buf->state = YY_CURRENT_BUFFER;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define LKC_DIRECT_LINK
|
||||
#include "lkc.h"
|
||||
|
||||
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
||||
@ -25,16 +24,12 @@ extern int zconflex(void);
|
||||
static void zconfprint(const char *err, ...);
|
||||
static void zconf_error(const char *err, ...);
|
||||
static void zconferror(const char *err);
|
||||
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
|
||||
static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
|
||||
|
||||
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
||||
|
||||
static struct menu *current_menu, *current_entry;
|
||||
|
||||
#define YYDEBUG 0
|
||||
#if YYDEBUG
|
||||
#define YYERROR_VERBOSE
|
||||
#endif
|
||||
%}
|
||||
%expect 30
|
||||
|
||||
@ -45,7 +40,7 @@ static struct menu *current_menu, *current_entry;
|
||||
struct symbol *symbol;
|
||||
struct expr *expr;
|
||||
struct menu *menu;
|
||||
struct kconf_id *id;
|
||||
const struct kconf_id *id;
|
||||
}
|
||||
|
||||
%token <id>T_MAINMENU
|
||||
@ -74,6 +69,10 @@ static struct menu *current_menu, *current_entry;
|
||||
%token <string> T_WORD
|
||||
%token <string> T_WORD_QUOTE
|
||||
%token T_UNEQUAL
|
||||
%token T_LESS
|
||||
%token T_LESS_EQUAL
|
||||
%token T_GREATER
|
||||
%token T_GREATER_EQUAL
|
||||
%token T_CLOSE_PAREN
|
||||
%token T_OPEN_PAREN
|
||||
%token T_EOL
|
||||
@ -81,6 +80,7 @@ static struct menu *current_menu, *current_entry;
|
||||
%left T_OR
|
||||
%left T_AND
|
||||
%left T_EQUAL T_UNEQUAL
|
||||
%left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL
|
||||
%nonassoc T_NOT
|
||||
|
||||
%type <string> prompt
|
||||
@ -229,7 +229,7 @@ symbol_option_list:
|
||||
/* empty */
|
||||
| symbol_option_list T_WORD symbol_option_arg
|
||||
{
|
||||
struct kconf_id *id = kconf_id_lookup($2, strlen($2));
|
||||
const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
|
||||
if (id && id->flags & TF_OPTION)
|
||||
menu_add_option(id->token, $3);
|
||||
else
|
||||
@ -472,6 +472,10 @@ if_expr: /* empty */ { $$ = NULL; }
|
||||
;
|
||||
|
||||
expr: symbol { $$ = expr_alloc_symbol($1); }
|
||||
| symbol T_LESS symbol { $$ = expr_alloc_comp(E_LTH, $1, $3); }
|
||||
| symbol T_LESS_EQUAL symbol { $$ = expr_alloc_comp(E_LEQ, $1, $3); }
|
||||
| symbol T_GREATER symbol { $$ = expr_alloc_comp(E_GTH, $1, $3); }
|
||||
| symbol T_GREATER_EQUAL symbol { $$ = expr_alloc_comp(E_GEQ, $1, $3); }
|
||||
| symbol T_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
|
||||
| symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
|
||||
| T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
|
||||
@ -498,10 +502,7 @@ void conf_parse(const char *name)
|
||||
|
||||
sym_init();
|
||||
_menu_init();
|
||||
modules_sym = sym_lookup(NULL, 0);
|
||||
modules_sym->type = S_BOOLEAN;
|
||||
modules_sym->flags |= SYMBOL_AUTO;
|
||||
rootmenu.prompt = menu_add_prompt(P_MENU, PACKAGE " Configuration", NULL);
|
||||
rootmenu.prompt = menu_add_prompt(P_MENU, "Crosstool-NG Configuration", NULL);
|
||||
|
||||
#if YYDEBUG
|
||||
if (getenv("ZCONF_DEBUG"))
|
||||
@ -510,12 +511,8 @@ void conf_parse(const char *name)
|
||||
zconfparse();
|
||||
if (zconfnerrs)
|
||||
exit(1);
|
||||
if (!modules_sym->prop) {
|
||||
struct property *prop;
|
||||
|
||||
prop = prop_alloc(P_DEFAULT, modules_sym);
|
||||
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
|
||||
}
|
||||
if (!modules_sym)
|
||||
modules_sym = sym_find( "n" );
|
||||
|
||||
rootmenu.prompt->text = _(rootmenu.prompt->text);
|
||||
rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
|
||||
@ -524,7 +521,7 @@ void conf_parse(const char *name)
|
||||
for_all_symbols(i, sym) {
|
||||
if (sym_check_deps(sym))
|
||||
zconfnerrs++;
|
||||
}
|
||||
}
|
||||
if (zconfnerrs)
|
||||
exit(1);
|
||||
sym_set_change_count(1);
|
||||
@ -545,7 +542,7 @@ static const char *zconf_tokenname(int token)
|
||||
return "<token>";
|
||||
}
|
||||
|
||||
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
|
||||
static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken)
|
||||
{
|
||||
if (id->token != endtoken) {
|
||||
zconf_error("unexpected '%s' within %s block",
|
||||
@ -590,9 +587,7 @@ static void zconf_error(const char *err, ...)
|
||||
|
||||
static void zconferror(const char *err)
|
||||
{
|
||||
#if YYDEBUG
|
||||
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_quoted_string(FILE *out, const char *str)
|
||||
@ -741,7 +736,7 @@ void zconfdump(FILE *out)
|
||||
}
|
||||
}
|
||||
|
||||
#include "lex.zconf.c"
|
||||
#include "zconf.lex.c"
|
||||
#include "util.c"
|
||||
#include "confdata.c"
|
||||
#include "expr.c"
|
||||
|
Loading…
x
Reference in New Issue
Block a user