scripts/config: sync with latest linux upstream
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
		| @@ -5,6 +5,7 @@ | ||||
|  | ||||
| #include <locale.h> | ||||
| #include <ctype.h> | ||||
| #include <limits.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| @@ -41,7 +42,7 @@ static int tty_stdio; | ||||
| static int valid_stdin = 1; | ||||
| static int sync_kconfig; | ||||
| static int conf_cnt; | ||||
| static char line[128]; | ||||
| static char line[PATH_MAX]; | ||||
| static struct menu *rootEntry; | ||||
|  | ||||
| static void print_help(struct menu *menu) | ||||
| @@ -109,7 +110,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) | ||||
| 		/* fall through */ | ||||
| 	case oldaskconfig: | ||||
| 		fflush(stdout); | ||||
| 		xfgets(line, 128, stdin); | ||||
| 		xfgets(line, sizeof(line), stdin); | ||||
| 		if (!tty_stdio) | ||||
| 			printf("\n"); | ||||
| 		return 1; | ||||
| @@ -311,7 +312,7 @@ static int conf_choice(struct menu *menu) | ||||
| 			/* fall through */ | ||||
| 		case oldaskconfig: | ||||
| 			fflush(stdout); | ||||
| 			xfgets(line, 128, stdin); | ||||
| 			xfgets(line, sizeof(line), stdin); | ||||
| 			strip(line); | ||||
| 			if (line[0] == '?') { | ||||
| 				print_help(menu); | ||||
| @@ -471,7 +472,7 @@ static struct option long_opts[] = { | ||||
| static void conf_usage(const char *progname) | ||||
| { | ||||
|  | ||||
| 	printf("Usage: %s [option] <kconfig-file>\n", progname); | ||||
| 	printf("Usage: %s [-s] [option] <kconfig-file>\n", progname); | ||||
| 	printf("[option] is _one_ of the following:\n"); | ||||
| 	printf("  --listnewconfig         List new options\n"); | ||||
| 	printf("  --oldaskconfig          Start a new configuration using a line-oriented program\n"); | ||||
| @@ -502,7 +503,11 @@ int main(int ac, char **av) | ||||
|  | ||||
| 	tty_stdio = isatty(0) && isatty(1) && isatty(2); | ||||
|  | ||||
| 	while ((opt = getopt_long(ac, av, "r:w:", long_opts, NULL)) != -1) { | ||||
| 	while ((opt = getopt_long(ac, av, "r:w:s", long_opts, NULL)) != -1) { | ||||
| 		if (opt == 's') { | ||||
| 			conf_set_message_callback(NULL); | ||||
| 			continue; | ||||
| 		} | ||||
| 		switch (opt) { | ||||
| 		case silentoldconfig: | ||||
| 			sync_kconfig = 1; | ||||
|   | ||||
| @@ -16,6 +16,11 @@ | ||||
|  | ||||
| #include "lkc.h" | ||||
|  | ||||
| struct conf_printer { | ||||
| 	void (*print_symbol)(FILE *, struct symbol *, const char *, void *); | ||||
| 	void (*print_comment)(FILE *, const char *, void *); | ||||
| }; | ||||
|  | ||||
| static void conf_warning(const char *fmt, ...) | ||||
| 	__attribute__ ((format (printf, 1, 2))); | ||||
|  | ||||
| @@ -59,6 +64,7 @@ static void conf_message(const char *fmt, ...) | ||||
| 	va_start(ap, fmt); | ||||
| 	if (conf_message_callback) | ||||
| 		conf_message_callback(fmt, ap); | ||||
| 	va_end(ap); | ||||
| } | ||||
|  | ||||
| const char *conf_get_configname(void) | ||||
| @@ -286,11 +292,8 @@ int conf_read_simple(const char *name, int def) | ||||
| 		if (in) | ||||
| 			goto load; | ||||
| 		sym_add_change_count(1); | ||||
| 		if (!sym_defconfig_list) { | ||||
| 			if (modules_sym) | ||||
| 				sym_calc_value(modules_sym); | ||||
| 		if (!sym_defconfig_list) | ||||
| 			return 1; | ||||
| 		} | ||||
|  | ||||
| 		for_all_defaults(sym_defconfig_list, prop) { | ||||
| 			if (expr_calc_value(prop->visible.expr) == no || | ||||
| @@ -375,7 +378,9 @@ load: | ||||
| 				continue; | ||||
| 		} else { | ||||
| 			if (line[0] != '\r' && line[0] != '\n') | ||||
| 				conf_warning("unexpected data"); | ||||
| 				conf_warning("unexpected data: %.*s", | ||||
| 					     (int)strcspn(line, "\r\n"), line); | ||||
|  | ||||
| 			continue; | ||||
| 		} | ||||
| setsym: | ||||
| @@ -401,9 +406,6 @@ setsym: | ||||
| 	} | ||||
| 	free(line); | ||||
| 	fclose(in); | ||||
|  | ||||
| 	if (modules_sym) | ||||
| 		sym_calc_value(modules_sym); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| @@ -414,8 +416,12 @@ int conf_read(const char *name) | ||||
|  | ||||
| 	sym_set_change_count(0); | ||||
|  | ||||
| 	if (conf_read_simple(name, S_DEF_USER)) | ||||
| 	if (conf_read_simple(name, S_DEF_USER)) { | ||||
| 		sym_calc_value(modules_sym); | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
| 	sym_calc_value(modules_sym); | ||||
|  | ||||
| 	for_all_symbols(i, sym) { | ||||
| 		sym_calc_value(sym); | ||||
| @@ -846,6 +852,7 @@ static int conf_split_config(void) | ||||
|  | ||||
| 	name = conf_get_autoconfig_name(); | ||||
| 	conf_read_simple(name, S_DEF_AUTO); | ||||
| 	sym_calc_value(modules_sym); | ||||
|  | ||||
| 	if (chdir("include/config")) | ||||
| 		return 1; | ||||
|   | ||||
| @@ -11,6 +11,9 @@ | ||||
|  | ||||
| #define DEBUG_EXPR	0 | ||||
|  | ||||
| static int expr_eq(struct expr *e1, struct expr *e2); | ||||
| static struct expr *expr_eliminate_yn(struct expr *e); | ||||
|  | ||||
| struct expr *expr_alloc_symbol(struct symbol *sym) | ||||
| { | ||||
| 	struct expr *e = xcalloc(1, sizeof(*e)); | ||||
| @@ -76,6 +79,10 @@ struct expr *expr_copy(const struct expr *org) | ||||
| 		e->left.expr = expr_copy(org->left.expr); | ||||
| 		break; | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		e->left.sym = org->left.sym; | ||||
| 		e->right.sym = org->right.sym; | ||||
| @@ -108,6 +115,10 @@ void expr_free(struct expr *e) | ||||
| 		expr_free(e->left.expr); | ||||
| 		return; | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		break; | ||||
| 	case E_OR: | ||||
| @@ -186,7 +197,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) | ||||
| #undef e1 | ||||
| #undef e2 | ||||
|  | ||||
| int expr_eq(struct expr *e1, struct expr *e2) | ||||
| static int expr_eq(struct expr *e1, struct expr *e2) | ||||
| { | ||||
| 	int res, old_count; | ||||
|  | ||||
| @@ -194,6 +205,10 @@ int expr_eq(struct expr *e1, struct expr *e2) | ||||
| 		return 0; | ||||
| 	switch (e1->type) { | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; | ||||
| 	case E_SYMBOL: | ||||
| @@ -228,7 +243,7 @@ int expr_eq(struct expr *e1, struct expr *e2) | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| struct expr *expr_eliminate_yn(struct expr *e) | ||||
| static struct expr *expr_eliminate_yn(struct expr *e) | ||||
| { | ||||
| 	struct expr *tmp; | ||||
|  | ||||
| @@ -553,62 +568,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct | ||||
| #undef e2 | ||||
| } | ||||
|  | ||||
| static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) | ||||
| { | ||||
| #define e1 (*ep1) | ||||
| #define e2 (*ep2) | ||||
| 	struct expr *tmp, *tmp1, *tmp2; | ||||
|  | ||||
| 	if (e1->type == type) { | ||||
| 		expr_eliminate_dups2(type, &e1->left.expr, &e2); | ||||
| 		expr_eliminate_dups2(type, &e1->right.expr, &e2); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (e2->type == type) { | ||||
| 		expr_eliminate_dups2(type, &e1, &e2->left.expr); | ||||
| 		expr_eliminate_dups2(type, &e1, &e2->right.expr); | ||||
| 	} | ||||
| 	if (e1 == e2) | ||||
| 		return; | ||||
|  | ||||
| 	switch (e1->type) { | ||||
| 	case E_OR: | ||||
| 		expr_eliminate_dups2(e1->type, &e1, &e1); | ||||
| 		// (FOO || BAR) && (!FOO && !BAR) -> n | ||||
| 		tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); | ||||
| 		tmp2 = expr_copy(e2); | ||||
| 		tmp = expr_extract_eq_and(&tmp1, &tmp2); | ||||
| 		if (expr_is_yes(tmp1)) { | ||||
| 			expr_free(e1); | ||||
| 			e1 = expr_alloc_symbol(&symbol_no); | ||||
| 			trans_count++; | ||||
| 		} | ||||
| 		expr_free(tmp2); | ||||
| 		expr_free(tmp1); | ||||
| 		expr_free(tmp); | ||||
| 		break; | ||||
| 	case E_AND: | ||||
| 		expr_eliminate_dups2(e1->type, &e1, &e1); | ||||
| 		// (FOO && BAR) || (!FOO || !BAR) -> y | ||||
| 		tmp1 = expr_transform(expr_alloc_one(E_NOT, expr_copy(e1))); | ||||
| 		tmp2 = expr_copy(e2); | ||||
| 		tmp = expr_extract_eq_or(&tmp1, &tmp2); | ||||
| 		if (expr_is_no(tmp1)) { | ||||
| 			expr_free(e1); | ||||
| 			e1 = expr_alloc_symbol(&symbol_yes); | ||||
| 			trans_count++; | ||||
| 		} | ||||
| 		expr_free(tmp2); | ||||
| 		expr_free(tmp1); | ||||
| 		expr_free(tmp); | ||||
| 		break; | ||||
| 	default: | ||||
| 		; | ||||
| 	} | ||||
| #undef e1 | ||||
| #undef e2 | ||||
| } | ||||
|  | ||||
| struct expr *expr_eliminate_dups(struct expr *e) | ||||
| { | ||||
| 	int oldcount; | ||||
| @@ -621,7 +580,6 @@ struct expr *expr_eliminate_dups(struct expr *e) | ||||
| 		switch (e->type) { | ||||
| 		case E_OR: case E_AND: | ||||
| 			expr_eliminate_dups1(e->type, &e, &e); | ||||
| 			expr_eliminate_dups2(e->type, &e, &e); | ||||
| 		default: | ||||
| 			; | ||||
| 		} | ||||
| @@ -641,6 +599,10 @@ struct expr *expr_transform(struct expr *e) | ||||
| 		return NULL; | ||||
| 	switch (e->type) { | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 	case E_SYMBOL: | ||||
| 	case E_LIST: | ||||
| @@ -713,6 +675,22 @@ struct expr *expr_transform(struct expr *e) | ||||
| 			e = tmp; | ||||
| 			e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; | ||||
| 			break; | ||||
| 		case E_LEQ: | ||||
| 		case E_GEQ: | ||||
| 			// !a<='x' -> a>'x' | ||||
| 			tmp = e->left.expr; | ||||
| 			free(e); | ||||
| 			e = tmp; | ||||
| 			e->type = e->type == E_LEQ ? E_GTH : E_LTH; | ||||
| 			break; | ||||
| 		case E_LTH: | ||||
| 		case E_GTH: | ||||
| 			// !a<'x' -> a>='x' | ||||
| 			tmp = e->left.expr; | ||||
| 			free(e); | ||||
| 			e = tmp; | ||||
| 			e->type = e->type == E_LTH ? E_GEQ : E_LEQ; | ||||
| 			break; | ||||
| 		case E_OR: | ||||
| 			// !(a || b) -> !a && !b | ||||
| 			tmp = e->left.expr; | ||||
| @@ -783,6 +761,10 @@ int expr_contains_symbol(struct expr *dep, struct symbol *sym) | ||||
| 	case E_SYMBOL: | ||||
| 		return dep->left.sym == sym; | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		return dep->left.sym == sym || | ||||
| 		       dep->right.sym == sym; | ||||
| @@ -823,57 +805,6 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym) | ||||
|  	return false; | ||||
| } | ||||
|  | ||||
| struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) | ||||
| { | ||||
| 	struct expr *tmp = NULL; | ||||
| 	expr_extract_eq(E_AND, &tmp, ep1, ep2); | ||||
| 	if (tmp) { | ||||
| 		*ep1 = expr_eliminate_yn(*ep1); | ||||
| 		*ep2 = expr_eliminate_yn(*ep2); | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
|  | ||||
| struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) | ||||
| { | ||||
| 	struct expr *tmp = NULL; | ||||
| 	expr_extract_eq(E_OR, &tmp, ep1, ep2); | ||||
| 	if (tmp) { | ||||
| 		*ep1 = expr_eliminate_yn(*ep1); | ||||
| 		*ep2 = expr_eliminate_yn(*ep2); | ||||
| 	} | ||||
| 	return tmp; | ||||
| } | ||||
|  | ||||
| void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) | ||||
| { | ||||
| #define e1 (*ep1) | ||||
| #define e2 (*ep2) | ||||
| 	if (e1->type == type) { | ||||
| 		expr_extract_eq(type, ep, &e1->left.expr, &e2); | ||||
| 		expr_extract_eq(type, ep, &e1->right.expr, &e2); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (e2->type == type) { | ||||
| 		expr_extract_eq(type, ep, ep1, &e2->left.expr); | ||||
| 		expr_extract_eq(type, ep, ep1, &e2->right.expr); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (expr_eq(e1, e2)) { | ||||
| 		*ep = *ep ? expr_alloc_two(type, *ep, e1) : e1; | ||||
| 		expr_free(e2); | ||||
| 		if (type == E_AND) { | ||||
| 			e1 = expr_alloc_symbol(&symbol_yes); | ||||
| 			e2 = expr_alloc_symbol(&symbol_yes); | ||||
| 		} else if (type == E_OR) { | ||||
| 			e1 = expr_alloc_symbol(&symbol_no); | ||||
| 			e2 = expr_alloc_symbol(&symbol_no); | ||||
| 		} | ||||
| 	} | ||||
| #undef e1 | ||||
| #undef e2 | ||||
| } | ||||
|  | ||||
| struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) | ||||
| { | ||||
| 	struct expr *e1, *e2; | ||||
| @@ -908,6 +839,10 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb | ||||
| 	case E_NOT: | ||||
| 		return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); | ||||
| 	case E_UNEQUAL: | ||||
| 	case E_LTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_GEQ: | ||||
| 	case E_EQUAL: | ||||
| 		if (type == E_EQUAL) { | ||||
| 			if (sym == &symbol_yes) | ||||
| @@ -935,10 +870,57 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
| enum string_value_kind { | ||||
| 	k_string, | ||||
| 	k_signed, | ||||
| 	k_unsigned, | ||||
| 	k_invalid | ||||
| }; | ||||
|  | ||||
| union string_value { | ||||
| 	unsigned long long u; | ||||
| 	signed long long s; | ||||
| }; | ||||
|  | ||||
| static enum string_value_kind expr_parse_string(const char *str, | ||||
| 						enum symbol_type type, | ||||
| 						union string_value *val) | ||||
| { | ||||
| 	char *tail; | ||||
| 	enum string_value_kind kind; | ||||
|  | ||||
| 	errno = 0; | ||||
| 	switch (type) { | ||||
| 	case S_BOOLEAN: | ||||
| 	case S_TRISTATE: | ||||
| 		return k_string; | ||||
| 	case S_INT: | ||||
| 		val->s = strtoll(str, &tail, 10); | ||||
| 		kind = k_signed; | ||||
| 		break; | ||||
| 	case S_HEX: | ||||
| 		val->u = strtoull(str, &tail, 16); | ||||
| 		kind = k_unsigned; | ||||
| 		break; | ||||
| 	case S_STRING: | ||||
| 	case S_UNKNOWN: | ||||
| 		val->s = strtoll(str, &tail, 0); | ||||
| 		kind = k_signed; | ||||
| 		break; | ||||
| 	default: | ||||
| 		return k_invalid; | ||||
| 	} | ||||
| 	return !errno && !*tail && tail > str && isxdigit(tail[-1]) | ||||
| 	       ? kind : k_string; | ||||
| } | ||||
|  | ||||
| tristate expr_calc_value(struct expr *e) | ||||
| { | ||||
| 	tristate val1, val2; | ||||
| 	const char *str1, *str2; | ||||
| 	enum string_value_kind k1 = k_string, k2 = k_string; | ||||
| 	union string_value lval = {}, rval = {}; | ||||
| 	int res; | ||||
|  | ||||
| 	if (!e) | ||||
| 		return yes; | ||||
| @@ -959,31 +941,70 @@ tristate expr_calc_value(struct expr *e) | ||||
| 		val1 = expr_calc_value(e->left.expr); | ||||
| 		return EXPR_NOT(val1); | ||||
| 	case E_EQUAL: | ||||
| 		sym_calc_value(e->left.sym); | ||||
| 		sym_calc_value(e->right.sym); | ||||
| 		str1 = sym_get_string_value(e->left.sym); | ||||
| 		str2 = sym_get_string_value(e->right.sym); | ||||
| 		return !strcmp(str1, str2) ? yes : no; | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		sym_calc_value(e->left.sym); | ||||
| 		sym_calc_value(e->right.sym); | ||||
| 		str1 = sym_get_string_value(e->left.sym); | ||||
| 		str2 = sym_get_string_value(e->right.sym); | ||||
| 		return !strcmp(str1, str2) ? no : yes; | ||||
| 		break; | ||||
| 	default: | ||||
| 		printf("expr_calc_value: %d?\n", e->type); | ||||
| 		return no; | ||||
| 	} | ||||
|  | ||||
| 	sym_calc_value(e->left.sym); | ||||
| 	sym_calc_value(e->right.sym); | ||||
| 	str1 = sym_get_string_value(e->left.sym); | ||||
| 	str2 = sym_get_string_value(e->right.sym); | ||||
|  | ||||
| 	if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) { | ||||
| 		k1 = expr_parse_string(str1, e->left.sym->type, &lval); | ||||
| 		k2 = expr_parse_string(str2, e->right.sym->type, &rval); | ||||
| 	} | ||||
|  | ||||
| 	if (k1 == k_string || k2 == k_string) | ||||
| 		res = strcmp(str1, str2); | ||||
| 	else if (k1 == k_invalid || k2 == k_invalid) { | ||||
| 		if (e->type != E_EQUAL && e->type != E_UNEQUAL) { | ||||
| 			printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2); | ||||
| 			return no; | ||||
| 		} | ||||
| 		res = strcmp(str1, str2); | ||||
| 	} else if (k1 == k_unsigned || k2 == k_unsigned) | ||||
| 		res = (lval.u > rval.u) - (lval.u < rval.u); | ||||
| 	else /* if (k1 == k_signed && k2 == k_signed) */ | ||||
| 		res = (lval.s > rval.s) - (lval.s < rval.s); | ||||
|  | ||||
| 	switch(e->type) { | ||||
| 	case E_EQUAL: | ||||
| 		return res ? no : yes; | ||||
| 	case E_GEQ: | ||||
| 		return res >= 0 ? yes : no; | ||||
| 	case E_GTH: | ||||
| 		return res > 0 ? yes : no; | ||||
| 	case E_LEQ: | ||||
| 		return res <= 0 ? yes : no; | ||||
| 	case E_LTH: | ||||
| 		return res < 0 ? yes : no; | ||||
| 	case E_UNEQUAL: | ||||
| 		return res ? yes : no; | ||||
| 	default: | ||||
| 		printf("expr_calc_value: relation %d?\n", e->type); | ||||
| 		return no; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| int expr_compare_type(enum expr_type t1, enum expr_type t2) | ||||
| static int expr_compare_type(enum expr_type t1, enum expr_type t2) | ||||
| { | ||||
| #if 0 | ||||
| 	return 1; | ||||
| #else | ||||
| 	if (t1 == t2) | ||||
| 		return 0; | ||||
| 	switch (t1) { | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 		if (t2 == E_EQUAL || t2 == E_UNEQUAL) | ||||
| 			return 1; | ||||
| 	case E_EQUAL: | ||||
| 	case E_UNEQUAL: | ||||
| 		if (t2 == E_NOT) | ||||
| @@ -1005,7 +1026,6 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2) | ||||
| 	} | ||||
| 	printf("[%dgt%d?]", t1, t2); | ||||
| 	return 0; | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static inline struct expr * | ||||
| @@ -1078,6 +1098,24 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * | ||||
| 		fn(data, NULL, "="); | ||||
| 		fn(data, e->right.sym, e->right.sym->name); | ||||
| 		break; | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 		if (e->left.sym->name) | ||||
| 			fn(data, e->left.sym, e->left.sym->name); | ||||
| 		else | ||||
| 			fn(data, NULL, "<choice>"); | ||||
| 		fn(data, NULL, e->type == E_LEQ ? "<=" : "<"); | ||||
| 		fn(data, e->right.sym, e->right.sym->name); | ||||
| 		break; | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 		if (e->left.sym->name) | ||||
| 			fn(data, e->left.sym, e->left.sym->name); | ||||
| 		else | ||||
| 			fn(data, NULL, "<choice>"); | ||||
| 		fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); | ||||
| 		fn(data, e->right.sym, e->right.sym->name); | ||||
| 		break; | ||||
| 	case E_UNEQUAL: | ||||
| 		if (e->left.sym->name) | ||||
| 			fn(data, e->left.sym, e->left.sym->name); | ||||
|   | ||||
| @@ -29,7 +29,9 @@ typedef enum tristate { | ||||
| } tristate; | ||||
|  | ||||
| enum expr_type { | ||||
| 	E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE | ||||
| 	E_NONE, E_OR, E_AND, E_NOT, | ||||
| 	E_EQUAL, E_UNEQUAL, E_LTH, E_LEQ, E_GTH, E_GEQ, | ||||
| 	E_LIST, E_SYMBOL, E_RANGE | ||||
| }; | ||||
|  | ||||
| union expr_data { | ||||
| @@ -206,18 +208,13 @@ struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); | ||||
| struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); | ||||
| struct expr *expr_copy(const struct expr *org); | ||||
| void expr_free(struct expr *e); | ||||
| int expr_eq(struct expr *e1, struct expr *e2); | ||||
| void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); | ||||
| tristate expr_calc_value(struct expr *e); | ||||
| struct expr *expr_eliminate_yn(struct expr *e); | ||||
| struct expr *expr_trans_bool(struct expr *e); | ||||
| struct expr *expr_eliminate_dups(struct expr *e); | ||||
| struct expr *expr_transform(struct expr *e); | ||||
| int expr_contains_symbol(struct expr *dep, struct symbol *sym); | ||||
| bool expr_depends_symbol(struct expr *dep, struct symbol *sym); | ||||
| struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); | ||||
| struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); | ||||
| void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); | ||||
| struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | ||||
| struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); | ||||
|  | ||||
|   | ||||
| @@ -21,9 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
| #define P(name,type,arg)	extern type name arg | ||||
| #include "lkc_proto.h" | ||||
| #undef P | ||||
|  | ||||
| #define SRCTREE "srctree" | ||||
|  | ||||
| @@ -70,9 +68,6 @@ struct kconf_id { | ||||
| 	enum symbol_type stype; | ||||
| }; | ||||
|  | ||||
| extern int zconfdebug; | ||||
|  | ||||
| int zconfparse(void); | ||||
| void zconfdump(FILE *out); | ||||
| void zconf_starthelp(void); | ||||
| FILE *zconf_fopen(const char *name); | ||||
| @@ -90,11 +85,6 @@ void sym_add_change_count(int count); | ||||
| bool conf_set_all_new_symbols(enum conf_def_mode mode); | ||||
| void set_all_choice_values(struct symbol *csym); | ||||
|  | ||||
| struct conf_printer { | ||||
| 	void (*print_symbol)(FILE *, struct symbol *, const char *, void *); | ||||
| 	void (*print_comment)(FILE *, const char *, void *); | ||||
| }; | ||||
|  | ||||
| /* confdata.c and expr.c */ | ||||
| static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | ||||
| { | ||||
| @@ -137,7 +127,6 @@ struct gstr { | ||||
| 	int max_width; | ||||
| }; | ||||
| struct gstr str_new(void); | ||||
| struct gstr str_assign(const char *s); | ||||
| void str_free(struct gstr *gs); | ||||
| void str_append(struct gstr *gs, const char *s); | ||||
| void str_printf(struct gstr *gs, const char *fmt, ...); | ||||
| @@ -148,8 +137,6 @@ extern struct expr *sym_env_list; | ||||
|  | ||||
| void sym_init(void); | ||||
| void sym_clear_all_valid(void); | ||||
| void sym_set_all_changed(void); | ||||
| void sym_set_changed(struct symbol *sym); | ||||
| struct symbol *sym_choice_default(struct symbol *sym); | ||||
| const char *sym_get_string_default(struct symbol *sym); | ||||
| struct symbol *sym_check_deps(struct symbol *sym); | ||||
|   | ||||
| @@ -1,58 +1,53 @@ | ||||
| #include <stdarg.h> | ||||
|  | ||||
| /* confdata.c */ | ||||
| P(conf_parse,void,(const char *name)); | ||||
| P(conf_read,int,(const char *name)); | ||||
| P(conf_read_simple,int,(const char *name, int)); | ||||
| P(conf_reset,void,(int)); | ||||
| P(conf_write_defconfig,int,(const char *name)); | ||||
| P(conf_write,int,(const char *name)); | ||||
| P(conf_write_autoconf,int,(void)); | ||||
| P(conf_get_changed,bool,(void)); | ||||
| P(conf_set_changed_callback, void,(void (*fn)(void))); | ||||
| P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); | ||||
| void conf_parse(const char *name); | ||||
| int conf_read(const char *name); | ||||
| int conf_read_simple(const char *name, int); | ||||
| void conf_reset(int def); | ||||
| int conf_write_defconfig(const char *name); | ||||
| int conf_write(const char *name); | ||||
| int conf_write_autoconf(void); | ||||
| bool conf_get_changed(void); | ||||
| void conf_set_changed_callback(void (*fn)(void)); | ||||
| void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); | ||||
|  | ||||
| /* menu.c */ | ||||
| P(rootmenu,struct menu,); | ||||
| extern struct menu rootmenu; | ||||
|  | ||||
| P(menu_is_empty, bool, (struct menu *menu)); | ||||
| P(menu_is_visible, bool, (struct menu *menu)); | ||||
| P(menu_has_prompt, bool, (struct menu *menu)); | ||||
| P(menu_get_prompt,const char *,(struct menu *menu)); | ||||
| P(menu_get_root_menu,struct menu *,(struct menu *menu)); | ||||
| P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | ||||
| P(menu_has_help,bool,(struct menu *menu)); | ||||
| P(menu_get_help,const char *,(struct menu *menu)); | ||||
| P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head | ||||
| 			 *head)); | ||||
| P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head | ||||
| 				   *head)); | ||||
| P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | ||||
| bool menu_is_empty(struct menu *menu); | ||||
| bool menu_is_visible(struct menu *menu); | ||||
| bool menu_has_prompt(struct menu *menu); | ||||
| const char * menu_get_prompt(struct menu *menu); | ||||
| struct menu * menu_get_root_menu(struct menu *menu); | ||||
| struct menu * menu_get_parent_menu(struct menu *menu); | ||||
| bool menu_has_help(struct menu *menu); | ||||
| const char * menu_get_help(struct menu *menu); | ||||
| struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); | ||||
| void menu_get_ext_help(struct menu *menu, struct gstr *help); | ||||
|  | ||||
| /* symbol.c */ | ||||
| P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); | ||||
| extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; | ||||
|  | ||||
| P(sym_lookup,struct symbol *,(const char *name, int flags)); | ||||
| P(sym_find,struct symbol *,(const char *name)); | ||||
| P(sym_expand_string_value,const char *,(const char *in)); | ||||
| P(sym_escape_string_value, const char *,(const char *in)); | ||||
| P(sym_re_search,struct symbol **,(const char *pattern)); | ||||
| P(sym_type_name,const char *,(enum symbol_type type)); | ||||
| P(sym_calc_value,void,(struct symbol *sym)); | ||||
| P(sym_get_type,enum symbol_type,(struct symbol *sym)); | ||||
| P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); | ||||
| P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); | ||||
| P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); | ||||
| P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); | ||||
| P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); | ||||
| P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); | ||||
| P(sym_is_changable,bool,(struct symbol *sym)); | ||||
| P(sym_get_choice_prop,struct property *,(struct symbol *sym)); | ||||
| P(sym_get_default_prop,struct property *,(struct symbol *sym)); | ||||
| P(sym_get_string_value,const char *,(struct symbol *sym)); | ||||
| struct symbol * sym_lookup(const char *name, int flags); | ||||
| struct symbol * sym_find(const char *name); | ||||
| const char * sym_expand_string_value(const char *in); | ||||
| const char * sym_escape_string_value(const char *in); | ||||
| struct symbol ** sym_re_search(const char *pattern); | ||||
| const char * sym_type_name(enum symbol_type type); | ||||
| void sym_calc_value(struct symbol *sym); | ||||
| enum symbol_type sym_get_type(struct symbol *sym); | ||||
| bool sym_tristate_within_range(struct symbol *sym,tristate tri); | ||||
| bool sym_set_tristate_value(struct symbol *sym,tristate tri); | ||||
| tristate sym_toggle_tristate_value(struct symbol *sym); | ||||
| bool sym_string_valid(struct symbol *sym, const char *newval); | ||||
| bool sym_string_within_range(struct symbol *sym, const char *str); | ||||
| bool sym_set_string_value(struct symbol *sym, const char *newval); | ||||
| bool sym_is_changable(struct symbol *sym); | ||||
| struct property * sym_get_choice_prop(struct symbol *sym); | ||||
| const char * sym_get_string_value(struct symbol *sym); | ||||
|  | ||||
| P(prop_get_type_name,const char *,(enum prop_type type)); | ||||
| const char * prop_get_type_name(enum prop_type type); | ||||
|  | ||||
| /* expr.c */ | ||||
| P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); | ||||
| P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); | ||||
| void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); | ||||
|   | ||||
| @@ -275,6 +275,7 @@ static int child_count; | ||||
| static int single_menu_mode; | ||||
| static int show_all_options; | ||||
| static int save_and_exit; | ||||
| static int silent; | ||||
|  | ||||
| static void conf(struct menu *menu, struct menu *active_menu); | ||||
| static void conf_choice(struct menu *menu); | ||||
| @@ -773,10 +774,12 @@ 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 (save_and_exit) { | ||||
| 		if (!silent) | ||||
| 			printf("%s", buf); | ||||
| 	else | ||||
| 	} else { | ||||
| 		show_textbox(NULL, buf, 6, 60); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void show_help(struct menu *menu) | ||||
| @@ -983,6 +986,7 @@ static int handle_exit(void) | ||||
| 		} | ||||
| 		/* fall through */ | ||||
| 	case -1: | ||||
| 		if (!silent) | ||||
| 			printf(_("\n\n" | ||||
| 				 "*** End of the configuration.\n" | ||||
| 				 "*** Execute 'make' to start the build or try 'make help'." | ||||
| @@ -990,6 +994,7 @@ static int handle_exit(void) | ||||
| 		res = 0; | ||||
| 		break; | ||||
| 	default: | ||||
| 		if (!silent) | ||||
| 			fprintf(stderr, _("\n\n" | ||||
| 					  "Your configuration changes were NOT saved." | ||||
| 					  "\n\n")); | ||||
| @@ -1016,6 +1021,12 @@ int main(int ac, char **av) | ||||
|  | ||||
| 	signal(SIGINT, sig_handler); | ||||
|  | ||||
| 	if (ac > 1 && strcmp(av[1], "-s") == 0) { | ||||
| 		silent = 1; | ||||
| 		/* Silence conf_read() until the real callback is set up */ | ||||
| 		conf_set_message_callback(NULL); | ||||
| 		av++; | ||||
| 	} | ||||
| 	conf_parse(av[1]); | ||||
| 	conf_read(NULL); | ||||
|  | ||||
|   | ||||
| @@ -477,7 +477,7 @@ bool menu_is_visible(struct menu *menu) | ||||
|  | ||||
| 	if (menu->visibility) { | ||||
| 		if (expr_calc_value(menu->visibility) == no) | ||||
| 			return no; | ||||
| 			return false; | ||||
| 	} | ||||
|  | ||||
| 	sym = menu->sym; | ||||
| @@ -615,7 +615,7 @@ static struct property *get_symbol_prop(struct symbol *sym) | ||||
| /* | ||||
|  * head is optional and may be NULL | ||||
|  */ | ||||
| void get_symbol_str(struct gstr *r, struct symbol *sym, | ||||
| static void get_symbol_str(struct gstr *r, struct symbol *sym, | ||||
| 		    struct list_head *head) | ||||
| { | ||||
| 	bool hit; | ||||
|   | ||||
| @@ -112,7 +112,7 @@ struct property *sym_get_env_prop(struct symbol *sym) | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
| struct property *sym_get_default_prop(struct symbol *sym) | ||||
| static struct property *sym_get_default_prop(struct symbol *sym) | ||||
| { | ||||
| 	struct property *prop; | ||||
|  | ||||
| @@ -186,15 +186,49 @@ static void sym_validate_range(struct symbol *sym) | ||||
| 	sym->curr.val = strdup(str); | ||||
| } | ||||
|  | ||||
| static void sym_set_changed(struct symbol *sym) | ||||
| { | ||||
| 	struct property *prop; | ||||
|  | ||||
| 	sym->flags |= SYMBOL_CHANGED; | ||||
| 	for (prop = sym->prop; prop; prop = prop->next) { | ||||
| 		if (prop->menu) | ||||
| 			prop->menu->flags |= MENU_CHANGED; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static void sym_set_all_changed(void) | ||||
| { | ||||
| 	struct symbol *sym; | ||||
| 	int i; | ||||
|  | ||||
| 	for_all_symbols(i, sym) | ||||
| 		sym_set_changed(sym); | ||||
| } | ||||
|  | ||||
| static void sym_calc_visibility(struct symbol *sym) | ||||
| { | ||||
| 	struct property *prop; | ||||
| 	struct symbol *choice_sym = NULL; | ||||
| 	tristate tri; | ||||
|  | ||||
| 	/* any prompt visible? */ | ||||
| 	tri = no; | ||||
|  | ||||
| 	if (sym_is_choice_value(sym)) | ||||
| 		choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); | ||||
|  | ||||
| 	for_all_prompts(sym, prop) { | ||||
| 		prop->visible.tri = expr_calc_value(prop->visible.expr); | ||||
| 		/* | ||||
| 		 * Tristate choice_values with visibility 'mod' are | ||||
| 		 * not visible if the corresponding choice's value is | ||||
| 		 * 'yes'. | ||||
| 		 */ | ||||
| 		if (choice_sym && sym->type == S_TRISTATE && | ||||
| 		    prop->visible.tri == mod && choice_sym->curr.tri == yes) | ||||
| 			prop->visible.tri = no; | ||||
|  | ||||
| 		tri = EXPR_OR(tri, prop->visible.tri); | ||||
| 	} | ||||
| 	if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) | ||||
| @@ -447,30 +481,9 @@ void sym_clear_all_valid(void) | ||||
| 	for_all_symbols(i, sym) | ||||
| 		sym->flags &= ~SYMBOL_VALID; | ||||
| 	sym_add_change_count(1); | ||||
| 	if (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) | ||||
| { | ||||
| 	int type = sym_get_type(sym); | ||||
| @@ -1117,6 +1130,8 @@ static void sym_check_print_recursive(struct symbol *last_sym) | ||||
| 		if (stack->sym == last_sym) | ||||
| 			fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", | ||||
| 				prop->file->name, prop->lineno); | ||||
| 			fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"); | ||||
| 			fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n"); | ||||
| 		if (stack->expr) { | ||||
| 			fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", | ||||
| 				prop->file->name, prop->lineno, | ||||
| @@ -1166,6 +1181,10 @@ static struct symbol *sym_check_expr_deps(struct expr *e) | ||||
| 	case E_NOT: | ||||
| 		return sym_check_expr_deps(e->left.expr); | ||||
| 	case E_EQUAL: | ||||
| 	case E_GEQ: | ||||
| 	case E_GTH: | ||||
| 	case E_LEQ: | ||||
| 	case E_LTH: | ||||
| 	case E_UNEQUAL: | ||||
| 		sym = sym_check_deps(e->left.sym); | ||||
| 		if (sym) | ||||
| @@ -1337,6 +1356,8 @@ const char *prop_get_type_name(enum prop_type type) | ||||
| 		return "range"; | ||||
| 	case P_SYMBOL: | ||||
| 		return "symbol"; | ||||
| 	case P_RESET: | ||||
| 		return "reset"; | ||||
| 	case P_UNKNOWN: | ||||
| 		break; | ||||
| 	} | ||||
|   | ||||
| @@ -88,16 +88,6 @@ struct gstr str_new(void) | ||||
| 	return gs; | ||||
| } | ||||
|  | ||||
| /* Allocate and assign growable string */ | ||||
| struct gstr str_assign(const char *s) | ||||
| { | ||||
| 	struct gstr gs; | ||||
| 	gs.s = strdup(s); | ||||
| 	gs.len = strlen(s) + 1; | ||||
| 	gs.max_width = 0; | ||||
| 	return gs; | ||||
| } | ||||
|  | ||||
| /* Free storage for growable string */ | ||||
| void str_free(struct gstr *gs) | ||||
| { | ||||
|   | ||||
| @@ -21,6 +21,7 @@ comment,	T_COMMENT,	TF_COMMAND | ||||
| config,		T_CONFIG,	TF_COMMAND | ||||
| menuconfig,	T_MENUCONFIG,	TF_COMMAND | ||||
| help,		T_HELP,		TF_COMMAND | ||||
| ---help---,	T_HELP,		TF_COMMAND | ||||
| if,		T_IF,		TF_COMMAND|TF_PARAM | ||||
| endif,		T_ENDIF,	TF_COMMAND | ||||
| depends,	T_DEPENDS,	TF_COMMAND | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| /* ANSI-C code produced by gperf version 3.0.3 */ | ||||
| /* Command-line: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/gperf  */ | ||||
| /* Command-line: gperf  */ | ||||
| /* Computed positions: -k'1,3' */ | ||||
|  | ||||
| #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ | ||||
| @@ -48,7 +48,7 @@ kconf_id_hash (register const char *str, register unsigned int len) | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 10, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
| @@ -71,7 +71,7 @@ kconf_id_hash (register const char *str, register unsigned int len) | ||||
|       49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | ||||
|       49, 49, 49, 49, 49, 49 | ||||
|     }; | ||||
|   register unsigned int hval = len; | ||||
|   register int hval = len; | ||||
|  | ||||
|   switch (hval) | ||||
|     { | ||||
| @@ -111,6 +111,7 @@ struct kconf_id_strings_t | ||||
|     char kconf_id_strings_str27[sizeof("modules")]; | ||||
|     char kconf_id_strings_str28[sizeof("tristate")]; | ||||
|     char kconf_id_strings_str29[sizeof("menu")]; | ||||
|     char kconf_id_strings_str30[sizeof("---help---")]; | ||||
|     char kconf_id_strings_str31[sizeof("source")]; | ||||
|     char kconf_id_strings_str32[sizeof("comment")]; | ||||
|     char kconf_id_strings_str33[sizeof("hex")]; | ||||
| @@ -148,6 +149,7 @@ static struct kconf_id_strings_t kconf_id_strings_contents = | ||||
|     "modules", | ||||
|     "tristate", | ||||
|     "menu", | ||||
|     "---help---", | ||||
|     "source", | ||||
|     "comment", | ||||
|     "hex", | ||||
| @@ -161,12 +163,18 @@ static struct kconf_id_strings_t kconf_id_strings_contents = | ||||
|     "mainmenu" | ||||
|   }; | ||||
| #define kconf_id_strings ((const char *) &kconf_id_strings_contents) | ||||
| #ifdef __GNUC__ | ||||
| __inline | ||||
| #ifdef __GNUC_STDC_INLINE__ | ||||
| __attribute__ ((__gnu_inline__)) | ||||
| #endif | ||||
| #endif | ||||
| struct kconf_id * | ||||
| kconf_id_lookup (register const char *str, register unsigned int len) | ||||
| { | ||||
|   enum | ||||
|     { | ||||
|       TOTAL_KEYWORDS = 34, | ||||
|       TOTAL_KEYWORDS = 35, | ||||
|       MIN_WORD_LENGTH = 2, | ||||
|       MAX_WORD_LENGTH = 14, | ||||
|       MIN_HASH_VALUE = 2, | ||||
| @@ -176,56 +184,56 @@ kconf_id_lookup (register const char *str, register unsigned int len) | ||||
|   static struct kconf_id wordlist[] = | ||||
|     { | ||||
|       {-1}, {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str2),		T_ON,		TF_PARAM}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2,		T_ON,		TF_PARAM}, | ||||
|       {-1}, {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str5),		T_ENDIF,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str6),		T_OPTION,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str7),	T_ENDMENU,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str8),	T_OPTIONAL,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str9),	T_ENDCHOICE,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str10),		T_RANGE,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str11),		T_CHOICE,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str12),	T_DEFAULT,	TF_COMMAND, S_UNKNOWN}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str13),	T_DEFAULT,	TF_COMMAND, S_BOOLEAN}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str14),		T_HELP,		TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5,		T_ENDIF,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6,		T_OPTION,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7,	T_ENDMENU,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8,	T_OPTIONAL,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9,	T_ENDCHOICE,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10,		T_RANGE,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str11,		T_CHOICE,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12,	T_DEFAULT,	TF_COMMAND, S_UNKNOWN}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13,	T_DEFAULT,	TF_COMMAND, S_BOOLEAN}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14,		T_HELP,		TF_COMMAND}, | ||||
|       {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str16),		T_CONFIG,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str17),	T_DEFAULT,	TF_COMMAND, S_TRISTATE}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str18),		T_OPT_ENV,	TF_OPTION}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str19),	T_OPT_DEFCONFIG_LIST,TF_OPTION}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str20),		T_RESET,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str21),		T_TYPE,		TF_COMMAND, S_STRING}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str22),		T_IF,		TF_COMMAND|TF_PARAM}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str23),		T_TYPE,		TF_COMMAND, S_INT}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16,		T_CONFIG,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17,	T_DEFAULT,	TF_COMMAND, S_TRISTATE}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18,		T_OPT_ENV,	TF_OPTION}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19,	T_OPT_DEFCONFIG_LIST,TF_OPTION}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str20,		T_RESET,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21,		T_TYPE,		TF_COMMAND, S_STRING}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22,		T_IF,		TF_COMMAND|TF_PARAM}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23,		T_TYPE,		TF_COMMAND, S_INT}, | ||||
|       {-1}, {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str26),		T_SELECT,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str27),	T_OPT_MODULES,	TF_OPTION}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str28),	T_TYPE,		TF_COMMAND, S_TRISTATE}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str29),		T_MENU,		TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26,		T_SELECT,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27,	T_OPT_MODULES,	TF_OPTION}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28,	T_TYPE,		TF_COMMAND, S_TRISTATE}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29,		T_MENU,		TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str30,	T_HELP,		TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31,		T_SOURCE,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32,	T_COMMENT,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33,		T_TYPE,		TF_COMMAND, S_HEX}, | ||||
|       {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str31),		T_SOURCE,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str32),	T_COMMENT,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str33),		T_TYPE,		TF_COMMAND, S_HEX}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35,	T_MENUCONFIG,	TF_COMMAND}, | ||||
|       {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str35),	T_MENUCONFIG,	TF_COMMAND}, | ||||
|       {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str37),	T_VISIBLE,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str38),	T_OPT_ALLNOCONFIG_Y,TF_OPTION}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37,	T_VISIBLE,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str38,	T_OPT_ALLNOCONFIG_Y,TF_OPTION}, | ||||
|       {-1}, {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str41),		T_PROMPT,	TF_COMMAND}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str42),	T_DEPENDS,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41,		T_PROMPT,	TF_COMMAND}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42,	T_DEPENDS,	TF_COMMAND}, | ||||
|       {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str44),		T_TYPE,		TF_COMMAND, S_BOOLEAN}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str44,		T_TYPE,		TF_COMMAND, S_BOOLEAN}, | ||||
|       {-1}, {-1}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str47),	T_TYPE,		TF_COMMAND, S_BOOLEAN}, | ||||
|       {offsetof(struct kconf_id_strings_t, kconf_id_strings_str48),	T_MAINMENU,	TF_COMMAND} | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47,	T_TYPE,		TF_COMMAND, S_BOOLEAN}, | ||||
|       {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48,	T_MAINMENU,	TF_COMMAND} | ||||
|     }; | ||||
|  | ||||
|   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | ||||
|     { | ||||
|       unsigned int key = kconf_id_hash (str, len); | ||||
|       register int key = kconf_id_hash (str, len); | ||||
|  | ||||
|       if (key <= MAX_HASH_VALUE) | ||||
|       if (key <= MAX_HASH_VALUE && key >= 0) | ||||
|         { | ||||
|           register int o = wordlist[key].name; | ||||
|           if (o >= 0) | ||||
|   | ||||
| @@ -68,9 +68,16 @@ static void alloc_string(const char *str, int size) | ||||
| 	memcpy(text, str, size); | ||||
| 	text[size] = 0; | ||||
| } | ||||
|  | ||||
| static void warn_ignored_character(char chr) | ||||
| { | ||||
| 	fprintf(stderr, | ||||
| 	        "%s:%d:warning: ignoring unsupported character '%c'\n", | ||||
| 	        zconf_curname(), zconf_lineno(), chr); | ||||
| } | ||||
| %} | ||||
|  | ||||
| n	[A-Za-z0-9_] | ||||
| n	[A-Za-z0-9_-] | ||||
|  | ||||
| %% | ||||
| 	int str = 0; | ||||
| @@ -108,7 +115,7 @@ n	[A-Za-z0-9_] | ||||
| 		zconflval.string = text; | ||||
| 		return T_WORD; | ||||
| 	} | ||||
| 	. | ||||
| 	.	warn_ignored_character(*yytext); | ||||
| 	\n	{ | ||||
| 		BEGIN(INITIAL); | ||||
| 		current_file->lineno++; | ||||
| @@ -124,14 +131,17 @@ n	[A-Za-z0-9_] | ||||
| 	"!"	return T_NOT; | ||||
| 	"="	return T_EQUAL; | ||||
| 	"!="	return T_UNEQUAL; | ||||
| 	"<="	return T_LESS_EQUAL; | ||||
| 	">="	return T_GREATER_EQUAL; | ||||
| 	"<"	return T_LESS; | ||||
| 	">"	return T_GREATER; | ||||
| 	\"|\'	{ | ||||
| 		str = yytext[0]; | ||||
| 		new_string(); | ||||
| 		BEGIN(STRING); | ||||
| 	} | ||||
| 	\n	BEGIN(INITIAL); current_file->lineno++; return T_EOL; | ||||
| 	---	/* ignore */ | ||||
| 	({n}|[-/.])+	{ | ||||
| 	({n}|[/.])+	{ | ||||
| 		const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); | ||||
| 		if (id && id->flags & TF_PARAM) { | ||||
| 			zconflval.id = id; | ||||
| @@ -143,7 +153,8 @@ n	[A-Za-z0-9_] | ||||
| 	} | ||||
| 	#.*	/* comment */ | ||||
| 	\\\n	current_file->lineno++; | ||||
| 	. | ||||
| 	[[:blank:]]+ | ||||
| 	.	warn_ignored_character(*yytext); | ||||
| 	<<EOF>> { | ||||
| 		BEGIN(INITIAL); | ||||
| 	} | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -70,6 +70,10 @@ static struct menu *current_menu, *current_entry; | ||||
| %token <string> T_WORD | ||||
| %token <string> T_WORD_QUOTE | ||||
| %token T_UNEQUAL | ||||
| %token T_LESS | ||||
| %token T_LESS_EQUAL | ||||
| %token T_GREATER | ||||
| %token T_GREATER_EQUAL | ||||
| %token T_CLOSE_PAREN | ||||
| %token T_OPEN_PAREN | ||||
| %token T_EOL | ||||
| @@ -77,6 +81,7 @@ static struct menu *current_menu, *current_entry; | ||||
| %left T_OR | ||||
| %left T_AND | ||||
| %left T_EQUAL T_UNEQUAL | ||||
| %left T_LESS T_LESS_EQUAL T_GREATER T_GREATER_EQUAL | ||||
| %nonassoc T_NOT | ||||
|  | ||||
| %type <string> prompt | ||||
| @@ -477,6 +482,10 @@ if_expr:  /* empty */			{ $$ = NULL; } | ||||
| ; | ||||
|  | ||||
| expr:	  symbol				{ $$ = expr_alloc_symbol($1); } | ||||
| 	| symbol T_LESS symbol			{ $$ = expr_alloc_comp(E_LTH, $1, $3); } | ||||
| 	| symbol T_LESS_EQUAL symbol		{ $$ = expr_alloc_comp(E_LEQ, $1, $3); } | ||||
| 	| symbol T_GREATER symbol		{ $$ = expr_alloc_comp(E_GTH, $1, $3); } | ||||
| 	| symbol T_GREATER_EQUAL symbol		{ $$ = expr_alloc_comp(E_GEQ, $1, $3); } | ||||
| 	| symbol T_EQUAL symbol			{ $$ = expr_alloc_comp(E_EQUAL, $1, $3); } | ||||
| 	| symbol T_UNEQUAL symbol		{ $$ = expr_alloc_comp(E_UNEQUAL, $1, $3); } | ||||
| 	| T_OPEN_PAREN expr T_CLOSE_PAREN	{ $$ = $2; } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Felix Fietkau
					Felix Fietkau