mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-02-21 09:21:52 +00:00
kconfig: Update kconfig. Sync with Linux-4.2
This change updates the kconfig utility to what is shipped with 4.2.0. Signed-off-by: Bryan Hundven <bryanhundven@gmail.com>
This commit is contained in:
parent
74b09f9c4a
commit
0cffa79d9f
@ -8,6 +8,8 @@ config BACKEND
|
|||||||
bool
|
bool
|
||||||
default y if IS_A_BACKEND = "y" || IS_A_BACKEND = "Y"
|
default y if IS_A_BACKEND = "y" || IS_A_BACKEND = "Y"
|
||||||
|
|
||||||
|
if BACKEND
|
||||||
|
|
||||||
config BACKEND_ARCH
|
config BACKEND_ARCH
|
||||||
string
|
string
|
||||||
option env="CT_BACKEND_ARCH"
|
option env="CT_BACKEND_ARCH"
|
||||||
@ -19,3 +21,5 @@ config BACKEND_KERNEL
|
|||||||
config BACKEND_LIBC
|
config BACKEND_LIBC
|
||||||
string
|
string
|
||||||
option env="CT_BACKEND_LIBC"
|
option env="CT_BACKEND_LIBC"
|
||||||
|
|
||||||
|
endif #if BACKEND
|
||||||
|
@ -15,7 +15,7 @@ _ct_ng () {
|
|||||||
start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
|
start_steps=$(echo "${steps}" |sed -r -e 's/($| )/\1+/;')
|
||||||
stop_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
|
defconfig savedefconfig
|
||||||
build build. build-all build-all.
|
build build. build-all build-all.
|
||||||
wiki-samples list-samples list-samples-short check-samples
|
wiki-samples list-samples list-samples-short check-samples
|
||||||
|
3
kconfig/.gitignore
vendored
3
kconfig/.gitignore
vendored
@ -2,7 +2,6 @@ conf
|
|||||||
?conf
|
?conf
|
||||||
**.o
|
**.o
|
||||||
**.dep
|
**.dep
|
||||||
lex.backup
|
zconf.lex.c
|
||||||
lex.zconf.c
|
|
||||||
zconf.hash.c
|
zconf.hash.c
|
||||||
zconf.tab.c
|
zconf.tab.c
|
||||||
|
@ -11,7 +11,7 @@ LDFLAGS =
|
|||||||
|
|
||||||
# Compiler flags to use gettext
|
# Compiler flags to use gettext
|
||||||
ifeq ($(gettext),)
|
ifeq ($(gettext),)
|
||||||
INTL_CFLAGS = -DKBUILD_NO_NLS
|
INTL_CFLAGS = -Wno-format-security -DKBUILD_NO_NLS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Compiler and linker flags to use ncurses
|
# 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|;' >$@
|
@$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MM $< |$(sed) -r -e 's|([^:]+.o)( *:+)|$(<:.c=.o) $@\2|;' >$@
|
||||||
|
|
||||||
# Generate the grammar parser
|
# Generate the grammar parser
|
||||||
zconf.tab.o: 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 lex.zconf.c
|
zconf.tab.dep: zconf.tab.c zconf.hash.c zconf.lex.c
|
||||||
|
|
||||||
.PRECIOUS: zconf.tab.c
|
.PRECIOUS: zconf.tab.c
|
||||||
zconf.tab.c: zconf.y
|
zconf.tab.c: zconf.y
|
||||||
@ -84,9 +84,9 @@ zconf.tab.c: zconf.y
|
|||||||
|
|
||||||
zconf.hash.c: zconf.gperf
|
zconf.hash.c: zconf.gperf
|
||||||
@echo " GPERF '$@'"
|
@echo " GPERF '$@'"
|
||||||
@$(gperf) < $< > $@
|
@$(gperf) -C < $< > $@
|
||||||
|
|
||||||
lex.zconf.c: zconf.l
|
zconf.lex.c: zconf.l
|
||||||
@echo " LEX '$@'"
|
@echo " LEX '$@'"
|
||||||
@flex -L -Pzconf -o$@ $<
|
@flex -L -Pzconf -o$@ $<
|
||||||
|
|
||||||
@ -114,4 +114,4 @@ conf: $(COMMON_OBJ) $(conf_OBJ)
|
|||||||
clean:
|
clean:
|
||||||
@echo " RM 'kconfig'"
|
@echo " RM 'kconfig'"
|
||||||
@rm -f conf mconf nconf $(ALL_OBJS) $(ALL_DEPS)
|
@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
|
#!/bin/sh
|
||||||
# Needed for systems without gettext
|
# 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>
|
#include <libintl.h>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -11,4 +11,3 @@ EOF
|
|||||||
if [ ! "$?" -eq "0" ]; then
|
if [ ! "$?" -eq "0" ]; then
|
||||||
echo -DKBUILD_NO_NLS;
|
echo -DKBUILD_NO_NLS;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
105
kconfig/conf.c
105
kconfig/conf.c
@ -13,12 +13,13 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
static void conf(struct menu *menu);
|
static void conf(struct menu *menu);
|
||||||
static void check_conf(struct menu *menu);
|
static void check_conf(struct menu *menu);
|
||||||
|
static void xfgets(char *str, int size, FILE *in);
|
||||||
|
|
||||||
enum input_mode {
|
enum input_mode {
|
||||||
oldaskconfig,
|
oldaskconfig,
|
||||||
@ -32,12 +33,11 @@ enum input_mode {
|
|||||||
defconfig,
|
defconfig,
|
||||||
savedefconfig,
|
savedefconfig,
|
||||||
listnewconfig,
|
listnewconfig,
|
||||||
oldnoconfig,
|
olddefconfig,
|
||||||
} input_mode = oldaskconfig;
|
} input_mode = oldaskconfig;
|
||||||
|
|
||||||
char *defconfig_file;
|
|
||||||
|
|
||||||
static int indent = 1;
|
static int indent = 1;
|
||||||
|
static int tty_stdio;
|
||||||
static int valid_stdin = 1;
|
static int valid_stdin = 1;
|
||||||
static int sync_kconfig;
|
static int sync_kconfig;
|
||||||
static int conf_cnt;
|
static int conf_cnt;
|
||||||
@ -106,9 +106,12 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
check_stdin();
|
check_stdin();
|
||||||
|
/* fall through */
|
||||||
case oldaskconfig:
|
case oldaskconfig:
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
xfgets(line, 128, stdin);
|
xfgets(line, 128, stdin);
|
||||||
|
if (!tty_stdio)
|
||||||
|
printf("\n");
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -150,6 +153,7 @@ static int conf_string(struct menu *menu)
|
|||||||
def = NULL;
|
def = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
line[strlen(line)-1] = 0;
|
line[strlen(line)-1] = 0;
|
||||||
def = line;
|
def = line;
|
||||||
@ -304,6 +308,7 @@ static int conf_choice(struct menu *menu)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
check_stdin();
|
check_stdin();
|
||||||
|
/* fall through */
|
||||||
case oldaskconfig:
|
case oldaskconfig:
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
xfgets(line, 128, stdin);
|
xfgets(line, 128, stdin);
|
||||||
@ -364,11 +369,12 @@ static void conf(struct menu *menu)
|
|||||||
case P_MENU:
|
case P_MENU:
|
||||||
if ((input_mode == silentoldconfig ||
|
if ((input_mode == silentoldconfig ||
|
||||||
input_mode == listnewconfig ||
|
input_mode == listnewconfig ||
|
||||||
input_mode == oldnoconfig) &&
|
input_mode == olddefconfig) &&
|
||||||
rootEntry != menu) {
|
rootEntry != menu) {
|
||||||
check_conf(menu);
|
check_conf(menu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
case P_COMMENT:
|
case P_COMMENT:
|
||||||
prompt = menu_get_prompt(menu);
|
prompt = menu_get_prompt(menu);
|
||||||
if (prompt)
|
if (prompt)
|
||||||
@ -427,7 +433,7 @@ static void check_conf(struct menu *menu)
|
|||||||
if (sym->name && !sym_is_choice_value(sym)) {
|
if (sym->name && !sym_is_choice_value(sym)) {
|
||||||
printf("%s%s\n", CONFIG_, sym->name);
|
printf("%s%s\n", CONFIG_, sym->name);
|
||||||
}
|
}
|
||||||
} else if (input_mode != oldnoconfig) {
|
} else if (input_mode != olddefconfig) {
|
||||||
if (!conf_cnt++)
|
if (!conf_cnt++)
|
||||||
printf(_("*\n* Restart config...\n*\n"));
|
printf(_("*\n* Restart config...\n*\n"));
|
||||||
rootEntry = menu_get_parent_menu(menu);
|
rootEntry = menu_get_parent_menu(menu);
|
||||||
@ -452,21 +458,34 @@ static struct option long_opts[] = {
|
|||||||
{"alldefconfig", no_argument, NULL, alldefconfig},
|
{"alldefconfig", no_argument, NULL, alldefconfig},
|
||||||
{"randconfig", no_argument, NULL, randconfig},
|
{"randconfig", no_argument, NULL, randconfig},
|
||||||
{"listnewconfig", no_argument, NULL, listnewconfig},
|
{"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}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
const char *progname = av[0];
|
||||||
int opt;
|
int opt;
|
||||||
const char *name;
|
const char *name, *defconfig_file = NULL /* gcc uninit */;
|
||||||
struct stat tmpstat;
|
struct stat tmpstat;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
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;
|
input_mode = (enum input_mode)opt;
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case silentoldconfig:
|
case silentoldconfig:
|
||||||
@ -480,17 +499,36 @@ int main(int ac, char **av)
|
|||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
unsigned int seed;
|
unsigned int seed;
|
||||||
|
char *seed_env;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use microseconds derived seed,
|
* Use microseconds derived seed,
|
||||||
* compensate for systems where it may be zero
|
* compensate for systems where it may be zero
|
||||||
*/
|
*/
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
|
|
||||||
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
|
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);
|
srand(seed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case oldaskconfig:
|
||||||
|
case oldconfig:
|
||||||
|
case allnoconfig:
|
||||||
|
case allyesconfig:
|
||||||
|
case allmodconfig:
|
||||||
|
case alldefconfig:
|
||||||
|
case listnewconfig:
|
||||||
|
case olddefconfig:
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, _("See README for usage info\n"));
|
fprintf(stderr, _("See README for usage info\n"));
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -533,7 +571,7 @@ int main(int ac, char **av)
|
|||||||
case oldaskconfig:
|
case oldaskconfig:
|
||||||
case oldconfig:
|
case oldconfig:
|
||||||
case listnewconfig:
|
case listnewconfig:
|
||||||
case oldnoconfig:
|
case olddefconfig:
|
||||||
conf_read(NULL);
|
conf_read(NULL);
|
||||||
break;
|
break;
|
||||||
case allnoconfig:
|
case allnoconfig:
|
||||||
@ -542,8 +580,15 @@ int main(int ac, char **av)
|
|||||||
case alldefconfig:
|
case alldefconfig:
|
||||||
case randconfig:
|
case randconfig:
|
||||||
name = getenv("KCONFIG_ALLCONFIG");
|
name = getenv("KCONFIG_ALLCONFIG");
|
||||||
if (name && !stat(name, &tmpstat)) {
|
if (!name)
|
||||||
conf_read_simple(name, S_DEF_USER);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
switch (input_mode) {
|
switch (input_mode) {
|
||||||
@ -554,10 +599,13 @@ int main(int ac, char **av)
|
|||||||
case randconfig: name = "allrandom.config"; break;
|
case randconfig: name = "allrandom.config"; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (!stat(name, &tmpstat))
|
if (conf_read_simple(name, S_DEF_USER) &&
|
||||||
conf_read_simple(name, S_DEF_USER);
|
conf_read_simple("all.config", S_DEF_USER)) {
|
||||||
else if (!stat("all.config", &tmpstat))
|
fprintf(stderr,
|
||||||
conf_read_simple("all.config", S_DEF_USER);
|
_("*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n"),
|
||||||
|
name);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -572,7 +620,7 @@ int main(int ac, char **av)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
valid_stdin = isatty(0) && isatty(1) && isatty(2);
|
valid_stdin = tty_stdio;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (input_mode) {
|
switch (input_mode) {
|
||||||
@ -589,7 +637,8 @@ int main(int ac, char **av)
|
|||||||
conf_set_all_new_symbols(def_default);
|
conf_set_all_new_symbols(def_default);
|
||||||
break;
|
break;
|
||||||
case randconfig:
|
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;
|
break;
|
||||||
case defconfig:
|
case defconfig:
|
||||||
conf_set_all_new_symbols(def_default);
|
conf_set_all_new_symbols(def_default);
|
||||||
@ -603,7 +652,7 @@ int main(int ac, char **av)
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
case oldconfig:
|
case oldconfig:
|
||||||
case listnewconfig:
|
case listnewconfig:
|
||||||
case oldnoconfig:
|
case olddefconfig:
|
||||||
case silentoldconfig:
|
case silentoldconfig:
|
||||||
/* Update until a loop caused no more changes */
|
/* Update until a loop caused no more changes */
|
||||||
do {
|
do {
|
||||||
@ -611,7 +660,7 @@ int main(int ac, char **av)
|
|||||||
check_conf(&rootmenu);
|
check_conf(&rootmenu);
|
||||||
} while (conf_cnt &&
|
} while (conf_cnt &&
|
||||||
(input_mode != listnewconfig &&
|
(input_mode != listnewconfig &&
|
||||||
input_mode != oldnoconfig));
|
input_mode != olddefconfig));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,11 +672,15 @@ int main(int ac, char **av)
|
|||||||
fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
|
fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
|
||||||
exit(1);
|
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) {
|
} else if (input_mode == savedefconfig) {
|
||||||
if (conf_write_defconfig(defconfig_file)) {
|
if (conf_write_defconfig(defconfig_file)) {
|
||||||
fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
|
fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"),
|
||||||
defconfig_file);
|
defconfig_file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (input_mode != listnewconfig) {
|
} else if (input_mode != listnewconfig) {
|
||||||
@ -638,13 +691,11 @@ int main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to facilitate fgets() by Jean Sacren.
|
* Helper function to facilitate fgets() by Jean Sacren.
|
||||||
*/
|
*/
|
||||||
void xfgets(str, size, in)
|
void xfgets(char *str, int size, FILE *in)
|
||||||
char *str;
|
|
||||||
int size;
|
|
||||||
FILE *in;
|
|
||||||
{
|
{
|
||||||
if (fgets(str, size, in) == NULL)
|
if (fgets(str, size, in) == NULL)
|
||||||
fprintf(stderr, "\nError in reading or end of file.\n");
|
fprintf(stderr, "\nError in reading or end of file.\n");
|
||||||
|
@ -7,15 +7,20 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#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, ...)
|
static void conf_warning(const char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
@ -59,6 +64,7 @@ static void conf_message(const char *fmt, ...)
|
|||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (conf_message_callback)
|
if (conf_message_callback)
|
||||||
conf_message_callback(fmt, ap);
|
conf_message_callback(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *conf_get_configname(void)
|
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;
|
sym->flags |= def_flags;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
case S_BOOLEAN:
|
case S_BOOLEAN:
|
||||||
if (p[0] == 'y') {
|
if (p[0] == 'y') {
|
||||||
sym->def[def].tri = yes;
|
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;
|
sym->flags |= def_flags;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
|
if (def != S_DEF_AUTO)
|
||||||
break;
|
conf_warning("symbol value '%s' invalid for %s",
|
||||||
|
p, sym->name);
|
||||||
|
return 1;
|
||||||
case S_OTHER:
|
case S_OTHER:
|
||||||
if (*p != '"') {
|
if (*p != '"') {
|
||||||
for (p2 = p; *p2 && !isspace(*p2); p2++)
|
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;
|
sym->type = S_STRING;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
case S_STRING:
|
case S_STRING:
|
||||||
if (*p++ != '"')
|
if (*p++ != '"')
|
||||||
break;
|
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));
|
memmove(p2, p2 + 1, strlen(p2));
|
||||||
}
|
}
|
||||||
if (!p2) {
|
if (!p2) {
|
||||||
conf_warning("invalid string found");
|
if (def != S_DEF_AUTO)
|
||||||
|
conf_warning("invalid string found");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/* fall through */
|
||||||
case S_INT:
|
case S_INT:
|
||||||
case S_HEX:
|
case S_HEX:
|
||||||
done:
|
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->def[def].val = strdup(p);
|
||||||
sym->flags |= def_flags;
|
sym->flags |= def_flags;
|
||||||
} else {
|
} 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;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -179,10 +193,66 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
|||||||
return 0;
|
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)
|
int conf_read_simple(const char *name, int def)
|
||||||
{
|
{
|
||||||
FILE *in = NULL;
|
FILE *in = NULL;
|
||||||
char line[1024];
|
char *line = NULL;
|
||||||
|
size_t line_asize = 0;
|
||||||
char *p, *p2;
|
char *p, *p2;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
int i, def_flags;
|
int i, def_flags;
|
||||||
@ -237,13 +307,14 @@ load:
|
|||||||
case S_STRING:
|
case S_STRING:
|
||||||
if (sym->def[def].val)
|
if (sym->def[def].val)
|
||||||
free(sym->def[def].val);
|
free(sym->def[def].val);
|
||||||
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
sym->def[def].val = NULL;
|
sym->def[def].val = NULL;
|
||||||
sym->def[def].tri = no;
|
sym->def[def].tri = no;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), in)) {
|
while (compat_getline(&line, &line_asize, in) != -1) {
|
||||||
conf_lineno++;
|
conf_lineno++;
|
||||||
sym = NULL;
|
sym = NULL;
|
||||||
if (line[0] == '#') {
|
if (line[0] == '#') {
|
||||||
@ -331,6 +402,7 @@ setsym:
|
|||||||
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
|
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(line);
|
||||||
fclose(in);
|
fclose(in);
|
||||||
|
|
||||||
if (modules_sym)
|
if (modules_sym)
|
||||||
@ -340,10 +412,8 @@ setsym:
|
|||||||
|
|
||||||
int conf_read(const char *name)
|
int conf_read(const char *name)
|
||||||
{
|
{
|
||||||
struct symbol *sym, *choice_sym;
|
struct symbol *sym;
|
||||||
struct property *prop;
|
int i;
|
||||||
struct expr *e;
|
|
||||||
int i, flags;
|
|
||||||
|
|
||||||
sym_set_change_count(0);
|
sym_set_change_count(0);
|
||||||
|
|
||||||
@ -353,7 +423,7 @@ int conf_read(const char *name)
|
|||||||
for_all_symbols(i, sym) {
|
for_all_symbols(i, sym) {
|
||||||
sym_calc_value(sym);
|
sym_calc_value(sym);
|
||||||
if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
|
if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))
|
||||||
goto sym_ok;
|
continue;
|
||||||
if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
|
if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
|
||||||
/* check that calculated value agrees with saved value */
|
/* check that calculated value agrees with saved value */
|
||||||
switch (sym->type) {
|
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))
|
if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
|
||||||
break;
|
break;
|
||||||
if (!sym_is_choice(sym))
|
if (!sym_is_choice(sym))
|
||||||
goto sym_ok;
|
continue;
|
||||||
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
|
if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
|
||||||
goto sym_ok;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
|
} else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
|
||||||
/* no previous value and not saved */
|
/* no previous value and not saved */
|
||||||
goto sym_ok;
|
continue;
|
||||||
conf_unsaved++;
|
conf_unsaved++;
|
||||||
/* maybe print value in verbose mode... */
|
/* 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) {
|
for_all_symbols(i, sym) {
|
||||||
@ -417,64 +476,191 @@ int conf_read(const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write a S_STRING */
|
/*
|
||||||
static void conf_write_string(bool headerfile, const char *name,
|
* Kconfig configuration printer
|
||||||
const char *str, FILE *out)
|
*
|
||||||
|
* 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) {
|
switch (sym->type) {
|
||||||
case S_BOOLEAN:
|
case S_BOOLEAN:
|
||||||
case S_TRISTATE:
|
case S_TRISTATE:
|
||||||
switch (sym_get_tristate_value(sym)) {
|
if (*value == 'n') {
|
||||||
case no:
|
bool skip_unset = (arg != NULL);
|
||||||
if (write_no)
|
|
||||||
fprintf(out, "# %s%s is not set\n",
|
if (!skip_unset)
|
||||||
|
fprintf(fp, "# %s%s is not set\n",
|
||||||
CONFIG_, sym->name);
|
CONFIG_, sym->name);
|
||||||
break;
|
return;
|
||||||
case mod:
|
|
||||||
fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
|
|
||||||
break;
|
|
||||||
case yes:
|
|
||||||
fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case S_STRING:
|
||||||
conf_write_string(false, sym->name, sym_get_string_value(sym), out);
|
|
||||||
break;
|
|
||||||
case S_HEX:
|
|
||||||
case S_INT:
|
case S_INT:
|
||||||
str = sym_get_string_value(sym);
|
fprintf(fp, "#define %s%s %s\n",
|
||||||
fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
|
CONFIG_, sym->name, value);
|
||||||
break;
|
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_OTHER:
|
||||||
case S_UNKNOWN:
|
case S_UNKNOWN:
|
||||||
break;
|
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.
|
* Write out a minimal config.
|
||||||
* All values that has default values are skipped as this is redundant.
|
* 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;
|
goto next_menu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conf_write_symbol(sym, out, true);
|
conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
|
||||||
}
|
}
|
||||||
next_menu:
|
next_menu:
|
||||||
if (menu->list != NULL) {
|
if (menu->list != NULL) {
|
||||||
@ -560,8 +746,6 @@ int conf_write(const char *name)
|
|||||||
const char *basename;
|
const char *basename;
|
||||||
const char *str;
|
const char *str;
|
||||||
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
|
||||||
time_t now;
|
|
||||||
int use_timestamp = 1;
|
|
||||||
char *env;
|
char *env;
|
||||||
|
|
||||||
dirname[0] = 0;
|
dirname[0] = 0;
|
||||||
@ -598,19 +782,7 @@ int conf_write(const char *name)
|
|||||||
if (!out)
|
if (!out)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
time(&now);
|
conf_write_heading(out, &kconfig_printer_cb, NULL);
|
||||||
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) : "");
|
|
||||||
|
|
||||||
if (!conf_get_changed())
|
if (!conf_get_changed())
|
||||||
sym_clear_all_valid();
|
sym_clear_all_valid();
|
||||||
@ -631,8 +803,8 @@ int conf_write(const char *name)
|
|||||||
if (!(sym->flags & SYMBOL_WRITE))
|
if (!(sym->flags & SYMBOL_WRITE))
|
||||||
goto next;
|
goto next;
|
||||||
sym->flags &= ~SYMBOL_WRITE;
|
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:
|
next:
|
||||||
@ -659,7 +831,7 @@ next:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_message(_("configuration saved"));
|
conf_message(_("configuration written to %s"), newname);
|
||||||
|
|
||||||
sym_set_change_count(0);
|
sym_set_change_count(0);
|
||||||
|
|
||||||
@ -781,7 +953,6 @@ out:
|
|||||||
int conf_write_autoconf(void)
|
int conf_write_autoconf(void)
|
||||||
{
|
{
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
const char *str;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
FILE *out, *tristate, *out_h;
|
FILE *out, *tristate, *out_h;
|
||||||
int i;
|
int i;
|
||||||
@ -810,68 +981,23 @@ int conf_write_autoconf(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out, "#\n"
|
conf_write_heading(out, &kconfig_printer_cb, NULL);
|
||||||
"# Automatically generated make config: don't edit\n"
|
|
||||||
"# %s\n"
|
conf_write_heading(tristate, &tristate_printer_cb, NULL);
|
||||||
"#\n",
|
|
||||||
rootmenu.prompt->text);
|
conf_write_heading(out_h, &header_printer_cb, NULL);
|
||||||
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);
|
|
||||||
|
|
||||||
for_all_symbols(i, sym) {
|
for_all_symbols(i, sym) {
|
||||||
sym_calc_value(sym);
|
sym_calc_value(sym);
|
||||||
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
|
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* write symbol to config file */
|
/* write symbol to auto.conf, tristate and header files */
|
||||||
conf_write_symbol(sym, out, false);
|
conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
|
||||||
|
|
||||||
/* update autoconf and tristate files */
|
conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
|
||||||
switch (sym->type) {
|
|
||||||
case S_BOOLEAN:
|
conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fclose(out);
|
fclose(out);
|
||||||
fclose(tristate);
|
fclose(tristate);
|
||||||
@ -925,7 +1051,7 @@ void conf_set_changed_callback(void (*fn)(void))
|
|||||||
conf_changed_callback = fn;
|
conf_changed_callback = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void randomize_choice_values(struct symbol *csym)
|
static bool randomize_choice_values(struct symbol *csym)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
@ -938,7 +1064,7 @@ static void randomize_choice_values(struct symbol *csym)
|
|||||||
* In both cases stop.
|
* In both cases stop.
|
||||||
*/
|
*/
|
||||||
if (csym->curr.tri != yes)
|
if (csym->curr.tri != yes)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
prop = sym_get_choice_prop(csym);
|
prop = sym_get_choice_prop(csym);
|
||||||
|
|
||||||
@ -962,13 +1088,18 @@ static void randomize_choice_values(struct symbol *csym)
|
|||||||
else {
|
else {
|
||||||
sym->def[S_DEF_USER].tri = no;
|
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;
|
csym->flags |= SYMBOL_DEF_USER;
|
||||||
/* clear VALID to get value calculated */
|
/* clear VALID to get value calculated */
|
||||||
csym->flags &= ~(SYMBOL_VALID);
|
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 property *prop;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
@ -985,20 +1116,66 @@ static void set_all_choice_values(struct symbol *csym)
|
|||||||
}
|
}
|
||||||
csym->flags |= SYMBOL_DEF_USER;
|
csym->flags |= SYMBOL_DEF_USER;
|
||||||
/* clear VALID to get value calculated */
|
/* 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;
|
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) {
|
for_all_symbols(i, sym) {
|
||||||
if (sym_has_value(sym))
|
if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
|
||||||
continue;
|
continue;
|
||||||
switch (sym_get_type(sym)) {
|
switch (sym_get_type(sym)) {
|
||||||
case S_BOOLEAN:
|
case S_BOOLEAN:
|
||||||
case S_TRISTATE:
|
case S_TRISTATE:
|
||||||
|
has_changed = true;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case def_yes:
|
case def_yes:
|
||||||
sym->def[S_DEF_USER].tri = 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;
|
sym->def[S_DEF_USER].tri = mod;
|
||||||
break;
|
break;
|
||||||
case def_no:
|
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;
|
break;
|
||||||
case def_random:
|
case def_random:
|
||||||
cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
|
sym->def[S_DEF_USER].tri = no;
|
||||||
sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
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,
|
* selected in a choice block and we set it to yes,
|
||||||
* and the rest to no.
|
* 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) {
|
for_all_symbols(i, csym) {
|
||||||
if (sym_has_value(csym) || !sym_is_choice(csym))
|
if (sym_has_value(csym) || !sym_is_choice(csym))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sym_calc_value(csym);
|
sym_calc_value(csym);
|
||||||
if (mode == def_random)
|
if (mode == def_random)
|
||||||
randomize_choice_values(csym);
|
has_changed = randomize_choice_values(csym);
|
||||||
else
|
else {
|
||||||
set_all_choice_values(csym);
|
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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
#define DEBUG_EXPR 0
|
#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 *expr_alloc_symbol(struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct expr *e = malloc(sizeof(*e));
|
struct expr *e = xcalloc(1, sizeof(*e));
|
||||||
memset(e, 0, sizeof(*e));
|
|
||||||
e->type = E_SYMBOL;
|
e->type = E_SYMBOL;
|
||||||
e->left.sym = sym;
|
e->left.sym = sym;
|
||||||
return e;
|
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 *expr_alloc_one(enum expr_type type, struct expr *ce)
|
||||||
{
|
{
|
||||||
struct expr *e = malloc(sizeof(*e));
|
struct expr *e = xcalloc(1, sizeof(*e));
|
||||||
memset(e, 0, sizeof(*e));
|
|
||||||
e->type = type;
|
e->type = type;
|
||||||
e->left.expr = ce;
|
e->left.expr = ce;
|
||||||
return e;
|
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 *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2)
|
||||||
{
|
{
|
||||||
struct expr *e = malloc(sizeof(*e));
|
struct expr *e = xcalloc(1, sizeof(*e));
|
||||||
memset(e, 0, sizeof(*e));
|
|
||||||
e->type = type;
|
e->type = type;
|
||||||
e->left.expr = e1;
|
e->left.expr = e1;
|
||||||
e->right.expr = e2;
|
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 *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2)
|
||||||
{
|
{
|
||||||
struct expr *e = malloc(sizeof(*e));
|
struct expr *e = xcalloc(1, sizeof(*e));
|
||||||
memset(e, 0, sizeof(*e));
|
|
||||||
e->type = type;
|
e->type = type;
|
||||||
e->left.sym = s1;
|
e->left.sym = s1;
|
||||||
e->right.sym = s2;
|
e->right.sym = s2;
|
||||||
@ -71,7 +69,7 @@ struct expr *expr_copy(const struct expr *org)
|
|||||||
if (!org)
|
if (!org)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
e = malloc(sizeof(*org));
|
e = xmalloc(sizeof(*org));
|
||||||
memcpy(e, org, sizeof(*org));
|
memcpy(e, org, sizeof(*org));
|
||||||
switch (org->type) {
|
switch (org->type) {
|
||||||
case E_SYMBOL:
|
case E_SYMBOL:
|
||||||
@ -81,6 +79,10 @@ struct expr *expr_copy(const struct expr *org)
|
|||||||
e->left.expr = expr_copy(org->left.expr);
|
e->left.expr = expr_copy(org->left.expr);
|
||||||
break;
|
break;
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
e->left.sym = org->left.sym;
|
e->left.sym = org->left.sym;
|
||||||
e->right.sym = org->right.sym;
|
e->right.sym = org->right.sym;
|
||||||
@ -113,6 +115,10 @@ void expr_free(struct expr *e)
|
|||||||
expr_free(e->left.expr);
|
expr_free(e->left.expr);
|
||||||
return;
|
return;
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
break;
|
break;
|
||||||
case E_OR:
|
case E_OR:
|
||||||
@ -191,7 +197,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
|||||||
#undef e1
|
#undef e1
|
||||||
#undef e2
|
#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;
|
int res, old_count;
|
||||||
|
|
||||||
@ -199,6 +205,10 @@ int expr_eq(struct expr *e1, struct expr *e2)
|
|||||||
return 0;
|
return 0;
|
||||||
switch (e1->type) {
|
switch (e1->type) {
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
|
return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym;
|
||||||
case E_SYMBOL:
|
case E_SYMBOL:
|
||||||
@ -233,7 +243,7 @@ int expr_eq(struct expr *e1, struct expr *e2)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct expr *expr_eliminate_yn(struct expr *e)
|
static struct expr *expr_eliminate_yn(struct expr *e)
|
||||||
{
|
{
|
||||||
struct expr *tmp;
|
struct expr *tmp;
|
||||||
|
|
||||||
@ -558,62 +568,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
|
|||||||
#undef e2
|
#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)
|
struct expr *expr_eliminate_dups(struct expr *e)
|
||||||
{
|
{
|
||||||
int oldcount;
|
int oldcount;
|
||||||
@ -626,7 +580,6 @@ struct expr *expr_eliminate_dups(struct expr *e)
|
|||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case E_OR: case E_AND:
|
case E_OR: case E_AND:
|
||||||
expr_eliminate_dups1(e->type, &e, &e);
|
expr_eliminate_dups1(e->type, &e, &e);
|
||||||
expr_eliminate_dups2(e->type, &e, &e);
|
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -646,6 +599,10 @@ struct expr *expr_transform(struct expr *e)
|
|||||||
return NULL;
|
return NULL;
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
case E_SYMBOL:
|
case E_SYMBOL:
|
||||||
case E_LIST:
|
case E_LIST:
|
||||||
@ -718,6 +675,22 @@ struct expr *expr_transform(struct expr *e)
|
|||||||
e = tmp;
|
e = tmp;
|
||||||
e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
|
e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL;
|
||||||
break;
|
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:
|
case E_OR:
|
||||||
// !(a || b) -> !a && !b
|
// !(a || b) -> !a && !b
|
||||||
tmp = e->left.expr;
|
tmp = e->left.expr;
|
||||||
@ -788,6 +761,10 @@ int expr_contains_symbol(struct expr *dep, struct symbol *sym)
|
|||||||
case E_SYMBOL:
|
case E_SYMBOL:
|
||||||
return dep->left.sym == sym;
|
return dep->left.sym == sym;
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
return dep->left.sym == sym ||
|
return dep->left.sym == sym ||
|
||||||
dep->right.sym == sym;
|
dep->right.sym == sym;
|
||||||
@ -828,57 +805,6 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
|
|||||||
return false;
|
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 *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct expr *e1, *e2;
|
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:
|
case E_NOT:
|
||||||
return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
|
return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym);
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
|
case E_LTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_GEQ:
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
if (type == E_EQUAL) {
|
if (type == E_EQUAL) {
|
||||||
if (sym == &symbol_yes)
|
if (sym == &symbol_yes)
|
||||||
@ -940,10 +870,57 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
|
|||||||
return NULL;
|
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 expr_calc_value(struct expr *e)
|
||||||
{
|
{
|
||||||
tristate val1, val2;
|
tristate val1, val2;
|
||||||
const char *str1, *str2;
|
const char *str1, *str2;
|
||||||
|
enum string_value_kind k1 = k_string, k2 = k_string;
|
||||||
|
union string_value lval = {}, rval = {};
|
||||||
|
int res;
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
return yes;
|
return yes;
|
||||||
@ -964,31 +941,70 @@ tristate expr_calc_value(struct expr *e)
|
|||||||
val1 = expr_calc_value(e->left.expr);
|
val1 = expr_calc_value(e->left.expr);
|
||||||
return EXPR_NOT(val1);
|
return EXPR_NOT(val1);
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
sym_calc_value(e->left.sym);
|
case E_GEQ:
|
||||||
sym_calc_value(e->right.sym);
|
case E_GTH:
|
||||||
str1 = sym_get_string_value(e->left.sym);
|
case E_LEQ:
|
||||||
str2 = sym_get_string_value(e->right.sym);
|
case E_LTH:
|
||||||
return !strcmp(str1, str2) ? yes : no;
|
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
sym_calc_value(e->left.sym);
|
break;
|
||||||
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;
|
|
||||||
default:
|
default:
|
||||||
printf("expr_calc_value: %d?\n", e->type);
|
printf("expr_calc_value: %d?\n", e->type);
|
||||||
return no;
|
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)
|
if (t1 == t2)
|
||||||
return 0;
|
return 0;
|
||||||
switch (t1) {
|
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_EQUAL:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
if (t2 == E_NOT)
|
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);
|
printf("[%dgt%d?]", t1, t2);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct expr *
|
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, NULL, "=");
|
||||||
fn(data, e->right.sym, e->right.sym->name);
|
fn(data, e->right.sym, e->right.sym->name);
|
||||||
break;
|
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:
|
case E_UNEQUAL:
|
||||||
if (e->left.sym->name)
|
if (e->left.sym->name)
|
||||||
fn(data, e->left.sym, e->left.sym->name);
|
fn(data, e->left.sym, e->left.sym->name);
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "list.h"
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
@ -27,7 +29,9 @@ typedef enum tristate {
|
|||||||
} tristate;
|
} tristate;
|
||||||
|
|
||||||
enum expr_type {
|
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 {
|
union expr_data {
|
||||||
@ -91,7 +95,7 @@ struct symbol {
|
|||||||
#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
|
#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */
|
||||||
#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
|
#define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */
|
||||||
#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
|
#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_CHANGED 0x0400 /* ? */
|
||||||
#define SYMBOL_AUTO 0x1000 /* value from environment variable */
|
#define SYMBOL_AUTO 0x1000 /* value from environment variable */
|
||||||
#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
|
#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_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
|
||||||
#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] 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_MAXLENGTH 256
|
||||||
#define SYMBOL_HASHSIZE 9973
|
#define SYMBOL_HASHSIZE 9973
|
||||||
|
|
||||||
@ -172,7 +182,14 @@ struct menu {
|
|||||||
#define MENU_CHANGED 0x0001
|
#define MENU_CHANGED 0x0001
|
||||||
#define MENU_ROOT 0x0002
|
#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 *file_list;
|
||||||
extern struct file *current_file;
|
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_alloc_or(struct expr *e1, struct expr *e2);
|
||||||
struct expr *expr_copy(const struct expr *org);
|
struct expr *expr_copy(const struct expr *org);
|
||||||
void expr_free(struct expr *e);
|
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);
|
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
|
||||||
tristate expr_calc_value(struct expr *e);
|
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_trans_bool(struct expr *e);
|
||||||
struct expr *expr_eliminate_dups(struct expr *e);
|
struct expr *expr_eliminate_dups(struct expr *e);
|
||||||
struct expr *expr_transform(struct expr *e);
|
struct expr *expr_transform(struct expr *e);
|
||||||
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
|
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
|
||||||
bool expr_depends_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_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
|
||||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
|
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);
|
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,11 @@ PHONY += $(configurators)
|
|||||||
|
|
||||||
$(configurators): config_files
|
$(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
|
# We need CONF for savedefconfig in scripts/saveSample.sh
|
||||||
export CONF := $(CT_LIB_DIR)/kconfig/conf
|
export CONF := $(CT_LIB_DIR)/kconfig/conf
|
||||||
MCONF := $(CT_LIB_DIR)/kconfig/mconf
|
MCONF := $(CT_LIB_DIR)/kconfig/mconf
|
||||||
@ -55,6 +60,7 @@ extractconfig:
|
|||||||
|
|
||||||
help-config::
|
help-config::
|
||||||
@echo ' menuconfig - Update current config using a menu based program'
|
@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 ' oldconfig - Update current config using a provided .config as base'
|
||||||
@echo ' extractconfig - Extract to stdout the configuration items from a'
|
@echo ' extractconfig - Extract to stdout the configuration items from a'
|
||||||
@echo ' build.log file piped to stdin'
|
@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" {
|
extern "C" {
|
||||||
#endif
|
#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"
|
#include "lkc_proto.h"
|
||||||
#undef P
|
|
||||||
|
|
||||||
#define SRCTREE "srctree"
|
#define SRCTREE "srctree"
|
||||||
|
|
||||||
@ -44,6 +37,12 @@ extern "C" {
|
|||||||
#ifndef CONFIG_
|
#ifndef CONFIG_
|
||||||
#define CONFIG_ "CONFIG_"
|
#define CONFIG_ "CONFIG_"
|
||||||
#endif
|
#endif
|
||||||
|
static inline const char *CONFIG_prefix(void)
|
||||||
|
{
|
||||||
|
return getenv( "CONFIG_" ) ?: CONFIG_;
|
||||||
|
}
|
||||||
|
#undef CONFIG_
|
||||||
|
#define CONFIG_ CONFIG_prefix()
|
||||||
|
|
||||||
#define TF_COMMAND 0x0001
|
#define TF_COMMAND 0x0001
|
||||||
#define TF_PARAM 0x0002
|
#define TF_PARAM 0x0002
|
||||||
@ -60,6 +59,7 @@ enum conf_def_mode {
|
|||||||
#define T_OPT_MODULES 1
|
#define T_OPT_MODULES 1
|
||||||
#define T_OPT_DEFCONFIG_LIST 2
|
#define T_OPT_DEFCONFIG_LIST 2
|
||||||
#define T_OPT_ENV 3
|
#define T_OPT_ENV 3
|
||||||
|
#define T_OPT_ALLNOCONFIG_Y 4
|
||||||
|
|
||||||
struct kconf_id {
|
struct kconf_id {
|
||||||
int name;
|
int name;
|
||||||
@ -68,11 +68,6 @@ struct kconf_id {
|
|||||||
enum symbol_type stype;
|
enum symbol_type stype;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef YYDEBUG
|
|
||||||
extern int zconfdebug;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int zconfparse(void);
|
|
||||||
void zconfdump(FILE *out);
|
void zconfdump(FILE *out);
|
||||||
void zconf_starthelp(void);
|
void zconf_starthelp(void);
|
||||||
FILE *zconf_fopen(const char *name);
|
FILE *zconf_fopen(const char *name);
|
||||||
@ -81,26 +76,23 @@ void zconf_nextfile(const char *name);
|
|||||||
int zconf_lineno(void);
|
int zconf_lineno(void);
|
||||||
const char *zconf_curname(void);
|
const char *zconf_curname(void);
|
||||||
|
|
||||||
/* conf.c */
|
|
||||||
void xfgets(char *str, int size, FILE *in);
|
|
||||||
|
|
||||||
/* confdata.c */
|
/* confdata.c */
|
||||||
const char *conf_get_configname(void);
|
const char *conf_get_configname(void);
|
||||||
const char *conf_get_autoconfig_name(void);
|
const char *conf_get_autoconfig_name(void);
|
||||||
char *conf_get_default_confname(void);
|
char *conf_get_default_confname(void);
|
||||||
void sym_set_change_count(int count);
|
void sym_set_change_count(int count);
|
||||||
void sym_add_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 */
|
/* confdata.c and expr.c */
|
||||||
static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
|
static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
|
||||||
{
|
{
|
||||||
if (fwrite(str, len, count, out) < count)
|
assert(len != 0);
|
||||||
fprintf(stderr, "\nError in writing or end of file.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* kconfig_load.c */
|
if (fwrite(str, len, count, out) != count)
|
||||||
void kconfig_load(void);
|
fprintf(stderr, "Error in writing or end of file.\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* menu.c */
|
/* menu.c */
|
||||||
void _menu_init(void);
|
void _menu_init(void);
|
||||||
@ -111,7 +103,6 @@ void menu_add_entry(struct symbol *sym);
|
|||||||
void menu_end_entry(void);
|
void menu_end_entry(void);
|
||||||
void menu_add_dep(struct expr *dep);
|
void menu_add_dep(struct expr *dep);
|
||||||
void menu_add_visibility(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);
|
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_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);
|
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 */
|
/* util.c */
|
||||||
struct file *file_lookup(const char *name);
|
struct file *file_lookup(const char *name);
|
||||||
int file_write_dep(const char *name);
|
int file_write_dep(const char *name);
|
||||||
|
void *xmalloc(size_t size);
|
||||||
|
void *xcalloc(size_t nmemb, size_t size);
|
||||||
|
|
||||||
struct gstr {
|
struct gstr {
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -133,7 +126,6 @@ struct gstr {
|
|||||||
int max_width;
|
int max_width;
|
||||||
};
|
};
|
||||||
struct gstr str_new(void);
|
struct gstr str_new(void);
|
||||||
struct gstr str_assign(const char *s);
|
|
||||||
void str_free(struct gstr *gs);
|
void str_free(struct gstr *gs);
|
||||||
void str_append(struct gstr *gs, const char *s);
|
void str_append(struct gstr *gs, const char *s);
|
||||||
void str_printf(struct gstr *gs, const char *fmt, ...);
|
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_init(void);
|
||||||
void sym_clear_all_valid(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);
|
struct symbol *sym_choice_default(struct symbol *sym);
|
||||||
const char *sym_get_string_default(struct symbol *sym);
|
const char *sym_get_string_default(struct symbol *sym);
|
||||||
struct symbol *sym_check_deps(struct symbol *sym);
|
struct symbol *sym_check_deps(struct symbol *sym);
|
||||||
|
@ -1,53 +1,52 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* confdata.c */
|
/* confdata.c */
|
||||||
P(conf_parse,void,(const char *name));
|
void conf_parse(const char *name);
|
||||||
P(conf_read,int,(const char *name));
|
int conf_read(const char *name);
|
||||||
P(conf_read_simple,int,(const char *name, int));
|
int conf_read_simple(const char *name, int);
|
||||||
P(conf_write_defconfig,int,(const char *name));
|
int conf_write_defconfig(const char *name);
|
||||||
P(conf_write,int,(const char *name));
|
int conf_write(const char *name);
|
||||||
P(conf_write_autoconf,int,(void));
|
int conf_write_autoconf(void);
|
||||||
P(conf_get_changed,bool,(void));
|
bool conf_get_changed(void);
|
||||||
P(conf_set_changed_callback, void,(void (*fn)(void)));
|
void conf_set_changed_callback(void (*fn)(void));
|
||||||
P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
|
void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap));
|
||||||
|
|
||||||
/* menu.c */
|
/* menu.c */
|
||||||
P(rootmenu,struct menu,);
|
extern struct menu rootmenu;
|
||||||
|
|
||||||
P(menu_is_visible, bool, (struct menu *menu));
|
bool menu_is_empty(struct menu *menu);
|
||||||
P(menu_has_prompt, bool, (struct menu *menu));
|
bool menu_is_visible(struct menu *menu);
|
||||||
P(menu_get_prompt,const char *,(struct menu *menu));
|
bool menu_has_prompt(struct menu *menu);
|
||||||
P(menu_get_root_menu,struct menu *,(struct menu *menu));
|
const char * menu_get_prompt(struct menu *menu);
|
||||||
P(menu_get_parent_menu,struct menu *,(struct menu *menu));
|
struct menu * menu_get_root_menu(struct menu *menu);
|
||||||
P(menu_has_help,bool,(struct menu *menu));
|
struct menu * menu_get_parent_menu(struct menu *menu);
|
||||||
P(menu_get_help,const char *,(struct menu *menu));
|
bool menu_has_help(struct menu *menu);
|
||||||
P(get_symbol_str, void, (struct gstr *r, struct symbol *sym));
|
const char * menu_get_help(struct menu *menu);
|
||||||
P(get_relations_str, struct gstr, (struct symbol **sym_arr));
|
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
|
||||||
P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
|
void menu_get_ext_help(struct menu *menu, struct gstr *help);
|
||||||
|
|
||||||
/* symbol.c */
|
/* 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));
|
struct symbol * sym_lookup(const char *name, int flags);
|
||||||
P(sym_find,struct symbol *,(const char *name));
|
struct symbol * sym_find(const char *name);
|
||||||
P(sym_expand_string_value,const char *,(const char *in));
|
const char * sym_expand_string_value(const char *in);
|
||||||
P(sym_re_search,struct symbol **,(const char *pattern));
|
const char * sym_escape_string_value(const char *in);
|
||||||
P(sym_type_name,const char *,(enum symbol_type type));
|
struct symbol ** sym_re_search(const char *pattern);
|
||||||
P(sym_calc_value,void,(struct symbol *sym));
|
const char * sym_type_name(enum symbol_type type);
|
||||||
P(sym_get_type,enum symbol_type,(struct symbol *sym));
|
void sym_calc_value(struct symbol *sym);
|
||||||
P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
|
enum symbol_type sym_get_type(struct symbol *sym);
|
||||||
P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
|
bool sym_tristate_within_range(struct symbol *sym,tristate tri);
|
||||||
P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
|
bool sym_set_tristate_value(struct symbol *sym,tristate tri);
|
||||||
P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
|
tristate sym_toggle_tristate_value(struct symbol *sym);
|
||||||
P(sym_string_within_range,bool,(struct symbol *sym, const char *str));
|
bool sym_string_valid(struct symbol *sym, const char *newval);
|
||||||
P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
|
bool sym_string_within_range(struct symbol *sym, const char *str);
|
||||||
P(sym_is_changable,bool,(struct symbol *sym));
|
bool sym_set_string_value(struct symbol *sym, const char *newval);
|
||||||
P(sym_get_choice_prop,struct property *,(struct symbol *sym));
|
bool sym_is_changable(struct symbol *sym);
|
||||||
P(sym_get_default_prop,struct property *,(struct symbol *sym));
|
struct property * sym_get_choice_prop(struct symbol *sym);
|
||||||
P(sym_get_string_value,const char *,(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 */
|
/* expr.c */
|
||||||
P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
|
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken);
|
||||||
P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken));
|
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
# What library to link
|
# What library to link
|
||||||
ldflags()
|
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
|
for lib in ncursesw ncurses curses ; do
|
||||||
$cc -print-file-name=lib${lib}.${ext} | grep -q /
|
$cc -print-file-name=lib${lib}.${ext} | grep -q /
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
@ -19,12 +21,17 @@ ldflags()
|
|||||||
# Where is ncurses.h?
|
# Where is ncurses.h?
|
||||||
ccflags()
|
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>"'
|
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
|
||||||
elif [ -f /usr/include/ncurses/curses.h ]; then
|
elif [ -f /usr/include/ncurses/curses.h ]; then
|
||||||
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
|
echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
|
||||||
elif [ -f /usr/include/ncursesw/curses.h ]; then
|
|
||||||
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
|
|
||||||
elif [ -f /usr/include/ncurses.h ]; then
|
elif [ -f /usr/include/ncurses.h ]; then
|
||||||
echo '-DCURSES_LOC="<ncurses.h>"'
|
echo '-DCURSES_LOC="<ncurses.h>"'
|
||||||
else
|
else
|
||||||
@ -38,7 +45,7 @@ trap "rm -f $tmp" 0 1 2 3 15
|
|||||||
|
|
||||||
# Check if we can link to ncurses
|
# Check if we can link to ncurses
|
||||||
check() {
|
check() {
|
||||||
$cc -xc - -o $tmp 2>/dev/null <<'EOF'
|
$cc -x c - -o $tmp 2>/dev/null <<'EOF'
|
||||||
#include CURSES_LOC
|
#include CURSES_LOC
|
||||||
main() {}
|
main() {}
|
||||||
EOF
|
EOF
|
||||||
|
@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
do_resize:
|
do_resize:
|
||||||
if (getmaxy(stdscr) < (height + 6))
|
if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
if (getmaxx(stdscr) < (width + 6))
|
if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
|
|
||||||
max_choice = MIN(list_height, item_count());
|
max_choice = MIN(list_height, item_count());
|
||||||
|
|
||||||
/* center dialog box on screen */
|
/* center dialog box on screen */
|
||||||
x = (COLS - width) / 2;
|
x = (getmaxx(stdscr) - width) / 2;
|
||||||
y = (LINES - height) / 2;
|
y = (getmaxy(stdscr) - height) / 2;
|
||||||
|
|
||||||
draw_shadow(stdscr, y, x, height, width);
|
draw_shadow(stdscr, y, x, height, width);
|
||||||
|
|
||||||
@ -168,13 +168,13 @@ do_resize:
|
|||||||
|
|
||||||
/* create new window for the list */
|
/* create new window for the list */
|
||||||
list = subwin(dialog, list_height, list_width, y + box_y + 1,
|
list = subwin(dialog, list_height, list_width, y + box_y + 1,
|
||||||
x + box_x + 1);
|
x + box_x + 1);
|
||||||
|
|
||||||
keypad(list, TRUE);
|
keypad(list, TRUE);
|
||||||
|
|
||||||
/* draw a box around the list items */
|
/* draw a box around the list items */
|
||||||
draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
|
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 */
|
/* Find length of longest item in order to center checklist */
|
||||||
check_x = 0;
|
check_x = 0;
|
||||||
|
@ -106,8 +106,14 @@ struct dialog_color {
|
|||||||
int hl; /* highlight this item */
|
int hl; /* highlight this item */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct subtitle_list {
|
||||||
|
struct subtitle_list *next;
|
||||||
|
const char *text;
|
||||||
|
};
|
||||||
|
|
||||||
struct dialog_info {
|
struct dialog_info {
|
||||||
const char *backtitle;
|
const char *backtitle;
|
||||||
|
struct subtitle_list *subtitles;
|
||||||
struct dialog_color screen;
|
struct dialog_color screen;
|
||||||
struct dialog_color shadow;
|
struct dialog_color shadow;
|
||||||
struct dialog_color dialog;
|
struct dialog_color dialog;
|
||||||
@ -144,6 +150,7 @@ struct dialog_info {
|
|||||||
*/
|
*/
|
||||||
extern struct dialog_info dlg;
|
extern struct dialog_info dlg;
|
||||||
extern char dialog_input_result[];
|
extern char dialog_input_result[];
|
||||||
|
extern int saved_x, saved_y; /* Needed in signal handler in mconf.c */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function prototypes
|
* Function prototypes
|
||||||
@ -163,7 +170,7 @@ char item_tag(void);
|
|||||||
/* item list manipulation for lxdialog use */
|
/* item list manipulation for lxdialog use */
|
||||||
#define MAXITEMSTR 200
|
#define MAXITEMSTR 200
|
||||||
struct dialog_item {
|
struct dialog_item {
|
||||||
char str[MAXITEMSTR]; /* promtp displayed */
|
char str[MAXITEMSTR]; /* prompt displayed */
|
||||||
char tag;
|
char tag;
|
||||||
void *data; /* pointer to menu item - used by menubox+checklist */
|
void *data; /* pointer to menu item - used by menubox+checklist */
|
||||||
int selected; /* Set to 1 by dialog_*() function if selected. */
|
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_esc(WINDOW *win);
|
||||||
int on_key_resize(void);
|
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);
|
int init_dialog(const char *backtitle);
|
||||||
void set_dialog_backtitle(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 end_dialog(int x, int y);
|
||||||
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
||||||
void dialog_clear(void);
|
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_yesno(const char *title, const char *prompt, int height, int width);
|
||||||
int dialog_msgbox(const char *title, const char *prompt, int height,
|
int dialog_msgbox(const char *title, const char *prompt, int height,
|
||||||
int width, int pause);
|
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,
|
int dialog_menu(const char *title, const char *prompt,
|
||||||
const void *selected, int *s_scroll);
|
const void *selected, int *s_scroll);
|
||||||
int dialog_checklist(const char *title, const char *prompt, int height,
|
int dialog_checklist(const char *title, const char *prompt, int height,
|
||||||
int width, int list_height);
|
int width, int list_height);
|
||||||
extern char dialog_input_result[];
|
|
||||||
int dialog_inputbox(const char *title, const char *prompt, int height,
|
int dialog_inputbox(const char *title, const char *prompt, int height,
|
||||||
int width, const char *init);
|
int width, const char *init);
|
||||||
|
|
||||||
|
@ -42,10 +42,11 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
|
|||||||
* Display a dialog box for inputing a string
|
* Display a dialog box for inputing a string
|
||||||
*/
|
*/
|
||||||
int dialog_inputbox(const char *title, const char *prompt, int height, int width,
|
int dialog_inputbox(const char *title, const char *prompt, int height, int width,
|
||||||
const char *init)
|
const char *init)
|
||||||
{
|
{
|
||||||
int i, x, y, box_y, box_x, box_width;
|
int i, x, y, box_y, box_x, box_width;
|
||||||
int input_x = 0, scroll = 0, key = 0, button = -1;
|
int input_x = 0, key = 0, button = -1;
|
||||||
|
int show_x, len, pos;
|
||||||
char *instr = dialog_input_result;
|
char *instr = dialog_input_result;
|
||||||
WINDOW *dialog;
|
WINDOW *dialog;
|
||||||
|
|
||||||
@ -55,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
|
|||||||
strcpy(instr, init);
|
strcpy(instr, init);
|
||||||
|
|
||||||
do_resize:
|
do_resize:
|
||||||
if (getmaxy(stdscr) <= (height - 2))
|
if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
if (getmaxx(stdscr) <= (width - 2))
|
if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
|
|
||||||
/* center dialog box on screen */
|
/* center dialog box on screen */
|
||||||
x = (COLS - width) / 2;
|
x = (getmaxx(stdscr) - width) / 2;
|
||||||
y = (LINES - height) / 2;
|
y = (getmaxy(stdscr) - height) / 2;
|
||||||
|
|
||||||
draw_shadow(stdscr, y, x, height, width);
|
draw_shadow(stdscr, y, x, height, width);
|
||||||
|
|
||||||
@ -97,14 +98,17 @@ do_resize:
|
|||||||
wmove(dialog, box_y, box_x);
|
wmove(dialog, box_y, box_x);
|
||||||
wattrset(dialog, dlg.inputbox.atr);
|
wattrset(dialog, dlg.inputbox.atr);
|
||||||
|
|
||||||
input_x = strlen(instr);
|
len = strlen(instr);
|
||||||
|
pos = len;
|
||||||
|
|
||||||
if (input_x >= box_width) {
|
if (len >= box_width) {
|
||||||
scroll = input_x - box_width + 1;
|
show_x = len - box_width + 1;
|
||||||
input_x = box_width - 1;
|
input_x = box_width - 1;
|
||||||
for (i = 0; i < box_width - 1; i++)
|
for (i = 0; i < box_width - 1; i++)
|
||||||
waddch(dialog, instr[scroll + i]);
|
waddch(dialog, instr[show_x + i]);
|
||||||
} else {
|
} else {
|
||||||
|
show_x = 0;
|
||||||
|
input_x = len;
|
||||||
waddstr(dialog, instr);
|
waddstr(dialog, instr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,45 +125,104 @@ do_resize:
|
|||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT:
|
|
||||||
continue;
|
|
||||||
case KEY_RIGHT:
|
|
||||||
continue;
|
|
||||||
case KEY_BACKSPACE:
|
case KEY_BACKSPACE:
|
||||||
case 127:
|
case 127:
|
||||||
if (input_x || scroll) {
|
if (pos) {
|
||||||
wattrset(dialog, dlg.inputbox.atr);
|
wattrset(dialog, dlg.inputbox.atr);
|
||||||
if (!input_x) {
|
if (input_x == 0) {
|
||||||
scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
|
show_x--;
|
||||||
wmove(dialog, box_y, box_x);
|
|
||||||
for (i = 0; i < box_width; i++)
|
|
||||||
waddch(dialog,
|
|
||||||
instr[scroll + input_x + i] ?
|
|
||||||
instr[scroll + input_x + i] : ' ');
|
|
||||||
input_x = strlen(instr) - scroll;
|
|
||||||
} else
|
} else
|
||||||
input_x--;
|
input_x--;
|
||||||
instr[scroll + input_x] = '\0';
|
|
||||||
mvwaddch(dialog, box_y, input_x + box_x, ' ');
|
if (pos < len) {
|
||||||
|
for (i = pos - 1; i < len; i++) {
|
||||||
|
instr[i] = instr[i+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos--;
|
||||||
|
len--;
|
||||||
|
instr[len] = '\0';
|
||||||
|
wmove(dialog, box_y, box_x);
|
||||||
|
for (i = 0; i < box_width; i++) {
|
||||||
|
if (!instr[show_x + i]) {
|
||||||
|
waddch(dialog, ' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
waddch(dialog, instr[show_x + i]);
|
||||||
|
}
|
||||||
wmove(dialog, box_y, input_x + box_x);
|
wmove(dialog, box_y, input_x + box_x);
|
||||||
wrefresh(dialog);
|
wrefresh(dialog);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
case KEY_LEFT:
|
||||||
|
if (pos > 0) {
|
||||||
|
if (input_x > 0) {
|
||||||
|
wmove(dialog, box_y, --input_x + box_x);
|
||||||
|
} else if (input_x == 0) {
|
||||||
|
show_x--;
|
||||||
|
wmove(dialog, box_y, box_x);
|
||||||
|
for (i = 0; i < box_width; i++) {
|
||||||
|
if (!instr[show_x + i]) {
|
||||||
|
waddch(dialog, ' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
waddch(dialog, instr[show_x + i]);
|
||||||
|
}
|
||||||
|
wmove(dialog, box_y, box_x);
|
||||||
|
}
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
case KEY_RIGHT:
|
||||||
|
if (pos < len) {
|
||||||
|
if (input_x < box_width - 1) {
|
||||||
|
wmove(dialog, box_y, ++input_x + box_x);
|
||||||
|
} else if (input_x == box_width - 1) {
|
||||||
|
show_x++;
|
||||||
|
wmove(dialog, box_y, box_x);
|
||||||
|
for (i = 0; i < box_width; i++) {
|
||||||
|
if (!instr[show_x + i]) {
|
||||||
|
waddch(dialog, ' ');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
waddch(dialog, instr[show_x + i]);
|
||||||
|
}
|
||||||
|
wmove(dialog, box_y, input_x + box_x);
|
||||||
|
}
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
default:
|
default:
|
||||||
if (key < 0x100 && isprint(key)) {
|
if (key < 0x100 && isprint(key)) {
|
||||||
if (scroll + input_x < MAX_LEN) {
|
if (len < MAX_LEN) {
|
||||||
wattrset(dialog, dlg.inputbox.atr);
|
wattrset(dialog, dlg.inputbox.atr);
|
||||||
instr[scroll + input_x] = key;
|
if (pos < len) {
|
||||||
instr[scroll + input_x + 1] = '\0';
|
for (i = len; i > pos; i--)
|
||||||
if (input_x == box_width - 1) {
|
instr[i] = instr[i-1];
|
||||||
scroll++;
|
instr[pos] = key;
|
||||||
wmove(dialog, box_y, box_x);
|
|
||||||
for (i = 0; i < box_width - 1; i++)
|
|
||||||
waddch(dialog, instr [scroll + i]);
|
|
||||||
} else {
|
} else {
|
||||||
wmove(dialog, box_y, input_x++ + box_x);
|
instr[len] = key;
|
||||||
waddch(dialog, 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);
|
wrefresh(dialog);
|
||||||
} else
|
} else
|
||||||
flash(); /* Alarm user about overflow */
|
flash(); /* Alarm user about overflow */
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
* *) A bugfix for the Page-Down problem
|
* *) 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
|
* 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
|
* smarter and works more like other menu systems (just have a look at
|
||||||
* it).
|
* it).
|
||||||
@ -64,7 +64,7 @@ static int menu_width, item_x;
|
|||||||
* Print menu item
|
* Print menu item
|
||||||
*/
|
*/
|
||||||
static void do_print_item(WINDOW * win, const char *item, int line_y,
|
static void do_print_item(WINDOW * win, const char *item, int line_y,
|
||||||
int selected, int hotkey)
|
int selected, int hotkey)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
char *menu_item = malloc(menu_width + 1);
|
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)
|
static void print_buttons(WINDOW * win, int height, int width, int selected)
|
||||||
{
|
{
|
||||||
int x = width / 2 - 16;
|
int x = width / 2 - 28;
|
||||||
int y = height - 2;
|
int y = height - 2;
|
||||||
|
|
||||||
print_button(win, gettext("Select"), y, x, selected == 0);
|
print_button(win, gettext("Select"), y, x, selected == 0);
|
||||||
print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
|
print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
|
||||||
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
|
print_button(win, gettext(" Help "), y, x + 24, selected == 2);
|
||||||
|
print_button(win, gettext(" Save "), y, x + 36, selected == 3);
|
||||||
|
print_button(win, gettext(" Load "), y, x + 48, selected == 4);
|
||||||
|
|
||||||
wmove(win, y, x + 1 + 12 * selected);
|
wmove(win, y, x + 1 + 12 * selected);
|
||||||
wrefresh(win);
|
wrefresh(win);
|
||||||
@ -180,7 +182,7 @@ static void do_scroll(WINDOW *win, int *scroll, int n)
|
|||||||
* Display a menu for choosing among a number of options
|
* Display a menu for choosing among a number of options
|
||||||
*/
|
*/
|
||||||
int dialog_menu(const char *title, const char *prompt,
|
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 i, j, x, y, box_x, box_y;
|
||||||
int height, width, menu_height;
|
int height, width, menu_height;
|
||||||
@ -191,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
|
|||||||
do_resize:
|
do_resize:
|
||||||
height = getmaxy(stdscr);
|
height = getmaxy(stdscr);
|
||||||
width = getmaxx(stdscr);
|
width = getmaxx(stdscr);
|
||||||
if (height < 15 || width < 65)
|
if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
|
|
||||||
height -= 4;
|
height -= 4;
|
||||||
@ -201,8 +203,8 @@ do_resize:
|
|||||||
max_choice = MIN(menu_height, item_count());
|
max_choice = MIN(menu_height, item_count());
|
||||||
|
|
||||||
/* center dialog box on screen */
|
/* center dialog box on screen */
|
||||||
x = (COLS - width) / 2;
|
x = (getmaxx(stdscr) - width) / 2;
|
||||||
y = (LINES - height) / 2;
|
y = (getmaxy(stdscr) - height) / 2;
|
||||||
|
|
||||||
draw_shadow(stdscr, y, x, height, width);
|
draw_shadow(stdscr, y, x, height, width);
|
||||||
|
|
||||||
@ -301,10 +303,11 @@ do_resize:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < max_choice ||
|
if (item_count() != 0 &&
|
||||||
key == KEY_UP || key == KEY_DOWN ||
|
(i < max_choice ||
|
||||||
key == '-' || key == '+' ||
|
key == KEY_UP || key == KEY_DOWN ||
|
||||||
key == KEY_PPAGE || key == KEY_NPAGE) {
|
key == '-' || key == '+' ||
|
||||||
|
key == KEY_PPAGE || key == KEY_NPAGE)) {
|
||||||
/* Remove highligt of current item */
|
/* Remove highligt of current item */
|
||||||
print_item(scroll + choice, choice, FALSE);
|
print_item(scroll + choice, choice, FALSE);
|
||||||
|
|
||||||
@ -372,7 +375,7 @@ do_resize:
|
|||||||
case TAB:
|
case TAB:
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
button = ((key == KEY_LEFT ? --button : ++button) < 0)
|
button = ((key == KEY_LEFT ? --button : ++button) < 0)
|
||||||
? 2 : (button > 2 ? 0 : button);
|
? 4 : (button > 4 ? 0 : button);
|
||||||
|
|
||||||
print_buttons(dialog, height, width, button);
|
print_buttons(dialog, height, width, button);
|
||||||
wrefresh(menu);
|
wrefresh(menu);
|
||||||
@ -399,17 +402,17 @@ do_resize:
|
|||||||
return 2;
|
return 2;
|
||||||
case 's':
|
case 's':
|
||||||
case 'y':
|
case 'y':
|
||||||
return 3;
|
|
||||||
case 'n':
|
|
||||||
return 4;
|
|
||||||
case 'm':
|
|
||||||
return 5;
|
return 5;
|
||||||
case ' ':
|
case 'n':
|
||||||
return 6;
|
return 6;
|
||||||
case '/':
|
case 'm':
|
||||||
return 7;
|
return 7;
|
||||||
case 'z':
|
case ' ':
|
||||||
return 8;
|
return 8;
|
||||||
|
case '/':
|
||||||
|
return 9;
|
||||||
|
case 'z':
|
||||||
|
return 10;
|
||||||
case '\n':
|
case '\n':
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
@ -22,23 +22,25 @@
|
|||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
|
||||||
static void back_lines(int n);
|
static void back_lines(int n);
|
||||||
static void print_page(WINDOW * win, int height, int width);
|
static void print_page(WINDOW *win, int height, int width, update_text_fn
|
||||||
static void print_line(WINDOW * win, int row, int width);
|
update_text, void *data);
|
||||||
|
static void print_line(WINDOW *win, int row, int width);
|
||||||
static char *get_line(void);
|
static char *get_line(void);
|
||||||
static void print_position(WINDOW * win);
|
static void print_position(WINDOW * win);
|
||||||
|
|
||||||
static int hscroll;
|
static int hscroll;
|
||||||
static int begin_reached, end_reached, page_length;
|
static int begin_reached, end_reached, page_length;
|
||||||
static const char *buf;
|
static char *buf;
|
||||||
static const char *page;
|
static char *page;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* refresh window content
|
* refresh window content
|
||||||
*/
|
*/
|
||||||
static void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw,
|
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);
|
print_position(dialog);
|
||||||
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
||||||
wrefresh(dialog);
|
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.
|
* 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 dialog_textbox(const char *title, char *tbuf, int initial_height,
|
||||||
int initial_height, int initial_width)
|
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 i, x, y, cur_x, cur_y, key = 0;
|
||||||
int height, width, boxh, boxw;
|
int height, width, boxh, boxw;
|
||||||
int passed_end;
|
|
||||||
WINDOW *dialog, *box;
|
WINDOW *dialog, *box;
|
||||||
|
bool done = false;
|
||||||
|
|
||||||
begin_reached = 1;
|
begin_reached = 1;
|
||||||
end_reached = 0;
|
end_reached = 0;
|
||||||
@ -63,9 +69,18 @@ int dialog_textbox(const char *title, const char *tbuf,
|
|||||||
buf = tbuf;
|
buf = tbuf;
|
||||||
page = buf; /* page is pointer to start of page to be displayed */
|
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:
|
do_resize:
|
||||||
getmaxyx(stdscr, height, width);
|
getmaxyx(stdscr, height, width);
|
||||||
if (height < 8 || width < 8)
|
if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
if (initial_height != 0)
|
if (initial_height != 0)
|
||||||
height = initial_height;
|
height = initial_height;
|
||||||
@ -83,8 +98,8 @@ do_resize:
|
|||||||
width = 0;
|
width = 0;
|
||||||
|
|
||||||
/* center dialog box on screen */
|
/* center dialog box on screen */
|
||||||
x = (COLS - width) / 2;
|
x = (getmaxx(stdscr) - width) / 2;
|
||||||
y = (LINES - height) / 2;
|
y = (getmaxy(stdscr) - height) / 2;
|
||||||
|
|
||||||
draw_shadow(stdscr, y, x, height, width);
|
draw_shadow(stdscr, y, x, height, width);
|
||||||
|
|
||||||
@ -120,25 +135,28 @@ do_resize:
|
|||||||
|
|
||||||
/* Print first page of text */
|
/* Print first page of text */
|
||||||
attr_clear(box, boxh, boxw, dlg.dialog.atr);
|
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);
|
key = wgetch(dialog);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'E': /* Exit */
|
case 'E': /* Exit */
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'X':
|
case 'X':
|
||||||
case 'x':
|
case 'x':
|
||||||
delwin(box);
|
case 'q':
|
||||||
delwin(dialog);
|
case '\n':
|
||||||
return 0;
|
done = true;
|
||||||
|
break;
|
||||||
case 'g': /* First page */
|
case 'g': /* First page */
|
||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
if (!begin_reached) {
|
if (!begin_reached) {
|
||||||
begin_reached = 1;
|
begin_reached = 1;
|
||||||
page = buf;
|
page = buf;
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw,
|
||||||
cur_y, cur_x);
|
cur_y, cur_x, update_text,
|
||||||
|
data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'G': /* Last page */
|
case 'G': /* Last page */
|
||||||
@ -148,78 +166,48 @@ do_resize:
|
|||||||
/* point to last char in buf */
|
/* point to last char in buf */
|
||||||
page = buf + strlen(buf);
|
page = buf + strlen(buf);
|
||||||
back_lines(boxh);
|
back_lines(boxh);
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
cur_y, cur_x);
|
cur_x, update_text, data);
|
||||||
break;
|
break;
|
||||||
case 'K': /* Previous line */
|
case 'K': /* Previous line */
|
||||||
case 'k':
|
case 'k':
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
if (!begin_reached) {
|
if (begin_reached)
|
||||||
back_lines(page_length + 1);
|
break;
|
||||||
|
|
||||||
/* We don't call print_page() here but use
|
back_lines(page_length + 1);
|
||||||
* scrolling to ensure faster screen update.
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
* However, 'end_reached' and 'page_length'
|
cur_x, update_text, data);
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'B': /* Previous page */
|
case 'B': /* Previous page */
|
||||||
case 'b':
|
case 'b':
|
||||||
|
case 'u':
|
||||||
case KEY_PPAGE:
|
case KEY_PPAGE:
|
||||||
if (begin_reached)
|
if (begin_reached)
|
||||||
break;
|
break;
|
||||||
back_lines(page_length + boxh);
|
back_lines(page_length + boxh);
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
cur_y, cur_x);
|
cur_x, update_text, data);
|
||||||
break;
|
break;
|
||||||
case 'J': /* Next line */
|
case 'J': /* Next line */
|
||||||
case 'j':
|
case 'j':
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
if (!end_reached) {
|
if (end_reached)
|
||||||
begin_reached = 0;
|
break;
|
||||||
scrollok(box, TRUE);
|
|
||||||
scroll(box); /* Scroll box region up one line */
|
back_lines(page_length - 1);
|
||||||
scrollok(box, FALSE);
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
print_line(box, boxh - 1, boxw);
|
cur_x, update_text, data);
|
||||||
wnoutrefresh(box);
|
|
||||||
print_position(dialog);
|
|
||||||
wmove(dialog, cur_y, cur_x); /* Restore cursor position */
|
|
||||||
wrefresh(dialog);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case KEY_NPAGE: /* Next page */
|
case KEY_NPAGE: /* Next page */
|
||||||
case ' ':
|
case ' ':
|
||||||
|
case 'd':
|
||||||
if (end_reached)
|
if (end_reached)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
begin_reached = 0;
|
begin_reached = 0;
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
cur_y, cur_x);
|
cur_x, update_text, data);
|
||||||
break;
|
break;
|
||||||
case '0': /* Beginning of line */
|
case '0': /* Beginning of line */
|
||||||
case 'H': /* Scroll left */
|
case 'H': /* Scroll left */
|
||||||
@ -234,8 +222,8 @@ do_resize:
|
|||||||
hscroll--;
|
hscroll--;
|
||||||
/* Reprint current page to scroll horizontally */
|
/* Reprint current page to scroll horizontally */
|
||||||
back_lines(page_length);
|
back_lines(page_length);
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
cur_y, cur_x);
|
cur_x, update_text, data);
|
||||||
break;
|
break;
|
||||||
case 'L': /* Scroll right */
|
case 'L': /* Scroll right */
|
||||||
case 'l':
|
case 'l':
|
||||||
@ -245,11 +233,12 @@ do_resize:
|
|||||||
hscroll++;
|
hscroll++;
|
||||||
/* Reprint current page to scroll horizontally */
|
/* Reprint current page to scroll horizontally */
|
||||||
back_lines(page_length);
|
back_lines(page_length);
|
||||||
refresh_text_box(dialog, box, boxh, boxw,
|
refresh_text_box(dialog, box, boxh, boxw, cur_y,
|
||||||
cur_y, cur_x);
|
cur_x, update_text, data);
|
||||||
break;
|
break;
|
||||||
case KEY_ESC:
|
case KEY_ESC:
|
||||||
key = on_key_esc(dialog);
|
if (on_key_esc(dialog) == KEY_ESC)
|
||||||
|
done = true;
|
||||||
break;
|
break;
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
back_lines(height);
|
back_lines(height);
|
||||||
@ -257,11 +246,31 @@ do_resize:
|
|||||||
delwin(dialog);
|
delwin(dialog);
|
||||||
on_key_resize();
|
on_key_resize();
|
||||||
goto do_resize;
|
goto do_resize;
|
||||||
|
default:
|
||||||
|
for (i = 0; keys[i]; i++) {
|
||||||
|
if (key == keys[i]) {
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delwin(box);
|
delwin(box);
|
||||||
delwin(dialog);
|
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;
|
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;
|
page_length = 0;
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
print_line(win, i, width);
|
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)
|
static void print_line(WINDOW * win, int row, int width)
|
||||||
{
|
{
|
||||||
int y, x;
|
|
||||||
char *line;
|
char *line;
|
||||||
|
|
||||||
line = get_line();
|
line = get_line();
|
||||||
@ -329,10 +348,10 @@ static void print_line(WINDOW * win, int row, int width)
|
|||||||
waddch(win, ' ');
|
waddch(win, ' ');
|
||||||
waddnstr(win, line, MIN(strlen(line), width - 2));
|
waddnstr(win, line, MIN(strlen(line), width - 2));
|
||||||
|
|
||||||
getyx(win, y, x);
|
|
||||||
/* Clear 'residue' of previous line */
|
/* Clear 'residue' of previous line */
|
||||||
#if OLD_NCURSES
|
#if OLD_NCURSES
|
||||||
{
|
{
|
||||||
|
int x = getcurx(win);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < width - x; i++)
|
for (i = 0; i < width - x; i++)
|
||||||
waddch(win, ' ');
|
waddch(win, ' ');
|
||||||
@ -355,10 +374,8 @@ static char *get_line(void)
|
|||||||
end_reached = 0;
|
end_reached = 0;
|
||||||
while (*page != '\n') {
|
while (*page != '\n') {
|
||||||
if (*page == '\0') {
|
if (*page == '\0') {
|
||||||
if (!end_reached) {
|
end_reached = 1;
|
||||||
end_reached = 1;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (i < MAX_LEN)
|
} else if (i < MAX_LEN)
|
||||||
line[i++] = *(page++);
|
line[i++] = *(page++);
|
||||||
else {
|
else {
|
||||||
@ -371,7 +388,7 @@ static char *get_line(void)
|
|||||||
if (i <= MAX_LEN)
|
if (i <= MAX_LEN)
|
||||||
line[i] = '\0';
|
line[i] = '\0';
|
||||||
if (!end_reached)
|
if (!end_reached)
|
||||||
page++; /* move pass '\n' */
|
page++; /* move past '\n' */
|
||||||
|
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
|
||||||
|
/* Needed in signal handler in mconf.c */
|
||||||
|
int saved_x, saved_y;
|
||||||
|
|
||||||
struct dialog_info dlg;
|
struct dialog_info dlg;
|
||||||
|
|
||||||
static void set_mono_theme(void)
|
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)
|
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 */
|
/* Display background title if it exists ... - SLH */
|
||||||
if (dlg.backtitle != NULL) {
|
if (dlg.backtitle != NULL) {
|
||||||
int i;
|
int i, len = 0, skip = 0;
|
||||||
|
struct subtitle_list *pos;
|
||||||
|
|
||||||
wattrset(stdscr, dlg.screen.atr);
|
wattrset(stdscr, dlg.screen.atr);
|
||||||
mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
|
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);
|
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);
|
waddch(stdscr, ACS_HLINE);
|
||||||
}
|
}
|
||||||
wnoutrefresh(stdscr);
|
wnoutrefresh(stdscr);
|
||||||
@ -273,8 +317,12 @@ int init_dialog(const char *backtitle)
|
|||||||
int height, width;
|
int height, width;
|
||||||
|
|
||||||
initscr(); /* Init curses */
|
initscr(); /* Init curses */
|
||||||
|
|
||||||
|
/* Get current cursor position for signal handler in mconf.c */
|
||||||
|
getyx(stdscr, saved_y, saved_x);
|
||||||
|
|
||||||
getmaxyx(stdscr, height, width);
|
getmaxyx(stdscr, height, width);
|
||||||
if (height < 19 || width < 80) {
|
if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
|
||||||
endwin();
|
endwin();
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
}
|
}
|
||||||
@ -295,6 +343,11 @@ void set_dialog_backtitle(const char *backtitle)
|
|||||||
dlg.backtitle = backtitle;
|
dlg.backtitle = backtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_dialog_subtitles(struct subtitle_list *subtitles)
|
||||||
|
{
|
||||||
|
dlg.subtitles = subtitles;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End using dialog functions.
|
* 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
|
* 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
|
* 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.
|
* 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)
|
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||||
{
|
{
|
||||||
int newl, cur_x, cur_y;
|
int newl, cur_x, cur_y;
|
||||||
int i, prompt_len, room, wlen;
|
int prompt_len, room, wlen;
|
||||||
char tempstr[MAX_LEN + 1], *word, *sp, *sp2;
|
char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
|
||||||
|
|
||||||
strcpy(tempstr, prompt);
|
strcpy(tempstr, prompt);
|
||||||
|
|
||||||
prompt_len = strlen(tempstr);
|
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 */
|
if (prompt_len <= width - x * 2) { /* If prompt is short */
|
||||||
wmove(win, y, (width - prompt_len) / 2);
|
wmove(win, y, (width - prompt_len) / 2);
|
||||||
waddstr(win, tempstr);
|
waddstr(win, tempstr);
|
||||||
@ -353,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
|||||||
newl = 1;
|
newl = 1;
|
||||||
word = tempstr;
|
word = tempstr;
|
||||||
while (word && *word) {
|
while (word && *word) {
|
||||||
sp = strchr(word, ' ');
|
sp = strpbrk(word, "\n ");
|
||||||
|
if (sp && *sp == '\n')
|
||||||
|
newline_separator = sp;
|
||||||
|
|
||||||
if (sp)
|
if (sp)
|
||||||
*sp++ = 0;
|
*sp++ = 0;
|
||||||
|
|
||||||
@ -365,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
|||||||
if (wlen > room ||
|
if (wlen > room ||
|
||||||
(newl && wlen < 4 && sp
|
(newl && wlen < 4 && sp
|
||||||
&& wlen + 1 + strlen(sp) > room
|
&& wlen + 1 + strlen(sp) > room
|
||||||
&& (!(sp2 = strchr(sp, ' '))
|
&& (!(sp2 = strpbrk(sp, "\n "))
|
||||||
|| wlen + 1 + (sp2 - sp) > room))) {
|
|| wlen + 1 + (sp2 - sp) > room))) {
|
||||||
cur_y++;
|
cur_y++;
|
||||||
cur_x = x;
|
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);
|
wmove(win, cur_y, cur_x);
|
||||||
waddstr(win, word);
|
waddstr(win, word);
|
||||||
getyx(win, cur_y, cur_x);
|
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 == ' ') {
|
if (sp && *sp == ' ') {
|
||||||
cur_x++; /* double space */
|
cur_x++; /* double space */
|
||||||
while (*++sp == ' ') ;
|
while (*++sp == ' ') ;
|
||||||
@ -567,7 +623,7 @@ void item_make(const char *fmt, ...)
|
|||||||
void item_add_str(const char *fmt, ...)
|
void item_add_str(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
size_t avail;
|
size_t avail;
|
||||||
|
|
||||||
avail = sizeof(item_cur->node.str) - strlen(item_cur->node.str);
|
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;
|
WINDOW *dialog;
|
||||||
|
|
||||||
do_resize:
|
do_resize:
|
||||||
if (getmaxy(stdscr) < (height + 4))
|
if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
if (getmaxx(stdscr) < (width + 4))
|
if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
|
||||||
return -ERRDISPLAYTOOSMALL;
|
return -ERRDISPLAYTOOSMALL;
|
||||||
|
|
||||||
/* center dialog box on screen */
|
/* center dialog box on screen */
|
||||||
x = (COLS - width) / 2;
|
x = (getmaxx(stdscr) - width) / 2;
|
||||||
y = (LINES - height) / 2;
|
y = (getmaxy(stdscr) - height) / 2;
|
||||||
|
|
||||||
draw_shadow(stdscr, y, x, height, width);
|
draw_shadow(stdscr, y, x, height, width);
|
||||||
|
|
||||||
|
431
kconfig/mconf.c
431
kconfig/mconf.c
@ -15,17 +15,17 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
#include "lxdialog/dialog.h"
|
#include "lxdialog/dialog.h"
|
||||||
|
|
||||||
static const char mconf_readme[] = N_(
|
static const char mconf_readme[] = N_(
|
||||||
"Overview\n"
|
"Overview\n"
|
||||||
"--------\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"
|
"Features can either be built-in, modularized, or ignored. Parameters\n"
|
||||||
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -39,16 +39,16 @@ static const char mconf_readme[] = N_(
|
|||||||
"\n"
|
"\n"
|
||||||
"To change any of these features, highlight it with the cursor\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"
|
"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"
|
"<N> to remove it. You may also press the <Space Bar> to cycle\n"
|
||||||
"through the available options (ie. Y->N->M->Y).\n"
|
"through the available options (i.e. Y->N->M->Y).\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Some additional keyboard hints:\n"
|
"Some additional keyboard hints:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Menus\n"
|
"Menus\n"
|
||||||
"----------\n"
|
"----------\n"
|
||||||
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
|
"o Use the Up/Down arrow keys (cursor keys) to highlight the item you\n"
|
||||||
" you wish to change or submenu wish to select and press <Enter>.\n"
|
" wish to change or the submenu you wish to select and press <Enter>.\n"
|
||||||
" Submenus are designated by \"--->\".\n"
|
" Submenus are designated by \"--->\", empty ones by \"----\".\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Shortcut: Press the option's highlighted letter (hotkey).\n"
|
" Shortcut: Press the option's highlighted letter (hotkey).\n"
|
||||||
" Pressing a hotkey more than once will sequence\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"
|
" there is a delayed response which you may find annoying.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
|
" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
|
||||||
" <Exit> and <Help>.\n"
|
" <Exit>, <Help>, <Save>, and <Load>.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"o To get help with an item, use the cursor keys to highlight <Help>\n"
|
"o To get help with an item, use the cursor keys to highlight <Help>\n"
|
||||||
" and press <ENTER>.\n"
|
" and press <ENTER>.\n"
|
||||||
@ -105,10 +105,10 @@ static const char mconf_readme[] = N_(
|
|||||||
"Text Box (Help Window)\n"
|
"Text Box (Help Window)\n"
|
||||||
"--------\n"
|
"--------\n"
|
||||||
"o Use the cursor keys to scroll up/down/left/right. The VI editor\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"
|
" keys h,j,k,l function here as do <u>, <d>, <SPACE BAR> and <B> for\n"
|
||||||
" who are familiar with less and lynx.\n"
|
" those who are familiar with less and lynx.\n"
|
||||||
"\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"
|
||||||
"\n"
|
"\n"
|
||||||
"Alternate Configuration Files\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"
|
"those who, for various reasons, find it necessary to switch\n"
|
||||||
"between different configurations.\n"
|
"between different configurations.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"At the end of the main menu you will find two options. One is\n"
|
"The <Save> button will let you save the current configuration to\n"
|
||||||
"for saving the current configuration to a file of your choosing.\n"
|
"a file of your choosing. Use the <Load> button to load a previously\n"
|
||||||
"The other option is for loading a previously saved alternate\n"
|
"saved alternate configuration.\n"
|
||||||
"configuration.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Even if you don't use alternate configuration files, but you\n"
|
"Even if you don't use alternate configuration files, but you find\n"
|
||||||
"find during a Menuconfig session that you have completely messed\n"
|
"during a Menuconfig session that you have completely messed up your\n"
|
||||||
"up your settings, you may use the \"Load Alternate...\" option to\n"
|
"settings, you may use the <Load> button to restore your previously\n"
|
||||||
"restore your previously saved settings from \".config\" without\n"
|
"saved settings from \".config\" without restarting Menuconfig.\n"
|
||||||
"restarting Menuconfig.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Other information\n"
|
"Other information\n"
|
||||||
"-----------------\n"
|
"-----------------\n"
|
||||||
"If you use Menuconfig in an XTERM window make sure you have your\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"
|
"$TERM variable set to point to an xterm definition which supports\n"
|
||||||
"Otherwise, Menuconfig will look rather bad. Menuconfig will not\n"
|
"color. Otherwise, Menuconfig will look rather bad. Menuconfig will\n"
|
||||||
"display correctly in a RXVT window because rxvt displays only one\n"
|
"not display correctly in an RXVT window because rxvt displays only one\n"
|
||||||
"intensity of color, bright.\n"
|
"intensity of color, bright.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Menuconfig will display larger menus on screens or xterms which are\n"
|
"Menuconfig will display larger menus on screens or xterms which are\n"
|
||||||
@ -148,8 +146,8 @@ static const char mconf_readme[] = N_(
|
|||||||
"\n"
|
"\n"
|
||||||
"Optional personality available\n"
|
"Optional personality available\n"
|
||||||
"------------------------------\n"
|
"------------------------------\n"
|
||||||
"If you prefer to have all of the options listed in a single menu, rather\n"
|
"If you prefer to have all of the options listed in a single menu,\n"
|
||||||
"than the default multimenu hierarchy, run the menuconfig with\n"
|
"rather than the default multimenu hierarchy, run the menuconfig with\n"
|
||||||
"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
|
"MENUCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"make MENUCONFIG_MODE=single_menu menuconfig\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"
|
" mono => selects colors suitable for monochrome displays\n"
|
||||||
" blackbg => selects a color scheme with black background\n"
|
" blackbg => selects a color scheme with black background\n"
|
||||||
" classic => theme with blue background. The classic look\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"),
|
"\n"),
|
||||||
menu_instructions[] = N_(
|
menu_instructions[] = N_(
|
||||||
"Arrow keys navigate the menu. "
|
"Arrow keys navigate the menu. "
|
||||||
"<Enter> selects submenus --->. "
|
"<Enter> selects submenus ---> (or empty submenus ----). "
|
||||||
"Highlighted letters are hotkeys. "
|
"Highlighted letters are hotkeys. "
|
||||||
"Pressing <Y> includes, <N> excludes, <M> modularizes features. "
|
"Pressing <Y> includes, <N> excludes, <M> modularizes features. "
|
||||||
"Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
|
"Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
|
||||||
@ -236,29 +234,36 @@ search_help[] = N_(
|
|||||||
"Result:\n"
|
"Result:\n"
|
||||||
"-----------------------------------------------------------------\n"
|
"-----------------------------------------------------------------\n"
|
||||||
"Symbol: FOO [=m]\n"
|
"Symbol: FOO [=m]\n"
|
||||||
|
"Type : tristate\n"
|
||||||
"Prompt: Foo bus is used to drive the bar HW\n"
|
"Prompt: Foo bus is used to drive the bar HW\n"
|
||||||
"Defined at drivers/pci/Kconfig:47\n"
|
" Location:\n"
|
||||||
"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
|
||||||
"Location:\n"
|
" -> PCI support (PCI [=y])\n"
|
||||||
" -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
|
"(1) -> PCI access mode (<choice> [=y])\n"
|
||||||
" -> PCI support (PCI [=y])\n"
|
" Defined at drivers/pci/Kconfig:47\n"
|
||||||
" -> PCI access mode (<choice> [=y])\n"
|
" Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
||||||
"Selects: LIBCRC32\n"
|
" Selects: LIBCRC32\n"
|
||||||
"Selected by: BAR\n"
|
" Selected by: BAR [=n]\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"
|
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
||||||
" this symbol\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"
|
" 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"
|
" 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"
|
" is located\n"
|
||||||
" A location followed by a [=y] indicate that this is a selectable\n"
|
" A location followed by a [=y] indicates that this is a\n"
|
||||||
" menu item - and current value is displayed inside brackets.\n"
|
" selectable menu item - and the current value is displayed inside\n"
|
||||||
"o The 'Selects:' line tell what symbol will be automatically\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"
|
" 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"
|
"\n"
|
||||||
"Only relevant lines are shown.\n"
|
"Only relevant lines are shown.\n"
|
||||||
"\n\n"
|
"\n\n"
|
||||||
@ -273,12 +278,17 @@ static struct menu *current_menu;
|
|||||||
static int child_count;
|
static int child_count;
|
||||||
static int single_menu_mode;
|
static int single_menu_mode;
|
||||||
static int show_all_options;
|
static int show_all_options;
|
||||||
|
static int save_and_exit;
|
||||||
|
static 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_choice(struct menu *menu);
|
||||||
static void conf_string(struct menu *menu);
|
static void conf_string(struct menu *menu);
|
||||||
static void conf_load(void);
|
static void conf_load(void);
|
||||||
static void conf_save(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_textbox(const char *title, const char *text, int r, int c);
|
||||||
static void show_helptext(const char *title, const char *text);
|
static void show_helptext(const char *title, const char *text);
|
||||||
static void show_help(struct menu *menu);
|
static void show_help(struct menu *menu);
|
||||||
@ -290,7 +300,7 @@ static void set_config_filename(const char *config_filename)
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
|
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))
|
if (size >= sizeof(menu_backtitle))
|
||||||
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
||||||
set_dialog_backtitle(menu_backtitle);
|
set_dialog_backtitle(menu_backtitle);
|
||||||
@ -300,18 +310,103 @@ static void set_config_filename(const char *config_filename)
|
|||||||
filename[sizeof(filename)-1] = '\0';
|
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)
|
static void search_conf(void)
|
||||||
{
|
{
|
||||||
struct symbol **sym_arr;
|
struct symbol **sym_arr;
|
||||||
struct gstr res;
|
struct gstr res;
|
||||||
|
struct gstr title;
|
||||||
char *dialog_input;
|
char *dialog_input;
|
||||||
int dres;
|
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:
|
again:
|
||||||
dialog_clear();
|
dialog_clear();
|
||||||
dres = dialog_inputbox(_("Search Configuration Parameter"),
|
dres = dialog_inputbox(_("Search Configuration Parameter"),
|
||||||
_("Enter " CONFIG_ " (sub)string to search for "
|
str_get(&title),
|
||||||
"(with or without \"" CONFIG_ "\")"),
|
|
||||||
10, 75, "");
|
10, 75, "");
|
||||||
switch (dres) {
|
switch (dres) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -320,6 +415,7 @@ again:
|
|||||||
show_helptext(_("Search Configuration"), search_help);
|
show_helptext(_("Search Configuration"), search_help);
|
||||||
goto again;
|
goto again;
|
||||||
default:
|
default:
|
||||||
|
str_free(&title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,11 +424,43 @@ again:
|
|||||||
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
|
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
|
||||||
dialog_input += strlen(CONFIG_);
|
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);
|
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);
|
free(sym_arr);
|
||||||
show_textbox(_("Search Results"), str_get(&res), 0, 0);
|
str_free(&title);
|
||||||
str_free(&res);
|
list_del(trail.prev);
|
||||||
|
str_free(&sttext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_conf(struct menu *menu)
|
static void build_conf(struct menu *menu)
|
||||||
@ -369,8 +497,9 @@ static void build_conf(struct menu *menu)
|
|||||||
menu->data ? "-->" : "++>",
|
menu->data ? "-->" : "++>",
|
||||||
indent + 1, ' ', prompt);
|
indent + 1, ' ', prompt);
|
||||||
} else
|
} 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_tag('m');
|
||||||
item_set_data(menu);
|
item_set_data(menu);
|
||||||
if (single_menu_mode && menu->data)
|
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)) ?
|
(sym_has_value(sym) || !sym_is_changable(sym)) ?
|
||||||
"" : _(" (NEW)"));
|
"" : _(" (NEW)"));
|
||||||
if (menu->prompt->type == P_MENU) {
|
if (menu->prompt->type == P_MENU) {
|
||||||
item_add_str(" --->");
|
item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -513,40 +642,40 @@ conf_childs:
|
|||||||
indent -= doint;
|
indent -= doint;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void conf(struct menu *menu)
|
static void conf(struct menu *menu, struct menu *active_menu)
|
||||||
{
|
{
|
||||||
struct menu *submenu;
|
struct menu *submenu;
|
||||||
const char *prompt = menu_get_prompt(menu);
|
const char *prompt = menu_get_prompt(menu);
|
||||||
|
struct subtitle_part stpart;
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
struct menu *active_menu = NULL;
|
|
||||||
int res;
|
int res;
|
||||||
int s_scroll = 0;
|
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) {
|
while (1) {
|
||||||
item_reset();
|
item_reset();
|
||||||
current_menu = menu;
|
current_menu = menu;
|
||||||
build_conf(menu);
|
build_conf(menu);
|
||||||
if (!child_count)
|
if (!child_count)
|
||||||
break;
|
break;
|
||||||
if (menu == &rootmenu) {
|
set_subtitle();
|
||||||
item_make("--- ");
|
|
||||||
item_set_tag(':');
|
|
||||||
item_make(_(" Load an Alternate Configuration File"));
|
|
||||||
item_set_tag('L');
|
|
||||||
item_make(_(" Save an Alternate Configuration File"));
|
|
||||||
item_set_tag('S');
|
|
||||||
}
|
|
||||||
dialog_clear();
|
dialog_clear();
|
||||||
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
|
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
|
||||||
_(menu_instructions),
|
_(menu_instructions),
|
||||||
active_menu, &s_scroll);
|
active_menu, &s_scroll);
|
||||||
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
|
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
|
||||||
break;
|
break;
|
||||||
if (!item_activate_selected())
|
if (item_count() != 0) {
|
||||||
continue;
|
if (!item_activate_selected())
|
||||||
if (!item_tag())
|
continue;
|
||||||
continue;
|
if (!item_tag())
|
||||||
|
continue;
|
||||||
|
}
|
||||||
submenu = item_data();
|
submenu = item_data();
|
||||||
active_menu = item_data();
|
active_menu = item_data();
|
||||||
if (submenu)
|
if (submenu)
|
||||||
@ -561,32 +690,36 @@ static void conf(struct menu *menu)
|
|||||||
if (single_menu_mode)
|
if (single_menu_mode)
|
||||||
submenu->data = (void *) (long) !submenu->data;
|
submenu->data = (void *) (long) !submenu->data;
|
||||||
else
|
else
|
||||||
conf(submenu);
|
conf(submenu, NULL);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
|
if (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)
|
||||||
conf_choice(submenu);
|
conf_choice(submenu);
|
||||||
else if (submenu->prompt->type == P_MENU)
|
else if (submenu->prompt->type == P_MENU)
|
||||||
conf(submenu);
|
conf(submenu, NULL);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
conf_string(submenu);
|
conf_string(submenu);
|
||||||
break;
|
break;
|
||||||
case 'L':
|
|
||||||
conf_load();
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
conf_save();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (sym)
|
if (sym)
|
||||||
show_help(submenu);
|
show_help(submenu);
|
||||||
else
|
else {
|
||||||
|
reset_subtitle();
|
||||||
show_helptext(_("README"), _(mconf_readme));
|
show_helptext(_("README"), _(mconf_readme));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
reset_subtitle();
|
||||||
|
conf_save();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
reset_subtitle();
|
||||||
|
conf_load();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
if (item_is_tag('t')) {
|
if (item_is_tag('t')) {
|
||||||
if (sym_set_tristate_value(sym, yes))
|
if (sym_set_tristate_value(sym, yes))
|
||||||
break;
|
break;
|
||||||
@ -594,34 +727,45 @@ static void conf(struct menu *menu)
|
|||||||
show_textbox(NULL, setmod_text, 6, 74);
|
show_textbox(NULL, setmod_text, 6, 74);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 6:
|
||||||
if (item_is_tag('t'))
|
if (item_is_tag('t'))
|
||||||
sym_set_tristate_value(sym, no);
|
sym_set_tristate_value(sym, no);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 7:
|
||||||
if (item_is_tag('t'))
|
if (item_is_tag('t'))
|
||||||
sym_set_tristate_value(sym, mod);
|
sym_set_tristate_value(sym, mod);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 8:
|
||||||
if (item_is_tag('t'))
|
if (item_is_tag('t'))
|
||||||
sym_toggle_tristate_value(sym);
|
sym_toggle_tristate_value(sym);
|
||||||
else if (item_is_tag('m'))
|
else if (item_is_tag('m'))
|
||||||
conf(submenu);
|
conf(submenu, NULL);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 9:
|
||||||
search_conf();
|
search_conf();
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 10:
|
||||||
show_all_options = !show_all_options;
|
show_all_options = !show_all_options;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
static void show_textbox(const char *title, const char *text, int r, int c)
|
||||||
{
|
{
|
||||||
dialog_clear();
|
show_textbox_ext(title, (char *) text, r, c, (int []) {0}, NULL, NULL,
|
||||||
dialog_textbox(title, text, r, c);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_helptext(const char *title, const char *text)
|
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);
|
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)
|
static void show_help(struct menu *menu)
|
||||||
{
|
{
|
||||||
struct gstr help = str_new();
|
struct gstr help = str_new();
|
||||||
@ -671,7 +828,9 @@ static void conf_choice(struct menu *menu)
|
|||||||
dialog_clear();
|
dialog_clear();
|
||||||
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
|
res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
|
||||||
_(radiolist_instructions),
|
_(radiolist_instructions),
|
||||||
15, 70, 6);
|
MENUBOX_HEIGTH_MIN,
|
||||||
|
MENUBOX_WIDTH_MIN,
|
||||||
|
CHECKLIST_HEIGTH_MIN);
|
||||||
selected = item_activate_selected();
|
selected = item_activate_selected();
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case 0:
|
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 main(int ac, char **av)
|
||||||
{
|
{
|
||||||
int saved_x, saved_y;
|
|
||||||
char *mode;
|
char *mode;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
@ -803,6 +1013,14 @@ int main(int ac, char **av)
|
|||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
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_parse(av[1]);
|
||||||
conf_read(NULL);
|
conf_read(NULL);
|
||||||
|
|
||||||
@ -812,9 +1030,6 @@ int main(int ac, char **av)
|
|||||||
single_menu_mode = 1;
|
single_menu_mode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
initscr();
|
|
||||||
|
|
||||||
getyx(stdscr, saved_y, saved_x);
|
|
||||||
if (init_dialog(NULL)) {
|
if (init_dialog(NULL)) {
|
||||||
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
|
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"));
|
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());
|
set_config_filename(conf_get_configname());
|
||||||
|
conf_set_message_callback(conf_message_callback);
|
||||||
do {
|
do {
|
||||||
conf(&rootmenu);
|
conf(&rootmenu, NULL);
|
||||||
dialog_clear();
|
res = handle_exit();
|
||||||
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;
|
|
||||||
} while (res == KEY_ESC);
|
} while (res == KEY_ESC);
|
||||||
end_dialog(saved_x, saved_y);
|
|
||||||
|
|
||||||
switch (res) {
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
169
kconfig/menu.c
169
kconfig/menu.c
@ -3,14 +3,14 @@
|
|||||||
* Released under the terms of the GNU GPL v2.0.
|
* Released under the terms of the GNU GPL v2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
static const char nohelp_text[] = N_(
|
static const char nohelp_text[] = "There is no help available for this option.";
|
||||||
"There is no help available for this option.\n");
|
|
||||||
|
|
||||||
struct menu rootmenu;
|
struct menu rootmenu;
|
||||||
static struct menu **last_entry_ptr;
|
static struct menu **last_entry_ptr;
|
||||||
@ -48,7 +48,7 @@ void menu_add_entry(struct symbol *sym)
|
|||||||
{
|
{
|
||||||
struct menu *menu;
|
struct menu *menu;
|
||||||
|
|
||||||
menu = malloc(sizeof(*menu));
|
menu = xmalloc(sizeof(*menu));
|
||||||
memset(menu, 0, sizeof(*menu));
|
memset(menu, 0, sizeof(*menu));
|
||||||
menu->sym = sym;
|
menu->sym = sym;
|
||||||
menu->parent = current_menu;
|
menu->parent = current_menu;
|
||||||
@ -119,12 +119,13 @@ void menu_set_type(int type)
|
|||||||
sym->type = type;
|
sym->type = type;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'",
|
menu_warn(current_entry,
|
||||||
sym->name ? sym->name : "<choice>",
|
"ignoring type redefinition of '%s' from '%s' to '%s'",
|
||||||
sym_type_name(sym->type), sym_type_name(type));
|
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);
|
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;
|
struct menu *menu = current_entry;
|
||||||
|
|
||||||
while ((menu = menu->parent) != NULL) {
|
while ((menu = menu->parent) != NULL) {
|
||||||
|
struct expr *dup_expr;
|
||||||
|
|
||||||
if (!menu->visibility)
|
if (!menu->visibility)
|
||||||
continue;
|
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
|
prop->visible.expr
|
||||||
= expr_alloc_and(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)
|
void menu_add_option(int token, char *arg)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
|
||||||
|
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case T_OPT_MODULES:
|
case T_OPT_MODULES:
|
||||||
prop = prop_alloc(P_DEFAULT, modules_sym);
|
if (modules_sym)
|
||||||
prop->expr = expr_alloc_symbol(current_entry->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;
|
break;
|
||||||
case T_OPT_DEFCONFIG_LIST:
|
case T_OPT_DEFCONFIG_LIST:
|
||||||
if (!sym_defconfig_list)
|
if (!sym_defconfig_list)
|
||||||
@ -206,6 +223,9 @@ void menu_add_option(int token, char *arg)
|
|||||||
case T_OPT_ENV:
|
case T_OPT_ENV:
|
||||||
prop_add_env(arg);
|
prop_add_env(arg);
|
||||||
break;
|
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 "
|
"config symbol '%s' uses select, but is "
|
||||||
"not boolean or tristate", sym->name);
|
"not boolean or tristate", sym->name);
|
||||||
else if (sym2->type != S_UNKNOWN &&
|
else if (sym2->type != S_UNKNOWN &&
|
||||||
sym2->type != S_BOOLEAN &&
|
sym2->type != S_BOOLEAN &&
|
||||||
sym2->type != S_TRISTATE)
|
sym2->type != S_TRISTATE)
|
||||||
prop_warn(prop,
|
prop_warn(prop,
|
||||||
"'%s' has wrong type. 'select' only "
|
"'%s' has wrong type. 'select' only "
|
||||||
"accept arguments of boolean and "
|
"accept arguments of boolean and "
|
||||||
@ -254,7 +274,7 @@ static void sym_check_prop(struct symbol *sym)
|
|||||||
case P_RANGE:
|
case P_RANGE:
|
||||||
if (sym->type != S_INT && sym->type != S_HEX)
|
if (sym->type != S_INT && sym->type != S_HEX)
|
||||||
prop_warn(prop, "range is only allowed "
|
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) ||
|
if (!menu_validate_number(sym, prop->expr->left.sym) ||
|
||||||
!menu_validate_number(sym, prop->expr->right.sym))
|
!menu_validate_number(sym, prop->expr->right.sym))
|
||||||
prop_warn(prop, "range is invalid");
|
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 */
|
/* set the type of the remaining choice values */
|
||||||
for (menu = parent->list; menu; menu = menu->next) {
|
for (menu = parent->list; menu; menu = menu->next) {
|
||||||
current_entry = menu;
|
current_entry = menu;
|
||||||
@ -441,6 +456,22 @@ bool menu_has_prompt(struct menu *menu)
|
|||||||
return true;
|
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)
|
bool menu_is_visible(struct menu *menu)
|
||||||
{
|
{
|
||||||
struct menu *child;
|
struct menu *child;
|
||||||
@ -518,27 +549,53 @@ const char *menu_get_help(struct menu *menu)
|
|||||||
return "";
|
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;
|
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, _("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;
|
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;
|
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) {
|
if (i > 0) {
|
||||||
str_printf(r, _(" Location:\n"));
|
str_printf(r, _(" Location:\n"));
|
||||||
for (j = 4; --i >= 0; j += 2) {
|
for (j = 4; --i >= 0; j += 2) {
|
||||||
menu = submenu[i];
|
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) {
|
if (menu->sym) {
|
||||||
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
str_printf(r, " (%s [=%s])", menu->sym->name ?
|
||||||
menu->sym->name : _("<choice>"),
|
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;
|
bool hit;
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
@ -568,7 +641,19 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for_all_prompts(sym, prop)
|
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;
|
hit = false;
|
||||||
for_all_properties(sym, prop, P_SELECT) {
|
for_all_properties(sym, prop, P_SELECT) {
|
||||||
if (!hit) {
|
if (!hit) {
|
||||||
@ -588,14 +673,14 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
|
|||||||
str_append(r, "\n\n");
|
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 symbol *sym;
|
||||||
struct gstr res = str_new();
|
struct gstr res = str_new();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
|
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
|
||||||
get_symbol_str(&res, sym);
|
get_symbol_str(&res, sym, head);
|
||||||
if (!i)
|
if (!i)
|
||||||
str_append(&res, _("No matches found.\n"));
|
str_append(&res, _("No matches found.\n"));
|
||||||
return res;
|
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)
|
void menu_get_ext_help(struct menu *menu, struct gstr *help)
|
||||||
{
|
{
|
||||||
struct symbol *sym = menu->sym;
|
struct symbol *sym = menu->sym;
|
||||||
|
const char *help_text = nohelp_text;
|
||||||
|
|
||||||
if (menu_has_help(menu)) {
|
if (menu_has_help(menu)) {
|
||||||
if (sym->name) {
|
if (sym->name)
|
||||||
str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
|
str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
|
||||||
str_append(help, _(menu_get_help(menu)));
|
help_text = menu_get_help(menu);
|
||||||
str_append(help, "\n");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
str_append(help, nohelp_text);
|
|
||||||
}
|
}
|
||||||
|
str_printf(help, "%s\n", _(help_text));
|
||||||
if (sym)
|
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
|
#define _GNU_SOURCE
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#define LKC_DIRECT_LINK
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
#include "nconf.h"
|
#include "nconf.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static const char nconf_readme[] = N_(
|
static const char nconf_global_help[] = N_(
|
||||||
"Overview\n"
|
"Help windows\n"
|
||||||
"--------\n"
|
"------------\n"
|
||||||
"This interface let you select features and parameters for the build.\n"
|
"o Global help: Unless in a data entry window, pressing <F1> will give \n"
|
||||||
"Features can either be built-in, modularized, or ignored. Parameters\n"
|
" you the global help window, which you are just reading.\n"
|
||||||
"must be entered in as decimal or hexadecimal numbers or text.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Menu items beginning with following braces represent features that\n"
|
"o A short version of the global help is available by pressing <F3>.\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"
|
|
||||||
"\n"
|
"\n"
|
||||||
"To change any of these features, highlight it with the cursor\n"
|
"o Local help: To get help related to the current menu entry, use any\n"
|
||||||
"keys and press <Y> to build it in, <M> to make it a module or\n"
|
" of <?> <h>, or if in a data entry window then press <F1>.\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"
|
"\n"
|
||||||
"Some additional keyboard hints:\n"
|
|
||||||
"\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"
|
"----------\n"
|
||||||
"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
|
"Enter the requested information and press <Enter>. Hexadecimal values\n"
|
||||||
" you wish to change use <Enter> or <Space>. Goto submenu by \n"
|
"may be entered without the \"0x\" prefix.\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"
|
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Radiolists (Choice lists)\n"
|
"Text Box (Help Window)\n"
|
||||||
"-----------\n"
|
"----------------------\n"
|
||||||
"o Use the cursor keys to select the option you wish to set and press\n"
|
"Use movement keys as listed in table above.\n"
|
||||||
" <S> or the <SPACE BAR>.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
" Shortcut: Press the first letter of the option you wish to set then\n"
|
"Press any of <Enter> <Esc> <q> <F5> <F9> to exit.\n"
|
||||||
" press <S> or <SPACE BAR>.\n"
|
|
||||||
"\n"
|
|
||||||
"o To see available help for the item, press <F1>\n"
|
|
||||||
" Shortcut: Press <H> or <?>.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Data Entry\n"
|
"Alternate configuration files\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"
|
|
||||||
"-----------------------------\n"
|
"-----------------------------\n"
|
||||||
"nconfig supports the use of alternate configuration files for\n"
|
"nconfig supports switching between different configurations.\n"
|
||||||
"those who, for various reasons, find it necessary to switch\n"
|
"Press <F6> to save your current configuration. Press <F7> and enter\n"
|
||||||
"between different configurations.\n"
|
"a file name to load a previously saved configuration.\n"
|
||||||
"\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"
|
"\n"
|
||||||
"Even if you don't use alternate configuration files, but you\n"
|
"Terminal configuration\n"
|
||||||
"find during a nconfig session that you have completely messed\n"
|
"----------------------\n"
|
||||||
"up your settings, you may use the \"Load Alternate...\" option to\n"
|
"If you use nconfig in a xterm window, make sure your TERM environment\n"
|
||||||
"restore your previously saved settings from \".config\" without\n"
|
"variable specifies a terminal configuration which supports at least\n"
|
||||||
"restarting nconfig.\n"
|
"16 colors. Otherwise nconfig will look rather bad.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Other information\n"
|
"If the \"stty size\" command reports the current terminalsize correctly,\n"
|
||||||
"-----------------\n"
|
"nconfig will adapt to sizes larger than the traditional 80x25 \"standard\"\n"
|
||||||
"If you use nconfig in an XTERM window make sure you have your\n"
|
"and display longer menus properly.\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"
|
|
||||||
"\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"
|
"\n"
|
||||||
"Optional personality available\n"
|
"Single menu mode\n"
|
||||||
"------------------------------\n"
|
"----------------\n"
|
||||||
"If you prefer to have all of the options listed in a single menu, rather\n"
|
"If you prefer to have all of the menu entries listed in a single menu,\n"
|
||||||
"than the default multimenu hierarchy, run the nconfig with NCONFIG_MODE\n"
|
"rather than the default multimenu hierarchy, run nconfig with\n"
|
||||||
"environment variable set to single_menu. Example:\n"
|
"NCONFIG_MODE environment variable set to single_menu. Example:\n"
|
||||||
"\n"
|
"\n"
|
||||||
"make NCONFIG_MODE=single_menu nconfig\n"
|
"ct-ng NCONFIG_MODE=single_menu nconfig\n"
|
||||||
"\n"
|
"\n"
|
||||||
"<Enter> will then unroll the appropriate category, or enfold it if it\n"
|
"<Enter> will then unfold the appropriate category, or fold it if it\n"
|
||||||
"is already unrolled.\n"
|
"is already unfolded. Folded menu entries will be designated by a\n"
|
||||||
|
"leading \"++>\" and unfolded entries by a leading \"-->\".\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Note that this mode can eventually be a little more CPU expensive\n"
|
"Note that this mode can eventually be a little more CPU expensive than\n"
|
||||||
"(especially with a larger number of unrolled categories) than the\n"
|
"the default mode, especially with a larger number of unfolded submenus.\n"
|
||||||
"default mode.\n"
|
|
||||||
"\n"),
|
"\n"),
|
||||||
menu_no_f_instructions[] = N_(
|
menu_no_f_instructions[] = N_(
|
||||||
" You do not have function keys support. Please follow the\n"
|
"Legend: [*] built-in [ ] excluded <M> automatic < > automatic capable.\n"
|
||||||
" following instructions:\n"
|
"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
|
||||||
" Arrow keys navigate the menu.\n"
|
"\n"
|
||||||
" <Enter> or <right-arrow> selects submenus --->.\n"
|
"Use the following keys to navigate the menus:\n"
|
||||||
" Capital Letters are hotkeys.\n"
|
"Move up or down with <Up> and <Down>.\n"
|
||||||
" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
|
"Enter a submenu with <Enter> or <Right>.\n"
|
||||||
" Pressing SpaceBar toggles between the above options.\n"
|
"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
|
||||||
" Press <Esc> or <left-arrow> to go back one menu,\n"
|
"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
|
||||||
" <?> or <h> for Help, </> for Search.\n"
|
"Pressing <Space> cycles through the available options.\n"
|
||||||
" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
|
"To search for menu entries press </>.\n"
|
||||||
" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
|
"<Esc> always leaves the current window.\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_(
|
menu_instructions[] = N_(
|
||||||
" Arrow keys navigate the menu.\n"
|
"Legend: [*] built-in [ ] excluded <M> automatic < > automatic capable.\n"
|
||||||
" <Enter> or <right-arrow> selects submenus --->.\n"
|
"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
|
||||||
" Capital Letters are hotkeys.\n"
|
"\n"
|
||||||
" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
|
"Use the following keys to navigate the menus:\n"
|
||||||
" Pressing SpaceBar toggles between the above options\n"
|
"Move up or down with <Up> or <Down>.\n"
|
||||||
" Press <Esc>, <F5> or <left-arrow> to go back one menu,\n"
|
"Enter a submenu with <Enter> or <Right>.\n"
|
||||||
" <?>, <F1> or <h> for Help, </> for Search.\n"
|
"Exit a submenu to its parent menu with <Esc> or <Left>.\n"
|
||||||
" <1> is interchangeable with <F1>, <2> with <F2>, etc.\n"
|
"Pressing <y> includes, <n> excludes, <m> modularizes features.\n"
|
||||||
" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
|
"Pressing <Space> cycles through the available options.\n"
|
||||||
" <Esc> always leaves the current window\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_(
|
radiolist_instructions[] = N_(
|
||||||
" Use the arrow keys to navigate this window or\n"
|
"Press <Up>, <Down>, <Home> or <End> to navigate a radiolist, select\n"
|
||||||
" press the hotkey of the item you wish to select\n"
|
"with <Space>.\n"
|
||||||
" followed by the <SPACE BAR>.\n"
|
"For help related to the current entry press <?> or <h>.\n"
|
||||||
" Press <?>, <F1> or <h> for additional information about this option.\n"),
|
"For global help press <F1>.\n"),
|
||||||
inputbox_instructions_int[] = N_(
|
inputbox_instructions_int[] = N_(
|
||||||
"Please enter a decimal value.\n"
|
"Please enter a decimal value.\n"
|
||||||
"Fractions will not be accepted.\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_(
|
inputbox_instructions_hex[] = N_(
|
||||||
"Please enter a hexadecimal value.\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_(
|
inputbox_instructions_string[] = N_(
|
||||||
"Please enter a string value.\n"
|
"Please enter a string value.\n"
|
||||||
"Press <RETURN> to accept, <ESC> to cancel."),
|
"Press <Enter> to apply, <Esc> to cancel."),
|
||||||
setmod_text[] = N_(
|
setmod_text[] = N_(
|
||||||
"This feature depends on another which\n"
|
"This feature depends on another feature which has been configured as\n"
|
||||||
"has been configured as a module.\n"
|
"automatic. As a result, the current feature will be built as automatic too."),
|
||||||
"As a result, this feature will be built as a module."),
|
|
||||||
nohelp_text[] = N_(
|
|
||||||
"There is no help available for this option.\n"),
|
|
||||||
load_config_text[] = N_(
|
load_config_text[] = N_(
|
||||||
"Enter the name of the configuration file you wish to load.\n"
|
"Enter the name of the configuration file you wish to load.\n"
|
||||||
"Accept the name shown to restore the configuration you\n"
|
"Accept the name shown to restore the configuration you last\n"
|
||||||
"last retrieved. Leave blank to abort."),
|
"retrieved. Leave empty to abort."),
|
||||||
load_config_help[] = N_(
|
load_config_help[] = N_(
|
||||||
"\n"
|
|
||||||
"For various reasons, one may wish to keep several different\n"
|
"For various reasons, one may wish to keep several different\n"
|
||||||
"configurations available on a single machine.\n"
|
"configurations available on a single machine.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If you have saved a previous configuration in a file other than the\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"
|
"default one, entering its name here will allow you to load and modify\n"
|
||||||
"configuration.\n"
|
"that configuration.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If you are uncertain, then you have probably never used alternate\n"
|
"Leave empty to abort.\n"),
|
||||||
"configuration files. You should therefor leave this blank to abort.\n"),
|
|
||||||
save_config_text[] = N_(
|
save_config_text[] = N_(
|
||||||
"Enter a filename to which this configuration should be saved\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_(
|
save_config_help[] = N_(
|
||||||
"\n"
|
"For various reasons, one may wish to keep several different\n"
|
||||||
"For various reasons, one may wish to keep different configurations\n"
|
"configurations available on a single machine.\n"
|
||||||
"available on a single machine.\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"Entering a file name here will allow you to later retrieve, modify\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"
|
"and use the current configuration as an alternate to whatever\n"
|
||||||
"configuration options you have selected at that time.\n"
|
"configuration options you have selected at that time.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If you are uncertain what all this means then you should probably\n"
|
"Leave empty to abort.\n"),
|
||||||
"leave this blank.\n"),
|
|
||||||
search_help[] = N_(
|
search_help[] = N_(
|
||||||
"\n"
|
"Search for symbols (configuration variable names CONFIG_*) and display\n"
|
||||||
"Search for symbols and display their relations. Regular expressions\n"
|
"their relations. Regular expressions are supported.\n"
|
||||||
"are allowed.\n"
|
"Example: Search for \"^FOO\".\n"
|
||||||
"Example: search for \"^FOO\"\n"
|
|
||||||
"Result:\n"
|
"Result:\n"
|
||||||
"-----------------------------------------------------------------\n"
|
"-----------------------------------------------------------------\n"
|
||||||
"Symbol: FOO [ = m]\n"
|
"Symbol: FOO [ = m]\n"
|
||||||
@ -225,32 +219,32 @@ search_help[] = N_(
|
|||||||
"Defined at drivers/pci/Kconfig:47\n"
|
"Defined at drivers/pci/Kconfig:47\n"
|
||||||
"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
|
||||||
"Location:\n"
|
"Location:\n"
|
||||||
" -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
|
" -> Bus options (PCI, PCMCIA, EISA, ISA)\n"
|
||||||
" -> PCI support (PCI [ = y])\n"
|
" -> PCI support (PCI [ = y])\n"
|
||||||
" -> PCI access mode (<choice> [ = y])\n"
|
" -> PCI access mode (<choice> [ = y])\n"
|
||||||
"Selects: LIBCRC32\n"
|
"Selects: LIBCRC32\n"
|
||||||
"Selected by: BAR\n"
|
"Selected by: BAR\n"
|
||||||
"-----------------------------------------------------------------\n"
|
"-----------------------------------------------------------------\n"
|
||||||
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
"o The line 'Prompt:' shows the text displayed for this symbol in\n"
|
||||||
" this symbol\n"
|
" the menu hierarchy.\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 is\n"
|
||||||
" is defined\n"
|
" defined.\n"
|
||||||
"o The 'Depends on:' line tell what symbols needs to be defined for\n"
|
"o The 'Depends on:' line lists symbols that need to be defined for\n"
|
||||||
" this symbol to be visible in the menu (selectable)\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"
|
"o The 'Location:' lines tell, where in the menu structure this symbol\n"
|
||||||
" is located\n"
|
" is located. A location followed by a [ = y] indicates that this is\n"
|
||||||
" A location followed by a [ = y] indicate that this is a selectable\n"
|
" a selectable menu item, and the current value is displayed inside\n"
|
||||||
" menu item - and current value is displayed inside brackets.\n"
|
" brackets.\n"
|
||||||
"o The 'Selects:' line tell what symbol will be automatically\n"
|
"o The 'Selects:' line tells, what symbol will be automatically selected\n"
|
||||||
" selected if this symbol is selected (y or m)\n"
|
" 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"
|
"\n"
|
||||||
"Only relevant lines are shown.\n"
|
"Only relevant lines are shown.\n"
|
||||||
"\n\n"
|
"\n\n"
|
||||||
"Search examples:\n"
|
"Search examples:\n"
|
||||||
"Examples: USB => find all symbols containing USB\n"
|
"USB => find all symbols containing USB\n"
|
||||||
" ^USB => find all symbols starting with USB\n"
|
"^USB => find all symbols starting with USB\n"
|
||||||
" USB$ => find all symbols ending with USB\n"
|
"USB$ => find all symbols ending with USB\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
struct mitem {
|
struct mitem {
|
||||||
@ -280,6 +274,9 @@ static int global_exit;
|
|||||||
/* the currently selected button */
|
/* the currently selected button */
|
||||||
const char *current_instructions = menu_instructions;
|
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(struct menu *menu);
|
||||||
static void conf_choice(struct menu *menu);
|
static void conf_choice(struct menu *menu);
|
||||||
static void conf_string(struct menu *menu);
|
static void conf_string(struct menu *menu);
|
||||||
@ -318,19 +315,19 @@ struct function_keys function_keys[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key_str = "F2",
|
.key_str = "F2",
|
||||||
.func = "Sym Info",
|
.func = "SymInfo",
|
||||||
.key = F_SYMBOL,
|
.key = F_SYMBOL,
|
||||||
.handler = handle_f2,
|
.handler = handle_f2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key_str = "F3",
|
.key_str = "F3",
|
||||||
.func = "Insts",
|
.func = "Help 2",
|
||||||
.key = F_INSTS,
|
.key = F_INSTS,
|
||||||
.handler = handle_f3,
|
.handler = handle_f3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key_str = "F4",
|
.key_str = "F4",
|
||||||
.func = "Config",
|
.func = "ShowAll",
|
||||||
.key = F_CONF,
|
.key = F_CONF,
|
||||||
.handler = handle_f4,
|
.handler = handle_f4,
|
||||||
},
|
},
|
||||||
@ -354,7 +351,7 @@ struct function_keys function_keys[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.key_str = "F8",
|
.key_str = "F8",
|
||||||
.func = "Sym Search",
|
.func = "SymSearch",
|
||||||
.key = F_SEARCH,
|
.key = F_SEARCH,
|
||||||
.handler = handle_f8,
|
.handler = handle_f8,
|
||||||
},
|
},
|
||||||
@ -371,15 +368,16 @@ static void print_function_line(void)
|
|||||||
int i;
|
int i;
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
const int skip = 1;
|
const int skip = 1;
|
||||||
|
int lines = getmaxy(stdscr);
|
||||||
|
|
||||||
for (i = 0; i < function_keys_num; i++) {
|
for (i = 0; i < function_keys_num; i++) {
|
||||||
(void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
|
(void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
|
||||||
mvwprintw(main_window, LINES-3, offset,
|
mvwprintw(main_window, lines-3, offset,
|
||||||
"%s",
|
"%s",
|
||||||
function_keys[i].key_str);
|
function_keys[i].key_str);
|
||||||
(void) wattrset(main_window, attributes[FUNCTION_TEXT]);
|
(void) wattrset(main_window, attributes[FUNCTION_TEXT]);
|
||||||
offset += strlen(function_keys[i].key_str);
|
offset += strlen(function_keys[i].key_str);
|
||||||
mvwprintw(main_window, LINES-3,
|
mvwprintw(main_window, lines-3,
|
||||||
offset, "%s",
|
offset, "%s",
|
||||||
function_keys[i].func);
|
function_keys[i].func);
|
||||||
offset += strlen(function_keys[i].func) + skip;
|
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)
|
static void handle_f1(int *key, struct menu *current_item)
|
||||||
{
|
{
|
||||||
show_scroll_win(main_window,
|
show_scroll_win(main_window,
|
||||||
_("README"), _(nconf_readme));
|
_("Global help"), _(nconf_global_help));
|
||||||
return;
|
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)
|
static void handle_f3(int *key, struct menu *current_item)
|
||||||
{
|
{
|
||||||
show_scroll_win(main_window,
|
show_scroll_win(main_window,
|
||||||
_("Instructions"),
|
_("Short help"),
|
||||||
_(current_instructions));
|
_(current_instructions));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -695,15 +693,19 @@ static void search_conf(void)
|
|||||||
{
|
{
|
||||||
struct symbol **sym_arr;
|
struct symbol **sym_arr;
|
||||||
struct gstr res;
|
struct gstr res;
|
||||||
char dialog_input_result[100];
|
struct gstr title;
|
||||||
char *dialog_input;
|
char *dialog_input;
|
||||||
int dres;
|
int dres;
|
||||||
|
|
||||||
|
title = str_new();
|
||||||
|
str_printf( &title, _("Enter (sub)string or regexp to search for "
|
||||||
|
"(with or without \"%s\")"), CONFIG_);
|
||||||
|
|
||||||
again:
|
again:
|
||||||
dres = dialog_inputbox(main_window,
|
dres = dialog_inputbox(main_window,
|
||||||
_("Search Configuration Parameter"),
|
_("Search Configuration Parameter"),
|
||||||
_("Enter " CONFIG_ " (sub)string to search for "
|
str_get(&title),
|
||||||
"(with or without \"" CONFIG_ "\")"),
|
"", &dialog_input_result, &dialog_input_result_len);
|
||||||
"", dialog_input_result, 99);
|
|
||||||
switch (dres) {
|
switch (dres) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@ -712,6 +714,7 @@ again:
|
|||||||
_("Search Configuration"), search_help);
|
_("Search Configuration"), search_help);
|
||||||
goto again;
|
goto again;
|
||||||
default:
|
default:
|
||||||
|
str_free(&title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,11 +724,12 @@ again:
|
|||||||
dialog_input += strlen(CONFIG_);
|
dialog_input += strlen(CONFIG_);
|
||||||
|
|
||||||
sym_arr = sym_re_search(dialog_input);
|
sym_arr = sym_re_search(dialog_input);
|
||||||
res = get_relations_str(sym_arr);
|
res = get_relations_str(sym_arr, NULL);
|
||||||
free(sym_arr);
|
free(sym_arr);
|
||||||
show_scroll_win(main_window,
|
show_scroll_win(main_window,
|
||||||
_("Search Results"), str_get(&res));
|
_("Search Results"), str_get(&res));
|
||||||
str_free(&res);
|
str_free(&res);
|
||||||
|
str_free(&title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -759,9 +763,9 @@ static void build_conf(struct menu *menu)
|
|||||||
indent + 1, ' ', prompt);
|
indent + 1, ' ', prompt);
|
||||||
} else
|
} else
|
||||||
item_make(menu, 'm',
|
item_make(menu, 'm',
|
||||||
" %*c%s --->",
|
" %*c%s %s",
|
||||||
indent + 1,
|
indent + 1, ' ', prompt,
|
||||||
' ', prompt);
|
menu_is_empty(menu) ? "----" : "--->");
|
||||||
|
|
||||||
if (single_menu_mode && menu->data)
|
if (single_menu_mode && menu->data)
|
||||||
goto conf_childs;
|
goto conf_childs;
|
||||||
@ -903,7 +907,7 @@ static void build_conf(struct menu *menu)
|
|||||||
(sym_has_value(sym) || !sym_is_changable(sym)) ?
|
(sym_has_value(sym) || !sym_is_changable(sym)) ?
|
||||||
"" : _(" (NEW)"));
|
"" : _(" (NEW)"));
|
||||||
if (menu->prompt && menu->prompt->type == P_MENU) {
|
if (menu->prompt && menu->prompt->type == P_MENU) {
|
||||||
item_add_str(" --->");
|
item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -954,7 +958,7 @@ static void show_menu(const char *prompt, const char *instructions,
|
|||||||
|
|
||||||
clear();
|
clear();
|
||||||
(void) wattrset(main_window, attributes[NORMAL]);
|
(void) wattrset(main_window, attributes[NORMAL]);
|
||||||
print_in_middle(stdscr, 1, 0, COLS,
|
print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
|
||||||
menu_backtitle,
|
menu_backtitle,
|
||||||
attributes[MAIN_HEADING]);
|
attributes[MAIN_HEADING]);
|
||||||
|
|
||||||
@ -1067,7 +1071,6 @@ static void conf(struct menu *menu)
|
|||||||
struct menu *submenu = 0;
|
struct menu *submenu = 0;
|
||||||
const char *prompt = menu_get_prompt(menu);
|
const char *prompt = menu_get_prompt(menu);
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
struct menu *active_menu = NULL;
|
|
||||||
int res;
|
int res;
|
||||||
int current_index = 0;
|
int current_index = 0;
|
||||||
int last_top_row = 0;
|
int last_top_row = 0;
|
||||||
@ -1152,13 +1155,9 @@ static void conf(struct menu *menu)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
submenu = (struct menu *) item_data();
|
submenu = (struct menu *) item_data();
|
||||||
active_menu = (struct menu *)item_data();
|
|
||||||
if (!submenu || !menu_is_visible(submenu))
|
if (!submenu || !menu_is_visible(submenu))
|
||||||
continue;
|
continue;
|
||||||
if (submenu)
|
sym = submenu->sym;
|
||||||
sym = submenu->sym;
|
|
||||||
else
|
|
||||||
sym = NULL;
|
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case ' ':
|
case ' ':
|
||||||
@ -1222,20 +1221,13 @@ static void conf_message_callback(const char *fmt, va_list ap)
|
|||||||
|
|
||||||
static void show_help(struct menu *menu)
|
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)
|
||||||
if (menu->sym->name) {
|
return;
|
||||||
str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name);
|
|
||||||
str_append(&help, _(menu_get_help(menu)));
|
help = str_new();
|
||||||
str_append(&help, "\n");
|
menu_get_ext_help(menu, &help);
|
||||||
get_symbol_str(&help, menu->sym);
|
|
||||||
} else {
|
|
||||||
str_append(&help, _(menu_get_help(menu)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
str_append(&help, nohelp_text);
|
|
||||||
}
|
|
||||||
show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
|
show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
|
||||||
str_free(&help);
|
str_free(&help);
|
||||||
}
|
}
|
||||||
@ -1360,7 +1352,6 @@ static void conf_choice(struct menu *menu)
|
|||||||
static void conf_string(struct menu *menu)
|
static void conf_string(struct menu *menu)
|
||||||
{
|
{
|
||||||
const char *prompt = menu_get_prompt(menu);
|
const char *prompt = menu_get_prompt(menu);
|
||||||
char dialog_input_result[256];
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int res;
|
int res;
|
||||||
@ -1383,8 +1374,8 @@ static void conf_string(struct menu *menu)
|
|||||||
prompt ? _(prompt) : _("Main Menu"),
|
prompt ? _(prompt) : _("Main Menu"),
|
||||||
heading,
|
heading,
|
||||||
sym_get_string_value(menu->sym),
|
sym_get_string_value(menu->sym),
|
||||||
dialog_input_result,
|
&dialog_input_result,
|
||||||
sizeof(dialog_input_result));
|
&dialog_input_result_len);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case 0:
|
case 0:
|
||||||
if (sym_set_string_value(menu->sym,
|
if (sym_set_string_value(menu->sym,
|
||||||
@ -1404,14 +1395,13 @@ static void conf_string(struct menu *menu)
|
|||||||
|
|
||||||
static void conf_load(void)
|
static void conf_load(void)
|
||||||
{
|
{
|
||||||
char dialog_input_result[256];
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int res;
|
int res;
|
||||||
res = dialog_inputbox(main_window,
|
res = dialog_inputbox(main_window,
|
||||||
NULL, load_config_text,
|
NULL, load_config_text,
|
||||||
filename,
|
filename,
|
||||||
dialog_input_result,
|
&dialog_input_result,
|
||||||
sizeof(dialog_input_result));
|
&dialog_input_result_len);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!dialog_input_result[0])
|
if (!dialog_input_result[0])
|
||||||
@ -1436,14 +1426,13 @@ static void conf_load(void)
|
|||||||
|
|
||||||
static void conf_save(void)
|
static void conf_save(void)
|
||||||
{
|
{
|
||||||
char dialog_input_result[256];
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int res;
|
int res;
|
||||||
res = dialog_inputbox(main_window,
|
res = dialog_inputbox(main_window,
|
||||||
NULL, save_config_text,
|
NULL, save_config_text,
|
||||||
filename,
|
filename,
|
||||||
dialog_input_result,
|
&dialog_input_result,
|
||||||
sizeof(dialog_input_result));
|
&dialog_input_result_len);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case 0:
|
case 0:
|
||||||
if (!dialog_input_result[0])
|
if (!dialog_input_result[0])
|
||||||
@ -1470,14 +1459,18 @@ static void conf_save(void)
|
|||||||
|
|
||||||
void setup_windows(void)
|
void setup_windows(void)
|
||||||
{
|
{
|
||||||
|
int lines, columns;
|
||||||
|
|
||||||
|
getmaxyx(stdscr, lines, columns);
|
||||||
|
|
||||||
if (main_window != NULL)
|
if (main_window != NULL)
|
||||||
delwin(main_window);
|
delwin(main_window);
|
||||||
|
|
||||||
/* set up the menu and menu 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);
|
keypad(main_window, TRUE);
|
||||||
mwin_max_lines = LINES-7;
|
mwin_max_lines = lines-7;
|
||||||
mwin_max_cols = COLS-6;
|
mwin_max_cols = columns-6;
|
||||||
|
|
||||||
/* panels order is from bottom to top */
|
/* panels order is from bottom to top */
|
||||||
new_panel(main_window);
|
new_panel(main_window);
|
||||||
@ -1485,12 +1478,18 @@ void setup_windows(void)
|
|||||||
|
|
||||||
int main(int ac, char **av)
|
int main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
int lines, columns;
|
||||||
char *mode;
|
char *mode;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
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_parse(av[1]);
|
||||||
conf_read(NULL);
|
conf_read(NULL);
|
||||||
|
|
||||||
@ -1510,7 +1509,8 @@ int main(int ac, char **av)
|
|||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|
||||||
if (COLS < 75 || LINES < 20) {
|
getmaxyx(stdscr, lines, columns);
|
||||||
|
if (columns < 75 || lines < 20) {
|
||||||
endwin();
|
endwin();
|
||||||
printf("Your terminal should have at "
|
printf("Your terminal should have at "
|
||||||
"least 20 lines and 75 columns\n");
|
"least 20 lines and 75 columns\n");
|
||||||
@ -1518,7 +1518,11 @@ int main(int ac, char **av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
notimeout(stdscr, FALSE);
|
notimeout(stdscr, FALSE);
|
||||||
|
#if NCURSES_REENTRANT
|
||||||
|
set_escdelay(1);
|
||||||
|
#else
|
||||||
ESCDELAY = 1;
|
ESCDELAY = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* set btns menu */
|
/* set btns menu */
|
||||||
curses_menu = new_menu(curses_menu_items);
|
curses_menu = new_menu(curses_menu_items);
|
||||||
@ -1558,4 +1562,3 @@ int main(int ac, char **av)
|
|||||||
endwin();
|
endwin();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ static void set_normal_colors(void)
|
|||||||
init_pair(INPUT_FIELD, -1, -1);
|
init_pair(INPUT_FIELD, -1, -1);
|
||||||
|
|
||||||
init_pair(FUNCTION_HIGHLIGHT, -1, -1);
|
init_pair(FUNCTION_HIGHLIGHT, -1, -1);
|
||||||
init_pair(FUNCTION_TEXT, COLOR_BLUE, -1);
|
init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* available attributes:
|
/* available attributes:
|
||||||
@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
|
|||||||
|
|
||||||
total_width = max(msg_width, btns_width);
|
total_width = max(msg_width, btns_width);
|
||||||
/* place dialog in middle of screen */
|
/* place dialog in middle of screen */
|
||||||
y = (LINES-(msg_lines+4))/2;
|
y = (getmaxy(stdscr)-(msg_lines+4))/2;
|
||||||
x = (COLS-(total_width+4))/2;
|
x = (getmaxx(stdscr)-(total_width+4))/2;
|
||||||
|
|
||||||
|
|
||||||
/* create the windows */
|
/* 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,
|
int dialog_inputbox(WINDOW *main_window,
|
||||||
const char *title, const char *prompt,
|
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_lines = 0;
|
||||||
int prompt_width = 0;
|
int prompt_width = 0;
|
||||||
@ -367,7 +367,13 @@ int dialog_inputbox(WINDOW *main_window,
|
|||||||
int i, x, y;
|
int i, x, y;
|
||||||
int res = -1;
|
int res = -1;
|
||||||
int cursor_position = strlen(init);
|
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: */
|
/* find the widest line of msg: */
|
||||||
prompt_lines = get_line_no(prompt);
|
prompt_lines = get_line_no(prompt);
|
||||||
@ -381,10 +387,10 @@ int dialog_inputbox(WINDOW *main_window,
|
|||||||
prompt_width = max(prompt_width, strlen(title));
|
prompt_width = max(prompt_width, strlen(title));
|
||||||
|
|
||||||
/* place dialog in middle of screen */
|
/* place dialog in middle of screen */
|
||||||
y = (LINES-(prompt_lines+4))/2;
|
y = (getmaxy(stdscr)-(prompt_lines+4))/2;
|
||||||
x = (COLS-(prompt_width+4))/2;
|
x = (getmaxx(stdscr)-(prompt_width+4))/2;
|
||||||
|
|
||||||
strncpy(result, init, result_len);
|
strncpy(result, init, *result_len);
|
||||||
|
|
||||||
/* create the windows */
|
/* create the windows */
|
||||||
win = newwin(prompt_lines+6, prompt_width+7, y, x);
|
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);
|
fill_window(prompt_win, prompt);
|
||||||
|
|
||||||
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
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 */
|
/* create panels */
|
||||||
panel = new_panel(win);
|
panel = new_panel(win);
|
||||||
@ -431,6 +439,8 @@ int dialog_inputbox(WINDOW *main_window,
|
|||||||
&result[cursor_position],
|
&result[cursor_position],
|
||||||
len-cursor_position+1);
|
len-cursor_position+1);
|
||||||
cursor_position--;
|
cursor_position--;
|
||||||
|
cursor_form_win--;
|
||||||
|
len--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_DC:
|
case KEY_DC:
|
||||||
@ -438,38 +448,63 @@ int dialog_inputbox(WINDOW *main_window,
|
|||||||
memmove(&result[cursor_position],
|
memmove(&result[cursor_position],
|
||||||
&result[cursor_position+1],
|
&result[cursor_position+1],
|
||||||
len-cursor_position+1);
|
len-cursor_position+1);
|
||||||
|
len--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
if (cursor_position < len &&
|
if (cursor_position < len) {
|
||||||
cursor_position < min(result_len, prompt_width))
|
|
||||||
cursor_position++;
|
cursor_position++;
|
||||||
|
cursor_form_win++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
if (cursor_position > 0)
|
if (cursor_position > 0) {
|
||||||
cursor_position--;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((isgraph(res) || isspace(res)) &&
|
if ((isgraph(res) || isspace(res))) {
|
||||||
len-2 < result_len) {
|
/* 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 */
|
/* insert the char at the proper position */
|
||||||
memmove(&result[cursor_position+1],
|
memmove(&result[cursor_position+1],
|
||||||
&result[cursor_position],
|
&result[cursor_position],
|
||||||
len+1);
|
len-cursor_position+1);
|
||||||
result[cursor_position] = res;
|
result[cursor_position] = res;
|
||||||
cursor_position++;
|
cursor_position++;
|
||||||
|
cursor_form_win++;
|
||||||
|
len++;
|
||||||
} else {
|
} else {
|
||||||
mvprintw(0, 0, "unknow key: %d\n", res);
|
mvprintw(0, 0, "unknown key: %d\n", res);
|
||||||
}
|
}
|
||||||
break;
|
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);
|
wmove(form_win, 0, 0);
|
||||||
wclrtoeol(form_win);
|
wclrtoeol(form_win);
|
||||||
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
||||||
mvwprintw(form_win, 0, 0, "%s", result);
|
mvwprintw(form_win, 0, 0, "%s",
|
||||||
wmove(form_win, 0, cursor_position);
|
result + cursor_position-cursor_form_win);
|
||||||
|
wmove(form_win, 0, cursor_form_win);
|
||||||
touchwin(win);
|
touchwin(win);
|
||||||
refresh_all_windows(main_window);
|
refresh_all_windows(main_window);
|
||||||
|
|
||||||
@ -510,7 +545,7 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
int total_lines = get_line_no(text);
|
int total_lines = get_line_no(text);
|
||||||
int x, y;
|
int x, y, lines, columns;
|
||||||
int start_x = 0, start_y = 0;
|
int start_x = 0, start_y = 0;
|
||||||
int text_lines = 0, text_cols = 0;
|
int text_lines = 0, text_cols = 0;
|
||||||
int total_cols = 0;
|
int total_cols = 0;
|
||||||
@ -521,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
WINDOW *pad;
|
WINDOW *pad;
|
||||||
PANEL *panel;
|
PANEL *panel;
|
||||||
|
|
||||||
|
getmaxyx(stdscr, lines, columns);
|
||||||
|
|
||||||
/* find the widest line of msg: */
|
/* find the widest line of msg: */
|
||||||
total_lines = get_line_no(text);
|
total_lines = get_line_no(text);
|
||||||
for (i = 0; i < total_lines; i++) {
|
for (i = 0; i < total_lines; i++) {
|
||||||
@ -534,14 +571,14 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
(void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
|
(void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
|
||||||
fill_window(pad, text);
|
fill_window(pad, text);
|
||||||
|
|
||||||
win_lines = min(total_lines+4, LINES-2);
|
win_lines = min(total_lines+4, lines-2);
|
||||||
win_cols = min(total_cols+2, COLS-2);
|
win_cols = min(total_cols+2, columns-2);
|
||||||
text_lines = max(win_lines-4, 0);
|
text_lines = max(win_lines-4, 0);
|
||||||
text_cols = max(win_cols-2, 0);
|
text_cols = max(win_cols-2, 0);
|
||||||
|
|
||||||
/* place window in middle of screen */
|
/* place window in middle of screen */
|
||||||
y = (LINES-win_lines)/2;
|
y = (lines-win_lines)/2;
|
||||||
x = (COLS-win_cols)/2;
|
x = (columns-win_cols)/2;
|
||||||
|
|
||||||
win = newwin(win_lines, win_cols, y, x);
|
win = newwin(win_lines, win_cols, y, x);
|
||||||
keypad(win, TRUE);
|
keypad(win, TRUE);
|
||||||
@ -569,9 +606,11 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
switch (res) {
|
switch (res) {
|
||||||
case KEY_NPAGE:
|
case KEY_NPAGE:
|
||||||
case ' ':
|
case ' ':
|
||||||
|
case 'd':
|
||||||
start_y += text_lines-2;
|
start_y += text_lines-2;
|
||||||
break;
|
break;
|
||||||
case KEY_PPAGE:
|
case KEY_PPAGE:
|
||||||
|
case 'u':
|
||||||
start_y -= text_lines+2;
|
start_y -= text_lines+2;
|
||||||
break;
|
break;
|
||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
@ -597,10 +636,10 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
start_x++;
|
start_x++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (res == 10 || res == 27 || res == 'q'
|
if (res == 10 || res == 27 || res == 'q' ||
|
||||||
|| res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) {
|
res == KEY_F(F_HELP) || res == KEY_F(F_BACK) ||
|
||||||
|
res == KEY_F(F_EXIT))
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (start_y < 0)
|
if (start_y < 0)
|
||||||
start_y = 0;
|
start_y = 0;
|
||||||
if (start_y >= total_lines-text_lines)
|
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 btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
|
||||||
int dialog_inputbox(WINDOW *main_window,
|
int dialog_inputbox(WINDOW *main_window,
|
||||||
const char *title, const char *prompt,
|
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 refresh_all_windows(WINDOW *main_window);
|
||||||
void show_scroll_win(WINDOW *main_window,
|
void show_scroll_win(WINDOW *main_window,
|
||||||
const char *title,
|
const char *title,
|
||||||
|
219
kconfig/symbol.c
219
kconfig/symbol.c
@ -9,7 +9,6 @@
|
|||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
struct symbol symbol_yes = {
|
struct symbol symbol_yes = {
|
||||||
@ -113,7 +112,7 @@ struct property *sym_get_env_prop(struct symbol *sym)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct property *sym_get_default_prop(struct symbol *sym)
|
static struct property *sym_get_default_prop(struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
|
|
||||||
@ -137,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
|
|||||||
return NULL;
|
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);
|
sym_calc_value(sym);
|
||||||
switch (sym->type) {
|
switch (sym->type) {
|
||||||
@ -150,13 +149,14 @@ static int sym_get_range_val(struct symbol *sym, int base)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return strtol(sym->curr.val, NULL, base);
|
return strtoll(sym->curr.val, NULL, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sym_validate_range(struct symbol *sym)
|
static void sym_validate_range(struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
int base, val, val2;
|
int base;
|
||||||
|
long long val, val2;
|
||||||
char str[64];
|
char str[64];
|
||||||
|
|
||||||
switch (sym->type) {
|
switch (sym->type) {
|
||||||
@ -172,7 +172,7 @@ static void sym_validate_range(struct symbol *sym)
|
|||||||
prop = sym_get_range_prop(sym);
|
prop = sym_get_range_prop(sym);
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return;
|
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);
|
val2 = sym_get_range_val(prop->expr->left.sym, base);
|
||||||
if (val >= val2) {
|
if (val >= val2) {
|
||||||
val2 = sym_get_range_val(prop->expr->right.sym, base);
|
val2 = sym_get_range_val(prop->expr->right.sym, base);
|
||||||
@ -180,12 +180,32 @@ static void sym_validate_range(struct symbol *sym)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sym->type == S_INT)
|
if (sym->type == S_INT)
|
||||||
sprintf(str, "%d", val2);
|
sprintf(str, "%lld", val2);
|
||||||
else
|
else
|
||||||
sprintf(str, "0x%x", val2);
|
sprintf(str, "0x%llx", val2);
|
||||||
sym->curr.val = strdup(str);
|
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)
|
static void sym_calc_visibility(struct symbol *sym)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
@ -263,11 +283,18 @@ static struct symbol *sym_calc_choice(struct symbol *sym)
|
|||||||
struct symbol *def_sym;
|
struct symbol *def_sym;
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
struct expr *e;
|
struct expr *e;
|
||||||
|
int flags;
|
||||||
|
|
||||||
/* first calculate all choice values' visibilities */
|
/* first calculate all choice values' visibilities */
|
||||||
|
flags = sym->flags;
|
||||||
prop = sym_get_choice_prop(sym);
|
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);
|
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? */
|
/* is the user choice visible? */
|
||||||
def_sym = sym->def[S_DEF_USER].val;
|
def_sym = sym->def[S_DEF_USER].val;
|
||||||
@ -294,6 +321,14 @@ void sym_calc_value(struct symbol *sym)
|
|||||||
|
|
||||||
if (sym->flags & SYMBOL_VALID)
|
if (sym->flags & SYMBOL_VALID)
|
||||||
return;
|
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;
|
sym->flags |= SYMBOL_VALID;
|
||||||
|
|
||||||
oldval = sym->curr;
|
oldval = sym->curr;
|
||||||
@ -419,6 +454,9 @@ void sym_calc_value(struct symbol *sym)
|
|||||||
|
|
||||||
if (sym->flags & SYMBOL_AUTO)
|
if (sym->flags & SYMBOL_AUTO)
|
||||||
sym->flags &= ~SYMBOL_WRITE;
|
sym->flags &= ~SYMBOL_WRITE;
|
||||||
|
|
||||||
|
if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
|
||||||
|
set_all_choice_values(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sym_clear_all_valid(void)
|
void sym_clear_all_valid(void)
|
||||||
@ -433,26 +471,6 @@ void sym_clear_all_valid(void)
|
|||||||
sym_calc_value(modules_sym);
|
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)
|
bool sym_tristate_within_range(struct symbol *sym, tristate val)
|
||||||
{
|
{
|
||||||
int type = sym_get_type(sym);
|
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)
|
bool sym_string_within_range(struct symbol *sym, const char *str)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
int val;
|
long long val;
|
||||||
|
|
||||||
switch (sym->type) {
|
switch (sym->type) {
|
||||||
case S_STRING:
|
case S_STRING:
|
||||||
@ -588,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
|
|||||||
prop = sym_get_range_prop(sym);
|
prop = sym_get_range_prop(sym);
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return true;
|
return true;
|
||||||
val = strtol(str, NULL, 10);
|
val = strtoll(str, NULL, 10);
|
||||||
return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
|
return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
|
||||||
val <= sym_get_range_val(prop->expr->right.sym, 10);
|
val <= sym_get_range_val(prop->expr->right.sym, 10);
|
||||||
case S_HEX:
|
case S_HEX:
|
||||||
@ -597,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
|
|||||||
prop = sym_get_range_prop(sym);
|
prop = sym_get_range_prop(sym);
|
||||||
if (!prop)
|
if (!prop)
|
||||||
return true;
|
return true;
|
||||||
val = strtol(str, NULL, 16);
|
val = strtoll(str, NULL, 16);
|
||||||
return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
|
return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
|
||||||
val <= sym_get_range_val(prop->expr->right.sym, 16);
|
val <= sym_get_range_val(prop->expr->right.sym, 16);
|
||||||
case S_BOOLEAN:
|
case S_BOOLEAN:
|
||||||
@ -650,11 +668,11 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
|
|||||||
size = strlen(newval) + 1;
|
size = strlen(newval) + 1;
|
||||||
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
|
if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
|
||||||
size += 2;
|
size += 2;
|
||||||
sym->def[S_DEF_USER].val = val = malloc(size);
|
sym->def[S_DEF_USER].val = val = xmalloc(size);
|
||||||
*val++ = '0';
|
*val++ = '0';
|
||||||
*val++ = 'x';
|
*val++ = 'x';
|
||||||
} else if (!oldval || strcmp(oldval, newval))
|
} else if (!oldval || strcmp(oldval, newval))
|
||||||
sym->def[S_DEF_USER].val = val = malloc(size);
|
sym->def[S_DEF_USER].val = val = xmalloc(size);
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -751,7 +769,8 @@ const char *sym_get_string_value(struct symbol *sym)
|
|||||||
case no:
|
case no:
|
||||||
return "n";
|
return "n";
|
||||||
case mod:
|
case mod:
|
||||||
return "m";
|
sym_calc_value(modules_sym);
|
||||||
|
return (modules_sym->curr.tri == no) ? "n" : "m";
|
||||||
case yes:
|
case yes:
|
||||||
return "y";
|
return "y";
|
||||||
}
|
}
|
||||||
@ -805,7 +824,7 @@ struct symbol *sym_lookup(const char *name, int flags)
|
|||||||
hash = 0;
|
hash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol = malloc(sizeof(*symbol));
|
symbol = xmalloc(sizeof(*symbol));
|
||||||
memset(symbol, 0, sizeof(*symbol));
|
memset(symbol, 0, sizeof(*symbol));
|
||||||
symbol->name = new_name;
|
symbol->name = new_name;
|
||||||
symbol->type = S_UNKNOWN;
|
symbol->type = S_UNKNOWN;
|
||||||
@ -856,7 +875,7 @@ const char *sym_expand_string_value(const char *in)
|
|||||||
size_t reslen;
|
size_t reslen;
|
||||||
|
|
||||||
reslen = strlen(in) + 1;
|
reslen = strlen(in) + 1;
|
||||||
res = malloc(reslen);
|
res = xmalloc(reslen);
|
||||||
res[0] = '\0';
|
res[0] = '\0';
|
||||||
|
|
||||||
while ((src = strchr(in, '$'))) {
|
while ((src = strchr(in, '$'))) {
|
||||||
@ -893,38 +912,132 @@ const char *sym_expand_string_value(const char *in)
|
|||||||
return res;
|
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_re_search(const char *pattern)
|
||||||
{
|
{
|
||||||
struct symbol *sym, **sym_arr = NULL;
|
struct symbol *sym, **sym_arr = NULL;
|
||||||
|
struct sym_match *sym_match_arr = NULL;
|
||||||
int i, cnt, size;
|
int i, cnt, size;
|
||||||
regex_t re;
|
regex_t re;
|
||||||
|
regmatch_t match[1];
|
||||||
|
|
||||||
cnt = size = 0;
|
cnt = size = 0;
|
||||||
/* Skip if empty */
|
/* Skip if empty */
|
||||||
if (strlen(pattern) == 0)
|
if (strlen(pattern) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
|
if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for_all_symbols(i, sym) {
|
for_all_symbols(i, sym) {
|
||||||
if (sym->flags & SYMBOL_CONST || !sym->name)
|
if (sym->flags & SYMBOL_CONST || !sym->name)
|
||||||
continue;
|
continue;
|
||||||
if (regexec(&re, sym->name, 0, NULL, 0))
|
if (regexec(&re, sym->name, 1, match, 0))
|
||||||
continue;
|
continue;
|
||||||
if (cnt + 1 >= size) {
|
if (cnt >= size) {
|
||||||
void *tmp = sym_arr;
|
void *tmp;
|
||||||
size += 16;
|
size += 16;
|
||||||
sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
|
tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
|
||||||
if (!sym_arr) {
|
if (!tmp)
|
||||||
free(tmp);
|
goto sym_re_search_free;
|
||||||
return NULL;
|
sym_match_arr = tmp;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sym_calc_value(sym);
|
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_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);
|
regfree(&re);
|
||||||
|
|
||||||
return sym_arr;
|
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
|
* When we check for recursive dependencies we use a stack to save
|
||||||
* current state so we can print out relevant info to user.
|
* 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.
|
* 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 {
|
static struct dep_stack {
|
||||||
struct dep_stack *prev, *next;
|
struct dep_stack *prev, *next;
|
||||||
@ -1053,6 +1166,10 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
|
|||||||
case E_NOT:
|
case E_NOT:
|
||||||
return sym_check_expr_deps(e->left.expr);
|
return sym_check_expr_deps(e->left.expr);
|
||||||
case E_EQUAL:
|
case E_EQUAL:
|
||||||
|
case E_GEQ:
|
||||||
|
case E_GTH:
|
||||||
|
case E_LEQ:
|
||||||
|
case E_LTH:
|
||||||
case E_UNEQUAL:
|
case E_UNEQUAL:
|
||||||
sym = sym_check_deps(e->left.sym);
|
sym = sym_check_deps(e->left.sym);
|
||||||
if (sym)
|
if (sym)
|
||||||
@ -1178,7 +1295,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
|
|||||||
struct property *prop;
|
struct property *prop;
|
||||||
struct property **propp;
|
struct property **propp;
|
||||||
|
|
||||||
prop = malloc(sizeof(*prop));
|
prop = xmalloc(sizeof(*prop));
|
||||||
memset(prop, 0, sizeof(*prop));
|
memset(prop, 0, sizeof(*prop));
|
||||||
prop->type = type;
|
prop->type = type;
|
||||||
prop->sym = sym;
|
prop->sym = sym;
|
||||||
@ -1255,4 +1372,6 @@ static void prop_add_env(const char *env)
|
|||||||
p = getenv(env);
|
p = getenv(env);
|
||||||
if (p)
|
if (p)
|
||||||
sym_add_default(sym, 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.
|
* Released under the terms of the GNU GPL v2.0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "lkc.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));
|
memset(file, 0, sizeof(*file));
|
||||||
file->name = file_name;
|
file->name = file_name;
|
||||||
file->next = file_list;
|
file->next = file_list;
|
||||||
@ -79,23 +81,13 @@ int file_write_dep(const char *name)
|
|||||||
struct gstr str_new(void)
|
struct gstr str_new(void)
|
||||||
{
|
{
|
||||||
struct gstr gs;
|
struct gstr gs;
|
||||||
gs.s = malloc(sizeof(char) * 64);
|
gs.s = xmalloc(sizeof(char) * 64);
|
||||||
gs.len = 64;
|
gs.len = 64;
|
||||||
gs.max_width = 0;
|
gs.max_width = 0;
|
||||||
strcpy(gs.s, "\0");
|
strcpy(gs.s, "\0");
|
||||||
return gs;
|
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 */
|
/* Free storage for growable string */
|
||||||
void str_free(struct gstr *gs)
|
void str_free(struct gstr *gs)
|
||||||
{
|
{
|
||||||
@ -136,3 +128,20 @@ const char *str_get(struct gstr *gs)
|
|||||||
return gs->s;
|
return gs->s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *xmalloc(size_t size)
|
||||||
|
{
|
||||||
|
void *p = malloc(size);
|
||||||
|
if (p)
|
||||||
|
return p;
|
||||||
|
fprintf(stderr, "Out of memory.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *xcalloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *p = calloc(nmemb, size);
|
||||||
|
if (p)
|
||||||
|
return p;
|
||||||
|
fprintf(stderr, "Out of memory.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
@ -7,18 +7,9 @@
|
|||||||
%pic
|
%pic
|
||||||
%struct-type
|
%struct-type
|
||||||
|
|
||||||
%{
|
|
||||||
# ifndef offsetof
|
|
||||||
# include <stddef.h>
|
|
||||||
# ifndef offsetof
|
|
||||||
# define offsetof(st, m) ((size_t)(&((st *)0)->m))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
%}
|
|
||||||
|
|
||||||
struct kconf_id;
|
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
|
mainmenu, T_MAINMENU, TF_COMMAND
|
||||||
@ -53,4 +44,5 @@ on, T_ON, TF_PARAM
|
|||||||
modules, T_OPT_MODULES, TF_OPTION
|
modules, T_OPT_MODULES, TF_OPTION
|
||||||
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
|
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
|
||||||
env, T_OPT_ENV, 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 nostdinit noyywrap never-interactive full ecs
|
||||||
%option 8bit backup nodefault perf-report perf-report
|
%option 8bit nodefault perf-report perf-report
|
||||||
%option noinput
|
%option noinput
|
||||||
%x COMMAND HELP STRING PARAM
|
%x COMMAND HELP STRING PARAM
|
||||||
%{
|
%{
|
||||||
@ -14,7 +14,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
#define START_STRSIZE 16
|
#define START_STRSIZE 16
|
||||||
@ -28,8 +27,8 @@ static char *text;
|
|||||||
static int text_size, text_asize;
|
static int text_size, text_asize;
|
||||||
|
|
||||||
struct buffer {
|
struct buffer {
|
||||||
struct buffer *parent;
|
struct buffer *parent;
|
||||||
YY_BUFFER_STATE state;
|
YY_BUFFER_STATE state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct buffer *current_buf;
|
struct buffer *current_buf;
|
||||||
@ -41,7 +40,7 @@ static void zconf_endfile(void);
|
|||||||
|
|
||||||
static void new_string(void)
|
static void new_string(void)
|
||||||
{
|
{
|
||||||
text = malloc(START_STRSIZE);
|
text = xmalloc(START_STRSIZE);
|
||||||
text_asize = START_STRSIZE;
|
text_asize = START_STRSIZE;
|
||||||
text_size = 0;
|
text_size = 0;
|
||||||
*text = 0;
|
*text = 0;
|
||||||
@ -63,13 +62,12 @@ static void append_string(const char *str, int size)
|
|||||||
|
|
||||||
static void alloc_string(const char *str, int size)
|
static void alloc_string(const char *str, int size)
|
||||||
{
|
{
|
||||||
text = malloc(size + 1);
|
text = xmalloc(size + 1);
|
||||||
memcpy(text, str, size);
|
memcpy(text, str, size);
|
||||||
text[size] = 0;
|
text[size] = 0;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
ws [ \n\t]
|
|
||||||
n [A-Za-z0-9_]
|
n [A-Za-z0-9_]
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -96,7 +94,7 @@ n [A-Za-z0-9_]
|
|||||||
|
|
||||||
<COMMAND>{
|
<COMMAND>{
|
||||||
{n}+ {
|
{n}+ {
|
||||||
struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||||
BEGIN(PARAM);
|
BEGIN(PARAM);
|
||||||
current_pos.file = current_file;
|
current_pos.file = current_file;
|
||||||
current_pos.lineno = current_file->lineno;
|
current_pos.lineno = current_file->lineno;
|
||||||
@ -124,6 +122,10 @@ n [A-Za-z0-9_]
|
|||||||
"!" return T_NOT;
|
"!" return T_NOT;
|
||||||
"=" return T_EQUAL;
|
"=" return T_EQUAL;
|
||||||
"!=" return T_UNEQUAL;
|
"!=" return T_UNEQUAL;
|
||||||
|
"<=" return T_LESS_EQUAL;
|
||||||
|
">=" return T_GREATER_EQUAL;
|
||||||
|
"<" return T_LESS;
|
||||||
|
">" return T_GREATER;
|
||||||
\"|\' {
|
\"|\' {
|
||||||
str = yytext[0];
|
str = yytext[0];
|
||||||
new_string();
|
new_string();
|
||||||
@ -132,7 +134,7 @@ n [A-Za-z0-9_]
|
|||||||
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
|
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
|
||||||
--- /* ignore */
|
--- /* ignore */
|
||||||
({n}|[-/.])+ {
|
({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) {
|
if (id && id->flags & TF_PARAM) {
|
||||||
zconflval.id = id;
|
zconflval.id = id;
|
||||||
return id->token;
|
return id->token;
|
||||||
@ -143,7 +145,12 @@ n [A-Za-z0-9_]
|
|||||||
}
|
}
|
||||||
#.* /* comment */
|
#.* /* comment */
|
||||||
\\\n current_file->lineno++;
|
\\\n current_file->lineno++;
|
||||||
.
|
[[:blank:]]+
|
||||||
|
. {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s:%d:warning: ignoring unsupported character '%c'\n",
|
||||||
|
zconf_curname(), zconf_lineno(), *yytext);
|
||||||
|
}
|
||||||
<<EOF>> {
|
<<EOF>> {
|
||||||
BEGIN(INITIAL);
|
BEGIN(INITIAL);
|
||||||
}
|
}
|
||||||
@ -289,7 +296,7 @@ void zconf_initscan(const char *name)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_buf = malloc(sizeof(*current_buf));
|
current_buf = xmalloc(sizeof(*current_buf));
|
||||||
memset(current_buf, 0, sizeof(*current_buf));
|
memset(current_buf, 0, sizeof(*current_buf));
|
||||||
|
|
||||||
current_file = file_lookup(name);
|
current_file = file_lookup(name);
|
||||||
@ -300,7 +307,7 @@ void zconf_nextfile(const char *name)
|
|||||||
{
|
{
|
||||||
struct file *iter;
|
struct file *iter;
|
||||||
struct file *file = file_lookup(name);
|
struct file *file = file_lookup(name);
|
||||||
struct buffer *buf = malloc(sizeof(*buf));
|
struct buffer *buf = xmalloc(sizeof(*buf));
|
||||||
memset(buf, 0, sizeof(*buf));
|
memset(buf, 0, sizeof(*buf));
|
||||||
|
|
||||||
current_buf->state = YY_CURRENT_BUFFER;
|
current_buf->state = YY_CURRENT_BUFFER;
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define LKC_DIRECT_LINK
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
#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 zconfprint(const char *err, ...);
|
||||||
static void zconf_error(const char *err, ...);
|
static void zconf_error(const char *err, ...);
|
||||||
static void zconferror(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];
|
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
||||||
|
|
||||||
static struct menu *current_menu, *current_entry;
|
static struct menu *current_menu, *current_entry;
|
||||||
|
|
||||||
#define YYDEBUG 0
|
|
||||||
#if YYDEBUG
|
|
||||||
#define YYERROR_VERBOSE
|
|
||||||
#endif
|
|
||||||
%}
|
%}
|
||||||
%expect 30
|
%expect 30
|
||||||
|
|
||||||
@ -45,7 +40,7 @@ static struct menu *current_menu, *current_entry;
|
|||||||
struct symbol *symbol;
|
struct symbol *symbol;
|
||||||
struct expr *expr;
|
struct expr *expr;
|
||||||
struct menu *menu;
|
struct menu *menu;
|
||||||
struct kconf_id *id;
|
const struct kconf_id *id;
|
||||||
}
|
}
|
||||||
|
|
||||||
%token <id>T_MAINMENU
|
%token <id>T_MAINMENU
|
||||||
@ -74,6 +69,10 @@ static struct menu *current_menu, *current_entry;
|
|||||||
%token <string> T_WORD
|
%token <string> T_WORD
|
||||||
%token <string> T_WORD_QUOTE
|
%token <string> T_WORD_QUOTE
|
||||||
%token T_UNEQUAL
|
%token T_UNEQUAL
|
||||||
|
%token T_LESS
|
||||||
|
%token T_LESS_EQUAL
|
||||||
|
%token T_GREATER
|
||||||
|
%token T_GREATER_EQUAL
|
||||||
%token T_CLOSE_PAREN
|
%token T_CLOSE_PAREN
|
||||||
%token T_OPEN_PAREN
|
%token T_OPEN_PAREN
|
||||||
%token T_EOL
|
%token T_EOL
|
||||||
@ -81,6 +80,7 @@ static struct menu *current_menu, *current_entry;
|
|||||||
%left T_OR
|
%left T_OR
|
||||||
%left T_AND
|
%left T_AND
|
||||||
%left T_EQUAL T_UNEQUAL
|
%left T_EQUAL T_UNEQUAL
|
||||||
|
%left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL
|
||||||
%nonassoc T_NOT
|
%nonassoc T_NOT
|
||||||
|
|
||||||
%type <string> prompt
|
%type <string> prompt
|
||||||
@ -229,7 +229,7 @@ symbol_option_list:
|
|||||||
/* empty */
|
/* empty */
|
||||||
| symbol_option_list T_WORD symbol_option_arg
|
| 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)
|
if (id && id->flags & TF_OPTION)
|
||||||
menu_add_option(id->token, $3);
|
menu_add_option(id->token, $3);
|
||||||
else
|
else
|
||||||
@ -472,6 +472,10 @@ if_expr: /* empty */ { $$ = NULL; }
|
|||||||
;
|
;
|
||||||
|
|
||||||
expr: symbol { $$ = expr_alloc_symbol($1); }
|
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_EQUAL symbol { $$ = expr_alloc_comp(E_EQUAL, $1, $3); }
|
||||||
| symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
|
| symbol T_UNEQUAL symbol { $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); }
|
||||||
| T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
|
| T_OPEN_PAREN expr T_CLOSE_PAREN { $$ = $2; }
|
||||||
@ -498,10 +502,7 @@ void conf_parse(const char *name)
|
|||||||
|
|
||||||
sym_init();
|
sym_init();
|
||||||
_menu_init();
|
_menu_init();
|
||||||
modules_sym = sym_lookup(NULL, 0);
|
rootmenu.prompt = menu_add_prompt(P_MENU, "Crosstool-NG Configuration", NULL);
|
||||||
modules_sym->type = S_BOOLEAN;
|
|
||||||
modules_sym->flags |= SYMBOL_AUTO;
|
|
||||||
rootmenu.prompt = menu_add_prompt(P_MENU, PACKAGE " Configuration", NULL);
|
|
||||||
|
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (getenv("ZCONF_DEBUG"))
|
if (getenv("ZCONF_DEBUG"))
|
||||||
@ -510,12 +511,8 @@ void conf_parse(const char *name)
|
|||||||
zconfparse();
|
zconfparse();
|
||||||
if (zconfnerrs)
|
if (zconfnerrs)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (!modules_sym->prop) {
|
if (!modules_sym)
|
||||||
struct property *prop;
|
modules_sym = sym_find( "n" );
|
||||||
|
|
||||||
prop = prop_alloc(P_DEFAULT, modules_sym);
|
|
||||||
prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
rootmenu.prompt->text = _(rootmenu.prompt->text);
|
rootmenu.prompt->text = _(rootmenu.prompt->text);
|
||||||
rootmenu.prompt->text = sym_expand_string_value(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) {
|
for_all_symbols(i, sym) {
|
||||||
if (sym_check_deps(sym))
|
if (sym_check_deps(sym))
|
||||||
zconfnerrs++;
|
zconfnerrs++;
|
||||||
}
|
}
|
||||||
if (zconfnerrs)
|
if (zconfnerrs)
|
||||||
exit(1);
|
exit(1);
|
||||||
sym_set_change_count(1);
|
sym_set_change_count(1);
|
||||||
@ -545,7 +542,7 @@ static const char *zconf_tokenname(int token)
|
|||||||
return "<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) {
|
if (id->token != endtoken) {
|
||||||
zconf_error("unexpected '%s' within %s block",
|
zconf_error("unexpected '%s' within %s block",
|
||||||
@ -590,9 +587,7 @@ static void zconf_error(const char *err, ...)
|
|||||||
|
|
||||||
static void zconferror(const char *err)
|
static void zconferror(const char *err)
|
||||||
{
|
{
|
||||||
#if YYDEBUG
|
|
||||||
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
|
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_quoted_string(FILE *out, const char *str)
|
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 "util.c"
|
||||||
#include "confdata.c"
|
#include "confdata.c"
|
||||||
#include "expr.c"
|
#include "expr.c"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user